X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/01998c0f97d412f4597ba87b8f593162c4c3b4ca..c5f01deabb423e98bc76610d2bb462f2d28285c8:/src/generic/grid.cpp diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index a07c8edb21..4b0e08f185 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -1461,12 +1461,12 @@ bool wxGridCellChoiceEditor::EndEdit(int row, int col, wxGrid* grid) { wxString value = Combo()->GetValue(); - bool changed = value != m_startValue; + if ( value == m_startValue ) + return false; - if ( changed ) - grid->GetTable()->SetValue(row, col, value); + grid->GetTable()->SetValue(row, col, value); - return changed; + return true; } void wxGridCellChoiceEditor::Reset() @@ -3849,15 +3849,8 @@ wxGrid::wxGrid( wxWindow *parent, m_colMinWidths(GRID_HASH_SIZE), m_rowMinHeights(GRID_HASH_SIZE) { - // in order to make sure that a size event is not - // trigerred in a unfinished state - m_cornerLabelWin = NULL ; - m_rowLabelWin = NULL ; - m_colLabelWin = NULL ; - m_gridWin = NULL ; - - SetBestFittingSize(size); Create(); + SetBestFittingSize(size); } bool wxGrid::Create(wxWindow *parent, wxWindowID id, @@ -3871,8 +3864,8 @@ bool wxGrid::Create(wxWindow *parent, wxWindowID id, m_colMinWidths = wxLongToLongHashMap(GRID_HASH_SIZE) ; m_rowMinHeights = wxLongToLongHashMap(GRID_HASH_SIZE) ; - SetBestFittingSize(size); Create() ; + SetBestFittingSize(size); return true; } @@ -8889,14 +8882,24 @@ void wxGrid::SetDefaultCellFont( const wxFont& font ) m_defaultCellAttr->SetFont(font); } + +// For editors and renderers the type registry takes precedence over the +// default attr, so we need to register the new editor/renderer for the string +// data type in order to make setting a default editor/renderer appear to +// work correctly. + void wxGrid::SetDefaultRenderer(wxGridCellRenderer *renderer) { - m_defaultCellAttr->SetRenderer(renderer); + RegisterDataType(wxGRID_VALUE_STRING, + renderer, + GetDefaultEditorForType(wxGRID_VALUE_STRING)); } void wxGrid::SetDefaultEditor(wxGridCellEditor *editor) { - m_defaultCellAttr->SetEditor(editor); + RegisterDataType(wxGRID_VALUE_STRING, + GetDefaultRendererForType(wxGRID_VALUE_STRING), + editor); } // ---------------------------------------------------------------------------- @@ -9104,9 +9107,10 @@ wxGridCellAttr *wxGrid::GetCellAttr(int row, int col) const wxGridCellAttr *wxGrid::GetOrCreateCellAttr(int row, int col) const { wxGridCellAttr *attr = (wxGridCellAttr *)NULL; + bool canHave = ((wxGrid*)this)->CanHaveAttributes(); - wxCHECK_MSG( m_table, attr, - _T("we may only be called if CanHaveAttributes() returned true and then m_table should be !NULL") ); + wxCHECK_MSG( canHave, attr, _T("Cell attributes not allowed")); + wxCHECK_MSG( m_table, attr, _T("must have a table") ); attr = m_table->GetAttr(row, col, wxGridCellAttr::Cell); if ( !attr )