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