Re: MDI Window as in Windows ?
- From: Ken Rastatter <krastatter sensotec com>
- To: gtk-list gnome org
- Subject: Re: MDI Window as in Windows ?
- Date: Wed, 15 Jan 2003 12:04:34 -0500
> Is it possible to have a MDI Window, if yes, how to do it ?
I'm not certain if you are asking about emulating MDI while running Linux or
Win32. Assuming you are talking about Win32, here is some information that
may help.
According to the GTK and GDK documentation, I think the following
function that I wrote *should* work. The good news is that
gdk_window_reparent()
does reparent the windows as one would expect for MDI and dialog boxes. The
bad
news is that gtk_window_set_position() doesn't center the window in GTK+ 2.2.0.
void GtkRulz_window_reparent(GtkWindow *child_window, GtkWindow
*parent_window)
{
GdkWindow *child_gdkwindow;
GdkWindow *parent_gdkwindow;
child_gdkwindow = GTK_WIDGET(child_window)->window;
parent_gdkwindow = GTK_WIDGET(parent_window)->window;
// REPARENT CHILD WINDOW
gdk_window_reparent(child_gdkwindow, parent_gdkwindow, 0, 0);
// MOVE CHILD TO CENTER OF PARENT
// gtk bug: GTK_WIN_POS_CENTER_ALWAYS moves child to wrong position in
2.2.0
gtk_window_set_position (child_window, GTK_WIN_POS_CENTER_ALWAYS);
// gtk bug: GTK_WIN_POS_CENTER_ON_PARENT moves child to top,left of
parent in 2.2.0
gtk_window_set_position (child_window, GTK_WIN_POS_CENTER_ON_PARENT);
}
In order to make the child centered upon the parent window (useful for
dialog boxes), I have to manually move the child window onto the center
of the parent. The centering algorithm below worked fairly well in GTK+ 2.0.9
and not as well in GTK+ 2.2.0.
I realize that the GTK documentation frowns upon manually centering
windows and suggests that one use gtk_window_set_position() instead. However,
until gtk_window_set_position() get fixed, this hack will have to do.
void GtkRulz_window_reparent(GtkWindow *child_window, GtkWindow
*parent_window)
{
GdkWindow *child_gdkwindow;
GdkWindow *parent_gdkwindow;
gint x, y, pw, ph;
GdkRectangle c_gdkrect;
child_gdkwindow = GTK_WIDGET(child_window)->window;
parent_gdkwindow = GTK_WIDGET(parent_window)->window;
// REPARENT CHILD WINDOW
gdk_window_reparent(child_gdkwindow, parent_gdkwindow, 0, 0);
// MOVE CHILD WINDOW TO CENTER OF PARENT
// Hack to bypass the problems with gtk_window_set_position()
gdk_window_get_frame_extents(child_gdkwindow, &c_gdkrect);
gtk_window_get_size(parent_window, &pw, &ph);
x = (pw - c_gdkrect.width) / 2;
y = (ph - c_gdkrect.height) / 3;
if (x<0) x = 0;
if (y<0) y = 0;
gtk_window_move(child_window, x, y);
}
--
Ken Rastatter, Design Engineer
Sensotec, Inc.
2080 Arlingate Lane, Columbus, Ohio, 43228-4112 USA
Voice: (614)850-5000 Fax: (614)850-6041 Toll Free: 1-800-848-6564
Home Page: http://www.sensotec.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]