diff --git a/include/wx/pickerbase.h b/include/wx/pickerbase.h index 963132bcb7..fc63379b90 100644 --- a/include/wx/pickerbase.h +++ b/include/wx/pickerbase.h @@ -76,29 +76,14 @@ public: // public API { return (GetTextCtrlItem()->GetFlag() & wxGROW) != 0; } void SetTextCtrlGrowable(bool grow = true) { - wxSizerItem* const item = GetTextCtrlItem(); - int f = item->GetFlag(); - if ( grow ) - f |= wxGROW; - else - f &= ~wxGROW; - - item->SetFlag(f); + DoSetGrowableFlagFor(GetTextCtrlItem(), grow); } bool IsPickerCtrlGrowable() const { return (GetPickerCtrlItem()->GetFlag() & wxGROW) != 0; } void SetPickerCtrlGrowable(bool grow = true) { - wxSizerItem* const item = GetPickerCtrlItem(); - int f = item->GetFlag(); - if ( grow ) - { - f &= ~wxALIGN_MASK; - f |= wxGROW; - } - - item->SetFlag(f); + DoSetGrowableFlagFor(GetPickerCtrlItem(), grow); } bool HasTextCtrl() const @@ -174,6 +159,9 @@ protected: wxBoxSizer *m_sizer; private: + // Common implementation of Set{Text,Picker}CtrlGrowable(). + void DoSetGrowableFlagFor(wxSizerItem* item, bool grow); + wxDECLARE_ABSTRACT_CLASS(wxPickerBase); }; diff --git a/src/common/pickerbase.cpp b/src/common/pickerbase.cpp index faf2b991fa..306166686d 100644 --- a/src/common/pickerbase.cpp +++ b/src/common/pickerbase.cpp @@ -153,6 +153,26 @@ void wxPickerBase::DoSetToolTip(wxToolTip *tip) #endif // wxUSE_TOOLTIPS +void wxPickerBase::DoSetGrowableFlagFor(wxSizerItem* item, bool grow) +{ + // We assume that our controls use either wxALIGN_CENTER_VERTICAL or wxGROW + // style, this code would need to be changed in the unlikely event any + // other style is used for them. + int f = item->GetFlag(); + if ( grow ) + { + f &= ~wxALIGN_CENTER_VERTICAL; + f |= wxGROW; + } + else + { + f &= ~wxGROW; + f |= wxALIGN_CENTER_VERTICAL; + } + + item->SetFlag(f); +} + // ---------------------------------------------------------------------------- // wxPickerBase - event handlers // ----------------------------------------------------------------------------