]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/colour.cpp
Fix nonsensical checked menu item label and behaviour
[wxWidgets.git] / src / os2 / colour.cpp
index a5e9556dac285940a5a1f07a91bf98991b0c2ec5..6845104c4eb483050826094c82291eadbbb3d8a2 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        colour.cpp
+// Name:        src/os2/colour.cpp
 // Purpose:     wxColour class
 // Author:      David Webster
 // Modified by:
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
+#ifndef WX_PRECOMP
+    #include "wx/colour.h"
+#endif
+
 #include "wx/gdicmn.h"
 #define INCL_GPI
 #define INCL_PM
@@ -21,11 +25,16 @@ IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
 
 // Colour
 
-wxColour::wxColour ()
+void wxColour::Init()
 {
-    m_bIsInit = FALSE;
+    m_bIsInit = false;
     m_vPixel = 0;
     m_cRed = m_cBlue = m_cGreen = 0;
+} // end of wxColour::Init
+
+wxColour::wxColour ()
+{
+    Init();
 } // end of wxColour::wxColour
 
 wxColour::wxColour (
@@ -34,22 +43,14 @@ wxColour::wxColour (
 , unsigned char                     cBlue
 )
 {
-    m_cRed    = cRed;
-    m_cGreen  = cGreen;
-    m_cBlue   = cBlue;
-    m_bIsInit = TRUE;
-    m_vPixel  = PALETTERGB (m_cRed, m_cGreen, m_cBlue);
+    Set(cRed, cGreen, cBlue);
 } // end of wxColour::wxColour
 
-wxColour::wxColour (
+wxColour::wxColour(
   const wxColour&                   rCol
 )
 {
-    m_cRed    = rCol.m_cRed;
-    m_cGreen  = rCol.m_cGreen;
-    m_cBlue   = rCol.m_cBlue;
-    m_bIsInit = rCol.m_bIsInit;
-    m_vPixel  = rCol.m_vPixel;
+    *this = rCol;
 } // end of wxColour::wxColour
 
 wxColour& wxColour::operator =(
@@ -68,30 +69,26 @@ void wxColour::InitFromName(
   const wxString&                   sCol
 )
 {
-    wxColour*                       pTheColour = wxTheColourDatabase->FindColour(sCol);
-
-    if (pTheColour)
-    {
-        m_cRed    = pTheColour->Red();
-        m_cGreen  = pTheColour->Green();
-        m_cBlue   = pTheColour->Blue();
-        m_bIsInit = TRUE;
-    }
-    else
+    if ( wxTheColourDatabase )
     {
-        m_cRed = 0;
-        m_cGreen = 0;
-        m_cBlue = 0;
-        m_bIsInit = FALSE;
+        wxColour col = wxTheColourDatabase->Find(sCol);
+        if ( col.Ok() )
+        {
+            *this = col;
+            return;
+        }
     }
-    m_vPixel = PALETTERGB (m_cRed, m_cGreen, m_cBlue);
+
+    // leave invalid
+    Init();
+
 } // end of wxColour::InitFromName
 
-wxColour::~wxColour ()
+wxColour::~wxColour()
 {
 } // end of wxColour::~wxColour
 
-void wxColour::Set (
+void wxColour::Set(
   unsigned char                     cRed
 , unsigned char                     cGreen
 , unsigned char                     cBlue
@@ -100,23 +97,6 @@ void wxColour::Set (
     m_cRed    = cRed;
     m_cGreen  = cGreen;
     m_cBlue   = cBlue;
-    m_bIsInit = TRUE;
-    m_vPixel  = PALETTERGB (m_cRed, m_cGreen, m_cBlue);
+    m_bIsInit = true;
+    m_vPixel  = OS2RGB (m_cRed, m_cGreen, m_cBlue);
 } // end of wxColour::Set
-
-//
-// Obsolete
-//
-#if WXWIN_COMPATIBILITY
-void wxColour::Get (
-  unsigned char*                   pRed
-, unsigned char*                   pGreen
-, unsigned char*                   pBlue
-) const
-{
-    *Red   = m_cRed;
-    *Green = m_cGreen;
-    *Blue  = m_cBlue;
-} // end of wxColour::Get
-#endif
-