SplitterGadget
Posted: Thu Apr 10, 2025 8:09 am
How to change the size of Splittergadget () between the panels, by default, is made equally?
Code: Select all
OpenWindow(0, 100, 100, 400, 300, "Splitter Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StringGadget(1, 0, 0, 0, 0, "Left Panel", #PB_Text_Center)
StringGadget(2, 0, 0, 0, 0, "Right Panel", #PB_Text_Center)
SplitterGadget(3, 10, 10, 380, 180, 1, 2, #PB_Splitter_Vertical)
SetGadgetState(3, 80)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
What? Of course it is. To modify firace's example:
Code: Select all
width = Random(380,200) ; Choose a random width between 200 and 380 pixels.
OpenWindow(0, 300, 300, 400, 200, "Splitter Example", #PB_Window_Invisible | #PB_Window_SystemMenu)
StringGadget(1, 0, 0, 0, 0, "Left", #PB_Text_Center)
StringGadget(2, 0, 0, 0, 0, "Right", #PB_Text_Center)
SplitterGadget(3, 10, 10, width, 180, 1, 2, #PB_Splitter_Vertical)
SetGadgetState(3, (width/2)-3)
ResizeWindow(0, #PB_Ignore, #PB_Ignore, width+20, #PB_Ignore)
HideWindow(0, #False)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Oh, I see what you mean (the splitter itself). I've never looked into that. But since he said "equally", that can only mean between two or more parts, so I assume he meant for it to be exactly in the middle of the two StringGadgets.
Code: Select all
OpenWindow(0, 100, 100, 400, 300, "Splitter Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ContainerGadget(1,10,32, 200,300, #PB_Container_Raised)
ListViewGadget(2, 0, 0, 0, 60)
EditorGadget(3, 0, 65, 0, 125)
ListViewGadget(4, 0, 65, 0, 125)
CloseGadgetList()
HideGadget(4,#True)
ButtonGadget(100,50,200,100,10,"button")
For i=1 To 30
AddGadgetItem(2,-1,"LIST-1 VISIBLE"+Str(i))
Next i
For i=1 To 30
AddGadgetItem(3,-1,"EDITOR! VISIBLE"+Str(i))
Next i
For i=1 To 30
AddGadgetItem(4,-1,"LIST-2 VISIBLE"+Str(i))
Next i
SplitterGadget(7, 10, 10, 380, 180, 2, 4)
SplitterGadget(8, 10, 10, 380, 180, 2, 3)
SetGadgetState(3, 20)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 100:
HideGadget(4,#False)
HideGadget(3,#True)
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow