]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/generic/grid.h
return empty string instead of NULL from mb_str()/wc_str() when conversion fails...
[wxWidgets.git] / include / wx / generic / grid.h
index a6e5a5b1bf30d6f181c2b37ba718d7e1b0b57799..9c16160f286e7589a1377593447ab8e0dd41dfa6 100644 (file)
@@ -218,8 +218,10 @@ public:
     // new value in its string form in the newval output parameter.
     //
     // This should also store the new value in its real type internally so that
-    // it could be used by ApplyEdit().
-    virtual bool EndEdit(const wxString& oldval, wxString *newval) = 0;
+    // it could be used by ApplyEdit() but it must not modify the grid as the
+    // change could still be vetoed.
+    virtual bool EndEdit(int row, int col, const wxGrid *grid,
+                         const wxString& oldval, wxString *newval) = 0;
 
     // Complete the editing of the current cell by storing the value saved by
     // the previous call to EndEdit() in the grid
@@ -281,7 +283,7 @@ protected:
     // no friends
     friend class wxGridCellEditorDummyFriend;
 
-    DECLARE_NO_COPY_CLASS(wxGridCellEditor)
+    wxDECLARE_NO_COPY_CLASS(wxGridCellEditor);
 };
 
 
@@ -435,7 +437,7 @@ private:
     wxAttrKind m_attrkind;
 
     // use Clone() instead
-    DECLARE_NO_COPY_CLASS(wxGridCellAttr)
+    wxDECLARE_NO_COPY_CLASS(wxGridCellAttr);
 
     // suppress the stupid gcc warning about the class having private dtor and
     // no friends
@@ -480,7 +482,7 @@ private:
 
     wxGridCellAttrProviderData *m_data;
 
-    DECLARE_NO_COPY_CLASS(wxGridCellAttrProvider)
+    wxDECLARE_NO_COPY_CLASS(wxGridCellAttrProvider);
 };
 
 // ----------------------------------------------------------------------------
@@ -649,7 +651,7 @@ private:
     wxGridCellAttrProvider *m_attrProvider;
 
     DECLARE_ABSTRACT_CLASS(wxGridTableBase)
-    DECLARE_NO_COPY_CLASS(wxGridTableBase)
+    wxDECLARE_NO_COPY_CLASS(wxGridTableBase);
 };
 
 
@@ -694,7 +696,7 @@ private:
     int m_comInt1;
     int m_comInt2;
 
-    DECLARE_NO_COPY_CLASS(wxGridTableMessage)
+    wxDECLARE_NO_COPY_CLASS(wxGridTableMessage);
 };
 
 
@@ -761,6 +763,39 @@ private:
 //  Grid view classes
 // ============================================================================
 
+// ----------------------------------------------------------------------------
+// wxGridSizesInfo stores information about sizes of the rows or columns.
+//
+// It assumes that most of the columns or rows have default size and so stores
+// the default size separately and uses a hash to map column or row numbers to
+// their non default size for those which don't have the default size.
+// ----------------------------------------------------------------------------
+
+// Hashmap to store postions as the keys and sizes as the values
+WX_DECLARE_HASH_MAP_WITH_DECL( unsigned, int, wxIntegerHash, wxIntegerEqual,
+                               wxUnsignedToIntHashMap, class WXDLLIMPEXP_ADV );
+
+struct WXDLLIMPEXP_ADV wxGridSizesInfo
+{
+    // default ctor, initialize m_sizeDefault and m_customSizes later
+    wxGridSizesInfo() { }
+
+    // ctor used by wxGrid::Get{Col,Row}Sizes()
+    wxGridSizesInfo(int defSize, const wxArrayInt& allSizes);
+
+    // default copy ctor, assignment operator and dtor are ok
+
+    // Get the size of the element with the given index
+    int GetSize(unsigned pos) const;
+
+
+    // default size
+    int m_sizeDefault;
+
+    // position -> size map containing all elements with non-default size
+    wxUnsignedToIntHashMap m_customSizes;
+};
+
 // ----------------------------------------------------------------------------
 // wxGrid
 // ----------------------------------------------------------------------------
@@ -1170,6 +1205,17 @@ public:
     void     HideCol(int col) { SetColSize(col, 0); }
     void     ShowCol(int col) { SetColSize(col, -1); }
 
+    // the row and column sizes can be also set all at once using
+    // wxGridSizesInfo which holds all of them at once
+
+    wxGridSizesInfo GetColSizes() const
+        { return wxGridSizesInfo(GetDefaultColSize(), m_colWidths); }
+    wxGridSizesInfo GetRowSizes() const
+        { return wxGridSizesInfo(GetDefaultRowSize(), m_rowHeights); }
+
+    void SetColSizes(const wxGridSizesInfo& sizeInfo);
+    void SetRowSizes(const wxGridSizesInfo& sizeInfo);
+
 
     // ------- columns (only, for now) reordering
 
@@ -2037,9 +2083,13 @@ private:
     bool DoAppendLines(bool (wxGridTableBase::*funcAppend)(size_t),
                        int num, bool updateLabels);
 
+    // Common part of Set{Col,Row}Sizes
+    void DoSetSizes(const wxGridSizesInfo& sizeInfo,
+                    const wxGridOperations& oper);
+
     DECLARE_DYNAMIC_CLASS( wxGrid )
     DECLARE_EVENT_TABLE()
-    DECLARE_NO_COPY_CLASS(wxGrid)
+    wxDECLARE_NO_COPY_CLASS(wxGrid);
 };
 
 // ----------------------------------------------------------------------------
@@ -2080,7 +2130,7 @@ private:
 
     wxGrid *m_grid;
 
-    DECLARE_NO_COPY_CLASS(wxGridUpdateLocker)
+    wxDECLARE_NO_COPY_CLASS(wxGridUpdateLocker);
 };
 
 // ----------------------------------------------------------------------------
@@ -2113,7 +2163,7 @@ public:
 
     // explicitly specifying inline allows gcc < 3.4 to
     // handle the deprecation attribute even in the constructor.
-    wxDEPRECATED( inline
+    wxDEPRECATED_CONSTRUCTOR(
     wxGridEvent(int id,
                 wxEventType type,
                 wxObject* obj,
@@ -2174,7 +2224,7 @@ public:
         SetEventObject(obj);
     }
 
-    wxDEPRECATED( inline
+    wxDEPRECATED_CONSTRUCTOR(
     wxGridSizeEvent(int id,
                     wxEventType type,
                     wxObject* obj,
@@ -2232,7 +2282,7 @@ public:
         SetEventObject(obj);
     }
 
-    wxDEPRECATED( inline
+    wxDEPRECATED_CONSTRUCTOR(
     wxGridRangeSelectEvent(int id,
                            wxEventType type,
                            wxObject* obj,
@@ -2304,26 +2354,26 @@ private:
 };
 
 
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_CELL_LEFT_CLICK;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_CELL_RIGHT_CLICK;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_CELL_LEFT_DCLICK;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_CELL_RIGHT_DCLICK;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_LABEL_LEFT_CLICK;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_LABEL_RIGHT_CLICK;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_LABEL_LEFT_DCLICK;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_LABEL_RIGHT_DCLICK;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_ROW_SIZE;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_COL_SIZE;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_RANGE_SELECT;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_CELL_CHANGING;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_CELL_CHANGED;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_SELECT_CELL;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_EDITOR_SHOWN;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_EDITOR_HIDDEN;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_EDITOR_CREATED;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_CELL_BEGIN_DRAG;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_COL_MOVE;
-extern WXDLLIMPEXP_ADV const wxEventType wxEVT_GRID_COL_SORT;
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_LEFT_CLICK, wxGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_RIGHT_DCLICK, wxGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_LEFT_CLICK, wxGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_RIGHT_CLICK, wxGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_LEFT_DCLICK, wxGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_RIGHT_DCLICK, wxGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_ROW_SIZE, wxGridSizeEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_COL_SIZE, wxGridSizeEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_RANGE_SELECT, wxGridRangeSelectEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_CHANGING, wxGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_CHANGED, wxGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_SELECT_CELL, wxGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_EDITOR_SHOWN, wxGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_EDITOR_HIDDEN, wxGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_EDITOR_CREATED, wxGridEditorCreatedEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_BEGIN_DRAG, wxGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_COL_MOVE, wxGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_COL_SORT, wxGridEvent );
 
 typedef void (wxEvtHandler::*wxGridEventFunction)(wxGridEvent&);
 typedef void (wxEvtHandler::*wxGridSizeEventFunction)(wxGridSizeEvent&);
@@ -2331,16 +2381,16 @@ typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction)(wxGridRangeSelectEv
 typedef void (wxEvtHandler::*wxGridEditorCreatedEventFunction)(wxGridEditorCreatedEvent&);
 
 #define wxGridEventHandler(func) \
-    (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxGridEventFunction, &func)
+    wxEVENT_HANDLER_CAST(wxGridEventFunction, func)
 
 #define wxGridSizeEventHandler(func) \
-    (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxGridSizeEventFunction, &func)
+    wxEVENT_HANDLER_CAST(wxGridSizeEventFunction, func)
 
 #define wxGridRangeSelectEventHandler(func) \
-    (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxGridRangeSelectEventFunction, &func)
+    wxEVENT_HANDLER_CAST(wxGridRangeSelectEventFunction, func)
 
 #define wxGridEditorCreatedEventHandler(func) \
-    (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxGridEditorCreatedEventFunction, &func)
+    wxEVENT_HANDLER_CAST(wxGridEditorCreatedEventFunction, func)
 
 #define wx__DECLARE_GRIDEVT(evt, id, fn) \
     wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridEventHandler(fn))