wxGridCellEditor plugged in and operational for strings.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6005 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -122,8 +122,6 @@ public:
|
|||||||
// Creates the actual edit control
|
// Creates the actual edit control
|
||||||
virtual void Create(wxWindow* parent,
|
virtual void Create(wxWindow* parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxPoint& pos,
|
|
||||||
const wxSize& size,
|
|
||||||
wxEvtHandler* evtHandler) = 0;
|
wxEvtHandler* evtHandler) = 0;
|
||||||
|
|
||||||
// Size and position the edit control
|
// Size and position the edit control
|
||||||
@@ -147,6 +145,11 @@ public:
|
|||||||
// Reset the value in the control back to its starting value
|
// Reset the value in the control back to its starting value
|
||||||
virtual void Reset() = 0;
|
virtual void Reset() = 0;
|
||||||
|
|
||||||
|
// If the editor is enabled by pressing keys on the grid, this
|
||||||
|
// will be called to let the editor do something about that key
|
||||||
|
// if desired.
|
||||||
|
virtual void StartingKey(wxKeyEvent& event);
|
||||||
|
|
||||||
// Some types of controls on some platforms may need some help
|
// Some types of controls on some platforms may need some help
|
||||||
// with the Return key.
|
// with the Return key.
|
||||||
virtual void HandleReturn(wxKeyEvent& event);
|
virtual void HandleReturn(wxKeyEvent& event);
|
||||||
@@ -166,8 +169,6 @@ public:
|
|||||||
|
|
||||||
virtual void Create(wxWindow* parent,
|
virtual void Create(wxWindow* parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxPoint& pos,
|
|
||||||
const wxSize& size,
|
|
||||||
wxEvtHandler* evtHandler);
|
wxEvtHandler* evtHandler);
|
||||||
|
|
||||||
virtual void BeginEdit(int row, int col, wxGrid* grid,
|
virtual void BeginEdit(int row, int col, wxGrid* grid,
|
||||||
@@ -177,6 +178,7 @@ public:
|
|||||||
wxGrid* grid, wxGridCellAttr* attr);
|
wxGrid* grid, wxGridCellAttr* attr);
|
||||||
|
|
||||||
virtual void Reset();
|
virtual void Reset();
|
||||||
|
virtual void StartingKey(wxKeyEvent& event);
|
||||||
virtual void HandleReturn(wxKeyEvent& event);
|
virtual void HandleReturn(wxKeyEvent& event);
|
||||||
|
|
||||||
|
|
||||||
@@ -590,12 +592,7 @@ class WXDLLEXPORT wxGrid : public wxScrolledWindow
|
|||||||
public:
|
public:
|
||||||
wxGrid()
|
wxGrid()
|
||||||
{
|
{
|
||||||
m_table = (wxGridTableBase *) NULL;
|
Create();
|
||||||
m_gridWin = (wxGridWindow *) NULL;
|
|
||||||
m_rowLabelWin = (wxGridRowLabelWindow *) NULL;
|
|
||||||
m_colLabelWin = (wxGridColLabelWindow *) NULL;
|
|
||||||
m_cornerLabelWin = (wxGridCornerLabelWindow *) NULL;
|
|
||||||
m_cellEditCtrl = (wxWindow *) NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGrid( wxWindow *parent,
|
wxGrid( wxWindow *parent,
|
||||||
@@ -693,7 +690,7 @@ public:
|
|||||||
void EnableCellEditControl( bool enable );
|
void EnableCellEditControl( bool enable );
|
||||||
|
|
||||||
bool IsCellEditControlEnabled()
|
bool IsCellEditControlEnabled()
|
||||||
{ return (m_cellEditCtrl && m_cellEditCtrlEnabled); }
|
{ return m_cellEditCtrlEnabled; }
|
||||||
|
|
||||||
void ShowCellEditControl();
|
void ShowCellEditControl();
|
||||||
void HideCellEditControl();
|
void HideCellEditControl();
|
||||||
@@ -1154,6 +1151,8 @@ protected:
|
|||||||
// looks for the attr in cache, if not found asks the table and caches the
|
// looks for the attr in cache, if not found asks the table and caches the
|
||||||
// result
|
// result
|
||||||
wxGridCellAttr *GetCellAttr(int row, int col) const;
|
wxGridCellAttr *GetCellAttr(int row, int col) const;
|
||||||
|
wxGridCellAttr *GetCellAttr(const wxGridCellCoords& coords )
|
||||||
|
{ return GetCellAttr( coords.GetRow(), coords.GetCol() ); }
|
||||||
|
|
||||||
// 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;
|
||||||
@@ -1204,8 +1203,6 @@ protected:
|
|||||||
wxCursor m_colResizeCursor;
|
wxCursor m_colResizeCursor;
|
||||||
|
|
||||||
bool m_editable; // applies to whole grid
|
bool m_editable; // applies to whole grid
|
||||||
int m_editCtrlType; // for current cell
|
|
||||||
wxWindow* m_cellEditCtrl;
|
|
||||||
bool m_cellEditCtrlEnabled;
|
bool m_cellEditCtrlEnabled;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -314,19 +314,24 @@ void wxGridCellEditor::HandleReturn(wxKeyEvent& event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wxGridCellEditor::StartingKey(wxKeyEvent& event)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
wxGridCellTextEditor::wxGridCellTextEditor()
|
wxGridCellTextEditor::wxGridCellTextEditor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGridCellTextEditor::Create(wxWindow* parent,
|
void wxGridCellTextEditor::Create(wxWindow* parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxPoint& pos,
|
|
||||||
const wxSize& size,
|
|
||||||
wxEvtHandler* evtHandler)
|
wxEvtHandler* evtHandler)
|
||||||
{
|
{
|
||||||
m_control = new wxTextCtrl(parent, -1, "", pos, size
|
m_control = new wxTextCtrl(parent, -1, "",
|
||||||
|
wxDefaultPosition, wxDefaultSize
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
, wxTE_MULTILINE | wxTE_NO_VSCROLL
|
, wxTE_MULTILINE | wxTE_NO_VSCROLL // necessary ???
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -364,7 +369,9 @@ bool wxGridCellTextEditor::EndEdit(int row, int col, bool saveValue,
|
|||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
grid->GetTable()->SetValue(row, col, value);
|
grid->GetTable()->SetValue(row, col, value);
|
||||||
|
|
||||||
m_startValue = "";
|
m_startValue = "";
|
||||||
|
((wxTextCtrl*)m_control)->SetValue(m_startValue);
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -379,6 +386,22 @@ void wxGridCellTextEditor::Reset()
|
|||||||
((wxTextCtrl*)m_control)->SetInsertionPointEnd();
|
((wxTextCtrl*)m_control)->SetInsertionPointEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wxGridCellTextEditor::StartingKey(wxKeyEvent& event)
|
||||||
|
{
|
||||||
|
wxASSERT_MSG(m_control,
|
||||||
|
wxT("The wxGridCellEditor must be Created first!"));
|
||||||
|
|
||||||
|
int code = event.KeyCode();
|
||||||
|
if (code >= 32 && code < 255) {
|
||||||
|
wxString st((char)code);
|
||||||
|
if (! event.ShiftDown())
|
||||||
|
st.LowerCase();
|
||||||
|
((wxTextCtrl*)m_control)->AppendText(st);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxGridCellTextEditor::HandleReturn(wxKeyEvent& event)
|
void wxGridCellTextEditor::HandleReturn(wxKeyEvent& event)
|
||||||
{
|
{
|
||||||
#if defined(__WXMOTIF__) || defined(__WXGTK__)
|
#if defined(__WXMOTIF__) || defined(__WXGTK__)
|
||||||
@@ -402,33 +425,30 @@ void wxGridCellEditorEvtHandler::OnKeyDown(wxKeyEvent& event)
|
|||||||
{
|
{
|
||||||
case WXK_ESCAPE:
|
case WXK_ESCAPE:
|
||||||
m_editor->Reset();
|
m_editor->Reset();
|
||||||
|
m_grid->EnableCellEditControl(FALSE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WXK_UP:
|
// case WXK_UP:
|
||||||
case WXK_DOWN:
|
// case WXK_DOWN:
|
||||||
case WXK_LEFT:
|
// case WXK_LEFT:
|
||||||
case WXK_RIGHT:
|
// case WXK_RIGHT:
|
||||||
case WXK_PRIOR:
|
// case WXK_PRIOR:
|
||||||
case WXK_NEXT:
|
// case WXK_NEXT:
|
||||||
case WXK_SPACE:
|
// case WXK_SPACE:
|
||||||
// send the event to the parent grid, skipping the
|
// case WXK_HOME:
|
||||||
// event if nothing happens
|
// case WXK_END:
|
||||||
//
|
// // send the event to the parent grid, skipping the
|
||||||
event.Skip( m_grid->ProcessEvent( event ) );
|
// // event if nothing happens
|
||||||
break;
|
// //
|
||||||
|
// event.Skip( m_grid->ProcessEvent( event ) );
|
||||||
|
// break;
|
||||||
|
|
||||||
|
case WXK_TAB:
|
||||||
case WXK_RETURN:
|
case WXK_RETURN:
|
||||||
if (!m_grid->ProcessEvent(event))
|
if (!m_grid->ProcessEvent(event))
|
||||||
m_editor->HandleReturn(event);
|
m_editor->HandleReturn(event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
event.Skip();
|
event.Skip();
|
||||||
@@ -1729,7 +1749,8 @@ void wxGrid::Create()
|
|||||||
|
|
||||||
m_table = (wxGridTableBase *) NULL;
|
m_table = (wxGridTableBase *) NULL;
|
||||||
m_ownTable = FALSE;
|
m_ownTable = FALSE;
|
||||||
m_cellEditCtrl = (wxWindow *) NULL;
|
|
||||||
|
m_cellEditCtrlEnabled = FALSE;
|
||||||
|
|
||||||
m_defaultCellAttr = new wxGridCellAttr;
|
m_defaultCellAttr = new wxGridCellAttr;
|
||||||
m_defaultCellAttr->SetDefAttr(m_defaultCellAttr);
|
m_defaultCellAttr->SetDefAttr(m_defaultCellAttr);
|
||||||
@@ -1921,23 +1942,6 @@ void wxGrid::Init()
|
|||||||
m_inOnKeyDown = FALSE;
|
m_inOnKeyDown = FALSE;
|
||||||
m_batchCount = 0;
|
m_batchCount = 0;
|
||||||
|
|
||||||
// TODO: extend this to other types of controls
|
|
||||||
//
|
|
||||||
m_cellEditCtrl = new wxGridTextCtrl( m_gridWin,
|
|
||||||
this,
|
|
||||||
FALSE,
|
|
||||||
wxGRID_CELLCTRL,
|
|
||||||
"",
|
|
||||||
wxPoint(1,1),
|
|
||||||
wxSize(1,1)
|
|
||||||
#if defined(__WXMSW__)
|
|
||||||
, wxTE_MULTILINE | wxTE_NO_VSCROLL
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
m_cellEditCtrl->Show( FALSE );
|
|
||||||
m_cellEditCtrlEnabled = FALSE;
|
|
||||||
m_editCtrlType = wxGRID_TEXTCTRL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3582,6 +3586,13 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WXK_TAB:
|
||||||
|
if (event.ShiftDown())
|
||||||
|
MoveCursorLeft();
|
||||||
|
else
|
||||||
|
MoveCursorRight();
|
||||||
|
break;
|
||||||
|
|
||||||
case WXK_HOME:
|
case WXK_HOME:
|
||||||
if ( event.ControlDown() )
|
if ( event.ControlDown() )
|
||||||
{
|
{
|
||||||
@@ -3618,6 +3629,7 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
|
|||||||
case WXK_SHIFT:
|
case WXK_SHIFT:
|
||||||
case WXK_ALT:
|
case WXK_ALT:
|
||||||
case WXK_CONTROL:
|
case WXK_CONTROL:
|
||||||
|
case WXK_CAPITAL:
|
||||||
event.Skip();
|
event.Skip();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -3634,9 +3646,11 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
|
|||||||
//
|
//
|
||||||
if ( !IsCellEditControlEnabled() )
|
if ( !IsCellEditControlEnabled() )
|
||||||
EnableCellEditControl( TRUE );
|
EnableCellEditControl( TRUE );
|
||||||
wxKeyEvent evt(event);
|
if (IsCellEditControlEnabled()) {
|
||||||
evt.SetEventObject( m_cellEditCtrl );
|
wxGridCellAttr* attr = GetCellAttr(m_currentCellCoords);
|
||||||
m_cellEditCtrl->GetEventHandler()->ProcessEvent( evt );
|
attr->GetEditor()->StartingKey(event);
|
||||||
|
attr->DecRef();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3669,6 +3683,7 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
|
|||||||
{
|
{
|
||||||
HideCellEditControl();
|
HideCellEditControl();
|
||||||
SaveEditControlValue();
|
SaveEditControlValue();
|
||||||
|
EnableCellEditControl(FALSE);
|
||||||
|
|
||||||
// Clear the old current cell highlight
|
// Clear the old current cell highlight
|
||||||
wxRect r = BlockToDeviceRect(m_currentCellCoords, m_currentCellCoords);
|
wxRect r = BlockToDeviceRect(m_currentCellCoords, m_currentCellCoords);
|
||||||
@@ -4125,35 +4140,30 @@ void wxGrid::EnableEditing( bool edit )
|
|||||||
{
|
{
|
||||||
m_editable = edit;
|
m_editable = edit;
|
||||||
|
|
||||||
// TODO: extend this for other edit control types
|
EnableCellEditControl(m_editable);
|
||||||
//
|
|
||||||
if ( m_editCtrlType == wxGRID_TEXTCTRL )
|
|
||||||
{
|
|
||||||
((wxTextCtrl *)m_cellEditCtrl)->SetEditable( m_editable );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxGrid::EnableCellEditControl( bool enable )
|
void wxGrid::EnableCellEditControl( bool enable )
|
||||||
{
|
{
|
||||||
|
if (! m_editable)
|
||||||
|
return;
|
||||||
|
|
||||||
if ( m_currentCellCoords == wxGridNoCellCoords )
|
if ( m_currentCellCoords == wxGridNoCellCoords )
|
||||||
SetCurrentCell( 0, 0 );
|
SetCurrentCell( 0, 0 );
|
||||||
if ( m_cellEditCtrl &&
|
|
||||||
enable != m_cellEditCtrlEnabled )
|
|
||||||
{
|
|
||||||
|
|
||||||
|
if ( enable != m_cellEditCtrlEnabled )
|
||||||
|
{
|
||||||
if ( enable )
|
if ( enable )
|
||||||
{
|
{
|
||||||
m_cellEditCtrlEnabled = enable;
|
m_cellEditCtrlEnabled = enable;
|
||||||
SetEditControlValue();
|
SetEditControlValue();
|
||||||
// requires m_cellEditCtrlEnabled to be already true
|
|
||||||
ShowCellEditControl();
|
ShowCellEditControl();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HideCellEditControl();
|
HideCellEditControl();
|
||||||
// requires m_cellEditCtrlEnabled to be still true
|
|
||||||
SaveEditControlValue();
|
SaveEditControlValue();
|
||||||
m_cellEditCtrlEnabled = enable;
|
m_cellEditCtrlEnabled = enable;
|
||||||
}
|
}
|
||||||
@@ -4163,8 +4173,6 @@ void wxGrid::EnableCellEditControl( bool enable )
|
|||||||
|
|
||||||
void wxGrid::ShowCellEditControl()
|
void wxGrid::ShowCellEditControl()
|
||||||
{
|
{
|
||||||
wxRect rect;
|
|
||||||
|
|
||||||
if ( IsCellEditControlEnabled() )
|
if ( IsCellEditControlEnabled() )
|
||||||
{
|
{
|
||||||
if ( !IsVisible( m_currentCellCoords ) )
|
if ( !IsVisible( m_currentCellCoords ) )
|
||||||
@@ -4173,7 +4181,9 @@ void wxGrid::ShowCellEditControl()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rect = CellToRect( m_currentCellCoords );
|
wxRect rect = CellToRect( m_currentCellCoords );
|
||||||
|
int row = m_currentCellCoords.GetRow();
|
||||||
|
int col = m_currentCellCoords.GetCol();
|
||||||
|
|
||||||
// convert to scrolled coords
|
// convert to scrolled coords
|
||||||
//
|
//
|
||||||
@@ -4189,8 +4199,7 @@ void wxGrid::ShowCellEditControl()
|
|||||||
//
|
//
|
||||||
int extra;
|
int extra;
|
||||||
#if defined(__WXMOTIF__)
|
#if defined(__WXMOTIF__)
|
||||||
if ( m_currentCellCoords.GetRow() == 0 ||
|
if ( row == 0 || col == 0 )
|
||||||
m_currentCellCoords.GetCol() == 0 )
|
|
||||||
{
|
{
|
||||||
extra = 2;
|
extra = 2;
|
||||||
}
|
}
|
||||||
@@ -4199,8 +4208,7 @@ void wxGrid::ShowCellEditControl()
|
|||||||
extra = 4;
|
extra = 4;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ( m_currentCellCoords.GetRow() == 0 ||
|
if ( row == 0 || col == 0 )
|
||||||
m_currentCellCoords.GetCol() == 0 )
|
|
||||||
{
|
{
|
||||||
extra = 1;
|
extra = 1;
|
||||||
}
|
}
|
||||||
@@ -4226,33 +4234,18 @@ void wxGrid::ShowCellEditControl()
|
|||||||
rect.SetBottom( rect.GetBottom() + 2*extra );
|
rect.SetBottom( rect.GetBottom() + 2*extra );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_cellEditCtrl->SetSize( rect );
|
wxGridCellAttr* attr = GetCellAttr(row, col);
|
||||||
m_cellEditCtrl->Show( TRUE );
|
wxGridCellEditor* editor = attr->GetEditor();
|
||||||
|
if (! editor->IsCreated()) {
|
||||||
switch ( m_editCtrlType )
|
editor->Create(m_gridWin, -1,
|
||||||
{
|
new wxGridCellEditorEvtHandler(this, editor));
|
||||||
case wxGRID_TEXTCTRL:
|
|
||||||
((wxTextCtrl *) m_cellEditCtrl)->SetInsertionPointEnd();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxGRID_CHECKBOX:
|
|
||||||
// TODO: anything ???
|
|
||||||
//
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxGRID_CHOICE:
|
|
||||||
// TODO: anything ???
|
|
||||||
//
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxGRID_COMBOBOX:
|
|
||||||
// TODO: anything ???
|
|
||||||
//
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_cellEditCtrl->SetFocus();
|
editor->SetSize( rect );
|
||||||
}
|
editor->Show( TRUE );
|
||||||
|
editor->BeginEdit(row, col, this, attr);
|
||||||
|
attr->DecRef();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4261,94 +4254,34 @@ void wxGrid::HideCellEditControl()
|
|||||||
{
|
{
|
||||||
if ( IsCellEditControlEnabled() )
|
if ( IsCellEditControlEnabled() )
|
||||||
{
|
{
|
||||||
m_cellEditCtrl->Show( FALSE );
|
int row = m_currentCellCoords.GetRow();
|
||||||
SetFocus();
|
int col = m_currentCellCoords.GetCol();
|
||||||
|
|
||||||
|
wxGridCellAttr* attr = GetCellAttr(row, col);
|
||||||
|
attr->GetEditor()->Show( FALSE );
|
||||||
|
attr->DecRef();
|
||||||
|
m_gridWin->SetFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxGrid::SetEditControlValue( const wxString& value )
|
void wxGrid::SetEditControlValue( const wxString& value )
|
||||||
{
|
{
|
||||||
if ( m_table )
|
|
||||||
{
|
|
||||||
wxString s;
|
|
||||||
if ( !value )
|
|
||||||
s = GetCellValue(m_currentCellCoords);
|
|
||||||
else
|
|
||||||
s = value;
|
|
||||||
|
|
||||||
if ( IsCellEditControlEnabled() )
|
|
||||||
{
|
|
||||||
switch ( m_editCtrlType )
|
|
||||||
{
|
|
||||||
case wxGRID_TEXTCTRL:
|
|
||||||
((wxGridTextCtrl *)m_cellEditCtrl)->SetStartValue(s);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxGRID_CHECKBOX:
|
|
||||||
// TODO: implement this
|
|
||||||
//
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxGRID_CHOICE:
|
|
||||||
// TODO: implement this
|
|
||||||
//
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxGRID_COMBOBOX:
|
|
||||||
// TODO: implement this
|
|
||||||
//
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxGrid::SaveEditControlValue()
|
void wxGrid::SaveEditControlValue()
|
||||||
{
|
{
|
||||||
if ( m_table )
|
if (IsCellEditControlEnabled()) {
|
||||||
{
|
int row = m_currentCellCoords.GetRow();
|
||||||
wxWindow *ctrl = (wxWindow *)NULL;
|
int col = m_currentCellCoords.GetCol();
|
||||||
|
|
||||||
if ( IsCellEditControlEnabled() )
|
wxGridCellAttr* attr = GetCellAttr(row, col);
|
||||||
{
|
bool changed = attr->GetEditor()->EndEdit(row, col, TRUE, this, attr);
|
||||||
ctrl = m_cellEditCtrl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool valueChanged = FALSE;
|
attr->DecRef();
|
||||||
|
|
||||||
switch ( m_editCtrlType )
|
if (changed) {
|
||||||
{
|
|
||||||
case wxGRID_TEXTCTRL:
|
|
||||||
valueChanged = (((wxGridTextCtrl *)ctrl)->GetValue() !=
|
|
||||||
((wxGridTextCtrl *)ctrl)->GetStartValue());
|
|
||||||
SetCellValue( m_currentCellCoords,
|
|
||||||
((wxTextCtrl *) ctrl)->GetValue() );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxGRID_CHECKBOX:
|
|
||||||
// TODO: implement this
|
|
||||||
//
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxGRID_CHOICE:
|
|
||||||
// TODO: implement this
|
|
||||||
//
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxGRID_COMBOBOX:
|
|
||||||
// TODO: implement this
|
|
||||||
//
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( valueChanged )
|
|
||||||
{
|
|
||||||
SendEvent( EVT_GRID_CELL_CHANGE,
|
SendEvent( EVT_GRID_CELL_CHANGE,
|
||||||
m_currentCellCoords.GetRow(),
|
m_currentCellCoords.GetRow(),
|
||||||
m_currentCellCoords.GetCol() );
|
m_currentCellCoords.GetCol() );
|
||||||
|
Reference in New Issue
Block a user