Use -1 as uninitialized value for m_expanderWidth
Use -1, not 0, for the not-yet-computed value. Prevents CPU-intensive recomputation when the calculated size _is_ zero - e.g. because the column is hidden.
This commit is contained in:
@@ -2092,7 +2092,7 @@ wxCocoaDataViewControl::wxCocoaDataViewControl(wxWindow* peer,
|
||||
),
|
||||
m_DataSource(NULL),
|
||||
m_OutlineView([[wxCocoaOutlineView alloc] init]),
|
||||
m_expanderWidth(0)
|
||||
m_expanderWidth(-1)
|
||||
{
|
||||
// initialize scrollview (the outline view is part of a scrollview):
|
||||
NSScrollView* scrollview = (NSScrollView*) GetWXWidget();
|
||||
@@ -2254,7 +2254,7 @@ void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos)
|
||||
m_view(view),
|
||||
m_column(columnIndex),
|
||||
m_indent(0),
|
||||
m_expander(0),
|
||||
m_expander(-1),
|
||||
m_tableColumn(column)
|
||||
{
|
||||
// account for indentation in the column with expander
|
||||
@@ -2275,7 +2275,7 @@ void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos)
|
||||
if ( m_indent )
|
||||
cellWidth += m_indent * [m_view levelForRow:row];
|
||||
|
||||
if ( m_expander == 0 && m_tableColumn == [m_view outlineTableColumn] )
|
||||
if ( m_expander == -1 && m_tableColumn == [m_view outlineTableColumn] )
|
||||
{
|
||||
NSRect rc = [m_view frameOfOutlineCellAtRow:row];
|
||||
m_expander = ceil(rc.origin.x + rc.size.width);
|
||||
@@ -2366,10 +2366,10 @@ void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos)
|
||||
|
||||
// there might not necessarily be an expander in the rows we've examined above so let's
|
||||
// globally store the expander width for re-use because it should always be the same
|
||||
if ( m_expanderWidth == 0 )
|
||||
if ( m_expanderWidth == -1 )
|
||||
m_expanderWidth = calculator.GetExpanderWidth();
|
||||
|
||||
[column setWidth:calculator.GetMaxWidth() + m_expanderWidth];
|
||||
[column setWidth:calculator.GetMaxWidth() + wxMax(0, m_expanderWidth)];
|
||||
}
|
||||
|
||||
//
|
||||
|
Reference in New Issue
Block a user