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