2008-09-12 16:57:41 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/propgrid/propgridpagestate.h
|
|
|
|
// Purpose: wxPropertyGridPageState class
|
|
|
|
// Author: Jaakko Salli
|
|
|
|
// Modified by:
|
|
|
|
// Created: 2008-08-24
|
|
|
|
// Copyright: (c) Jaakko Salli
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-09-12 16:57:41 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_PROPGRID_PROPGRIDPAGESTATE_H_
|
|
|
|
#define _WX_PROPGRID_PROPGRIDPAGESTATE_H_
|
|
|
|
|
2010-08-26 09:25:07 -04:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
2008-09-17 11:00:00 -04:00
|
|
|
#if wxUSE_PROPGRID
|
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
#include "wx/propgrid/property.h"
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// A return value from wxPropertyGrid::HitTest(),
|
|
|
|
// contains all you need to know about an arbitrary location on the grid.
|
2009-08-23 14:38:13 -04:00
|
|
|
class WXDLLIMPEXP_PROPGRID wxPropertyGridHitTestResult
|
2008-09-12 16:57:41 -04:00
|
|
|
{
|
|
|
|
friend class wxPropertyGridPageState;
|
|
|
|
public:
|
2009-08-23 14:38:13 -04:00
|
|
|
wxPropertyGridHitTestResult()
|
|
|
|
{
|
|
|
|
m_property = NULL;
|
|
|
|
m_column = -1;
|
|
|
|
m_splitter = -1;
|
|
|
|
m_splitterHitOffset = 0;
|
|
|
|
}
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2009-08-23 14:38:13 -04:00
|
|
|
~wxPropertyGridHitTestResult()
|
|
|
|
{
|
|
|
|
}
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Returns column hit. -1 for margin.
|
2009-08-23 14:38:13 -04:00
|
|
|
int GetColumn() const { return m_column; }
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Returns property hit. NULL if empty space below
|
|
|
|
// properties was hit instead.
|
2009-08-23 14:38:13 -04:00
|
|
|
wxPGProperty* GetProperty() const
|
|
|
|
{
|
|
|
|
return m_property;
|
|
|
|
}
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Returns index of splitter hit, -1 for none.
|
2009-08-23 14:38:13 -04:00
|
|
|
int GetSplitter() const { return m_splitter; }
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// If splitter hit, then this member function
|
|
|
|
// returns offset to the exact splitter position.
|
2009-08-23 14:38:13 -04:00
|
|
|
int GetSplitterHitOffset() const { return m_splitterHitOffset; }
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
private:
|
2016-07-02 17:20:11 -04:00
|
|
|
// Property. NULL if empty space below properties was hit.
|
2009-08-23 14:38:13 -04:00
|
|
|
wxPGProperty* m_property;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Column. -1 for margin.
|
2009-08-23 14:38:13 -04:00
|
|
|
int m_column;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Index of splitter hit, -1 for none.
|
2009-08-23 14:38:13 -04:00
|
|
|
int m_splitter;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// If splitter hit, offset to that.
|
2009-08-23 14:38:13 -04:00
|
|
|
int m_splitterHitOffset;
|
2008-09-12 16:57:41 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#define wxPG_IT_CHILDREN(A) ((A)<<16)
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// 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.
|
2008-09-12 16:57:41 -04:00
|
|
|
enum wxPG_ITERATOR_FLAGS
|
|
|
|
{
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Iterate through 'normal' property items (does not include children of
|
|
|
|
// aggregate or hidden items by default).
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPG_ITERATE_PROPERTIES = wxPG_PROP_PROPERTY |
|
|
|
|
wxPG_PROP_MISC_PARENT |
|
|
|
|
wxPG_PROP_AGGREGATE |
|
|
|
|
wxPG_PROP_COLLAPSED |
|
|
|
|
wxPG_IT_CHILDREN(wxPG_PROP_MISC_PARENT) |
|
|
|
|
wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY),
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Iterate children of collapsed parents, and individual items that are hidden.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPG_ITERATE_HIDDEN = wxPG_PROP_HIDDEN |
|
|
|
|
wxPG_IT_CHILDREN(wxPG_PROP_COLLAPSED),
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Iterate children of parent that is an aggregate property (ie has fixed
|
|
|
|
// children).
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPG_ITERATE_FIXED_CHILDREN = wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE) |
|
|
|
|
wxPG_ITERATE_PROPERTIES,
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Iterate categories.
|
|
|
|
// Note that even without this flag, children of categories are still iterated
|
|
|
|
// through.
|
2008-09-12 16:57:41 -04:00
|
|
|
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,
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
|
|
|
wxPG_ITERATOR_MASK_OP_ITEM = wxPG_ITERATOR_FLAGS_ALL,
|
|
|
|
|
|
|
|
// (wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY)
|
|
|
|
wxPG_ITERATOR_MASK_OP_PARENT = wxPG_ITERATOR_FLAGS_ALL,
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Combines all flags needed to iterate through visible properties
|
|
|
|
// (ie. hidden properties and children of collapsed parents are skipped).
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPG_ITERATE_VISIBLE = wxPG_ITERATE_PROPERTIES |
|
|
|
|
wxPG_PROP_CATEGORY |
|
|
|
|
wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE),
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Iterate all items.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPG_ITERATE_ALL = wxPG_ITERATE_VISIBLE |
|
|
|
|
wxPG_ITERATE_HIDDEN,
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Iterate through individual properties (ie categories and children of
|
|
|
|
// aggregate properties are skipped).
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPG_ITERATE_NORMAL = wxPG_ITERATE_PROPERTIES |
|
|
|
|
wxPG_ITERATE_HIDDEN,
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Default iterator flags.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPG_ITERATE_DEFAULT = wxPG_ITERATE_NORMAL
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define wxPG_ITERATOR_CREATE_MASKS(FLAGS, A, B) \
|
|
|
|
A = (FLAGS ^ wxPG_ITERATOR_MASK_OP_ITEM) & \
|
|
|
|
wxPG_ITERATOR_MASK_OP_ITEM & 0xFFFF; \
|
|
|
|
B = ((FLAGS>>16) ^ wxPG_ITERATOR_MASK_OP_PARENT) & \
|
|
|
|
wxPG_ITERATOR_MASK_OP_PARENT & 0xFFFF;
|
|
|
|
|
|
|
|
|
|
|
|
// Macro to test if children of PWC should be iterated through
|
|
|
|
#define wxPG_ITERATOR_PARENTEXMASK_TEST(PWC, PARENTMASK) \
|
|
|
|
( \
|
2015-05-16 11:16:30 -04:00
|
|
|
!PWC->HasFlag(PARENTMASK) && \
|
2008-09-12 16:57:41 -04:00
|
|
|
PWC->GetChildCount() \
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// Base for wxPropertyGridIterator classes.
|
|
|
|
class WXDLLIMPEXP_PROPGRID wxPropertyGridIteratorBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxPropertyGridIteratorBase()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Assign( const wxPropertyGridIteratorBase& it );
|
|
|
|
|
|
|
|
bool AtEnd() const { return m_property == NULL; }
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Get current property.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPGProperty* GetProperty() const { return m_property; }
|
|
|
|
|
|
|
|
void Init( wxPropertyGridPageState* state,
|
|
|
|
int flags,
|
|
|
|
wxPGProperty* property,
|
|
|
|
int dir = 1 );
|
|
|
|
|
|
|
|
void Init( wxPropertyGridPageState* state,
|
|
|
|
int flags,
|
|
|
|
int startPos = wxTOP,
|
|
|
|
int dir = 0 );
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Iterate to the next property.
|
2008-09-12 16:57:41 -04:00
|
|
|
void Next( bool iterateChildren = true );
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Iterate to the previous property.
|
2008-09-12 16:57:41 -04:00
|
|
|
void Prev();
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Set base parent, i.e. a property when, in which iteration returns, it
|
|
|
|
// ends.
|
|
|
|
// Default base parent is the root of the used wxPropertyGridPageState.
|
2008-09-12 16:57:41 -04:00
|
|
|
void SetBaseParent( wxPGProperty* baseParent )
|
|
|
|
{ m_baseParent = baseParent; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
wxPGProperty* m_property;
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxPropertyGridPageState* m_state;
|
|
|
|
wxPGProperty* m_baseParent;
|
|
|
|
|
|
|
|
// Masks are used to quickly exclude items
|
2015-05-16 11:16:30 -04:00
|
|
|
wxPGProperty::FlagType m_itemExMask;
|
|
|
|
wxPGProperty::FlagType m_parentExMask;
|
2008-09-12 16:57:41 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define wxPG_IMPLEMENT_ITERATOR(CLASS, PROPERTY, STATE) \
|
|
|
|
CLASS( STATE* state, int flags = wxPG_ITERATE_DEFAULT, \
|
|
|
|
PROPERTY* property = NULL, int dir = 1 ) \
|
|
|
|
: wxPropertyGridIteratorBase() \
|
|
|
|
{ Init( (wxPropertyGridPageState*)state, flags, \
|
|
|
|
(wxPGProperty*)property, dir ); } \
|
|
|
|
CLASS( STATE* state, int flags, int startPos, int dir = 0 ) \
|
|
|
|
: wxPropertyGridIteratorBase() \
|
|
|
|
{ Init( (wxPropertyGridPageState*)state, flags, startPos, dir ); } \
|
|
|
|
CLASS() \
|
|
|
|
: wxPropertyGridIteratorBase() \
|
|
|
|
{ \
|
|
|
|
m_property = NULL; \
|
|
|
|
} \
|
|
|
|
CLASS( const CLASS& it ) \
|
|
|
|
: wxPropertyGridIteratorBase( ) \
|
|
|
|
{ \
|
|
|
|
Assign(it); \
|
|
|
|
} \
|
|
|
|
~CLASS() \
|
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
const CLASS& operator=( const CLASS& it ) \
|
|
|
|
{ \
|
2008-11-16 13:03:08 -05:00
|
|
|
if (this != &it) \
|
|
|
|
Assign(it); \
|
2008-09-12 16:57:41 -04:00
|
|
|
return *this; \
|
|
|
|
} \
|
|
|
|
CLASS& operator++() { Next(); return *this; } \
|
|
|
|
CLASS operator++(int) { CLASS it=*this;Next();return it; } \
|
|
|
|
CLASS& operator--() { Prev(); return *this; } \
|
|
|
|
CLASS operator--(int) { CLASS it=*this;Prev();return it; } \
|
|
|
|
PROPERTY* operator *() const { return (PROPERTY*)m_property; } \
|
|
|
|
static PROPERTY* OneStep( STATE* state, \
|
|
|
|
int flags = wxPG_ITERATE_DEFAULT, \
|
|
|
|
PROPERTY* property = NULL, \
|
|
|
|
int dir = 1 ) \
|
|
|
|
{ \
|
|
|
|
CLASS it( state, flags, property, dir ); \
|
|
|
|
if ( property ) \
|
|
|
|
{ \
|
|
|
|
if ( dir == 1 ) it.Next(); \
|
|
|
|
else it.Prev(); \
|
|
|
|
} \
|
|
|
|
return *it; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Preferable way to iterate through contents of wxPropertyGrid,
|
|
|
|
// wxPropertyGridManager, and wxPropertyGridPage.
|
|
|
|
// See wxPropertyGridInterface::GetIterator() for more information about usage.
|
2008-09-12 16:57:41 -04:00
|
|
|
class WXDLLIMPEXP_PROPGRID
|
|
|
|
wxPropertyGridIterator : public wxPropertyGridIteratorBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
wxPG_IMPLEMENT_ITERATOR(wxPropertyGridIterator,
|
|
|
|
wxPGProperty,
|
|
|
|
wxPropertyGridPageState)
|
|
|
|
|
|
|
|
protected:
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Const version of wxPropertyGridIterator.
|
|
|
|
class WXDLLIMPEXP_PROPGRID
|
|
|
|
wxPropertyGridConstIterator : public wxPropertyGridIteratorBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxPG_IMPLEMENT_ITERATOR(wxPropertyGridConstIterator,
|
|
|
|
const wxPGProperty,
|
|
|
|
const wxPropertyGridPageState)
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Additional copy constructor.
|
2008-10-27 12:47:35 -04:00
|
|
|
wxPropertyGridConstIterator( const wxPropertyGridIterator& other )
|
|
|
|
{
|
|
|
|
Assign(other);
|
|
|
|
}
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Additional assignment operator.
|
2008-10-27 12:50:45 -04:00
|
|
|
const wxPropertyGridConstIterator& operator=( const wxPropertyGridIterator& it )
|
|
|
|
{
|
|
|
|
Assign(it);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
protected:
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Base class to derive new viterators.
|
2009-06-12 13:14:28 -04:00
|
|
|
class WXDLLIMPEXP_PROPGRID wxPGVIteratorBase : public wxObjectRefData
|
2008-09-12 16:57:41 -04:00
|
|
|
{
|
|
|
|
friend class wxPGVIterator;
|
|
|
|
public:
|
2009-06-12 13:14:28 -04:00
|
|
|
wxPGVIteratorBase() { }
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual void Next() = 0;
|
|
|
|
protected:
|
|
|
|
virtual ~wxPGVIteratorBase() { }
|
|
|
|
|
|
|
|
wxPropertyGridIterator m_it;
|
|
|
|
};
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Abstract implementation of a simple iterator. Can only be used
|
|
|
|
// to iterate in forward order, and only through the entire container.
|
|
|
|
// Used to have functions dealing with all properties work with both
|
|
|
|
// wxPropertyGrid and wxPropertyGridManager.
|
2008-09-12 16:57:41 -04:00
|
|
|
class WXDLLIMPEXP_PROPGRID wxPGVIterator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxPGVIterator() { m_pIt = NULL; }
|
|
|
|
wxPGVIterator( wxPGVIteratorBase* obj ) { m_pIt = obj; }
|
|
|
|
~wxPGVIterator() { UnRef(); }
|
|
|
|
void UnRef() { if (m_pIt) m_pIt->DecRef(); }
|
|
|
|
wxPGVIterator( const wxPGVIterator& it )
|
|
|
|
{
|
|
|
|
m_pIt = it.m_pIt;
|
|
|
|
m_pIt->IncRef();
|
|
|
|
}
|
|
|
|
const wxPGVIterator& operator=( const wxPGVIterator& it )
|
|
|
|
{
|
2008-11-16 13:03:08 -05:00
|
|
|
if (this != &it)
|
|
|
|
{
|
|
|
|
UnRef();
|
|
|
|
m_pIt = it.m_pIt;
|
|
|
|
m_pIt->IncRef();
|
|
|
|
}
|
2008-09-12 16:57:41 -04:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// 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.
|
|
|
|
// - Currently this class is not implemented in wxPython.
|
2008-09-12 16:57:41 -04:00
|
|
|
class WXDLLIMPEXP_PROPGRID wxPropertyGridPageState
|
|
|
|
{
|
|
|
|
friend class wxPropertyGrid;
|
|
|
|
friend class wxPropertyGridInterface;
|
|
|
|
friend class wxPropertyGridPage;
|
|
|
|
friend class wxPropertyGridManager;
|
|
|
|
public:
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Default constructor.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPropertyGridPageState();
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Destructor.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual ~wxPropertyGridPageState();
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Makes sure all columns have minimum width.
|
2008-09-12 16:57:41 -04:00
|
|
|
void CheckColumnWidths( int widthChange = 0 );
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Override this member function to add custom behaviour on property
|
|
|
|
// deletion.
|
2008-12-11 12:11:35 -05:00
|
|
|
virtual void DoDelete( wxPGProperty* item, bool doDelete = true );
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
wxSize DoFitColumns( bool allowGridResize = false );
|
|
|
|
|
|
|
|
wxPGProperty* DoGetItemAtY( int y ) const;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Override this member function to add custom behaviour on property
|
|
|
|
// insertion.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual wxPGProperty* DoInsert( wxPGProperty* parent,
|
|
|
|
int index,
|
|
|
|
wxPGProperty* property );
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// This needs to be overridden in grid used the manager so that splitter
|
|
|
|
// changes can be propagated to other pages.
|
2008-09-12 16:57:41 -04:00
|
|
|
virtual void DoSetSplitterPosition( int pos,
|
|
|
|
int splitterColumn = 0,
|
2009-12-13 07:00:04 -05:00
|
|
|
int flags = 0 );
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
bool EnableCategories( bool enable );
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Make sure virtual height is up-to-date.
|
2008-09-12 16:57:41 -04:00
|
|
|
void EnsureVirtualHeight()
|
|
|
|
{
|
|
|
|
if ( m_vhCalcPending )
|
|
|
|
{
|
|
|
|
RecalculateVirtualHeight();
|
2014-09-25 13:29:50 -04:00
|
|
|
m_vhCalcPending = false;
|
2008-09-12 16:57:41 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Returns (precalculated) height of contained visible properties.
|
2008-09-12 16:57:41 -04:00
|
|
|
unsigned int GetVirtualHeight() const
|
|
|
|
{
|
|
|
|
wxASSERT( !m_vhCalcPending );
|
|
|
|
return m_virtualHeight;
|
|
|
|
}
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Returns (precalculated) height of contained visible properties.
|
2008-09-12 16:57:41 -04:00
|
|
|
unsigned int GetVirtualHeight()
|
|
|
|
{
|
|
|
|
EnsureVirtualHeight();
|
|
|
|
return m_virtualHeight;
|
|
|
|
}
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Returns actual height of contained visible properties.
|
|
|
|
// Mostly used for internal diagnostic purposes.
|
2019-05-25 19:13:08 -04:00
|
|
|
unsigned int GetActualVirtualHeight() const;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
unsigned int GetColumnCount() const
|
|
|
|
{
|
2008-10-12 08:23:48 -04:00
|
|
|
return (unsigned int) m_colWidths.size();
|
2008-09-12 16:57:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int GetColumnMinWidth( int column ) const;
|
|
|
|
|
|
|
|
int GetColumnWidth( unsigned int column ) const
|
|
|
|
{
|
|
|
|
return m_colWidths[column];
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPropertyGrid* GetGrid() const { return m_pPropGrid; }
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Returns last item which could be iterated using given flags.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT );
|
|
|
|
|
|
|
|
const wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ) const
|
|
|
|
{
|
|
|
|
return ((wxPropertyGridPageState*)this)->GetLastItem(flags);
|
|
|
|
}
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Returns currently selected property.
|
2009-08-17 14:36:00 -04:00
|
|
|
wxPGProperty* GetSelection() const
|
|
|
|
{
|
2015-05-24 14:36:16 -04:00
|
|
|
return m_selection.empty()? NULL: m_selection[0];
|
2009-08-17 14:36:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void DoSetSelection( wxPGProperty* prop )
|
|
|
|
{
|
|
|
|
m_selection.clear();
|
|
|
|
if ( prop )
|
|
|
|
m_selection.push_back(prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DoClearSelection()
|
|
|
|
{
|
|
|
|
return DoSelectProperty(NULL);
|
|
|
|
}
|
|
|
|
|
2009-08-18 10:28:08 -04:00
|
|
|
void DoRemoveFromSelection( wxPGProperty* prop );
|
|
|
|
|
2010-02-14 09:09:06 -05:00
|
|
|
void DoSetColumnProportion( unsigned int column, int proportion );
|
|
|
|
|
2010-02-16 10:38:12 -05:00
|
|
|
int DoGetColumnProportion( unsigned int column ) const
|
|
|
|
{
|
|
|
|
return m_columnProportions[column];
|
|
|
|
}
|
|
|
|
|
2010-02-16 11:24:30 -05:00
|
|
|
void ResetColumnSizes( int setSplitterFlags );
|
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPropertyCategory* GetPropertyCategory( const wxPGProperty* p ) const;
|
|
|
|
|
2015-01-13 11:41:33 -05:00
|
|
|
#if WXWIN_COMPATIBILITY_3_0
|
2014-07-14 13:18:58 -04:00
|
|
|
wxDEPRECATED_MSG("don't refer directly to wxPropertyGridPageState::GetPropertyByLabel")
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPGProperty* GetPropertyByLabel( const wxString& name,
|
|
|
|
wxPGProperty* parent = NULL ) const;
|
2014-07-14 13:18:58 -04:00
|
|
|
#endif // WXWIN_COMPATIBILITY_3_0
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
wxVariant DoGetPropertyValues( const wxString& listname,
|
|
|
|
wxPGProperty* baseparent,
|
|
|
|
long flags ) const;
|
|
|
|
|
|
|
|
wxPGProperty* DoGetRoot() const { return m_properties; }
|
|
|
|
|
2008-09-29 13:01:04 -04:00
|
|
|
void DoSetPropertyName( wxPGProperty* p, const wxString& newName );
|
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
// Returns combined width of margin and all the columns
|
|
|
|
int GetVirtualWidth() const
|
|
|
|
{
|
|
|
|
return m_width;
|
|
|
|
}
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Returns minimal width for given column so that all images and texts
|
|
|
|
// will fit entirely.
|
|
|
|
// Used by SetSplitterLeft() and DoFitColumns().
|
2008-09-12 16:57:41 -04:00
|
|
|
int GetColumnFitWidth(wxClientDC& dc,
|
|
|
|
wxPGProperty* pwc,
|
|
|
|
unsigned int col,
|
|
|
|
bool subProps) const;
|
|
|
|
|
2013-08-06 09:05:42 -04:00
|
|
|
int GetColumnFullWidth(wxClientDC &dc, wxPGProperty *p, unsigned int col);
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Returns information about arbitrary position in the grid.
|
|
|
|
// pt - Logical coordinates in the virtual grid space. Use
|
|
|
|
// wxScrolled<T>::CalcUnscrolledPosition() if you need to
|
|
|
|
// translate a scrolled position into a logical one.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Returns true if page is visibly displayed.
|
2019-05-25 19:13:08 -04:00
|
|
|
bool IsDisplayed() const;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
|
|
|
bool IsInNonCatMode() const { return (bool)(m_properties == m_abcArray); }
|
|
|
|
|
|
|
|
void DoLimitPropertyEditing( wxPGProperty* p, bool limit = true )
|
|
|
|
{
|
|
|
|
p->SetFlagRecursively(wxPG_PROP_NOEDITOR, limit);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 );
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// widthChange is non-client.
|
2008-09-12 16:57:41 -04:00
|
|
|
void OnClientWidthChange( int newWidth,
|
|
|
|
int widthChange,
|
|
|
|
bool fromOnResize = false );
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Recalculates m_virtualHeight.
|
2008-09-12 16:57:41 -04:00
|
|
|
void RecalculateVirtualHeight()
|
|
|
|
{
|
|
|
|
m_virtualHeight = GetActualVirtualHeight();
|
|
|
|
}
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Set virtual width for this particular page.
|
2008-09-12 16:57:41 -04:00
|
|
|
void SetVirtualWidth( int width );
|
|
|
|
|
2009-01-10 10:16:03 -05:00
|
|
|
void DoSortChildren( wxPGProperty* p, int flags = 0 );
|
|
|
|
void DoSort( int flags = 0 );
|
|
|
|
|
|
|
|
bool PrepareAfterItemsAdded();
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Called after virtual height needs to be recalculated.
|
2008-09-12 16:57:41 -04:00
|
|
|
void VirtualHeightChanged()
|
|
|
|
{
|
2014-09-25 13:29:50 -04:00
|
|
|
m_vhCalcPending = true;
|
2008-09-12 16:57:41 -04:00
|
|
|
}
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Base append.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPGProperty* DoAppend( wxPGProperty* property );
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Returns property by its name.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPGProperty* BaseGetPropertyByName( const wxString& name ) const;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Called in, for example, wxPropertyGrid::Clear.
|
2008-09-12 16:57:41 -04:00
|
|
|
void DoClear();
|
|
|
|
|
2009-08-17 14:36:00 -04:00
|
|
|
bool DoIsPropertySelected( wxPGProperty* prop ) const;
|
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
bool DoCollapse( wxPGProperty* p );
|
|
|
|
|
|
|
|
bool DoExpand( wxPGProperty* p );
|
|
|
|
|
|
|
|
void CalculateFontAndBitmapStuff( int vspacing );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2009-09-06 03:51:35 -04:00
|
|
|
// Utility to check if two properties are visibly next to each other
|
|
|
|
bool ArePropertiesAdjacent( wxPGProperty* prop1,
|
|
|
|
wxPGProperty* prop2,
|
|
|
|
int iterFlags = wxPG_ITERATE_VISIBLE ) const;
|
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
int DoGetSplitterPosition( int splitterIndex = 0 ) const;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Returns column at x coordinate (in GetGrid()->GetPanel()).
|
|
|
|
// pSplitterHit - Give pointer to int that receives index to splitter that is at x.
|
|
|
|
// pSplitterHitOffset - Distance from said splitter.
|
2008-09-12 16:57:41 -04:00
|
|
|
int HitTestH( int x, int* pSplitterHit, int* pSplitterHitOffset ) const;
|
|
|
|
|
2008-10-14 13:15:59 -04:00
|
|
|
bool PrepareToAddItem( wxPGProperty* property,
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPGProperty* scheduledParent );
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Returns property by its label.
|
2014-07-14 13:18:58 -04:00
|
|
|
wxPGProperty* BaseGetPropertyByLabel( const wxString& label,
|
|
|
|
wxPGProperty* parent = NULL ) const;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Unselect sub-properties.
|
2014-10-31 12:04:44 -04:00
|
|
|
void DoRemoveChildrenFromSelection(wxPGProperty* p, bool recursive,
|
|
|
|
int selFlags);
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Mark sub-properties as being deleted.
|
2014-10-31 12:04:44 -04:00
|
|
|
void DoMarkChildrenAsDeleted(wxPGProperty* p, bool recursive);
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Rename the property
|
|
|
|
// so it won't remain in the way of the user code.
|
2014-11-10 11:41:07 -05:00
|
|
|
void DoInvalidatePropertyName(wxPGProperty* p);
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Rename sub-properties
|
|
|
|
// so it won't remain in the way of the user code.
|
2014-11-10 11:41:07 -05:00
|
|
|
void DoInvalidateChildrenNames(wxPGProperty* p, bool recursive);
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Check if property contains given sub-category.
|
2014-11-10 11:46:16 -05:00
|
|
|
bool IsChildCategory(wxPGProperty* p,
|
|
|
|
wxPropertyCategory* cat, bool recursive);
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// If visible, then this is pointer to wxPropertyGrid.
|
|
|
|
// This shall *never* be NULL to indicate that this state is not visible.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPropertyGrid* m_pPropGrid;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Pointer to currently used array.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPGProperty* m_properties;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Array for categoric mode.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPGRootProperty m_regularArray;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Array for root of non-categoric mode.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPGRootProperty* m_abcArray;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Dictionary for name-based access.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPGHashMapS2P m_dictName;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// List of column widths (first column does not include margin).
|
2018-11-01 13:22:22 -04:00
|
|
|
wxVector<int> m_colWidths;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// List of indices of columns the user can edit by clicking it.
|
2018-11-01 13:22:22 -04:00
|
|
|
wxVector<int> m_editableColumns;
|
2009-08-23 11:31:03 -04:00
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Column proportions.
|
2018-11-01 13:22:22 -04:00
|
|
|
wxVector<int> m_columnProportions;
|
2010-02-14 09:09:06 -05:00
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
double m_fSplitterX;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Most recently added category.
|
2008-09-12 16:57:41 -04:00
|
|
|
wxPropertyCategory* m_currentCategory;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Array of selected property.
|
2009-08-17 14:36:00 -04:00
|
|
|
wxArrayPGProperty m_selection;
|
2008-09-12 16:57:41 -04:00
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Virtual width.
|
2008-09-12 16:57:41 -04:00
|
|
|
int m_width;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Indicates total virtual height of visible properties.
|
2008-09-12 16:57:41 -04:00
|
|
|
unsigned int m_virtualHeight;
|
|
|
|
|
2014-11-24 11:06:42 -05:00
|
|
|
#if WXWIN_COMPATIBILITY_3_0
|
2016-07-02 17:20:11 -04:00
|
|
|
// 1 if m_lastCaption is also the bottommost caption.
|
2008-09-12 16:57:41 -04:00
|
|
|
unsigned char m_lastCaptionBottomnest;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// 1 items appended/inserted, so stuff needs to be done before drawing;
|
|
|
|
// If m_virtualHeight == 0, then calcylatey's must be done.
|
|
|
|
// Otherwise just sort.
|
2008-09-12 16:57:41 -04:00
|
|
|
unsigned char m_itemsAdded;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// 1 if any value is modified.
|
2008-09-12 16:57:41 -04:00
|
|
|
unsigned char m_anyModified;
|
|
|
|
|
|
|
|
unsigned char m_vhCalcPending;
|
2014-09-25 13:29:50 -04:00
|
|
|
#else
|
2016-07-02 17:20:11 -04:00
|
|
|
// True if m_lastCaption is also the bottommost caption.
|
2014-09-25 13:29:50 -04:00
|
|
|
bool m_lastCaptionBottomnest;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// True: items appended/inserted, so stuff needs to be done before drawing;
|
|
|
|
// If m_virtualHeight == 0, then calcylatey's must be done.
|
|
|
|
// Otherwise just sort.
|
2014-09-25 13:29:50 -04:00
|
|
|
bool m_itemsAdded;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// True if any value is modified.
|
2014-09-25 13:29:50 -04:00
|
|
|
bool m_anyModified;
|
|
|
|
|
|
|
|
bool m_vhCalcPending;
|
|
|
|
#endif // WXWIN_COMPATIBILITY_3_0
|
2009-01-31 06:48:28 -05:00
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// True if splitter has been pre-set by the application.
|
2009-10-11 11:30:03 -04:00
|
|
|
bool m_isSplitterPreSet;
|
|
|
|
|
2016-07-02 17:20:11 -04:00
|
|
|
// Used to (temporarily) disable splitter centering.
|
2009-10-11 11:30:03 -04:00
|
|
|
bool m_dontCenterSplitter;
|
|
|
|
|
2009-01-31 06:48:28 -05:00
|
|
|
private:
|
2016-07-02 17:20:11 -04:00
|
|
|
// Only inits arrays, doesn't migrate things or such.
|
2009-01-31 06:48:28 -05:00
|
|
|
void InitNonCatMode();
|
2008-09-12 16:57:41 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-09-17 11:00:00 -04:00
|
|
|
#endif // wxUSE_PROPGRID
|
|
|
|
|
2008-09-12 16:57:41 -04:00
|
|
|
#endif // _WX_PROPGRID_PROPGRIDPAGESTATE_H_
|