]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/frame.cpp
1. wxStaticBox doesn't draw over the underlying controls any more
[wxWidgets.git] / src / gtk1 / frame.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: frame.cpp
3// Purpose:
4// Author: Robert Roebling
a81258be 5// Id: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling
19717c50 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
fe4e9e6c 11 #pragma implementation "frame.h"
c801d85f
KB
12#endif
13
14#include "wx/frame.h"
15#include "wx/dialog.h"
16#include "wx/control.h"
17#include "wx/app.h"
cf4219e7 18#include "wx/menu.h"
dcf924a3 19#if wxUSE_TOOLBAR
cf4219e7 20#include "wx/toolbar.h"
dcf924a3
RR
21#endif
22#if wxUSE_STATUSBAR
cf4219e7 23#include "wx/statusbr.h"
dcf924a3 24#endif
362c6693 25#include "wx/dcclient.h"
83624f79
RR
26
27#include "glib.h"
28#include "gdk/gdk.h"
29#include "gtk/gtk.h"
c801d85f 30#include "wx/gtk/win_gtk.h"
801aa178 31#include "gdk/gdkkeysyms.h"
cd25b18c 32#include "gdk/gdkx.h"
c801d85f 33
2f2aa628
RR
34//-----------------------------------------------------------------------------
35// constants
36//-----------------------------------------------------------------------------
37
907789a0 38const int wxMENU_HEIGHT = 27;
c67daf87 39const int wxSTATUS_HEIGHT = 25;
41ca191f 40const int wxPLACE_HOLDER = 0;
c801d85f 41
acfd422a
RR
42//-----------------------------------------------------------------------------
43// idle system
44//-----------------------------------------------------------------------------
45
46extern void wxapp_install_idle_handler();
47extern bool g_isIdle;
2d68e1b4 48extern int g_openDialogs;
acfd422a 49
2f2aa628
RR
50//-----------------------------------------------------------------------------
51// data
52//-----------------------------------------------------------------------------
53
c801d85f
KB
54extern wxList wxPendingDelete;
55
2e563988
RR
56//-----------------------------------------------------------------------------
57// debug
58//-----------------------------------------------------------------------------
59
60#ifdef __WXDEBUG__
61
62extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window );
63
64#endif
65
c801d85f 66//-----------------------------------------------------------------------------
2f2aa628 67// "size_allocate"
c801d85f 68//-----------------------------------------------------------------------------
c801d85f 69
2f2aa628 70static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win )
ed7a557b 71{
88ac883a 72 if (g_isIdle)
121a3581 73 wxapp_install_idle_handler();
acfd422a 74
54517652
RR
75 if (!win->m_hasVMT)
76 return;
8bbe427f 77
121a3581
RR
78 if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
79 {
54517652
RR
80/*
81 wxPrintf( "OnSize from " );
82 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
83 wxPrintf( win->GetClassInfo()->GetClassName() );
84 wxPrintf( " %d %d %d %d\n", (int)alloc->x,
85 (int)alloc->y,
86 (int)alloc->width,
87 (int)alloc->height );
88*/
7beba2fc 89
121a3581
RR
90 win->m_width = alloc->width;
91 win->m_height = alloc->height;
92 win->UpdateSize();
93 }
362c6693 94}
c801d85f
KB
95
96//-----------------------------------------------------------------------------
2f2aa628
RR
97// "delete_event"
98//-----------------------------------------------------------------------------
c801d85f 99
2f2aa628 100static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxFrame *win )
ed7a557b 101{
88ac883a 102 if (g_isIdle)
121a3581 103 wxapp_install_idle_handler();
ed7a557b 104
2d68e1b4
RR
105 if (g_openDialogs == 0)
106 win->Close();
c801d85f 107
fb1585ae 108 return TRUE;
362c6693 109}
c801d85f 110
16bcc879
RR
111//-----------------------------------------------------------------------------
112// "child_attached" of menu bar
113//-----------------------------------------------------------------------------
114
115static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
116{
a2053b27 117 if (!win->m_hasVMT) return;
88ac883a 118
16bcc879 119 win->m_menuBarDetached = FALSE;
f03fc89f 120 win->UpdateSize();
16bcc879
RR
121}
122
123//-----------------------------------------------------------------------------
124// "child_detached" of menu bar
125//-----------------------------------------------------------------------------
126
127static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
128{
a2053b27 129 if (!win->m_hasVMT) return;
88ac883a 130
16bcc879 131 win->m_menuBarDetached = TRUE;
f03fc89f 132 win->UpdateSize();
16bcc879
RR
133}
134
88ac883a 135#if wxUSE_TOOLBAR
16bcc879
RR
136//-----------------------------------------------------------------------------
137// "child_attached" of tool bar
138//-----------------------------------------------------------------------------
139
140static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
141{
a2053b27 142 if (!win->m_hasVMT) return;
88ac883a 143
16bcc879 144 win->m_toolBarDetached = FALSE;
88ac883a 145
f03fc89f 146 win->UpdateSize();
16bcc879
RR
147}
148
149//-----------------------------------------------------------------------------
150// "child_detached" of tool bar
151//-----------------------------------------------------------------------------
152
5e0201ea 153static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
16bcc879 154{
88ac883a 155 if (g_isIdle)
801aa178 156 wxapp_install_idle_handler();
acfd422a 157
a2053b27 158 if (!win->m_hasVMT) return;
88ac883a 159
16bcc879 160 win->m_toolBarDetached = TRUE;
f03fc89f 161 win->UpdateSize();
16bcc879 162}
88ac883a 163#endif // wxUSE_TOOLBAR
16bcc879 164
47908e25 165//-----------------------------------------------------------------------------
2f2aa628
RR
166// "configure_event"
167//-----------------------------------------------------------------------------
47908e25 168
7beba2fc 169static gint
2d68e1b4 170#if (GTK_MINOR_VERSION > 0)
c693edf3
RR
171gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxFrame *win )
172#else
173gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win )
174#endif
47908e25 175{
7beba2fc 176 if (g_isIdle)
121a3581 177 wxapp_install_idle_handler();
acfd422a 178
2d68e1b4
RR
179 if (!win->m_hasVMT)
180 return FALSE;
181
182#if (GTK_MINOR_VERSION > 0)
dfc3d7e0
RR
183 int x = 0;
184 int y = 0;
185 gdk_window_get_root_origin( win->m_widget->window, &x, &y );
dfc3d7e0
RR
186 win->m_x = x;
187 win->m_y = y;
c693edf3
RR
188#else
189 win->m_x = event->x;
190 win->m_y = event->y;
191#endif
8bbe427f 192
a2053b27 193 wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
36b3b54a
RR
194 mevent.SetEventObject( win );
195 win->GetEventHandler()->ProcessEvent( mevent );
196
fb1585ae 197 return FALSE;
362c6693 198}
47908e25 199
2b07d713
RR
200//-----------------------------------------------------------------------------
201// "realize" from m_widget
202//-----------------------------------------------------------------------------
203
88ac883a 204/* we cannot MWM hints and icons before the widget has been realized,
2b07d713
RR
205 so we do this directly after realization */
206
88ac883a 207static gint
2e5c594e 208gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win )
2b07d713 209{
88ac883a 210 if (g_isIdle)
121a3581 211 wxapp_install_idle_handler();
acfd422a 212
2e5c594e
RR
213 /* I haven't been able to set the position of
214 the dialog before it is shown, so I set the
215 position in "realize" */
8487f887 216 gtk_widget_set_uposition( widget, win->m_x, win->m_y );
2e5c594e 217
2b07d713
RR
218 /* all this is for Motif Window Manager "hints" and is supposed to be
219 recognized by other WM as well. not tested. */
051b55ad
KB
220 long decor = (long) GDK_DECOR_BORDER;
221 long func = (long) GDK_FUNC_MOVE;
88ac883a 222
f03fc89f
VZ
223 if ((win->GetWindowStyle() & wxCAPTION) != 0)
224 decor |= GDK_DECOR_TITLE;
225 if ((win->GetWindowStyle() & wxSYSTEM_MENU) != 0)
aa64626e
KB
226 {
227 decor |= GDK_DECOR_MENU;
228 func |= GDK_FUNC_CLOSE;
229 }
f03fc89f 230 if ((win->GetWindowStyle() & wxMINIMIZE_BOX) != 0)
15b24b14 231 {
f03fc89f
VZ
232 func |= GDK_FUNC_MINIMIZE;
233 decor |= GDK_DECOR_MINIMIZE;
15b24b14 234 }
f03fc89f 235 if ((win->GetWindowStyle() & wxMAXIMIZE_BOX) != 0)
15b24b14 236 {
f03fc89f
VZ
237 func |= GDK_FUNC_MAXIMIZE;
238 decor |= GDK_DECOR_MAXIMIZE;
15b24b14 239 }
f03fc89f 240 if ((win->GetWindowStyle() & wxRESIZE_BORDER) != 0)
aa64626e
KB
241 {
242 func |= GDK_FUNC_RESIZE;
243 decor |= GDK_DECOR_RESIZEH;
aa64626e
KB
244 }
245
a2053b27
RR
246 gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
247 gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
88ac883a 248
2b07d713 249 /* GTK's shrinking/growing policy */
f03fc89f 250 if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0)
a2053b27 251 gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
2b07d713 252 else
a2053b27 253 gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
88ac883a 254
738f9e5a 255 /* set size hints */
8487f887 256 gint flag = 0; // GDK_HINT_POS;
738f9e5a
RR
257 if ((win->GetMinWidth() != -1) || (win->GetMinHeight() != -1)) flag |= GDK_HINT_MIN_SIZE;
258 if ((win->GetMaxWidth() != -1) || (win->GetMaxHeight() != -1)) flag |= GDK_HINT_MAX_SIZE;
259 if (flag)
260 {
7beba2fc
VZ
261 gdk_window_set_hints( win->m_widget->window,
262 win->m_x, win->m_y,
263 win->GetMinWidth(), win->GetMinHeight(),
264 win->GetMaxWidth(), win->GetMaxHeight(),
265 flag );
738f9e5a 266 }
7beba2fc 267
58dea4b0
RR
268 /* reset the icon */
269 if (win->m_icon != wxNullIcon)
270 {
271 wxIcon icon( win->m_icon );
272 win->m_icon = wxNullIcon;
f03fc89f 273 win->SetIcon( icon );
58dea4b0 274 }
88ac883a 275
2e563988
RR
276 /* we set the focus to the child that accepts the focus. this
277 doesn't really have to be done in "realize" but why not? */
f03fc89f 278 wxWindowList::Node *node = win->GetChildren().GetFirst();
2e563988
RR
279 while (node)
280 {
f03fc89f
VZ
281 wxWindow *child = node->GetData();
282 if (child->AcceptsFocus())
283 {
284 child->SetFocus();
285 break;
286 }
88ac883a 287
f03fc89f 288 node = node->GetNext();
2e563988 289 }
88ac883a 290
227e5e99
RR
291 return FALSE;
292}
88ac883a 293
f362b96d
RR
294//-----------------------------------------------------------------------------
295// InsertChild for wxFrame
296//-----------------------------------------------------------------------------
297
298/* Callback for wxFrame. This very strange beast has to be used because
299 * C++ has no virtual methods in a constructor. We have to emulate a
300 * virtual function here as wxWindows requires different ways to insert
301 * a child in container classes. */
302
6bc8a1c8 303static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
f362b96d 304{
5fd11f09 305 wxASSERT( GTK_IS_WIDGET(child->m_widget) );
7beba2fc 306
6bc8a1c8 307 if (!parent->m_insertInClientArea)
f362b96d
RR
308 {
309 /* these are outside the client area */
f03fc89f 310 wxFrame* frame = (wxFrame*) parent;
da048e3d 311 gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget),
a2053b27
RR
312 GTK_WIDGET(child->m_widget),
313 child->m_x,
314 child->m_y,
315 child->m_width,
316 child->m_height );
88ac883a
VZ
317
318#if wxUSE_TOOLBAR
f03fc89f
VZ
319 /* we connect to these events for recalculating the client area
320 space when the toolbar is floating */
321 if (wxIS_KIND_OF(child,wxToolBar))
322 {
323 wxToolBar *toolBar = (wxToolBar*) child;
324 if (toolBar->GetWindowStyle() & wxTB_DOCKABLE)
325 {
a2053b27 326 gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_attached",
41ca191f 327 GTK_SIGNAL_FUNC(gtk_toolbar_attached_callback), (gpointer)parent );
88ac883a 328
a2053b27 329 gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_detached",
41ca191f 330 GTK_SIGNAL_FUNC(gtk_toolbar_detached_callback), (gpointer)parent );
f03fc89f
VZ
331 }
332 }
88ac883a 333#endif // wxUSE_TOOLBAR
f362b96d
RR
334 }
335 else
336 {
337 /* these are inside the client area */
da048e3d 338 gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
a2053b27
RR
339 GTK_WIDGET(child->m_widget),
340 child->m_x,
341 child->m_y,
342 child->m_width,
343 child->m_height );
f362b96d
RR
344 }
345
f362b96d 346 /* resize on OnInternalIdle */
f03fc89f 347 parent->UpdateSize();
f362b96d
RR
348}
349
2f2aa628
RR
350//-----------------------------------------------------------------------------
351// wxFrame
c801d85f
KB
352//-----------------------------------------------------------------------------
353
354BEGIN_EVENT_TABLE(wxFrame, wxWindow)
fb1585ae 355 EVT_SIZE(wxFrame::OnSize)
54517652 356 EVT_IDLE(wxFrame::OnIdle)
fe4e9e6c 357 EVT_CLOSE(wxFrame::OnCloseWindow)
342b6a2f 358 EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
c801d85f
KB
359END_EVENT_TABLE()
360
361IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow)
362
ddb6bc71 363void wxFrame::Init()
c801d85f 364{
fb1585ae 365 m_frameMenuBar = (wxMenuBar *) NULL;
88ac883a 366#if wxUSE_STATUSBAR
fb1585ae 367 m_frameStatusBar = (wxStatusBar *) NULL;
88ac883a
VZ
368#endif // wxUSE_STATUSBAR
369#if wxUSE_TOOLBAR
fb1585ae 370 m_frameToolBar = (wxToolBar *) NULL;
88ac883a 371#endif // wxUSE_TOOLBAR
fb1585ae 372 m_sizeSet = FALSE;
b2b3ccc5
RR
373 m_miniEdge = 0;
374 m_miniTitle = 0;
ab2b3dd4 375 m_mainWidget = (GtkWidget*) NULL;
16bcc879
RR
376 m_menuBarDetached = FALSE;
377 m_toolBarDetached = FALSE;
6bc8a1c8 378 m_insertInClientArea = TRUE;
54517652 379 m_isFrame = TRUE;
362c6693 380}
c801d85f 381
ed7a557b 382wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title,
debe6624
JS
383 const wxPoint &pos, const wxSize &size,
384 long style, const wxString &name )
c801d85f 385{
ddb6bc71 386 Init();
88ac883a 387
fb1585ae 388 Create( parent, id, title, pos, size, style, name );
362c6693 389}
c801d85f 390
debe6624 391bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
c801d85f 392 const wxPoint &pos, const wxSize &size,
debe6624 393 long style, const wxString &name )
c801d85f 394{
a802c3a1 395 wxTopLevelWindows.Append( this );
8bbe427f 396
fb1585ae 397 m_needParent = FALSE;
ed7a557b 398
4dcaf11a
RR
399 if (!PreCreation( parent, pos, size ) ||
400 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
401 {
223d09f6 402 wxFAIL_MSG( wxT("wxFrame creation failed") );
7beba2fc 403 return FALSE;
4dcaf11a 404 }
c801d85f 405
fb1585ae 406 m_title = title;
88ac883a 407
6bc8a1c8 408 m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
ed7a557b 409
faecf4cb 410 GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
fb1585ae 411 if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP;
8bbe427f 412
fb1585ae 413 m_widget = gtk_window_new( win_type );
88ac883a 414
de1c750f
RR
415 if (!name.IsEmpty())
416 gtk_window_set_wmclass( GTK_WINDOW(m_widget), name.mb_str(), name.mb_str() );
8bbe427f 417
2e563988 418#ifdef __WXDEBUG__
223d09f6 419 debug_focus_in( m_widget, wxT("wxFrame::m_widget"), name );
2e563988
RR
420#endif
421
ed9b9841 422 gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
fb1585ae 423 GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
ed7a557b 424
fb1585ae
RR
425 gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
426 GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
ed7a557b 427
f362b96d 428 /* m_mainWidget holds the toolbar, the menubar and the client area */
da048e3d 429 m_mainWidget = gtk_pizza_new();
f362b96d
RR
430 gtk_widget_show( m_mainWidget );
431 GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
432 gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
88ac883a 433
2e563988 434#ifdef __WXDEBUG__
223d09f6 435 debug_focus_in( m_mainWidget, wxT("wxFrame::m_mainWidget"), name );
2e563988
RR
436#endif
437
f362b96d 438 /* m_wxwindow only represents the client area without toolbar and menubar */
da048e3d 439 m_wxwindow = gtk_pizza_new();
fb1585ae 440 gtk_widget_show( m_wxwindow );
f362b96d 441 gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow );
88ac883a 442
2e563988 443#ifdef __WXDEBUG__
223d09f6 444 debug_focus_in( m_wxwindow, wxT("wxFrame::m_wxwindow"), name );
2e563988
RR
445#endif
446
447 /* we donm't allow the frame to get the focus as otherwise
448 the frame will grabit at arbitrary fcous changes. */
449 GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
ed7a557b 450
de8113d9
RR
451 if (m_parent) m_parent->AddChild( this );
452
54517652
RR
453 /* the user resized the frame by dragging etc. */
454 gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
455 GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
456
de8113d9
RR
457 PostCreation();
458
58dea4b0 459 /* we cannot set MWM hints and icons before the widget has
2b07d713
RR
460 been realized, so we do this directly after realization */
461 gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
f03fc89f 462 GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this );
88ac883a 463
ab2b3dd4 464 /* the only way to get the window size is to connect to this event */
fb1585ae
RR
465 gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
466 GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
8bbe427f 467
fb1585ae 468 return TRUE;
362c6693 469}
c801d85f 470
19717c50 471wxFrame::~wxFrame()
c801d85f 472{
31c6b4fc 473 m_isBeingDeleted = TRUE;
88ac883a 474
fb1585ae 475 if (m_frameMenuBar) delete m_frameMenuBar;
e27ce4e9 476 m_frameMenuBar = (wxMenuBar *) NULL;
88ac883a
VZ
477
478#if wxUSE_STATUSBAR
fb1585ae 479 if (m_frameStatusBar) delete m_frameStatusBar;
e27ce4e9 480 m_frameStatusBar = (wxStatusBar *) NULL;
88ac883a
VZ
481#endif // wxUSE_STATUSBAR
482
483#if wxUSE_TOOLBAR
fb1585ae 484 if (m_frameToolBar) delete m_frameToolBar;
e27ce4e9 485 m_frameToolBar = (wxToolBar *) NULL;
88ac883a 486#endif // wxUSE_TOOLBAR
ed7a557b 487
fb1585ae 488 wxTopLevelWindows.DeleteObject( this );
2b854a32 489
0d2a2b60 490 if (wxTheApp->GetTopWindow() == this)
0d2a2b60 491 wxTheApp->SetTopWindow( (wxWindow*) NULL );
2b854a32 492
0d2a2b60 493 if (wxTopLevelWindows.Number() == 0)
0d2a2b60 494 wxTheApp->ExitMainLoop();
362c6693 495}
ed7a557b 496
debe6624 497bool wxFrame::Show( bool show )
c801d85f 498{
223d09f6 499 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 500
35178437 501 if (show && !m_sizeSet)
fb1585ae 502 {
e27ce4e9
RR
503 /* by calling GtkOnSize here, we don't have to call
504 either after showing the frame, which would entail
f362b96d 505 much ugly flicker or from within the size_allocate
e27ce4e9 506 handler, because GTK 1.1.X forbids that. */
8bbe427f 507
35178437 508 GtkOnSize( m_x, m_y, m_width, m_height );
fb1585ae 509 }
8bbe427f 510
fb1585ae 511 return wxWindow::Show( show );
362c6693 512}
c801d85f 513
19717c50 514bool wxFrame::Destroy()
c801d85f 515{
223d09f6 516 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 517
fb1585ae 518 if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
ed7a557b 519
fb1585ae 520 return TRUE;
c801d85f
KB
521}
522
bfc6fde4 523void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags )
903f689b 524{
223d09f6 525 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 526
ab2b3dd4 527 /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
223d09f6 528 wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
88ac883a 529
ab2b3dd4 530 /* avoid recursions */
88ac883a 531 if (m_resizing) return;
fb1585ae
RR
532 m_resizing = TRUE;
533
534 int old_x = m_x;
535 int old_y = m_y;
7beba2fc 536
fb1585ae
RR
537 int old_width = m_width;
538 int old_height = m_height;
8bbe427f 539
85ad5eb5 540 if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
fb1585ae
RR
541 {
542 if (x != -1) m_x = x;
543 if (y != -1) m_y = y;
544 if (width != -1) m_width = width;
545 if (height != -1) m_height = height;
546 }
547 else
548 {
549 m_x = x;
550 m_y = y;
551 m_width = width;
552 m_height = height;
553 }
554
11e1c70d 555/*
fb1585ae
RR
556 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
557 {
558 if (width == -1) m_width = 80;
559 }
560
561 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
562 {
563 if (height == -1) m_height = 26;
564 }
11e1c70d 565*/
8bbe427f 566
fb1585ae
RR
567 if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
568 if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
0c77152e
RR
569 if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
570 if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
fb1585ae
RR
571
572 if ((m_x != -1) || (m_y != -1))
573 {
8bbe427f 574 if ((m_x != old_x) || (m_y != old_y))
0138c2de 575 {
8487f887 576 gtk_widget_set_uposition( m_widget, m_x, m_y );
0138c2de 577 }
fb1585ae 578 }
8bbe427f 579
fb1585ae
RR
580 if ((m_width != old_width) || (m_height != old_height))
581 {
ab2b3dd4 582 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
f03fc89f
VZ
583 done either directly before the frame is shown or in idle time
584 so that different calls to SetSize() don't lead to flicker. */
de8113d9 585 m_sizeSet = FALSE;
fb1585ae 586 }
8bbe427f 587
fb1585ae 588 m_resizing = FALSE;
903f689b
RR
589}
590
591void wxFrame::Centre( int direction )
592{
223d09f6 593 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 594
43a18898
RR
595 int x = 0;
596 int y = 0;
8bbe427f 597
f5eafd0e
RR
598 if ((direction & wxHORIZONTAL) == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
599 if ((direction & wxVERTICAL) == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
8bbe427f 600
fb1585ae 601 Move( x, y );
903f689b
RR
602}
603
f9241296 604void wxFrame::DoGetClientSize( int *width, int *height ) const
c801d85f 605{
223d09f6 606 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 607
f9241296 608 wxWindow::DoGetClientSize( width, height );
fb1585ae 609 if (height)
46dc76ba 610 {
41ca191f
RR
611 /* menu bar */
612 if (m_frameMenuBar)
f03fc89f 613 {
88ac883a 614 if (!m_menuBarDetached)
f03fc89f
VZ
615 (*height) -= wxMENU_HEIGHT;
616 else
617 (*height) -= wxPLACE_HOLDER;
618 }
88ac883a 619
dcf924a3 620#if wxUSE_STATUSBAR
f03fc89f 621 /* status bar */
fb1585ae 622 if (m_frameStatusBar) (*height) -= wxSTATUS_HEIGHT;
dcf924a3 623#endif
88ac883a 624
dcf924a3 625#if wxUSE_TOOLBAR
f03fc89f 626 /* tool bar */
fb1585ae
RR
627 if (m_frameToolBar)
628 {
f03fc89f
VZ
629 if (!m_toolBarDetached)
630 {
41ca191f
RR
631 int y = 0;
632 m_frameToolBar->GetSize( (int *) NULL, &y );
633 (*height) -= y;
f03fc89f
VZ
634 }
635 else
41ca191f 636 (*height) -= wxPLACE_HOLDER;
fb1585ae 637 }
dcf924a3 638#endif
88ac883a 639
f03fc89f 640 /* mini edge */
b2b3ccc5
RR
641 (*height) -= m_miniEdge*2 + m_miniTitle;
642 }
643 if (width)
644 {
645 (*width) -= m_miniEdge*2;
46dc76ba 646 }
362c6693 647}
c801d85f 648
bfc6fde4 649void wxFrame::DoSetClientSize( int width, int height )
b593568e 650{
223d09f6 651 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 652
41ca191f
RR
653 /* menu bar */
654 if (m_frameMenuBar)
f03fc89f 655 {
88ac883a 656 if (!m_menuBarDetached)
f03fc89f
VZ
657 height += wxMENU_HEIGHT;
658 else
659 height += wxPLACE_HOLDER;
660 }
88ac883a 661
dcf924a3 662#if wxUSE_STATUSBAR
f03fc89f 663 /* status bar */
41ca191f 664 if (m_frameStatusBar) height += wxSTATUS_HEIGHT;
dcf924a3 665#endif
88ac883a 666
dcf924a3 667#if wxUSE_TOOLBAR
f03fc89f 668 /* tool bar */
41ca191f
RR
669 if (m_frameToolBar)
670 {
f03fc89f
VZ
671 if (!m_toolBarDetached)
672 {
41ca191f
RR
673 int y = 0;
674 m_frameToolBar->GetSize( (int *) NULL, &y );
675 height += y;
f03fc89f
VZ
676 }
677 else
41ca191f
RR
678 height += wxPLACE_HOLDER;
679 }
dcf924a3 680#endif
88ac883a 681
3017f78d 682 DoSetSize( -1, -1, width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0 );
362c6693 683}
b593568e 684
47908e25 685void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height )
c801d85f 686{
f5368809
RR
687 // due to a bug in gtk, x,y are always 0
688 // m_x = x;
689 // m_y = y;
690
ab2b3dd4 691 /* avoid recursions */
e52f60e6
RR
692 if (m_resizing) return;
693 m_resizing = TRUE;
8bbe427f 694
ab2b3dd4 695 /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
223d09f6 696 wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
88ac883a 697
f5368809
RR
698 m_width = width;
699 m_height = height;
7beba2fc 700
ab2b3dd4 701 /* space occupied by m_frameToolBar and m_frameMenuBar */
88ac883a 702 int client_area_y_offset = 0;
8bbe427f 703
ab2b3dd4
RR
704 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
705 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
706 set in wxFrame::Create so it is used to check what kind of frame we
707 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
708 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
709 importantly) m_mainWidget */
88ac883a 710
ab2b3dd4 711 if (m_mainWidget)
f5368809 712 {
ab2b3dd4
RR
713 /* check if size is in legal range */
714 if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
715 if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
716 if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
717 if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
718
719 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
720 * menubar, the toolbar and the client area, which is represented by
721 * m_wxwindow.
722 * this hurts in the eye, but I don't want to call SetSize()
723 * because I don't want to call any non-native functions here. */
88ac883a 724
ab2b3dd4
RR
725 if (m_frameMenuBar)
726 {
727 int xx = m_miniEdge;
728 int yy = m_miniEdge + m_miniTitle;
729 int ww = m_width - 2*m_miniEdge;
41ca191f 730 int hh = wxMENU_HEIGHT;
f03fc89f 731 if (m_menuBarDetached) hh = wxPLACE_HOLDER;
121a3581
RR
732 m_frameMenuBar->m_x = xx;
733 m_frameMenuBar->m_y = yy;
734 m_frameMenuBar->m_width = ww;
735 m_frameMenuBar->m_height = hh;
da048e3d 736 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
88ac883a 737 m_frameMenuBar->m_widget,
f03fc89f
VZ
738 xx, yy, ww, hh );
739 client_area_y_offset += hh;
ab2b3dd4 740 }
88ac883a 741
dcf924a3 742#if wxUSE_TOOLBAR
11e1c70d 743 if ((m_frameToolBar) &&
7beba2fc 744 (m_frameToolBar->m_widget->parent == m_mainWidget))
ab2b3dd4
RR
745 {
746 int xx = m_miniEdge;
747 int yy = m_miniEdge + m_miniTitle;
41ca191f 748 if (m_frameMenuBar)
f03fc89f 749 {
88ac883a
VZ
750 if (!m_menuBarDetached)
751 yy += wxMENU_HEIGHT;
752 else
f03fc89f
VZ
753 yy += wxPLACE_HOLDER;
754 }
ab2b3dd4 755 int ww = m_width - 2*m_miniEdge;
a2053b27 756 int hh = m_frameToolBar->m_height;
7beba2fc 757 if (m_toolBarDetached) hh = wxPLACE_HOLDER;
121a3581
RR
758 m_frameToolBar->m_x = xx;
759 m_frameToolBar->m_y = yy;
11e1c70d
RR
760 /* m_frameToolBar->m_height = hh; don't change the toolbar's reported size
761 m_frameToolBar->m_width = ww; */
da048e3d 762 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
88ac883a 763 m_frameToolBar->m_widget,
f03fc89f
VZ
764 xx, yy, ww, hh );
765 client_area_y_offset += hh;
ab2b3dd4 766 }
dcf924a3 767#endif
88ac883a 768
32a95f9f 769 int client_x = m_miniEdge;
f03fc89f 770 int client_y = client_area_y_offset + m_miniEdge + m_miniTitle;
32a95f9f 771 int client_w = m_width - 2*m_miniEdge;
f03fc89f 772 int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle;
da048e3d 773 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
88ac883a 774 m_wxwindow,
f03fc89f 775 client_x, client_y, client_w, client_h );
32a95f9f
RR
776 }
777 else
778 {
779 /* if there is no m_mainWidget between m_widget and m_wxwindow there
f03fc89f 780 is no need to set the size or position of m_wxwindow. */
f5368809 781 }
88ac883a 782
dcf924a3 783#if wxUSE_STATUSBAR
f5368809
RR
784 if (m_frameStatusBar)
785 {
b2b3ccc5 786 int xx = 0 + m_miniEdge;
f362b96d 787 int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset;
ac57418f
RR
788 int ww = m_width - 2*m_miniEdge;
789 int hh = wxSTATUS_HEIGHT;
121a3581
RR
790 m_frameStatusBar->m_x = xx;
791 m_frameStatusBar->m_y = yy;
792 m_frameStatusBar->m_width = ww;
793 m_frameStatusBar->m_height = hh;
da048e3d 794 gtk_pizza_set_size( GTK_PIZZA(m_wxwindow),
88ac883a 795 m_frameStatusBar->m_widget,
f03fc89f 796 xx, yy, ww, hh );
f5368809 797 }
dcf924a3 798#endif
8bbe427f 799
de8113d9
RR
800 /* we actually set the size of a frame here and no-where else */
801 gtk_widget_set_usize( m_widget, m_width, m_height );
88ac883a 802
8bbe427f 803
54517652 804 m_sizeSet = TRUE;
7beba2fc 805
54517652 806 // send size event to frame
43a18898
RR
807 wxSizeEvent event( wxSize(m_width,m_height), GetId() );
808 event.SetEventObject( this );
e52f60e6 809 GetEventHandler()->ProcessEvent( event );
8bbe427f 810
54517652 811 // send size event to status bar
5aa5e35a
RR
812 if (m_frameStatusBar)
813 {
a2053b27 814 wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() );
5aa5e35a
RR
815 event2.SetEventObject( m_frameStatusBar );
816 m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 );
817 }
884470b1 818
e52f60e6
RR
819 m_resizing = FALSE;
820}
821
ca26177c
RR
822void wxFrame::MakeModal( bool modal )
823{
824 if (modal)
ca26177c 825 gtk_grab_add( m_widget );
ca26177c 826 else
c25ccf85 827 gtk_grab_remove( m_widget );
ca26177c
RR
828}
829
9390a202 830void wxFrame::OnInternalIdle()
e52f60e6 831{
1b3667ab 832 if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow))
54517652 833 {
e52f60e6 834 GtkOnSize( m_x, m_y, m_width, m_height );
7beba2fc
VZ
835
836 // we'll come back later
54517652
RR
837 if (g_isIdle)
838 wxapp_install_idle_handler();
7beba2fc 839 return;
54517652 840 }
88ac883a 841
082b2798 842 if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle();
dcf924a3 843#if wxUSE_TOOLBAR
082b2798 844 if (m_frameToolBar) m_frameToolBar->OnInternalIdle();
dcf924a3
RR
845#endif
846#if wxUSE_STATUSBAR
082b2798 847 if (m_frameStatusBar) m_frameStatusBar->OnInternalIdle();
dcf924a3 848#endif
5e014a0c
RR
849
850 wxWindow::OnInternalIdle();
362c6693 851}
c801d85f 852
6bc8a1c8 853void wxFrame::OnCloseWindow( wxCloseEvent& WXUNUSED(event) )
fe4e9e6c 854{
e3065973 855 Destroy();
fe4e9e6c
VZ
856}
857
c801d85f
KB
858void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
859{
223d09f6 860 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 861
88ac883a 862#if wxUSE_CONSTRAINTS
f5368809
RR
863 if (GetAutoLayout())
864 {
865 Layout();
866 }
8bbe427f 867 else
88ac883a 868#endif // wxUSE_CONSTRAINTS
c801d85f 869 {
ab46dc18 870 /* do we have exactly one child? */
0138c2de
VZ
871 wxWindow *child = (wxWindow *)NULL;
872 for ( wxNode *node = GetChildren().First(); node; node = node->Next() )
f5368809
RR
873 {
874 wxWindow *win = (wxWindow *)node->Data();
0138c2de 875 if ( !wxIS_KIND_OF(win,wxFrame) && !wxIS_KIND_OF(win,wxDialog) )
f5368809 876 {
ab46dc18 877 if (child)
0138c2de 878 {
ab46dc18 879 /* it's the second one: do nothing */
0138c2de
VZ
880 return;
881 }
882
f5368809
RR
883 child = win;
884 }
885 }
ed7a557b 886
ab46dc18
RR
887 /* no children at all? */
888 if (child)
0138c2de 889 {
ab46dc18 890 /* yes: set it's size to fill all the frame */
0138c2de 891 int client_x, client_y;
326f9654 892 DoGetClientSize( &client_x, &client_y );
0138c2de
VZ
893 child->SetSize( 1, 1, client_x-2, client_y-2 );
894 }
362c6693 895 }
362c6693 896}
c801d85f 897
c801d85f
KB
898void wxFrame::SetMenuBar( wxMenuBar *menuBar )
899{
223d09f6
KB
900 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
901 wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
8bbe427f 902
f5368809 903 m_frameMenuBar = menuBar;
8bbe427f 904
f5368809 905 if (m_frameMenuBar)
30dea054 906 {
5bd9e519 907 m_frameMenuBar->SetInvokingWindow( this );
8bbe427f 908
f03fc89f 909 if (m_frameMenuBar->GetParent() != this)
f5368809 910 {
f03fc89f 911 m_frameMenuBar->SetParent(this);
da048e3d 912 gtk_pizza_put( GTK_PIZZA(m_mainWidget),
88ac883a
VZ
913 m_frameMenuBar->m_widget,
914 m_frameMenuBar->m_x,
a2053b27
RR
915 m_frameMenuBar->m_y,
916 m_frameMenuBar->m_width,
917 m_frameMenuBar->m_height );
88ac883a 918
f03fc89f
VZ
919 if (menuBar->GetWindowStyle() & wxMB_DOCKABLE)
920 {
a2053b27 921 gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_attached",
16bcc879 922 GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this );
88ac883a 923
a2053b27 924 gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached",
16bcc879 925 GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this );
f03fc89f 926 }
7beba2fc
VZ
927
928 m_frameMenuBar->Show( TRUE );
f5368809 929 }
716b7364 930 }
8bbe427f 931
1e133b7d 932 /* resize window in OnInternalIdle */
5b077d48 933 m_sizeSet = FALSE;
362c6693 934}
c801d85f 935
8bbe427f 936wxMenuBar *wxFrame::GetMenuBar() const
46dc76ba 937{
f5368809 938 return m_frameMenuBar;
362c6693 939}
46dc76ba 940
342b6a2f
RR
941void wxFrame::OnMenuHighlight(wxMenuEvent& event)
942{
88ac883a 943#if wxUSE_STATUSBAR
342b6a2f
RR
944 if (GetStatusBar())
945 {
0138c2de
VZ
946 // if no help string found, we will clear the status bar text
947 wxString helpString;
948
949 int menuId = event.GetMenuId();
10c1d217 950 if ( menuId != wxID_SEPARATOR && menuId != -2 /* wxID_TITLE */ )
342b6a2f
RR
951 {
952 wxMenuBar *menuBar = GetMenuBar();
10c1d217 953 if ( menuBar )
342b6a2f 954 {
10c1d217
VZ
955 // it's ok if we don't find the item because it might belong to
956 // the popup menu
957 wxMenuItem *item = menuBar->FindItem(menuId);
958 if ( item )
959 helpString = item->GetHelp();
342b6a2f
RR
960 }
961 }
0138c2de
VZ
962
963 SetStatusText(helpString);
342b6a2f 964 }
88ac883a 965#endif // wxUSE_STATUSBAR
342b6a2f
RR
966}
967
88ac883a 968#if wxUSE_TOOLBAR
6bc8a1c8 969wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name )
46dc76ba 970{
223d09f6 971 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 972
223d09f6 973 wxCHECK_MSG( m_frameToolBar == NULL, FALSE, wxT("recreating toolbar in wxFrame") );
362c6693 974
6bc8a1c8 975 m_insertInClientArea = FALSE;
88ac883a 976
f5368809 977 m_frameToolBar = OnCreateToolBar( style, id, name );
8bbe427f 978
6bc8a1c8 979 if (m_frameToolBar) GetChildren().DeleteObject( m_frameToolBar );
88ac883a 980
6bc8a1c8 981 m_insertInClientArea = TRUE;
8bbe427f 982
5b077d48 983 m_sizeSet = FALSE;
8bbe427f 984
f5368809 985 return m_frameToolBar;
362c6693 986}
46dc76ba 987
362c6693 988wxToolBar* wxFrame::OnCreateToolBar( long style, wxWindowID id, const wxString& name )
46dc76ba 989{
f5368809 990 return new wxToolBar( this, id, wxDefaultPosition, wxDefaultSize, style, name );
362c6693
RR
991}
992
7beba2fc
VZ
993void wxFrame::SetToolBar(wxToolBar *toolbar)
994{
995 m_frameToolBar = toolbar;
307f16e8
RR
996 if (m_frameToolBar)
997 {
998 /* insert into toolbar area if not already there */
3017f78d
RR
999 if ((m_frameToolBar->m_widget->parent) &&
1000 (m_frameToolBar->m_widget->parent != m_mainWidget))
307f16e8 1001 {
3017f78d 1002 GetChildren().DeleteObject( m_frameToolBar );
7beba2fc
VZ
1003
1004 gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget );
1005 UpdateSize();
1006 }
307f16e8
RR
1007 }
1008}
1009
8bbe427f
VZ
1010wxToolBar *wxFrame::GetToolBar() const
1011{
1012 return m_frameToolBar;
362c6693 1013}
88ac883a 1014#endif // wxUSE_TOOLBAR
46dc76ba 1015
88ac883a 1016#if wxUSE_STATUSBAR
e3e65dac 1017wxStatusBar* wxFrame::CreateStatusBar( int number, long style, wxWindowID id, const wxString& name )
c801d85f 1018{
223d09f6 1019 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 1020
223d09f6 1021 wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, wxT("recreating status bar in wxFrame") );
c801d85f 1022
f5368809 1023 m_frameStatusBar = OnCreateStatusBar( number, style, id, name );
8bbe427f 1024
5b077d48 1025 m_sizeSet = FALSE;
8bbe427f 1026
f5368809 1027 return m_frameStatusBar;
362c6693
RR
1028}
1029
1030wxStatusBar *wxFrame::OnCreateStatusBar( int number, long style, wxWindowID id, const wxString& name )
1031{
f5368809 1032 wxStatusBar *statusBar = (wxStatusBar *) NULL;
8bbe427f 1033
f5368809 1034 statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 20), style, name);
8bbe427f 1035
f5368809
RR
1036 // Set the height according to the font and the border size
1037 wxClientDC dc(statusBar);
8bbe427f 1038 dc.SetFont( statusBar->GetFont() );
362c6693 1039
f5368809
RR
1040 long x, y;
1041 dc.GetTextExtent( "X", &x, &y );
362c6693 1042
f5368809 1043 int height = (int)( (y * 1.1) + 2* statusBar->GetBorderY());
362c6693 1044
f5368809 1045 statusBar->SetSize( -1, -1, 100, height );
362c6693 1046
f5368809
RR
1047 statusBar->SetFieldsCount( number );
1048 return statusBar;
362c6693 1049}
c801d85f 1050
88ac883a 1051wxStatusBar *wxFrame::GetStatusBar() const
30f1b5f3 1052{
88ac883a 1053 return m_frameStatusBar;
30f1b5f3
RR
1054}
1055
362c6693 1056void wxFrame::SetStatusText(const wxString& text, int number)
c801d85f 1057{
223d09f6 1058 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 1059
223d09f6 1060 wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set text for") );
c801d85f 1061
f5368809 1062 m_frameStatusBar->SetStatusText(text, number);
362c6693
RR
1063}
1064
1065void wxFrame::SetStatusWidths(int n, const int widths_field[] )
c801d85f 1066{
223d09f6 1067 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 1068
223d09f6 1069 wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set widths for") );
362c6693 1070
f5368809 1071 m_frameStatusBar->SetStatusWidths(n, widths_field);
362c6693 1072}
88ac883a 1073#endif // wxUSE_STATUSBAR
c801d85f 1074
88ac883a 1075void wxFrame::Command( int id )
c801d85f 1076{
88ac883a
VZ
1077 wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, id);
1078 commandEvent.SetInt( id );
1079 commandEvent.SetEventObject( this );
1080
1081 wxMenuBar *bar = GetMenuBar();
1082 if (!bar) return;
1083
1987af7e 1084 wxMenuItem *item = bar->FindItem(id) ;
88ac883a
VZ
1085 if (item && item->IsCheckable())
1086 {
1987af7e 1087 bar->Check(id, !bar->IsChecked(id)) ;
88ac883a
VZ
1088 }
1089
1090 wxEvtHandler* evtHandler = GetEventHandler();
1091
1092 evtHandler->ProcessEvent(commandEvent);
362c6693 1093}
c801d85f 1094
c801d85f
KB
1095void wxFrame::SetTitle( const wxString &title )
1096{
223d09f6 1097 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 1098
f5368809 1099 m_title = title;
223d09f6 1100 if (m_title.IsNull()) m_title = wxT("");
ed9b9841 1101 gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
362c6693 1102}
c801d85f 1103
d355d3fe
RR
1104void wxFrame::SetIcon( const wxIcon &icon )
1105{
223d09f6 1106 wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
8bbe427f 1107
f5368809
RR
1108 m_icon = icon;
1109 if (!icon.Ok()) return;
8bbe427f 1110
58dea4b0
RR
1111 if (!m_widget->window) return;
1112
f5368809
RR
1113 wxMask *mask = icon.GetMask();
1114 GdkBitmap *bm = (GdkBitmap *) NULL;
1115 if (mask) bm = mask->GetBitmap();
8bbe427f 1116
f5368809 1117 gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm );
d355d3fe 1118}
b2b3ccc5 1119
7beba2fc 1120void wxFrame::Maximize(bool WXUNUSED(maximize))
cd25b18c
RR
1121{
1122}
1123
7beba2fc 1124void wxFrame::Restore()
cd25b18c
RR
1125{
1126}
1127
7beba2fc
VZ
1128void wxFrame::Iconize( bool iconize )
1129{
cd25b18c
RR
1130 if (iconize)
1131 {
1132 XIconifyWindow( GDK_WINDOW_XDISPLAY( m_widget->window ),
7beba2fc
VZ
1133 GDK_WINDOW_XWINDOW( m_widget->window ),
1134 DefaultScreen( GDK_DISPLAY() ) );
cd25b18c
RR
1135 }
1136}
1137
7beba2fc
VZ
1138bool wxFrame::IsIconized() const
1139{
1140 return FALSE;
cd25b18c 1141}