]> git.saurik.com Git - wxWidgets.git/commitdiff
Removed wxLongStringProperty derived property creator macros (just subclass and imple...
authorJaakko Salli <jaakko.salli@dnainternet.net>
Tue, 7 Oct 2008 16:56:43 +0000 (16:56 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Tue, 7 Oct 2008 16:56:43 +0000 (16:56 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56147 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/propgrid/props.h
interface/wx/propgrid/property.h
samples/propgrid/tests.cpp
src/propgrid/property.cpp
src/propgrid/props.cpp

index 903d8313292989c69dd1a40753b6a20454ef09e8..edda643d04fd18388cff20fd20e80d1b7f1f333f 100644 (file)
@@ -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) \
 DECL CLASSNAME : public wxSystemColourProperty \
 { \
index a0639cb8dddef7f7c579f9251c48501dde4e5395..6795ed0a187f842fd18ce769f09905210d95c239 100644 (file)
     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.
index f8d146f76aef168756b0b721d66b4d47c61d0853..a237687684fb920378da7bc3c2608c6c81984acb 100644 (file)
@@ -98,54 +98,6 @@ WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY(wxMyColour2Property,
                                        (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
-}
-
 // -----------------------------------------------------------------------
 
 //
@@ -243,8 +195,6 @@ void FormMain::AddTestProperties( wxPropertyGridPage* pg )
     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) );
 }
 
 // -----------------------------------------------------------------------
index 1022055d36cc0589130bf6a9f3d0223954a1f3ed..cc14b53a9f3b0ce4ea400f45a0842a51370652a3 100644 (file)
@@ -1414,7 +1414,7 @@ bool wxPGProperty::HasVisibleChildren() const
 
 bool wxPGProperty::PrepareValueForDialogEditing( wxPropertyGrid* propGrid )
 {
-    return propGrid->EditorValidate();
+    return propGrid->CommitChangesFromEditor();
 }
 
 
index ba0c468b1aaaa5f5b3e6da9c4722be79b754e60f..d4e078bd2d2250bbf0228fdbe1e5df78f04ed9be 100644 (file)
@@ -1545,8 +1545,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxDirProperty, wxLongStringProperty)
 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
@@ -1556,6 +1557,9 @@ 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,