Finding absolute position of widget on the screen
- From: "Padraig O'Briain" <Padraig Obriain Sun COM>
- To: gtk-app-devel-list gnome org
- Subject: Finding absolute position of widget on the screen
- Date: Fri, 16 Mar 2001 09:06:13 +0000 (GMT)
I am trying to figure out what functions I should be using to find the absolute
position of a widget.
I found the message below in the archives at
http://mail.gnome.org/archives/gtk-list/1999-February/msg00023.html
but it does not work for me. It does work if I replace gdk_window_get_position()
with gdk_window_get_origin(). is there a description somewhere of what the
difference between the two functions?
BTW, I am using the development branch 1.3.x of GTK+.
Padraig
------------- Begin Included Message -------------
You can access the GdkWindow for a widget with widget->window.
A fail-safe way of getting the absolute screen coordinates
for a GtkWidget would be something like:
====
if (GTK_WIDGET_TOPLEVEL (widget))
gdk_window_get_position (widget->window, &x, &y);
else
{
GdkWindow *window;
if (GTK_WIDGET_NO_WINDOW (widget))
window = widget->window;
else
window = gdk_window_get_parent (widget->window);
gdk_window_get_position (window, &x, &y);
x += widget->allocation.x;
y += widget->allocation.y;
}
====
- What is the widget at position x,y?
This is a little harder - there is a lot of address translation
going on. The following routines (I wrote these very
recently, and haven't tested them much yet) may help.
Regards,
Owen
=====
------------- End Included Message -------------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]