📄 gridg.h
字号:
// Don't refresh within the outer pair of these.
void BeginBatch() { m_batchCount ++; }
void EndBatch() { m_batchCount --; }
int GetBatchCount() { return m_batchCount; }
// implementation from now on
void OnPaint(wxPaintEvent& event);
void OnEraseBackground(wxEraseEvent& event);
void OnMouseEvent(wxMouseEvent& event);
void OnSize(wxSizeEvent& event);
void OnText(wxCommandEvent& ev);
void OnTextEnter(wxCommandEvent& ev);
void OnTextInPlace(wxCommandEvent& ev);
void OnTextInPlaceEnter(wxCommandEvent& ev);
void OnGridScroll(wxScrollEvent& ev);
protected:
wxPanel* m_editingPanel; // Contains the text control
wxTextCtrl* m_textItem;
wxTextCtrl* m_inPlaceTextItem;
wxScrollBar* m_hScrollBar;
wxScrollBar* m_vScrollBar;
int m_wCursorRow;
int m_wCursorColumn;
wxRect m_currentRect;
bool m_currentRectVisible;
wxGridCell*** m_gridCells;
wxGridCell** m_rowLabelCells;
wxGridCell** m_colLabelCells;
bool m_editCreated;
bool m_editable;
bool m_editInPlace;
bool m_inOnTextInPlace;
bool m_inScroll;
int m_totalRows;
int m_totalCols;
// Row and column we're currently looking at
int m_scrollPosX;
int m_scrollPosY;
// Dimensions
int m_leftOfSheet;
int m_topOfSheet;
int m_rightOfSheet; // Calculated from m_colWidths
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;
int m_verticalLabelAlignment;
int m_horizontalLabelAlignment;
int m_cellAlignment;
short* m_colWidths; // Dynamically allocated
short* m_rowHeights; // Dynamically allocated
int m_scrollWidth; // Vert. scroll width, horiz. scroll height
// Colours
wxColour m_cellTextColour;
wxColour m_cellBackgroundColour;
wxFont m_cellTextFont;
wxColour m_labelTextColour;
wxColour m_labelBackgroundColour;
wxBrush m_labelBackgroundBrush;
wxFont m_labelTextFont;
wxPen m_divisionPen;
wxPen m_highlightPen;
wxBitmap* m_doubleBufferingBitmap;
// Position of Edit control
wxRect m_editControlPosition;
// Drag status
int m_dragStatus;
int m_dragRowOrCol;
int m_dragStartPosition;
int m_dragLastPosition;
wxCursor m_horizontalSashCursor;
wxCursor m_verticalSashCursor;
// To avoid multiple refreshes, use Begin/EndBatch
int m_batchCount;
DECLARE_EVENT_TABLE()
};
#define wxGRID_TEXT_CTRL 2000
#define wxGRID_HSCROLL 2001
#define wxGRID_VSCROLL 2002
#define wxGRID_EDIT_IN_PLACE_TEXT_CTRL 2003
class WXDLLEXPORT wxGridCell : public wxObject
{
public:
wxString textValue;
wxFont font;
wxColour textColour;
wxColour backgroundColour;
wxBrush backgroundBrush;
wxBitmap* cellBitmap;
void* cellData; // intended for additional data associated with a cell
int alignment;
wxGridCell(wxGenericGrid *window = (wxGenericGrid *) NULL);
~wxGridCell();
virtual wxString& GetTextValue() const { return (wxString&) textValue; }
virtual void SetTextValue(const wxString& str) { textValue = str; }
wxFont& GetFont() const { return (wxFont&) font; }
void SetFont(const wxFont& f) { font = f; }
wxColour& GetTextColour() const { return (wxColour&) textColour; }
void SetTextColour(const wxColour& colour) { textColour = colour; }
wxColour& GetBackgroundColour() const { return (wxColour&) backgroundColour; }
void SetBackgroundColour(const wxColour& colour);
wxBrush& GetBackgroundBrush() const { return (wxBrush&) backgroundBrush; }
void SetBackgroundBrush(const wxBrush& brush) { backgroundBrush = brush; }
int GetAlignment() const { return alignment; }
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
{
public:
wxGrid() : wxGenericGrid() { }
wxGrid(wxWindow *parent, int x=-1, int y=-1, int width=-1, int height=-1,
long style=0, char *name = "gridWindow")
: 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
{
DECLARE_DYNAMIC_CLASS(wxGridEvent)
public:
wxGridEvent()
: wxCommandEvent(), m_row(-1), m_col(-1), m_x(-1), m_y(-1),
m_control(0), m_shift(0), m_cell(0)
{
}
wxGridEvent(int id, wxEventType type, wxObject* obj,
int row=-1, int col=-1, int x=-1, int y=-1,
bool control=FALSE, bool shift=FALSE)
: wxCommandEvent(type, id), m_row(row), m_col(col), m_x(x), m_y(y),
m_control(control), m_shift(shift), m_cell(0)
{
SetEventObject(obj);
}
//private:
int m_row;
int m_col;
int m_x;
int m_y;
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;
const wxEventType wxEVT_GRID_CREATE_CELL = wxEVT_FIRST + 1576;
const wxEventType wxEVT_GRID_CHANGE_LABELS = wxEVT_FIRST + 1577;
const wxEventType wxEVT_GRID_CHANGE_SEL_LABEL = wxEVT_FIRST + 1578;
const wxEventType wxEVT_GRID_CELL_CHANGE = wxEVT_FIRST + 1579;
const wxEventType wxEVT_GRID_CELL_LCLICK = wxEVT_FIRST + 1580;
const wxEventType wxEVT_GRID_CELL_RCLICK = wxEVT_FIRST + 1581;
const wxEventType wxEVT_GRID_LABEL_LCLICK = wxEVT_FIRST + 1582;
const wxEventType wxEVT_GRID_LABEL_RCLICK = wxEVT_FIRST + 1583;
typedef void (wxEvtHandler::*wxGridEventFunction)(wxGridEvent&);
#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__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -