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

📄 propdev.h

📁 非常好用的可移植的多平台C/C++源代码编辑器
💻 H
📖 第 1 页 / 共 4 页
字号:
    void OnListBoxClick(wxCommandEvent& event);
    void OnUpClick(wxCommandEvent& event);
    void OnDownClick(wxCommandEvent& event);
    //void OnCustomEditClick(wxCommandEvent& event);
    void OnIdle(wxIdleEvent& event);

protected:
    wxTextCtrl*     m_edValue;
    wxListBox*      m_lbStrings;

    wxButton*       m_butAdd;       // Button pointers
    wxButton*       m_butCustom;    // required for disabling/enabling changing.
    wxButton*       m_butUpdate;
    wxButton*       m_butRemove;
    wxButton*       m_butUp;
    wxButton*       m_butDown;

    //wxArrayString   m_array;

    const wxChar*   m_custBtText;
    //wxArrayStringPropertyClass*     m_pCallingClass;

    bool            m_modified;

    unsigned char   m_curFocus;

    // These must be overridden - must return TRUE on success.
    virtual wxString ArrayGet( size_t index ) = 0;
    virtual size_t ArrayGetCount() = 0;
    virtual bool ArrayInsert( const wxString& str, int index ) = 0;
    virtual bool ArraySet( size_t index, const wxString& str ) = 0;
    virtual void ArrayRemoveAt( int index ) = 0;
    virtual void ArraySwap( size_t first, size_t second ) = 0;

private:
    DECLARE_DYNAMIC_CLASS_NO_COPY(wxArrayEditorDialog)
    DECLARE_EVENT_TABLE()
};

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

/** This is a simple property which holds sub-properties. Has default editing
    textctrl based editing capability. In essence, it is a category that has
    look and feel of a property, and which children can be edited via the textctrl.
*/
class wxParentPropertyClass : public wxPGPropertyWithChildren
{
    WX_PG_DECLARE_PROPERTY_CLASS()
public:

    wxParentPropertyClass ( const wxString& label, const wxString& name = wxPG_LABEL );
    virtual ~wxParentPropertyClass ();

    virtual void DoSetValue ( wxPGVariant value );
    virtual wxPGVariant DoGetValue () const;
    virtual void ChildChanged ( wxPGProperty* p );

protected:
    wxString    m_string;
};

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

/** \class wxCustomPropertyClass
    \ingroup classes
    \brief This is a rather inefficient but very versatile property class.

   Base class offers the following:
     - Add any properties as children (i.e. like the old wxParentProperty)
     - Editor control can be set at run-time.
     - By default has string value type.
     - Has capacity to have choices.
     - Can have custom-paint bitmap.

   Also note:
     - Has m_parentingType of -2 (technical detail).
*/
class wxCustomPropertyClass : public wxPGPropertyWithChildren
{
    WX_PG_DECLARE_PROPERTY_CLASS()
public:

    wxCustomPropertyClass ( const wxString& label, const wxString& name = wxPG_LABEL );
    virtual ~wxCustomPropertyClass ();

    virtual void DoSetValue ( wxPGVariant value );
    virtual wxPGVariant DoGetValue () const;
    virtual bool SetValueFromString ( const wxString& text, int flags );
    virtual wxString GetValueAsString ( int arg_flags ) const;

    virtual bool OnEvent ( wxPropertyGrid* propgrid, wxPGCtrlClass* primary, wxEvent& event );

    WX_PG_DECLARE_CUSTOM_PAINT_METHODS()

    virtual bool SetValueFromInt ( long value, int );
    virtual int GetChoiceInfo ( wxPGChoiceInfo* choiceinfo );

    virtual void SetAttribute ( int id, wxVariant value );

protected:
    wxPGEditor*             m_editor;
    wxPGConstants*          m_constants;
    wxBitmap*               m_bitmap;
    wxPropertyGridCallback  m_callback;
    wxPGPaintCallback       m_paintCallback;

    wxString                m_value;
};

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

//
// Tokenizer macros.
// NOTE: I have made two versions - worse ones (performance and consistency
//   wise) use wxStringTokenizer and better ones (may have unfound bugs)
//   use custom code.
//

#include <wx/tokenzr.h>

// TOKENIZER1 can be done with wxStringTokenizer
#define WX_PG_TOKENIZER1_BEGIN(WXSTRING,DELIMITER) \
    wxStringTokenizer tkz(WXSTRING,DELIMITER,wxTOKEN_RET_EMPTY); \
    while ( tkz.HasMoreTokens() ) \
    { \
        wxString token = tkz.GetNextToken(); \
        token.Trim(TRUE); \
        token.Trim(FALSE);

#define WX_PG_TOKENIZER1_END() \
    }


/*#define WX_PG_TOKENIZER1_BEGIN(WXSTRING,DELIMITER) \
    const wxChar* ptr = WXSTRING.c_str(); \
    wxString token; \
    const wxChar* token_start = NULL; \
    wxChar a = 0; \
    do \
    { \
        a = *ptr; \
        while ( a == ' ' ) { ptr++; a = *ptr; } \
        token_start = ptr; \
        while ( a != DELIMITER && a != 0 ) { ptr++; a = *ptr; } \
        if ( ptr > token_start ) \
        { \
            unsigned int str_len = ptr-token_start; \
            wxChar* store_ptr = token.GetWriteBuf ( str_len+1 ); \
            wxTmemcpy ( store_ptr, token_start, str_len ); \
            store_ptr[str_len] = 0; \
            token.UngetWriteBuf ( str_len ); \
            token.Trim(); \
        } \
        else \
            token.Empty();

#define WX_PG_TOKENIZER1_END() \
        ptr++; \
    } while ( a );*/

/*

#define WX_PG_TOKENIZER2_BEGIN(WXSTRING,DELIMITER) \
    wxStringTokenizer tkz(WXSTRING,DELIMITER,wxTOKEN_RET_EMPTY); \
    int phase = 0; \
    while ( tkz.HasMoreTokens() ) \
    { \
        wxString token = tkz.GetNextToken(); \
        if ( phase != 0 ) \
        {

#define WX_PG_TOKENIZER2_END() \
            phase = -1; \
        } \
        phase += 1; \
    }

*/

//
// 2nd version: tokens are surrounded by DELIMITERs (for example, C-style strings).
// TOKENIZER2 must use custom code (a class) for full compliancy
// with " surrounded strings with \" inside.
//
// class implementation is in propgrid.cpp
//

class WXDLLIMPEXP_PG wxPGStringTokenizer
{
public:
    wxPGStringTokenizer(const wxString& str,
                        wxChar delimeter);
    ~wxPGStringTokenizer();

    bool HasMoreTokens(); // not const so we can do some stuff in it
    wxString GetNextToken();

protected:

    const wxString* m_str;
    const wxChar*   m_curPos;
#if wxUSE_STL
    //wxString        m_buffer;
#endif
    wxString        m_readyToken;
    wxChar          m_delimeter;
};

#define WX_PG_TOKENIZER2_BEGIN(WXSTRING,DELIMITER) \
    wxPGStringTokenizer tkz(WXSTRING,DELIMITER); \
    while ( tkz.HasMoreTokens() ) \
    { \
        wxString token = tkz.GetNextToken();

#define WX_PG_TOKENIZER2_END() \
    }

/*
#if wxUSE_STL

// 2nd version: tokens are surrounded by DELIMITERs (for example, C-style strings).
// TOKENIZER2 must use custom code for full compliancy
// with " surrounded strings with \" inside.
#define WX_PG_TOKENIZER2_BEGIN(WXSTRING,DELIMITER) \
    const wxChar* ptr = WXSTRING.c_str(); \
    wxString token; \
    wxStringBuffer strbuf(token,2048); \
    wxChar* store_ptr_start = NULL; \
    wxChar* store_ptr = NULL; \
    wxChar a = *ptr; \
    wxChar prev_a = 0; \
    while ( a ) \
    { \
        if ( !store_ptr_start ) \
        { \
            if ( a == DELIMITER ) \
            { \
                store_ptr_start = store_ptr = strbuf; \
                prev_a = 0; \
            } \
        } \
        else \
        { \
            if ( prev_a != wxT('\\') ) \
            { \
                if ( a != DELIMITER ) \
                { \
                    if ( a != wxT('\\') ) \
                    { \
                        *store_ptr = a; \
                        store_ptr++; \
                    } \
                } \
                else \
                { \
                    *store_ptr = 0; \
                    wxASSERT ( (store_ptr-store_ptr_start) < 2048 );

#define WX_PG_TOKENIZER2_END() \
                    store_ptr_start = NULL; \
                } \
                prev_a = a; \
            } \
            else \
            { \
                *store_ptr = a; \
                store_ptr++; \
                prev_a = 0; \
            } \
        } \
        ptr++; \
        a = *ptr; \
    }


#else // wxUSE_STL

//
// NON USE_STL COMPLIANT VERSION
//
// 2nd version: tokens are surrounded by DELIMITERs (for example, C-style strings).
// TOKENIZER2 must use custom code for full compliancy
// with " surrounded strings with \" inside.
#define WX_PG_TOKENIZER2_BEGIN(WXSTRING,DELIMITER) \
    const wxChar* ptr = WXSTRING.c_str(); \
    const wxChar* ptr_end = &ptr[WXSTRING.length()]; \
    wxString token; \
    wxChar* store_ptr_start = NULL; \
    wxChar* store_ptr = NULL; \
    wxChar a = *ptr; \
    wxChar prev_a = 0; \
    while ( a ) \
    { \
        if ( !store_ptr_start ) \
        { \
            if ( a == DELIMITER ) \
            { \
                store_ptr_start = store_ptr = token.GetWriteBuf ( ptr_end-ptr+1 ); \
                prev_a = 0; \
            } \
        } \
        else \
        { \
            if ( prev_a != wxT('\\') ) \
            { \
                if ( a != DELIMITER ) \
                { \
                    if ( a != wxT('\\') ) \
                    { \
                        *store_ptr = a; \
                        store_ptr++; \
                    } \
                } \
                else \
                { \
                    *store_ptr = 0; \
                    token.UngetWriteBuf ( store_ptr-store_ptr_start ); \

#define WX_PG_TOKENIZER2_END() \
                    store_ptr_start = NULL; \
                } \
                prev_a = a; \
            } \
            else \
            { \
                *store_ptr = a; \
                store_ptr++; \
                prev_a = 0; \
            } \
        } \
        ptr++; \
        a = *ptr; \
    } \
    if ( store_ptr_start ) \
        token.UngetWriteBuf ( store_ptr-store_ptr_start );

#endif // !wxUSE_STL

*/
// -----------------------------------------------------------------------

#endif // !DOXYGEN

#endif // _WX_PROPGRID_PROPDEV_H_

⌨️ 快捷键说明

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