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