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

📄 grid.h

📁 wxGTK 是 wxWidgets 的 linux GTK+ (>2.2.3)版本。wxWidgets 是一个跨平台的 GUI 框架
💻 H
📖 第 1 页 / 共 5 页
字号:
    wxGridCellAttr*     m_defGridAttr;    wxAttrReadMode m_isReadOnly;    wxAttrKind m_attrkind;    // use Clone() instead    DECLARE_NO_COPY_CLASS(wxGridCellAttr)    // suppress the stupid gcc warning about the class having private dtor and    // no friends    friend class wxGridCellAttrDummyFriend;};// ----------------------------------------------------------------------------// wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the// cell attributes.// ----------------------------------------------------------------------------// implementation note: we separate it from wxGridTableBase because we wish to// avoid deriving a new table class if possible, and sometimes it will be// enough to just derive another wxGridCellAttrProvider instead//// 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 oneclass WXDLLIMPEXP_ADV wxGridCellAttrProvider : public wxClientDataContainer{public:    wxGridCellAttrProvider();    virtual ~wxGridCellAttrProvider();    // DecRef() must be called on the returned pointer    virtual wxGridCellAttr *GetAttr(int row, int col,                                    wxGridCellAttr::wxAttrKind  kind ) const;    // all these functions take ownership of the pointer, don't call DecRef()    // on it    virtual void SetAttr(wxGridCellAttr *attr, int row, int col);    virtual void SetRowAttr(wxGridCellAttr *attr, int row);    virtual void SetColAttr(wxGridCellAttr *attr, int col);    // these functions must be called whenever some rows/cols are deleted    // because the internal data must be updated then    void UpdateAttrRows( size_t pos, int numRows );    void UpdateAttrCols( size_t pos, int numCols );private:    void InitData();    wxGridCellAttrProviderData *m_data;    DECLARE_NO_COPY_CLASS(wxGridCellAttrProvider)};//////////////////////////////////////////////////////////////////////////  Grid table classes////////////////////////////////////////////////////////////////////////class WXDLLIMPEXP_ADV wxGridTableBase : public wxObject, public wxClientDataContainer{public:    wxGridTableBase();    virtual ~wxGridTableBase();    // You must override these functions in a derived table class    //    virtual int GetNumberRows() = 0;    virtual int GetNumberCols() = 0;    virtual bool IsEmptyCell( int row, int col ) = 0;    virtual wxString GetValue( int row, int col ) = 0;    virtual void SetValue( int row, int col, const wxString& value ) = 0;    // Data type determination and value access    virtual wxString GetTypeName( int row, int col );    virtual bool CanGetValueAs( int row, int col, const wxString& typeName );    virtual bool CanSetValueAs( int row, int col, const wxString& typeName );    virtual long GetValueAsLong( int row, int col );    virtual double GetValueAsDouble( int row, int col );    virtual bool GetValueAsBool( int row, int col );    virtual void SetValueAsLong( int row, int col, long value );    virtual void SetValueAsDouble( int row, int col, double value );    virtual void SetValueAsBool( int row, int col, bool value );    // For user defined types    virtual void* GetValueAsCustom( int row, int col, const wxString& typeName );    virtual void  SetValueAsCustom( int row, int col, const wxString& typeName, void* value );    // Overriding these is optional    //    virtual void SetView( wxGrid *grid ) { m_view = grid; }    virtual wxGrid * GetView() const { return m_view; }    virtual void Clear() {}    virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 );    virtual bool AppendRows( size_t numRows = 1 );    virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 );    virtual bool InsertCols( size_t pos = 0, size_t numCols = 1 );    virtual bool AppendCols( size_t numCols = 1 );    virtual bool DeleteCols( size_t pos = 0, size_t numCols = 1 );    virtual wxString GetRowLabelValue( int row );    virtual wxString GetColLabelValue( int col );    virtual void SetRowLabelValue( int WXUNUSED(row), const wxString& ) {}    virtual void SetColLabelValue( int WXUNUSED(col), const wxString& ) {}    // Attribute handling    //    // give us the attr provider to use - we take ownership of the pointer    void SetAttrProvider(wxGridCellAttrProvider *attrProvider);    // get the currently used attr provider (may be NULL)    wxGridCellAttrProvider *GetAttrProvider() const { return m_attrProvider; }    // Does this table allow attributes?  Default implementation creates    // a wxGridCellAttrProvider if necessary.    virtual bool CanHaveAttributes();    // by default forwarded to wxGridCellAttrProvider if any. May be    // overridden to handle attributes directly in the table.    virtual wxGridCellAttr *GetAttr( int row, int col,                                     wxGridCellAttr::wxAttrKind  kind );    // these functions take ownership of the pointer    virtual void SetAttr(wxGridCellAttr* attr, int row, int col);    virtual void SetRowAttr(wxGridCellAttr *attr, int row);    virtual void SetColAttr(wxGridCellAttr *attr, int col);private:    wxGrid * m_view;    wxGridCellAttrProvider *m_attrProvider;    DECLARE_ABSTRACT_CLASS(wxGridTableBase)    DECLARE_NO_COPY_CLASS(wxGridTableBase)};// ----------------------------------------------------------------------------// wxGridTableMessage// ----------------------------------------------------------------------------// IDs for messages sent from grid table to view//enum wxGridTableRequest{    wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000,    wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES,    wxGRIDTABLE_NOTIFY_ROWS_INSERTED,    wxGRIDTABLE_NOTIFY_ROWS_APPENDED,    wxGRIDTABLE_NOTIFY_ROWS_DELETED,    wxGRIDTABLE_NOTIFY_COLS_INSERTED,    wxGRIDTABLE_NOTIFY_COLS_APPENDED,    wxGRIDTABLE_NOTIFY_COLS_DELETED};class WXDLLIMPEXP_ADV wxGridTableMessage{public:    wxGridTableMessage();    wxGridTableMessage( wxGridTableBase *table, int id,                        int comInt1 = -1,                        int comInt2 = -1 );    void SetTableObject( wxGridTableBase *table ) { m_table = table; }    wxGridTableBase * GetTableObject() const { return m_table; }    void SetId( int id ) { m_id = id; }    int  GetId() { return m_id; }    void SetCommandInt( int comInt1 ) { m_comInt1 = comInt1; }    int  GetCommandInt() { return m_comInt1; }    void SetCommandInt2( int comInt2 ) { m_comInt2 = comInt2; }    int  GetCommandInt2() { return m_comInt2; }private:    wxGridTableBase *m_table;    int m_id;    int m_comInt1;    int m_comInt2;    DECLARE_NO_COPY_CLASS(wxGridTableMessage)};// ------ wxGridStringArray// A 2-dimensional array of strings for data values//WX_DECLARE_OBJARRAY_WITH_DECL(wxArrayString, wxGridStringArray,                              class WXDLLIMPEXP_ADV);// ------ wxGridStringTable//// Simplest type of data table for a grid for small tables of strings// that are stored in memory//class WXDLLIMPEXP_ADV wxGridStringTable : public wxGridTableBase{public:    wxGridStringTable();    wxGridStringTable( int numRows, int numCols );    virtual ~wxGridStringTable();    // these are pure virtual in wxGridTableBase    //    int GetNumberRows();    int GetNumberCols();    wxString GetValue( int row, int col );    void SetValue( int row, int col, const wxString& s );    bool IsEmptyCell( int row, int col );    // overridden functions from wxGridTableBase    //    void Clear();    bool InsertRows( size_t pos = 0, size_t numRows = 1 );    bool AppendRows( size_t numRows = 1 );    bool DeleteRows( size_t pos = 0, size_t numRows = 1 );    bool InsertCols( size_t pos = 0, size_t numCols = 1 );    bool AppendCols( size_t numCols = 1 );    bool DeleteCols( size_t pos = 0, size_t numCols = 1 );    void SetRowLabelValue( int row, const wxString& );    void SetColLabelValue( int col, const wxString& );    wxString GetRowLabelValue( int row );    wxString GetColLabelValue( int col );private:    wxGridStringArray m_data;    // These only get used if you set your own labels, otherwise the    // GetRow/ColLabelValue functions return wxGridTableBase defaults    //    wxArrayString     m_rowLabels;    wxArrayString     m_colLabels;    DECLARE_DYNAMIC_CLASS_NO_COPY( wxGridStringTable )};// ============================================================================//  Grid view classes// ============================================================================// ----------------------------------------------------------------------------// wxGridCellCoords: location of a cell in the grid// ----------------------------------------------------------------------------class WXDLLIMPEXP_ADV wxGridCellCoords{public:    wxGridCellCoords() { m_row = m_col = -1; }    wxGridCellCoords( int r, int c ) { m_row = r; m_col = c; }    // default copy ctor is ok    int GetRow() const { return m_row; }    void SetRow( int n ) { m_row = n; }    int GetCol() const { return m_col; }    void SetCol( int n ) { m_col = n; }    void Set( int row, int col ) { m_row = row; m_col = col; }    wxGridCellCoords& operator=( const wxGridCellCoords& other )    {        if ( &other != this )        {            m_row=other.m_row;            m_col=other.m_col;        }        return *this;    }    bool operator==( const wxGridCellCoords& other ) const    {        return (m_row == other.m_row  &&  m_col == other.m_col);    }    bool operator!=( const wxGridCellCoords& other ) const    {        return (m_row != other.m_row  ||  m_col != other.m_col);    }    bool operator!() const    {        return (m_row == -1 && m_col == -1 );    }private:    int m_row;    int m_col;};// For comparisons...//extern WXDLLIMPEXP_ADV wxGridCellCoords wxGridNoCellCoords;extern WXDLLIMPEXP_ADV wxRect           wxGridNoCellRect;// An array of cell coords...//WX_DECLARE_OBJARRAY_WITH_DECL(wxGridCellCoords, wxGridCellCoordsArray,                              class WXDLLIMPEXP_ADV);// ----------------------------------------------------------------------------// wxGrid// ----------------------------------------------------------------------------class WXDLLIMPEXP_ADV wxGrid : public wxScrolledWindow{public:    wxGrid() ;        wxGrid( wxWindow *parent,            wxWindowID id,            const wxPoint& pos = wxDefaultPosition,            const wxSize& size = wxDefaultSize,            long style = wxWANTS_CHARS,            const wxString& name = wxGridNameStr );    bool Create( wxWindow *parent,            wxWindowID id,            const wxPoint& pos = wxDefaultPosition,            const wxSize& size = wxDefaultSize,            long style = wxWANTS_CHARS,            const wxString& name = wxGridNameStr );    virtual ~wxGrid();    enum wxGridSelectionModes {wxGridSelectCells,                               wxGridSelectRows,                               wxGridSelectColumns};    bool CreateGrid( int numRows, int numCols,                     wxGrid::wxGridSelectionModes selmode =                     wxGrid::wxGridSelectCells );    void SetSelectionMode(wxGrid::wxGridSelectionModes selmode);    wxGrid::wxGridSelectionModes GetSelectionMode() const;    // ------ grid dimensions    //    int      GetNumberRows() { return  m_numRows; }    int      GetNumberCols() { return  m_numCols; }    // ------ display update functions    //    wxArrayInt CalcRowLabelsExposed( const wxRegion& reg );    wxArrayInt CalcColLabelsExposed( const wxRegion& reg );    wxGridCellCoordsArray CalcCellsExposed( const wxRegion& reg );    // ------ event handlers    //    void ProcessRowLabelMouseEvent( wxMouseEvent& event );    void ProcessColLabelMouseEvent( wxMouseEvent& event );    void ProcessCornerLabelMouseEvent( wxMouseEvent& event );    void ProcessGridCellMouseEvent( wxMouseEvent& event );    bool ProcessTableMessage( wxGridTableMessage& );    void DoEndDragResizeRow();    void DoEndDragResizeCol();    void DoEndDragMoveCol();    wxGridTableBase * GetTable() const { return m_table; }    bool SetTable( wxGridTableBase *table, bool takeOwnership = false,                   wxGrid::wxGridSelectionModes selmode =                   wxGrid::wxGridSelectCells );

⌨️ 快捷键说明

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