Deprecate wxPickerBase::GetDefaultXXXFlag() methods

They just seem completely useless, not documented and only used by wxPickerBase
itself internally. Replace the code using them with wxSizerFlags which is more
clear and also doesn't hard code the border sizes (especially in the case of
the picker control which doesn't even have borders in the first place) and
prepare for removing them later.
This commit is contained in:
Vadim Zeitlin
2016-06-08 02:51:53 +02:00
parent c5825827fb
commit 0d86c01b8b
2 changed files with 15 additions and 9 deletions

View File

@@ -76,27 +76,29 @@ public: // public API
{ return (GetTextCtrlItem()->GetFlag() & wxGROW) != 0; } { return (GetTextCtrlItem()->GetFlag() & wxGROW) != 0; }
void SetTextCtrlGrowable(bool grow = true) void SetTextCtrlGrowable(bool grow = true)
{ {
int f = GetDefaultTextCtrlFlag(); wxSizerItem* const item = GetTextCtrlItem();
int f = item->GetFlag();
if ( grow ) if ( grow )
f |= wxGROW; f |= wxGROW;
else else
f &= ~wxGROW; f &= ~wxGROW;
GetTextCtrlItem()->SetFlag(f); item->SetFlag(f);
} }
bool IsPickerCtrlGrowable() const bool IsPickerCtrlGrowable() const
{ return (GetPickerCtrlItem()->GetFlag() & wxGROW) != 0; } { return (GetPickerCtrlItem()->GetFlag() & wxGROW) != 0; }
void SetPickerCtrlGrowable(bool grow = true) void SetPickerCtrlGrowable(bool grow = true)
{ {
int f = GetDefaultPickerCtrlFlag(); wxSizerItem* const item = GetPickerCtrlItem();
int f = item->GetFlag();
if ( grow ) if ( grow )
{ {
f &= ~wxALIGN_MASK; f &= ~wxALIGN_MASK;
f |= wxGROW; f |= wxGROW;
} }
GetPickerCtrlItem()->SetFlag(f); item->SetFlag(f);
} }
bool HasTextCtrl() const bool HasTextCtrl() const
@@ -150,15 +152,19 @@ protected:
return m_sizer->GetItem((size_t)0); return m_sizer->GetItem((size_t)0);
} }
#if WXWIN_COMPATIBILITY_3_0
wxDEPRECATED_MSG("useless and will be removed in the future")
int GetDefaultPickerCtrlFlag() const int GetDefaultPickerCtrlFlag() const
{ {
return wxALIGN_CENTER_VERTICAL; return wxALIGN_CENTER_VERTICAL;
} }
wxDEPRECATED_MSG("useless and will be removed in the future")
int GetDefaultTextCtrlFlag() const int GetDefaultTextCtrlFlag() const
{ {
return wxALIGN_CENTER_VERTICAL | wxRIGHT; return wxALIGN_CENTER_VERTICAL | wxRIGHT;
} }
#endif // WXWIN_COMPATIBILITY_3_0
void PostCreation(); void PostCreation();

View File

@@ -102,8 +102,8 @@ bool wxPickerBase::CreateBase(wxWindow *parent,
wxWindowDestroyEventHandler(wxPickerBase::OnTextCtrlDelete), wxWindowDestroyEventHandler(wxPickerBase::OnTextCtrlDelete),
NULL, this); NULL, this);
// the text control's proportion values defaults to 2 m_sizer->Add(m_text,
m_sizer->Add(m_text, 2, GetDefaultTextCtrlFlag(), 5); wxSizerFlags(1).CentreVertical().Border(wxRIGHT));
} }
return true; return true;
@@ -111,9 +111,9 @@ bool wxPickerBase::CreateBase(wxWindow *parent,
void wxPickerBase::PostCreation() void wxPickerBase::PostCreation()
{ {
// the picker's proportion value defaults to 1 when there's no text control // the picker grows in the major direction only if there is no text control
// associated with it - in that case it defaults to 0 m_sizer->Add(m_picker,
m_sizer->Add(m_picker, HasTextCtrl() ? 0 : 1, GetDefaultPickerCtrlFlag(), 5); wxSizerFlags(HasTextCtrl() ? 0 : 1).CentreVertical());
// For aesthetic reasons, make sure the picker is at least as high as the // For aesthetic reasons, make sure the picker is at least as high as the
// associated text control and is always at least square, unless we are // associated text control and is always at least square, unless we are