
But it is easy to be adapted for various use.
Tested in PB v5.20 b13.
Edit: code updated.
Code: Select all
#Group_CurrentGroup = -1
Structure GadgetGroup
Group.i
List Gadgets.i()
EndStructure
Global NewList ___GadgetGroups.GadgetGroup()
Global NewList ___GroupStack.i()
Macro __mAddGadgetToGroup()
If ListIndex(___GadgetGroups()) >= 0 And Result
If Gadget = #PB_Any
Gadget = Result
EndIf
ForEach ___GadgetGroups()\Gadgets()
If ___GadgetGroups()\Gadgets() = Gadget ;if the gadget element already exists.
ProcedureReturn Result
EndIf
Next
If AddElement(___GadgetGroups()\Gadgets()) ;if it doesn't exist, create a new element.
___GadgetGroups()\Gadgets() = Gadget
EndIf
EndIf
EndMacro
;{
; ButtonGadget
Procedure __pButtonGadget(Gadget, x, y, Width, Height, Text$, Flags)
Protected Result = ButtonGadget(Gadget, x, y, Width, Height, Text$, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro ButtonGadget(Gadget, x, y, Width, Height, Text, Flags=0)
__pButtonGadget(Gadget, x, y, Width, Height, Text, Flags)
EndMacro
; ButtonImageGadget
Procedure __pButtonImageGadget(Gadget, x, y, Width, Height, ImageID, Flags)
Protected Result = ButtonImageGadget(Gadget, x, y, Width, Height, ImageID, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro ButtonImageGadget(Gadget, x, y, Width, Height, ImageID, Flags=0)
__pButtonImageGadget(Gadget, x, y, Width, Height, ImageID, Flags)
EndMacro
; CalendarGadget
Procedure __pCalendarGadget(Gadget, x, y, Width, Height, Date, Flags)
Protected Result = CalendarGadget(Gadget, x, y, Width, Height, Date, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro CalendarGadget(Gadget, x, y, Width, Height, Date=-1, Flags=0)
__pCalendarGadget(Gadget, x, y, Width, Height, Date, Flags)
EndMacro
; CanvasGadget
Procedure __pCanvasGadget(Gadget, x, y, Width, Height, Flags)
Protected Result = CanvasGadget(Gadget, x, y, Width, Height, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro CanvasGadget(Gadget, x, y, Width, Height, Flags=0)
__pCanvasGadget(Gadget, x, y, Width, Height, Flags)
EndMacro
; CheckBoxGadget
Procedure __pCheckBoxGadget(Gadget, x, y, Width, Height, Text$, Flags)
Protected Result = CheckBoxGadget(Gadget, x, y, Width, Height, Text$, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro CheckBoxGadget(Gadget, x, y, Width, Height, Text, Flags=0)
__pCheckBoxGadget(Gadget, x, y, Width, Height, Text, Flags)
EndMacro
; ComboBoxGadget
Procedure __pComboBoxGadget(Gadget, x, y, Width, Height, Flags)
Protected Result = ComboBoxGadget(Gadget, x, y, Width, Height, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro ComboBoxGadget(Gadget, x, y, Width, Height, Flags=0)
__pComboBoxGadget(Gadget, x, y, Width, Height, Flags)
EndMacro
; ContainerGadget
Procedure __pContainerGadget(Gadget, x, y, Width, Height, Flags)
Protected Result = ContainerGadget(Gadget, x, y, Width, Height, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro ContainerGadget(Gadget, x, y, Width, Height, Flags=0)
__pContainerGadget(Gadget, x, y, Width, Height, Flags)
EndMacro
; DateGadget
Procedure __pDateGadget(Gadget, x, y, Width, Height, Mask$, Date, Flags)
Protected Result = DateGadget(Gadget, x, y, Width, Height, Mask$, Date, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro DateGadget(Gadget, x, y, Width, Height, Mask="", Date=-1, Flags=0)
__pDateGadget(Gadget, x, y, Width, Height, Mask, Date, Flags)
EndMacro
; EditorGadget
Procedure __pEditorGadget(Gadget, x, y, Width, Height, Flags)
Protected Result = EditorGadget(Gadget, x, y, Width, Height, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro EditorGadget(Gadget, x, y, Width, Height, Flags=0)
__pEditorGadget(Gadget, x, y, Width, Height, Flags)
EndMacro
; ExplorerComboGadget
Procedure __pExplorerComboGadget(Gadget, x, y, Width, Height, Directory$, Flags)
Protected Result = ExplorerComboGadget(Gadget, x, y, Width, Height, Directory$, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro ExplorerComboGadget(Gadget, x, y, Width, Height, Directory, Flags=0)
__pExplorerComboGadget(Gadget, x, y, Width, Height, Directory, Flags)
EndMacro
; ExplorerListGadget
Procedure __pExplorerListGadget(Gadget, x, y, Width, Height, Directory$, Flags)
Protected Result = ExplorerListGadget(Gadget, x, y, Width, Height, Directory$, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro ExplorerListGadget(Gadget, x, y, Width, Height, Directory, Flags=0)
__pExplorerListGadget(Gadget, x, y, Width, Height, Directory, Flags)
EndMacro
; ExplorerTreeGadget
Procedure __pExplorerTreeGadget(Gadget, x, y, Width, Height, Directory$, Flags)
Protected Result = ExplorerTreeGadget(Gadget, x, y, Width, Height, Directory$, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro ExplorerTreeGadget(Gadget, x, y, Width, Height, Directory, Flags=0)
__pExplorerTreeGadget(Gadget, x, y, Width, Height, Directory, Flags)
EndMacro
; Frame3DGadget(FrameGadget)
CompilerIf #PB_Compiler_Version => 520
Procedure __pFrameGadget(Gadget, x, y, Width, Height, Text$, Flags)
Protected Result = FrameGadget(Gadget, x, y, Width, Height, Text$, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro FrameGadget(Gadget, x, y, Width, Height, Text, Flags=0)
__pFrameGadget(Gadget, x, y, Width, Height, Text, Flags)
EndMacro
CompilerElse
Procedure __pFrame3DGadget(Gadget, x, y, Width, Height, Text$, Flags)
Protected Result = Frame3DGadget(Gadget, x, y, Width, Height, Text$, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro Frame3DGadget(Gadget, x, y, Width, Height, Text, Flags=0)
__pFrame3DGadget(Gadget, x, y, Width, Height, Text, Flags)
EndMacro
CompilerEndIf
; HyperLinkGadget
Procedure __pHyperLinkGadget(Gadget, x, y, Width, Height, Text$, Color, Flags)
Protected Result = HyperLinkGadget(Gadget, x, y, Width, Height, Text$, Color, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro HyperLinkGadget(Gadget, x, y, Width, Height, Text, Color, Flags=0)
__pHyperLinkGadget(Gadget, x, y, Width, Height, Text, Color, Flags)
EndMacro
; IPAddressGadget
Procedure __pIPAddressGadget(Gadget, x, y, Width, Height)
Protected Result = IPAddressGadget(Gadget, x, y, Width, Height)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro IPAddressGadget(Gadget, x, y, Width, Height)
__pIPAddressGadget(Gadget, x, y, Width, Height)
EndMacro
; ImageGadget
Procedure __pImageGadget(Gadget, x, y, Width, Height, ImageID, Flags)
Protected Result = ImageGadget(Gadget, x, y, Width, Height, ImageID, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro ImageGadget(Gadget, x, y, Width, Height, ImageID, Flags=0)
__pImageGadget(Gadget, x, y, Width, Height, ImageID, Flags)
EndMacro
; ListIconGadget
Procedure __pListIconGadget(Gadget, x, y, Width, Height, Title$, TitleWidth, Flags)
Protected Result = ListIconGadget(Gadget, x, y, Width, Height, Title$, TitleWidth, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro ListIconGadget(Gadget, x, y, Width, Height, Title, TitleWidth, Flags=0)
__pListIconGadget(Gadget, x, y, Width, Height, Title, TitleWidth, Flags)
EndMacro
; ListViewGadget
Procedure __pListViewGadget(Gadget, x, y, Width, Height, Flags)
Protected Result = ListViewGadget(Gadget, x, y, Width, Height, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro ListViewGadget(Gadget, x, y, Width, Height, Flags=0)
__pListViewGadget(Gadget, x, y, Width, Height, Flags)
EndMacro
; MDIGadget
Procedure __pMDIGadget(Gadget, x, y, Width, Height, SubMenu, MenuItem, Flags)
Protected Result = MDIGadget(Gadget, x, y, Width, Height, SubMenu, MenuItem, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro MDIGadget(Gadget, x, y, Width, Height, SubMenu, MenuItem, Flags=0)
__pMDIGadget(Gadget, x, y, Width, Height, SubMenu, MenuItem, Flags)
EndMacro
; OptionGadget
Procedure __pOptionGadget(Gadget, x, y, Width, Height, Text$)
Protected Result = OptionGadget(Gadget, x, y, Width, Height, Text$)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro OptionGadget(Gadget, x, y, Width, Height, Text)
__pOptionGadget(Gadget, x, y, Width, Height, Text)
EndMacro
; PanelGadget
Procedure __pPanelGadget(Gadget, x, y, Width, Height)
Protected Result = PanelGadget(Gadget, x, y, Width, Height)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro PanelGadget(Gadget, x, y, Width, Height)
__pPanelGadget(Gadget, x, y, Width, Height)
EndMacro
; ProgressBarGadget
Procedure __pProgressBarGadget(Gadget, x, y, Width, Height, Minimum, Maximum, Flags)
Protected Result = ProgressBarGadget(Gadget, x, y, Width, Height, Minimum, Maximum, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro ProgressBarGadget(Gadget, x, y, Width, Height, Minimum, Maximum, Flags=0)
__pProgressBarGadget(Gadget, x, y, Width, Height, Minimum, Maximum, Flags)
EndMacro
; ScrollAreaGadget
Procedure __pScrollAreaGadget(Gadget, x, y, Width, Height, ScrollAreaWidth, ScrollAreaHeight, ScrollStep, Flags)
Protected Result = ScrollAreaGadget(Gadget, x, y, Width, Height, ScrollAreaWidth, ScrollAreaHeight, ScrollStep, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro ScrollAreaGadget(Gadget, x, y, Width, Height, ScrollAreaWidth, ScrollAreaHeight, ScrollStep=10, Flags=0)
__pScrollAreaGadget(Gadget, x, y, Width, Height, ScrollAreaWidth, ScrollAreaHeight, ScrollStep, Flags)
EndMacro
; ScrollBarGadget
Procedure __pScrollBarGadget(Gadget, x, y, Width, Height, Minimum, Maximum, PageLength, Flags)
Protected Result = ScrollBarGadget(Gadget, x, y, Width, Height, Minimum, Maximum, PageLength, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro ScrollBarGadget(Gadget, x, y, Width, Height, Minimum, Maximum, PageLength, Flags=0)
__pScrollBarGadget(Gadget, x, y, Width, Height, Minimum, Maximum, PageLength, Flags)
EndMacro
; ShortcutGadget
Procedure __pShortcutGadget(Gadget, x, y, Width, Height, Shortcut)
Protected Result = ShortcutGadget(Gadget, x, y, Width, Height, Shortcut)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro ShortcutGadget(Gadget, x, y, Width, Height, Shortcut)
__pShortcutGadget(Gadget, x, y, Width, Height, Shortcut)
EndMacro
; SpinGadget
Procedure __pSpinGadget(Gadget, x, y, Width, Height, Minimum, Maximum, Flags)
Protected Result = SpinGadget(Gadget, x, y, Width, Height, Minimum, Maximum, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro SpinGadget(Gadget, x, y, Width, Height, Minimum, Maximum, Flags=0)
__pSpinGadget(Gadget, x, y, Width, Height, Minimum, Maximum, Flags)
EndMacro
; SplitterGadget
Procedure __pSplitterGadget(Gadget, x, y, Width, Height, Gadget1, Gadget2, Flags)
Protected Result = SplitterGadget(Gadget, x, y, Width, Height, Gadget1, Gadget2, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro SplitterGadget(Gadget, x, y, Width, Height, Gadget1, Gadget2, Flags=0)
__pSplitterGadget(Gadget, x, y, Width, Height, Gadget1, Gadget2, Flags)
EndMacro
; StringGadget
Procedure __pStringGadget(Gadget, x, y, Width, Height, Content$, Flags)
Protected Result = StringGadget(Gadget, x, y, Width, Height, Content$, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro StringGadget(Gadget, x, y, Width, Height, Content, Flags=0)
__pStringGadget(Gadget, x, y, Width, Height, Content, Flags)
EndMacro
; TextGadget
Procedure __pTextGadget(Gadget, x, y, Width, Height, Text$, Flags)
Protected Result = TextGadget(Gadget, x, y, Width, Height, Text$, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro TextGadget(Gadget, x, y, Width, Height, Text, Flags=0)
__pTextGadget(Gadget, x, y, Width, Height, Text, Flags)
EndMacro
; TrackBarGadget
Procedure __pTrackBarGadget(Gadget, x, y, Width, Height, Minimum, Maximum, Flags)
Protected Result = TrackBarGadget(Gadget, x, y, Width, Height, Minimum, Maximum, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro TrackBarGadget(Gadget, x, y, Width, Height, Minimum, Maximum, Flags=0)
__pTrackBarGadget(Gadget, x, y, Width, Height, Minimum, Maximum, Flags)
EndMacro
; TreeGadget
Procedure __pTreeGadget(Gadget, x, y, Width, Height, Flags)
Protected Result = TreeGadget(Gadget, x, y, Width, Height, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro TreeGadget(Gadget, x, y, Width, Height, Flags=0)
__pTreeGadget(Gadget, x, y, Width, Height, Flags)
EndMacro
; WebGadget
Procedure __pWebGadget(Gadget, x, y, Width, Height, URL$, Flags)
Protected Result = WebGadget(Gadget, x, y, Width, Height, URL$, Flags)
__mAddGadgetToGroup()
ProcedureReturn Result
EndProcedure
Macro WebGadget(Gadget, x, y, Width, Height, URL, Flags=0)
__pWebGadget(Gadget, x, y, Width, Height, URL, Flags)
EndMacro
;}
;-
Procedure PushGroup()
LastElement(___GroupStack())
If AddElement(___GroupStack())
If ListIndex(___GadgetGroups()) >= 0
___GroupStack() = @___GadgetGroups()
Else
___GroupStack() = 0
EndIf
;Debug "push stack: " + Str(___GroupStack())
EndIf
EndProcedure
Procedure PopGroup()
If ListSize(___GroupStack()) > 0
LastElement(___GroupStack())
;Debug "pop stack: " + Str(___GroupStack())
If ___GroupStack()
ChangeCurrentElement(___GadgetGroups(), ___GroupStack())
Else
ResetList(___GadgetGroups())
EndIf
DeleteElement(___GroupStack())
EndIf
EndProcedure
;Create a new group, or open existing group.
; Group: any number, including #PB_Any.
; Return value: a pointer to new/existing group element.(if #PB_Any is used, it is new group number)
; 0 (failure).
Procedure OpenGadgetGroup(Group)
Protected Result
PushGroup()
If Group = #PB_Any ;create always.
Result = AddElement(___GadgetGroups())
If Result
___GadgetGroups()\Group = Result
EndIf
Else
ForEach ___GadgetGroups()
If ___GadgetGroups()\Group = Group ;if the group exists, select it.
ProcedureReturn @___GadgetGroups()
EndIf
Next
;if the group doesn't exist, create it.
Result = AddElement(___GadgetGroups())
If Result
___GadgetGroups()\Group = Group
EndIf
EndIf
If Result = 0
PopGroup()
EndIf
ProcedureReturn Result
EndProcedure
;Close open group(s).
; CloseAll: 0 (close current group only), 1 (close all the open groups).
Procedure CloseGadgetGroup(CloseAll=0)
If CloseAll = 0
PopGroup()
Else
ResetList(___GadgetGroups())
ClearList(___GroupStack())
EndIf
EndProcedure
;Delete an existing group.
; Group: any number, including #PB_All.
; Return value: 1 (success), 0 (failure).
Procedure DeleteGadgetGroup(Group)
Protected Result
If ListIndex(___GadgetGroups()) >= 0 And (___GadgetGroups()\Group = Group Or Group = #PB_All) ;don't delete the current open group.
Debug "Close the current group, and then delete it."
ProcedureReturn 0
EndIf
If Group = #PB_All
ClearList(___GadgetGroups())
ProcedureReturn 1
EndIf
PushListPosition(___GadgetGroups())
ForEach ___GadgetGroups()
If ___GadgetGroups()\Group = Group
DeleteElement(___GadgetGroups())
Result = 1
Break
EndIf
Next
PopListPosition(___GadgetGroups())
ProcedureReturn Result
EndProcedure
;Get current group number.
; Return value: current group number (success), -1 (failure).
Procedure GetCurrentGroup()
Protected Result = ListIndex(___GadgetGroups())
If Result >= 0
Result = ___GadgetGroups()\Group
EndIf
ProcedureReturn Result
EndProcedure
;Add a gadget to a group.
; Gadget: any existing(valid) gadget number.
; Group(optional): any existing(valid) group number, or #Group_CurrentGroup(default).
; Return value: a pointer to the gadget element.
; 0 (failure. the gadget isn't valid, or the group element doesn't exist).
Procedure AddGadget(Gadget, Group=#Group_CurrentGroup)
Protected Result
If IsGadget(Gadget) = 0 : ProcedureReturn 0 : EndIf
If Group = #Group_CurrentGroup
If ListIndex(___GadgetGroups()) >= 0
ForEach ___GadgetGroups()\Gadgets()
If ___GadgetGroups()\Gadgets() = Gadget ;if the gadget element already exists.
ProcedureReturn @___GadgetGroups()\Gadgets()
EndIf
Next
Result = AddElement(___GadgetGroups()\Gadgets()) ;if it doesn't exist, create a new element.
If Result
___GadgetGroups()\Gadgets() = Gadget
EndIf
EndIf
Else
PushListPosition(___GadgetGroups())
ForEach ___GadgetGroups()
If ___GadgetGroups()\Group = Group ;if the group exists.
ForEach ___GadgetGroups()\Gadgets()
If ___GadgetGroups()\Gadgets() = Gadget ;if the gadget element already exists.
Result = @___GadgetGroups()\Gadgets()
Break 2
EndIf
Next
Result = AddElement(___GadgetGroups()\Gadgets()) ;if it doesn't exist, create a new element.
If Result
___GadgetGroups()\Gadgets() = Gadget
EndIf
Break
EndIf
Next
PopListPosition(___GadgetGroups())
EndIf
ProcedureReturn Result
EndProcedure
;Delete a gadget from a group.
; Gadget: any existing(valid) gadget number.
; Group(optional): any existing(valid) group number, or #Group_CurrentGroup(default).
; Return value: 1 (success), 0 (failure. the gadget isn't valid, the gadget or group element doesn't exist).
Procedure DeleteGadget(Gadget, Group=#Group_CurrentGroup)
Protected Result
If IsGadget(Gadget) = 0 : ProcedureReturn 0 : EndIf
If Group = #Group_CurrentGroup
If ListIndex(___GadgetGroups()) >= 0
ForEach ___GadgetGroups()\Gadgets()
If ___GadgetGroups()\Gadgets() = Gadget ;if the gadget element already exists.
DeleteElement(___GadgetGroups()\Gadgets())
ProcedureReturn 1
EndIf
Next
EndIf
Else
PushListPosition(___GadgetGroups())
ForEach ___GadgetGroups()
If ___GadgetGroups()\Group = Group ;if the group exists.
ForEach ___GadgetGroups()\Gadgets()
If ___GadgetGroups()\Gadgets() = Gadget ;if the gadget element already exists.
DeleteElement(___GadgetGroups()\Gadgets())
Result = 1
Break 2
EndIf
Next
Break
EndIf
Next
PopListPosition(___GadgetGroups())
EndIf
ProcedureReturn Result
EndProcedure
;Delete a gadget from all groups.
; Gadget: any existing(valid) gadget number.
; Return value: 1 (success), 0 (failure. the gadget isn't valid, the gadget element doesn't exist).
Procedure DeleteGadgetAll(Gadget)
Protected Result
If IsGadget(Gadget) = 0 : ProcedureReturn 0 : EndIf
PushListPosition(___GadgetGroups())
ForEach ___GadgetGroups()
ForEach ___GadgetGroups()\Gadgets()
If ___GadgetGroups()\Gadgets() = Gadget ;if the gadget element exists.
DeleteElement(___GadgetGroups()\Gadgets())
Result = 1
EndIf
Next
Next
PopListPosition(___GadgetGroups())
ProcedureReturn Result
EndProcedure
;- function examples.
Procedure DisableGroup(Group, State)
If ListSize(___GadgetGroups()) > 0
PushListPosition(___GadgetGroups())
ForEach ___GadgetGroups()
If ___GadgetGroups()\Group = Group
ForEach ___GadgetGroups()\Gadgets()
Gadget = ___GadgetGroups()\Gadgets()
If IsGadget(Gadget)
DisableGadget(Gadget, State)
EndIf
Next
Break
EndIf
Next
PopListPosition(___GadgetGroups())
EndIf
EndProcedure
Procedure HideGroup(Group, State)
If ListSize(___GadgetGroups()) > 0
PushListPosition(___GadgetGroups())
ForEach ___GadgetGroups()
If ___GadgetGroups()\Group = Group
ForEach ___GadgetGroups()\Gadgets()
Gadget = ___GadgetGroups()\Gadgets()
If IsGadget(Gadget)
HideGadget(Gadget, State)
EndIf
Next
Break
EndIf
Next
PopListPosition(___GadgetGroups())
EndIf
EndProcedure
Procedure FreeGroup(Group)
Protected Done
If ListSize(___GadgetGroups()) > 0
PushListPosition(___GadgetGroups())
ForEach ___GadgetGroups()
If ___GadgetGroups()\Group = Group
ForEach ___GadgetGroups()\Gadgets()
Gadget = ___GadgetGroups()\Gadgets()
If IsGadget(Gadget)
FreeGadget(Gadget)
DeleteGadgetAll(Gadget)
EndIf
Next
Done = 1
Break
EndIf
Next
PopListPosition(___GadgetGroups())
If Done
DeleteGadgetGroup(Group)
EndIf
Debug GetCurrentGroup()
EndIf
EndProcedure
;-
Code: Select all
;- Example 1
OpenWindow(0, 0, 0, 322, 220, "Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Debug GetCurrentGroup() ; -1
OpenGadgetGroup(1)
PanelGadget (0, 8, 8, 306, 203)
AddGadgetItem (0, -1, "Panel 1")
OpenGadgetGroup(3)
PanelGadget (1, 5, 5, 290, 166)
AddGadgetItem(1, -1, "Sub-Panel 1")
AddGadgetItem(1, -1, "Sub-Panel 2")
AddGadgetItem(1, -1, "Sub-Panel 3")
CloseGadgetList()
AddGadgetItem (0, -1,"Panel 2")
Debug GetCurrentGroup() ; 3
OpenGadgetGroup(2)
ButtonGadget(2, 10, 15, 80, 24,"Button 1")
ButtonGadget(3, 95, 15, 80, 24,"Button 2")
Debug GetCurrentGroup() ; 2
CloseGadgetGroup()
Debug GetCurrentGroup() ; 3
CloseGadgetGroup()
Debug GetCurrentGroup() ; 1
CloseGadgetList()
CloseGadgetGroup()
Debug GetCurrentGroup() ; -1
DisableGroup(3, 1)
DisableGroup(2, 1)
HideGroup(2, 1)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Code: Select all
;- Example 2
Enumeration
#Window_0
EndEnumeration
Enumeration
#Button_0
#ProgressBar_0
#Scrollbar_0
#Calendar_0
#Canvas_0
#Checkbox_0
#Option_0
#Combo_0
#Editor_0
#ExplorerCombo_0
#ExplorerList_0
#ExplorerTree_0
#Hyperlink_0
#IP_0
#Spin_0
#String_0
#Text_0
#TrackBar_0
#btn1
#btn2
#btn3
#btn4
#btn5
EndEnumeration
Procedure OpenWindow_0(x = 0, y = 0, width = 720, height = 600)
OpenWindow(#Window_0, x, y, width, height, "Example", #PB_Window_SystemMenu)
OpenGadgetGroup(0)
ButtonGadget(#Button_0, 45, 35, 95, 35, "test")
ProgressBarGadget(#ProgressBar_0, 45, 75, 95, 30, 0, 0)
ScrollBarGadget(#Scrollbar_0, 45, 110, 95, 30, 0, 0, 0)
CalendarGadget(#Calendar_0, 150, 35, 165, 120, 0)
CloseGadgetGroup()
Debug "Current Group: " + GetCurrentGroup()
OpenGadgetGroup(1)
CanvasGadget(#Canvas_0, 405, 45, 125, 100)
CheckBoxGadget(#Checkbox_0, 545, 45, 125, 30, "test")
OptionGadget(#Option_0, 545, 120, 140, 25, "test")
ComboBoxGadget(#Combo_0, 545, 85, 140, 25)
CloseGadgetGroup()
Debug "Current Group: " + GetCurrentGroup()
OpenGadgetGroup(2)
EditorGadget(#Editor_0, 45, 215, 155, 200)
ExplorerComboGadget(#ExplorerCombo_0, 215, 220, 170, 35, "")
ExplorerListGadget(#ExplorerList_0, 215, 270, 170, 145, "")
ExplorerTreeGadget(#ExplorerTree_0, 390, 220, 140, 195, "")
CloseGadgetGroup()
Debug "Current Group: " + GetCurrentGroup()
OpenGadgetGroup(3)
HyperLinkGadget(#Hyperlink_0, 550, 220, 135, 30, "test", 0)
IPAddressGadget(#IP_0, 550, 260, 135, 25)
SpinGadget(#Spin_0, 550, 295, 135, 30, 0, 0)
StringGadget(#String_0, 550, 335, 135, 25, "test")
TextGadget(#Text_0, 550, 365, 135, 30, "test")
TrackBarGadget(#TrackBar_0, 550, 400, 135, 25, 0, 0)
CloseGadgetGroup()
Debug "Current Group: " + GetCurrentGroup()
ButtonGadget(#btn1, 10, 525, 160, 25, "disable/enable 0")
ButtonGadget(#btn2, 190, 525, 160, 25, "disable/enable 1")
ButtonGadget(#btn3, 10, 560, 160, 25, "disable/enable 2")
ButtonGadget(#btn4, 190, 560, 160, 25, "disable/enable 3")
ButtonGadget(#btn5, 400, 525, 100, 25, "free 3")
EndProcedure
OpenWindow_0()
Repeat
e = WaitWindowEvent()
Select e
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case #btn1
g1 = 1 - g1
DisableGroup(0, g1)
Case #btn2
g2 = 1 - g2
DisableGroup(1, g2)
Case #btn3
g3 = 1 - g3
DisableGroup(2, g3)
Case #btn4
g4 = 1 - g4
DisableGroup(3, g4)
Case #btn5
FreeGroup(3)
EndSelect
EndSelect
ForEver