// Creates the actual edit control
virtual void Create(wxWindow* parent,
wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
wxEvtHandler* evtHandler) = 0;
// Size and position the edit control
// Reset the value in the control back to its starting value
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 first key if desired.
+ virtual void StartingKey(wxKeyEvent& event);
+
// Some types of controls on some platforms may need some help
// with the Return key.
virtual void HandleReturn(wxKeyEvent& event);
virtual void Create(wxWindow* parent,
wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
wxEvtHandler* evtHandler);
virtual void BeginEdit(int row, int col, wxGrid* grid,
wxGrid* grid, wxGridCellAttr* attr);
virtual void Reset();
+ virtual void StartingKey(wxKeyEvent& event);
virtual void HandleReturn(wxKeyEvent& event);
// takes ownership of the pointer
void SetRenderer(wxGridCellRenderer *renderer)
{ delete m_renderer; m_renderer = renderer; }
+ void SetEditor(wxGridCellEditor* editor)
+ { delete m_editor; m_editor = editor; }
// accessors
bool HasTextColour() const { return m_colText.Ok(); }
bool HasFont() const { return m_font.Ok(); }
bool HasAlignment() const { return m_hAlign || m_vAlign; }
bool HasRenderer() const { return m_renderer != NULL; }
+ bool HasEditor() const { return m_editor != NULL; }
const wxColour& GetTextColour() const;
const wxColour& GetBackgroundColour() const;
const wxFont& GetFont() const;
void GetAlignment(int *hAlign, int *vAlign) const;
wxGridCellRenderer *GetRenderer() const;
+ wxGridCellEditor *GetEditor() const;
void SetDefAttr(wxGridCellAttr* defAttr) { m_defGridAttr = defAttr; }
private:
// the common part of all ctors
- void Init() { m_nRef = 1; m_renderer = (wxGridCellRenderer *)NULL; }
+ void Init() {
+ m_nRef = 1;
+ m_renderer = NULL;
+ m_editor = NULL;
+ }
// the dtor is private because only DecRef() can delete us
- ~wxGridCellAttr() { delete m_renderer; }
+ ~wxGridCellAttr() { delete m_renderer; delete m_editor; }
// the ref count - when it goes to 0, we die
size_t m_nRef;
int m_hAlign,
m_vAlign;
- wxGridCellRenderer *m_renderer;
- wxGridCellAttr* m_defGridAttr;
+ wxGridCellRenderer* m_renderer;
+ wxGridCellEditor* m_editor;
+ wxGridCellAttr* m_defGridAttr;
// suppress the stupid gcc warning about the class having private dtor and
// no friends
-// This set of classes is to provide for the use of different types of
-// cell edit controls in the grid while avoiding the wx class info
-// system in deference to wxPython
-
-class WXDLLEXPORT wxGridTextCtrl : public wxTextCtrl
-{
-public:
- wxGridTextCtrl() {}
- wxGridTextCtrl( wxWindow *,
- wxGrid *,
- bool isCellControl,
- wxWindowID id,
- const wxString& value = wxEmptyString,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0 );
-
- void SetStartValue( const wxString& );
- wxString GetStartValue() { return startValue; }
-
-private:
- wxGrid *m_grid;
-
- // TRUE for controls placed over cells,
- // FALSE for a control on a grid control panel
- bool m_isCellControl;
-
- wxString startValue;
-
- void OnKeyDown( wxKeyEvent& );
-
- DECLARE_DYNAMIC_CLASS( wxGridTextCtrl )
- DECLARE_EVENT_TABLE()
-};
-
-//-----------------------------------------------------------------------------
-// wxGridEditTimer (internal)
-//-----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxGridEditTimer: public wxTimer
-{
- private:
- wxGrid *m_owner;
-
- public:
- wxGridEditTimer( wxGrid *owner );
- void Notify();
-};
-
// ----------------------------------------------------------------------------
// wxGrid
// ----------------------------------------------------------------------------
public:
wxGrid()
{
- m_table = (wxGridTableBase *) NULL;
- m_gridWin = (wxGridWindow *) NULL;
- m_rowLabelWin = (wxGridRowLabelWindow *) NULL;
- m_colLabelWin = (wxGridColLabelWindow *) NULL;
- m_cornerLabelWin = (wxGridCornerLabelWindow *) NULL;
- m_cellEditCtrl = (wxWindow *) NULL;
+ Create();
}
wxGrid( wxWindow *parent,
void DrawCellBorder( wxDC& dc, const wxGridCellCoords& );
void DrawAllGridLines( wxDC& dc, const wxRegion & reg );
void DrawCell( wxDC& dc, const wxGridCellCoords& );
+ void DrawCellHighlight( wxDC& dc );
void DrawRowLabels( wxDC& dc );
void DrawRowLabel( wxDC& dc, int row );
void EnableCellEditControl( bool enable );
bool IsCellEditControlEnabled()
- { return (m_cellEditCtrl && m_cellEditCtrlEnabled); }
+ { return m_cellEditCtrlEnabled; }
void ShowCellEditControl();
void HideCellEditControl();
int m_defaultColWidth;
wxArrayInt m_colWidths;
wxArrayInt m_colRights;
-
int m_rowLabelWidth;
int m_colLabelHeight;
// looks for the attr in cache, if not found asks the table and caches the
// result
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
wxGridCellAttr* m_defaultCellAttr;
wxWindow *m_winCapture; // the window which captured the mouse
CursorMode m_cursorMode;
- int m_dragLastPos;
- int m_dragRowOrCol;
- bool m_isDragging;
+ int m_dragLastPos;
+ int m_dragRowOrCol;
+ bool m_isDragging;
+ wxPoint m_startDragPos;
- wxTimer *m_editTimer;
+ bool m_waitForSlowClick;
wxGridCellCoords m_selectionStart;
wxCursor m_colResizeCursor;
bool m_editable; // applies to whole grid
- int m_editCtrlType; // for current cell
- wxWindow* m_cellEditCtrl;
bool m_cellEditCtrlEnabled;