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
* WXUNUSED(widget
), wxFrame
*win
)
249 wxapp_install_idle_handler();
251 if ((win
->m_miniEdge
> 0) || (win
->HasFlag(wxSIMPLE_BORDER
)))
253 /* This is a mini-frame or a borderless frame. */
254 gdk_window_set_decorations( win
->m_widget
->window
, (GdkWMDecoration
)0 );
255 gdk_window_set_functions( win
->m_widget
->window
, (GdkWMFunction
)0 );
259 /* All this is for Motif Window Manager "hints" and is supposed to be
260 recognized by other WM as well. Not tested. */
261 long decor
= (long) GDK_DECOR_BORDER
;
262 long func
= (long) GDK_FUNC_MOVE
;
264 if ((win
->GetWindowStyle() & wxCAPTION
) != 0)
265 decor
|= GDK_DECOR_TITLE
;
266 if ((win
->GetWindowStyle() & wxSYSTEM_MENU
) != 0)
268 decor
|= GDK_DECOR_MENU
;
269 func
|= GDK_FUNC_CLOSE
;
271 if ((win
->GetWindowStyle() & wxMINIMIZE_BOX
) != 0)
273 func
|= GDK_FUNC_MINIMIZE
;
274 decor
|= GDK_DECOR_MINIMIZE
;
276 if ((win
->GetWindowStyle() & wxMAXIMIZE_BOX
) != 0)
278 func
|= GDK_FUNC_MAXIMIZE
;
279 decor
|= GDK_DECOR_MAXIMIZE
;
281 if ((win
->GetWindowStyle() & wxRESIZE_BORDER
) != 0)
283 func
|= GDK_FUNC_RESIZE
;
284 decor
|= GDK_DECOR_RESIZEH
;
287 gdk_window_set_decorations( win
->m_widget
->window
, (GdkWMDecoration
)decor
);
288 gdk_window_set_functions( win
->m_widget
->window
, (GdkWMFunction
)func
);
291 /* GTK's shrinking/growing policy */
292 if ((win
->GetWindowStyle() & wxRESIZE_BORDER
) == 0)
293 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 0, 0, 1);
295 gtk_window_set_policy(GTK_WINDOW(win
->m_widget
), 1, 1, 1);
298 wxIcon iconOld
= win
->GetIcon();
299 if ( iconOld
!= wxNullIcon
)
301 wxIcon
icon( iconOld
);
302 win
->SetIcon( wxNullIcon
);
303 win
->SetIcon( icon
);
306 /* we set the focus to the child that accepts the focus. this
307 doesn't really have to be done in "realize" but why not? */
308 wxWindowList::Node
*node
= win
->GetChildren().GetFirst();
311 wxWindow
*child
= node
->GetData();
312 if (child
->AcceptsFocus())
318 node
= node
->GetNext();
324 // ----------------------------------------------------------------------------
326 // ----------------------------------------------------------------------------
328 //-----------------------------------------------------------------------------
329 // InsertChild for wxFrame
330 //-----------------------------------------------------------------------------
332 /* Callback for wxFrame. This very strange beast has to be used because
333 * C++ has no virtual methods in a constructor. We have to emulate a
334 * virtual function here as wxWindows requires different ways to insert
335 * a child in container classes. */
337 static void wxInsertChildInFrame( wxFrame
* parent
, wxWindow
* child
)
339 wxASSERT( GTK_IS_WIDGET(child
->m_widget
) );
341 if (!parent
->m_insertInClientArea
)
343 /* these are outside the client area */
344 wxFrame
* frame
= (wxFrame
*) parent
;
345 gtk_pizza_put( GTK_PIZZA(frame
->m_mainWidget
),
346 GTK_WIDGET(child
->m_widget
),
352 #if wxUSE_TOOLBAR_NATIVE
353 /* we connect to these events for recalculating the client area
354 space when the toolbar is floating */
355 if (wxIS_KIND_OF(child
,wxToolBar
))
357 wxToolBar
*toolBar
= (wxToolBar
*) child
;
358 if (toolBar
->GetWindowStyle() & wxTB_DOCKABLE
)
360 gtk_signal_connect( GTK_OBJECT(toolBar
->m_widget
), "child_attached",
361 GTK_SIGNAL_FUNC(gtk_toolbar_attached_callback
), (gpointer
)parent
);
363 gtk_signal_connect( GTK_OBJECT(toolBar
->m_widget
), "child_detached",
364 GTK_SIGNAL_FUNC(gtk_toolbar_detached_callback
), (gpointer
)parent
);
367 #endif // wxUSE_TOOLBAR
371 /* these are inside the client area */
372 gtk_pizza_put( GTK_PIZZA(parent
->m_wxwindow
),
373 GTK_WIDGET(child
->m_widget
),
380 /* resize on OnInternalIdle */
381 parent
->GtkUpdateSize();
384 // ----------------------------------------------------------------------------
386 // ----------------------------------------------------------------------------
393 m_mainWidget
= (GtkWidget
*) NULL
;
394 m_menuBarDetached
= FALSE
;
395 m_toolBarDetached
= FALSE
;
396 m_insertInClientArea
= TRUE
;
399 bool wxFrame::Create( wxWindow
*parent
,
401 const wxString
&title
,
405 const wxString
&name
)
407 wxTopLevelWindows
.Append( this );
409 m_needParent
= FALSE
;
411 if (!PreCreation( parent
, pos
, size
) ||
412 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
414 wxFAIL_MSG( wxT("wxFrame creation failed") );
420 m_insertCallback
= (wxInsertChildFunction
) wxInsertChildInFrame
;
422 GtkWindowType win_type
= GTK_WINDOW_TOPLEVEL
;
424 m_widget
= gtk_window_new( win_type
);
426 if ((m_parent
) && (HasFlag(wxFRAME_FLOAT_ON_PARENT
)) && (GTK_IS_WINDOW(m_parent
->m_widget
)))
427 gtk_window_set_transient_for( GTK_WINDOW(m_widget
), GTK_WINDOW(m_parent
->m_widget
) );
430 gtk_window_set_wmclass( GTK_WINDOW(m_widget
), name
.mb_str(), name
.mb_str() );
433 debug_focus_in( m_widget
, wxT("wxFrame::m_widget"), name
);
436 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
437 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
439 gtk_signal_connect( GTK_OBJECT(m_widget
), "delete_event",
440 GTK_SIGNAL_FUNC(gtk_frame_delete_callback
), (gpointer
)this );
442 /* m_mainWidget holds the toolbar, the menubar and the client area */
443 m_mainWidget
= gtk_pizza_new();
444 gtk_widget_show( m_mainWidget
);
445 GTK_WIDGET_UNSET_FLAGS( m_mainWidget
, GTK_CAN_FOCUS
);
446 gtk_container_add( GTK_CONTAINER(m_widget
), m_mainWidget
);
449 debug_focus_in( m_mainWidget
, wxT("wxFrame::m_mainWidget"), name
);
452 /* m_wxwindow only represents the client area without toolbar and menubar */
453 m_wxwindow
= gtk_pizza_new();
454 gtk_widget_show( m_wxwindow
);
455 gtk_container_add( GTK_CONTAINER(m_mainWidget
), m_wxwindow
);
458 debug_focus_in( m_wxwindow
, wxT("wxFrame::m_wxwindow"), name
);
461 /* we donm't allow the frame to get the focus as otherwise
462 the frame will grabit at arbitrary fcous changes. */
463 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
465 if (m_parent
) m_parent
->AddChild( this );
467 /* the user resized the frame by dragging etc. */
468 gtk_signal_connect( GTK_OBJECT(m_widget
), "size_allocate",
469 GTK_SIGNAL_FUNC(gtk_frame_size_callback
), (gpointer
)this );
473 if ((m_x
!= -1) || (m_y
!= -1))
474 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
475 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
477 /* we cannot set MWM hints and icons before the widget has
478 been realized, so we do this directly after realization */
479 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
480 GTK_SIGNAL_FUNC(gtk_frame_realized_callback
), (gpointer
) this );
482 /* the only way to get the window size is to connect to this event */
483 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
484 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
486 /* disable native tab traversal */
487 gtk_signal_connect( GTK_OBJECT(m_widget
), "focus",
488 GTK_SIGNAL_FUNC(gtk_frame_focus_callback
), (gpointer
)this );
495 m_isBeingDeleted
= TRUE
;
499 wxTopLevelWindows
.DeleteObject( this );
501 if (wxTheApp
->GetTopWindow() == this)
502 wxTheApp
->SetTopWindow( (wxWindow
*) NULL
);
504 if ((wxTopLevelWindows
.Number() == 0) &&
505 (wxTheApp
->GetExitOnFrameDelete()))
507 wxTheApp
->ExitMainLoop();
511 // ----------------------------------------------------------------------------
512 // overridden wxWindow methods
513 // ----------------------------------------------------------------------------
515 bool wxFrame::Show( bool show
)
517 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
519 if (show
&& !m_sizeSet
)
521 /* by calling GtkOnSize here, we don't have to call
522 either after showing the frame, which would entail
523 much ugly flicker or from within the size_allocate
524 handler, because GTK 1.1.X forbids that. */
526 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
529 return wxWindow::Show( show
);
532 void wxFrame::DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
), int WXUNUSED(width
), int WXUNUSED(height
) )
534 wxFAIL_MSG( wxT("DoMoveWindow called for wxFrame") );
537 void wxFrame::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
539 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
541 /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
542 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
544 /* avoid recursions */
552 int old_width
= m_width
;
553 int old_height
= m_height
;
555 if ((sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) == 0)
557 if (x
!= -1) m_x
= x
;
558 if (y
!= -1) m_y
= y
;
559 if (width
!= -1) m_width
= width
;
560 if (height
!= -1) m_height
= height
;
571 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
573 if (width == -1) m_width = 80;
576 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
578 if (height == -1) m_height = 26;
582 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
583 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
584 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
585 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
587 if ((m_x
!= -1) || (m_y
!= -1))
589 if ((m_x
!= old_x
) || (m_y
!= old_y
))
591 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
595 if ((m_width
!= old_width
) || (m_height
!= old_height
))
597 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
599 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
600 done either directly before the frame is shown or in idle time
601 so that different calls to SetSize() don't lead to flicker. */
608 void wxFrame::DoGetClientSize( int *width
, int *height
) const
610 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
612 wxWindow::DoGetClientSize( width
, height
);
618 if (!m_menuBarDetached
)
619 (*height
) -= wxMENU_HEIGHT
;
621 (*height
) -= wxPLACE_HOLDER
;
626 if (m_frameStatusBar
) (*height
) -= wxSTATUS_HEIGHT
;
627 #endif // wxUSE_STATUSBAR
633 if (m_toolBarDetached
)
635 *height
-= wxPLACE_HOLDER
;
640 m_frameToolBar
->GetSize( &x
, &y
);
641 if ( m_frameToolBar
->GetWindowStyle() & wxTB_VERTICAL
)
651 #endif // wxUSE_TOOLBAR
654 *height
-= m_miniEdge
*2 + m_miniTitle
;
658 *width
-= m_miniEdge
*2;
662 void wxFrame::DoSetClientSize( int width
, int height
)
664 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
669 if (!m_menuBarDetached
)
670 height
+= wxMENU_HEIGHT
;
672 height
+= wxPLACE_HOLDER
;
677 if (m_frameStatusBar
) height
+= wxSTATUS_HEIGHT
;
684 if (m_toolBarDetached
)
686 height
+= wxPLACE_HOLDER
;
691 m_frameToolBar
->GetSize( &x
, &y
);
692 if ( m_frameToolBar
->GetWindowStyle() & wxTB_VERTICAL
)
704 DoSetSize( -1, -1, width
+ m_miniEdge
*2, height
+ m_miniEdge
*2 + m_miniTitle
, 0 );
707 void wxFrame::GtkOnSize( int WXUNUSED(x
), int WXUNUSED(y
),
708 int width
, int height
)
710 // due to a bug in gtk, x,y are always 0
714 /* avoid recursions */
715 if (m_resizing
) return;
718 /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
719 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
724 /* space occupied by m_frameToolBar and m_frameMenuBar */
725 int client_area_x_offset
= 0,
726 client_area_y_offset
= 0;
728 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
729 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
730 set in wxFrame::Create so it is used to check what kind of frame we
731 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
732 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
733 importantly) m_mainWidget */
735 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
736 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
737 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
738 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
743 gint flag
= 0; // GDK_HINT_POS;
744 if ((m_minWidth
!= -1) || (m_minHeight
!= -1)) flag
|= GDK_HINT_MIN_SIZE
;
745 if ((m_maxWidth
!= -1) || (m_maxHeight
!= -1)) flag
|= GDK_HINT_MAX_SIZE
;
747 geom
.min_width
= m_minWidth
;
748 geom
.min_height
= m_minHeight
;
749 geom
.max_width
= m_maxWidth
;
750 geom
.max_height
= m_maxHeight
;
751 gtk_window_set_geometry_hints( GTK_WINDOW(m_widget
),
754 (GdkWindowHints
) flag
);
756 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
757 * menubar, the toolbar and the client area, which is represented by
759 * this hurts in the eye, but I don't want to call SetSize()
760 * because I don't want to call any non-native functions here. */
765 int yy
= m_miniEdge
+ m_miniTitle
;
766 int ww
= m_width
- 2*m_miniEdge
;
767 int hh
= wxMENU_HEIGHT
;
768 if (m_menuBarDetached
) hh
= wxPLACE_HOLDER
;
769 m_frameMenuBar
->m_x
= xx
;
770 m_frameMenuBar
->m_y
= yy
;
771 m_frameMenuBar
->m_width
= ww
;
772 m_frameMenuBar
->m_height
= hh
;
773 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
774 m_frameMenuBar
->m_widget
,
776 client_area_y_offset
+= hh
;
780 if ((m_frameToolBar
) &&
781 (m_frameToolBar
->m_widget
->parent
== m_mainWidget
))
784 int yy
= m_miniEdge
+ m_miniTitle
;
787 if (!m_menuBarDetached
)
790 yy
+= wxPLACE_HOLDER
;
793 m_frameToolBar
->m_x
= xx
;
794 m_frameToolBar
->m_y
= yy
;
796 /* don't change the toolbar's reported height/width */
798 if ( m_frameToolBar
->GetWindowStyle() & wxTB_VERTICAL
)
800 ww
= m_toolBarDetached
? wxPLACE_HOLDER
801 : m_frameToolBar
->m_width
;
802 hh
= m_height
- 2*m_miniEdge
;
804 client_area_x_offset
+= ww
;
808 ww
= m_width
- 2*m_miniEdge
;
809 hh
= m_toolBarDetached
? wxPLACE_HOLDER
810 : m_frameToolBar
->m_height
;
812 client_area_y_offset
+= hh
;
815 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
816 m_frameToolBar
->m_widget
,
819 #endif // wxUSE_TOOLBAR
821 int client_x
= client_area_x_offset
+ m_miniEdge
;
822 int client_y
= client_area_y_offset
+ m_miniEdge
+ m_miniTitle
;
823 int client_w
= m_width
- client_area_x_offset
- 2*m_miniEdge
;
824 int client_h
= m_height
- client_area_y_offset
- 2*m_miniEdge
- m_miniTitle
;
825 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
827 client_x
, client_y
, client_w
, client_h
);
831 /* if there is no m_mainWidget between m_widget and m_wxwindow there
832 is no need to set the size or position of m_wxwindow. */
836 if (m_frameStatusBar
)
838 int xx
= 0 + m_miniEdge
;
839 int yy
= m_height
- wxSTATUS_HEIGHT
- m_miniEdge
- client_area_y_offset
;
840 int ww
= m_width
- 2*m_miniEdge
;
841 int hh
= wxSTATUS_HEIGHT
;
842 m_frameStatusBar
->m_x
= xx
;
843 m_frameStatusBar
->m_y
= yy
;
844 m_frameStatusBar
->m_width
= ww
;
845 m_frameStatusBar
->m_height
= hh
;
846 gtk_pizza_set_size( GTK_PIZZA(m_wxwindow
),
847 m_frameStatusBar
->m_widget
,
849 gtk_widget_draw( m_frameStatusBar
->m_widget
, (GdkRectangle
*) NULL
);
855 // send size event to frame
856 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
857 event
.SetEventObject( this );
858 GetEventHandler()->ProcessEvent( event
);
860 // send size event to status bar
861 if (m_frameStatusBar
)
863 wxSizeEvent
event2( wxSize(m_frameStatusBar
->m_width
,m_frameStatusBar
->m_height
), m_frameStatusBar
->GetId() );
864 event2
.SetEventObject( m_frameStatusBar
);
865 m_frameStatusBar
->GetEventHandler()->ProcessEvent( event2
);
871 void wxFrame::MakeModal( bool modal
)
874 gtk_grab_add( m_widget
);
876 gtk_grab_remove( m_widget
);
879 void wxFrame::OnInternalIdle()
881 if (!m_sizeSet
&& GTK_WIDGET_REALIZED(m_wxwindow
))
883 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
885 // we'll come back later
887 wxapp_install_idle_handler();
891 if (m_frameMenuBar
) m_frameMenuBar
->OnInternalIdle();
893 if (m_frameToolBar
) m_frameToolBar
->OnInternalIdle();
896 if (m_frameStatusBar
) m_frameStatusBar
->OnInternalIdle();
899 wxWindow::OnInternalIdle();
902 // ----------------------------------------------------------------------------
903 // menu/tool/status bar stuff
904 // ----------------------------------------------------------------------------
906 void wxFrame::SetMenuBar( wxMenuBar
*menuBar
)
908 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
909 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
911 if (menuBar
== m_frameMenuBar
)
916 m_frameMenuBar
->UnsetInvokingWindow( this );
918 if (m_frameMenuBar
->GetWindowStyle() & wxMB_DOCKABLE
)
920 gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar
->m_widget
),
921 GTK_SIGNAL_FUNC(gtk_menu_attached_callback
), (gpointer
)this );
923 gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar
->m_widget
),
924 GTK_SIGNAL_FUNC(gtk_menu_detached_callback
), (gpointer
)this );
927 gtk_container_remove( GTK_CONTAINER(m_mainWidget
), m_frameMenuBar
->m_widget
);
928 gtk_widget_ref( m_frameMenuBar
->m_widget
);
929 gtk_widget_unparent( m_frameMenuBar
->m_widget
);
932 m_frameMenuBar
= menuBar
;
936 m_frameMenuBar
->SetInvokingWindow( this );
938 m_frameMenuBar
->SetParent(this);
939 gtk_pizza_put( GTK_PIZZA(m_mainWidget
),
940 m_frameMenuBar
->m_widget
,
943 m_frameMenuBar
->m_width
,
944 m_frameMenuBar
->m_height
);
946 if (menuBar
->GetWindowStyle() & wxMB_DOCKABLE
)
948 gtk_signal_connect( GTK_OBJECT(menuBar
->m_widget
), "child_attached",
949 GTK_SIGNAL_FUNC(gtk_menu_attached_callback
), (gpointer
)this );
951 gtk_signal_connect( GTK_OBJECT(menuBar
->m_widget
), "child_detached",
952 GTK_SIGNAL_FUNC(gtk_menu_detached_callback
), (gpointer
)this );
955 m_frameMenuBar
->Show( TRUE
);
958 /* resize window in OnInternalIdle */
963 wxToolBar
* wxFrame::CreateToolBar( long style
, wxWindowID id
, const wxString
& name
)
965 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
967 m_insertInClientArea
= FALSE
;
969 m_frameToolBar
= wxFrameBase::CreateToolBar( style
, id
, name
);
971 m_insertInClientArea
= TRUE
;
975 return m_frameToolBar
;
978 void wxFrame::SetToolBar(wxToolBar
*toolbar
)
980 wxFrameBase::SetToolBar(toolbar
);
984 /* insert into toolbar area if not already there */
985 if ((m_frameToolBar
->m_widget
->parent
) &&
986 (m_frameToolBar
->m_widget
->parent
!= m_mainWidget
))
988 GetChildren().DeleteObject( m_frameToolBar
);
990 gtk_widget_reparent( m_frameToolBar
->m_widget
, m_mainWidget
);
996 #endif // wxUSE_TOOLBAR
1000 wxStatusBar
* wxFrame::CreateStatusBar(int number
,
1003 const wxString
& name
)
1005 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
1007 // because it will change when toolbar is added
1010 return wxFrameBase::CreateStatusBar( number
, style
, id
, name
);
1013 void wxFrame::PositionStatusBar()
1015 if ( !m_frameStatusBar
)
1020 #endif // wxUSE_STATUSBAR
1022 // ----------------------------------------------------------------------------
1024 // ----------------------------------------------------------------------------
1026 void wxFrame::SetTitle( const wxString
&title
)
1028 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
1031 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
1034 void wxFrame::SetIcon( const wxIcon
&icon
)
1036 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
1038 wxFrameBase::SetIcon(icon
);
1043 if (!m_widget
->window
)
1046 wxMask
*mask
= icon
.GetMask();
1047 GdkBitmap
*bm
= (GdkBitmap
*) NULL
;
1048 if (mask
) bm
= mask
->GetBitmap();
1050 gdk_window_set_icon( m_widget
->window
, (GdkWindow
*) NULL
, icon
.GetPixmap(), bm
);
1053 // ----------------------------------------------------------------------------
1054 // frame state: maximized/iconized/normal (TODO)
1055 // ----------------------------------------------------------------------------
1057 void wxFrame::Maximize(bool WXUNUSED(maximize
))
1061 bool wxFrame::IsMaximized() const
1066 void wxFrame::Restore()
1070 void wxFrame::Iconize( bool iconize
)
1074 XIconifyWindow( GDK_WINDOW_XDISPLAY( m_widget
->window
),
1075 GDK_WINDOW_XWINDOW( m_widget
->window
),
1076 DefaultScreen( GDK_DISPLAY() ) );
1080 bool wxFrame::IsIconized() const