]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/propgrid/propgrid.h
another fix for wxUSE_DRAG_AND_DROP==0 build
[wxWidgets.git] / include / wx / propgrid / propgrid.h
index cd239f59591aee258792243fc53550702cc99401..e0edca337dbb371483c177ffb3cc626fca97ce28 100644 (file)
@@ -495,8 +495,8 @@ enum wxPG_KEYBOARD_ACTIONS
 #define wxPG_MAN_FL_PAGE_INSERTED           0x02000000
 // Active editor control is abnormally large
 #define wxPG_FL_ABNORMAL_EDITOR             0x04000000
 #define wxPG_MAN_FL_PAGE_INSERTED           0x02000000
 // Active editor control is abnormally large
 #define wxPG_FL_ABNORMAL_EDITOR             0x04000000
-// Recursion guard for OnCustomEditorEvent
-#define wxPG_FL_IN_ONCUSTOMEDITOREVENT      0x08000000
+// Recursion guard for HandleCustomEditorEvent
+#define wxPG_FL_IN_HANDLECUSTOMEDITOREVENT  0x08000000
 #define wxPG_FL_VALUE_CHANGE_IN_EVENT       0x10000000
 // Editor control width should not change on resize
 #define wxPG_FL_FIXED_WIDTH_EDITOR          0x20000000
 #define wxPG_FL_VALUE_CHANGE_IN_EVENT       0x10000000
 // Editor control width should not change on resize
 #define wxPG_FL_FIXED_WIDTH_EDITOR          0x20000000
@@ -1008,6 +1008,45 @@ public:
         m_iFlags |= wxPG_FL_SPLITTER_PRE_SET;
     }
 
         m_iFlags |= wxPG_FL_SPLITTER_PRE_SET;
     }
 
+    /**
+        Sets the property sorting function.
+
+        @param sortFunction
+            The sorting function to be used. It should return a value greater
+            than 0 if position of p1 is after p2. So, for instance, when
+            comparing property names, you can use following implementation:
+
+            @code
+                int MyPropertySortFunction(wxPropertyGrid* propGrid,
+                                           wxPGProperty* p1,
+                                           wxPGProperty* p2)
+                {
+                    return p1->GetBaseName().compare( p2->GetBaseName() );
+                }
+            @endcode
+
+        @remarks
+            Default property sort function sorts properties by their labels
+            (case-insensitively).
+
+        @see GetSortFunction, wxPropertyGridInterface::Sort,
+             wxPropertyGridInterface::SortChildren
+    */
+    void SetSortFunction( wxPGSortCallback sortFunction )
+    {
+        m_sortFunction = sortFunction;
+    }
+
+    /**
+        Returns the property sort function (default is @NULL).
+
+        @see SetSortFunction
+    */
+    wxPGSortCallback GetSortFunction() const
+    {
+        return m_sortFunction;
+    }
+
     /** Set virtual width for this particular page. Width -1 indicates that the
         virtual width should be disabled. */
     void SetVirtualWidth( int width );
     /** Set virtual width for this particular page. Width -1 indicates that the
         virtual width should be disabled. */
     void SetVirtualWidth( int width );
@@ -1041,13 +1080,6 @@ public:
         DoShowPropertyError(p, msg);
     }
 
         DoShowPropertyError(p, msg);
     }
 
-    /** Sorts all items at all levels (except sub-properties). */
-    void Sort();
-
-    /** Sorts children of a category.
-    */
-    void SortChildren( wxPGPropArg id );
-
     /////////////////////////////////////////////////////////////////
     //
     // Following methods do not need to be (currently) documented
     /////////////////////////////////////////////////////////////////
     //
     // Following methods do not need to be (currently) documented
@@ -1179,6 +1211,14 @@ public:
         return m_wndEditor2;
     }
 
         return m_wndEditor2;
     }
 
+    /**
+        Refreshes any active editor control.
+    */
+    void RefreshEditor();
+
+    // Events from editor controls are forward to this function
+    void HandleCustomEditorEvent( wxEvent &event );
+
 #ifndef SWIG
 
     /**
 #ifndef SWIG
 
     /**
@@ -1196,22 +1236,6 @@ public:
     // Mostly useful for page switching.
     void SwitchState( wxPropertyGridPageState* pNewState );
 
     // Mostly useful for page switching.
     void SwitchState( wxPropertyGridPageState* pNewState );
 
-    /**
-        When creating custom property editors, connect required editor events to
-        this function. For instance:
-
-        @code
-            control->Connect(control->GetId(), wxEVT_COMMAND_TEXT_UPDATED,
-                             wxEventHandler(wxPropertyGrid::OnCustomEditorEvent),
-                             NULL, propgrid);
-        @endcode
-
-        @remarks You should never need to call this function directly!
-
-        @see wxPGEditor::CreateControls(), wxEvtHandler::Connect()
-    */
-    void OnCustomEditorEvent( wxEvent &event );
-
     long GetInternalFlags() const { return m_iFlags; }
     bool HasInternalFlag( long flag ) const
         { return (m_iFlags & flag) ? true : false; }
     long GetInternalFlags() const { return m_iFlags; }
     bool HasInternalFlag( long flag ) const
         { return (m_iFlags & flag) ? true : false; }
@@ -1270,12 +1294,8 @@ public:
         To add your own validation failure behavior, override
         wxPropertyGrid::DoOnValidationFailure().
     */
         To add your own validation failure behavior, override
         wxPropertyGrid::DoOnValidationFailure().
     */
-    bool OnValidationFailure( wxPGProperty* property, wxVariant& invalidValue )
-    {
-        bool res = DoOnValidationFailure(property, invalidValue);
-        property->SetFlag(wxPG_PROP_INVALID_VALUE);
-        return res;
-    }
+    bool OnValidationFailure( wxPGProperty* property,
+                              wxVariant& invalidValue );
 
     /** Called to indicate property and editor has valid value now.
     */
 
     /** Called to indicate property and editor has valid value now.
     */
@@ -1327,7 +1347,6 @@ public:
     */
     bool UnfocusEditor();
 
     */
     bool UnfocusEditor();
 
-    virtual bool ProcessEvent(wxEvent& event);
     virtual void SetWindowStyleFlag( long style );
 
 protected:
     virtual void SetWindowStyleFlag( long style );
 
 protected:
@@ -1586,6 +1605,9 @@ protected:
     // Top level parent
     wxWindow*           m_tlp;
 
     // Top level parent
     wxWindow*           m_tlp;
 
+    // Sort function
+    wxPGSortCallback    m_sortFunction;
+
     // y coordinate of property that mouse hovering
     int                 m_propHoverY;
     // Which column's editor is selected (usually 1)?
     // y coordinate of property that mouse hovering
     int                 m_propHoverY;
     // Which column's editor is selected (usually 1)?
@@ -1722,8 +1744,6 @@ protected:
                      const wxRect* clip_rect,
                      bool isBuffered ) const;
 
                      const wxRect* clip_rect,
                      bool isBuffered ) const;
 
-    void DoSetPropertyValueUnspecified( wxPGProperty* p );
-
     /** Draws an expand/collapse (ie. +/-) button.
     */
     virtual void DrawExpanderButton( wxDC& dc, const wxRect& rect,
     /** Draws an expand/collapse (ie. +/-) button.
     */
     virtual void DrawExpanderButton( wxDC& dc, const wxRect& rect,
@@ -1874,15 +1894,15 @@ inline bool wxPGProperty::SetMaxLength( int maxLen )
 
 #ifndef SWIG
 
 
 #ifndef SWIG
 
-extern WXDLLIMPEXP_PROPGRID const wxEventType wxEVT_PG_SELECTED;
-extern WXDLLIMPEXP_PROPGRID const wxEventType wxEVT_PG_CHANGING;
-extern WXDLLIMPEXP_PROPGRID const wxEventType wxEVT_PG_CHANGED;
-extern WXDLLIMPEXP_PROPGRID const wxEventType wxEVT_PG_HIGHLIGHTED;
-extern WXDLLIMPEXP_PROPGRID const wxEventType wxEVT_PG_RIGHT_CLICK;
-extern WXDLLIMPEXP_PROPGRID const wxEventType wxEVT_PG_PAGE_CHANGED;
-extern WXDLLIMPEXP_PROPGRID const wxEventType wxEVT_PG_ITEM_COLLAPSED;
-extern WXDLLIMPEXP_PROPGRID const wxEventType wxEVT_PG_ITEM_EXPANDED;
-extern WXDLLIMPEXP_PROPGRID const wxEventType wxEVT_PG_DOUBLE_CLICK;
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_SELECTED, wxPropertyGridEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_CHANGING, wxPropertyGridEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_CHANGED, wxPropertyGridEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_HIGHLIGHTED, wxPropertyGridEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_RIGHT_CLICK, wxPropertyGridEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_PAGE_CHANGED, wxPropertyGridEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_ITEM_COLLAPSED, wxPropertyGridEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_ITEM_EXPANDED, wxPropertyGridEvent )
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_DOUBLE_CLICK, wxPropertyGridEvent )
 
 #else
     enum {
 
 #else
     enum {
@@ -1906,18 +1926,18 @@ extern WXDLLIMPEXP_PROPGRID const wxEventType wxEVT_PG_DOUBLE_CLICK;
 #ifndef SWIG
 typedef void (wxEvtHandler::*wxPropertyGridEventFunction)(wxPropertyGridEvent&);
 
 #ifndef SWIG
 typedef void (wxEvtHandler::*wxPropertyGridEventFunction)(wxPropertyGridEvent&);
 
-#define EVT_PG_SELECTED(id, fn)              DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
-#define EVT_PG_CHANGING(id, fn)              DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
-#define EVT_PG_CHANGED(id, fn)               DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
-#define EVT_PG_HIGHLIGHTED(id, fn)           DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_HIGHLIGHTED, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
-#define EVT_PG_RIGHT_CLICK(id, fn)           DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
-#define EVT_PG_DOUBLE_CLICK(id, fn)          DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_DOUBLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
-#define EVT_PG_PAGE_CHANGED(id, fn)          DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_PAGE_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
-#define EVT_PG_ITEM_COLLAPSED(id, fn)        DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_COLLAPSED, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
-#define EVT_PG_ITEM_EXPANDED(id, fn)         DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_EXPANDED, id, -1, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxPropertyGridEventFunction, & fn ), (wxObject *) NULL ),
-
-#define wxPropertyGridEventHandler(A) \
-    ((wxObjectEventFunction)(wxEventFunction)(wxPropertyGridEventFunction)&A)
+#define EVT_PG_SELECTED(id, fn)              DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_SELECTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
+#define EVT_PG_CHANGING(id, fn)              DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
+#define EVT_PG_CHANGED(id, fn)               DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
+#define EVT_PG_HIGHLIGHTED(id, fn)           DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_HIGHLIGHTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
+#define EVT_PG_RIGHT_CLICK(id, fn)           DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_RIGHT_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
+#define EVT_PG_DOUBLE_CLICK(id, fn)          DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_DOUBLE_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
+#define EVT_PG_PAGE_CHANGED(id, fn)          DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_PAGE_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
+#define EVT_PG_ITEM_COLLAPSED(id, fn)        DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_COLLAPSED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
+#define EVT_PG_ITEM_EXPANDED(id, fn)         DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_EXPANDED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
+
+#define wxPropertyGridEventHandler(fn) \
+    wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn )
 
 #endif
 
 
 #endif