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 /* all this is for Motif Window Manager "hints" and is supposed to be
257 recognized by other WM as well. not tested. */
258 long decor
= (long) GDK_DECOR_BORDER
;
259 long func
= (long) GDK_FUNC_MOVE
;
261 if ((win
->GetWindowStyle() & wxCAPTION
) != 0)
262 decor
|= GDK_DECOR_TITLE
;
263 if ((win
->GetWindowStyle() & wxSYSTEM_MENU
) != 0)
265 decor
|= GDK_DECOR_MENU
;
266 func
|= GDK_FUNC_CLOSE
;
268 if ((win
->GetWindowStyle() & wxMINIMIZE_BOX
) != 0)
270 func
|= GDK_FUNC_MINIMIZE
;
271 decor
|= GDK_DECOR_MINIMIZE
;
273 if ((win
->GetWindowStyle() & wxMAXIMIZE_BOX
) != 0)
275 func
|= GDK_FUNC_MAXIMIZE
;
276 decor
|= GDK_DECOR_MAXIMIZE
;
278 if ((win
->GetWindowStyle() & wxRESIZE_BORDER
) != 0)
280 func
|= GDK_FUNC_RESIZE
;
281 decor
|= GDK_DECOR_RESIZEH
;
284 gdk_window_set_decorations( win
->m_widget
->window
, (GdkWMDecoration
)decor
);
285 gdk_window_set_functions( win
->m_widget
->window
, (GdkWMFunction
)func
);
287 /* GTK's shrinking/growing policy */
288 if ((win
->GetWindowStyle() & wxRESIZE_BORDER
) == 0)
289 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 0, 0, 1);
291 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 1, 1, 1);
294 gint flag
= 0; // GDK_HINT_POS;
295 if ((win
->GetMinWidth() != -1) || (win
->GetMinHeight() != -1)) flag
|= GDK_HINT_MIN_SIZE
;
296 if ((win
->GetMaxWidth() != -1) || (win
->GetMaxHeight() != -1)) flag
|= GDK_HINT_MAX_SIZE
;
299 gdk_window_set_hints( win
->m_widget
->window
,
301 win
->GetMinWidth(), win
->GetMinHeight(),
302 win
->GetMaxWidth(), win
->GetMaxHeight(),
307 wxIcon iconOld
= win
->GetIcon();
308 if ( iconOld
!= wxNullIcon
)
310 wxIcon
icon( iconOld
);
311 win
->SetIcon( wxNullIcon
);
312 win
->SetIcon( icon
);
315 /* we set the focus to the child that accepts the focus. this
316 doesn't really have to be done in "realize" but why not? */
317 wxWindowList::Node
*node
= win
->GetChildren().GetFirst();
320 wxWindow
*child
= node
->GetData();
321 if (child
->AcceptsFocus())
327 node
= node
->GetNext();
333 // ----------------------------------------------------------------------------
335 // ----------------------------------------------------------------------------
337 //-----------------------------------------------------------------------------
338 // InsertChild for wxFrame
339 //-----------------------------------------------------------------------------
341 /* Callback for wxFrame. This very strange beast has to be used because
342 * C++ has no virtual methods in a constructor. We have to emulate a
343 * virtual function here as wxWindows requires different ways to insert
344 * a child in container classes. */
346 static void wxInsertChildInFrame( wxFrame
* parent
, wxWindow
* child
)
348 wxASSERT( GTK_IS_WIDGET(child
->m_widget
) );
350 if (!parent
->m_insertInClientArea
)
352 /* these are outside the client area */
353 wxFrame
* frame
= (wxFrame
*) parent
;
354 gtk_pizza_put( GTK_PIZZA(frame
->m_mainWidget
),
355 GTK_WIDGET(child
->m_widget
),
361 #if wxUSE_TOOLBAR_NATIVE
362 /* we connect to these events for recalculating the client area
363 space when the toolbar is floating */
364 if (wxIS_KIND_OF(child
,wxToolBar
))
366 wxToolBar
*toolBar
= (wxToolBar
*) child
;
367 if (toolBar
->GetWindowStyle() & wxTB_DOCKABLE
)
369 gtk_signal_connect( GTK_OBJECT(toolBar
->m_widget
), "child_attached",
370 GTK_SIGNAL_FUNC(gtk_toolbar_attached_callback
), (gpointer
)parent
);
372 gtk_signal_connect( GTK_OBJECT(toolBar
->m_widget
), "child_detached",
373 GTK_SIGNAL_FUNC(gtk_toolbar_detached_callback
), (gpointer
)parent
);
376 #endif // wxUSE_TOOLBAR
380 /* these are inside the client area */
381 gtk_pizza_put( GTK_PIZZA(parent
->m_wxwindow
),
382 GTK_WIDGET(child
->m_widget
),
389 /* resize on OnInternalIdle */
390 parent
->GtkUpdateSize();
393 // ----------------------------------------------------------------------------
395 // ----------------------------------------------------------------------------
402 m_mainWidget
= (GtkWidget
*) NULL
;
403 m_menuBarDetached
= FALSE
;
404 m_toolBarDetached
= FALSE
;
405 m_insertInClientArea
= TRUE
;
409 bool wxFrame::Create( wxWindow
*parent
,
411 const wxString
&title
,
415 const wxString
&name
)
417 wxTopLevelWindows
.Append( this );
419 m_needParent
= FALSE
;
422 if (!PreCreation( parent
, pos
, size
) ||
423 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
425 wxFAIL_MSG( wxT("wxFrame creation failed") );
431 m_insertCallback
= (wxInsertChildFunction
) wxInsertChildInFrame
;
433 GtkWindowType win_type
= GTK_WINDOW_TOPLEVEL
;
434 if (style
& wxSIMPLE_BORDER
) win_type
= GTK_WINDOW_POPUP
;
436 m_widget
= gtk_window_new( win_type
);
439 gtk_window_set_wmclass( GTK_WINDOW(m_widget
), name
.mb_str(), name
.mb_str() );
442 debug_focus_in( m_widget
, wxT("wxFrame::m_widget"), name
);
445 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
446 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
448 gtk_signal_connect( GTK_OBJECT(m_widget
), "delete_event",
449 GTK_SIGNAL_FUNC(gtk_frame_delete_callback
), (gpointer
)this );
451 /* m_mainWidget holds the toolbar, the menubar and the client area */
452 m_mainWidget
= gtk_pizza_new();
453 gtk_widget_show( m_mainWidget
);
454 GTK_WIDGET_UNSET_FLAGS( m_mainWidget
, GTK_CAN_FOCUS
);
455 gtk_container_add( GTK_CONTAINER(m_widget
), m_mainWidget
);
458 debug_focus_in( m_mainWidget
, wxT("wxFrame::m_mainWidget"), name
);
461 /* m_wxwindow only represents the client area without toolbar and menubar */
462 m_wxwindow
= gtk_pizza_new();
463 gtk_widget_show( m_wxwindow
);
464 gtk_container_add( GTK_CONTAINER(m_mainWidget
), m_wxwindow
);
467 debug_focus_in( m_wxwindow
, wxT("wxFrame::m_wxwindow"), name
);
470 /* we donm't allow the frame to get the focus as otherwise
471 the frame will grabit at arbitrary fcous changes. */
472 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
474 if (m_parent
) m_parent
->AddChild( this );
476 /* the user resized the frame by dragging etc. */
477 gtk_signal_connect( GTK_OBJECT(m_widget
), "size_allocate",
478 GTK_SIGNAL_FUNC(gtk_frame_size_callback
), (gpointer
)this );
482 /* we cannot set MWM hints and icons before the widget has
483 been realized, so we do this directly after realization */
484 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
485 GTK_SIGNAL_FUNC(gtk_frame_realized_callback
), (gpointer
) this );
487 /* the only way to get the window size is to connect to this event */
488 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
489 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
491 /* disable native tab traversal */
492 gtk_signal_connect( GTK_OBJECT(m_widget
), "focus",
493 GTK_SIGNAL_FUNC(gtk_frame_focus_callback
), (gpointer
)this );
500 m_isBeingDeleted
= TRUE
;
504 wxTopLevelWindows
.DeleteObject( this );
506 if (wxTheApp
->GetTopWindow() == this)
507 wxTheApp
->SetTopWindow( (wxWindow
*) NULL
);
509 if ((wxTopLevelWindows
.Number() == 0) &&
510 (wxTheApp
->GetExitOnFrameDelete()))
512 wxTheApp
->ExitMainLoop();
516 // ----------------------------------------------------------------------------
517 // overridden wxWindow methods
518 // ----------------------------------------------------------------------------
520 bool wxFrame::Show( bool show
)
522 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
524 if (show
&& !m_sizeSet
)
526 /* by calling GtkOnSize here, we don't have to call
527 either after showing the frame, which would entail
528 much ugly flicker or from within the size_allocate
529 handler, because GTK 1.1.X forbids that. */
531 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
534 return wxWindow::Show( show
);
537 void wxFrame::DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
), int WXUNUSED(width
), int WXUNUSED(height
) )
539 wxFAIL_MSG( wxT("DoMoveWindow called for wxFrame") );
542 void wxFrame::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
544 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
546 /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
547 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
549 /* avoid recursions */
557 int old_width
= m_width
;
558 int old_height
= m_height
;
560 if ((sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) == 0)
562 if (x
!= -1) m_x
= x
;
563 if (y
!= -1) m_y
= y
;
564 if (width
!= -1) m_width
= width
;
565 if (height
!= -1) m_height
= height
;
576 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
578 if (width == -1) m_width = 80;
581 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
583 if (height == -1) m_height = 26;
587 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
588 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
589 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
590 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
592 if ((m_x
!= -1) || (m_y
!= -1))
594 if ((m_x
!= old_x
) || (m_y
!= old_y
))
596 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
600 if ((m_width
!= old_width
) || (m_height
!= old_height
))
602 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
603 done either directly before the frame is shown or in idle time
604 so that different calls to SetSize() don't lead to flicker. */
611 void wxFrame::DoGetClientSize( int *width
, int *height
) const
613 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
615 wxWindow::DoGetClientSize( width
, height
);
621 if (!m_menuBarDetached
)
622 (*height
) -= wxMENU_HEIGHT
;
624 (*height
) -= wxPLACE_HOLDER
;
629 if (m_frameStatusBar
) (*height
) -= wxSTATUS_HEIGHT
;
630 #endif // wxUSE_STATUSBAR
636 if (m_toolBarDetached
)
638 *height
-= wxPLACE_HOLDER
;
643 m_frameToolBar
->GetSize( &x
, &y
);
644 if ( m_frameToolBar
->GetWindowStyle() & wxTB_VERTICAL
)
654 #endif // wxUSE_TOOLBAR
657 *height
-= m_miniEdge
*2 + m_miniTitle
;
661 *width
-= m_miniEdge
*2;
665 void wxFrame::DoSetClientSize( int width
, int height
)
667 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
672 if (!m_menuBarDetached
)
673 height
+= wxMENU_HEIGHT
;
675 height
+= wxPLACE_HOLDER
;
680 if (m_frameStatusBar
) height
+= wxSTATUS_HEIGHT
;
687 if (m_toolBarDetached
)
689 height
+= wxPLACE_HOLDER
;
694 m_frameToolBar
->GetSize( &x
, &y
);
695 if ( m_frameToolBar
->GetWindowStyle() & wxTB_VERTICAL
)
707 DoSetSize( -1, -1, width
+ m_miniEdge
*2, height
+ m_miniEdge
*2 + m_miniTitle
, 0 );
710 void wxFrame::GtkOnSize( int WXUNUSED(x
), int WXUNUSED(y
),
711 int width
, int height
)
713 // due to a bug in gtk, x,y are always 0
717 /* avoid recursions */
718 if (m_resizing
) return;
721 /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
722 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
727 /* space occupied by m_frameToolBar and m_frameMenuBar */
728 int client_area_x_offset
= 0,
729 client_area_y_offset
= 0;
731 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
732 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
733 set in wxFrame::Create so it is used to check what kind of frame we
734 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
735 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
736 importantly) m_mainWidget */
740 /* check if size is in legal range */
741 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
742 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
743 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
744 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
746 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
747 * menubar, the toolbar and the client area, which is represented by
749 * this hurts in the eye, but I don't want to call SetSize()
750 * because I don't want to call any non-native functions here. */
755 int yy
= m_miniEdge
+ m_miniTitle
;
756 int ww
= m_width
- 2*m_miniEdge
;
757 int hh
= wxMENU_HEIGHT
;
758 if (m_menuBarDetached
) hh
= wxPLACE_HOLDER
;
759 m_frameMenuBar
->m_x
= xx
;
760 m_frameMenuBar
->m_y
= yy
;
761 m_frameMenuBar
->m_width
= ww
;
762 m_frameMenuBar
->m_height
= hh
;
763 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
764 m_frameMenuBar
->m_widget
,
766 client_area_y_offset
+= hh
;
770 if ((m_frameToolBar
) &&
771 (m_frameToolBar
->m_widget
->parent
== m_mainWidget
))
774 int yy
= m_miniEdge
+ m_miniTitle
;
777 if (!m_menuBarDetached
)
780 yy
+= wxPLACE_HOLDER
;
783 m_frameToolBar
->m_x
= xx
;
784 m_frameToolBar
->m_y
= yy
;
786 /* don't change the toolbar's reported height/width */
788 if ( m_frameToolBar
->GetWindowStyle() & wxTB_VERTICAL
)
790 ww
= m_toolBarDetached
? wxPLACE_HOLDER
791 : m_frameToolBar
->m_width
;
792 hh
= m_height
- 2*m_miniEdge
;
794 client_area_x_offset
+= ww
;
798 ww
= m_width
- 2*m_miniEdge
;
799 hh
= m_toolBarDetached
? wxPLACE_HOLDER
800 : m_frameToolBar
->m_height
;
802 client_area_y_offset
+= hh
;
805 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
806 m_frameToolBar
->m_widget
,
809 #endif // wxUSE_TOOLBAR
811 int client_x
= client_area_x_offset
+ m_miniEdge
;
812 int client_y
= client_area_y_offset
+ m_miniEdge
+ m_miniTitle
;
813 int client_w
= m_width
- client_area_x_offset
- 2*m_miniEdge
;
814 int client_h
= m_height
- client_area_y_offset
- 2*m_miniEdge
- m_miniTitle
;
815 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
817 client_x
, client_y
, client_w
, client_h
);
821 /* if there is no m_mainWidget between m_widget and m_wxwindow there
822 is no need to set the size or position of m_wxwindow. */
826 if (m_frameStatusBar
)
828 int xx
= 0 + m_miniEdge
;
829 int yy
= m_height
- wxSTATUS_HEIGHT
- m_miniEdge
- client_area_y_offset
;
830 int ww
= m_width
- 2*m_miniEdge
;
831 int hh
= wxSTATUS_HEIGHT
;
832 m_frameStatusBar
->m_x
= xx
;
833 m_frameStatusBar
->m_y
= yy
;
834 m_frameStatusBar
->m_width
= ww
;
835 m_frameStatusBar
->m_height
= hh
;
836 gtk_pizza_set_size( GTK_PIZZA(m_wxwindow
),
837 m_frameStatusBar
->m_widget
,
839 gtk_widget_draw( m_frameStatusBar
->m_widget
, (GdkRectangle
*) NULL
);
843 /* we actually set the size of a frame here and no-where else */
844 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
848 // send size event to frame
849 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
850 event
.SetEventObject( this );
851 GetEventHandler()->ProcessEvent( event
);
853 // send size event to status bar
854 if (m_frameStatusBar
)
856 wxSizeEvent
event2( wxSize(m_frameStatusBar
->m_width
,m_frameStatusBar
->m_height
), m_frameStatusBar
->GetId() );
857 event2
.SetEventObject( m_frameStatusBar
);
858 m_frameStatusBar
->GetEventHandler()->ProcessEvent( event2
);
864 void wxFrame::MakeModal( bool modal
)
867 gtk_grab_add( m_widget
);
869 gtk_grab_remove( m_widget
);
872 void wxFrame::OnInternalIdle()
874 if (!m_sizeSet
&& GTK_WIDGET_REALIZED(m_wxwindow
))
876 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
878 // we'll come back later
880 wxapp_install_idle_handler();
884 if (m_frameMenuBar
) m_frameMenuBar
->OnInternalIdle();
886 if (m_frameToolBar
) m_frameToolBar
->OnInternalIdle();
889 if (m_frameStatusBar
) m_frameStatusBar
->OnInternalIdle();
892 wxWindow::OnInternalIdle();
895 // ----------------------------------------------------------------------------
896 // menu/tool/status bar stuff
897 // ----------------------------------------------------------------------------
899 void wxFrame::SetMenuBar( wxMenuBar
*menuBar
)
901 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
902 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
904 if (menuBar
== m_frameMenuBar
)
909 m_frameMenuBar
->UnsetInvokingWindow( this );
911 if (m_frameMenuBar
->GetWindowStyle() & wxMB_DOCKABLE
)
913 gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar
->m_widget
),
914 GTK_SIGNAL_FUNC(gtk_menu_attached_callback
), (gpointer
)this );
916 gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar
->m_widget
),
917 GTK_SIGNAL_FUNC(gtk_menu_detached_callback
), (gpointer
)this );
920 gtk_container_remove( GTK_CONTAINER(m_mainWidget
), m_frameMenuBar
->m_widget
);
921 gtk_widget_ref( m_frameMenuBar
->m_widget
);
922 gtk_widget_unparent( m_frameMenuBar
->m_widget
);
925 m_frameMenuBar
= menuBar
;
929 m_frameMenuBar
->SetInvokingWindow( this );
931 m_frameMenuBar
->SetParent(this);
932 gtk_pizza_put( GTK_PIZZA(m_mainWidget
),
933 m_frameMenuBar
->m_widget
,
936 m_frameMenuBar
->m_width
,
937 m_frameMenuBar
->m_height
);
939 if (menuBar
->GetWindowStyle() & wxMB_DOCKABLE
)
941 gtk_signal_connect( GTK_OBJECT(menuBar
->m_widget
), "child_attached",
942 GTK_SIGNAL_FUNC(gtk_menu_attached_callback
), (gpointer
)this );
944 gtk_signal_connect( GTK_OBJECT(menuBar
->m_widget
), "child_detached",
945 GTK_SIGNAL_FUNC(gtk_menu_detached_callback
), (gpointer
)this );
948 m_frameMenuBar
->Show( TRUE
);
951 /* resize window in OnInternalIdle */
956 wxToolBar
* wxFrame::CreateToolBar( long style
, wxWindowID id
, const wxString
& name
)
958 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
960 m_insertInClientArea
= FALSE
;
962 m_frameToolBar
= wxFrameBase::CreateToolBar( style
, id
, name
);
965 GetChildren().DeleteObject( m_frameToolBar
);
967 m_insertInClientArea
= TRUE
;
971 return m_frameToolBar
;
974 void wxFrame::SetToolBar(wxToolBar
*toolbar
)
976 wxFrameBase::SetToolBar(toolbar
);
980 /* insert into toolbar area if not already there */
981 if ((m_frameToolBar
->m_widget
->parent
) &&
982 (m_frameToolBar
->m_widget
->parent
!= m_mainWidget
))
984 GetChildren().DeleteObject( m_frameToolBar
);
986 gtk_widget_reparent( m_frameToolBar
->m_widget
, m_mainWidget
);
992 #endif // wxUSE_TOOLBAR
996 wxStatusBar
* wxFrame::CreateStatusBar(int number
,
999 const wxString
& name
)
1001 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
1003 // because it will change when toolbar is added
1006 return wxFrameBase::CreateStatusBar( number
, style
, id
, name
);
1009 void wxFrame::PositionStatusBar()
1011 if ( !m_frameStatusBar
)
1016 #endif // wxUSE_STATUSBAR
1018 // ----------------------------------------------------------------------------
1020 // ----------------------------------------------------------------------------
1022 void wxFrame::SetTitle( const wxString
&title
)
1024 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
1027 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
1030 void wxFrame::SetIcon( const wxIcon
&icon
)
1032 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
1034 wxFrameBase::SetIcon(icon
);
1039 if (!m_widget
->window
)
1042 wxMask
*mask
= icon
.GetMask();
1043 GdkBitmap
*bm
= (GdkBitmap
*) NULL
;
1044 if (mask
) bm
= mask
->GetBitmap();
1046 gdk_window_set_icon( m_widget
->window
, (GdkWindow
*) NULL
, icon
.GetPixmap(), bm
);
1049 // ----------------------------------------------------------------------------
1050 // frame state: maximized/iconized/normal (TODO)
1051 // ----------------------------------------------------------------------------
1053 void wxFrame::Maximize(bool WXUNUSED(maximize
))
1057 bool wxFrame::IsMaximized() const
1062 void wxFrame::Restore()
1066 void wxFrame::Iconize( bool iconize
)
1070 XIconifyWindow( GDK_WINDOW_XDISPLAY( m_widget
->window
),
1071 GDK_WINDOW_XWINDOW( m_widget
->window
),
1072 DefaultScreen( GDK_DISPLAY() ) );
1076 bool wxFrame::IsIconized() const