From 0fbc4cd6abe9944d0a4c76d4cb04fef51745f824 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 22 Dec 2018 12:30:05 +0100 Subject: [PATCH] Allow setting custom tooltip text for "New" button in wxPGArrayEditorDialog Ability to change the tooltip can be useful if standard text "New item" is not descriptive enough. --- docs/changes.txt | 2 ++ include/wx/propgrid/props.h | 14 ++++++++++++-- interface/wx/propgrid/props.h | 6 +++++- src/propgrid/props.cpp | 6 ++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index c3d49daf94..9c6647462b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -116,6 +116,8 @@ All (GUI): - Fix wxInfoBar close button size in high DPI (Stefan Ziegler). - Make disabling the window before creating it actually work. +- Allow changing tooltip text for button allowing to enter a new string + in wxPGArrayEditorDialog. 3.1.2: (released 2018-12-10) diff --git a/include/wx/propgrid/props.h b/include/wx/propgrid/props.h index a5c4a601d9..1a94a422b5 100644 --- a/include/wx/propgrid/props.h +++ b/include/wx/propgrid/props.h @@ -796,8 +796,7 @@ wxValidator* PROPNAME::DoGetValidator () const \ #if wxUSE_EDITABLELISTBOX -class WXDLLIMPEXP_FWD_CORE wxEditableListBox; -class WXDLLIMPEXP_FWD_CORE wxListEvent; +#include "wx/editlbox.h" #define wxAEDIALOG_STYLE \ (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE) @@ -829,6 +828,15 @@ public: m_hasCustomNewAction = true; } + void SetNewButtonText(const wxString& text) + { + m_customNewButtonText = text; + if ( m_elb && m_elb->GetNewButton() ) + { + m_elb->GetNewButton()->SetToolTip(text); + } + } + // Set value modified by dialog. virtual void SetDialogValue( const wxVariant& WXUNUSED(value) ) { @@ -880,6 +888,7 @@ protected: bool m_modified; bool m_hasCustomNewAction; + wxString m_customNewButtonText; // These must be overridden - must return true on success. virtual wxString ArrayGet( size_t index ) = 0; @@ -929,6 +938,7 @@ public: if ( !custBtText.empty() ) { EnableCustomNewAction(); + SetNewButtonText(custBtText); m_pCallingClass = pcc; } } diff --git a/interface/wx/propgrid/props.h b/interface/wx/propgrid/props.h index 564916c829..824581b2ae 100644 --- a/interface/wx/propgrid/props.h +++ b/interface/wx/propgrid/props.h @@ -726,7 +726,11 @@ public: const wxSize& sz = wxDefaultSize ); void EnableCustomNewAction(); - + + /** Sets tooltip text for button allowing the user to enter new string. + */ + void SetNewButtonText(const wxString& text); + /** Set value modified by dialog. */ virtual void SetDialogValue( const wxVariant& value ); diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index 9a530fe7cc..2587f841b5 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -2467,6 +2467,12 @@ bool wxPGArrayEditorDialog::Create( wxWindow *parent, wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE); + // Set custom text for "New" button, if provided + if ( !m_customNewButtonText.empty() ) + { + m_elb->GetNewButton()->SetToolTip(m_customNewButtonText); + } + // Populate the list box wxArrayString arr; for ( unsigned int i=0; i