Although it's not a direct PureBasic bug, I'm posting this problem under bugs as a hint, because it can make placing gadgets even more difficult under gtk3:
Code: Select all
ImportC ""
gtk_widget_get_window(*widget.GtkWidget)
EndImport
Global.i gEvent, gQuit
Procedure.i GetGdkWindow(Window)
ProcedureReturn gtk_widget_get_window(WindowID(Window))
EndProcedure
Procedure Create_WinMain()
If OpenWindow(0, 300, 200, 400, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
;some Gadgets and their positions ...
Debug "Immediate values of GadgetX/Y[#PB_Gadget_WindowCoordinate] (try gtk2 & gtk3) ..."
ButtonGadget(0, 5, 5, 100, 26, "Button")
Debug "Button:"
Debug Str(GadgetX(0, #PB_Gadget_WindowCoordinate)) + "," + Str(GadgetY(0, #PB_Gadget_WindowCoordinate))
TextGadget (1, 5, 35, 100, 22, "Text")
Debug "Text:"
Debug Str(GadgetX(1, #PB_Gadget_WindowCoordinate)) + "," + Str(GadgetY(1, #PB_Gadget_WindowCoordinate))
If LoadImage(0, #PB_Compiler_Home + "examples/sources/Data/Drive.bmp")
ImageGadget(2, 5, 65, 32, 32, ImageID(0))
EndIf
Debug "Image:"
Debug Str(GadgetX(2, #PB_Gadget_WindowCoordinate)) + "," + Str(GadgetY(2, #PB_Gadget_WindowCoordinate))
ComboBoxGadget(3, 5, 100, 150, 28)
AddGadgetItem (3, -1, "ComboBoxGadget") : SetGadgetState(3, 0)
Debug "ComboBox:"
Debug Str(GadgetX(3, #PB_Gadget_WindowCoordinate)) + "," + Str(GadgetY(3, #PB_Gadget_WindowCoordinate))
ContainerGadget(4, 5, 130, 390, 100, #PB_Container_Flat)
ButtonGadget(5, 5, 5, 100, 26, "Button")
Debug "Button in Container: (if not -x, the roughly coordinates of the container are returned"
Debug Str(GadgetX(5, #PB_Gadget_WindowCoordinate)) + "," + Str(GadgetY(5, #PB_Gadget_WindowCoordinate))
CloseGadgetList()
;emtying event-loop, wait and redraw ...
While WindowEvent() : Wend: Delay(200)
gdk_window_process_updates_(GetGdkWindow(0), #True)
While WindowEvent() : Wend
;and again the positions ...
Debug ""
Debug "Button: 2. attempt (after a while and updates)"
Debug Str(GadgetX(0, #PB_Gadget_WindowCoordinate)) + "," + Str(GadgetY(0, #PB_Gadget_WindowCoordinate))
Debug "Text:"
Debug Str(GadgetX(1, #PB_Gadget_WindowCoordinate)) + "," + Str(GadgetY(1, #PB_Gadget_WindowCoordinate))
Debug "Image:"
Debug Str(GadgetX(2, #PB_Gadget_WindowCoordinate)) + "," + Str(GadgetY(2, #PB_Gadget_WindowCoordinate))
Debug "ComboBox:"
Debug Str(GadgetX(3, #PB_Gadget_WindowCoordinate)) + "," + Str(GadgetY(3, #PB_Gadget_WindowCoordinate))
Debug "Button in Container: (if not -x, the roughly coordinates of the container are returned"
Debug Str(GadgetX(5, #PB_Gadget_WindowCoordinate)) + "," + Str(GadgetY(5, #PB_Gadget_WindowCoordinate))
EndIf
EndProcedure
Create_WinMain()
Repeat
gEvent= WaitWindowEvent()
Select gEvent
Case #PB_Event_CloseWindow
gQuit= #True
EndSelect
Until gQuit
This means that a placement of gadgets is only reasonable after emptying event-loop, some redraws and/or after using the timer, taking into account the actual size of top or left-handed gadgets.
Regards, Charly