]> git.saurik.com Git - wxWidgets.git/commitdiff
Remove unneeded wxTLW child inserter function.
authorPaul Cornett <paulcor@bullseye.com>
Fri, 25 May 2007 05:08:18 +0000 (05:08 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Fri, 25 May 2007 05:08:18 +0000 (05:08 +0000)
Simplify wxFrame child inserter.
Use the same signature for all the child inserters.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46206 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/toplevel.h
include/wx/gtk/window.h
src/gtk/frame.cpp
src/gtk/mdi.cpp
src/gtk/notebook.cpp
src/gtk/popupwin.cpp
src/gtk/tbargtk.cpp
src/gtk/toplevel.cpp
src/gtk/window.cpp

index bd0792f340e8c7f7f5651b9869e74a3bf0532231..bb4fb338ebafc3a3ca5fba71ad688db8c5c78665 100644 (file)
@@ -92,7 +92,6 @@ public:
     int           m_miniEdge,
                   m_miniTitle;
     GtkWidget    *m_mainWidget;
-    bool          m_insertInClientArea;  /* not from within OnCreateXXX */
 
     bool          m_fsIsShowing;         /* full screen */
     long          m_fsSaveGdkFunc, m_fsSaveGdkDecor;
index 60ee66ab09d06a01e7392845e3e7d1e6cd68d159..962e33bc67ccc36bc47316649152c1bc59f30dad 100644 (file)
@@ -18,13 +18,6 @@ struct wxGtkIMData;
 
 WX_DEFINE_EXPORTED_ARRAY_PTR(GdkWindow *, wxArrayGdkWindows);
 
-//-----------------------------------------------------------------------------
-// callback definition for inserting a window (internal)
-//-----------------------------------------------------------------------------
-
-class WXDLLIMPEXP_CORE wxWindowGTK;
-typedef void (*wxInsertChildFunction)( wxWindowGTK*, wxWindowGTK* );
-
 //-----------------------------------------------------------------------------
 // wxWindowGTK
 //-----------------------------------------------------------------------------
@@ -61,7 +54,6 @@ public:
     virtual void Lower();
 
     virtual bool Show( bool show = true );
-    virtual void DoEnable( bool enable );
 
     virtual void SetWindowStyleFlag( long style );
 
@@ -312,12 +304,13 @@ public:
 
     bool                 m_showOnIdle:1;        // postpone showing the window until idle
 
+protected:
     // C++ has no virtual methods in the constrcutor of any class but we need
     // different methods of inserting a child window into a wxFrame,
     // wxMDIFrame, wxNotebook etc. this is the callback that will get used.
-    wxInsertChildFunction  m_insertCallback;
+    typedef void (*InsertChildFunction)(wxWindowGTK*, wxWindowGTK*);
+    InsertChildFunction m_insertCallback;
 
-protected:
     // implement the base class pure virtuals
     virtual void DoClientToScreen( int *x, int *y ) const;
     virtual void DoScreenToClient( int *x, int *y ) const;
@@ -329,6 +322,7 @@ protected:
                            int sizeFlags = wxSIZE_AUTO);
     virtual void DoSetClientSize(int width, int height);
     virtual void DoMoveWindow(int x, int y, int width, int height);
+    virtual void DoEnable(bool enable);
 
 #if wxUSE_MENUS_NATIVE
     virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
index c535e66b930c3b93d53eb2e232485431257795d8..79a8a40c51666ee72c816a5c97a5dd2b548653d6 100644 (file)
@@ -124,49 +124,35 @@ static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
  * virtual function here as wxWidgets requires different ways to insert
  * a child in container classes. */
 
-static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
+static void wxInsertChildInFrame(wxWindow* parent, wxWindow* child)
 {
     wxASSERT( GTK_IS_WIDGET(child->m_widget) );
 
-    if (!parent->m_insertInClientArea)
-    {
-        // These are outside the client area
-        wxFrame* frame = (wxFrame*) parent;
-        gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget),
-                         child->m_widget,
-                         child->m_x,
-                         child->m_y,
-                         child->m_width,
-                         child->m_height );
+    // These are outside the client area
+    wxFrame* frame = wx_static_cast(wxFrame*, parent);
+    gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget),
+                     child->m_widget,
+                     child->m_x,
+                     child->m_y,
+                     child->m_width,
+                     child->m_height );
 
 #if wxUSE_TOOLBAR_NATIVE
-        // We connect to these events for recalculating the client area
-        // space when the toolbar is floating
-        if (wxIS_KIND_OF(child,wxToolBar))
+    // We connect to these events for recalculating the client area
+    // space when the toolbar is floating
+    if (wxIS_KIND_OF(child,wxToolBar))
+    {
+        if (child->HasFlag(wxTB_DOCKABLE))
         {
-            wxToolBar *toolBar = (wxToolBar*) child;
-            if (toolBar->GetWindowStyle() & wxTB_DOCKABLE)
-            {
-                g_signal_connect (toolBar->m_widget, "child_attached",
-                                  G_CALLBACK (gtk_toolbar_attached_callback),
-                                  parent);
-                g_signal_connect (toolBar->m_widget, "child_detached",
-                                  G_CALLBACK (gtk_toolbar_detached_callback),
-                                  parent);
-            }
+            g_signal_connect (child->m_widget, "child_attached",
+                              G_CALLBACK (gtk_toolbar_attached_callback),
+                              parent);
+            g_signal_connect (child->m_widget, "child_detached",
+                              G_CALLBACK (gtk_toolbar_detached_callback),
+                              parent);
         }
-#endif // wxUSE_TOOLBAR
-    }
-    else
-    {
-        // These are inside the client area
-        gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
-                         child->m_widget,
-                         child->m_x,
-                         child->m_y,
-                         child->m_width,
-                         child->m_height );
     }
+#endif // wxUSE_TOOLBAR
 }
 
 // ----------------------------------------------------------------------------
@@ -188,11 +174,7 @@ bool wxFrame::Create( wxWindow *parent,
                       long style,
                       const wxString &name )
 {
-    bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig,
-                                       style, name);
-    m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
-
-    return rt;
+    return wxFrameBase::Create(parent, id, title, pos, sizeOrig, style, name);
 }
 
 wxFrame::~wxFrame()
@@ -583,11 +565,10 @@ wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& na
 {
     wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
 
-    m_insertInClientArea = false;
-
+    InsertChildFunction save = m_insertCallback;
+    m_insertCallback = wxInsertChildInFrame;
     m_frameToolBar = wxFrameBase::CreateToolBar( style, id, name );
-
-    m_insertInClientArea = true;
+    m_insertCallback = save;
 
     GtkUpdateSize();
 
index 3525a297db6ae651490cad071345c06817c6e93a..607dc314d73395c4e67508c2db6752d36d804002 100644 (file)
@@ -443,9 +443,10 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
 // InsertChild callback for wxMDIClientWindow
 //-----------------------------------------------------------------------------
 
-static void wxInsertChildInMDI( wxMDIClientWindow* parent, wxMDIChildFrame* child )
+static void wxInsertChildInMDI(wxWindow* parent, wxWindow* child)
 {
-    wxString s = child->GetTitle();
+    wxMDIChildFrame* child_frame = wx_static_cast(wxMDIChildFrame*, child);
+    wxString s = child_frame->GetTitle();
     if (s.IsNull()) s = _("MDI child");
 
     GtkWidget *label_widget = gtk_label_new( s.mbc_str() );
@@ -458,9 +459,9 @@ static void wxInsertChildInMDI( wxMDIClientWindow* parent, wxMDIChildFrame* chil
 
     gtk_notebook_append_page( notebook, child->m_widget, label_widget );
 
-    child->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data);
+    child_frame->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data);
 
-    wxMDIParentFrame *parent_frame = (wxMDIParentFrame*) parent->GetParent();
+    wxMDIParentFrame *parent_frame = wx_static_cast(wxMDIParentFrame*, parent->GetParent());
     parent_frame->m_justInserted = true;
 }
 
@@ -486,7 +487,7 @@ wxMDIClientWindow::~wxMDIClientWindow()
 
 bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
 {
-    m_insertCallback = (wxInsertChildFunction)wxInsertChildInMDI;
+    m_insertCallback = wxInsertChildInMDI;
 
     if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) ||
         !CreateBase( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("wxMDIClientWindow") ))
index 41659072dc1bb6aca0109f89016c1cd967da1dc5..f0f8bc5abdf02d2aca313497db1659bbe38214e2 100644 (file)
@@ -159,7 +159,7 @@ gtk_notebook_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win )
 // InsertChild callback for wxNotebook
 //-----------------------------------------------------------------------------
 
-static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* child )
+static void wxInsertChildInNotebook(wxWindow* parent, wxWindow* child)
 {
     // Hack Alert! (Part I): This sets the notebook as the parent of the child
     // widget, and takes care of some details such as updating the state and
@@ -217,7 +217,7 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
                         const wxPoint& pos, const wxSize& size,
                         long style, const wxString& name )
 {
-    m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook;
+    m_insertCallback = wxInsertChildInNotebook;
 
     if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
         style |= wxBK_TOP;
index b041273f9f16af4bc65ada20632d6e5c46522a9b..1aa9e22b6b4386a0472fad5f8851e5c32609aa59 100644 (file)
@@ -110,7 +110,7 @@ gtk_dialog_realized_callback( GtkWidget * WXUNUSED(widget), wxPopupWindow *win )
  * virtual function here as wxWidgets requires different ways to insert
  * a child in container classes. */
 
-static void wxInsertChildInDialog( wxPopupWindow* parent, wxWindow* child )
+static void wxInsertChildInPopupWin(wxWindow* parent, wxWindow* child)
 {
     gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
                    child->m_widget,
@@ -158,7 +158,7 @@ bool wxPopupWindow::Create( wxWindow *parent, int style )
     // All dialogs should really have this style
     m_windowStyle |= wxTAB_TRAVERSAL;
 
-    m_insertCallback = (wxInsertChildFunction) wxInsertChildInDialog;
+    m_insertCallback = wxInsertChildInPopupWin;
 
     m_widget = gtk_window_new( GTK_WINDOW_POPUP );
 
index a28e8eb817c869d10597c5a4161f4618c1168d39..87b8aa903fc7234aaace0da8fb0dec69ea1a5bd5 100644 (file)
@@ -355,7 +355,7 @@ void gtktoolwidget_size_callback( GtkWidget *widget,
 // InsertChild callback for wxToolBar
 //-----------------------------------------------------------------------------
 
-static void wxInsertChildInToolBar( wxToolBar* WXUNUSED(parent),
+static void wxInsertChildInToolBar( wxWindow* WXUNUSED(parent),
                                     wxWindow* WXUNUSED(child) )
 {
     // we don't do anything here
@@ -413,7 +413,7 @@ bool wxToolBar::Create( wxWindow *parent,
                         long style,
                         const wxString& name )
 {
-    m_insertCallback = (wxInsertChildFunction)wxInsertChildInToolBar;
+    m_insertCallback = wxInsertChildInToolBar;
 
     if ( !PreCreation( parent, pos, size ) ||
          !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
index 16588492bf0acaa1b28c77612b1cff6688d43011..b32e2b0d5a4d6d8926d027a5cd6b92bdf156f479 100644 (file)
@@ -378,46 +378,6 @@ gtk_window_expose_callback( GtkWidget *widget,
 }
 }
 
-// ----------------------------------------------------------------------------
-// wxTopLevelWindowGTK itself
-// ----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-// InsertChild for wxTopLevelWindowGTK
-//-----------------------------------------------------------------------------
-
-/* Callback for wxTopLevelWindowGTK. This very strange beast has to be used because
- * C++ has no virtual methods in a constructor. We have to emulate a
- * virtual function here as wxWidgets requires different ways to insert
- * a child in container classes. */
-
-static void wxInsertChildInTopLevelWindow( wxTopLevelWindowGTK* parent, wxWindow* child )
-{
-    wxASSERT( GTK_IS_WIDGET(child->m_widget) );
-
-    if (!parent->m_insertInClientArea)
-    {
-        // these are outside the client area
-        wxTopLevelWindowGTK* frame = (wxTopLevelWindowGTK*) parent;
-        gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget),
-                         child->m_widget,
-                         child->m_x,
-                         child->m_y,
-                         child->m_width,
-                         child->m_height );
-    }
-    else
-    {
-        // these are inside the client area
-        gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
-                         child->m_widget,
-                         child->m_x,
-                         child->m_y,
-                         child->m_width,
-                         child->m_height );
-    }
-}
-
 // ----------------------------------------------------------------------------
 // wxTopLevelWindowGTK creation
 // ----------------------------------------------------------------------------
@@ -428,7 +388,6 @@ void wxTopLevelWindowGTK::Init()
     m_miniEdge = 0;
     m_miniTitle = 0;
     m_mainWidget = (GtkWidget*) NULL;
-    m_insertInClientArea = true;
     m_isIconized = false;
     m_fsIsShowing = false;
     m_fsSaveFlag = 0;
@@ -464,8 +423,6 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
 
     m_title = title;
 
-    m_insertCallback = (wxInsertChildFunction) wxInsertChildInTopLevelWindow;
-
     // NB: m_widget may be !=NULL if it was created by derived class' Create,
     //     e.g. in wxTaskBarIconAreaGTK
     if (m_widget == NULL)
index 2389e69cd634aecb3a4ed0e8c9e3d736ca984e53..0eb815a39d9e8a6b0a86028ca72bfbb43f6a66fb 100644 (file)
@@ -2272,7 +2272,7 @@ void wxWindowGTK::Init()
 
     m_resizing = false;
 
-    m_insertCallback = (wxInsertChildFunction) NULL;
+    m_insertCallback = wxInsertChildInWindow;
 
     m_hasFocus = false;
 
@@ -2317,9 +2317,6 @@ bool wxWindowGTK::Create( wxWindow *parent,
         return false;
     }
 
-    m_insertCallback = wxInsertChildInWindow;
-
-
     if (!HasFlag(wxHSCROLL) && !HasFlag(wxVSCROLL))
     {
         m_wxwindow = gtk_pizza_new_no_scroll();
@@ -3305,11 +3302,8 @@ bool wxWindowGTK::Reparent( wxWindowBase *newParentBase )
 void wxWindowGTK::DoAddChild(wxWindowGTK *child)
 {
     wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
-
     wxASSERT_MSG( (child != NULL), wxT("invalid child window") );
 
-    wxASSERT_MSG( (m_insertCallback != NULL), wxT("invalid child insertion function") );
-
     /* add to list */
     AddChild( child );