📄 propdev.h
字号:
}; \
WX_PG_IMPLEMENT_DERIVED_TYPE(long_##NAME,long,DEFVAL) \
WX_PG_IMPLEMENT_PROPERTY_CLASS(NAME,wxFlagsProperty,long_##NAME,long,TextCtrl) \
CLASSNAME::CLASSNAME( const wxString& label, const wxString& name, long value ) \
: wxFlagsPropertyClass(label,name,LABELS,VALUES,value!=-1?value:DEFVAL) \
{ \
wxPG_INIT_REQUIRED_TYPE2(long_##NAME) \
m_flags |= wxPG_PROP_STATIC_CHOICES; \
} \
CLASSNAME::~CLASSNAME() { }
#define WX_PG_IMPLEMENT_CUSTOM_FLAGS_PROPERTY(NAME,LABELS,VALUES,DEFVAL) \
WX_PG_IMPLEMENT_CUSTOM_FLAGS_PROPERTY2(NAME,wxPG_PROPCLASS(NAME),LABELS,VALUES,DEFVAL)
// -----------------------------------------------------------------------
// This will create interface for Enum property derived class
// named CLASSNAME.
#define WX_PG_IMPLEMENT_CUSTOM_ENUM_PROPERTY2(NAME,CLASSNAME,LABELS,VALUES,DEFVAL) \
class CLASSNAME : public wxEnumPropertyClass \
{ \
WX_PG_DECLARE_PROPERTY_CLASS() \
public: \
CLASSNAME ( const wxString& label, const wxString& name, int value ); \
virtual ~CLASSNAME(); \
}; \
WX_PG_IMPLEMENT_DERIVED_TYPE(long_##NAME,long,DEFVAL) \
WX_PG_IMPLEMENT_PROPERTY_CLASS(NAME,wxEnumProperty,long_##NAME,int,Choice) \
CLASSNAME::CLASSNAME ( const wxString& label, const wxString& name, int value ) \
: wxEnumPropertyClass(label,name,LABELS,VALUES,value!=-1?value:DEFVAL) \
{ \
wxPG_INIT_REQUIRED_TYPE2(long_##NAME) \
m_flags |= wxPG_PROP_STATIC_CHOICES; \
} \
CLASSNAME::~CLASSNAME() { }
#define WX_PG_IMPLEMENT_CUSTOM_ENUM_PROPERTY(NAME,LABELS,VALUES,DEFVAL) \
WX_PG_IMPLEMENT_CUSTOM_ENUM_PROPERTY2(NAME,wxPG_PROPCLASS(NAME),LABELS,VALUES,DEFVAL)
// -----------------------------------------------------------------------
// Implementation for user wxColour editor property
#define WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY2(NAME,CLASSNAME,LABELS,VALUES,COLOURS) \
class CLASSNAME : public wxPG_PROPCLASS(wxSystemColourProperty) \
{ \
WX_PG_DECLARE_DERIVED_PROPERTY_CLASS() \
public: \
CLASSNAME( const wxString& label, const wxString& name, \
const wxColourPropertyValue& value ); \
virtual ~CLASSNAME (); \
virtual long GetColour ( int index ); \
}; \
static wxPGChoices gs_##NAME##_choicesCache; \
WX_PG_IMPLEMENT_DERIVED_PROPERTY_CLASS(NAME,wxSystemColourProperty,const wxColourPropertyValue&) \
CLASSNAME::CLASSNAME( const wxString& label, const wxString& name, \
const wxColourPropertyValue& value ) \
: wxPG_PROPCLASS(wxSystemColourProperty)(label,name,LABELS,VALUES,&gs_##NAME##_choicesCache,value ) \
{ \
wxPG_INIT_REQUIRED_TYPE(wxColourPropertyValue) \
m_flags |= wxPG_PROP_TRANSLATE_CUSTOM; \
DoSetValue ( &m_value ); \
} \
CLASSNAME::~CLASSNAME () { } \
long CLASSNAME::GetColour ( int index ) \
{ \
const wxArrayInt& values = GetValues(); \
if ( !values.GetCount() ) \
{ \
wxASSERT( index < (int)m_choices.GetCount() ); \
return COLOURS[index]; \
} \
return COLOURS[values[index]]; \
}
#define WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY(NAME,LABELS,VALUES,COLOURS) \
WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY2(NAME,wxPG_PROPCLASS(NAME),LABELS,VALUES,COLOURS)
// -----------------------------------------------------------------------
#define WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR2(NAME,CLASSNAME,LABELS,VALUES,COLOURS,EDITOR) \
class CLASSNAME : public wxPG_PROPCLASS(wxSystemColourProperty) \
{ \
WX_PG_DECLARE_PROPERTY_CLASS() \
public: \
CLASSNAME( const wxString& label, const wxString& name, \
const wxColour& value ); \
virtual ~CLASSNAME (); \
virtual void DoSetValue ( wxPGVariant value ); \
virtual wxPGVariant DoGetValue() const; \
virtual wxString GetValueAsString ( int argFlags ) const; \
virtual long GetColour ( int index ); \
}; \
static wxPGChoices gs_##NAME##_choicesCache; \
WX_PG_IMPLEMENT_PROPERTY_CLASS(NAME,wxSystemColourProperty,wxColour,const wxColour&,EDITOR) \
CLASSNAME::CLASSNAME( const wxString& label, const wxString& name, const wxColour& value ) \
: wxPG_PROPCLASS(wxSystemColourProperty)(label,name,LABELS,VALUES,&gs_##NAME##_choicesCache,value ) \
{ \
wxPG_INIT_REQUIRED_TYPE(wxColour) \
m_flags |= wxPG_PROP_TRANSLATE_CUSTOM; \
DoSetValue(&m_value.m_colour); \
} \
CLASSNAME::~CLASSNAME () { } \
void CLASSNAME::DoSetValue( wxPGVariant value ) \
{ \
wxColour* pval = wxPGVariantToWxObjectPtr(value, wxColour); \
wxCHECK_RET(pval, wxT("NULL wxColour pointer")); \
m_value.m_type = wxPG_COLOUR_CUSTOM; \
if ( m_flags & wxPG_PROP_TRANSLATE_CUSTOM ) \
{ \
int found_ind = ColToInd(*pval); \
if ( found_ind != wxNOT_FOUND ) m_value.m_type = found_ind; \
} \
m_value.m_colour = *pval; \
if ( m_value.m_type < wxPG_COLOUR_WEB_BASE ) \
wxPG_PROPCLASS(wxEnumProperty)::DoSetValue ( (long)m_value.m_type ); \
else \
m_index = GetItemCount()-1; \
} \
wxPGVariant CLASSNAME::DoGetValue () const \
{ \
return wxPGVariantCreator(m_value.m_colour); \
} \
wxString CLASSNAME::GetValueAsString ( int argFlags ) const \
{ \
const wxPGEditor* editor = GetEditorClass(); \
if ( editor != wxPG_EDITOR(Choice) && \
editor != wxPG_EDITOR(ChoiceAndButton) ) \
argFlags |= wxPG_PROPERTY_SPECIFIC; \
return wxSystemColourPropertyClass::GetValueAsString(argFlags); \
} \
long CLASSNAME::GetColour ( int index ) \
{ \
const wxArrayInt& values = GetValues(); \
if ( !values.GetCount() ) \
{ \
wxASSERT( index < (int)GetItemCount() ); \
return COLOURS[index]; \
} \
return COLOURS[values[index]]; \
}
#define WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR(NAME,LABELS,VALUES,COLOURS) \
WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR2(NAME,wxPG_PROPCLASS(NAME),LABELS,VALUES,COLOURS,Choice)
// -----------------------------------------------------------------------
//
// These macros helps creating DoGetValidator
#define WX_PG_DOGETVALIDATOR_ENTRY() \
WX_PG_GLOBALS_LOCKER() \
static wxValidator* s_ptr = (wxValidator*) NULL; \
if ( s_ptr ) return s_ptr;
// Common function exit
#define WX_PG_DOGETVALIDATOR_EXIT(VALIDATOR) \
s_ptr = VALIDATOR; \
wxPGGlobalVars->m_arrValidators.Add( (void*) VALIDATOR ); \
return VALIDATOR;
// -----------------------------------------------------------------------
//
// Ids for sub-controls
// NB: It should not matter what these are.
#define wxPG_SUBID1 11485
#define wxPG_SUBID2 11486
#define wxPG_SUBID_TEMP1 11487
// -----------------------------------------------------------------------
/** \class wxPGPaintData
\ingroup classes
\brief Contains information relayed to property's OnCustomPaint.
*/
struct wxPGPaintData
{
/** wxPropertyGrid. */
const wxPropertyGrid* m_parent;
/** Normally -1, otherwise index to drop-down list item that has to be drawn. */
int m_choiceItem;
/** Set to drawn width in OnCustomPaint (optional). */
int m_drawnWidth;
/** In a measure item call, set this to the height of item at m_choiceItem index. */
int m_drawnHeight;
};
// -----------------------------------------------------------------------
#ifndef SWIG
/** \class wxPGInDialogValidator
\ingroup classes
\brief Creates and manages a temporary wxTextCtrl for validation purposes.
Uses wxPropertyGrid's current editor, if available.
*/
class WXDLLIMPEXP_PG wxPGInDialogValidator
{
public:
wxPGInDialogValidator()
{
m_textCtrl = NULL;
}
~wxPGInDialogValidator()
{
if ( m_textCtrl )
m_textCtrl->Destroy();
}
bool DoValidate( wxPropertyGrid* propGrid, wxValidator* validator, const wxString& value );
private:
wxTextCtrl* m_textCtrl;
};
#endif
#ifndef DOXYGEN
// -----------------------------------------------------------------------
// Some property class definitions (these should be useful to inherit from).
// -----------------------------------------------------------------------
//#ifndef SWIG
#if 1
#define wxPG_PROP_PASSWORD wxPG_PROP_CLASS_SPECIFIC_2
class WXDLLIMPEXP_PG wxStringPropertyClass : public wxPGProperty
{
WX_PG_DECLARE_PROPERTY_CLASS_NOPARENS
public:
wxStringPropertyClass( const wxString& label, const wxString& name, const wxString& value );
virtual ~wxStringPropertyClass();
WX_PG_DECLARE_BASIC_TYPE_METHODS()
WX_PG_DECLARE_ATTRIBUTE_METHODS()
protected:
wxString m_value;
};
// -----------------------------------------------------------------------
// This provides base for wxEnumPropertyClass and any custom
// "dynamic" enum property classes.
class WXDLLIMPEXP_PG wxBaseEnumPropertyClass : public wxPGProperty
{
public:
wxBaseEnumPropertyClass( const wxString& label, const wxString& name );
virtual void DoSetValue( wxPGVariant value );
virtual wxPGVariant DoGetValue() const;
virtual wxString GetValueAsString( int argFlags ) const;
virtual bool SetValueFromString( const wxString& text, int argFlags );
virtual bool SetValueFromInt( long value, int argFlags );
//
// Additional virtuals
// This must be overridden to have non-index based value
virtual int GetIndexForValue( int value ) const;
// This returns string and value for index
// Returns NULL if beyond last item
// pvalue is never NULL - always set it.
virtual const wxString* GetEntry( size_t index, int* pvalue ) const = 0;
protected:
int m_index;
};
// -----------------------------------------------------------------------
// If set, then selection of choices is static and should not be
// changed (i.e. returns NULL in GetPropertyChoices).
#define wxPG_PROP_STATIC_CHOICES wxPG_PROP_CLASS_SPECIFIC_1
class WXDLLIMPEXP_PG wxEnumPropertyClass : public wxBaseEnumPropertyClass
{
WX_PG_DECLARE_PROPERTY_CLASS()
public:
#ifndef SWIG
wxEnumPropertyClass( const wxString& label, const wxString& name, const wxChar** labels,
const long* values = NULL, int value = 0 );
wxEnumPropertyClass( const wxString& label, const wxString& name,
wxPGChoices& choices, int value = 0 );
// Special constructor for caching choices (used by derived class)
wxEnumPropertyClass( const wxString& label, const wxString& name, const wxChar** labels,
const long* values, wxPGChoices* choicesCache, int value = 0 );
#endif
wxEnumPropertyClass( const wxString& label, const wxString& name,
const wxArrayString& labels, const wxArrayInt& values = wxArrayInt(), int value = 0 );
virtual ~wxEnumPropertyClass();
virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
virtual int GetIndexForValue( int value ) const;
virtual const wxString* GetEntry( size_t index, int* pvalue ) const;
inline size_t GetItemCount() const { return m_choices.GetCount(); }
inline const wxArrayInt& GetValues() const { return m_choices.GetValues(); }
protected:
wxPGChoices m_choices;
};
// -----------------------------------------------------------------------
class WXDLLIMPEXP_PG wxFlagsPropertyClass : public wxPGPropertyWithChildren
{
WX_PG_DECLARE_PROPERTY_CLASS()
public:
#ifndef SWIG
wxFlagsPropertyClass( const wxString& label, const wxString& name, const wxChar** labels,
const long* values = NULL, long value = 0 );
wxFlagsPropertyClass( const wxString& label, const wxString& name,
wxPGChoices& choices, long value = 0 );
#endif
wxFlagsPropertyClass( const wxString& label, const wxString& name,
const wxArrayString& labels, const wxArrayInt& values, int value = 0 );
virtual ~wxFlagsPropertyClass ();
virtual void DoSetValue( wxPGVariant value );
virtual wxPGVariant DoGetValue() const;
virtual wxString GetValueAsString( int argFlags ) const;
virtual bool SetValueFromString( const wxString& text, int flags );
virtual void ChildChanged( wxPGProperty* p );
virtual void RefreshChildren();
// this is necessary for conveying m_choices
virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
// helpers
inline size_t GetItemCount() const { return m_choices.GetCount(); }
inline const wxArrayInt& GetValues() const { return m_choices.GetValues(); }
inline const wxString& GetLabel( size_t ind ) const { return m_choices.GetLabel(ind); }
protected:
wxPGChoices m_choices;
// Used to detect if choices have been changed
wxPGChoicesData* m_oldChoicesData;
long m_value;
// Converts string id to a relevant bit.
long IdToBit( const wxString& id ) const;
// Creates children and sets value.
void Init();
};
// -----------------------------------------------------------------------
#include <wx/filename.h>
// Indicates first bit useable by derived properties.
#define wxPG_PROP_SHOW_FULL_FILENAME wxPG_PROP_CLASS_SPECIFIC_1
class WXDLLIMPEXP_PG wxFilePropertyClass : public wxPGProperty
{
WX_PG_DECLARE_PROPERTY_CLASS()
public:
wxFilePropertyClass( const wxString& label, const wxString& name = wxPG_LABEL,
const wxString& value = wxEmptyString );
virtual ~wxFilePropertyClass ();
virtual void DoSetValue( wxPGVariant value );
virtual wxPGVariant DoGetValue() const;
virtual wxString GetValueAsString( int argFlags ) const;
virtual bool SetValueFromString( const wxString& text, int flags );
virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* wnd_primary, wxEvent& event );
virtual void SetAttribute( int id, wxVariant& value );
#if wxUSE_VALIDATORS
static wxValidator* GetClassValidator();
virtual wxValidator* DoGetValidator() const;
#endif
protected:
wxString m_wildcard;
wxString m_fnstr; // needed for return value
wxString m_basePath; // If set, then show path relative to it
wxString m_initialPath; // If set, start the file dialog here
wxString m_dlgTitle; // If set, used as title for file dialog
wxFileName m_filename; // used as primary storage
int m_indFilter; // index to the selected filter
};
// -----------------------------------------------------------------------
#define wxPG_PROP_NO_ESCAPE wxPG_PROP_CLASS_SPECIFIC_1
//
// In wxTextCtrl, strings a space delimited C-like strings. For example:
// "String 1" "String 2" "String 3"
//
// To have " in a string, use \".
// To have \ in a string, use \\.
//
class WXDLLIMPEXP_PG wxLongStringPropertyClass : public wxBasePropertyClass
{
WX_PG_DECLARE_PROPERTY_CLASS()
public:
wxLongStringPropertyClass( const wxString& label, const wxString& name = wxPG_LABEL, const wxString& value = wxEmptyString );
virtual ~wxLongStringPropertyClass();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -