1. EVT_GRID_XXX constants renamed to wxEVT_GRID_XXX
2. EVT_GRID_EDITOR_SHOWN/HIDDEN added 3. Alt-X now work in the grid (instead of being eaten in StartingKey) 4. added CanEnableCellControl() and use it before calling EnableEC git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6106 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -185,6 +185,8 @@ public:
|
|||||||
virtual void StartingKey(wxKeyEvent& event);
|
virtual void StartingKey(wxKeyEvent& event);
|
||||||
virtual void HandleReturn(wxKeyEvent& event);
|
virtual void HandleReturn(wxKeyEvent& event);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxTextCtrl *Text() const { return (wxTextCtrl *)m_control; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxString m_startValue;
|
wxString m_startValue;
|
||||||
@@ -675,9 +677,12 @@ public:
|
|||||||
bool IsEditable() { return m_editable; }
|
bool IsEditable() { return m_editable; }
|
||||||
void EnableEditing( bool edit );
|
void EnableEditing( bool edit );
|
||||||
|
|
||||||
void EnableCellEditControl( bool enable );
|
void EnableCellEditControl( bool enable = TRUE );
|
||||||
|
void DisableCellEditControl() { EnableCellEditControl(FALSE); }
|
||||||
|
bool CanEnableCellControl() const;
|
||||||
|
bool IsCellEditControlEnabled() const;
|
||||||
|
|
||||||
bool IsCellEditControlEnabled();
|
bool IsCurrentCellReadOnly() const;
|
||||||
|
|
||||||
void ShowCellEditControl();
|
void ShowCellEditControl();
|
||||||
void HideCellEditControl();
|
void HideCellEditControl();
|
||||||
@@ -1199,7 +1204,7 @@ protected:
|
|||||||
wxCursor m_colResizeCursor;
|
wxCursor m_colResizeCursor;
|
||||||
|
|
||||||
bool m_editable; // applies to whole grid
|
bool m_editable; // applies to whole grid
|
||||||
bool m_cellEditCtrlEnabled;
|
bool m_cellEditCtrlEnabled; // is in-place edit currently shown?
|
||||||
|
|
||||||
|
|
||||||
void Create();
|
void Create();
|
||||||
@@ -1209,13 +1214,14 @@ protected:
|
|||||||
bool Redimension( wxGridTableMessage& );
|
bool Redimension( wxGridTableMessage& );
|
||||||
|
|
||||||
|
|
||||||
bool SendEvent( const wxEventType,
|
bool SendEvent( const wxEventType, int row, int col, wxMouseEvent& );
|
||||||
int row, int col,
|
bool SendEvent( const wxEventType, int row, int col );
|
||||||
wxMouseEvent& );
|
bool SendEvent( const wxEventType type)
|
||||||
|
{
|
||||||
bool SendEvent( const wxEventType,
|
return SendEvent(type,
|
||||||
int row, int col );
|
m_currentCellCoords.GetRow(),
|
||||||
|
m_currentCellCoords.GetCol());
|
||||||
|
}
|
||||||
|
|
||||||
void OnPaint( wxPaintEvent& );
|
void OnPaint( wxPaintEvent& );
|
||||||
void OnSize( wxSizeEvent& );
|
void OnSize( wxSizeEvent& );
|
||||||
@@ -1280,7 +1286,6 @@ protected:
|
|||||||
DECLARE_DYNAMIC_CLASS(wxGridEvent)
|
DECLARE_DYNAMIC_CLASS(wxGridEvent)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxGridSizeEvent : public wxNotifyEvent
|
class WXDLLEXPORT wxGridSizeEvent : public wxNotifyEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -1356,50 +1361,54 @@ protected:
|
|||||||
DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent)
|
DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO move to wx/event.h
|
||||||
const wxEventType EVT_GRID_CELL_LEFT_CLICK = wxEVT_FIRST + 1580;
|
const wxEventType wxEVT_GRID_CELL_LEFT_CLICK = wxEVT_FIRST + 1580;
|
||||||
const wxEventType EVT_GRID_CELL_RIGHT_CLICK = wxEVT_FIRST + 1581;
|
const wxEventType wxEVT_GRID_CELL_RIGHT_CLICK = wxEVT_FIRST + 1581;
|
||||||
const wxEventType EVT_GRID_CELL_LEFT_DCLICK = wxEVT_FIRST + 1582;
|
const wxEventType wxEVT_GRID_CELL_LEFT_DCLICK = wxEVT_FIRST + 1582;
|
||||||
const wxEventType EVT_GRID_CELL_RIGHT_DCLICK = wxEVT_FIRST + 1583;
|
const wxEventType wxEVT_GRID_CELL_RIGHT_DCLICK = wxEVT_FIRST + 1583;
|
||||||
const wxEventType EVT_GRID_LABEL_LEFT_CLICK = wxEVT_FIRST + 1584;
|
const wxEventType wxEVT_GRID_LABEL_LEFT_CLICK = wxEVT_FIRST + 1584;
|
||||||
const wxEventType EVT_GRID_LABEL_RIGHT_CLICK = wxEVT_FIRST + 1585;
|
const wxEventType wxEVT_GRID_LABEL_RIGHT_CLICK = wxEVT_FIRST + 1585;
|
||||||
const wxEventType EVT_GRID_LABEL_LEFT_DCLICK = wxEVT_FIRST + 1586;
|
const wxEventType wxEVT_GRID_LABEL_LEFT_DCLICK = wxEVT_FIRST + 1586;
|
||||||
const wxEventType EVT_GRID_LABEL_RIGHT_DCLICK = wxEVT_FIRST + 1587;
|
const wxEventType wxEVT_GRID_LABEL_RIGHT_DCLICK = wxEVT_FIRST + 1587;
|
||||||
const wxEventType EVT_GRID_ROW_SIZE = wxEVT_FIRST + 1588;
|
const wxEventType wxEVT_GRID_ROW_SIZE = wxEVT_FIRST + 1588;
|
||||||
const wxEventType EVT_GRID_COL_SIZE = wxEVT_FIRST + 1589;
|
const wxEventType wxEVT_GRID_COL_SIZE = wxEVT_FIRST + 1589;
|
||||||
const wxEventType EVT_GRID_RANGE_SELECT = wxEVT_FIRST + 1590;
|
const wxEventType wxEVT_GRID_RANGE_SELECT = wxEVT_FIRST + 1590;
|
||||||
const wxEventType EVT_GRID_CELL_CHANGE = wxEVT_FIRST + 1591;
|
const wxEventType wxEVT_GRID_CELL_CHANGE = wxEVT_FIRST + 1591;
|
||||||
const wxEventType EVT_GRID_SELECT_CELL = wxEVT_FIRST + 1592;
|
const wxEventType wxEVT_GRID_SELECT_CELL = wxEVT_FIRST + 1592;
|
||||||
|
const wxEventType wxEVT_GRID_EDITOR_SHOWN = wxEVT_FIRST + 1593;
|
||||||
|
const wxEventType wxEVT_GRID_EDITOR_HIDDEN = wxEVT_FIRST + 1594;
|
||||||
|
|
||||||
|
|
||||||
typedef void (wxEvtHandler::*wxGridEventFunction)(wxGridEvent&);
|
typedef void (wxEvtHandler::*wxGridEventFunction)(wxGridEvent&);
|
||||||
typedef void (wxEvtHandler::*wxGridSizeEventFunction)(wxGridSizeEvent&);
|
typedef void (wxEvtHandler::*wxGridSizeEventFunction)(wxGridSizeEvent&);
|
||||||
typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction)(wxGridRangeSelectEvent&);
|
typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction)(wxGridRangeSelectEvent&);
|
||||||
|
|
||||||
#define EVT_GRID_CELL_LEFT_CLICK(fn) { EVT_GRID_CELL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
#define EVT_GRID_CELL_LEFT_CLICK(fn) { wxEVT_GRID_CELL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
||||||
#define EVT_GRID_CELL_RIGHT_CLICK(fn) { EVT_GRID_CELL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
#define EVT_GRID_CELL_RIGHT_CLICK(fn) { wxEVT_GRID_CELL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
||||||
#define EVT_GRID_CELL_LEFT_DCLICK(fn) { EVT_GRID_CELL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
#define EVT_GRID_CELL_LEFT_DCLICK(fn) { wxEVT_GRID_CELL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
||||||
#define EVT_GRID_CELL_RIGHT_DCLICK(fn) { EVT_GRID_CELL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
#define EVT_GRID_CELL_RIGHT_DCLICK(fn) { wxEVT_GRID_CELL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
||||||
#define EVT_GRID_LABEL_LEFT_CLICK(fn) { EVT_GRID_LABEL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
#define EVT_GRID_LABEL_LEFT_CLICK(fn) { wxEVT_GRID_LABEL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
||||||
#define EVT_GRID_LABEL_RIGHT_CLICK(fn) { EVT_GRID_LABEL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
#define EVT_GRID_LABEL_RIGHT_CLICK(fn) { wxEVT_GRID_LABEL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
||||||
#define EVT_GRID_LABEL_LEFT_DCLICK(fn) { EVT_GRID_LABEL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
#define EVT_GRID_LABEL_LEFT_DCLICK(fn) { wxEVT_GRID_LABEL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
||||||
#define EVT_GRID_LABEL_RIGHT_DCLICK(fn) { EVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
#define EVT_GRID_LABEL_RIGHT_DCLICK(fn) { wxEVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
||||||
#define EVT_GRID_ROW_SIZE(fn) { EVT_GRID_ROW_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL },
|
#define EVT_GRID_ROW_SIZE(fn) { wxEVT_GRID_ROW_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL },
|
||||||
#define EVT_GRID_COL_SIZE(fn) { EVT_GRID_COL_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL },
|
#define EVT_GRID_COL_SIZE(fn) { wxEVT_GRID_COL_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL },
|
||||||
#define EVT_GRID_RANGE_SELECT(fn) { EVT_GRID_RANGE_SELECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridRangeSelectEventFunction) &fn, NULL },
|
#define EVT_GRID_RANGE_SELECT(fn) { wxEVT_GRID_RANGE_SELECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridRangeSelectEventFunction) &fn, NULL },
|
||||||
#define EVT_GRID_CELL_CHANGE(fn) { EVT_GRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
#define EVT_GRID_CELL_CHANGE(fn) { wxEVT_GRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
||||||
#define EVT_GRID_SELECT_CELL(fn) { EVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
#define EVT_GRID_SELECT_CELL(fn) { wxEVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
||||||
|
#define EVT_GRID_EDITOR_SHOWN(fn) { wxEVT_GRID_EDITOR_SHOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
||||||
|
#define EVT_GRID_EDITOR_HIDDEN(fn) { wxEVT_GRID_EDITOR_HIDDEN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
||||||
|
|
||||||
|
|
||||||
#if 0 // TODO: implement these ? others ?
|
#if 0 // TODO: implement these ? others ?
|
||||||
|
|
||||||
const wxEventType EVT_GRID_CREATE_CELL = wxEVT_FIRST + 1576;
|
const wxEventType wxEVT_GRID_CREATE_CELL = wxEVT_FIRST + 1576;
|
||||||
const wxEventType EVT_GRID_CHANGE_LABELS = wxEVT_FIRST + 1577;
|
const wxEventType wxEVT_GRID_CHANGE_LABELS = wxEVT_FIRST + 1577;
|
||||||
const wxEventType EVT_GRID_CHANGE_SEL_LABEL = wxEVT_FIRST + 1578;
|
const wxEventType wxEVT_GRID_CHANGE_SEL_LABEL = wxEVT_FIRST + 1578;
|
||||||
|
|
||||||
#define EVT_GRID_CREATE_CELL(fn) { EVT_GRID_CREATE_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
#define EVT_GRID_CREATE_CELL(fn) { wxEVT_GRID_CREATE_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
||||||
#define EVT_GRID_CHANGE_LABELS(fn) { EVT_GRID_CHANGE_LABELS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
#define EVT_GRID_CHANGE_LABELS(fn) { wxEVT_GRID_CHANGE_LABELS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
||||||
#define EVT_GRID_CHANGE_SEL_LABEL(fn) { EVT_GRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
#define EVT_GRID_CHANGE_SEL_LABEL(fn) { wxEVT_GRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -95,6 +95,9 @@ BEGIN_EVENT_TABLE( GridFrame, wxFrame )
|
|||||||
EVT_GRID_SELECT_CELL( GridFrame::OnSelectCell )
|
EVT_GRID_SELECT_CELL( GridFrame::OnSelectCell )
|
||||||
EVT_GRID_RANGE_SELECT( GridFrame::OnRangeSelected )
|
EVT_GRID_RANGE_SELECT( GridFrame::OnRangeSelected )
|
||||||
EVT_GRID_CELL_CHANGE( GridFrame::OnCellValueChanged )
|
EVT_GRID_CELL_CHANGE( GridFrame::OnCellValueChanged )
|
||||||
|
|
||||||
|
EVT_GRID_EDITOR_SHOWN( GridFrame::OnEditorShown )
|
||||||
|
EVT_GRID_EDITOR_HIDDEN( GridFrame::OnEditorHidden )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
@@ -574,6 +577,19 @@ void GridFrame::OnCellValueChanged( wxGridEvent& ev )
|
|||||||
ev.Skip();
|
ev.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GridFrame::OnEditorShown( wxGridEvent& ev )
|
||||||
|
{
|
||||||
|
wxLogMessage( "Cell editor shown." );
|
||||||
|
|
||||||
|
ev.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridFrame::OnEditorHidden( wxGridEvent& ev )
|
||||||
|
{
|
||||||
|
wxLogMessage( "Cell editor hidden." );
|
||||||
|
|
||||||
|
ev.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
void GridFrame::About( wxCommandEvent& WXUNUSED(ev) )
|
void GridFrame::About( wxCommandEvent& WXUNUSED(ev) )
|
||||||
{
|
{
|
||||||
|
@@ -62,6 +62,9 @@ class GridFrame : public wxFrame
|
|||||||
void OnRangeSelected( wxGridRangeSelectEvent& );
|
void OnRangeSelected( wxGridRangeSelectEvent& );
|
||||||
void OnCellValueChanged( wxGridEvent& );
|
void OnCellValueChanged( wxGridEvent& );
|
||||||
|
|
||||||
|
void OnEditorShown(wxGridEvent&);
|
||||||
|
void OnEditorHidden(wxGridEvent&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GridFrame();
|
GridFrame();
|
||||||
~GridFrame();
|
~GridFrame();
|
||||||
|
@@ -274,7 +274,6 @@ static const size_t GRID_SCROLL_LINE = 10;
|
|||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxGridCellEditor
|
// wxGridCellEditor
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -370,9 +369,16 @@ void wxGridCellEditor::HandleReturn(wxKeyEvent& event)
|
|||||||
|
|
||||||
void wxGridCellEditor::StartingKey(wxKeyEvent& event)
|
void wxGridCellEditor::StartingKey(wxKeyEvent& event)
|
||||||
{
|
{
|
||||||
|
wxASSERT_MSG(m_control,
|
||||||
|
wxT("The wxGridCellEditor must be Created first!"));
|
||||||
|
|
||||||
|
// pass the event to the control
|
||||||
|
m_control->GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxGridCellTextEditor
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxGridCellTextEditor::wxGridCellTextEditor()
|
wxGridCellTextEditor::wxGridCellTextEditor()
|
||||||
{
|
{
|
||||||
@@ -400,9 +406,9 @@ void wxGridCellTextEditor::BeginEdit(int row, int col, wxGrid* grid)
|
|||||||
wxT("The wxGridCellEditor must be Created first!"));
|
wxT("The wxGridCellEditor must be Created first!"));
|
||||||
|
|
||||||
m_startValue = grid->GetTable()->GetValue(row, col);
|
m_startValue = grid->GetTable()->GetValue(row, col);
|
||||||
((wxTextCtrl*)m_control)->SetValue(m_startValue);
|
Text()->SetValue(m_startValue);
|
||||||
((wxTextCtrl*)m_control)->SetInsertionPointEnd();
|
Text()->SetInsertionPointEnd();
|
||||||
((wxTextCtrl*)m_control)->SetFocus();
|
Text()->SetFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -414,7 +420,7 @@ bool wxGridCellTextEditor::EndEdit(int row, int col, bool saveValue,
|
|||||||
wxT("The wxGridCellEditor must be Created first!"));
|
wxT("The wxGridCellEditor must be Created first!"));
|
||||||
|
|
||||||
bool changed = FALSE;
|
bool changed = FALSE;
|
||||||
wxString value = ((wxTextCtrl*)m_control)->GetValue();
|
wxString value = Text()->GetValue();
|
||||||
if (value != m_startValue)
|
if (value != m_startValue)
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
|
|
||||||
@@ -422,7 +428,7 @@ bool wxGridCellTextEditor::EndEdit(int row, int col, bool saveValue,
|
|||||||
grid->GetTable()->SetValue(row, col, value);
|
grid->GetTable()->SetValue(row, col, value);
|
||||||
|
|
||||||
m_startValue = wxEmptyString;
|
m_startValue = wxEmptyString;
|
||||||
((wxTextCtrl*)m_control)->SetValue(m_startValue);
|
Text()->SetValue(m_startValue);
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -433,35 +439,43 @@ void wxGridCellTextEditor::Reset()
|
|||||||
wxASSERT_MSG(m_control,
|
wxASSERT_MSG(m_control,
|
||||||
wxT("The wxGridCellEditor must be Created first!"));
|
wxT("The wxGridCellEditor must be Created first!"));
|
||||||
|
|
||||||
((wxTextCtrl*)m_control)->SetValue(m_startValue);
|
Text()->SetValue(m_startValue);
|
||||||
((wxTextCtrl*)m_control)->SetInsertionPointEnd();
|
Text()->SetInsertionPointEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxGridCellTextEditor::StartingKey(wxKeyEvent& event)
|
void wxGridCellTextEditor::StartingKey(wxKeyEvent& event)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG(m_control,
|
if ( !event.AltDown() && !event.MetaDown() && !event.ControlDown() )
|
||||||
wxT("The wxGridCellEditor must be Created first!"));
|
{
|
||||||
|
// insert the key in the control
|
||||||
int code = event.KeyCode();
|
long keycode = event.KeyCode();
|
||||||
if (code >= 32 && code < 255) {
|
if ( isprint(keycode) )
|
||||||
wxString st((char)code);
|
{
|
||||||
if (! event.ShiftDown())
|
// FIXME this is not going to work for non letters...
|
||||||
st.LowerCase();
|
if ( !event.ShiftDown() )
|
||||||
((wxTextCtrl*)m_control)->AppendText(st);
|
{
|
||||||
|
keycode = tolower(keycode);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
Text()->AppendText((wxChar)keycode);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
void wxGridCellTextEditor::HandleReturn(wxKeyEvent& event)
|
void wxGridCellTextEditor::HandleReturn(wxKeyEvent& event)
|
||||||
{
|
{
|
||||||
#if defined(__WXMOTIF__) || defined(__WXGTK__)
|
#if defined(__WXMOTIF__) || defined(__WXGTK__)
|
||||||
// wxMotif needs a little extra help...
|
// wxMotif needs a little extra help...
|
||||||
int pos = ((wxTextCtrl*)m_control)->GetInsertionPoint();
|
int pos = Text()->GetInsertionPoint();
|
||||||
wxString s( ((wxTextCtrl*)m_control)->GetValue() );
|
wxString s( Text()->GetValue() );
|
||||||
s = s.Left(pos) + "\n" + s.Mid(pos);
|
s = s.Left(pos) + "\n" + s.Mid(pos);
|
||||||
((wxTextCtrl*)m_control)->SetValue(s);
|
Text()->SetValue(s);
|
||||||
((wxTextCtrl*)m_control)->SetInsertionPoint( pos );
|
Text()->SetInsertionPoint( pos );
|
||||||
#else
|
#else
|
||||||
// the other ports can handle a Return key press
|
// the other ports can handle a Return key press
|
||||||
//
|
//
|
||||||
@@ -476,7 +490,7 @@ void wxGridCellEditorEvtHandler::OnKeyDown(wxKeyEvent& event)
|
|||||||
{
|
{
|
||||||
case WXK_ESCAPE:
|
case WXK_ESCAPE:
|
||||||
m_editor->Reset();
|
m_editor->Reset();
|
||||||
m_grid->EnableCellEditControl(FALSE);
|
m_grid->DisableCellEditControl();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WXK_TAB:
|
case WXK_TAB:
|
||||||
@@ -2476,7 +2490,7 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
|
|||||||
{
|
{
|
||||||
row = YToRow(y);
|
row = YToRow(y);
|
||||||
if ( row >= 0 &&
|
if ( row >= 0 &&
|
||||||
!SendEvent( EVT_GRID_LABEL_LEFT_CLICK, row, -1, event ) )
|
!SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, row, -1, event ) )
|
||||||
{
|
{
|
||||||
SelectRow( row, event.ShiftDown() );
|
SelectRow( row, event.ShiftDown() );
|
||||||
ChangeCursorMode(WXGRID_CURSOR_SELECT_ROW, m_rowLabelWin);
|
ChangeCursorMode(WXGRID_CURSOR_SELECT_ROW, m_rowLabelWin);
|
||||||
@@ -2498,7 +2512,7 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
|
|||||||
if ( YToEdgeOfRow(y) < 0 )
|
if ( YToEdgeOfRow(y) < 0 )
|
||||||
{
|
{
|
||||||
row = YToRow(y);
|
row = YToRow(y);
|
||||||
SendEvent( EVT_GRID_LABEL_LEFT_DCLICK, row, -1, event );
|
SendEvent( wxEVT_GRID_LABEL_LEFT_DCLICK, row, -1, event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2514,7 +2528,7 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
|
|||||||
// Note: we are ending the event *after* doing
|
// Note: we are ending the event *after* doing
|
||||||
// default processing in this case
|
// default processing in this case
|
||||||
//
|
//
|
||||||
SendEvent( EVT_GRID_ROW_SIZE, m_dragRowOrCol, -1, event );
|
SendEvent( wxEVT_GRID_ROW_SIZE, m_dragRowOrCol, -1, event );
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, m_rowLabelWin);
|
ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, m_rowLabelWin);
|
||||||
@@ -2527,7 +2541,7 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
|
|||||||
else if ( event.RightDown() )
|
else if ( event.RightDown() )
|
||||||
{
|
{
|
||||||
row = YToRow(y);
|
row = YToRow(y);
|
||||||
if ( !SendEvent( EVT_GRID_LABEL_RIGHT_CLICK, row, -1, event ) )
|
if ( !SendEvent( wxEVT_GRID_LABEL_RIGHT_CLICK, row, -1, event ) )
|
||||||
{
|
{
|
||||||
// no default action at the moment
|
// no default action at the moment
|
||||||
}
|
}
|
||||||
@@ -2539,7 +2553,7 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
|
|||||||
else if ( event.RightDClick() )
|
else if ( event.RightDClick() )
|
||||||
{
|
{
|
||||||
row = YToRow(y);
|
row = YToRow(y);
|
||||||
if ( !SendEvent( EVT_GRID_LABEL_RIGHT_DCLICK, row, -1, event ) )
|
if ( !SendEvent( wxEVT_GRID_LABEL_RIGHT_DCLICK, row, -1, event ) )
|
||||||
{
|
{
|
||||||
// no default action at the moment
|
// no default action at the moment
|
||||||
}
|
}
|
||||||
@@ -2642,7 +2656,7 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
|
|||||||
{
|
{
|
||||||
col = XToCol(x);
|
col = XToCol(x);
|
||||||
if ( col >= 0 &&
|
if ( col >= 0 &&
|
||||||
!SendEvent( EVT_GRID_LABEL_LEFT_CLICK, -1, col, event ) )
|
!SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, -1, col, event ) )
|
||||||
{
|
{
|
||||||
SelectCol( col, event.ShiftDown() );
|
SelectCol( col, event.ShiftDown() );
|
||||||
ChangeCursorMode(WXGRID_CURSOR_SELECT_COL, m_colLabelWin);
|
ChangeCursorMode(WXGRID_CURSOR_SELECT_COL, m_colLabelWin);
|
||||||
@@ -2664,7 +2678,7 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
|
|||||||
if ( XToEdgeOfCol(x) < 0 )
|
if ( XToEdgeOfCol(x) < 0 )
|
||||||
{
|
{
|
||||||
col = XToCol(x);
|
col = XToCol(x);
|
||||||
SendEvent( EVT_GRID_LABEL_LEFT_DCLICK, -1, col, event );
|
SendEvent( wxEVT_GRID_LABEL_LEFT_DCLICK, -1, col, event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2680,7 +2694,7 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
|
|||||||
// Note: we are ending the event *after* doing
|
// Note: we are ending the event *after* doing
|
||||||
// default processing in this case
|
// default processing in this case
|
||||||
//
|
//
|
||||||
SendEvent( EVT_GRID_COL_SIZE, -1, m_dragRowOrCol, event );
|
SendEvent( wxEVT_GRID_COL_SIZE, -1, m_dragRowOrCol, event );
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, m_colLabelWin);
|
ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, m_colLabelWin);
|
||||||
@@ -2693,7 +2707,7 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
|
|||||||
else if ( event.RightDown() )
|
else if ( event.RightDown() )
|
||||||
{
|
{
|
||||||
col = XToCol(x);
|
col = XToCol(x);
|
||||||
if ( !SendEvent( EVT_GRID_LABEL_RIGHT_CLICK, -1, col, event ) )
|
if ( !SendEvent( wxEVT_GRID_LABEL_RIGHT_CLICK, -1, col, event ) )
|
||||||
{
|
{
|
||||||
// no default action at the moment
|
// no default action at the moment
|
||||||
}
|
}
|
||||||
@@ -2705,7 +2719,7 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
|
|||||||
else if ( event.RightDClick() )
|
else if ( event.RightDClick() )
|
||||||
{
|
{
|
||||||
col = XToCol(x);
|
col = XToCol(x);
|
||||||
if ( !SendEvent( EVT_GRID_LABEL_RIGHT_DCLICK, -1, col, event ) )
|
if ( !SendEvent( wxEVT_GRID_LABEL_RIGHT_DCLICK, -1, col, event ) )
|
||||||
{
|
{
|
||||||
// no default action at the moment
|
// no default action at the moment
|
||||||
}
|
}
|
||||||
@@ -2740,7 +2754,7 @@ void wxGrid::ProcessCornerLabelMouseEvent( wxMouseEvent& event )
|
|||||||
// indicate corner label by having both row and
|
// indicate corner label by having both row and
|
||||||
// col args == -1
|
// col args == -1
|
||||||
//
|
//
|
||||||
if ( !SendEvent( EVT_GRID_LABEL_LEFT_CLICK, -1, -1, event ) )
|
if ( !SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, -1, -1, event ) )
|
||||||
{
|
{
|
||||||
SelectAll();
|
SelectAll();
|
||||||
}
|
}
|
||||||
@@ -2748,12 +2762,12 @@ void wxGrid::ProcessCornerLabelMouseEvent( wxMouseEvent& event )
|
|||||||
|
|
||||||
else if ( event.LeftDClick() )
|
else if ( event.LeftDClick() )
|
||||||
{
|
{
|
||||||
SendEvent( EVT_GRID_LABEL_LEFT_DCLICK, -1, -1, event );
|
SendEvent( wxEVT_GRID_LABEL_LEFT_DCLICK, -1, -1, event );
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( event.RightDown() )
|
else if ( event.RightDown() )
|
||||||
{
|
{
|
||||||
if ( !SendEvent( EVT_GRID_LABEL_RIGHT_CLICK, -1, -1, event ) )
|
if ( !SendEvent( wxEVT_GRID_LABEL_RIGHT_CLICK, -1, -1, event ) )
|
||||||
{
|
{
|
||||||
// no default action at the moment
|
// no default action at the moment
|
||||||
}
|
}
|
||||||
@@ -2761,7 +2775,7 @@ void wxGrid::ProcessCornerLabelMouseEvent( wxMouseEvent& event )
|
|||||||
|
|
||||||
else if ( event.RightDClick() )
|
else if ( event.RightDClick() )
|
||||||
{
|
{
|
||||||
if ( !SendEvent( EVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, event ) )
|
if ( !SendEvent( wxEVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, event ) )
|
||||||
{
|
{
|
||||||
// no default action at the moment
|
// no default action at the moment
|
||||||
}
|
}
|
||||||
@@ -2953,7 +2967,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
|
|||||||
//
|
//
|
||||||
if ( event.LeftDown() )
|
if ( event.LeftDown() )
|
||||||
{
|
{
|
||||||
EnableCellEditControl( FALSE );
|
DisableCellEditControl();
|
||||||
if ( event.ShiftDown() )
|
if ( event.ShiftDown() )
|
||||||
{
|
{
|
||||||
SelectBlock( m_currentCellCoords, coords );
|
SelectBlock( m_currentCellCoords, coords );
|
||||||
@@ -2961,7 +2975,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
|
|||||||
else if ( XToEdgeOfCol(x) < 0 &&
|
else if ( XToEdgeOfCol(x) < 0 &&
|
||||||
YToEdgeOfRow(y) < 0 )
|
YToEdgeOfRow(y) < 0 )
|
||||||
{
|
{
|
||||||
if ( !SendEvent( EVT_GRID_CELL_LEFT_CLICK,
|
if ( !SendEvent( wxEVT_GRID_CELL_LEFT_CLICK,
|
||||||
coords.GetRow(),
|
coords.GetRow(),
|
||||||
coords.GetCol(),
|
coords.GetCol(),
|
||||||
event ) )
|
event ) )
|
||||||
@@ -2970,14 +2984,15 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
|
|||||||
|
|
||||||
// if this is the second click on this cell then start
|
// if this is the second click on this cell then start
|
||||||
// the edit control
|
// the edit control
|
||||||
if (m_waitForSlowClick && coords == m_currentCellCoords) {
|
if ( m_waitForSlowClick &&
|
||||||
EnableCellEditControl(TRUE);
|
(coords == m_currentCellCoords) &&
|
||||||
// VZ: this is done by the call above, so why do it
|
CanEnableCellControl())
|
||||||
// again? please remove this line if it's ok
|
{
|
||||||
//ShowCellEditControl();
|
EnableCellEditControl();
|
||||||
m_waitForSlowClick = FALSE;
|
m_waitForSlowClick = FALSE;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
SetCurrentCell( coords );
|
SetCurrentCell( coords );
|
||||||
m_waitForSlowClick = TRUE;
|
m_waitForSlowClick = TRUE;
|
||||||
}
|
}
|
||||||
@@ -2990,10 +3005,10 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
|
|||||||
//
|
//
|
||||||
else if ( event.LeftDClick() )
|
else if ( event.LeftDClick() )
|
||||||
{
|
{
|
||||||
EnableCellEditControl( FALSE );
|
DisableCellEditControl();
|
||||||
if ( XToEdgeOfCol(x) < 0 && YToEdgeOfRow(y) < 0 )
|
if ( XToEdgeOfCol(x) < 0 && YToEdgeOfRow(y) < 0 )
|
||||||
{
|
{
|
||||||
SendEvent( EVT_GRID_CELL_LEFT_DCLICK,
|
SendEvent( wxEVT_GRID_CELL_LEFT_DCLICK,
|
||||||
coords.GetRow(),
|
coords.GetRow(),
|
||||||
coords.GetCol(),
|
coords.GetCol(),
|
||||||
event );
|
event );
|
||||||
@@ -3013,7 +3028,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
|
|||||||
m_winCapture->ReleaseMouse();
|
m_winCapture->ReleaseMouse();
|
||||||
m_winCapture = NULL;
|
m_winCapture = NULL;
|
||||||
}
|
}
|
||||||
SendEvent( EVT_GRID_RANGE_SELECT, -1, -1, event );
|
SendEvent( wxEVT_GRID_RANGE_SELECT, -1, -1, event );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the edit control, if it has been hidden for
|
// Show the edit control, if it has been hidden for
|
||||||
@@ -3028,7 +3043,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
|
|||||||
// Note: we are ending the event *after* doing
|
// Note: we are ending the event *after* doing
|
||||||
// default processing in this case
|
// default processing in this case
|
||||||
//
|
//
|
||||||
SendEvent( EVT_GRID_ROW_SIZE, m_dragRowOrCol, -1, event );
|
SendEvent( wxEVT_GRID_ROW_SIZE, m_dragRowOrCol, -1, event );
|
||||||
}
|
}
|
||||||
else if ( m_cursorMode == WXGRID_CURSOR_RESIZE_COL )
|
else if ( m_cursorMode == WXGRID_CURSOR_RESIZE_COL )
|
||||||
{
|
{
|
||||||
@@ -3038,7 +3053,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
|
|||||||
// Note: we are ending the event *after* doing
|
// Note: we are ending the event *after* doing
|
||||||
// default processing in this case
|
// default processing in this case
|
||||||
//
|
//
|
||||||
SendEvent( EVT_GRID_COL_SIZE, -1, m_dragRowOrCol, event );
|
SendEvent( wxEVT_GRID_COL_SIZE, -1, m_dragRowOrCol, event );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dragLastPos = -1;
|
m_dragLastPos = -1;
|
||||||
@@ -3049,8 +3064,8 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
|
|||||||
//
|
//
|
||||||
else if ( event.RightDown() )
|
else if ( event.RightDown() )
|
||||||
{
|
{
|
||||||
EnableCellEditControl( FALSE );
|
DisableCellEditControl();
|
||||||
if ( !SendEvent( EVT_GRID_CELL_RIGHT_CLICK,
|
if ( !SendEvent( wxEVT_GRID_CELL_RIGHT_CLICK,
|
||||||
coords.GetRow(),
|
coords.GetRow(),
|
||||||
coords.GetCol(),
|
coords.GetCol(),
|
||||||
event ) )
|
event ) )
|
||||||
@@ -3064,8 +3079,8 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
|
|||||||
//
|
//
|
||||||
else if ( event.RightDClick() )
|
else if ( event.RightDClick() )
|
||||||
{
|
{
|
||||||
EnableCellEditControl( FALSE );
|
DisableCellEditControl();
|
||||||
if ( !SendEvent( EVT_GRID_CELL_RIGHT_DCLICK,
|
if ( !SendEvent( wxEVT_GRID_CELL_RIGHT_DCLICK,
|
||||||
coords.GetRow(),
|
coords.GetRow(),
|
||||||
coords.GetCol(),
|
coords.GetCol(),
|
||||||
event ) )
|
event ) )
|
||||||
@@ -3259,7 +3274,7 @@ bool wxGrid::InsertRows( int pos, int numRows, bool WXUNUSED(updateLabels) )
|
|||||||
if ( m_table )
|
if ( m_table )
|
||||||
{
|
{
|
||||||
if (IsCellEditControlEnabled())
|
if (IsCellEditControlEnabled())
|
||||||
EnableCellEditControl(FALSE);
|
DisableCellEditControl();
|
||||||
|
|
||||||
bool ok = m_table->InsertRows( pos, numRows );
|
bool ok = m_table->InsertRows( pos, numRows );
|
||||||
|
|
||||||
@@ -3346,7 +3361,7 @@ bool wxGrid::DeleteRows( int pos, int numRows, bool WXUNUSED(updateLabels) )
|
|||||||
if ( m_table )
|
if ( m_table )
|
||||||
{
|
{
|
||||||
if (IsCellEditControlEnabled())
|
if (IsCellEditControlEnabled())
|
||||||
EnableCellEditControl(FALSE);
|
DisableCellEditControl();
|
||||||
|
|
||||||
if (m_table->DeleteRows( pos, numRows ))
|
if (m_table->DeleteRows( pos, numRows ))
|
||||||
{
|
{
|
||||||
@@ -3376,7 +3391,7 @@ bool wxGrid::InsertCols( int pos, int numCols, bool WXUNUSED(updateLabels) )
|
|||||||
if ( m_table )
|
if ( m_table )
|
||||||
{
|
{
|
||||||
if (IsCellEditControlEnabled())
|
if (IsCellEditControlEnabled())
|
||||||
EnableCellEditControl(FALSE);
|
DisableCellEditControl();
|
||||||
|
|
||||||
bool ok = m_table->InsertCols( pos, numCols );
|
bool ok = m_table->InsertCols( pos, numCols );
|
||||||
|
|
||||||
@@ -3454,7 +3469,7 @@ bool wxGrid::DeleteCols( int pos, int numCols, bool WXUNUSED(updateLabels) )
|
|||||||
if ( m_table )
|
if ( m_table )
|
||||||
{
|
{
|
||||||
if (IsCellEditControlEnabled())
|
if (IsCellEditControlEnabled())
|
||||||
EnableCellEditControl(FALSE);
|
DisableCellEditControl();
|
||||||
|
|
||||||
if ( m_table->DeleteCols( pos, numCols ) )
|
if ( m_table->DeleteCols( pos, numCols ) )
|
||||||
{
|
{
|
||||||
@@ -3482,8 +3497,7 @@ bool wxGrid::SendEvent( const wxEventType type,
|
|||||||
int row, int col,
|
int row, int col,
|
||||||
wxMouseEvent& mouseEv )
|
wxMouseEvent& mouseEv )
|
||||||
{
|
{
|
||||||
if ( type == EVT_GRID_ROW_SIZE ||
|
if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE )
|
||||||
type == EVT_GRID_COL_SIZE )
|
|
||||||
{
|
{
|
||||||
int rowOrCol = (row == -1 ? col : row);
|
int rowOrCol = (row == -1 ? col : row);
|
||||||
|
|
||||||
@@ -3499,7 +3513,7 @@ bool wxGrid::SendEvent( const wxEventType type,
|
|||||||
|
|
||||||
return GetEventHandler()->ProcessEvent(gridEvt);
|
return GetEventHandler()->ProcessEvent(gridEvt);
|
||||||
}
|
}
|
||||||
else if ( type == EVT_GRID_RANGE_SELECT )
|
else if ( type == wxEVT_GRID_RANGE_SELECT )
|
||||||
{
|
{
|
||||||
wxGridRangeSelectEvent gridEvt( GetId(),
|
wxGridRangeSelectEvent gridEvt( GetId(),
|
||||||
type,
|
type,
|
||||||
@@ -3536,8 +3550,7 @@ bool wxGrid::SendEvent( const wxEventType type,
|
|||||||
bool wxGrid::SendEvent( const wxEventType type,
|
bool wxGrid::SendEvent( const wxEventType type,
|
||||||
int row, int col )
|
int row, int col )
|
||||||
{
|
{
|
||||||
if ( type == EVT_GRID_ROW_SIZE ||
|
if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE )
|
||||||
type == EVT_GRID_COL_SIZE )
|
|
||||||
{
|
{
|
||||||
int rowOrCol = (row == -1 ? col : row);
|
int rowOrCol = (row == -1 ? col : row);
|
||||||
|
|
||||||
@@ -3729,9 +3742,9 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
|
|||||||
default:
|
default:
|
||||||
// now try the cell edit control
|
// now try the cell edit control
|
||||||
//
|
//
|
||||||
if ( !IsCellEditControlEnabled() )
|
if ( !IsCellEditControlEnabled() && CanEnableCellControl() )
|
||||||
EnableCellEditControl( TRUE );
|
{
|
||||||
if (IsCellEditControlEnabled()) {
|
EnableCellEditControl();
|
||||||
wxGridCellAttr* attr = GetCellAttr(m_currentCellCoords);
|
wxGridCellAttr* attr = GetCellAttr(m_currentCellCoords);
|
||||||
attr->GetEditor()->StartingKey(event);
|
attr->GetEditor()->StartingKey(event);
|
||||||
attr->DecRef();
|
attr->DecRef();
|
||||||
@@ -3752,7 +3765,7 @@ void wxGrid::OnEraseBackground(wxEraseEvent&)
|
|||||||
|
|
||||||
void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
|
void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
|
||||||
{
|
{
|
||||||
if ( SendEvent( EVT_GRID_SELECT_CELL, coords.GetRow(), coords.GetCol() ) )
|
if ( SendEvent( wxEVT_GRID_SELECT_CELL, coords.GetRow(), coords.GetCol() ) )
|
||||||
{
|
{
|
||||||
// the event has been intercepted - do nothing
|
// the event has been intercepted - do nothing
|
||||||
return;
|
return;
|
||||||
@@ -3763,7 +3776,7 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
|
|||||||
{
|
{
|
||||||
HideCellEditControl();
|
HideCellEditControl();
|
||||||
SaveEditControlValue();
|
SaveEditControlValue();
|
||||||
EnableCellEditControl(FALSE);
|
DisableCellEditControl();
|
||||||
|
|
||||||
// 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);
|
||||||
@@ -4255,6 +4268,9 @@ void wxGrid::EnableEditing( bool edit )
|
|||||||
{
|
{
|
||||||
m_editable = edit;
|
m_editable = edit;
|
||||||
|
|
||||||
|
// FIXME IMHO this won't disable the edit control if edit == FALSE
|
||||||
|
// because of the check in the beginning of
|
||||||
|
// EnableCellEditControl() just below (VZ)
|
||||||
EnableCellEditControl(m_editable);
|
EnableCellEditControl(m_editable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4270,9 +4286,18 @@ void wxGrid::EnableCellEditControl( bool enable )
|
|||||||
|
|
||||||
if ( enable != m_cellEditCtrlEnabled )
|
if ( enable != m_cellEditCtrlEnabled )
|
||||||
{
|
{
|
||||||
|
// TODO allow the app to Veto() this event?
|
||||||
|
SendEvent(enable ? wxEVT_GRID_EDITOR_SHOWN : wxEVT_GRID_EDITOR_HIDDEN);
|
||||||
|
|
||||||
if ( enable )
|
if ( enable )
|
||||||
{
|
{
|
||||||
|
// this should be checked by the caller!
|
||||||
|
wxASSERT_MSG( CanEnableCellControl(),
|
||||||
|
_T("can't enable editing for this cell!") );
|
||||||
|
|
||||||
|
// do it before ShowCellEditControl()
|
||||||
m_cellEditCtrlEnabled = enable;
|
m_cellEditCtrlEnabled = enable;
|
||||||
|
|
||||||
SetEditControlValue();
|
SetEditControlValue();
|
||||||
ShowCellEditControl();
|
ShowCellEditControl();
|
||||||
}
|
}
|
||||||
@@ -4280,28 +4305,33 @@ void wxGrid::EnableCellEditControl( bool enable )
|
|||||||
{
|
{
|
||||||
HideCellEditControl();
|
HideCellEditControl();
|
||||||
SaveEditControlValue();
|
SaveEditControlValue();
|
||||||
|
|
||||||
|
// do it after HideCellEditControl()
|
||||||
m_cellEditCtrlEnabled = enable;
|
m_cellEditCtrlEnabled = enable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxGrid::IsCurrentCellReadOnly() const
|
||||||
bool wxGrid::IsCellEditControlEnabled()
|
|
||||||
{
|
{
|
||||||
bool enabled;
|
// const_cast
|
||||||
|
wxGridCellAttr* attr = ((wxGrid *)this)->GetCellAttr(m_currentCellCoords);
|
||||||
if ( m_cellEditCtrlEnabled )
|
bool readonly = attr->IsReadOnly();
|
||||||
{
|
|
||||||
wxGridCellAttr* attr = GetCellAttr(m_currentCellCoords);
|
|
||||||
enabled = !attr->IsReadOnly();
|
|
||||||
attr->DecRef();
|
attr->DecRef();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
enabled = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return enabled;
|
return readonly;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxGrid::CanEnableCellControl() const
|
||||||
|
{
|
||||||
|
return m_editable && !IsCurrentCellReadOnly();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxGrid::IsCellEditControlEnabled() const
|
||||||
|
{
|
||||||
|
// the cell edit control might be disable for all cells or just for the
|
||||||
|
// current one if it's read only
|
||||||
|
return m_cellEditCtrlEnabled ? !IsCurrentCellReadOnly() : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGrid::ShowCellEditControl()
|
void wxGrid::ShowCellEditControl()
|
||||||
@@ -4423,7 +4453,7 @@ void wxGrid::SaveEditControlValue()
|
|||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
SendEvent( EVT_GRID_CELL_CHANGE,
|
SendEvent( wxEVT_GRID_CELL_CHANGE,
|
||||||
m_currentCellCoords.GetRow(),
|
m_currentCellCoords.GetRow(),
|
||||||
m_currentCellCoords.GetCol() );
|
m_currentCellCoords.GetCol() );
|
||||||
}
|
}
|
||||||
@@ -5797,7 +5827,7 @@ void wxGrid::SelectRow( int row, bool addToSelected )
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxGridRangeSelectEvent gridEvt( GetId(),
|
wxGridRangeSelectEvent gridEvt( GetId(),
|
||||||
EVT_GRID_RANGE_SELECT,
|
wxEVT_GRID_RANGE_SELECT,
|
||||||
this,
|
this,
|
||||||
m_selectedTopLeft,
|
m_selectedTopLeft,
|
||||||
m_selectedBottomRight );
|
m_selectedBottomRight );
|
||||||
@@ -5875,7 +5905,7 @@ void wxGrid::SelectCol( int col, bool addToSelected )
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxGridRangeSelectEvent gridEvt( GetId(),
|
wxGridRangeSelectEvent gridEvt( GetId(),
|
||||||
EVT_GRID_RANGE_SELECT,
|
wxEVT_GRID_RANGE_SELECT,
|
||||||
this,
|
this,
|
||||||
m_selectedTopLeft,
|
m_selectedTopLeft,
|
||||||
m_selectedBottomRight );
|
m_selectedBottomRight );
|
||||||
@@ -6005,7 +6035,7 @@ void wxGrid::SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol )
|
|||||||
if ( !m_isDragging )
|
if ( !m_isDragging )
|
||||||
{
|
{
|
||||||
wxGridRangeSelectEvent gridEvt( GetId(),
|
wxGridRangeSelectEvent gridEvt( GetId(),
|
||||||
EVT_GRID_RANGE_SELECT,
|
wxEVT_GRID_RANGE_SELECT,
|
||||||
this,
|
this,
|
||||||
m_selectedTopLeft,
|
m_selectedTopLeft,
|
||||||
m_selectedBottomRight );
|
m_selectedBottomRight );
|
||||||
|
Reference in New Issue
Block a user