; Module/File: LIG_GetLIGSize.pb ; Function: Get width/height of the ListIconGadget-Area (without scrollbars, not the whole GtkScrolledWindow like PB-GadgetWidth()) - Linux ; Author: Omi ; Date: Jan. 02, 2016 ; Version: 0.1 ; Target Compiler: PureBasic 5.22/5.31/5.40 ; Target OS: Linux: (X/K/L)ubuntu, Mint, 32/64, Ascii/Uni ;-------------------------------------------------------------- EnableExplicit ImportC "" ; gtk_widget_get_allocated_width(*widget.GtkWidget); for gtk3 ; gtk_widget_get_allocated_height(*widget.GtkWidget); for gtk3 gtk_widget_get_allocation(*widget.GtkWidget, *allocation.GtkAllocation); gtk2 + gtk3 EndImport ;Object constants #MainWin = 0 #But1 = 0 #But2 = 1 #But3 = 2 #LIG = 3 Global.i gEvent, gQuit, gI Global Allocation.GtkAllocation Procedure TreeView_GetWidth(Gadget) gtk_widget_get_allocation(GadgetID(Gadget), @Allocation) ProcedureReturn Allocation\width ;only gtk3 ... ; ProcedureReturn gtk_widget_get_allocated_width(GadgetID(Gadget)) EndProcedure Procedure TreeView_GetHeight(Gadget) gtk_widget_get_allocation(GadgetID(Gadget), @Allocation) ProcedureReturn Allocation\height ;only gtk3 .. ; ProcedureReturn gtk_widget_get_allocated_height(GadgetID(Gadget)) EndProcedure Procedure CreateWindow_Main() If OpenWindow(#MainWin, 200, 200, 380, 390, "ListIconGadget-Area - Sizes", #PB_Window_SystemMenu) TextGadget (#PB_Any, 5, 5, 370, 22, "Change col.-width, delete/add rows & watch sizes...") ButtonGadget(#But1, 5, 28, 110, 26, "Remove row") ButtonGadget(#But2, 120, 28, 110, 26, "Add row") ButtonGadget(#But3, 255, 28, 120, 26, "Debug size") ListIconGadget(#LIG, 5, 60, 370, 325, "column 0", 70, #PB_ListIcon_AlwaysShowSelection | #PB_ListIcon_GridLines | #PB_ListIcon_CheckBoxes) AddGadgetColumn(#LIG, 1, "column "+Str(1), 140) AddGadgetColumn(#LIG, 2, "column "+Str(2), 140) For gI= 0 To 15 AddGadgetItem(#LIG, -1, Str(gI) + ".0" + #LF$ + Str(gI) + ".1" + #LF$ + Str(gI) + ".2") Next gI EndIf EndProcedure CreateWindow_Main() Repeat gEvent= WaitWindowEvent() Select gEvent Case #PB_Event_CloseWindow gQuit= #True Case #PB_Event_Gadget Select EventGadget() Case #But1 RemoveGadgetItem(#LIG, 0) Case #But2 gI+ 1 AddGadgetItem(#LIG, -1, Str(gI)+".0" + #LF$ + "col 1" + #LF$ + "col 2") Case #But3 Debug "Width (PB, = GtkScrolledWindow) : " + GadgetWidth(#LIG, #PB_Gadget_ActualSize) Debug "Height (PB, = GtkScrolledWindow) : " + GadgetHeight(#LIG, #PB_Gadget_ActualSize) Debug "Width (LIG area within GtkScrolledWindow) : " + TreeView_GetWidth(#LIG) Debug "Height (LIG area within GtkScrolledWindow) : " + TreeView_GetHeight(#LIG) Debug " ---" EndSelect EndSelect Until gQuit ; IDE Options = PureBasic 5.45 LTS (Linux - x86) ; CursorPosition = 3 ; Folding = - ; EnableUnicode ; EnableXP