X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6d30807295d16ad7bddd2ef03b7dbf91a7a6335a..80a07196b3b9bdafcb36f99ec43accdda3113faa:/src/generic/grid.cpp diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index cc293fb374..4b0e08f185 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -1461,18 +1461,12 @@ bool wxGridCellChoiceEditor::EndEdit(int row, int col, wxGrid* grid) { wxString value = Combo()->GetValue(); - bool changed = value != m_startValue; - - if ( changed ) - grid->GetTable()->SetValue(row, col, value); + if ( value == m_startValue ) + return false; - m_startValue = wxEmptyString; - if (m_allowOthers) - Combo()->SetValue(m_startValue); - else - Combo()->SetSelection(0); + grid->GetTable()->SetValue(row, col, value); - return changed; + return true; } void wxGridCellChoiceEditor::Reset() @@ -3855,10 +3849,8 @@ wxGrid::wxGrid( wxWindow *parent, m_colMinWidths(GRID_HASH_SIZE), m_rowMinHeights(GRID_HASH_SIZE) { - // Can't use SetBestFittingSize here to avoid a crash as CreateGrid hasn't - // been called yet. - SetMinSize(size); Create(); + SetBestFittingSize(size); } bool wxGrid::Create(wxWindow *parent, wxWindowID id, @@ -3872,10 +3864,8 @@ bool wxGrid::Create(wxWindow *parent, wxWindowID id, m_colMinWidths = wxLongToLongHashMap(GRID_HASH_SIZE) ; m_rowMinHeights = wxLongToLongHashMap(GRID_HASH_SIZE) ; - // Can't use SetBestFittingSize here to avoid a crash as CreateGrid hasn't - // been called yet. - SetMinSize(size); Create() ; + SetBestFittingSize(size); return true; } @@ -8892,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); } // ---------------------------------------------------------------------------- @@ -9107,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 ) @@ -9885,8 +9886,10 @@ wxSize wxGrid::DoGetBestSize() const // of the scrollbars, is there any magic incantaion for that? int xpu, ypu; GetScrollPixelsPerUnit(&xpu, &ypu); - width += 1 + xpu - (width % xpu); - height += 1 + ypu - (height % ypu); + if (xpu) + width += 1 + xpu - (width % xpu); + if (ypu) + height += 1 + ypu - (height % ypu); // limit to 1/4 of the screen size int maxwidth, maxheight;