From b06a9d227f64bc53a56dfaec502398cce67b6266 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 3 Aug 2019 20:47:06 +0200 Subject: [PATCH] Replace wxPG_FILE_DIALOG_TITLE and wxPG_DIR_DIALOG_MESSAGE attributes with wxPG_DIALOG_TITLE Current wxPG_FILE_DIALOG_TITLE and wxPG_DIR_DIALOG_MESSAGE attributes can be used to customize editor dialog titles only for wxFileProperty and wxDirProperty, respectively. New wxPG_DIALOG_TITLE property is applicable to all properties derived from wxEditorDialogProperty so not only editor dialog titles for wxFileProperty and wxDirProperty can be set but also for wxFontProperty, wxLongStringProperty, etc. wxPG_FILE_DIALOG_TITLE and wxPG_DIR_DIALOG_MESSAGE attributes are marked obsolete. --- docs/changes.txt | 1 + include/wx/propgrid/property.h | 29 +++++++++++++++++++-- include/wx/propgrid/props.h | 3 +++ interface/wx/propgrid/advprops.h | 15 +++++++++++ interface/wx/propgrid/property.h | 43 ++++++++++++++++++++++---------- interface/wx/propgrid/props.h | 20 +++++++++++---- samples/propgrid/propgrid.cpp | 6 ++--- src/propgrid/props.cpp | 14 +++++++++++ 8 files changed, 108 insertions(+), 23 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index f0c27d5995..f9b8dba0ad 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -146,6 +146,7 @@ All (GUI): - Allow changing tooltip text for button allowing to enter a new string in wxPGArrayEditorDialog. - Fix wxPropertyGrid issues with horizontal scrolling. +- Add wxPG_DIALOG_TITLE wxPGProperty attribute. wxGTK: diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index 711ca53a80..081b413d6c 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -448,6 +448,15 @@ wxPG_PROP_CLASS_SPECIFIC_3 = 0x00400000 // ----------------------------------------------------------------------- +// Helpers to mark macros as deprecated +#if defined(__clang__) || wxCHECK_GCC_VERSION(4, 5) +#define wxPG_STRINGIFY(X) #X +#define wxPG_DEPRECATED_MACRO_VALUE(value, msg) \ + _Pragma(wxPG_STRINGIFY(GCC warning msg)) value +#else +#define wxPG_DEPRECATED_MACRO_VALUE(value, msg) value +#endif // clang || GCC + // wxPGProperty::SetAttribute() and // wxPropertyGridInterface::SetPropertyAttribute() accept one of these as // attribute name argument. @@ -518,6 +527,10 @@ wxPG_PROP_CLASS_SPECIFIC_3 = 0x00400000 // Only wxPG_PREFIX_NONE works with Decimal and Octal numbers. #define wxPG_UINT_PREFIX wxS("Prefix") +// Specific to wxEditorDialogProperty and derivatives, wxString, default is empty. +// Sets a specific title for the editor dialog. +#define wxPG_DIALOG_TITLE wxS("DialogTitle") + // wxFileProperty/wxImageFileProperty specific, wxChar*, default is // detected/varies. // Sets the wildcard used in the triggered wxFileDialog. Format is the same. @@ -536,17 +549,29 @@ wxPG_PROP_CLASS_SPECIFIC_3 = 0x00400000 // Sets the initial path of where to look for files. #define wxPG_FILE_INITIAL_PATH wxS("InitialPath") +#if WXWIN_COMPATIBILITY_3_0 +#if wxCHECK_VISUALC_VERSION(10) +#pragma deprecated(wxPG_FILE_DIALOG_TITLE) +#endif // Specific to wxFileProperty and derivatives, wxString, default is empty. // Sets a specific title for the dir dialog. -#define wxPG_FILE_DIALOG_TITLE wxS("DialogTitle") +#define wxPG_FILE_DIALOG_TITLE wxPG_DEPRECATED_MACRO_VALUE(wxS("DialogTitle"),\ + "wxPG_FILE_DIALOG_TITLE is deprecated. Use wxPG_DIALOG_TITLE instead.") +#endif // WXWIN_COMPATIBILITY_3_0 // Specific to wxFileProperty and derivatives, long, default is 0. // Sets a specific wxFileDialog style for the file dialog, e.g. ::wxFD_SAVE. #define wxPG_FILE_DIALOG_STYLE wxS("DialogStyle") +#if WXWIN_COMPATIBILITY_3_0 +#if wxCHECK_VISUALC_VERSION(10) +#pragma deprecated(wxPG_DIR_DIALOG_MESSAGE) +#endif // Specific to wxDirProperty, wxString, default is empty. // Sets a specific message for the dir dialog. -#define wxPG_DIR_DIALOG_MESSAGE wxS("DialogMessage") +#define wxPG_DIR_DIALOG_MESSAGE wxPG_DEPRECATED_MACRO_VALUE(wxS("DialogMessage"),\ + "wxPG_DIR_DIALOG_MESSAGE is deprecated. Use wxPG_DIALOG_TITLE instead.") +#endif // WXWIN_COMPATIBILITY_3_0 // wxArrayStringProperty's string delimiter character. If this is // a quotation mark or hyphen, then strings will be quoted instead diff --git a/include/wx/propgrid/props.h b/include/wx/propgrid/props.h index fd1beef5fb..07647ddc70 100644 --- a/include/wx/propgrid/props.h +++ b/include/wx/propgrid/props.h @@ -583,6 +583,7 @@ public: virtual ~wxEditorDialogProperty(); virtual wxPGEditorDialogAdapter* GetEditorDialog() const wxOVERRIDE; + virtual bool DoSetAttribute(const wxString& name, wxVariant& value) wxOVERRIDE; protected: wxEditorDialogProperty(const wxString& label, const wxString& name); @@ -674,7 +675,9 @@ public: virtual wxString ValueToString(wxVariant& value, int argFlags = 0) const wxOVERRIDE; virtual bool StringToValue(wxVariant& variant, const wxString& text, int argFlags = 0) const wxOVERRIDE; +#if WXWIN_COMPATIBILITY_3_0 virtual bool DoSetAttribute(const wxString& name, wxVariant& value) wxOVERRIDE; +#endif // WXWIN_COMPATIBILITY_3_0 virtual wxValidator* DoGetValidator() const wxOVERRIDE; protected: diff --git a/interface/wx/propgrid/advprops.h b/interface/wx/propgrid/advprops.h index 1dec8f6b5f..e9a7754d39 100644 --- a/interface/wx/propgrid/advprops.h +++ b/interface/wx/propgrid/advprops.h @@ -65,6 +65,9 @@ public: /** @class wxFontProperty @ingroup classes Property representing wxFont. + + Supported special attributes: + - ::wxPG_DIALOG_TITLE: Sets a specific title for the font dialog (since 3.1.3). */ class wxFontProperty : public wxEditorDialogProperty { @@ -219,6 +222,17 @@ const wxString& wxPGGetDefaultImageWildcard(); /** @class wxImageFileProperty @ingroup classes Property representing image file(name). + + Supported special attributes: + - ::wxPG_DIALOG_TITLE: Sets a specific title for the file dialog (since 3.1.3). + - ::wxPG_FILE_DIALOG_STYLE: Sets a specific wxFileDialog style for the file dialog. + - ::wxPG_FILE_WILDCARD: Sets wildcard (see wxFileDialog for format details), "All + files..." is default. + - ::wxPG_FILE_SHOW_FULL_PATH: Default @true. When @false, only the file name is shown + (i.e. drive and directory are hidden). + - ::wxPG_FILE_SHOW_RELATIVE_PATH: If set, then the filename is shown relative to the + given path string. + - ::wxPG_FILE_INITIAL_PATH: Sets the initial path of where to look for files. */ class wxImageFileProperty : public wxFileProperty { @@ -253,6 +267,7 @@ protected: enter strings that are not in the list of choices. If this value is 1, user strings are preferably placed in front of valid choices. If value is 2, then those strings will placed behind valid choices. + - ::wxPG_DIALOG_TITLE: Sets a specific title for the editor dialog (since 3.1.3). */ class wxMultiChoiceProperty : public wxEditorDialogProperty { diff --git a/interface/wx/propgrid/property.h b/interface/wx/propgrid/property.h index ff6edffe23..d89f16101e 100644 --- a/interface/wx/propgrid/property.h +++ b/interface/wx/propgrid/property.h @@ -129,6 +129,13 @@ struct wxPGPaintData */ #define wxPG_UINT_PREFIX wxS("Prefix") +/** Built-in attribute specific to wxEditorDialogProperty and derivatives, + wxString, default is empty. Sets a specific title for the editor dialog. + + @since 3.1.3 +*/ +#define wxPG_DIALOG_TITLE wxS("DialogTitle") + /** wxFileProperty and wxImageFileProperty specific built-in attribute, @c wxChar*, default is detected/varies. Sets the wildcard used in the triggered wxFileDialog. Format is the same. @@ -152,11 +159,6 @@ struct wxPGPaintData */ #define wxPG_FILE_INITIAL_PATH wxS("InitialPath") -/** Built-in attribute specific to wxFileProperty and derivatives, wxString, - default is empty. Sets a specific title for the dir dialog. -*/ -#define wxPG_FILE_DIALOG_TITLE wxS("DialogTitle") - /** Built-in attribute specific to wxFileProperty and derivatives, @c long, default is 0. Sets a specific wxFileDialog style for the file dialog, e.g. ::wxFD_SAVE. @@ -165,11 +167,6 @@ struct wxPGPaintData */ #define wxPG_FILE_DIALOG_STYLE wxS("DialogStyle") -/** Built-in attribute specific to wxDirProperty, wxString, default is empty. - Sets a specific message for the dir dialog. -*/ -#define wxPG_DIR_DIALOG_MESSAGE wxS("DialogMessage") - /** Built-in attribute to set wxArrayStringProperty's string delimiter character. If this is a quotation mark or hyphen, then strings @@ -615,12 +612,15 @@ wxPG_PROP_CLASS_SPECIFIC_3 = 0x00400000 m_flags |= wxPG_PROP_NO_ESCAPE; @endcode + Supported special attributes: + - ::wxPG_DIALOG_TITLE: Sets a specific title for the text editor dialog. + @subsection wxDirProperty Like wxLongStringProperty, but the button triggers dir selector instead. Supported special attributes: - - ::wxPG_DIR_DIALOG_MESSAGE: Sets specific message in the dir selector. + - ::wxPG_DIALOG_TITLE: Sets specific title for the dir selector. @see @ref propgrid_property_attributes @subsection wxFileProperty @@ -630,6 +630,8 @@ wxPG_PROP_CLASS_SPECIFIC_3 = 0x00400000 ::wxPG_FILE_WILDCARD attribute. Supported special attributes: + - ::wxPG_DIALOG_TITLE: Sets a specific title for the file dialog. + - ::wxPG_FILE_DIALOG_STYLE: Sets a specific wxFileDialog style for the file dialog. - ::wxPG_FILE_WILDCARD: Sets wildcard (see wxFileDialog for format details), "All files..." is default. - ::wxPG_FILE_SHOW_FULL_PATH: Default @true. When @false, only the file name is shown @@ -637,8 +639,6 @@ wxPG_PROP_CLASS_SPECIFIC_3 = 0x00400000 - ::wxPG_FILE_SHOW_RELATIVE_PATH: If set, then the filename is shown relative to the given path string. - ::wxPG_FILE_INITIAL_PATH: Sets the initial path of where to look for files. - - ::wxPG_FILE_DIALOG_TITLE: Sets a specific title for the dir dialog. - - ::wxPG_FILE_DIALOG_STYLE: Sets a specific wxFileDialog style for the file dialog. @see @ref propgrid_property_attributes @subsection wxEnumProperty @@ -666,6 +666,7 @@ wxPG_PROP_CLASS_SPECIFIC_3 = 0x00400000 Supported special attributes: - ::wxPG_ARRAY_DELIMITER: Sets string delimiter character. + - ::wxPG_DIALOG_TITLE: Sets a specific title for the editor dialog. Default is comma (','). @see @ref propgrid_property_attributes @@ -702,6 +703,7 @@ wxPG_PROP_CLASS_SPECIFIC_3 = 0x00400000 enter strings that are not in the list of choices. If this value is 1, user strings are preferably placed in front of valid choices. If value is 2, then those strings will placed behind valid choices. + - ::wxPG_DIALOG_TITLE: Sets a specific title for the editor dialog. @see @ref propgrid_property_attributes @subsection wxImageFileProperty @@ -710,6 +712,18 @@ wxPG_PROP_CLASS_SPECIFIC_3 = 0x00400000 but has thumbnail of the image in front of the filename and autogenerates wildcard from available image handlers. + Supported special attributes: + - ::wxPG_DIALOG_TITLE: Sets a specific title for the file dialog. + - ::wxPG_FILE_DIALOG_STYLE: Sets a specific wxFileDialog style for the file dialog. + - ::wxPG_FILE_WILDCARD: Sets wildcard (see wxFileDialog for format details), "All + files..." is default. + - ::wxPG_FILE_SHOW_FULL_PATH: Default @true. When @false, only the file name is shown + (i.e. drive and directory are hidden). + - ::wxPG_FILE_SHOW_RELATIVE_PATH: If set, then the filename is shown relative to the + given path string. + - ::wxPG_FILE_INITIAL_PATH: Sets the initial path of where to look for files. + @see @ref propgrid_property_attributes + @subsection wxColourProperty Useful alternate editor: Choice. @@ -728,6 +742,9 @@ wxPG_PROP_CLASS_SPECIFIC_3 = 0x00400000 Represents wxFont. Various sub-properties are used to edit individual subvalues. + Supported special attributes: + - ::wxPG_DIALOG_TITLE: Sets a specific title for the font dialog. + @subsection wxSystemColourProperty Represents wxColour and a system colour index. wxChoice is used to edit diff --git a/interface/wx/propgrid/props.h b/interface/wx/propgrid/props.h index 70fd14a2e5..fe486c9175 100644 --- a/interface/wx/propgrid/props.h +++ b/interface/wx/propgrid/props.h @@ -553,6 +553,9 @@ protected: having a button triggering an editor dialog, like e.g. wxLongStringProperty, wxDirProperty, wxFileProperty. + Supported special attributes: + - ::wxPG_DIALOG_TITLE: Sets a specific title for the editor dialog. + @since 3.1.3 */ class wxEditorDialogProperty : public wxPGProperty @@ -561,6 +564,7 @@ public: virtual ~wxEditorDialogProperty(); virtual wxPGEditorDialogAdapter* GetEditorDialog() const; + virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); protected: /** @@ -599,6 +603,9 @@ protected: Like wxLongStringProperty, but the button triggers file selector instead. Supported special attributes: + - ::wxPG_DIALOG_TITLE: Sets a specific title for the file dialog (since 3.1.3). + - ::wxPG_FILE_DIALOG_STYLE: Sets a specific wxFileDialog style for the file + dialog (since 2.9.4). - ::wxPG_FILE_WILDCARD: Sets wildcard (see wxFileDialog for format details), "All files..." is default. - ::wxPG_FILE_SHOW_FULL_PATH: Default @true. When @false, only the file name is @@ -606,9 +613,6 @@ protected: - ::wxPG_FILE_SHOW_RELATIVE_PATH: If set, then the filename is shown relative to the given path string. - ::wxPG_FILE_INITIAL_PATH: Sets the initial path of where to look for files. - - ::wxPG_FILE_DIALOG_TITLE: Sets a specific title for the dir dialog. - - ::wxPG_FILE_DIALOG_STYLE: Sets a specific wxFileDialog style for the file - dialog (since 2.9.4). */ class wxFileProperty : public wxEditorDialogProperty { @@ -650,6 +654,9 @@ protected: @ingroup classes Like wxStringProperty, but has a button that triggers a small text editor dialog. + + Supported special attributes: + - ::wxPG_DIALOG_TITLE: Sets a specific title for the text editor dialog (since 3.1.3). */ class wxLongStringProperty : public wxEditorDialogProperty { @@ -676,7 +683,7 @@ protected: instead. Supported special attributes: - - ::wxPG_DIR_DIALOG_MESSAGE: Sets specific message in the dir selector. + - ::wxPG_DIALOG_TITLE: Sets a specific title for the file dialog (since 3.1.3). */ class wxDirProperty : public wxEditorDialogProperty { @@ -689,7 +696,6 @@ public: virtual wxString ValueToString(wxVariant& value, int argFlags = 0) const; virtual bool StringToValue(wxVariant& variant, const wxString& text, int argFlags = 0) const; - virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); virtual wxValidator* DoGetValidator() const; protected: @@ -707,6 +713,10 @@ protected: /** @class wxArrayStringProperty @ingroup classes Property that manages a list of strings. + + Supported special attributes: + - ::wxPG_ARRAY_DELIMITER: Sets string delimiter character. + - ::wxPG_DIALOG_TITLE: Sets a specific title for the editor dialog (since 3.1.3). */ class wxArrayStringProperty : public wxEditorDialogProperty { diff --git a/samples/propgrid/propgrid.cpp b/samples/propgrid/propgrid.cpp index 2d89e03189..3292dc0438 100644 --- a/samples/propgrid/propgrid.cpp +++ b/samples/propgrid/propgrid.cpp @@ -1243,7 +1243,7 @@ void FormMain::PopulateWithExamples () pg->Append( prop ); prop->SetAttribute(wxPG_FILE_WILDCARD,"Text Files (*.txt)|*.txt"); - prop->SetAttribute(wxPG_FILE_DIALOG_TITLE,"Custom File Dialog Title"); + prop->SetAttribute(wxPG_DIALOG_TITLE,"Custom File Dialog Title"); prop->SetAttribute(wxPG_FILE_SHOW_FULL_PATH,false); #ifdef __WXMSW__ @@ -1359,8 +1359,8 @@ void FormMain::PopulateWithExamples () // is allowed (naturally, in this case property cannot be accessed by name). pg->Append( new wxDirProperty( "DirProperty", wxPG_LABEL, ::wxGetUserHome()) ); pg->SetPropertyAttribute( "DirProperty", - wxPG_DIR_DIALOG_MESSAGE, - "This is a custom dir dialog message" ); + wxPG_DIALOG_TITLE, + "This is a custom dir dialog title" ); // Add string property - first arg is label, second name, and third initial value pg->Append( new wxStringProperty ( "StringProperty", wxPG_LABEL ) ); diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index e8f5963b37..14689dba39 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -1938,6 +1938,7 @@ bool wxDirProperty::DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) return false; } +#if WXWIN_COMPATIBILITY_3_0 bool wxDirProperty::DoSetAttribute(const wxString& name, wxVariant& value) { if ( name == wxPG_DIR_DIALOG_MESSAGE ) @@ -1947,6 +1948,7 @@ bool wxDirProperty::DoSetAttribute(const wxString& name, wxVariant& value) } return wxEditorDialogProperty::DoSetAttribute(name, value); } +#endif // WXWIN_COMPATIBILITY_3_0 // ----------------------------------------------------------------------- // wxPGDialogAdapter @@ -2000,6 +2002,16 @@ wxPGEditorDialogAdapter* wxEditorDialogProperty::GetEditorDialog() const return new wxPGDialogAdapter(); } +bool wxEditorDialogProperty::DoSetAttribute(const wxString& name, wxVariant& value) +{ + if ( name == wxPG_DIALOG_TITLE ) + { + m_dlgTitle = value.GetString(); + return true; + } + return wxPGProperty::DoSetAttribute(name, value); +} + // ----------------------------------------------------------------------- // wxFileProperty // ----------------------------------------------------------------------- @@ -2184,11 +2196,13 @@ bool wxFileProperty::DoSetAttribute( const wxString& name, wxVariant& value ) m_initialPath = value.GetString(); return true; } +#if WXWIN_COMPATIBILITY_3_0 else if ( name == wxPG_FILE_DIALOG_TITLE ) { m_dlgTitle = value.GetString(); return true; } +#endif // WXWIN_COMPATIBILITY_3_0 else if ( name == wxPG_FILE_DIALOG_STYLE ) { m_dlgStyle = value.GetLong();