// Author: Jaakko Salli
// Modified by:
// Created: 2005-05-14
-// RCS-ID: $Id:
+// RCS-ID: $Id$
// Copyright: (c) Jaakko Salli
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#include "wx/sizer.h"
#include "wx/textdlg.h"
#include "wx/filedlg.h"
- #include "wx/statusbr.h"
#include "wx/intl.h"
#endif
-#include <wx/filename.h>
+#include "wx/filename.h"
-#include <wx/propgrid/propgrid.h>
+#include "wx/propgrid/propgrid.h"
#define wxPG_CUSTOM_IMAGE_WIDTH 20 // for wxColourProperty etc.
-#include <typeinfo>
-
// -----------------------------------------------------------------------
// wxStringProperty
if ( GetChildCount() && HasFlag(wxPG_PROP_COMPOSED_VALUE) )
return wxPGProperty::StringToValue(variant, text, argFlags);
- if ( m_value.GetString() != text )
+ if ( variant != text )
{
variant = text;
return true;
if ( useText.ToLong( &value32, 0 ) )
{
- if ( !isPrevLong || m_value.GetLong() != value32 )
+ if ( !isPrevLong || variant != value32 )
{
variant = value32;
return true;
bool wxIntProperty::IntToValue( wxVariant& variant, int value, int WXUNUSED(argFlags) ) const
{
- if ( variant.GetType() != wxPG_VARIANT_TYPE_LONG || variant.GetLong() != value )
+ if ( variant.GetType() != wxPG_VARIANT_TYPE_LONG || variant != (long)value )
{
variant = (long)value;
return true;
if ( value < min )
{
if ( mode == wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE )
- pValidationInfo->m_failureMessage = wxString::Format(_("Value must be %lld or higher"),min);
+ pValidationInfo->SetFailureMessage(
+ wxString::Format(_("Value must be %lld or higher"),min)
+ );
else if ( mode == wxPG_PROPERTY_VALIDATION_SATURATE )
value = min;
else
if ( value > max )
{
if ( mode == wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE )
- pValidationInfo->m_failureMessage = wxString::Format(_("Value must be %lld or higher"),min);
+ pValidationInfo->SetFailureMessage(
+ wxString::Format(_("Value must be %lld or higher"),min)
+ );
else if ( mode == wxPG_PROPERTY_VALIDATION_SATURATE )
value = max;
else
else
{
unsigned long value32 = wxLongLong(value64).GetLo();
- if ( !isPrevLong || m_value.GetLong() != (long)value32 )
+ if ( !isPrevLong || m_value != (long)value32 )
{
variant = (long)value32;
return true;
bool wxUIntProperty::IntToValue( wxVariant& variant, int number, int WXUNUSED(argFlags) ) const
{
- if ( m_value != (long)number )
+ if ( variant != (long)number )
{
variant = (long)number;
return true;
wxPGVariantToULongLong(variant, &min);
if ( ll < min )
{
- validationInfo.m_failureMessage = wxString::Format(_("Value must be %llu or higher"),min);
+ validationInfo.SetFailureMessage(
+ wxString::Format(_("Value must be %llu or higher"),min)
+ );
return false;
}
}
wxPGVariantToULongLong(variant, &max);
if ( ll > max )
{
- validationInfo.m_failureMessage = wxString::Format(_("Value must be %llu or less"),max);
+ validationInfo.SetFailureMessage(
+ wxString::Format(_("Value must be %llu or less"),max)
+ );
return false;
}
}
bool res = text.ToDouble(&value);
if ( res )
{
- if ( m_value != value )
+ if ( variant != value )
{
variant = value;
return true;
if ( value < min )
{
if ( mode == wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE )
- pValidationInfo->m_failureMessage = wxString::Format(_("Value must be %f or higher"),min);
+ pValidationInfo->SetFailureMessage(
+ wxString::Format(_("Value must be %f or higher"),min)
+ );
else if ( mode == wxPG_PROPERTY_VALIDATION_SATURATE )
value = min;
else
if ( value > max )
{
if ( mode == wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE )
- pValidationInfo->m_failureMessage = wxString::Format(_("Value must be %f or less"),max);
+ pValidationInfo->SetFailureMessage(
+ wxString::Format(_("Value must be %f or less"),max)
+ );
else if ( mode == wxPG_PROPERTY_VALIDATION_SATURATE )
value = max;
else
// Select correct editor control.
#if wxPG_INCLUDE_CHECKBOX
if ( !(m_flags & wxPG_PROP_USE_CHECKBOX) )
- return wxPG_EDITOR(Choice);
- return wxPG_EDITOR(CheckBox);
+ return wxPGEditor_Choice;
+ return wxPGEditor_CheckBox;
#else
- return wxPG_EDITOR(Choice);
+ return wxPGEditor_Choice;
#endif
}
wxBoolProperty::wxBoolProperty( const wxString& label, const wxString& name, bool value ) :
wxPGProperty(label,name)
{
+ m_choices.Assign(wxPGGlobalVars->m_boolChoices);
+
SetValue(wxPGVariant_Bool(value));
m_flags |= wxPG_PROP_USE_DCC;
return text;
}
-int wxBoolProperty::GetChoiceInfo( wxPGChoiceInfo* choiceinfo )
-{
- if ( IsValueUnspecified() )
- return -1;
-
- if ( choiceinfo )
- choiceinfo->m_choices = &wxPGGlobalVars->m_boolChoices;
- return m_value.GetBool()?1:0;
-}
-
bool wxBoolProperty::StringToValue( wxVariant& variant, const wxString& text, int WXUNUSED(argFlags) ) const
{
- int value = 0;
+ bool boolValue = false;
if ( text.CmpNoCase(wxPGGlobalVars->m_boolChoices[1].GetText()) == 0 ||
text.CmpNoCase(wxS("true")) == 0 ||
text.CmpNoCase(m_label) == 0 )
- value = 1;
+ boolValue = true;
if ( text.length() == 0 )
{
return true;
}
- bool oldValue = m_value.GetBool();
-
- if ( (oldValue && !value) || (!oldValue && value) )
+ if ( variant != boolValue )
{
- variant = wxPGVariant_Bool(value);
+ variant = wxPGVariant_Bool(boolValue);
return true;
}
return false;
bool wxBoolProperty::IntToValue( wxVariant& variant, int value, int ) const
{
bool boolValue = value ? true : false;
- bool oldValue = m_value.GetBool();
- if ( oldValue != boolValue )
+ if ( variant != boolValue )
{
variant = wxPGVariant_Bool(boolValue);
return true;
return (const wxString*) NULL;
}
-int wxEnumProperty::GetChoiceInfo( wxPGChoiceInfo* choiceinfo )
-{
- if ( choiceinfo )
- choiceinfo->m_choices = &m_choices;
-
- if ( !m_choices.IsOk() )
- return -1;
-
- return GetIndex();
-}
-
// -----------------------------------------------------------------------
// wxEditEnumProperty
// -----------------------------------------------------------------------
//
unsigned int i;
- unsigned int prevChildCount = m_children.GetCount();
+ unsigned int prevChildCount = m_children.size();
int oldSel = -1;
if ( prevChildCount )
if ( selected )
{
if ( selected->GetParent() == this )
- oldSel = selected->GetArrIndex();
+ oldSel = selected->GetIndexInParent();
else if ( selected == this )
oldSel = -2;
}
// Delete old children
for ( i=0; i<prevChildCount; i++ )
- delete ( (wxPGProperty*) m_children[i] );
+ delete m_children[i];
- m_children.Empty();
+ m_children.clear();
if ( m_choices.IsOk() )
{
return false;
long newFlags = 0;
- long oldValue = m_value;
// semicolons are no longer valid delimeters
WX_PG_TOKENIZER1_BEGIN(text,wxS(','))
WX_PG_TOKENIZER1_END()
- variant = newFlags;
-
- if ( newFlags != oldValue )
+ if ( variant != (long)newFlags )
+ {
+ variant = (long)newFlags;
return true;
+ }
return false;
}
thisValue = (long)(oldValue & ~(vi));
}
-int wxFlagsProperty::GetChoiceInfo( wxPGChoiceInfo* choiceinfo )
-{
- if ( choiceinfo )
- choiceinfo->m_choices = &m_choices;
- return -1;
-}
-
// -----------------------------------------------------------------------
// wxDirProperty
// -----------------------------------------------------------------------
-WX_PG_IMPLEMENT_DERIVED_PROPERTY_CLASS(wxDirProperty,wxLongStringProperty,const wxString&)
+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
bool wxDirProperty::OnButtonClick( wxPropertyGrid* propGrid, wxString& value )
{
+ // Update property value from editor, if necessary
wxSize dlg_sz(300,400);
wxDirDialog dlg( propGrid,
if ( propGrid->IsMainButtonEvent(event) )
{
// Update the value
- PrepareValueForDialogEditing(propGrid);
+ wxVariant useValue = propGrid->GetUncommittedPropertyValue();
- wxString val1 = GetValueAsString(0);
+ wxString val1 = useValue.GetString();
wxString val_orig = val1;
wxString value;
bool wxLongStringProperty::StringToValue( wxVariant& variant, const wxString& text, int ) const
{
- if ( m_value != text )
+ if ( variant != text )
{
variant = text;
return true;
IMPLEMENT_ABSTRACT_CLASS(wxArrayEditorDialog, wxDialog)
-#include <wx/statline.h>
+#include "wx/statline.h"
// -----------------------------------------------------------------------
const wxChar* cbt )
{
// Update the value
- PrepareValueForDialogEditing(propGrid);
+ wxVariant useValue = propGrid->GetUncommittedPropertyValue();
if ( !propGrid->EditorValidate() )
return false;
if ( strEdDlg )
strEdDlg->SetCustomButton(cbt, this);
- dlg->SetDialogValue( wxVariant(m_value) );
+ dlg->SetDialogValue( useValue );
dlg->Create(propGrid, wxEmptyString, m_label);
#if !wxPG_SMALL_SCREEN