*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="_therm.vcx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS _progressbar AS container 
 	*< CLASSDATA: Baseclass="container" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="Shape5" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="shpThermBar" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lblPercentage" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lblPercentage2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="shape1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="shape2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape4" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: complete
		*m: reset		&& Property Description will appear here.
		*m: update
		*p: ibasis
		*p: ipercentage
		*p: iprogress
	*</DefinedPropArrayMethod>

	*<PropValue>
		Height = 17
		ibasis = 0
		ipercentage = 0
		iprogress = 0
		Name = "_progressbar"
		Width = 333
	*</PropValue>

	ADD OBJECT 'lblPercentage' AS label WITH ;
		BackStyle = 0, ;
		Caption = "0%", ;
		FontName = "MS Sans Serif", ;
		FontSize = 8, ;
		Height = 13, ;
		Left = 159, ;
		Name = "lblPercentage", ;
		Top = 2, ;
		Width = 16
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lblPercentage2' AS label WITH ;
		BackColor = 0,0,255, ;
		BackStyle = 0, ;
		Caption = "Label1", ;
		FontName = "MS Sans Serif", ;
		FontSize = 8, ;
		ForeColor = 255,255,255, ;
		Height = 13, ;
		Left = 159, ;
		Name = "lblPercentage2", ;
		Top = 2, ;
		Width = 0
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'shape1' AS shape WITH ;
		BorderColor = 128,128,128, ;
		Height = 16, ;
		Left = 0, ;
		Name = "shape1", ;
		Top = 0, ;
		Width = 1
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'shape2' AS shape WITH ;
		BorderColor = 128,128,128, ;
		Height = 1, ;
		Left = 0, ;
		Name = "shape2", ;
		Top = 0, ;
		Width = 332
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape3' AS shape WITH ;
		BorderColor = 255,255,255, ;
		Height = 1, ;
		Left = 0, ;
		Name = "Shape3", ;
		Top = 16, ;
		Width = 333
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape4' AS shape WITH ;
		BorderColor = 255,255,255, ;
		Height = 17, ;
		Left = 332, ;
		Name = "Shape4", ;
		Top = 0, ;
		Width = 1
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape5' AS shape WITH ;
		BackStyle = 0, ;
		BorderWidth = 0, ;
		FillColor = 192,192,192, ;
		FillStyle = 0, ;
		Height = 16, ;
		Left = 1, ;
		Name = "Shape5", ;
		Top = 1, ;
		Width = 332
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'shpThermBar' AS shape WITH ;
		BackColor = 128,128,128, ;
		BorderStyle = 0, ;
		FillColor = 128,128,128, ;
		FillStyle = 0, ;
		Height = 17, ;
		Left = 1, ;
		Name = "shpThermBar", ;
		Top = 1, ;
		Width = 0
		*< END OBJECT: BaseClass="shape" />
	
	PROCEDURE complete
		local iSeconds
		this.Update(iif(this.iBasis <> 0, this.iBasis, 100))
		m.iSeconds=seconds() + .5
		do while seconds() < m.iSeconds
			&& wait half a sec
		enddo
		
	ENDPROC

	PROCEDURE Init
		DECLARE INTEGER GetSysColor IN Win32API INTEGER
		this.shpThermBar.FillColor = GetSysColor(13)  &&COLOR HIGHLIGHT
		this.shape5.FillColor = this.parent.backcolor
		
	ENDPROC

	PROCEDURE reset		&& Property Description will appear here.
		Lparameters iBasis
		this.iBasis = iif(type('m.iBasis') = 'N', m.iBasis, 0)
		this.Update(0)
		
	ENDPROC

	PROCEDURE update
		* m.iProgress is the percentage complete, or, if this.iBasis
		* is non-zero, is used to calculate the percentage complete.
		
		Lparameters m.iProgress
		
		LOCAL iPercentage,iAvgCharWidth 
		this.iProgress = max(0, m.iProgress)
		
		if !empty(this.iBasis)
			m.iPercentage = int(this.iProgress/this.iBasis*100)
		else
			m.iPercentage = this.iProgress
		endif
		m.iPercentage = min(100,max(0,m.iPercentage))
		if m.iPercentage <> this.iPercentage
			if len(alltrim(str(m.iPercentage,3)))<>len(alltrim(str(this.iPercentage,3)))
				iAvgCharWidth=fontmetric(6,this.lblPercentage.FontName, ;
					this.lblPercentage.FontSize, ;
					iif(this.lblPercentage.FontBold,'B','')+ ;
					iif(this.lblPercentage.FontItalic,'I',''))
				this.lblPercentage.Width=txtwidth(alltrim(str(m.iPercentage,3)) + '%', ;
					this.lblPercentage.FontName,this.lblPercentage.FontSize, ;
					iif(this.lblPercentage.FontBold,'B','')+ ;
					iif(this.lblPercentage.FontItalic,'I','')) * iAvgCharWidth
					
				this.lblPercentage.Left=int((this.Shape5.Width - ;
					this.lblPercentage.Width) / 2)+this.shpThermBar.Left-1
				this.lblPercentage2.Left=this.lblPercentage.Left
			endif
			this.iPercentage = m.iPercentage
		
			this.shpThermBar.Width = int((this.Shape5.Width)*this.iPercentage/100)
		
			this.lblPercentage.Caption = alltrim(str(m.iPercentage,3)) + '%'
			this.lblPercentage2.Caption = this.lblPercentage.Caption
			if this.shpThermBar.Left + this.shpThermBar.Width -1 >= ;
				this.lblPercentage2.Left
				if this.shpThermBar.Left + this.shpThermBar.Width - 1 >= ;
					this.lblPercentage2.Left + this.lblPercentage.Width - 1
					this.lblPercentage2.Width = this.lblPercentage.Width
				else
					this.lblPercentage2.Width = ;
						this.shpThermBar.Left + this.shpThermBar.Width - ;
						this.lblPercentage2.Left - 1
				endif
			else
				this.lblPercentage2.Width = 0
			endif
		endif
		
	ENDPROC

ENDDEFINE

DEFINE CLASS _thermometer AS form 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="Shape10" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape9" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape8" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape7" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape6" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape4" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape5" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lblTitle" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lblTask" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="shpThermBar" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lblPercentage" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lblPercentage2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape11" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape12" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape13" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape14" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lblEscapeMessage" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: complete		&& Displays 100% complete thermometer.
		*m: update		&& Updates thermometer. Parameter iProgress, cTask. iProgress - percent to display, cTask - message to display.
		*p: ccurrenttask		&& Current task.
		*p: cthermref
		*p: ibasis		&& Basis for calculating percentage.
		*p: ipercentage		&& This is percentage complete to display
		*p: iprogress		&& This is amount complete.
		*p: shpthermbarmaxwidth
	*</DefinedPropArrayMethod>

	*<PropValue>
		AlwaysOnTop = .F.
		AutoCenter = .T.
		BorderStyle = 0
		Caption = ""
		ccurrenttask = ('')
		Closable = .F.
		ControlBox = .F.
		cthermref = ('')
		DoCreate = .T.
		Height = 88
		ibasis = (0)
		ipercentage = (0)
		iprogress = (0)
		MaxButton = .F.
		MinButton = .F.
		Movable = .F.
		Name = "_thermometer"
		ScaleMode = 3
		shpthermbarmaxwidth = 322
		Width = 356
	*</PropValue>

	ADD OBJECT 'lblEscapeMessage' AS label WITH ;
		Alignment = 2, ;
		BackColor = 192,192,192, ;
		BackStyle = 0, ;
		Caption = "", ;
		FontBold = .F., ;
		FontCharSet = 238, ;
		FontName = "Arial", ;
		FontSize = 8, ;
		Height = 14, ;
		Left = 17, ;
		Name = "lblEscapeMessage", ;
		Top = 68, ;
		Width = 322, ;
		WordWrap = .F.
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lblPercentage' AS label WITH ;
		BackStyle = 0, ;
		Caption = "0%", ;
		FontName = "MS Sans Serif", ;
		FontSize = 8, ;
		Height = 13, ;
		Left = 170, ;
		Name = "lblPercentage", ;
		Top = 47, ;
		Width = 16
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lblPercentage2' AS label WITH ;
		BackColor = 0,0,255, ;
		BackStyle = 0, ;
		Caption = "Label1", ;
		FontName = "MS Sans Serif", ;
		FontSize = 8, ;
		ForeColor = 255,255,255, ;
		Height = 13, ;
		Left = 170, ;
		Name = "lblPercentage2", ;
		Top = 47, ;
		Width = 0
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lblTask' AS label WITH ;
		BackColor = 192,192,192, ;
		BackStyle = 0, ;
		Caption = "", ;
		FontCharSet = 238, ;
		FontName = "Arial", ;
		FontSize = 8, ;
		Height = 16, ;
		Left = 18, ;
		Name = "lblTask", ;
		Top = 27, ;
		Width = 319, ;
		WordWrap = .F.
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lblTitle' AS label WITH ;
		BackColor = 192,192,192, ;
		BackStyle = 0, ;
		Caption = "", ;
		FontCharSet = 238, ;
		FontName = "Arial", ;
		FontSize = 8, ;
		Height = 16, ;
		Left = 18, ;
		Name = "lblTitle", ;
		Top = 14, ;
		Width = 319, ;
		WordWrap = .F.
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Shape1' AS shape WITH ;
		BackStyle = 0, ;
		Height = 88, ;
		Left = 0, ;
		Name = "Shape1", ;
		Top = 0, ;
		Width = 356
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape10' AS shape WITH ;
		BorderColor = 128,128,128, ;
		Height = 81, ;
		Left = 3, ;
		Name = "Shape10", ;
		Top = 3, ;
		Width = 1
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape11' AS shape WITH ;
		BorderColor = 128,128,128, ;
		Height = 1, ;
		Left = 16, ;
		Name = "Shape11", ;
		Top = 45, ;
		Width = 322
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape12' AS shape WITH ;
		BorderColor = 255,255,255, ;
		Height = 1, ;
		Left = 16, ;
		Name = "Shape12", ;
		Top = 61, ;
		Width = 323
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape13' AS shape WITH ;
		BorderColor = 128,128,128, ;
		Height = 16, ;
		Left = 16, ;
		Name = "Shape13", ;
		Top = 45, ;
		Width = 1
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape14' AS shape WITH ;
		BorderColor = 255,255,255, ;
		Height = 17, ;
		Left = 338, ;
		Name = "Shape14", ;
		Top = 45, ;
		Width = 1
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape2' AS shape WITH ;
		BorderColor = 255,255,255, ;
		Height = 1, ;
		Left = 1, ;
		Name = "Shape2", ;
		Top = 1, ;
		Width = 353
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape3' AS shape WITH ;
		BorderColor = 255,255,255, ;
		Height = 85, ;
		Left = 1, ;
		Name = "Shape3", ;
		Top = 1, ;
		Width = 1
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape4' AS shape WITH ;
		BorderColor = 128,128,128, ;
		Height = 1, ;
		Left = 1, ;
		Name = "Shape4", ;
		Top = 86, ;
		Width = 354
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape5' AS shape WITH ;
		BorderStyle = 0, ;
		FillColor = 192,192,192, ;
		FillStyle = 0, ;
		Height = 15, ;
		Left = 17, ;
		Name = "Shape5", ;
		Top = 47, ;
		Width = 322
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape6' AS shape WITH ;
		BorderColor = 128,128,128, ;
		Height = 86, ;
		Left = 354, ;
		Name = "Shape6", ;
		Top = 1, ;
		Width = 1
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape7' AS shape WITH ;
		BorderColor = 255,255,255, ;
		Height = 1, ;
		Left = 3, ;
		Name = "Shape7", ;
		Top = 84, ;
		Width = 350
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape8' AS shape WITH ;
		BorderColor = 255,255,255, ;
		Height = 82, ;
		Left = 352, ;
		Name = "Shape8", ;
		Top = 3, ;
		Width = 1
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape9' AS shape WITH ;
		BorderColor = 128,128,128, ;
		Height = 1, ;
		Left = 3, ;
		Name = "Shape9", ;
		Top = 3, ;
		Width = 349
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'shpThermBar' AS shape WITH ;
		BorderStyle = 0, ;
		FillColor = 128,128,128, ;
		FillStyle = 0, ;
		Height = 16, ;
		Left = 17, ;
		Name = "shpThermBar", ;
		Top = 46, ;
		Width = 0
		*< END OBJECT: BaseClass="shape" />
	
	PROCEDURE complete		&& Displays 100% complete thermometer.
		* This is the default complete message
		Lparameters m.cTask
		
		#define THERMCOMPLETE_LOC	"Terminat."
		
		LOCAL iSeconds,cThermRef
		
		if PCOUNT() = 0
			m.cTask = THERMCOMPLETE_LOC
		endif
		
		this.Update(iif(this.iBasis <> 0, this.iBasis, 100), m.cTask)
		m.iSeconds=seconds() + 1
		do while seconds() < m.iSeconds
			*- wait a sec
		enddo
		
		if !empty(this.cThermRef)
			m.cThermRef = this.cThermRef
			&cThermRef = .NULL.
			release this
		endif
		
	ENDPROC

	PROCEDURE Init
		* m.cTitle is displayed on the first line of the window
		* m.iBasis is used to calculate the percentage complete
		* m.iInterval is the frequency used for updating the thermometer
		
		Lparameters cTitle, iBasis, iInterval
		
		this.shape5.fillcolor = this.backcolor  && for Win95 compat
		this.lblTitle.Caption = iif(empty(m.cTitle),'',m.cTitle)
		this.iBasis = iif(empty(m.iBasis),0,m.iBasis)
		
		this.shpThermBar.FillColor = rgb(128,128,128)
		
	ENDPROC

	PROCEDURE update		&& Updates thermometer. Parameter iProgress, cTask. iProgress - percent to display, cTask - message to display.
		* m.iProgress is the percentage complete, or, if Init() was passed
		* an m.iBasis value, is used to calculate the percentage
		* m.cTask is displayed on the second line of the window
		
		Lparameters m.iProgress, m.cTask
		LOCAL iPercentage,iAvgCharWidth 
		
		if parameters()<>0 .and. type('m.iProgress') = 'N'
			this.iProgress = max(0, m.iProgress)
		endif
		if PCOUNT() >= 2 .and. type('m.cTask') = 'C'
			* If we're specifically passed a null string, clear the current task,
			* otherwise leave it alone
			this.cCurrentTask = m.cTask
		endif
		
		if !empty(this.iBasis)
			m.iPercentage = int(this.iProgress/this.iBasis*100)
		else
			m.iPercentage = this.iProgress
		endif
		m.iPercentage = min(100,max(0,m.iPercentage))
		if m.iPercentage <> this.iPercentage
			if len(alltrim(str(m.iPercentage,3)))<>len(alltrim(str(this.iPercentage,3)))
				iAvgCharWidth=fontmetric(6,this.lblPercentage.FontName, ;
					this.lblPercentage.FontSize, ;
					iif(this.lblPercentage.FontBold,'B','')+ ;
					iif(this.lblPercentage.FontItalic,'I',''))
				this.lblPercentage.Width=txtwidth(alltrim(str(m.iPercentage,3)) + '%', ;
					this.lblPercentage.FontName,this.lblPercentage.FontSize, ;
					iif(this.lblPercentage.FontBold,'B','')+ ;
					iif(this.lblPercentage.FontItalic,'I','')) * iAvgCharWidth
				this.lblPercentage.Left=int((this.shpThermBarMaxWidth- ;
					this.lblPercentage.Width) / 2)+this.shpThermBar.Left-1
				this.lblPercentage2.Left=this.lblPercentage.Left
			endif
			this.iPercentage = m.iPercentage
			this.shpThermBar.Width = int((this.shpThermBarMaxWidth)*this.iPercentage/100)
			this.lblPercentage.Caption = alltrim(str(m.iPercentage,3)) + '%'
			this.lblPercentage2.Caption = this.lblPercentage.Caption
			if this.shpThermBar.Left + this.shpThermBar.Width -1 >= ;
				this.lblPercentage2.Left
				if this.shpThermBar.Left + this.shpThermBar.Width - 1 >= ;
					this.lblPercentage2.Left + this.lblPercentage.Width - 1
					this.lblPercentage2.Width = this.lblPercentage.Width
				else
					this.lblPercentage2.Width = ;
						this.shpThermBar.Left + this.shpThermBar.Width - ;
						this.lblPercentage2.Left - 1
				endif
			else
				this.lblPercentage2.Width = 0
			endif
		endif
		
		if ! this.lblTask.Caption == this.cCurrentTask
			this.lblTask.Caption = this.cCurrentTask
		endif
		
	ENDPROC

ENDDEFINE
