Re: getwindowRect
- From: zentara <zentara1 sbcglobal net>
- To: gtk-list gnome org
- Subject: Re: getwindowRect
- Date: Thu, 18 Dec 2008 12:59:40 -0500
On Thu, 18 Dec 2008 12:42:25 -0200
"Luiz Rafael Culik Guimaraes" <luiz xharbour com br> wrote:
>Dear Friends
>
>is their any function or way in gtk to emulate GetWindowRect() and return
>the widget top/left/bottom/right position?
Here is an example. You need to call the functions after
the window is realized on the screen....so either a button
callback or an expose event.
(Any improvements welcome, I'm still learning)
#############################################
#include <gtk/gtk.h>
void destroy( GtkWidget *widget, gpointer data ){
gtk_main_quit();
}
void locate( GtkWidget *widget, gpointer data ){
gint x,y,w,h;
GtkWidget *window;
window = data;
gdk_window_get_size (window->window, &w, &h);
gdk_window_get_position (window->window, &x, &y);
g_print ("Size: width %d height %d\n", w, h);
g_print ("Location x %d y %d\n", x, y);
}
int main( int argc, char *argv[] ){
GtkWidget *window;
GtkWidget *button;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK(destroy), NULL);
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
button = gtk_button_new_with_label ("Check Location");
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (locate), G_OBJECT (window) );
gtk_container_add (GTK_CONTAINER (window), button);
gtk_widget_show (button);
gtk_widget_show (window);
gtk_main ();
return 0;
}
############################################
zentara
--
I'm not really a human, but I play one on earth.
http://zentara.net/Remember_How_Lucky_You_Are.html
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]