Check for existing colour names when adding to wxTheColourDatabase

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14041 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-02-07 01:44:05 +00:00
parent 1192dbd450
commit fe40185d40
3 changed files with 39 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ class TestWindow(wxScrolledWindow):
wxScrolledWindow.__init__(self, parent, -1) wxScrolledWindow.__init__(self, parent, -1)
self.clrList = colourdb.getColourList() self.clrList = colourdb.getColourList()
#self.clrList.sort()
self.bg_bmp = images.getGridBGBitmap() self.bg_bmp = images.getGridBGBitmap()
EVT_PAINT(self, self.OnPaint) EVT_PAINT(self, self.OnPaint)

View File

@@ -643,6 +643,25 @@ public:
%addmethods { %addmethods {
void Append(const wxString& name, int red, int green, int blue) { void Append(const wxString& name, int red, int green, int blue) {
// first see if the name is already there
wxString cName = name;
cName.MakeUpper();
wxString cName2 = cName;
if ( !cName2.Replace("GRAY", "GREY") )
cName2.clear();
wxNode *node = self->First();
while ( node ) {
const wxChar *key = node->GetKeyString();
if ( cName == key || cName2 == key ) {
wxColour* c = (wxColour *)node->Data();
c->Set(red, green, blue);
return;
}
node = node->Next();
}
// otherwise append the new colour
self->Append(name.c_str(), new wxColour(red, green, blue)); self->Append(name.c_str(), new wxColour(red, green, blue));
} }
} }

View File

@@ -5775,6 +5775,25 @@ static PyObject *_wrap_wxColourDatabase_FindName(PyObject *self, PyObject *args,
} }
static void wxColourDatabase_Append(wxColourDatabase *self,const wxString & name,int red,int green,int blue) { static void wxColourDatabase_Append(wxColourDatabase *self,const wxString & name,int red,int green,int blue) {
// first see if the name is already there
wxString cName = name;
cName.MakeUpper();
wxString cName2 = cName;
if ( !cName2.Replace("GRAY", "GREY") )
cName2.clear();
wxNode *node = self->First();
while ( node ) {
const wxChar *key = node->GetKeyString();
if ( cName == key || cName2 == key ) {
wxColour* c = (wxColour *)node->Data();
c->Set(red, green, blue);
return;
}
node = node->Next();
}
// otherwise append the new colour
self->Append(name.c_str(), new wxColour(red, green, blue)); self->Append(name.c_str(), new wxColour(red, green, blue));
} }
static PyObject *_wrap_wxColourDatabase_Append(PyObject *self, PyObject *args, PyObject *kwargs) { static PyObject *_wrap_wxColourDatabase_Append(PyObject *self, PyObject *args, PyObject *kwargs) {