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 <gdk/gdkkeysyms.h>
41 #include "wx/gtk/win_gtk.h"
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
47 const int wxMENU_HEIGHT
= 27;
48 const int wxSTATUS_HEIGHT
= 25;
49 const int wxPLACE_HOLDER
= 0;
51 // ----------------------------------------------------------------------------
53 // ----------------------------------------------------------------------------
55 extern void wxapp_install_idle_handler();
57 extern int g_openDialogs
;
59 // ----------------------------------------------------------------------------
61 // ----------------------------------------------------------------------------
63 IMPLEMENT_DYNAMIC_CLASS(wxFrame
,wxWindow
)
65 // ----------------------------------------------------------------------------
67 // ----------------------------------------------------------------------------
69 extern wxList wxPendingDelete
;
71 // ----------------------------------------------------------------------------
73 // ----------------------------------------------------------------------------
77 extern void debug_focus_in( GtkWidget
* widget
, const wxChar
* name
, const wxChar
*window
);
81 // ============================================================================
83 // ============================================================================
85 // ----------------------------------------------------------------------------
87 // ----------------------------------------------------------------------------
89 //-----------------------------------------------------------------------------
90 // "focus" from m_window
91 //-----------------------------------------------------------------------------
93 static gint
gtk_frame_focus_callback( GtkWidget
*widget
, GtkDirectionType
WXUNUSED(d
), wxWindow
*WXUNUSED(win
) )
96 wxapp_install_idle_handler();
98 // This disables GTK's tab traversal
99 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "focus" );
103 //-----------------------------------------------------------------------------
105 //-----------------------------------------------------------------------------
107 static void gtk_frame_size_callback( GtkWidget
*WXUNUSED(widget
), GtkAllocation
* alloc
, wxFrame
*win
)
110 wxapp_install_idle_handler();
115 if ((win
->m_width
!= alloc
->width
) || (win
->m_height
!= alloc
->height
))
118 wxPrintf( "OnSize from " );
119 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
120 wxPrintf( win->GetClassInfo()->GetClassName() );
121 wxPrintf( " %d %d %d %d\n", (int)alloc->x,
124 (int)alloc->height );
127 win
->m_width
= alloc
->width
;
128 win
->m_height
= alloc
->height
;
129 win
->GtkUpdateSize();
133 //-----------------------------------------------------------------------------
135 //-----------------------------------------------------------------------------
137 static gint
gtk_frame_delete_callback( GtkWidget
*WXUNUSED(widget
), GdkEvent
*WXUNUSED(event
), wxFrame
*win
)
140 wxapp_install_idle_handler();
142 if ((g_openDialogs
== 0) && (win
->IsEnabled()))
148 //-----------------------------------------------------------------------------
149 // "child_attached" of menu bar
150 //-----------------------------------------------------------------------------
152 static void gtk_menu_attached_callback( GtkWidget
*WXUNUSED(widget
), GtkWidget
*WXUNUSED(child
), wxFrame
*win
)
154 if (!win
->m_hasVMT
) return;
156 win
->m_menuBarDetached
= FALSE
;
157 win
->GtkUpdateSize();
160 //-----------------------------------------------------------------------------
161 // "child_detached" of menu bar
162 //-----------------------------------------------------------------------------
164 static void gtk_menu_detached_callback( GtkWidget
*WXUNUSED(widget
), GtkWidget
*WXUNUSED(child
), wxFrame
*win
)
166 if (!win
->m_hasVMT
) return;
168 win
->m_menuBarDetached
= TRUE
;
169 win
->GtkUpdateSize();
173 //-----------------------------------------------------------------------------
174 // "child_attached" of tool bar
175 //-----------------------------------------------------------------------------
177 static void gtk_toolbar_attached_callback( GtkWidget
*WXUNUSED(widget
), GtkWidget
*WXUNUSED(child
), wxFrame
*win
)
179 if (!win
->m_hasVMT
) return;
181 win
->m_toolBarDetached
= FALSE
;
183 win
->GtkUpdateSize();
186 //-----------------------------------------------------------------------------
187 // "child_detached" of tool bar
188 //-----------------------------------------------------------------------------
190 static void gtk_toolbar_detached_callback( GtkWidget
*WXUNUSED(widget
), GtkWidget
*WXUNUSED(child
), wxFrame
*win
)
193 wxapp_install_idle_handler();
195 if (!win
->m_hasVMT
) return;
197 win
->m_toolBarDetached
= TRUE
;
198 win
->GtkUpdateSize();
200 #endif // wxUSE_TOOLBAR
202 //-----------------------------------------------------------------------------
204 //-----------------------------------------------------------------------------
207 #if (GTK_MINOR_VERSION > 0)
208 gtk_frame_configure_callback( GtkWidget
*WXUNUSED(widget
), GdkEventConfigure
*WXUNUSED(event
), wxFrame
*win
)
210 gtk_frame_configure_callback( GtkWidget
*WXUNUSED(widget
), GdkEventConfigure
*event
, wxFrame
*win
)
214 wxapp_install_idle_handler();
219 #if (GTK_MINOR_VERSION > 0)
222 gdk_window_get_root_origin( win
->m_widget
->window
, &x
, &y
);
230 wxMoveEvent
mevent( wxPoint(win
->m_x
,win
->m_y
), win
->GetId() );
231 mevent
.SetEventObject( win
);
232 win
->GetEventHandler()->ProcessEvent( mevent
);
237 //-----------------------------------------------------------------------------
238 // "realize" from m_widget
239 //-----------------------------------------------------------------------------
241 /* we cannot MWM hints and icons before the widget has been realized,
242 so we do this directly after realization */
245 gtk_frame_realized_callback( GtkWidget
*widget
, wxFrame
*win
)
248 wxapp_install_idle_handler();
250 /* I haven't been able to set the position of
251 the dialog before it is shown, so I set the
252 position in "realize" */
253 gtk_widget_set_uposition( widget
, win
->m_x
, win
->m_y
);
255 /* all this is for Motif Window Manager "hints" and is supposed to be
256 recognized by other WM as well. not tested. */
257 long decor
= (long) GDK_DECOR_BORDER
;
258 long func
= (long) GDK_FUNC_MOVE
;
260 if ((win
->GetWindowStyle() & wxCAPTION
) != 0)
261 decor
|= GDK_DECOR_TITLE
;
262 if ((win
->GetWindowStyle() & wxSYSTEM_MENU
) != 0)
264 decor
|= GDK_DECOR_MENU
;
265 func
|= GDK_FUNC_CLOSE
;
267 if ((win
->GetWindowStyle() & wxMINIMIZE_BOX
) != 0)
269 func
|= GDK_FUNC_MINIMIZE
;
270 decor
|= GDK_DECOR_MINIMIZE
;
272 if ((win
->GetWindowStyle() & wxMAXIMIZE_BOX
) != 0)
274 func
|= GDK_FUNC_MAXIMIZE
;
275 decor
|= GDK_DECOR_MAXIMIZE
;
277 if ((win
->GetWindowStyle() & wxRESIZE_BORDER
) != 0)
279 func
|= GDK_FUNC_RESIZE
;
280 decor
|= GDK_DECOR_RESIZEH
;
283 gdk_window_set_decorations( win
->m_widget
->window
, (GdkWMDecoration
)decor
);
284 gdk_window_set_functions( win
->m_widget
->window
, (GdkWMFunction
)func
);
286 /* GTK's shrinking/growing policy */
287 if ((win
->GetWindowStyle() & wxRESIZE_BORDER
) == 0)
288 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 0, 0, 1);
290 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 1, 1, 1);
293 gint flag
= 0; // GDK_HINT_POS;
294 if ((win
->GetMinWidth() != -1) || (win
->GetMinHeight() != -1)) flag
|= GDK_HINT_MIN_SIZE
;
295 if ((win
->GetMaxWidth() != -1) || (win
->GetMaxHeight() != -1)) flag
|= GDK_HINT_MAX_SIZE
;
298 gdk_window_set_hints( win
->m_widget
->window
,
300 win
->GetMinWidth(), win
->GetMinHeight(),
301 win
->GetMaxWidth(), win
->GetMaxHeight(),
306 wxIcon iconOld
= win
->GetIcon();
307 if ( iconOld
!= wxNullIcon
)
309 wxIcon
icon( iconOld
);
310 win
->SetIcon( wxNullIcon
);
311 win
->SetIcon( icon
);
314 /* we set the focus to the child that accepts the focus. this
315 doesn't really have to be done in "realize" but why not? */
316 wxWindowList::Node
*node
= win
->GetChildren().GetFirst();
319 wxWindow
*child
= node
->GetData();
320 if (child
->AcceptsFocus())
326 node
= node
->GetNext();
332 // ----------------------------------------------------------------------------
334 // ----------------------------------------------------------------------------
336 //-----------------------------------------------------------------------------
337 // InsertChild for wxFrame
338 //-----------------------------------------------------------------------------
340 /* Callback for wxFrame. This very strange beast has to be used because
341 * C++ has no virtual methods in a constructor. We have to emulate a
342 * virtual function here as wxWindows requires different ways to insert
343 * a child in container classes. */
345 static void wxInsertChildInFrame( wxFrame
* parent
, wxWindow
* child
)
347 wxASSERT( GTK_IS_WIDGET(child
->m_widget
) );
349 if (!parent
->m_insertInClientArea
)
351 /* these are outside the client area */
352 wxFrame
* frame
= (wxFrame
*) parent
;
353 gtk_pizza_put( GTK_PIZZA(frame
->m_mainWidget
),
354 GTK_WIDGET(child
->m_widget
),
360 #if wxUSE_TOOLBAR_NATIVE
361 /* we connect to these events for recalculating the client area
362 space when the toolbar is floating */
363 if (wxIS_KIND_OF(child
,wxToolBar
))
365 wxToolBar
*toolBar
= (wxToolBar
*) child
;
366 if (toolBar
->GetWindowStyle() & wxTB_DOCKABLE
)
368 gtk_signal_connect( GTK_OBJECT(toolBar
->m_widget
), "child_attached",
369 GTK_SIGNAL_FUNC(gtk_toolbar_attached_callback
), (gpointer
)parent
);
371 gtk_signal_connect( GTK_OBJECT(toolBar
->m_widget
), "child_detached",
372 GTK_SIGNAL_FUNC(gtk_toolbar_detached_callback
), (gpointer
)parent
);
375 #endif // wxUSE_TOOLBAR
379 /* these are inside the client area */
380 gtk_pizza_put( GTK_PIZZA(parent
->m_wxwindow
),
381 GTK_WIDGET(child
->m_widget
),
388 /* resize on OnInternalIdle */
389 parent
->GtkUpdateSize();
392 // ----------------------------------------------------------------------------
394 // ----------------------------------------------------------------------------
401 m_mainWidget
= (GtkWidget
*) NULL
;
402 m_menuBarDetached
= FALSE
;
403 m_toolBarDetached
= FALSE
;
404 m_insertInClientArea
= TRUE
;
408 bool wxFrame::Create( wxWindow
*parent
,
410 const wxString
&title
,
414 const wxString
&name
)
416 wxTopLevelWindows
.Append( this );
418 m_needParent
= FALSE
;
420 if (!PreCreation( parent
, pos
, size
) ||
421 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
423 wxFAIL_MSG( wxT("wxFrame creation failed") );
429 m_insertCallback
= (wxInsertChildFunction
) wxInsertChildInFrame
;
431 GtkWindowType win_type
= GTK_WINDOW_TOPLEVEL
;
432 if (style
& wxSIMPLE_BORDER
) win_type
= GTK_WINDOW_POPUP
;
434 m_widget
= gtk_window_new( win_type
);
437 gtk_window_set_wmclass( GTK_WINDOW(m_widget
), name
.mb_str(), name
.mb_str() );
440 debug_focus_in( m_widget
, wxT("wxFrame::m_widget"), name
);
443 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
444 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
446 gtk_signal_connect( GTK_OBJECT(m_widget
), "delete_event",
447 GTK_SIGNAL_FUNC(gtk_frame_delete_callback
), (gpointer
)this );
449 /* m_mainWidget holds the toolbar, the menubar and the client area */
450 m_mainWidget
= gtk_pizza_new();
451 gtk_widget_show( m_mainWidget
);
452 GTK_WIDGET_UNSET_FLAGS( m_mainWidget
, GTK_CAN_FOCUS
);
453 gtk_container_add( GTK_CONTAINER(m_widget
), m_mainWidget
);
456 debug_focus_in( m_mainWidget
, wxT("wxFrame::m_mainWidget"), name
);
459 /* m_wxwindow only represents the client area without toolbar and menubar */
460 m_wxwindow
= gtk_pizza_new();
461 gtk_widget_show( m_wxwindow
);
462 gtk_container_add( GTK_CONTAINER(m_mainWidget
), m_wxwindow
);
465 debug_focus_in( m_wxwindow
, wxT("wxFrame::m_wxwindow"), name
);
468 /* we donm't allow the frame to get the focus as otherwise
469 the frame will grabit at arbitrary fcous changes. */
470 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
472 if (m_parent
) m_parent
->AddChild( this );
474 /* the user resized the frame by dragging etc. */
475 gtk_signal_connect( GTK_OBJECT(m_widget
), "size_allocate",
476 GTK_SIGNAL_FUNC(gtk_frame_size_callback
), (gpointer
)this );
480 /* we cannot set MWM hints and icons before the widget has
481 been realized, so we do this directly after realization */
482 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
483 GTK_SIGNAL_FUNC(gtk_frame_realized_callback
), (gpointer
) this );
485 /* the only way to get the window size is to connect to this event */
486 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
487 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
489 /* disable native tab traversal */
490 gtk_signal_connect( GTK_OBJECT(m_widget
), "focus",
491 GTK_SIGNAL_FUNC(gtk_frame_focus_callback
), (gpointer
)this );
498 m_isBeingDeleted
= TRUE
;
502 wxTopLevelWindows
.DeleteObject( this );
504 if (wxTheApp
->GetTopWindow() == this)
505 wxTheApp
->SetTopWindow( (wxWindow
*) NULL
);
507 if ((wxTopLevelWindows
.Number() == 0) &&
508 (wxTheApp
->GetExitOnFrameDelete()))
510 wxTheApp
->ExitMainLoop();
514 // ----------------------------------------------------------------------------
515 // overridden wxWindow methods
516 // ----------------------------------------------------------------------------
518 bool wxFrame::Show( bool show
)
520 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
522 if (show
&& !m_sizeSet
)
524 /* by calling GtkOnSize here, we don't have to call
525 either after showing the frame, which would entail
526 much ugly flicker or from within the size_allocate
527 handler, because GTK 1.1.X forbids that. */
529 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
532 return wxWindow::Show( show
);
535 void wxFrame::DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
), int WXUNUSED(width
), int WXUNUSED(height
) )
537 wxFAIL_MSG( wxT("DoMoveWindow called for wxFrame") );
540 void wxFrame::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
542 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
544 /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
545 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
547 /* avoid recursions */
555 int old_width
= m_width
;
556 int old_height
= m_height
;
558 if ((sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) == 0)
560 if (x
!= -1) m_x
= x
;
561 if (y
!= -1) m_y
= y
;
562 if (width
!= -1) m_width
= width
;
563 if (height
!= -1) m_height
= height
;
574 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
576 if (width == -1) m_width = 80;
579 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
581 if (height == -1) m_height = 26;
585 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
586 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
587 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
588 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
590 if ((m_x
!= -1) || (m_y
!= -1))
592 if ((m_x
!= old_x
) || (m_y
!= old_y
))
594 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
598 if ((m_width
!= old_width
) || (m_height
!= old_height
))
600 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
601 done either directly before the frame is shown or in idle time
602 so that different calls to SetSize() don't lead to flicker. */
609 void wxFrame::DoGetClientSize( int *width
, int *height
) const
611 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
613 wxWindow::DoGetClientSize( width
, height
);
619 if (!m_menuBarDetached
)
620 (*height
) -= wxMENU_HEIGHT
;
622 (*height
) -= wxPLACE_HOLDER
;
627 if (m_frameStatusBar
) (*height
) -= wxSTATUS_HEIGHT
;
628 #endif // wxUSE_STATUSBAR
634 if (m_toolBarDetached
)
636 *height
-= wxPLACE_HOLDER
;
641 m_frameToolBar
->GetSize( &x
, &y
);
642 if ( m_frameToolBar
->GetWindowStyle() & wxTB_VERTICAL
)
652 #endif // wxUSE_TOOLBAR
655 *height
-= m_miniEdge
*2 + m_miniTitle
;
659 *width
-= m_miniEdge
*2;
663 void wxFrame::DoSetClientSize( int width
, int height
)
665 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
670 if (!m_menuBarDetached
)
671 height
+= wxMENU_HEIGHT
;
673 height
+= wxPLACE_HOLDER
;
678 if (m_frameStatusBar
) height
+= wxSTATUS_HEIGHT
;
685 if (m_toolBarDetached
)
687 height
+= wxPLACE_HOLDER
;
692 m_frameToolBar
->GetSize( &x
, &y
);
693 if ( m_frameToolBar
->GetWindowStyle() & wxTB_VERTICAL
)
705 DoSetSize( -1, -1, width
+ m_miniEdge
*2, height
+ m_miniEdge
*2 + m_miniTitle
, 0 );
708 void wxFrame::GtkOnSize( int WXUNUSED(x
), int WXUNUSED(y
),
709 int width
, int height
)
711 // due to a bug in gtk, x,y are always 0
715 /* avoid recursions */
716 if (m_resizing
) return;
719 /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
720 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
725 /* space occupied by m_frameToolBar and m_frameMenuBar */
726 int client_area_x_offset
= 0,
727 client_area_y_offset
= 0;
729 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
730 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
731 set in wxFrame::Create so it is used to check what kind of frame we
732 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
733 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
734 importantly) m_mainWidget */
738 /* check if size is in legal range */
739 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
740 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
741 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
742 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
744 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
745 * menubar, the toolbar and the client area, which is represented by
747 * this hurts in the eye, but I don't want to call SetSize()
748 * because I don't want to call any non-native functions here. */
753 int yy
= m_miniEdge
+ m_miniTitle
;
754 int ww
= m_width
- 2*m_miniEdge
;
755 int hh
= wxMENU_HEIGHT
;
756 if (m_menuBarDetached
) hh
= wxPLACE_HOLDER
;
757 m_frameMenuBar
->m_x
= xx
;
758 m_frameMenuBar
->m_y
= yy
;
759 m_frameMenuBar
->m_width
= ww
;
760 m_frameMenuBar
->m_height
= hh
;
761 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
762 m_frameMenuBar
->m_widget
,
764 client_area_y_offset
+= hh
;
768 if ((m_frameToolBar
) &&
769 (m_frameToolBar
->m_widget
->parent
== m_mainWidget
))
772 int yy
= m_miniEdge
+ m_miniTitle
;
775 if (!m_menuBarDetached
)
778 yy
+= wxPLACE_HOLDER
;
781 m_frameToolBar
->m_x
= xx
;
782 m_frameToolBar
->m_y
= yy
;
784 /* don't change the toolbar's reported height/width */
786 if ( m_frameToolBar
->GetWindowStyle() & wxTB_VERTICAL
)
788 ww
= m_toolBarDetached
? wxPLACE_HOLDER
789 : m_frameToolBar
->m_width
;
790 hh
= m_height
- 2*m_miniEdge
;
792 client_area_x_offset
+= ww
;
796 ww
= m_width
- 2*m_miniEdge
;
797 hh
= m_toolBarDetached
? wxPLACE_HOLDER
798 : m_frameToolBar
->m_height
;
800 client_area_y_offset
+= hh
;
803 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
804 m_frameToolBar
->m_widget
,
807 #endif // wxUSE_TOOLBAR
809 int client_x
= client_area_x_offset
+ m_miniEdge
;
810 int client_y
= client_area_y_offset
+ m_miniEdge
+ m_miniTitle
;
811 int client_w
= m_width
- client_area_x_offset
- 2*m_miniEdge
;
812 int client_h
= m_height
- client_area_y_offset
- 2*m_miniEdge
- m_miniTitle
;
813 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
815 client_x
, client_y
, client_w
, client_h
);
819 /* if there is no m_mainWidget between m_widget and m_wxwindow there
820 is no need to set the size or position of m_wxwindow. */
824 if (m_frameStatusBar
)
826 int xx
= 0 + m_miniEdge
;
827 int yy
= m_height
- wxSTATUS_HEIGHT
- m_miniEdge
- client_area_y_offset
;
828 int ww
= m_width
- 2*m_miniEdge
;
829 int hh
= wxSTATUS_HEIGHT
;
830 m_frameStatusBar
->m_x
= xx
;
831 m_frameStatusBar
->m_y
= yy
;
832 m_frameStatusBar
->m_width
= ww
;
833 m_frameStatusBar
->m_height
= hh
;
834 gtk_pizza_set_size( GTK_PIZZA(m_wxwindow
),
835 m_frameStatusBar
->m_widget
,
837 gtk_widget_draw( m_frameStatusBar
->m_widget
, (GdkRectangle
*) NULL
);
841 /* we actually set the size of a frame here and no-where else */
842 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
846 // send size event to frame
847 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
848 event
.SetEventObject( this );
849 GetEventHandler()->ProcessEvent( event
);
851 // send size event to status bar
852 if (m_frameStatusBar
)
854 wxSizeEvent
event2( wxSize(m_frameStatusBar
->m_width
,m_frameStatusBar
->m_height
), m_frameStatusBar
->GetId() );
855 event2
.SetEventObject( m_frameStatusBar
);
856 m_frameStatusBar
->GetEventHandler()->ProcessEvent( event2
);
862 void wxFrame::MakeModal( bool modal
)
865 gtk_grab_add( m_widget
);
867 gtk_grab_remove( m_widget
);
870 void wxFrame::OnInternalIdle()
872 if (!m_sizeSet
&& GTK_WIDGET_REALIZED(m_wxwindow
))
874 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
876 // we'll come back later
878 wxapp_install_idle_handler();
882 if (m_frameMenuBar
) m_frameMenuBar
->OnInternalIdle();
884 if (m_frameToolBar
) m_frameToolBar
->OnInternalIdle();
887 if (m_frameStatusBar
) m_frameStatusBar
->OnInternalIdle();
890 wxWindow::OnInternalIdle();
893 // ----------------------------------------------------------------------------
894 // menu/tool/status bar stuff
895 // ----------------------------------------------------------------------------
897 void wxFrame::SetMenuBar( wxMenuBar
*menuBar
)
899 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
900 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
902 if (menuBar
== m_frameMenuBar
)
907 m_frameMenuBar
->UnsetInvokingWindow( this );
909 if (m_frameMenuBar
->GetWindowStyle() & wxMB_DOCKABLE
)
911 gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar
->m_widget
),
912 GTK_SIGNAL_FUNC(gtk_menu_attached_callback
), (gpointer
)this );
914 gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar
->m_widget
),
915 GTK_SIGNAL_FUNC(gtk_menu_detached_callback
), (gpointer
)this );
918 gtk_container_remove( GTK_CONTAINER(m_mainWidget
), m_frameMenuBar
->m_widget
);
919 gtk_widget_ref( m_frameMenuBar
->m_widget
);
920 gtk_widget_unparent( m_frameMenuBar
->m_widget
);
923 m_frameMenuBar
= menuBar
;
927 m_frameMenuBar
->SetInvokingWindow( this );
929 m_frameMenuBar
->SetParent(this);
930 gtk_pizza_put( GTK_PIZZA(m_mainWidget
),
931 m_frameMenuBar
->m_widget
,
934 m_frameMenuBar
->m_width
,
935 m_frameMenuBar
->m_height
);
937 if (menuBar
->GetWindowStyle() & wxMB_DOCKABLE
)
939 gtk_signal_connect( GTK_OBJECT(menuBar
->m_widget
), "child_attached",
940 GTK_SIGNAL_FUNC(gtk_menu_attached_callback
), (gpointer
)this );
942 gtk_signal_connect( GTK_OBJECT(menuBar
->m_widget
), "child_detached",
943 GTK_SIGNAL_FUNC(gtk_menu_detached_callback
), (gpointer
)this );
946 m_frameMenuBar
->Show( TRUE
);
949 /* resize window in OnInternalIdle */
954 wxToolBar
* wxFrame::CreateToolBar( long style
, wxWindowID id
, const wxString
& name
)
956 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
958 m_insertInClientArea
= FALSE
;
960 m_frameToolBar
= wxFrameBase::CreateToolBar( style
, id
, name
);
963 GetChildren().DeleteObject( m_frameToolBar
);
965 m_insertInClientArea
= TRUE
;
969 return m_frameToolBar
;
972 void wxFrame::SetToolBar(wxToolBar
*toolbar
)
974 wxFrameBase::SetToolBar(toolbar
);
978 /* insert into toolbar area if not already there */
979 if ((m_frameToolBar
->m_widget
->parent
) &&
980 (m_frameToolBar
->m_widget
->parent
!= m_mainWidget
))
982 GetChildren().DeleteObject( m_frameToolBar
);
984 gtk_widget_reparent( m_frameToolBar
->m_widget
, m_mainWidget
);
990 #endif // wxUSE_TOOLBAR
994 wxStatusBar
* wxFrame::CreateStatusBar(int number
,
997 const wxString
& name
)
999 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
1001 // because it will change when toolbar is added
1004 return wxFrameBase::CreateStatusBar( number
, style
, id
, name
);
1007 void wxFrame::PositionStatusBar()
1009 if ( !m_frameStatusBar
)
1014 #endif // wxUSE_STATUSBAR
1016 // ----------------------------------------------------------------------------
1018 // ----------------------------------------------------------------------------
1020 void wxFrame::SetTitle( const wxString
&title
)
1022 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
1025 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
1028 void wxFrame::SetIcon( const wxIcon
&icon
)
1030 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
1032 wxFrameBase::SetIcon(icon
);
1037 if (!m_widget
->window
)
1040 wxMask
*mask
= icon
.GetMask();
1041 GdkBitmap
*bm
= (GdkBitmap
*) NULL
;
1042 if (mask
) bm
= mask
->GetBitmap();
1044 gdk_window_set_icon( m_widget
->window
, (GdkWindow
*) NULL
, icon
.GetPixmap(), bm
);
1047 // ----------------------------------------------------------------------------
1048 // frame state: maximized/iconized/normal (TODO)
1049 // ----------------------------------------------------------------------------
1051 void wxFrame::Maximize(bool WXUNUSED(maximize
))
1055 bool wxFrame::IsMaximized() const
1060 void wxFrame::Restore()
1064 void wxFrame::Iconize( bool iconize
)
1068 XIconifyWindow( GDK_WINDOW_XDISPLAY( m_widget
->window
),
1069 GDK_WINDOW_XWINDOW( m_widget
->window
),
1070 DefaultScreen( GDK_DISPLAY() ) );
1074 bool wxFrame::IsIconized() const