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