From 9b4aede26d327d24d9a5d2ee4675b24ecde75cf5 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 16 Feb 2000 17:51:33 +0000 Subject: [PATCH] Added getters/setters for cell and grid-default editors git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6082 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/grid.h | 6 +++++ src/generic/grid.cpp | 56 +++++++++++++++++++++++++++------------ 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index c11656fdd5..836f125827 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -784,6 +784,12 @@ public: wxGridCellRenderer *GetDefaultRenderer() const; wxGridCellRenderer* GetCellRenderer(int row, int col); + // takes ownership of the pointer + void SetDefaultEditor(wxGridCellEditor *editor); + void SetCellEditor(int row, int col, wxGridCellEditor *editor); + wxGridCellEditor *GetDefaultEditor() const; + wxGridCellEditor* GetCellEditor(int row, int col); + // ------ cell value accessors // diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 37688f3073..edc925b87e 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -431,22 +431,10 @@ void wxGridCellEditorEvtHandler::OnKeyDown(wxKeyEvent& event) m_grid->EnableCellEditControl(FALSE); break; -// case WXK_UP: -// case WXK_DOWN: -// case WXK_LEFT: -// case WXK_RIGHT: -// case WXK_PRIOR: -// case WXK_NEXT: -// case WXK_SPACE: -// case WXK_HOME: -// case WXK_END: -// // send the event to the parent grid, skipping the -// // event if nothing happens -// // -// event.Skip( m_grid->ProcessEvent( event ) ); -// break; - case WXK_TAB: + event.Skip( m_grid->ProcessEvent( event ) ); + break; + case WXK_RETURN: if (!m_grid->ProcessEvent(event)) m_editor->HandleReturn(event); @@ -1296,7 +1284,7 @@ bool wxGridStringTable::DeleteRows( size_t pos, size_t numRows ) m_data.Remove( pos ); } } - UpdateAttrRows( pos, -numRows ); + UpdateAttrRows( pos, -((int)numRows) ); if ( GetView() ) { wxGridTableMessage msg( this, @@ -1413,7 +1401,7 @@ bool wxGridStringTable::DeleteCols( size_t pos, size_t numCols ) } } } - UpdateAttrCols( pos, -numCols ); + UpdateAttrCols( pos, -((int)numCols) ); if ( GetView() ) { wxGridTableMessage msg( this, @@ -3551,6 +3539,12 @@ void wxGrid::OnKeyDown( wxKeyEvent& event ) if ( !parent->GetEventHandler()->ProcessEvent( keyEvt ) ) { + + // TODO: Should also support Shift-cursor keys for + // extending the selection. Maybe add a flag to + // MoveCursorXXX() and MoveCursorXXXBlock() and + // just send event.ShiftDown(). + // try local handlers // switch ( event.KeyCode() ) @@ -5186,6 +5180,11 @@ void wxGrid::SetDefaultRenderer(wxGridCellRenderer *renderer) m_defaultCellAttr->SetRenderer(renderer); } +void wxGrid::SetDefaultEditor(wxGridCellEditor *editor) +{ + m_defaultCellAttr->SetEditor(editor); +} + // ---------------------------------------------------------------------------- // access to the default attrbiutes // ---------------------------------------------------------------------------- @@ -5215,6 +5214,11 @@ wxGridCellRenderer *wxGrid::GetDefaultRenderer() const return m_defaultCellAttr->GetRenderer(); } +wxGridCellEditor *wxGrid::GetDefaultEditor() const +{ + return m_defaultCellAttr->GetEditor(); +} + // ---------------------------------------------------------------------------- // access to cell attributes // ---------------------------------------------------------------------------- @@ -5258,6 +5262,14 @@ wxGridCellRenderer* wxGrid::GetCellRenderer(int row, int col) return renderer; } +wxGridCellEditor* wxGrid::GetCellEditor(int row, int col) +{ + wxGridCellAttr* attr = GetCellAttr(row, col); + wxGridCellEditor* editor = attr->GetEditor(); + attr->DecRef(); + return editor; +} + // ---------------------------------------------------------------------------- // attribute support: cache, automatic provider creation, ... // ---------------------------------------------------------------------------- @@ -5448,6 +5460,16 @@ void wxGrid::SetCellRenderer(int row, int col, wxGridCellRenderer *renderer) } } +void wxGrid::SetCellEditor(int row, int col, wxGridCellEditor* editor) +{ + if ( CanHaveAttributes() ) + { + wxGridCellAttr *attr = GetOrCreateCellAttr(row, col); + attr->SetEditor(editor); + attr->DecRef(); + } +} + // ---------------------------------------------------------------------------- // row/col size // ---------------------------------------------------------------------------- -- 2.45.2