*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="buttons.vcx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS button 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="imgBackgroundLeft" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="imgBackgroundMiddle" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="imgBackgroundRight" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmdFocus" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="shpMouseHandler" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="imgIcon" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lblCaption" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: changetheme		&& Occurs when theme change.
		*m: initthemedcontrol
		*m: setimages		&& Internal to the class.
		*p: custombuilder
		*p: imgleftfocused
		*p: imgleftnotfocused
		*p: imgmiddlefocused
		*p: imgmiddlenotfocused
		*p: imgrightfocused
		*p: imgrightnotfocused
		*p: initialised
		*p: lblfocusedcolor
		*p: lblnotfocusedcolor
		*p: type		&& Specify the button type: 0 - Normal or 1 - Hot Tracking.
		*p: version
		*p: _memberdata		&& XML Metadata for customizable properties
	*</DefinedPropArrayMethod>

	HIDDEN imgleftfocused,imgleftnotfocused,imgmiddlefocused,imgmiddlenotfocused,imgrightfocused,imgrightnotfocused,initialised,lblfocusedcolor,lblnotfocusedcolor
	PROTECTED Init,Resize
	*<PropValue>
		BackStyle = 0
		BorderWidth = 0
		custombuilder = Double click here to open Builder
		Height = 32
		imgleftfocused = ("")
		imgleftnotfocused = =""
		imgmiddlefocused = =""
		imgmiddlenotfocused = ("")
		imgrightfocused = =""
		imgrightnotfocused = =""
		initialised = .F.
		lblfocusedcolor = 0
		lblnotfocusedcolor = 0
		Name = "button"
		type = 0
		version = 3.5.0
		Width = 160
		_memberdata = <VFPData>
			<memberdata name="buttoncolor" type="property" display="ButtonColor"/>
			<memberdata name="changetheme" type="method" display="ChangeTheme"/>
			<memberdata name="setimages" type="method" display="SetImages"/>
			<memberdata name="imgleftfocused" type="property" display="ImgLeftFocused"/>
			<memberdata name="imgrightfocused" type="property" display="ImgRightFocused"/>
			<memberdata name="imgmiddlefocused" type="property" display="ImgMiddleFocused"/>
			<memberdata name="imgleftnotfocused" type="property" display="ImgLeftNotFocused"/>
			<memberdata name="imgrightnotfocused" type="property" display="ImgRightNotFocused"/>
			<memberdata name="imgmiddlenotfocused" type="property" display="ImgMiddleNotFocused"/>
			<memberdata name="version" type="property" display="Version"/>
			<memberdata name="initialised" type="property" display="Initialised"/>
			<memberdata name="custombuilder" type="property" display="CustomBuilder" script="Local lnControls, laObjects[1]&#xA;m.lnControls = Aselobj(m.laObjects)&#xA;If m.lnControls # 0&#xA;   Local loObject, lcClassLib, loBuilder&#xA;   m.loObject = m.laObjects[1]&#xA;   m.lcClassLib = Addbs(Justpath(m.loObject.ClassLibrary))+&quot;ThemedControlsBuilders.vcx&quot;&#xA;   Set Classlib To (m.lcClassLib) Additive&#xA;   m.loBuilder = Createobject(&quot;ButtonBuilder&quot;, m.loObject)&#xA;   m.loBuilder.Show()&#xA;Endif"/>
			<memberdata name="lblfocusedcolor" type="property" display="LblFocusedColor"/>
			<memberdata name="lblnotfocusedcolor" type="property" display="LblNotFocusedColor"/>
			<memberdata name="type" type="property" display="Type"/>
			<memberdata name="initthemedcontrol" type="method" display="InitThemedControl"/>
		</VFPData>
	*</PropValue>

	ADD OBJECT 'cmdFocus' AS commandbutton WITH ;
		Caption = "", ;
		Left = 0, ;
		Name = "cmdFocus", ;
		Style = 1, ;
		TabIndex = 1, ;
		Top = -20
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'imgBackgroundLeft' AS image WITH ;
		BackStyle = 0, ;
		Left = 0, ;
		Name = "imgBackgroundLeft", ;
		Top = -20
		*< END OBJECT: BaseClass="image" />

	ADD OBJECT 'imgBackgroundMiddle' AS image WITH ;
		BackStyle = 0, ;
		Left = 0, ;
		Name = "imgBackgroundMiddle", ;
		Top = -20
		*< END OBJECT: BaseClass="image" />

	ADD OBJECT 'imgBackgroundRight' AS image WITH ;
		BackStyle = 0, ;
		Left = 0, ;
		Name = "imgBackgroundRight", ;
		Top = -20
		*< END OBJECT: BaseClass="image" />

	ADD OBJECT 'imgIcon' AS image WITH ;
		BackStyle = 0, ;
		Height = 24, ;
		Left = 3, ;
		Name = "imgIcon", ;
		Top = 4, ;
		Width = 24
		*< END OBJECT: BaseClass="image" />

	ADD OBJECT 'lblCaption' AS label WITH ;
		BackStyle = 0, ;
		Caption = "Caption", ;
		FontBold = .T., ;
		FontSize = 8, ;
		Height = 16, ;
		Left = 31, ;
		Name = "lblCaption", ;
		TabIndex = 2, ;
		Top = 8, ;
		Width = 132
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'shpMouseHandler' AS shape WITH ;
		BackStyle = 0, ;
		BorderStyle = 0, ;
		Left = 0, ;
		Name = "shpMouseHandler", ;
		Top = -20
		*< END OBJECT: BaseClass="shape" />
	
	PROCEDURE changetheme		&& Occurs when theme change.
		With _Screen.ThemesManager
		   If This.Type==0
		      This.ImgLeftFocused = .GetMember("Button.Left.Focused.Picture")
		      This.ImgMiddleFocused = .GetMember("Button.Middle.Focused.Picture")
		      This.ImgRightFocused = .GetMember("Button.Right.Focused.Picture")
		      This.ImgLeftNotFocused = .GetMember("Button.Left.NotFocused.Picture")
		      This.ImgMiddleNotFocused = .GetMember("Button.Middle.NotFocused.Picture")
		      This.ImgRightNotFocused = .GetMember("Button.Right.NotFocused.Picture")
		   Else
		      This.imgBackgroundLeft.Picture = .GetMember("Button.Left.HotTracking.Picture")
		      This.imgBackgroundMiddle.Picture = .GetMember("Button.Middle.HotTracking.Picture")
		      This.imgBackgroundRight.Picture = .GetMember("Button.Right.HotTracking.Picture")
		   Endif
		   This.LblFocusedColor = .GetMember("Button.Focused.FontColor")
		   This.LblNotFocusedColor = .GetMember("Button.NotFocused.FontColor")
		   This.SetImages(.F.)
		Endwith
	ENDPROC

	PROTECTED PROCEDURE Init
		Thisform.ShowTips = .T.
		With This
			.Initialised = .T.
			.Resize()
			*
			* Reorder objects
			.imgBackgroundMiddle.ZOrder(0)
			.imgBackgroundLeft.ZOrder(0)
			.imgBackgroundRight.ZOrder(0)
			.imgIcon.ZOrder(0)
			.lblCaption.ZOrder(0)
			.cmdFocus.Caption = This.lblCaption.Caption
			.cmdFocus.ZOrder(0)
			.shpMouseHandler.ZOrder(0)
			*
			.InitThemedControl()
		Endwith
	ENDPROC

	HIDDEN PROCEDURE initthemedcontrol
		If Not Vartype(_Screen.ThemesManager)=="O"
			_Screen.Newobject("ThemesManager","ThemesManager","ThemedControls.vcx")
		Endif
		This.ChangeTheme()
	ENDPROC

	PROTECTED PROCEDURE Resize
		If This.Initialised
		   With This.imgBackgroundLeft
		      .Height = This.Height
		      .Left = 0
		      .Top = 0
		      .Width = 2
		   Endwith
		   *
		   With This.imgBackgroundMiddle
		      .Stretch = 2
		      .Height = This.Height
		      .Left = 2
		      .Top = 0
		      .Width = This.Width - 4
		   Endwith
		   *
		   With This.imgBackgroundRight
		      .Height = This.Height
		      .Left = This.Width - 2
		      .Top = 0
		      .Width = 2
		   Endwith
		   *
		   With This.cmdFocus
		      .Height = This.Height - 6
		      .Left = 3
		      .Top = 3
		      .Width = This.Width - 6
		   Endwith
		   *
		   With This.shpMouseHandler
		      .Height = This.Height
		      .Left = 0
		      .Top = 0
		      .Width = This.Width
		   Endwith
		   *
		   With This.imgIcon
		      .Height = 24
		      .Left = 3
		      .Top = 4
		      .Width = 24
		   Endwith
		   *
		   With This.lblCaption
		      .Height = 16
		      .Left = 31
		      .Top = 8
		      .Width = This.Width - 34
		   Endwith
		Endif
	ENDPROC

	PROCEDURE setimages		&& Internal to the class.
		Lparameters llFocus
		With This
		   If This.Type==0
		      If llFocus
		         .imgBackgroundLeft.Picture = .ImgLeftFocused
		         .imgBackgroundMiddle.Picture = .ImgMiddleFocused
		         .imgBackgroundRight.Picture = .ImgRightFocused
		      Else
		         .imgBackgroundLeft.Picture = .ImgLeftNotFocused
		         .imgBackgroundMiddle.Picture = .ImgMiddleNotFocused
		         .imgBackgroundRight.Picture = .ImgRightNotFocused
		      Endif
		   Else
		      Store llFocus To ;
		         .imgBackgroundLeft.Visible, ;
		         .imgBackgroundMiddle.Visible, ;
		         .imgBackgroundRight.Visible
		   Endif
		   If llFocus
		      .lblCaption.ForeColor = .LblFocusedColor
		   Else
		      .lblCaption.ForeColor = .LblNotFocusedColor
		   Endif
		   .cmdFocus.Visible = .F.
		   .cmdFocus.Visible = .T.
		Endwith
	ENDPROC

	PROCEDURE cmdFocus.Click
		This.Parent.Click()
	ENDPROC

	PROCEDURE cmdFocus.KeyPress
		Lparameters nKeyCode, nShiftAltCtrl
		If nKeyCode==13
		   Nodefault
		   This.Parent.Click()
		Endif
	ENDPROC

	PROCEDURE shpMouseHandler.Click
		This.Parent.cmdFocus.SetFocus()
		This.Parent.Click()
	ENDPROC

	PROCEDURE shpMouseHandler.MouseEnter
		Lparameters nButton, nShift, nXCoord, nYCoord
		This.Parent.SetImages(.T.)
	ENDPROC

	PROCEDURE shpMouseHandler.MouseLeave
		Lparameters nButton, nShift, nXCoord, nYCoord
		This.Parent.SetImages(.F.)
	ENDPROC

ENDDEFINE
