]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/frame.cpp
Here it comes:
[wxWidgets.git] / src / gtk / frame.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: frame.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifdef __GNUG__
11 #pragma implementation "frame.h"
12 #endif
13
14 #include "wx/frame.h"
15 #include "wx/dialog.h"
16 #include "wx/control.h"
17 #include "wx/app.h"
18 #include "wx/menu.h"
19 #include "wx/toolbar.h"
20 #include "wx/statusbr.h"
21 #include "wx/dcclient.h"
22
23 #include "glib.h"
24 #include "gdk/gdk.h"
25 #include "gtk/gtk.h"
26 #include "wx/gtk/win_gtk.h"
27
28 //-----------------------------------------------------------------------------
29 // constants
30 //-----------------------------------------------------------------------------
31
32 const int wxMENU_HEIGHT = 27;
33 const int wxSTATUS_HEIGHT = 25;
34
35 //-----------------------------------------------------------------------------
36 // data
37 //-----------------------------------------------------------------------------
38
39 extern wxList wxPendingDelete;
40
41 //-----------------------------------------------------------------------------
42 // "size_allocate"
43 //-----------------------------------------------------------------------------
44
45 static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win )
46 {
47 if (!win->HasVMT()) return;
48
49 /*
50 printf( "OnFrameResize from " );
51 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
52 printf( win->GetClassInfo()->GetClassName() );
53 printf( ".\n" );
54 */
55
56 if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
57 {
58 win->m_sizeSet = FALSE;
59 win->m_width = alloc->width;
60 win->m_height = alloc->height;
61 }
62 }
63
64 //-----------------------------------------------------------------------------
65 // "delete_event"
66 //-----------------------------------------------------------------------------
67
68 static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxFrame *win )
69 {
70 /*
71 printf( "OnDelete from " );
72 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
73 printf( win->GetClassInfo()->GetClassName() );
74 printf( ".\n" );
75 */
76
77 win->Close();
78
79 return TRUE;
80 }
81
82 //-----------------------------------------------------------------------------
83 // "configure_event"
84 //-----------------------------------------------------------------------------
85
86 static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win )
87 {
88 if (!win->HasVMT()) return FALSE;
89
90 win->m_x = event->x;
91 win->m_y = event->y;
92
93 wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
94 mevent.SetEventObject( win );
95 win->GetEventHandler()->ProcessEvent( mevent );
96
97 return FALSE;
98 }
99
100 //-----------------------------------------------------------------------------
101 // wxFrame
102 //-----------------------------------------------------------------------------
103
104 BEGIN_EVENT_TABLE(wxFrame, wxWindow)
105 EVT_SIZE(wxFrame::OnSize)
106 EVT_CLOSE(wxFrame::OnCloseWindow)
107 EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
108 END_EVENT_TABLE()
109
110 IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow)
111
112 wxFrame::wxFrame()
113 {
114 m_frameMenuBar = (wxMenuBar *) NULL;
115 m_mdiMenuBar = (wxMenuBar *) NULL;
116 m_frameStatusBar = (wxStatusBar *) NULL;
117 m_frameToolBar = (wxToolBar *) NULL;
118 m_sizeSet = FALSE;
119 m_miniEdge = 0;
120 m_miniTitle = 0;
121 }
122
123 wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title,
124 const wxPoint &pos, const wxSize &size,
125 long style, const wxString &name )
126 {
127 m_frameMenuBar = (wxMenuBar *) NULL;
128 m_mdiMenuBar = (wxMenuBar *) NULL;
129 m_frameStatusBar = (wxStatusBar *) NULL;
130 m_frameToolBar = (wxToolBar *) NULL;
131 m_sizeSet = FALSE;
132 m_miniEdge = 0;
133 m_miniTitle = 0;
134 Create( parent, id, title, pos, size, style, name );
135 }
136
137 bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
138 const wxPoint &pos, const wxSize &size,
139 long style, const wxString &name )
140 {
141 wxTopLevelWindows.Append( this );
142
143 m_needParent = FALSE;
144
145 PreCreation( parent, id, pos, size, style, name );
146
147 m_title = title;
148
149 GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
150 if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP;
151
152 m_widget = gtk_window_new( win_type );
153
154 gtk_window_set_title( GTK_WINDOW(m_widget), title );
155 GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
156
157 gtk_window_set_policy( GTK_WINDOW(m_widget), 1, 1, 0 );
158
159 gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
160 GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
161
162 m_wxwindow = gtk_myfixed_new();
163 gtk_widget_show( m_wxwindow );
164 GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
165
166 gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
167
168 if (m_parent) m_parent->AddChild( this );
169
170 PostCreation();
171
172 gtk_widget_realize( m_widget );
173
174 long decor = (long) GDK_DECOR_ALL;
175 long func = (long) GDK_FUNC_ALL;
176
177 if ((m_windowStyle & wxCAPTION) == 0)
178 decor |= GDK_DECOR_TITLE;
179 if ((m_windowStyle & wxMINIMIZE) == 0)
180 func |= GDK_FUNC_MINIMIZE;
181 if ((m_windowStyle & wxMAXIMIZE) == 0)
182 func |= GDK_FUNC_MAXIMIZE;
183 if ((m_windowStyle & wxSYSTEM_MENU) == 0)
184 decor |= GDK_DECOR_MENU;
185 if ((m_windowStyle & wxMINIMIZE_BOX) == 0)
186 decor |= GDK_DECOR_MINIMIZE;
187 if ((m_windowStyle & wxMAXIMIZE_BOX) == 0)
188 decor |= GDK_DECOR_MAXIMIZE;
189 if ((m_windowStyle & wxRESIZE_BORDER) == 0)
190 func |= GDK_FUNC_RESIZE;
191
192 gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
193 gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
194
195 gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
196 GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
197
198 gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
199 GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
200
201 return TRUE;
202 }
203
204 wxFrame::~wxFrame()
205 {
206 if (m_frameMenuBar) delete m_frameMenuBar;
207 m_frameMenuBar = (wxMenuBar *) NULL;
208
209 if (m_frameStatusBar) delete m_frameStatusBar;
210 m_frameStatusBar = (wxStatusBar *) NULL;
211
212 if (m_frameToolBar) delete m_frameToolBar;
213 m_frameToolBar = (wxToolBar *) NULL;
214
215 wxTopLevelWindows.DeleteObject( this );
216
217 if (wxTheApp->GetTopWindow() == this)
218 {
219 wxTheApp->SetTopWindow( (wxWindow*) NULL );
220 }
221
222 if (wxTopLevelWindows.Number() == 0)
223 {
224 wxTheApp->ExitMainLoop();
225 }
226 }
227
228 bool wxFrame::Show( bool show )
229 {
230 wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
231
232 if (show && !m_sizeSet)
233 {
234 /* by calling GtkOnSize here, we don't have to call
235 either after showing the frame, which would entail
236 much ugly flicker nor from within the size_allocate
237 handler, because GTK 1.1.X forbids that. */
238
239 GtkOnSize( m_x, m_y, m_width, m_height );
240 }
241
242 return wxWindow::Show( show );
243 }
244
245 bool wxFrame::Destroy()
246 {
247 wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
248
249 if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
250
251 return TRUE;
252 }
253
254 wxPoint wxFrame::GetClientAreaOrigin() const
255 {
256 wxPoint pt( m_miniEdge, m_miniEdge + m_miniTitle );
257 if (m_frameMenuBar)
258 {
259 int h = 0;
260 m_frameMenuBar->GetSize( (int*)NULL, &h );
261 pt.y += h;
262 }
263 if (m_frameToolBar)
264 {
265 int h = 0;
266 m_frameToolBar->GetSize( (int*)NULL, &h );
267 pt.y += h;
268 }
269 return pt;
270 }
271
272 void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags )
273 {
274 wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
275
276 /* don't do anything for children of wxMDIChildFrame */
277 if (!m_wxwindow) return;
278
279 if (m_resizing) return; // I don't like recursions
280 m_resizing = TRUE;
281
282 int old_x = m_x;
283 int old_y = m_y;
284 int old_width = m_width;
285 int old_height = m_height;
286
287 if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
288 {
289 if (x != -1) m_x = x;
290 if (y != -1) m_y = y;
291 if (width != -1) m_width = width;
292 if (height != -1) m_height = height;
293 }
294 else
295 {
296 m_x = x;
297 m_y = y;
298 m_width = width;
299 m_height = height;
300 }
301
302 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
303 {
304 if (width == -1) m_width = 80;
305 }
306
307 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
308 {
309 if (height == -1) m_height = 26;
310 }
311
312 if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
313 if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
314 if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
315 if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
316
317 if ((m_x != -1) || (m_y != -1))
318 {
319 if ((m_x != old_x) || (m_y != old_y))
320 {
321 /* m_sizeSet = FALSE; */
322 gtk_widget_set_uposition( m_widget, m_x, m_y );
323 }
324 }
325
326 if ((m_width != old_width) || (m_height != old_height))
327 {
328 /* we set the size in GtkOnSize */
329 m_sizeSet = FALSE;
330 }
331
332 m_resizing = FALSE;
333 }
334
335 void wxFrame::Centre( int direction )
336 {
337 wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
338
339 int x = 0;
340 int y = 0;
341
342 if ((direction & wxHORIZONTAL) == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
343 if ((direction & wxVERTICAL) == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
344
345 Move( x, y );
346 }
347
348 void wxFrame::GetClientSize( int *width, int *height ) const
349 {
350 wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
351
352 wxWindow::GetClientSize( width, height );
353 if (height)
354 {
355 if (m_frameMenuBar) (*height) -= wxMENU_HEIGHT;
356 if (m_frameStatusBar) (*height) -= wxSTATUS_HEIGHT;
357 if (m_frameToolBar)
358 {
359 int y = 0;
360 m_frameToolBar->GetSize( (int *) NULL, &y );
361 (*height) -= y;
362 }
363 (*height) -= m_miniEdge*2 + m_miniTitle;
364 }
365 if (width)
366 {
367 (*width) -= m_miniEdge*2;
368 }
369 }
370
371 void wxFrame::DoSetClientSize( int width, int height )
372 {
373 wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
374
375 int h = height;
376 if (m_frameMenuBar) h += wxMENU_HEIGHT;
377 if (m_frameStatusBar) h += wxSTATUS_HEIGHT;
378 if (m_frameToolBar)
379 {
380 int y = 0;
381 m_frameToolBar->GetSize( (int *) NULL, &y );
382 h += y;
383 }
384 wxWindow::DoSetClientSize( width + m_miniEdge*2, h + m_miniEdge*2 + m_miniTitle );
385 }
386
387 void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height )
388 {
389 // due to a bug in gtk, x,y are always 0
390 // m_x = x;
391 // m_y = y;
392
393 if (m_resizing) return;
394 m_resizing = TRUE;
395
396 if (!m_wxwindow) return;
397
398 m_width = width;
399 m_height = height;
400
401 /* check if size is in legal range */
402 if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
403 if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
404 if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
405 if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
406
407 /* this emulates the new wxMSW behaviour of placing all
408 * frame-subwindows (menu, toolbar..) on one native window
409 * this hurts in the eye, but I don't want to call SetSize()
410 * because I don't want to call any non-native functions here. */
411
412 if (m_frameMenuBar)
413 {
414 int xx = m_miniEdge;
415 int yy = m_miniEdge + m_miniTitle;
416 int ww = m_width - 2*m_miniEdge;
417 int hh = wxMENU_HEIGHT;
418 m_frameMenuBar->m_x = xx;
419 m_frameMenuBar->m_y = yy;
420 m_frameMenuBar->m_width = ww;
421 m_frameMenuBar->m_height = hh;
422
423 gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameMenuBar->m_widget, xx, yy );
424 gtk_widget_set_usize( m_frameMenuBar->m_widget, ww, hh );
425 }
426
427 if (m_frameToolBar)
428 {
429 int xx = m_miniEdge;
430 int yy = m_miniEdge + m_miniTitle;
431 if ((m_frameMenuBar) || (m_mdiMenuBar)) yy += wxMENU_HEIGHT;
432 int ww = m_width - 2*m_miniEdge;
433 int hh = m_frameToolBar->m_height;
434
435 m_frameToolBar->m_x = xx;
436 m_frameToolBar->m_y = yy;
437 m_frameToolBar->m_height = hh;
438 m_frameToolBar->m_width = ww;
439
440 gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameToolBar->m_widget, xx, yy );
441 gtk_widget_set_usize( m_frameToolBar->m_widget, ww, hh );
442 }
443
444 if (m_frameStatusBar)
445 {
446 int xx = 0 + m_miniEdge;
447 int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge;
448 int ww = m_width - 2*m_miniEdge;
449 int hh = wxSTATUS_HEIGHT;
450
451 m_frameStatusBar->m_x = xx;
452 m_frameStatusBar->m_y = yy;
453 m_frameStatusBar->m_width = ww;
454 m_frameStatusBar->m_height = hh;
455
456 gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameStatusBar->m_widget, xx, yy );
457 gtk_widget_set_usize( m_frameStatusBar->m_widget, ww, hh );
458 }
459
460 /* we actually set the size of a frame here and no-where else */
461 gtk_widget_set_usize( m_widget, m_width, m_height );
462
463 m_sizeSet = TRUE;
464
465 /* send size event to frame */
466 wxSizeEvent event( wxSize(m_width,m_height), GetId() );
467 event.SetEventObject( this );
468 GetEventHandler()->ProcessEvent( event );
469
470 /* send size event to status bar */
471 if (m_frameStatusBar)
472 {
473 wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() );
474 event2.SetEventObject( m_frameStatusBar );
475 m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 );
476 }
477
478 m_resizing = FALSE;
479 }
480
481 void wxFrame::OnInternalIdle()
482 {
483 if (!m_sizeSet)
484 GtkOnSize( m_x, m_y, m_width, m_height );
485
486 DoMenuUpdates();
487 }
488
489 void wxFrame::OnCloseWindow( wxCloseEvent& event )
490 {
491 // close the window if it wasn't vetoed by the application
492 // if ( !event.GetVeto() ) // No, this isn't the interpretation of GetVeto.
493 Destroy();
494 }
495
496 void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
497 {
498 wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
499
500 if (GetAutoLayout())
501 {
502 Layout();
503 }
504 else
505 {
506 // do we have exactly one child?
507 wxWindow *child = (wxWindow *)NULL;
508 for ( wxNode *node = GetChildren().First(); node; node = node->Next() )
509 {
510 wxWindow *win = (wxWindow *)node->Data();
511 if ( !wxIS_KIND_OF(win,wxFrame) && !wxIS_KIND_OF(win,wxDialog) )
512 {
513 if ( child )
514 {
515 // it's the second one: do nothing
516 return;
517 }
518
519 child = win;
520 }
521 }
522
523 // no children at all?
524 if ( child )
525 {
526 // yes: set it's size to fill all the frame
527 int client_x, client_y;
528 GetClientSize( &client_x, &client_y );
529 child->SetSize( 1, 1, client_x-2, client_y-2 );
530 }
531 }
532 }
533
534 static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
535 {
536 menu->SetInvokingWindow( win );
537 wxNode *node = menu->GetItems().First();
538 while (node)
539 {
540 wxMenuItem *menuitem = (wxMenuItem*)node->Data();
541 if (menuitem->IsSubMenu())
542 SetInvokingWindow( menuitem->GetSubMenu(), win );
543 node = node->Next();
544 }
545 }
546
547 void wxFrame::SetMenuBar( wxMenuBar *menuBar )
548 {
549 wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
550 wxASSERT_MSG( (m_wxwindow != NULL), "invalid frame" );
551
552 m_frameMenuBar = menuBar;
553
554 if (m_frameMenuBar)
555 {
556 wxNode *node = m_frameMenuBar->GetMenus().First();
557 while (node)
558 {
559 wxMenu *menu = (wxMenu*)node->Data();
560 SetInvokingWindow( menu, this );
561 node = node->Next();
562 }
563
564 if (m_frameMenuBar->m_parent != this)
565 {
566 m_frameMenuBar->m_parent = this;
567 gtk_myfixed_put( GTK_MYFIXED(m_wxwindow),
568 m_frameMenuBar->m_widget, m_frameMenuBar->m_x, m_frameMenuBar->m_y );
569
570 /* an mdi child menu bar might be underneath */
571 if (m_mdiMenuBar)
572 m_frameMenuBar->Show( FALSE );
573 }
574 }
575
576 m_sizeSet = FALSE;
577 }
578
579 wxMenuBar *wxFrame::GetMenuBar() const
580 {
581 return m_frameMenuBar;
582 }
583
584 void wxFrame::OnMenuHighlight(wxMenuEvent& event)
585 {
586 if (GetStatusBar())
587 {
588 // if no help string found, we will clear the status bar text
589 wxString helpString;
590
591 int menuId = event.GetMenuId();
592 if ( menuId != -1 )
593 {
594 wxMenuBar *menuBar = GetMenuBar();
595 if (menuBar)
596 {
597 helpString = menuBar->GetHelpString(menuId);
598 }
599 }
600
601 SetStatusText(helpString);
602 }
603 }
604
605 wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
606 {
607 wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
608
609 wxCHECK_MSG( m_frameToolBar == NULL, FALSE, "recreating toolbar in wxFrame" );
610
611 m_frameToolBar = OnCreateToolBar( style, id, name );
612
613 GetChildren().DeleteObject( m_frameToolBar );
614
615 m_sizeSet = FALSE;
616
617 return m_frameToolBar;
618 }
619
620 wxToolBar* wxFrame::OnCreateToolBar( long style, wxWindowID id, const wxString& name )
621 {
622 return new wxToolBar( this, id, wxDefaultPosition, wxDefaultSize, style, name );
623 }
624
625 wxToolBar *wxFrame::GetToolBar() const
626 {
627 return m_frameToolBar;
628 }
629
630 wxStatusBar* wxFrame::CreateStatusBar( int number, long style, wxWindowID id, const wxString& name )
631 {
632 wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
633
634 wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, "recreating status bar in wxFrame" );
635
636 m_frameStatusBar = OnCreateStatusBar( number, style, id, name );
637
638 m_sizeSet = FALSE;
639
640 return m_frameStatusBar;
641 }
642
643 wxStatusBar *wxFrame::OnCreateStatusBar( int number, long style, wxWindowID id, const wxString& name )
644 {
645 wxStatusBar *statusBar = (wxStatusBar *) NULL;
646
647 statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 20), style, name);
648
649 // Set the height according to the font and the border size
650 wxClientDC dc(statusBar);
651 dc.SetFont( statusBar->GetFont() );
652
653 long x, y;
654 dc.GetTextExtent( "X", &x, &y );
655
656 int height = (int)( (y * 1.1) + 2* statusBar->GetBorderY());
657
658 statusBar->SetSize( -1, -1, 100, height );
659
660 statusBar->SetFieldsCount( number );
661 return statusBar;
662 }
663
664 void wxFrame::Command( int id )
665 {
666 wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, id);
667 commandEvent.SetInt( id );
668 commandEvent.SetEventObject( this );
669
670 wxMenuBar *bar = GetMenuBar();
671 if (!bar) return;
672
673 wxMenuItem *item = bar->FindItemForId(id) ;
674 if (item && item->IsCheckable())
675 {
676 bar->Check(id,!bar->Checked(id)) ;
677 }
678
679 wxEvtHandler* evtHandler = GetEventHandler();
680
681 evtHandler->ProcessEvent(commandEvent);
682 }
683
684 void wxFrame::SetStatusText(const wxString& text, int number)
685 {
686 wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
687
688 wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set text for" );
689
690 m_frameStatusBar->SetStatusText(text, number);
691 }
692
693 void wxFrame::SetStatusWidths(int n, const int widths_field[] )
694 {
695 wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
696
697 wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set widths for" );
698
699 m_frameStatusBar->SetStatusWidths(n, widths_field);
700 }
701
702 wxStatusBar *wxFrame::GetStatusBar() const
703 {
704 return m_frameStatusBar;
705 }
706
707 void wxFrame::SetTitle( const wxString &title )
708 {
709 wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
710
711 m_title = title;
712 if (m_title.IsNull()) m_title = "";
713 gtk_window_set_title( GTK_WINDOW(m_widget), title );
714 }
715
716 void wxFrame::SetIcon( const wxIcon &icon )
717 {
718 wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
719
720 m_icon = icon;
721 if (!icon.Ok()) return;
722
723 wxMask *mask = icon.GetMask();
724 GdkBitmap *bm = (GdkBitmap *) NULL;
725 if (mask) bm = mask->GetBitmap();
726
727 gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm );
728 }
729