]> git.saurik.com Git - wxWidgets.git/commitdiff
replaced all occurences of wxColourDatabase::FindColour() with Find(); minor code...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 18 Oct 2003 23:51:01 +0000 (23:51 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 18 Oct 2003 23:51:01 +0000 (23:51 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24231 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

19 files changed:
include/wx/mac/colour.h
include/wx/mgl/colour.h
include/wx/motif/colour.h
include/wx/x11/colour.h
src/generic/colrdlgg.cpp
src/generic/filedlgg.cpp
src/generic/fontdlgg.cpp
src/generic/sashwin.cpp
src/gtk/glcanvas.cpp
src/gtk1/glcanvas.cpp
src/mac/carbon/colour.cpp
src/mac/carbon/glcanvas.cpp
src/mac/colour.cpp
src/mac/glcanvas.cpp
src/mgl/colour.cpp
src/motif/colour.cpp
src/msw/glcanvas.cpp
src/x11/colour.cpp
src/x11/glcanvas.cpp

index 25b6d3b7268db915bea0d73262496dfd19b87603..88deff7b3c84fc48e821082d23004a8531b556fd 100644 (file)
@@ -25,19 +25,17 @@ class WXDLLEXPORT wxColour: public wxObject
 public:
   // ctors
     // default
-  wxColour();
+  wxColour() { Init(); }
     // from RGB
-  wxColour( unsigned char red, unsigned char green, unsigned char blue );
+  wxColour( unsigned char red, unsigned char green, unsigned char blue )
+      { Set(red, green, blue); }
   wxColour( unsigned long colRGB )
-      : m_isInit(FALSE), m_red(0), m_blue(0), m_green(0)
       { Set(colRGB); }
   
     // implicit conversion from the colour name
   wxColour( const wxString &colourName )
-      : m_isInit(FALSE), m_red(0), m_blue(0), m_green(0)
       { InitFromName(colourName); }
   wxColour( const wxChar *colourName )
-      : m_isInit(FALSE), m_red(0), m_blue(0), m_green(0)
       { InitFromName(colourName); }
 
     // copy ctors and assignment operators
@@ -86,6 +84,8 @@ private:
   unsigned char m_blue;
   unsigned char m_green;
 
+  void Init();
+
 public:
   WXCOLORREF m_pixel ;
   void Set( const WXCOLORREF* color ) ;
index eb75ad93ba210c1ea0f79304a4e3aa677aed1e00..13531891078118e2dec5819aac79b0a37d90c304 100644 (file)
@@ -25,7 +25,8 @@ public:
       // default
     wxColour();
       // from RGB
-    wxColour(unsigned char red, unsigned char green, unsigned char blue);
+    wxColour(unsigned char red, unsigned char green, unsigned char blue)
+        { Set(red, green, blue); }
     wxColour(unsigned long colRGB) { Set(colRGB); }
 
       // implicit conversion from the colour name
@@ -74,7 +75,8 @@ private:
     unsigned char m_blue;
     unsigned char m_green;
 
-    // helper func
+    // ctors helpers
+    void Init();
     void InitFromName(const wxString& colourName);
 
 private:
index bc5387483537f2cb7ed91f2c65a3ba65e9990695..b478f37b1945cf5faf86434a44f3e2b1d5b507f2 100644 (file)
@@ -28,7 +28,8 @@ public:
     // default
     wxColour();
     // from RGB
-    wxColour( unsigned char red, unsigned char green, unsigned char blue );
+    wxColour( unsigned char red, unsigned char green, unsigned char blue )
+        { Set(red, green, blue); }
     wxColour( unsigned long colRGB ) { Set(colRGB); }
     
     // implicit conversion from the colour name
index d2ab2624209ccbd6f3be42d12f20058b6ffa8a31..30481cba51c5c17ec4c11ee683d8c9000d1a9835 100644 (file)
@@ -53,6 +53,9 @@ public:
     wxColour( const wxChar *colourName ) { InitFromName( wxString(colourName) ); }
 #endif
 
+    // Get colour from name or wxNullColour
+    static wxColour CreateByName(const wxString& name);
+
     wxColour( const wxColour& col ) { Ref(col); }
     wxColour& operator = ( const wxColour& col ) { Ref(col); return *this; }
 
index 99b32860e4cf93b2217a39118f07ab66e1ead963..38275f47bb551ba3eb286bc55e07c52ecc66ae50 100644 (file)
@@ -304,14 +304,14 @@ void wxGenericColourDialog::InitializeColours(void)
 
     for (i = 0; i < WXSIZEOF(wxColourDialogNames); i++)
     {
-        wxColour *col = wxTheColourDatabase->FindColour(wxColourDialogNames[i]);
-        if (col)
-            standardColours[i].Set(col->Red(), col->Green(), col->Blue());
+        wxColour col = wxTheColourDatabase->Find(wxColourDialogNames[i]);
+        if (col.Ok())
+            standardColours[i].Set(col.Red(), col.Green(), col.Blue());
         else
             standardColours[i].Set(0, 0, 0);
     }
 
-    for (i = 0; i < 16; i++)
+    for (i = 0; i < WXSIZEOF(customColours); i++)
     {
         customColours[i] = colourData.GetCustomColour(i);
     }
@@ -333,7 +333,7 @@ void wxGenericColourDialog::InitializeColours(void)
         }
         if ( !initColourFound )
         {
-            for ( i = 0; i < 16; i++ )
+            for ( i = 0; i < WXSIZEOF(customColours); i++ )
             {
                 if ( customColours[i] == curr )
                 {
index 2c0933436d3a184baaa87f07b8a9dc71a66a4d3e..69335d597f4bd1225b4e033b221fefc0f2a58092 100644 (file)
@@ -343,8 +343,9 @@ void wxFileData::MakeItem( wxListItem &item )
 
     if (IsLink())
     {
-        wxColour *dg = wxTheColourDatabase->FindColour( _T("MEDIUM GREY") );
-        item.SetTextColour(*dg);
+        wxColour dg = wxTheColourDatabase->Find( _T("MEDIUM GREY") );
+        if ( dg.Ok() )
+            item.SetTextColour(dg);
     }
     item.m_data = (long)this;
 }
index 427f51b1a216da638edb4808ac6653878dfd3826..9ac0c7dcfa4034a28728e1653ef1f27e5b0bd04c 100644 (file)
@@ -339,11 +339,11 @@ void wxGenericFontDialog::OnChangeFont(wxCommandEvent& WXUNUSED(event))
   m_previewer->SetFont(dialogFont);
   if (colourChoice->GetStringSelection() != wxT(""))
   {
-    wxColour *col = wxTheColourDatabase->FindColour(colourChoice->GetStringSelection());
-    if (col)
+    wxColour col = wxTheColourDatabase->Find(colourChoice->GetStringSelection());
+    if (col.Ok())
     {
-      m_fontData.m_fontColour = *col;
-      m_previewer->SetForegroundColour(*col);
+      m_fontData.m_fontColour = col;
+      m_previewer->SetForegroundColour(col);
     }
   }
   m_previewer->Refresh();
index 55664e587c0a0140f25cc8e6188177e0103a17d0..f026ed1b74840cad7508f69c155a841b11ee38ee 100644 (file)
@@ -677,11 +677,11 @@ void wxSashWindow::InitColours()
     m_lightShadowColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT);
     m_hilightColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DHILIGHT);
 #else
-    m_faceColour = *(wxTheColourDatabase->FindColour("LIGHT GREY"));
-    m_mediumShadowColour = *(wxTheColourDatabase->FindColour("GREY"));
-    m_darkShadowColour = *(wxTheColourDatabase->FindColour("BLACK"));
-    m_lightShadowColour = *(wxTheColourDatabase->FindColour("LIGHT GREY"));
-    m_hilightColour = *(wxTheColourDatabase->FindColour("WHITE"));
+    m_faceColour = wxTheColourDatabase->Find("LIGHT GREY");
+    m_mediumShadowColour = wxTheColourDatabase->Find("GREY");
+    m_darkShadowColour = wxTheColourDatabase->Find("BLACK");
+    m_lightShadowColour = wxTheColourDatabase->Find("LIGHT GREY");
+    m_hilightColour = wxTheColourDatabase->Find("WHITE");
 #endif
 }
 
index f9599d1aa427e75eb1c8e44e92ed4e1e91c2d417..88018d4bb84fd2792800062e556b2e55a395857e 100644 (file)
@@ -130,15 +130,12 @@ void wxGLContext::SetCurrent()
 
 void wxGLContext::SetColour(const wxChar *colour)
 {
-    float r = 0.0;
-    float g = 0.0;
-    float b = 0.0;
-    wxColour *col = wxTheColourDatabase->FindColour(colour);
-    if (col)
+    wxColour col = wxTheColourDatabase->Find(colour);
+    if (col.Ok())
     {
-        r = (float)(col->Red()/256.0);
-        g = (float)(col->Green()/256.0);
-        b = (float)(col->Blue()/256.0);
+        float r = (float)(col.Red()/256.0);
+        float g = (float)(col.Green()/256.0);
+        float b = (float)(col.Blue()/256.0);
         glColor3f( r, g, b);
     }
 }
index f9599d1aa427e75eb1c8e44e92ed4e1e91c2d417..88018d4bb84fd2792800062e556b2e55a395857e 100644 (file)
@@ -130,15 +130,12 @@ void wxGLContext::SetCurrent()
 
 void wxGLContext::SetColour(const wxChar *colour)
 {
-    float r = 0.0;
-    float g = 0.0;
-    float b = 0.0;
-    wxColour *col = wxTheColourDatabase->FindColour(colour);
-    if (col)
+    wxColour col = wxTheColourDatabase->Find(colour);
+    if (col.Ok())
     {
-        r = (float)(col->Red()/256.0);
-        g = (float)(col->Green()/256.0);
-        b = (float)(col->Blue()/256.0);
+        float r = (float)(col.Red()/256.0);
+        float g = (float)(col.Green()/256.0);
+        float b = (float)(col.Blue()/256.0);
         glColor3f( r, g, b);
     }
 }
index 12a65e02a53125240a4c8d68cc0c943447bcfd82..13b88761bc91ac7428e0930b9dafd3ccfb4342a1 100644 (file)
@@ -33,24 +33,16 @@ static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green
     col->green = (green << 8) + green;
 }
 
-wxColour::wxColour ()
+void wxColour::Init()
 {
     m_isInit = FALSE;
-    m_red = m_blue = m_green = 0;
+    m_red =
+    m_blue =
+    m_green = 0;
     
     wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
 }
 
-wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b)
-{
-    m_red = r;
-    m_green = g;
-    m_blue = b;
-    m_isInit = TRUE;
-
-    wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
-}
-
 wxColour::wxColour (const wxColour& col)
     : wxObject()
 {
@@ -84,25 +76,17 @@ wxColour& wxColour::operator =(const wxColour& col)
     return *this;
 }
 
-void wxColour::InitFromName(const wxString& col)
+void wxColour::InitFromName(const wxString& name)
 {
-    wxColour *the_colour = wxTheColourDatabase->FindColour (col);
-    if (the_colour)
+    wxColour col = wxTheColourDatabase->Find(name);
+    if ( col.Ok() )
     {
-        m_red = the_colour->Red ();
-        m_green = the_colour->Green ();
-        m_blue = the_colour->Blue ();
-        m_isInit = TRUE;
+        *this = col;
     }
     else
     {
-        m_red = 0;
-        m_green = 0;
-        m_blue = 0;
-        m_isInit = FALSE;
+        Init();
     }
-
-    wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
 }
 
 wxColour::~wxColour ()
index 44215b6b75824b9678a9a68717f3131d14498dea..e208531ff41307375decf7fa64b0e0e0c56e7094 100644 (file)
@@ -97,15 +97,12 @@ void wxGLContext::Update()
 
 void wxGLContext::SetColour(const wxChar *colour)
 {
-    float r = 0.0;
-    float g = 0.0;
-    float b = 0.0;
-    wxColour *col = wxTheColourDatabase->FindColour(colour);
-    if (col)
+    wxColour col = wxTheColourDatabase->Find(colour);
+    if (col.Ok())
     {
-        r = (float)(col->Red()/256.0);
-        g = (float)(col->Green()/256.0);
-        b = (float)(col->Blue()/256.0);
+        float r = (float)(col.Red()/256.0);
+        float g = (float)(col.Green()/256.0);
+        float b = (float)(col.Blue()/256.0);
         glColor3f( r, g, b);
     }
 }
index 12a65e02a53125240a4c8d68cc0c943447bcfd82..13b88761bc91ac7428e0930b9dafd3ccfb4342a1 100644 (file)
@@ -33,24 +33,16 @@ static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green
     col->green = (green << 8) + green;
 }
 
-wxColour::wxColour ()
+void wxColour::Init()
 {
     m_isInit = FALSE;
-    m_red = m_blue = m_green = 0;
+    m_red =
+    m_blue =
+    m_green = 0;
     
     wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
 }
 
-wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b)
-{
-    m_red = r;
-    m_green = g;
-    m_blue = b;
-    m_isInit = TRUE;
-
-    wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
-}
-
 wxColour::wxColour (const wxColour& col)
     : wxObject()
 {
@@ -84,25 +76,17 @@ wxColour& wxColour::operator =(const wxColour& col)
     return *this;
 }
 
-void wxColour::InitFromName(const wxString& col)
+void wxColour::InitFromName(const wxString& name)
 {
-    wxColour *the_colour = wxTheColourDatabase->FindColour (col);
-    if (the_colour)
+    wxColour col = wxTheColourDatabase->Find(name);
+    if ( col.Ok() )
     {
-        m_red = the_colour->Red ();
-        m_green = the_colour->Green ();
-        m_blue = the_colour->Blue ();
-        m_isInit = TRUE;
+        *this = col;
     }
     else
     {
-        m_red = 0;
-        m_green = 0;
-        m_blue = 0;
-        m_isInit = FALSE;
+        Init();
     }
-
-    wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
 }
 
 wxColour::~wxColour ()
index 44215b6b75824b9678a9a68717f3131d14498dea..e208531ff41307375decf7fa64b0e0e0c56e7094 100644 (file)
@@ -97,15 +97,12 @@ void wxGLContext::Update()
 
 void wxGLContext::SetColour(const wxChar *colour)
 {
-    float r = 0.0;
-    float g = 0.0;
-    float b = 0.0;
-    wxColour *col = wxTheColourDatabase->FindColour(colour);
-    if (col)
+    wxColour col = wxTheColourDatabase->Find(colour);
+    if (col.Ok())
     {
-        r = (float)(col->Red()/256.0);
-        g = (float)(col->Green()/256.0);
-        b = (float)(col->Blue()/256.0);
+        float r = (float)(col.Red()/256.0);
+        float g = (float)(col.Green()/256.0);
+        float b = (float)(col.Blue()/256.0);
         glColor3f( r, g, b);
     }
 }
index 9eaf41f563aec351f27913d6dc2cc4a597978906..ebab19fba22f0f7c7dfeab0d7d38f9451d30a2b8 100644 (file)
@@ -27,53 +27,38 @@ IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
 
 // Colour
 
-wxColour::wxColour()
+void wxColour::Init()
 {
-  m_red = m_blue = m_green = 0;
-  m_isInit = FALSE;
-}
-
-wxColour::wxColour(unsigned char r, unsigned char g, unsigned char b)
-{
-  m_red = r;
-  m_green = g;
-  m_blue = b;
-  m_isInit = TRUE;
+    m_red =
+    m_blue =
+    m_green = 0;
+    m_isInit = FALSE;
 }
 
 wxColour::wxColour(const wxColour& col)
 {
-  m_red = col.m_red;
-  m_green = col.m_green;
-  m_blue = col.m_blue;
-  m_isInit = col.m_isInit;
+    *this = col;
 }
 
 wxColour& wxColour::operator =(const wxColour& col)
 {
-  m_red = col.m_red;
-  m_green = col.m_green;
-  m_blue = col.m_blue;
-  m_isInit = col.m_isInit;
-  return *this;
+    m_red = col.m_red;
+    m_green = col.m_green;
+    m_blue = col.m_blue;
+    m_isInit = col.m_isInit;
+    return *this;
 }
 
-void wxColour::InitFromName(const wxString& col)
+void wxColour::InitFromName(const wxString& name)
 {
-  wxColour *the_colour = wxTheColourDatabase->FindColour (col);
-  if (the_colour)
+    wxColour *col = wxTheColourDatabase->Find(name);
+    if ( col.Ok() )
     {
-      m_red = the_colour->Red();
-      m_green = the_colour->Green();
-      m_blue = the_colour->Blue();
-      m_isInit = TRUE;
+        *this = col;
     }
-  else
+    else
     {
-      m_red = 0;
-      m_green = 0;
-      m_blue = 0;
-      m_isInit = FALSE;
+        Init();
     }
 }
 
@@ -83,8 +68,8 @@ wxColour::~wxColour()
 
 void wxColour::Set(unsigned char r, unsigned char g, unsigned char b)
 {
-  m_red = r;
-  m_green = g;
-  m_blue = b;
-  m_isInit = TRUE;
+    m_red = r;
+    m_green = g;
+    m_blue = b;
+    m_isInit = TRUE;
 }
index c36d3b085ce2cf5ff3bf7b42553b19a68385f169..ee95c0a045c0b012c5bc3da3b87ce107f7064494 100644 (file)
@@ -37,26 +37,15 @@ IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
 wxColour::wxColour ()
 {
     m_isInit = FALSE;
-    m_red = m_blue = m_green = 0;
-    m_pixel = -1;
-}
-
-wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b)
-{
-    m_red = r;
-    m_green = g;
-    m_blue = b;
-    m_isInit = TRUE;
+    m_red =
+    m_blue =
+    m_green = 0;
     m_pixel = -1;
 }
 
 wxColour::wxColour (const wxColour& col)
 {
-    m_red = col.m_red;
-    m_green = col.m_green;
-    m_blue = col.m_blue;
-    m_isInit = col.m_isInit;
-    m_pixel = col.m_pixel;
+    *this = col;
 }
 
 wxColour& wxColour::operator =(const wxColour& col)
@@ -69,24 +58,9 @@ wxColour& wxColour::operator =(const wxColour& col)
     return *this;
 }
 
-void wxColour::InitFromName(const wxString& col)
+void wxColour::InitFromName(const wxString& name)
 {
-    wxColour *the_colour = wxTheColourDatabase->FindColour (col);
-    if (the_colour)
-    {
-        m_red = the_colour->Red ();
-        m_green = the_colour->Green ();
-        m_blue = the_colour->Blue ();
-        m_pixel = the_colour->m_pixel;
-        m_isInit = TRUE;
-    }
-    else
-    {
-        m_red = 0;
-        m_green = 0;
-        m_blue = 0;
-        m_isInit = FALSE;
-    }
+    *this = wxTheColourDatabase->Find(name);
 }
 
 wxColour::~wxColour ()
index feb72526b16d5892de25aae031b2e060bff746ad..c5a0523d00ca861c6960996ee35ecb72fcff9747 100644 (file)
@@ -134,17 +134,14 @@ void wxGLContext::SetCurrent()
 
 void wxGLContext::SetColour(const wxChar *colour)
 {
-  float r = 0.0;
-  float g = 0.0;
-  float b = 0.0;
-  wxColour *col = wxTheColourDatabase->FindColour(colour);
-  if (col)
-  {
-    r = (float)(col->Red()/256.0);
-    g = (float)(col->Green()/256.0);
-    b = (float)(col->Blue()/256.0);
-    glColor3f( r, g, b);
-  }
+    wxColour col = wxTheColourDatabase->Find(colour);
+    if (col.Ok())
+    {
+        float r = (float)(col.Red()/256.0);
+        float g = (float)(col.Green()/256.0);
+        float b = (float)(col.Blue()/256.0);
+        glColor3f( r, g, b);
+    }
 }
 
 
index d9ef08580817ffa92c598c118a4f137bdcaaccfb..95b0c786e700590e38a71176a6297274618ffc45 100644 (file)
@@ -155,34 +155,46 @@ wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue )
     M_COLDATA->m_color.pixel = 0;
 }
 
-void wxColour::InitFromName( const wxString &colourName )
+/* static */
+wxColour wxColour::CreateByName(const wxString& name)
 {
-    wxColour* col;
-    if ( (wxTheColourDatabase) && (col = wxTheColourDatabase->FindColourNoAdd(colourName)) )
+    wxColour col;
+
+    Display *dpy = wxGlobalDisplay();
+    WXColormap colormap = wxTheApp->GetMainColormap( dpy );
+    XColor xcol;
+    if ( XParseColor( dpy, (Colormap)colormap, name.mb_str(), &xcol ) )
     {
-        UnRef();
-        if (col) Ref( *col );
+        wxColourRefData *refData = new wxColourRefData;
+        refData->m_colormap = colormap;
+        refData->m_color = xcol;
+        col.m_refData = refData;
     }
-    else
+
+    return col;
+}
+
+void wxColour::InitFromName( const wxString &colourName )
+{
+    // check the cache first
+    wxColour col;
+    if ( wxTheColourDatabase )
     {
-        m_refData = new wxColourRefData();
-        
-        M_COLDATA->m_colormap = wxTheApp->GetMainColormap( wxGlobalDisplay() );
-        
-        if (!XParseColor( wxGlobalDisplay(), (Colormap) M_COLDATA->m_colormap, colourName.mb_str(), &M_COLDATA->m_color ))
-        {
-            // VZ: asserts are good in general but this one is triggered by
-            //     calling wxColourDatabase::FindColour() with an
-            //     unrecognized colour name and this can't be avoided from the
-            //     user code, so don't give it here
-            //
-            //     a better solution would be to changed code in FindColour()
+        col = wxTheColourDatabase->Find(colourName);
+    }
 
-            //wxFAIL_MSG( wxT("wxColour: couldn't find colour") );
+    if ( !col.Ok() )
+    {
+        col = CreateByName(colourName);
+    }
 
-            delete m_refData;
-            m_refData = (wxObjectRefData *) NULL;
-        }
+    if ( col.Ok() )
+    {
+        *this = col;
+    }
+    else
+    {
+        wxFAIL_MSG( wxT("wxColour: couldn't find colour") );
     }
 }
 
index 5b619202a0d358ee33158654e7b21c27e7f013d1..0059ab89cf9b459ac510fc17d6c1f947c574515e 100644 (file)
@@ -138,28 +138,32 @@ void wxGLContext::SetCurrent()
 
 void wxGLContext::SetColour(const wxChar *colour)
 {
-    wxColour *the_colour = wxTheColourDatabase->FindColour(colour);
-    if(the_colour) {
-       GLboolean b;
-       glGetBooleanv(GL_RGBA_MODE, &b);
-       if(b) {
-           glColor3ub(the_colour->Red(),
-                      the_colour->Green(),
-                      the_colour->Blue());
-       } else {
+    wxColour the_colour = wxTheColourDatabase->Find(colour);
+    if(the_colour.Ok())
+    {
+        GLboolean b;
+        glGetBooleanv(GL_RGBA_MODE, &b);
+        if(b)
+        {
+            glColor3ub(the_colour.Red(),
+                    the_colour.Green(),
+                    the_colour.Blue());
+        }
+        else
+        {
 #ifdef __WXMOTIF__
-            the_colour->AllocColour(m_window->GetXDisplay());
+            the_colour.AllocColour(m_window->GetXDisplay());
 #else
-            the_colour->CalcPixel(wxTheApp->GetMainColormap(wxGetDisplay()));
+            the_colour.CalcPixel(wxTheApp->GetMainColormap(wxGetDisplay()));
 #endif
-           GLint pix = (GLint)the_colour->GetPixel();
-           if(pix == -1)
+            GLint pix = (GLint)the_colour.GetPixel();
+            if(pix == -1)
             {
                 wxLogError(wxT("wxGLCanvas: cannot allocate color\n"));
-               return;
+                return;
             }
-           glIndexi(pix);
-       }
+            glIndexi(pix);
+        }
     }
 }