X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f85afd4e46af8d5432aefa584bb3e54a8eac5522..c61f4f6dbd971245f694eb01034c86040a44db00:/include/wx/generic/grid.h?ds=sidebyside diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index f36a93b26a..4ab8ec061e 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -93,8 +93,8 @@ class wxGridTableBase : public wxObject virtual wxString GetRowLabelValue( int row ); virtual wxString GetColLabelValue( int col ); - virtual void SetRowLabelValue( int row, const wxString& ) {} - virtual void SetColLabelValue( int col, const wxString& ) {} + virtual void SetRowLabelValue( int WXUNUSED(row), const wxString& ) {} + virtual void SetColLabelValue( int WXUNUSED(col), const wxString& ) {} DECLARE_ABSTRACT_CLASS( wxGridTableBase ); }; @@ -195,46 +195,6 @@ class wxGridStringTable : public wxGridTableBase -#if 0 - -// ------ sketchy experimental code to create a grid table for a given type -// -// This doesn't work at the moment !! -// - -#define _WX_DECLARE_GRIDTABLE( T, name ) \ - \ - \ -WX_DECLARE_ARRAY( T, T##Row ) \ -WX_DECLARE_OBJARRAY( T##Row, T##Array ) \ - \ -class WXDLLEXPORT name : public wxGridTableBase \ -{ \ - T##Array m_data; \ - int m_numRows; \ - int m_numCols; \ - \ - public: \ - name() { } \ - name( int numRows, int numCols ); \ - ~name(); \ - \ - wxString GetValue( int row, int col ); \ - wxString SetValue( int row, int col, const wxString& s ); \ - \ - DECLARE_DYNAMIC_CLASS( name ) \ -} - - -#define WX_DECLARE_GRIDTABLE(T, name) \ - typedef T name##var; \ - _WX_DECLARE_GRIDTABLE(name##var, name) - - -#endif // if 0 - - - ////////////////////////////////////////////////////////////////////// // // Grid view classes @@ -327,7 +287,7 @@ class wxGrid : public wxPanel { DECLARE_DYNAMIC_CLASS( wxGrid ) - private: + protected: bool m_created; wxGridTableBase *m_table; @@ -349,10 +309,12 @@ class wxGrid : public wxPanel int m_defaultRowHeight; wxArrayInt m_rowHeights; wxArrayInt m_rowBottoms; + int m_sumRowHeights; int m_defaultColWidth; wxArrayInt m_colWidths; wxArrayInt m_colRights; + int m_sumColWidths; int m_rowLabelWidth; int m_colLabelHeight; @@ -411,7 +373,6 @@ class wxGrid : public wxPanel bool m_cellEditCtrlEnabled; wxWindow* m_topEditCtrl; bool m_topEditCtrlEnabled; - // ------ internal init and update functions // @@ -434,7 +395,7 @@ class wxGrid : public wxPanel void OnSize( wxSizeEvent& ); void OnMouse( wxMouseEvent& ); void OnKeyDown( wxKeyEvent& ); - void OnText( wxKeyEvent& ); + void OnText( wxCommandEvent& ); void OnGridScroll( wxScrollEvent& ); void SelectCell( const wxGridCellCoords& coords ); @@ -475,6 +436,8 @@ class wxGrid : public wxPanel bool MoveCursorDown(); bool MoveCursorLeft(); bool MoveCursorRight(); + bool MovePageDown(); + bool MovePageUp(); bool MoveCursorUpBlock(); bool MoveCursorDownBlock(); bool MoveCursorLeftBlock(); @@ -498,14 +461,21 @@ class wxGrid : public wxPanel void DrawGridLines( wxDC& dc ); void DrawCells( wxDC& dc ); void DrawCellBackground( wxDC& dc, const wxRect&, int row, int col ); - void DrawCellValue( wxDC& dc, const wxRect&, int row, int col ); - - // this one is useful when you just need to draw one or a few + void DrawCellValue( wxDC& dc, const wxRect&, int row, int col, + const wxString& value = wxEmptyString, bool useValueArg = FALSE ); + + // this updates the displayed cell text value but not the underlying + // table cell value (it is used to echo text being entered into + // the top edit control when in-place editing is turned off) + // + void DrawCellValue( const wxGridCellCoords& coords, const wxString& value ); + + // these are useful when you just need to draw one or a few // cells void DrawCell( int row, int col ); void DrawCell( const wxGridCellCoords& coords ) { DrawCell( coords.GetRow(), coords.GetCol() ); } - + void DrawCellHighlight( wxDC& dc, int row, int col ); void DrawCellHighlight( wxDC& dc, wxGridCellCoords& coords ) { DrawCellHighlight( dc, coords.GetRow(), coords.GetCol() ); } @@ -660,7 +630,7 @@ class wxGrid : public wxPanel void SetDefaultCellAlignment( int horiz, int vert ); void SetCellAlignment( int row, int col, int horiz, int vert ); - + // ------ cell value accessors // wxString GetCellValue( int row, int col ) @@ -835,7 +805,7 @@ class wxGrid : public wxPanel SetRowLabelAlignment( align, -1 ); } - int GetLabelAlignment( int orientation, int align ) + int GetLabelAlignment( int orientation, int WXUNUSED(align) ) { int h, v; if ( orientation == wxHORIZONTAL ) @@ -869,7 +839,7 @@ class wxGrid : public wxPanel wxFont GetCellTextFont() const { return m_defaultCellFont; } - wxFont GetCellTextFont(int row, int col) const + wxFont GetCellTextFont(int WXUNUSED(row), int WXUNUSED(col)) const { return m_defaultCellFont; } void SetCellTextFont(const wxFont& fnt) @@ -895,6 +865,14 @@ class wxGrid : public wxPanel bool GetEditInPlace() { return IsCellEditControlEnabled(); } void SetEditInPlace(bool edit = TRUE) { EnableCellEditControl( edit ); } + void SetCellAlignment( int align, int row, int col) + { SetCellAlignment(row, col, align, wxCENTER); } + void SetCellAlignment( int WXUNUSED(align) ) {} + void SetCellBitmap(wxBitmap *WXUNUSED(bitmap), int WXUNUSED(row), int WXUNUSED(col)) + { } + void SetDividerPen(const wxPen& WXUNUSED(pen)) { } + wxPen& GetDividerPen() const { return wxNullPen; } + void OnActivate(bool WXUNUSED(active)) {} // ******** End of compatibility functions ********** @@ -927,7 +905,7 @@ class WXDLLEXPORT wxGridEvent : public wxNotifyEvent { DECLARE_DYNAMIC_CLASS(wxGridEvent) - private: + protected: int m_row; int m_col; int m_x; @@ -962,7 +940,7 @@ class WXDLLEXPORT wxGridSizeEvent : public wxNotifyEvent { DECLARE_DYNAMIC_CLASS(wxGridSizeEvent) - private: + protected: int m_rowOrCol; int m_x; int m_y; @@ -995,7 +973,7 @@ class WXDLLEXPORT wxGridRangeSelectEvent : public wxNotifyEvent { DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent) - private: + protected: wxGridCellCoords m_topLeft; wxGridCellCoords m_bottomRight; bool m_control; @@ -1034,48 +1012,49 @@ class WXDLLEXPORT wxGridRangeSelectEvent : public wxNotifyEvent }; -const wxEventType EVT_WXGRID_CELL_LEFT_CLICK = wxEVT_FIRST + 1580; -const wxEventType EVT_WXGRID_CELL_RIGHT_CLICK = wxEVT_FIRST + 1581; -const wxEventType EVT_WXGRID_CELL_LEFT_DCLICK = wxEVT_FIRST + 1582; -const wxEventType EVT_WXGRID_CELL_RIGHT_DCLICK = wxEVT_FIRST + 1583; -const wxEventType EVT_WXGRID_LABEL_LEFT_CLICK = wxEVT_FIRST + 1584; -const wxEventType EVT_WXGRID_LABEL_RIGHT_CLICK = wxEVT_FIRST + 1585; -const wxEventType EVT_WXGRID_LABEL_LEFT_DCLICK = wxEVT_FIRST + 1586; -const wxEventType EVT_WXGRID_LABEL_RIGHT_DCLICK = wxEVT_FIRST + 1587; -const wxEventType EVT_WXGRID_ROW_SIZE = wxEVT_FIRST + 1588; -const wxEventType EVT_WXGRID_COL_SIZE = wxEVT_FIRST + 1589; -const wxEventType EVT_WXGRID_RANGE_SELECT = wxEVT_FIRST + 1590; -const wxEventType EVT_WXGRID_CELL_CHANGE = wxEVT_FIRST + 1591; +const wxEventType EVT_GRID_CELL_LEFT_CLICK = wxEVT_FIRST + 1580; +const wxEventType EVT_GRID_CELL_RIGHT_CLICK = wxEVT_FIRST + 1581; +const wxEventType EVT_GRID_CELL_LEFT_DCLICK = wxEVT_FIRST + 1582; +const wxEventType EVT_GRID_CELL_RIGHT_DCLICK = wxEVT_FIRST + 1583; +const wxEventType EVT_GRID_LABEL_LEFT_CLICK = wxEVT_FIRST + 1584; +const wxEventType EVT_GRID_LABEL_RIGHT_CLICK = wxEVT_FIRST + 1585; +const wxEventType EVT_GRID_LABEL_LEFT_DCLICK = wxEVT_FIRST + 1586; +const wxEventType EVT_GRID_LABEL_RIGHT_DCLICK = wxEVT_FIRST + 1587; +const wxEventType EVT_GRID_ROW_SIZE = wxEVT_FIRST + 1588; +const wxEventType EVT_GRID_COL_SIZE = wxEVT_FIRST + 1589; +const wxEventType EVT_GRID_RANGE_SELECT = wxEVT_FIRST + 1590; +const wxEventType EVT_GRID_CELL_CHANGE = wxEVT_FIRST + 1591; +const wxEventType EVT_GRID_SELECT_CELL = wxEVT_FIRST + 1592; + typedef void (wxEvtHandler::*wxGridEventFunction)(wxGridEvent&); typedef void (wxEvtHandler::*wxGridSizeEventFunction)(wxGridSizeEvent&); typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction)(wxGridRangeSelectEvent&); -#define EVT_WXGRID_CELL_LEFT_CLICK(fn) { EVT_WXGRID_CELL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, -#define EVT_WXGRID_CELL_RIGHT_CLICK(fn) { EVT_WXGRID_CELL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, -#define EVT_WXGRID_CELL_LEFT_DCLICK(fn) { EVT_WXGRID_CELL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, -#define EVT_WXGRID_CELL_RIGHT_DCLICK(fn) { EVT_WXGRID_CELL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, -#define EVT_WXGRID_LABEL_LEFT_CLICK(fn) { EVT_WXGRID_LABEL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, -#define EVT_WXGRID_LABEL_RIGHT_CLICK(fn) { EVT_WXGRID_LABEL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, -#define EVT_WXGRID_LABEL_LEFT_DCLICK(fn) { EVT_WXGRID_LABEL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, -#define EVT_WXGRID_LABEL_RIGHT_DCLICK(fn) { EVT_WXGRID_LABEL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, -#define EVT_WXGRID_ROW_SIZE(fn) { EVT_WXGRID_ROW_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL }, -#define EVT_WXGRID_COL_SIZE(fn) { EVT_WXGRID_COL_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL }, -#define EVT_WXGRID_RANGE_SELECT(fn) { EVT_WXGRID_RANGE_SELECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridRangeSelectEventFunction) &fn, NULL }, -#define EVT_WXGRID_CELL_CHANGE(fn) { EVT_WXGRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, +#define EVT_GRID_CELL_LEFT_CLICK(fn) { EVT_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_LEFT_DCLICK(fn) { EVT_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_LABEL_LEFT_CLICK(fn) { EVT_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_LEFT_DCLICK(fn) { EVT_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_ROW_SIZE(fn) { EVT_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_RANGE_SELECT(fn) { EVT_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_SELECT_CELL(fn) { EVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, #if 0 // TODO: implement these ? others ? -const wxEventType EVT_WXGRID_SELECT_CELL = wxEVT_FIRST + 1575; -const wxEventType EVT_WXGRID_CREATE_CELL = wxEVT_FIRST + 1576; -const wxEventType EVT_WXGRID_CHANGE_LABELS = wxEVT_FIRST + 1577; -const wxEventType EVT_WXGRID_CHANGE_SEL_LABEL = wxEVT_FIRST + 1578; +const wxEventType EVT_GRID_CREATE_CELL = wxEVT_FIRST + 1576; +const wxEventType EVT_GRID_CHANGE_LABELS = wxEVT_FIRST + 1577; +const wxEventType EVT_GRID_CHANGE_SEL_LABEL = wxEVT_FIRST + 1578; -#define EVT_WXGRID_SELECT_CELL(fn) { EVT_WXGRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, -#define EVT_WXGRID_CREATE_CELL(fn) { EVT_WXGRID_CREATE_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, -#define EVT_WXGRID_CHANGE_LABELS(fn) { EVT_WXGRID_CHANGE_LABELS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, -#define EVT_WXGRID_CHANGE_SEL_LABEL(fn) { EVT_WXGRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, +#define EVT_GRID_CREATE_CELL(fn) { EVT_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_SEL_LABEL(fn) { EVT_GRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, #endif