I have a gtkscrolledwindow and there is a gtk image in it. How can i get current showing area in GtkScrolledWindow? For example my image is 1366x768 pix and 300x400 pix part of image is showing in scrolledwindow. I want to get coordinates of showing part like (x,y,width,height) I'm looking here: https://developer.gnome.org/gtkmm/unstable/classGtk_1_1ScrolledWindow.html but can't find any solution. Thanks.
EDIT:The solution from user1146332 Thank you very much. For the python codes:
x = self.scrolledwindow.get_hadjustment() print str(x.get_page_size()) + " width of showing area" y =self.scrolledwindow.get_vadjustment() print str(y.get_page_size()) + " height of showing area" print str(x.get_upper()) + " image width in scrolledwindow" print str(y.get_upper()) + " image height in scrolledwindow" print str(x.get_value()) + " x position" print str(y.get_value()) + " y position"
Note that for adjustments which are used in a GtkScrollbar, the effective range of allowed values goes from adjustment->lower to adjustment->upper - adjustment->page_size.
I guess you want to achieve something like this:
Whereas
x
andy
describes the point located at the upper left corner of the image section andwidth
andheight
are related to the size of the image section. Further i assume that theGtkImage
object is added to aGtkViewport
widget and theGtkViewport
is added to aGtkScrolledWindow
.Unfortunately i can't give you a python specific answer since i don't know anything about it. But if you are able to transfer information from gtk's reference manual to python you should be able to implement it.
If you want information about the coordinates of the image section you first have to get the
vadjustment
andhadjustment
properties of theGtkScrolledWindow
widget. These properties areGtkAdjustment
objects and contains the information you need. Thepage-size
property of those objects is related to the size of the visible image section i.ewidth
andheight
. Whereas thevalue
property of bothvadjustment
andhadjustment
defines the point at the upper left corner of the image section i.e.x
andy
.If you want to react upon changes of the mentioned properties asynchronously you should connect the
changed
andvalue-changed
signals of both adjustment objects to one and the same signal handler.