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