⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 propgrid.h

📁 非常好用的可移植的多平台C/C++源代码编辑器
💻 H
📖 第 1 页 / 共 5 页
字号:
    /** Does std validation process and if ok calls DoSetValue,
        otherwise shows the reported validation error.
    */
    bool StdValidationProcedure( wxPGVariant value );

#else

    inline bool StdValidationProcedure( wxPGVariant value )
    {
        DoSetValue( value );
        return TRUE;
    }

#endif

    /** Updates property value in case there were last minute
        changes. If value was unspecified, it will be set to default.
        Use only for properties that have TextCtrl-based editor.
        \remarks
        If you have code similar to
        \code
            // Update the value in case of last minute changes
            if ( primary && propgrid->IsEditorsValueModified() )
                 GetEditorClass()->CopyValueFromControl( this, primary );
        \endcode
        in wxPGProperty::OnEvent wxEVT_COMMAND_BUTTON_CLICKED handler,
        then replace it with call to this method.
        \retval
        True if value changed.
    */
    bool PrepareValueForDialogEditing( wxPropertyGrid* propgrid );

#if wxPG_USE_CLIENT_DATA
    inline void* GetClientData () const { return m_clientData; }
    inline void SetClientData ( void* clientData ) { m_clientData = clientData; }
#endif

    /** If is non-zero and found, then set choices to refer to that.
        If not, then creates new set of choices with given id.
        Returns id of created wxPGConstants.
    */
    size_t SetChoices ( size_t id, const wxArrayString& labels, const wxArrayInt& values );

    inline const wxString& GetHelpString () const { return m_helpString; }

    inline void ClearFlag( unsigned char flag ) { m_flags &= ~(flag); }

    // Use, for example, to detect if item is inside collapsed section.
    bool IsSomeParent ( wxPGProperty* candidate_parent ) const;

    // Shows error as a tooltip or something similar (depends on platform).
    void ShowError ( const wxString& msg );

protected:

    // Called in constructors.
    void Init ();

    wxString                    m_label;
//#if wxPG_EMBED_VARIANT
//    wxVariant                   m_variant;
//#else
    wxString                    m_name;
    wxPGPropertyWithChildren*   m_parent;
    wxString                    m_helpString; // Help shown in statusbar or help box.
#if wxPG_USE_CLIENT_DATA
    void*                       m_clientData;
#endif
#if wxPG_USE_VALIDATORS
    wxPropertyValidator*        m_validator;
#endif
    unsigned int                m_arrIndex; // Index in parent.
    int                         m_y; // This could be short int.
    unsigned char               m_flags; // This could be short int.

    // 1 = category
    // 0 = no children
    // -1 = has fixed-set of sub-properties
    // -2 = this is wxCustomProperty (sub-properties can be added)
    signed char                 m_parentingType;

    unsigned char               m_depth; // Root has 0, categories etc. at that level 1, etc.

    // m_depthBgCol indicates width of background colour between margin and item
    // (essentially this is category's depth, if none then equals m_depth).
    unsigned char               m_depthBgCol;

    unsigned char               m_bgColIndex; // Cell background brush index.

};

//
// wxPGId comparison operators.
// TODO: Are these really used?
//

inline bool operator==(const wxPGId& id, const wxString& b)
{
    wxASSERT (wxPGIdIsOk(id));
    const wxString& a = id.GetProperty().GetName();
    return (a.Len() == b.Len()) && (a.Cmp(b) == 0);
}

inline bool operator==(const wxPGId& id, const wxChar* b)
{
    wxASSERT (wxPGIdIsOk(id));
    return id.GetProperty().GetName().Cmp(b) == 0;
}


// For dual-pointer-usage reasons, we need to use this trickery
// instead of wxObjArray. wxPGValueType hash map is declared
// in propdev.h.
typedef wxArrayPtrVoid wxPGArrayProperty;

// It was reported that the alternative does not work with GCC 4.1
#if wxUSE_UNICODE || wxCHECK_GCC_VERSION(4,0) || wxUSE_STL

// Always use wxString based hashmap with unicode
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(void*,
                                     wxPGHashMapS2P,
                                     class WXDLLIMPEXP_PG);

# define wxPGNameStr            const wxString&
# define wxPGNameConv(STR)      STR

#else

WX_DECLARE_HASH_MAP_WITH_DECL(wxChar*,     // type of the keys
                              void*,                 // type of the values
                              wxStringHash,          // hasher
                              wxStringEqual,         // key equality predicate
                              wxPGHashMapS2P,       // name of the class
                              class WXDLLIMPEXP_PG);

# define wxPGNameStr         const wxChar*       // Should be same as hashmap type
# define wxPGNameConv(STR)   ((char * const)STR.c_str())

#endif

// -----------------------------------------------------------------------

// Hash map for int-to-int mapping
WX_DECLARE_HASH_MAP_WITH_DECL(size_t,
                              size_t,
                              wxIntegerHash,
                              wxIntegerEqual,
                              wxPGHashMapI2I,
                              class WXDLLIMPEXP_PG);

// -----------------------------------------------------------------------

#if !wxPG_EMBED_VARIANT
inline wxVariant wxPGProperty::GetValueAsVariant () const
{
    wxPGVariant value = DoGetValue();
    const wxPGValueType* typeclass = GetValueType();
    wxASSERT_MSG ( typeclass, wxT("Did you forgot to use wxPG_INIT_REQUIRED_TYPE(T) in constructor?") );
    return typeclass->GenerateVariant(value,m_name);
}
#endif

// -----------------------------------------------------------------------

/** \class wxPGPropertyWithChildren
    \ingroup classes
    \brief Base class for new properties that have sub-properties. For
    example, wxFontProperty and wxFlagsProperty descend from this class.
*/
class WXDLLIMPEXP_PG wxPGPropertyWithChildren : public wxPGProperty
{
    friend class wxPGProperty;
    friend class wxPropertyGridState;
    friend class wxPropertyGrid;
public:

    /** Special constructor only used in special cases. */
    wxPGPropertyWithChildren();

    /** When new class is derived, call this constructor.
        \param label
        Label for the property.
    */
    wxPGPropertyWithChildren( const wxString& label, const wxString& name );

    /** Destructor. */
    virtual ~wxPGPropertyWithChildren();

    //virtual int GetParentingType() const;

    /** Advanced variant of GetValueAsString() that forms a string that
        contains sequence of text representations of sub-properties.
    */
    // Advanced version that gives property list and index to this item
    virtual wxString GetValueAsString ( int arg_flags = 0 ) const;

    /** This overridden version converts comma or semicolon separated
        tokens into child values.
    */
    virtual bool SetValueFromString ( const wxString& text, int flags );

    /** Refresh values of child properties.
    */
    virtual void RefreshChildren();

    /** Called after child property p has been altered.
        The value of this parent property should now be updated accordingly.
    */
    virtual void ChildChanged ( wxPGProperty* p );

    /** Returns number of sub-properties. */
    inline size_t GetCount() const { return m_children.GetCount(); }

    /** Returns sub-property at index i. */
    inline wxPGProperty* Item ( size_t i ) const { return (wxPGProperty*)m_children.Item(i); }

    /** Returns last sub-property. */
    inline wxPGProperty* Last () const { return (wxPGProperty*)m_children.Last(); }

    /** Returns index of given sub-property. */
    inline int Index ( const wxPGProperty* p ) const { return m_children.Index((void*)p); }

    /** Deletes all sub-properties. */
    void Empty();

    inline bool IsExpanded() const
    {
        return ( m_expanded > 0 ) ? TRUE : FALSE;
    }

    wxPropertyGridState* GetParentState() const { return m_parentState; }

    // Puts correct indexes to children
    void FixIndexesOfChildren ( size_t starthere = 0 );

    wxPGProperty* GetItemAtY ( unsigned int y, unsigned int lh );

    void AddChild ( wxPGProperty* prop, int index = -1, bool correct_mode = TRUE );

    inline void SetParentState ( wxPropertyGridState* pstate ) { m_parentState = pstate; }

protected:

    wxPropertyGridState*    m_parentState;

    wxPGArrayProperty   m_children;
    unsigned char       m_expanded;
};


// -----------------------------------------------------------------------

/** \class wxPGRootPropertyClass
    \ingroup classes
    \brief Root parent property.
*/
class WXDLLIMPEXP_PG wxPGRootPropertyClass : public wxPGPropertyWithChildren
{
    WX_PG_DECLARE_PROPERTY_CLASS()
public:

    /** Constructor. */
    wxPGRootPropertyClass();
    virtual ~wxPGRootPropertyClass();

    /** Override this to return 1 (just in case). */
    //virtual int GetParentingType() const;

protected:
};

// -----------------------------------------------------------------------

/** \class wxPropertyCategoryClass
    \ingroup classes
    \brief Category property.
*/
class WXDLLIMPEXP_PG wxPropertyCategoryClass : public wxPGPropertyWithChildren
{
    WX_PG_DECLARE_PROPERTY_CLASS()
public:

    /** Special constructor only used in special cases. */
    wxPropertyCategoryClass();

    /** Construct.
        \param label
        Label for the category.
        \remarks
        All non-category properties appended will have most recently
        added category.
    */
    wxPropertyCategoryClass( const wxString& label, const wxString& name = wxPG_LABEL );
    ~wxPropertyCategoryClass();

    /** Must be overridden with function that doesn't do anything. */
    virtual wxString GetValueAsString ( int arg_flags ) const;

    //virtual int GetParentingType() const;

    inline int GetTextExtent() const { return m_textExtent; }

    void CalculateTextExtent ( wxWindow* wnd, wxFont& font );

protected:
    int m_textExtent; // pre-calculated length of text
};

// -----------------------------------------------------------------------

// Used to indicate wxPGConstants::Add etc that the value shall not be added
#define wxPG_INVALID_VALUE      2147483647

/** \class wxPGConstants
    \ingroup classes
    \brief Helper class for managing constant (key=value) sequences.
*/
class WXDLLIMPEXP_PG wxPGConstants
{
public:
    
    /** Basic constructor. */
    wxPGConstants();

    /** Constructor. */
    wxPGConstants( const wxChar** labels, const long* values = NULL, unsigned int itemcount = 0 );

    /** Constructor. */
    wxPGConstants( const wxArrayString& labels, const wxArrayInt& values = *((const wxArrayInt*)NULL) );

    /** Adds to current. If did not have own copies, creates them now. If was empty,
        identical to set except that creates copies.
    */
    void Add ( const wxChar** labels, const long* values = NULL, unsigned int itemcount = 0 );

    /** Version that works with wxArrayString. */
    void Add ( const wxArrayString& arr, const long* values = NULL );

    /** Version that works with wxArrayString and wxArrayInt. */
    void Add ( const wxArrayString& arr, const wxArrayInt& arrint );

    /** Adds single item. */
    void Add ( const wxChar* label, int value = wxPG_INVALID_VALUE );

    /** Returns reference to wxArrayString of labels for you to modify.
    */
    inline wxArrayString& GetLabels()
    {
        wxASSERT ( m_refCount != 0xFFFFFFF );
        return m_arrLabels;
    }

    /** Returns reference to wxArrayInt of values for you to modify.
    */
    inline wxArrayInt& GetValues()
    {
        wxASSERT ( m_refCount != 0xFFFFFFF );
        return m_arrValues;
    }

    /** Returns false if this is a constant empty set of choices,
        which should not be modified.
    */
    bool IsOk () const
    {
        return ( m_refCount != 0xFFFFFFF );
    }

    /** Returns TRUE if this is a temporary in-stack set of choices.
    */
    bool IsTemporary () const
    {
        return ( m_refCount == 0 );
    }

    /** Gets a unsigned number identifying this list. */
    size_t GetId() const { return m_id; };

    /** Does not create copies for itself. */
    void Set ( const wxChar** labels, const long* values = NULL, unsigned int 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -