It is currently Fri Aug 23, 2019 11:07 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Editor_Scroll To Bottomline crash works not
PostPosted: Wed Oct 14, 2015 9:26 am 
Offline
Addict
Addict

Joined: Sat Mar 02, 2013 9:17 am
Posts: 931
Tested PB 5.40 b10 Mint 64

Code:
;======================================================================
; Module/File:     Editor_ScrollToBottomline.pb
; Function:        scrollt zur letzten Zeile - Linux
; Author:          freak
; Date:            July 30, 2014
; Version:         0.1
; Target Compiler: PureBasic 5.22, 5.30
; Target OS:       (X/K)ubuntu 32/64, Ascii/Uni
; License:         Free, unrestricted, no warranty
;======================================================================

ImportC ""
   gtk_adjustment_get_page_size.d(*adjustment.GtkAdjustment)
   gtk_adjustment_get_upper.d(*adjustment.GtkAdjustment)
   gtk_adjustment_get_step_increment.d(*adjustment.GtkAdjustment)
EndImport

EnableExplicit

; Object constants
#MainWin= 0
#Button = 0
#Editor = 1

#WinX=300
#WinY=200
#WinW=400
#WinH=200

Global.i gEvent, gLineCount
Global *Adjustment.GtkAdjustment


If OpenWindow(0, #WinX, #WinY, #WinW, #WinH, "editor scroll", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   
   ButtonGadget(#Button, 10, 10, 150, 30, "add line")
   EditorGadget(#Editor, 10, 50, 380, 140)
   
   Repeat
      gEvent = WaitWindowEvent()
      
      If gEvent = #PB_Event_Gadget And EventGadget() = #Button
         AddGadgetItem(#Editor, -1, "New line: " + Str(gLineCount))
         gLineCount+ 1
         
         ; get the vertical adjustment of the scrolled window ...
         *Adjustment= gtk_scrolled_window_get_vadjustment_(gtk_widget_get_parent_(GadgetID(#Editor)))
         
         ; some Adjustment-values to debug ...
         Debug "Page-Size     : " + Str(gtk_adjustment_get_page_size(*Adjustment))
         Debug "rel. upper pos: " + Str(gtk_adjustment_get_upper(*Adjustment))
         Debug "step increment: " + Str(gtk_adjustment_get_step_increment(*Adjustment))
         
         ; change the value to the max ...
         *Adjustment\value= *Adjustment\upper
         
         ; notify the scrolled window of the change ...
         gtk_adjustment_value_changed_(*Adjustment)     
      EndIf
      
   Until gEvent = #PB_Event_CloseWindow
EndIf
; IDE Options = PureBasic 5.30 (Linux - x64)
; CursorPosition = 10
; EnableUnicode
; EnableXP
; CurrentDirectory = /home/charly-xubuntu/Programming/PureBasic/purebasic/

_________________
http://www.nachtoptik.de


Top
 Profile  
Reply with quote  
 Post subject: Re: Editor_Scroll To Bottomline crash works not
PostPosted: Wed Oct 14, 2015 9:33 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13611
Location: France
This is not a PB function, it's not granted to work on all futur PB version.


Top
 Profile  
Reply with quote  
 Post subject: Re: Editor_Scroll To Bottomline crash works not
PostPosted: Wed Oct 14, 2015 4:48 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Jun 26, 2014 9:17 am
Posts: 306
Location: Germany
Hello walbus,

this method doesn't work very reliable and makes problems an gtk2 too. (And it's no PureBasic-Bug.)
The examples in the Linux-API-Lib aren't prepared for gtk3 at the moment. Please wait for the update after the PureBasic-Betas with fixes, news or marked codes.

Maybe you can use one of the new examples for EditorGadget-scrolling...
Code:
ImportC ""
   gtk_adjustment_get_page_size.d(*adjustment.GtkAdjustment)
   gtk_adjustment_get_upper.d(*adjustment.GtkAdjustment)
   gtk_adjustment_set_value(*adjustment.GtkAdjustment, value.d)
EndImport

; Object constants
#MainWin= 0
#Edt1   = 0
#Bt1    = 1
#Bt2    = 2

#WinX= 300
#WinY= 200
#WinW= 300
#WinH= 200

Global.i gEvent, gQuit, I
Global *gAdjustment.GtkAdjustment
Global.d EdtPageSize, EdtUpper
Global.s EditString1= "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. " +
                      " Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."


If OpenWindow(#MainWin, #WinX, #WinY, #WinW, #WinH, "EditorGadget - to bottom/top", #PB_Window_SystemMenu)
   ButtonGadget(#Bt1, 5, 5, 100, 25, "to bottomline")
   ButtonGadget(#Bt2, 105, 5, 100, 25, "to topline")
   EditorGadget(#Edt1, 5, 35, #WinW-10, #WinH-39, #PB_Editor_WordWrap)
   AddGadgetItem(#Edt1, -1, EditString1)
   
   gtk_text_view_set_wrap_mode_(GadgetID(#Edt1), #GTK_WRAP_WORD)
   *gAdjustment= gtk_scrolled_window_get_vadjustment_(gtk_widget_get_parent_(GadgetID(#Edt1)))
   
   
   Repeat
      gEvent= WaitWindowEvent()
      
      Select gEvent
         Case #PB_Event_CloseWindow
            gQuit= #True
            
         Case #PB_Event_Gadget
            Select EventGadget()
               Case #Bt1
                     EdtPageSize= gtk_adjustment_get_page_size(*gAdjustment)
                     EdtUpper= gtk_adjustment_get_upper(*gAdjustment)
                     gtk_adjustment_set_value(*gAdjustment, EdtUpper-EdtPageSize);  to bottomline
                     
               Case #Bt2
                     ;EdtPageSize= gtk_adjustment_get_page_size(*gAdjustment)
                     ;EdtUpper= gtk_adjustment_get_upper(*gAdjustment)
                     gtk_adjustment_set_value(*gAdjustment, 0);                     to topline
                  
            EndSelect

      EndSelect
      
   Until gQuit
EndIf


Regards, Charly

_________________
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de


Top
 Profile  
Reply with quote  
 Post subject: Re: Editor_Scroll To Bottomline crash works not
PostPosted: Wed Oct 14, 2015 7:19 pm 
Offline
Addict
Addict

Joined: Sat Mar 02, 2013 9:17 am
Posts: 931
Many thanks Charly, its very helpful.
Regards Wernerl

_________________
http://www.nachtoptik.de


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye