1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "frame.h"
15 #include "wx/dialog.h"
16 #include "wx/control.h"
19 #include "wx/toolbar.h"
20 #include "wx/statusbr.h"
21 #include "wx/dcclient.h"
26 #include "wx/gtk/win_gtk.h"
28 //-----------------------------------------------------------------------------
30 //-----------------------------------------------------------------------------
32 const int wxMENU_HEIGHT
= 27;
33 const int wxSTATUS_HEIGHT
= 25;
35 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
39 extern wxList wxPendingDelete
;
41 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
45 static void gtk_frame_size_callback( GtkWidget
*WXUNUSED(widget
), GtkAllocation
* alloc
, wxFrame
*win
)
47 if (!win
->HasVMT()) return;
50 printf( "OnFrameResize from " );
51 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
52 printf( win->GetClassInfo()->GetClassName() );
56 if ((win
->m_width
!= alloc
->width
) || (win
->m_height
!= alloc
->height
))
58 win
->m_sizeSet
= FALSE
;
59 win
->m_width
= alloc
->width
;
60 win
->m_height
= alloc
->height
;
64 //-----------------------------------------------------------------------------
66 //-----------------------------------------------------------------------------
68 static gint
gtk_frame_delete_callback( GtkWidget
*WXUNUSED(widget
), GdkEvent
*WXUNUSED(event
), wxFrame
*win
)
71 printf( "OnDelete from " );
72 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
73 printf( win->GetClassInfo()->GetClassName() );
82 //-----------------------------------------------------------------------------
84 //-----------------------------------------------------------------------------
86 static gint
gtk_frame_configure_callback( GtkWidget
*WXUNUSED(widget
), GdkEventConfigure
*event
, wxFrame
*win
)
88 if (!win
->HasVMT()) return FALSE
;
93 wxMoveEvent
mevent( wxPoint(win
->m_x
,win
->m_y
), win
->GetId() );
94 mevent
.SetEventObject( win
);
95 win
->GetEventHandler()->ProcessEvent( mevent
);
100 //-----------------------------------------------------------------------------
101 // InsertChild for wxFrame
102 //-----------------------------------------------------------------------------
104 /* Callback for wxFrame. This very strange beast has to be used because
105 * C++ has no virtual methods in a constructor. We have to emulate a
106 * virtual function here as wxWindows requires different ways to insert
107 * a child in container classes. */
109 static void wxInsertChildInFrame( wxWindow
* parent
, wxWindow
* child
)
111 if (wxIS_KIND_OF(child
,wxToolBar
) || wxIS_KIND_OF(child
,wxMenuBar
))
113 /* these are outside the client area */
114 wxFrame
* frame
= (wxFrame
*) parent
;
115 gtk_myfixed_put( GTK_MYFIXED(frame
->m_mainWidget
),
116 GTK_WIDGET(child
->m_widget
),
122 /* these are inside the client area */
123 gtk_myfixed_put( GTK_MYFIXED(parent
->m_wxwindow
),
124 GTK_WIDGET(child
->m_widget
),
129 gtk_widget_set_usize( GTK_WIDGET(child
->m_widget
),
133 /* resize on OnInternalIdle */
134 parent
->m_sizeSet
= FALSE
;
136 if (parent
->m_windowStyle
& wxTAB_TRAVERSAL
)
138 /* we now allow a window to get the focus as long as it
139 doesn't have any children. */
140 GTK_WIDGET_UNSET_FLAGS( parent
->m_wxwindow
, GTK_CAN_FOCUS
);
144 //-----------------------------------------------------------------------------
146 //-----------------------------------------------------------------------------
148 BEGIN_EVENT_TABLE(wxFrame
, wxWindow
)
149 EVT_SIZE(wxFrame::OnSize
)
150 EVT_CLOSE(wxFrame::OnCloseWindow
)
151 EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight
)
154 IMPLEMENT_DYNAMIC_CLASS(wxFrame
,wxWindow
)
158 m_frameMenuBar
= (wxMenuBar
*) NULL
;
159 m_mdiMenuBar
= (wxMenuBar
*) NULL
;
160 m_frameStatusBar
= (wxStatusBar
*) NULL
;
161 m_frameToolBar
= (wxToolBar
*) NULL
;
165 m_mainWidget
= (GtkWidget
*) NULL
;
168 wxFrame::wxFrame( wxWindow
*parent
, wxWindowID id
, const wxString
&title
,
169 const wxPoint
&pos
, const wxSize
&size
,
170 long style
, const wxString
&name
)
172 m_frameMenuBar
= (wxMenuBar
*) NULL
;
173 m_mdiMenuBar
= (wxMenuBar
*) NULL
;
174 m_frameStatusBar
= (wxStatusBar
*) NULL
;
175 m_frameToolBar
= (wxToolBar
*) NULL
;
179 m_mainWidget
= (GtkWidget
*) NULL
;
180 Create( parent
, id
, title
, pos
, size
, style
, name
);
183 bool wxFrame::Create( wxWindow
*parent
, wxWindowID id
, const wxString
&title
,
184 const wxPoint
&pos
, const wxSize
&size
,
185 long style
, const wxString
&name
)
187 wxTopLevelWindows
.Append( this );
189 m_needParent
= FALSE
;
191 PreCreation( parent
, id
, pos
, size
, style
, name
);
195 m_insertCallback
= wxInsertChildInFrame
;
197 GtkWindowType win_type
= GTK_WINDOW_TOPLEVEL
;
198 if (style
& wxSIMPLE_BORDER
) win_type
= GTK_WINDOW_POPUP
;
200 m_widget
= gtk_window_new( win_type
);
202 gtk_window_set_title( GTK_WINDOW(m_widget
), title
);
203 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
206 gtk_window_set_policy( GTK_WINDOW(m_widget
), 1, 1, 0 );
208 gtk_signal_connect( GTK_OBJECT(m_widget
), "delete_event",
209 GTK_SIGNAL_FUNC(gtk_frame_delete_callback
), (gpointer
)this );
211 /* m_mainWidget holds the toolbar, the menubar and the client area */
212 m_mainWidget
= gtk_myfixed_new();
213 gtk_widget_show( m_mainWidget
);
214 GTK_WIDGET_UNSET_FLAGS( m_mainWidget
, GTK_CAN_FOCUS
);
215 gtk_container_add( GTK_CONTAINER(m_widget
), m_mainWidget
);
216 gtk_widget_realize( m_mainWidget
);
218 /* m_wxwindow only represents the client area without toolbar and menubar */
219 m_wxwindow
= gtk_myfixed_new();
220 gtk_widget_show( m_wxwindow
);
221 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
222 gtk_container_add( GTK_CONTAINER(m_mainWidget
), m_wxwindow
);
224 if (m_parent
) m_parent
->AddChild( this );
228 gtk_widget_realize( m_widget
);
230 /* all this is for Motif Window Manager "hints" and is supposed to be
231 recognized by other WM as well. not tested. */
232 long decor
= (long) GDK_DECOR_ALL
;
233 long func
= (long) GDK_FUNC_ALL
;
234 if ((m_windowStyle
& wxCAPTION
) == 0)
235 decor
|= GDK_DECOR_TITLE
;
237 if ((m_windowStyle & wxMINIMIZE) == 0)
238 func |= GDK_FUNC_MINIMIZE;
239 if ((m_windowStyle & wxMAXIMIZE) == 0)
240 func |= GDK_FUNC_MAXIMIZE;
242 if ((m_windowStyle
& wxSYSTEM_MENU
) == 0)
243 decor
|= GDK_DECOR_MENU
;
244 if ((m_windowStyle
& wxMINIMIZE_BOX
) == 0)
245 decor
|= GDK_DECOR_MINIMIZE
;
246 if ((m_windowStyle
& wxMAXIMIZE_BOX
) == 0)
247 decor
|= GDK_DECOR_MAXIMIZE
;
248 if ((m_windowStyle
& wxRESIZE_BORDER
) == 0)
249 func
|= GDK_FUNC_RESIZE
;
250 gdk_window_set_decorations(m_widget
->window
, (GdkWMDecoration
)decor
);
251 gdk_window_set_functions(m_widget
->window
, (GdkWMFunction
)func
);
253 /* the user resized the frame by dragging etc. */
254 gtk_signal_connect( GTK_OBJECT(m_widget
), "size_allocate",
255 GTK_SIGNAL_FUNC(gtk_frame_size_callback
), (gpointer
)this );
257 /* the only way to get the window size is to connect to this event */
258 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
259 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
266 if (m_frameMenuBar
) delete m_frameMenuBar
;
267 m_frameMenuBar
= (wxMenuBar
*) NULL
;
269 if (m_frameStatusBar
) delete m_frameStatusBar
;
270 m_frameStatusBar
= (wxStatusBar
*) NULL
;
272 if (m_frameToolBar
) delete m_frameToolBar
;
273 m_frameToolBar
= (wxToolBar
*) NULL
;
275 wxTopLevelWindows
.DeleteObject( this );
277 if (wxTheApp
->GetTopWindow() == this)
279 wxTheApp
->SetTopWindow( (wxWindow
*) NULL
);
282 if (wxTopLevelWindows
.Number() == 0)
284 wxTheApp
->ExitMainLoop();
288 bool wxFrame::Show( bool show
)
290 wxASSERT_MSG( (m_widget
!= NULL
), "invalid frame" );
292 if (show
&& !m_sizeSet
)
294 /* by calling GtkOnSize here, we don't have to call
295 either after showing the frame, which would entail
296 much ugly flicker or from within the size_allocate
297 handler, because GTK 1.1.X forbids that. */
299 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
302 return wxWindow::Show( show
);
305 bool wxFrame::Destroy()
307 wxASSERT_MSG( (m_widget
!= NULL
), "invalid frame" );
309 if (!wxPendingDelete
.Member(this)) wxPendingDelete
.Append(this);
314 void wxFrame::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
316 wxASSERT_MSG( (m_widget
!= NULL
), "invalid frame" );
318 /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
319 wxASSERT_MSG( (m_wxwindow
!= NULL
), "invalid frame" );
321 /* avoid recursions */
322 if (m_resizing
) return;
327 int old_width
= m_width
;
328 int old_height
= m_height
;
330 if ((sizeFlags
& wxSIZE_USE_EXISTING
) == wxSIZE_USE_EXISTING
)
332 if (x
!= -1) m_x
= x
;
333 if (y
!= -1) m_y
= y
;
334 if (width
!= -1) m_width
= width
;
335 if (height
!= -1) m_height
= height
;
345 if ((sizeFlags
& wxSIZE_AUTO_WIDTH
) == wxSIZE_AUTO_WIDTH
)
347 if (width
== -1) m_width
= 80;
350 if ((sizeFlags
& wxSIZE_AUTO_HEIGHT
) == wxSIZE_AUTO_HEIGHT
)
352 if (height
== -1) m_height
= 26;
355 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
356 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
357 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
358 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
360 if ((m_x
!= -1) || (m_y
!= -1))
362 if ((m_x
!= old_x
) || (m_y
!= old_y
))
364 /* m_sizeSet = FALSE; */
365 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
369 if ((m_width
!= old_width
) || (m_height
!= old_height
))
371 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
372 done either directly before the frame is shown or in idle time
373 so that different calls to SetSize() don't lead to flicker. */
380 void wxFrame::Centre( int direction
)
382 wxASSERT_MSG( (m_widget
!= NULL
), "invalid frame" );
387 if ((direction
& wxHORIZONTAL
) == wxHORIZONTAL
) x
= (gdk_screen_width () - m_width
) / 2;
388 if ((direction
& wxVERTICAL
) == wxVERTICAL
) y
= (gdk_screen_height () - m_height
) / 2;
393 void wxFrame::GetClientSize( int *width
, int *height
) const
395 wxASSERT_MSG( (m_widget
!= NULL
), "invalid frame" );
397 wxWindow::GetClientSize( width
, height
);
400 if (m_frameMenuBar
) (*height
) -= wxMENU_HEIGHT
;
401 if (m_frameStatusBar
) (*height
) -= wxSTATUS_HEIGHT
;
405 m_frameToolBar
->GetSize( (int *) NULL
, &y
);
408 (*height
) -= m_miniEdge
*2 + m_miniTitle
;
412 (*width
) -= m_miniEdge
*2;
416 void wxFrame::DoSetClientSize( int width
, int height
)
418 wxASSERT_MSG( (m_widget
!= NULL
), "invalid frame" );
421 if (m_frameMenuBar
) h
+= wxMENU_HEIGHT
;
422 if (m_frameStatusBar
) h
+= wxSTATUS_HEIGHT
;
426 m_frameToolBar
->GetSize( (int *) NULL
, &y
);
429 wxWindow::DoSetClientSize( width
+ m_miniEdge
*2, h
+ m_miniEdge
*2 + m_miniTitle
);
432 void wxFrame::GtkOnSize( int WXUNUSED(x
), int WXUNUSED(y
), int width
, int height
)
434 // due to a bug in gtk, x,y are always 0
438 /* avoid recursions */
439 if (m_resizing
) return;
442 /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
443 wxASSERT_MSG( (m_wxwindow
!= NULL
), "invalid frame" );
448 /* space occupied by m_frameToolBar and m_frameMenuBar */
449 int client_area_y_offset
= 0;
451 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
452 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
453 set in wxFrame::Create so it is used to check what kind of frame we
454 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
455 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
456 importantly) m_mainWidget */
460 /* check if size is in legal range */
461 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
462 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
463 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
464 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
466 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
467 * menubar, the toolbar and the client area, which is represented by
469 * this hurts in the eye, but I don't want to call SetSize()
470 * because I don't want to call any non-native functions here. */
475 int yy
= m_miniEdge
+ m_miniTitle
;
476 int ww
= m_width
- 2*m_miniEdge
;
477 int hh
= wxMENU_HEIGHT
;
478 m_frameMenuBar
->m_x
= xx
;
479 m_frameMenuBar
->m_y
= yy
;
480 m_frameMenuBar
->m_width
= ww
;
481 m_frameMenuBar
->m_height
= hh
;
483 gtk_myfixed_move( GTK_MYFIXED(m_mainWidget
), m_frameMenuBar
->m_widget
, xx
, yy
);
484 gtk_widget_set_usize( m_frameMenuBar
->m_widget
, ww
, hh
);
486 client_area_y_offset
+= hh
;
492 int yy
= m_miniEdge
+ m_miniTitle
;
493 if ((m_frameMenuBar
) || (m_mdiMenuBar
)) yy
+= wxMENU_HEIGHT
;
494 int ww
= m_width
- 2*m_miniEdge
;
495 int hh
= m_frameToolBar
->m_height
;
497 m_frameToolBar
->m_x
= xx
;
498 m_frameToolBar
->m_y
= yy
;
499 m_frameToolBar
->m_height
= hh
;
500 m_frameToolBar
->m_width
= ww
;
502 gtk_myfixed_move( GTK_MYFIXED(m_mainWidget
), m_frameToolBar
->m_widget
, xx
, yy
);
503 gtk_widget_set_usize( m_frameToolBar
->m_widget
, ww
, hh
);
505 client_area_y_offset
+= hh
;
508 int client_x
= m_miniEdge
;
509 int client_y
= client_area_y_offset
+ m_miniEdge
+ m_miniTitle
;
510 gtk_myfixed_move( GTK_MYFIXED(m_mainWidget
), m_wxwindow
, client_x
, client_y
);
512 int client_w
= m_width
- 2*m_miniEdge
;
513 int client_h
= m_height
- client_area_y_offset
- 2*m_miniEdge
- m_miniTitle
;
514 gtk_widget_set_usize( m_wxwindow
, client_w
, client_h
);
518 /* if there is no m_mainWidget between m_widget and m_wxwindow there
519 is no need to set the size or position of m_wxwindow. */
522 if (m_frameStatusBar
)
524 int xx
= 0 + m_miniEdge
;
525 int yy
= m_height
- wxSTATUS_HEIGHT
- m_miniEdge
- client_area_y_offset
;
526 int ww
= m_width
- 2*m_miniEdge
;
527 int hh
= wxSTATUS_HEIGHT
;
529 m_frameStatusBar
->m_x
= xx
;
530 m_frameStatusBar
->m_y
= yy
;
531 m_frameStatusBar
->m_width
= ww
;
532 m_frameStatusBar
->m_height
= hh
;
534 gtk_myfixed_move( GTK_MYFIXED(m_wxwindow
), m_frameStatusBar
->m_widget
, xx
, yy
);
535 gtk_widget_set_usize( m_frameStatusBar
->m_widget
, ww
, hh
);
538 /* we actually set the size of a frame here and no-where else */
539 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
543 /* send size event to frame */
544 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
545 event
.SetEventObject( this );
546 GetEventHandler()->ProcessEvent( event
);
548 /* send size event to status bar */
549 if (m_frameStatusBar
)
551 wxSizeEvent
event2( wxSize(m_frameStatusBar
->m_width
,m_frameStatusBar
->m_height
), m_frameStatusBar
->GetId() );
552 event2
.SetEventObject( m_frameStatusBar
);
553 m_frameStatusBar
->GetEventHandler()->ProcessEvent( event2
);
559 void wxFrame::OnInternalIdle()
562 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
567 void wxFrame::OnCloseWindow( wxCloseEvent
& event
)
572 void wxFrame::OnSize( wxSizeEvent
&WXUNUSED(event
) )
574 wxASSERT_MSG( (m_widget
!= NULL
), "invalid frame" );
582 // do we have exactly one child?
583 wxWindow
*child
= (wxWindow
*)NULL
;
584 for ( wxNode
*node
= GetChildren().First(); node
; node
= node
->Next() )
586 wxWindow
*win
= (wxWindow
*)node
->Data();
587 if ( !wxIS_KIND_OF(win
,wxFrame
) && !wxIS_KIND_OF(win
,wxDialog
) )
591 // it's the second one: do nothing
599 // no children at all?
602 // yes: set it's size to fill all the frame
603 int client_x
, client_y
;
604 GetClientSize( &client_x
, &client_y
);
605 child
->SetSize( 1, 1, client_x
-2, client_y
-2 );
610 static void SetInvokingWindow( wxMenu
*menu
, wxWindow
*win
)
612 menu
->SetInvokingWindow( win
);
613 wxNode
*node
= menu
->GetItems().First();
616 wxMenuItem
*menuitem
= (wxMenuItem
*)node
->Data();
617 if (menuitem
->IsSubMenu())
618 SetInvokingWindow( menuitem
->GetSubMenu(), win
);
623 void wxFrame::SetMenuBar( wxMenuBar
*menuBar
)
625 wxASSERT_MSG( (m_widget
!= NULL
), "invalid frame" );
626 wxASSERT_MSG( (m_wxwindow
!= NULL
), "invalid frame" );
628 m_frameMenuBar
= menuBar
;
632 wxNode
*node
= m_frameMenuBar
->GetMenus().First();
635 wxMenu
*menu
= (wxMenu
*)node
->Data();
636 SetInvokingWindow( menu
, this );
640 if (m_frameMenuBar
->m_parent
!= this)
642 m_frameMenuBar
->m_parent
= this;
643 gtk_myfixed_put( GTK_MYFIXED(m_mainWidget
),
644 m_frameMenuBar
->m_widget
, m_frameMenuBar
->m_x
, m_frameMenuBar
->m_y
);
646 /* an mdi child menu bar might be underneath */
648 m_frameMenuBar
->Show( FALSE
);
655 wxMenuBar
*wxFrame::GetMenuBar() const
657 return m_frameMenuBar
;
660 void wxFrame::OnMenuHighlight(wxMenuEvent
& event
)
664 // if no help string found, we will clear the status bar text
667 int menuId
= event
.GetMenuId();
670 wxMenuBar
*menuBar
= GetMenuBar();
673 helpString
= menuBar
->GetHelpString(menuId
);
677 SetStatusText(helpString
);
681 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
683 wxASSERT_MSG( (m_widget
!= NULL
), "invalid frame" );
685 wxCHECK_MSG( m_frameToolBar
== NULL
, FALSE
, "recreating toolbar in wxFrame" );
687 m_frameToolBar
= OnCreateToolBar( style
, id
, name
);
689 GetChildren().DeleteObject( m_frameToolBar
);
693 return m_frameToolBar
;
696 wxToolBar
* wxFrame::OnCreateToolBar( long style
, wxWindowID id
, const wxString
& name
)
698 return new wxToolBar( this, id
, wxDefaultPosition
, wxDefaultSize
, style
, name
);
701 wxToolBar
*wxFrame::GetToolBar() const
703 return m_frameToolBar
;
706 wxStatusBar
* wxFrame::CreateStatusBar( int number
, long style
, wxWindowID id
, const wxString
& name
)
708 wxASSERT_MSG( (m_widget
!= NULL
), "invalid frame" );
710 wxCHECK_MSG( m_frameStatusBar
== NULL
, FALSE
, "recreating status bar in wxFrame" );
712 m_frameStatusBar
= OnCreateStatusBar( number
, style
, id
, name
);
716 return m_frameStatusBar
;
719 wxStatusBar
*wxFrame::OnCreateStatusBar( int number
, long style
, wxWindowID id
, const wxString
& name
)
721 wxStatusBar
*statusBar
= (wxStatusBar
*) NULL
;
723 statusBar
= new wxStatusBar(this, id
, wxPoint(0, 0), wxSize(100, 20), style
, name
);
725 // Set the height according to the font and the border size
726 wxClientDC
dc(statusBar
);
727 dc
.SetFont( statusBar
->GetFont() );
730 dc
.GetTextExtent( "X", &x
, &y
);
732 int height
= (int)( (y
* 1.1) + 2* statusBar
->GetBorderY());
734 statusBar
->SetSize( -1, -1, 100, height
);
736 statusBar
->SetFieldsCount( number
);
740 void wxFrame::Command( int id
)
742 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, id
);
743 commandEvent
.SetInt( id
);
744 commandEvent
.SetEventObject( this );
746 wxMenuBar
*bar
= GetMenuBar();
749 wxMenuItem
*item
= bar
->FindItemForId(id
) ;
750 if (item
&& item
->IsCheckable())
752 bar
->Check(id
,!bar
->Checked(id
)) ;
755 wxEvtHandler
* evtHandler
= GetEventHandler();
757 evtHandler
->ProcessEvent(commandEvent
);
760 void wxFrame::SetStatusText(const wxString
& text
, int number
)
762 wxASSERT_MSG( (m_widget
!= NULL
), "invalid frame" );
764 wxCHECK_RET( m_frameStatusBar
!= NULL
, "no statusbar to set text for" );
766 m_frameStatusBar
->SetStatusText(text
, number
);
769 void wxFrame::SetStatusWidths(int n
, const int widths_field
[] )
771 wxASSERT_MSG( (m_widget
!= NULL
), "invalid frame" );
773 wxCHECK_RET( m_frameStatusBar
!= NULL
, "no statusbar to set widths for" );
775 m_frameStatusBar
->SetStatusWidths(n
, widths_field
);
778 wxStatusBar
*wxFrame::GetStatusBar() const
780 return m_frameStatusBar
;
783 void wxFrame::SetTitle( const wxString
&title
)
785 wxASSERT_MSG( (m_widget
!= NULL
), "invalid frame" );
788 if (m_title
.IsNull()) m_title
= "";
789 gtk_window_set_title( GTK_WINDOW(m_widget
), title
);
792 void wxFrame::SetIcon( const wxIcon
&icon
)
794 wxASSERT_MSG( (m_widget
!= NULL
), "invalid frame" );
797 if (!icon
.Ok()) return;
799 wxMask
*mask
= icon
.GetMask();
800 GdkBitmap
*bm
= (GdkBitmap
*) NULL
;
801 if (mask
) bm
= mask
->GetBitmap();
803 gdk_window_set_icon( m_widget
->window
, (GdkWindow
*) NULL
, icon
.GetPixmap(), bm
);