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