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

📄 propdev.h

📁 非常好用的可移植的多平台C/C++源代码编辑器
💻 H
📖 第 1 页 / 共 4 页
字号:
    } \
    m_value.m_colour = *pval; \
    wxPG_SetVariantWxObjectValue(); \
    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 wxPGVariant(&m_value.m_colour); \
} \
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,ITEMCOUNT) \
    WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR2(NAME,wxPG_PROPCLASS(NAME),LABELS,VALUES,COLOURS,ITEMCOUNT)

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

// These may be useful for external properties (I think these could be any two values)
#define wxPG_SUBID1                     11485
#define wxPG_SUBID2                     11486

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

/** \class wxPGPaintData
    \ingroup classes
    \brief Contains information relayed to property's OnCustomPaint.
*/
struct wxPGPaintData
{
    /** wxPropertyGrid. */
    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;

};

#if defined(_WX_WINDOW_H_BASE_) // DOXYGEN


// -----------------------------------------------------------------------
// Some property class definitions (these should be useful to inherit from).
// -----------------------------------------------------------------------

// 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 arg_flags ) const;
    virtual bool SetValueFromString ( const wxString& text, int arg_flags );
    virtual bool SetValueFromInt ( long value, int arg_flags );

    //
    // 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 // wxPGProperty
{
    WX_PG_DECLARE_PROPERTY_CLASS()
public:

    wxEnumPropertyClass ( const wxString& label, const wxString& name, const wxChar** labels,
        const long* values = NULL, unsigned int itemcount = 0, int value = 0 );
    wxEnumPropertyClass ( const wxString& label, const wxString& name, 
        wxPGConstants& constants, 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_constants->GetCount(); }
    inline const wxArrayInt& GetValues() const { return m_constants->GetValues(); }

    inline wxPGConstants& GetChoices() const { return *m_constants; }

protected:
    wxPGConstants*          m_constants;
};

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

class WXDLLIMPEXP_PG wxFlagsPropertyClass : public wxPGPropertyWithChildren
{
    WX_PG_DECLARE_PROPERTY_CLASS()
public:

    wxFlagsPropertyClass ( const wxString& label, const wxString& name, const wxChar** labels,
        const long* values = NULL, unsigned int itemcount = 0, long value = 0 );
    wxFlagsPropertyClass ( const wxString& label, const wxString& name, 
        wxPGConstants& constants, long value = 0 );
    virtual ~wxFlagsPropertyClass ();

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

    // this is necessary for conveying m_constants
    virtual int GetChoiceInfo ( wxPGChoiceInfo* choiceinfo );

    // helpers
    inline size_t GetItemCount() const { return m_constants->GetCount(); }
    inline const wxArrayInt& GetValues() const { return m_constants->GetValues(); }
    inline const wxString& GetLabel( size_t ind ) const { return m_constants->GetLabel(ind); }

protected:
    wxPGConstants*          m_constants;

    long                    m_value;

    // Converts string id to a relevant bit.
    long IdToBit ( const wxString& id ) const;

    // Creates children and sets their 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 arg_flags ) const;
    virtual bool SetValueFromString ( const wxString& text, int flags );
    virtual bool OnEvent ( wxPropertyGrid* propgrid, wxPGCtrlClass* wnd_primary, wxEvent& event );

    virtual void SetAttribute ( int id, wxVariant value );

protected:
    wxString    m_wildcard;
    wxString    m_fnstr; // needed for return value
    wxFileName  m_filename; // used as primary storage
    int         m_indFilter; // index to the selected filter
};

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

//
// 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 wxPGProperty
{
    WX_PG_DECLARE_PROPERTY_CLASS()
public:

    wxLongStringPropertyClass ( const wxString& label, const wxString& name = wxPG_LABEL, const wxString& value = wxEmptyString );
    virtual ~wxLongStringPropertyClass ();

    virtual void DoSetValue ( wxPGVariant value );
    virtual wxPGVariant DoGetValue () const;
    virtual wxString GetValueAsString ( int arg_flags = 0 ) const;
    virtual bool SetValueFromString ( const wxString& text, int flags );
    virtual bool OnEvent ( wxPropertyGrid* propgrid, wxPGCtrlClass* wnd_primary, wxEvent& event );

    //  Shows string editor dialog. Value to be edited should be read from value, and
    //  if dialog is not cancelled, it should be stored back and TRUE should be returned
    //  if that was the case.
    virtual bool OnButtonClick ( wxPropertyGrid* propgrid, wxString& value );

protected:
    wxString    m_value;
};

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

class WXDLLIMPEXP_PG wxArrayStringPropertyClass : public wxPGProperty
{
    WX_PG_DECLARE_PROPERTY_CLASS()
public:

    wxArrayStringPropertyClass ( const wxString& label, const wxString& name,
        const wxArrayString& value );
    virtual ~wxArrayStringPropertyClass ();

    WX_PG_DECLARE_BASIC_TYPE_METHODS()
    WX_PG_DECLARE_EVENT_METHODS()
    virtual void GenerateValueAsString ();

    //  Shows string editor dialog. Value to be edited should be read from value, and
    //  if dialog is not cancelled, it should be stored back and TRUE should be returned
    //  if that was the case.
    virtual bool OnCustomStringEdit ( wxWindow* parent, wxString& value );

    // Helper.
    bool OnButtonClick ( wxPropertyGrid* propgrid, wxPGCtrlClass* primary,
        const wxChar* cbt );

protected:
    wxArrayString   m_value;
    wxString        m_display; // Cache for displayed text.
};

#define WX_PG_IMPLEMENT_ARRAYSTRING_PROPERTY(PROPNAME,DELIMCHAR,CUSTBUTTXT) \
class wxPG_PROPCLASS(PROPNAME) : public wxPG_PROPCLASS(wxArrayStringProperty) \
{ \
    WX_PG_DECLARE_PROPERTY_CLASS() \
public: \
    wxPG_PROPCLASS(PROPNAME) ( const wxString& label, const wxString& name, const wxArrayString& value ); \
    ~wxPG_PROPCLASS(PROPNAME) (); \
    virtual void GenerateValueAsString (); \
    virtual bool SetValueFromString ( const wxString& text, int ); \
    virtual bool OnEvent ( wxPropertyGrid* propgrid, wxPGCtrlClass* primary, wxEvent& event ); \
    virtual bool OnCustomStringEdit ( wxWindow* parent, wxString& value ); \
}; \
WX_PG_IMPLEMENT_PROPERTY_CLASS(PROPNAME,wxArrayString,const wxArrayString&,TextCtrlAndButton) \
wxPG_PROPCLASS(PROPNAME)::wxPG_PROPCLASS(PROPNAME) ( const wxString& label, const wxString& name, const wxArrayString& value ) \
    : wxPG_PROPCLASS(wxArrayStringProperty)(label,name,value) \
{ \
} \
wxPG_PROPCLASS(PROPNAME)::~wxPG_PROPCLASS(PROPNAME)() { } \
void wxPG_PROPCLASS(PROPNAME)::GenerateValueAsString () \
{ \
    wxChar delim_char = DELIMCHAR; \
    if ( delim_char == wxT('"') ) \
        wxPG_PROPCLASS(wxArrayStringProperty)::GenerateValueAsString(); \
    else \
        wxPropertyGrid::ArrayStringToString(m_display,m_value,0,DELIMCHAR,0); \
} \
bool wxPG_PROPCLASS(PROPNAME)::SetValueFromString ( const wxString& text, int ) \
{ \
    wxChar delim_char = DELIMCHAR; \
    if ( delim_char == wxT('"') ) \
        return wxPG_PROPCLASS(wxArrayStringProperty)::SetValueFromString(text,0); \
    \
    m_value.Empty(); \
    WX_PG_TOKENIZER1_BEGIN(text,DELIMCHAR) \
        m_value.Add ( token ); \
    WX_PG_TOKENIZER1_END() \
    GenerateValueAsString(); \
    return TRUE; \
} \
bool wxPG_PROPCLASS(PROPNAME)::OnEvent ( wxPropertyGrid* propgrid, wxPGCtrlClass* primary, wxEvent& event ) \
{ \
    if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) \
        return OnButtonClick(propgrid,primary,(const wxChar*) CUSTBUTTXT); \
    return FALSE; \
}


// -----------------------------------------------------------------------
// wxArrayEditorDialog
// -----------------------------------------------------------------------

#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/listbox.h>

#define wxAEDIALOG_STYLE \
    (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)

class WXDLLIMPEXP_PG wxArrayEditorDialog : public wxDialog
{
public:
    wxArrayEditorDialog();

    void Init();

    wxArrayEditorDialog(wxWindow *parent,
                              const wxString& message,
                              const wxString& caption,
                              long style = wxAEDIALOG_STYLE,
                              const wxPoint& pos = wxDefaultPosition,
                              const wxSize& sz = wxDefaultSize );

    bool Create(wxWindow *parent,
                const wxString& message,
                const wxString& caption,
                long style = wxAEDIALOG_STYLE,
                const wxPoint& pos = wxDefaultPosition,
                const wxSize& sz = wxDefaultSize );

    /*
    inline void SetCustomButton ( const wxChar* custBtText, wxArrayStringPropertyClass* pcc )
    {
        m_custBtText = custBtText;
        m_pCallingClass = pcc;
    }*/

    // Returns TRUE if array was actually modified
    bool IsModified() const { return m_modified; }

    //const wxArrayString& GetStrings() const { return m_array; }

    // implementation from now on
    void OnUpdateClick(wxCommandEvent& event);
    void OnAddClick(wxCommandEvent& event);
    void OnDeleteClick(wxCommandEvent& event);

⌨️ 快捷键说明

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