Code: Select all
; Procedure _GadgetX(id, flags)
; Protected gRect.RECT
; GetWindowRect_(GadgetID(id), gRect.RECT)
; Select flags
; Case #PB_Gadget_ContainerCoordinate
; MapWindowPoints_(0, GetAncestor_(GadgetID(id), #GA_PARENT), gRect, 2)
; Case #PB_Gadget_WindowCoordinate
; MapWindowPoints_(0, GetAncestor_(GadgetID(id), #GA_ROOT), gRect, 2)
; EndSelect
; ProcedureReturn gRect\left
; EndProcedure
; Macro GadgetX(id, flags=#PB_Gadget_ContainerCoordinate)
; _GadgetX(id, flags)
; EndMacro
; Procedure _GadgetY(id, flags)
; Protected gRect.RECT
; GetWindowRect_(GadgetID(id), gRect.RECT)
; Select flags
; Case #PB_Gadget_ContainerCoordinate
; MapWindowPoints_(0, GetAncestor_(GadgetID(id), #GA_PARENT), gRect, 2)
; Case #PB_Gadget_WindowCoordinate
; MapWindowPoints_(0, GetAncestor_(GadgetID(id), #GA_ROOT), gRect, 2)
; EndSelect
; ProcedureReturn gRect\top
; EndProcedure
; Macro GadgetY(id, flags=#PB_Gadget_ContainerCoordinate)
; _GadgetY(id, flags)
; EndMacro
Global width = 30
Global height = 30
Global offset = 5
Procedure WindowResize()
ResizeGadget(1, WindowWidth(0) - width - offset, offset, #PB_Ignore, #PB_Ignore)
ResizeGadget(2, WindowWidth(0) - width - offset, WindowHeight(0) - height - offset, #PB_Ignore, #PB_Ignore)
ResizeGadget(3, offset, WindowHeight(0) - height - offset, #PB_Ignore, #PB_Ignore)
ResizeGadget(4, GadgetX(0) + GadgetWidth(0), GadgetY(0) + GadgetHeight(0), GadgetX(1) - GadgetX(0) - GadgetWidth(0), GadgetY(3) - (GadgetY(0) + GadgetHeight(0)))
EndProcedure
SetProcessDefaultLayout_(1)
OpenWindow(0, 0, 0, 325, 295, "", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
ButtonGadget(0, offset, offset, width, height, "1")
ButtonGadget(1, WindowWidth(0) - width - offset, offset, width, height, "2")
ButtonGadget(2, WindowWidth(0) - width - offset, WindowHeight(0) - height - offset, width, height, "3")
ButtonGadget(3, offset, WindowHeight(0) - height - offset, width, height, "4")
EditorGadget(4, GadgetX(0) + GadgetWidth(0), GadgetY(0) + GadgetHeight(0), GadgetX(1) - GadgetX(0) - GadgetWidth(0), GadgetY(3) - (GadgetY(0) + GadgetHeight(0)))
BindEvent(#PB_Event_SizeWindow, @WindowResize())
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend