]> git.saurik.com Git - wxWidgets.git/commitdiff
Refactor initialization code in wxTopLevelWindowMSW::Create().
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 5 Oct 2009 22:58:15 +0000 (22:58 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 5 Oct 2009 22:58:15 +0000 (22:58 +0000)
No real changes as the old code was, in fact, correct (although Create()
didn't initialize m_parent explicitly, it was still done in AddChild() if the
parent was not NUL) but just make it more explicit and clear.

Add a new helper wxWindowBase::CreateBase() overload for top level windows,
not taking the validator parameter which doesn't apply to them.

Also make CreateBase() protected as it is only meant to be called from derived
classes Create().

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

include/wx/window.h
src/common/wincmn.cpp
src/msw/toplevel.cpp

index 42a300ef827f992d30c33283e627d932751dec14..4fff9c3cd81ef08368391ee63f6780807a468781 100644 (file)
@@ -174,15 +174,6 @@ public:
         // Create()
     wxWindowBase() ;
 
-        // pseudo ctor (can't be virtual, called from ctor)
-    bool CreateBase(wxWindowBase *parent,
-                    wxWindowID winid,
-                    const wxPoint& pos = wxDefaultPosition,
-                    const wxSize& size = wxDefaultSize,
-                    long style = 0,
-                    const wxValidator& validator = wxDefaultValidator,
-                    const wxString& name = wxPanelNameStr);
-
     virtual ~wxWindowBase();
 
     // deleting the window
@@ -1421,6 +1412,24 @@ public:
     virtual bool CanApplyThemeBorder() const { return true; }
 
 protected:
+    // helper for the derived class Create() methods: the first overload, with
+    // validator parameter, should be used for child windows while the second
+    // one is used for top level ones
+    bool CreateBase(wxWindowBase *parent,
+                    wxWindowID winid,
+                    const wxPoint& pos = wxDefaultPosition,
+                    const wxSize& size = wxDefaultSize,
+                    long style = 0,
+                    const wxValidator& validator = wxDefaultValidator,
+                    const wxString& name = wxPanelNameStr);
+
+    bool CreateBase(wxWindowBase *parent,
+                    wxWindowID winid,
+                    const wxPoint& pos,
+                    const wxSize& size,
+                    long style,
+                    const wxString& name);
+
     // event handling specific to wxWindow
     virtual bool TryBefore(wxEvent& event);
     virtual bool TryAfter(wxEvent& event);
index 1a03e224efbbff798ddf748a495f025f410368c9..30dc0105107312bfbbc2bce5d7e3f97079741f17 100644 (file)
@@ -215,7 +215,6 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent,
                               const wxPoint& WXUNUSED(pos),
                               const wxSize& WXUNUSED(size),
                               long style,
-                              const wxValidator& wxVALIDATOR_PARAM(validator),
                               const wxString& name)
 {
     // ids are limited to 16 bits under MSW so if you care about portability,
@@ -243,6 +242,20 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent,
     SetName(name);
     SetParent(parent);
 
+    return true;
+}
+
+bool wxWindowBase::CreateBase(wxWindowBase *parent,
+                              wxWindowID id,
+                              const wxPoint& pos,
+                              const wxSize& size,
+                              long style,
+                              const wxValidator& wxVALIDATOR_PARAM(validator),
+                              const wxString& name)
+{
+    if ( !CreateBase(parent, id, pos, size, style, name) )
+        return false;
+
 #if wxUSE_VALIDATORS
     SetValidator(validator);
 #endif // wxUSE_VALIDATORS
index 274bc888c983628069c14b1e1cf4ff3abbdbe8f6..37739849902b79ece53fe6be7c667838cfb917ce 100644 (file)
@@ -476,19 +476,15 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent,
                                  long style,
                                  const wxString& name)
 {
-    bool ret wxDUMMY_INITIALIZE(false);
-
     wxSize sizeReal = size;
     if ( !sizeReal.IsFullySpecified() )
     {
         sizeReal.SetDefaults(GetDefaultSize());
     }
 
-    m_windowStyle = style;
-
-    SetName(name);
-
-    m_windowId = id == wxID_ANY ? NewControlId() : id;
+    bool ret = CreateBase(parent, id, pos, sizeReal, style, name);
+    if ( !ret )
+        return false;
 
     wxTopLevelWindows.Append(this);