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

	*<DefinedPropArrayMethod>
		*m: caption_assign
		*p: _memberdata		&& XML Metadata for customizable properties
	*</DefinedPropArrayMethod>

	PROTECTED Destroy,Init
	*<PropValue>
		BackColor = 255,255,255
		Caption = "Page1"
		Height = 156
		Name = "pane"
		Width = 156
		_memberdata = <VFPData>
			<memberdata name="caption_assign" type="method" display="Caption_Assign"/>
		</VFPData>
	*</PropValue>
	
	PROCEDURE Activate
		With This.Parent.Parent
		   .TitleClicked(.Controls(This.PageOrder+1).Name)
		Endwith
	ENDPROC

	HIDDEN PROCEDURE caption_assign
		Lparameters vNewVal
		Store m.vNewVal To This.Caption, ;
			This.Parent.Parent.Controls(This.PageOrder+1).lblCaption.Caption
	ENDPROC

	PROTECTED PROCEDURE Destroy
		Try
			With This.Parent.Parent
				* Remove all titles
				Local lnTitle
				m.lnTitle = "TITLE"+Transform(This.PageOrder)
				.RemoveObject(m.lnTitle)
			Endwith
		Catch
		Endtry
	ENDPROC

	PROTECTED PROCEDURE Init
		With This
			.Parent.Parent.Newobject("Title"+Alltrim(Transform(.PageOrder)),;
				"Title","ToolBox",,.PageOrder,.Caption)
		Endwith
	ENDPROC

ENDDEFINE

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

	*<DefinedPropArrayMethod>
		*m: pagecount_assign
		*p: _memberdata		&& XML Metadata for customizable properties
	*</DefinedPropArrayMethod>

	*<PropValue>
		ActivePage = 0
		BorderWidth = 0
		ErasePage = .T.
		Height = 398
		MemberClass = "pane"
		MemberClassLibrary = toolbox.vcx
		Name = "panes"
		PageCount = 0
		SpecialEffect = 2
		Tabs = .F.
		Themes = .F.
		Width = 198
		_memberdata = <VFPData>
			<memberdata name="pagecount_assign" type="method" display="PageCount_Assign"/>
		</VFPData>
	*</PropValue>
	
	HIDDEN PROCEDURE pagecount_assign
		Lparameters vNewVal
		With This
			Local lnActivePage
			lnActivePage = .ActivePage
			.PageCount = m.vNewVal
			*
			Do Case
				Case .PageCount==0
					.ActivePage = 0
				Case lnActivePage > .PageCount
					.ActivePage = 1
				Otherwise
					.ActivePage = .ActivePage
			Endcase
			.Parent.ReArrangeTitles()
		Endwith
	ENDPROC

ENDDEFINE

DEFINE CLASS title 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="imgBackground" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="imgPicture" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lblCaption" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmdFocus" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="shpClickHandler" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: changetheme
		*m: initthemedcontrol
		*p: titleid		&& Title ID.
		*p: _memberdata		&& XML Metadata for customizable properties
	*</DefinedPropArrayMethod>

	*<PropValue>
		BackStyle = 0
		Height = 19
		Name = "title"
		titleid = 0
		Width = 200
		_memberdata = <VFPData>
			<memberdata name="titleid" type="property" display="TitleID"/>
			<memberdata name="changetheme" type="method" display="ChangeTheme"/>
		</VFPData>
	*</PropValue>

	ADD OBJECT 'cmdFocus' AS commandbutton WITH ;
		Anchor = 10, ;
		Caption = "", ;
		Height = 15, ;
		Left = 2, ;
		Name = "cmdFocus", ;
		Style = 1, ;
		TabIndex = 1, ;
		Themes = .F., ;
		Top = 2, ;
		Width = 196
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'imgBackground' AS image WITH ;
		Anchor = 15, ;
		Height = 17, ;
		Left = 1, ;
		Name = "imgBackground", ;
		Stretch = 2, ;
		Top = 1, ;
		Width = 198
		*< END OBJECT: BaseClass="image" />

	ADD OBJECT 'imgPicture' AS image WITH ;
		Anchor = 2, ;
		Height = 9, ;
		Left = 6, ;
		Name = "imgPicture", ;
		Top = 5, ;
		Width = 9
		*< END OBJECT: BaseClass="image" />

	ADD OBJECT 'lblCaption' AS label WITH ;
		Anchor = 10, ;
		BackStyle = 0, ;
		Caption = "", ;
		FontSize = 8, ;
		Height = 17, ;
		Left = 26, ;
		Name = "lblCaption", ;
		TabIndex = 2, ;
		Top = 2, ;
		Width = 168
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'shpClickHandler' AS shape WITH ;
		BackStyle = 0, ;
		BorderStyle = 0, ;
		Height = 19, ;
		Name = "shpClickHandler", ;
		Width = 200
		*< END OBJECT: BaseClass="shape" />
	
	PROCEDURE changetheme
		With _Screen.ThemesManager
			This.BorderColor = .GetMember("Title.BorderColor")
			This.imgBackground.Left = .GetMember("Title.Background.Left")
			This.imgBackground.Width = This.Width - This.imgBackground.Left - 1
			This.imgBackground.Picture = .GetMember("ToolTitle.Background.Picture")
			This.imgBackground.Anchor = 0
			This.imgBackground.Anchor = 15
			This.lblCaption.ForeColor = .GetMember("ToolTitle.FontColor")
		Endwith
	ENDPROC

	PROCEDURE Init
		Lparameters liID, lcCaption
		With This
			.TitleID = liID
			.lblCaption.Caption = lcCaption
			.InitThemedControl()
			.Visible = .T.
		Endwith
	ENDPROC

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

	PROCEDURE cmdFocus.KeyPress
		Lparameters nKeyCode, nShiftAltCtrl
		Do Case
		   Case nKeyCode==13
		      Nodefault
		   Case Inlist(nKeyCode,43,45)
		      With This.Parent
		         Local lnActivePage
		         lnActivePage = .Parent.Panes.ActivePage
		         If (nKeyCode==43 And Not .TitleID==lnActivePage) Or ;
		               (nKeyCode==45 And .TitleID==lnActivePage)
		            .shpClickHandler.Click()
		         Endif
		      Endwith
		Endcase
	ENDPROC

	PROCEDURE shpClickHandler.Click
		With This.Parent
			If .Parent.Panes.ActivePage==.TitleID
				If .Parent.Wrap
					.Parent.Panes.ActivePage = Iif(.Parent.Panes.PageCount==.TitleID,1,.TitleID+1)
				Else
					.Parent.Panes.ActivePage = .TitleID + Iif(.Parent.Panes.PageCount==.TitleID,-1,1)
				Endif
			Else
				.Parent.Panes.ActivePage = .TitleID
			Endif
			.Parent.ReArrangeTitles()
			* Needed to show focus rectangle
			Local loTitle
			If Upper(Thisform.BaseClass)=="TOOLBAR"
				loTitle = This.Parent
			Else
				loTitle = .Parent.Controls(.Parent.Panes.ActivePage+1)
			Endif
			With loTitle
				.cmdFocus.Visible = .F.
				.cmdFocus.Visible = .T.
				.SetFocus()
			Endwith
			loTitle = Null
		Endwith
	ENDPROC

ENDDEFINE

DEFINE CLASS toolbox 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="Panes" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: changetheme		&& Occurs when theme change.
		*m: initthemedcontrol
		*m: rearrangetitles		&& Internal to the class. Rearrange title to show in correctly and position.
		*m: titleclicked		&& Occurs when a title is clicked.
		*p: version		&& ToolBox version.
		*p: wrap		&& Specify if the focus goes to the first Title (.T.) or to the previous Title (.F.) when the last Title is collapsed.
		*p: _memberdata		&& XML Metadata for customizable properties
	*</DefinedPropArrayMethod>

	PROTECTED Init,Resize,version
	*<PropValue>
		Anchor = 15
		BackColor = 255,255,255
		Height = 400
		Name = "toolbox"
		version = 3.5.0
		Width = 200
		wrap = .T.
		_memberdata = <VFPData>
			<memberdata name="changetheme" type="method" display="ChangeTheme"/>
			<memberdata name="rearrangetitles" type="method" display="ReArrangeTitles"/>
			<memberdata name="titleclicked" type="method" display="TitleClicked"/>
			<memberdata name="version" type="property" display="Version"/>
			<memberdata name="wrap" type="property" display="Wrap"/>
			<memberdata name="initthemedcontrol" type="method" display="InitThemedControl"/>
		</VFPData>
	*</PropValue>

	ADD OBJECT 'Panes' AS panes WITH ;
		ErasePage = .T., ;
		Height = 398, ;
		Left = 1, ;
		Name = "Panes", ;
		Top = 1
		*< END OBJECT: ClassLib="toolbox.vcx" BaseClass="pageframe" />
	
	PROCEDURE changetheme		&& Occurs when theme change.
		This.BorderColor = _Screen.ThemesManager.GetMember("Container.BorderColor")
	ENDPROC

	PROTECTED PROCEDURE Init
		This.Panes.ActivePage = 1
		This.InitThemedControl()
		This.ReArrangeTitles()
	ENDPROC

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

	PROCEDURE rearrangetitles		&& Internal to the class. Rearrange title to show in correctly and position.
		Local lnTop, lnTitles, lnHeight, lnTabIndex, loControl, llBottom
		lnTop = 0
		lnTitles = (This.ControlCount-1)
		lnHeight = This.Height
		lnTabIndex = 1
		For Each loControl In This.Controls
		   loControl.TabIndex = lnTabIndex
		   lnTabIndex = lnTabIndex + 1
		   If Upper(loControl.Class)==Upper("Title")
		      loControl.Width = This.Width
		      loControl.Top = lnTop
		      If (loControl.TitleID)==This.Panes.ActivePage
		         loControl.imgPicture.Picture = _Screen.ThemesManager.GetMember("Signs.Minus.Picture")
		         llBottom = .T.
		         With This.Panes
		            .Top = loControl.Top + loControl.Height
		            .TabIndex = lnTabIndex
		         Endwith
		         lnTabIndex = lnTabIndex + 1
		      Else
		         loControl.imgPicture.Picture = _Screen.ThemesManager.GetMember("Signs.Plus.Picture")
		      Endif
		      lnTitles = lnTitles - 1
		      If Not llBottom
		         lnTop = lnTop + (loControl.Height-1)
		      Else
		         lnTop = This.Height - (lnTitles*(loControl.Height-1)) - 1
		         lnHeight = Min(lnHeight,lnTop - This.Panes.Top)
		      Endif
		   Else
		      loControl.Width = This.Width - 2
		   Endif
		Endfor
		loControl = Null
		This.Panes.Height = lnHeight
	ENDPROC

	PROTECTED PROCEDURE Resize
		If This.ControlCount>1 && Execute only after all titles was added
		   This.ReArrangeTitles()
		Endif
	ENDPROC

	PROCEDURE titleclicked		&& Occurs when a title is clicked.
		Lparameters lcTitle
	ENDPROC

ENDDEFINE
