X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1c4293cb91327247ad69e6ec8d589bfaa299db28..446659cac6be2946cc58ccc574fc8a4d1f7bad5a:/include/wx/propgrid/propgridpagestate.h diff --git a/include/wx/propgrid/propgridpagestate.h b/include/wx/propgrid/propgridpagestate.h index 5ff8ab5f57..c25b9e5bac 100644 --- a/include/wx/propgrid/propgridpagestate.h +++ b/include/wx/propgrid/propgridpagestate.h @@ -4,14 +4,18 @@ // Author: Jaakko Salli // Modified by: // Created: 2008-08-24 -// RCS-ID: $Id: +// RCS-ID: $Id$ // Copyright: (c) Jaakko Salli -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_PROPGRID_PROPGRIDPAGESTATE_H_ #define _WX_PROPGRID_PROPGRIDPAGESTATE_H_ +#include "wx/defs.h" + +#if wxUSE_PROPGRID + #include "wx/propgrid/property.h" // ----------------------------------------------------------------------- @@ -21,25 +25,59 @@ A return value from wxPropertyGrid::HitTest(), contains all you need to know about an arbitrary location on the grid. */ -struct WXDLLIMPEXP_PROPGRID wxPropertyGridHitTestResult +class WXDLLIMPEXP_PROPGRID wxPropertyGridHitTestResult { friend class wxPropertyGridPageState; public: + wxPropertyGridHitTestResult() + { + m_property = NULL; + m_column = -1; + m_splitter = -1; + m_splitterHitOffset = 0; + } - wxPGProperty* GetProperty() const { return property; } + ~wxPropertyGridHitTestResult() + { + } - /** Column. -1 for margin. */ - int column; + /** + Returns column hit. -1 for margin. + */ + int GetColumn() const { return m_column; } - /** Index of splitter hit, -1 for none. */ - int splitter; + /** + Returns property hit. NULL if empty space below + properties was hit instead. + */ + wxPGProperty* GetProperty() const + { + return m_property; + } - /** If splitter hit, offset to that */ - int splitterHitOffset; + /** + Returns index of splitter hit, -1 for none. + */ + int GetSplitter() const { return m_splitter; } + + /** + If splitter hit, then this member function + returns offset to the exact splitter position. + */ + int GetSplitterHitOffset() const { return m_splitterHitOffset; } private: /** Property. NULL if empty space below properties was hit */ - wxPGProperty* property; + wxPGProperty* m_property; + + /** Column. -1 for margin. */ + int m_column; + + /** Index of splitter hit, -1 for none. */ + int m_splitter; + + /** If splitter hit, offset to that */ + int m_splitterHitOffset; }; // ----------------------------------------------------------------------- @@ -232,7 +270,8 @@ private: } \ const CLASS& operator=( const CLASS& it ) \ { \ - Assign(it); \ + if (this != &it) \ + Assign(it); \ return *this; \ } \ CLASS& operator++() { Next(); return *this; } \ @@ -287,6 +326,23 @@ public: const wxPGProperty, const wxPropertyGridPageState) + /** + Additional copy constructor. + */ + wxPropertyGridConstIterator( const wxPropertyGridIterator& other ) + { + Assign(other); + } + + /** + Additional assignment operator. + */ + const wxPropertyGridConstIterator& operator=( const wxPropertyGridIterator& it ) + { + Assign(it); + return *this; + } + protected: }; @@ -294,28 +350,16 @@ protected: /** Base class to derive new viterators. */ -class WXDLLIMPEXP_PROPGRID wxPGVIteratorBase +class WXDLLIMPEXP_PROPGRID wxPGVIteratorBase : public wxObjectRefData { friend class wxPGVIterator; public: - wxPGVIteratorBase() { m_refCount = 1; } + wxPGVIteratorBase() { } virtual void Next() = 0; - void IncRef() - { - m_refCount++; - } - void DecRef() - { - m_refCount--; - if ( m_refCount <= 0 ) - delete this; - } protected: virtual ~wxPGVIteratorBase() { } wxPropertyGridIterator m_it; -private: - int m_refCount; }; /** @class wxPGVIterator @@ -337,15 +381,16 @@ public: m_pIt = it.m_pIt; m_pIt->IncRef(); } -#ifndef SWIG const wxPGVIterator& operator=( const wxPGVIterator& it ) { - UnRef(); - m_pIt = it.m_pIt; - m_pIt->IncRef(); + if (this != &it) + { + UnRef(); + m_pIt = it.m_pIt; + m_pIt->IncRef(); + } return *this; } -#endif void Next() { m_pIt->Next(); } bool AtEnd() const { return m_pIt->m_it.AtEnd(); } wxPGProperty* GetProperty() const { return m_pIt->m_it.GetProperty(); } @@ -355,9 +400,6 @@ protected: // ----------------------------------------------------------------------- -#ifndef SWIG -// We won't need this class from wxPython - /** @class wxPropertyGridPageState Contains low-level property page information (properties, column widths, @@ -395,17 +437,17 @@ public: void CheckColumnWidths( int widthChange = 0 ); /** - Override this member function to add custom behavior on property + Override this member function to add custom behaviour on property deletion. */ - virtual void DoDelete( wxPGProperty* item ); + virtual void DoDelete( wxPGProperty* item, bool doDelete = true ); wxSize DoFitColumns( bool allowGridResize = false ); wxPGProperty* DoGetItemAtY( int y ) const; /** - Override this member function to add custom behavior on property + Override this member function to add custom behaviour on property insertion. */ virtual wxPGProperty* DoInsert( wxPGProperty* parent, @@ -418,8 +460,7 @@ public: */ virtual void DoSetSplitterPosition( int pos, int splitterColumn = 0, - bool allPages = false, - bool fromAutoCenter = false ); + int flags = 0 ); bool EnableCategories( bool enable ); @@ -434,9 +475,6 @@ public: } } - /** Enables or disables given property and its subproperties. */ - bool DoEnableProperty( wxPGProperty* p, bool enable ); - /** Returns (precalculated) height of contained visible properties. */ unsigned int GetVirtualHeight() const @@ -461,12 +499,7 @@ public: unsigned int GetColumnCount() const { - return m_colWidths.size(); - } - - wxPGProperty* GetSelection() const - { - return m_selected; + return (unsigned int) m_colWidths.size(); } int GetColumnMinWidth( int column ) const; @@ -489,6 +522,39 @@ public: return ((wxPropertyGridPageState*)this)->GetLastItem(flags); } + /** + Returns currently selected property. + */ + wxPGProperty* GetSelection() const + { + if ( m_selection.size() == 0 ) + return NULL; + return m_selection[0]; + } + + void DoSetSelection( wxPGProperty* prop ) + { + m_selection.clear(); + if ( prop ) + m_selection.push_back(prop); + } + + bool DoClearSelection() + { + return DoSelectProperty(NULL); + } + + void DoRemoveFromSelection( wxPGProperty* prop ); + + void DoSetColumnProportion( unsigned int column, int proportion ); + + int DoGetColumnProportion( unsigned int column ) const + { + return m_columnProportions[column]; + } + + void ResetColumnSizes( int setSplitterFlags ); + wxPropertyCategory* GetPropertyCategory( const wxPGProperty* p ) const; wxPGProperty* GetPropertyByLabel( const wxString& name, @@ -500,6 +566,8 @@ public: wxPGProperty* DoGetRoot() const { return m_properties; } + void DoSetPropertyName( wxPGProperty* p, const wxString& newName ); + // Returns combined width of margin and all the columns int GetVirtualWidth() const { @@ -517,24 +585,13 @@ public: unsigned int col, bool subProps) const; - /** Returns information about arbitrary position in the grid. - - wxPropertyGridHitTestResult definition: - @code - struct wxPropertyGridHitTestResult - { - wxPGProperty* GetProperty() const; - - // column. -1 for margin - int column; - - // Index of splitter hit, -1 for none. - int splitter; + /** + Returns information about arbitrary position in the grid. - // If splitter hit, then offset to that. - int splitterHitOffset; - }; - @endcode + @param pt + Logical coordinates in the virtual grid space. Use + wxScrolled::CalcUnscrolledPosition() if you need to + translate a scrolled position into a logical one. */ wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const; @@ -544,9 +601,6 @@ public: bool IsInNonCatMode() const { return (bool)(m_properties == m_abcArray); } - /** Only inits arrays, doesn't migrate things or such. */ - void InitNonCatMode (); - void DoLimitPropertyEditing( wxPGProperty* p, bool limit = true ) { p->SetFlagRecursively(wxPG_PROP_NOEDITOR, limit); @@ -581,17 +635,15 @@ public: void DoSetPropertyValues( const wxVariantList& list, wxPGProperty* default_category ); - void DoSetPropertyValueUnspecified( wxPGProperty* p ); - void SetSplitterLeft( bool subProps = false ); /** Set virtual width for this particular page. */ void SetVirtualWidth( int width ); - void SortChildren( wxPGProperty* p ); - void Sort(); + void DoSortChildren( wxPGProperty* p, int flags = 0 ); + void DoSort( int flags = 0 ); - void SetSelection( wxPGProperty* p ) { m_selected = p; } + bool PrepareAfterItemsAdded(); /** Called after virtual height needs to be recalculated. */ @@ -606,14 +658,11 @@ public: /** Returns property by its name. */ wxPGProperty* BaseGetPropertyByName( const wxString& name ) const; - void DoClearSelection() - { - m_selected = NULL; - } - /** Called in, for example, wxPropertyGrid::Clear. */ void DoClear(); + bool DoIsPropertySelected( wxPGProperty* prop ) const; + bool DoCollapse( wxPGProperty* p ); bool DoExpand( wxPGProperty* p ); @@ -622,6 +671,11 @@ public: protected: + // Utility to check if two properties are visibly next to each other + bool ArePropertiesAdjacent( wxPGProperty* prop1, + wxPGProperty* prop2, + int iterFlags = wxPG_ITERATE_VISIBLE ) const; + int DoGetSplitterPosition( int splitterIndex = 0 ) const; /** Returns column at x coordinate (in GetGrid()->GetPanel()). @@ -632,7 +686,7 @@ protected: */ int HitTestH( int x, int* pSplitterHit, int* pSplitterHitOffset ) const; - int PrepareToAddItem ( wxPGProperty* property, + bool PrepareToAddItem( wxPGProperty* property, wxPGProperty* scheduledParent ); /** If visible, then this is pointer to wxPropertyGrid. @@ -655,13 +709,19 @@ protected: /** List of column widths (first column does not include margin). */ wxArrayInt m_colWidths; + /** List of indices of columns the user can edit by clicking it. */ + wxArrayInt m_editableColumns; + + /** Column proportions */ + wxArrayInt m_columnProportions; + double m_fSplitterX; /** Most recently added category. */ wxPropertyCategory* m_currentCategory; - /** Pointer to selected property. */ - wxPGProperty* m_selected; + /** Array of selected property. */ + wxArrayPGProperty m_selection; /** Virtual width. */ int m_width; @@ -682,11 +742,21 @@ protected: unsigned char m_anyModified; unsigned char m_vhCalcPending; -}; -#endif // #ifndef SWIG + /** True if splitter has been pre-set by the application. */ + bool m_isSplitterPreSet; + + /** Used to (temporarily) disable splitter centering. */ + bool m_dontCenterSplitter; + +private: + /** Only inits arrays, doesn't migrate things or such. */ + void InitNonCatMode(); +}; // ----------------------------------------------------------------------- +#endif // wxUSE_PROPGRID + #endif // _WX_PROPGRID_PROPGRIDPAGESTATE_H_