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