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