Page 1 of 1

TreeGadget resizing

Posted: Tue Oct 10, 2017 1:19 pm
by Machiavelli
Hello

I have a window with one TreeGadget on the left, second TreeGadget on the right, and the PanelGadget between them (so i can't use splittergadget)
Is there any way to make treegadgets resizeable with mouse? (only horizontally)
I've tried to detect mouse clicks over the edge of the gadget and then resizing it but it didn't really work.

Re: TreeGadget resizing

Posted: Tue Oct 10, 2017 1:59 pm
by RASHAD
No you can use SplitterGadget

Code: Select all

flags = #PB_Window_SystemMenu| #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered
OpenWindow(0,0,0,600,400,"Test",Flags)
cont = ContainerGadget(#PB_Any,10,10,580,380,#PB_Container_Flat)
  tree1 = TreeGadget(#PB_Any,0,0,0,0)
  For a = 0 To 100
   AddGadgetItem(tree1, -1, "Elément normal "+Str(a), 0, 0)
  Next
  panel = PanelGadget(#PB_Any,0,0,0,0)  
    AddGadgetItem (panel, -1, "Panel 1")
  CloseGadgetList()
  split = SplitterGadget(#PB_Any,0,0,580,380,tree1,panel, #PB_Splitter_Separator|#PB_Splitter_Vertical )  
CloseGadgetList()
SetGadgetState(split, 200)
tree2 = TreeGadget(#PB_Any,0,0,0,0)
For a = 0 To 100
 AddGadgetItem(tree2, -1, "Elément normal "+Str(a), 0, 0)
Next
split2 = SplitterGadget(#PB_Any,10,10,580,380,cont,tree2, #PB_Splitter_Separator|#PB_Splitter_Vertical )
SetGadgetState(split2, 400)   

Repeat
           
  Select WaitWindowEvent()      
    Case #PB_Event_CloseWindow
        Quit = 1
  EndSelect
Until Quit = 1
End
Edit :Modified

Re: TreeGadget resizing

Posted: Tue Oct 10, 2017 2:34 pm
by spikey
If you don't want to use two splitters, as Rashad shows, then you could also:-

1) Use a canvas gadget as a container and process the #PB_EventType_LeftButtonDown and #PB_EventType_LeftButtonUp events.
2) Use a window callback procedure to process the #WM_LBUTTONDOWN and #WM_LBUTTONUP messages.

In either case you would need to range test the X and Y co-ordinates to determine which gap had been clicked in the button down and the new gadget dimensions in the button up.