]>
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> |
3cbab641 | 37 | #include "wx/gtk1/private.h" |
9e691f46 | 38 | |
55703c91 RR |
39 | #include <gdk/gdkkeysyms.h> |
40 | #include <gdk/gdkx.h> | |
41 | ||
3cbab641 | 42 | #include "wx/gtk1/win_gtk.h" |
c801d85f | 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 | { | |
a2053b27 | 183 | gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_attached", |
41ca191f | 184 | GTK_SIGNAL_FUNC(gtk_toolbar_attached_callback), (gpointer)parent ); |
88ac883a | 185 | |
a2053b27 | 186 | gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_detached", |
41ca191f | 187 | GTK_SIGNAL_FUNC(gtk_toolbar_detached_callback), (gpointer)parent ); |
f03fc89f VZ |
188 | } |
189 | } | |
88ac883a | 190 | #endif // wxUSE_TOOLBAR |
f362b96d RR |
191 | } |
192 | else | |
193 | { | |
047ac72b | 194 | // These are inside the client area |
da048e3d | 195 | gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow), |
a2053b27 RR |
196 | GTK_WIDGET(child->m_widget), |
197 | child->m_x, | |
198 | child->m_y, | |
199 | child->m_width, | |
200 | child->m_height ); | |
f362b96d | 201 | } |
91af0895 | 202 | |
047ac72b | 203 | // Resize on OnInternalIdle |
5b8a521e | 204 | parent->GtkUpdateSize(); |
f362b96d RR |
205 | } |
206 | ||
7c0ea335 | 207 | // ---------------------------------------------------------------------------- |
0d53fc34 | 208 | // wxFrame creation |
7c0ea335 | 209 | // ---------------------------------------------------------------------------- |
c801d85f | 210 | |
0d53fc34 | 211 | void wxFrame::Init() |
c801d85f | 212 | { |
91af0895 WS |
213 | m_menuBarDetached = false; |
214 | m_toolBarDetached = false; | |
2b5f62a0 | 215 | m_menuBarHeight = 2; |
362c6693 | 216 | } |
c801d85f | 217 | |
0d53fc34 | 218 | bool wxFrame::Create( wxWindow *parent, |
7c0ea335 | 219 | wxWindowID id, |
ca8bf976 VZ |
220 | const wxString& title, |
221 | const wxPoint& pos, | |
222 | const wxSize& sizeOrig, | |
7c0ea335 VZ |
223 | long style, |
224 | const wxString &name ) | |
c801d85f | 225 | { |
7b4c2a06 | 226 | bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig, |
7d9f12f3 | 227 | style, name); |
6bc8a1c8 | 228 | m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame; |
91af0895 | 229 | |
7d9f12f3 | 230 | return rt; |
362c6693 | 231 | } |
c801d85f | 232 | |
0d53fc34 | 233 | wxFrame::~wxFrame() |
c801d85f | 234 | { |
91af0895 | 235 | m_isBeingDeleted = true; |
7c0ea335 | 236 | DeleteAllBars(); |
3d0c4d2e RR |
237 | } |
238 | ||
7c0ea335 VZ |
239 | // ---------------------------------------------------------------------------- |
240 | // overridden wxWindow methods | |
241 | // ---------------------------------------------------------------------------- | |
242 | ||
0d53fc34 | 243 | void wxFrame::DoGetClientSize( int *width, int *height ) const |
c801d85f | 244 | { |
223d09f6 | 245 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
7b4c2a06 | 246 | |
7d9f12f3 | 247 | wxTopLevelWindow::DoGetClientSize( width, height ); |
8bbe427f | 248 | |
fb1585ae | 249 | if (height) |
46dc76ba | 250 | { |
75c9da25 | 251 | #if wxUSE_MENUS_NATIVE |
047ac72b | 252 | // menu bar |
41ca191f | 253 | if (m_frameMenuBar) |
f03fc89f | 254 | { |
88ac883a | 255 | if (!m_menuBarDetached) |
2b5f62a0 | 256 | (*height) -= m_menuBarHeight; |
f03fc89f VZ |
257 | else |
258 | (*height) -= wxPLACE_HOLDER; | |
259 | } | |
75c9da25 | 260 | #endif // wxUSE_MENUS_NATIVE |
88ac883a | 261 | |
dcf924a3 | 262 | #if wxUSE_STATUSBAR |
047ac72b | 263 | // status bar |
7b4c2a06 | 264 | if (m_frameStatusBar && m_frameStatusBar->IsShown()) |
7d9f12f3 | 265 | (*height) -= wxSTATUS_HEIGHT; |
93fa69f8 | 266 | #endif // wxUSE_STATUSBAR |
88ac883a | 267 | |
dcf924a3 | 268 | #if wxUSE_TOOLBAR |
047ac72b | 269 | // tool bar |
fa755cf1 | 270 | if (m_frameToolBar && m_frameToolBar->IsShown()) |
fb1585ae | 271 | { |
93fa69f8 | 272 | if (m_toolBarDetached) |
f03fc89f | 273 | { |
93fa69f8 | 274 | *height -= wxPLACE_HOLDER; |
f03fc89f VZ |
275 | } |
276 | else | |
93fa69f8 VZ |
277 | { |
278 | int x, y; | |
279 | m_frameToolBar->GetSize( &x, &y ); | |
280 | if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) | |
281 | { | |
282 | *width -= x; | |
283 | } | |
284 | else | |
285 | { | |
286 | *height -= y; | |
287 | } | |
288 | } | |
fb1585ae | 289 | } |
93fa69f8 | 290 | #endif // wxUSE_TOOLBAR |
46dc76ba | 291 | } |
362c6693 | 292 | } |
c801d85f | 293 | |
0d53fc34 | 294 | void wxFrame::DoSetClientSize( int width, int height ) |
b593568e | 295 | { |
223d09f6 | 296 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
8bbe427f | 297 | |
75c9da25 | 298 | #if wxUSE_MENUS_NATIVE |
047ac72b | 299 | // menu bar |
41ca191f | 300 | if (m_frameMenuBar) |
f03fc89f | 301 | { |
88ac883a | 302 | if (!m_menuBarDetached) |
2b5f62a0 | 303 | height += m_menuBarHeight; |
f03fc89f VZ |
304 | else |
305 | height += wxPLACE_HOLDER; | |
306 | } | |
75c9da25 | 307 | #endif // wxUSE_MENUS_NATIVE |
88ac883a | 308 | |
dcf924a3 | 309 | #if wxUSE_STATUSBAR |
047ac72b | 310 | // status bar |
fa755cf1 | 311 | if (m_frameStatusBar && m_frameStatusBar->IsShown()) height += wxSTATUS_HEIGHT; |
dcf924a3 | 312 | #endif |
88ac883a | 313 | |
dcf924a3 | 314 | #if wxUSE_TOOLBAR |
047ac72b | 315 | // tool bar |
fa755cf1 | 316 | if (m_frameToolBar && m_frameToolBar->IsShown()) |
41ca191f | 317 | { |
93fa69f8 | 318 | if (m_toolBarDetached) |
f03fc89f | 319 | { |
93fa69f8 | 320 | height += wxPLACE_HOLDER; |
f03fc89f VZ |
321 | } |
322 | else | |
93fa69f8 VZ |
323 | { |
324 | int x, y; | |
325 | m_frameToolBar->GetSize( &x, &y ); | |
326 | if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) | |
327 | { | |
328 | width += x; | |
329 | } | |
330 | else | |
331 | { | |
332 | height += y; | |
333 | } | |
334 | } | |
41ca191f | 335 | } |
dcf924a3 | 336 | #endif |
88ac883a | 337 | |
7d9f12f3 | 338 | wxTopLevelWindow::DoSetClientSize( width, height ); |
362c6693 | 339 | } |
b593568e | 340 | |
0d53fc34 | 341 | void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), |
7c0ea335 | 342 | int width, int height ) |
c801d85f | 343 | { |
f5368809 RR |
344 | // due to a bug in gtk, x,y are always 0 |
345 | // m_x = x; | |
346 | // m_y = y; | |
347 | ||
047ac72b | 348 | // avoid recursions |
e52f60e6 | 349 | if (m_resizing) return; |
91af0895 | 350 | m_resizing = true; |
8bbe427f | 351 | |
047ac72b | 352 | // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow |
223d09f6 | 353 | wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") ); |
88ac883a | 354 | |
f5368809 RR |
355 | m_width = width; |
356 | m_height = height; | |
7beba2fc | 357 | |
047ac72b | 358 | // space occupied by m_frameToolBar and m_frameMenuBar |
93fa69f8 VZ |
359 | int client_area_x_offset = 0, |
360 | client_area_y_offset = 0; | |
8bbe427f | 361 | |
0d53fc34 | 362 | /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses |
ab2b3dd4 | 363 | wxWindow::Create to create it's GTK equivalent. m_mainWidget is only |
0d53fc34 | 364 | set in wxFrame::Create so it is used to check what kind of frame we |
ab2b3dd4 RR |
365 | have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we |
366 | skip the part which handles m_frameMenuBar, m_frameToolBar and (most | |
367 | importantly) m_mainWidget */ | |
88ac883a | 368 | |
e7dda1ff VS |
369 | int minWidth = GetMinWidth(), |
370 | minHeight = GetMinHeight(), | |
371 | maxWidth = GetMaxWidth(), | |
372 | maxHeight = GetMaxHeight(); | |
373 | ||
374 | if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth; | |
375 | if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight; | |
376 | if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth; | |
377 | if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight; | |
1f3c610d | 378 | |
ab2b3dd4 | 379 | if (m_mainWidget) |
f5368809 | 380 | { |
047ac72b | 381 | // set size hints |
f6bcfd97 | 382 | gint flag = 0; // GDK_HINT_POS; |
e7dda1ff VS |
383 | if ((minWidth != -1) || (minHeight != -1)) flag |= GDK_HINT_MIN_SIZE; |
384 | if ((maxWidth != -1) || (maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE; | |
f6bcfd97 | 385 | GdkGeometry geom; |
e7dda1ff VS |
386 | geom.min_width = minWidth; |
387 | geom.min_height = minHeight; | |
388 | geom.max_width = maxWidth; | |
389 | geom.max_height = maxHeight; | |
f6bcfd97 BP |
390 | gtk_window_set_geometry_hints( GTK_WINDOW(m_widget), |
391 | (GtkWidget*) NULL, | |
392 | &geom, | |
393 | (GdkWindowHints) flag ); | |
ab2b3dd4 | 394 | |
047ac72b RR |
395 | // I revert back to wxGTK's original behaviour. m_mainWidget holds |
396 | // the menubar, the toolbar and the client area, which is represented | |
397 | // by m_wxwindow. | |
398 | // This hurts in the eye, but I don't want to call SetSize() | |
399 | // because I don't want to call any non-native functions here. | |
88ac883a | 400 | |
75c9da25 | 401 | #if wxUSE_MENUS_NATIVE |
ab2b3dd4 RR |
402 | if (m_frameMenuBar) |
403 | { | |
404 | int xx = m_miniEdge; | |
405 | int yy = m_miniEdge + m_miniTitle; | |
406 | int ww = m_width - 2*m_miniEdge; | |
2b5f62a0 | 407 | int hh = m_menuBarHeight; |
f03fc89f | 408 | if (m_menuBarDetached) hh = wxPLACE_HOLDER; |
121a3581 RR |
409 | m_frameMenuBar->m_x = xx; |
410 | m_frameMenuBar->m_y = yy; | |
411 | m_frameMenuBar->m_width = ww; | |
412 | m_frameMenuBar->m_height = hh; | |
da048e3d | 413 | gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), |
88ac883a | 414 | m_frameMenuBar->m_widget, |
f03fc89f VZ |
415 | xx, yy, ww, hh ); |
416 | client_area_y_offset += hh; | |
ab2b3dd4 | 417 | } |
75c9da25 | 418 | #endif // wxUSE_MENUS_NATIVE |
88ac883a | 419 | |
dcf924a3 | 420 | #if wxUSE_TOOLBAR |
fa755cf1 | 421 | if ((m_frameToolBar) && m_frameToolBar->IsShown() && |
7beba2fc | 422 | (m_frameToolBar->m_widget->parent == m_mainWidget)) |
ab2b3dd4 RR |
423 | { |
424 | int xx = m_miniEdge; | |
425 | int yy = m_miniEdge + m_miniTitle; | |
75c9da25 | 426 | #if wxUSE_MENUS_NATIVE |
41ca191f | 427 | if (m_frameMenuBar) |
f03fc89f | 428 | { |
88ac883a | 429 | if (!m_menuBarDetached) |
2b5f62a0 | 430 | yy += m_menuBarHeight; |
88ac883a | 431 | else |
f03fc89f VZ |
432 | yy += wxPLACE_HOLDER; |
433 | } | |
75c9da25 | 434 | #endif // wxUSE_MENUS_NATIVE |
93fa69f8 | 435 | |
121a3581 RR |
436 | m_frameToolBar->m_x = xx; |
437 | m_frameToolBar->m_y = yy; | |
93fa69f8 | 438 | |
047ac72b | 439 | // don't change the toolbar's reported height/width |
93fa69f8 VZ |
440 | int ww, hh; |
441 | if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) | |
442 | { | |
443 | ww = m_toolBarDetached ? wxPLACE_HOLDER | |
444 | : m_frameToolBar->m_width; | |
445 | hh = m_height - 2*m_miniEdge; | |
446 | ||
447 | client_area_x_offset += ww; | |
448 | } | |
449 | else | |
450 | { | |
451 | ww = m_width - 2*m_miniEdge; | |
452 | hh = m_toolBarDetached ? wxPLACE_HOLDER | |
453 | : m_frameToolBar->m_height; | |
7b4c2a06 | 454 | |
93fa69f8 VZ |
455 | client_area_y_offset += hh; |
456 | } | |
457 | ||
da048e3d | 458 | gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), |
88ac883a | 459 | m_frameToolBar->m_widget, |
f03fc89f | 460 | xx, yy, ww, hh ); |
ab2b3dd4 | 461 | } |
93fa69f8 | 462 | #endif // wxUSE_TOOLBAR |
88ac883a | 463 | |
93fa69f8 | 464 | int client_x = client_area_x_offset + m_miniEdge; |
f03fc89f | 465 | int client_y = client_area_y_offset + m_miniEdge + m_miniTitle; |
93fa69f8 | 466 | int client_w = m_width - client_area_x_offset - 2*m_miniEdge; |
f03fc89f | 467 | int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle; |
da048e3d | 468 | gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), |
88ac883a | 469 | m_wxwindow, |
f03fc89f | 470 | client_x, client_y, client_w, client_h ); |
32a95f9f RR |
471 | } |
472 | else | |
473 | { | |
047ac72b RR |
474 | // If there is no m_mainWidget between m_widget and m_wxwindow there |
475 | // is no need to set the size or position of m_wxwindow. | |
f5368809 | 476 | } |
88ac883a | 477 | |
dcf924a3 | 478 | #if wxUSE_STATUSBAR |
fa755cf1 | 479 | if (m_frameStatusBar && m_frameStatusBar->IsShown()) |
f5368809 | 480 | { |
b2b3ccc5 | 481 | int xx = 0 + m_miniEdge; |
f362b96d | 482 | int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset; |
ac57418f RR |
483 | int ww = m_width - 2*m_miniEdge; |
484 | int hh = wxSTATUS_HEIGHT; | |
121a3581 RR |
485 | m_frameStatusBar->m_x = xx; |
486 | m_frameStatusBar->m_y = yy; | |
487 | m_frameStatusBar->m_width = ww; | |
488 | m_frameStatusBar->m_height = hh; | |
da048e3d | 489 | gtk_pizza_set_size( GTK_PIZZA(m_wxwindow), |
7c0ea335 VZ |
490 | m_frameStatusBar->m_widget, |
491 | xx, yy, ww, hh ); | |
b6fa52db | 492 | gtk_widget_draw( m_frameStatusBar->m_widget, (GdkRectangle*) NULL ); |
f5368809 | 493 | } |
1e6feb95 | 494 | #endif // wxUSE_STATUSBAR |
8bbe427f | 495 | |
91af0895 | 496 | m_sizeSet = true; |
7beba2fc | 497 | |
54517652 | 498 | // send size event to frame |
43a18898 RR |
499 | wxSizeEvent event( wxSize(m_width,m_height), GetId() ); |
500 | event.SetEventObject( this ); | |
e52f60e6 | 501 | GetEventHandler()->ProcessEvent( event ); |
8bbe427f | 502 | |
1e6feb95 | 503 | #if wxUSE_STATUSBAR |
54517652 | 504 | // send size event to status bar |
5aa5e35a RR |
505 | if (m_frameStatusBar) |
506 | { | |
a2053b27 | 507 | wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() ); |
5aa5e35a RR |
508 | event2.SetEventObject( m_frameStatusBar ); |
509 | m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 ); | |
510 | } | |
1e6feb95 | 511 | #endif // wxUSE_STATUSBAR |
884470b1 | 512 | |
91af0895 | 513 | m_resizing = false; |
e52f60e6 RR |
514 | } |
515 | ||
0d53fc34 | 516 | void wxFrame::OnInternalIdle() |
e52f60e6 | 517 | { |
e39af974 | 518 | wxFrameBase::OnInternalIdle(); |
88ac883a | 519 | |
75c9da25 | 520 | #if wxUSE_MENUS_NATIVE |
082b2798 | 521 | if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle(); |
75c9da25 | 522 | #endif // wxUSE_MENUS_NATIVE |
dcf924a3 | 523 | #if wxUSE_TOOLBAR |
082b2798 | 524 | if (m_frameToolBar) m_frameToolBar->OnInternalIdle(); |
dcf924a3 RR |
525 | #endif |
526 | #if wxUSE_STATUSBAR | |
e4edaf5c JS |
527 | if (m_frameStatusBar) |
528 | { | |
529 | m_frameStatusBar->OnInternalIdle(); | |
530 | ||
531 | // There may be controls in the status bar that | |
532 | // need to be updated | |
533 | for ( wxWindowList::compatibility_iterator node = m_frameStatusBar->GetChildren().GetFirst(); | |
534 | node; | |
535 | node = node->GetNext() ) | |
536 | { | |
537 | wxWindow *child = node->GetData(); | |
538 | child->OnInternalIdle(); | |
539 | } | |
540 | } | |
dcf924a3 | 541 | #endif |
362c6693 | 542 | } |
c801d85f | 543 | |
7c0ea335 VZ |
544 | // ---------------------------------------------------------------------------- |
545 | // menu/tool/status bar stuff | |
546 | // ---------------------------------------------------------------------------- | |
c801d85f | 547 | |
6522713c | 548 | #if wxUSE_MENUS_NATIVE |
1e6feb95 | 549 | |
0d53fc34 | 550 | void wxFrame::DetachMenuBar() |
c801d85f | 551 | { |
223d09f6 KB |
552 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
553 | wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") ); | |
8bbe427f | 554 | |
6522713c | 555 | if ( m_frameMenuBar ) |
186baeb2 RR |
556 | { |
557 | m_frameMenuBar->UnsetInvokingWindow( this ); | |
558 | ||
559 | if (m_frameMenuBar->GetWindowStyle() & wxMB_DOCKABLE) | |
560 | { | |
561 | gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar->m_widget), | |
562 | GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this ); | |
563 | ||
564 | gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar->m_widget), | |
565 | GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this ); | |
566 | } | |
f6bcfd97 | 567 | |
186baeb2 | 568 | gtk_widget_ref( m_frameMenuBar->m_widget ); |
f283a575 RR |
569 | |
570 | gtk_container_remove( GTK_CONTAINER(m_mainWidget), m_frameMenuBar->m_widget ); | |
186baeb2 RR |
571 | } |
572 | ||
6522713c VZ |
573 | wxFrameBase::DetachMenuBar(); |
574 | } | |
575 | ||
0d53fc34 | 576 | void wxFrame::AttachMenuBar( wxMenuBar *menuBar ) |
6522713c VZ |
577 | { |
578 | wxFrameBase::AttachMenuBar(menuBar); | |
8bbe427f | 579 | |
f5368809 | 580 | if (m_frameMenuBar) |
30dea054 | 581 | { |
5bd9e519 | 582 | m_frameMenuBar->SetInvokingWindow( this ); |
8bbe427f | 583 | |
186baeb2 RR |
584 | m_frameMenuBar->SetParent(this); |
585 | gtk_pizza_put( GTK_PIZZA(m_mainWidget), | |
88ac883a VZ |
586 | m_frameMenuBar->m_widget, |
587 | m_frameMenuBar->m_x, | |
a2053b27 RR |
588 | m_frameMenuBar->m_y, |
589 | m_frameMenuBar->m_width, | |
590 | m_frameMenuBar->m_height ); | |
88ac883a | 591 | |
186baeb2 RR |
592 | if (menuBar->GetWindowStyle() & wxMB_DOCKABLE) |
593 | { | |
594 | gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_attached", | |
595 | GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this ); | |
7beba2fc | 596 | |
186baeb2 RR |
597 | gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached", |
598 | GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this ); | |
f5368809 | 599 | } |
91af0895 | 600 | |
02a8e64c | 601 | gtk_widget_show( m_frameMenuBar->m_widget ); |
2b5f62a0 VZ |
602 | |
603 | UpdateMenuBarSize(); | |
716b7364 | 604 | } |
2b5f62a0 VZ |
605 | else |
606 | { | |
607 | m_menuBarHeight = 2; | |
608 | GtkUpdateSize(); // resize window in OnInternalIdle | |
609 | } | |
610 | } | |
611 | ||
612 | void wxFrame::UpdateMenuBarSize() | |
613 | { | |
2b5f62a0 VZ |
614 | GtkRequisition req; |
615 | ||
616 | req.width = 2; | |
617 | req.height = 2; | |
91af0895 | 618 | |
e5894d19 CE |
619 | // this is called after Remove with a NULL m_frameMenuBar |
620 | if ( m_frameMenuBar ) | |
0a164d4c WS |
621 | (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_frameMenuBar->m_widget) )->size_request ) |
622 | (m_frameMenuBar->m_widget, &req ); | |
2b5f62a0 VZ |
623 | |
624 | m_menuBarHeight = req.height; | |
625 | ||
0a164d4c | 626 | // resize window in OnInternalIdle |
8bbe427f | 627 | |
b8b7f03c | 628 | GtkUpdateSize(); |
362c6693 | 629 | } |
c801d85f | 630 | |
6522713c | 631 | #endif // wxUSE_MENUS_NATIVE |
1e6feb95 | 632 | |
88ac883a | 633 | #if wxUSE_TOOLBAR |
1e6feb95 | 634 | |
0d53fc34 | 635 | wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name ) |
46dc76ba | 636 | { |
223d09f6 | 637 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
8bbe427f | 638 | |
91af0895 | 639 | m_insertInClientArea = false; |
88ac883a | 640 | |
7c0ea335 | 641 | m_frameToolBar = wxFrameBase::CreateToolBar( style, id, name ); |
8bbe427f | 642 | |
91af0895 | 643 | m_insertInClientArea = true; |
8bbe427f | 644 | |
b8b7f03c | 645 | GtkUpdateSize(); |
8bbe427f | 646 | |
f5368809 | 647 | return m_frameToolBar; |
362c6693 | 648 | } |
46dc76ba | 649 | |
0d53fc34 | 650 | void wxFrame::SetToolBar(wxToolBar *toolbar) |
7beba2fc | 651 | { |
94f14509 VZ |
652 | bool hadTbar = m_frameToolBar != NULL; |
653 | ||
7c0ea335 VZ |
654 | wxFrameBase::SetToolBar(toolbar); |
655 | ||
94f14509 | 656 | if ( m_frameToolBar ) |
307f16e8 | 657 | { |
f283a575 | 658 | // insert into toolbar area if not already there |
3017f78d RR |
659 | if ((m_frameToolBar->m_widget->parent) && |
660 | (m_frameToolBar->m_widget->parent != m_mainWidget)) | |
307f16e8 | 661 | { |
3017f78d | 662 | GetChildren().DeleteObject( m_frameToolBar ); |
7beba2fc VZ |
663 | |
664 | gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget ); | |
5b8a521e | 665 | GtkUpdateSize(); |
7beba2fc | 666 | } |
307f16e8 | 667 | } |
94f14509 VZ |
668 | else // toolbar unset |
669 | { | |
670 | // still need to update size if it had been there before | |
671 | if ( hadTbar ) | |
672 | { | |
673 | GtkUpdateSize(); | |
674 | } | |
675 | } | |
307f16e8 RR |
676 | } |
677 | ||
88ac883a | 678 | #endif // wxUSE_TOOLBAR |
46dc76ba | 679 | |
88ac883a | 680 | #if wxUSE_STATUSBAR |
8bbe427f | 681 | |
0d53fc34 | 682 | wxStatusBar* wxFrame::CreateStatusBar(int number, |
7c0ea335 VZ |
683 | long style, |
684 | wxWindowID id, | |
685 | const wxString& name) | |
c801d85f | 686 | { |
223d09f6 | 687 | wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); |
8bbe427f | 688 | |
7c0ea335 | 689 | // because it will change when toolbar is added |
b8b7f03c | 690 | GtkUpdateSize(); |
c801d85f | 691 | |
7c0ea335 | 692 | return wxFrameBase::CreateStatusBar( number, style, id, name ); |
362c6693 RR |
693 | } |
694 | ||
3851e479 RR |
695 | void wxFrame::SetStatusBar(wxStatusBar *statbar) |
696 | { | |
697 | bool hadStatBar = m_frameStatusBar != NULL; | |
91af0895 | 698 | |
3851e479 | 699 | wxFrameBase::SetStatusBar(statbar); |
91af0895 WS |
700 | |
701 | if (hadStatBar && !m_frameStatusBar) | |
3851e479 RR |
702 | GtkUpdateSize(); |
703 | } | |
704 | ||
0d53fc34 | 705 | void wxFrame::PositionStatusBar() |
8febdd39 RR |
706 | { |
707 | if ( !m_frameStatusBar ) | |
708 | return; | |
709 | ||
b8b7f03c | 710 | GtkUpdateSize(); |
8febdd39 | 711 | } |
88ac883a | 712 | #endif // wxUSE_STATUSBAR |