// Author: Jaakko Salli
// Modified by:
// Created: 2008-08-23
-// RCS-ID: $Id:
+// RCS-ID: $Id$
// Copyright: (c) Jaakko Salli
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#include "wx/intl.h"
#endif
-#include <wx/propgrid/propgrid.h>
+#include "wx/propgrid/propgrid.h"
#define PWC_CHILD_SUMMARY_LIMIT 16 // Maximum number of children summarized in a parent property's
return m_parentState->GetGrid();
}
+int wxPGProperty::Index( const wxPGProperty* p ) const
+{
+ for ( unsigned int i = 0; i<m_children.size(); i++ )
+ {
+ if ( p == m_children[i] )
+ return i;
+ }
+ return wxNOT_FOUND;
+}
void wxPGProperty::UpdateControl( wxWindow* primary )
{
void wxPGProperty::GenerateComposedValue( wxString& text, int argFlags ) const
{
int i;
- int iMax = m_children.GetCount();
+ int iMax = m_children.size();
text.clear();
if ( iMax == 0 )
if ( !IsTextEditable() )
argFlags |= wxPG_UNEDITABLE_COMPOSITE_FRAGMENT;
- wxPGProperty* curChild = (wxPGProperty*) m_children.Item(0);
+ wxPGProperty* curChild = m_children[0];
for ( i = 0; i < iMax; i++ )
{
text += wxS(" ");
}
- curChild = (wxPGProperty*) m_children.Item(i+1);
+ curChild = m_children[i+1];
}
}
if ( text.EndsWith(wxS("; "), &rest) )
text = rest;
- if ( (unsigned int)i < m_children.GetCount() )
+ if ( (unsigned int)i < m_children.size() )
text += wxS("; ...");
}
unsigned int curChild = 0;
- unsigned int iMax = m_children.GetCount();
+ unsigned int iMax = m_children.size();
if ( iMax > PWC_CHILD_SUMMARY_LIMIT &&
!(argFlags & wxPG_FULL_VALUE) )
const wxPGEditor* wxPGProperty::DoGetEditorClass() const
{
- return wxPG_EDITOR(TextCtrl);
+ return wxPGEditor_TextCtrl;
}
// Default extra property event handling - that is, none at all.
void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags )
{
+ // If auto unspecified values are not wanted (via window or property style),
+ // then get default value instead of wxNullVariant.
+ if ( value.IsNull() && (flags & wxPG_SETVAL_BY_USER) &&
+ !UsesAutoUnspecified() )
+ {
+ value = GetDefaultValue();
+ }
+
if ( !value.IsNull() )
{
wxVariant tempListVariant;
{
// TextCtrlAndButton -> ComboBoxAndButton
if ( editor->IsKindOf(CLASSINFO(wxPGTextCtrlAndButtonEditor)) )
- editor = wxPG_EDITOR(ChoiceAndButton);
+ editor = wxPGEditor_ChoiceAndButton;
// TextCtrl -> ComboBox
else if ( editor->IsKindOf(CLASSINFO(wxPGTextCtrlEditor)) )
- editor = wxPG_EDITOR(ComboBox);
+ editor = wxPGEditor_ComboBox;
}
return editor;
// This is used by Insert etc.
void wxPGProperty::AddChild2( wxPGProperty* prop, int index, bool correct_mode )
{
- if ( index < 0 || (size_t)index >= m_children.GetCount() )
+ if ( index < 0 || (size_t)index >= m_children.size() )
{
- if ( correct_mode ) prop->m_arrIndex = m_children.GetCount();
- m_children.Add( prop );
+ if ( correct_mode ) prop->m_arrIndex = m_children.size();
+ m_children.push_back( prop );
}
else
{
- m_children.Insert( prop, index );
+ m_children.insert( m_children.begin()+index, prop);
if ( correct_mode ) FixIndexesOfChildren( index );
}
wxASSERT_MSG( prop->GetBaseName().length(),
"Property's children must have unique, non-empty names within their scope" );
- prop->m_arrIndex = m_children.GetCount();
- m_children.Add( prop );
+ prop->m_arrIndex = m_children.size();
+ m_children.push_back( prop );
int custImgHeight = prop->OnMeasureImage().y;
if ( custImgHeight < 0 /*|| custImgHeight > 1*/ )
prop->m_parent = this;
}
+void wxPGProperty::RemoveChild( wxPGProperty* p )
+{
+ wxArrayPGProperty::iterator it;
+ wxArrayPGProperty& children = m_children;
+
+ for ( it=children.begin(); it != children.end(); it++ )
+ {
+ if ( *it == p )
+ {
+ m_children.erase(it);
+ break;
+ }
+ }
+}
void wxPGProperty::AdaptListToValue( wxVariant& list, wxVariant* value ) const
{
{
for ( i=0; i<GetChildCount(); i++ )
{
- wxPGProperty* p = (wxPGProperty*) Item(i);
- delete p;
+ delete m_children[i];
}
}
- m_children.Empty();
+ m_children.clear();
}
void wxPGProperty::ChildChanged( wxVariant& WXUNUSED(thisValue),
depth--;
- i = nparent->GetArrIndex() + 1;
+ i = nparent->GetIndexInParent() + 1;
nparent = nparent->GetParent();
}
}
PrepareSubProperties();
wxPGProperty* sel = (wxPGProperty*) NULL;
- if ( oldSelInd >= (int)m_children.GetCount() )
- oldSelInd = (int)m_children.GetCount() - 1;
+ if ( oldSelInd >= (int)m_children.size() )
+ oldSelInd = (int)m_children.size() - 1;
if ( oldSelInd >= 0 )
- sel = (wxPGProperty*) m_children[oldSelInd];
+ sel = m_children[oldSelInd];
else if ( oldSelInd == -2 )
sel = this;
// Free old, if any
wxPGHashMapS2P::iterator it = m_map.find(name);
if ( it != m_map.end() )
+ {
((wxVariantData*)it->second)->DecRef();
+ if ( !data )
+ {
+ // If Null variant, just remove from set
+ m_map.erase(it);
+ return;
+ }
+ }
+
if ( data )
+ {
data->IncRef();
- m_map[name] = data;
+ m_map[name] = data;
+ }
}
#endif // wxUSE_PROPGRID