⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gridg.h

📁 浙江大学的悟空嵌入式系统模拟器
💻 H
📖 第 1 页 / 共 2 页
字号:
/////////////////////////////////////////////////////////////////////////////
// Name:        gridg.h
// Purpose:     wxGenericGrid
// Author:      Julian Smart
// Modified by: Michael Bedward
//                Added edit in place facility, 20 April 1999
//                Added cursor key control, 29 Jun 1999
// Created:     01/02/97
// RCS-ID:      $Id: gridg.h,v 1.1 2005/03/16 06:49:37 kehc Exp $
// Copyright:   (c)
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

#ifndef __GRIDH_G__
#define __GRIDH_G__

#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "gridg.h"
#endif

#include "wx/defs.h"

#if wxUSE_GRID

#include "wx/panel.h"
#include "wx/string.h"
#include "wx/scrolbar.h"
#include "wx/event.h"

#define wxGRID_DEFAULT_EDIT_WIDTH 300
#define wxGRID_DEFAULT_EDIT_HEIGHT 27
#define wxGRID_DEFAULT_EDIT_X 2
#define wxGRID_DEFAULT_EDIT_Y 1
#define wxGRID_DEFAULT_SHEET_TOP 31
#define wxGRID_DEFAULT_SHEET_LEFT 0
#define wxGRID_DEFAULT_CELL_HEIGHT 20
#define wxGRID_DEFAULT_CELL_WIDTH 80
#define wxGRID_DEFAULT_VERTICAL_LABEL_WIDTH 40
#define wxGRID_DEFAULT_HORIZONAL_LABEL_HEIGHT 20

#define WXGENERIC_GRID_VERSION  0.5

class WXDLLEXPORT wxGridEvent;
class WXDLLEXPORT wxGridCell;

class WXDLLEXPORT wxGenericGrid : public wxPanel
{
    DECLARE_DYNAMIC_CLASS(wxGenericGrid)

public:
    wxGenericGrid();

    wxGenericGrid(wxWindow *parent, int x, int y, int width, int height, long style = 0, char *name = "grid")
    {
        Create(parent, -1, wxPoint(x, y), wxSize(width, height), style, name);
    }
    wxGenericGrid(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style = 0, const wxString& name = "grid")
    {
        Create(parent, id, pos, size, style, name);
    }
    ~wxGenericGrid();

    bool Create(wxWindow *parent, wxWindowID, const wxPoint& pos, const wxSize& size, long style = 0, const wxString& name = "grid");

    bool CreateGrid(int nRows, int nCols, wxString **cellValues = (wxString **) NULL, short *widths = (short *) NULL,
            short defaultWidth = wxGRID_DEFAULT_CELL_WIDTH, short defaultHeight = wxGRID_DEFAULT_CELL_HEIGHT);
    void PaintGrid(wxDC& dc);
    void ClearGrid();
    virtual wxGridCell *GetCell(int row, int col) const;
    wxGridCell ***GetCells() const { return m_gridCells; }
    bool InsertCols(int pos = 0, int n = 1, bool updateLabels = TRUE);
    bool InsertRows(int pos = 0, int n = 1, bool updateLabels = TRUE);
    bool AppendCols(int n = 1, bool updateLabels = TRUE);
    bool AppendRows(int n = 1, bool updateLabels = TRUE);
    bool DeleteCols(int pos = 0, int n = 1, bool updateLabels = TRUE);
    bool DeleteRows(int pos = 0, int n = 1, bool updateLabels = TRUE);

    // Cell accessors
    void SetCellValue(const wxString& val, int row, int col);
    wxString& GetCellValue(int row, int col) const;
    void SetCellAlignment(int flag, int row, int col);
    void SetCellAlignment(int flag);
    int GetCellAlignment(int row, int col) const;
    int GetCellAlignment() const;
    void SetCellTextColour(const wxColour& val, int row, int col);
    void SetCellTextColour(const wxColour& col);
    wxColour& GetCellTextColour(int row, int col) const;
    wxColour& GetCellTextColour() const { return (wxColour&) m_cellTextColour; }
    void SetCellBackgroundColour(const wxColour& col);
    void SetCellBackgroundColour(const wxColour& colour, int row, int col);
    wxColour& GetCellBackgroundColour() const { return (wxColour&) m_cellBackgroundColour; }
    wxColour& GetCellBackgroundColour(int row, int col) const;
    wxFont& GetCellTextFont() const { return (wxFont&) m_cellTextFont; }
    wxFont& GetCellTextFont(int row, int col) const;
    void SetCellTextFont(const wxFont& fnt);
    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);
    int GetLabelSize(int orientation) const;
    void SetLabelAlignment(int orientation, int alignment);
    int GetLabelAlignment(int orientation) const;
    wxGridCell *GetLabelCell(int orientation, int pos) const;
    void SetLabelValue(int orientation, const wxString& val, int pos);
    wxString& GetLabelValue(int orientation, int pos) const;
    void SetLabelTextColour(const wxColour& colour);
    void SetLabelBackgroundColour(const wxColour& colour);
    wxColour& GetLabelTextColour() const { return (wxColour&) m_labelTextColour; }
    wxColour& GetLabelBackgroundColour() { return (wxColour&) m_labelBackgroundColour; }
    wxFont& GetLabelTextFont() { return (wxFont&) m_labelTextFont; }
    void SetLabelTextFont(const wxFont& fnt) { m_labelTextFont = fnt; }

    // Miscellaneous accessors
    int GetCursorRow() const { return m_wCursorRow; }
    int GetCursorColumn() const { return m_wCursorColumn; }
    void SetGridCursor(int row, int col);
    int GetRows() const { return m_totalRows; }
    int GetCols() const { return m_totalCols; }
    int GetScrollPosX() const { return m_scrollPosX; }
    int GetScrollPosY() const { return m_scrollPosY; }
    void SetScrollPosX(int pos) { m_scrollPosX = pos; }
    void SetScrollPosY(int pos) { m_scrollPosY = pos; }
    wxTextCtrl *GetTextItem() const { return m_textItem; }
    wxScrollBar *GetHorizScrollBar() const { return m_hScrollBar; }
    wxScrollBar *GetVertScrollBar() const { return m_vScrollBar; }
    bool GetEditable() const { return m_editable; }
    void SetEditable(bool edit);

    bool GetEditInPlace() const { return m_editInPlace; }
    void SetEditInPlace(bool edit = TRUE);

    wxRect& GetCurrentRect() const { return (wxRect&) m_currentRect; }
    bool CurrentCellVisible() const { return m_currentRectVisible; }
    void SetDividerPen(const wxPen& pen) { m_divisionPen = pen; }
    wxPen& GetDividerPen() const { return (wxPen&) m_divisionPen; }

    // High-level event handling
    // Override e.g. to check value of current cell; but call
    // base member for default processing.
    virtual void OnSelectCellImplementation(wxDC *dc, int row, int col);

    virtual void OnSelectCell(int WXUNUSED(row), int WXUNUSED(col)) {};
    void _OnSelectCell(wxGridEvent& event);

    // Override to create your own class of grid cell
    virtual wxGridCell *OnCreateCell();
    void _OnCreateCell(wxGridEvent& event);

    // Override to change labels e.g. creation of grid, inserting/deleting a row/col.
    // By default, auto-labels the grid.
    virtual void OnChangeLabels();
    void _OnChangeLabels(wxGridEvent& event);

    // Override to change the label of the edit field when selecting a cell
    // By default, sets it to e.g. A12
    virtual void OnChangeSelectionLabel();
    void _OnChangeSelectionLabel(wxGridEvent& event);

    // Override for event processing
    virtual void OnCellChange(int WXUNUSED(row), int WXUNUSED(col)) {};
    virtual void OnCellLeftClick(int WXUNUSED(row), int WXUNUSED(col), int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(control), bool WXUNUSED(shift)) {};
    virtual void OnCellRightClick(int WXUNUSED(row), int WXUNUSED(col), int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(control), bool WXUNUSED(shift)) {};
    virtual void OnLabelLeftClick(int WXUNUSED(row), int WXUNUSED(col), int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(control), bool WXUNUSED(shift)) {};
    virtual void OnLabelRightClick(int WXUNUSED(row), int WXUNUSED(col), int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(control), bool WXUNUSED(shift)) {};

    void _OnCellChange(wxGridEvent& event);
    void _OnCellLeftClick(wxGridEvent& event);
    void _OnCellRightClick(wxGridEvent& event);
    void _OnLabelLeftClick(wxGridEvent& event);
    void _OnLabelRightClick(wxGridEvent& event);

    // Activation: call from wxFrame::OnActivate
    void OnActivate(bool active);

    // Miscellaneous
    void AdjustScrollbars();
    void UpdateDimensions();

    void SetCurrentRect (int Row, int Column, int canvasW = -1, int canvasH = -1);
    void HighlightCell(wxDC *dc, bool doHighlight);
    void DrawCellText();
    void SetGridClippingRegion(wxDC *dc);

    virtual bool CellHitTest(int x, int y, int *row, int *col);
    virtual bool LabelSashHitTest(int x, int y, int *orientation, int *rowOrCol, int *startPos);
    virtual bool LabelHitTest(int x, int y, int *row, int *col);

    // Painting
    virtual void DrawLabelAreas(wxDC *dc);
    virtual void DrawEditableArea(wxDC *dc);
    virtual void DrawGridLines(wxDC *dc);
    virtual void DrawColumnLabels(wxDC *dc);
    virtual void DrawColumnLabel(wxDC *dc, wxRect *rect, int col);
    virtual void DrawRowLabels(wxDC *dc);
    virtual void DrawRowLabel(wxDC *dc, wxRect *rect, int row);
    virtual void DrawCells(wxDC *dc);
    virtual void DrawCellValue(wxDC *dc, wxRect *rect, int row, int col);
    virtual void DrawCellBackground(wxDC *dc, wxRect *rect, int row, int col);
    virtual void DrawTextRect(wxDC *dc, const wxString& text, wxRect *rect, int flag);
    virtual void DrawBitmapRect(wxDC *dc, wxBitmap *bitmap, wxRect *rect, int flag);

    // Refresh cell and optionally set the text field
    void RefreshCell(int row, int col, bool setText = FALSE);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -