From 0d86c01b8b2fb675ee79beb21b5d0f53ea5ed736 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 8 Jun 2016 02:51:53 +0200 Subject: [PATCH] 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. --- include/wx/pickerbase.h | 14 ++++++++++---- src/common/pickerbase.cpp | 10 +++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/wx/pickerbase.h b/include/wx/pickerbase.h index f4ec165784..963132bcb7 100644 --- a/include/wx/pickerbase.h +++ b/include/wx/pickerbase.h @@ -76,27 +76,29 @@ public: // public API { return (GetTextCtrlItem()->GetFlag() & wxGROW) != 0; } void SetTextCtrlGrowable(bool grow = true) { - int f = GetDefaultTextCtrlFlag(); + wxSizerItem* const item = GetTextCtrlItem(); + int f = item->GetFlag(); if ( grow ) f |= wxGROW; else f &= ~wxGROW; - GetTextCtrlItem()->SetFlag(f); + item->SetFlag(f); } bool IsPickerCtrlGrowable() const { return (GetPickerCtrlItem()->GetFlag() & wxGROW) != 0; } void SetPickerCtrlGrowable(bool grow = true) { - int f = GetDefaultPickerCtrlFlag(); + wxSizerItem* const item = GetPickerCtrlItem(); + int f = item->GetFlag(); if ( grow ) { f &= ~wxALIGN_MASK; f |= wxGROW; } - GetPickerCtrlItem()->SetFlag(f); + item->SetFlag(f); } bool HasTextCtrl() const @@ -150,15 +152,19 @@ protected: 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 { return wxALIGN_CENTER_VERTICAL; } + wxDEPRECATED_MSG("useless and will be removed in the future") int GetDefaultTextCtrlFlag() const { return wxALIGN_CENTER_VERTICAL | wxRIGHT; } +#endif // WXWIN_COMPATIBILITY_3_0 void PostCreation(); diff --git a/src/common/pickerbase.cpp b/src/common/pickerbase.cpp index ffe484e9e4..faf2b991fa 100644 --- a/src/common/pickerbase.cpp +++ b/src/common/pickerbase.cpp @@ -102,8 +102,8 @@ bool wxPickerBase::CreateBase(wxWindow *parent, wxWindowDestroyEventHandler(wxPickerBase::OnTextCtrlDelete), NULL, this); - // the text control's proportion values defaults to 2 - m_sizer->Add(m_text, 2, GetDefaultTextCtrlFlag(), 5); + m_sizer->Add(m_text, + wxSizerFlags(1).CentreVertical().Border(wxRIGHT)); } return true; @@ -111,9 +111,9 @@ bool wxPickerBase::CreateBase(wxWindow *parent, void wxPickerBase::PostCreation() { - // the picker's proportion value defaults to 1 when there's no text control - // associated with it - in that case it defaults to 0 - m_sizer->Add(m_picker, HasTextCtrl() ? 0 : 1, GetDefaultPickerCtrlFlag(), 5); + // the picker grows in the major direction only if there is no text control + m_sizer->Add(m_picker, + wxSizerFlags(HasTextCtrl() ? 0 : 1).CentreVertical()); // 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