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