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