Req.: Autoresize Gadgets to parent- or Containergadget
Posted: Sun Jul 24, 2016 8:52 pm
It would be nice, if each side of a gadget (top, left, right, bottom side) can made "sticky" to the parent gadget (e.g. container, splitter (the width) or window). Just as it's actually working with the SplitterGadget().
In my example you see one vertical SplitterGadget. Within this SplitterGadget are handled two horizontal Splittergadgets. Within this horizontal Spilttergadgets there is a Conatainergadget (one each SplitterGadget). Within the Containers there are a TextGadget and an EditorGadget.
Actually we have to perfom resizing action for all four Container- and all four EditorGadgets.
It would be very nice, if a Gadget can have a parameter like "#PB_StickToParent" for x, y, width als height, to stick the boundaries to the parent Gadget or to the Window, if no parent Gadget is available.
Btw: with the actual (manual) resizing solution the Gadgets are flickering like hell each time we resize the window or drag the splitters. Even if we use SmartWindowRefresh().
In my example you see one vertical SplitterGadget. Within this SplitterGadget are handled two horizontal Splittergadgets. Within this horizontal Spilttergadgets there is a Conatainergadget (one each SplitterGadget). Within the Containers there are a TextGadget and an EditorGadget.
Actually we have to perfom resizing action for all four Container- and all four EditorGadgets.
It would be very nice, if a Gadget can have a parameter like "#PB_StickToParent" for x, y, width als height, to stick the boundaries to the parent Gadget or to the Window, if no parent Gadget is available.
Btw: with the actual (manual) resizing solution the Gadgets are flickering like hell each time we resize the window or drag the splitters. Even if we use SmartWindowRefresh().
Code: Select all
Global Window_Main
Global Window_Main_Container_TopLeft
Global Window_Main_Text_TopLeft
Global Window_Main_Editor_TopLeft
Global Window_Main_Container_BottomLeft
Global Window_Main_Text_BottomLeft
Global Window_Main_Editor_BottomLeft
Global Window_Main_Splitter_Left
Global Window_Main_Container_TopRight
Global Window_Main_Text_TopRight
Global Window_Main_Editor_TopRight
Global Window_Main_Container_BottomRight
Global Window_Main_Text_BottomRight
Global Window_Main_Editor_BottomRight
Global Window_Main_Splitter_Right
Global Window_Main_Splitter_Middle
Procedure Main_SizeWindowHandler()
ResizeGadget(Window_Main_Splitter_Middle, #PB_Ignore, #PB_Ignore, WindowWidth(Window_Main)-10, WindowHeight(Window_Main)-10)
; Wieso auch den Container anpassen?
ResizeGadget(Window_Main_Container_TopLeft, #PB_Ignore, #PB_Ignore, GadgetWidth(Window_Main_Splitter_Left), #PB_Ignore)
ResizeGadget(Window_Main_Container_BottomLeft, #PB_Ignore, #PB_Ignore, GadgetWidth(Window_Main_Splitter_Left), #PB_Ignore)
ResizeGadget(Window_Main_Editor_TopLeft, #PB_Ignore, #PB_Ignore, GadgetWidth(Window_Main_Container_TopLeft), GadgetHeight(Window_Main_Container_TopLeft)-15)
ResizeGadget(Window_Main_Editor_BottomLeft, #PB_Ignore, #PB_Ignore, GadgetWidth(Window_Main_Container_BottomLeft), GadgetHeight(Window_Main_Container_BottomLeft)-15)
ResizeGadget(Window_Main_Container_TopRight, #PB_Ignore, #PB_Ignore, GadgetWidth(Window_Main_Splitter_Right), #PB_Ignore)
ResizeGadget(Window_Main_Container_BottomRight, #PB_Ignore, #PB_Ignore, GadgetWidth(Window_Main_Splitter_Right), #PB_Ignore)
ResizeGadget(Window_Main_Editor_TopRight, #PB_Ignore, #PB_Ignore, GadgetWidth(Window_Main_Container_TopRight), GadgetHeight(Window_Main_Container_TopRight)-15)
ResizeGadget(Window_Main_Editor_BottomRight, #PB_Ignore, #PB_Ignore, GadgetWidth(Window_Main_Container_BottomRight), GadgetHeight(Window_Main_Container_BottomRight)-15)
EndProcedure
Window_Main = OpenWindow(#PB_Any, #PB_Ignore, #PB_Ignore, 1015, 420, "", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered)
If Window_Main
Window_Main_Container_TopLeft = ContainerGadget(#PB_Any, 0, 0, 0, 0)
Window_Main_Text_TopLeft = TextGadget(#PB_Any, 0, 0, 105, 15, "Top Left")
Window_Main_Editor_TopLeft = EditorGadget(#PB_Any, 0, 15, 500, 185, #PB_Editor_ReadOnly)
CloseGadgetList()
Window_Main_Container_BottomLeft = ContainerGadget(#PB_Any, 0, 0, 0, 0)
Window_Main_Text_BottomLeft = TextGadget(#PB_Any, 0, 0, 105, 15, "Bottom Left")
Window_Main_Editor_BottomLeft = EditorGadget(#PB_Any, 0, 15, 500, 185)
CloseGadgetList()
Window_Main_Splitter_Left = SplitterGadget(#PB_Any, 5, 5, 500, 415, Window_Main_Container_TopLeft, Window_Main_Container_BottomLeft, #PB_Splitter_Separator)
Window_Main_Container_TopRight = ContainerGadget(#PB_Any, 0, 0, 0, 0)
Window_Main_Text_TopRight = TextGadget(#PB_Any, 0, 0, 155, 15, "Top Right")
Window_Main_Editor_TopRight = EditorGadget(#PB_Any, 0, 15, 500, 185, #PB_Editor_ReadOnly)
CloseGadgetList()
Window_Main_Container_BottomRight = ContainerGadget(#PB_Any, 0, 0, 0, 0)
Window_Main_Text_BottomRight = TextGadget(#PB_Any, 0, 0, 130, 15, "Bottom Right")
Window_Main_Editor_BottomRight = EditorGadget(#PB_Any, 0, 15, 500, 185, #PB_Editor_ReadOnly)
CloseGadgetList()
Window_Main_Splitter_Right = SplitterGadget(#PB_Any, 510, 5, 500, 410, Window_Main_Container_TopRight, Window_Main_Container_BottomRight, #PB_Splitter_Separator)
Window_Main_Splitter_Middle = SplitterGadget(#PB_Any, 5, 5, 1005, 410, Window_Main_Splitter_Left, Window_Main_Splitter_Right, #PB_Splitter_Vertical | #PB_Splitter_Separator)
SmartWindowRefresh(Window_Main, #True)
BindGadgetEvent(Window_Main_Splitter_Left,@Main_SizeWindowHandler())
BindGadgetEvent(Window_Main_Splitter_Right,@Main_SizeWindowHandler())
BindGadgetEvent(Window_Main_Splitter_Middle,@Main_SizeWindowHandler())
BindEvent(#PB_Event_SizeWindow, @Main_SizeWindowHandler())
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf