Merge branch 'grid-attr-smart-ptr'
Use smart pointers in wxGrid code. See https://github.com/wxWidgets/wxWidgets/pull/1731
This commit is contained in:
@@ -206,6 +206,9 @@ public:
|
|||||||
virtual wxGridCellRenderer *Clone() const = 0;
|
virtual wxGridCellRenderer *Clone() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Smart pointer to wxGridCellRenderer, calling DecRef() on it automatically.
|
||||||
|
typedef wxObjectDataPtr<wxGridCellRenderer> wxGridCellRendererPtr;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxGridCellEditor: This class is responsible for providing and manipulating
|
// wxGridCellEditor: This class is responsible for providing and manipulating
|
||||||
// the in-place edit controls for the grid. Instances of wxGridCellEditor
|
// the in-place edit controls for the grid. Instances of wxGridCellEditor
|
||||||
@@ -333,6 +336,9 @@ protected:
|
|||||||
wxDECLARE_NO_COPY_CLASS(wxGridCellEditor);
|
wxDECLARE_NO_COPY_CLASS(wxGridCellEditor);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Smart pointer to wxGridCellEditor, calling DecRef() on it automatically.
|
||||||
|
typedef wxObjectDataPtr<wxGridCellEditor> wxGridCellEditorPtr;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxGridHeaderRenderer and company: like wxGridCellRenderer but for headers
|
// wxGridHeaderRenderer and company: like wxGridCellRenderer but for headers
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -573,8 +579,18 @@ public:
|
|||||||
// whether the cell will draw the overflowed text to neighbour cells
|
// whether the cell will draw the overflowed text to neighbour cells
|
||||||
// currently only left aligned cells can overflow
|
// currently only left aligned cells can overflow
|
||||||
bool CanOverflow() const;
|
bool CanOverflow() const;
|
||||||
|
|
||||||
wxGridCellRenderer *GetRenderer(const wxGrid* grid, int row, int col) const;
|
wxGridCellRenderer *GetRenderer(const wxGrid* grid, int row, int col) const;
|
||||||
|
wxGridCellRendererPtr GetRendererPtr(const wxGrid* grid, int row, int col) const
|
||||||
|
{
|
||||||
|
return wxGridCellRendererPtr(GetRenderer(grid, row, col));
|
||||||
|
}
|
||||||
|
|
||||||
wxGridCellEditor *GetEditor(const wxGrid* grid, int row, int col) const;
|
wxGridCellEditor *GetEditor(const wxGrid* grid, int row, int col) const;
|
||||||
|
wxGridCellEditorPtr GetEditorPtr(const wxGrid* grid, int row, int col) const
|
||||||
|
{
|
||||||
|
return wxGridCellEditorPtr(GetEditor(grid, row, col));
|
||||||
|
}
|
||||||
|
|
||||||
bool IsReadOnly() const { return m_isReadOnly == wxGridCellAttr::ReadOnly; }
|
bool IsReadOnly() const { return m_isReadOnly == wxGridCellAttr::ReadOnly; }
|
||||||
|
|
||||||
@@ -628,6 +644,9 @@ private:
|
|||||||
friend class wxGridCellAttrDummyFriend;
|
friend class wxGridCellAttrDummyFriend;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Smart pointer to wxGridCellAttr, calling DecRef() on it automatically.
|
||||||
|
typedef wxObjectDataPtr<wxGridCellAttr> wxGridCellAttrPtr;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the
|
// wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the
|
||||||
// cell attributes.
|
// cell attributes.
|
||||||
@@ -650,6 +669,13 @@ public:
|
|||||||
virtual wxGridCellAttr *GetAttr(int row, int col,
|
virtual wxGridCellAttr *GetAttr(int row, int col,
|
||||||
wxGridCellAttr::wxAttrKind kind ) const;
|
wxGridCellAttr::wxAttrKind kind ) const;
|
||||||
|
|
||||||
|
// Helper returning smart pointer calling DecRef() automatically.
|
||||||
|
wxGridCellAttrPtr GetAttrPtr(int row, int col,
|
||||||
|
wxGridCellAttr::wxAttrKind kind ) const
|
||||||
|
{
|
||||||
|
return wxGridCellAttrPtr(GetAttr(row, col, kind));
|
||||||
|
}
|
||||||
|
|
||||||
// all these functions take ownership of the pointer, don't call DecRef()
|
// all these functions take ownership of the pointer, don't call DecRef()
|
||||||
// on it
|
// on it
|
||||||
virtual void SetAttr(wxGridCellAttr *attr, int row, int col);
|
virtual void SetAttr(wxGridCellAttr *attr, int row, int col);
|
||||||
@@ -824,6 +850,11 @@ public:
|
|||||||
virtual wxGridCellAttr *GetAttr( int row, int col,
|
virtual wxGridCellAttr *GetAttr( int row, int col,
|
||||||
wxGridCellAttr::wxAttrKind kind );
|
wxGridCellAttr::wxAttrKind kind );
|
||||||
|
|
||||||
|
wxGridCellAttrPtr GetAttrPtr(int row, int col,
|
||||||
|
wxGridCellAttr::wxAttrKind kind)
|
||||||
|
{
|
||||||
|
return wxGridCellAttrPtr(GetAttr(row, col, kind));
|
||||||
|
}
|
||||||
|
|
||||||
// these functions take ownership of the pointer
|
// these functions take ownership of the pointer
|
||||||
virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
|
virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
|
||||||
@@ -1478,6 +1509,11 @@ public:
|
|||||||
// DecRef() must be called on the returned pointer, as usual
|
// DecRef() must be called on the returned pointer, as usual
|
||||||
wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
|
wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
|
||||||
|
|
||||||
|
wxGridCellAttrPtr GetOrCreateCellAttrPtr(int row, int col) const
|
||||||
|
{
|
||||||
|
return wxGridCellAttrPtr(GetOrCreateCellAttr(row, col));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// shortcuts for setting the column parameters
|
// shortcuts for setting the column parameters
|
||||||
|
|
||||||
@@ -2196,6 +2232,16 @@ protected:
|
|||||||
wxGridCellAttr *GetCellAttr(const wxGridCellCoords& coords ) const
|
wxGridCellAttr *GetCellAttr(const wxGridCellCoords& coords ) const
|
||||||
{ return GetCellAttr( coords.GetRow(), coords.GetCol() ); }
|
{ return GetCellAttr( coords.GetRow(), coords.GetCol() ); }
|
||||||
|
|
||||||
|
wxGridCellAttrPtr GetCellAttrPtr(int row, int col) const
|
||||||
|
{
|
||||||
|
return wxGridCellAttrPtr(GetCellAttr(row, col));
|
||||||
|
}
|
||||||
|
wxGridCellAttrPtr GetCellAttrPtr(const wxGridCellCoords& coords) const
|
||||||
|
{
|
||||||
|
return wxGridCellAttrPtr(GetCellAttr(coords));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// the default cell attr object for cells that don't have their own
|
// the default cell attr object for cells that don't have their own
|
||||||
wxGridCellAttr* m_defaultCellAttr;
|
wxGridCellAttr* m_defaultCellAttr;
|
||||||
|
|
||||||
|
@@ -95,6 +95,20 @@ protected:
|
|||||||
virtual ~wxGridCellRenderer();
|
virtual ~wxGridCellRenderer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Smart pointer wrapping wxGridCellRenderer.
|
||||||
|
|
||||||
|
wxGridCellRendererPtr takes ownership of wxGridCellRenderer passed to it on
|
||||||
|
construction and calls DecRef() on it automatically when it is destroyed.
|
||||||
|
It also provides transparent access to wxGridCellRenderer methods by allowing
|
||||||
|
to use objects of this class as if they were wxGridCellRenderer pointers.
|
||||||
|
|
||||||
|
@since 3.1.4
|
||||||
|
|
||||||
|
@category{grid}
|
||||||
|
*/
|
||||||
|
typedef wxObjectDataPtr<wxGridCellRenderer> wxGridCellRendererPtr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class wxGridCellAutoWrapStringRenderer
|
@class wxGridCellAutoWrapStringRenderer
|
||||||
|
|
||||||
@@ -591,6 +605,20 @@ protected:
|
|||||||
virtual ~wxGridCellEditor();
|
virtual ~wxGridCellEditor();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Smart pointer wrapping wxGridCellEditor.
|
||||||
|
|
||||||
|
wxGridCellEditorPtr takes ownership of wxGridCellEditor passed to it on
|
||||||
|
construction and calls DecRef() on it automatically when it is destroyed.
|
||||||
|
It also provides transparent access to wxGridCellEditor methods by allowing
|
||||||
|
to use objects of this class as if they were wxGridCellEditor pointers.
|
||||||
|
|
||||||
|
@since 3.1.4
|
||||||
|
|
||||||
|
@category{grid}
|
||||||
|
*/
|
||||||
|
typedef wxObjectDataPtr<wxGridCellEditor> wxGridCellEditorPtr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class wxGridCellAutoWrapStringEditor
|
@class wxGridCellAutoWrapStringEditor
|
||||||
|
|
||||||
@@ -976,6 +1004,10 @@ public:
|
|||||||
changing their attributes from the defaults. An object of this class may be
|
changing their attributes from the defaults. An object of this class may be
|
||||||
returned by wxGridTableBase::GetAttr().
|
returned by wxGridTableBase::GetAttr().
|
||||||
|
|
||||||
|
Note that objects of this class are reference-counted and it's recommended
|
||||||
|
to use wxGridCellAttrPtr smart pointer class when working with them to
|
||||||
|
avoid memory leaks.
|
||||||
|
|
||||||
@library{wxcore}
|
@library{wxcore}
|
||||||
@category{grid}
|
@category{grid}
|
||||||
*/
|
*/
|
||||||
@@ -1054,9 +1086,22 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the cell editor.
|
Returns the cell editor.
|
||||||
|
|
||||||
|
The caller is responsible for calling DecRef() on the returned pointer,
|
||||||
|
use GetEditorPtr() to do it automatically.
|
||||||
*/
|
*/
|
||||||
wxGridCellEditor* GetEditor(const wxGrid* grid, int row, int col) const;
|
wxGridCellEditor* GetEditor(const wxGrid* grid, int row, int col) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the cell editor.
|
||||||
|
|
||||||
|
This method is identical to GetEditor(), but returns a smart pointer,
|
||||||
|
which frees the caller from the need to call DecRef() manually.
|
||||||
|
|
||||||
|
@since 3.1.4
|
||||||
|
*/
|
||||||
|
wxGridCellEditorPtr GetEditorPtr(const wxGrid* grid, int row, int col) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the font.
|
Returns the font.
|
||||||
*/
|
*/
|
||||||
@@ -1087,9 +1132,22 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the cell renderer.
|
Returns the cell renderer.
|
||||||
|
|
||||||
|
The caller is responsible for calling DecRef() on the returned pointer,
|
||||||
|
use GetRendererPtr() to do it automatically.
|
||||||
*/
|
*/
|
||||||
wxGridCellRenderer* GetRenderer(const wxGrid* grid, int row, int col) const;
|
wxGridCellRenderer* GetRenderer(const wxGrid* grid, int row, int col) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the cell editor.
|
||||||
|
|
||||||
|
This method is identical to GetRenderer(), but returns a smart pointer,
|
||||||
|
which frees the caller from the need to call DecRef() manually.
|
||||||
|
|
||||||
|
@since 3.1.4
|
||||||
|
*/
|
||||||
|
wxGridCellRendererPtr GetRendererPtr(const wxGrid* grid, int row, int col) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the text colour.
|
Returns the text colour.
|
||||||
*/
|
*/
|
||||||
@@ -1257,6 +1315,20 @@ protected:
|
|||||||
virtual ~wxGridCellAttr();
|
virtual ~wxGridCellAttr();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Smart pointer wrapping wxGridCellAttr.
|
||||||
|
|
||||||
|
wxGridCellAttrPtr takes ownership of wxGridCellAttr passed to it on
|
||||||
|
construction and calls DecRef() on it automatically when it is destroyed.
|
||||||
|
It also provides transparent access to wxGridCellAttr methods by allowing
|
||||||
|
to use objects of this class as if they were wxGridCellAttr pointers.
|
||||||
|
|
||||||
|
@since 3.1.4
|
||||||
|
|
||||||
|
@category{grid}
|
||||||
|
*/
|
||||||
|
typedef wxObjectDataPtr<wxGridCellAttr> wxGridCellAttrPtr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Base class for header cells renderers.
|
Base class for header cells renderers.
|
||||||
|
|
||||||
@@ -1459,7 +1531,7 @@ public:
|
|||||||
the cell attribute having the highest precedence.
|
the cell attribute having the highest precedence.
|
||||||
|
|
||||||
Notice that the caller must call DecRef() on the returned pointer if it
|
Notice that the caller must call DecRef() on the returned pointer if it
|
||||||
is non-@NULL.
|
is non-@NULL. GetAttrPtr() method can be used to do this automatically.
|
||||||
|
|
||||||
@param row
|
@param row
|
||||||
The row of the cell.
|
The row of the cell.
|
||||||
@@ -1474,6 +1546,17 @@ public:
|
|||||||
virtual wxGridCellAttr *GetAttr(int row, int col,
|
virtual wxGridCellAttr *GetAttr(int row, int col,
|
||||||
wxGridCellAttr::wxAttrKind kind) const;
|
wxGridCellAttr::wxAttrKind kind) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the attribute to use for the specified cell.
|
||||||
|
|
||||||
|
This method is identical to GetAttr(), but returns a smart pointer,
|
||||||
|
which frees the caller from the need to call DecRef() manually.
|
||||||
|
|
||||||
|
@since 3.1.4
|
||||||
|
*/
|
||||||
|
wxGridCellAttrPtr GetAttrPtr(int row, int col,
|
||||||
|
wxGridCellAttr::wxAttrKind kind) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@name Setting attributes.
|
@name Setting attributes.
|
||||||
|
|
||||||
@@ -2121,10 +2204,24 @@ public:
|
|||||||
By default this function is simply forwarded to
|
By default this function is simply forwarded to
|
||||||
wxGridCellAttrProvider::GetAttr() but it may be overridden to handle
|
wxGridCellAttrProvider::GetAttr() but it may be overridden to handle
|
||||||
attributes directly in the table.
|
attributes directly in the table.
|
||||||
|
|
||||||
|
Prefer to use GetAttrPtr() to avoid the need to call DecRef() on the
|
||||||
|
returned pointer manually.
|
||||||
*/
|
*/
|
||||||
virtual wxGridCellAttr *GetAttr(int row, int col,
|
virtual wxGridCellAttr *GetAttr(int row, int col,
|
||||||
wxGridCellAttr::wxAttrKind kind);
|
wxGridCellAttr::wxAttrKind kind);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return the attribute for the given cell.
|
||||||
|
|
||||||
|
This method is identical to GetAttr(), but returns a smart pointer,
|
||||||
|
which frees the caller from the need to call DecRef() manually.
|
||||||
|
|
||||||
|
@since 3.1.4
|
||||||
|
*/
|
||||||
|
wxGridCellAttrPtr GetAttrPtr(int row, int col,
|
||||||
|
wxGridCellAttr::wxAttrKind kind);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set attribute of the specified cell.
|
Set attribute of the specified cell.
|
||||||
|
|
||||||
@@ -4939,10 +5036,24 @@ public:
|
|||||||
attribute is created, associated with the cell and returned. In any
|
attribute is created, associated with the cell and returned. In any
|
||||||
case the caller must call DecRef() on the returned pointer.
|
case the caller must call DecRef() on the returned pointer.
|
||||||
|
|
||||||
|
Prefer to use GetOrCreateCellAttrPtr() to avoid the need to call
|
||||||
|
DecRef() on the returned pointer.
|
||||||
|
|
||||||
This function may only be called if CanHaveAttributes() returns @true.
|
This function may only be called if CanHaveAttributes() returns @true.
|
||||||
*/
|
*/
|
||||||
wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
|
wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the attribute for the given cell creating one if necessary.
|
||||||
|
|
||||||
|
This method is identical to GetOrCreateCellAttr(), but returns a smart
|
||||||
|
pointer, which frees the caller from the need to call DecRef()
|
||||||
|
manually.
|
||||||
|
|
||||||
|
@since 3.1.4
|
||||||
|
*/
|
||||||
|
wxGridCellAttrPtr GetOrCreateCellAttrPtr(int row, int col) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns a base pointer to the current table object.
|
Returns a base pointer to the current table object.
|
||||||
|
|
||||||
|
@@ -2837,8 +2837,8 @@ void wxGrid::CalcDimensions()
|
|||||||
int y = GetRowTop(r);
|
int y = GetRowTop(r);
|
||||||
|
|
||||||
// how big is the editor
|
// how big is the editor
|
||||||
wxGridCellAttr* attr = GetCellAttr(r, c);
|
wxGridCellAttrPtr attr = GetCellAttrPtr(r, c);
|
||||||
wxGridCellEditor* editor = attr->GetEditor(this, r, c);
|
wxGridCellEditorPtr editor = attr->GetEditorPtr(this, r, c);
|
||||||
editor->GetWindow()->GetSize(&w2, &h2);
|
editor->GetWindow()->GetSize(&w2, &h2);
|
||||||
w2 += x;
|
w2 += x;
|
||||||
h2 += y;
|
h2 += y;
|
||||||
@@ -2846,8 +2846,6 @@ void wxGrid::CalcDimensions()
|
|||||||
w = w2;
|
w = w2;
|
||||||
if ( h2 > h )
|
if ( h2 > h )
|
||||||
h = h2;
|
h = h2;
|
||||||
editor->DecRef();
|
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPoint offset = GetGridWindowOffset(m_gridWin);
|
wxPoint offset = GetGridWindowOffset(m_gridWin);
|
||||||
@@ -4484,11 +4482,9 @@ wxGrid::DoGridCellLeftUp(wxMouseEvent& event,
|
|||||||
ClearSelection();
|
ClearSelection();
|
||||||
EnableCellEditControl();
|
EnableCellEditControl();
|
||||||
|
|
||||||
wxGridCellAttr *attr = GetCellAttr(coords);
|
wxGridCellAttrPtr attr = GetCellAttrPtr(coords);
|
||||||
wxGridCellEditor *editor = attr->GetEditor(this, coords.GetRow(), coords.GetCol());
|
wxGridCellEditorPtr editor = attr->GetEditorPtr(this, coords.GetRow(), coords.GetCol());
|
||||||
editor->StartingClick();
|
editor->StartingClick();
|
||||||
editor->DecRef();
|
|
||||||
attr->DecRef();
|
|
||||||
|
|
||||||
m_waitForSlowClick = false;
|
m_waitForSlowClick = false;
|
||||||
}
|
}
|
||||||
@@ -5729,8 +5725,8 @@ void wxGrid::OnChar( wxKeyEvent& event )
|
|||||||
// yes, now check whether the cells editor accepts the key
|
// yes, now check whether the cells editor accepts the key
|
||||||
int row = m_currentCellCoords.GetRow();
|
int row = m_currentCellCoords.GetRow();
|
||||||
int col = m_currentCellCoords.GetCol();
|
int col = m_currentCellCoords.GetCol();
|
||||||
wxGridCellAttr *attr = GetCellAttr(row, col);
|
wxGridCellAttrPtr attr = GetCellAttrPtr(row, col);
|
||||||
wxGridCellEditor *editor = attr->GetEditor(this, row, col);
|
wxGridCellEditorPtr editor = attr->GetEditorPtr(this, row, col);
|
||||||
|
|
||||||
// <F2> is special and will always start editing, for
|
// <F2> is special and will always start editing, for
|
||||||
// other keys - ask the editor itself
|
// other keys - ask the editor itself
|
||||||
@@ -5752,9 +5748,6 @@ void wxGrid::OnChar( wxKeyEvent& event )
|
|||||||
{
|
{
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
editor->DecRef();
|
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -5885,11 +5878,10 @@ bool wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
|
|||||||
#if !defined(__WXMAC__)
|
#if !defined(__WXMAC__)
|
||||||
if ( !GetBatchCount() )
|
if ( !GetBatchCount() )
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr = GetCellAttr( coords );
|
wxGridCellAttrPtr attr = GetCellAttrPtr( coords );
|
||||||
wxClientDC dc( currentGridWindow );
|
wxClientDC dc( currentGridWindow );
|
||||||
PrepareDCFor(dc, currentGridWindow);
|
PrepareDCFor(dc, currentGridWindow);
|
||||||
DrawCellHighlight( dc, attr );
|
DrawCellHighlight( dc, attr.get() );
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -6086,11 +6078,7 @@ void wxGrid::DrawGridCellArea( wxDC& dc, const wxGridCellCoordsArray& cells )
|
|||||||
{
|
{
|
||||||
if (!m_table->IsEmptyCell(row + l, j))
|
if (!m_table->IsEmptyCell(row + l, j))
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr = GetCellAttr(row + l, j);
|
if ( GetCellAttrPtr(row + l, j)->CanOverflow() )
|
||||||
const bool canOverflow = attr->CanOverflow();
|
|
||||||
attr->DecRef();
|
|
||||||
|
|
||||||
if ( canOverflow )
|
|
||||||
{
|
{
|
||||||
wxGridCellCoords cell(row + l, j);
|
wxGridCellCoords cell(row + l, j);
|
||||||
bool marked = false;
|
bool marked = false;
|
||||||
@@ -6177,7 +6165,7 @@ void wxGrid::DrawCell( wxDC& dc, const wxGridCellCoords& coords )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// we draw the cell border ourselves
|
// we draw the cell border ourselves
|
||||||
wxGridCellAttr* attr = GetCellAttr(row, col);
|
wxGridCellAttrPtr attr = GetCellAttrPtr(row, col);
|
||||||
|
|
||||||
bool isCurrent = coords == m_currentCellCoords;
|
bool isCurrent = coords == m_currentCellCoords;
|
||||||
|
|
||||||
@@ -6187,19 +6175,14 @@ void wxGrid::DrawCell( wxDC& dc, const wxGridCellCoords& coords )
|
|||||||
// Note: However, only if it is really _shown_, i.e. not hidden!
|
// Note: However, only if it is really _shown_, i.e. not hidden!
|
||||||
if ( isCurrent && IsCellEditControlShown() )
|
if ( isCurrent && IsCellEditControlShown() )
|
||||||
{
|
{
|
||||||
wxGridCellEditor *editor = attr->GetEditor(this, row, col);
|
attr->GetEditorPtr(this, row, col)->PaintBackground(dc, rect, *attr);
|
||||||
editor->PaintBackground(dc, rect, *attr);
|
|
||||||
editor->DecRef();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// but all the rest is drawn by the cell renderer and hence may be customized
|
// but all the rest is drawn by the cell renderer and hence may be customized
|
||||||
wxGridCellRenderer *renderer = attr->GetRenderer(this, row, col);
|
attr->GetRendererPtr(this, row, col)
|
||||||
renderer->Draw(*this, *attr, dc, rect, row, col, IsInSelection(coords));
|
->Draw(*this, *attr, dc, rect, row, col, IsInSelection(coords));
|
||||||
renderer->DecRef();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGrid::DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr )
|
void wxGrid::DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr )
|
||||||
@@ -6326,9 +6309,8 @@ void wxGrid::DrawHighlight(wxDC& dc, const wxGridCellCoordsArray& cells)
|
|||||||
|
|
||||||
if ( cell == m_currentCellCoords )
|
if ( cell == m_currentCellCoords )
|
||||||
{
|
{
|
||||||
wxGridCellAttr* attr = GetCellAttr(m_currentCellCoords);
|
wxGridCellAttrPtr attr = GetCellAttrPtr(m_currentCellCoords);
|
||||||
DrawCellHighlight(dc, attr);
|
DrawCellHighlight(dc, attr.get());
|
||||||
attr->DecRef();
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -7070,12 +7052,8 @@ void wxGrid::EnableCellEditControl( bool enable )
|
|||||||
|
|
||||||
bool wxGrid::IsCurrentCellReadOnly() const
|
bool wxGrid::IsCurrentCellReadOnly() const
|
||||||
{
|
{
|
||||||
wxGridCellAttr*
|
return const_cast<wxGrid *>(this)->
|
||||||
attr = const_cast<wxGrid *>(this)->GetCellAttr(m_currentCellCoords);
|
GetCellAttrPtr(m_currentCellCoords)->IsReadOnly();
|
||||||
bool readonly = attr->IsReadOnly();
|
|
||||||
attr->DecRef();
|
|
||||||
|
|
||||||
return readonly;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGrid::CanEnableCellControl() const
|
bool wxGrid::CanEnableCellControl() const
|
||||||
@@ -7099,18 +7077,13 @@ bool wxGrid::IsCellEditControlShown() const
|
|||||||
{
|
{
|
||||||
int row = m_currentCellCoords.GetRow();
|
int row = m_currentCellCoords.GetRow();
|
||||||
int col = m_currentCellCoords.GetCol();
|
int col = m_currentCellCoords.GetCol();
|
||||||
wxGridCellAttr* attr = GetCellAttr(row, col);
|
wxGridCellEditorPtr editor = GetCellAttrPtr(row, col)->GetEditorPtr(this, row, col);
|
||||||
wxGridCellEditor* editor = attr->GetEditor(this, row, col);
|
|
||||||
attr->DecRef();
|
|
||||||
|
|
||||||
if ( editor )
|
if ( editor )
|
||||||
{
|
{
|
||||||
if ( editor->IsCreated() )
|
if ( editor->IsCreated() )
|
||||||
{
|
{
|
||||||
isShown = editor->GetWindow()->IsShown();
|
isShown = editor->GetWindow()->IsShown();
|
||||||
}
|
}
|
||||||
|
|
||||||
editor->DecRef();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7149,7 +7122,7 @@ void wxGrid::ShowCellEditControl()
|
|||||||
// might not cover the entire cell
|
// might not cover the entire cell
|
||||||
wxClientDC dc( gridWindow );
|
wxClientDC dc( gridWindow );
|
||||||
PrepareDCFor(dc, gridWindow);
|
PrepareDCFor(dc, gridWindow);
|
||||||
wxGridCellAttr* attr = GetCellAttr(row, col);
|
wxGridCellAttrPtr attr = GetCellAttrPtr(row, col);
|
||||||
dc.SetBrush(wxBrush(attr->GetBackgroundColour()));
|
dc.SetBrush(wxBrush(attr->GetBackgroundColour()));
|
||||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
dc.DrawRectangle(rect);
|
dc.DrawRectangle(rect);
|
||||||
@@ -7170,11 +7143,11 @@ void wxGrid::ShowCellEditControl()
|
|||||||
rect.Deflate(1, 1);
|
rect.Deflate(1, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxGridCellEditor* editor = attr->GetEditor(this, row, col);
|
wxGridCellEditorPtr editor = attr->GetEditorPtr(this, row, col);
|
||||||
if ( !editor->IsCreated() )
|
if ( !editor->IsCreated() )
|
||||||
{
|
{
|
||||||
editor->Create(gridWindow, wxID_ANY,
|
editor->Create(gridWindow, wxID_ANY,
|
||||||
new wxGridCellEditorEvtHandler(this, editor));
|
new wxGridCellEditorEvtHandler(this, editor.get()));
|
||||||
|
|
||||||
// Ensure the editor window has wxWANTS_CHARS flag, so that it
|
// Ensure the editor window has wxWANTS_CHARS flag, so that it
|
||||||
// gets Tab, Enter and Esc keys, which need to be processed
|
// gets Tab, Enter and Esc keys, which need to be processed
|
||||||
@@ -7238,13 +7211,13 @@ void wxGrid::ShowCellEditControl()
|
|||||||
rect.SetRight( client_right - 1 );
|
rect.SetRight( client_right - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
editor->SetCellAttr( attr );
|
editor->SetCellAttr( attr.get() );
|
||||||
editor->SetSize( rect );
|
editor->SetSize( rect );
|
||||||
if (nXMove != 0)
|
if (nXMove != 0)
|
||||||
editor->GetWindow()->Move(
|
editor->GetWindow()->Move(
|
||||||
editor->GetWindow()->GetPosition().x + nXMove,
|
editor->GetWindow()->GetPosition().x + nXMove,
|
||||||
editor->GetWindow()->GetPosition().y );
|
editor->GetWindow()->GetPosition().y );
|
||||||
editor->Show( true, attr );
|
editor->Show( true, attr.get() );
|
||||||
|
|
||||||
// recalc dimensions in case we need to
|
// recalc dimensions in case we need to
|
||||||
// expand the scrolled window to account for editor
|
// expand the scrolled window to account for editor
|
||||||
@@ -7252,9 +7225,6 @@ void wxGrid::ShowCellEditControl()
|
|||||||
|
|
||||||
editor->BeginEdit(row, col, this);
|
editor->BeginEdit(row, col, this);
|
||||||
editor->SetCellAttr(NULL);
|
editor->SetCellAttr(NULL);
|
||||||
|
|
||||||
editor->DecRef();
|
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7266,16 +7236,14 @@ void wxGrid::HideCellEditControl()
|
|||||||
int row = m_currentCellCoords.GetRow();
|
int row = m_currentCellCoords.GetRow();
|
||||||
int col = m_currentCellCoords.GetCol();
|
int col = m_currentCellCoords.GetCol();
|
||||||
|
|
||||||
wxGridCellAttr *attr = GetCellAttr(row, col);
|
wxGridCellAttrPtr attr = GetCellAttrPtr(row, col);
|
||||||
wxGridCellEditor *editor = attr->GetEditor(this, row, col);
|
wxGridCellEditorPtr editor = attr->GetEditorPtr(this, row, col);
|
||||||
const bool editorHadFocus = editor->GetWindow()->IsDescendant(FindFocus());
|
const bool editorHadFocus = editor->GetWindow()->IsDescendant(FindFocus());
|
||||||
|
|
||||||
if ( editor->GetWindow()->GetParent() != m_gridWin )
|
if ( editor->GetWindow()->GetParent() != m_gridWin )
|
||||||
editor->GetWindow()->Reparent(m_gridWin);
|
editor->GetWindow()->Reparent(m_gridWin);
|
||||||
|
|
||||||
editor->Show( false );
|
editor->Show( false );
|
||||||
editor->DecRef();
|
|
||||||
attr->DecRef();
|
|
||||||
|
|
||||||
wxGridWindow *gridWindow = CellToGridWindow(row, col);
|
wxGridWindow *gridWindow = CellToGridWindow(row, col);
|
||||||
// return the focus to the grid itself if the editor had it
|
// return the focus to the grid itself if the editor had it
|
||||||
@@ -7330,8 +7298,8 @@ void wxGrid::DoSaveEditControlValue()
|
|||||||
|
|
||||||
wxString oldval = GetCellValue(row, col);
|
wxString oldval = GetCellValue(row, col);
|
||||||
|
|
||||||
wxGridCellAttr* attr = GetCellAttr(row, col);
|
wxGridCellAttrPtr attr = GetCellAttrPtr(row, col);
|
||||||
wxGridCellEditor* editor = attr->GetEditor(this, row, col);
|
wxGridCellEditorPtr editor = attr->GetEditorPtr(this, row, col);
|
||||||
|
|
||||||
wxString newval;
|
wxString newval;
|
||||||
bool changed = editor->EndEdit(row, col, this, oldval, &newval);
|
bool changed = editor->EndEdit(row, col, this, oldval, &newval);
|
||||||
@@ -7349,9 +7317,6 @@ void wxGrid::DoSaveEditControlValue()
|
|||||||
SetCellValue(row, col, oldval);
|
SetCellValue(row, col, oldval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editor->DecRef();
|
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGrid::OnHideEditor(wxCommandEvent& WXUNUSED(event))
|
void wxGrid::OnHideEditor(wxCommandEvent& WXUNUSED(event))
|
||||||
@@ -8383,9 +8348,8 @@ void wxGrid::SetCellHighlightColour( const wxColour& colour )
|
|||||||
wxClientDC dc( gridWindow );
|
wxClientDC dc( gridWindow );
|
||||||
PrepareDCFor( dc, gridWindow );
|
PrepareDCFor( dc, gridWindow );
|
||||||
|
|
||||||
wxGridCellAttr* attr = GetCellAttr(m_currentCellCoords);
|
wxGridCellAttrPtr attr = GetCellAttrPtr(m_currentCellCoords);
|
||||||
DrawCellHighlight(dc, attr);
|
DrawCellHighlight(dc, attr.get());
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8629,53 +8593,33 @@ wxGridCellEditor *wxGrid::GetDefaultEditor() const
|
|||||||
|
|
||||||
wxColour wxGrid::GetCellBackgroundColour(int row, int col) const
|
wxColour wxGrid::GetCellBackgroundColour(int row, int col) const
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr = GetCellAttr(row, col);
|
return GetCellAttrPtr(row, col)->GetBackgroundColour();
|
||||||
wxColour colour = attr->GetBackgroundColour();
|
|
||||||
attr->DecRef();
|
|
||||||
|
|
||||||
return colour;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxColour wxGrid::GetCellTextColour( int row, int col ) const
|
wxColour wxGrid::GetCellTextColour( int row, int col ) const
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr = GetCellAttr(row, col);
|
return GetCellAttrPtr(row, col)->GetTextColour();
|
||||||
wxColour colour = attr->GetTextColour();
|
|
||||||
attr->DecRef();
|
|
||||||
|
|
||||||
return colour;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFont wxGrid::GetCellFont( int row, int col ) const
|
wxFont wxGrid::GetCellFont( int row, int col ) const
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr = GetCellAttr(row, col);
|
return GetCellAttrPtr(row, col)->GetFont();
|
||||||
wxFont font = attr->GetFont();
|
|
||||||
attr->DecRef();
|
|
||||||
|
|
||||||
return font;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGrid::GetCellAlignment( int row, int col, int *horiz, int *vert ) const
|
void wxGrid::GetCellAlignment( int row, int col, int *horiz, int *vert ) const
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr = GetCellAttr(row, col);
|
return GetCellAttrPtr(row, col)->GetAlignment(horiz, vert);
|
||||||
attr->GetAlignment(horiz, vert);
|
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGridFitMode wxGrid::GetCellFitMode( int row, int col ) const
|
wxGridFitMode wxGrid::GetCellFitMode( int row, int col ) const
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr = GetCellAttr(row, col);
|
return GetCellAttrPtr(row, col)->GetFitMode();
|
||||||
wxGridFitMode fitMode = attr->GetFitMode();
|
|
||||||
attr->DecRef();
|
|
||||||
|
|
||||||
return fitMode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGrid::CellSpan
|
wxGrid::CellSpan
|
||||||
wxGrid::GetCellSize( int row, int col, int *num_rows, int *num_cols ) const
|
wxGrid::GetCellSize( int row, int col, int *num_rows, int *num_cols ) const
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr = GetCellAttr(row, col);
|
GetCellAttrPtr(row, col)->GetSize( num_rows, num_cols );
|
||||||
attr->GetSize( num_rows, num_cols );
|
|
||||||
attr->DecRef();
|
|
||||||
|
|
||||||
if ( *num_rows == 1 && *num_cols == 1 )
|
if ( *num_rows == 1 && *num_cols == 1 )
|
||||||
return CellSpan_None; // just a normal cell
|
return CellSpan_None; // just a normal cell
|
||||||
@@ -8689,29 +8633,17 @@ wxGrid::GetCellSize( int row, int col, int *num_rows, int *num_cols ) const
|
|||||||
|
|
||||||
wxGridCellRenderer* wxGrid::GetCellRenderer(int row, int col) const
|
wxGridCellRenderer* wxGrid::GetCellRenderer(int row, int col) const
|
||||||
{
|
{
|
||||||
wxGridCellAttr* attr = GetCellAttr(row, col);
|
return GetCellAttrPtr(row, col)->GetRenderer(this, row, col);
|
||||||
wxGridCellRenderer* renderer = attr->GetRenderer(this, row, col);
|
|
||||||
attr->DecRef();
|
|
||||||
|
|
||||||
return renderer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGridCellEditor* wxGrid::GetCellEditor(int row, int col) const
|
wxGridCellEditor* wxGrid::GetCellEditor(int row, int col) const
|
||||||
{
|
{
|
||||||
wxGridCellAttr* attr = GetCellAttr(row, col);
|
return GetCellAttrPtr(row, col)->GetEditor(this, row, col);
|
||||||
wxGridCellEditor* editor = attr->GetEditor(this, row, col);
|
|
||||||
attr->DecRef();
|
|
||||||
|
|
||||||
return editor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGrid::IsReadOnly(int row, int col) const
|
bool wxGrid::IsReadOnly(int row, int col) const
|
||||||
{
|
{
|
||||||
wxGridCellAttr* attr = GetCellAttr(row, col);
|
return GetCellAttrPtr(row, col)->IsReadOnly();
|
||||||
bool isReadOnly = attr->IsReadOnly();
|
|
||||||
attr->DecRef();
|
|
||||||
|
|
||||||
return isReadOnly;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -8932,9 +8864,7 @@ void wxGrid::SetCellBackgroundColour( int row, int col, const wxColour& colour )
|
|||||||
{
|
{
|
||||||
if ( CanHaveAttributes() )
|
if ( CanHaveAttributes() )
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr = GetOrCreateCellAttr(row, col);
|
GetOrCreateCellAttrPtr(row, col)->SetBackgroundColour(colour);
|
||||||
attr->SetBackgroundColour(colour);
|
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8942,9 +8872,7 @@ void wxGrid::SetCellTextColour( int row, int col, const wxColour& colour )
|
|||||||
{
|
{
|
||||||
if ( CanHaveAttributes() )
|
if ( CanHaveAttributes() )
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr = GetOrCreateCellAttr(row, col);
|
GetOrCreateCellAttrPtr(row, col)->SetTextColour(colour);
|
||||||
attr->SetTextColour(colour);
|
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8952,9 +8880,7 @@ void wxGrid::SetCellFont( int row, int col, const wxFont& font )
|
|||||||
{
|
{
|
||||||
if ( CanHaveAttributes() )
|
if ( CanHaveAttributes() )
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr = GetOrCreateCellAttr(row, col);
|
GetOrCreateCellAttrPtr(row, col)->SetFont(font);
|
||||||
attr->SetFont(font);
|
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8962,9 +8888,7 @@ void wxGrid::SetCellAlignment( int row, int col, int horiz, int vert )
|
|||||||
{
|
{
|
||||||
if ( CanHaveAttributes() )
|
if ( CanHaveAttributes() )
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr = GetOrCreateCellAttr(row, col);
|
GetOrCreateCellAttrPtr(row, col)->SetAlignment(horiz, vert);
|
||||||
attr->SetAlignment(horiz, vert);
|
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8972,9 +8896,7 @@ void wxGrid::SetCellFitMode( int row, int col, wxGridFitMode fitMode )
|
|||||||
{
|
{
|
||||||
if ( CanHaveAttributes() )
|
if ( CanHaveAttributes() )
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr = GetOrCreateCellAttr(row, col);
|
GetOrCreateCellAttrPtr(row, col)->SetFitMode(fitMode);
|
||||||
attr->SetFitMode(fitMode);
|
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8984,10 +8906,9 @@ void wxGrid::SetCellSize( int row, int col, int num_rows, int num_cols )
|
|||||||
{
|
{
|
||||||
int cell_rows, cell_cols;
|
int cell_rows, cell_cols;
|
||||||
|
|
||||||
wxGridCellAttr *attr = GetOrCreateCellAttr(row, col);
|
wxGridCellAttrPtr attr = GetOrCreateCellAttrPtr(row, col);
|
||||||
attr->GetSize(&cell_rows, &cell_cols);
|
attr->GetSize(&cell_rows, &cell_cols);
|
||||||
attr->SetSize(num_rows, num_cols);
|
attr->SetSize(num_rows, num_cols);
|
||||||
attr->DecRef();
|
|
||||||
|
|
||||||
// Cannot set the size of a cell to 0 or negative values
|
// Cannot set the size of a cell to 0 or negative values
|
||||||
// While it is perfectly legal to do that, this function cannot
|
// While it is perfectly legal to do that, this function cannot
|
||||||
@@ -9008,9 +8929,7 @@ void wxGrid::SetCellSize( int row, int col, int num_rows, int num_cols )
|
|||||||
{
|
{
|
||||||
if ((i != col) || (j != row))
|
if ((i != col) || (j != row))
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr_stub = GetOrCreateCellAttr(j, i);
|
GetOrCreateCellAttrPtr(j, i)->SetSize( 1, 1 );
|
||||||
attr_stub->SetSize( 1, 1 );
|
|
||||||
attr_stub->DecRef();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9027,9 +8946,7 @@ void wxGrid::SetCellSize( int row, int col, int num_rows, int num_cols )
|
|||||||
{
|
{
|
||||||
if ((i != col) || (j != row))
|
if ((i != col) || (j != row))
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr_stub = GetOrCreateCellAttr(j, i);
|
GetOrCreateCellAttrPtr(j, i)->SetSize( row - j, col - i );
|
||||||
attr_stub->SetSize( row - j, col - i );
|
|
||||||
attr_stub->DecRef();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9041,9 +8958,7 @@ void wxGrid::SetCellRenderer(int row, int col, wxGridCellRenderer *renderer)
|
|||||||
{
|
{
|
||||||
if ( CanHaveAttributes() )
|
if ( CanHaveAttributes() )
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr = GetOrCreateCellAttr(row, col);
|
GetOrCreateCellAttrPtr(row, col)->SetRenderer(renderer);
|
||||||
attr->SetRenderer(renderer);
|
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9051,9 +8966,7 @@ void wxGrid::SetCellEditor(int row, int col, wxGridCellEditor* editor)
|
|||||||
{
|
{
|
||||||
if ( CanHaveAttributes() )
|
if ( CanHaveAttributes() )
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr = GetOrCreateCellAttr(row, col);
|
GetOrCreateCellAttrPtr(row, col)->SetEditor(editor);
|
||||||
attr->SetEditor(editor);
|
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9061,9 +8974,7 @@ void wxGrid::SetReadOnly(int row, int col, bool isReadOnly)
|
|||||||
{
|
{
|
||||||
if ( CanHaveAttributes() )
|
if ( CanHaveAttributes() )
|
||||||
{
|
{
|
||||||
wxGridCellAttr *attr = GetOrCreateCellAttr(row, col);
|
GetOrCreateCellAttrPtr(row, col)->SetReadOnly(isReadOnly);
|
||||||
attr->SetReadOnly(isReadOnly);
|
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9548,8 +9459,8 @@ wxGrid::AutoSizeColOrRow(int colOrRow, bool setAsMin, wxGridDirection direction)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get cell ( main cell if CellSpan_Inside ) renderer best size
|
// get cell ( main cell if CellSpan_Inside ) renderer best size
|
||||||
wxGridCellAttr *attr = GetCellAttr(row, col);
|
wxGridCellAttrPtr attr = GetCellAttrPtr(row, col);
|
||||||
wxGridCellRenderer *renderer = attr->GetRenderer(this, row, col);
|
wxGridCellRendererPtr renderer = attr->GetRendererPtr(this, row, col);
|
||||||
if ( renderer )
|
if ( renderer )
|
||||||
{
|
{
|
||||||
extent = column
|
extent = column
|
||||||
@@ -9572,11 +9483,7 @@ wxGrid::AutoSizeColOrRow(int colOrRow, bool setAsMin, wxGridDirection direction)
|
|||||||
|
|
||||||
if ( extent > extentMax )
|
if ( extent > extentMax )
|
||||||
extentMax = extent;
|
extentMax = extent;
|
||||||
|
|
||||||
renderer->DecRef();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attr->DecRef();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// now also compare with the column label extent
|
// now also compare with the column label extent
|
||||||
@@ -10472,15 +10379,11 @@ int wxGridTypeRegistry::FindOrCloneDataType(const wxString& typeName)
|
|||||||
return wxNOT_FOUND;
|
return wxNOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGridCellRenderer *renderer = GetRenderer(index);
|
wxGridCellRenderer* const
|
||||||
wxGridCellRenderer *rendererOld = renderer;
|
renderer = wxGridCellRendererPtr(GetRenderer(index))->Clone();
|
||||||
renderer = renderer->Clone();
|
|
||||||
rendererOld->DecRef();
|
|
||||||
|
|
||||||
wxGridCellEditor *editor = GetEditor(index);
|
wxGridCellEditor* const
|
||||||
wxGridCellEditor *editorOld = editor;
|
editor = wxGridCellEditorPtr(GetEditor(index))->Clone();
|
||||||
editor = editor->Clone();
|
|
||||||
editorOld->DecRef();
|
|
||||||
|
|
||||||
// do it even if there are no parameters to reset them to defaults
|
// do it even if there are no parameters to reset them to defaults
|
||||||
wxString params = typeName.AfterFirst(wxT(':'));
|
wxString params = typeName.AfterFirst(wxT(':'));
|
||||||
|
Reference in New Issue
Block a user