X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dfe1eee3bb9ecde8c4490ea69c07b5030d69530c..ef344ff86223f1f0961f025c0b249c898529c095:/include/wx/generic/gridg.h diff --git a/include/wx/generic/gridg.h b/include/wx/generic/gridg.h index 81a409bea1..1fa85c62bd 100644 --- a/include/wx/generic/gridg.h +++ b/include/wx/generic/gridg.h @@ -2,7 +2,7 @@ // Name: gridg.h // Purpose: wxGenericGrid // Author: Julian Smart -// Modified by: Michael Bedward +// Modified by: Michael Bedward // Added edit in place facility, 20 April 1999 // Added cursor key control, 29 Jun 1999 // Created: 01/02/97 @@ -19,6 +19,9 @@ #endif #include "wx/defs.h" + +#if wxUSE_GRID + #include "wx/panel.h" #include "wx/string.h" #include "wx/scrolbar.h" @@ -35,14 +38,6 @@ #define wxGRID_DEFAULT_VERTICAL_LABEL_WIDTH 40 #define wxGRID_DEFAULT_HORIZONAL_LABEL_HEIGHT 20 -#ifndef wxLEFT - #define wxLEFT 0x0400 -#endif - -#ifndef wxRIGHT - #define wxRIGHT 0x0800 -#endif - #define WXGENERIC_GRID_VERSION 0.5 class WXDLLEXPORT wxGridEvent; @@ -101,12 +96,16 @@ public: void SetCellTextFont(const wxFont& fnt, int row, int col); wxBitmap *GetCellBitmap(int row, int col) const; void SetCellBitmap(wxBitmap *bitmap, int row, int col); + void *SetCellData(void *data, int row, int col); + void *GetCellData(int row, int col); // Size accessors void SetColumnWidth(int col, int width); int GetColumnWidth(int col) const; void SetRowHeight(int row, int height); int GetRowHeight(int row) const; + int GetViewHeight() const { return m_viewHeight; } + int GetViewWidth() const { return m_viewWidth; } // Label accessors void SetLabelSize(int orientation, int sz); @@ -190,7 +189,7 @@ public: void UpdateDimensions(); void SetCurrentRect (int Row, int Column, int canvasW = -1, int canvasH = -1); - void HighlightCell (wxDC *dc); + void HighlightCell(wxDC *dc, bool doHighlight); void DrawCellText(); void SetGridClippingRegion(wxDC *dc); @@ -251,6 +250,7 @@ protected: bool m_editable; bool m_editInPlace; bool m_inOnTextInPlace; + bool m_inScroll; int m_totalRows; int m_totalCols; @@ -266,6 +266,8 @@ protected: int m_bottomOfSheet; // Calculated from m_rowHeights int m_totalGridWidth; // Total 'virtual' size int m_totalGridHeight; + int m_viewHeight; // Number of rows displayed + int m_viewWidth; // Number of columns displayed int m_cellHeight; // For now, a default int m_verticalLabelWidth; int m_horizontalLabelHeight; @@ -285,6 +287,7 @@ protected: wxBrush m_labelBackgroundBrush; wxFont m_labelTextFont; wxPen m_divisionPen; + wxPen m_highlightPen; wxBitmap* m_doubleBufferingBitmap; // Position of Edit control @@ -318,7 +321,8 @@ public: wxColour backgroundColour; wxBrush backgroundBrush; wxBitmap* cellBitmap; - int alignment; + void* cellData; // intended for additional data associated with a cell + int alignment; wxGridCell(wxGenericGrid *window = (wxGenericGrid *) NULL); ~wxGridCell(); @@ -337,6 +341,9 @@ public: void SetAlignment(int align) { alignment = align; } wxBitmap *GetCellBitmap() const { return cellBitmap; } void SetCellBitmap(wxBitmap *bitmap) { cellBitmap = bitmap; } + + void *SetCellData(void *data) { void *rc = cellData; cellData = data; return rc; } + void *GetCellData() const { return cellData; } }; class WXDLLEXPORT wxGrid : public wxGenericGrid @@ -348,6 +355,12 @@ public: : wxGenericGrid(parent, x, y, width, height, style, name) { } + wxGrid(wxWindow *parent, wxWindowID id, const wxPoint& pos, + const wxSize& size, long style = 0, const wxString& name = "grid") + : wxGenericGrid(parent, id, pos, size, style, name) + { + } + }; class WXDLLEXPORT wxGridEvent : public wxCommandEvent @@ -378,6 +391,13 @@ public: bool m_control; bool m_shift; wxGridCell* m_cell; + + int GetRow() const { return m_row; } + int GetCol() const { return m_col; } + wxPoint GetPosition() const { return wxPoint( m_x, m_y ); } + wxGridCell* GetCell() const { return m_cell; } + bool ControlDown() const { return m_control; } + bool ShiftDown() const { return m_shift; } }; const wxEventType wxEVT_GRID_SELECT_CELL = wxEVT_FIRST + 1575; @@ -393,15 +413,17 @@ const wxEventType wxEVT_GRID_LABEL_RCLICK = wxEVT_FIRST + 1583; typedef void (wxEvtHandler::*wxGridEventFunction)(wxGridEvent&); -#define EVT_GRID_SELECT_CELL(fn) { wxEVT_GRID_SELECT_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) { wxEVT_GRID_CHANGE_LABELS, -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 }, -#define EVT_GRID_CELL_CHANGE(fn) { wxEVT_GRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, -#define EVT_GRID_CELL_LCLICK(fn) { wxEVT_GRID_CELL_LCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, -#define EVT_GRID_CELL_RCLICK(fn) { wxEVT_GRID_CELL_RCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, -#define EVT_GRID_LABEL_LCLICK(fn) { wxEVT_GRID_LABEL_LCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, -#define EVT_GRID_LABEL_RCLICK(fn) { wxEVT_GRID_LABEL_RCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL }, +#define EVT_GRID_SELECT_CELL(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL), +#define EVT_GRID_CREATE_CELL(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_GRID_CREATE_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL), +#define EVT_GRID_CHANGE_LABELS(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_GRID_CHANGE_LABELS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL), +#define EVT_GRID_CHANGE_SEL_LABEL(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_GRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL), +#define EVT_GRID_CELL_CHANGE(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_GRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL), +#define EVT_GRID_CELL_LCLICK(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_GRID_CELL_LCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL), +#define EVT_GRID_CELL_RCLICK(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_GRID_CELL_RCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL), +#define EVT_GRID_LABEL_LCLICK(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_GRID_LABEL_LCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL), +#define EVT_GRID_LABEL_RCLICK(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_GRID_LABEL_RCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL), + +#endif // wxUSE_GRID #endif // __GRIDH_G__