Refactor initialization code in wxTopLevelWindowMSW::Create().

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
This commit is contained in:
Vadim Zeitlin 2009-10-05 22:58:15 +00:00
parent 7ccc497b9c
commit 2973301f6f
3 changed files with 35 additions and 17 deletions

View 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);

View 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

View 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);