// This define is necessary to prevent macro clearing
#define __wxPG_SOURCE_FILE__
-#include <wx/propgrid/propgrid.h>
-#include <wx/propgrid/editors.h>
+#include "wx/propgrid/propgrid.h"
+#include "wx/propgrid/editors.h"
#if wxPG_USE_RENDERER_NATIVE
- #include <wx/renderer.h>
+ #include "wx/renderer.h"
#endif
-#include <wx/odcombo.h>
+#include "wx/odcombo.h"
#include "wx/timer.h"
#include "wx/dcbuffer.h"
-#include <wx/clipbrd.h>
-#include <wx/dataobj.h>
+#include "wx/clipbrd.h"
+#include "wx/dataobj.h"
#ifdef __WXMSW__
- #include <wx/msw/private.h>
+ #include "wx/msw/private.h"
#endif
// Two pics for the expand / collapse buttons.
// Statics in one class for easy destruction.
// -----------------------------------------------------------------------
-#include <wx/module.h>
+#include "wx/module.h"
class wxPGGlobalVarsClassManager : public wxModule
{
// TODO: Following code is disabled with wxMac because
// it is reported to fail. I (JMS) cannot debug it
// personally right now.
-#if !defined(__WXMAC__)
+ // CS: should be fixed now, leaving old code in just in case, TODO: REMOVE
+#if 1 // !defined(__WXMAC__)
bool res = wxScrolledWindow::SetFont( font );
if ( res )
{
// -----------------------------------------------------------------------
-bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue )
+bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue,
+ int flags )
{
//
// Runs all validation functionality.
wxVariant evtChangingValue = value;
- // FIXME: After proper ValueToString()s added, remove
- // this. It is just a temporary fix, as evt_changing
- // will simply not work for wxPG_PROP_COMPOSED_VALUE
- // (unless it is selected, and textctrl editor is open).
- if ( changedProperty->HasFlag(wxPG_PROP_COMPOSED_VALUE) )
+ if ( flags & SendEvtChanging )
{
- evtChangingProperty = baseChangedProperty;
- if ( evtChangingProperty != p )
- {
- evtChangingProperty->AdaptListToValue( bcpPendingList, &evtChangingValue );
- }
- else
+ // FIXME: After proper ValueToString()s added, remove
+ // this. It is just a temporary fix, as evt_changing
+ // will simply not work for wxPG_PROP_COMPOSED_VALUE
+ // (unless it is selected, and textctrl editor is open).
+ if ( changedProperty->HasFlag(wxPG_PROP_COMPOSED_VALUE) )
{
- evtChangingValue = pendingValue;
+ evtChangingProperty = baseChangedProperty;
+ if ( evtChangingProperty != p )
+ {
+ evtChangingProperty->AdaptListToValue( bcpPendingList, &evtChangingValue );
+ }
+ else
+ {
+ evtChangingValue = pendingValue;
+ }
}
- }
- if ( evtChangingProperty->HasFlag(wxPG_PROP_COMPOSED_VALUE) )
- {
- if ( changedProperty == m_selected )
+ if ( evtChangingProperty->HasFlag(wxPG_PROP_COMPOSED_VALUE) )
{
- wxWindow* editor = GetEditorControl();
- wxASSERT( editor->IsKindOf(CLASSINFO(wxTextCtrl)) );
- evtChangingValue = wxStaticCast(editor, wxTextCtrl)->GetValue();
- }
- else
- {
- wxLogDebug(wxT("WARNING: wxEVT_PG_CHANGING is about to happen with old value."));
+ if ( changedProperty == m_selected )
+ {
+ wxWindow* editor = GetEditorControl();
+ wxASSERT( editor->IsKindOf(CLASSINFO(wxTextCtrl)) );
+ evtChangingValue = wxStaticCast(editor, wxTextCtrl)->GetValue();
+ }
+ else
+ {
+ wxLogDebug(wxT("WARNING: wxEVT_PG_CHANGING is about to happen with old value."));
+ }
}
}
return false;
}
- // SendEvent returns true if event was vetoed
- if ( SendEvent( wxEVT_PG_CHANGING, evtChangingProperty, &evtChangingValue, 0 ) )
- return false;
+ if ( flags & SendEvtChanging )
+ {
+ // SendEvent returns true if event was vetoed
+ if ( SendEvent( wxEVT_PG_CHANGING, evtChangingProperty, &evtChangingValue, 0 ) )
+ return false;
+ }
+
+ if ( flags & IsStandaloneValidation )
+ {
+ // If called in 'generic' context, we need to reset
+ // m_chgInfo_changedProperty and write back translated value.
+ m_chgInfo_changedProperty = NULL;
+ pendingValue = value;
+ }
return true;
}
// -----------------------------------------------------------------------
+wxVariant wxPropertyGrid::GetUncommittedPropertyValue()
+{
+ wxPGProperty* prop = GetSelectedProperty();
+
+ if ( !prop )
+ return wxNullVariant;
+
+ wxTextCtrl* tc = GetEditorTextCtrl();
+ wxVariant value = prop->GetValue();
+
+ if ( !tc || !IsEditorsValueModified() )
+ return value;
+
+ if ( !prop->StringToValue(value, tc->GetValue()) )
+ return value;
+
+ if ( !PerformValidation(prop, value, IsStandaloneValidation) )
+ return prop->GetValue();
+
+ return value;
+}
+
+// -----------------------------------------------------------------------
+
// Runs wxValidator for the selected property
bool wxPropertyGrid::DoEditorValidate()
{
// Existing editor under this name?
wxPGHashMapS2P::iterator vt_it = wxPGGlobalVars->m_mapEditorClasses.find(name);
+ if ( vt_it != wxPGGlobalVars->m_mapEditorClasses.end() )
+ {
+ // If this name was already used, try class name.
+ name = editorClass->GetClassInfo()->GetClassName();
+ vt_it = wxPGGlobalVars->m_mapEditorClasses.find(name);
+ }
+
wxCHECK_MSG( vt_it == wxPGGlobalVars->m_mapEditorClasses.end(),
(wxPGEditor*) vt_it->second,
"Editor with given name was already registered" );
return editorClass;
}
+// Use this in RegisterDefaultEditors.
+#define wxPGRegisterDefaultEditorClass(EDITOR) \
+ if ( wxPGEditor_##EDITOR == (wxPGEditor*) NULL ) \
+ { \
+ wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( \
+ new wxPG##EDITOR##Editor, true ); \
+ }
+
// Registers all default editor classes
void wxPropertyGrid::RegisterDefaultEditors()
{