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 18, 2014 11:19 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: x y widget coordinates GTK+ 3 [SOLVED]
PostPosted: Fri Jan 13, 2012 1:48 pm 
Offline
GTK+ Geek

Joined: Mon Mar 30, 2009 12:40 pm
Posts: 67
Location: España
How can i get the x, y coordinates from a widget in GTK+ 3?.

Now i do this: gdk_window_get_origin(gtk_widget_get_window(Chisme->entrada),&x,&y);

But this returns now the window coordinates, not the widet coordinates.

Thanks.


Last edited by laremi400 on Mon Jan 16, 2012 1:03 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: x y widget coordinates GTK+ 3
PostPosted: Sat Jan 14, 2012 9:21 am 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
The reason you're getting this is because gtk_widget_get_window gets the window the widget is contained in. Try out gtk_widget_get_allocation


Top
 Profile  
 
 Post subject: Re: x y widget coordinates GTK+ 3
PostPosted: Mon Jan 16, 2012 6:41 am 
Offline
GTK+ Geek

Joined: Mon Mar 30, 2009 12:40 pm
Posts: 67
Location: España
gtk_widget_get_allocation returns size of widget. I need the x,y coordinates position int he window.

And the allocation.x and allocation.y returns the coordinates of the GdkScreen, not the coordinates of the GtkWidget.


Top
 Profile  
 
 Post subject: Re: x y widget coordinates GTK+ 3
PostPosted: Mon Jan 16, 2012 10:28 am 
Offline
Familiar Face

Joined: Thu Dec 15, 2011 6:23 pm
Posts: 36
Location: Hrvatska
did you try
Code:
gtk_window_get_position(window, &x, &y)
it is counterpart of
Code:
gtk_window_move(window, x, y)
it seems to me , those two will make a job


Top
 Profile  
 
 Post subject: Re: x y widget coordinates GTK+ 3
PostPosted: Mon Jan 16, 2012 1:02 pm 
Offline
GTK+ Geek

Joined: Mon Mar 30, 2009 12:40 pm
Posts: 67
Location: España
Solved:
Code:
(...)
gint x,y;
GtkAllocation allocation;

//x,y GtkWindow coordinates
gdk_window_get_origin(gtk_widget_get_window(widget),&x,&y);

//widget coordinates into GtkWindow
gtk_widget_get_allocation(widget,&allocation);
//x, y widget coordinates
x += allocation.x;
y += alocation.y;



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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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