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
->m_queuedFullRedraw
= TRUE
;
130 win
->GtkUpdateSize();
134 //-----------------------------------------------------------------------------
136 //-----------------------------------------------------------------------------
138 static gint
gtk_frame_delete_callback( GtkWidget
*WXUNUSED(widget
), GdkEvent
*WXUNUSED(event
), wxFrame
*win
)
141 wxapp_install_idle_handler();
143 if ((g_openDialogs
== 0) && (win
->IsEnabled()))
149 //-----------------------------------------------------------------------------
150 // "child_attached" of menu bar
151 //-----------------------------------------------------------------------------
153 static void gtk_menu_attached_callback( GtkWidget
*WXUNUSED(widget
), GtkWidget
*WXUNUSED(child
), wxFrame
*win
)
155 if (!win
->m_hasVMT
) return;
157 win
->m_menuBarDetached
= FALSE
;
158 win
->GtkUpdateSize();
161 //-----------------------------------------------------------------------------
162 // "child_detached" of menu bar
163 //-----------------------------------------------------------------------------
165 static void gtk_menu_detached_callback( GtkWidget
*WXUNUSED(widget
), GtkWidget
*WXUNUSED(child
), wxFrame
*win
)
167 if (!win
->m_hasVMT
) return;
169 win
->m_menuBarDetached
= TRUE
;
170 win
->GtkUpdateSize();
174 //-----------------------------------------------------------------------------
175 // "child_attached" of tool bar
176 //-----------------------------------------------------------------------------
178 static void gtk_toolbar_attached_callback( GtkWidget
*WXUNUSED(widget
), GtkWidget
*WXUNUSED(child
), wxFrame
*win
)
180 if (!win
->m_hasVMT
) return;
182 win
->m_toolBarDetached
= FALSE
;
184 win
->GtkUpdateSize();
187 //-----------------------------------------------------------------------------
188 // "child_detached" of tool bar
189 //-----------------------------------------------------------------------------
191 static void gtk_toolbar_detached_callback( GtkWidget
*WXUNUSED(widget
), GtkWidget
*WXUNUSED(child
), wxFrame
*win
)
194 wxapp_install_idle_handler();
196 if (!win
->m_hasVMT
) return;
198 win
->m_toolBarDetached
= TRUE
;
199 win
->GtkUpdateSize();
201 #endif // wxUSE_TOOLBAR
203 //-----------------------------------------------------------------------------
205 //-----------------------------------------------------------------------------
208 #if (GTK_MINOR_VERSION > 0)
209 gtk_frame_configure_callback( GtkWidget
*WXUNUSED(widget
), GdkEventConfigure
*WXUNUSED(event
), wxFrame
*win
)
211 gtk_frame_configure_callback( GtkWidget
*WXUNUSED(widget
), GdkEventConfigure
*event
, wxFrame
*win
)
215 wxapp_install_idle_handler();
220 #if (GTK_MINOR_VERSION > 0)
223 gdk_window_get_root_origin( win
->m_widget
->window
, &x
, &y
);
231 wxMoveEvent
mevent( wxPoint(win
->m_x
,win
->m_y
), win
->GetId() );
232 mevent
.SetEventObject( win
);
233 win
->GetEventHandler()->ProcessEvent( mevent
);
238 //-----------------------------------------------------------------------------
239 // "realize" from m_widget
240 //-----------------------------------------------------------------------------
242 /* we cannot MWM hints and icons before the widget has been realized,
243 so we do this directly after realization */
246 gtk_frame_realized_callback( GtkWidget
*widget
, wxFrame
*win
)
249 wxapp_install_idle_handler();
251 /* I haven't been able to set the position of
252 the dialog before it is shown, so I set the
253 position in "realize" */
254 gtk_widget_set_uposition( widget
, win
->m_x
, win
->m_y
);
256 if (win
->m_miniEdge
> 0)
258 /* This is a mini-frame. */
259 gdk_window_set_decorations( win
->m_widget
->window
, (GdkWMDecoration
)0 );
260 gdk_window_set_functions( win
->m_widget
->window
, (GdkWMFunction
)0 );
264 /* All this is for Motif Window Manager "hints" and is supposed to be
265 recognized by other WM as well. Not tested. */
266 long decor
= (long) GDK_DECOR_BORDER
;
267 long func
= (long) GDK_FUNC_MOVE
;
269 if ((win
->GetWindowStyle() & wxCAPTION
) != 0)
270 decor
|= GDK_DECOR_TITLE
;
271 if ((win
->GetWindowStyle() & wxSYSTEM_MENU
) != 0)
273 decor
|= GDK_DECOR_MENU
;
274 func
|= GDK_FUNC_CLOSE
;
276 if ((win
->GetWindowStyle() & wxMINIMIZE_BOX
) != 0)
278 func
|= GDK_FUNC_MINIMIZE
;
279 decor
|= GDK_DECOR_MINIMIZE
;
281 if ((win
->GetWindowStyle() & wxMAXIMIZE_BOX
) != 0)
283 func
|= GDK_FUNC_MAXIMIZE
;
284 decor
|= GDK_DECOR_MAXIMIZE
;
286 if ((win
->GetWindowStyle() & wxRESIZE_BORDER
) != 0)
288 func
|= GDK_FUNC_RESIZE
;
289 decor
|= GDK_DECOR_RESIZEH
;
292 gdk_window_set_decorations( win
->m_widget
->window
, (GdkWMDecoration
)decor
);
293 gdk_window_set_functions( win
->m_widget
->window
, (GdkWMFunction
)func
);
296 /* GTK's shrinking/growing policy */
297 if ((win
->GetWindowStyle() & wxRESIZE_BORDER
) == 0)
298 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 0, 0, 1);
300 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 1, 1, 1);
303 gint flag
= 0; // GDK_HINT_POS;
304 if ((win
->GetMinWidth() != -1) || (win
->GetMinHeight() != -1)) flag
|= GDK_HINT_MIN_SIZE
;
305 if ((win
->GetMaxWidth() != -1) || (win
->GetMaxHeight() != -1)) flag
|= GDK_HINT_MAX_SIZE
;
308 gdk_window_set_hints( win
->m_widget
->window
,
310 win
->GetMinWidth(), win
->GetMinHeight(),
311 win
->GetMaxWidth(), win
->GetMaxHeight(),
316 wxIcon iconOld
= win
->GetIcon();
317 if ( iconOld
!= wxNullIcon
)
319 wxIcon
icon( iconOld
);
320 win
->SetIcon( wxNullIcon
);
321 win
->SetIcon( icon
);
324 /* we set the focus to the child that accepts the focus. this
325 doesn't really have to be done in "realize" but why not? */
326 wxWindowList::Node
*node
= win
->GetChildren().GetFirst();
329 wxWindow
*child
= node
->GetData();
330 if (child
->AcceptsFocus())
336 node
= node
->GetNext();
342 // ----------------------------------------------------------------------------
344 // ----------------------------------------------------------------------------
346 //-----------------------------------------------------------------------------
347 // InsertChild for wxFrame
348 //-----------------------------------------------------------------------------
350 /* Callback for wxFrame. This very strange beast has to be used because
351 * C++ has no virtual methods in a constructor. We have to emulate a
352 * virtual function here as wxWindows requires different ways to insert
353 * a child in container classes. */
355 static void wxInsertChildInFrame( wxFrame
* parent
, wxWindow
* child
)
357 wxASSERT( GTK_IS_WIDGET(child
->m_widget
) );
359 if (!parent
->m_insertInClientArea
)
361 /* these are outside the client area */
362 wxFrame
* frame
= (wxFrame
*) parent
;
363 gtk_pizza_put( GTK_PIZZA(frame
->m_mainWidget
),
364 GTK_WIDGET(child
->m_widget
),
370 #if wxUSE_TOOLBAR_NATIVE
371 /* we connect to these events for recalculating the client area
372 space when the toolbar is floating */
373 if (wxIS_KIND_OF(child
,wxToolBar
))
375 wxToolBar
*toolBar
= (wxToolBar
*) child
;
376 if (toolBar
->GetWindowStyle() & wxTB_DOCKABLE
)
378 gtk_signal_connect( GTK_OBJECT(toolBar
->m_widget
), "child_attached",
379 GTK_SIGNAL_FUNC(gtk_toolbar_attached_callback
), (gpointer
)parent
);
381 gtk_signal_connect( GTK_OBJECT(toolBar
->m_widget
), "child_detached",
382 GTK_SIGNAL_FUNC(gtk_toolbar_detached_callback
), (gpointer
)parent
);
385 #endif // wxUSE_TOOLBAR
389 /* these are inside the client area */
390 gtk_pizza_put( GTK_PIZZA(parent
->m_wxwindow
),
391 GTK_WIDGET(child
->m_widget
),
398 /* resize on OnInternalIdle */
399 parent
->GtkUpdateSize();
402 // ----------------------------------------------------------------------------
404 // ----------------------------------------------------------------------------
411 m_mainWidget
= (GtkWidget
*) NULL
;
412 m_menuBarDetached
= FALSE
;
413 m_toolBarDetached
= FALSE
;
414 m_insertInClientArea
= TRUE
;
418 bool wxFrame::Create( wxWindow
*parent
,
420 const wxString
&title
,
424 const wxString
&name
)
426 wxTopLevelWindows
.Append( this );
428 m_needParent
= FALSE
;
431 if (!PreCreation( parent
, pos
, size
) ||
432 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
434 wxFAIL_MSG( wxT("wxFrame creation failed") );
440 m_insertCallback
= (wxInsertChildFunction
) wxInsertChildInFrame
;
442 GtkWindowType win_type
= GTK_WINDOW_TOPLEVEL
;
443 if (style
& wxSIMPLE_BORDER
) win_type
= GTK_WINDOW_POPUP
;
445 m_widget
= gtk_window_new( win_type
);
448 gtk_window_set_wmclass( GTK_WINDOW(m_widget
), name
.mb_str(), name
.mb_str() );
451 debug_focus_in( m_widget
, wxT("wxFrame::m_widget"), name
);
454 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
455 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
457 gtk_signal_connect( GTK_OBJECT(m_widget
), "delete_event",
458 GTK_SIGNAL_FUNC(gtk_frame_delete_callback
), (gpointer
)this );
460 /* m_mainWidget holds the toolbar, the menubar and the client area */
461 m_mainWidget
= gtk_pizza_new();
462 gtk_widget_show( m_mainWidget
);
463 GTK_WIDGET_UNSET_FLAGS( m_mainWidget
, GTK_CAN_FOCUS
);
464 gtk_container_add( GTK_CONTAINER(m_widget
), m_mainWidget
);
467 debug_focus_in( m_mainWidget
, wxT("wxFrame::m_mainWidget"), name
);
470 /* m_wxwindow only represents the client area without toolbar and menubar */
471 m_wxwindow
= gtk_pizza_new();
472 gtk_widget_show( m_wxwindow
);
473 gtk_container_add( GTK_CONTAINER(m_mainWidget
), m_wxwindow
);
476 debug_focus_in( m_wxwindow
, wxT("wxFrame::m_wxwindow"), name
);
479 /* we donm't allow the frame to get the focus as otherwise
480 the frame will grabit at arbitrary fcous changes. */
481 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
483 if (m_parent
) m_parent
->AddChild( this );
485 /* the user resized the frame by dragging etc. */
486 gtk_signal_connect( GTK_OBJECT(m_widget
), "size_allocate",
487 GTK_SIGNAL_FUNC(gtk_frame_size_callback
), (gpointer
)this );
491 /* we cannot set MWM hints and icons before the widget has
492 been realized, so we do this directly after realization */
493 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
494 GTK_SIGNAL_FUNC(gtk_frame_realized_callback
), (gpointer
) this );
496 /* the only way to get the window size is to connect to this event */
497 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
498 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
500 /* disable native tab traversal */
501 gtk_signal_connect( GTK_OBJECT(m_widget
), "focus",
502 GTK_SIGNAL_FUNC(gtk_frame_focus_callback
), (gpointer
)this );
509 m_isBeingDeleted
= TRUE
;
513 wxTopLevelWindows
.DeleteObject( this );
515 if (wxTheApp
->GetTopWindow() == this)
516 wxTheApp
->SetTopWindow( (wxWindow
*) NULL
);
518 if ((wxTopLevelWindows
.Number() == 0) &&
519 (wxTheApp
->GetExitOnFrameDelete()))
521 wxTheApp
->ExitMainLoop();
525 // ----------------------------------------------------------------------------
526 // overridden wxWindow methods
527 // ----------------------------------------------------------------------------
529 bool wxFrame::Show( bool show
)
531 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
533 if (show
&& !m_sizeSet
)
535 /* by calling GtkOnSize here, we don't have to call
536 either after showing the frame, which would entail
537 much ugly flicker or from within the size_allocate
538 handler, because GTK 1.1.X forbids that. */
540 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
543 return wxWindow::Show( show
);
546 void wxFrame::DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
), int WXUNUSED(width
), int WXUNUSED(height
) )
548 wxFAIL_MSG( wxT("DoMoveWindow called for wxFrame") );
551 void wxFrame::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
553 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
555 /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
556 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
558 /* avoid recursions */
566 int old_width
= m_width
;
567 int old_height
= m_height
;
569 if ((sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) == 0)
571 if (x
!= -1) m_x
= x
;
572 if (y
!= -1) m_y
= y
;
573 if (width
!= -1) m_width
= width
;
574 if (height
!= -1) m_height
= height
;
585 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
587 if (width == -1) m_width = 80;
590 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
592 if (height == -1) m_height = 26;
596 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
597 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
598 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
599 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
601 if ((m_x
!= -1) || (m_y
!= -1))
603 if ((m_x
!= old_x
) || (m_y
!= old_y
))
605 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
609 if ((m_width
!= old_width
) || (m_height
!= old_height
))
611 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
612 done either directly before the frame is shown or in idle time
613 so that different calls to SetSize() don't lead to flicker. */
620 void wxFrame::DoGetClientSize( int *width
, int *height
) const
622 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
624 wxWindow::DoGetClientSize( width
, height
);
630 if (!m_menuBarDetached
)
631 (*height
) -= wxMENU_HEIGHT
;
633 (*height
) -= wxPLACE_HOLDER
;
638 if (m_frameStatusBar
) (*height
) -= wxSTATUS_HEIGHT
;
639 #endif // wxUSE_STATUSBAR
645 if (m_toolBarDetached
)
647 *height
-= wxPLACE_HOLDER
;
652 m_frameToolBar
->GetSize( &x
, &y
);
653 if ( m_frameToolBar
->GetWindowStyle() & wxTB_VERTICAL
)
663 #endif // wxUSE_TOOLBAR
666 *height
-= m_miniEdge
*2 + m_miniTitle
;
670 *width
-= m_miniEdge
*2;
674 void wxFrame::DoSetClientSize( int width
, int height
)
676 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
681 if (!m_menuBarDetached
)
682 height
+= wxMENU_HEIGHT
;
684 height
+= wxPLACE_HOLDER
;
689 if (m_frameStatusBar
) height
+= wxSTATUS_HEIGHT
;
696 if (m_toolBarDetached
)
698 height
+= wxPLACE_HOLDER
;
703 m_frameToolBar
->GetSize( &x
, &y
);
704 if ( m_frameToolBar
->GetWindowStyle() & wxTB_VERTICAL
)
716 DoSetSize( -1, -1, width
+ m_miniEdge
*2, height
+ m_miniEdge
*2 + m_miniTitle
, 0 );
719 void wxFrame::GtkOnSize( int WXUNUSED(x
), int WXUNUSED(y
),
720 int width
, int height
)
722 // due to a bug in gtk, x,y are always 0
726 /* avoid recursions */
727 if (m_resizing
) return;
730 /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
731 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
736 /* space occupied by m_frameToolBar and m_frameMenuBar */
737 int client_area_x_offset
= 0,
738 client_area_y_offset
= 0;
740 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
741 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
742 set in wxFrame::Create so it is used to check what kind of frame we
743 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
744 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
745 importantly) m_mainWidget */
749 /* check if size is in legal range */
750 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
751 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
752 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
753 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
755 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
756 * menubar, the toolbar and the client area, which is represented by
758 * this hurts in the eye, but I don't want to call SetSize()
759 * because I don't want to call any non-native functions here. */
764 int yy
= m_miniEdge
+ m_miniTitle
;
765 int ww
= m_width
- 2*m_miniEdge
;
766 int hh
= wxMENU_HEIGHT
;
767 if (m_menuBarDetached
) hh
= wxPLACE_HOLDER
;
768 m_frameMenuBar
->m_x
= xx
;
769 m_frameMenuBar
->m_y
= yy
;
770 m_frameMenuBar
->m_width
= ww
;
771 m_frameMenuBar
->m_height
= hh
;
772 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
773 m_frameMenuBar
->m_widget
,
775 client_area_y_offset
+= hh
;
779 if ((m_frameToolBar
) &&
780 (m_frameToolBar
->m_widget
->parent
== m_mainWidget
))
783 int yy
= m_miniEdge
+ m_miniTitle
;
786 if (!m_menuBarDetached
)
789 yy
+= wxPLACE_HOLDER
;
792 m_frameToolBar
->m_x
= xx
;
793 m_frameToolBar
->m_y
= yy
;
795 /* don't change the toolbar's reported height/width */
797 if ( m_frameToolBar
->GetWindowStyle() & wxTB_VERTICAL
)
799 ww
= m_toolBarDetached
? wxPLACE_HOLDER
800 : m_frameToolBar
->m_width
;
801 hh
= m_height
- 2*m_miniEdge
;
803 client_area_x_offset
+= ww
;
807 ww
= m_width
- 2*m_miniEdge
;
808 hh
= m_toolBarDetached
? wxPLACE_HOLDER
809 : m_frameToolBar
->m_height
;
811 client_area_y_offset
+= hh
;
814 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
815 m_frameToolBar
->m_widget
,
818 #endif // wxUSE_TOOLBAR
820 int client_x
= client_area_x_offset
+ m_miniEdge
;
821 int client_y
= client_area_y_offset
+ m_miniEdge
+ m_miniTitle
;
822 int client_w
= m_width
- client_area_x_offset
- 2*m_miniEdge
;
823 int client_h
= m_height
- client_area_y_offset
- 2*m_miniEdge
- m_miniTitle
;
824 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
826 client_x
, client_y
, client_w
, client_h
);
830 /* if there is no m_mainWidget between m_widget and m_wxwindow there
831 is no need to set the size or position of m_wxwindow. */
835 if (m_frameStatusBar
)
837 int xx
= 0 + m_miniEdge
;
838 int yy
= m_height
- wxSTATUS_HEIGHT
- m_miniEdge
- client_area_y_offset
;
839 int ww
= m_width
- 2*m_miniEdge
;
840 int hh
= wxSTATUS_HEIGHT
;
841 m_frameStatusBar
->m_x
= xx
;
842 m_frameStatusBar
->m_y
= yy
;
843 m_frameStatusBar
->m_width
= ww
;
844 m_frameStatusBar
->m_height
= hh
;
845 gtk_pizza_set_size( GTK_PIZZA(m_wxwindow
),
846 m_frameStatusBar
->m_widget
,
848 gtk_widget_draw( m_frameStatusBar
->m_widget
, (GdkRectangle
*) NULL
);
852 /* we actually set the size of a frame here and no-where else */
853 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
857 // send size event to frame
858 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
859 event
.SetEventObject( this );
860 GetEventHandler()->ProcessEvent( event
);
862 // send size event to status bar
863 if (m_frameStatusBar
)
865 wxSizeEvent
event2( wxSize(m_frameStatusBar
->m_width
,m_frameStatusBar
->m_height
), m_frameStatusBar
->GetId() );
866 event2
.SetEventObject( m_frameStatusBar
);
867 m_frameStatusBar
->GetEventHandler()->ProcessEvent( event2
);
873 void wxFrame::MakeModal( bool modal
)
876 gtk_grab_add( m_widget
);
878 gtk_grab_remove( m_widget
);
881 void wxFrame::OnInternalIdle()
883 if (!m_sizeSet
&& GTK_WIDGET_REALIZED(m_wxwindow
))
885 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
887 // we'll come back later
889 wxapp_install_idle_handler();
893 if (m_frameMenuBar
) m_frameMenuBar
->OnInternalIdle();
895 if (m_frameToolBar
) m_frameToolBar
->OnInternalIdle();
898 if (m_frameStatusBar
) m_frameStatusBar
->OnInternalIdle();
901 wxWindow::OnInternalIdle();
904 // ----------------------------------------------------------------------------
905 // menu/tool/status bar stuff
906 // ----------------------------------------------------------------------------
908 void wxFrame::SetMenuBar( wxMenuBar
*menuBar
)
910 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
911 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
913 if (menuBar
== m_frameMenuBar
)
918 m_frameMenuBar
->UnsetInvokingWindow( this );
920 if (m_frameMenuBar
->GetWindowStyle() & wxMB_DOCKABLE
)
922 gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar
->m_widget
),
923 GTK_SIGNAL_FUNC(gtk_menu_attached_callback
), (gpointer
)this );
925 gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar
->m_widget
),
926 GTK_SIGNAL_FUNC(gtk_menu_detached_callback
), (gpointer
)this );
929 gtk_container_remove( GTK_CONTAINER(m_mainWidget
), m_frameMenuBar
->m_widget
);
930 gtk_widget_ref( m_frameMenuBar
->m_widget
);
931 gtk_widget_unparent( m_frameMenuBar
->m_widget
);
934 m_frameMenuBar
= menuBar
;
938 m_frameMenuBar
->SetInvokingWindow( this );
940 m_frameMenuBar
->SetParent(this);
941 gtk_pizza_put( GTK_PIZZA(m_mainWidget
),
942 m_frameMenuBar
->m_widget
,
945 m_frameMenuBar
->m_width
,
946 m_frameMenuBar
->m_height
);
948 if (menuBar
->GetWindowStyle() & wxMB_DOCKABLE
)
950 gtk_signal_connect( GTK_OBJECT(menuBar
->m_widget
), "child_attached",
951 GTK_SIGNAL_FUNC(gtk_menu_attached_callback
), (gpointer
)this );
953 gtk_signal_connect( GTK_OBJECT(menuBar
->m_widget
), "child_detached",
954 GTK_SIGNAL_FUNC(gtk_menu_detached_callback
), (gpointer
)this );
957 m_frameMenuBar
->Show( TRUE
);
960 /* resize window in OnInternalIdle */
965 wxToolBar
* wxFrame::CreateToolBar( long style
, wxWindowID id
, const wxString
& name
)
967 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
969 m_insertInClientArea
= FALSE
;
971 m_frameToolBar
= wxFrameBase::CreateToolBar( style
, id
, name
);
974 GetChildren().DeleteObject( m_frameToolBar
);
976 m_insertInClientArea
= TRUE
;
980 return m_frameToolBar
;
983 void wxFrame::SetToolBar(wxToolBar
*toolbar
)
985 wxFrameBase::SetToolBar(toolbar
);
989 /* insert into toolbar area if not already there */
990 if ((m_frameToolBar
->m_widget
->parent
) &&
991 (m_frameToolBar
->m_widget
->parent
!= m_mainWidget
))
993 GetChildren().DeleteObject( m_frameToolBar
);
995 gtk_widget_reparent( m_frameToolBar
->m_widget
, m_mainWidget
);
1001 #endif // wxUSE_TOOLBAR
1005 wxStatusBar
* wxFrame::CreateStatusBar(int number
,
1008 const wxString
& name
)
1010 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
1012 // because it will change when toolbar is added
1015 return wxFrameBase::CreateStatusBar( number
, style
, id
, name
);
1018 void wxFrame::PositionStatusBar()
1020 if ( !m_frameStatusBar
)
1025 #endif // wxUSE_STATUSBAR
1027 // ----------------------------------------------------------------------------
1029 // ----------------------------------------------------------------------------
1031 void wxFrame::SetTitle( const wxString
&title
)
1033 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
1036 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
1039 void wxFrame::SetIcon( const wxIcon
&icon
)
1041 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
1043 wxFrameBase::SetIcon(icon
);
1048 if (!m_widget
->window
)
1051 wxMask
*mask
= icon
.GetMask();
1052 GdkBitmap
*bm
= (GdkBitmap
*) NULL
;
1053 if (mask
) bm
= mask
->GetBitmap();
1055 gdk_window_set_icon( m_widget
->window
, (GdkWindow
*) NULL
, icon
.GetPixmap(), bm
);
1058 // ----------------------------------------------------------------------------
1059 // frame state: maximized/iconized/normal (TODO)
1060 // ----------------------------------------------------------------------------
1062 void wxFrame::Maximize(bool WXUNUSED(maximize
))
1066 bool wxFrame::IsMaximized() const
1071 void wxFrame::Restore()
1075 void wxFrame::Iconize( bool iconize
)
1079 XIconifyWindow( GDK_WINDOW_XDISPLAY( m_widget
->window
),
1080 GDK_WINDOW_XWINDOW( m_widget
->window
),
1081 DefaultScreen( GDK_DISPLAY() ) );
1085 bool wxFrame::IsIconized() const