X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1c4293cb91327247ad69e6ec8d589bfaa299db28..1d065710d3cf39e519f05fd02760006b9a929c38:/include/wx/propgrid/manager.h diff --git a/include/wx/propgrid/manager.h b/include/wx/propgrid/manager.h index 42c44b81f4..9a1c43f2b8 100644 --- a/include/wx/propgrid/manager.h +++ b/include/wx/propgrid/manager.h @@ -4,14 +4,18 @@ // Author: Jaakko Salli // Modified by: // Created: 2005-01-14 -// RCS-ID: $Id: +// RCS-ID: $Id$ // Copyright: (c) Jaakko Salli -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_PROPGRID_MANAGER_H_ #define _WX_PROPGRID_MANAGER_H_ +#include "wx/defs.h" + +#if wxUSE_PROPGRID + #include "wx/propgrid/propgrid.h" #include "wx/dcclient.h" @@ -21,11 +25,12 @@ #include "wx/button.h" #include "wx/textctrl.h" #include "wx/dialog.h" +#include "wx/headerctrl.h" // ----------------------------------------------------------------------- #ifndef SWIG -extern WXDLLIMPEXP_PROPGRID const wxChar *wxPropertyGridManagerNameStr; +extern WXDLLIMPEXP_DATA_PROPGRID(const char) wxPropertyGridManagerNameStr[]; #endif /** @class wxPropertyGridPage @@ -63,9 +68,7 @@ class WXDLLIMPEXP_PROPGRID wxPropertyGridPage : public wxEvtHandler, public wxPropertyGridPageState { friend class wxPropertyGridManager; -#ifndef SWIG DECLARE_CLASS(wxPropertyGridPage) -#endif public: wxPropertyGridPage(); @@ -125,7 +128,7 @@ public: */ int GetToolId() const { - return m_id; + return m_toolId; } /** Do any member initialization in this method. @@ -161,14 +164,7 @@ protected: */ virtual void DoSetSplitterPosition( int pos, int splitterColumn = 0, - bool allPages = false ); - - /** Propagate to other pages. - */ - void DoSetSplitterPositionThisPage( int pos, int splitterColumn = 0 ) - { - wxPropertyGridPageState::DoSetSplitterPosition( pos, splitterColumn ); - } + int flags = wxPG_SPLITTER_REFRESH ); /** Page label (may be referred as name in some parts of documentation). Can be set in constructor, or passed in @@ -176,24 +172,27 @@ protected: */ wxString m_label; -#ifndef SWIG - //virtual bool ProcessEvent( wxEvent& event ); wxPropertyGridManager* m_manager; - int m_id; // toolbar index + // Toolbar tool id. Note that this is only valid when the tool bar + // exists. + int m_toolId; private: bool m_isDefault; // is this base page object? -private: DECLARE_EVENT_TABLE() -#endif }; // ----------------------------------------------------------------------- +#if wxUSE_HEADERCTRL +class wxPGHeaderCtrl; +#endif + + /** @class wxPropertyGridManager wxPropertyGridManager is an efficient multi-page version of wxPropertyGrid, @@ -216,39 +215,18 @@ private: class WXDLLIMPEXP_PROPGRID wxPropertyGridManager : public wxPanel, public wxPropertyGridInterface { -#ifndef SWIG DECLARE_CLASS(wxPropertyGridManager) -#endif friend class wxPropertyGridPage; public: -#ifdef SWIG - %pythonAppend wxPropertyGridManager { - self._setOORInfo(self) - self.DoDefaultTypeMappings() - self.edited_objects = {} - self.DoDefaultValueTypeMappings() - if not hasattr(self.__class__,'_vt2setter'): - self.__class__._vt2setter = {} - } - %pythonAppend wxPropertyGridManager() "" - - wxPropertyGridManager( wxWindow *parent, wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxPGMAN_DEFAULT_STYLE, - const wxChar* name = - wxPyPropertyGridManagerNameStr ); - %RenameCtor(PrePropertyGridManager, wxPropertyGridManager()); - -#else - +#ifndef SWIG /** Two step constructor. Call Create when this constructor is called to build up the wxPropertyGridManager. */ wxPropertyGridManager(); +#endif /** The default constructor. The styles to be used are styles valid for the wxWindow. @@ -258,13 +236,11 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxPGMAN_DEFAULT_STYLE, - const wxChar* name = wxPropertyGridManagerNameStr ); + const wxString& name = wxPropertyGridManagerNameStr ); /** Destructor */ virtual ~wxPropertyGridManager(); -#endif - /** Creates new property page. Note that the first page is not created automatically. @param label @@ -275,25 +251,20 @@ public: @param pageObj wxPropertyGridPage instance. Manager will take ownership of this object. NULL indicates that a default page instance should be created. + @return - Returns index to the page created. + Returns pointer to created page. + @remarks If toolbar is used, it is highly recommended that the pages are added when the toolbar is not turned off using window style flag switching. */ - int AddPage( const wxString& label = wxEmptyString, - const wxBitmap& bmp = wxPG_NULL_BITMAP, - wxPropertyGridPage* pageObj = (wxPropertyGridPage*) NULL ) - { - return InsertPage(-1,label,bmp,pageObj); - } - - void ClearModifiedStatus ( wxPGPropArg id ); - - void ClearModifiedStatus () + wxPropertyGridPage* AddPage( const wxString& label = wxEmptyString, + const wxBitmap& bmp = wxPG_NULL_BITMAP, + wxPropertyGridPage* pageObj = NULL ) { - m_pPropGrid->ClearModifiedStatus(); + return InsertPage(-1, label, bmp, pageObj); } /** Deletes all all properties and all pages. @@ -323,7 +294,7 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxPGMAN_DEFAULT_STYLE, - const wxChar* name = wxPropertyGridManagerNameStr ); + const wxString& name = wxPropertyGridManagerNameStr ); /** Enables or disables (shows/hides) categories according to parameter @@ -344,25 +315,6 @@ public: */ bool EnsureVisible( wxPGPropArg id ); - /** Returns number of children of the root property of the selected page. */ - size_t GetChildrenCount() - { - return GetChildrenCount( m_pPropGrid->m_pState->m_properties ); - } - - /** Returns number of children of the root property of given page. */ - size_t GetChildrenCount( int pageIndex ); - - /** Returns number of children for the property. - - NB: Cannot be in container methods class due to name hiding. - */ - size_t GetChildrenCount( wxPGPropArg id ) const - { - wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0) - return p->GetChildCount(); - } - /** Returns number of columns on given page. By the default, returns number of columns on current page. */ int GetColumnCount( int page = -1 ) const; @@ -443,18 +395,11 @@ public: return GetPage(m_selPage); } - /** Returns last page. - */ - wxPropertyGridPage* GetLastPage() const - { - return GetPage(m_arrPages.size()-1); - } - /** Returns page object for given page index. */ wxPropertyGridPage* GetPage( unsigned int ind ) const { - return (wxPropertyGridPage*)m_arrPages.Item(ind); + return m_arrPages[ind]; } /** Returns page object for given page name. @@ -477,10 +422,12 @@ public: */ int GetPageByState( const wxPropertyGridPageState* pstate ) const; +protected: /** Returns wxPropertyGridPageState of given page, current page's for -1. */ virtual wxPropertyGridPageState* GetPageState( int page ) const; +public: /** Returns number of managed pages. */ size_t GetPageCount() const; @@ -495,14 +442,17 @@ public: /** Returns index to currently selected page. */ int GetSelectedPage() const { return m_selPage; } - /** Shortcut for GetGrid()->GetSelection(). */ + /** Alias for GetSelection(). */ wxPGProperty* GetSelectedProperty() const { - return m_pPropGrid->GetSelection(); + return GetSelection(); } - /** Synonyme for GetSelectedPage. */ - int GetSelection() const { return m_selPage; } + /** Shortcut for GetGrid()->GetSelection(). */ + wxPGProperty* GetSelection() const + { + return m_pPropGrid->GetSelection(); + } /** Returns a pointer to the toolbar currently associated with the wxPropertyGridManager (if any). */ @@ -520,13 +470,14 @@ public: @param pageObj wxPropertyGridPage instance. Manager will take ownership of this object. If NULL, default page object is constructed. + @return - Returns index to the page created. + Returns pointer to created page. */ - virtual int InsertPage( int index, - const wxString& label, - const wxBitmap& bmp = wxNullBitmap, - wxPropertyGridPage* pageObj = NULL ); + virtual wxPropertyGridPage* InsertPage( int index, + const wxString& label, + const wxBitmap& bmp = wxNullBitmap, + wxPropertyGridPage* pageObj = NULL ); /** Returns true if any property on any page has been modified by the user. @@ -545,6 +496,12 @@ public: */ bool IsPageModified( size_t index ) const; + /** + Returns true if property is selected. Since selection is page + based, this function checks every page in the manager. + */ + virtual bool IsPropertySelected( wxPGPropArg id ) const; + virtual void Refresh( bool eraseBackground = true, const wxRect* rect = (const wxRect*) NULL ); @@ -554,10 +511,10 @@ public: */ virtual bool RemovePage( int page ); - /** Select and displays a given page. Also makes it target page for - insert operations etc. + /** Select and displays a given page. + @param index - Index of page being seleced. Can be -1 to select nothing. + Index of page being seleced. Can be -1 to select nothing. */ void SelectPage( int index ); @@ -582,7 +539,21 @@ public: return p->GetParentState()->DoSelectProperty(p, focus); } - /** Sets number of columns on given page (default is current page). + /** + Sets a column title. Default title for column 0 is "Property", + and "Value" for column 1. + + @remarks If header is not shown yet, then calling this + member function will make it visible. + */ + void SetColumnTitle( int idx, const wxString& title ); + + /** + Sets number of columns on given page (default is current page). + + @remarks If you use header, then you should always use this + member function to set the column count, instead of + ones present in wxPropertyGrid or wxPropertyGridPage. */ void SetColumnCount( int colCount, int page = -1 ); @@ -593,12 +564,6 @@ public: /** Sets y coordinate of the description box splitter. */ void SetDescBoxHeight( int ht, bool refresh = true ); - /** Sets property attribute for all applicapple properties. - Be sure to use this method after all properties have been - added to the grid. - */ - void SetPropertyAttributeAll( const wxString& name, wxVariant value ); - /** Moves splitter as left as possible, while still allowing all labels to be shown in full. @param subProps @@ -609,39 +574,38 @@ public: */ void SetSplitterLeft( bool subProps = false, bool allPages = true ); - /** Sets splitter position on individual page. */ - void SetPageSplitterPosition( int page, int pos, int column = 0 ) - { - GetPage(page)->DoSetSplitterPosition( pos, column ); - } + /** + Sets splitter position on individual page. - /** Sets splitter position for all pages. - @remarks - Splitter position cannot exceed grid size, and therefore setting it - during form creation may fail as initial grid size is often smaller - than desired splitter position, especially when sizers are being used. + @remarks If you use header, then you should always use this + member function to set the splitter position, instead of + ones present in wxPropertyGrid or wxPropertyGridPage. + */ + void SetPageSplitterPosition( int page, int pos, int column = 0 ); + + /** + Sets splitter position for all pages. + + @remarks Splitter position cannot exceed grid size, and therefore + setting it during form creation may fail as initial grid + size is often smaller than desired splitter position, + especially when sizers are being used. + + If you use header, then you should always use this + member function to set the splitter position, instead of + ones present in wxPropertyGrid or wxPropertyGridPage. */ void SetSplitterPosition( int pos, int column = 0 ); - /** Synonyme for SelectPage(name). */ - void SetStringSelection( const wxChar* name ) - { - SelectPage( GetPageByName(name) ); - } +#if wxUSE_HEADERCTRL + /** + Show or hide the property grid header control. It is hidden + by the default. -#ifdef SWIG - %pythoncode { - def GetValuesFromPage(self, - page, - dict_=None, - as_strings=False, - inc_attributes=False): - """ - Same as GetValues, but returns values from specific page only. - For argument descriptions, see GetValues. - """ - return page.GetPropertyValues(dict_, as_strings, inc_attributes) - } + @remarks Grid may look better if you use wxPG_NO_INTERNAL_BORDER + window style when showing a header. + */ + void ShowHeader(bool show = true); #endif protected: @@ -650,22 +614,22 @@ protected: // Subclassing helpers // - /** Creates property grid for the manager. Override to use subclassed - wxPropertyGrid. + /** + Creates property grid for the manager. Reimplement in derived class to + use subclassed wxPropertyGrid. However, if you you do this then you + must also use the two-step construction (ie. default constructor and + Create() instead of constructor with arguments) when creating the + manager. */ virtual wxPropertyGrid* CreatePropertyGrid() const; - virtual void RefreshProperty( wxPGProperty* p ); - public: - -#ifndef DOXYGEN + virtual void RefreshProperty( wxPGProperty* p ); // // Overridden functions - no documentation required. // - virtual wxSize DoGetBestSize() const; void SetId( wxWindowID winid ); virtual void Freeze(); @@ -673,12 +637,10 @@ public: virtual void SetExtraStyle ( long exStyle ); virtual bool SetFont ( const wxFont& font ); virtual void SetWindowStyleFlag ( long style ); + virtual bool Reparent( wxWindowBase *newParent ); protected: - -public: - -#ifndef SWIG + virtual wxSize DoGetBestSize() const; // // Event handlers @@ -693,21 +655,26 @@ public: void OnToolbarClick( wxCommandEvent &event ); void OnResize( wxSizeEvent& event ); void OnPropertyGridSelect( wxPropertyGridEvent& event ); + void OnPGColDrag( wxPropertyGridEvent& event ); -protected: wxPropertyGrid* m_pPropGrid; - wxArrayPtrVoid m_arrPages; + wxVector m_arrPages; #if wxUSE_TOOLBAR wxToolBar* m_pToolbar; +#endif +#if wxUSE_HEADERCTRL + wxPGHeaderCtrl* m_pHeaderCtrl; #endif wxStaticText* m_pTxtHelpCaption; wxStaticText* m_pTxtHelpContent; wxPropertyGridPage* m_emptyPage; + wxArrayString m_columnLabels; + long m_iFlags; // Selected page index. @@ -723,20 +690,22 @@ protected: int m_splitterHeight; - int m_nextTbInd; - int m_dragOffset; wxCursor m_cursorSizeNS; int m_nextDescBoxSize; - wxWindowID m_baseId; + // Toolbar tool ids for categorized and alphabetic mode selectors. + int m_categorizedModeToolId; + int m_alphabeticModeToolId; unsigned char m_dragStatus; unsigned char m_onSplitter; + bool m_showHeader; + virtual wxPGProperty* DoGetPropertyByName( const wxString& name ) const; /** Select and displays a given page. */ @@ -752,6 +721,8 @@ protected: virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle) const; #endif*/ + virtual bool ProcessEvent( wxEvent& event ); + /** Recalculates new positions for components, according to the given size. */ @@ -760,22 +731,21 @@ protected: /** (Re)creates/destroys controls, according to the window style bits. */ void RecreateControls(); - void RefreshHelpBox( int new_splittery, int new_width, int new_height ); + void UpdateDescriptionBox( int new_splittery, int new_width, int new_height ); - void RepaintSplitter( wxDC& dc, - int new_splittery, - int new_width, - int new_height, - bool desc_too ); + void RepaintDescBoxDecorations( wxDC& dc, + int newSplitterY, + int newWidth, + int newHeight ); void SetDescribedProperty( wxPGProperty* p ); - virtual bool ProcessEvent( wxEvent& event ); + // Reimplement these to handle "descboxheight" state item + virtual bool SetEditableStateItem( const wxString& name, wxVariant value ); + virtual wxVariant GetEditableStateItem( const wxString& name ) const; private: DECLARE_EVENT_TABLE() -#endif // #ifndef SWIG -#endif // #ifndef DOXYGEN }; // ----------------------------------------------------------------------- @@ -789,4 +759,6 @@ inline int wxPropertyGridPage::GetIndex() const // ----------------------------------------------------------------------- +#endif // wxUSE_PROPGRID + #endif // _WX_PROPGRID_MANAGER_H_