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