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