// -----------------------------------------------------------------------
-#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) \
DECL CLASSNAME : public wxSystemColourProperty \
{ \
dialog. Note that in long string values, tabs are represented by "\t" and
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
Like wxLongStringProperty, but the button triggers dir selector instead.
(long*)NULL,
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
-}
-
// -----------------------------------------------------------------------
//
pg->SetPropertyHelpString(wxT("CustomColourProperty3"),
wxT("This is a MyColourProperty3 from the sample app. ")
wxT("It is built by subclassing wxColourProperty."));
-
- pg->Append( new wxTextStringPropertyWithValidator(wxT("TestProp1"), wxPG_LABEL) );
}
// -----------------------------------------------------------------------
bool wxPGProperty::PrepareValueForDialogEditing( wxPropertyGrid* propGrid )
{
- return propGrid->EditorValidate();
+ return propGrid->CommitChangesFromEditor();
}
wxDirProperty::wxDirProperty( const wxString& name, const wxString& label, const wxString& value )
: wxLongStringProperty(name,label,value)
{
- m_flags |= wxPG_NO_ESCAPE;
+ m_flags |= wxPG_PROP_NO_ESCAPE;
}
+
wxDirProperty::~wxDirProperty() { }
wxValidator* wxDirProperty::DoGetValidator() const
bool wxDirProperty::OnButtonClick( wxPropertyGrid* propGrid, wxString& value )
{
+ // Update property value from editor, if necessary
+ PrepareValueForDialogEditing(propGrid);
+
wxSize dlg_sz(300,400);
wxDirDialog dlg( propGrid,