Re: Centering Windows

From: Date: Sun, 11 Mar 2001 00:43:50 +0000
Subject: Re: Centering Windows
References: 1  Groups: php.gtk 
Request: Send a blank email to php-gtk+get-670@lists.php.net to get a copy of this message
> How would I center a window in the screen? > I've found GTK_WIN_POS_CENTER in the GTK documentation but have no idea > where php-gtk needs that. I've just been using the screen resolution to center windows. As an example: $width = 400; // width of our new window $height = 400; // height of our new window // use Gdk functions to get the current screen resolution. I usually have // SCREEN_{WIDTH,HEIGHT} defined as global variables. $SCREEN_WIDTH = Gdk::screen_width(); $SCREEN_HEIGHT = Gdk::screen_height(); $aboutwin = &new GtkWindow(); $aboutwin->set_usize ($width, $height); $aboutwin->set_uposition (intval(($SCREEN_WIDTH / 2) - ($width / 2)), intval(($SCREEN_HEIGHT / 2) - ($height / 2))); This example will create a 400x400 window centered on the screen. You could very easily turn this into a function and then just say something like: $aboutwin = create_gtk_window_centered (400, 400); There may be another way to do it using Gtk, but this is pretty simple. Hth. -- Michael.

« previous php.gtk (#670) next »