Removed wxLongStringProperty derived property creator macros (just subclass and implement OnButtonClick()); Partially fixed wxPGProperty::PrepareValueForDialogEditing()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56147 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -38,43 +38,6 @@ WX_PG_IMPLEMENT_PROPERTY_CLASS2(NAME,NAME,UPNAME,T,T_AS_ARG,EDITOR)
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
#define wxPG_NO_ESCAPE wxPG_PROP_NO_ESCAPE // No escape sequences
|
|
||||||
#define wxPG_ESCAPE 0 // Escape sequences
|
|
||||||
|
|
||||||
#define WX_PG_DECLARE_STRING_PROPERTY_WITH_DECL(NAME, DECL) \
|
|
||||||
DECL NAME : public wxLongStringProperty \
|
|
||||||
{ \
|
|
||||||
DECLARE_DYNAMIC_CLASS(NAME) \
|
|
||||||
public: \
|
|
||||||
NAME( const wxString& name = wxPG_LABEL, \
|
|
||||||
const wxString& label = wxPG_LABEL, \
|
|
||||||
const wxString& value = wxEmptyString); \
|
|
||||||
virtual ~NAME(); \
|
|
||||||
virtual bool OnButtonClick( wxPropertyGrid* propgrid, wxString& value ); \
|
|
||||||
virtual wxValidator* DoGetValidator() const; \
|
|
||||||
};
|
|
||||||
|
|
||||||
#define WX_PG_DECLARE_STRING_PROPERTY(NAME) \
|
|
||||||
WX_PG_DECLARE_STRING_PROPERTY_WITH_DECL(NAME, class) \
|
|
||||||
|
|
||||||
#define WX_PG_IMPLEMENT_STRING_PROPERTY_WITH_VALIDATOR(NAME, FLAGS) \
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(NAME,wxLongStringProperty) \
|
|
||||||
NAME::NAME( const wxString& name, \
|
|
||||||
const wxString& label, \
|
|
||||||
const wxString& value ) \
|
|
||||||
: wxLongStringProperty(name,label,value) \
|
|
||||||
{ \
|
|
||||||
m_flags |= FLAGS; \
|
|
||||||
} \
|
|
||||||
NAME::~NAME() { }
|
|
||||||
|
|
||||||
#define WX_PG_IMPLEMENT_STRING_PROPERTY(NAME, FLAGS) \
|
|
||||||
WX_PG_IMPLEMENT_STRING_PROPERTY_WITH_VALIDATOR(NAME,FLAGS) \
|
|
||||||
wxValidator* NAME::DoGetValidator () const \
|
|
||||||
{ return (wxValidator*) NULL; }
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#define WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_WITH_DECL(CLASSNAME, DECL) \
|
#define WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_WITH_DECL(CLASSNAME, DECL) \
|
||||||
DECL CLASSNAME : public wxSystemColourProperty \
|
DECL CLASSNAME : public wxSystemColourProperty \
|
||||||
{ \
|
{ \
|
||||||
|
@@ -234,6 +234,40 @@
|
|||||||
dialog. Note that in long string values, tabs are represented by "\t" and
|
dialog. Note that in long string values, tabs are represented by "\t" and
|
||||||
line break by "\n".
|
line break by "\n".
|
||||||
|
|
||||||
|
To display custom dialog on button press, you can subclass
|
||||||
|
wxLongStringProperty and implement OnButtonClick, like this:
|
||||||
|
|
||||||
|
@code
|
||||||
|
virtual bool OnButtonClick( wxPropertyGrid* propGrid, wxString& value )
|
||||||
|
{
|
||||||
|
// Update property value from editor, if necessary
|
||||||
|
PrepareValueForDialogEditing(propGrid);
|
||||||
|
|
||||||
|
wxSize dialogSize(...size of your dialog...);
|
||||||
|
|
||||||
|
wxPoint dlgPos = propGrid->GetGoodEditorDialogPosition(this,
|
||||||
|
dialogSize)
|
||||||
|
|
||||||
|
// Create dialog dlg at dlgPos. Use value as initial string
|
||||||
|
// value.
|
||||||
|
...
|
||||||
|
|
||||||
|
if ( dlg.ShowModal() == wxID_OK )
|
||||||
|
{
|
||||||
|
value = dlg.GetStringValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
Also, if you wish not to have line breaks and tabs translated to
|
||||||
|
escape sequences, then do following in constructor of your subclass:
|
||||||
|
|
||||||
|
@code
|
||||||
|
m_flags |= wxPG_PROP_NO_ESCAPE;
|
||||||
|
@endcode
|
||||||
|
|
||||||
@subsection wxDirProperty
|
@subsection wxDirProperty
|
||||||
|
|
||||||
Like wxLongStringProperty, but the button triggers dir selector instead.
|
Like wxLongStringProperty, but the button triggers dir selector instead.
|
||||||
|
@@ -98,54 +98,6 @@ WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY(wxMyColour2Property,
|
|||||||
(long*)NULL,
|
(long*)NULL,
|
||||||
mycolprop_colours)
|
mycolprop_colours)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Just testing the macros
|
|
||||||
WX_PG_DECLARE_STRING_PROPERTY(wxTestStringProperty)
|
|
||||||
WX_PG_IMPLEMENT_STRING_PROPERTY(wxTestStringProperty,wxPG_NO_ESCAPE)
|
|
||||||
bool wxTestStringProperty::OnButtonClick( wxPropertyGrid*,
|
|
||||||
wxString& )
|
|
||||||
{
|
|
||||||
::wxMessageBox(wxT("Button Clicked"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
WX_PG_DECLARE_STRING_PROPERTY(wxTextStringPropertyWithValidator)
|
|
||||||
WX_PG_IMPLEMENT_STRING_PROPERTY_WITH_VALIDATOR(wxTextStringPropertyWithValidator,
|
|
||||||
wxPG_NO_ESCAPE)
|
|
||||||
|
|
||||||
bool wxTextStringPropertyWithValidator::OnButtonClick( wxPropertyGrid* WXUNUSED(propgrid),
|
|
||||||
wxString& WXUNUSED(value) )
|
|
||||||
{
|
|
||||||
::wxMessageBox(wxT("Button Clicked"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxValidator* wxTextStringPropertyWithValidator::DoGetValidator() const
|
|
||||||
{
|
|
||||||
#if wxUSE_VALIDATORS
|
|
||||||
WX_PG_DOGETVALIDATOR_ENTRY()
|
|
||||||
wxTextValidator* validator = new
|
|
||||||
wxTextValidator(wxFILTER_INCLUDE_CHAR_LIST);
|
|
||||||
wxArrayString oValid;
|
|
||||||
oValid.Add(wxT("0"));
|
|
||||||
oValid.Add(wxT("1"));
|
|
||||||
oValid.Add(wxT("2"));
|
|
||||||
oValid.Add(wxT("3"));
|
|
||||||
oValid.Add(wxT("4"));
|
|
||||||
oValid.Add(wxT("5"));
|
|
||||||
oValid.Add(wxT("6"));
|
|
||||||
oValid.Add(wxT("7"));
|
|
||||||
oValid.Add(wxT("8"));
|
|
||||||
oValid.Add(wxT("9"));
|
|
||||||
oValid.Add(wxT("$"));
|
|
||||||
validator->SetIncludes(oValid);
|
|
||||||
WX_PG_DOGETVALIDATOR_EXIT(validator)
|
|
||||||
#else
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -243,8 +195,6 @@ void FormMain::AddTestProperties( wxPropertyGridPage* pg )
|
|||||||
pg->SetPropertyHelpString(wxT("CustomColourProperty3"),
|
pg->SetPropertyHelpString(wxT("CustomColourProperty3"),
|
||||||
wxT("This is a MyColourProperty3 from the sample app. ")
|
wxT("This is a MyColourProperty3 from the sample app. ")
|
||||||
wxT("It is built by subclassing wxColourProperty."));
|
wxT("It is built by subclassing wxColourProperty."));
|
||||||
|
|
||||||
pg->Append( new wxTextStringPropertyWithValidator(wxT("TestProp1"), wxPG_LABEL) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
@@ -1414,7 +1414,7 @@ bool wxPGProperty::HasVisibleChildren() const
|
|||||||
|
|
||||||
bool wxPGProperty::PrepareValueForDialogEditing( wxPropertyGrid* propGrid )
|
bool wxPGProperty::PrepareValueForDialogEditing( wxPropertyGrid* propGrid )
|
||||||
{
|
{
|
||||||
return propGrid->EditorValidate();
|
return propGrid->CommitChangesFromEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1545,8 +1545,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxDirProperty, wxLongStringProperty)
|
|||||||
wxDirProperty::wxDirProperty( const wxString& name, const wxString& label, const wxString& value )
|
wxDirProperty::wxDirProperty( const wxString& name, const wxString& label, const wxString& value )
|
||||||
: wxLongStringProperty(name,label,value)
|
: wxLongStringProperty(name,label,value)
|
||||||
{
|
{
|
||||||
m_flags |= wxPG_NO_ESCAPE;
|
m_flags |= wxPG_PROP_NO_ESCAPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDirProperty::~wxDirProperty() { }
|
wxDirProperty::~wxDirProperty() { }
|
||||||
|
|
||||||
wxValidator* wxDirProperty::DoGetValidator() const
|
wxValidator* wxDirProperty::DoGetValidator() const
|
||||||
@@ -1556,6 +1557,9 @@ wxValidator* wxDirProperty::DoGetValidator() const
|
|||||||
|
|
||||||
bool wxDirProperty::OnButtonClick( wxPropertyGrid* propGrid, wxString& value )
|
bool wxDirProperty::OnButtonClick( wxPropertyGrid* propGrid, wxString& value )
|
||||||
{
|
{
|
||||||
|
// Update property value from editor, if necessary
|
||||||
|
PrepareValueForDialogEditing(propGrid);
|
||||||
|
|
||||||
wxSize dlg_sz(300,400);
|
wxSize dlg_sz(300,400);
|
||||||
|
|
||||||
wxDirDialog dlg( propGrid,
|
wxDirDialog dlg( propGrid,
|
||||||
|
Reference in New Issue
Block a user