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