X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f3793429150870568992e96fedacbdf87c0c3340..2780d31b74cd415150d080ca9fe9c29428073587:/include/wx/propgrid/propgridiface.h diff --git a/include/wx/propgrid/propgridiface.h b/include/wx/propgrid/propgridiface.h index bace16830a..d71db90dea 100644 --- a/include/wx/propgrid/propgridiface.h +++ b/include/wx/propgrid/propgridiface.h @@ -4,7 +4,7 @@ // Author: Jaakko Salli // Modified by: // Created: 2008-08-24 -// RCS-ID: $Id: +// RCS-ID: $Id$ // Copyright: (c) Jaakko Salli // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// @@ -12,6 +12,8 @@ #ifndef __WX_PROPGRID_PROPGRIDIFACE_H__ #define __WX_PROPGRID_PROPGRIDIFACE_H__ +#if wxUSE_PROPGRID + #include "wx/propgrid/property.h" #include "wx/propgrid/propgridpagestate.h" @@ -116,10 +118,10 @@ typedef const wxPGPropArgCls& wxPGPropArg; WXDLLIMPEXP_PROPGRID void wxPGTypeOperationFailed( const wxPGProperty* p, - const wxChar* typestr, - const wxChar* op ); + const wxString& typestr, + const wxString& op ); WXDLLIMPEXP_PROPGRID -void wxPGGetFailed( const wxPGProperty* p, const wxChar* typestr ); +void wxPGGetFailed( const wxPGProperty* p, const wxString& typestr ); // ----------------------------------------------------------------------- @@ -167,20 +169,6 @@ public: /** Destructor */ virtual ~wxPropertyGridInterface() { } - /** Adds choice to a property that can accept one. - @remarks - - If you need to make sure that you modify only the set of choices of - a single property (and not also choices of other properties with - initially identical set), call - wxPropertyGrid::SetPropertyChoicesPrivate. - - This usually only works for wxEnumProperty and derivatives - (wxFlagsProperty can get accept new items but its items may not get - updated). - */ - void AddPropertyChoice( wxPGPropArg id, - const wxString& label, - int value = wxPG_INVALID_VALUE ); - /** Appends property to the list. @@ -218,11 +206,7 @@ public: /** Resets modified status of all properties. */ - void ClearModifiedStatus() - { - SetPropertyModifiedStatus(m_pState->m_properties, false); - m_pState->m_anyModified = false; - } + void ClearModifiedStatus(); /** Collapses given category or property with children. Returns true if actually collapses. @@ -261,14 +245,6 @@ public: */ void DeleteProperty( wxPGPropArg id ); - /** Deletes choice from a property. - - If selected item is deleted, then the value is set to unspecified. - - See AddPropertyChoice for more details. - */ - void DeletePropertyChoice( wxPGPropArg id, int index ); - /** Disables property. */ bool DisableProperty( wxPGPropArg id ) { return EnableProperty(id,false); } @@ -461,12 +437,6 @@ public: wxPGProperty* GetPropertyByName( const wxString& name, const wxString& subname ) const; - /** Returns writable reference to property's list of choices (and relevant - values). If property does not have any choices, will return reference - to an invalid set of choices that will return false on IsOk call. - */ - wxPGChoices& GetPropertyChoices( wxPGPropArg id ); - /** Returns property's editor. */ const wxPGEditor* GetPropertyEditor( wxPGPropArg id ) const { @@ -488,13 +458,6 @@ public: return p->GetValueImage(); } - /** Returns property's position under its parent. */ - unsigned int GetPropertyIndex( wxPGPropArg id ) - { - wxPG_PROP_ARG_CALL_PROLOG_RETVAL(INT_MAX) - return p->GetIndexInParent(); - } - /** Returns label of a property. */ const wxString& GetPropertyLabel( wxPGPropArg id ) { @@ -503,10 +466,9 @@ public: } /** Returns name of a property, by which it is globally accessible. */ - wxString GetPropertyName( wxPGPropArg id ) + wxString GetPropertyName( wxPGProperty* property ) { - wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString) - return p->GetName(); + return property->GetName(); } /** Returns parent item of a property. */ @@ -550,74 +512,65 @@ public: #endif bool GetPropertyValueAsBool( wxPGPropArg id ) const; double GetPropertyValueAsDouble( wxPGPropArg id ) const; - wxObject* GetPropertyValueAsWxObjectPtr( wxPGPropArg id ) const; - void* GetPropertyValueAsVoidPtr( wxPGPropArg id ) const; #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(TYPENAME, DEFVAL) \ wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \ - if ( p->m_value.GetType() != TYPENAME ) \ + wxString typeName(wxS(TYPENAME)); \ + wxVariant value = p->GetValue(); \ + if ( value.GetType() != typeName ) \ { \ - wxPGGetFailed(p, TYPENAME); \ + wxPGGetFailed(p, typeName); \ return DEFVAL; \ } #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(TYPENAME, DEFVAL) \ wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \ - if ( p->m_value.GetType() != TYPENAME ) \ + wxVariant value = p->GetValue(); \ + if ( value.GetType() != wxS(TYPENAME) ) \ return DEFVAL; \ wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const { - wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("arrstring"), + wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("arrstring", wxArrayString()) - return p->m_value.GetArrayString(); - } - - wxPoint GetPropertyValueAsPoint( wxPGPropArg id ) const - { - wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxPoint"), wxPoint()) - return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxPoint); - } - - wxSize GetPropertyValueAsSize( wxPGPropArg id ) const - { - wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxSize"), wxSize()) - return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxSize); + return value.GetArrayString(); } +#if wxUSE_LONGLONG_NATIVE wxLongLong_t GetPropertyValueAsLongLong( wxPGPropArg id ) const { - wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(wxT("wxLongLong"), + wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK("wxLongLong", (long) GetPropertyValueAsLong(id)) - return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxLongLong).GetValue(); + wxLongLong ll; + ll << value; + return ll.GetValue(); } wxULongLong_t GetPropertyValueAsULongLong( wxPGPropArg id ) const { - wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(wxT("wxULongLong"), + wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK("wxULongLong", (unsigned long) GetPropertyValueAsULong(id)) - return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxULongLong).GetValue(); + wxULongLong ull; + ull << value; + return ull.GetValue(); } +#endif wxArrayInt GetPropertyValueAsArrayInt( wxPGPropArg id ) const { - wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxArrayInt"), + wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("wxArrayInt", wxArrayInt()) - wxArrayInt arr = WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxArrayInt); + wxArrayInt arr; + arr << value; return arr; } #if wxUSE_DATETIME wxDateTime GetPropertyValueAsDateTime( wxPGPropArg id ) const { - wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxDateTime()) - - if ( wxStrcmp(p->m_value.GetType(), wxT("datetime")) != 0 ) - { - wxPGGetFailed(p, wxT("datetime")); - return wxDateTime(); - } - return p->m_value.GetDateTime(); + wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("datetime", + wxDateTime()) + return value.GetDateTime(); } #endif @@ -639,12 +592,6 @@ public: } #endif - wxString GetPropertyValueType( wxPGPropArg id ) - { - wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString) - return p->GetValueType(); - } - /** Returns currently selected property. */ wxPGProperty* GetSelection() const { @@ -754,15 +701,6 @@ public: return p->IsCategory(); } - /** Inserts choice to a property that can accept one. - - See AddPropertyChoice for more details. - */ - void InsertPropertyChoice( wxPGPropArg id, - const wxString& label, - int index, - int value = wxPG_INVALID_VALUE ); - /** Returns true if property is enabled. */ bool IsPropertyEnabled( wxPGPropArg id ) const { @@ -856,6 +794,9 @@ public: PageState = 0x08, /** Include splitter position. Stored for each page. */ SplitterPosState = 0x10, + /** Include description box size. + Only applies to wxPropertyGridManager. */ + DescBoxState = 0x20, /** Include all supported user editable state information. @@ -864,7 +805,8 @@ public: ExpandedState | ScrollPosState | PageState | - SplitterPosState + SplitterPosState | + DescBoxState }; /** @@ -937,6 +879,12 @@ public: DoSetPropertyAttribute(id,attrName,value,argFlags); } + /** Sets property attribute for all applicapple properties. + Be sure to use this method only after all properties have been + added to the grid. + */ + void SetPropertyAttributeAll( const wxString& attrName, wxVariant value ); + /** Sets attributes from a wxPGAttributeStorage. */ void SetPropertyAttributes( wxPGPropArg id, @@ -963,28 +911,6 @@ public: p->SetCell( column, new wxPGCell(text, bitmap, fgCol, bgCol) ); } - /** Set choices of a property to specified set of labels and values. - - @remarks - This operation clears the property value. - */ - void SetPropertyChoices( wxPGPropArg id, wxPGChoices& choices) - { - wxPG_PROP_ARG_CALL_PROLOG() - p->SetChoices(choices); - } - - - /** - If property's set of choices is shared, then calling this method - converts it to private. - */ - void SetPropertyChoicesExclusive( wxPGPropArg id ) - { - wxPG_PROP_ARG_CALL_PROLOG() - p->SetChoicesExclusive(); - } - #ifndef SWIG /** Sets client data (void*) of a property. @remarks @@ -1027,12 +953,19 @@ public: */ void SetPropertyLabel( wxPGPropArg id, const wxString& newproplabel ); - /** Set modified status of a property and all its children. + /** + Sets name of a property. + + @param id + Name or pointer of property which name to change. + + @param newName + New name for property. */ - void SetPropertyModifiedStatus( wxPGPropArg id, bool modified ) + void SetPropertyName( wxPGPropArg id, const wxString& newName ) { wxPG_PROP_ARG_CALL_PROLOG() - p->SetModifiedStatus(modified); + m_pState->DoSetPropertyName( p, newName ); } /** @@ -1153,7 +1086,13 @@ public: wxVariant v(value); SetPropVal( id, v ); } - void SetPropertyValue( wxPGPropArg id, const wxChar* value ) +#if wxUSE_WCHAR_T + void SetPropertyValue( wxPGPropArg id, const wchar_t* value ) + { + SetPropertyValueString( id, wxString(value) ); + } +#endif + void SetPropertyValue( wxPGPropArg id, const char* value ) { SetPropertyValueString( id, wxString(value) ); } @@ -1192,20 +1131,7 @@ public: SetPropVal( id, v ); } - /** Sets value (wxPoint&) of a property. - */ - void SetPropertyValue( wxPGPropArg id, const wxPoint& value ) - { - wxVariant v = WXVARIANT(value); - SetPropVal( id, v ); - } - /** Sets value (wxSize&) of a property. - */ - void SetPropertyValue( wxPGPropArg id, const wxSize& value ) - { - wxVariant v = WXVARIANT(value); - SetPropVal( id, v ); - } +#if wxUSE_LONGLONG_NATIVE /** Sets value (wxLongLong&) of a property. */ void SetPropertyValue( wxPGPropArg id, wxLongLong_t value ) @@ -1220,6 +1146,8 @@ public: wxVariant v = WXVARIANT(wxULongLong(value)); SetPropVal( id, v ); } +#endif + /** Sets value (wxArrayInt&) of a property. */ void SetPropertyValue( wxPGPropArg id, const wxArrayInt& value ) @@ -1511,6 +1439,27 @@ public: protected: + /** + In derived class, implement to set editable state component with + given name to given value. + */ + virtual bool SetEditableStateItem( const wxString& name, wxVariant value ) + { + wxUnusedVar(name); + wxUnusedVar(value); + return false; + } + + /** + In derived class, implement to return editable state component with + given name. + */ + virtual wxVariant GetEditableStateItem( const wxString& name ) const + { + wxUnusedVar(name); + return wxNullVariant; + } + // Returns page state data for given (sub) page (-1 means current page). virtual wxPropertyGridPageState* GetPageState( int pageIndex ) const { @@ -1556,4 +1505,6 @@ private: friend class wxPropertyGridManager; }; +#endif // wxUSE_PROPGRID + #endif // __WX_PROPGRID_PROPGRIDIFACE_H__