Fix recently broken wxPickerBase::SetPickerCtrlGrowable()
Resetting growable flag didn't work correctly after the changes of
0d86c01b8b
, fix this and reuse the same code for
both this function and SetTextCtrlGrowable().
See https://github.com/wxWidgets/wxWidgets/pull/296
This commit is contained in:
parent
2e67381548
commit
dd562649f0
@ -76,29 +76,14 @@ public: // public API
|
|||||||
{ return (GetTextCtrlItem()->GetFlag() & wxGROW) != 0; }
|
{ return (GetTextCtrlItem()->GetFlag() & wxGROW) != 0; }
|
||||||
void SetTextCtrlGrowable(bool grow = true)
|
void SetTextCtrlGrowable(bool grow = true)
|
||||||
{
|
{
|
||||||
wxSizerItem* const item = GetTextCtrlItem();
|
DoSetGrowableFlagFor(GetTextCtrlItem(), grow);
|
||||||
int f = item->GetFlag();
|
|
||||||
if ( grow )
|
|
||||||
f |= wxGROW;
|
|
||||||
else
|
|
||||||
f &= ~wxGROW;
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
wxSizerItem* const item = GetPickerCtrlItem();
|
DoSetGrowableFlagFor(GetPickerCtrlItem(), grow);
|
||||||
int f = item->GetFlag();
|
|
||||||
if ( grow )
|
|
||||||
{
|
|
||||||
f &= ~wxALIGN_MASK;
|
|
||||||
f |= wxGROW;
|
|
||||||
}
|
|
||||||
|
|
||||||
item->SetFlag(f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasTextCtrl() const
|
bool HasTextCtrl() const
|
||||||
@ -174,6 +159,9 @@ protected:
|
|||||||
wxBoxSizer *m_sizer;
|
wxBoxSizer *m_sizer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Common implementation of Set{Text,Picker}CtrlGrowable().
|
||||||
|
void DoSetGrowableFlagFor(wxSizerItem* item, bool grow);
|
||||||
|
|
||||||
wxDECLARE_ABSTRACT_CLASS(wxPickerBase);
|
wxDECLARE_ABSTRACT_CLASS(wxPickerBase);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -153,6 +153,26 @@ void wxPickerBase::DoSetToolTip(wxToolTip *tip)
|
|||||||
|
|
||||||
#endif // wxUSE_TOOLTIPS
|
#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
|
// wxPickerBase - event handlers
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user