Added and documented wxColourDatabase::AddColour.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21925 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -246,8 +246,7 @@ is only one instance of this class: {\bf wxTheColourDatabase}.
|
|||||||
|
|
||||||
\wxheading{Derived from}
|
\wxheading{Derived from}
|
||||||
|
|
||||||
\helpref{wxList}{wxlist}\\
|
None
|
||||||
\helpref{wxObject}{wxobject}
|
|
||||||
|
|
||||||
\wxheading{Include files}
|
\wxheading{Include files}
|
||||||
|
|
||||||
@@ -282,6 +281,13 @@ YELLOW GREEN.
|
|||||||
|
|
||||||
Constructs the colour database.
|
Constructs the colour database.
|
||||||
|
|
||||||
|
\membersection{wxColourDatabase::AddColour}\label{wxcolourdatabaseaddcolour}
|
||||||
|
|
||||||
|
\func{void}{AddColour}{\param{const wxString\& }{colourName}, \param{wxColour* }{colour}}
|
||||||
|
|
||||||
|
Adds a colour to the database. If a colour with the same name already exists,
|
||||||
|
it is replaced.
|
||||||
|
|
||||||
\membersection{wxColourDatabase::FindColour}\label{wxcolourdatabasefindcolour}
|
\membersection{wxColourDatabase::FindColour}\label{wxcolourdatabasefindcolour}
|
||||||
|
|
||||||
\func{wxColour*}{FindColour}{\param{const wxString\& }{colourName}}
|
\func{wxColour*}{FindColour}{\param{const wxString\& }{colourName}}
|
||||||
|
@@ -431,6 +431,7 @@ public:
|
|||||||
wxColour *FindColour(const wxString& colour) ;
|
wxColour *FindColour(const wxString& colour) ;
|
||||||
wxColour *FindColourNoAdd(const wxString& colour) const;
|
wxColour *FindColourNoAdd(const wxString& colour) const;
|
||||||
wxString FindName(const wxColour& colour) const;
|
wxString FindName(const wxColour& colour) const;
|
||||||
|
void AddColour(const wxString& name, wxColour* colour);
|
||||||
void Initialize();
|
void Initialize();
|
||||||
#ifdef __WXPM__
|
#ifdef __WXPM__
|
||||||
// PM keeps its own type of colour table
|
// PM keeps its own type of colour table
|
||||||
|
@@ -196,10 +196,7 @@ wxColourDatabase::wxColourDatabase ()
|
|||||||
|
|
||||||
wxColourDatabase::~wxColourDatabase ()
|
wxColourDatabase::~wxColourDatabase ()
|
||||||
{
|
{
|
||||||
typedef wxStringToColourHashMap::iterator iterator;
|
WX_CLEAR_HASH_MAP(wxStringToColourHashMap, *m_map);
|
||||||
|
|
||||||
for( iterator it = m_map->begin(), en = m_map->end(); it != en; ++it )
|
|
||||||
delete it->second;
|
|
||||||
|
|
||||||
delete m_map;
|
delete m_map;
|
||||||
m_map = NULL;
|
m_map = NULL;
|
||||||
@@ -289,6 +286,7 @@ void wxColourDatabase::Initialize ()
|
|||||||
{wxT("WHITE"), 255, 255, 255},
|
{wxT("WHITE"), 255, 255, 255},
|
||||||
{wxT("YELLOW"), 255, 255, 0},
|
{wxT("YELLOW"), 255, 255, 0},
|
||||||
{wxT("YELLOW GREEN"), 153, 204, 50},
|
{wxT("YELLOW GREEN"), 153, 204, 50},
|
||||||
|
{wxT("YELLOW GREEN"), 153, 204, 50}
|
||||||
};
|
};
|
||||||
|
|
||||||
size_t n;
|
size_t n;
|
||||||
@@ -296,7 +294,7 @@ void wxColourDatabase::Initialize ()
|
|||||||
for ( n = 0; n < WXSIZEOF(wxColourTable); n++ )
|
for ( n = 0; n < WXSIZEOF(wxColourTable); n++ )
|
||||||
{
|
{
|
||||||
const wxColourDesc& cc = wxColourTable[n];
|
const wxColourDesc& cc = wxColourTable[n];
|
||||||
(*m_map)[cc.name] = new wxColour(cc.r,cc.g,cc.b);
|
AddColour(cc.name, new wxColour(cc.r,cc.g,cc.b));
|
||||||
}
|
}
|
||||||
#ifdef __WXPM__
|
#ifdef __WXPM__
|
||||||
m_palTable = new long[n];
|
m_palTable = new long[n];
|
||||||
@@ -328,6 +326,26 @@ wxColour *wxColourDatabase::FindColourNoAdd(const wxString& colour) const
|
|||||||
return ((wxColourDatabase*)this)->FindColour(colour, false);
|
return ((wxColourDatabase*)this)->FindColour(colour, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxColourDatabase::AddColour (const wxString& name, wxColour* colour)
|
||||||
|
{
|
||||||
|
wxString colName = name;
|
||||||
|
colName.MakeUpper();
|
||||||
|
wxString colName2 = colName;
|
||||||
|
if ( !colName2.Replace(_T("GRAY"), _T("GREY")) )
|
||||||
|
colName2.clear();
|
||||||
|
|
||||||
|
wxStringToColourHashMap::iterator it = m_map->find(colName);
|
||||||
|
if ( it == m_map->end() )
|
||||||
|
it = m_map->find(colName2);
|
||||||
|
if ( it != m_map->end() )
|
||||||
|
{
|
||||||
|
delete it->second;
|
||||||
|
it->second = colour;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*m_map)[name] = colour;
|
||||||
|
}
|
||||||
|
|
||||||
wxColour *wxColourDatabase::FindColour(const wxString& colour, bool add)
|
wxColour *wxColourDatabase::FindColour(const wxString& colour, bool add)
|
||||||
{
|
{
|
||||||
// VZ: make the comparaison case insensitive and also match both grey and
|
// VZ: make the comparaison case insensitive and also match both grey and
|
||||||
@@ -377,7 +395,7 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour, bool add)
|
|||||||
delete col;
|
delete col;
|
||||||
return (wxColour *) NULL;
|
return (wxColour *) NULL;
|
||||||
}
|
}
|
||||||
(*m_map)[colour] = col;
|
AddColour(colour, col);
|
||||||
return col;
|
return col;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -405,7 +423,7 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour, bool add)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxColour *col = new wxColour(r, g, b);
|
wxColour *col = new wxColour(r, g, b);
|
||||||
(*m_map)[colour] = col;
|
AddColour(colour, col);
|
||||||
|
|
||||||
return col;
|
return col;
|
||||||
#endif // __X__
|
#endif // __X__
|
||||||
|
Reference in New Issue
Block a user