X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/73145b0ed18e99b66988c3caf6ad9119911913bb..4104ed92a537f36f7f41ce07d34cadbe4d78685c:/include/wx/generic/grid.h diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 8ece9e5136..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, @@ -368,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) @@ -378,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 @@ -422,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 @@ -467,6 +477,8 @@ private: m_max; long m_valueOld; + + DECLARE_NO_COPY_CLASS(wxGridCellNumberEditor) }; // the editor for floating point numbers (double) data @@ -500,6 +512,8 @@ private: int m_width, m_precision; double m_valueOld; + + DECLARE_NO_COPY_CLASS(wxGridCellFloatEditor) }; #endif // wxUSE_TEXTCTRL @@ -510,6 +524,8 @@ private: class WXDLLEXPORT wxGridCellBoolEditor : public wxGridCellEditor { public: + wxGridCellBoolEditor() { } + virtual void Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler); @@ -535,6 +551,8 @@ protected: private: bool m_startValue; + + DECLARE_NO_COPY_CLASS(wxGridCellBoolEditor) }; #endif // wxUSE_CHECKBOX @@ -578,6 +596,8 @@ protected: wxString m_startValue; wxArrayString m_choices; bool m_allowOthers; + + DECLARE_NO_COPY_CLASS(wxGridCellChoiceEditor) }; #endif // wxUSE_COMBOBOX @@ -643,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; } @@ -663,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; @@ -687,6 +710,13 @@ private: ReadOnly }; + enum wxAttrOverflowMode + { + UnsetOverflow = -1, + Overflow, + SingleCell + }; + // the common part of all ctors void Init(wxGridCellAttr *attrDefault = NULL); @@ -707,7 +737,8 @@ private: m_vAlign; int m_sizeRows, m_sizeCols; - bool m_overflow; + + wxAttrOverflowMode m_overflow; wxGridCellRenderer* m_renderer; wxGridCellEditor* m_editor; @@ -762,6 +793,8 @@ private: void InitData(); wxGridCellAttrProviderData *m_data; + + DECLARE_NO_COPY_CLASS(wxGridCellAttrProvider) }; ////////////////////////////////////////////////////////////////////// @@ -850,6 +883,7 @@ private: wxGridCellAttrProvider *m_attrProvider; DECLARE_ABSTRACT_CLASS( wxGridTableBase ); + DECLARE_NO_COPY_CLASS(wxGridTableBase) }; @@ -893,6 +927,8 @@ private: int m_id; int m_comInt1; int m_comInt2; + + DECLARE_NO_COPY_CLASS(wxGridTableMessage) }; @@ -950,7 +986,7 @@ private: wxArrayString m_rowLabels; wxArrayString m_colLabels; - DECLARE_DYNAMIC_CLASS( wxGridStringTable ) + DECLARE_DYNAMIC_CLASS_NO_COPY( wxGridStringTable ) }; @@ -1109,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 @@ -1225,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; } @@ -1239,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& ); @@ -1315,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& ); @@ -1656,6 +1714,7 @@ protected: void InitRowHeights(); int m_defaultRowHeight; + int m_minAcceptableRowHeight; wxArrayInt m_rowHeights; wxArrayInt m_rowBottoms; @@ -1663,6 +1722,7 @@ protected: void InitColWidths(); int m_defaultColWidth; + int m_minAcceptableColWidth; wxArrayInt m_colWidths; wxArrayInt m_colRights; @@ -1694,6 +1754,7 @@ protected: int m_rowLabelVertAlign; int m_colLabelHorizAlign; int m_colLabelVertAlign; + int m_colLabelTextOrientation; bool m_defaultRowLabelValues; bool m_defaultColLabelValues; @@ -1714,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; @@ -1847,8 +1908,10 @@ protected: DECLARE_DYNAMIC_CLASS( wxGrid ) DECLARE_EVENT_TABLE() + DECLARE_NO_COPY_CLASS(wxGrid) }; + // ---------------------------------------------------------------------------- // Grid event class and event types // ---------------------------------------------------------------------------- @@ -1886,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 @@ -1918,7 +1981,7 @@ protected: bool m_shift; bool m_alt; - DECLARE_DYNAMIC_CLASS(wxGridSizeEvent) + DECLARE_DYNAMIC_CLASS_NO_COPY(wxGridSizeEvent) }; @@ -1965,7 +2028,7 @@ protected: bool m_shift; bool m_alt; - DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent) + DECLARE_DYNAMIC_CLASS_NO_COPY(wxGridRangeSelectEvent) }; @@ -1995,6 +2058,7 @@ private: wxControl* m_ctrl; DECLARE_DYNAMIC_CLASS(wxGridEditorCreatedEvent) + DECLARE_NO_COPY_CLASS(wxGridEditorCreatedEvent) }; @@ -2053,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