X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f521bae6653b1c2f0e196fb5c5550c03206e59ce..86ac84b8ce086e6bbda58f422d41f84268606e35:/include/wx/propgrid/propgrid.h diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index 4456641a4a..29d257b336 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -74,6 +74,7 @@ public: wxPGCachedString m_strbool; wxPGCachedString m_strlist; + wxPGCachedString m_strDefaultValue; wxPGCachedString m_strMin; wxPGCachedString m_strMax; wxPGCachedString m_strUnits; @@ -87,9 +88,7 @@ public: int m_extraStyle; // global extra style -#ifdef __WXDEBUG__ int m_warnings; -#endif int HasExtraStyle( int style ) const { return (m_extraStyle & style); } }; @@ -104,6 +103,10 @@ extern WXDLLIMPEXP_PROPGRID wxPGGlobalVarsClass* wxPGGlobalVars; #define wxPGVariant_Bool(A) (A?wxPGVariant_True:wxPGVariant_False) +// When wxPG is loaded dynamically after the application is already running +// then the built-in module system won't pick this one up. Add it manually. +WXDLLIMPEXP_PROPGRID void wxPGInitResourceModule(); + #endif // !SWIG // ----------------------------------------------------------------------- @@ -581,30 +584,10 @@ class WXDLLIMPEXP_PROPGRID friend class wxPropertyGridManager; friend class wxPGCanvas; -#ifndef SWIG DECLARE_DYNAMIC_CLASS(wxPropertyGrid) -#endif public: -#ifdef SWIG - %pythonAppend wxPropertyGrid { - self._setOORInfo(self) - self.DoDefaultTypeMappings() - self.edited_objects = {} - self.DoDefaultValueTypeMappings() - if not hasattr(self.__class__,'_vt2setter'): - self.__class__._vt2setter = {} - } - %pythonAppend wxPropertyGrid() "" - - wxPropertyGrid( wxWindow *parent, wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxPG_DEFAULT_STYLE, - const wxChar* name = wxPyPropertyGridNameStr ); - %RenameCtor(PrePropertyGrid, wxPropertyGrid()); -#else - +#ifndef SWIG /** Two step constructor. @@ -612,6 +595,7 @@ public: wxPropertyGrid */ wxPropertyGrid(); +#endif /** The default constructor. The styles to be used are styles valid for the wxWindow and wxScrolledWindow. @@ -626,7 +610,6 @@ public: /** Destructor */ virtual ~wxPropertyGrid(); -#endif /** Adds given key combination to trigger given action. @@ -880,15 +863,24 @@ public: /** Returns current vertical spacing. */ int GetVerticalSpacing() const { return (int)m_vspacing; } + /** + Returns @true if a property editor control has focus. + */ + bool IsEditorFocused() const; + /** Returns true if editor's value was marked modified. */ bool IsEditorsValueModified() const { return ( m_iFlags & wxPG_FL_VALUE_MODIFIED ) ? true : false; } - /** Returns information about arbitrary position in the grid. + /** + Returns information about arbitrary position in the grid. - For wxPropertyGridHitTestResult definition, see - wxPropertyGridPageState::HitTest(). + @param pt + Coordinates in the virtual grid space. You may need to use + wxScrolledWindow::CalcScrolledPosition() for translating + wxPropertyGrid client coordinates into something this member + function can use. */ wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const; @@ -901,6 +893,20 @@ public: */ bool IsFrozen() const { return (m_frozen>0)?true:false; } + /** + Call this any time your code causes wxPropertyGrid's top-level parent + to change. + + @param newTLP + New top-level parent that is about to be set. Old top-level parent + window should still exist as the current one. + + @remarks This function is automatically called from wxPropertyGrid:: + Reparent() and wxPropertyGridManager::Reparent(). You only + need to use it if you reparent wxPropertyGrid indirectly. + */ + void OnTLPChanging( wxWindow* newTLP ); + /** Redraws given property. */ virtual void RefreshProperty( wxPGProperty* p ); @@ -911,7 +917,14 @@ public: Pointer to the editor class instance that should be used. */ static wxPGEditor* RegisterEditorClass( wxPGEditor* editor, - bool noDefCheck = false ); + bool noDefCheck = false ) + { + return DoRegisterEditorClass(editor, wxEmptyString, noDefCheck); + } + + static wxPGEditor* DoRegisterEditorClass( wxPGEditor* editorClass, + const wxString& editorName, + bool noDefCheck = false ); #endif /** Resets all colours to the original system values. @@ -1008,6 +1021,45 @@ public: 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 ); @@ -1041,13 +1093,6 @@ public: 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 @@ -1262,12 +1307,8 @@ public: 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. */ @@ -1321,6 +1362,21 @@ public: virtual void SetWindowStyleFlag( long style ); + void DrawItems( const wxPGProperty* p1, const wxPGProperty* p2 ); + + void DrawItem( wxPGProperty* p ) + { + DrawItems(p,p); + } + + virtual void DrawItemAndChildren( wxPGProperty* p ); + + /** + Draws item, children, and consequtive parents as long as category is + not met. + */ + void DrawItemAndValueRelated( wxPGProperty* p ); + protected: /** @@ -1381,7 +1437,7 @@ public: virtual void Freeze(); virtual void SetExtraStyle( long exStyle ); virtual void Thaw(); - + virtual bool Reparent( wxWindowBase *newParent ); protected: virtual wxSize DoGetBestSize() const; @@ -1571,12 +1627,12 @@ protected: // handling mess). wxWindow* m_curFocused; - // wxPGTLWHandler - wxEvtHandler* m_tlwHandler; - - // Top level parent + // Last known 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)? @@ -1677,6 +1733,8 @@ protected: void OnSysColourChanged( wxSysColourChangedEvent &event ); + void OnTLPClose( wxCloseEvent& event ); + protected: /** @@ -1698,23 +1756,14 @@ protected: */ void CorrectEditorWidgetPosY(); -#ifdef __WXDEBUG__ - void _log_items(); - void OnScreenNote( const wxChar* format, ... ); -#endif - /** Deselect current selection, if any. Returns true if success (ie. validator did not intercept). */ bool DoClearSelection(); int DoDrawItems( wxDC& dc, - const wxPGProperty* first_item, - const wxPGProperty* last_item, - const wxRect* clip_rect, + const wxRect* clipRect, bool isBuffered ) const; - void DoSetPropertyValueUnspecified( wxPGProperty* p ); - /** Draws an expand/collapse (ie. +/-) button. */ virtual void DrawExpanderButton( wxDC& dc, const wxRect& rect, @@ -1724,21 +1773,6 @@ protected: void DrawItems( wxDC& dc, unsigned int topitemy, unsigned int bottomitemy, const wxRect* clip_rect = (const wxRect*) NULL ); - void DrawItems( const wxPGProperty* p1, const wxPGProperty* p2 ); - - void DrawItem( wxPGProperty* p ) - { - DrawItems(p,p); - } - - virtual void DrawItemAndChildren( wxPGProperty* p ); - - /** - Draws item, children, and consequtive parents as long as category is - not met. - */ - void DrawItemAndValueRelated( wxPGProperty* p ); - // Translate wxKeyEvent to wxPG_ACTION_XXX int KeyEventToActions(wxKeyEvent &event, int* pSecond) const; @@ -1749,9 +1783,6 @@ protected: void ImprovedClientToScreen( int* px, int* py ); - // Returns True if editor control has focus - bool IsEditorFocused() const; - // Called by focus event handlers. newFocused is the window that becomes // focused. void HandleFocusChange( wxWindow* newFocused ); @@ -1839,6 +1870,11 @@ inline int wxPGProperty::GetDisplayedCommonValueCount() const return 0; } +inline void wxPGProperty::SetDefaultValue( wxVariant& value ) +{ + SetAttribute(wxPG_ATTR_DEFAULT_VALUE, value); +} + inline void wxPGProperty::SetEditor( const wxString& editorName ) { m_customEditor = wxPropertyGridInterface::GetEditorByName(editorName); @@ -1865,15 +1901,15 @@ inline bool wxPGProperty::SetMaxLength( int maxLen ) #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 { @@ -1897,18 +1933,18 @@ extern WXDLLIMPEXP_PROPGRID const wxEventType wxEVT_PG_DOUBLE_CLICK; #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