1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // ============================================================================
12 // ============================================================================
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
19 #pragma implementation "frame.h"
23 #include "wx/dialog.h"
24 #include "wx/control.h"
28 #include "wx/toolbar.h"
31 #include "wx/statusbr.h"
33 #include "wx/dcclient.h"
38 #include "wx/gtk/win_gtk.h"
39 #include "gdk/gdkkeysyms.h"
42 // ----------------------------------------------------------------------------
44 // ----------------------------------------------------------------------------
46 const int wxMENU_HEIGHT
= 27;
47 const int wxSTATUS_HEIGHT
= 25;
48 const int wxPLACE_HOLDER
= 0;
50 // ----------------------------------------------------------------------------
52 // ----------------------------------------------------------------------------
54 extern void wxapp_install_idle_handler();
56 extern int g_openDialogs
;
58 // ----------------------------------------------------------------------------
60 // ----------------------------------------------------------------------------
62 IMPLEMENT_DYNAMIC_CLASS(wxFrame
,wxWindow
)
64 // ----------------------------------------------------------------------------
66 // ----------------------------------------------------------------------------
68 extern wxList wxPendingDelete
;
70 // ----------------------------------------------------------------------------
72 // ----------------------------------------------------------------------------
76 extern void debug_focus_in( GtkWidget
* widget
, const wxChar
* name
, const wxChar
*window
);
80 // ============================================================================
82 // ============================================================================
84 // ----------------------------------------------------------------------------
86 // ----------------------------------------------------------------------------
88 //-----------------------------------------------------------------------------
89 // "focus" from m_window
90 //-----------------------------------------------------------------------------
92 static gint
gtk_frame_focus_callback( GtkWidget
*widget
, GtkDirectionType
WXUNUSED(d
), wxWindow
*WXUNUSED(win
) )
95 wxapp_install_idle_handler();
97 // This disables GTK's tab traversal
98 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "focus" );
102 //-----------------------------------------------------------------------------
104 //-----------------------------------------------------------------------------
106 static void gtk_frame_size_callback( GtkWidget
*WXUNUSED(widget
), GtkAllocation
* alloc
, wxFrame
*win
)
109 wxapp_install_idle_handler();
114 if ((win
->m_width
!= alloc
->width
) || (win
->m_height
!= alloc
->height
))
117 wxPrintf( "OnSize from " );
118 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
119 wxPrintf( win->GetClassInfo()->GetClassName() );
120 wxPrintf( " %d %d %d %d\n", (int)alloc->x,
123 (int)alloc->height );
126 win
->m_width
= alloc
->width
;
127 win
->m_height
= alloc
->height
;
132 //-----------------------------------------------------------------------------
134 //-----------------------------------------------------------------------------
136 static gint
gtk_frame_delete_callback( GtkWidget
*WXUNUSED(widget
), GdkEvent
*WXUNUSED(event
), wxFrame
*win
)
139 wxapp_install_idle_handler();
141 if (g_openDialogs
== 0)
147 //-----------------------------------------------------------------------------
148 // "child_attached" of menu bar
149 //-----------------------------------------------------------------------------
151 static void gtk_menu_attached_callback( GtkWidget
*WXUNUSED(widget
), GtkWidget
*WXUNUSED(child
), wxFrame
*win
)
153 if (!win
->m_hasVMT
) return;
155 win
->m_menuBarDetached
= FALSE
;
159 //-----------------------------------------------------------------------------
160 // "child_detached" of menu bar
161 //-----------------------------------------------------------------------------
163 static void gtk_menu_detached_callback( GtkWidget
*WXUNUSED(widget
), GtkWidget
*WXUNUSED(child
), wxFrame
*win
)
165 if (!win
->m_hasVMT
) return;
167 win
->m_menuBarDetached
= TRUE
;
172 //-----------------------------------------------------------------------------
173 // "child_attached" of tool bar
174 //-----------------------------------------------------------------------------
176 static void gtk_toolbar_attached_callback( GtkWidget
*WXUNUSED(widget
), GtkWidget
*WXUNUSED(child
), wxFrame
*win
)
178 if (!win
->m_hasVMT
) return;
180 win
->m_toolBarDetached
= FALSE
;
185 //-----------------------------------------------------------------------------
186 // "child_detached" of tool bar
187 //-----------------------------------------------------------------------------
189 static void gtk_toolbar_detached_callback( GtkWidget
*WXUNUSED(widget
), GtkWidget
*WXUNUSED(child
), wxFrame
*win
)
192 wxapp_install_idle_handler();
194 if (!win
->m_hasVMT
) return;
196 win
->m_toolBarDetached
= TRUE
;
199 #endif // wxUSE_TOOLBAR
201 //-----------------------------------------------------------------------------
203 //-----------------------------------------------------------------------------
206 #if (GTK_MINOR_VERSION > 0)
207 gtk_frame_configure_callback( GtkWidget
*WXUNUSED(widget
), GdkEventConfigure
*WXUNUSED(event
), wxFrame
*win
)
209 gtk_frame_configure_callback( GtkWidget
*WXUNUSED(widget
), GdkEventConfigure
*event
, wxFrame
*win
)
213 wxapp_install_idle_handler();
218 #if (GTK_MINOR_VERSION > 0)
221 gdk_window_get_root_origin( win
->m_widget
->window
, &x
, &y
);
229 wxMoveEvent
mevent( wxPoint(win
->m_x
,win
->m_y
), win
->GetId() );
230 mevent
.SetEventObject( win
);
231 win
->GetEventHandler()->ProcessEvent( mevent
);
236 //-----------------------------------------------------------------------------
237 // "realize" from m_widget
238 //-----------------------------------------------------------------------------
240 /* we cannot MWM hints and icons before the widget has been realized,
241 so we do this directly after realization */
244 gtk_frame_realized_callback( GtkWidget
*widget
, wxFrame
*win
)
247 wxapp_install_idle_handler();
249 /* I haven't been able to set the position of
250 the dialog before it is shown, so I set the
251 position in "realize" */
252 gtk_widget_set_uposition( widget
, win
->m_x
, win
->m_y
);
254 /* all this is for Motif Window Manager "hints" and is supposed to be
255 recognized by other WM as well. not tested. */
256 long decor
= (long) GDK_DECOR_BORDER
;
257 long func
= (long) GDK_FUNC_MOVE
;
259 if ((win
->GetWindowStyle() & wxCAPTION
) != 0)
260 decor
|= GDK_DECOR_TITLE
;
261 if ((win
->GetWindowStyle() & wxSYSTEM_MENU
) != 0)
263 decor
|= GDK_DECOR_MENU
;
264 func
|= GDK_FUNC_CLOSE
;
266 if ((win
->GetWindowStyle() & wxMINIMIZE_BOX
) != 0)
268 func
|= GDK_FUNC_MINIMIZE
;
269 decor
|= GDK_DECOR_MINIMIZE
;
271 if ((win
->GetWindowStyle() & wxMAXIMIZE_BOX
) != 0)
273 func
|= GDK_FUNC_MAXIMIZE
;
274 decor
|= GDK_DECOR_MAXIMIZE
;
276 if ((win
->GetWindowStyle() & wxRESIZE_BORDER
) != 0)
278 func
|= GDK_FUNC_RESIZE
;
279 decor
|= GDK_DECOR_RESIZEH
;
282 gdk_window_set_decorations( win
->m_widget
->window
, (GdkWMDecoration
)decor
);
283 gdk_window_set_functions( win
->m_widget
->window
, (GdkWMFunction
)func
);
285 /* GTK's shrinking/growing policy */
286 if ((win
->GetWindowStyle() & wxRESIZE_BORDER
) == 0)
287 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 0, 0, 1);
289 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 1, 1, 1);
292 gint flag
= 0; // GDK_HINT_POS;
293 if ((win
->GetMinWidth() != -1) || (win
->GetMinHeight() != -1)) flag
|= GDK_HINT_MIN_SIZE
;
294 if ((win
->GetMaxWidth() != -1) || (win
->GetMaxHeight() != -1)) flag
|= GDK_HINT_MAX_SIZE
;
297 gdk_window_set_hints( win
->m_widget
->window
,
299 win
->GetMinWidth(), win
->GetMinHeight(),
300 win
->GetMaxWidth(), win
->GetMaxHeight(),
305 wxIcon iconOld
= win
->GetIcon();
306 if ( iconOld
!= wxNullIcon
)
308 wxIcon
icon( iconOld
);
309 win
->SetIcon( wxNullIcon
);
310 win
->SetIcon( icon
);
313 /* we set the focus to the child that accepts the focus. this
314 doesn't really have to be done in "realize" but why not? */
315 wxWindowList::Node
*node
= win
->GetChildren().GetFirst();
318 wxWindow
*child
= node
->GetData();
319 if (child
->AcceptsFocus())
325 node
= node
->GetNext();
331 // ----------------------------------------------------------------------------
333 // ----------------------------------------------------------------------------
335 //-----------------------------------------------------------------------------
336 // InsertChild for wxFrame
337 //-----------------------------------------------------------------------------
339 /* Callback for wxFrame. This very strange beast has to be used because
340 * C++ has no virtual methods in a constructor. We have to emulate a
341 * virtual function here as wxWindows requires different ways to insert
342 * a child in container classes. */
344 static void wxInsertChildInFrame( wxFrame
* parent
, wxWindow
* child
)
346 wxASSERT( GTK_IS_WIDGET(child
->m_widget
) );
348 if (!parent
->m_insertInClientArea
)
350 /* these are outside the client area */
351 wxFrame
* frame
= (wxFrame
*) parent
;
352 gtk_pizza_put( GTK_PIZZA(frame
->m_mainWidget
),
353 GTK_WIDGET(child
->m_widget
),
360 /* we connect to these events for recalculating the client area
361 space when the toolbar is floating */
362 if (wxIS_KIND_OF(child
,wxToolBar
))
364 wxToolBar
*toolBar
= (wxToolBar
*) child
;
365 if (toolBar
->GetWindowStyle() & wxTB_DOCKABLE
)
367 gtk_signal_connect( GTK_OBJECT(toolBar
->m_widget
), "child_attached",
368 GTK_SIGNAL_FUNC(gtk_toolbar_attached_callback
), (gpointer
)parent
);
370 gtk_signal_connect( GTK_OBJECT(toolBar
->m_widget
), "child_detached",
371 GTK_SIGNAL_FUNC(gtk_toolbar_detached_callback
), (gpointer
)parent
);
374 #endif // wxUSE_TOOLBAR
378 /* these are inside the client area */
379 gtk_pizza_put( GTK_PIZZA(parent
->m_wxwindow
),
380 GTK_WIDGET(child
->m_widget
),
387 /* resize on OnInternalIdle */
388 parent
->UpdateSize();
391 // ----------------------------------------------------------------------------
393 // ----------------------------------------------------------------------------
400 m_mainWidget
= (GtkWidget
*) NULL
;
401 m_menuBarDetached
= FALSE
;
402 m_toolBarDetached
= FALSE
;
403 m_insertInClientArea
= TRUE
;
407 bool wxFrame::Create( wxWindow
*parent
,
409 const wxString
&title
,
413 const wxString
&name
)
415 wxTopLevelWindows
.Append( this );
417 m_needParent
= FALSE
;
419 if (!PreCreation( parent
, pos
, size
) ||
420 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
422 wxFAIL_MSG( wxT("wxFrame creation failed") );
428 m_insertCallback
= (wxInsertChildFunction
) wxInsertChildInFrame
;
430 GtkWindowType win_type
= GTK_WINDOW_TOPLEVEL
;
431 if (style
& wxSIMPLE_BORDER
) win_type
= GTK_WINDOW_POPUP
;
433 m_widget
= gtk_window_new( win_type
);
436 gtk_window_set_wmclass( GTK_WINDOW(m_widget
), name
.mb_str(), name
.mb_str() );
439 debug_focus_in( m_widget
, wxT("wxFrame::m_widget"), name
);
442 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
443 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
445 gtk_signal_connect( GTK_OBJECT(m_widget
), "delete_event",
446 GTK_SIGNAL_FUNC(gtk_frame_delete_callback
), (gpointer
)this );
448 /* m_mainWidget holds the toolbar, the menubar and the client area */
449 m_mainWidget
= gtk_pizza_new();
450 gtk_widget_show( m_mainWidget
);
451 GTK_WIDGET_UNSET_FLAGS( m_mainWidget
, GTK_CAN_FOCUS
);
452 gtk_container_add( GTK_CONTAINER(m_widget
), m_mainWidget
);
455 debug_focus_in( m_mainWidget
, wxT("wxFrame::m_mainWidget"), name
);
458 /* m_wxwindow only represents the client area without toolbar and menubar */
459 m_wxwindow
= gtk_pizza_new();
460 gtk_widget_show( m_wxwindow
);
461 gtk_container_add( GTK_CONTAINER(m_mainWidget
), m_wxwindow
);
464 debug_focus_in( m_wxwindow
, wxT("wxFrame::m_wxwindow"), name
);
467 /* we donm't allow the frame to get the focus as otherwise
468 the frame will grabit at arbitrary fcous changes. */
469 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
471 if (m_parent
) m_parent
->AddChild( this );
473 /* the user resized the frame by dragging etc. */
474 gtk_signal_connect( GTK_OBJECT(m_widget
), "size_allocate",
475 GTK_SIGNAL_FUNC(gtk_frame_size_callback
), (gpointer
)this );
479 /* we cannot set MWM hints and icons before the widget has
480 been realized, so we do this directly after realization */
481 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
482 GTK_SIGNAL_FUNC(gtk_frame_realized_callback
), (gpointer
) this );
484 /* the only way to get the window size is to connect to this event */
485 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
486 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
488 /* disable native tab traversal */
489 gtk_signal_connect( GTK_OBJECT(m_widget
), "focus",
490 GTK_SIGNAL_FUNC(gtk_frame_focus_callback
), (gpointer
)this );
497 m_isBeingDeleted
= TRUE
;
501 wxTopLevelWindows
.DeleteObject( this );
503 if (wxTheApp
->GetTopWindow() == this)
504 wxTheApp
->SetTopWindow( (wxWindow
*) NULL
);
506 if (wxTopLevelWindows
.Number() == 0)
507 wxTheApp
->ExitMainLoop();
510 // ----------------------------------------------------------------------------
511 // overridden wxWindow methods
512 // ----------------------------------------------------------------------------
514 bool wxFrame::Show( bool show
)
516 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
518 if (show
&& !m_sizeSet
)
520 /* by calling GtkOnSize here, we don't have to call
521 either after showing the frame, which would entail
522 much ugly flicker or from within the size_allocate
523 handler, because GTK 1.1.X forbids that. */
525 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
528 return wxWindow::Show( show
);
531 void wxFrame::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
533 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
535 /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
536 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
538 /* avoid recursions */
546 int old_width
= m_width
;
547 int old_height
= m_height
;
549 if ((sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) == 0)
551 if (x
!= -1) m_x
= x
;
552 if (y
!= -1) m_y
= y
;
553 if (width
!= -1) m_width
= width
;
554 if (height
!= -1) m_height
= height
;
565 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
567 if (width == -1) m_width = 80;
570 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
572 if (height == -1) m_height = 26;
576 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
577 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
578 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
579 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
581 if ((m_x
!= -1) || (m_y
!= -1))
583 if ((m_x
!= old_x
) || (m_y
!= old_y
))
585 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
589 if ((m_width
!= old_width
) || (m_height
!= old_height
))
591 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
592 done either directly before the frame is shown or in idle time
593 so that different calls to SetSize() don't lead to flicker. */
600 void wxFrame::DoGetClientSize( int *width
, int *height
) const
602 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
604 wxWindow::DoGetClientSize( width
, height
);
610 if (!m_menuBarDetached
)
611 (*height
) -= wxMENU_HEIGHT
;
613 (*height
) -= wxPLACE_HOLDER
;
618 if (m_frameStatusBar
) (*height
) -= wxSTATUS_HEIGHT
;
625 if (!m_toolBarDetached
)
628 m_frameToolBar
->GetSize( (int *) NULL
, &y
);
632 (*height
) -= wxPLACE_HOLDER
;
637 (*height
) -= m_miniEdge
*2 + m_miniTitle
;
641 (*width
) -= m_miniEdge
*2;
645 void wxFrame::DoSetClientSize( int width
, int height
)
647 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
652 if (!m_menuBarDetached
)
653 height
+= wxMENU_HEIGHT
;
655 height
+= wxPLACE_HOLDER
;
660 if (m_frameStatusBar
) height
+= wxSTATUS_HEIGHT
;
667 if (!m_toolBarDetached
)
670 m_frameToolBar
->GetSize( (int *) NULL
, &y
);
674 height
+= wxPLACE_HOLDER
;
678 DoSetSize( -1, -1, width
+ m_miniEdge
*2, height
+ m_miniEdge
*2 + m_miniTitle
, 0 );
681 void wxFrame::GtkOnSize( int WXUNUSED(x
), int WXUNUSED(y
),
682 int width
, int height
)
684 // due to a bug in gtk, x,y are always 0
688 /* avoid recursions */
689 if (m_resizing
) return;
692 /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
693 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
698 /* space occupied by m_frameToolBar and m_frameMenuBar */
699 int client_area_y_offset
= 0;
701 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
702 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
703 set in wxFrame::Create so it is used to check what kind of frame we
704 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
705 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
706 importantly) m_mainWidget */
710 /* check if size is in legal range */
711 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
712 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
713 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
714 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
716 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
717 * menubar, the toolbar and the client area, which is represented by
719 * this hurts in the eye, but I don't want to call SetSize()
720 * because I don't want to call any non-native functions here. */
725 int yy
= m_miniEdge
+ m_miniTitle
;
726 int ww
= m_width
- 2*m_miniEdge
;
727 int hh
= wxMENU_HEIGHT
;
728 if (m_menuBarDetached
) hh
= wxPLACE_HOLDER
;
729 m_frameMenuBar
->m_x
= xx
;
730 m_frameMenuBar
->m_y
= yy
;
731 m_frameMenuBar
->m_width
= ww
;
732 m_frameMenuBar
->m_height
= hh
;
733 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
734 m_frameMenuBar
->m_widget
,
736 client_area_y_offset
+= hh
;
740 if ((m_frameToolBar
) &&
741 (m_frameToolBar
->m_widget
->parent
== m_mainWidget
))
744 int yy
= m_miniEdge
+ m_miniTitle
;
747 if (!m_menuBarDetached
)
750 yy
+= wxPLACE_HOLDER
;
752 int ww
= m_width
- 2*m_miniEdge
;
753 int hh
= m_frameToolBar
->m_height
;
754 if (m_toolBarDetached
) hh
= wxPLACE_HOLDER
;
755 m_frameToolBar
->m_x
= xx
;
756 m_frameToolBar
->m_y
= yy
;
757 /* m_frameToolBar->m_height = hh; don't change the toolbar's reported size
758 m_frameToolBar->m_width = ww; */
759 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
760 m_frameToolBar
->m_widget
,
762 client_area_y_offset
+= hh
;
766 int client_x
= m_miniEdge
;
767 int client_y
= client_area_y_offset
+ m_miniEdge
+ m_miniTitle
;
768 int client_w
= m_width
- 2*m_miniEdge
;
769 int client_h
= m_height
- client_area_y_offset
- 2*m_miniEdge
- m_miniTitle
;
770 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
772 client_x
, client_y
, client_w
, client_h
);
776 /* if there is no m_mainWidget between m_widget and m_wxwindow there
777 is no need to set the size or position of m_wxwindow. */
781 if (m_frameStatusBar
)
783 int xx
= 0 + m_miniEdge
;
784 int yy
= m_height
- wxSTATUS_HEIGHT
- m_miniEdge
- client_area_y_offset
;
785 int ww
= m_width
- 2*m_miniEdge
;
786 int hh
= wxSTATUS_HEIGHT
;
787 m_frameStatusBar
->m_x
= xx
;
788 m_frameStatusBar
->m_y
= yy
;
789 m_frameStatusBar
->m_width
= ww
;
790 m_frameStatusBar
->m_height
= hh
;
791 gtk_pizza_set_size( GTK_PIZZA(m_wxwindow
),
792 m_frameStatusBar
->m_widget
,
797 /* we actually set the size of a frame here and no-where else */
798 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
802 // send size event to frame
803 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
804 event
.SetEventObject( this );
805 GetEventHandler()->ProcessEvent( event
);
807 // send size event to status bar
808 if (m_frameStatusBar
)
810 wxSizeEvent
event2( wxSize(m_frameStatusBar
->m_width
,m_frameStatusBar
->m_height
), m_frameStatusBar
->GetId() );
811 event2
.SetEventObject( m_frameStatusBar
);
812 m_frameStatusBar
->GetEventHandler()->ProcessEvent( event2
);
818 void wxFrame::MakeModal( bool modal
)
821 gtk_grab_add( m_widget
);
823 gtk_grab_remove( m_widget
);
826 void wxFrame::OnInternalIdle()
828 if (!m_sizeSet
&& GTK_WIDGET_REALIZED(m_wxwindow
))
830 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
832 // we'll come back later
834 wxapp_install_idle_handler();
838 if (m_frameMenuBar
) m_frameMenuBar
->OnInternalIdle();
840 if (m_frameToolBar
) m_frameToolBar
->OnInternalIdle();
843 if (m_frameStatusBar
) m_frameStatusBar
->OnInternalIdle();
846 wxWindow::OnInternalIdle();
849 // ----------------------------------------------------------------------------
850 // menu/tool/status bar stuff
851 // ----------------------------------------------------------------------------
853 void wxFrame::SetMenuBar( wxMenuBar
*menuBar
)
855 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
856 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
858 m_frameMenuBar
= menuBar
;
862 m_frameMenuBar
->SetInvokingWindow( this );
864 if (m_frameMenuBar
->GetParent() != this)
866 m_frameMenuBar
->SetParent(this);
867 gtk_pizza_put( GTK_PIZZA(m_mainWidget
),
868 m_frameMenuBar
->m_widget
,
871 m_frameMenuBar
->m_width
,
872 m_frameMenuBar
->m_height
);
874 if (menuBar
->GetWindowStyle() & wxMB_DOCKABLE
)
876 gtk_signal_connect( GTK_OBJECT(menuBar
->m_widget
), "child_attached",
877 GTK_SIGNAL_FUNC(gtk_menu_attached_callback
), (gpointer
)this );
879 gtk_signal_connect( GTK_OBJECT(menuBar
->m_widget
), "child_detached",
880 GTK_SIGNAL_FUNC(gtk_menu_detached_callback
), (gpointer
)this );
883 m_frameMenuBar
->Show( TRUE
);
887 /* resize window in OnInternalIdle */
892 wxToolBar
* wxFrame::CreateToolBar( long style
, wxWindowID id
, const wxString
& name
)
894 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
896 m_insertInClientArea
= FALSE
;
898 m_frameToolBar
= wxFrameBase::CreateToolBar( style
, id
, name
);
901 GetChildren().DeleteObject( m_frameToolBar
);
903 m_insertInClientArea
= TRUE
;
907 return m_frameToolBar
;
910 void wxFrame::SetToolBar(wxToolBar
*toolbar
)
912 wxFrameBase::SetToolBar(toolbar
);
916 /* insert into toolbar area if not already there */
917 if ((m_frameToolBar
->m_widget
->parent
) &&
918 (m_frameToolBar
->m_widget
->parent
!= m_mainWidget
))
920 GetChildren().DeleteObject( m_frameToolBar
);
922 gtk_widget_reparent( m_frameToolBar
->m_widget
, m_mainWidget
);
928 #endif // wxUSE_TOOLBAR
932 wxStatusBar
* wxFrame::CreateStatusBar(int number
,
935 const wxString
& name
)
937 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
939 // because it will change when toolbar is added
942 return wxFrameBase::CreateStatusBar( number
, style
, id
, name
);
945 #endif // wxUSE_STATUSBAR
947 // ----------------------------------------------------------------------------
949 // ----------------------------------------------------------------------------
951 void wxFrame::SetTitle( const wxString
&title
)
953 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
956 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
959 void wxFrame::SetIcon( const wxIcon
&icon
)
961 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
963 wxFrameBase::SetIcon(icon
);
968 if (!m_widget
->window
)
971 wxMask
*mask
= icon
.GetMask();
972 GdkBitmap
*bm
= (GdkBitmap
*) NULL
;
973 if (mask
) bm
= mask
->GetBitmap();
975 gdk_window_set_icon( m_widget
->window
, (GdkWindow
*) NULL
, icon
.GetPixmap(), bm
);
978 // ----------------------------------------------------------------------------
979 // frame state: maximized/iconized/normal (TODO)
980 // ----------------------------------------------------------------------------
982 void wxFrame::Maximize(bool WXUNUSED(maximize
))
986 bool wxFrame::IsMaximized() const
991 void wxFrame::Restore()
995 void wxFrame::Iconize( bool iconize
)
999 XIconifyWindow( GDK_WINDOW_XDISPLAY( m_widget
->window
),
1000 GDK_WINDOW_XWINDOW( m_widget
->window
),
1001 DefaultScreen( GDK_DISPLAY() ) );
1005 bool wxFrame::IsIconized() const