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

📄 grid.h

📁 wxGTK 是 wxWidgets 的 linux GTK+ (>2.2.3)版本。wxWidgets 是一个跨平台的 GUI 框架
💻 H
📖 第 1 页 / 共 5 页
字号:
// the editor for string/text dataclass WXDLLIMPEXP_ADV wxGridCellTextEditor : public wxGridCellEditor{public:    wxGridCellTextEditor();    virtual void Create(wxWindow* parent,                        wxWindowID id,                        wxEvtHandler* evtHandler);    virtual void SetSize(const wxRect& rect);    virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);    virtual bool IsAcceptedKey(wxKeyEvent& event);    virtual void BeginEdit(int row, int col, wxGrid* grid);    virtual bool EndEdit(int row, int col, wxGrid* grid);    virtual void Reset();    virtual void StartingKey(wxKeyEvent& event);    virtual void HandleReturn(wxKeyEvent& event);    // parameters string format is "max_width"    virtual void SetParameters(const wxString& params);    virtual wxGridCellEditor *Clone() const        { return new wxGridCellTextEditor; }    // added GetValue so we can get the value which is in the control    virtual wxString GetValue() const;protected:    wxTextCtrl *Text() const { return (wxTextCtrl *)m_control; }    // parts of our virtual functions reused by the derived classes    void DoBeginEdit(const wxString& startValue);    void DoReset(const wxString& startValue);private:    size_t   m_maxChars;        // max number of chars allowed    wxString m_startValue;    DECLARE_NO_COPY_CLASS(wxGridCellTextEditor)};// the editor for numeric (long) dataclass WXDLLIMPEXP_ADV wxGridCellNumberEditor : public wxGridCellTextEditor{public:    // allows to specify the range - if min == max == -1, no range checking is    // done    wxGridCellNumberEditor(int min = -1, int max = -1);    virtual void Create(wxWindow* parent,                        wxWindowID id,                        wxEvtHandler* evtHandler);    virtual bool IsAcceptedKey(wxKeyEvent& event);    virtual void BeginEdit(int row, int col, wxGrid* grid);    virtual bool EndEdit(int row, int col, wxGrid* grid);    virtual void Reset();    virtual void StartingKey(wxKeyEvent& event);    // parameters string format is "min,max"    virtual void SetParameters(const wxString& params);    virtual wxGridCellEditor *Clone() const        { return new wxGridCellNumberEditor(m_min, m_max); }    // added GetValue so we can get the value which is in the control    virtual wxString GetValue() const;protected:#if wxUSE_SPINCTRL    wxSpinCtrl *Spin() const { return (wxSpinCtrl *)m_control; }#endif    // if HasRange(), we use wxSpinCtrl - otherwise wxTextCtrl    bool HasRange() const    {#if wxUSE_SPINCTRL        return m_min != m_max;#else        return false;#endif    }    // string representation of m_valueOld    wxString GetString() const        { return wxString::Format(_T("%ld"), m_valueOld); }private:    int m_min,        m_max;    long m_valueOld;    DECLARE_NO_COPY_CLASS(wxGridCellNumberEditor)};// the editor for floating point numbers (double) dataclass WXDLLIMPEXP_ADV wxGridCellFloatEditor : public wxGridCellTextEditor{public:    wxGridCellFloatEditor(int width = -1, int precision = -1);    virtual void Create(wxWindow* parent,                        wxWindowID id,                        wxEvtHandler* evtHandler);    virtual bool IsAcceptedKey(wxKeyEvent& event);    virtual void BeginEdit(int row, int col, wxGrid* grid);    virtual bool EndEdit(int row, int col, wxGrid* grid);    virtual void Reset();    virtual void StartingKey(wxKeyEvent& event);    virtual wxGridCellEditor *Clone() const        { return new wxGridCellFloatEditor(m_width, m_precision); }    // parameters string format is "width,precision"    virtual void SetParameters(const wxString& params);protected:    // string representation of m_valueOld    wxString GetString() const;private:    int m_width,        m_precision;    double m_valueOld;    DECLARE_NO_COPY_CLASS(wxGridCellFloatEditor)};#endif // wxUSE_TEXTCTRL#if wxUSE_CHECKBOX// the editor for boolean dataclass WXDLLIMPEXP_ADV wxGridCellBoolEditor : public wxGridCellEditor{public:    wxGridCellBoolEditor() { }    virtual void Create(wxWindow* parent,                        wxWindowID id,                        wxEvtHandler* evtHandler);    virtual void SetSize(const wxRect& rect);    virtual void Show(bool show, wxGridCellAttr *attr = NULL);    virtual bool IsAcceptedKey(wxKeyEvent& event);    virtual void BeginEdit(int row, int col, wxGrid* grid);    virtual bool EndEdit(int row, int col, wxGrid* grid);    virtual void Reset();    virtual void StartingClick();    virtual void StartingKey(wxKeyEvent& event);    virtual wxGridCellEditor *Clone() const        { return new wxGridCellBoolEditor; }    // added GetValue so we can get the value which is in the control, see    // also UseStringValues()    virtual wxString GetValue() const;    // set the string values returned by GetValue() for the true and false    // states, respectively    static void UseStringValues(const wxString& valueTrue = _T("1"),                                const wxString& valueFalse = wxEmptyString);    // return true if the given string is equal to the string representation of    // true value which we currently use    static bool IsTrueValue(const wxString& value);protected:    wxCheckBox *CBox() const { return (wxCheckBox *)m_control; }private:    bool m_startValue;    static wxString ms_stringValues[2];    DECLARE_NO_COPY_CLASS(wxGridCellBoolEditor)};#endif // wxUSE_CHECKBOX#if wxUSE_COMBOBOX// the editor for string data allowing to choose from the list of stringsclass WXDLLIMPEXP_ADV wxGridCellChoiceEditor : public wxGridCellEditor{public:    // if !allowOthers, user can't type a string not in choices array    wxGridCellChoiceEditor(size_t count = 0,                           const wxString choices[] = NULL,                           bool allowOthers = false);    wxGridCellChoiceEditor(const wxArrayString& choices,                           bool allowOthers = false);    virtual void Create(wxWindow* parent,                        wxWindowID id,                        wxEvtHandler* evtHandler);    virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);    virtual void BeginEdit(int row, int col, wxGrid* grid);    virtual bool EndEdit(int row, int col, wxGrid* grid);    virtual void Reset();    // parameters string format is "item1[,item2[...,itemN]]"    virtual void SetParameters(const wxString& params);    virtual wxGridCellEditor *Clone() const;    // added GetValue so we can get the value which is in the control    virtual wxString GetValue() const;protected:    wxComboBox *Combo() const { return (wxComboBox *)m_control; }// DJC - (MAPTEK) you at least need access to m_choices if you//                wish to override this classprotected:    wxString        m_startValue;    wxArrayString   m_choices;    bool            m_allowOthers;    DECLARE_NO_COPY_CLASS(wxGridCellChoiceEditor)};#endif // wxUSE_COMBOBOX// ----------------------------------------------------------------------------// wxGridCellAttr: this class can be used to alter the cells appearance in// the grid by changing their colour/font/... from default. An object of this// class may be returned by wxGridTable::GetAttr().// ----------------------------------------------------------------------------class WXDLLIMPEXP_ADV wxGridCellAttr : public wxClientDataContainer{public:    enum wxAttrKind    {        Any,        Default,        Cell,        Row,        Col,        Merged    };    // ctors    wxGridCellAttr(wxGridCellAttr *attrDefault = NULL)    {        Init(attrDefault);        // MB: args used to be 0,0 here but wxALIGN_LEFT is 0        SetAlignment(-1, -1);    }    // VZ: considering the number of members wxGridCellAttr has now, this ctor    //     seems to be pretty useless... may be we should just remove it?    wxGridCellAttr(const wxColour& colText,                   const wxColour& colBack,                   const wxFont& font,                   int hAlign,                   int vAlign)        : m_colText(colText), m_colBack(colBack), m_font(font)    {        Init();        SetAlignment(hAlign, vAlign);    }    // creates a new copy of this object    wxGridCellAttr *Clone() const;    void MergeWith(wxGridCellAttr *mergefrom);    // this class is ref counted: it is created with ref count of 1, so    // calling DecRef() once will delete it. Calling IncRef() allows to lock    // it until the matching DecRef() is called    void IncRef() { m_nRef++; }    void DecRef() { if ( --m_nRef == 0 ) delete this; }    // setters    void SetTextColour(const wxColour& colText) { m_colText = colText; }    void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }    void SetFont(const wxFont& font) { m_font = font; }    void SetAlignment(int hAlign, int vAlign)    {        m_hAlign = hAlign;        m_vAlign = vAlign;    }    void SetSize(int num_rows, int num_cols);    void SetOverflow(bool allow = true)        { m_overflow = allow ? Overflow : SingleCell; }    void SetReadOnly(bool isReadOnly = true)        { m_isReadOnly = isReadOnly ? ReadOnly : ReadWrite; }    // takes ownership of the pointer    void SetRenderer(wxGridCellRenderer *renderer)        { wxSafeDecRef(m_renderer); m_renderer = renderer; }    void SetEditor(wxGridCellEditor* editor)        { wxSafeDecRef(m_editor); m_editor = editor; }    void SetKind(wxAttrKind kind) { m_attrkind = kind; }    // accessors    bool HasTextColour() const { return m_colText.Ok(); }    bool HasBackgroundColour() const { return m_colBack.Ok(); }    bool HasFont() const { return m_font.Ok(); }    bool HasAlignment() const { return (m_hAlign != -1 || m_vAlign != -1); }    bool HasRenderer() const { return m_renderer != NULL; }    bool HasEditor() const { return m_editor != NULL; }    bool HasReadWriteMode() const { return m_isReadOnly != Unset; }    bool HasOverflowMode() const { return m_overflow != UnsetOverflow; }    bool HasSize() const { return m_sizeRows != 1 || m_sizeCols != 1; }    const wxColour& GetTextColour() const;    const wxColour& GetBackgroundColour() const;    const wxFont& GetFont() const;    void GetAlignment(int *hAlign, int *vAlign) const;    void GetSize(int *num_rows, int *num_cols) const;    bool GetOverflow() const        { return m_overflow != SingleCell; }    wxGridCellRenderer *GetRenderer(wxGrid* grid, int row, int col) const;    wxGridCellEditor *GetEditor(wxGrid* grid, int row, int col) const;    bool IsReadOnly() const { return m_isReadOnly == wxGridCellAttr::ReadOnly; }    wxAttrKind GetKind() { return m_attrkind; }    void SetDefAttr(wxGridCellAttr* defAttr) { m_defGridAttr = defAttr; }protected:    // the dtor is private because only DecRef() can delete us    virtual ~wxGridCellAttr()    {        wxSafeDecRef(m_renderer);        wxSafeDecRef(m_editor);    }private:    enum wxAttrReadMode    {        Unset = -1,        ReadWrite,        ReadOnly    };    enum wxAttrOverflowMode    {        UnsetOverflow = -1,        Overflow,        SingleCell    };    // the common part of all ctors    void Init(wxGridCellAttr *attrDefault = NULL);    // the ref count - when it goes to 0, we die    size_t   m_nRef;    wxColour m_colText,             m_colBack;    wxFont   m_font;    int      m_hAlign,             m_vAlign;    int      m_sizeRows,             m_sizeCols;    wxAttrOverflowMode  m_overflow;    wxGridCellRenderer* m_renderer;    wxGridCellEditor*   m_editor;

⌨️ 快捷键说明

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