X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/aa5b885706e9a5bee8ad5346f024710a72356108..4104ed92a537f36f7f41ce07d34cadbe4d78685c:/include/wx/generic/grid.h diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 8825ffe555..c66bfc6bd9 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -11,10 +11,6 @@ #include "wx/defs.h" -#if !defined(wxUSE_NEW_GRID) || !(wxUSE_NEW_GRID) -#include "wx/generic/gridg.h" -#else - #ifndef __WXGRID_H__ #define __WXGRID_H__ @@ -22,10 +18,11 @@ #pragma interface "grid.h" #endif -#include "wx/hash.h" +#include "wx/hashmap.h" #include "wx/panel.h" #include "wx/scrolwin.h" #include "wx/string.h" +#include "wx/arrstr.h" #include "wx/scrolbar.h" #include "wx/event.h" #include "wx/combobox.h" @@ -84,6 +81,9 @@ class WXDLLEXPORT wxComboBox; class WXDLLEXPORT wxTextCtrl; class WXDLLEXPORT wxSpinCtrl; +WX_DECLARE_EXPORTED_HASH_MAP( long, long, wxIntegerHash, wxIntegerEqual, + wxLongToLongHashMap ); + // ---------------------------------------------------------------------------- // macros // ---------------------------------------------------------------------------- @@ -302,6 +302,9 @@ public: wxControl* GetControl() { return m_control; } void SetControl(wxControl* control) { m_control = control; } + wxGridCellAttr* GetCellAttr() { return m_attr; } + void SetCellAttr(wxGridCellAttr* attr) { m_attr = attr; } + // Creates the actual edit control virtual void Create(wxWindow* parent, wxWindowID id, @@ -357,6 +360,10 @@ public: // create a new object which is the copy of this one virtual wxGridCellEditor *Clone() const = 0; + // DJC MAPTEK + // added GetValue so we can get the value which is in the control + virtual wxString GetValue() const = 0; + protected: // the dtor is private because only DecRef() can delete us virtual ~wxGridCellEditor(); @@ -364,6 +371,9 @@ protected: // the control we show on screen wxControl* m_control; + // a temporary pointer to the attribute being edited + wxGridCellAttr* m_attr; + // if we change the colours/font of the control from the default ones, we // must restore the default later and we save them here between calls to // Show(TRUE) and Show(FALSE) @@ -374,6 +384,8 @@ protected: // suppress the stupid gcc warning about the class having private dtor and // no friends friend class wxGridCellEditorDummyFriend; + + DECLARE_NO_COPY_CLASS(wxGridCellEditor) }; #if wxUSE_TEXTCTRL @@ -405,6 +417,9 @@ public: virtual wxGridCellEditor *Clone() const { return new wxGridCellTextEditor; } + // DJC MAPTEK + // 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; } @@ -415,6 +430,8 @@ protected: private: size_t m_maxChars; // max number of chars allowed wxString m_startValue; + + DECLARE_NO_COPY_CLASS(wxGridCellTextEditor) }; // the editor for numeric (long) data @@ -441,6 +458,9 @@ public: virtual wxGridCellEditor *Clone() const { return new wxGridCellNumberEditor(m_min, m_max); } + // DJC MAPTEK + // added GetValue so we can get the value which is in the control + virtual wxString GetValue() const; protected: wxSpinCtrl *Spin() const { return (wxSpinCtrl *)m_control; } @@ -457,6 +477,8 @@ private: m_max; long m_valueOld; + + DECLARE_NO_COPY_CLASS(wxGridCellNumberEditor) }; // the editor for floating point numbers (double) data @@ -490,6 +512,8 @@ private: int m_width, m_precision; double m_valueOld; + + DECLARE_NO_COPY_CLASS(wxGridCellFloatEditor) }; #endif // wxUSE_TEXTCTRL @@ -500,6 +524,8 @@ private: class WXDLLEXPORT wxGridCellBoolEditor : public wxGridCellEditor { public: + wxGridCellBoolEditor() { } + virtual void Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler); @@ -516,12 +542,17 @@ public: virtual wxGridCellEditor *Clone() const { return new wxGridCellBoolEditor; } + // DJC MAPTEK + // added GetValue so we can get the value which is in the control + virtual wxString GetValue() const; protected: wxCheckBox *CBox() const { return (wxCheckBox *)m_control; } private: bool m_startValue; + + DECLARE_NO_COPY_CLASS(wxGridCellBoolEditor) }; #endif // wxUSE_CHECKBOX @@ -552,14 +583,21 @@ public: virtual void SetParameters(const wxString& params); virtual wxGridCellEditor *Clone() const; + // DJC MAPTEK + // 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; } -private: +// DJC - (MAPTEK) you at least need access to m_choices if you +// wish to override this class +protected: wxString m_startValue; wxArrayString m_choices; bool m_allowOthers; + + DECLARE_NO_COPY_CLASS(wxGridCellChoiceEditor) }; #endif // wxUSE_COMBOBOX @@ -625,7 +663,8 @@ public: m_vAlign = vAlign; } void SetSize(int num_rows, int num_cols); - void SetOverflow( bool allow ) { m_overflow = allow; } + void SetOverflow(bool allow = TRUE) + { m_overflow = allow ? Overflow : SingleCell; } void SetReadOnly(bool isReadOnly = TRUE) { m_isReadOnly = isReadOnly ? ReadOnly : ReadWrite; } @@ -645,13 +684,15 @@ public: 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; } 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; } + 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; @@ -669,6 +710,13 @@ private: ReadOnly }; + enum wxAttrOverflowMode + { + UnsetOverflow = -1, + Overflow, + SingleCell + }; + // the common part of all ctors void Init(wxGridCellAttr *attrDefault = NULL); @@ -689,7 +737,8 @@ private: m_vAlign; int m_sizeRows, m_sizeCols; - bool m_overflow; + + wxAttrOverflowMode m_overflow; wxGridCellRenderer* m_renderer; wxGridCellEditor* m_editor; @@ -744,6 +793,8 @@ private: void InitData(); wxGridCellAttrProviderData *m_data; + + DECLARE_NO_COPY_CLASS(wxGridCellAttrProvider) }; ////////////////////////////////////////////////////////////////////// @@ -832,6 +883,7 @@ private: wxGridCellAttrProvider *m_attrProvider; DECLARE_ABSTRACT_CLASS( wxGridTableBase ); + DECLARE_NO_COPY_CLASS(wxGridTableBase) }; @@ -875,6 +927,8 @@ private: int m_id; int m_comInt1; int m_comInt2; + + DECLARE_NO_COPY_CLASS(wxGridTableMessage) }; @@ -932,7 +986,7 @@ private: wxArrayString m_rowLabels; wxArrayString m_colLabels; - DECLARE_DYNAMIC_CLASS( wxGridStringTable ) + DECLARE_DYNAMIC_CLASS_NO_COPY( wxGridStringTable ) }; @@ -1091,11 +1145,13 @@ public: // void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&, int horizontalAlignment = wxALIGN_LEFT, - int verticalAlignment = wxALIGN_TOP ); + int verticalAlignment = wxALIGN_TOP, + int textOrientation = wxHORIZONTAL ); void DrawTextRectangle( wxDC& dc, const wxArrayString& lines, const wxRect&, int horizontalAlignment = wxALIGN_LEFT, - int verticalAlignment = wxALIGN_TOP ); + int verticalAlignment = wxALIGN_TOP, + int textOrientation = wxHORIZONTAL ); // Split a string containing newline chararcters into an array of @@ -1118,7 +1174,8 @@ public: int GetBatchCount() { return m_batchCount; } - virtual void Refresh(bool eraseb=true, wxRect* rect= NULL); + virtual void Refresh(bool eraseb = TRUE, + const wxRect* rect = (const wxRect *) NULL); // Use this, rather than wxWindow::Refresh(), to force an // immediate repainting of the grid. Has no effect if you are @@ -1206,6 +1263,7 @@ public: wxFont GetLabelFont() { return m_labelFont; } void GetRowLabelAlignment( int *horiz, int *vert ); void GetColLabelAlignment( int *horiz, int *vert ); + int GetColLabelTextOrientation(); wxString GetRowLabelValue( int row ); wxString GetColLabelValue( int col ); wxColour GetGridLineColour() { return m_gridLineColour; } @@ -1220,6 +1278,7 @@ public: void SetLabelFont( const wxFont& ); void SetRowLabelAlignment( int horiz, int vert ); void SetColLabelAlignment( int horiz, int vert ); + void SetColLabelTextOrientation( int textOrientation ); void SetRowLabelValue( int row, const wxString& ); void SetColLabelValue( int col, const wxString& ); void SetGridLineColour( const wxColour& ); @@ -1296,12 +1355,30 @@ public: // and also set the grid size to just fit its contents void AutoSize(); + // autosize row height depending on label text + void AutoSizeRowLabelSize( int row ); + + // autosize column width depending on label text + void AutoSizeColLabelSize( int col ); + // column won't be resized to be lesser width - this must be called during // the grid creation because it won't resize the column if it's already // narrower than the minimal width void SetColMinimalWidth( int col, int width ); void SetRowMinimalHeight( int row, int width ); + /* These members can be used to query and modify the minimal + * acceptable size of grid rows and columns. Call this function in + * your code which creates the grid if you want to display cells + * with a size smaller than the default acceptable minimum size. + * Like the members SetColMinimalWidth and SetRowMinimalWidth, + * the existing rows or columns will not be checked/resized. + */ + void SetColMinimalAcceptableWidth( int width ); + void SetRowMinimalAcceptableHeight( int width ); + int GetColMinimalAcceptableWidth() const; + int GetRowMinimalAcceptableHeight() const; + void SetDefaultCellBackgroundColour( const wxColour& ); void SetCellBackgroundColour( int row, int col, const wxColour& ); void SetDefaultCellTextColour( const wxColour& ); @@ -1415,12 +1492,13 @@ public: void RegisterDataType(const wxString& typeName, wxGridCellRenderer* renderer, wxGridCellEditor* editor); - wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const; + // DJC MAPTEK + virtual wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const; wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const { return GetDefaultEditorForCell(c.GetRow(), c.GetCol()); } - wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const; - wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const; - wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const; + virtual wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const; + virtual wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const; + virtual wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const; // grid may occupy more space than needed for its rows/columns, this // function allows to set how big this extra space is @@ -1636,6 +1714,7 @@ protected: void InitRowHeights(); int m_defaultRowHeight; + int m_minAcceptableRowHeight; wxArrayInt m_rowHeights; wxArrayInt m_rowBottoms; @@ -1643,6 +1722,7 @@ protected: void InitColWidths(); int m_defaultColWidth; + int m_minAcceptableColWidth; wxArrayInt m_colWidths; wxArrayInt m_colRights; @@ -1674,6 +1754,7 @@ protected: int m_rowLabelVertAlign; int m_colLabelHorizAlign; int m_colLabelVertAlign; + int m_colLabelTextOrientation; bool m_defaultRowLabelValues; bool m_defaultColLabelValues; @@ -1694,8 +1775,8 @@ protected: // if a column has a minimal width, it will be the value for it in this // hash table - wxHashTableLong m_colMinWidths, - m_rowMinHeights; + wxLongToLongHashMap m_colMinWidths, + m_rowMinHeights; // get the minimal width of the given column/row int GetColMinimalWidth(int col) const; @@ -1823,12 +1904,14 @@ protected: bool GetModelValues(); bool SetModelValues(); - friend class wxGridSelection; + friend class WXDLLEXPORT wxGridSelection; DECLARE_DYNAMIC_CLASS( wxGrid ) DECLARE_EVENT_TABLE() + DECLARE_NO_COPY_CLASS(wxGrid) }; + // ---------------------------------------------------------------------------- // Grid event class and event types // ---------------------------------------------------------------------------- @@ -1866,7 +1949,7 @@ protected: bool m_shift; bool m_alt; - DECLARE_DYNAMIC_CLASS(wxGridEvent) + DECLARE_DYNAMIC_CLASS_NO_COPY(wxGridEvent) }; class WXDLLEXPORT wxGridSizeEvent : public wxNotifyEvent @@ -1898,7 +1981,7 @@ protected: bool m_shift; bool m_alt; - DECLARE_DYNAMIC_CLASS(wxGridSizeEvent) + DECLARE_DYNAMIC_CLASS_NO_COPY(wxGridSizeEvent) }; @@ -1945,7 +2028,7 @@ protected: bool m_shift; bool m_alt; - DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent) + DECLARE_DYNAMIC_CLASS_NO_COPY(wxGridRangeSelectEvent) }; @@ -1975,6 +2058,7 @@ private: wxControl* m_ctrl; DECLARE_DYNAMIC_CLASS(wxGridEditorCreatedEvent) + DECLARE_NO_COPY_CLASS(wxGridEditorCreatedEvent) }; @@ -2033,6 +2117,5 @@ extern const int wxEVT_GRID_CHANGE_SEL_LABEL; #endif -#endif // #ifndef __WXGRID_H__ +#endif // ifndef wxUSE_GRID -#endif // ifndef wxUSE_NEW_GRID