GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Apr 25, 2014 5:01 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: gtktextview scroll position
PostPosted: Wed May 23, 2007 5:04 am 
Offline
Familiar Face

Joined: Tue Mar 27, 2007 8:56 am
Posts: 26
Hello,
If I have a gtktextview or gtksourceview, and I type some text and it scroll both vertically and horizontally. How to get the scroll position? I mean the row and column coordinate of the top-left corner of the visible text area.

Thankx


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 1:35 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
Assuming that you place it in a GtkScrolledWindow, you can use gtk_scrolled_window_get_hadjustment() and gtk_scrolled_window_get_vadjustment() to get the horizontal and vertical adjustments. In the vertical adjustment, the lower and upper values represent the far left of the widget, and the point that will be on the far left when the scrollbar is completely moved to the right. (Does that make sense?)

Therefore, you can use the value property to get the current position in each. However, I'm not completely sure if that is in pixels, so you should test it out. If not, you will have to use the page size and size of the widget to calculate the pixel size, which shouldn't be too difficult.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 2:56 pm 
Offline
Familiar Face

Joined: Tue Mar 27, 2007 8:56 am
Posts: 26
Thank you!.
GtkScrolledWindow is definitely the way. The adjustments give values in pixels, so that the vertical scroll is easier to calculate, but the horizontal scroll is rather difficult (give up).


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 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
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group