

Code: Select all
;
; Simple PropertyGrid
;
; by Danilo, May 2012, PureBasic 4.60
;
#PropertyGrid_SectionFont = "Arial"
#PropertyGrid_ImageLineColor = $0000ff
#PropertyGrid_ImageBackgroundColor = $ffffff
#PropertyGrid_SectionNamePreSpace = #True
Macro OS_Select ( variable, windows, linux, macos, def )
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows : variable = windows
CompilerCase #PB_OS_Linux : variable = linux
CompilerCase #PB_OS_MacOS : variable = macos
CompilerDefault : variable = def
CompilerEndSelect
EndMacro
OS_Select ( #PropertyGrid_DefaultItemHeight, 20, 22, 25, 20 )
OS_Select ( #PropertyGrid_SectionFontSize, 10, 10, 14, 12 )
Structure PropertyGridGadgetSubItem
DescriptionGadget.i
ItemGadget.i
EndStructure
Structure PropertyGridItem
SectionDescriptionGadget.i
SectionButtonGadget.i
IsSection.i
IsLocked.b
Opened.i
PopupMenu.i
test.l[4096]
List SubItems.PropertyGridGadgetSubItem()
EndStructure
Structure PropertyGridData
GridID.l
ItemHeight.i
Font.i
backColor.q
frontColor.q
Window.i
PopupMenu.i
test.l[4096]
List Items.PropertyGridItem()
EndStructure
Structure PropertyGridInfo
ID.l
Parent.i
test.l[4096]
EndStructure
Structure PropertyGridPopup
GridGadget.i
MenuItem.i
Parent.i
Item.i
EndStructure
Global NewList PopupMenuItems.PropertyGridPopup()
Global LastPopupMenuItem.i = -1
Procedure __GetPropertyGridImage ( state.i )
Static openImage.i, closeImage.i, lockImage.i, defaultImage.i
If Not defaultImage
defaultImage = CreateImage ( #PB_Any, 11, 11, 24 )
If defaultImage And StartDrawing ( ImageOutput ( defaultImage ) )
Box ( 0, 0, 11, 11, #PropertyGrid_ImageBackgroundColor )
DrawingMode ( #PB_2DDrawing_Outlined )
Box ( 0, 0, 11, 11, #PropertyGrid_ImageLineColor )
StopDrawing()
EndIf
EndIf
If Not openImage
openImage = CopyImage ( defaultImage, #PB_Any )
If openImage And StartDrawing ( ImageOutput ( openImage ) )
LineXY ( 2, 5, 8, 5, #PropertyGrid_ImageLineColor )
StopDrawing ( )
EndIf
EndIf
If Not closeImage
closeImage = CopyImage ( openImage, #PB_Any )
If closeImage And StartDrawing( ImageOutput ( closeImage ) )
LineXY ( 5, 2, 5, 8, #PropertyGrid_ImageLineColor )
StopDrawing ( )
EndIf
EndIf
If Not lockImage
lockImage = CopyImage ( defaultImage, #PB_Any )
If lockImage And StartDrawing( ImageOutput ( lockImage ) )
Box ( 3, 3, 5, 5, #PropertyGrid_ImageLineColor )
StopDrawing ( )
EndIf
EndIf
Select state
Case 0 : ProcedureReturn closeImage
Case 1 : ProcedureReturn openImage
Case 2 : ProcedureReturn lockImage
Default : ProcedureReturn defaultImage
EndSelect
EndProcedure
Procedure UpdatePropertyGrid ( PropertyGridGadget )
*memory.PropertyGridData = GetGadgetData ( PropertyGridGadget )
If *memory
i = 0
height = *memory\ItemHeight
width = GadgetWidth ( PropertyGridGadget )
ForEach *memory\Items()
If *memory\Items()\IsSection
ResizeGadget( *memory\Items()\SectionDescriptionGadget, 20, i, width - 20, height - 1 )
ResizeGadget( *memory\Items()\SectionButtonGadget , 4, i + height * 0.5 - 6, 11, 11 )
Else
ResizeGadget( *memory\Items()\SectionDescriptionGadget, 20, i, width * 0.5 - 40, height - 1 )
ResizeGadget( *memory\Items()\SectionButtonGadget , width * 0.5 - 19, i, width * 0.5 - 4, height - 1 )
EndIf
i + height
If *memory\Items()\Opened
ForEach *memory\Items()\SubItems()
ResizeGadget( *memory\Items()\SubItems()\DescriptionGadget, 20, i, width * 0.5 - 40, height - 1)
ResizeGadget( *memory\Items()\SubItems()\ItemGadget , width * 0.5 - 19, i, width * 0.5 - 4, height - 1 )
i + height
Next
EndIf
Next
SetGadgetAttribute ( PropertyGridGadget, #PB_ScrollArea_InnerHeight, i )
SetGadgetAttribute ( PropertyGridGadget, #PB_ScrollArea_InnerWidth, width - 20 )
EndIf
EndProcedure
Procedure __SetSection ( PropertyGridGadget, section )
*memory.PropertyGridData = GetGadgetData ( PropertyGridGadget )
If *memory
If section = 0
LastElement( *memory\Items() )
OpenGadgetList ( PropertyGridGadget )
ProcedureReturn #True
EndIf
ForEach *memory\Items()
If *memory\Items()\SectionButtonGadget = section
OpenGadgetList ( PropertyGridGadget )
ProcedureReturn #True
EndIf
Next
EndIf
EndProcedure
Procedure __AddSectionItem ( PropertyGridGadget, section, Description.s, Gadget.i )
*memory.PropertyGridData = GetGadgetData ( PropertyGridGadget )
If *memory
descGadget = StringGadget ( #PB_Any, 0, 0, 0, 0, Description, #PB_String_ReadOnly )
;descGadget = TextGadget(#PB_Any,0,0,0,0,Description);,#PB_Text_Border)
;DisableGadget( descGadget, 1 )
If section = 0
If AddElement( *memory\Items() )
With *memory\Items()
\IsSection = 0
\IsLocked = #False
\SectionButtonGadget = Gadget
\SectionDescriptionGadget = descGadget
EndWith
CloseGadgetList()
UpdatePropertyGrid ( PropertyGridGadget )
ProcedureReturn #True
EndIf
Else
LastElement( *memory\Items()\SubItems() )
If AddElement( *memory\Items()\SubItems() )
With *memory\Items()\SubItems()
\DescriptionGadget = descGadget
\ItemGadget = Gadget
EndWith
CloseGadgetList()
If *memory\Items()\Opened
UpdatePropertyGrid(PropertyGridGadget)
Else
HideGadget ( *memory\Items()\SubItems()\DescriptionGadget, 1 )
HideGadget ( *memory\Items()\SubItems()\ItemGadget , 1 )
EndIf
ProcedureReturn #True
EndIf
EndIf
EndIf
FreeGadget ( Gadget )
EndProcedure
Procedure __SetGadgetColor ( gadget, color_type, color )
If color <> -1
SetGadgetColor ( gadget, color_type, color )
EndIf
EndProcedure
Procedure __AddPopupMenuItem ( PropertyGridGadget, button, menu_item, text.s )
LastPopupMenuItem + 1
AddElement ( PopupMenuItems() )
PopupMenuItems()\GridGadget = PropertyGridGadget
PopupMenuItems()\Item = LastPopupMenuItem
PopupMenuItems()\MenuItem = menu_item
PopupMenuItems()\Parent = button
MenuItem ( LastPopupMenuItem, text )
EndProcedure
Procedure PropertyGridGadget ( gadgetNr, window, x, y, width, height, backColor.q = -1, frontColor.q = -1, flags = #PB_ScrollArea_Single )
gadget = ScrollAreaGadget ( gadgetNr, x, y, width, height, width - 20, 1, #PropertyGrid_DefaultItemHeight, flags )
If gadget
If gadgetNr = #PB_Any : gadgetNr = gadget : EndIf
__SetGadgetColor ( gadgetNr, #PB_Gadget_BackColor, backColor )
__SetGadgetColor ( gadgetNr, #PB_Gadget_FrontColor, frontColor )
*memory.PropertyGridData = AllocateMemory( SizeOf ( PropertyGridData ) )
If Not *memory
FreeGadget(gadgetNr)
ProcedureReturn 0
EndIf
InitializeStructure ( *memory,PropertyGridData )
With *memory
\ItemHeight = #PropertyGrid_DefaultItemHeight
\Font = LoadFont ( #PB_Any, #PropertyGrid_SectionFont, #PropertyGrid_SectionFontSize, #PB_Font_Bold )
\backColor = backColor
\frontColor = frontColor
\Window = window
EndWith
SetGadgetData ( gadgetNr, *memory )
CloseGadgetList()
EndIf
ProcedureReturn gadgetNr
EndProcedure
Procedure AddSection ( PropertyGridGadget, sectionName.s, open.i = 1, backColor.q = -1, frontColor.q = -1 )
If #PropertyGrid_SectionNamePreSpace = #True
sectionName = " " + sectionName
EndIf
*memory.PropertyGridData = GetGadgetData ( PropertyGridGadget )
If *memory
LastElement( *memory\Items() )
If AddElement( *memory\Items() )
OpenGadgetList ( PropertyGridGadget )
width = GadgetWidth ( PropertyGridGadget )
height = *memory\ItemHeight
gadget = TextGadget ( #PB_Any, 20, 0, width - 20, height, sectionName )
With *memory\Items()
\SectionDescriptionGadget = gadget
\SectionButtonGadget = ImageGadget ( #PB_Any, 0, 0, 0, 0, ImageID ( __GetPropertyGridImage ( open ) ) )
\Opened = open
\IsSection = 1
\IsLocked = #False
If \SectionButtonGadget
PopupMenu = CreatePopupMenu ( #PB_Any )
If PopupMenu
__AddPopupMenuItem ( PropertyGridGadget, \SectionButtonGadget, 1, "Expand All" )
__AddPopupMenuItem ( PropertyGridGadget, \SectionButtonGadget, 2, "Colapse All" )
__AddPopupMenuItem ( PropertyGridGadget, \SectionButtonGadget, 3, "Lock / Unlock" )
\PopupMenu = PopupMenu
EndIf
*memory_button.PropertyGridInfo = AllocateMemory ( SizeOf ( PropertyGridInfo ) )
If *memory_button
*memory_button\ID = $44495247
*memory_button\Parent = PropertyGridGadget
EndIf
SetGadgetData ( \SectionButtonGadget, *memory_button )
EndIf
EndWith
If backColor = -1 : backColor = *memory\backColor : EndIf
If frontColor = -1 : frontColor = *memory\frontColor : EndIf
SetGadgetFont ( gadget, FontID ( *memory\Font ) )
__SetGadgetColor ( gadget, #PB_Gadget_BackColor, backColor )
__SetGadgetColor ( gadget, #PB_Gadget_FrontColor, frontColor )
CloseGadgetList()
UpdatePropertyGrid ( PropertyGridGadget )
ProcedureReturn *memory\Items()\SectionButtonGadget
EndIf
EndIf
EndProcedure
Procedure LockSection ( PropertyGridGadget, Section, Lock )
*memory.PropertyGridData = GetGadgetData ( PropertyGridGadget )
If *memory
ForEach *memory\Items()
If *memory\Items()\SectionButtonGadget = Section
*memory\Items()\IsLocked = Lock
If Lock = #True
image_number = 2
Else
image_number = *memory\Items()\Opened
EndIf
SetGadgetState ( *memory\Items()\SectionButtonGadget, ImageID ( __GetPropertyGridImage ( image_number ) ) )
Break
EndIf
Next
EndIf
EndProcedure
Procedure ChangeSectionState ( *memory.PropertyGridItem, state )
If state = 2
*memory\Opened ! 1
Else
*memory\Opened = state
EndIf
SetGadgetState ( *memory\SectionButtonGadget, ImageID ( __GetPropertyGridImage ( *memory\Opened ) ) )
ForEach *memory\SubItems()
HideGadget( *memory\SubItems()\DescriptionGadget , 1 - *memory\Opened )
HideGadget( *memory\SubItems()\ItemGadget , 1 - *memory\Opened )
Next
EndProcedure
Procedure CheckPropertyGridSectionClick ( PropertyGridGadget, EventGadget, EventType )
*memory.PropertyGridData = GetGadgetData ( PropertyGridGadget )
If *memory
ForEach *memory\Items()
If EventGadget = *memory\Items()\SectionButtonGadget
If EventType = #PB_EventType_LeftClick And *memory\Items()\IsLocked = #False
ChangeSectionState ( *memory\Items(), 2 )
UpdatePropertyGrid ( PropertyGridGadget )
ProcedureReturn
EndIf
If EventType = #PB_EventType_RightClick And *memory\Items()\PopupMenu <> 0
DisplayPopupMenu ( *memory\Items()\PopupMenu, WindowID ( *memory\Window ) )
EndIf
EndIf
Next
EndIf
EndProcedure
Procedure SectionActions ( PropertyGridGadget, Section, Action )
*memory.PropertyGridData = GetGadgetData ( PropertyGridGadget )
If *memory
ForEach *memory\Items()
Select Action
Case 1
If *memory\Items()\IsLocked = #False
ChangeSectionState ( *memory\Items(), 1 )
EndIf
Case 2
If *memory\Items()\IsLocked = #False
ChangeSectionState ( *memory\Items(), 0 )
EndIf
Case 3
If Section = *memory\Items()\SectionButtonGadget
If *memory\Items()\IsLocked = #True
LockSection ( PropertyGridGadget, Section, #False )
Else
LockSection ( PropertyGridGadget, Section, #True )
EndIf
ProcedureReturn
EndIf
EndSelect
Next
UpdatePropertyGrid ( PropertyGridGadget )
EndIf
EndProcedure
;---[ PropertyGrid Gadgets ]---
Macro AddGridGadget ( PGG, Section, GadgetNr )
If __SetSection ( PGG, Section )
gadget = GadgetNr
If __AddSectionItem ( PGG, Section, Description, gadget )
ProcedureReturn gadget
EndIf
Else
FreeGadget ( GadgetNr )
EndIf
EndMacro
Procedure AddStringGadget ( PropertyGridGadget, section, Description.s, Content.s, flags = 0 )
AddGridGadget ( PropertyGridGadget, section, StringGadget ( #PB_Any, 0, 0, 0, 0, Content, flags ) )
EndProcedure
Procedure AddCheckBoxGadget ( PropertyGridGadget, section, Description.s, Text.s, flags = 0 )
AddGridGadget ( PropertyGridGadget, section, CheckBoxGadget ( #PB_Any, 0, 0, 0, 0, Text, flags ) )
EndProcedure
Procedure AddButtonGadget ( PropertyGridGadget, section, Description.s, Text.s, flags = 0 )
AddGridGadget ( PropertyGridGadget, section, ButtonGadget ( #PB_Any, 0, 0, 0, 0, Text, flags ) )
EndProcedure
Procedure AddComboBoxGadget ( PropertyGridGadget, section, Description.s, flags = 0 )
AddGridGadget ( PropertyGridGadget, section, ComboBoxGadget ( #PB_Any, 0, 0, 0, 0, flags ) )
EndProcedure
Procedure AddProgressBarGadget ( PropertyGridGadget, section, Description.s, Minimum, Maximum, flags = 0 )
AddGridGadget ( PropertyGridGadget, section, ProgressBarGadget ( #PB_Any, 0, 0, 0, 0, Minimum, Maximum, flags ) )
EndProcedure
Procedure AddSpinGadget ( PropertyGridGadget, section, Description.s, Minimum, Maximum, flags = 0 )
AddGridGadget ( PropertyGridGadget, section, SpinGadget ( #PB_Any, 0, 0, 0, 0, Minimum, Maximum, flags ) )
EndProcedure
Procedure AddTrackBarGadget ( PropertyGridGadget, section, Description.s, Minimum, Maximum, flags = 0 )
AddGridGadget ( PropertyGridGadget, section, TrackBarGadget ( #PB_Any, 0, 0, 0, 0, Minimum, Maximum, flags ) )
EndProcedure
Procedure AddSplitterGadget ( PropertyGridGadget, section, Description.s, Gadget1, Gadget2, flags = 0 )
AddGridGadget ( PropertyGridGadget, section, SplitterGadget ( #PB_Any, 0, 0, 0, 0, Gadget1, Gadget2, flags ) )
EndProcedure
Procedure AddIPAddressGadget ( PropertyGridGadget, section, Description.s )
AddGridGadget ( PropertyGridGadget, section, IPAddressGadget ( #PB_Any, 0, 0, 120, #PropertyGrid_DefaultItemHeight ) )
EndProcedure
Procedure AddShortcutGadget ( PropertyGridGadget, section, Description.s, Shortcut )
AddGridGadget ( PropertyGridGadget, section, ShortcutGadget ( #PB_Any, 0, 0, 0, 0, Shortcut ) )
EndProcedure
Procedure AddDateGadget ( PropertyGridGadget, section, Description.s, Mask$ = "", Date = 0, flags = 0 )
AddGridGadget ( PropertyGridGadget, section, DateGadget ( #PB_Any, 0, 0, 0, 0, Mask$, Date, flags ) )
EndProcedure
Procedure AddHyperLinkGadget ( PropertyGridGadget, section, Description.s, Text$, Color, flags = 0 )
AddGridGadget ( PropertyGridGadget, section, HyperLinkGadget ( #PB_Any, 0, 0, 0, 0, Text$, Color, flags ) )
EndProcedure
Procedure IsGridGadget ( Gadget )
*memory.PropertyGridInfo = GetGadgetData ( Gadget )
If *memory
If *memory\ID = $44495247
ProcedureReturn *memory\Parent
EndIf
EndIf
ProcedureReturn 0
EndProcedure
;---------------------------------------------------------------------
Procedure AddComboBox_FalseTrue(PropertyGridGadget,section,Description.s,FalseTrue.i)
combo = AddComboBoxGadget(PropertyGridGadget,section,Description)
AddGadgetItem(combo,-1,"False")
AddGadgetItem(combo,-1,"True")
SetGadgetState(combo,FalseTrue)
ProcedureReturn combo
EndProcedure
main_window = OpenWindow ( #PB_Any,0,0,800,600,"PropertyGrid",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible)
prop = PropertyGridGadget(#PB_Any, main_window, 10, 10, 300, 580);,RGB($80,$80,$80),RGB($00,$00,$00))
section1 = AddSection(prop,"Section 1", 1, $ffcc00 )
string1 = AddStringGadget(prop,section1,"String","Item 1")
string2 = AddStringGadget(prop,section1,"Number","123456",#PB_String_Numeric)
spin1 = AddSpinGadget (prop,section1,"SpinGadget",1,100,#PB_Spin_Numeric)
SetGadgetText(spin1,"1")
split = AddSplitterGadget(prop,section1,"Splitter",ButtonGadget(#PB_Any,0,0,50,0,"1"),ButtonGadget(#PB_Any,0,0,50,0,"2"),#PB_Splitter_Vertical)
SetGadgetAttribute(split,#PB_Splitter_FirstMinimumSize,50)
SetGadgetAttribute(split,#PB_Splitter_SecondMinimumSize,50)
AddTrackBarGadget(prop,section1,"Trackbar",1,100)
LockSection ( prop, section1, #True )
section2 = AddSection(prop,"Section 2", 1, $00ccff)
combo1 = AddComboBoxGadget(prop,section2,"Combobox 1")
For i = 1 To 10 : AddGadgetItem(combo1,-1,"Item "+Str(i)) : Next
check1 = AddCheckBoxGadget(prop,section2,"Checkbox 1","Check me!")
btn1 = AddButtonGadget (prop,section2,"Choose Directory","...")
section3 = AddSection(prop,"Section 3")
progress = AddProgressBarGadget(prop,section3,"Progress",0,100)
SetGadgetState(progress,40)
AddShortcutGadget(prop,section3,"Shortcut",0)
AddDateGadget(prop,section3,"Date")
AddHyperLinkGadget(prop,section3,"Hyperlink","Hyper Hyper!",RGB($00,$00,$FF))
ip = AddIPAddressGadget(prop,section3,"IP Address")
SetGadgetState(ip, MakeIPAddress(127, 0, 0, 1))
For i = 4 To 20
sec = AddSection(prop,"Section "+Str(i),0)
For j = 1 To 10
AddStringGadget(prop,sec,"Description "+Str(j),"Item "+Str(j))
Next j
Next i
prop2 = PropertyGridGadget(#PB_Any, main_window, 330,10,450,280,RGB($40,$40,$40),RGB($FF,$FF,$FF))
For i = 1 To 20
sec = AddSection(prop2,"Section "+Str(i),0)
For j = 1 To 10
AddStringGadget(prop2,sec,"Section "+Str(i)+", Field "+Str(j),"Item "+Str(j))
Next j
Next i
prop3 = PropertyGridGadget(#PB_Any, main_window, 330,300,300,280,-1,-1,#PB_ScrollArea_Flat)
AddComboBox_FalseTrue(prop3,0,"AllowDrop" ,#False)
AddComboBox_FalseTrue(prop3,0,"Enabled" ,#True)
AddComboBox_FalseTrue(prop3,0,"FullRowSelect",#False)
AddComboBox_FalseTrue(prop3,0,"HideSelection",#True)
AddComboBox_FalseTrue(prop3,0,"HotTracking" ,#False)
spinImgIdx = AddSpinGadget (prop3,0,"ImageIndex",1,100,#PB_Spin_Numeric) : SetGadgetText(spinImgIdx,"1")
secImageSize = AddSection(prop3,"ImageSize",0)
spinImgWidth = AddSpinGadget (prop3,secImageSize,"Width ",1,100,#PB_Spin_Numeric) : SetGadgetText(spinImgWidth ,"32")
spinImgHeight = AddSpinGadget (prop3,secImageSize,"Height",1,100,#PB_Spin_Numeric) : SetGadgetText(spinImgHeight,"32")
While WindowEvent():Wend
HideWindow(main_window,0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Menu
ResetList ( PopupMenuItems() )
ForEach PopupMenuItems()
If PopupMenuItems()\Item = EventMenu()
SectionActions ( PopupMenuItems()\GridGadget, PopupMenuItems()\Parent, PopupMenuItems()\MenuItem )
EndIf
Next
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
Select EventGadget
Case btn1
MessageRequester("INFO","Button pressed")
LockSection ( prop, section1, #False )
Default
GridGagdet = IsGridGadget ( EventGadget )
If GridGagdet
CheckPropertyGridSectionClick ( GridGagdet, EventGadget, EventType )
EndIf
EndSelect
EndSelect
ForEver
peterb made the start, the community can improve it more and more. I had more ideas, but I don't want+18 wrote:hello Danilo
in firstly, thanks for share a useful grid whit we, and i suggest to improve your nice project please ... please and please![]()
thanks again
Don't worry about that Danilo; no worries at all. If my controls are rendered redundant by someone else's work then I can have no complaints; that's life.Danilo wrote:I had more ideas, but I don't want to disturb srod's Grid or other products. Beside that I don't have a personal need for it, it was just fun.
Code: Select all
Macro OS_Select ( windows, linux, macos, def )
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
windows
CompilerCase #PB_OS_Linux
linux
CompilerCase #PB_OS_MacOS
macos
CompilerDefault
def
CompilerEndSelect
EndMacro
#PropertyGrid_DefaultItemHeight = OS_Select (20, 22, 25, 20 ) ; err! CompilerSelect not allowed amidst an assignment.
#PropertyGrid_SectionFontSize = OS_Select(10, 10, 14, 12 )
Code: Select all
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : PropertyGridGadget
; File Name : PropertyGridGadget.pb
; File version: 1.0.0
; Programming : OK
; Programmed by : Guimauve
; Date : 09-10-2012
; Last Update : 09-10-2012
; PureBasic code : 4.70
; Platform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Programming notes :
;
; 1. This PropertyGrigGadget is based on the original work
; done by Danilo (PureBasic English Forum).
;
; 2. The CheckBoxGadget and the OptionGadget (Added) don't
; have a Description Gadget and Item Gadget. They are
; created has a Description gadget.
;
; 3. It possible to select Section and Item by Index number.
; Remember, Section Index number start at 0 and Item Index
; number start at 0 for each Section.
;
; 4. The Item creation outside a Section is no longer
; possible. (See "What is planned" about this point.)
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; What is planned (No date about when this will be added) :
;
; 1. PopupMenu to Open/Collapse/Lock/Unlock all Section.
;
; 2. A possibility to add 3-4 gadgets has item. (For the moment
; only 2 gadgets are possible.)
;
; 3. A better way to handle event and maybe Run User procedures
; on specific Gadgets events.
;
; 4. A possibility to add user Data to all items.
;
; 5. Restore the possibility to add Items without Section.
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
#PropertyGrid_SectionFont = "Arial"
#PropertyGrid_DefaultItemHeight = 20
#PropertyGrid_SectionFontSize = 10
CompilerCase #PB_OS_Linux
#PropertyGrid_SectionFont = "Mint Spirit"
#PropertyGrid_DefaultItemHeight = 30
#PropertyGrid_SectionFontSize = 10
CompilerCase #PB_OS_MacOS
#PropertyGrid_SectionFont = "Arial"
#PropertyGrid_DefaultItemHeight = 25
#PropertyGrid_SectionFontSize = 14
CompilerDefault ; future
#PropertyGrid_SectionFont = "Arial"
#PropertyGrid_DefaultItemHeight = 20
#PropertyGrid_SectionFontSize = 12
CompilerEndSelect
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Structure declaration <<<<<
Structure PropertyGridSubItem
DescriptionGadget.i
ItemGadget.i
EndStructure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The observators <<<<<
Macro GetPropertyGridSubItemDescriptionGadget(PropertyGridSubItemA)
PropertyGridSubItemA\DescriptionGadget
EndMacro
Macro GetPropertyGridSubItemItemGadget(PropertyGridSubItemA)
PropertyGridSubItemA\ItemGadget
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The mutators <<<<<
Macro SetPropertyGridSubItemDescriptionGadget(PropertyGridSubItemA, P_DescriptionGadget)
GetPropertyGridSubItemDescriptionGadget(PropertyGridSubItemA) = P_DescriptionGadget
EndMacro
Macro SetPropertyGridSubItemItemGadget(PropertyGridSubItemA, P_ItemGadget)
GetPropertyGridSubItemItemGadget(PropertyGridSubItemA) = P_ItemGadget
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The Reset operator <<<<<
Macro ResetPropertyGridSubItem(PropertyGridSubItemA)
If IsGadget(GetPropertyGridSubItemDescriptionGadget(PropertyGridSubItemA))
FreeGadget(GetPropertyGridSubItemDescriptionGadget(PropertyGridSubItemA))
SetPropertyGridSubItemDescriptionGadget(PropertyGridSubItemA, 0)
EndIf
If IsGadget(GetPropertyGridSubItemItemGadget(PropertyGridSubItemA))
FreeGadget(GetPropertyGridSubItemItemGadget(PropertyGridSubItemA))
SetPropertyGridSubItemItemGadget(PropertyGridSubItemA, 0)
EndIf
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Code generated in : 00.003 seconds (17333.33 lines/second) <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Structure declaration <<<<<
Structure PropertyGridItem
SectionDescriptionGadget.i
SectionButtonGadget.i
IsSection.i
Opened.i ; Special : Toggle
List SubItems.PropertyGridSubItem()
EndStructure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The observators <<<<<
Macro GetPropertyGridItemSectionDescriptionGadget(PropertyGridItemA)
PropertyGridItemA\SectionDescriptionGadget
EndMacro
Macro GetPropertyGridItemSectionButtonGadget(PropertyGridItemA)
PropertyGridItemA\SectionButtonGadget
EndMacro
Macro GetPropertyGridItemIsSection(PropertyGridItemA)
PropertyGridItemA\IsSection
EndMacro
Macro GetPropertyGridItemOpened(PropertyGridItemA)
PropertyGridItemA\Opened
EndMacro
Macro GetPropertyGridItemSubItems(PropertyGridItemA)
PropertyGridItemA\SubItems()
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The mutators <<<<<
Macro SetPropertyGridItemSectionDescriptionGadget(PropertyGridItemA, P_SectionDescriptionGadget)
GetPropertyGridItemSectionDescriptionGadget(PropertyGridItemA) = P_SectionDescriptionGadget
EndMacro
Macro SetPropertyGridItemSectionButtonGadget(PropertyGridItemA, P_SectionButtonGadget)
GetPropertyGridItemSectionButtonGadget(PropertyGridItemA) = P_SectionButtonGadget
EndMacro
Macro SetPropertyGridItemIsSection(PropertyGridItemA, P_IsSection)
GetPropertyGridItemIsSection(PropertyGridItemA) = P_IsSection
EndMacro
Macro SetPropertyGridItemOpened(PropertyGridItemA, P_Opened)
GetPropertyGridItemOpened(PropertyGridItemA) = P_Opened
EndMacro
Macro SetPropertyGridItemSubItems(PropertyGridItemA, P_SubItems)
CopyPropertyGridSubItem(P_SubItems, GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Complentemary Macros for Linked Lists <<<<<
Macro AddPropertyGridItemSubItemsElement(PropertyGridItemA)
AddElement(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro AddPropertyGridItemSubItemsElementEx(PropertyGridItemA, P_Element)
AddElement(GetPropertyGridItemSubItems(PropertyGridItemA))
SetPropertyGridItemSubItems(PropertyGridItemA, P_Element)
EndMacro
Macro InsertPropertyGridItemSubItemsElement(PropertyGridItemA)
InsertElement(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro InsertPropertyGridItemSubItemsElementEx(PropertyGridItemA, P_Element)
InsertElement(GetPropertyGridItemSubItems(PropertyGridItemA))
SetPropertyGridItemSubItems(PropertyGridItemA, P_Element)
EndMacro
Macro SelectPropertyGridItemSubItemsElement(PropertyGridItemA, Position)
SelectElement(GetPropertyGridItemSubItems(PropertyGridItemA), Position)
EndMacro
Macro PreviousPropertyGridItemSubItemsElement(PropertyGridItemA)
PreviousElement(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro NextPropertyGridItemSubItemsElement(PropertyGridItemA)
NextElement(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro FirstPropertyGridItemSubItemsElement(PropertyGridItemA)
FirstElement(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro LastPropertyGridItemSubItemsElement(PropertyGridItemA)
LastElement(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro PopListPropertyGridItemSubItemsPosition(PropertyGridItemA)
PopListPosition(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro PushListPropertyGridItemSubItemsPosition(PropertyGridItemA)
PushListPosition(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro DeletePropertyGridItemSubItemsElement(PropertyGridItemA, Flag = 0)
DeleteElement(GetPropertyGridItemSubItems(PropertyGridItemA), Flag)
EndMacro
Macro ListPropertyGridItemSubItemsSize(PropertyGridItemA)
ListSize(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro ResetPropertyGridItemSubItemsList(PropertyGridItemA)
ResetList(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro ListPropertyGridItemSubItemsIndex(PropertyGridItemA)
ListIndex(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro ClearPropertyGridItemSubItemsList(PropertyGridItemA)
ClearList(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The specials operators <<<<<
Macro TogglePropertyGridItemOpened(PropertyGridItemA)
SetPropertyGridItemOpened(PropertyGridItemA, GetPropertyGridItemOpened(PropertyGridItemA) ! 1)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The Reset operator <<<<<
Macro ResetPropertyGridItem(PropertyGridItemA)
If IsGadget(GetPropertyGridItemSectionDescriptionGadget(PropertyGridItemA))
FreeGadget(GetPropertyGridItemSectionDescriptionGadget(PropertyGridItemA))
SetPropertyGridItemSectionDescriptionGadget(PropertyGridItemA, 0)
EndIf
If IsGadget(GetPropertyGridItemSectionButtonGadget(PropertyGridItemA))
FreeGadget(GetPropertyGridItemSectionButtonGadget(PropertyGridItemA))
SetPropertyGridItemSectionButtonGadget(PropertyGridItemA, 0)
EndIf
SetPropertyGridItemIsSection(PropertyGridItemA, 0)
SetPropertyGridItemOpened(PropertyGridItemA, 0)
ForEach GetPropertyGridItemSubItems(PropertyGridItemA)
ResetPropertyGridSubItem(GetPropertyGridItemSubItems(PropertyGridItemA))
Next
ClearPropertyGridItemSubItemsList(PropertyGridItemA)
ClearStructure(PropertyGridItemA, PropertyGridItem)
InitializeStructure(PropertyGridItemA, PropertyGridItem)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Code generated in : 00.012 seconds (17500.00 lines/second) <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Structure declaration <<<<<
Structure PropertyGridData
ItemHeight.i
Font.i
BackColor.l
FrontColor.l
List Items.PropertyGridItem()
EndStructure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The observators <<<<<
Macro GetPropertyGridDataItemHeight(PropertyGridDataA)
PropertyGridDataA\ItemHeight
EndMacro
Macro GetPropertyGridDataFont(PropertyGridDataA)
PropertyGridDataA\Font
EndMacro
Macro GetPropertyGridDataBackColor(PropertyGridDataA)
PropertyGridDataA\BackColor
EndMacro
Macro GetPropertyGridDataFrontColor(PropertyGridDataA)
PropertyGridDataA\FrontColor
EndMacro
Macro GetPropertyGridDataItems(PropertyGridDataA)
PropertyGridDataA\Items()
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The mutators <<<<<
Macro SetPropertyGridDataItemHeight(PropertyGridDataA, P_ItemHeight)
GetPropertyGridDataItemHeight(PropertyGridDataA) = P_ItemHeight
EndMacro
Macro SetPropertyGridDataFont(PropertyGridDataA, P_Font)
GetPropertyGridDataFont(PropertyGridDataA) = P_Font
EndMacro
Macro SetPropertyGridDataBackColor(PropertyGridDataA, P_BackColor)
GetPropertyGridDataBackColor(PropertyGridDataA) = P_BackColor
EndMacro
Macro SetPropertyGridDataFrontColor(PropertyGridDataA, P_FrontColor)
GetPropertyGridDataFrontColor(PropertyGridDataA) = P_FrontColor
EndMacro
Macro SetPropertyGridDataItems(PropertyGridDataA, P_Items)
CopyPropertyGridItem(P_Items, GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Complentemary Macros for Linked Lists <<<<<
Macro AddPropertyGridDataItemsElement(PropertyGridDataA)
AddElement(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro AddPropertyGridDataItemsElementEx(PropertyGridDataA, P_Element)
AddElement(GetPropertyGridDataItems(PropertyGridDataA))
SetPropertyGridDataItems(PropertyGridDataA, P_Element)
EndMacro
Macro InsertPropertyGridDataItemsElement(PropertyGridDataA)
InsertElement(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro InsertPropertyGridDataItemsElementEx(PropertyGridDataA, P_Element)
InsertElement(GetPropertyGridDataItems(PropertyGridDataA))
SetPropertyGridDataItems(PropertyGridDataA, P_Element)
EndMacro
Macro SelectPropertyGridDataItemsElement(PropertyGridDataA, Position)
SelectElement(GetPropertyGridDataItems(PropertyGridDataA), Position)
EndMacro
Macro PreviousPropertyGridDataItemsElement(PropertyGridDataA)
PreviousElement(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro NextPropertyGridDataItemsElement(PropertyGridDataA)
NextElement(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro FirstPropertyGridDataItemsElement(PropertyGridDataA)
FirstElement(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro LastPropertyGridDataItemsElement(PropertyGridDataA)
LastElement(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro PopListPropertyGridDataItemsPosition(PropertyGridDataA)
PopListPosition(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro PushListPropertyGridDataItemsPosition(PropertyGridDataA)
PushListPosition(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro DeletePropertyGridDataItemsElement(PropertyGridDataA, Flag = 0)
DeleteElement(GetPropertyGridDataItems(PropertyGridDataA), Flag)
EndMacro
Macro ListPropertyGridDataItemsSize(PropertyGridDataA)
ListSize(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro ResetPropertyGridDataItemsList(PropertyGridDataA)
ResetList(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro ListPropertyGridDataItemsIndex(PropertyGridDataA)
ListIndex(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro ClearPropertyGridDataItemsList(PropertyGridDataA)
ClearList(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The Reset operator <<<<<
Macro ResetPropertyGridData(PropertyGridDataA)
SetPropertyGridDataItemHeight(PropertyGridDataA, 0)
If IsFont(GetPropertyGridDataFont(PropertyGridDataA))
FreeFont(GetPropertyGridDataFont(PropertyGridDataA))
SetPropertyGridDataFont(PropertyGridDataA, 0)
EndIf
SetPropertyGridDataBackColor(PropertyGridDataA, 0)
SetPropertyGridDataFrontColor(PropertyGridDataA, 0)
ForEach GetPropertyGridDataItems(PropertyGridDataA)
ResetPropertyGridItem(GetPropertyGridDataItems(PropertyGridDataA))
Next
ClearPropertyGridDataItemsList(PropertyGridDataA)
ClearStructure(PropertyGridDataA, PropertyGridData)
InitializeStructure(PropertyGridDataA, PropertyGridData)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Code generated in : 00.011 seconds (18272.73 lines/second) <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The Private operators <<<<<
Procedure Private_PropertyGrid_OpenClose_Image(IsOpen.b)
Static OpenImage.i, CloseImage.i, OneShot.b
If OneShot = #False
OpenImage = CreateImage(#PB_Any, 11, 11, 32)
If OpenImage And StartDrawing(ImageOutput(OpenImage))
Box(0, 0, 11, 11, RGB($FF, $FF, $FF))
DrawingMode(#PB_2DDrawing_Outlined)
Box(0, 0, 11, 11, RGB($00, $00, $00))
LineXY(2, 5, 8, 5, RGB($00, $00, $00))
StopDrawing()
EndIf
CloseImage = CreateImage(#PB_Any, 11, 11, 32)
If CloseImage And StartDrawing(ImageOutput(CloseImage))
Box(0,0,11,11,RGB($FF,$FF,$FF))
DrawingMode(#PB_2DDrawing_Outlined)
Box(0,0,11,11,RGB($00,$00,$00))
LineXY(2,5,8,5,RGB($00,$00,$00))
LineXY(5,2,5,8,RGB($00,$00,$00))
StopDrawing()
EndIf
OneShot = #True
EndIf
If IsOpen
ProcedureReturn OpenImage
Else
ProcedureReturn CloseImage
EndIf
EndProcedure
Procedure Private_HidePropertyGridSubItem(*PropertyGridSubItemA.PropertyGridSubItem, IsOpen.b)
HideGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 1 - IsOpen)
If IsGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA))
HideGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), 1 - IsOpen)
EndIf
EndProcedure
Procedure Private_RelocatePropertyGridSubItem(*PropertyGridSubItemA.PropertyGridSubItem, Index, Width, Height)
ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index - 12, width >> 1 - 40, height - 1)
If IsGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA))
ResizeGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), width >> 1 - 19, Index - 12, width >> 1 - 4, height - 1)
EndIf
EndProcedure
Procedure Private_RelocatePropertyGridItem(*PropertyGridItemA.PropertyGridItem, Index, Width, Height)
If GetPropertyGridItemIsSection(*PropertyGridItemA)
ResizeGadget(GetPropertyGridItemSectionDescriptionGadget(*PropertyGridItemA), 20, Index, Width - 20, Height - 1)
ResizeGadget(GetPropertyGridItemSectionButtonGadget(*PropertyGridItemA), 4, Index + Height >> 1 - 12, 11, 11)
Else
ResizeGadget(GetPropertyGridItemSectionDescriptionGadget(*PropertyGridItemA), 20, Index, Width >> 1 - 40, Height - 1)
ResizeGadget(GetPropertyGridItemSectionButtonGadget(*PropertyGridItemA), Width >> 1 - 19, Index, Width >> 1 - 4, Height - 1)
EndIf
Index + Height
If GetPropertyGridItemOpened(*PropertyGridItemA) = #True
ForEach GetPropertyGridItemSubItems(*PropertyGridItemA)
Private_RelocatePropertyGridSubItem(GetPropertyGridItemSubItems(*PropertyGridItemA), Index, Width, Height)
Index + Height
Next
EndIf
ProcedureReturn Index
EndProcedure
Procedure Private_Create_PropertyGridItem(*PropertyGridItemA.PropertyGridItem, SectionName.s, Width, Height, FrontColor, BackColor, IsOpen.b, FontID)
SetPropertyGridItemSectionDescriptionGadget(*PropertyGridItemA, TextGadget(#PB_Any, 20, 0, width - 20, height, SectionName))
SetPropertyGridItemSectionButtonGadget(*PropertyGridItemA, ImageGadget(#PB_Any,0,0,0,0,ImageID(Private_PropertyGrid_OpenClose_Image(IsOpen))))
SetPropertyGridItemIsSection(*PropertyGridItemA, #True)
SetPropertyGridItemOpened(*PropertyGridItemA, IsOpen)
SetGadgetFont(GetPropertyGridItemSectionDescriptionGadget(*PropertyGridItemA), FontID(FontID))
If BackColor <> -1
SetGadgetColor(GetPropertyGridItemSectionDescriptionGadget(*PropertyGridItemA), #PB_Gadget_BackColor, BackColor)
EndIf
If FrontColor <> -1
SetGadgetColor(GetPropertyGridItemSectionDescriptionGadget(*PropertyGridItemA), #PB_Gadget_FrontColor, FrontColor)
EndIf
EndProcedure
Procedure Private_Update_PropertyGrid(PropertyGridID)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
Index = 0
height = GetPropertyGridDataItemHeight(*PropertyGridDataA)
width = GadgetWidth(PropertyGridID)
ForEach GetPropertyGridDataItems(*PropertyGridDataA)
Index = Private_RelocatePropertyGridItem(GetPropertyGridDataItems(*PropertyGridDataA), Index, Width, Height)
Next
If GetGadgetAttribute(PropertyGridID, #PB_ScrollArea_InnerHeight) <> Index
SetGadgetAttribute(PropertyGridID, #PB_ScrollArea_InnerHeight, Index)
EndIf
If GetGadgetAttribute(PropertyGridID, #PB_ScrollArea_InnerWidth) <> width - 20
SetGadgetAttribute(PropertyGridID, #PB_ScrollArea_InnerWidth, width - 20)
EndIf
EndIf
EndProcedure
Procedure Private_PropertyGridItem_EventManagement(*PropertyGridDataA.PropertyGridData, *PropertyGridItemA.PropertyGridItem)
If EventGadget() = GetPropertyGridItemSectionButtonGadget(*PropertyGridItemA) And EventType() = #PB_EventType_LeftClick
TogglePropertyGridItemOpened(GetPropertyGridDataItems(*PropertyGridDataA))
SetGadgetState(GetPropertyGridItemSectionButtonGadget(*PropertyGridItemA), ImageID(Private_PropertyGrid_OpenClose_Image(GetPropertyGridItemOpened(*PropertyGridItemA))))
ForEach GetPropertyGridItemSubItems(*PropertyGridItemA)
Private_HidePropertyGridSubItem(GetPropertyGridItemSubItems(*PropertyGridItemA), GetPropertyGridItemOpened(*PropertyGridItemA))
Next
SomethingHappen.b = #True
EndIf
ProcedureReturn SomethingHappen
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The Public operators <<<<<
Procedure PropertyGridGadget(PropertyGridID, x, y, Width, Height, FrontColor.l = -1, BackColor.l = -1, Flags = #PB_ScrollArea_Flat)
GadgetHandle = ScrollAreaGadget(PropertyGridID, x, y, Width, Height, Width - 20, 1, #PropertyGrid_DefaultItemHeight, Flags)
If GadgetHandle
If PropertyGridID = #PB_Any
PropertyGridID = GadgetHandle
EndIf
If FrontColor <> -1
SetGadgetColor(PropertyGridID, #PB_Gadget_FrontColor, FrontColor)
EndIf
If BackColor <> -1
SetGadgetColor(PropertyGridID, #PB_Gadget_BackColor, BackColor)
EndIf
*PropertyGridDataA.PropertyGridData = AllocateMemory(SizeOf(PropertyGridData))
If *PropertyGridDataA = #Null
FreeGadget(PropertyGridID)
ProcedureReturn 0
EndIf
InitializeStructure(*PropertyGridDataA, PropertyGridData)
SetPropertyGridDataItemHeight(*PropertyGridDataA, #PropertyGrid_DefaultItemHeight)
SetPropertyGridDataFont(*PropertyGridDataA, LoadFont(#PB_Any, #PropertyGrid_SectionFont, #PropertyGrid_SectionFontSize, #PB_Font_Bold))
SetPropertyGridDataBackColor(*PropertyGridDataA, BackColor)
SetPropertyGridDataFrontColor(*PropertyGridDataA, FrontColor)
SetGadgetData(PropertyGridID, *PropertyGridDataA)
CloseGadgetList()
EndIf
ProcedureReturn PropertyGridID
EndProcedure
Procedure AddPropertyGridSection(PropertyGridID, SectionName.s, IsOpen.b = #True)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
LastPropertyGridDataItemsElement(*PropertyGridDataA)
If AddPropertyGridDataItemsElement(*PropertyGridDataA)
InitializeStructure(GetPropertyGridDataItems(*PropertyGridDataA), PropertyGridItem)
OpenGadgetList(PropertyGridID)
Private_Create_PropertyGridItem(GetPropertyGridDataItems(*PropertyGridDataA), SectionName, GadgetWidth(PropertyGridID), GetPropertyGridDataItemHeight(*PropertyGridDataA), GetPropertyGridDataFrontColor(*PropertyGridDataA), GetPropertyGridDataBackColor(*PropertyGridDataA), IsOpen, GetPropertyGridDataFont(*PropertyGridDataA))
CloseGadgetList()
Private_Update_PropertyGrid(PropertyGridID)
ProcedureReturn #True
EndIf
EndIf
EndProcedure
Procedure CheckPropertyGridSectionClick(PropertyGridID)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
ForEach GetPropertyGridDataItems(*PropertyGridDataA)
If Private_PropertyGridItem_EventManagement(*PropertyGridDataA, GetPropertyGridDataItems(*PropertyGridDataA))
Private_Update_PropertyGrid(PropertyGridID)
Break
EndIf
Next
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure SetPropertyGridSectionName(PropertyGridID, SectionNo, SectionName.s)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
SetGadgetText(GetPropertyGridItemSectionDescriptionGadget(GetPropertyGridDataItems(*PropertyGridDataA)), SectionName)
EndIf
EndIf
EndIf
EndProcedure
Procedure.s GetPropertyGridSectionName(PropertyGridID, SectionNo)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
ProcedureReturn GetGadgetText(GetPropertyGridItemSectionDescriptionGadget(GetPropertyGridDataItems(*PropertyGridDataA)))
EndIf
EndIf
EndIf
EndProcedure
Procedure SetPropertyGridSectionItemDescription(PropertyGridID, SectionNo, ItemNo, Description.s)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
If ItemNo >= 0 And ItemNo <= ListPropertyGridItemSubItemsSize(GetPropertyGridDataItems(*PropertyGridDataA)) - 1
If SelectPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA), ItemNo)
If IsGadget(GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
SetGadgetText(GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))), Description)
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndProcedure
Procedure SetPropertyGridSectionItemContent(PropertyGridID, SectionNo, ItemNo, Content.s)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
If ItemNo >= 0 And ItemNo <= ListPropertyGridItemSubItemsSize(GetPropertyGridDataItems(*PropertyGridDataA)) - 1
If SelectPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA), ItemNo)
If IsGadget(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
SetGadgetText(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))), Content)
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndProcedure
Procedure.s GetPropertyGridSectionItemContent(PropertyGridID, SectionNo, ItemNo)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
If ItemNo >= 0 And ItemNo <= ListPropertyGridItemSubItemsSize(GetPropertyGridDataItems(*PropertyGridDataA)) - 1
If SelectPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA), ItemNo)
If IsGadget(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
ProcedureReturn GetGadgetText(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndProcedure
Procedure SetPropertyGridSectionItemGadgetState(PropertyGridID, SectionNo, ItemNo, State)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
If ItemNo >= 0 And ItemNo <= ListPropertyGridItemSubItemsSize(GetPropertyGridDataItems(*PropertyGridDataA)) - 1
If SelectPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA), ItemNo)
If GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))) = -1
If IsGadget(GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
SetGadgetState(GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))), State)
ProcedureReturn 1
Else
ProcedureReturn -1
EndIf
Else
If IsGadget(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
SetGadgetState(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))), State)
ProcedureReturn 1
Else
ProcedureReturn -1
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndProcedure
Procedure GetPropertyGridSectionItemGadgetHandle(PropertyGridID, SectionNo, ItemNo)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
If ItemNo >= 0 And ItemNo <= ListPropertyGridItemSubItemsSize(GetPropertyGridDataItems(*PropertyGridDataA)) - 1
If SelectPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA), ItemNo)
If GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))) = -1
If IsGadget(GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
ProcedureReturn GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)))
Else
ProcedureReturn -1
EndIf
Else
If IsGadget(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
ProcedureReturn GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)))
Else
ProcedureReturn -1
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndProcedure
Procedure GetPropertyGridSectionItemGadgetState(PropertyGridID, SectionNo, ItemNo)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
If ItemNo >= 0 And ItemNo <= ListPropertyGridItemSubItemsSize(GetPropertyGridDataItems(*PropertyGridDataA)) - 1
If SelectPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA), ItemNo)
If GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))) = -1
If IsGadget(GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
ProcedureReturn GetGadgetState(GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
Else
ProcedureReturn -1
EndIf
Else
If IsGadget(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
ProcedureReturn GetGadgetState(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
Else
ProcedureReturn -1
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndProcedure
Procedure GetPropertyGridSectionCount(PropertyGridID)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
SectionCount.l = -1
If *PropertyGridDataA <> #Null
SectionCount = ListPropertyGridDataItemsSize(*PropertyGridDataA)
EndIf
ProcedureReturn SectionCount
EndProcedure
Procedure AddPropertyGridStringGadget(PropertyGridID, SectionNo, Description.s = "", Content.s = "", Flags = 0)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), StringGadget(#PB_Any, 0, 0, 0, 0, Description, #PB_String_ReadOnly))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), StringGadget(#PB_Any, 0, 0, 0, 0, Content, Flags))
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure AddPropertyGridButtonGadget(PropertyGridID, SectionNo, Description.s = "", Content.s = "", Flags = 0)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), StringGadget(#PB_Any, 0, 0, 0, 0, Description, #PB_String_ReadOnly))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), ButtonGadget(#PB_Any, 0, 0, 0, 0, Content, Flags))
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure AddPropertyGridCheckBoxGadget(PropertyGridID, SectionNo, Description.s = "", Flags = 0)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), CheckBoxGadget(#PB_Any, 0, 0, 0, 0, Description, Flags))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), -1)
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure AddPropertyGridOptionGadget(PropertyGridID, SectionNo, Description.s = "")
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), OptionGadget(#PB_Any, 0, 0, 0, 0, Description))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), -1)
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure AddPropertyGridComboBoxGadget(PropertyGridID, SectionNo, Description.s = "", Flags = 0)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), StringGadget(#PB_Any, 0, 0, 0, 0, Description, #PB_String_ReadOnly))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), ComboBoxGadget(#PB_Any, 0, 0, 0, 0, Flags))
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure AddPropertyGridGadgetItems(PropertyGridID, SectionNo, ItemNo, Position, Text.s)
GadgetHandle = GetPropertyGridSectionItemGadgetHandle(PropertyGridID, SectionNo, ItemNo)
If IsGadget(GadgetHandle)
AddGadgetItem(GadgetHandle, Position, Text)
EndIf
EndProcedure
Procedure AddPropertyGridSpinGadget(PropertyGridID, SectionNo, Description.s = "", Minimum = 0, Maximum = 100, Flags = #PB_Spin_Numeric | #PB_Spin_ReadOnly)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), StringGadget(#PB_Any, 0, 0, 0, 0, Description, #PB_String_ReadOnly))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), SpinGadget(#PB_Any, 0, 0, 0, 0, Minimum, Maximum, Flags))
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure AddPropertyGridTrackBarGadget(PropertyGridID, SectionNo, Description.s = "", Minimum = 0, Maximum = 100, Flags = #PB_TrackBar_Ticks)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), StringGadget(#PB_Any, 0, 0, 0, 0, Description, #PB_String_ReadOnly))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), TrackBarGadget(#PB_Any, 0, 0, 0, 0, Minimum, Maximum, Flags))
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure AddPropertyGridProgressBarGadget(PropertyGridID, SectionNo, Description.s = "", Minimum = 0, Maximum = 100, Flags = #PB_ProgressBar_Smooth)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), StringGadget(#PB_Any, 0, 0, 0, 0, Description, #PB_String_ReadOnly))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), ProgressBarGadget(#PB_Any, 0, 0, 0, 0, Minimum, Maximum, Flags))
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure ClearPropertyGridGadgetSections(PropertyGridID)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
ForEach GetPropertyGridDataItems(*PropertyGridDataA)
ResetPropertyGridItem(GetPropertyGridDataItems(*PropertyGridDataA))
Next
ClearPropertyGridDataItemsList(*PropertyGridDataA)
InitializeStructure(*PropertyGridDataA, PropertyGridData)
EndIf
EndProcedure
Procedure FreePropertyGridGadget(PropertyGridID)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
ResetPropertyGridData(*PropertyGridDataA)
FreeMemory(*PropertyGridDataA)
FreeGadget(PropertyGridID)
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< !!! WARNING - YOU ARE NOW IN A TESTING ZONE - WARNING !!! <<<<<
; <<<<< !!! WARNING - THIS CODE SHOULD BE COMMENTED - WARNING !!! <<<<<
; <<<<< !!! WARNING - BEFORE THE FINAL COMPILATION. - WARNING !!! <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Enumeration
#PropertyGrid
EndEnumeration
If OpenWindow(0,0,0,800,600,"PropertyGrid",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
HideWindow(0, #True)
PropertyGridGadget(#PropertyGrid, 5, 5, 390, 500)
For SectionID = 0 To 5
AddPropertyGridSection(#PropertyGrid, "Section 0" + Str(SectionID))
AddPropertyGridCheckBoxGadget(#PropertyGrid, SectionID, "Is Visible")
AddPropertyGridStringGadget(#PropertyGrid, SectionID, "String", "Enter a text here !")
AddPropertyGridComboBoxGadget(#PropertyGrid, SectionID, "ComboBox")
AddPropertyGridButtonGadget(#PropertyGrid, SectionID, "Button", "Button 0" + Str(SectionID))
AddPropertyGridSpinGadget(#PropertyGrid, SectionID, "SpinGadget", 0, 15)
AddPropertyGridTrackBarGadget(#PropertyGrid, SectionID, "TrackBar")
AddPropertyGridProgressBarGadget(#PropertyGrid, SectionID, "ProgressBar")
SetPropertyGridSectionItemGadgetState(#PropertyGrid, SectionID, 0, 1)
AddPropertyGridGadgetItems(#PropertyGrid, SectionID, 2, 0, "ComboBox Item 0")
AddPropertyGridGadgetItems(#PropertyGrid, SectionID, 2, 1, "ComboBox Item 1")
AddPropertyGridGadgetItems(#PropertyGrid, SectionID, 2, 2, "ComboBox Item 2")
AddPropertyGridGadgetItems(#PropertyGrid, SectionID, 2, 3, "ComboBox Item 3")
SetPropertyGridSectionItemGadgetState(#PropertyGrid, SectionID, 5, Random(90) + 5)
SetPropertyGridSectionItemGadgetState(#PropertyGrid, SectionID, 6, Random(90) + 5)
Next
HideWindow(0, #False)
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #PropertyGrid
Case GetPropertyGridSectionItemGadgetHandle(#PropertyGrid, 0, 0)
If GetPropertyGridSectionItemGadgetState(#PropertyGrid, 0, 0)
Debug "CheckBox Section 0 Item 1 (Is Visible)"
Else
Debug "CheckBox Section 0 Item 1 (Is not visible)"
EndIf
Default
CheckPropertyGridSectionClick(#PropertyGrid)
EndSelect
EndSelect
Until EventID = #PB_Event_CloseWindow
FreePropertyGridGadget(#PropertyGrid)
EndIf
; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<
This is a late post, but I like that OS_Select macro too, here's my alternative:Tenaja wrote:I like that OS_Select macro! Too bad PB does not allow this syntax
Code: Select all
; WLMO(Windows, Linux, Mac, Other) Macro
CompilerSelect (#PB_Compiler_OS)
CompilerCase #PB_OS_Windows
Macro WLMO(Windows, Linux, Mac, Other)
Windows
EndMacro
CompilerCase #PB_OS_Linux
Macro WLMO(Windows, Linux, Mac, Other)
Linux
EndMacro
CompilerCase #PB_OS_MacOS
Macro WLMO(Windows, Linux, Mac, Other)
Mac
EndMacro
CompilerDefault
Macro WLMO(Windows, Linux, Mac, Other)
Other
EndMacro
CompilerEndSelect
#PropertyGrid_DefaultItemHeight = WLMO(20, 22, 25, 20)
#PropertyGrid_SectionFontSize = WLMO(10, 10, 14, 12)
Debug WLMO("Windows", "Linux", "Mac", "Other") + " Constants:"
Debug #PropertyGrid_DefaultItemHeight
Debug #PropertyGrid_SectionFontSize
Apparently, it's impossible to re-use the same Gadget positioning calculation. The Danilo's original code on Linux Mint + Gnome-Shell all gadget appear lower inside their section space. I will see what I can do with this issue.Kwaï chang caïne wrote:Just for info an help..lines are cut
For example IsVisible is under Section04, but all do the same thing
Code: Select all
Procedure Private_RelocatePropertyGridSubItem(*PropertyGridSubItemA.PropertyGridSubItem, Index, Width, Height)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index, width >> 1 - 40, height - 1)
If IsGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA))
ResizeGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), width >> 1 - 19, Index, width >> 1 - 4, height - 1)
EndIf
CompilerCase #PB_OS_Linux
ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index - 12, width >> 1 - 40, height - 1)
If IsGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA))
ResizeGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), width >> 1 - 19, Index - 12, width >> 1 - 4, height - 1)
EndIf
CompilerCase #PB_OS_MacOS
ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index, width >> 1 - 40, height - 1)
If IsGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA))
ResizeGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), width >> 1 - 19, Index, width >> 1 - 4, height - 1)
EndIf
CompilerEndSelect
EndProcedure
Code: Select all
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : PropertyGridGadget
; File Name : PropertyGridGadget.pb
; File version: 1.0.1
; Programming : OK
; Programmed by : Guimauve
; Date : 09-10-2012
; Last Update : 11-10-2012
; PureBasic code : 5.00
; Platform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Programming notes :
;
; 1. This PropertyGrigGadget is based on the original work
; done by Danilo (PureBasic English Forum).
;
; 2. The CheckBoxGadget and the OptionGadget (Added) don't
; have a Description Gadget and Item Gadget. They are
; created has a Description gadget.
;
; 3. It possible to select Section and Item by Index number.
; Remember, Section Index number start at 0 and Item Index
; number start at 0 for each Section.
;
; 4. The Item creation outside a Section is no longer
; possible. (See "What is planned" about this point.)
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; What is planned (No date about when this will be added) :
;
; 1. PopupMenu to Open/Collapse/Lock/Unlock all Section.
;
; 2. A possibility to add 3-4 gadgets has item. (For the moment
; only 2 gadgets are possible.)
;
; 3. A better way to handle event and maybe Run User procedures
; on specific Gadgets events.
;
; 4. A possibility to add user Data to all items.
;
; 5. Restore the possibility to add Items without Section.
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Change for V1.0.1 :
;
; Removed : ClearPropertyGridGadgetSections()
; Added : DisablePropertyGridSubItem() --> "Private" Macro
; Added : ClearPropertyGridGadgetSection()
; Added : ClearPropertyGridGadget()
; Added : DisablePropertyGridGadgetSection()
; Added : AddPropertyGridTextGadget()
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
#PropertyGrid_SectionFont = "Arial"
#PropertyGrid_DefaultItemHeight = 20
#PropertyGrid_SectionFontSize = 10
CompilerCase #PB_OS_Linux
#PropertyGrid_SectionFont = "Mint Spirit"
#PropertyGrid_DefaultItemHeight = 30
#PropertyGrid_SectionFontSize = 10
CompilerCase #PB_OS_MacOS
#PropertyGrid_SectionFont = "Arial"
#PropertyGrid_DefaultItemHeight = 25
#PropertyGrid_SectionFontSize = 14
CompilerDefault ; future
#PropertyGrid_SectionFont = "Arial"
#PropertyGrid_DefaultItemHeight = 20
#PropertyGrid_SectionFontSize = 12
CompilerEndSelect
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Déclaration de la Structure <<<<<
Structure PropertyGridSubItem
DescriptionGadget.i
ItemGadget.i
EndStructure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les observateurs <<<<<
Macro GetPropertyGridSubItemDescriptionGadget(PropertyGridSubItemA)
PropertyGridSubItemA\DescriptionGadget
EndMacro
Macro GetPropertyGridSubItemItemGadget(PropertyGridSubItemA)
PropertyGridSubItemA\ItemGadget
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les mutateurs <<<<<
Macro SetPropertyGridSubItemDescriptionGadget(PropertyGridSubItemA, P_DescriptionGadget)
GetPropertyGridSubItemDescriptionGadget(PropertyGridSubItemA) = P_DescriptionGadget
EndMacro
Macro SetPropertyGridSubItemItemGadget(PropertyGridSubItemA, P_ItemGadget)
GetPropertyGridSubItemItemGadget(PropertyGridSubItemA) = P_ItemGadget
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Reset <<<<<
Macro ResetPropertyGridSubItem(PropertyGridSubItemA)
If IsGadget(GetPropertyGridSubItemDescriptionGadget(PropertyGridSubItemA))
FreeGadget(GetPropertyGridSubItemDescriptionGadget(PropertyGridSubItemA))
SetPropertyGridSubItemDescriptionGadget(PropertyGridSubItemA, 0)
EndIf
If IsGadget(GetPropertyGridSubItemItemGadget(PropertyGridSubItemA))
FreeGadget(GetPropertyGridSubItemItemGadget(PropertyGridSubItemA))
SetPropertyGridSubItemItemGadget(PropertyGridSubItemA, 0)
EndIf
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Disable <<<<<
Macro DisablePropertyGridSubItem(PropertyGridSubItemA, P_State)
If IsGadget(GetPropertyGridSubItemDescriptionGadget(PropertyGridSubItemA))
DisableGadget(GetPropertyGridSubItemDescriptionGadget(PropertyGridSubItemA), P_State)
EndIf
If IsGadget(GetPropertyGridSubItemItemGadget(PropertyGridSubItemA))
DisableGadget(GetPropertyGridSubItemItemGadget(PropertyGridSubItemA), P_State)
EndIf
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Code généré en : 00.004 secondes (17500.00 lignes/seconde) <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Déclaration de la Structure <<<<<
Structure PropertyGridItem
SectionDescriptionGadget.i
SectionButtonGadget.i
IsSection.i
Opened.i ; Special : Toggle
List SubItems.PropertyGridSubItem()
EndStructure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les observateurs <<<<<
Macro GetPropertyGridItemSectionDescriptionGadget(PropertyGridItemA)
PropertyGridItemA\SectionDescriptionGadget
EndMacro
Macro GetPropertyGridItemSectionButtonGadget(PropertyGridItemA)
PropertyGridItemA\SectionButtonGadget
EndMacro
Macro GetPropertyGridItemIsSection(PropertyGridItemA)
PropertyGridItemA\IsSection
EndMacro
Macro GetPropertyGridItemOpened(PropertyGridItemA)
PropertyGridItemA\Opened
EndMacro
Macro GetPropertyGridItemSubItems(PropertyGridItemA)
PropertyGridItemA\SubItems()
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les mutateurs <<<<<
Macro SetPropertyGridItemSectionDescriptionGadget(PropertyGridItemA, P_SectionDescriptionGadget)
GetPropertyGridItemSectionDescriptionGadget(PropertyGridItemA) = P_SectionDescriptionGadget
EndMacro
Macro SetPropertyGridItemSectionButtonGadget(PropertyGridItemA, P_SectionButtonGadget)
GetPropertyGridItemSectionButtonGadget(PropertyGridItemA) = P_SectionButtonGadget
EndMacro
Macro SetPropertyGridItemIsSection(PropertyGridItemA, P_IsSection)
GetPropertyGridItemIsSection(PropertyGridItemA) = P_IsSection
EndMacro
Macro SetPropertyGridItemOpened(PropertyGridItemA, P_Opened)
GetPropertyGridItemOpened(PropertyGridItemA) = P_Opened
EndMacro
Macro SetPropertyGridItemSubItems(PropertyGridItemA, P_SubItems)
CopyPropertyGridSubItem(P_SubItems, GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les macros complémentaires pour les Listes chaînées <<<<<
Macro AddPropertyGridItemSubItemsElement(PropertyGridItemA)
AddElement(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro AddPropertyGridItemSubItemsElementEx(PropertyGridItemA, P_Element)
AddElement(GetPropertyGridItemSubItems(PropertyGridItemA))
SetPropertyGridItemSubItems(PropertyGridItemA, P_Element)
EndMacro
Macro InsertPropertyGridItemSubItemsElement(PropertyGridItemA)
InsertElement(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro InsertPropertyGridItemSubItemsElementEx(PropertyGridItemA, P_Element)
InsertElement(GetPropertyGridItemSubItems(PropertyGridItemA))
SetPropertyGridItemSubItems(PropertyGridItemA, P_Element)
EndMacro
Macro SelectPropertyGridItemSubItemsElement(PropertyGridItemA, Position)
SelectElement(GetPropertyGridItemSubItems(PropertyGridItemA), Position)
EndMacro
Macro PreviousPropertyGridItemSubItemsElement(PropertyGridItemA)
PreviousElement(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro NextPropertyGridItemSubItemsElement(PropertyGridItemA)
NextElement(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro FirstPropertyGridItemSubItemsElement(PropertyGridItemA)
FirstElement(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro LastPropertyGridItemSubItemsElement(PropertyGridItemA)
LastElement(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro PopListPropertyGridItemSubItemsPosition(PropertyGridItemA)
PopListPosition(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro PushListPropertyGridItemSubItemsPosition(PropertyGridItemA)
PushListPosition(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro DeletePropertyGridItemSubItemsElement(PropertyGridItemA, Flag = 0)
DeleteElement(GetPropertyGridItemSubItems(PropertyGridItemA), Flag)
EndMacro
Macro ListPropertyGridItemSubItemsSize(PropertyGridItemA)
ListSize(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro ResetPropertyGridItemSubItemsList(PropertyGridItemA)
ResetList(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro ListPropertyGridItemSubItemsIndex(PropertyGridItemA)
ListIndex(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
Macro ClearPropertyGridItemSubItemsList(PropertyGridItemA)
ClearList(GetPropertyGridItemSubItems(PropertyGridItemA))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les opérateurs spéciaux <<<<<
Macro TogglePropertyGridItemOpened(PropertyGridItemA)
SetPropertyGridItemOpened(PropertyGridItemA, GetPropertyGridItemOpened(PropertyGridItemA) ! 1)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Reset <<<<<
Macro ResetPropertyGridItem(PropertyGridItemA)
If IsGadget(GetPropertyGridItemSectionDescriptionGadget(PropertyGridItemA))
FreeGadget(GetPropertyGridItemSectionDescriptionGadget(PropertyGridItemA))
SetPropertyGridItemSectionDescriptionGadget(PropertyGridItemA, 0)
EndIf
If IsGadget(GetPropertyGridItemSectionButtonGadget(PropertyGridItemA))
FreeGadget(GetPropertyGridItemSectionButtonGadget(PropertyGridItemA))
SetPropertyGridItemSectionButtonGadget(PropertyGridItemA, 0)
EndIf
SetPropertyGridItemIsSection(PropertyGridItemA, 0)
SetPropertyGridItemOpened(PropertyGridItemA, 0)
ForEach GetPropertyGridItemSubItems(PropertyGridItemA)
ResetPropertyGridSubItem(GetPropertyGridItemSubItems(PropertyGridItemA))
Next
ClearPropertyGridItemSubItemsList(PropertyGridItemA)
ClearStructure(PropertyGridItemA, PropertyGridItem)
InitializeStructure(PropertyGridItemA, PropertyGridItem)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Code généré en : 00.012 secondes (19000.00 lignes/seconde) <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Déclaration de la Structure <<<<<
Structure PropertyGridData
ItemHeight.i
Font.i
BackColor.l
FrontColor.l
List Items.PropertyGridItem()
EndStructure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les observateurs <<<<<
Macro GetPropertyGridDataItemHeight(PropertyGridDataA)
PropertyGridDataA\ItemHeight
EndMacro
Macro GetPropertyGridDataFont(PropertyGridDataA)
PropertyGridDataA\Font
EndMacro
Macro GetPropertyGridDataBackColor(PropertyGridDataA)
PropertyGridDataA\BackColor
EndMacro
Macro GetPropertyGridDataFrontColor(PropertyGridDataA)
PropertyGridDataA\FrontColor
EndMacro
Macro GetPropertyGridDataItems(PropertyGridDataA)
PropertyGridDataA\Items()
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les mutateurs <<<<<
Macro SetPropertyGridDataItemHeight(PropertyGridDataA, P_ItemHeight)
GetPropertyGridDataItemHeight(PropertyGridDataA) = P_ItemHeight
EndMacro
Macro SetPropertyGridDataFont(PropertyGridDataA, P_Font)
GetPropertyGridDataFont(PropertyGridDataA) = P_Font
EndMacro
Macro SetPropertyGridDataBackColor(PropertyGridDataA, P_BackColor)
GetPropertyGridDataBackColor(PropertyGridDataA) = P_BackColor
EndMacro
Macro SetPropertyGridDataFrontColor(PropertyGridDataA, P_FrontColor)
GetPropertyGridDataFrontColor(PropertyGridDataA) = P_FrontColor
EndMacro
Macro SetPropertyGridDataItems(PropertyGridDataA, P_Items)
CopyPropertyGridItem(P_Items, GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les macros complémentaires pour les Listes chaînées <<<<<
Macro AddPropertyGridDataItemsElement(PropertyGridDataA)
AddElement(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro AddPropertyGridDataItemsElementEx(PropertyGridDataA, P_Element)
AddElement(GetPropertyGridDataItems(PropertyGridDataA))
SetPropertyGridDataItems(PropertyGridDataA, P_Element)
EndMacro
Macro InsertPropertyGridDataItemsElement(PropertyGridDataA)
InsertElement(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro InsertPropertyGridDataItemsElementEx(PropertyGridDataA, P_Element)
InsertElement(GetPropertyGridDataItems(PropertyGridDataA))
SetPropertyGridDataItems(PropertyGridDataA, P_Element)
EndMacro
Macro SelectPropertyGridDataItemsElement(PropertyGridDataA, Position)
SelectElement(GetPropertyGridDataItems(PropertyGridDataA), Position)
EndMacro
Macro PreviousPropertyGridDataItemsElement(PropertyGridDataA)
PreviousElement(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro NextPropertyGridDataItemsElement(PropertyGridDataA)
NextElement(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro FirstPropertyGridDataItemsElement(PropertyGridDataA)
FirstElement(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro LastPropertyGridDataItemsElement(PropertyGridDataA)
LastElement(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro PopListPropertyGridDataItemsPosition(PropertyGridDataA)
PopListPosition(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro PushListPropertyGridDataItemsPosition(PropertyGridDataA)
PushListPosition(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro DeletePropertyGridDataItemsElement(PropertyGridDataA, Flag = 0)
DeleteElement(GetPropertyGridDataItems(PropertyGridDataA), Flag)
EndMacro
Macro ListPropertyGridDataItemsSize(PropertyGridDataA)
ListSize(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro ResetPropertyGridDataItemsList(PropertyGridDataA)
ResetList(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro ListPropertyGridDataItemsIndex(PropertyGridDataA)
ListIndex(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
Macro ClearPropertyGridDataItemsList(PropertyGridDataA)
ClearList(GetPropertyGridDataItems(PropertyGridDataA))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Reset <<<<<
Macro ResetPropertyGridData(PropertyGridDataA)
SetPropertyGridDataItemHeight(PropertyGridDataA, 0)
If IsFont(GetPropertyGridDataFont(PropertyGridDataA))
FreeFont(GetPropertyGridDataFont(PropertyGridDataA))
SetPropertyGridDataFont(PropertyGridDataA, 0)
EndIf
SetPropertyGridDataBackColor(PropertyGridDataA, 0)
SetPropertyGridDataFrontColor(PropertyGridDataA, 0)
ForEach GetPropertyGridDataItems(PropertyGridDataA)
ResetPropertyGridItem(GetPropertyGridDataItems(PropertyGridDataA))
Next
ClearPropertyGridDataItemsList(PropertyGridDataA)
ClearStructure(PropertyGridDataA, PropertyGridData)
InitializeStructure(PropertyGridDataA, PropertyGridData)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Code généré en : 00.014 secondes (15642.86 lignes/seconde) <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Procedure Private_PropertyGrid_OpenClose_Image(IsOpen.b)
Static OpenImage.i, CloseImage.i, OneShot.b
If OneShot = #False
OpenImage = CreateImage(#PB_Any, 11, 11, 32)
If OpenImage And StartDrawing(ImageOutput(OpenImage))
Box(0, 0, 11, 11, RGB($FF, $FF, $FF))
DrawingMode(#PB_2DDrawing_Outlined)
Box(0, 0, 11, 11, RGB($00, $00, $00))
LineXY(2, 5, 8, 5, RGB($00, $00, $00))
StopDrawing()
EndIf
CloseImage = CreateImage(#PB_Any, 11, 11, 32)
If CloseImage And StartDrawing(ImageOutput(CloseImage))
Box(0,0,11,11,RGB($FF,$FF,$FF))
DrawingMode(#PB_2DDrawing_Outlined)
Box(0,0,11,11,RGB($00,$00,$00))
LineXY(2,5,8,5,RGB($00,$00,$00))
LineXY(5,2,5,8,RGB($00,$00,$00))
StopDrawing()
EndIf
OneShot = #True
EndIf
If IsOpen
ProcedureReturn OpenImage
Else
ProcedureReturn CloseImage
EndIf
EndProcedure
Procedure Private_HidePropertyGridSubItem(*PropertyGridSubItemA.PropertyGridSubItem, IsOpen.b)
HideGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 1 - IsOpen)
If IsGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA))
HideGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), 1 - IsOpen)
EndIf
EndProcedure
Procedure Private_RelocatePropertyGridSubItem(*PropertyGridSubItemA.PropertyGridSubItem, Index, Width, Height)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index, width >> 1 - 40, height - 1)
If IsGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA))
ResizeGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), width >> 1 - 19, Index, width >> 1 - 4, height - 1)
EndIf
CompilerCase #PB_OS_Linux
ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index - 12, width >> 1 - 40, height - 1)
If IsGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA))
ResizeGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), width >> 1 - 19, Index - 12, width >> 1 - 4, height - 1)
EndIf
CompilerCase #PB_OS_MacOS
ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index, width >> 1 - 40, height - 1)
If IsGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA))
ResizeGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), width >> 1 - 19, Index, width >> 1 - 4, height - 1)
EndIf
CompilerEndSelect
EndProcedure
Procedure Private_RelocatePropertyGridItem(*PropertyGridItemA.PropertyGridItem, Index, Width, Height)
If GetPropertyGridItemIsSection(*PropertyGridItemA)
ResizeGadget(GetPropertyGridItemSectionDescriptionGadget(*PropertyGridItemA), 20, Index, Width - 20, Height - 1)
ResizeGadget(GetPropertyGridItemSectionButtonGadget(*PropertyGridItemA), 4, Index + Height >> 1 - 12, 11, 11)
Else
ResizeGadget(GetPropertyGridItemSectionDescriptionGadget(*PropertyGridItemA), 20, Index, Width >> 1 - 40, Height - 1)
ResizeGadget(GetPropertyGridItemSectionButtonGadget(*PropertyGridItemA), Width >> 1 - 19, Index, Width >> 1 - 4, Height - 1)
EndIf
Index + Height
If GetPropertyGridItemOpened(*PropertyGridItemA) = #True
ForEach GetPropertyGridItemSubItems(*PropertyGridItemA)
Private_RelocatePropertyGridSubItem(GetPropertyGridItemSubItems(*PropertyGridItemA), Index, Width, Height)
Index + Height
Next
EndIf
ProcedureReturn Index
EndProcedure
Procedure Private_Create_PropertyGridItem(*PropertyGridItemA.PropertyGridItem, SectionName.s, Width, Height, FrontColor, BackColor, IsOpen.b, FontID)
SetPropertyGridItemSectionDescriptionGadget(*PropertyGridItemA, TextGadget(#PB_Any, 20, 0, width - 20, height, SectionName))
SetPropertyGridItemSectionButtonGadget(*PropertyGridItemA, ImageGadget(#PB_Any,0,0,0,0,ImageID(Private_PropertyGrid_OpenClose_Image(IsOpen))))
SetPropertyGridItemIsSection(*PropertyGridItemA, #True)
SetPropertyGridItemOpened(*PropertyGridItemA, IsOpen)
SetGadgetFont(GetPropertyGridItemSectionDescriptionGadget(*PropertyGridItemA), FontID(FontID))
If BackColor <> -1
SetGadgetColor(GetPropertyGridItemSectionDescriptionGadget(*PropertyGridItemA), #PB_Gadget_BackColor, BackColor)
EndIf
If FrontColor <> -1
SetGadgetColor(GetPropertyGridItemSectionDescriptionGadget(*PropertyGridItemA), #PB_Gadget_FrontColor, FrontColor)
EndIf
EndProcedure
Procedure Private_Update_PropertyGrid(PropertyGridID)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
Index = 0
height = GetPropertyGridDataItemHeight(*PropertyGridDataA)
width = GadgetWidth(PropertyGridID)
ForEach GetPropertyGridDataItems(*PropertyGridDataA)
Index = Private_RelocatePropertyGridItem(GetPropertyGridDataItems(*PropertyGridDataA), Index, Width, Height)
Next
If GetGadgetAttribute(PropertyGridID, #PB_ScrollArea_InnerHeight) <> Index
SetGadgetAttribute(PropertyGridID, #PB_ScrollArea_InnerHeight, Index)
EndIf
If GetGadgetAttribute(PropertyGridID, #PB_ScrollArea_InnerWidth) <> width - 20
SetGadgetAttribute(PropertyGridID, #PB_ScrollArea_InnerWidth, width - 20)
EndIf
EndIf
EndProcedure
Procedure Private_PropertyGridItem_EventManagement(*PropertyGridDataA.PropertyGridData, *PropertyGridItemA.PropertyGridItem)
If EventGadget() = GetPropertyGridItemSectionButtonGadget(*PropertyGridItemA) And EventType() = #PB_EventType_LeftClick
TogglePropertyGridItemOpened(GetPropertyGridDataItems(*PropertyGridDataA))
SetGadgetState(GetPropertyGridItemSectionButtonGadget(*PropertyGridItemA), ImageID(Private_PropertyGrid_OpenClose_Image(GetPropertyGridItemOpened(*PropertyGridItemA))))
ForEach GetPropertyGridItemSubItems(*PropertyGridItemA)
Private_HidePropertyGridSubItem(GetPropertyGridItemSubItems(*PropertyGridItemA), GetPropertyGridItemOpened(*PropertyGridItemA))
Next
SomethingHappen.b = #True
EndIf
ProcedureReturn SomethingHappen
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les commandes à utiliser partout <<<<<
Procedure PropertyGridGadget(PropertyGridID, x, y, Width, Height, FrontColor.l = -1, BackColor.l = -1, Flags = #PB_ScrollArea_Flat)
GadgetHandle = ScrollAreaGadget(PropertyGridID, x, y, Width, Height, Width - 20, 1, #PropertyGrid_DefaultItemHeight, Flags)
If GadgetHandle
If PropertyGridID = #PB_Any
PropertyGridID = GadgetHandle
EndIf
If FrontColor <> -1
SetGadgetColor(PropertyGridID, #PB_Gadget_FrontColor, FrontColor)
EndIf
If BackColor <> -1
SetGadgetColor(PropertyGridID, #PB_Gadget_BackColor, BackColor)
EndIf
*PropertyGridDataA.PropertyGridData = AllocateMemory(SizeOf(PropertyGridData))
If *PropertyGridDataA = #Null
FreeGadget(PropertyGridID)
ProcedureReturn 0
EndIf
InitializeStructure(*PropertyGridDataA, PropertyGridData)
SetPropertyGridDataItemHeight(*PropertyGridDataA, #PropertyGrid_DefaultItemHeight)
SetPropertyGridDataFont(*PropertyGridDataA, LoadFont(#PB_Any, #PropertyGrid_SectionFont, #PropertyGrid_SectionFontSize, #PB_Font_Bold))
SetPropertyGridDataBackColor(*PropertyGridDataA, BackColor)
SetPropertyGridDataFrontColor(*PropertyGridDataA, FrontColor)
SetGadgetData(PropertyGridID, *PropertyGridDataA)
CloseGadgetList()
EndIf
ProcedureReturn PropertyGridID
EndProcedure
Procedure AddPropertyGridSection(PropertyGridID, SectionName.s, IsOpen.b = #True)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
LastPropertyGridDataItemsElement(*PropertyGridDataA)
If AddPropertyGridDataItemsElement(*PropertyGridDataA)
InitializeStructure(GetPropertyGridDataItems(*PropertyGridDataA), PropertyGridItem)
OpenGadgetList(PropertyGridID)
Private_Create_PropertyGridItem(GetPropertyGridDataItems(*PropertyGridDataA), SectionName, GadgetWidth(PropertyGridID), GetPropertyGridDataItemHeight(*PropertyGridDataA), GetPropertyGridDataFrontColor(*PropertyGridDataA), GetPropertyGridDataBackColor(*PropertyGridDataA), IsOpen, GetPropertyGridDataFont(*PropertyGridDataA))
CloseGadgetList()
Private_Update_PropertyGrid(PropertyGridID)
ProcedureReturn #True
EndIf
EndIf
EndProcedure
Procedure CheckPropertyGridSectionClick(PropertyGridID)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
ForEach GetPropertyGridDataItems(*PropertyGridDataA)
If Private_PropertyGridItem_EventManagement(*PropertyGridDataA, GetPropertyGridDataItems(*PropertyGridDataA))
Private_Update_PropertyGrid(PropertyGridID)
Break
EndIf
Next
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure SetPropertyGridSectionName(PropertyGridID, SectionNo, SectionName.s)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
SetGadgetText(GetPropertyGridItemSectionDescriptionGadget(GetPropertyGridDataItems(*PropertyGridDataA)), SectionName)
EndIf
EndIf
EndIf
EndProcedure
Procedure.s GetPropertyGridSectionName(PropertyGridID, SectionNo)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
ProcedureReturn GetGadgetText(GetPropertyGridItemSectionDescriptionGadget(GetPropertyGridDataItems(*PropertyGridDataA)))
EndIf
EndIf
EndIf
EndProcedure
Procedure SetPropertyGridSectionItemDescription(PropertyGridID, SectionNo, ItemNo, Description.s)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
If ItemNo >= 0 And ItemNo <= ListPropertyGridItemSubItemsSize(GetPropertyGridDataItems(*PropertyGridDataA)) - 1
If SelectPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA), ItemNo)
If IsGadget(GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
SetGadgetText(GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))), Description)
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndProcedure
Procedure SetPropertyGridSectionItemContent(PropertyGridID, SectionNo, ItemNo, Content.s)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
If ItemNo >= 0 And ItemNo <= ListPropertyGridItemSubItemsSize(GetPropertyGridDataItems(*PropertyGridDataA)) - 1
If SelectPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA), ItemNo)
If IsGadget(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
SetGadgetText(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))), Content)
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndProcedure
Procedure.s GetPropertyGridSectionItemContent(PropertyGridID, SectionNo, ItemNo)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
If ItemNo >= 0 And ItemNo <= ListPropertyGridItemSubItemsSize(GetPropertyGridDataItems(*PropertyGridDataA)) - 1
If SelectPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA), ItemNo)
If IsGadget(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
ProcedureReturn GetGadgetText(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndProcedure
Procedure SetPropertyGridSectionItemGadgetState(PropertyGridID, SectionNo, ItemNo, State)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
If ItemNo >= 0 And ItemNo <= ListPropertyGridItemSubItemsSize(GetPropertyGridDataItems(*PropertyGridDataA)) - 1
If SelectPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA), ItemNo)
If GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))) = -1
If IsGadget(GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
SetGadgetState(GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))), State)
ProcedureReturn 1
Else
ProcedureReturn -1
EndIf
Else
If IsGadget(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
SetGadgetState(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))), State)
ProcedureReturn 1
Else
ProcedureReturn -1
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndProcedure
Procedure GetPropertyGridSectionItemGadgetHandle(PropertyGridID, SectionNo, ItemNo)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
If ItemNo >= 0 And ItemNo <= ListPropertyGridItemSubItemsSize(GetPropertyGridDataItems(*PropertyGridDataA)) - 1
If SelectPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA), ItemNo)
If GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))) = -1
If IsGadget(GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
ProcedureReturn GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)))
Else
ProcedureReturn -1
EndIf
Else
If IsGadget(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
ProcedureReturn GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)))
Else
ProcedureReturn -1
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndProcedure
Procedure GetPropertyGridSectionItemGadgetState(PropertyGridID, SectionNo, ItemNo)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
If ItemNo >= 0 And ItemNo <= ListPropertyGridItemSubItemsSize(GetPropertyGridDataItems(*PropertyGridDataA)) - 1
If SelectPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA), ItemNo)
If GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))) = -1
If IsGadget(GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
ProcedureReturn GetGadgetState(GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
Else
ProcedureReturn -1
EndIf
Else
If IsGadget(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
ProcedureReturn GetGadgetState(GetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))))
Else
ProcedureReturn -1
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndProcedure
Procedure GetPropertyGridSectionCount(PropertyGridID)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
SectionCount.l = -1
If *PropertyGridDataA <> #Null
SectionCount = ListPropertyGridDataItemsSize(*PropertyGridDataA)
EndIf
ProcedureReturn SectionCount
EndProcedure
Procedure AddPropertyGridStringGadget(PropertyGridID, SectionNo, Description.s = "", Content.s = "", Flags = 0)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), StringGadget(#PB_Any, 0, 0, 0, 0, Description, #PB_String_ReadOnly))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), StringGadget(#PB_Any, 0, 0, 0, 0, Content, Flags))
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure AddPropertyGridButtonGadget(PropertyGridID, SectionNo, Description.s = "", Content.s = "", Flags = 0)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), StringGadget(#PB_Any, 0, 0, 0, 0, Description, #PB_String_ReadOnly))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), ButtonGadget(#PB_Any, 0, 0, 0, 0, Content, Flags))
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure AddPropertyGridCheckBoxGadget(PropertyGridID, SectionNo, Description.s = "", Flags = 0)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), CheckBoxGadget(#PB_Any, 0, 0, 0, 0, Description, Flags))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), -1)
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure AddPropertyGridOptionGadget(PropertyGridID, SectionNo, Description.s = "")
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), OptionGadget(#PB_Any, 0, 0, 0, 0, Description))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), -1)
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure AddPropertyGridTextGadget(PropertyGridID, SectionNo, Description.s = "", Flags = 0)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), TextGadget(#PB_Any, 0, 0, 0, 0, Description, Flags))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), -1)
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure AddPropertyGridComboBoxGadget(PropertyGridID, SectionNo, Description.s = "", Flags = 0)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), StringGadget(#PB_Any, 0, 0, 0, 0, Description, #PB_String_ReadOnly))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), ComboBoxGadget(#PB_Any, 0, 0, 0, 0, Flags))
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure AddPropertyGridGadgetItems(PropertyGridID, SectionNo, ItemNo, Position, Text.s)
GadgetHandle = GetPropertyGridSectionItemGadgetHandle(PropertyGridID, SectionNo, ItemNo)
If IsGadget(GadgetHandle)
AddGadgetItem(GadgetHandle, Position, Text)
EndIf
EndProcedure
Procedure AddPropertyGridSpinGadget(PropertyGridID, SectionNo, Description.s = "", Minimum = 0, Maximum = 100, Flags = #PB_Spin_Numeric | #PB_Spin_ReadOnly)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), StringGadget(#PB_Any, 0, 0, 0, 0, Description, #PB_String_ReadOnly))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), SpinGadget(#PB_Any, 0, 0, 0, 0, Minimum, Maximum, Flags))
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure AddPropertyGridTrackBarGadget(PropertyGridID, SectionNo, Description.s = "", Minimum = 0, Maximum = 100, Flags = #PB_TrackBar_Ticks)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), StringGadget(#PB_Any, 0, 0, 0, 0, Description, #PB_String_ReadOnly))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), TrackBarGadget(#PB_Any, 0, 0, 0, 0, Minimum, Maximum, Flags))
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure AddPropertyGridProgressBarGadget(PropertyGridID, SectionNo, Description.s = "", Minimum = 0, Maximum = 100, Flags = #PB_ProgressBar_Smooth)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
OpenGadgetList(PropertyGridID)
SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), StringGadget(#PB_Any, 0, 0, 0, 0, Description, #PB_String_ReadOnly))
SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), ProgressBarGadget(#PB_Any, 0, 0, 0, 0, Minimum, Maximum, Flags))
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure DisablePropertyGridGadgetSection(PropertyGridID, SectionNo, State)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
OpenGadgetList(PropertyGridID)
ForEach GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))
DisablePropertyGridSubItem(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), State)
Next
CloseGadgetList()
EndIf
EndIf
EndIf
EndProcedure
Procedure ClearPropertyGridGadgetSection(PropertyGridID, SectionNo)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
OpenGadgetList(PropertyGridID)
ForEach GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA))
ResetPropertyGridSubItem(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)))
Next
ClearPropertyGridItemSubItemsList(GetPropertyGridDataItems(*PropertyGridDataA))
CloseGadgetList()
EndIf
EndIf
Private_Update_PropertyGrid(PropertyGridID)
EndIf
EndProcedure
Procedure ClearPropertyGridGadget(PropertyGridID)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
ForEach GetPropertyGridDataItems(*PropertyGridDataA)
ResetPropertyGridItem(GetPropertyGridDataItems(*PropertyGridDataA))
Next
ClearPropertyGridDataItemsList(*PropertyGridDataA)
InitializeStructure(*PropertyGridDataA, PropertyGridData)
EndIf
EndProcedure
Procedure FreePropertyGridGadget(PropertyGridID)
*PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
If *PropertyGridDataA <> #Null
ResetPropertyGridData(*PropertyGridDataA)
FreeMemory(*PropertyGridDataA)
FreeGadget(PropertyGridID)
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< !!! WARNING - YOU ARE NOW IN A TESTING ZONE - WARNING !!! <<<<<
; <<<<< !!! WARNING - THIS CODE SHOULD BE COMMENTED - WARNING !!! <<<<<
; <<<<< !!! WARNING - BEFORE THE FINAL COMPILATION. - WARNING !!! <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Enumeration
#PropertyGrid
#Btn_Clear_Section
EndEnumeration
If OpenWindow(0,0,0,800,600,"PropertyGrid",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
HideWindow(0, #True)
PropertyGridGadget(#PropertyGrid, 5, 5, 390, 500)
ButtonGadget(#Btn_Clear_Section, 5, 510,150,30, "Clear Section 2")
For SectionID = 0 To 5
AddPropertyGridSection(#PropertyGrid, "Section 0" + Str(SectionID))
AddPropertyGridCheckBoxGadget(#PropertyGrid, SectionID, "Is Visible")
AddPropertyGridStringGadget(#PropertyGrid, SectionID, "String", "Enter a text here !")
AddPropertyGridComboBoxGadget(#PropertyGrid, SectionID, "ComboBox")
AddPropertyGridButtonGadget(#PropertyGrid, SectionID, "Button", "Button 0" + Str(SectionID))
AddPropertyGridSpinGadget(#PropertyGrid, SectionID, "SpinGadget", 0, 15)
AddPropertyGridTrackBarGadget(#PropertyGrid, SectionID, "TrackBar")
AddPropertyGridProgressBarGadget(#PropertyGrid, SectionID, "ProgressBar")
SetPropertyGridSectionItemGadgetState(#PropertyGrid, SectionID, 0, 1)
AddPropertyGridGadgetItems(#PropertyGrid, SectionID, 2, 0, "ComboBox Item 0")
AddPropertyGridGadgetItems(#PropertyGrid, SectionID, 2, 1, "ComboBox Item 1")
AddPropertyGridGadgetItems(#PropertyGrid, SectionID, 2, 2, "ComboBox Item 2")
AddPropertyGridGadgetItems(#PropertyGrid, SectionID, 2, 3, "ComboBox Item 3")
SetPropertyGridSectionItemGadgetState(#PropertyGrid, SectionID, 5, Random(90) + 5)
SetPropertyGridSectionItemGadgetState(#PropertyGrid, SectionID, 6, Random(90) + 5)
Next
HideWindow(0, #False)
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #PropertyGrid
Case #Btn_Clear_Section
ClearPropertyGridGadgetSection(#PropertyGrid, 2)
Case GetPropertyGridSectionItemGadgetHandle(#PropertyGrid, 0, 0)
If GetPropertyGridSectionItemGadgetState(#PropertyGrid, 0, 0)
Debug "CheckBox Section 0 Item 1 (Is Visible)"
Else
Debug "CheckBox Section 0 Item 1 (Is not visible)"
EndIf
Default
CheckPropertyGridSectionClick(#PropertyGrid)
EndSelect
EndSelect
Until EventID = #PB_Event_CloseWindow
FreePropertyGridGadget(#PropertyGrid)
EndIf
; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<