]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: frame.cpp | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
a81258be | 5 | // Id: $Id$ |
01111366 | 6 | // Copyright: (c) 1998 Robert Roebling |
19717c50 | 7 | // Licence: wxWindows licence |
c801d85f KB |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
7c0ea335 VZ |
10 | // ============================================================================ |
11 | // declarations | |
12 | // ============================================================================ | |
13 | ||
14 | // ---------------------------------------------------------------------------- | |
15 | // headers | |
16 | // ---------------------------------------------------------------------------- | |
17 | ||
c801d85f | 18 | #ifdef __GNUG__ |
fe4e9e6c | 19 | #pragma implementation "frame.h" |
c801d85f KB |
20 | #endif |
21 | ||
d02af7bb JJ |
22 | #ifdef __VMS |
23 | #define XIconifyWindow XICONIFYWINDOW | |
24 | #endif | |
25 | ||
c801d85f KB |
26 | #include "wx/frame.h" |
27 | #include "wx/dialog.h" | |
28 | #include "wx/control.h" | |
29 | #include "wx/app.h" | |
cf4219e7 | 30 | #include "wx/menu.h" |
dcf924a3 | 31 | #if wxUSE_TOOLBAR |
7c0ea335 | 32 | #include "wx/toolbar.h" |
dcf924a3 RR |
33 | #endif |
34 | #if wxUSE_STATUSBAR | |
7c0ea335 | 35 | #include "wx/statusbr.h" |
dcf924a3 | 36 | #endif |
362c6693 | 37 | #include "wx/dcclient.h" |
83624f79 | 38 | |
55703c91 RR |
39 | #include <glib.h> |
40 | #include <gdk/gdk.h> | |
41 | #include <gtk/gtk.h> | |
42 | #include <gdk/gdkkeysyms.h> | |
43 | #include <gdk/gdkx.h> | |
44 | ||
c801d85f KB |
45 | #include "wx/gtk/win_gtk.h" |
46 | ||
7c0ea335 | 47 | // ---------------------------------------------------------------------------- |
2f2aa628 | 48 | // constants |
7c0ea335 | 49 | // ---------------------------------------------------------------------------- |
2f2aa628 | 50 | |
907789a0 | 51 | const int wxMENU_HEIGHT = 27; |
c67daf87 | 52 | const int wxSTATUS_HEIGHT = 25; |
41ca191f | 53 | const int wxPLACE_HOLDER = 0; |
c801d85f | 54 | |
7c0ea335 | 55 | // ---------------------------------------------------------------------------- |
acfd422a | 56 | // idle system |
7c0ea335 | 57 | // ---------------------------------------------------------------------------- |
acfd422a RR |
58 | |
59 | extern void wxapp_install_idle_handler(); | |
60 | extern bool g_isIdle; | |
2d68e1b4 | 61 | extern int g_openDialogs; |
acfd422a | 62 | |
7c0ea335 VZ |
63 | // ---------------------------------------------------------------------------- |
64 | // event tables | |
65 | // ---------------------------------------------------------------------------- | |
66 | ||
1e6feb95 VZ |
67 | #ifdef __WXUNIVERSAL__ |
68 | IMPLEMENT_DYNAMIC_CLASS(wxFrameGTK, wxWindow) | |
69 | #else | |
3a12b404 JS |
70 | IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxFrameGTK) |
71 | IMPLEMENT_DYNAMIC_CLASS(wxFrameGTK, wxWindow) | |
1e6feb95 | 72 | #endif |
7c0ea335 VZ |
73 | |
74 | // ---------------------------------------------------------------------------- | |
2f2aa628 | 75 | // data |
7c0ea335 | 76 | // ---------------------------------------------------------------------------- |
2f2aa628 | 77 | |
c801d85f KB |
78 | extern wxList wxPendingDelete; |
79 | ||
7c0ea335 | 80 | // ---------------------------------------------------------------------------- |
2e563988 | 81 | // debug |
7c0ea335 | 82 | // ---------------------------------------------------------------------------- |
2e563988 RR |
83 | |
84 | #ifdef __WXDEBUG__ | |
85 | ||
86 | extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window ); | |
87 | ||
88 | #endif | |
89 | ||
7c0ea335 VZ |
90 | // ============================================================================ |
91 | // implementation | |
92 | // ============================================================================ | |
93 | ||
94 | // ---------------------------------------------------------------------------- | |
95 | // GTK callbacks | |
96 | // ---------------------------------------------------------------------------- | |
97 | ||
69ffe1d2 RR |
98 | //----------------------------------------------------------------------------- |
99 | // "focus" from m_window | |
100 | //----------------------------------------------------------------------------- | |
101 | ||
102 | static gint gtk_frame_focus_callback( GtkWidget *widget, GtkDirectionType WXUNUSED(d), wxWindow *WXUNUSED(win) ) | |
103 | { | |
104 | if (g_isIdle) | |
105 | wxapp_install_idle_handler(); | |
106 | ||
107 | // This disables GTK's tab traversal | |
108 | gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus" ); | |
109 | return TRUE; | |
110 | } | |
111 | ||
c801d85f | 112 | //----------------------------------------------------------------------------- |
2f2aa628 | 113 | // "size_allocate" |
c801d85f | 114 | //----------------------------------------------------------------------------- |
c801d85f | 115 | |
1e6feb95 | 116 | static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrameGTK *win ) |
ed7a557b | 117 | { |
88ac883a | 118 | if (g_isIdle) |
121a3581 | 119 | wxapp_install_idle_handler(); |
acfd422a | 120 | |
54517652 RR |
121 | if (!win->m_hasVMT) |
122 | return; | |
8bbe427f | 123 | |
121a3581 RR |
124 | if ((win->m_width != alloc->width) || (win->m_height != alloc->height)) |
125 | { | |
54517652 RR |
126 | /* |
127 | wxPrintf( "OnSize from " ); | |
128 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
129 | wxPrintf( win->GetClassInfo()->GetClassName() ); | |
130 | wxPrintf( " %d %d %d %d\n", (int)alloc->x, | |
131 | (int)alloc->y, | |
132 | (int)alloc->width, | |
133 | (int)alloc->height ); | |
134 | */ | |
7beba2fc | 135 | |
121a3581 RR |
136 | win->m_width = alloc->width; |
137 | win->m_height = alloc->height; | |
8cb9f0d0 | 138 | win->m_queuedFullRedraw = TRUE; |
5b8a521e | 139 | win->GtkUpdateSize(); |
121a3581 | 140 | } |
362c6693 | 141 | } |
c801d85f KB |
142 | |
143 | //----------------------------------------------------------------------------- | |
2f2aa628 RR |
144 | // "delete_event" |
145 | //----------------------------------------------------------------------------- | |
c801d85f | 146 | |
1e6feb95 | 147 | static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxFrameGTK *win ) |
ed7a557b | 148 | { |
88ac883a | 149 | if (g_isIdle) |
121a3581 | 150 | wxapp_install_idle_handler(); |
ed7a557b | 151 | |
a56fcaaf | 152 | if ((g_openDialogs == 0) && (win->IsEnabled())) |
2d68e1b4 | 153 | win->Close(); |
c801d85f | 154 | |
fb1585ae | 155 | return TRUE; |
362c6693 | 156 | } |
c801d85f | 157 | |
1e6feb95 | 158 | #if wxUSE_MENUS |
16bcc879 RR |
159 | //----------------------------------------------------------------------------- |
160 | // "child_attached" of menu bar | |
161 | //----------------------------------------------------------------------------- | |
162 | ||
1e6feb95 | 163 | static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrameGTK *win ) |
16bcc879 | 164 | { |
a2053b27 | 165 | if (!win->m_hasVMT) return; |
88ac883a | 166 | |
16bcc879 | 167 | win->m_menuBarDetached = FALSE; |
5b8a521e | 168 | win->GtkUpdateSize(); |
16bcc879 RR |
169 | } |
170 | ||
171 | //----------------------------------------------------------------------------- | |
172 | // "child_detached" of menu bar | |
173 | //----------------------------------------------------------------------------- | |
174 | ||
1e6feb95 | 175 | static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrameGTK *win ) |
16bcc879 | 176 | { |
a2053b27 | 177 | if (!win->m_hasVMT) return; |
88ac883a | 178 | |
16bcc879 | 179 | win->m_menuBarDetached = TRUE; |
5b8a521e | 180 | win->GtkUpdateSize(); |
16bcc879 | 181 | } |
1e6feb95 | 182 | #endif // wxUSE_MENUS |
16bcc879 | 183 | |
88ac883a | 184 | #if wxUSE_TOOLBAR |
16bcc879 RR |
185 | //----------------------------------------------------------------------------- |
186 | // "child_attached" of tool bar | |
187 | //----------------------------------------------------------------------------- | |
188 | ||
1e6feb95 | 189 | static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrameGTK *win ) |
16bcc879 | 190 | { |
a2053b27 | 191 | if (!win->m_hasVMT) return; |
88ac883a | 192 | |
16bcc879 | 193 | win->m_toolBarDetached = FALSE; |
88ac883a | 194 | |
5b8a521e | 195 | win->GtkUpdateSize(); |
16bcc879 RR |
196 | } |
197 | ||
198 | //----------------------------------------------------------------------------- | |
199 | // "child_detached" of tool bar | |
200 | //----------------------------------------------------------------------------- | |
201 | ||
1e6feb95 | 202 | static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrameGTK *win ) |
16bcc879 | 203 | { |
88ac883a | 204 | if (g_isIdle) |
801aa178 | 205 | wxapp_install_idle_handler(); |
acfd422a | 206 | |
a2053b27 | 207 | if (!win->m_hasVMT) return; |
88ac883a | 208 | |
16bcc879 | 209 | win->m_toolBarDetached = TRUE; |
5b8a521e | 210 | win->GtkUpdateSize(); |
16bcc879 | 211 | } |
88ac883a | 212 | #endif // wxUSE_TOOLBAR |
16bcc879 | 213 | |
47908e25 | 214 | //----------------------------------------------------------------------------- |
2f2aa628 RR |
215 | // "configure_event" |
216 | //----------------------------------------------------------------------------- | |
47908e25 | 217 | |
7beba2fc | 218 | static gint |
2d68e1b4 | 219 | #if (GTK_MINOR_VERSION > 0) |
1e6feb95 | 220 | gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxFrameGTK *win ) |
c693edf3 | 221 | #else |
1e6feb95 | 222 | gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrameGTK *win ) |
c693edf3 | 223 | #endif |
47908e25 | 224 | { |
7beba2fc | 225 | if (g_isIdle) |
121a3581 | 226 | wxapp_install_idle_handler(); |
acfd422a | 227 | |
7c0ea335 | 228 | if (!win->m_hasVMT) |
2d68e1b4 | 229 | return FALSE; |
f6bcfd97 | 230 | |
2d68e1b4 | 231 | #if (GTK_MINOR_VERSION > 0) |
dfc3d7e0 RR |
232 | int x = 0; |
233 | int y = 0; | |
234 | gdk_window_get_root_origin( win->m_widget->window, &x, &y ); | |
dfc3d7e0 RR |
235 | win->m_x = x; |
236 | win->m_y = y; | |
c693edf3 RR |
237 | #else |
238 | win->m_x = event->x; | |
239 | win->m_y = event->y; | |
240 | #endif | |
8bbe427f | 241 | |
a2053b27 | 242 | wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() ); |
36b3b54a RR |
243 | mevent.SetEventObject( win ); |
244 | win->GetEventHandler()->ProcessEvent( mevent ); | |
245 | ||
fb1585ae | 246 | return FALSE; |
362c6693 | 247 | } |
47908e25 | 248 | |
2b07d713 RR |
249 | //----------------------------------------------------------------------------- |
250 | // "realize" from m_widget | |
251 | //----------------------------------------------------------------------------- | |
252 | ||
88ac883a | 253 | /* we cannot MWM hints and icons before the widget has been realized, |
2b07d713 RR |
254 | so we do this directly after realization */ |
255 | ||
43f5c493 | 256 | static void |
1e6feb95 | 257 | gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget), wxFrameGTK *win ) |
2b07d713 | 258 | { |
88ac883a | 259 | if (g_isIdle) |
121a3581 | 260 | wxapp_install_idle_handler(); |
acfd422a | 261 | |
84eacd30 | 262 | if ((win->m_miniEdge > 0) || (win->HasFlag(wxSIMPLE_BORDER)) || (win->HasFlag(wxNO_BORDER))) |
15b24b14 | 263 | { |
80629c8b | 264 | /* This is a mini-frame or a borderless frame. */ |
81855216 RR |
265 | gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)0 ); |
266 | gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)0 ); | |
15b24b14 | 267 | } |
81855216 | 268 | else |
aa64626e | 269 | { |
81855216 RR |
270 | /* All this is for Motif Window Manager "hints" and is supposed to be |
271 | recognized by other WM as well. Not tested. */ | |
272 | long decor = (long) GDK_DECOR_BORDER; | |
273 | long func = (long) GDK_FUNC_MOVE; | |
274 | ||
275 | if ((win->GetWindowStyle() & wxCAPTION) != 0) | |
276 | decor |= GDK_DECOR_TITLE; | |
277 | if ((win->GetWindowStyle() & wxSYSTEM_MENU) != 0) | |
278 | { | |
279 | decor |= GDK_DECOR_MENU; | |
280 | func |= GDK_FUNC_CLOSE; | |
281 | } | |
282 | if ((win->GetWindowStyle() & wxMINIMIZE_BOX) != 0) | |
283 | { | |
284 | func |= GDK_FUNC_MINIMIZE; | |
285 | decor |= GDK_DECOR_MINIMIZE; | |
286 | } | |
287 | if ((win->GetWindowStyle() & wxMAXIMIZE_BOX) != 0) | |
288 | { | |
289 | func |= GDK_FUNC_MAXIMIZE; | |
290 | decor |= GDK_DECOR_MAXIMIZE; | |
291 | } | |
292 | if ((win->GetWindowStyle() & wxRESIZE_BORDER) != 0) | |
293 | { | |
294 | func |= GDK_FUNC_RESIZE; | |
295 | decor |= GDK_DECOR_RESIZEH; | |
296 | } | |
f6bcfd97 | 297 | |
81855216 RR |
298 | gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor); |
299 | gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func); | |
aa64626e KB |
300 | } |
301 | ||
2b07d713 | 302 | /* GTK's shrinking/growing policy */ |
f03fc89f | 303 | if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0) |
a2053b27 | 304 | gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1); |
2b07d713 | 305 | else |
a2053b27 | 306 | gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); |
88ac883a | 307 | |
58dea4b0 | 308 | /* reset the icon */ |
7c0ea335 VZ |
309 | wxIcon iconOld = win->GetIcon(); |
310 | if ( iconOld != wxNullIcon ) | |
58dea4b0 | 311 | { |
7c0ea335 VZ |
312 | wxIcon icon( iconOld ); |
313 | win->SetIcon( wxNullIcon ); | |
f03fc89f | 314 | win->SetIcon( icon ); |
58dea4b0 | 315 | } |
88ac883a | 316 | |
2e563988 RR |
317 | /* we set the focus to the child that accepts the focus. this |
318 | doesn't really have to be done in "realize" but why not? */ | |
f03fc89f | 319 | wxWindowList::Node *node = win->GetChildren().GetFirst(); |
2e563988 RR |
320 | while (node) |
321 | { | |
f03fc89f VZ |
322 | wxWindow *child = node->GetData(); |
323 | if (child->AcceptsFocus()) | |
324 | { | |
325 | child->SetFocus(); | |
326 | break; | |
327 | } | |
88ac883a | 328 | |
f03fc89f | 329 | node = node->GetNext(); |
2e563988 | 330 | } |
43f5c493 | 331 | } |
88ac883a | 332 | |
43f5c493 RR |
333 | //----------------------------------------------------------------------------- |
334 | // "map_event" from m_widget | |
335 | //----------------------------------------------------------------------------- | |
336 | ||
337 | static void | |
c0f09a2e VZ |
338 | gtk_frame_map_callback( GtkWidget * WXUNUSED(widget), |
339 | GdkEvent * WXUNUSED(event), | |
340 | wxFrame *win ) | |
43f5c493 | 341 | { |
3dd9b88a | 342 | win->SetIconizeState(FALSE); |
43f5c493 RR |
343 | } |
344 | ||
345 | //----------------------------------------------------------------------------- | |
346 | // "unmap_event" from m_widget | |
347 | //----------------------------------------------------------------------------- | |
348 | ||
349 | static void | |
c0f09a2e VZ |
350 | gtk_frame_unmap_callback( GtkWidget * WXUNUSED(widget), |
351 | GdkEvent * WXUNUSED(event), | |
352 | wxFrame *win ) | |
43f5c493 | 353 | { |
3dd9b88a | 354 | win->SetIconizeState(TRUE); |
227e5e99 | 355 | } |
88ac883a | 356 | |
117247fd RR |
357 | //----------------------------------------------------------------------------- |
358 | // "expose_event" of m_client | |
359 | //----------------------------------------------------------------------------- | |
360 | ||
361 | static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxWindow *win ) | |
362 | { | |
363 | GtkPizza *pizza = GTK_PIZZA(widget); | |
364 | ||
365 | gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, | |
3dd9b88a VZ |
366 | GTK_SHADOW_NONE, &gdk_event->area, win->m_widget, "base", 0, 0, -1, -1); |
367 | ||
117247fd RR |
368 | return TRUE; |
369 | } | |
370 | ||
371 | //----------------------------------------------------------------------------- | |
372 | // "draw" of m_client | |
373 | //----------------------------------------------------------------------------- | |
374 | ||
375 | ||
376 | static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxWindow *win ) | |
377 | { | |
378 | GtkPizza *pizza = GTK_PIZZA(widget); | |
379 | ||
3dd9b88a VZ |
380 | gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, |
381 | GTK_SHADOW_NONE, rect, win->m_widget, "base", 0, 0, -1, -1); | |
117247fd RR |
382 | } |
383 | ||
7c0ea335 | 384 | // ---------------------------------------------------------------------------- |
1e6feb95 | 385 | // wxFrameGTK itself |
7c0ea335 VZ |
386 | // ---------------------------------------------------------------------------- |
387 | ||
f362b96d | 388 | //----------------------------------------------------------------------------- |
1e6feb95 | 389 | // InsertChild for wxFrameGTK |
f362b96d RR |
390 | //----------------------------------------------------------------------------- |
391 | ||
1e6feb95 | 392 | /* Callback for wxFrameGTK. This very strange beast has to be used because |
f362b96d RR |
393 | * C++ has no virtual methods in a constructor. We have to emulate a |
394 | * virtual function here as wxWindows requires different ways to insert | |
395 | * a child in container classes. */ | |
396 | ||
1e6feb95 | 397 | static void wxInsertChildInFrame( wxFrameGTK* parent, wxWindow* child ) |
f362b96d | 398 | { |
5fd11f09 | 399 | wxASSERT( GTK_IS_WIDGET(child->m_widget) ); |
7beba2fc | 400 | |
6bc8a1c8 | 401 | if (!parent->m_insertInClientArea) |
f362b96d RR |
402 | { |
403 | /* these are outside the client area */ | |
1e6feb95 | 404 | wxFrameGTK* frame = (wxFrameGTK*) parent; |
da048e3d | 405 | gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget), |
a2053b27 RR |
406 | GTK_WIDGET(child->m_widget), |
407 | child->m_x, | |
408 | child->m_y, | |
409 | child->m_width, | |
410 | child->m_height ); | |
88ac883a | 411 | |
caf51f95 | 412 | #if wxUSE_TOOLBAR_NATIVE |
f03fc89f VZ |
413 | /* we connect to these events for recalculating the client area |
414 | space when the toolbar is floating */ | |
415 | if (wxIS_KIND_OF(child,wxToolBar)) | |
416 | { | |
417 | wxToolBar *toolBar = (wxToolBar*) child; | |
418 | if (toolBar->GetWindowStyle() & wxTB_DOCKABLE) | |
419 | { | |
a2053b27 | 420 | gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_attached", |
41ca191f | 421 | GTK_SIGNAL_FUNC(gtk_toolbar_attached_callback), (gpointer)parent ); |
88ac883a | 422 | |
a2053b27 | 423 | gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_detached", |
41ca191f | 424 | GTK_SIGNAL_FUNC(gtk_toolbar_detached_callback), (gpointer)parent ); |
f03fc89f VZ |
425 | } |
426 | } | |
88ac883a | 427 | #endif // wxUSE_TOOLBAR |
f362b96d RR |
428 | } |
429 | else | |
430 | { | |
431 | /* these are inside the client area */ | |
da048e3d | 432 | gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow), |
a2053b27 RR |
433 | GTK_WIDGET(child->m_widget), |
434 | child->m_x, | |
435 | child->m_y, | |
436 | child->m_width, | |
437 | child->m_height ); | |
f362b96d RR |
438 | } |
439 | ||
f362b96d | 440 | /* resize on OnInternalIdle */ |
5b8a521e | 441 | parent->GtkUpdateSize(); |
f362b96d RR |
442 | } |
443 | ||
7c0ea335 | 444 | // ---------------------------------------------------------------------------- |
1e6feb95 | 445 | // wxFrameGTK creation |
7c0ea335 | 446 | // ---------------------------------------------------------------------------- |
c801d85f | 447 | |
1e6feb95 | 448 | void wxFrameGTK::Init() |
c801d85f | 449 | { |
fb1585ae | 450 | m_sizeSet = FALSE; |
b2b3ccc5 RR |
451 | m_miniEdge = 0; |
452 | m_miniTitle = 0; | |
ab2b3dd4 | 453 | m_mainWidget = (GtkWidget*) NULL; |
16bcc879 RR |
454 | m_menuBarDetached = FALSE; |
455 | m_toolBarDetached = FALSE; | |
6bc8a1c8 | 456 | m_insertInClientArea = TRUE; |
d786bf87 | 457 | m_isFrame = TRUE; |
f94fca1b | 458 | m_isIconized = FALSE; |
43f5c493 | 459 | m_fsIsShowing = FALSE; |
a2d93e73 | 460 | m_themeEnabled = TRUE; |
362c6693 | 461 | } |
c801d85f | 462 | |
1e6feb95 | 463 | bool wxFrameGTK::Create( wxWindow *parent, |
7c0ea335 | 464 | wxWindowID id, |
ca8bf976 VZ |
465 | const wxString& title, |
466 | const wxPoint& pos, | |
467 | const wxSize& sizeOrig, | |
7c0ea335 VZ |
468 | long style, |
469 | const wxString &name ) | |
c801d85f | 470 | { |
ca8bf976 VZ |
471 | // always create a frame of some reasonable, even if arbitrary, size (at |
472 | // least for MSW compatibility) | |
473 | wxSize size = sizeOrig; | |
474 | if ( size.x == -1 || size.y == -1 ) | |
475 | { | |
476 | wxSize sizeDpy = wxGetDisplaySize(); | |
477 | if ( size.x == -1 ) | |
478 | size.x = sizeDpy.x / 3; | |
479 | if ( size.y == -1 ) | |
480 | size.y = sizeDpy.y / 5; | |
481 | } | |
482 | ||
a802c3a1 | 483 | wxTopLevelWindows.Append( this ); |
8bbe427f | 484 | |
fb1585ae | 485 | m_needParent = FALSE; |
ed7a557b | 486 | |
4dcaf11a RR |
487 | if (!PreCreation( parent, pos, size ) || |
488 | !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) | |
489 | { | |
1e6feb95 | 490 | wxFAIL_MSG( wxT("wxFrameGTK creation failed") ); |
7beba2fc | 491 | return FALSE; |
4dcaf11a | 492 | } |
c801d85f | 493 | |
fb1585ae | 494 | m_title = title; |
88ac883a | 495 | |
6bc8a1c8 | 496 | m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame; |
ed7a557b | 497 | |
faecf4cb | 498 | GtkWindowType win_type = GTK_WINDOW_TOPLEVEL; |
3dd9b88a | 499 | |
343e14b3 RR |
500 | if (style & wxFRAME_TOOL_WINDOW) |
501 | win_type = GTK_WINDOW_POPUP; | |
8bbe427f | 502 | |
fb1585ae | 503 | m_widget = gtk_window_new( win_type ); |
88ac883a | 504 | |
80629c8b RR |
505 | if ((m_parent) && (HasFlag(wxFRAME_FLOAT_ON_PARENT)) && (GTK_IS_WINDOW(m_parent->m_widget))) |
506 | gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) ); | |
507 | ||
de1c750f RR |
508 | if (!name.IsEmpty()) |
509 | gtk_window_set_wmclass( GTK_WINDOW(m_widget), name.mb_str(), name.mb_str() ); | |
8bbe427f | 510 | |
2e563988 | 511 | #ifdef __WXDEBUG__ |
1e6feb95 | 512 | debug_focus_in( m_widget, wxT("wxFrameGTK::m_widget"), name ); |
2e563988 RR |
513 | #endif |
514 | ||
ed9b9841 | 515 | gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() ); |
fb1585ae | 516 | GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); |
ed7a557b | 517 | |
fb1585ae RR |
518 | gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", |
519 | GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this ); | |
ed7a557b | 520 | |
f362b96d | 521 | /* m_mainWidget holds the toolbar, the menubar and the client area */ |
da048e3d | 522 | m_mainWidget = gtk_pizza_new(); |
f362b96d RR |
523 | gtk_widget_show( m_mainWidget ); |
524 | GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS ); | |
525 | gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget ); | |
88ac883a | 526 | |
117247fd RR |
527 | /* for m_mainWidget themes */ |
528 | gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event", | |
529 | GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this ); | |
530 | gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw", | |
531 | GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); | |
532 | ||
2e563988 | 533 | #ifdef __WXDEBUG__ |
1e6feb95 | 534 | debug_focus_in( m_mainWidget, wxT("wxFrameGTK::m_mainWidget"), name ); |
2e563988 RR |
535 | #endif |
536 | ||
f362b96d | 537 | /* m_wxwindow only represents the client area without toolbar and menubar */ |
da048e3d | 538 | m_wxwindow = gtk_pizza_new(); |
fb1585ae | 539 | gtk_widget_show( m_wxwindow ); |
f362b96d | 540 | gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow ); |
88ac883a | 541 | |
2e563988 | 542 | #ifdef __WXDEBUG__ |
1e6feb95 | 543 | debug_focus_in( m_wxwindow, wxT("wxFrameGTK::m_wxwindow"), name ); |
2e563988 RR |
544 | #endif |
545 | ||
546 | /* we donm't allow the frame to get the focus as otherwise | |
3dd9b88a | 547 | the frame will grab it at arbitrary focus changes. */ |
2e563988 | 548 | GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); |
ed7a557b | 549 | |
de8113d9 RR |
550 | if (m_parent) m_parent->AddChild( this ); |
551 | ||
54517652 RR |
552 | /* the user resized the frame by dragging etc. */ |
553 | gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", | |
554 | GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); | |
555 | ||
de8113d9 RR |
556 | PostCreation(); |
557 | ||
15909a16 RR |
558 | if ((m_x != -1) || (m_y != -1)) |
559 | gtk_widget_set_uposition( m_widget, m_x, m_y ); | |
560 | gtk_widget_set_usize( m_widget, m_width, m_height ); | |
f6bcfd97 | 561 | |
58dea4b0 | 562 | /* we cannot set MWM hints and icons before the widget has |
2b07d713 RR |
563 | been realized, so we do this directly after realization */ |
564 | gtk_signal_connect( GTK_OBJECT(m_widget), "realize", | |
f03fc89f | 565 | GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this ); |
88ac883a | 566 | |
ab2b3dd4 | 567 | /* the only way to get the window size is to connect to this event */ |
fb1585ae RR |
568 | gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", |
569 | GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this ); | |
8bbe427f | 570 | |
43f5c493 RR |
571 | /* map and unmap for iconized state */ |
572 | gtk_signal_connect( GTK_OBJECT(m_widget), "map_event", | |
573 | GTK_SIGNAL_FUNC(gtk_frame_map_callback), (gpointer)this ); | |
574 | gtk_signal_connect( GTK_OBJECT(m_widget), "unmap_event", | |
575 | GTK_SIGNAL_FUNC(gtk_frame_unmap_callback), (gpointer)this ); | |
576 | ||
577 | /* the only way to get the window size is to connect to this event */ | |
578 | gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", | |
579 | GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this ); | |
580 | ||
69ffe1d2 RR |
581 | /* disable native tab traversal */ |
582 | gtk_signal_connect( GTK_OBJECT(m_widget), "focus", | |
583 | GTK_SIGNAL_FUNC(gtk_frame_focus_callback), (gpointer)this ); | |
584 | ||
fb1585ae | 585 | return TRUE; |
362c6693 | 586 | } |
c801d85f | 587 | |
1e6feb95 | 588 | wxFrameGTK::~wxFrameGTK() |
c801d85f | 589 | { |
31c6b4fc | 590 | m_isBeingDeleted = TRUE; |
88ac883a | 591 | |
7c0ea335 | 592 | DeleteAllBars(); |
ed7a557b | 593 | |
fb1585ae | 594 | wxTopLevelWindows.DeleteObject( this ); |
2b854a32 | 595 | |
0d2a2b60 | 596 | if (wxTheApp->GetTopWindow() == this) |
0d2a2b60 | 597 | wxTheApp->SetTopWindow( (wxWindow*) NULL ); |
2b854a32 | 598 | |
f59d80ca RR |
599 | if ((wxTopLevelWindows.Number() == 0) && |
600 | (wxTheApp->GetExitOnFrameDelete())) | |
601 | { | |
0d2a2b60 | 602 | wxTheApp->ExitMainLoop(); |
f59d80ca | 603 | } |
362c6693 | 604 | } |
ed7a557b | 605 | |
3d0c4d2e RR |
606 | bool wxFrame::ShowFullScreen(bool show, long style ) |
607 | { | |
608 | if (show == m_fsIsShowing) return FALSE; // return what? | |
609 | ||
610 | m_fsIsShowing = show; | |
3dd9b88a | 611 | |
3d0c4d2e RR |
612 | if (show) |
613 | { | |
614 | m_fsSaveStyle = m_windowStyle; | |
615 | m_fsSaveFlag = style; | |
616 | GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y ); | |
617 | GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height ); | |
3dd9b88a | 618 | |
3d0c4d2e RR |
619 | gtk_widget_hide( m_widget ); |
620 | gtk_widget_unrealize( m_widget ); | |
3dd9b88a | 621 | |
3d0c4d2e | 622 | m_windowStyle = wxSIMPLE_BORDER; |
3dd9b88a | 623 | |
3d0c4d2e RR |
624 | int x; |
625 | int y; | |
626 | wxDisplaySize( &x, &y ); | |
627 | SetSize( 0, 0, x, y ); | |
3dd9b88a | 628 | |
3d0c4d2e RR |
629 | gtk_widget_realize( m_widget ); |
630 | gtk_widget_show( m_widget ); | |
631 | } | |
632 | else | |
633 | { | |
634 | gtk_widget_hide( m_widget ); | |
635 | gtk_widget_unrealize( m_widget ); | |
3dd9b88a | 636 | |
3d0c4d2e | 637 | m_windowStyle = m_fsSaveStyle; |
3dd9b88a | 638 | |
3d0c4d2e | 639 | SetSize( m_fsSaveFrame.x, m_fsSaveFrame.y, m_fsSaveFrame.width, m_fsSaveFrame.height ); |
3dd9b88a | 640 | |
3d0c4d2e RR |
641 | gtk_widget_realize( m_widget ); |
642 | gtk_widget_show( m_widget ); | |
643 | } | |
3dd9b88a | 644 | |
3d0c4d2e RR |
645 | return TRUE; |
646 | } | |
647 | ||
7c0ea335 VZ |
648 | // ---------------------------------------------------------------------------- |
649 | // overridden wxWindow methods | |
650 | // ---------------------------------------------------------------------------- | |
651 | ||
1e6feb95 | 652 | bool wxFrameGTK::Show( bool show ) |
c801d85f | 653 | { |
223d09f6 | 654 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
8bbe427f | 655 | |
35178437 | 656 | if (show && !m_sizeSet) |
fb1585ae | 657 | { |
e27ce4e9 RR |
658 | /* by calling GtkOnSize here, we don't have to call |
659 | either after showing the frame, which would entail | |
f362b96d | 660 | much ugly flicker or from within the size_allocate |
e27ce4e9 | 661 | handler, because GTK 1.1.X forbids that. */ |
8bbe427f | 662 | |
35178437 | 663 | GtkOnSize( m_x, m_y, m_width, m_height ); |
fb1585ae | 664 | } |
8bbe427f | 665 | |
fb1585ae | 666 | return wxWindow::Show( show ); |
362c6693 | 667 | } |
c801d85f | 668 | |
1e6feb95 | 669 | void wxFrameGTK::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) ) |
23efdd02 | 670 | { |
1e6feb95 | 671 | wxFAIL_MSG( wxT("DoMoveWindow called for wxFrameGTK") ); |
23efdd02 | 672 | } |
f6bcfd97 | 673 | |
1e6feb95 | 674 | void wxFrameGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags ) |
903f689b | 675 | { |
223d09f6 | 676 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
8bbe427f | 677 | |
1e6feb95 | 678 | /* this shouldn't happen: wxFrameGTK, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */ |
223d09f6 | 679 | wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") ); |
88ac883a | 680 | |
ab2b3dd4 | 681 | /* avoid recursions */ |
7c0ea335 VZ |
682 | if (m_resizing) |
683 | return; | |
fb1585ae RR |
684 | m_resizing = TRUE; |
685 | ||
686 | int old_x = m_x; | |
687 | int old_y = m_y; | |
7beba2fc | 688 | |
fb1585ae RR |
689 | int old_width = m_width; |
690 | int old_height = m_height; | |
8bbe427f | 691 | |
85ad5eb5 | 692 | if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0) |
fb1585ae RR |
693 | { |
694 | if (x != -1) m_x = x; | |
695 | if (y != -1) m_y = y; | |
696 | if (width != -1) m_width = width; | |
697 | if (height != -1) m_height = height; | |
698 | } | |
699 | else | |
700 | { | |
701 | m_x = x; | |
702 | m_y = y; | |
703 | m_width = width; | |
704 | m_height = height; | |
705 | } | |
706 | ||
11e1c70d | 707 | /* |
fb1585ae RR |
708 | if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH) |
709 | { | |
710 | if (width == -1) m_width = 80; | |
711 | } | |
712 | ||
713 | if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT) | |
714 | { | |
715 | if (height == -1) m_height = 26; | |
716 | } | |
11e1c70d | 717 | */ |
8bbe427f | 718 | |
fb1585ae RR |
719 | if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; |
720 | if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; | |
0c77152e RR |
721 | if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth; |
722 | if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight; | |
fb1585ae RR |
723 | |
724 | if ((m_x != -1) || (m_y != -1)) | |
725 | { | |
8bbe427f | 726 | if ((m_x != old_x) || (m_y != old_y)) |
0138c2de | 727 | { |
8487f887 | 728 | gtk_widget_set_uposition( m_widget, m_x, m_y ); |
0138c2de | 729 | } |
fb1585ae | 730 | } |
8bbe427f | 731 | |
fb1585ae RR |
732 | if ((m_width != old_width) || (m_height != old_height)) |
733 | { | |
15909a16 RR |
734 | gtk_widget_set_usize( m_widget, m_width, m_height ); |
735 | ||
ab2b3dd4 | 736 | /* we set the size in GtkOnSize, i.e. mostly the actual resizing is |
f03fc89f VZ |
737 | done either directly before the frame is shown or in idle time |
738 | so that different calls to SetSize() don't lead to flicker. */ | |
de8113d9 | 739 | m_sizeSet = FALSE; |
fb1585ae | 740 | } |
8bbe427f | 741 | |
fb1585ae | 742 | m_resizing = FALSE; |
903f689b RR |
743 | } |
744 | ||
1e6feb95 | 745 | void wxFrameGTK::DoGetClientSize( int *width, int *height ) const |
c801d85f | 746 | { |
223d09f6 | 747 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
8bbe427f | 748 | |
f9241296 | 749 | wxWindow::DoGetClientSize( width, height ); |
fb1585ae | 750 | if (height) |
46dc76ba | 751 | { |
1e6feb95 | 752 | #if wxUSE_MENUS |
41ca191f RR |
753 | /* menu bar */ |
754 | if (m_frameMenuBar) | |
f03fc89f | 755 | { |
88ac883a | 756 | if (!m_menuBarDetached) |
f03fc89f VZ |
757 | (*height) -= wxMENU_HEIGHT; |
758 | else | |
759 | (*height) -= wxPLACE_HOLDER; | |
760 | } | |
1e6feb95 | 761 | #endif // wxUSE_MENUS |
88ac883a | 762 | |
dcf924a3 | 763 | #if wxUSE_STATUSBAR |
f03fc89f | 764 | /* status bar */ |
fa755cf1 | 765 | if (m_frameStatusBar && m_frameStatusBar->IsShown()) (*height) -= wxSTATUS_HEIGHT; |
93fa69f8 | 766 | #endif // wxUSE_STATUSBAR |
88ac883a | 767 | |
dcf924a3 | 768 | #if wxUSE_TOOLBAR |
f03fc89f | 769 | /* tool bar */ |
fa755cf1 | 770 | if (m_frameToolBar && m_frameToolBar->IsShown()) |
fb1585ae | 771 | { |
93fa69f8 | 772 | if (m_toolBarDetached) |
f03fc89f | 773 | { |
93fa69f8 | 774 | *height -= wxPLACE_HOLDER; |
f03fc89f VZ |
775 | } |
776 | else | |
93fa69f8 VZ |
777 | { |
778 | int x, y; | |
779 | m_frameToolBar->GetSize( &x, &y ); | |
780 | if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) | |
781 | { | |
782 | *width -= x; | |
783 | } | |
784 | else | |
785 | { | |
786 | *height -= y; | |
787 | } | |
788 | } | |
fb1585ae | 789 | } |
93fa69f8 | 790 | #endif // wxUSE_TOOLBAR |
88ac883a | 791 | |
f03fc89f | 792 | /* mini edge */ |
93fa69f8 | 793 | *height -= m_miniEdge*2 + m_miniTitle; |
b2b3ccc5 RR |
794 | } |
795 | if (width) | |
796 | { | |
93fa69f8 | 797 | *width -= m_miniEdge*2; |
46dc76ba | 798 | } |
362c6693 | 799 | } |
c801d85f | 800 | |
1e6feb95 | 801 | void wxFrameGTK::DoSetClientSize( int width, int height ) |
b593568e | 802 | { |
223d09f6 | 803 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
8bbe427f | 804 | |
1e6feb95 | 805 | #if wxUSE_MENUS |
41ca191f RR |
806 | /* menu bar */ |
807 | if (m_frameMenuBar) | |
f03fc89f | 808 | { |
88ac883a | 809 | if (!m_menuBarDetached) |
f03fc89f VZ |
810 | height += wxMENU_HEIGHT; |
811 | else | |
812 | height += wxPLACE_HOLDER; | |
813 | } | |
1e6feb95 | 814 | #endif // wxUSE_MENUS |
88ac883a | 815 | |
dcf924a3 | 816 | #if wxUSE_STATUSBAR |
f03fc89f | 817 | /* status bar */ |
fa755cf1 | 818 | if (m_frameStatusBar && m_frameStatusBar->IsShown()) height += wxSTATUS_HEIGHT; |
dcf924a3 | 819 | #endif |
88ac883a | 820 | |
dcf924a3 | 821 | #if wxUSE_TOOLBAR |
f03fc89f | 822 | /* tool bar */ |
fa755cf1 | 823 | if (m_frameToolBar && m_frameToolBar->IsShown()) |
41ca191f | 824 | { |
93fa69f8 | 825 | if (m_toolBarDetached) |
f03fc89f | 826 | { |
93fa69f8 | 827 | height += wxPLACE_HOLDER; |
f03fc89f VZ |
828 | } |
829 | else | |
93fa69f8 VZ |
830 | { |
831 | int x, y; | |
832 | m_frameToolBar->GetSize( &x, &y ); | |
833 | if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) | |
834 | { | |
835 | width += x; | |
836 | } | |
837 | else | |
838 | { | |
839 | height += y; | |
840 | } | |
841 | } | |
41ca191f | 842 | } |
dcf924a3 | 843 | #endif |
88ac883a | 844 | |
3017f78d | 845 | DoSetSize( -1, -1, width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0 ); |
362c6693 | 846 | } |
b593568e | 847 | |
1e6feb95 | 848 | void wxFrameGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), |
7c0ea335 | 849 | int width, int height ) |
c801d85f | 850 | { |
f5368809 RR |
851 | // due to a bug in gtk, x,y are always 0 |
852 | // m_x = x; | |
853 | // m_y = y; | |
854 | ||
ab2b3dd4 | 855 | /* avoid recursions */ |
e52f60e6 RR |
856 | if (m_resizing) return; |
857 | m_resizing = TRUE; | |
8bbe427f | 858 | |
1e6feb95 | 859 | /* this shouldn't happen: wxFrameGTK, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */ |
223d09f6 | 860 | wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") ); |
88ac883a | 861 | |
f5368809 RR |
862 | m_width = width; |
863 | m_height = height; | |
7beba2fc | 864 | |
ab2b3dd4 | 865 | /* space occupied by m_frameToolBar and m_frameMenuBar */ |
93fa69f8 VZ |
866 | int client_area_x_offset = 0, |
867 | client_area_y_offset = 0; | |
8bbe427f | 868 | |
1e6feb95 | 869 | /* wxMDIChildFrame derives from wxFrameGTK but it _is_ a wxWindow as it uses |
ab2b3dd4 | 870 | wxWindow::Create to create it's GTK equivalent. m_mainWidget is only |
1e6feb95 | 871 | set in wxFrameGTK::Create so it is used to check what kind of frame we |
ab2b3dd4 RR |
872 | have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we |
873 | skip the part which handles m_frameMenuBar, m_frameToolBar and (most | |
874 | importantly) m_mainWidget */ | |
88ac883a | 875 | |
1f3c610d RR |
876 | if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; |
877 | if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; | |
878 | if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth; | |
879 | if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight; | |
1f3c610d | 880 | |
ab2b3dd4 | 881 | if (m_mainWidget) |
f5368809 | 882 | { |
f6bcfd97 BP |
883 | /* set size hints */ |
884 | gint flag = 0; // GDK_HINT_POS; | |
885 | if ((m_minWidth != -1) || (m_minHeight != -1)) flag |= GDK_HINT_MIN_SIZE; | |
886 | if ((m_maxWidth != -1) || (m_maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE; | |
887 | GdkGeometry geom; | |
888 | geom.min_width = m_minWidth; | |
889 | geom.min_height = m_minHeight; | |
890 | geom.max_width = m_maxWidth; | |
891 | geom.max_height = m_maxHeight; | |
892 | gtk_window_set_geometry_hints( GTK_WINDOW(m_widget), | |
893 | (GtkWidget*) NULL, | |
894 | &geom, | |
895 | (GdkWindowHints) flag ); | |
ab2b3dd4 RR |
896 | |
897 | /* I revert back to wxGTK's original behaviour. m_mainWidget holds the | |
898 | * menubar, the toolbar and the client area, which is represented by | |
899 | * m_wxwindow. | |
900 | * this hurts in the eye, but I don't want to call SetSize() | |
901 | * because I don't want to call any non-native functions here. */ | |
88ac883a | 902 | |
1e6feb95 | 903 | #if wxUSE_MENUS |
ab2b3dd4 RR |
904 | if (m_frameMenuBar) |
905 | { | |
906 | int xx = m_miniEdge; | |
907 | int yy = m_miniEdge + m_miniTitle; | |
908 | int ww = m_width - 2*m_miniEdge; | |
41ca191f | 909 | int hh = wxMENU_HEIGHT; |
f03fc89f | 910 | if (m_menuBarDetached) hh = wxPLACE_HOLDER; |
121a3581 RR |
911 | m_frameMenuBar->m_x = xx; |
912 | m_frameMenuBar->m_y = yy; | |
913 | m_frameMenuBar->m_width = ww; | |
914 | m_frameMenuBar->m_height = hh; | |
da048e3d | 915 | gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), |
88ac883a | 916 | m_frameMenuBar->m_widget, |
f03fc89f VZ |
917 | xx, yy, ww, hh ); |
918 | client_area_y_offset += hh; | |
ab2b3dd4 | 919 | } |
1e6feb95 | 920 | #endif // wxUSE_MENUS |
88ac883a | 921 | |
dcf924a3 | 922 | #if wxUSE_TOOLBAR |
fa755cf1 | 923 | if ((m_frameToolBar) && m_frameToolBar->IsShown() && |
7beba2fc | 924 | (m_frameToolBar->m_widget->parent == m_mainWidget)) |
ab2b3dd4 RR |
925 | { |
926 | int xx = m_miniEdge; | |
927 | int yy = m_miniEdge + m_miniTitle; | |
1e6feb95 | 928 | #if wxUSE_MENUS |
41ca191f | 929 | if (m_frameMenuBar) |
f03fc89f | 930 | { |
88ac883a VZ |
931 | if (!m_menuBarDetached) |
932 | yy += wxMENU_HEIGHT; | |
933 | else | |
f03fc89f VZ |
934 | yy += wxPLACE_HOLDER; |
935 | } | |
1e6feb95 | 936 | #endif // wxUSE_MENUS |
93fa69f8 | 937 | |
121a3581 RR |
938 | m_frameToolBar->m_x = xx; |
939 | m_frameToolBar->m_y = yy; | |
93fa69f8 VZ |
940 | |
941 | /* don't change the toolbar's reported height/width */ | |
942 | int ww, hh; | |
943 | if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) | |
944 | { | |
945 | ww = m_toolBarDetached ? wxPLACE_HOLDER | |
946 | : m_frameToolBar->m_width; | |
947 | hh = m_height - 2*m_miniEdge; | |
948 | ||
949 | client_area_x_offset += ww; | |
950 | } | |
951 | else | |
952 | { | |
953 | ww = m_width - 2*m_miniEdge; | |
954 | hh = m_toolBarDetached ? wxPLACE_HOLDER | |
955 | : m_frameToolBar->m_height; | |
956 | ||
957 | client_area_y_offset += hh; | |
958 | } | |
959 | ||
da048e3d | 960 | gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), |
88ac883a | 961 | m_frameToolBar->m_widget, |
f03fc89f | 962 | xx, yy, ww, hh ); |
ab2b3dd4 | 963 | } |
93fa69f8 | 964 | #endif // wxUSE_TOOLBAR |
88ac883a | 965 | |
93fa69f8 | 966 | int client_x = client_area_x_offset + m_miniEdge; |
f03fc89f | 967 | int client_y = client_area_y_offset + m_miniEdge + m_miniTitle; |
93fa69f8 | 968 | int client_w = m_width - client_area_x_offset - 2*m_miniEdge; |
f03fc89f | 969 | int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle; |
da048e3d | 970 | gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), |
88ac883a | 971 | m_wxwindow, |
f03fc89f | 972 | client_x, client_y, client_w, client_h ); |
32a95f9f RR |
973 | } |
974 | else | |
975 | { | |
976 | /* if there is no m_mainWidget between m_widget and m_wxwindow there | |
f03fc89f | 977 | is no need to set the size or position of m_wxwindow. */ |
f5368809 | 978 | } |
88ac883a | 979 | |
dcf924a3 | 980 | #if wxUSE_STATUSBAR |
fa755cf1 | 981 | if (m_frameStatusBar && m_frameStatusBar->IsShown()) |
f5368809 | 982 | { |
b2b3ccc5 | 983 | int xx = 0 + m_miniEdge; |
f362b96d | 984 | int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset; |
ac57418f RR |
985 | int ww = m_width - 2*m_miniEdge; |
986 | int hh = wxSTATUS_HEIGHT; | |
121a3581 RR |
987 | m_frameStatusBar->m_x = xx; |
988 | m_frameStatusBar->m_y = yy; | |
989 | m_frameStatusBar->m_width = ww; | |
990 | m_frameStatusBar->m_height = hh; | |
da048e3d | 991 | gtk_pizza_set_size( GTK_PIZZA(m_wxwindow), |
7c0ea335 VZ |
992 | m_frameStatusBar->m_widget, |
993 | xx, yy, ww, hh ); | |
b6fa52db | 994 | gtk_widget_draw( m_frameStatusBar->m_widget, (GdkRectangle*) NULL ); |
f5368809 | 995 | } |
1e6feb95 | 996 | #endif // wxUSE_STATUSBAR |
8bbe427f | 997 | |
54517652 | 998 | m_sizeSet = TRUE; |
7beba2fc | 999 | |
54517652 | 1000 | // send size event to frame |
43a18898 RR |
1001 | wxSizeEvent event( wxSize(m_width,m_height), GetId() ); |
1002 | event.SetEventObject( this ); | |
e52f60e6 | 1003 | GetEventHandler()->ProcessEvent( event ); |
8bbe427f | 1004 | |
1e6feb95 | 1005 | #if wxUSE_STATUSBAR |
54517652 | 1006 | // send size event to status bar |
5aa5e35a RR |
1007 | if (m_frameStatusBar) |
1008 | { | |
a2053b27 | 1009 | wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() ); |
5aa5e35a RR |
1010 | event2.SetEventObject( m_frameStatusBar ); |
1011 | m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 ); | |
1012 | } | |
1e6feb95 | 1013 | #endif // wxUSE_STATUSBAR |
884470b1 | 1014 | |
e52f60e6 RR |
1015 | m_resizing = FALSE; |
1016 | } | |
1017 | ||
1e6feb95 | 1018 | void wxFrameGTK::MakeModal( bool modal ) |
ca26177c RR |
1019 | { |
1020 | if (modal) | |
ca26177c | 1021 | gtk_grab_add( m_widget ); |
ca26177c | 1022 | else |
c25ccf85 | 1023 | gtk_grab_remove( m_widget ); |
ca26177c RR |
1024 | } |
1025 | ||
1e6feb95 | 1026 | void wxFrameGTK::OnInternalIdle() |
e52f60e6 | 1027 | { |
1b3667ab | 1028 | if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow)) |
54517652 | 1029 | { |
e52f60e6 | 1030 | GtkOnSize( m_x, m_y, m_width, m_height ); |
7beba2fc VZ |
1031 | |
1032 | // we'll come back later | |
54517652 RR |
1033 | if (g_isIdle) |
1034 | wxapp_install_idle_handler(); | |
7beba2fc | 1035 | return; |
54517652 | 1036 | } |
88ac883a | 1037 | |
1e6feb95 | 1038 | #if wxUSE_MENUS |
082b2798 | 1039 | if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle(); |
1e6feb95 | 1040 | #endif // wxUSE_MENUS |
dcf924a3 | 1041 | #if wxUSE_TOOLBAR |
082b2798 | 1042 | if (m_frameToolBar) m_frameToolBar->OnInternalIdle(); |
dcf924a3 RR |
1043 | #endif |
1044 | #if wxUSE_STATUSBAR | |
082b2798 | 1045 | if (m_frameStatusBar) m_frameStatusBar->OnInternalIdle(); |
dcf924a3 | 1046 | #endif |
5e014a0c RR |
1047 | |
1048 | wxWindow::OnInternalIdle(); | |
362c6693 | 1049 | } |
c801d85f | 1050 | |
7c0ea335 VZ |
1051 | // ---------------------------------------------------------------------------- |
1052 | // menu/tool/status bar stuff | |
1053 | // ---------------------------------------------------------------------------- | |
c801d85f | 1054 | |
1e6feb95 VZ |
1055 | #if wxUSE_MENUS |
1056 | ||
1057 | void wxFrameGTK::SetMenuBar( wxMenuBar *menuBar ) | |
c801d85f | 1058 | { |
223d09f6 KB |
1059 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
1060 | wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") ); | |
8bbe427f | 1061 | |
186baeb2 RR |
1062 | if (menuBar == m_frameMenuBar) |
1063 | return; | |
1064 | ||
1065 | if (m_frameMenuBar) | |
1066 | { | |
1067 | m_frameMenuBar->UnsetInvokingWindow( this ); | |
1068 | ||
1069 | if (m_frameMenuBar->GetWindowStyle() & wxMB_DOCKABLE) | |
1070 | { | |
1071 | gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar->m_widget), | |
1072 | GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this ); | |
1073 | ||
1074 | gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar->m_widget), | |
1075 | GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this ); | |
1076 | } | |
f6bcfd97 | 1077 | |
186baeb2 RR |
1078 | gtk_container_remove( GTK_CONTAINER(m_mainWidget), m_frameMenuBar->m_widget ); |
1079 | gtk_widget_ref( m_frameMenuBar->m_widget ); | |
1080 | gtk_widget_unparent( m_frameMenuBar->m_widget ); | |
1081 | } | |
1082 | ||
f5368809 | 1083 | m_frameMenuBar = menuBar; |
8bbe427f | 1084 | |
f5368809 | 1085 | if (m_frameMenuBar) |
30dea054 | 1086 | { |
5bd9e519 | 1087 | m_frameMenuBar->SetInvokingWindow( this ); |
8bbe427f | 1088 | |
186baeb2 RR |
1089 | m_frameMenuBar->SetParent(this); |
1090 | gtk_pizza_put( GTK_PIZZA(m_mainWidget), | |
88ac883a VZ |
1091 | m_frameMenuBar->m_widget, |
1092 | m_frameMenuBar->m_x, | |
a2053b27 RR |
1093 | m_frameMenuBar->m_y, |
1094 | m_frameMenuBar->m_width, | |
1095 | m_frameMenuBar->m_height ); | |
88ac883a | 1096 | |
186baeb2 RR |
1097 | if (menuBar->GetWindowStyle() & wxMB_DOCKABLE) |
1098 | { | |
1099 | gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_attached", | |
1100 | GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this ); | |
7beba2fc | 1101 | |
186baeb2 RR |
1102 | gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached", |
1103 | GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this ); | |
f5368809 | 1104 | } |
186baeb2 RR |
1105 | |
1106 | m_frameMenuBar->Show( TRUE ); | |
716b7364 | 1107 | } |
8bbe427f | 1108 | |
1e133b7d | 1109 | /* resize window in OnInternalIdle */ |
5b077d48 | 1110 | m_sizeSet = FALSE; |
362c6693 | 1111 | } |
c801d85f | 1112 | |
1e6feb95 VZ |
1113 | #endif // wxUSE_MENUS |
1114 | ||
88ac883a | 1115 | #if wxUSE_TOOLBAR |
1e6feb95 VZ |
1116 | |
1117 | wxToolBar* wxFrameGTK::CreateToolBar( long style, wxWindowID id, const wxString& name ) | |
46dc76ba | 1118 | { |
223d09f6 | 1119 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
8bbe427f | 1120 | |
6bc8a1c8 | 1121 | m_insertInClientArea = FALSE; |
88ac883a | 1122 | |
7c0ea335 | 1123 | m_frameToolBar = wxFrameBase::CreateToolBar( style, id, name ); |
8bbe427f | 1124 | |
6bc8a1c8 | 1125 | m_insertInClientArea = TRUE; |
8bbe427f | 1126 | |
5b077d48 | 1127 | m_sizeSet = FALSE; |
8bbe427f | 1128 | |
f5368809 | 1129 | return m_frameToolBar; |
362c6693 | 1130 | } |
46dc76ba | 1131 | |
1e6feb95 | 1132 | void wxFrameGTK::SetToolBar(wxToolBar *toolbar) |
7beba2fc | 1133 | { |
7c0ea335 VZ |
1134 | wxFrameBase::SetToolBar(toolbar); |
1135 | ||
307f16e8 RR |
1136 | if (m_frameToolBar) |
1137 | { | |
1138 | /* insert into toolbar area if not already there */ | |
3017f78d RR |
1139 | if ((m_frameToolBar->m_widget->parent) && |
1140 | (m_frameToolBar->m_widget->parent != m_mainWidget)) | |
307f16e8 | 1141 | { |
3017f78d | 1142 | GetChildren().DeleteObject( m_frameToolBar ); |
7beba2fc VZ |
1143 | |
1144 | gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget ); | |
5b8a521e | 1145 | GtkUpdateSize(); |
7beba2fc | 1146 | } |
307f16e8 RR |
1147 | } |
1148 | } | |
1149 | ||
88ac883a | 1150 | #endif // wxUSE_TOOLBAR |
46dc76ba | 1151 | |
88ac883a | 1152 | #if wxUSE_STATUSBAR |
8bbe427f | 1153 | |
1e6feb95 | 1154 | wxStatusBar* wxFrameGTK::CreateStatusBar(int number, |
7c0ea335 VZ |
1155 | long style, |
1156 | wxWindowID id, | |
1157 | const wxString& name) | |
c801d85f | 1158 | { |
223d09f6 | 1159 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
8bbe427f | 1160 | |
7c0ea335 VZ |
1161 | // because it will change when toolbar is added |
1162 | m_sizeSet = FALSE; | |
c801d85f | 1163 | |
7c0ea335 | 1164 | return wxFrameBase::CreateStatusBar( number, style, id, name ); |
362c6693 RR |
1165 | } |
1166 | ||
1e6feb95 | 1167 | void wxFrameGTK::PositionStatusBar() |
8febdd39 RR |
1168 | { |
1169 | if ( !m_frameStatusBar ) | |
1170 | return; | |
1171 | ||
1172 | m_sizeSet = FALSE; | |
1173 | } | |
88ac883a | 1174 | #endif // wxUSE_STATUSBAR |
c801d85f | 1175 | |
7c0ea335 VZ |
1176 | // ---------------------------------------------------------------------------- |
1177 | // frame title/icon | |
1178 | // ---------------------------------------------------------------------------- | |
c801d85f | 1179 | |
1e6feb95 | 1180 | void wxFrameGTK::SetTitle( const wxString &title ) |
c801d85f | 1181 | { |
223d09f6 | 1182 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
8bbe427f | 1183 | |
f5368809 | 1184 | m_title = title; |
ed9b9841 | 1185 | gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() ); |
362c6693 | 1186 | } |
c801d85f | 1187 | |
1e6feb95 | 1188 | void wxFrameGTK::SetIcon( const wxIcon &icon ) |
d355d3fe | 1189 | { |
223d09f6 | 1190 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
8bbe427f | 1191 | |
7c0ea335 | 1192 | wxFrameBase::SetIcon(icon); |
8bbe427f | 1193 | |
7c0ea335 VZ |
1194 | if ( !m_icon.Ok() ) |
1195 | return; | |
1196 | ||
1197 | if (!m_widget->window) | |
1198 | return; | |
58dea4b0 | 1199 | |
f5368809 RR |
1200 | wxMask *mask = icon.GetMask(); |
1201 | GdkBitmap *bm = (GdkBitmap *) NULL; | |
1202 | if (mask) bm = mask->GetBitmap(); | |
8bbe427f | 1203 | |
f5368809 | 1204 | gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm ); |
d355d3fe | 1205 | } |
b2b3ccc5 | 1206 | |
7c0ea335 | 1207 | // ---------------------------------------------------------------------------- |
c0f09a2e | 1208 | // frame state: maximized/iconized/normal |
7c0ea335 VZ |
1209 | // ---------------------------------------------------------------------------- |
1210 | ||
1e6feb95 | 1211 | void wxFrameGTK::Maximize(bool WXUNUSED(maximize)) |
cd25b18c | 1212 | { |
c0f09a2e | 1213 | wxFAIL_MSG( _T("not implemented") ); |
cd25b18c RR |
1214 | } |
1215 | ||
1e6feb95 | 1216 | bool wxFrameGTK::IsMaximized() const |
7c0ea335 | 1217 | { |
a2d93e73 | 1218 | // wxFAIL_MSG( _T("not implemented") ); |
c0f09a2e | 1219 | |
a2d93e73 | 1220 | // This is an approximation |
7c0ea335 VZ |
1221 | return FALSE; |
1222 | } | |
1223 | ||
1e6feb95 | 1224 | void wxFrameGTK::Restore() |
cd25b18c | 1225 | { |
c0f09a2e | 1226 | wxFAIL_MSG( _T("not implemented") ); |
cd25b18c RR |
1227 | } |
1228 | ||
1e6feb95 | 1229 | void wxFrameGTK::Iconize( bool iconize ) |
7beba2fc | 1230 | { |
cd25b18c RR |
1231 | if (iconize) |
1232 | { | |
1233 | XIconifyWindow( GDK_WINDOW_XDISPLAY( m_widget->window ), | |
7beba2fc VZ |
1234 | GDK_WINDOW_XWINDOW( m_widget->window ), |
1235 | DefaultScreen( GDK_DISPLAY() ) ); | |
cd25b18c RR |
1236 | } |
1237 | } | |
1238 | ||
1e6feb95 | 1239 | bool wxFrameGTK::IsIconized() const |
7beba2fc | 1240 | { |
43f5c493 | 1241 | return m_isIconized; |
cd25b18c | 1242 | } |
3dd9b88a VZ |
1243 | |
1244 | void wxFrame::SetIconizeState(bool iconize) | |
1245 | { | |
1246 | if ( iconize != m_isIconized ) | |
1247 | { | |
1248 | m_isIconized = iconize; | |
1249 | (void)SendIconizeEvent(iconize); | |
1250 | } | |
1251 | else | |
1252 | { | |
1253 | // this is not supposed to happen if we're called only from | |
1254 | // gtk_frame_(un)map_callback! | |
f94fca1b RR |
1255 | |
1256 | // RR: I don't understand this test. Upon startup, the frame is | |
1257 | // not iconized by default, it has just not been created | |
1258 | // yet. | |
1259 | ///wxFAIL_MSG( _T("unexpected call to SendIconizeEvent ignored") ); | |
3dd9b88a VZ |
1260 | } |
1261 | } | |
1262 |