]> git.saurik.com Git - wxWidgets.git/commitdiff
Check for existing colour names when adding to wxTheColourDatabase
authorRobin Dunn <robin@alldunn.com>
Thu, 7 Feb 2002 01:44:05 +0000 (01:44 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 7 Feb 2002 01:44:05 +0000 (01:44 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14041 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/demo/ColourDB.py
wxPython/src/gdi.i
wxPython/src/msw/gdi.cpp

index 91878075131596194ddead81af8f586fc4ace510..8e00407dba60196db5cca2dfaecf4b137762c8d1 100644 (file)
@@ -17,6 +17,7 @@ class TestWindow(wxScrolledWindow):
         wxScrolledWindow.__init__(self, parent, -1)
 
         self.clrList = colourdb.getColourList()
         wxScrolledWindow.__init__(self, parent, -1)
 
         self.clrList = colourdb.getColourList()
+        #self.clrList.sort()
         self.bg_bmp = images.getGridBGBitmap()
 
         EVT_PAINT(self, self.OnPaint)
         self.bg_bmp = images.getGridBGBitmap()
 
         EVT_PAINT(self, self.OnPaint)
index 117d7c97796837d008e061d1f5ae1541c6518d97..a8d6dd79bc5a9a756ce1ed4f1031ee2b265004bb 100644 (file)
@@ -643,6 +643,25 @@ public:
 
     %addmethods {
         void Append(const wxString& name, int red, int green, int blue) {
 
     %addmethods {
         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));
         }
     }
index 4b21d4fe4e880153624513b57c217e4309ffdeec..7edbe17540f91a3badf8d163820335da161e5840 100644 (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));
         }
 static PyObject *_wrap_wxColourDatabase_Append(PyObject *self, PyObject *args, PyObject *kwargs) {
             self->Append(name.c_str(), new wxColour(red, green, blue));
         }
 static PyObject *_wrap_wxColourDatabase_Append(PyObject *self, PyObject *args, PyObject *kwargs) {