]>
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 | ||
0c394212 VZ |
22 | #include "wx/defs.h" |
23 | ||
c801d85f KB |
24 | #include "wx/dialog.h" |
25 | #include "wx/control.h" | |
26 | #include "wx/app.h" | |
cf4219e7 | 27 | #include "wx/menu.h" |
dcf924a3 | 28 | #if wxUSE_TOOLBAR |
7c0ea335 | 29 | #include "wx/toolbar.h" |
dcf924a3 RR |
30 | #endif |
31 | #if wxUSE_STATUSBAR | |
7c0ea335 | 32 | #include "wx/statusbr.h" |
dcf924a3 | 33 | #endif |
362c6693 | 34 | #include "wx/dcclient.h" |
83624f79 | 35 | |
55703c91 | 36 | #include <glib.h> |
9e691f46 VZ |
37 | #include "wx/gtk/private.h" |
38 | ||
55703c91 RR |
39 | #include <gdk/gdkkeysyms.h> |
40 | #include <gdk/gdkx.h> | |
41 | ||
c801d85f KB |
42 | #include "wx/gtk/win_gtk.h" |
43 | ||
7c0ea335 | 44 | // ---------------------------------------------------------------------------- |
2f2aa628 | 45 | // constants |
7c0ea335 | 46 | // ---------------------------------------------------------------------------- |
2f2aa628 | 47 | |
907789a0 | 48 | const int wxMENU_HEIGHT = 27; |
c67daf87 | 49 | const int wxSTATUS_HEIGHT = 25; |
41ca191f | 50 | const int wxPLACE_HOLDER = 0; |
c801d85f | 51 | |
7c0ea335 | 52 | // ---------------------------------------------------------------------------- |
acfd422a | 53 | // idle system |
7c0ea335 | 54 | // ---------------------------------------------------------------------------- |
acfd422a RR |
55 | |
56 | extern void wxapp_install_idle_handler(); | |
57 | extern bool g_isIdle; | |
2d68e1b4 | 58 | extern int g_openDialogs; |
acfd422a | 59 | |
7c0ea335 VZ |
60 | // ---------------------------------------------------------------------------- |
61 | // event tables | |
62 | // ---------------------------------------------------------------------------- | |
63 | ||
0d53fc34 | 64 | IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow) |
2e563988 | 65 | |
7c0ea335 VZ |
66 | // ============================================================================ |
67 | // implementation | |
68 | // ============================================================================ | |
69 | ||
70 | // ---------------------------------------------------------------------------- | |
71 | // GTK callbacks | |
72 | // ---------------------------------------------------------------------------- | |
73 | ||
6522713c VZ |
74 | #if wxUSE_MENUS_NATIVE |
75 | ||
16bcc879 RR |
76 | //----------------------------------------------------------------------------- |
77 | // "child_attached" of menu bar | |
78 | //----------------------------------------------------------------------------- | |
79 | ||
0d53fc34 | 80 | static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) |
16bcc879 | 81 | { |
a2053b27 | 82 | if (!win->m_hasVMT) return; |
88ac883a | 83 | |
16bcc879 | 84 | win->m_menuBarDetached = FALSE; |
5b8a521e | 85 | win->GtkUpdateSize(); |
16bcc879 RR |
86 | } |
87 | ||
88 | //----------------------------------------------------------------------------- | |
89 | // "child_detached" of menu bar | |
90 | //----------------------------------------------------------------------------- | |
91 | ||
0d53fc34 | 92 | static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) |
16bcc879 | 93 | { |
a2053b27 | 94 | if (!win->m_hasVMT) return; |
88ac883a | 95 | |
16bcc879 | 96 | win->m_menuBarDetached = TRUE; |
5b8a521e | 97 | win->GtkUpdateSize(); |
16bcc879 | 98 | } |
6522713c VZ |
99 | |
100 | #endif // wxUSE_MENUS_NATIVE | |
16bcc879 | 101 | |
88ac883a | 102 | #if wxUSE_TOOLBAR |
16bcc879 RR |
103 | //----------------------------------------------------------------------------- |
104 | // "child_attached" of tool bar | |
105 | //----------------------------------------------------------------------------- | |
106 | ||
0d53fc34 | 107 | static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) |
16bcc879 | 108 | { |
a2053b27 | 109 | if (!win->m_hasVMT) return; |
88ac883a | 110 | |
16bcc879 | 111 | win->m_toolBarDetached = FALSE; |
88ac883a | 112 | |
5b8a521e | 113 | win->GtkUpdateSize(); |
16bcc879 RR |
114 | } |
115 | ||
116 | //----------------------------------------------------------------------------- | |
117 | // "child_detached" of tool bar | |
118 | //----------------------------------------------------------------------------- | |
119 | ||
0d53fc34 | 120 | static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) |
16bcc879 | 121 | { |
88ac883a | 122 | if (g_isIdle) |
801aa178 | 123 | wxapp_install_idle_handler(); |
acfd422a | 124 | |
a2053b27 | 125 | if (!win->m_hasVMT) return; |
88ac883a | 126 | |
16bcc879 | 127 | win->m_toolBarDetached = TRUE; |
5b8a521e | 128 | win->GtkUpdateSize(); |
16bcc879 | 129 | } |
88ac883a | 130 | #endif // wxUSE_TOOLBAR |
16bcc879 | 131 | |
117247fd | 132 | |
7c0ea335 | 133 | // ---------------------------------------------------------------------------- |
0d53fc34 | 134 | // wxFrame itself |
7c0ea335 VZ |
135 | // ---------------------------------------------------------------------------- |
136 | ||
f362b96d | 137 | //----------------------------------------------------------------------------- |
0d53fc34 | 138 | // InsertChild for wxFrame |
f362b96d RR |
139 | //----------------------------------------------------------------------------- |
140 | ||
0d53fc34 | 141 | /* Callback for wxFrame. This very strange beast has to be used because |
f362b96d RR |
142 | * C++ has no virtual methods in a constructor. We have to emulate a |
143 | * virtual function here as wxWindows requires different ways to insert | |
144 | * a child in container classes. */ | |
145 | ||
0d53fc34 | 146 | static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) |
f362b96d | 147 | { |
5fd11f09 | 148 | wxASSERT( GTK_IS_WIDGET(child->m_widget) ); |
7beba2fc | 149 | |
6bc8a1c8 | 150 | if (!parent->m_insertInClientArea) |
f362b96d RR |
151 | { |
152 | /* these are outside the client area */ | |
0d53fc34 | 153 | wxFrame* frame = (wxFrame*) parent; |
da048e3d | 154 | gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget), |
a2053b27 RR |
155 | GTK_WIDGET(child->m_widget), |
156 | child->m_x, | |
157 | child->m_y, | |
158 | child->m_width, | |
159 | child->m_height ); | |
88ac883a | 160 | |
caf51f95 | 161 | #if wxUSE_TOOLBAR_NATIVE |
f03fc89f VZ |
162 | /* we connect to these events for recalculating the client area |
163 | space when the toolbar is floating */ | |
164 | if (wxIS_KIND_OF(child,wxToolBar)) | |
165 | { | |
166 | wxToolBar *toolBar = (wxToolBar*) child; | |
167 | if (toolBar->GetWindowStyle() & wxTB_DOCKABLE) | |
168 | { | |
a2053b27 | 169 | gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_attached", |
41ca191f | 170 | GTK_SIGNAL_FUNC(gtk_toolbar_attached_callback), (gpointer)parent ); |
88ac883a | 171 | |
a2053b27 | 172 | gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_detached", |
41ca191f | 173 | GTK_SIGNAL_FUNC(gtk_toolbar_detached_callback), (gpointer)parent ); |
f03fc89f VZ |
174 | } |
175 | } | |
88ac883a | 176 | #endif // wxUSE_TOOLBAR |
f362b96d RR |
177 | } |
178 | else | |
179 | { | |
180 | /* these are inside the client area */ | |
da048e3d | 181 | gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow), |
a2053b27 RR |
182 | GTK_WIDGET(child->m_widget), |
183 | child->m_x, | |
184 | child->m_y, | |
185 | child->m_width, | |
186 | child->m_height ); | |
f362b96d RR |
187 | } |
188 | ||
f362b96d | 189 | /* resize on OnInternalIdle */ |
5b8a521e | 190 | parent->GtkUpdateSize(); |
f362b96d RR |
191 | } |
192 | ||
7c0ea335 | 193 | // ---------------------------------------------------------------------------- |
0d53fc34 | 194 | // wxFrame creation |
7c0ea335 | 195 | // ---------------------------------------------------------------------------- |
c801d85f | 196 | |
0d53fc34 | 197 | void wxFrame::Init() |
c801d85f | 198 | { |
16bcc879 RR |
199 | m_menuBarDetached = FALSE; |
200 | m_toolBarDetached = FALSE; | |
362c6693 | 201 | } |
c801d85f | 202 | |
0d53fc34 | 203 | bool wxFrame::Create( wxWindow *parent, |
7c0ea335 | 204 | wxWindowID id, |
ca8bf976 VZ |
205 | const wxString& title, |
206 | const wxPoint& pos, | |
207 | const wxSize& sizeOrig, | |
7c0ea335 VZ |
208 | long style, |
209 | const wxString &name ) | |
c801d85f | 210 | { |
7d9f12f3 VS |
211 | bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig, |
212 | style, name); | |
6bc8a1c8 | 213 | m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame; |
7d9f12f3 | 214 | return rt; |
362c6693 | 215 | } |
c801d85f | 216 | |
0d53fc34 | 217 | wxFrame::~wxFrame() |
c801d85f | 218 | { |
31c6b4fc | 219 | m_isBeingDeleted = TRUE; |
7c0ea335 | 220 | DeleteAllBars(); |
3d0c4d2e RR |
221 | } |
222 | ||
7c0ea335 VZ |
223 | // ---------------------------------------------------------------------------- |
224 | // overridden wxWindow methods | |
225 | // ---------------------------------------------------------------------------- | |
226 | ||
0d53fc34 | 227 | void wxFrame::DoGetClientSize( int *width, int *height ) const |
c801d85f | 228 | { |
223d09f6 | 229 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
7d9f12f3 VS |
230 | |
231 | wxTopLevelWindow::DoGetClientSize( width, height ); | |
8bbe427f | 232 | |
fb1585ae | 233 | if (height) |
46dc76ba | 234 | { |
75c9da25 | 235 | #if wxUSE_MENUS_NATIVE |
41ca191f RR |
236 | /* menu bar */ |
237 | if (m_frameMenuBar) | |
f03fc89f | 238 | { |
88ac883a | 239 | if (!m_menuBarDetached) |
f03fc89f VZ |
240 | (*height) -= wxMENU_HEIGHT; |
241 | else | |
242 | (*height) -= wxPLACE_HOLDER; | |
243 | } | |
75c9da25 | 244 | #endif // wxUSE_MENUS_NATIVE |
88ac883a | 245 | |
dcf924a3 | 246 | #if wxUSE_STATUSBAR |
f03fc89f | 247 | /* status bar */ |
7d9f12f3 VS |
248 | if (m_frameStatusBar && m_frameStatusBar->IsShown()) |
249 | (*height) -= wxSTATUS_HEIGHT; | |
93fa69f8 | 250 | #endif // wxUSE_STATUSBAR |
88ac883a | 251 | |
dcf924a3 | 252 | #if wxUSE_TOOLBAR |
f03fc89f | 253 | /* tool bar */ |
fa755cf1 | 254 | if (m_frameToolBar && m_frameToolBar->IsShown()) |
fb1585ae | 255 | { |
93fa69f8 | 256 | if (m_toolBarDetached) |
f03fc89f | 257 | { |
93fa69f8 | 258 | *height -= wxPLACE_HOLDER; |
f03fc89f VZ |
259 | } |
260 | else | |
93fa69f8 VZ |
261 | { |
262 | int x, y; | |
263 | m_frameToolBar->GetSize( &x, &y ); | |
264 | if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) | |
265 | { | |
266 | *width -= x; | |
267 | } | |
268 | else | |
269 | { | |
270 | *height -= y; | |
271 | } | |
272 | } | |
fb1585ae | 273 | } |
93fa69f8 | 274 | #endif // wxUSE_TOOLBAR |
46dc76ba | 275 | } |
362c6693 | 276 | } |
c801d85f | 277 | |
0d53fc34 | 278 | void wxFrame::DoSetClientSize( int width, int height ) |
b593568e | 279 | { |
223d09f6 | 280 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
8bbe427f | 281 | |
75c9da25 | 282 | #if wxUSE_MENUS_NATIVE |
41ca191f RR |
283 | /* menu bar */ |
284 | if (m_frameMenuBar) | |
f03fc89f | 285 | { |
88ac883a | 286 | if (!m_menuBarDetached) |
f03fc89f VZ |
287 | height += wxMENU_HEIGHT; |
288 | else | |
289 | height += wxPLACE_HOLDER; | |
290 | } | |
75c9da25 | 291 | #endif // wxUSE_MENUS_NATIVE |
88ac883a | 292 | |
dcf924a3 | 293 | #if wxUSE_STATUSBAR |
f03fc89f | 294 | /* status bar */ |
fa755cf1 | 295 | if (m_frameStatusBar && m_frameStatusBar->IsShown()) height += wxSTATUS_HEIGHT; |
dcf924a3 | 296 | #endif |
88ac883a | 297 | |
dcf924a3 | 298 | #if wxUSE_TOOLBAR |
f03fc89f | 299 | /* tool bar */ |
fa755cf1 | 300 | if (m_frameToolBar && m_frameToolBar->IsShown()) |
41ca191f | 301 | { |
93fa69f8 | 302 | if (m_toolBarDetached) |
f03fc89f | 303 | { |
93fa69f8 | 304 | height += wxPLACE_HOLDER; |
f03fc89f VZ |
305 | } |
306 | else | |
93fa69f8 VZ |
307 | { |
308 | int x, y; | |
309 | m_frameToolBar->GetSize( &x, &y ); | |
310 | if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) | |
311 | { | |
312 | width += x; | |
313 | } | |
314 | else | |
315 | { | |
316 | height += y; | |
317 | } | |
318 | } | |
41ca191f | 319 | } |
dcf924a3 | 320 | #endif |
88ac883a | 321 | |
7d9f12f3 | 322 | wxTopLevelWindow::DoSetClientSize( width, height ); |
362c6693 | 323 | } |
b593568e | 324 | |
0d53fc34 | 325 | void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), |
7c0ea335 | 326 | int width, int height ) |
c801d85f | 327 | { |
f5368809 RR |
328 | // due to a bug in gtk, x,y are always 0 |
329 | // m_x = x; | |
330 | // m_y = y; | |
331 | ||
ab2b3dd4 | 332 | /* avoid recursions */ |
e52f60e6 RR |
333 | if (m_resizing) return; |
334 | m_resizing = TRUE; | |
8bbe427f | 335 | |
0d53fc34 | 336 | /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */ |
223d09f6 | 337 | wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") ); |
88ac883a | 338 | |
f5368809 RR |
339 | m_width = width; |
340 | m_height = height; | |
7beba2fc | 341 | |
ab2b3dd4 | 342 | /* space occupied by m_frameToolBar and m_frameMenuBar */ |
93fa69f8 VZ |
343 | int client_area_x_offset = 0, |
344 | client_area_y_offset = 0; | |
8bbe427f | 345 | |
0d53fc34 | 346 | /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses |
ab2b3dd4 | 347 | wxWindow::Create to create it's GTK equivalent. m_mainWidget is only |
0d53fc34 | 348 | set in wxFrame::Create so it is used to check what kind of frame we |
ab2b3dd4 RR |
349 | have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we |
350 | skip the part which handles m_frameMenuBar, m_frameToolBar and (most | |
351 | importantly) m_mainWidget */ | |
88ac883a | 352 | |
e7dda1ff VS |
353 | int minWidth = GetMinWidth(), |
354 | minHeight = GetMinHeight(), | |
355 | maxWidth = GetMaxWidth(), | |
356 | maxHeight = GetMaxHeight(); | |
357 | ||
358 | if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth; | |
359 | if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight; | |
360 | if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth; | |
361 | if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight; | |
1f3c610d | 362 | |
ab2b3dd4 | 363 | if (m_mainWidget) |
f5368809 | 364 | { |
f6bcfd97 BP |
365 | /* set size hints */ |
366 | gint flag = 0; // GDK_HINT_POS; | |
e7dda1ff VS |
367 | if ((minWidth != -1) || (minHeight != -1)) flag |= GDK_HINT_MIN_SIZE; |
368 | if ((maxWidth != -1) || (maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE; | |
f6bcfd97 | 369 | GdkGeometry geom; |
e7dda1ff VS |
370 | geom.min_width = minWidth; |
371 | geom.min_height = minHeight; | |
372 | geom.max_width = maxWidth; | |
373 | geom.max_height = maxHeight; | |
f6bcfd97 BP |
374 | gtk_window_set_geometry_hints( GTK_WINDOW(m_widget), |
375 | (GtkWidget*) NULL, | |
376 | &geom, | |
377 | (GdkWindowHints) flag ); | |
ab2b3dd4 RR |
378 | |
379 | /* I revert back to wxGTK's original behaviour. m_mainWidget holds the | |
380 | * menubar, the toolbar and the client area, which is represented by | |
381 | * m_wxwindow. | |
382 | * this hurts in the eye, but I don't want to call SetSize() | |
383 | * because I don't want to call any non-native functions here. */ | |
88ac883a | 384 | |
75c9da25 | 385 | #if wxUSE_MENUS_NATIVE |
ab2b3dd4 RR |
386 | if (m_frameMenuBar) |
387 | { | |
388 | int xx = m_miniEdge; | |
389 | int yy = m_miniEdge + m_miniTitle; | |
390 | int ww = m_width - 2*m_miniEdge; | |
41ca191f | 391 | int hh = wxMENU_HEIGHT; |
f03fc89f | 392 | if (m_menuBarDetached) hh = wxPLACE_HOLDER; |
121a3581 RR |
393 | m_frameMenuBar->m_x = xx; |
394 | m_frameMenuBar->m_y = yy; | |
395 | m_frameMenuBar->m_width = ww; | |
396 | m_frameMenuBar->m_height = hh; | |
da048e3d | 397 | gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), |
88ac883a | 398 | m_frameMenuBar->m_widget, |
f03fc89f VZ |
399 | xx, yy, ww, hh ); |
400 | client_area_y_offset += hh; | |
ab2b3dd4 | 401 | } |
75c9da25 | 402 | #endif // wxUSE_MENUS_NATIVE |
88ac883a | 403 | |
dcf924a3 | 404 | #if wxUSE_TOOLBAR |
fa755cf1 | 405 | if ((m_frameToolBar) && m_frameToolBar->IsShown() && |
7beba2fc | 406 | (m_frameToolBar->m_widget->parent == m_mainWidget)) |
ab2b3dd4 RR |
407 | { |
408 | int xx = m_miniEdge; | |
409 | int yy = m_miniEdge + m_miniTitle; | |
75c9da25 | 410 | #if wxUSE_MENUS_NATIVE |
41ca191f | 411 | if (m_frameMenuBar) |
f03fc89f | 412 | { |
88ac883a VZ |
413 | if (!m_menuBarDetached) |
414 | yy += wxMENU_HEIGHT; | |
415 | else | |
f03fc89f VZ |
416 | yy += wxPLACE_HOLDER; |
417 | } | |
75c9da25 | 418 | #endif // wxUSE_MENUS_NATIVE |
93fa69f8 | 419 | |
121a3581 RR |
420 | m_frameToolBar->m_x = xx; |
421 | m_frameToolBar->m_y = yy; | |
93fa69f8 VZ |
422 | |
423 | /* don't change the toolbar's reported height/width */ | |
424 | int ww, hh; | |
425 | if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) | |
426 | { | |
427 | ww = m_toolBarDetached ? wxPLACE_HOLDER | |
428 | : m_frameToolBar->m_width; | |
429 | hh = m_height - 2*m_miniEdge; | |
430 | ||
431 | client_area_x_offset += ww; | |
432 | } | |
433 | else | |
434 | { | |
435 | ww = m_width - 2*m_miniEdge; | |
436 | hh = m_toolBarDetached ? wxPLACE_HOLDER | |
437 | : m_frameToolBar->m_height; | |
438 | ||
439 | client_area_y_offset += hh; | |
440 | } | |
441 | ||
da048e3d | 442 | gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), |
88ac883a | 443 | m_frameToolBar->m_widget, |
f03fc89f | 444 | xx, yy, ww, hh ); |
ab2b3dd4 | 445 | } |
93fa69f8 | 446 | #endif // wxUSE_TOOLBAR |
88ac883a | 447 | |
93fa69f8 | 448 | int client_x = client_area_x_offset + m_miniEdge; |
f03fc89f | 449 | int client_y = client_area_y_offset + m_miniEdge + m_miniTitle; |
93fa69f8 | 450 | int client_w = m_width - client_area_x_offset - 2*m_miniEdge; |
f03fc89f | 451 | int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle; |
da048e3d | 452 | gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), |
88ac883a | 453 | m_wxwindow, |
f03fc89f | 454 | client_x, client_y, client_w, client_h ); |
32a95f9f RR |
455 | } |
456 | else | |
457 | { | |
458 | /* if there is no m_mainWidget between m_widget and m_wxwindow there | |
f03fc89f | 459 | is no need to set the size or position of m_wxwindow. */ |
f5368809 | 460 | } |
88ac883a | 461 | |
dcf924a3 | 462 | #if wxUSE_STATUSBAR |
fa755cf1 | 463 | if (m_frameStatusBar && m_frameStatusBar->IsShown()) |
f5368809 | 464 | { |
b2b3ccc5 | 465 | int xx = 0 + m_miniEdge; |
f362b96d | 466 | int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset; |
ac57418f RR |
467 | int ww = m_width - 2*m_miniEdge; |
468 | int hh = wxSTATUS_HEIGHT; | |
121a3581 RR |
469 | m_frameStatusBar->m_x = xx; |
470 | m_frameStatusBar->m_y = yy; | |
471 | m_frameStatusBar->m_width = ww; | |
472 | m_frameStatusBar->m_height = hh; | |
da048e3d | 473 | gtk_pizza_set_size( GTK_PIZZA(m_wxwindow), |
7c0ea335 VZ |
474 | m_frameStatusBar->m_widget, |
475 | xx, yy, ww, hh ); | |
b6fa52db | 476 | gtk_widget_draw( m_frameStatusBar->m_widget, (GdkRectangle*) NULL ); |
f5368809 | 477 | } |
1e6feb95 | 478 | #endif // wxUSE_STATUSBAR |
8bbe427f | 479 | |
54517652 | 480 | m_sizeSet = TRUE; |
7beba2fc | 481 | |
54517652 | 482 | // send size event to frame |
43a18898 RR |
483 | wxSizeEvent event( wxSize(m_width,m_height), GetId() ); |
484 | event.SetEventObject( this ); | |
e52f60e6 | 485 | GetEventHandler()->ProcessEvent( event ); |
8bbe427f | 486 | |
1e6feb95 | 487 | #if wxUSE_STATUSBAR |
54517652 | 488 | // send size event to status bar |
5aa5e35a RR |
489 | if (m_frameStatusBar) |
490 | { | |
a2053b27 | 491 | wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() ); |
5aa5e35a RR |
492 | event2.SetEventObject( m_frameStatusBar ); |
493 | m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 ); | |
494 | } | |
1e6feb95 | 495 | #endif // wxUSE_STATUSBAR |
884470b1 | 496 | |
e52f60e6 RR |
497 | m_resizing = FALSE; |
498 | } | |
499 | ||
0d53fc34 | 500 | void wxFrame::OnInternalIdle() |
e52f60e6 | 501 | { |
7d9f12f3 | 502 | wxTopLevelWindow::OnInternalIdle(); |
88ac883a | 503 | |
75c9da25 | 504 | #if wxUSE_MENUS_NATIVE |
082b2798 | 505 | if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle(); |
75c9da25 | 506 | #endif // wxUSE_MENUS_NATIVE |
dcf924a3 | 507 | #if wxUSE_TOOLBAR |
082b2798 | 508 | if (m_frameToolBar) m_frameToolBar->OnInternalIdle(); |
dcf924a3 RR |
509 | #endif |
510 | #if wxUSE_STATUSBAR | |
082b2798 | 511 | if (m_frameStatusBar) m_frameStatusBar->OnInternalIdle(); |
dcf924a3 | 512 | #endif |
362c6693 | 513 | } |
c801d85f | 514 | |
7c0ea335 VZ |
515 | // ---------------------------------------------------------------------------- |
516 | // menu/tool/status bar stuff | |
517 | // ---------------------------------------------------------------------------- | |
c801d85f | 518 | |
6522713c | 519 | #if wxUSE_MENUS_NATIVE |
1e6feb95 | 520 | |
0d53fc34 | 521 | void wxFrame::DetachMenuBar() |
c801d85f | 522 | { |
223d09f6 KB |
523 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
524 | wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") ); | |
8bbe427f | 525 | |
6522713c | 526 | if ( m_frameMenuBar ) |
186baeb2 RR |
527 | { |
528 | m_frameMenuBar->UnsetInvokingWindow( this ); | |
529 | ||
530 | if (m_frameMenuBar->GetWindowStyle() & wxMB_DOCKABLE) | |
531 | { | |
532 | gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar->m_widget), | |
533 | GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this ); | |
534 | ||
535 | gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar->m_widget), | |
536 | GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this ); | |
537 | } | |
f6bcfd97 | 538 | |
186baeb2 | 539 | gtk_widget_ref( m_frameMenuBar->m_widget ); |
f283a575 RR |
540 | |
541 | gtk_container_remove( GTK_CONTAINER(m_mainWidget), m_frameMenuBar->m_widget ); | |
186baeb2 RR |
542 | } |
543 | ||
6522713c VZ |
544 | wxFrameBase::DetachMenuBar(); |
545 | } | |
546 | ||
0d53fc34 | 547 | void wxFrame::AttachMenuBar( wxMenuBar *menuBar ) |
6522713c VZ |
548 | { |
549 | wxFrameBase::AttachMenuBar(menuBar); | |
8bbe427f | 550 | |
f5368809 | 551 | if (m_frameMenuBar) |
30dea054 | 552 | { |
5bd9e519 | 553 | m_frameMenuBar->SetInvokingWindow( this ); |
8bbe427f | 554 | |
186baeb2 RR |
555 | m_frameMenuBar->SetParent(this); |
556 | gtk_pizza_put( GTK_PIZZA(m_mainWidget), | |
88ac883a VZ |
557 | m_frameMenuBar->m_widget, |
558 | m_frameMenuBar->m_x, | |
a2053b27 RR |
559 | m_frameMenuBar->m_y, |
560 | m_frameMenuBar->m_width, | |
561 | m_frameMenuBar->m_height ); | |
88ac883a | 562 | |
186baeb2 RR |
563 | if (menuBar->GetWindowStyle() & wxMB_DOCKABLE) |
564 | { | |
565 | gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_attached", | |
566 | GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this ); | |
7beba2fc | 567 | |
186baeb2 RR |
568 | gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached", |
569 | GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this ); | |
f5368809 | 570 | } |
186baeb2 RR |
571 | |
572 | m_frameMenuBar->Show( TRUE ); | |
716b7364 | 573 | } |
8bbe427f | 574 | |
f283a575 | 575 | // resize window in OnInternalIdle |
5b077d48 | 576 | m_sizeSet = FALSE; |
362c6693 | 577 | } |
c801d85f | 578 | |
6522713c | 579 | #endif // wxUSE_MENUS_NATIVE |
1e6feb95 | 580 | |
88ac883a | 581 | #if wxUSE_TOOLBAR |
1e6feb95 | 582 | |
0d53fc34 | 583 | wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name ) |
46dc76ba | 584 | { |
223d09f6 | 585 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
8bbe427f | 586 | |
6bc8a1c8 | 587 | m_insertInClientArea = FALSE; |
88ac883a | 588 | |
7c0ea335 | 589 | m_frameToolBar = wxFrameBase::CreateToolBar( style, id, name ); |
8bbe427f | 590 | |
6bc8a1c8 | 591 | m_insertInClientArea = TRUE; |
8bbe427f | 592 | |
5b077d48 | 593 | m_sizeSet = FALSE; |
8bbe427f | 594 | |
f5368809 | 595 | return m_frameToolBar; |
362c6693 | 596 | } |
46dc76ba | 597 | |
0d53fc34 | 598 | void wxFrame::SetToolBar(wxToolBar *toolbar) |
7beba2fc | 599 | { |
7c0ea335 VZ |
600 | wxFrameBase::SetToolBar(toolbar); |
601 | ||
307f16e8 RR |
602 | if (m_frameToolBar) |
603 | { | |
f283a575 | 604 | // insert into toolbar area if not already there |
3017f78d RR |
605 | if ((m_frameToolBar->m_widget->parent) && |
606 | (m_frameToolBar->m_widget->parent != m_mainWidget)) | |
307f16e8 | 607 | { |
3017f78d | 608 | GetChildren().DeleteObject( m_frameToolBar ); |
7beba2fc VZ |
609 | |
610 | gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget ); | |
5b8a521e | 611 | GtkUpdateSize(); |
7beba2fc | 612 | } |
307f16e8 RR |
613 | } |
614 | } | |
615 | ||
88ac883a | 616 | #endif // wxUSE_TOOLBAR |
46dc76ba | 617 | |
88ac883a | 618 | #if wxUSE_STATUSBAR |
8bbe427f | 619 | |
0d53fc34 | 620 | wxStatusBar* wxFrame::CreateStatusBar(int number, |
7c0ea335 VZ |
621 | long style, |
622 | wxWindowID id, | |
623 | const wxString& name) | |
c801d85f | 624 | { |
223d09f6 | 625 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
8bbe427f | 626 | |
7c0ea335 VZ |
627 | // because it will change when toolbar is added |
628 | m_sizeSet = FALSE; | |
c801d85f | 629 | |
7c0ea335 | 630 | return wxFrameBase::CreateStatusBar( number, style, id, name ); |
362c6693 RR |
631 | } |
632 | ||
0d53fc34 | 633 | void wxFrame::PositionStatusBar() |
8febdd39 RR |
634 | { |
635 | if ( !m_frameStatusBar ) | |
636 | return; | |
637 | ||
638 | m_sizeSet = FALSE; | |
639 | } | |
88ac883a | 640 | #endif // wxUSE_STATUSBAR |
c801d85f | 641 |