X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/19d7140ec28c705ad1cfe75c7817ad47492825fc..0c5b83b0fa94deaa77ff72760bb9ba0e51a03202:/include/wx/generic/grid.h diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 02c593a38a..e74f117ae4 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -12,7 +12,7 @@ #include "wx/defs.h" #if !defined(wxUSE_NEW_GRID) || !(wxUSE_NEW_GRID) -#include "gridg.h" +#include "wx/generic/gridg.h" #else #ifndef __WXGRID_H__ @@ -31,6 +31,7 @@ #include "wx/combobox.h" #include "wx/dynarray.h" #include "wx/timer.h" +#include "wx/clntdata.h" // ---------------------------------------------------------------------------- // constants @@ -98,7 +99,7 @@ class WXDLLEXPORT wxSpinCtrl; // class is not documented and is not public at all // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxGridCellWorker +class WXDLLEXPORT wxGridCellWorker : public wxClientDataContainer { public: wxGridCellWorker() { m_nRef = 1; } @@ -375,6 +376,8 @@ protected: friend class wxGridCellEditorDummyFriend; }; +#if wxUSE_TEXTCTRL + // the editor for string/text data class WXDLLEXPORT wxGridCellTextEditor : public wxGridCellEditor { @@ -489,6 +492,10 @@ private: double m_valueOld; }; +#endif // wxUSE_TEXTCTRL + +#if wxUSE_CHECKBOX + // the editor for boolean data class WXDLLEXPORT wxGridCellBoolEditor : public wxGridCellEditor { @@ -517,6 +524,10 @@ private: bool m_startValue; }; +#endif // wxUSE_CHECKBOX + +#if wxUSE_COMBOBOX + // the editor for string data allowing to choose from the list of strings class WXDLLEXPORT wxGridCellChoiceEditor : public wxGridCellEditor { @@ -551,13 +562,15 @@ private: bool m_allowOthers; }; +#endif // wxUSE_COMBOBOX + // ---------------------------------------------------------------------------- // wxGridCellAttr: this class can be used to alter the cells appearance in // the grid by changing their colour/font/... from default. An object of this // class may be returned by wxGridTable::GetAttr(). // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxGridCellAttr +class WXDLLEXPORT wxGridCellAttr : public wxClientDataContainer { public: enum wxAttrKind @@ -571,9 +584,10 @@ public: }; // ctors - wxGridCellAttr() + wxGridCellAttr(wxGridCellAttr *attrDefault = NULL) { - Init(); + Init(attrDefault); + // MB: args used to be 0,0 here but wxALIGN_LEFT is 0 SetAlignment(-1, -1); } @@ -649,20 +663,10 @@ private: Unset = -1, ReadWrite, ReadOnly - }; + }; // the common part of all ctors - void Init() - { - m_nRef = 1; - - m_isReadOnly = Unset; - - m_renderer = NULL; - m_editor = NULL; - - m_attrkind = wxGridCellAttr::Cell; - } + void Init(wxGridCellAttr *attrDefault = NULL); // the dtor is private because only DecRef() can delete us ~wxGridCellAttr() @@ -689,7 +693,7 @@ private: wxAttrKind m_attrkind; // use Clone() instead - DECLARE_NO_COPY_CLASS(wxGridCellAttr); + DECLARE_NO_COPY_CLASS(wxGridCellAttr) // suppress the stupid gcc warning about the class having private dtor and // no friends @@ -708,7 +712,7 @@ private: // the default implementation is reasonably efficient for the generic case, // but you might still wish to implement your own for some specific situations // if you have performance problems with the stock one -class WXDLLEXPORT wxGridCellAttrProvider +class WXDLLEXPORT wxGridCellAttrProvider : public wxClientDataContainer { public: wxGridCellAttrProvider(); @@ -742,7 +746,7 @@ private: ////////////////////////////////////////////////////////////////////// -class WXDLLEXPORT wxGridTableBase : public wxObject +class WXDLLEXPORT wxGridTableBase : public wxObject, public wxClientDataContainer { public: wxGridTableBase(); @@ -887,7 +891,7 @@ class WXDLLEXPORT wxGridStringTable : public wxGridTableBase public: wxGridStringTable(); wxGridStringTable( int numRows, int numCols ); - ~wxGridStringTable(); + virtual ~wxGridStringTable(); // these are pure virtual in wxGridTableBase // @@ -1007,7 +1011,7 @@ public: long style = wxWANTS_CHARS, const wxString& name = wxPanelNameStr ); - ~wxGrid(); + virtual ~wxGrid(); enum wxGridSelectionModes {wxGridSelectCells, wxGridSelectRows, @@ -1027,10 +1031,10 @@ public: // ------ display update functions // - void CalcRowLabelsExposed( const wxRegion& reg ); + wxArrayInt CalcRowLabelsExposed( const wxRegion& reg ); - void CalcColLabelsExposed( const wxRegion& reg ); - void CalcCellsExposed( const wxRegion& reg ); + wxArrayInt CalcColLabelsExposed( const wxRegion& reg ); + wxGridCellCoordsArray CalcCellsExposed( const wxRegion& reg ); // ------ event handlers @@ -1057,21 +1061,21 @@ public: bool AppendCols( int numCols = 1, bool updateLabels=TRUE ); bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE ); - void DrawGridCellArea( wxDC& dc ); + void DrawGridCellArea( wxDC& dc , const wxGridCellCoordsArray& cells ); void DrawGridSpace( wxDC& dc ); void DrawCellBorder( wxDC& dc, const wxGridCellCoords& ); void DrawAllGridLines( wxDC& dc, const wxRegion & reg ); void DrawCell( wxDC& dc, const wxGridCellCoords& ); - void DrawHighlight(wxDC& dc); + void DrawHighlight(wxDC& dc, const wxGridCellCoordsArray& cells); // this function is called when the current cell highlight must be redrawn // and may be overridden by the user virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr ); - void DrawRowLabels( wxDC& dc ); + void DrawRowLabels( wxDC& dc, const wxArrayInt& rows ); void DrawRowLabel( wxDC& dc, int row ); - void DrawColLabels( wxDC& dc ); + void DrawColLabels( wxDC& dc, const wxArrayInt& cols ); void DrawColLabel( wxDC& dc, int col ); @@ -1081,13 +1085,18 @@ public: int horizontalAlignment = wxALIGN_LEFT, int verticalAlignment = wxALIGN_TOP ); + void DrawTextRectangle( wxDC& dc, const wxArrayString& lines, const wxRect&, + int horizontalAlignment = wxALIGN_LEFT, + int verticalAlignment = wxALIGN_TOP ); + + // Split a string containing newline chararcters into an array of // strings and return the number of lines // void StringToLines( const wxString& value, wxArrayString& lines ); void GetTextBoxSize( wxDC& dc, - wxArrayString& lines, + const wxArrayString& lines, long *width, long *height ); @@ -1397,6 +1406,8 @@ public: { m_extraWidth = extraWidth; m_extraHeight = extraHeight; + + CalcDimensions(); } // Accessors for component windows @@ -1704,12 +1715,6 @@ protected: wxGridCellAttr* m_defaultCellAttr; - wxGridCellCoordsArray m_cellsExposed; - wxArrayInt m_rowsExposed; - wxArrayInt m_colsExposed; - wxArrayInt m_rowLabelsExposed; - wxArrayInt m_colLabelsExposed; - bool m_inOnKeyDown; int m_batchCount; @@ -1764,9 +1769,9 @@ protected: bool Redimension( wxGridTableMessage& ); - bool SendEvent( const wxEventType, int row, int col, wxMouseEvent& ); - bool SendEvent( const wxEventType, int row, int col ); - bool SendEvent( const wxEventType type) + int SendEvent( const wxEventType, int row, int col, wxMouseEvent& ); + int SendEvent( const wxEventType, int row, int col ); + int SendEvent( const wxEventType type) { return SendEvent(type, m_currentCellCoords.GetRow(), @@ -1921,6 +1926,36 @@ protected: DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent) }; + +class WXDLLEXPORT wxGridEditorCreatedEvent : public wxCommandEvent { +public: + wxGridEditorCreatedEvent() + : wxCommandEvent() + { + m_row = 0; + m_col = 0; + m_ctrl = NULL; + } + + wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj, + int row, int col, wxControl* ctrl); + + int GetRow() { return m_row; } + int GetCol() { return m_col; } + wxControl* GetControl() { return m_ctrl; } + void SetRow(int row) { m_row = row; } + void SetCol(int col) { m_col = col; } + void SetControl(wxControl* ctrl) { m_ctrl = ctrl; } + +private: + int m_row; + int m_col; + wxControl* m_ctrl; + + DECLARE_DYNAMIC_CLASS(wxGridEditorCreatedEvent) +}; + + BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_LEFT_CLICK, 1580) DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_RIGHT_CLICK, 1581) @@ -1937,12 +1972,14 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE(wxEVT_GRID_SELECT_CELL, 1592) DECLARE_EVENT_TYPE(wxEVT_GRID_EDITOR_SHOWN, 1593) DECLARE_EVENT_TYPE(wxEVT_GRID_EDITOR_HIDDEN, 1594) + DECLARE_EVENT_TYPE(wxEVT_GRID_EDITOR_CREATED, 1595) END_DECLARE_EVENT_TYPES() typedef void (wxEvtHandler::*wxGridEventFunction)(wxGridEvent&); typedef void (wxEvtHandler::*wxGridSizeEventFunction)(wxGridSizeEvent&); typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction)(wxGridRangeSelectEvent&); +typedef void (wxEvtHandler::*wxGridEditorCreatedEventFunction)(wxGridEditorCreatedEvent&); #define EVT_GRID_CELL_LEFT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ), #define EVT_GRID_CELL_RIGHT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ), @@ -1959,6 +1996,7 @@ typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction)(wxGridRangeSelectEv #define EVT_GRID_SELECT_CELL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ), #define EVT_GRID_EDITOR_SHOWN(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_SHOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ), #define EVT_GRID_EDITOR_HIDDEN(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_HIDDEN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ), +#define EVT_GRID_EDITOR_CREATED(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_CREATED, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEditorCreatedEventFunction) &fn, NULL ), #if 0 // TODO: implement these ? others ?