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