Added wxPGChoices::Copy(), tweaked related documentation

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58432 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Jaakko Salli 2009-01-26 17:28:29 +00:00
parent 619df5a4e2
commit e1ef506e13
2 changed files with 44 additions and 4 deletions

View File

@ -737,6 +737,11 @@ private:
Helper class for managing choices of wxPropertyGrid properties.
Each entry can have label, value, bitmap, text colour, and background
colour.
wxPGChoices uses reference counting, similar to other wxWidgets classes.
This means that assignment operator and copy constructor only copy the
reference and not the actual data. Use Copy() member function to create a
real copy.
@remarks If you do not specify value for entry, index is used.
@ -754,7 +759,10 @@ public:
Init();
}
/** Copy constructor. */
/**
Copy constructor, uses reference counting. To create a real copy,
use Copy() member function instead.
*/
wxPGChoices( const wxPGChoices& a )
{
if ( a.m_data != wxPGChoicesEmptyData )
@ -853,6 +861,10 @@ public:
wxPGChoiceEntry& AddAsSorted( const wxString& label,
int value = wxPG_INVALID_VALUE );
/**
Assigns choices data, using reference counting. To create a real copy,
use Copy() member function instead.
*/
void Assign( const wxPGChoices& a )
{
AssignData(a.m_data);
@ -867,6 +879,17 @@ public:
m_data->Clear();
}
/**
Returns a real copy of the choices.
*/
wxPGChoices Copy() const
{
wxPGChoices dst;
dst.EnsureData();
dst.m_data->CopyDataFrom(m_data);
return dst;
}
void EnsureData()
{
if ( m_data == wxPGChoicesEmptyData )

View File

@ -1425,7 +1425,15 @@ public:
@class wxPGChoices
Helper class for managing choices of wxPropertyGrid properties.
Each entry can have label, value, bitmap, text colour, and background colour.
Each entry can have label, value, bitmap, text colour, and background
colour.
wxPGChoices uses reference counting, similar to other wxWidgets classes.
This means that assignment operator and copy constructor only copy the
reference and not the actual data. Use Copy() member function to create a
real copy.
@remarks If you do not specify value for entry, index is used.
@library{wxpropgrid}
@category{propgrid}
@ -1440,7 +1448,10 @@ public:
*/
wxPGChoices();
/** Copy constructor. */
/**
Copy constructor, uses reference counting. To create a real copy,
use Copy() member function instead.
*/
wxPGChoices( const wxPGChoices& a );
/** Constructor. */
@ -1481,7 +1492,8 @@ public:
wxPGChoiceEntry& AddAsSorted( const wxString& label, int value = wxPG_INVALID_VALUE );
/**
Assigns data from another set of choices.
Assigns choices data, using reference counting. To create a real copy,
use Copy() member function instead.
*/
void Assign( const wxPGChoices& a );
@ -1495,6 +1507,11 @@ public:
*/
void Clear();
/**
Returns a real copy of the choices.
*/
wxPGChoices Copy() const;
/**
Returns labe of item.
*/