Updated documentation of some wxPropertyGrid-related classes.

Updated wxPropertyGridPageState, wxPropertyGridHitTestResult, wxPropertyGridIterator,  documentation.
This commit is contained in:
Artur Wieczorek
2016-07-02 23:20:11 +02:00
parent 4d91d6d2ff
commit 7968f37883
2 changed files with 524 additions and 279 deletions

View File

@@ -19,11 +19,8 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
/** @section propgrid_hittestresult wxPropertyGridHitTestResult // A return value from wxPropertyGrid::HitTest(),
// contains all you need to know about an arbitrary location on the grid.
A return value from wxPropertyGrid::HitTest(),
contains all you need to know about an arbitrary location on the grid.
*/
class WXDLLIMPEXP_PROPGRID wxPropertyGridHitTestResult class WXDLLIMPEXP_PROPGRID wxPropertyGridHitTestResult
{ {
friend class wxPropertyGridPageState; friend class wxPropertyGridPageState;
@@ -40,42 +37,34 @@ public:
{ {
} }
/** // Returns column hit. -1 for margin.
Returns column hit. -1 for margin.
*/
int GetColumn() const { return m_column; } int GetColumn() const { return m_column; }
/** // Returns property hit. NULL if empty space below
Returns property hit. NULL if empty space below // properties was hit instead.
properties was hit instead.
*/
wxPGProperty* GetProperty() const wxPGProperty* GetProperty() const
{ {
return m_property; return m_property;
} }
/** // Returns index of splitter hit, -1 for none.
Returns index of splitter hit, -1 for none.
*/
int GetSplitter() const { return m_splitter; } int GetSplitter() const { return m_splitter; }
/** // If splitter hit, then this member function
If splitter hit, then this member function // returns offset to the exact splitter position.
returns offset to the exact splitter position.
*/
int GetSplitterHitOffset() const { return m_splitterHitOffset; } int GetSplitterHitOffset() const { return m_splitterHitOffset; }
private: private:
/** Property. NULL if empty space below properties was hit */ // Property. NULL if empty space below properties was hit.
wxPGProperty* m_property; wxPGProperty* m_property;
/** Column. -1 for margin. */ // Column. -1 for margin.
int m_column; int m_column;
/** Index of splitter hit, -1 for none. */ // Index of splitter hit, -1 for none.
int m_splitter; int m_splitter;
/** If splitter hit, offset to that */ // If splitter hit, offset to that.
int m_splitterHitOffset; int m_splitterHitOffset;
}; };
@@ -83,21 +72,14 @@ private:
#define wxPG_IT_CHILDREN(A) ((A)<<16) #define wxPG_IT_CHILDREN(A) ((A)<<16)
/** @section propgrid_iterator_flags wxPropertyGridIterator Flags // NOTES: At lower 16-bits, there are flags to check if item will be included.
@{ // At higher 16-bits, there are same flags, but to instead check if children
// will be included.
NOTES: At lower 16-bits, there are flags to check if item will be included.
At higher 16-bits, there are same flags, but to instead check if children
will be included.
*/
enum wxPG_ITERATOR_FLAGS enum wxPG_ITERATOR_FLAGS
{ {
/** // Iterate through 'normal' property items (does not include children of
Iterate through 'normal' property items (does not include children of // aggregate or hidden items by default).
aggregate or hidden items by default).
*/
wxPG_ITERATE_PROPERTIES = wxPG_PROP_PROPERTY | wxPG_ITERATE_PROPERTIES = wxPG_PROP_PROPERTY |
wxPG_PROP_MISC_PARENT | wxPG_PROP_MISC_PARENT |
wxPG_PROP_AGGREGATE | wxPG_PROP_AGGREGATE |
@@ -105,22 +87,18 @@ wxPG_ITERATE_PROPERTIES = wxPG_PROP_PROPERTY |
wxPG_IT_CHILDREN(wxPG_PROP_MISC_PARENT) | wxPG_IT_CHILDREN(wxPG_PROP_MISC_PARENT) |
wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY), wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY),
/** Iterate children of collapsed parents, and individual items that are hidden. // Iterate children of collapsed parents, and individual items that are hidden.
*/
wxPG_ITERATE_HIDDEN = wxPG_PROP_HIDDEN | wxPG_ITERATE_HIDDEN = wxPG_PROP_HIDDEN |
wxPG_IT_CHILDREN(wxPG_PROP_COLLAPSED), wxPG_IT_CHILDREN(wxPG_PROP_COLLAPSED),
/** // Iterate children of parent that is an aggregate property (ie has fixed
Iterate children of parent that is an aggregate property (ie has fixed // children).
children).
*/
wxPG_ITERATE_FIXED_CHILDREN = wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE) | wxPG_ITERATE_FIXED_CHILDREN = wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE) |
wxPG_ITERATE_PROPERTIES, wxPG_ITERATE_PROPERTIES,
/** Iterate categories. // Iterate categories.
Note that even without this flag, children of categories are still iterated // Note that even without this flag, children of categories are still iterated
through. // through.
*/
wxPG_ITERATE_CATEGORIES = wxPG_PROP_CATEGORY | wxPG_ITERATE_CATEGORIES = wxPG_PROP_CATEGORY |
wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY) | wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY) |
wxPG_PROP_COLLAPSED, wxPG_PROP_COLLAPSED,
@@ -145,33 +123,26 @@ wxPG_ITERATOR_MASK_OP_ITEM = wxPG_ITERATOR_FLAGS_ALL,
// (wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY) // (wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY)
wxPG_ITERATOR_MASK_OP_PARENT = wxPG_ITERATOR_FLAGS_ALL, wxPG_ITERATOR_MASK_OP_PARENT = wxPG_ITERATOR_FLAGS_ALL,
/** Combines all flags needed to iterate through visible properties // Combines all flags needed to iterate through visible properties
(ie hidden properties and children of collapsed parents are skipped). // (ie. hidden properties and children of collapsed parents are skipped).
*/
wxPG_ITERATE_VISIBLE = wxPG_ITERATE_PROPERTIES | wxPG_ITERATE_VISIBLE = wxPG_ITERATE_PROPERTIES |
wxPG_PROP_CATEGORY | wxPG_PROP_CATEGORY |
wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE), wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE),
/** Iterate all items. // Iterate all items.
*/
wxPG_ITERATE_ALL = wxPG_ITERATE_VISIBLE | wxPG_ITERATE_ALL = wxPG_ITERATE_VISIBLE |
wxPG_ITERATE_HIDDEN, wxPG_ITERATE_HIDDEN,
/** Iterate through individual properties (ie categories and children of // Iterate through individual properties (ie categories and children of
aggregate properties are skipped). // aggregate properties are skipped).
*/
wxPG_ITERATE_NORMAL = wxPG_ITERATE_PROPERTIES | wxPG_ITERATE_NORMAL = wxPG_ITERATE_PROPERTIES |
wxPG_ITERATE_HIDDEN, wxPG_ITERATE_HIDDEN,
/** Default iterator flags. // Default iterator flags.
*/
wxPG_ITERATE_DEFAULT = wxPG_ITERATE_NORMAL wxPG_ITERATE_DEFAULT = wxPG_ITERATE_NORMAL
}; };
/** @}
*/
#define wxPG_ITERATOR_CREATE_MASKS(FLAGS, A, B) \ #define wxPG_ITERATOR_CREATE_MASKS(FLAGS, A, B) \
A = (FLAGS ^ wxPG_ITERATOR_MASK_OP_ITEM) & \ A = (FLAGS ^ wxPG_ITERATOR_MASK_OP_ITEM) & \
@@ -200,8 +171,7 @@ public:
bool AtEnd() const { return m_property == NULL; } bool AtEnd() const { return m_property == NULL; }
/** Get current property. // Get current property.
*/
wxPGProperty* GetProperty() const { return m_property; } wxPGProperty* GetProperty() const { return m_property; }
void Init( wxPropertyGridPageState* state, void Init( wxPropertyGridPageState* state,
@@ -214,20 +184,15 @@ public:
int startPos = wxTOP, int startPos = wxTOP,
int dir = 0 ); int dir = 0 );
/** Iterate to the next property. // Iterate to the next property.
*/
void Next( bool iterateChildren = true ); void Next( bool iterateChildren = true );
/** Iterate to the previous property. // Iterate to the previous property.
*/
void Prev(); void Prev();
/** // Set base parent, i.e. a property when, in which iteration returns, it
Set base parent, i.e. a property when, in which iteration returns, it // ends.
ends. // Default base parent is the root of the used wxPropertyGridPageState.
Default base parent is the root of the used wxPropertyGridPageState.
*/
void SetBaseParent( wxPGProperty* baseParent ) void SetBaseParent( wxPGProperty* baseParent )
{ m_baseParent = baseParent; } { m_baseParent = baseParent; }
@@ -293,16 +258,9 @@ private:
} }
/** @class wxPropertyGridIterator // Preferable way to iterate through contents of wxPropertyGrid,
// wxPropertyGridManager, and wxPropertyGridPage.
Preferable way to iterate through contents of wxPropertyGrid, // See wxPropertyGridInterface::GetIterator() for more information about usage.
wxPropertyGridManager, and wxPropertyGridPage.
See wxPropertyGridInterface::GetIterator() for more information about usage.
@library{wxpropgrid}
@category{propgrid}
*/
class WXDLLIMPEXP_PROPGRID class WXDLLIMPEXP_PROPGRID
wxPropertyGridIterator : public wxPropertyGridIteratorBase wxPropertyGridIterator : public wxPropertyGridIteratorBase
{ {
@@ -325,17 +283,13 @@ public:
const wxPGProperty, const wxPGProperty,
const wxPropertyGridPageState) const wxPropertyGridPageState)
/** // Additional copy constructor.
Additional copy constructor.
*/
wxPropertyGridConstIterator( const wxPropertyGridIterator& other ) wxPropertyGridConstIterator( const wxPropertyGridIterator& other )
{ {
Assign(other); Assign(other);
} }
/** // Additional assignment operator.
Additional assignment operator.
*/
const wxPropertyGridConstIterator& operator=( const wxPropertyGridIterator& it ) const wxPropertyGridConstIterator& operator=( const wxPropertyGridIterator& it )
{ {
Assign(it); Assign(it);
@@ -347,8 +301,7 @@ protected:
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
/** Base class to derive new viterators. // Base class to derive new viterators.
*/
class WXDLLIMPEXP_PROPGRID wxPGVIteratorBase : public wxObjectRefData class WXDLLIMPEXP_PROPGRID wxPGVIteratorBase : public wxObjectRefData
{ {
friend class wxPGVIterator; friend class wxPGVIterator;
@@ -361,13 +314,10 @@ protected:
wxPropertyGridIterator m_it; wxPropertyGridIterator m_it;
}; };
/** @class wxPGVIterator // Abstract implementation of a simple iterator. Can only be used
// to iterate in forward order, and only through the entire container.
Abstract implementation of a simple iterator. Can only be used // Used to have functions dealing with all properties work with both
to iterate in forward order, and only through the entire container. // wxPropertyGrid and wxPropertyGridManager.
Used to have functions dealing with all properties work with both
wxPropertyGrid and wxPropertyGridManager.
*/
class WXDLLIMPEXP_PROPGRID wxPGVIterator class WXDLLIMPEXP_PROPGRID wxPGVIterator
{ {
public: public:
@@ -399,22 +349,14 @@ protected:
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
/** @class wxPropertyGridPageState // Contains low-level property page information (properties, column widths,
// etc.) of a single wxPropertyGrid or single wxPropertyGridPage. Generally you
Contains low-level property page information (properties, column widths, // should not use this class directly, but instead member functions in
etc.) of a single wxPropertyGrid or single wxPropertyGridPage. Generally you // wxPropertyGridInterface, wxPropertyGrid, wxPropertyGridPage, and
should not use this class directly, but instead member functions in // wxPropertyGridManager.
wxPropertyGridInterface, wxPropertyGrid, wxPropertyGridPage, and // - In separate wxPropertyGrid component this class was known as
wxPropertyGridManager. // wxPropertyGridState.
// - Currently this class is not implemented in wxPython.
@remarks
- In separate wxPropertyGrid component this class was known as
wxPropertyGridState.
- Currently this class is not implemented in wxPython.
@library{wxpropgrid}
@category{propgrid}
*/
class WXDLLIMPEXP_PROPGRID wxPropertyGridPageState class WXDLLIMPEXP_PROPGRID wxPropertyGridPageState
{ {
friend class wxPGProperty; friend class wxPGProperty;
@@ -425,46 +367,38 @@ class WXDLLIMPEXP_PROPGRID wxPropertyGridPageState
friend class wxPropertyGridManager; friend class wxPropertyGridManager;
public: public:
/** Default constructor. */ // Default constructor.
wxPropertyGridPageState(); wxPropertyGridPageState();
/** Destructor. */ // Destructor.
virtual ~wxPropertyGridPageState(); virtual ~wxPropertyGridPageState();
/** Makes sure all columns have minimum width. // Makes sure all columns have minimum width.
*/
void CheckColumnWidths( int widthChange = 0 ); void CheckColumnWidths( int widthChange = 0 );
/** // Override this member function to add custom behaviour on property
Override this member function to add custom behaviour on property // deletion.
deletion.
*/
virtual void DoDelete( wxPGProperty* item, bool doDelete = true ); virtual void DoDelete( wxPGProperty* item, bool doDelete = true );
wxSize DoFitColumns( bool allowGridResize = false ); wxSize DoFitColumns( bool allowGridResize = false );
wxPGProperty* DoGetItemAtY( int y ) const; wxPGProperty* DoGetItemAtY( int y ) const;
/** // Override this member function to add custom behaviour on property
Override this member function to add custom behaviour on property // insertion.
insertion.
*/
virtual wxPGProperty* DoInsert( wxPGProperty* parent, virtual wxPGProperty* DoInsert( wxPGProperty* parent,
int index, int index,
wxPGProperty* property ); wxPGProperty* property );
/** // This needs to be overridden in grid used the manager so that splitter
This needs to be overridden in grid used the manager so that splitter // changes can be propagated to other pages.
changes can be propagated to other pages.
*/
virtual void DoSetSplitterPosition( int pos, virtual void DoSetSplitterPosition( int pos,
int splitterColumn = 0, int splitterColumn = 0,
int flags = 0 ); int flags = 0 );
bool EnableCategories( bool enable ); bool EnableCategories( bool enable );
/** Make sure virtual height is up-to-date. // Make sure virtual height is up-to-date.
*/
void EnsureVirtualHeight() void EnsureVirtualHeight()
{ {
if ( m_vhCalcPending ) if ( m_vhCalcPending )
@@ -474,26 +408,22 @@ public:
} }
} }
/** Returns (precalculated) height of contained visible properties. // Returns (precalculated) height of contained visible properties.
*/
unsigned int GetVirtualHeight() const unsigned int GetVirtualHeight() const
{ {
wxASSERT( !m_vhCalcPending ); wxASSERT( !m_vhCalcPending );
return m_virtualHeight; return m_virtualHeight;
} }
/** Returns (precalculated) height of contained visible properties. // Returns (precalculated) height of contained visible properties.
*/
unsigned int GetVirtualHeight() unsigned int GetVirtualHeight()
{ {
EnsureVirtualHeight(); EnsureVirtualHeight();
return m_virtualHeight; return m_virtualHeight;
} }
/** Returns actual height of contained visible properties. // Returns actual height of contained visible properties.
@remarks // Mostly used for internal diagnostic purposes.
Mostly used for internal diagnostic purposes.
*/
inline unsigned int GetActualVirtualHeight() const; inline unsigned int GetActualVirtualHeight() const;
unsigned int GetColumnCount() const unsigned int GetColumnCount() const
@@ -510,10 +440,7 @@ public:
wxPropertyGrid* GetGrid() const { return m_pPropGrid; } wxPropertyGrid* GetGrid() const { return m_pPropGrid; }
/** Returns last item which could be iterated using given flags. // Returns last item which could be iterated using given flags.
@param flags
@link iteratorflags List of iterator flags@endlink
*/
wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ); wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT );
const wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ) const const wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ) const
@@ -521,9 +448,7 @@ public:
return ((wxPropertyGridPageState*)this)->GetLastItem(flags); return ((wxPropertyGridPageState*)this)->GetLastItem(flags);
} }
/** // Returns currently selected property.
Returns currently selected property.
*/
wxPGProperty* GetSelection() const wxPGProperty* GetSelection() const
{ {
return m_selection.empty()? NULL: m_selection[0]; return m_selection.empty()? NULL: m_selection[0];
@@ -574,12 +499,9 @@ public:
return m_width; return m_width;
} }
/** // Returns minimal width for given column so that all images and texts
Returns minimal width for given column so that all images and texts // will fit entirely.
will fit entirely. // Used by SetSplitterLeft() and DoFitColumns().
Used by SetSplitterLeft() and DoFitColumns().
*/
int GetColumnFitWidth(wxClientDC& dc, int GetColumnFitWidth(wxClientDC& dc,
wxPGProperty* pwc, wxPGProperty* pwc,
unsigned int col, unsigned int col,
@@ -587,18 +509,13 @@ public:
int GetColumnFullWidth(wxClientDC &dc, wxPGProperty *p, unsigned int col); int GetColumnFullWidth(wxClientDC &dc, wxPGProperty *p, unsigned int col);
/** // Returns information about arbitrary position in the grid.
Returns information about arbitrary position in the grid. // pt - Logical coordinates in the virtual grid space. Use
// wxScrolled<T>::CalcUnscrolledPosition() if you need to
@param pt // translate a scrolled position into a logical one.
Logical coordinates in the virtual grid space. Use
wxScrolled<T>::CalcUnscrolledPosition() if you need to
translate a scrolled position into a logical one.
*/
wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const; wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const;
/** Returns true if page is visibly displayed. // Returns true if page is visibly displayed.
*/
inline bool IsDisplayed() const; inline bool IsDisplayed() const;
bool IsInNonCatMode() const { return (bool)(m_properties == m_abcArray); } bool IsInNonCatMode() const { return (bool)(m_properties == m_abcArray); }
@@ -610,14 +527,12 @@ public:
bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 ); bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 );
/** widthChange is non-client. // widthChange is non-client.
*/
void OnClientWidthChange( int newWidth, void OnClientWidthChange( int newWidth,
int widthChange, int widthChange,
bool fromOnResize = false ); bool fromOnResize = false );
/** Recalculates m_virtualHeight. // Recalculates m_virtualHeight.
*/
void RecalculateVirtualHeight() void RecalculateVirtualHeight()
{ {
m_virtualHeight = GetActualVirtualHeight(); m_virtualHeight = GetActualVirtualHeight();
@@ -639,7 +554,7 @@ public:
void SetSplitterLeft( bool subProps = false ); void SetSplitterLeft( bool subProps = false );
/** Set virtual width for this particular page. */ // Set virtual width for this particular page.
void SetVirtualWidth( int width ); void SetVirtualWidth( int width );
void DoSortChildren( wxPGProperty* p, int flags = 0 ); void DoSortChildren( wxPGProperty* p, int flags = 0 );
@@ -647,20 +562,19 @@ public:
bool PrepareAfterItemsAdded(); bool PrepareAfterItemsAdded();
/** Called after virtual height needs to be recalculated. // Called after virtual height needs to be recalculated.
*/
void VirtualHeightChanged() void VirtualHeightChanged()
{ {
m_vhCalcPending = true; m_vhCalcPending = true;
} }
/** Base append. */ // Base append.
wxPGProperty* DoAppend( wxPGProperty* property ); wxPGProperty* DoAppend( wxPGProperty* property );
/** Returns property by its name. */ // Returns property by its name.
wxPGProperty* BaseGetPropertyByName( const wxString& name ) const; wxPGProperty* BaseGetPropertyByName( const wxString& name ) const;
/** Called in, for example, wxPropertyGrid::Clear. */ // Called in, for example, wxPropertyGrid::Clear.
void DoClear(); void DoClear();
bool DoIsPropertySelected( wxPGProperty* prop ) const; bool DoIsPropertySelected( wxPGProperty* prop ) const;
@@ -680,120 +594,112 @@ protected:
int DoGetSplitterPosition( int splitterIndex = 0 ) const; int DoGetSplitterPosition( int splitterIndex = 0 ) const;
/** Returns column at x coordinate (in GetGrid()->GetPanel()). // Returns column at x coordinate (in GetGrid()->GetPanel()).
@param pSplitterHit // pSplitterHit - Give pointer to int that receives index to splitter that is at x.
Give pointer to int that receives index to splitter that is at x. // pSplitterHitOffset - Distance from said splitter.
@param pSplitterHitOffset
Distance from said splitter.
*/
int HitTestH( int x, int* pSplitterHit, int* pSplitterHitOffset ) const; int HitTestH( int x, int* pSplitterHit, int* pSplitterHitOffset ) const;
bool PrepareToAddItem( wxPGProperty* property, bool PrepareToAddItem( wxPGProperty* property,
wxPGProperty* scheduledParent ); wxPGProperty* scheduledParent );
/** Returns property by its label. */ // Returns property by its label.
wxPGProperty* BaseGetPropertyByLabel( const wxString& label, wxPGProperty* BaseGetPropertyByLabel( const wxString& label,
wxPGProperty* parent = NULL ) const; wxPGProperty* parent = NULL ) const;
/** Unselect sub-properties */ // Unselect sub-properties.
void DoRemoveChildrenFromSelection(wxPGProperty* p, bool recursive, void DoRemoveChildrenFromSelection(wxPGProperty* p, bool recursive,
int selFlags); int selFlags);
/** Mark sub-properties as being deleted */ // Mark sub-properties as being deleted.
void DoMarkChildrenAsDeleted(wxPGProperty* p, bool recursive); void DoMarkChildrenAsDeleted(wxPGProperty* p, bool recursive);
/** Rename the property // Rename the property
so it won't remain in the way of the user code. // so it won't remain in the way of the user code.
*/
void DoInvalidatePropertyName(wxPGProperty* p); void DoInvalidatePropertyName(wxPGProperty* p);
/** Rename sub-properties // Rename sub-properties
so it won't remain in the way of the user code. // so it won't remain in the way of the user code.
*/
void DoInvalidateChildrenNames(wxPGProperty* p, bool recursive); void DoInvalidateChildrenNames(wxPGProperty* p, bool recursive);
/** Check if property contains given sub-category */ // Check if property contains given sub-category.
bool IsChildCategory(wxPGProperty* p, bool IsChildCategory(wxPGProperty* p,
wxPropertyCategory* cat, bool recursive); wxPropertyCategory* cat, bool recursive);
/** If visible, then this is pointer to wxPropertyGrid. // If visible, then this is pointer to wxPropertyGrid.
This shall *never* be NULL to indicate that this state is not visible. // This shall *never* be NULL to indicate that this state is not visible.
*/
wxPropertyGrid* m_pPropGrid; wxPropertyGrid* m_pPropGrid;
/** Pointer to currently used array. */ // Pointer to currently used array.
wxPGProperty* m_properties; wxPGProperty* m_properties;
/** Array for categoric mode. */ // Array for categoric mode.
wxPGRootProperty m_regularArray; wxPGRootProperty m_regularArray;
/** Array for root of non-categoric mode. */ // Array for root of non-categoric mode.
wxPGRootProperty* m_abcArray; wxPGRootProperty* m_abcArray;
/** Dictionary for name-based access. */ // Dictionary for name-based access.
wxPGHashMapS2P m_dictName; wxPGHashMapS2P m_dictName;
/** List of column widths (first column does not include margin). */ // List of column widths (first column does not include margin).
wxArrayInt m_colWidths; wxArrayInt m_colWidths;
/** List of indices of columns the user can edit by clicking it. */ // List of indices of columns the user can edit by clicking it.
wxArrayInt m_editableColumns; wxArrayInt m_editableColumns;
/** Column proportions */ // Column proportions.
wxArrayInt m_columnProportions; wxArrayInt m_columnProportions;
double m_fSplitterX; double m_fSplitterX;
/** Most recently added category. */ // Most recently added category.
wxPropertyCategory* m_currentCategory; wxPropertyCategory* m_currentCategory;
/** Array of selected property. */ // Array of selected property.
wxArrayPGProperty m_selection; wxArrayPGProperty m_selection;
/** Virtual width. */ // Virtual width.
int m_width; int m_width;
/** Indicates total virtual height of visible properties. */ // Indicates total virtual height of visible properties.
unsigned int m_virtualHeight; unsigned int m_virtualHeight;
#if WXWIN_COMPATIBILITY_3_0 #if WXWIN_COMPATIBILITY_3_0
/** 1 if m_lastCaption is also the bottommost caption. */ // 1 if m_lastCaption is also the bottommost caption.
unsigned char m_lastCaptionBottomnest; unsigned char m_lastCaptionBottomnest;
/** 1 items appended/inserted, so stuff needs to be done before drawing; // 1 items appended/inserted, so stuff needs to be done before drawing;
If m_virtualHeight == 0, then calcylatey's must be done. // If m_virtualHeight == 0, then calcylatey's must be done.
Otherwise just sort. // Otherwise just sort.
*/
unsigned char m_itemsAdded; unsigned char m_itemsAdded;
/** 1 if any value is modified. */ // 1 if any value is modified.
unsigned char m_anyModified; unsigned char m_anyModified;
unsigned char m_vhCalcPending; unsigned char m_vhCalcPending;
#else #else
/** True if m_lastCaption is also the bottommost caption. */ // True if m_lastCaption is also the bottommost caption.
bool m_lastCaptionBottomnest; bool m_lastCaptionBottomnest;
/** True: items appended/inserted, so stuff needs to be done before drawing; // True: items appended/inserted, so stuff needs to be done before drawing;
If m_virtualHeight == 0, then calcylatey's must be done. // If m_virtualHeight == 0, then calcylatey's must be done.
Otherwise just sort. // Otherwise just sort.
*/
bool m_itemsAdded; bool m_itemsAdded;
/** True if any value is modified. */ // True if any value is modified.
bool m_anyModified; bool m_anyModified;
bool m_vhCalcPending; bool m_vhCalcPending;
#endif // WXWIN_COMPATIBILITY_3_0 #endif // WXWIN_COMPATIBILITY_3_0
/** True if splitter has been pre-set by the application. */ // True if splitter has been pre-set by the application.
bool m_isSplitterPreSet; bool m_isSplitterPreSet;
/** Used to (temporarily) disable splitter centering. */ // Used to (temporarily) disable splitter centering.
bool m_dontCenterSplitter; bool m_dontCenterSplitter;
private: private:
/** Only inits arrays, doesn't migrate things or such. */ // Only inits arrays, doesn't migrate things or such.
void InitNonCatMode(); void InitNonCatMode();
}; };
@@ -802,4 +708,3 @@ private:
#endif // wxUSE_PROPGRID #endif // wxUSE_PROPGRID
#endif // _WX_PROPGRID_PROPGRIDPAGESTATE_H_ #endif // _WX_PROPGRID_PROPGRIDPAGESTATE_H_

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: property.h // Name: propgridpagestate.h
// Purpose: interface of wxPGProperty // Purpose: interface of wxPGProperty
// Author: wxWidgets team // Author: wxWidgets team
// Licence: wxWindows licence // Licence: wxWindows licence
@@ -12,29 +12,40 @@
A return value from wxPropertyGrid::HitTest(), A return value from wxPropertyGrid::HitTest(),
contains all you need to know about an arbitrary location on the grid. contains all you need to know about an arbitrary location on the grid.
*/ */
struct wxPropertyGridHitTestResult class wxPropertyGridHitTestResult
{ {
friend class wxPropertyGridPageState;
public: public:
wxPropertyGridHitTestResult();
wxPGProperty* GetProperty() const { return property; } ~wxPropertyGridHitTestResult();
/** Column. -1 for margin. */ /**
int column; Returns column hit. -1 for margin.
*/
int GetColumn() const;
/** Index of splitter hit, -1 for none. */ /**
int splitter; Returns property hit. NULL if empty space below
properties was hit instead.
*/
wxPGProperty* GetProperty() const;
/** If splitter hit, offset to that */ /**
int splitterHitOffset; Returns index of splitter hit, -1 for none.
*/
int GetSplitter() const;
private: /**
/** Property. NULL if empty space below properties was hit */ If splitter hit, then this member function
wxPGProperty* property; returns offset to the exact splitter position.
*/
int GetSplitterHitOffset() const;
}; };
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
#define wxPG_IT_CHILDREN(A) (A<<16) #define wxPG_IT_CHILDREN(A) ((A)<<16)
/** @section propgrid_iterator_flags wxPropertyGridIterator Flags /** @section propgrid_iterator_flags wxPropertyGridIterator Flags
@{ @{
@@ -45,53 +56,106 @@ private:
enum wxPG_ITERATOR_FLAGS enum wxPG_ITERATOR_FLAGS
{ {
/**
/** Iterate through 'normal' property items (does not include children of aggregate or hidden items by default). Iterate through 'normal' property items (does not include children of
aggregate or hidden items by default).
@hideinitializer
*/ */
wxPG_ITERATE_PROPERTIES = (wxPG_PROP_PROPERTY|wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE| \ wxPG_ITERATE_PROPERTIES = wxPG_PROP_PROPERTY |
wxPG_PROP_COLLAPSED|((wxPG_PROP_MISC_PARENT|wxPG_PROP_CATEGORY)<<16)), wxPG_PROP_MISC_PARENT |
wxPG_PROP_AGGREGATE |
wxPG_PROP_COLLAPSED |
wxPG_IT_CHILDREN(wxPG_PROP_MISC_PARENT) |
wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY),
/** Iterate children of collapsed parents, and individual items that are hidden. /**
Iterate children of collapsed parents, and individual items that are hidden.
@hideinitializer
*/ */
wxPG_ITERATE_HIDDEN = (wxPG_PROP_HIDDEN|wxPG_IT_CHILDREN(wxPG_PROP_COLLAPSED)), wxPG_ITERATE_HIDDEN = wxPG_PROP_HIDDEN |
wxPG_IT_CHILDREN(wxPG_PROP_COLLAPSED),
/** Iterate children of parent that is an aggregate property (ie. has fixed children). /**
Iterate children of parent that is an aggregate property (ie has fixed
children).
@hideinitializer
*/ */
wxPG_ITERATE_FIXED_CHILDREN = (wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)|wxPG_ITERATE_PROPERTIES), wxPG_ITERATE_FIXED_CHILDREN = wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE) |
wxPG_ITERATE_PROPERTIES,
/** Iterate categories. Note that even without this flag, children of categories /** Iterate categories.
are still iterated through. Note that even without this flag, children of categories are still iterated
through.
@hideinitializer
*/ */
wxPG_ITERATE_CATEGORIES = (wxPG_PROP_CATEGORY|wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY)|wxPG_PROP_COLLAPSED), wxPG_ITERATE_CATEGORIES = wxPG_PROP_CATEGORY |
wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY) |
wxPG_PROP_COLLAPSED,
wxPG_ITERATE_ALL_PARENTS = (wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY), /**
@hideinitializer
*/
wxPG_ITERATE_ALL_PARENTS = wxPG_PROP_MISC_PARENT |
wxPG_PROP_AGGREGATE |
wxPG_PROP_CATEGORY,
wxPG_ITERATE_ALL_PARENTS_RECURSIVELY = (wxPG_ITERATE_ALL_PARENTS|wxPG_IT_CHILDREN(wxPG_ITERATE_ALL_PARENTS)), /**
@hideinitializer
*/
wxPG_ITERATE_ALL_PARENTS_RECURSIVELY = wxPG_ITERATE_ALL_PARENTS |
wxPG_IT_CHILDREN(
wxPG_ITERATE_ALL_PARENTS),
wxPG_ITERATOR_FLAGS_ALL = (wxPG_PROP_PROPERTY|wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE| \ /**
wxPG_PROP_HIDDEN|wxPG_PROP_CATEGORY|wxPG_PROP_COLLAPSED), @hideinitializer
*/
wxPG_ITERATOR_FLAGS_ALL = wxPG_PROP_PROPERTY |
wxPG_PROP_MISC_PARENT |
wxPG_PROP_AGGREGATE |
wxPG_PROP_HIDDEN |
wxPG_PROP_CATEGORY |
wxPG_PROP_COLLAPSED,
wxPG_ITERATOR_MASK_OP_ITEM = wxPG_ITERATOR_FLAGS_ALL, /**
@hideinitializer
*/
wxPG_ITERATOR_MASK_OP_ITEM = wxPG_ITERATOR_FLAGS_ALL,
wxPG_ITERATOR_MASK_OP_PARENT = wxPG_ITERATOR_FLAGS_ALL, // (wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY) // (wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY)
/**
@hideinitializer
*/
wxPG_ITERATOR_MASK_OP_PARENT = wxPG_ITERATOR_FLAGS_ALL,
/** Combines all flags needed to iterate through visible properties /**
Combines all flags needed to iterate through visible properties
(ie. hidden properties and children of collapsed parents are skipped). (ie. hidden properties and children of collapsed parents are skipped).
@hideinitializer
*/ */
wxPG_ITERATE_VISIBLE = (wxPG_ITERATE_PROPERTIES|wxPG_PROP_CATEGORY|wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)), wxPG_ITERATE_VISIBLE = wxPG_ITERATE_PROPERTIES |
wxPG_PROP_CATEGORY |
wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE),
/** Iterate all items. /**
Iterate all items.
@hideinitializer
*/ */
wxPG_ITERATE_ALL = (wxPG_ITERATE_VISIBLE|wxPG_ITERATE_HIDDEN), wxPG_ITERATE_ALL = wxPG_ITERATE_VISIBLE |
wxPG_ITERATE_HIDDEN,
/** Iterate through individual properties (ie. categories and children of /**
Iterate through individual properties (ie categories and children of
aggregate properties are skipped). aggregate properties are skipped).
@hideinitializer
*/ */
wxPG_ITERATE_NORMAL = (wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_HIDDEN), wxPG_ITERATE_NORMAL = wxPG_ITERATE_PROPERTIES |
wxPG_ITERATE_HIDDEN,
/** Default iterator flags. /**
Default iterator flags.
@hideinitializer
*/ */
wxPG_ITERATE_DEFAULT = wxPG_ITERATE_NORMAL wxPG_ITERATE_DEFAULT = wxPG_ITERATE_NORMAL
}; };
@@ -109,19 +173,35 @@ wxPG_ITERATE_DEFAULT = wxPG_ITERATE_NORMAL
@library{wxpropgrid} @library{wxpropgrid}
@category{propgrid} @category{propgrid}
@{
*/ */
class wxPropertyGridIterator : public wxPropertyGridIteratorBase /**
Base for wxPropertyGridIterator classes.
*/
class wxPropertyGridIteratorBase
{ {
public: public:
wxPropertyGridIteratorBase();
void Assign( const wxPropertyGridIteratorBase& it ); void Assign( const wxPropertyGridIteratorBase& it );
bool AtEnd() const { return m_property == NULL; } bool AtEnd() const;
/** /**
Get current property. Get current property.
*/ */
wxPGProperty* GetProperty() const { return m_property; } wxPGProperty* GetProperty() const;
void Init( wxPropertyGridPageState* state,
int flags,
wxPGProperty* property,
int dir = 1 );
void Init( wxPropertyGridPageState* state,
int flags,
int startPos = wxTOP,
int dir = 0 );
/** /**
Iterate to the next property. Iterate to the next property.
@@ -133,9 +213,40 @@ public:
*/ */
void Prev(); void Prev();
protected: /**
Set base parent, i.e. a property when, in which iteration returns,
it ends.
Default base parent is the root of the used wxPropertyGridPageState.
*/
void SetBaseParent( wxPGProperty* baseParent );
}; };
class wxPropertyGridIterator : public wxPropertyGridIteratorBase
{
public:
};
/**
Const version of wxPropertyGridIterator.
*/
class wxPropertyGridConstIterator : public wxPropertyGridIteratorBase
{
public:
/**
Additional copy constructor.
*/
wxPropertyGridConstIterator( const wxPropertyGridIterator& other );
/**
Additional assignment operator.
*/
const wxPropertyGridConstIterator& operator=( const wxPropertyGridIterator& it );
};
/** @}
*/
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
/** /**
@@ -149,27 +260,256 @@ protected:
class wxPGVIterator class wxPGVIterator
{ {
public: public:
wxPGVIterator() { m_pIt = NULL; } wxPGVIterator();
wxPGVIterator( wxPGVIteratorBase* obj ) { m_pIt = obj; } wxPGVIterator( wxPGVIteratorBase* obj );
~wxPGVIterator() { UnRef(); } ~wxPGVIterator();
void UnRef() { if (m_pIt) m_pIt->DecRef(); } void UnRef();
wxPGVIterator( const wxPGVIterator& it ) wxPGVIterator( const wxPGVIterator& it );
{ const wxPGVIterator& operator=( const wxPGVIterator& it );
m_pIt = it.m_pIt; void Next();
m_pIt->IncRef(); bool AtEnd() const;
} wxPGProperty* GetProperty() const;
const wxPGVIterator& operator=( const wxPGVIterator& it )
{
UnRef();
m_pIt = it.m_pIt;
m_pIt->IncRef();
return *this;
}
void Next() { m_pIt->Next(); }
bool AtEnd() const { return m_pIt->m_it.AtEnd(); }
wxPGProperty* GetProperty() const { return m_pIt->m_it.GetProperty(); }
protected:
wxPGVIteratorBase* m_pIt;
}; };
// -----------------------------------------------------------------------
/** @class wxPropertyGridPageState
Contains low-level property page information (properties, column widths,
etc.) of a single wxPropertyGrid or single wxPropertyGridPage. Generally you
should not use this class directly, but instead member functions in
wxPropertyGridInterface, wxPropertyGrid, wxPropertyGridPage, and
wxPropertyGridManager.
@remarks
- In separate wxPropertyGrid component this class was known as
wxPropertyGridState.
- Currently this class is not implemented in wxPython.
@library{wxpropgrid}
@category{propgrid}
*/
class wxPropertyGridPageState
{
friend class wxPGProperty;
friend class wxPropertyGrid;
friend class wxPGCanvas;
friend class wxPropertyGridInterface;
friend class wxPropertyGridPage;
friend class wxPropertyGridManager;
public:
/**
Default constructor.
*/
wxPropertyGridPageState();
/**
Destructor.
*/
virtual ~wxPropertyGridPageState();
/**
Makes sure all columns have minimum width.
*/
void CheckColumnWidths( int widthChange = 0 );
/**
Override this member function to add custom behaviour on property
deletion.
*/
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 behaviour on property
insertion.
*/
virtual wxPGProperty* DoInsert( wxPGProperty* parent,
int index,
wxPGProperty* property );
/**
This needs to be overridden in grid used the manager so that splitter
changes can be propagated to other pages.
*/
virtual void DoSetSplitterPosition( int pos,
int splitterColumn = 0,
int flags = 0 );
bool EnableCategories( bool enable );
/**
Make sure virtual height is up-to-date.
*/
void EnsureVirtualHeight();
/**
Returns (precalculated) height of contained visible properties.
*/
unsigned int GetVirtualHeight() const;
/**
Returns (precalculated) height of contained visible properties.
*/
unsigned int GetVirtualHeight();
/**
Returns actual height of contained visible properties.
@remarks
Mostly used for internal diagnostic purposes.
*/
inline unsigned int GetActualVirtualHeight() const;
unsigned int GetColumnCount() const'
int GetColumnMinWidth( int column ) const;
int GetColumnWidth( unsigned int column ) const;
wxPropertyGrid* GetGrid() const;
/**
Returns last item which could be iterated using given flags.
@param flags
@ref propgrid_iterator_flags
*/
wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT );
const wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ) const;
/**
Returns currently selected property.
*/
wxPGProperty* GetSelection() const;
void DoSetSelection( wxPGProperty* prop );
bool DoClearSelection();
void DoRemoveFromSelection( wxPGProperty* prop );
void DoSetColumnProportion( unsigned int column, int proportion );
int DoGetColumnProportion( unsigned int column ) const;
void ResetColumnSizes( int setSplitterFlags );
wxPropertyCategory* GetPropertyCategory( const wxPGProperty* p ) const;
wxVariant DoGetPropertyValues( const wxString& listname,
wxPGProperty* baseparent,
long flags ) const;
wxPGProperty* DoGetRoot() const;
void DoSetPropertyName( wxPGProperty* p, const wxString& newName );
/**
Returns combined width of margin and all the columns.
*/
int GetVirtualWidth() const;
/**
Returns minimal width for given column so that all images and texts
will fit entirely.
Used by SetSplitterLeft() and DoFitColumns().
*/
int GetColumnFitWidth(wxClientDC& dc,
wxPGProperty* pwc,
unsigned int col,
bool subProps) const;
int GetColumnFullWidth(wxClientDC &dc, wxPGProperty *p, unsigned int col);
/**
Returns information about arbitrary position in the grid.
@param pt
Logical coordinates in the virtual grid space. Use
wxScrolled<T>::CalcUnscrolledPosition() if you need to
translate a scrolled position into a logical one.
*/
wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const;
/**
Returns true if page is visibly displayed.
*/
inline bool IsDisplayed() const;
bool IsInNonCatMode() const;
void DoLimitPropertyEditing( wxPGProperty* p, bool limit = true );
bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 );
/**
widthChange is non-client.
*/
void OnClientWidthChange( int newWidth,
int widthChange,
bool fromOnResize = false );
/**
Recalculates m_virtualHeight.
*/
void RecalculateVirtualHeight();
void SetColumnCount( int colCount );
void PropagateColSizeDec( int column, int decrease, int dir );
bool DoHideProperty( wxPGProperty* p, bool hide, int flags = wxPG_RECURSE );
bool DoSetPropertyValueString( wxPGProperty* p, const wxString& value );
bool DoSetPropertyValue( wxPGProperty* p, wxVariant& value );
bool DoSetPropertyValueWxObjectPtr( wxPGProperty* p, wxObject* value );
void DoSetPropertyValues( const wxVariantList& list,
wxPGProperty* default_category );
void SetSplitterLeft( bool subProps = false );
/**
Set virtual width for this particular page.
*/
void SetVirtualWidth( int width );
void DoSortChildren( wxPGProperty* p, int flags = 0 );
void DoSort( int flags = 0 );
bool PrepareAfterItemsAdded();
/**
Called after virtual height needs to be recalculated.
*/
void VirtualHeightChanged();
/**
Base append.
*/
wxPGProperty* DoAppend( wxPGProperty* property );
/**
Returns property by its name.
*/
wxPGProperty* BaseGetPropertyByName( const wxString& name ) const;
/**
Called in, for example, wxPropertyGrid::Clear.
*/
void DoClear();
bool DoIsPropertySelected( wxPGProperty* prop ) const;
bool DoCollapse( wxPGProperty* p );
bool DoExpand( wxPGProperty* p );
void CalculateFontAndBitmapStuff( int vspacing );
}: