; Module/File: LV_GetVisibleItems.pb ; Function: Get number of partially (visible) items - Linux ; Author: Omi ; Date: Juli 11, 2014 ; 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_tree_view_get_visible_range(*tree_view.GtkTreeView, *tPathF, *tPathL) EndImport ; Object constants #MainWin= 0 #LV= 0 #CbBox= 1 #WinX= 200 #WinY= 200 #WinW= 300 #WinH= 450 Global.i gEvent, gQuit Global gFItem, gLItem ;- Functions ... Procedure.i TV_GetIndexFromPath(Gadget, *tPath); LIG + LV: Index / Zeile (= Item) anhand des Pfad-Zeigers holen ProcedureReturn PeekL(gtk_tree_path_get_indices_(*tPath)) EndProcedure Procedure TV_GetVisibleItems(Gadget) Protected.i Ret, Num Protected *tPathF, *tPathL Ret= gtk_tree_view_get_visible_range(GadgetID(Gadget), @*tPathF, @*tPathL) If Ret Num= TV_GetIndexFromPath(Gadget, *tPathL) - TV_GetIndexFromPath(Gadget, *tPathF) + 1 Else Debug "not Okay" EndIf gtk_tree_path_free_(*tPathF) gtk_tree_path_free_(*tPathL) ProcedureReturn Num EndProcedure ;- Example ... Procedure CreateWindow_Main() Protected.l I Protected *Column #Img1= 0 #Img2= 1 If OpenWindow(#MainWin, #WinX, #WinY, #WinW, #WinH, "GetItemRanges", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) ListViewGadget(#LV, 5, 5, 280, 380) ButtonGadget(#CbBox, 5, 400, 150, 25, "Debug visible items") For I= 1 To 40 AddGadgetItem(#LV, -1, Str(I)+".1") Next I EndIf EndProcedure CreateWindow_Main() Repeat gEvent= WaitWindowEvent() Select gEvent Case #PB_Event_CloseWindow gQuit= #True Case #PB_Event_Gadget Select EventGadget() Case #CbBox Debug TV_GetVisibleItems(#LV) EndSelect EndSelect Until gQuit ; IDE Options = PureBasic 5.40 LTS Beta 9 (Linux - x86) ; CursorPosition = 8 ; Folding = - ; EnableUnicode ; EnableXP ; CurrentDirectory = /home/charly-xubuntu/Programming/PureBasic/purebasic/