]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/propgrid/propgrid.h
Use correct visual attributes for wxSpinCtrl.
[wxWidgets.git] / include / wx / propgrid / propgrid.h
index 974fd034cd2c15c20c18ebd1a5e84651808f6236..40350413b3b5ee68b43ea2cb2ee2d65ab1beb8a6 100644 (file)
@@ -247,10 +247,40 @@ wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES    = 0x00400000,
 
 /** Hides page selection buttons from toolbar.
 */
-wxPG_EX_HIDE_PAGE_BUTTONS               = 0x01000000
+wxPG_EX_HIDE_PAGE_BUTTONS               = 0x01000000,
+
+/** Allows multiple properties to be selected by user (by pressing SHIFT
+    when clicking on a property, or by dragging with left mouse button
+    down).
+
+    You can get array of selected properties with
+    wxPropertyGridInterface::GetSelectedProperties(). In multiple selection
+    mode wxPropertyGridInterface::GetSelection() returns
+    property which has editor active (usually the first one
+    selected). Other useful member functions are ClearSelection(),
+    AddToSelection() and RemoveFromSelection().
+*/
+wxPG_EX_MULTIPLE_SELECTION              = 0x02000000,
+
+/**
+    This enables top-level window tracking which allows wxPropertyGrid to
+    notify the application of last-minute property value changes by user.
+
+    This style is not enabled by default because it may cause crashes when
+    wxPropertyGrid is used in with wxAUI or similar system.
+
+    @remarks If you are not in fact using any system that may change
+             wxPropertyGrid's top-level parent window on its own, then you
+             are recommended to enable this style.
+*/
+wxPG_EX_ENABLE_TLP_TRACKING             = 0x04000000
 
 };
 
+#if wxPG_COMPATIBILITY_1_4
+    #define wxPG_EX_DISABLE_TLP_TRACKING    0x00000000
+#endif
+
 /** Combines various styles.
 */
 #define wxPG_DEFAULT_STYLE          (0)
@@ -435,22 +465,23 @@ enum wxPG_KEYBOARD_ACTIONS
 // wxPropertyGrid::DoSelectProperty flags (selFlags)
 
 // Focuses to created editor
-#define wxPG_SEL_FOCUS                  0x01
+#define wxPG_SEL_FOCUS                  0x0001
 // Forces deletion and recreation of editor
-#define wxPG_SEL_FORCE                  0x02
+#define wxPG_SEL_FORCE                  0x0002
 // For example, doesn't cause EnsureVisible
-#define wxPG_SEL_NONVISIBLE             0x04
+#define wxPG_SEL_NONVISIBLE             0x0004
 // Do not validate editor's value before selecting
-#define wxPG_SEL_NOVALIDATE             0x08
+#define wxPG_SEL_NOVALIDATE             0x0008
 // Property being deselected is about to be deleted
-#define wxPG_SEL_DELETING               0x10
+#define wxPG_SEL_DELETING               0x0010
 // Property's values was set to unspecified by the user
-#define wxPG_SEL_SETUNSPEC              0x20
+#define wxPG_SEL_SETUNSPEC              0x0020
 // Property's event handler changed the value
-#define wxPG_SEL_DIALOGVAL              0x40
+#define wxPG_SEL_DIALOGVAL              0x0040
 // Set to disable sending of wxEVT_PG_SELECTED event
-#define wxPG_SEL_DONT_SEND_EVENT        0x80
-
+#define wxPG_SEL_DONT_SEND_EVENT        0x0080
+// Don't make any graphics updates
+#define wxPG_SEL_NO_REFRESH             0x0100
 
 // -----------------------------------------------------------------------
 
@@ -570,6 +601,14 @@ enum wxPG_KEYBOARD_ACTIONS
     @event{EVT_PG_ITEM_EXPANDED(id, func)}
         Respond to wxEVT_PG_ITEM_EXPANDED event, generated when user expands
         a property or category..
+    @event{EVT_PG_LABEL_EDIT_BEGIN(id, func)}
+        Respond to wxEVT_PG_LABEL_EDIT_BEGIN event, generated when is about to
+        begin editing a property label. You can veto this event to prevent the
+        action.
+    @event{EVT_PG_LABEL_EDIT_ENDING(id, func)}
+        Respond to wxEVT_PG_LABEL_EDIT_ENDING event, generated when is about to
+        end editing of a property label. You can veto this event to prevent the
+        action.
     @endEventTable
 
     @remarks
@@ -839,12 +878,6 @@ public:
     /** Returns currently selected property. */
     wxPGProperty* GetSelectedProperty() const { return GetSelection(); }
 
-    /** Returns currently selected property. */
-    wxPGProperty* GetSelection() const
-    {
-        return m_selected;
-    }
-
     /** Returns current selection background colour. */
     wxColour GetSelectionBackgroundColour() const { return m_colSelBack; }
 
@@ -953,10 +986,94 @@ public:
                  wxEVT_PG_SELECTED. In wxWidgets 2.9 and later, it no longer
                  does that.
 
-        @see wxPropertyGrid::Unselect
+        @remarks This clears any previous selection.
     */
     bool SelectProperty( wxPGPropArg id, bool focus = false );
 
+    /**
+        Set entire new selection from given list of properties.
+    */
+    void SetSelection( const wxArrayPGProperty& newSelection )
+    {
+        DoSetSelection( newSelection, wxPG_SEL_DONT_SEND_EVENT );
+    }
+
+    /**
+        Adds given property into selection. If wxPG_EX_MULTIPLE_SELECTION
+        extra style is not used, then this has same effect as
+        calling SelectProperty().
+
+        @remarks Multiple selection is not supported for categories. This
+                 means that if you have properties selected, you cannot
+                 add category to selection, and also if you have category
+                 selected, you cannot add other properties to selection.
+                 This member function will fail silently in these cases,
+                 even returning true.
+    */
+    bool AddToSelection( wxPGPropArg id )
+    {
+        wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
+        return DoAddToSelection(p, wxPG_SEL_DONT_SEND_EVENT);
+    }
+
+    /**
+        Removes given property from selection. If property is not selected,
+        an assertion failure will occur.
+    */
+    bool RemoveFromSelection( wxPGPropArg id )
+    {
+        wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
+        return DoRemoveFromSelection(p, wxPG_SEL_DONT_SEND_EVENT);
+    }
+
+    /**
+        Makes given column editable by user.
+
+        @param editable
+            Using @false here will disable column from being editable.
+    */
+    void MakeColumnEditable( unsigned int column, bool editable = true );
+
+    /**
+        Creates label editor wxTextCtrl for given column, for property
+        that is currently selected. When multiple selection is
+        enabled, this applies to whatever property GetSelection()
+        returns.
+
+        @param colIndex
+            Which column's label to edit. Note that you should not
+            use value 1, which is reserved for property value
+            column.
+
+        @see EndLabelEdit(), MakeColumnEditable()
+    */
+    void BeginLabelEdit( unsigned int column = 0 )
+    {
+        DoBeginLabelEdit(column, wxPG_SEL_DONT_SEND_EVENT);
+    }
+
+    /**
+        Destroys label editor wxTextCtrl, if any.
+
+        @param commit
+            Use @true (default) to store edited label text in
+            property cell data.
+
+        @see BeginLabelEdit(), MakeColumnEditable()
+    */
+    void EndLabelEdit( bool commit = true )
+    {
+        DoEndLabelEdit(commit, wxPG_SEL_DONT_SEND_EVENT);
+    }
+
+    /**
+        Returns currently active label editor, NULL if none.
+    */
+    wxTextCtrl* GetLabelEditor() const
+    {
+        return m_labelEditor;
+    }
+
     /** Sets category caption background colour. */
     void SetCaptionBackgroundColour(const wxColour& col);
 
@@ -1156,6 +1273,7 @@ public:
         shown).
     */
     void FixPosForTextCtrl( wxWindow* ctrl,
+                            unsigned int forColumn = 1,
                             const wxPoint& offset = wxPoint(0, 0) );
 
     /** Shortcut for creating text editor widget.
@@ -1179,7 +1297,8 @@ public:
                                       const wxString& value,
                                       wxWindow* secondary,
                                       int extraStyle = 0,
-                                      int maxLen = 0 );
+                                      int maxLen = 0,
+                                      unsigned int forColumn = 1 );
 
     /* Generates both textctrl and button.
     */
@@ -1443,7 +1562,6 @@ public:
 
     //
     // Public methods for semi-public use
-    // (not protected for optimization)
     //
     bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 );
 
@@ -1635,15 +1753,18 @@ protected:
     /** When drawing next time, clear this many item slots at the end. */
     int                 m_clearThisMany;
 
-    /** Pointer to selected property. Note that this is duplicated in
-        m_state for better transiency between pages so that the selected
-        item can be retained.
-    */
-    wxPGProperty*       m_selected;
+    // Mouse is hovering over this column (index)
+    unsigned int        m_colHover;
 
     // pointer to property that has mouse hovering
     wxPGProperty*       m_propHover;
 
+    // Active label editor
+    wxTextCtrl*         m_labelEditor;
+
+    // For which property the label editor is active
+    wxPGProperty*       m_labelEditorProperty;
+
     // EventObject for wxPropertyGridEvents
     wxWindow*           m_eventObject;
 
@@ -1665,8 +1786,9 @@ protected:
 
     // y coordinate of property that mouse hovering
     int                 m_propHoverY;
+
     // Which column's editor is selected (usually 1)?
-    int                 m_selColumn;
+    unsigned int        m_selColumn;
 
     // x relative to splitter (needed for resize).
     int                 m_ctrlXAdjust;
@@ -1767,6 +1889,11 @@ protected:
 
 protected:
 
+    bool AddToSelectionFromInputEvent( wxPGProperty* prop,
+                                       unsigned int colIndex,
+                                       wxMouseEvent* event = NULL,
+                                       int selFlags = 0 );
+
     /**
         Adjust the centering of the bitmap icons (collapse / expand) when the
         caption font changes.
@@ -1786,14 +1913,6 @@ protected:
     */
     void CorrectEditorWidgetPosY();
 
-    /** Deselect current selection, if any. Returns true if success
-        (ie. validator did not intercept).
-
-        Unlike ClearSelection(), DoClearSelection() sends the
-        wxEVT_PG_SELECTED event.
-    */
-    bool DoClearSelection();
-
     int DoDrawItems( wxDC& dc,
                      const wxRect* clipRect,
                      bool isBuffered ) const;
@@ -1826,6 +1945,27 @@ protected:
 
     bool DoEditorValidate();
 
+    // Similar to DoSelectProperty() but also works on columns
+    // other than 1. Does not active editor if column is not
+    // editable.
+    bool DoSelectAndEdit( wxPGProperty* prop,
+                          unsigned int colIndex,
+                          unsigned int selFlags );
+
+    void DoSetSelection( const wxArrayPGProperty& newSelection,
+                         int selFlags = 0 );
+
+    bool DoAddToSelection( wxPGProperty* prop,
+                           int selFlags = 0 );
+
+    bool DoRemoveFromSelection( wxPGProperty* prop,
+                                int selFlags = 0 );
+
+    void DoBeginLabelEdit( unsigned int colIndex, int selFlags = 0 );
+    void DoEndLabelEdit( bool commit, int selFlags = 0 );
+    void OnLabelEditorEnterPress( wxCommandEvent& event );
+    void OnLabelEditorKeyPress( wxKeyEvent& event );
+
     wxPGProperty* DoGetItemAtY( int y ) const;
 
     void DoSetSplitterPosition_( int newxpos,
@@ -1833,6 +1973,7 @@ protected:
                                  int splitterIndex = 0,
                                  bool allPages = false );
 
+    void DestroyEditorWnd( wxWindow* wnd );
     void FreeEditors();
 
     virtual bool DoExpand( wxPGProperty* p, bool sendEvent = false );
@@ -1859,10 +2000,11 @@ protected:
 
     void PrepareAfterItemsAdded();
 
-    bool SendEvent( int eventType,
-                    wxPGProperty* p,
+    // Omit the wxPG_SEL_NOVALIDATE flag to allow vetoing the event
+    bool SendEvent( int eventType, wxPGProperty* p,
                     wxVariant* pValue = NULL,
-                    unsigned int selFlags = 0 );
+                    unsigned int selFlags = wxPG_SEL_NOVALIDATE,
+                    unsigned int column = 1 );
 
     void SetFocusOnCanvas();
 
@@ -1939,6 +2081,10 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_PAGE_CHANGED, wxPropert
 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 );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID,
+                          wxEVT_PG_LABEL_EDIT_BEGIN, wxPropertyGridEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID,
+                          wxEVT_PG_LABEL_EDIT_ENDING, wxPropertyGridEvent );
 
 #else
     enum {
@@ -1950,7 +2096,9 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_DOUBLE_CLICK, wxPropert
         wxEVT_PG_PAGE_CHANGED,
         wxEVT_PG_ITEM_COLLAPSED,
         wxEVT_PG_ITEM_EXPANDED,
-        wxEVT_PG_DOUBLE_CLICK
+        wxEVT_PG_DOUBLE_CLICK,
+        wxEVT_PG_LABEL_EDIT_BEGIN,
+        wxEVT_PG_LABEL_EDIT_ENDING
     };
 #endif
 
@@ -1971,6 +2119,8 @@ typedef void (wxEvtHandler::*wxPropertyGridEventFunction)(wxPropertyGridEvent&);
 #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 EVT_PG_LABEL_EDIT_BEGIN(id, fn)      DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_LABEL_EDIT_BEGIN, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
+#define EVT_PG_LABEL_EDIT_ENDING(id, fn)     DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_LABEL_EDIT_ENDING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
 
 #define wxPropertyGridEventHandler(fn) \
     wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn )
@@ -2002,6 +2152,14 @@ public:
     /** Copyer. */
     virtual wxEvent* Clone() const;
 
+    /**
+        Returns the column index associated with this event.
+    */
+    unsigned int GetColumn() const
+    {
+        return m_column;
+    }
+
     wxPGProperty* GetMainParent() const
     {
         wxASSERT(m_property);
@@ -2073,6 +2231,11 @@ public:
         return m_validationInfo->GetFailureBehavior();
     }
 
+    void SetColumn( unsigned int column )
+    {
+        m_column = column;
+    }
+
     void SetCanVeto( bool canVeto ) { m_canVeto = canVeto; }
     bool WasVetoed() const { return m_wasVetoed; }
 
@@ -2096,6 +2259,8 @@ private:
     wxPropertyGrid*     m_pg;
     wxPGValidationInfo* m_validationInfo;
 
+    unsigned int        m_column;
+
     bool                m_canVeto;
     bool                m_wasVetoed;