1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/propgrid/property.cpp
3 // Purpose: wxPGProperty and related support classes
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
23 #include "wx/object.h"
25 #include "wx/string.h"
28 #include "wx/window.h"
31 #include "wx/dcmemory.h"
34 #include "wx/settings.h"
38 #include "wx/propgrid/propgrid.h"
41 #define PWC_CHILD_SUMMARY_LIMIT 16 // Maximum number of children summarized in a parent property's
44 #define PWC_CHILD_SUMMARY_CHAR_LIMIT 64 // Character limit of summary field when not editing
46 #if wxPG_COMPATIBILITY_1_4
48 // Used to establish backwards compatiblity
49 const char* g_invalidStringContent
= "@__TOTALLY_INVALID_STRING__@";
53 // -----------------------------------------------------------------------
55 static void wxPGDrawFocusRect( wxDC
& dc
, const wxRect
& rect
)
57 #if defined(__WXMSW__) && !defined(__WXWINCE__)
58 // FIXME: Use DrawFocusRect code above (currently it draws solid line
59 // for caption focus but works ok for other stuff).
60 // Also, it seems that this code may not work in future wx versions.
61 dc
.SetLogicalFunction(wxINVERT
);
63 wxPen
pen(*wxBLACK
,1,wxDOT
);
64 pen
.SetCap(wxCAP_BUTT
);
66 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
68 dc
.DrawRectangle(rect
);
70 dc
.SetLogicalFunction(wxCOPY
);
72 dc
.SetLogicalFunction(wxINVERT
);
74 dc
.SetPen(wxPen(*wxBLACK
,1,wxDOT
));
75 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
77 dc
.DrawRectangle(rect
);
79 dc
.SetLogicalFunction(wxCOPY
);
83 // -----------------------------------------------------------------------
85 // -----------------------------------------------------------------------
87 wxSize
wxPGCellRenderer::GetImageSize( const wxPGProperty
* WXUNUSED(property
),
89 int WXUNUSED(item
) ) const
94 void wxPGCellRenderer::DrawText( wxDC
& dc
, const wxRect
& rect
,
95 int xOffset
, const wxString
& text
) const
98 rect
.x
+xOffset
+wxPG_XBEFORETEXT
,
99 rect
.y
+((rect
.height
-dc
.GetCharHeight())/2) );
102 void wxPGCellRenderer::DrawEditorValue( wxDC
& dc
, const wxRect
& rect
,
103 int xOffset
, const wxString
& text
,
104 wxPGProperty
* property
,
105 const wxPGEditor
* editor
) const
107 int yOffset
= ((rect
.height
-dc
.GetCharHeight())/2);
114 rect2
.height
-= yOffset
;
115 editor
->DrawValue( dc
, rect2
, property
, text
);
120 rect
.x
+xOffset
+wxPG_XBEFORETEXT
,
125 void wxPGCellRenderer::DrawCaptionSelectionRect( wxDC
& dc
, int x
, int y
, int w
, int h
) const
127 wxRect
focusRect(x
,y
+((h
-dc
.GetCharHeight())/2),w
,h
);
128 wxPGDrawFocusRect(dc
,focusRect
);
131 int wxPGCellRenderer::PreDrawCell( wxDC
& dc
, const wxRect
& rect
, const wxPGCell
& cell
, int flags
) const
135 // If possible, use cell colours
136 if ( !(flags
& DontUseCellBgCol
) )
138 const wxColour
& bgCol
= cell
.GetBgCol();
143 if ( !(flags
& DontUseCellFgCol
) )
145 dc
.SetTextForeground(cell
.GetFgCol());
148 // Draw Background, but only if not rendering in control
149 // (as control already has rendered correct background).
150 if ( !(flags
& (Control
|ChoicePopup
)) )
151 dc
.DrawRectangle(rect
);
153 // Use cell font, if provided
154 const wxFont
& font
= cell
.GetFont();
158 const wxBitmap
& bmp
= cell
.GetBitmap();
160 // Do not draw oversized bitmap outside choice popup
161 ((flags
& ChoicePopup
) || bmp
.GetHeight() < rect
.height
)
165 rect
.x
+ wxPG_CONTROL_MARGIN
+ wxCC_CUSTOM_IMAGE_MARGIN1
,
166 rect
.y
+ wxPG_CUSTOM_IMAGE_SPACINGY
,
168 imageWidth
= bmp
.GetWidth();
174 void wxPGCellRenderer::PostDrawCell( wxDC
& dc
,
175 const wxPropertyGrid
* propGrid
,
176 const wxPGCell
& cell
,
177 int WXUNUSED(flags
) ) const
180 const wxFont
& font
= cell
.GetFont();
182 dc
.SetFont(propGrid
->GetFont());
185 // -----------------------------------------------------------------------
186 // wxPGDefaultRenderer
187 // -----------------------------------------------------------------------
189 bool wxPGDefaultRenderer::Render( wxDC
& dc
, const wxRect
& rect
,
190 const wxPropertyGrid
* propertyGrid
, wxPGProperty
* property
,
191 int column
, int item
, int flags
) const
193 const wxPGEditor
* editor
= NULL
;
194 const wxPGCell
* cell
= NULL
;
197 bool isUnspecified
= property
->IsValueUnspecified();
199 if ( column
== 1 && item
== -1 )
201 int cmnVal
= property
->GetCommonValue();
205 if ( !isUnspecified
)
207 text
= propertyGrid
->GetCommonValueLabel(cmnVal
);
208 DrawText( dc
, rect
, 0, text
);
217 int preDrawFlags
= flags
;
220 property
->GetDisplayInfo(column
, item
, flags
, &text
, &cell
);
222 imageWidth
= PreDrawCell( dc
, rect
, *cell
, preDrawFlags
);
226 editor
= property
->GetColumnEditor(column
);
228 if ( !isUnspecified
)
230 // Regular property value
232 wxSize imageSize
= propertyGrid
->GetImageSize(property
, item
);
234 wxPGPaintData paintdata
;
235 paintdata
.m_parent
= propertyGrid
;
236 paintdata
.m_choiceItem
= item
;
238 if ( imageSize
.x
> 0 )
240 wxRect
imageRect(rect
.x
+ wxPG_CONTROL_MARGIN
+ wxCC_CUSTOM_IMAGE_MARGIN1
,
241 rect
.y
+wxPG_CUSTOM_IMAGE_SPACINGY
,
242 wxPG_CUSTOM_IMAGE_WIDTH
,
243 rect
.height
-(wxPG_CUSTOM_IMAGE_SPACINGY
*2));
245 dc
.SetPen( wxPen(propertyGrid
->GetCellTextColour(), 1, wxSOLID
) );
247 paintdata
.m_drawnWidth
= imageSize
.x
;
248 paintdata
.m_drawnHeight
= imageSize
.y
;
250 property
->OnCustomPaint( dc
, imageRect
, paintdata
);
252 imageWidth
= paintdata
.m_drawnWidth
;
255 text
= property
->GetValueAsString();
258 if ( propertyGrid
->GetColumnCount() <= 2 )
260 wxString unitsString
= property
->GetAttribute(wxPGGlobalVars
->m_strUnits
, wxEmptyString
);
261 if ( unitsString
.length() )
262 text
= wxString::Format(wxS("%s %s"), text
.c_str(), unitsString
.c_str() );
266 if ( text
.length() == 0 )
268 text
= property
->GetHintText();
269 if ( text
.length() > 0 )
273 const wxColour
& hCol
=
274 propertyGrid
->GetCellDisabledTextColour();
275 dc
.SetTextForeground(hCol
);
277 // Must make the editor NULL to override it's own rendering
288 int imageOffset
= property
->GetImageOffset(imageWidth
);
290 DrawEditorValue( dc
, rect
, imageOffset
, text
, property
, editor
);
292 // active caption gets nice dotted rectangle
293 if ( property
->IsCategory() && column
== 0 )
295 if ( flags
& Selected
)
297 if ( imageOffset
> 0 )
299 imageOffset
-= DEFAULT_IMAGE_OFFSET_INCREMENT
;
300 imageOffset
+= wxCC_CUSTOM_IMAGE_MARGIN2
+ 4;
303 DrawCaptionSelectionRect( dc
,
304 rect
.x
+wxPG_XBEFORETEXT
-wxPG_CAPRECTXMARGIN
+imageOffset
,
305 rect
.y
-wxPG_CAPRECTYMARGIN
+1,
306 ((wxPropertyCategory
*)property
)->GetTextExtent(propertyGrid
,
307 propertyGrid
->GetCaptionFont())
308 +(wxPG_CAPRECTXMARGIN
*2),
309 propertyGrid
->GetFontHeight()+(wxPG_CAPRECTYMARGIN
*2) );
313 PostDrawCell(dc
, propertyGrid
, *cell
, preDrawFlags
);
318 wxSize
wxPGDefaultRenderer::GetImageSize( const wxPGProperty
* property
,
322 if ( property
&& column
== 1 )
326 wxBitmap
* bmp
= property
->GetValueImage();
328 if ( bmp
&& bmp
->Ok() )
329 return wxSize(bmp
->GetWidth(),bmp
->GetHeight());
335 // -----------------------------------------------------------------------
337 // -----------------------------------------------------------------------
339 wxPGCellData::wxPGCellData()
342 m_hasValidText
= false;
345 // -----------------------------------------------------------------------
347 // -----------------------------------------------------------------------
354 wxPGCell::wxPGCell( const wxString
& text
,
355 const wxBitmap
& bitmap
,
356 const wxColour
& fgCol
,
357 const wxColour
& bgCol
)
360 wxPGCellData
* data
= new wxPGCellData();
363 data
->m_bitmap
= bitmap
;
364 data
->m_fgCol
= fgCol
;
365 data
->m_bgCol
= bgCol
;
366 data
->m_hasValidText
= true;
369 wxObjectRefData
*wxPGCell::CloneRefData( const wxObjectRefData
*data
) const
371 wxPGCellData
* c
= new wxPGCellData();
372 const wxPGCellData
* o
= (const wxPGCellData
*) data
;
373 c
->m_text
= o
->m_text
;
374 c
->m_bitmap
= o
->m_bitmap
;
375 c
->m_fgCol
= o
->m_fgCol
;
376 c
->m_bgCol
= o
->m_bgCol
;
377 c
->m_hasValidText
= o
->m_hasValidText
;
381 void wxPGCell::SetText( const wxString
& text
)
385 GetData()->SetText(text
);
388 void wxPGCell::SetBitmap( const wxBitmap
& bitmap
)
392 GetData()->SetBitmap(bitmap
);
395 void wxPGCell::SetFgCol( const wxColour
& col
)
399 GetData()->SetFgCol(col
);
402 void wxPGCell::SetFont( const wxFont
& font
)
406 GetData()->SetFont(font
);
409 void wxPGCell::SetBgCol( const wxColour
& col
)
413 GetData()->SetBgCol(col
);
416 void wxPGCell::MergeFrom( const wxPGCell
& srcCell
)
420 wxPGCellData
* data
= GetData();
422 if ( srcCell
.HasText() )
423 data
->SetText(srcCell
.GetText());
425 if ( srcCell
.GetFgCol().IsOk() )
426 data
->SetFgCol(srcCell
.GetFgCol());
428 if ( srcCell
.GetBgCol().IsOk() )
429 data
->SetBgCol(srcCell
.GetBgCol());
431 if ( srcCell
.GetBitmap().IsOk() )
432 data
->SetBitmap(srcCell
.GetBitmap());
435 void wxPGCell::SetEmptyData()
441 // -----------------------------------------------------------------------
443 // -----------------------------------------------------------------------
445 IMPLEMENT_ABSTRACT_CLASS(wxPGProperty
, wxObject
)
447 wxString
* wxPGProperty::sm_wxPG_LABEL
= NULL
;
449 void wxPGProperty::Init()
455 m_parentState
= NULL
;
458 m_clientObject
= NULL
;
460 m_customEditor
= NULL
;
464 m_valueBitmap
= NULL
;
466 m_maxLen
= 0; // infinite maximum length
468 m_flags
= wxPG_PROP_PROPERTY
;
476 void wxPGProperty::Init( const wxString
& label
, const wxString
& name
)
478 // We really need to check if &label and &name are NULL pointers
479 // (this can if we are called before property grid has been initalized)
481 if ( (&label
) != NULL
&& label
!= wxPG_LABEL
)
484 if ( (&name
) != NULL
&& name
!= wxPG_LABEL
)
487 DoSetName( m_label
);
492 void wxPGProperty::InitAfterAdded( wxPropertyGridPageState
* pageState
,
493 wxPropertyGrid
* propgrid
)
496 // Called after property has been added to grid or page
497 // (so propgrid can be NULL, too).
499 wxPGProperty
* parent
= m_parent
;
500 bool parentIsRoot
= parent
->IsKindOf(CLASSINFO(wxPGRootProperty
));
502 m_parentState
= pageState
;
504 #if wxPG_COMPATIBILITY_1_4
505 // Make sure deprecated virtual functions are not implemented
506 wxString s
= GetValueAsString( 0xFFFF );
507 wxASSERT_MSG( s
== g_invalidStringContent
,
508 "Implement ValueToString() instead of GetValueAsString()" );
511 if ( !parentIsRoot
&& !parent
->IsCategory() )
513 m_cells
= parent
->m_cells
;
516 // If in hideable adding mode, or if assigned parent is hideable, then
517 // make this one hideable.
519 ( !parentIsRoot
&& parent
->HasFlag(wxPG_PROP_HIDDEN
) ) ||
520 ( propgrid
&& (propgrid
->HasInternalFlag(wxPG_FL_ADDING_HIDEABLES
)) )
522 SetFlag( wxPG_PROP_HIDDEN
);
524 // Set custom image flag.
525 int custImgHeight
= OnMeasureImage().y
;
526 if ( custImgHeight
< 0 )
528 SetFlag(wxPG_PROP_CUSTOMIMAGE
);
531 if ( propgrid
&& (propgrid
->HasFlag(wxPG_LIMITED_EDITING
)) )
532 SetFlag(wxPG_PROP_NOEDITOR
);
534 // Make sure parent has some parental flags
535 if ( !parent
->HasFlag(wxPG_PROP_PARENTAL_FLAGS
) )
536 parent
->SetParentalType(wxPG_PROP_MISC_PARENT
);
540 // This is not a category.
544 unsigned char depth
= 1;
547 depth
= parent
->m_depth
;
548 if ( !parent
->IsCategory() )
552 unsigned char greyDepth
= depth
;
556 wxPropertyCategory
* pc
;
558 if ( parent
->IsCategory() )
559 pc
= (wxPropertyCategory
* ) parent
;
561 // This conditional compile is necessary to
562 // bypass some compiler bug.
563 pc
= pageState
->GetPropertyCategory(parent
);
566 greyDepth
= pc
->GetDepth();
568 greyDepth
= parent
->m_depthBgCol
;
571 m_depthBgCol
= greyDepth
;
575 // This is a category.
578 unsigned char depth
= 1;
581 depth
= parent
->m_depth
+ 1;
584 m_depthBgCol
= depth
;
588 // Has initial children
589 if ( GetChildCount() )
591 // Check parental flags
592 wxASSERT_MSG( ((m_flags
& wxPG_PROP_PARENTAL_FLAGS
) ==
593 wxPG_PROP_AGGREGATE
) ||
594 ((m_flags
& wxPG_PROP_PARENTAL_FLAGS
) ==
595 wxPG_PROP_MISC_PARENT
),
596 "wxPGProperty parental flags set incorrectly at "
599 if ( HasFlag(wxPG_PROP_AGGREGATE
) )
601 // Properties with private children are not expanded by default.
604 else if ( propgrid
&& propgrid
->HasFlag(wxPG_HIDE_MARGIN
) )
606 // ...unless it cannot be expanded by user and therefore must
607 // remain visible at all times
612 // Prepare children recursively
613 for ( unsigned int i
=0; i
<GetChildCount(); i
++ )
615 wxPGProperty
* child
= Item(i
);
616 child
->InitAfterAdded(pageState
, pageState
->GetGrid());
619 if ( propgrid
&& (propgrid
->GetExtraStyle() & wxPG_EX_AUTO_UNSPECIFIED_VALUES
) )
620 SetFlagRecursively(wxPG_PROP_AUTO_UNSPECIFIED
, true);
624 wxPGProperty::wxPGProperty()
631 wxPGProperty::wxPGProperty( const wxString
& label
, const wxString
& name
)
638 wxPGProperty::~wxPGProperty()
640 delete m_clientObject
;
642 Empty(); // this deletes items
644 delete m_valueBitmap
;
649 // This makes it easier for us to detect dangling pointers
654 bool wxPGProperty::IsSomeParent( wxPGProperty
* candidate
) const
656 wxPGProperty
* parent
= m_parent
;
659 if ( parent
== candidate
)
661 parent
= parent
->m_parent
;
666 void wxPGProperty::SetName( const wxString
& newName
)
668 wxPropertyGrid
* pg
= GetGrid();
671 pg
->SetPropertyName(this, newName
);
676 wxString
wxPGProperty::GetName() const
678 wxPGProperty
* parent
= GetParent();
680 if ( !m_name
.length() || !parent
|| parent
->IsCategory() || parent
->IsRoot() )
683 return m_parent
->GetName() + wxS(".") + m_name
;
686 wxPropertyGrid
* wxPGProperty::GetGrid() const
688 if ( !m_parentState
)
690 return m_parentState
->GetGrid();
693 int wxPGProperty::Index( const wxPGProperty
* p
) const
695 for ( unsigned int i
= 0; i
<m_children
.size(); i
++ )
697 if ( p
== m_children
[i
] )
703 bool wxPGProperty::ValidateValue( wxVariant
& WXUNUSED(value
), wxPGValidationInfo
& WXUNUSED(validationInfo
) ) const
708 void wxPGProperty::OnSetValue()
712 void wxPGProperty::RefreshChildren ()
716 void wxPGProperty::OnValidationFailure( wxVariant
& WXUNUSED(pendingValue
) )
720 void wxPGProperty::GetDisplayInfo( unsigned int column
,
724 const wxPGCell
** pCell
)
726 const wxPGCell
* cell
= NULL
;
728 if ( !(flags
& wxPGCellRenderer::ChoicePopup
) )
730 // Not painting list of choice popups, so get text from property
731 if ( column
!= 1 || !IsValueUnspecified() || IsCategory() )
733 cell
= &GetCell(column
);
737 // Use special unspecified value cell
738 cell
= &GetGrid()->GetUnspecifiedValueAppearance();
741 if ( cell
->HasText() )
743 *pString
= cell
->GetText();
748 *pString
= GetLabel();
749 else if ( column
== 1 )
750 *pString
= GetDisplayedString();
751 else if ( column
== 2 )
752 *pString
= GetAttribute(wxPGGlobalVars
->m_strUnits
, wxEmptyString
);
757 wxASSERT( column
== 1 );
759 if ( choiceIndex
!= wxNOT_FOUND
)
761 const wxPGChoiceEntry
& entry
= m_choices
[choiceIndex
];
762 if ( entry
.GetBitmap().IsOk() ||
763 entry
.GetFgCol().IsOk() ||
764 entry
.GetBgCol().IsOk() )
766 *pString
= m_choices
.GetLabel(choiceIndex
);
771 cell
= &GetCell(column
);
773 wxASSERT_MSG( cell
->GetData(),
774 wxString::Format("Invalid cell for property %s",
775 GetName().c_str()) );
781 wxString wxPGProperty::GetColumnText( unsigned int col, int choiceIndex ) const
784 if ( col != 1 || choiceIndex == wxNOT_FOUND )
786 const wxPGCell& cell = GetCell(col);
787 if ( cell->HasText() )
789 return cell->GetText();
796 return GetDisplayedString();
798 return GetAttribute(wxPGGlobalVars->m_strUnits, wxEmptyString);
804 return m_choices.GetLabel(choiceIndex);
807 return wxEmptyString;
811 void wxPGProperty::DoGenerateComposedValue( wxString
& text
,
813 const wxVariantList
* valueOverrides
,
814 wxPGHashMapS2S
* childResults
) const
817 int iMax
= m_children
.size();
823 if ( iMax
> PWC_CHILD_SUMMARY_LIMIT
&&
824 !(argFlags
& wxPG_FULL_VALUE
) )
825 iMax
= PWC_CHILD_SUMMARY_LIMIT
;
827 int iMaxMinusOne
= iMax
-1;
829 if ( !IsTextEditable() )
830 argFlags
|= wxPG_UNEDITABLE_COMPOSITE_FRAGMENT
;
832 wxPGProperty
* curChild
= m_children
[0];
834 bool overridesLeft
= false;
835 wxVariant overrideValue
;
836 wxVariantList::const_iterator node
;
838 if ( valueOverrides
)
840 node
= valueOverrides
->begin();
841 if ( node
!= valueOverrides
->end() )
843 overrideValue
= *node
;
844 overridesLeft
= true;
848 for ( i
= 0; i
< iMax
; i
++ )
850 wxVariant childValue
;
852 wxString childLabel
= curChild
->GetLabel();
854 // Check for value override
855 if ( overridesLeft
&& overrideValue
.GetName() == childLabel
)
857 if ( !overrideValue
.IsNull() )
858 childValue
= overrideValue
;
860 childValue
= curChild
->GetValue();
862 if ( node
!= valueOverrides
->end() )
863 overrideValue
= *node
;
865 overridesLeft
= false;
869 childValue
= curChild
->GetValue();
873 if ( !childValue
.IsNull() )
875 if ( overridesLeft
&&
876 curChild
->HasFlag(wxPG_PROP_COMPOSED_VALUE
) &&
877 childValue
.GetType() == wxPG_VARIANT_TYPE_LIST
)
879 wxVariantList
& childList
= childValue
.GetList();
880 DoGenerateComposedValue(s
, argFlags
|wxPG_COMPOSITE_FRAGMENT
,
881 &childList
, childResults
);
885 s
= curChild
->ValueToString(childValue
,
886 argFlags
|wxPG_COMPOSITE_FRAGMENT
);
890 if ( childResults
&& curChild
->GetChildCount() )
891 (*childResults
)[curChild
->GetName()] = s
;
894 if ( (argFlags
& wxPG_UNEDITABLE_COMPOSITE_FRAGMENT
) && !s
.length() )
897 if ( !curChild
->GetChildCount() || skip
)
900 text
+= wxS("[") + s
+ wxS("]");
902 if ( i
< iMaxMinusOne
)
904 if ( text
.length() > PWC_CHILD_SUMMARY_CHAR_LIMIT
&&
905 !(argFlags
& wxPG_EDITABLE_VALUE
) &&
906 !(argFlags
& wxPG_FULL_VALUE
) )
911 if ( !curChild
->GetChildCount() )
917 curChild
= m_children
[i
+1];
921 if ( (unsigned int)i
< m_children
.size() )
923 if ( !text
.EndsWith(wxS("; ")) )
924 text
+= wxS("; ...");
930 wxString
wxPGProperty::ValueToString( wxVariant
& WXUNUSED(value
),
933 wxCHECK_MSG( GetChildCount() > 0,
935 "If user property does not have any children, it must "
936 "override GetValueAsString" );
938 // FIXME: Currently code below only works if value is actually m_value
939 wxASSERT_MSG( argFlags
& wxPG_VALUE_IS_CURRENT
,
940 "Sorry, currently default wxPGProperty::ValueToString() "
941 "implementation only works if value is m_value." );
944 DoGenerateComposedValue(text
, argFlags
);
948 wxString
wxPGProperty::GetValueAsString( int argFlags
) const
950 #if wxPG_COMPATIBILITY_1_4
951 // This is backwards compatibility test
952 // That is, to make sure this function is not overridden
953 // (instead, ValueToString() should be).
954 if ( argFlags
== 0xFFFF )
956 // Do not override! (for backwards compliancy)
957 return g_invalidStringContent
;
961 wxPropertyGrid
* pg
= GetGrid();
963 if ( IsValueUnspecified() )
964 return pg
->GetUnspecifiedValueText(argFlags
);
966 if ( m_commonValue
== -1 )
968 wxVariant
value(GetValue());
969 return ValueToString(value
, argFlags
|wxPG_VALUE_IS_CURRENT
);
973 // Return common value's string representation
974 const wxPGCommonValue
* cv
= pg
->GetCommonValue(m_commonValue
);
976 if ( argFlags
& wxPG_FULL_VALUE
)
978 return cv
->GetLabel();
980 else if ( argFlags
& wxPG_EDITABLE_VALUE
)
982 return cv
->GetEditableText();
986 return cv
->GetLabel();
990 wxString
wxPGProperty::GetValueString( int argFlags
) const
992 return GetValueAsString(argFlags
);
995 bool wxPGProperty::IntToValue( wxVariant
& variant
, int number
, int WXUNUSED(argFlags
) ) const
997 variant
= (long)number
;
1001 // Convert semicolon delimited tokens into child values.
1002 bool wxPGProperty::StringToValue( wxVariant
& variant
, const wxString
& text
, int argFlags
) const
1004 if ( !GetChildCount() )
1007 unsigned int curChild
= 0;
1009 unsigned int iMax
= m_children
.size();
1011 if ( iMax
> PWC_CHILD_SUMMARY_LIMIT
&&
1012 !(argFlags
& wxPG_FULL_VALUE
) )
1013 iMax
= PWC_CHILD_SUMMARY_LIMIT
;
1015 bool changed
= false;
1020 // Its best only to add non-empty group items
1021 bool addOnlyIfNotEmpty
= false;
1022 const wxChar delimeter
= wxS(';');
1024 size_t tokenStart
= 0xFFFFFF;
1026 wxVariantList temp_list
;
1027 wxVariant
list(temp_list
);
1029 int propagatedFlags
= argFlags
& (wxPG_REPORT_ERROR
|wxPG_PROGRAMMATIC_VALUE
);
1031 wxLogTrace("propgrid",
1032 wxT(">> %s.StringToValue('%s')"), GetLabel(), text
);
1034 wxString::const_iterator it
= text
.begin();
1037 if ( it
!= text
.end() )
1044 // How many units we iterate string forward at the end of loop?
1045 // We need to keep track of this or risk going to negative
1046 // with it-- operation.
1047 unsigned int strPosIncrement
= 1;
1049 if ( tokenStart
!= 0xFFFFFF )
1052 if ( a
== delimeter
|| a
== 0 )
1054 token
= text
.substr(tokenStart
,pos
-tokenStart
);
1056 size_t len
= token
.length();
1058 if ( !addOnlyIfNotEmpty
|| len
> 0 )
1060 const wxPGProperty
* child
= Item(curChild
);
1061 wxVariant
variant(child
->GetValue());
1062 wxString childName
= child
->GetBaseName();
1064 wxLogTrace("propgrid",
1065 wxT("token = '%s', child = %s"),
1068 // Add only if editable or setting programmatically
1069 if ( (argFlags
& wxPG_PROGRAMMATIC_VALUE
) ||
1070 (!child
->HasFlag(wxPG_PROP_DISABLED
) &&
1071 !child
->HasFlag(wxPG_PROP_READONLY
)) )
1075 if ( child
->StringToValue(variant
, token
,
1076 propagatedFlags
|wxPG_COMPOSITE_FRAGMENT
) )
1078 // We really need to set the variant's name
1079 // *after* child->StringToValue() has been
1080 // called, since variant's value may be set by
1081 // assigning another variant into it, which
1082 // then usually causes name to be copied (ie.
1083 // usually cleared) as well. wxBoolProperty
1084 // being case in point with its use of
1085 // wxPGVariant_Bool macro as an optimization.
1086 variant
.SetName(childName
);
1087 list
.Append(variant
);
1094 // Empty, becomes unspecified
1096 variant
.SetName(childName
);
1097 list
.Append(variant
);
1103 if ( curChild
>= iMax
)
1107 tokenStart
= 0xFFFFFF;
1112 // Token is not running
1113 if ( a
!= wxS(' ') )
1116 addOnlyIfNotEmpty
= false;
1118 // Is this a group of tokens?
1119 if ( a
== wxS('[') )
1123 if ( it
!= text
.end() ) ++it
;
1125 size_t startPos
= pos
;
1127 // Group item - find end
1128 while ( it
!= text
.end() && depth
> 0 )
1134 if ( a
== wxS(']') )
1136 else if ( a
== wxS('[') )
1140 token
= text
.substr(startPos
,pos
-startPos
-1);
1142 if ( !token
.length() )
1145 const wxPGProperty
* child
= Item(curChild
);
1147 wxVariant oldChildValue
= child
->GetValue();
1148 wxVariant
variant(oldChildValue
);
1150 if ( (argFlags
& wxPG_PROGRAMMATIC_VALUE
) ||
1151 (!child
->HasFlag(wxPG_PROP_DISABLED
) &&
1152 !child
->HasFlag(wxPG_PROP_READONLY
)) )
1154 wxString childName
= child
->GetBaseName();
1156 bool stvRes
= child
->StringToValue( variant
, token
,
1158 if ( stvRes
|| (variant
!= oldChildValue
) )
1160 variant
.SetName(childName
);
1161 list
.Append(variant
);
1172 if ( curChild
>= iMax
)
1175 addOnlyIfNotEmpty
= true;
1177 tokenStart
= 0xFFFFFF;
1183 if ( a
== delimeter
)
1184 strPosIncrement
-= 1;
1192 it
+= strPosIncrement
;
1194 if ( it
!= text
.end() )
1203 pos
+= strPosIncrement
;
1212 bool wxPGProperty::SetValueFromString( const wxString
& text
, int argFlags
)
1214 wxVariant
variant(m_value
);
1215 bool res
= StringToValue(variant
, text
, argFlags
);
1221 bool wxPGProperty::SetValueFromInt( long number
, int argFlags
)
1223 wxVariant
variant(m_value
);
1224 bool res
= IntToValue(variant
, number
, argFlags
);
1230 wxSize
wxPGProperty::OnMeasureImage( int WXUNUSED(item
) ) const
1232 if ( m_valueBitmap
)
1233 return wxSize(m_valueBitmap
->GetWidth(),-1);
1238 int wxPGProperty::GetImageOffset( int imageWidth
) const
1240 int imageOffset
= 0;
1244 // Do not increment offset too much for wide images
1245 if ( imageWidth
<= (wxPG_CUSTOM_IMAGE_WIDTH
+5) )
1246 imageOffset
= imageWidth
+ DEFAULT_IMAGE_OFFSET_INCREMENT
;
1248 imageOffset
= imageWidth
+ 1;
1254 wxPGCellRenderer
* wxPGProperty::GetCellRenderer( int WXUNUSED(column
) ) const
1256 return wxPGGlobalVars
->m_defaultRenderer
;
1259 void wxPGProperty::OnCustomPaint( wxDC
& dc
,
1263 wxBitmap
* bmp
= m_valueBitmap
;
1265 wxCHECK_RET( bmp
&& bmp
->Ok(), wxT("invalid bitmap") );
1267 wxCHECK_RET( rect
.x
>= 0, wxT("unexpected measure call") );
1269 dc
.DrawBitmap(*bmp
,rect
.x
,rect
.y
);
1272 const wxPGEditor
* wxPGProperty::DoGetEditorClass() const
1274 return wxPGEditor_TextCtrl
;
1277 // Default extra property event handling - that is, none at all.
1278 bool wxPGProperty::OnEvent( wxPropertyGrid
*, wxWindow
*, wxEvent
& )
1284 void wxPGProperty::SetValue( wxVariant value
, wxVariant
* pList
, int flags
)
1286 // If auto unspecified values are not wanted (via window or property style),
1287 // then get default value instead of wxNullVariant.
1288 if ( value
.IsNull() && (flags
& wxPG_SETVAL_BY_USER
) &&
1289 !UsesAutoUnspecified() )
1291 value
= GetDefaultValue();
1294 if ( !value
.IsNull() )
1296 wxVariant tempListVariant
;
1299 // List variants are reserved a special purpose
1300 // as intermediate containers for child values
1301 // of properties with children.
1302 if ( value
.GetType() == wxPG_VARIANT_TYPE_LIST
)
1305 // However, situation is different for composed string properties
1306 if ( HasFlag(wxPG_PROP_COMPOSED_VALUE
) )
1308 tempListVariant
= value
;
1309 pList
= &tempListVariant
;
1313 AdaptListToValue(value
, &newValue
);
1315 //wxLogDebug(wxT(">> %s.SetValue() adapted list value to type '%s'"),GetName().c_str(),value.GetType().c_str());
1318 if ( HasFlag( wxPG_PROP_AGGREGATE
) )
1319 flags
|= wxPG_SETVAL_AGGREGATED
;
1321 if ( pList
&& !pList
->IsNull() )
1323 wxASSERT( pList
->GetType() == wxPG_VARIANT_TYPE_LIST
);
1324 wxASSERT( GetChildCount() );
1325 wxASSERT( !IsCategory() );
1327 wxVariantList
& list
= pList
->GetList();
1328 wxVariantList::iterator node
;
1331 //wxLogDebug(wxT(">> %s.SetValue() pList parsing"),GetName().c_str());
1333 // Children in list can be in any order, but we will give hint to
1334 // GetPropertyByNameWH(). This optimizes for full list parsing.
1335 for ( node
= list
.begin(); node
!= list
.end(); ++node
)
1337 wxVariant
& childValue
= *((wxVariant
*)*node
);
1338 wxPGProperty
* child
= GetPropertyByNameWH(childValue
.GetName(), i
);
1341 //wxLogDebug(wxT("%i: child = %s, childValue.GetType()=%s"),i,child->GetBaseName().c_str(),childValue.GetType().c_str());
1342 if ( childValue
.GetType() == wxPG_VARIANT_TYPE_LIST
)
1344 if ( child
->HasFlag(wxPG_PROP_AGGREGATE
) && !(flags
& wxPG_SETVAL_AGGREGATED
) )
1346 wxVariant listRefCopy
= childValue
;
1347 child
->SetValue(childValue
, &listRefCopy
, flags
|wxPG_SETVAL_FROM_PARENT
);
1351 wxVariant oldVal
= child
->GetValue();
1352 child
->SetValue(oldVal
, &childValue
, flags
|wxPG_SETVAL_FROM_PARENT
);
1355 else if ( child
->GetValue() != childValue
)
1357 // For aggregate properties, we will trust RefreshChildren()
1358 // to update child values.
1359 if ( !HasFlag(wxPG_PROP_AGGREGATE
) )
1360 child
->SetValue(childValue
, NULL
, flags
|wxPG_SETVAL_FROM_PARENT
);
1361 if ( flags
& wxPG_SETVAL_BY_USER
)
1362 child
->SetFlag(wxPG_PROP_MODIFIED
);
1369 if ( !value
.IsNull() )
1375 if ( flags
& wxPG_SETVAL_BY_USER
)
1376 SetFlag(wxPG_PROP_MODIFIED
);
1378 if ( HasFlag(wxPG_PROP_AGGREGATE
) )
1383 if ( m_commonValue
!= -1 )
1385 wxPropertyGrid
* pg
= GetGrid();
1386 if ( !pg
|| m_commonValue
!= pg
->GetUnspecifiedCommonValue() )
1392 // Set children to unspecified, but only if aggregate or
1393 // value is <composed>
1394 if ( AreChildrenComponents() )
1397 for ( i
=0; i
<GetChildCount(); i
++ )
1398 Item(i
)->SetValue(value
, NULL
, flags
|wxPG_SETVAL_FROM_PARENT
);
1402 if ( !(flags
& wxPG_SETVAL_FROM_PARENT
) )
1403 UpdateParentValues();
1406 // Update editor control.
1407 if ( flags
& wxPG_SETVAL_REFRESH_EDITOR
)
1409 wxPropertyGrid
* pg
= GetGridIfDisplayed();
1412 wxPGProperty
* selected
= pg
->GetSelectedProperty();
1414 // Only refresh the control if this was selected, or
1415 // this was some parent of selected, or vice versa)
1416 if ( selected
&& (selected
== this ||
1417 selected
->IsSomeParent(this) ||
1418 this->IsSomeParent(selected
)) )
1421 pg
->DrawItemAndValueRelated(this);
1427 void wxPGProperty::SetValueInEvent( wxVariant value
) const
1429 GetGrid()->ValueChangeInEvent(value
);
1432 void wxPGProperty::SetFlagRecursively( wxPGPropertyFlags flag
, bool set
)
1434 ChangeFlag(flag
, set
);
1437 for ( i
= 0; i
< GetChildCount(); i
++ )
1438 Item(i
)->SetFlagRecursively(flag
, set
);
1441 void wxPGProperty::RefreshEditor()
1446 wxPropertyGrid
* pg
= GetGrid();
1447 if ( pg
&& pg
->GetSelectedProperty() == this )
1448 pg
->RefreshEditor();
1451 wxVariant
wxPGProperty::GetDefaultValue() const
1453 wxVariant defVal
= GetAttribute(wxPG_ATTR_DEFAULT_VALUE
);
1454 if ( !defVal
.IsNull() )
1457 wxVariant value
= GetValue();
1459 if ( !value
.IsNull() )
1461 wxString
valueType(value
.GetType());
1463 if ( valueType
== wxPG_VARIANT_TYPE_LONG
)
1464 return wxPGVariant_Zero
;
1465 if ( valueType
== wxPG_VARIANT_TYPE_STRING
)
1466 return wxPGVariant_EmptyString
;
1467 if ( valueType
== wxPG_VARIANT_TYPE_BOOL
)
1468 return wxPGVariant_False
;
1469 if ( valueType
== wxPG_VARIANT_TYPE_DOUBLE
)
1470 return wxVariant(0.0);
1471 if ( valueType
== wxPG_VARIANT_TYPE_ARRSTRING
)
1472 return wxVariant(wxArrayString());
1473 if ( valueType
== wxS("wxLongLong") )
1474 return WXVARIANT(wxLongLong(0));
1475 if ( valueType
== wxS("wxULongLong") )
1476 return WXVARIANT(wxULongLong(0));
1477 if ( valueType
== wxS("wxColour") )
1478 return WXVARIANT(*wxBLACK
);
1480 if ( valueType
== wxPG_VARIANT_TYPE_DATETIME
)
1481 return wxVariant(wxDateTime::Now());
1483 if ( valueType
== wxS("wxFont") )
1484 return WXVARIANT(*wxNORMAL_FONT
);
1485 if ( valueType
== wxS("wxPoint") )
1486 return WXVARIANT(wxPoint(0, 0));
1487 if ( valueType
== wxS("wxSize") )
1488 return WXVARIANT(wxSize(0, 0));
1494 void wxPGProperty::EnsureCells( unsigned int column
)
1496 if ( column
>= m_cells
.size() )
1498 // Fill empty slots with default cells
1499 wxPropertyGrid
* pg
= GetGrid();
1500 wxPGCell defaultCell
;
1502 // Work around possible VC6 bug by using intermediate variables
1503 const wxPGCell
& propDefCell
= pg
->GetPropertyDefaultCell();
1504 const wxPGCell
& catDefCell
= pg
->GetCategoryDefaultCell();
1506 if ( !HasFlag(wxPG_PROP_CATEGORY
) )
1507 defaultCell
= propDefCell
;
1509 defaultCell
= catDefCell
;
1511 // TODO: Replace with resize() call
1512 unsigned int cellCountMax
= column
+1;
1514 for ( unsigned int i
=m_cells
.size(); i
<cellCountMax
; i
++ )
1515 m_cells
.push_back(defaultCell
);
1519 void wxPGProperty::SetCell( int column
,
1520 const wxPGCell
& cell
)
1522 EnsureCells(column
);
1524 m_cells
[column
] = cell
;
1527 void wxPGProperty::AdaptiveSetCell( unsigned int firstCol
,
1528 unsigned int lastCol
,
1529 const wxPGCell
& cell
,
1530 const wxPGCell
& srcData
,
1531 wxPGCellData
* unmodCellData
,
1532 FlagType ignoreWithFlags
,
1536 // Sets cell in memory optimizing fashion. That is, if
1537 // current cell data matches unmodCellData, we will
1538 // simply get reference to data from cell. Otherwise,
1539 // cell information from srcData is merged into current.
1542 if ( !(m_flags
& ignoreWithFlags
) && !IsRoot() )
1544 EnsureCells(lastCol
);
1546 for ( unsigned int col
=firstCol
; col
<=lastCol
; col
++ )
1548 if ( m_cells
[col
].GetData() == unmodCellData
)
1550 // Data matches... use cell directly
1551 m_cells
[col
] = cell
;
1555 // Data did not match... merge valid information
1556 m_cells
[col
].MergeFrom(srcData
);
1563 for ( unsigned int i
=0; i
<GetChildCount(); i
++ )
1564 Item(i
)->AdaptiveSetCell( firstCol
,
1574 const wxPGCell
& wxPGProperty::GetCell( unsigned int column
) const
1576 if ( m_cells
.size() > column
)
1577 return m_cells
[column
];
1579 wxPropertyGrid
* pg
= GetGrid();
1582 return pg
->GetCategoryDefaultCell();
1584 return pg
->GetPropertyDefaultCell();
1587 wxPGCell
& wxPGProperty::GetOrCreateCell( unsigned int column
)
1589 EnsureCells(column
);
1590 return m_cells
[column
];
1593 void wxPGProperty::SetBackgroundColour( const wxColour
& colour
,
1596 wxPGProperty
* firstProp
= this;
1597 bool recursively
= flags
& wxPG_RECURSE
? true : false;
1600 // If category is tried to set recursively, skip it and only
1601 // affect the children.
1604 while ( firstProp
->IsCategory() )
1606 if ( !firstProp
->GetChildCount() )
1608 firstProp
= firstProp
->Item(0);
1612 wxPGCell
& firstCell
= firstProp
->GetCell(0);
1613 wxPGCellData
* firstCellData
= firstCell
.GetData();
1615 wxPGCell
newCell(firstCell
);
1616 newCell
.SetBgCol(colour
);
1618 srcCell
.SetBgCol(colour
);
1621 GetParentState()->GetColumnCount()-1,
1625 recursively
? wxPG_PROP_CATEGORY
: 0,
1629 void wxPGProperty::SetTextColour( const wxColour
& colour
,
1632 wxPGProperty
* firstProp
= this;
1633 bool recursively
= flags
& wxPG_RECURSE
? true : false;
1636 // If category is tried to set recursively, skip it and only
1637 // affect the children.
1640 while ( firstProp
->IsCategory() )
1642 if ( !firstProp
->GetChildCount() )
1644 firstProp
= firstProp
->Item(0);
1648 wxPGCell
& firstCell
= firstProp
->GetCell(0);
1649 wxPGCellData
* firstCellData
= firstCell
.GetData();
1651 wxPGCell
newCell(firstCell
);
1652 newCell
.SetFgCol(colour
);
1654 srcCell
.SetFgCol(colour
);
1657 GetParentState()->GetColumnCount()-1,
1661 recursively
? wxPG_PROP_CATEGORY
: 0,
1665 wxPGEditorDialogAdapter
* wxPGProperty::GetEditorDialog() const
1670 bool wxPGProperty::DoSetAttribute( const wxString
& WXUNUSED(name
), wxVariant
& WXUNUSED(value
) )
1675 void wxPGProperty::SetAttribute( const wxString
& name
, wxVariant value
)
1677 if ( DoSetAttribute( name
, value
) )
1679 // Support working without grid, when possible
1680 if ( wxPGGlobalVars
->HasExtraStyle( wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES
) )
1684 m_attributes
.Set( name
, value
);
1687 void wxPGProperty::SetAttributes( const wxPGAttributeStorage
& attributes
)
1689 wxPGAttributeStorage::const_iterator it
= attributes
.StartIteration();
1692 while ( attributes
.GetNext(it
, variant
) )
1693 SetAttribute( variant
.GetName(), variant
);
1696 wxVariant
wxPGProperty::DoGetAttribute( const wxString
& WXUNUSED(name
) ) const
1702 wxVariant
wxPGProperty::GetAttribute( const wxString
& name
) const
1704 return m_attributes
.FindValue(name
);
1707 wxString
wxPGProperty::GetAttribute( const wxString
& name
, const wxString
& defVal
) const
1709 wxVariant variant
= m_attributes
.FindValue(name
);
1711 if ( !variant
.IsNull() )
1712 return variant
.GetString();
1717 long wxPGProperty::GetAttributeAsLong( const wxString
& name
, long defVal
) const
1719 wxVariant variant
= m_attributes
.FindValue(name
);
1721 if ( variant
.IsNull() )
1724 return variant
.GetLong();
1727 double wxPGProperty::GetAttributeAsDouble( const wxString
& name
, double defVal
) const
1729 wxVariant variant
= m_attributes
.FindValue(name
);
1731 if ( variant
.IsNull() )
1734 return variant
.GetDouble();
1737 wxVariant
wxPGProperty::GetAttributesAsList() const
1739 wxVariantList tempList
;
1740 wxVariant
v( tempList
, wxString::Format(wxS("@%s@attr"),m_name
.c_str()) );
1742 wxPGAttributeStorage::const_iterator it
= m_attributes
.StartIteration();
1745 while ( m_attributes
.GetNext(it
, variant
) )
1751 // Slots of utility flags are NULL
1752 const unsigned int gs_propFlagToStringSize
= 14;
1754 static const wxChar
* const gs_propFlagToString
[gs_propFlagToStringSize
] = {
1771 wxString
wxPGProperty::GetFlagsAsString( FlagType flagsMask
) const
1774 int relevantFlags
= m_flags
& flagsMask
& wxPG_STRING_STORED_FLAGS
;
1778 for ( i
=0; i
<gs_propFlagToStringSize
; i
++ )
1780 if ( relevantFlags
& a
)
1782 const wxChar
* fs
= gs_propFlagToString
[i
];
1794 void wxPGProperty::SetFlagsFromString( const wxString
& str
)
1798 WX_PG_TOKENIZER1_BEGIN(str
, wxS('|'))
1800 for ( i
=0; i
<gs_propFlagToStringSize
; i
++ )
1802 const wxChar
* fs
= gs_propFlagToString
[i
];
1803 if ( fs
&& str
== fs
)
1809 WX_PG_TOKENIZER1_END()
1811 m_flags
= (m_flags
& ~wxPG_STRING_STORED_FLAGS
) | flags
;
1814 wxValidator
* wxPGProperty::DoGetValidator() const
1819 int wxPGProperty::InsertChoice( const wxString
& label
, int index
, int value
)
1821 wxPropertyGrid
* pg
= GetGrid();
1822 int sel
= GetChoiceSelection();
1826 if ( index
== wxNOT_FOUND
)
1827 index
= m_choices
.GetCount();
1832 m_choices
.Insert(label
, index
, value
);
1834 if ( sel
!= newSel
)
1835 SetChoiceSelection(newSel
);
1837 if ( this == pg
->GetSelection() )
1838 GetEditorClass()->InsertItem(pg
->GetEditorControl(),label
,index
);
1844 void wxPGProperty::DeleteChoice( int index
)
1846 wxPropertyGrid
* pg
= GetGrid();
1848 int sel
= GetChoiceSelection();
1851 // Adjust current value
1854 SetValueToUnspecified();
1857 else if ( index
< sel
)
1862 m_choices
.RemoveAt(index
);
1864 if ( sel
!= newSel
)
1865 SetChoiceSelection(newSel
);
1867 if ( this == pg
->GetSelection() )
1868 GetEditorClass()->DeleteItem(pg
->GetEditorControl(), index
);
1871 int wxPGProperty::GetChoiceSelection() const
1873 wxVariant value
= GetValue();
1874 wxString valueType
= value
.GetType();
1875 int index
= wxNOT_FOUND
;
1877 if ( IsValueUnspecified() || !m_choices
.GetCount() )
1880 if ( valueType
== wxPG_VARIANT_TYPE_LONG
)
1882 index
= value
.GetLong();
1884 else if ( valueType
== wxPG_VARIANT_TYPE_STRING
)
1886 index
= m_choices
.Index(value
.GetString());
1888 else if ( valueType
== wxPG_VARIANT_TYPE_BOOL
)
1890 index
= value
.GetBool()? 1 : 0;
1896 void wxPGProperty::SetChoiceSelection( int newValue
)
1898 // Changes value of a property with choices, but only
1899 // works if the value type is long or string.
1900 wxString valueType
= GetValue().GetType();
1902 wxCHECK_RET( m_choices
.IsOk(), wxT("invalid choiceinfo") );
1904 if ( valueType
== wxPG_VARIANT_TYPE_STRING
)
1906 SetValue( m_choices
.GetLabel(newValue
) );
1908 else // if ( valueType == wxPG_VARIANT_TYPE_LONG )
1910 SetValue( (long) newValue
);
1914 bool wxPGProperty::SetChoices( wxPGChoices
& choices
)
1916 // Property must be de-selected first (otherwise choices in
1917 // the control would be de-synced with true choices)
1918 wxPropertyGrid
* pg
= GetGrid();
1919 if ( pg
&& pg
->GetSelection() == this )
1920 pg
->ClearSelection();
1922 m_choices
.Assign(choices
);
1925 // This may be needed to trigger some initialization
1926 // (but don't do it if property is somewhat uninitialized)
1927 wxVariant defVal
= GetDefaultValue();
1928 if ( defVal
.IsNull() )
1938 const wxPGEditor
* wxPGProperty::GetEditorClass() const
1940 const wxPGEditor
* editor
;
1942 if ( !m_customEditor
)
1944 editor
= DoGetEditorClass();
1947 editor
= m_customEditor
;
1950 // Maybe override editor if common value specified
1951 if ( GetDisplayedCommonValueCount() )
1953 // TextCtrlAndButton -> ComboBoxAndButton
1954 if ( editor
->IsKindOf(CLASSINFO(wxPGTextCtrlAndButtonEditor
)) )
1955 editor
= wxPGEditor_ChoiceAndButton
;
1957 // TextCtrl -> ComboBox
1958 else if ( editor
->IsKindOf(CLASSINFO(wxPGTextCtrlEditor
)) )
1959 editor
= wxPGEditor_ComboBox
;
1965 bool wxPGProperty::Hide( bool hide
, int flags
)
1967 wxPropertyGrid
* pg
= GetGrid();
1969 return pg
->HideProperty(this, hide
, flags
);
1971 return DoHide( hide
, flags
);
1974 bool wxPGProperty::DoHide( bool hide
, int flags
)
1977 ClearFlag( wxPG_PROP_HIDDEN
);
1979 SetFlag( wxPG_PROP_HIDDEN
);
1981 if ( flags
& wxPG_RECURSE
)
1984 for ( i
= 0; i
< GetChildCount(); i
++ )
1985 Item(i
)->DoHide(hide
, flags
| wxPG_RECURSE_STARTS
);
1991 bool wxPGProperty::HasVisibleChildren() const
1995 for ( i
=0; i
<GetChildCount(); i
++ )
1997 wxPGProperty
* child
= Item(i
);
1999 if ( !child
->HasFlag(wxPG_PROP_HIDDEN
) )
2006 bool wxPGProperty::RecreateEditor()
2008 wxPropertyGrid
* pg
= GetGrid();
2011 wxPGProperty
* selected
= pg
->GetSelection();
2012 if ( this == selected
)
2014 pg
->DoSelectProperty(this, wxPG_SEL_FORCE
);
2021 void wxPGProperty::SetValueImage( wxBitmap
& bmp
)
2023 delete m_valueBitmap
;
2025 if ( &bmp
&& bmp
.Ok() )
2028 wxSize maxSz
= GetGrid()->GetImageSize();
2029 wxSize
imSz(bmp
.GetWidth(),bmp
.GetHeight());
2031 if ( imSz
.y
!= maxSz
.y
)
2033 // Create a memory DC
2034 wxBitmap
* bmpNew
= new wxBitmap(maxSz
.x
,maxSz
.y
,bmp
.GetDepth());
2037 dc
.SelectObject(*bmpNew
);
2040 // FIXME: This is ugly - use image or wait for scaling patch.
2041 double scaleY
= (double)maxSz
.y
/ (double)imSz
.y
;
2043 dc
.SetUserScale(scaleY
, scaleY
);
2045 dc
.DrawBitmap(bmp
, 0, 0);
2047 m_valueBitmap
= bmpNew
;
2051 m_valueBitmap
= new wxBitmap(bmp
);
2054 m_flags
|= wxPG_PROP_CUSTOMIMAGE
;
2058 m_valueBitmap
= NULL
;
2059 m_flags
&= ~(wxPG_PROP_CUSTOMIMAGE
);
2064 wxPGProperty
* wxPGProperty::GetMainParent() const
2066 const wxPGProperty
* curChild
= this;
2067 const wxPGProperty
* curParent
= m_parent
;
2069 while ( curParent
&& !curParent
->IsCategory() )
2071 curChild
= curParent
;
2072 curParent
= curParent
->m_parent
;
2075 return (wxPGProperty
*) curChild
;
2079 const wxPGProperty
* wxPGProperty::GetLastVisibleSubItem() const
2082 // Returns last visible sub-item, recursively.
2083 if ( !IsExpanded() || !GetChildCount() )
2086 return Last()->GetLastVisibleSubItem();
2090 bool wxPGProperty::IsVisible() const
2092 const wxPGProperty
* parent
;
2094 if ( HasFlag(wxPG_PROP_HIDDEN
) )
2097 for ( parent
= GetParent(); parent
!= NULL
; parent
= parent
->GetParent() )
2099 if ( !parent
->IsExpanded() || parent
->HasFlag(wxPG_PROP_HIDDEN
) )
2106 wxPropertyGrid
* wxPGProperty::GetGridIfDisplayed() const
2108 wxPropertyGridPageState
* state
= GetParentState();
2111 wxPropertyGrid
* propGrid
= state
->GetGrid();
2112 if ( state
== propGrid
->GetState() )
2118 int wxPGProperty::GetY2( int lh
) const
2120 const wxPGProperty
* parent
;
2121 const wxPGProperty
* child
= this;
2125 for ( parent
= GetParent(); parent
!= NULL
; parent
= child
->GetParent() )
2127 if ( !parent
->IsExpanded() )
2129 y
+= parent
->GetChildrenHeight(lh
, child
->GetIndexInParent());
2134 y
-= lh
; // need to reduce one level
2140 int wxPGProperty::GetY() const
2142 return GetY2(GetGrid()->GetRowHeight());
2145 // This is used by Insert etc.
2146 void wxPGProperty::DoAddChild( wxPGProperty
* prop
, int index
,
2149 if ( index
< 0 || (size_t)index
>= m_children
.size() )
2151 if ( correct_mode
) prop
->m_arrIndex
= m_children
.size();
2152 m_children
.push_back( prop
);
2156 m_children
.insert( m_children
.begin()+index
, prop
);
2157 if ( correct_mode
) FixIndicesOfChildren( index
);
2160 prop
->m_parent
= this;
2163 void wxPGProperty::DoPreAddChild( int index
, wxPGProperty
* prop
)
2165 wxASSERT_MSG( prop
->GetBaseName().length(),
2166 "Property's children must have unique, non-empty "
2167 "names within their scope" );
2169 prop
->m_arrIndex
= index
;
2170 m_children
.insert( m_children
.begin()+index
,
2173 int custImgHeight
= prop
->OnMeasureImage().y
;
2174 if ( custImgHeight
< 0 /*|| custImgHeight > 1*/ )
2175 prop
->m_flags
|= wxPG_PROP_CUSTOMIMAGE
;
2177 prop
->m_parent
= this;
2180 void wxPGProperty::AddPrivateChild( wxPGProperty
* prop
)
2182 if ( !(m_flags
& wxPG_PROP_PARENTAL_FLAGS
) )
2183 SetParentalType(wxPG_PROP_AGGREGATE
);
2185 wxASSERT_MSG( (m_flags
& wxPG_PROP_PARENTAL_FLAGS
) ==
2186 wxPG_PROP_AGGREGATE
,
2187 "Do not mix up AddPrivateChild() calls with other "
2188 "property adders." );
2190 DoPreAddChild( m_children
.size(), prop
);
2193 #if wxPG_COMPATIBILITY_1_4
2194 void wxPGProperty::AddChild( wxPGProperty
* prop
)
2196 AddPrivateChild(prop
);
2200 wxPGProperty
* wxPGProperty::InsertChild( int index
,
2201 wxPGProperty
* childProperty
)
2204 index
= m_children
.size();
2206 if ( m_parentState
)
2208 m_parentState
->DoInsert(this, index
, childProperty
);
2212 if ( !(m_flags
& wxPG_PROP_PARENTAL_FLAGS
) )
2213 SetParentalType(wxPG_PROP_MISC_PARENT
);
2215 wxASSERT_MSG( (m_flags
& wxPG_PROP_PARENTAL_FLAGS
) ==
2216 wxPG_PROP_MISC_PARENT
,
2217 "Do not mix up AddPrivateChild() calls with other "
2218 "property adders." );
2220 DoPreAddChild( index
, childProperty
);
2223 return childProperty
;
2226 void wxPGProperty::RemoveChild( wxPGProperty
* p
)
2228 wxArrayPGProperty::iterator it
;
2229 wxArrayPGProperty
& children
= m_children
;
2231 for ( it
=children
.begin(); it
!= children
.end(); it
++ )
2241 void wxPGProperty::AdaptListToValue( wxVariant
& list
, wxVariant
* value
) const
2243 wxASSERT( GetChildCount() );
2244 wxASSERT( !IsCategory() );
2246 *value
= GetValue();
2248 if ( !list
.GetCount() )
2251 wxASSERT( GetChildCount() >= (unsigned int)list
.GetCount() );
2253 bool allChildrenSpecified
;
2255 // Don't fully update aggregate properties unless all children have
2257 if ( HasFlag(wxPG_PROP_AGGREGATE
) )
2258 allChildrenSpecified
= AreAllChildrenSpecified(&list
);
2260 allChildrenSpecified
= true;
2262 wxVariant childValue
= list
[0];
2266 //wxLogDebug(wxT(">> %s.AdaptListToValue()"),GetBaseName().c_str());
2268 for ( i
=0; i
<GetChildCount(); i
++ )
2270 const wxPGProperty
* child
= Item(i
);
2272 if ( childValue
.GetName() == child
->GetBaseName() )
2274 //wxLogDebug(wxT(" %s(n=%i), %s"),childValue.GetName().c_str(),n,childValue.GetType().c_str());
2276 if ( childValue
.GetType() == wxPG_VARIANT_TYPE_LIST
)
2278 wxVariant
cv2(child
->GetValue());
2279 child
->AdaptListToValue(childValue
, &cv2
);
2283 if ( allChildrenSpecified
)
2285 *value
= ChildChanged(*value
, i
, childValue
);
2289 if ( n
== (unsigned int)list
.GetCount() )
2291 childValue
= list
[n
];
2297 void wxPGProperty::FixIndicesOfChildren( unsigned int starthere
)
2300 for ( i
=starthere
;i
<GetChildCount();i
++)
2301 Item(i
)->m_arrIndex
= i
;
2305 // Returns (direct) child property with given name (or NULL if not found)
2306 wxPGProperty
* wxPGProperty::GetPropertyByName( const wxString
& name
) const
2310 for ( i
=0; i
<GetChildCount(); i
++ )
2312 wxPGProperty
* p
= Item(i
);
2313 if ( p
->m_name
== name
)
2317 // Does it have point, then?
2318 int pos
= name
.Find(wxS('.'));
2322 wxPGProperty
* p
= GetPropertyByName(name
. substr(0,pos
));
2324 if ( !p
|| !p
->GetChildCount() )
2327 return p
->GetPropertyByName(name
.substr(pos
+1,name
.length()-pos
-1));
2330 wxPGProperty
* wxPGProperty::GetPropertyByNameWH( const wxString
& name
, unsigned int hintIndex
) const
2332 unsigned int i
= hintIndex
;
2334 if ( i
>= GetChildCount() )
2337 unsigned int lastIndex
= i
- 1;
2339 if ( lastIndex
>= GetChildCount() )
2340 lastIndex
= GetChildCount() - 1;
2344 wxPGProperty
* p
= Item(i
);
2345 if ( p
->m_name
== name
)
2348 if ( i
== lastIndex
)
2352 if ( i
== GetChildCount() )
2359 int wxPGProperty::GetChildrenHeight( int lh
, int iMax_
) const
2361 // Returns height of children, recursively, and
2362 // by taking expanded/collapsed status into account.
2364 // iMax is used when finding property y-positions.
2370 iMax_
= GetChildCount();
2372 unsigned int iMax
= iMax_
;
2374 wxASSERT( iMax
<= GetChildCount() );
2376 if ( !IsExpanded() && GetParent() )
2381 wxPGProperty
* pwc
= (wxPGProperty
*) Item(i
);
2383 if ( !pwc
->HasFlag(wxPG_PROP_HIDDEN
) )
2385 if ( !pwc
->IsExpanded() ||
2386 pwc
->GetChildCount() == 0 )
2389 h
+= pwc
->GetChildrenHeight(lh
) + lh
;
2398 wxPGProperty
* wxPGProperty::GetItemAtY( unsigned int y
,
2400 unsigned int* nextItemY
) const
2402 wxASSERT( nextItemY
);
2404 // Linear search at the moment
2406 // nextItemY = y of next visible property, final value will be written back.
2407 wxPGProperty
* result
= NULL
;
2408 wxPGProperty
* current
= NULL
;
2409 unsigned int iy
= *nextItemY
;
2411 unsigned int iMax
= GetChildCount();
2415 wxPGProperty
* pwc
= Item(i
);
2417 if ( !pwc
->HasFlag(wxPG_PROP_HIDDEN
) )
2428 if ( pwc
->IsExpanded() &&
2429 pwc
->GetChildCount() > 0 )
2431 result
= (wxPGProperty
*) pwc
->GetItemAtY( y
, lh
, &iy
);
2443 if ( !result
&& y
< iy
)
2451 wxLogDebug(wxT("%s::GetItemAtY(%i) -> %s"),this->GetLabel().c_str(),y,current->GetLabel().c_str());
2455 wxLogDebug(wxT("%s::GetItemAtY(%i) -> NULL"),this->GetLabel().c_str(),y);
2459 return (wxPGProperty
*) result
;
2462 void wxPGProperty::Empty()
2465 if ( !HasFlag(wxPG_PROP_CHILDREN_ARE_COPIES
) )
2467 for ( i
=0; i
<GetChildCount(); i
++ )
2469 delete m_children
[i
];
2476 wxPGProperty
* wxPGProperty::GetItemAtY( unsigned int y
) const
2478 unsigned int nextItem
;
2479 return GetItemAtY( y
, GetGrid()->GetRowHeight(), &nextItem
);
2482 void wxPGProperty::DeleteChildren()
2484 wxPropertyGridPageState
* state
= m_parentState
;
2486 if ( !GetChildCount() )
2489 // Because deletion is sometimes deferred, we have to use
2490 // this sort of code for enumerating the child properties.
2491 unsigned int i
= GetChildCount();
2495 state
->DoDelete(Item(i
), true);
2499 wxVariant
wxPGProperty::ChildChanged( wxVariant
& WXUNUSED(thisValue
),
2500 int WXUNUSED(childIndex
),
2501 wxVariant
& WXUNUSED(childValue
) ) const
2503 return wxNullVariant
;
2506 bool wxPGProperty::AreAllChildrenSpecified( wxVariant
* pendingList
) const
2510 const wxVariantList
* pList
= NULL
;
2511 wxVariantList::const_iterator node
;
2515 pList
= &pendingList
->GetList();
2516 node
= pList
->begin();
2519 for ( i
=0; i
<GetChildCount(); i
++ )
2521 wxPGProperty
* child
= Item(i
);
2522 const wxVariant
* listValue
= NULL
;
2527 const wxString
& childName
= child
->GetBaseName();
2529 for ( ; node
!= pList
->end(); ++node
)
2531 const wxVariant
& item
= *((const wxVariant
*)*node
);
2532 if ( item
.GetName() == childName
)
2542 value
= child
->GetValue();
2544 if ( value
.IsNull() )
2547 // Check recursively
2548 if ( child
->GetChildCount() )
2550 const wxVariant
* childList
= NULL
;
2552 if ( listValue
&& listValue
->GetType() == wxPG_VARIANT_TYPE_LIST
)
2553 childList
= listValue
;
2555 if ( !child
->AreAllChildrenSpecified((wxVariant
*)childList
) )
2563 wxPGProperty
* wxPGProperty::UpdateParentValues()
2565 wxPGProperty
* parent
= m_parent
;
2566 if ( parent
&& parent
->HasFlag(wxPG_PROP_COMPOSED_VALUE
) &&
2567 !parent
->IsCategory() && !parent
->IsRoot() )
2570 parent
->DoGenerateComposedValue(s
);
2571 parent
->m_value
= s
;
2572 return parent
->UpdateParentValues();
2577 bool wxPGProperty::IsTextEditable() const
2579 if ( HasFlag(wxPG_PROP_READONLY
) )
2582 if ( HasFlag(wxPG_PROP_NOEDITOR
) &&
2584 wxString(GetEditorClass()->GetClassInfo()->GetClassName()).EndsWith(wxS("Button")))
2591 // Call after fixed sub-properties added/removed after creation.
2592 // if oldSelInd >= 0 and < new max items, then selection is
2593 // moved to it. Note: oldSelInd -2 indicates that this property
2594 // should be selected.
2595 void wxPGProperty::SubPropsChanged( int oldSelInd
)
2597 wxPropertyGridPageState
* state
= GetParentState();
2598 wxPropertyGrid
* grid
= state
->GetGrid();
2601 // Re-repare children (recursively)
2602 for ( unsigned int i
=0; i
<GetChildCount(); i
++ )
2604 wxPGProperty
* child
= Item(i
);
2605 child
->InitAfterAdded(state
, grid
);
2608 wxPGProperty
* sel
= NULL
;
2609 if ( oldSelInd
>= (int)m_children
.size() )
2610 oldSelInd
= (int)m_children
.size() - 1;
2612 if ( oldSelInd
>= 0 )
2613 sel
= m_children
[oldSelInd
];
2614 else if ( oldSelInd
== -2 )
2618 state
->DoSelectProperty(sel
);
2620 if ( state
== grid
->GetState() )
2622 grid
->GetPanel()->Refresh();
2626 // -----------------------------------------------------------------------
2628 // -----------------------------------------------------------------------
2630 WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(wxPGRootProperty
,none
,TextCtrl
)
2631 IMPLEMENT_DYNAMIC_CLASS(wxPGRootProperty
, wxPGProperty
)
2634 wxPGRootProperty::wxPGRootProperty( const wxString
& name
)
2644 wxPGRootProperty::~wxPGRootProperty()
2649 // -----------------------------------------------------------------------
2650 // wxPropertyCategory
2651 // -----------------------------------------------------------------------
2653 WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(wxPropertyCategory
,none
,TextCtrl
)
2654 IMPLEMENT_DYNAMIC_CLASS(wxPropertyCategory
, wxPGProperty
)
2656 void wxPropertyCategory::Init()
2658 // don't set colour - prepareadditem method should do this
2659 SetParentalType(wxPG_PROP_CATEGORY
);
2660 m_capFgColIndex
= 1;
2664 wxPropertyCategory::wxPropertyCategory()
2671 wxPropertyCategory::wxPropertyCategory( const wxString
&label
, const wxString
& name
)
2672 : wxPGProperty(label
,name
)
2678 wxPropertyCategory::~wxPropertyCategory()
2683 wxString
wxPropertyCategory::ValueToString( wxVariant
& WXUNUSED(value
),
2684 int WXUNUSED(argFlags
) ) const
2686 if ( m_value
.GetType() == wxPG_VARIANT_TYPE_STRING
)
2687 return m_value
.GetString();
2688 return wxEmptyString
;
2691 wxString
wxPropertyCategory::GetValueAsString( int argFlags
) const
2693 #if wxPG_COMPATIBILITY_1_4
2694 // This is backwards compatibility test
2695 // That is, to make sure this function is not overridden
2696 // (instead, ValueToString() should be).
2697 if ( argFlags
== 0xFFFF )
2699 // Do not override! (for backwards compliancy)
2700 return g_invalidStringContent
;
2704 // Unspecified value is always empty string
2705 if ( IsValueUnspecified() )
2706 return wxEmptyString
;
2708 return wxPGProperty::GetValueAsString(argFlags
);
2711 int wxPropertyCategory::GetTextExtent( const wxWindow
* wnd
, const wxFont
& font
) const
2713 if ( m_textExtent
> 0 )
2714 return m_textExtent
;
2716 ((wxWindow
*)wnd
)->GetTextExtent( m_label
, &x
, &y
, 0, 0, &font
);
2720 void wxPropertyCategory::CalculateTextExtent( wxWindow
* wnd
, const wxFont
& font
)
2723 wnd
->GetTextExtent( m_label
, &x
, &y
, 0, 0, &font
);
2727 // -----------------------------------------------------------------------
2729 // -----------------------------------------------------------------------
2731 wxPGChoiceEntry
& wxPGChoices::Add( const wxString
& label
, int value
)
2735 wxPGChoiceEntry
entry(label
, value
);
2736 return m_data
->Insert( -1, entry
);
2739 // -----------------------------------------------------------------------
2741 wxPGChoiceEntry
& wxPGChoices::Add( const wxString
& label
, const wxBitmap
& bitmap
, int value
)
2745 wxPGChoiceEntry
entry(label
, value
);
2746 entry
.SetBitmap(bitmap
);
2747 return m_data
->Insert( -1, entry
);
2750 // -----------------------------------------------------------------------
2752 wxPGChoiceEntry
& wxPGChoices::Insert( const wxPGChoiceEntry
& entry
, int index
)
2756 return m_data
->Insert( index
, entry
);
2759 // -----------------------------------------------------------------------
2761 wxPGChoiceEntry
& wxPGChoices::Insert( const wxString
& label
, int index
, int value
)
2765 wxPGChoiceEntry
entry(label
, value
);
2766 return m_data
->Insert( index
, entry
);
2769 // -----------------------------------------------------------------------
2771 wxPGChoiceEntry
& wxPGChoices::AddAsSorted( const wxString
& label
, int value
)
2777 while ( index
< GetCount() )
2779 int cmpRes
= GetLabel(index
).Cmp(label
);
2785 wxPGChoiceEntry
entry(label
, value
);
2786 return m_data
->Insert( index
, entry
);
2789 // -----------------------------------------------------------------------
2791 void wxPGChoices::Add( const wxChar
* const* labels
, const ValArrItem
* values
)
2795 unsigned int itemcount
= 0;
2796 const wxChar
* const* p
= &labels
[0];
2797 while ( *p
) { p
++; itemcount
++; }
2800 for ( i
= 0; i
< itemcount
; i
++ )
2805 wxPGChoiceEntry
entry(labels
[i
], value
);
2806 m_data
->Insert( i
, entry
);
2810 // -----------------------------------------------------------------------
2812 void wxPGChoices::Add( const wxArrayString
& arr
, const wxArrayInt
& arrint
)
2817 unsigned int itemcount
= arr
.size();
2819 for ( i
= 0; i
< itemcount
; i
++ )
2822 if ( &arrint
&& arrint
.size() )
2824 wxPGChoiceEntry
entry(arr
[i
], value
);
2825 m_data
->Insert( i
, entry
);
2829 // -----------------------------------------------------------------------
2831 void wxPGChoices::RemoveAt(size_t nIndex
, size_t count
)
2835 wxASSERT( m_data
->GetRefCount() != -1 );
2836 m_data
->m_items
.erase(m_data
->m_items
.begin()+nIndex
,
2837 m_data
->m_items
.begin()+nIndex
+count
);
2840 // -----------------------------------------------------------------------
2842 void wxPGChoices::Clear()
2844 if ( m_data
!= wxPGChoicesEmptyData
)
2851 // -----------------------------------------------------------------------
2853 int wxPGChoices::Index( const wxString
& str
) const
2858 for ( i
=0; i
< m_data
->GetCount(); i
++ )
2860 const wxPGChoiceEntry
& entry
= m_data
->Item(i
);
2861 if ( entry
.HasText() && entry
.GetText() == str
)
2868 // -----------------------------------------------------------------------
2870 int wxPGChoices::Index( int val
) const
2875 for ( i
=0; i
< m_data
->GetCount(); i
++ )
2877 const wxPGChoiceEntry
& entry
= m_data
->Item(i
);
2878 if ( entry
.GetValue() == val
)
2885 // -----------------------------------------------------------------------
2887 wxArrayString
wxPGChoices::GetLabels() const
2892 if ( this && IsOk() )
2893 for ( i
=0; i
<GetCount(); i
++ )
2894 arr
.push_back(GetLabel(i
));
2899 // -----------------------------------------------------------------------
2901 wxArrayInt
wxPGChoices::GetValuesForStrings( const wxArrayString
& strings
) const
2908 for ( i
=0; i
< strings
.size(); i
++ )
2910 int index
= Index(strings
[i
]);
2912 arr
.Add(GetValue(index
));
2914 arr
.Add(wxPG_INVALID_VALUE
);
2921 // -----------------------------------------------------------------------
2923 wxArrayInt
wxPGChoices::GetIndicesForStrings( const wxArrayString
& strings
,
2924 wxArrayString
* unmatched
) const
2931 for ( i
=0; i
< strings
.size(); i
++ )
2933 const wxString
& str
= strings
[i
];
2934 int index
= Index(str
);
2937 else if ( unmatched
)
2938 unmatched
->Add(str
);
2945 // -----------------------------------------------------------------------
2947 void wxPGChoices::AllocExclusive()
2951 if ( m_data
->GetRefCount() != 1 )
2953 wxPGChoicesData
* data
= new wxPGChoicesData();
2954 data
->CopyDataFrom(m_data
);
2960 // -----------------------------------------------------------------------
2962 void wxPGChoices::AssignData( wxPGChoicesData
* data
)
2966 if ( data
!= wxPGChoicesEmptyData
)
2973 // -----------------------------------------------------------------------
2975 void wxPGChoices::Init()
2977 m_data
= wxPGChoicesEmptyData
;
2980 // -----------------------------------------------------------------------
2982 void wxPGChoices::Free()
2984 if ( m_data
!= wxPGChoicesEmptyData
)
2987 m_data
= wxPGChoicesEmptyData
;
2991 // -----------------------------------------------------------------------
2992 // wxPGAttributeStorage
2993 // -----------------------------------------------------------------------
2995 wxPGAttributeStorage::wxPGAttributeStorage()
2999 wxPGAttributeStorage::~wxPGAttributeStorage()
3001 wxPGHashMapS2P::iterator it
;
3003 for ( it
= m_map
.begin(); it
!= m_map
.end(); ++it
)
3005 wxVariantData
* data
= (wxVariantData
*) it
->second
;
3010 void wxPGAttributeStorage::Set( const wxString
& name
, const wxVariant
& value
)
3012 wxVariantData
* data
= value
.GetData();
3015 wxPGHashMapS2P::iterator it
= m_map
.find(name
);
3016 if ( it
!= m_map
.end() )
3018 ((wxVariantData
*)it
->second
)->DecRef();
3022 // If Null variant, just remove from set
3036 #endif // wxUSE_PROPGRID