Merge branch 'collpane-bestsize'
Fix generic collapsible pane best size determination. See https://github.com/wxWidgets/wxWidgets/pull/1580
This commit is contained in:
@@ -73,7 +73,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// overridden methods
|
// overridden methods
|
||||||
virtual wxSize DoGetBestSize() const wxOVERRIDE;
|
virtual wxSize DoGetBestClientSize() const wxOVERRIDE;
|
||||||
|
|
||||||
int GetBorder() const;
|
int GetBorder() const;
|
||||||
|
|
||||||
|
@@ -77,17 +77,28 @@ bool wxGenericCollapsibleHeaderCtrl::Create(wxWindow *parent,
|
|||||||
|
|
||||||
wxSize wxGenericCollapsibleHeaderCtrl::DoGetBestClientSize() const
|
wxSize wxGenericCollapsibleHeaderCtrl::DoGetBestClientSize() const
|
||||||
{
|
{
|
||||||
wxClientDC dc(const_cast<wxGenericCollapsibleHeaderCtrl*>(this));
|
wxGenericCollapsibleHeaderCtrl* const
|
||||||
wxSize btnSize = wxRendererNative::Get().GetCollapseButtonSize(const_cast<wxGenericCollapsibleHeaderCtrl*>(this), dc);
|
self = const_cast<wxGenericCollapsibleHeaderCtrl*>(this);
|
||||||
|
|
||||||
|
// The code here parallels that of OnPaint() -- except without drawing.
|
||||||
|
wxClientDC dc(self);
|
||||||
|
|
||||||
|
wxSize size = wxRendererNative::Get().GetCollapseButtonSize(self, dc);
|
||||||
|
|
||||||
wxString text;
|
wxString text;
|
||||||
wxControl::FindAccelIndex(GetLabel(), &text);
|
wxControl::FindAccelIndex(GetLabel(), &text);
|
||||||
wxSize textSize = dc.GetTextExtent(text);
|
|
||||||
// Add some padding if the label is not empty
|
|
||||||
if ( textSize.x > 0 )
|
|
||||||
textSize.x += FromDIP(4);
|
|
||||||
|
|
||||||
return wxSize(btnSize.x + textSize.x,
|
const wxSize textSize = dc.GetTextExtent(text);
|
||||||
wxMax(textSize.y, btnSize.y));
|
|
||||||
|
size.x += FromDIP(2) + textSize.x;
|
||||||
|
if ( textSize.y > size.y )
|
||||||
|
size.y = textSize.y;
|
||||||
|
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
size.IncBy(1);
|
||||||
|
#endif // __WXMSW__
|
||||||
|
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGenericCollapsibleHeaderCtrl::SetCollapsed(bool collapsed)
|
void wxGenericCollapsibleHeaderCtrl::SetCollapsed(bool collapsed)
|
||||||
|
@@ -84,8 +84,7 @@ bool wxGenericCollapsiblePane::Create(wxWindow *parent,
|
|||||||
m_pButton = new wxCollapsibleHeaderCtrl(this, wxID_ANY, label, wxPoint(0, 0),
|
m_pButton = new wxCollapsibleHeaderCtrl(this, wxID_ANY, label, wxPoint(0, 0),
|
||||||
wxDefaultSize);
|
wxDefaultSize);
|
||||||
|
|
||||||
// on other platforms we put the static line and the button horizontally
|
m_sz->Add(m_pButton, wxSizerFlags().Border(wxALL, GetBorder()));
|
||||||
m_sz->Add(m_pButton, 0, wxLEFT|wxTOP|wxBOTTOM, GetBorder());
|
|
||||||
|
|
||||||
// FIXME: at least under wxGTK1 the background is black if we don't do
|
// FIXME: at least under wxGTK1 the background is black if we don't do
|
||||||
// this, no idea why...
|
// this, no idea why...
|
||||||
@@ -112,7 +111,7 @@ wxGenericCollapsiblePane::~wxGenericCollapsiblePane()
|
|||||||
wxDELETE(m_sz);
|
wxDELETE(m_sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxGenericCollapsiblePane::DoGetBestSize() const
|
wxSize wxGenericCollapsiblePane::DoGetBestClientSize() const
|
||||||
{
|
{
|
||||||
// NB: do not use GetSize() but rather GetMinSize()
|
// NB: do not use GetSize() but rather GetMinSize()
|
||||||
wxSize sz = m_sz->GetMinSize();
|
wxSize sz = m_sz->GetMinSize();
|
||||||
|
@@ -220,7 +220,15 @@ bool wxOSXDataViewModelNotifier::ValueChanged(wxDataViewItem const& item, unsign
|
|||||||
|
|
||||||
bool wxOSXDataViewModelNotifier::Cleared()
|
bool wxOSXDataViewModelNotifier::Cleared()
|
||||||
{
|
{
|
||||||
return m_DataViewCtrlPtr->GetDataViewPeer()->Reload();
|
// As when individual items are deleted, we must ensure that we don't touch
|
||||||
|
// the model item possibly being edited, as it's not valid any more.
|
||||||
|
m_DataViewCtrlPtr->SetDeleting(true);
|
||||||
|
|
||||||
|
const bool rc = m_DataViewCtrlPtr->GetDataViewPeer()->Reload();
|
||||||
|
|
||||||
|
m_DataViewCtrlPtr->SetDeleting(false);
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxOSXDataViewModelNotifier::Resort()
|
void wxOSXDataViewModelNotifier::Resort()
|
||||||
|
Reference in New Issue
Block a user