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 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
;
400 bool wxFrame::Create( wxWindow
*parent
,
402 const wxString
&title
,
406 const wxString
&name
)
408 wxTopLevelWindows
.Append( this );
410 m_needParent
= FALSE
;
413 if (!PreCreation( parent
, pos
, size
) ||
414 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
416 wxFAIL_MSG( wxT("wxFrame creation failed") );
422 m_insertCallback
= (wxInsertChildFunction
) wxInsertChildInFrame
;
424 GtkWindowType win_type
= GTK_WINDOW_TOPLEVEL
;
426 m_widget
= gtk_window_new( win_type
);
428 if ((m_parent
) && (HasFlag(wxFRAME_FLOAT_ON_PARENT
)) && (GTK_IS_WINDOW(m_parent
->m_widget
)))
429 gtk_window_set_transient_for( GTK_WINDOW(m_widget
), GTK_WINDOW(m_parent
->m_widget
) );
432 gtk_window_set_wmclass( GTK_WINDOW(m_widget
), name
.mb_str(), name
.mb_str() );
435 debug_focus_in( m_widget
, wxT("wxFrame::m_widget"), name
);
438 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
439 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
441 gtk_signal_connect( GTK_OBJECT(m_widget
), "delete_event",
442 GTK_SIGNAL_FUNC(gtk_frame_delete_callback
), (gpointer
)this );
444 /* m_mainWidget holds the toolbar, the menubar and the client area */
445 m_mainWidget
= gtk_pizza_new();
446 gtk_widget_show( m_mainWidget
);
447 GTK_WIDGET_UNSET_FLAGS( m_mainWidget
, GTK_CAN_FOCUS
);
448 gtk_container_add( GTK_CONTAINER(m_widget
), m_mainWidget
);
451 debug_focus_in( m_mainWidget
, wxT("wxFrame::m_mainWidget"), name
);
454 /* m_wxwindow only represents the client area without toolbar and menubar */
455 m_wxwindow
= gtk_pizza_new();
456 gtk_widget_show( m_wxwindow
);
457 gtk_container_add( GTK_CONTAINER(m_mainWidget
), m_wxwindow
);
460 debug_focus_in( m_wxwindow
, wxT("wxFrame::m_wxwindow"), name
);
463 /* we donm't allow the frame to get the focus as otherwise
464 the frame will grabit at arbitrary fcous changes. */
465 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
467 if (m_parent
) m_parent
->AddChild( this );
469 /* the user resized the frame by dragging etc. */
470 gtk_signal_connect( GTK_OBJECT(m_widget
), "size_allocate",
471 GTK_SIGNAL_FUNC(gtk_frame_size_callback
), (gpointer
)this );
475 if ((m_x
!= -1) || (m_y
!= -1))
476 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
477 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
479 /* we cannot set MWM hints and icons before the widget has
480 been realized, so we do this directly after realization */
481 gtk_signal_connect( GTK_OBJECT(m_widget
), "realize",
482 GTK_SIGNAL_FUNC(gtk_frame_realized_callback
), (gpointer
) this );
484 /* the only way to get the window size is to connect to this event */
485 gtk_signal_connect( GTK_OBJECT(m_widget
), "configure_event",
486 GTK_SIGNAL_FUNC(gtk_frame_configure_callback
), (gpointer
)this );
488 /* disable native tab traversal */
489 gtk_signal_connect( GTK_OBJECT(m_widget
), "focus",
490 GTK_SIGNAL_FUNC(gtk_frame_focus_callback
), (gpointer
)this );
497 m_isBeingDeleted
= TRUE
;
501 wxTopLevelWindows
.DeleteObject( this );
503 if (wxTheApp
->GetTopWindow() == this)
504 wxTheApp
->SetTopWindow( (wxWindow
*) NULL
);
506 if ((wxTopLevelWindows
.Number() == 0) &&
507 (wxTheApp
->GetExitOnFrameDelete()))
509 wxTheApp
->ExitMainLoop();
513 // ----------------------------------------------------------------------------
514 // overridden wxWindow methods
515 // ----------------------------------------------------------------------------
517 bool wxFrame::Show( bool show
)
519 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
521 if (show
&& !m_sizeSet
)
523 /* by calling GtkOnSize here, we don't have to call
524 either after showing the frame, which would entail
525 much ugly flicker or from within the size_allocate
526 handler, because GTK 1.1.X forbids that. */
528 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
531 return wxWindow::Show( show
);
534 void wxFrame::DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
), int WXUNUSED(width
), int WXUNUSED(height
) )
536 wxFAIL_MSG( wxT("DoMoveWindow called for wxFrame") );
539 void wxFrame::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
541 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
543 /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
544 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
546 /* avoid recursions */
554 int old_width
= m_width
;
555 int old_height
= m_height
;
557 if ((sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) == 0)
559 if (x
!= -1) m_x
= x
;
560 if (y
!= -1) m_y
= y
;
561 if (width
!= -1) m_width
= width
;
562 if (height
!= -1) m_height
= height
;
573 if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
575 if (width == -1) m_width = 80;
578 if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
580 if (height == -1) m_height = 26;
584 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
585 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
586 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
587 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
589 if ((m_x
!= -1) || (m_y
!= -1))
591 if ((m_x
!= old_x
) || (m_y
!= old_y
))
593 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
597 if ((m_width
!= old_width
) || (m_height
!= old_height
))
599 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
601 /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
602 done either directly before the frame is shown or in idle time
603 so that different calls to SetSize() don't lead to flicker. */
610 void wxFrame::DoGetClientSize( int *width
, int *height
) const
612 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
614 wxWindow::DoGetClientSize( width
, height
);
620 if (!m_menuBarDetached
)
621 (*height
) -= wxMENU_HEIGHT
;
623 (*height
) -= wxPLACE_HOLDER
;
628 if (m_frameStatusBar
) (*height
) -= wxSTATUS_HEIGHT
;
629 #endif // wxUSE_STATUSBAR
635 if (m_toolBarDetached
)
637 *height
-= wxPLACE_HOLDER
;
642 m_frameToolBar
->GetSize( &x
, &y
);
643 if ( m_frameToolBar
->GetWindowStyle() & wxTB_VERTICAL
)
653 #endif // wxUSE_TOOLBAR
656 *height
-= m_miniEdge
*2 + m_miniTitle
;
660 *width
-= m_miniEdge
*2;
664 void wxFrame::DoSetClientSize( int width
, int height
)
666 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
671 if (!m_menuBarDetached
)
672 height
+= wxMENU_HEIGHT
;
674 height
+= wxPLACE_HOLDER
;
679 if (m_frameStatusBar
) height
+= wxSTATUS_HEIGHT
;
686 if (m_toolBarDetached
)
688 height
+= wxPLACE_HOLDER
;
693 m_frameToolBar
->GetSize( &x
, &y
);
694 if ( m_frameToolBar
->GetWindowStyle() & wxTB_VERTICAL
)
706 DoSetSize( -1, -1, width
+ m_miniEdge
*2, height
+ m_miniEdge
*2 + m_miniTitle
, 0 );
709 void wxFrame::GtkOnSize( int WXUNUSED(x
), int WXUNUSED(y
),
710 int width
, int height
)
712 // due to a bug in gtk, x,y are always 0
716 /* avoid recursions */
717 if (m_resizing
) return;
720 /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
721 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
726 /* space occupied by m_frameToolBar and m_frameMenuBar */
727 int client_area_x_offset
= 0,
728 client_area_y_offset
= 0;
730 /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
731 wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
732 set in wxFrame::Create so it is used to check what kind of frame we
733 have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
734 skip the part which handles m_frameMenuBar, m_frameToolBar and (most
735 importantly) m_mainWidget */
737 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
738 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
739 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
740 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
);
759 /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
760 * menubar, the toolbar and the client area, which is represented by
762 * this hurts in the eye, but I don't want to call SetSize()
763 * because I don't want to call any non-native functions here. */
768 int yy
= m_miniEdge
+ m_miniTitle
;
769 int ww
= m_width
- 2*m_miniEdge
;
770 int hh
= wxMENU_HEIGHT
;
771 if (m_menuBarDetached
) hh
= wxPLACE_HOLDER
;
772 m_frameMenuBar
->m_x
= xx
;
773 m_frameMenuBar
->m_y
= yy
;
774 m_frameMenuBar
->m_width
= ww
;
775 m_frameMenuBar
->m_height
= hh
;
776 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
777 m_frameMenuBar
->m_widget
,
779 client_area_y_offset
+= hh
;
783 if ((m_frameToolBar
) &&
784 (m_frameToolBar
->m_widget
->parent
== m_mainWidget
))
787 int yy
= m_miniEdge
+ m_miniTitle
;
790 if (!m_menuBarDetached
)
793 yy
+= wxPLACE_HOLDER
;
796 m_frameToolBar
->m_x
= xx
;
797 m_frameToolBar
->m_y
= yy
;
799 /* don't change the toolbar's reported height/width */
801 if ( m_frameToolBar
->GetWindowStyle() & wxTB_VERTICAL
)
803 ww
= m_toolBarDetached
? wxPLACE_HOLDER
804 : m_frameToolBar
->m_width
;
805 hh
= m_height
- 2*m_miniEdge
;
807 client_area_x_offset
+= ww
;
811 ww
= m_width
- 2*m_miniEdge
;
812 hh
= m_toolBarDetached
? wxPLACE_HOLDER
813 : m_frameToolBar
->m_height
;
815 client_area_y_offset
+= hh
;
818 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
819 m_frameToolBar
->m_widget
,
822 #endif // wxUSE_TOOLBAR
824 int client_x
= client_area_x_offset
+ m_miniEdge
;
825 int client_y
= client_area_y_offset
+ m_miniEdge
+ m_miniTitle
;
826 int client_w
= m_width
- client_area_x_offset
- 2*m_miniEdge
;
827 int client_h
= m_height
- client_area_y_offset
- 2*m_miniEdge
- m_miniTitle
;
828 gtk_pizza_set_size( GTK_PIZZA(m_mainWidget
),
830 client_x
, client_y
, client_w
, client_h
);
834 /* if there is no m_mainWidget between m_widget and m_wxwindow there
835 is no need to set the size or position of m_wxwindow. */
839 if (m_frameStatusBar
)
841 int xx
= 0 + m_miniEdge
;
842 int yy
= m_height
- wxSTATUS_HEIGHT
- m_miniEdge
- client_area_y_offset
;
843 int ww
= m_width
- 2*m_miniEdge
;
844 int hh
= wxSTATUS_HEIGHT
;
845 m_frameStatusBar
->m_x
= xx
;
846 m_frameStatusBar
->m_y
= yy
;
847 m_frameStatusBar
->m_width
= ww
;
848 m_frameStatusBar
->m_height
= hh
;
849 gtk_pizza_set_size( GTK_PIZZA(m_wxwindow
),
850 m_frameStatusBar
->m_widget
,
852 gtk_widget_draw( m_frameStatusBar
->m_widget
, (GdkRectangle
*) NULL
);
858 // send size event to frame
859 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
860 event
.SetEventObject( this );
861 GetEventHandler()->ProcessEvent( event
);
863 // send size event to status bar
864 if (m_frameStatusBar
)
866 wxSizeEvent
event2( wxSize(m_frameStatusBar
->m_width
,m_frameStatusBar
->m_height
), m_frameStatusBar
->GetId() );
867 event2
.SetEventObject( m_frameStatusBar
);
868 m_frameStatusBar
->GetEventHandler()->ProcessEvent( event2
);
874 void wxFrame::MakeModal( bool modal
)
877 gtk_grab_add( m_widget
);
879 gtk_grab_remove( m_widget
);
882 void wxFrame::OnInternalIdle()
884 if (!m_sizeSet
&& GTK_WIDGET_REALIZED(m_wxwindow
))
886 GtkOnSize( m_x
, m_y
, m_width
, m_height
);
888 // we'll come back later
890 wxapp_install_idle_handler();
894 if (m_frameMenuBar
) m_frameMenuBar
->OnInternalIdle();
896 if (m_frameToolBar
) m_frameToolBar
->OnInternalIdle();
899 if (m_frameStatusBar
) m_frameStatusBar
->OnInternalIdle();
902 wxWindow::OnInternalIdle();
905 // ----------------------------------------------------------------------------
906 // menu/tool/status bar stuff
907 // ----------------------------------------------------------------------------
909 void wxFrame::SetMenuBar( wxMenuBar
*menuBar
)
911 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
912 wxASSERT_MSG( (m_wxwindow
!= NULL
), wxT("invalid frame") );
914 if (menuBar
== m_frameMenuBar
)
919 m_frameMenuBar
->UnsetInvokingWindow( this );
921 if (m_frameMenuBar
->GetWindowStyle() & wxMB_DOCKABLE
)
923 gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar
->m_widget
),
924 GTK_SIGNAL_FUNC(gtk_menu_attached_callback
), (gpointer
)this );
926 gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar
->m_widget
),
927 GTK_SIGNAL_FUNC(gtk_menu_detached_callback
), (gpointer
)this );
930 gtk_container_remove( GTK_CONTAINER(m_mainWidget
), m_frameMenuBar
->m_widget
);
931 gtk_widget_ref( m_frameMenuBar
->m_widget
);
932 gtk_widget_unparent( m_frameMenuBar
->m_widget
);
935 m_frameMenuBar
= menuBar
;
939 m_frameMenuBar
->SetInvokingWindow( this );
941 m_frameMenuBar
->SetParent(this);
942 gtk_pizza_put( GTK_PIZZA(m_mainWidget
),
943 m_frameMenuBar
->m_widget
,
946 m_frameMenuBar
->m_width
,
947 m_frameMenuBar
->m_height
);
949 if (menuBar
->GetWindowStyle() & wxMB_DOCKABLE
)
951 gtk_signal_connect( GTK_OBJECT(menuBar
->m_widget
), "child_attached",
952 GTK_SIGNAL_FUNC(gtk_menu_attached_callback
), (gpointer
)this );
954 gtk_signal_connect( GTK_OBJECT(menuBar
->m_widget
), "child_detached",
955 GTK_SIGNAL_FUNC(gtk_menu_detached_callback
), (gpointer
)this );
958 m_frameMenuBar
->Show( TRUE
);
961 /* resize window in OnInternalIdle */
966 wxToolBar
* wxFrame::CreateToolBar( long style
, wxWindowID id
, const wxString
& name
)
968 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
970 m_insertInClientArea
= FALSE
;
972 m_frameToolBar
= wxFrameBase::CreateToolBar( style
, id
, name
);
975 GetChildren().DeleteObject( m_frameToolBar
);
977 m_insertInClientArea
= TRUE
;
981 return m_frameToolBar
;
984 void wxFrame::SetToolBar(wxToolBar
*toolbar
)
986 wxFrameBase::SetToolBar(toolbar
);
990 /* insert into toolbar area if not already there */
991 if ((m_frameToolBar
->m_widget
->parent
) &&
992 (m_frameToolBar
->m_widget
->parent
!= m_mainWidget
))
994 GetChildren().DeleteObject( m_frameToolBar
);
996 gtk_widget_reparent( m_frameToolBar
->m_widget
, m_mainWidget
);
1002 #endif // wxUSE_TOOLBAR
1006 wxStatusBar
* wxFrame::CreateStatusBar(int number
,
1009 const wxString
& name
)
1011 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
1013 // because it will change when toolbar is added
1016 return wxFrameBase::CreateStatusBar( number
, style
, id
, name
);
1019 void wxFrame::PositionStatusBar()
1021 if ( !m_frameStatusBar
)
1026 #endif // wxUSE_STATUSBAR
1028 // ----------------------------------------------------------------------------
1030 // ----------------------------------------------------------------------------
1032 void wxFrame::SetTitle( const wxString
&title
)
1034 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
1037 gtk_window_set_title( GTK_WINDOW(m_widget
), title
.mbc_str() );
1040 void wxFrame::SetIcon( const wxIcon
&icon
)
1042 wxASSERT_MSG( (m_widget
!= NULL
), wxT("invalid frame") );
1044 wxFrameBase::SetIcon(icon
);
1049 if (!m_widget
->window
)
1052 wxMask
*mask
= icon
.GetMask();
1053 GdkBitmap
*bm
= (GdkBitmap
*) NULL
;
1054 if (mask
) bm
= mask
->GetBitmap();
1056 gdk_window_set_icon( m_widget
->window
, (GdkWindow
*) NULL
, icon
.GetPixmap(), bm
);
1059 // ----------------------------------------------------------------------------
1060 // frame state: maximized/iconized/normal (TODO)
1061 // ----------------------------------------------------------------------------
1063 void wxFrame::Maximize(bool WXUNUSED(maximize
))
1067 bool wxFrame::IsMaximized() const
1072 void wxFrame::Restore()
1076 void wxFrame::Iconize( bool iconize
)
1080 XIconifyWindow( GDK_WINDOW_XDISPLAY( m_widget
->window
),
1081 GDK_WINDOW_XWINDOW( m_widget
->window
),
1082 DefaultScreen( GDK_DISPLAY() ) );
1086 bool wxFrame::IsIconized() const