; Module/File: LIG_Scroll2Point.pb ; Function: scrolls Line to top without selection, uses rel. coordinates. Need constant lineheights- Linux ; Author: Shardik ; Date: July 09, 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 ; Link to topic: http://www.purebasic.fr/english/viewtopic.php?f=40&t=57788 ; Link to topic: http://www.purebasic.fr/german/viewtopic.php?f=21&t=21580 ;-------------------------------------------------------------- EnableExplicit Global.i gEvent Global.i I Procedure TV_ScrollToPoint(Gadget, Item); Scrollt zu Zeile, Erfragte Zeilenhöhe wg. Systemzeichensatz (Alle Zeilen müssen gleich hoch sein) Protected *tPath, *tColumn, Rect.GdkRectangle If Item< 0 : ProcedureReturn : EndIf gtk_tree_view_get_path_at_pos_(GadgetID(Gadget), 5, 5, @*tPath, @*tColumn, #Null, #Null) gtk_tree_view_get_cell_area_ (GadgetID(Gadget), *tPath, *tColumn, Rect) gtk_tree_view_scroll_to_point_(GadgetID(Gadget), -1, Item * Rect\height) gtk_tree_path_free_(*tPath) EndProcedure If OpenWindow(0, 100, 200, 180, 170, "Scroll to point", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) ListIconGadget(0, 5, 5, WindowWidth(0) - 10, WindowHeight(0) - 45, "Spalte 1", 60) SpinGadget(1, 5, WindowHeight(0)- 35, 50, 25, 1, 100, #PB_Spin_Numeric) SetGadgetState(1, 1) SetGadgetText(1, Str(GetGadgetState(1))) ButtonGadget(2, 105, WindowHeight(0) - 35, 70, 25, "Anzeigen") For I= 1 To 100 AddGadgetItem(0, -1, "Zeile " + Str(i)) Next I Repeat gEvent = WaitWindowEvent() If gEvent = #PB_Event_Gadget Select EventGadget() Case 1 SetGadgetState(1, Val(GetGadgetText(1))) Case 2 TV_ScrollToPoint(0, GetGadgetState(1)-1) EndSelect EndIf Until gEvent= #PB_Event_CloseWindow EndIf ; IDE Options = PureBasic 5.44 LTS (Linux - x86) ; CursorPosition = 8 ; Folding = - ; EnableUnicode ; EnableXP ; Executable = ../../ImageViewer/LinuxPbSystemIconViewer ; DisableDebugger ; CurrentDirectory = /home/charly-xubuntu/Programming/PureBasic/purebasic/