[ 1473731 ] 'wxColourBase and wxString <-> wxColour implementation' with minor modifi...
[wxWidgets.git] / src / os2 / colour.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/colour.cpp
3 // Purpose: wxColour class
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/13/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #include "wx/colour.h"
16
17 #ifndef WX_PRECOMP
18 #endif
19
20 #include "wx/gdicmn.h"
21 #define INCL_GPI
22 #define INCL_PM
23 #include<os2.h>
24
25 IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
26
27 // Colour
28
29 void wxColour::Init()
30 {
31 m_bIsInit = false;
32 m_vPixel = 0;
33 m_cRed = m_cBlue = m_cGreen = 0;
34 } // end of wxColour::Init
35
36 wxColour::wxColour ()
37 {
38 Init();
39 } // end of wxColour::wxColour
40
41 wxColour::wxColour (
42 unsigned char cRed
43 , unsigned char cGreen
44 , unsigned char cBlue
45 )
46 {
47 Set(cRed, cGreen, cBlue);
48 } // end of wxColour::wxColour
49
50 wxColour::wxColour(
51 const wxColour& rCol
52 )
53 {
54 *this = rCol;
55 } // end of wxColour::wxColour
56
57 wxColour& wxColour::operator =(
58 const wxColour& rCol
59 )
60 {
61 m_cRed = rCol.m_cRed;
62 m_cGreen = rCol.m_cGreen;
63 m_cBlue = rCol.m_cBlue;
64 m_bIsInit = rCol.m_bIsInit;
65 m_vPixel = rCol.m_vPixel;
66 return *this;
67 } // end of wxColour& wxColour::operator =
68
69 void wxColour::InitFromName(
70 const wxString& sCol
71 )
72 {
73 if ( wxString2Colour(sCol, this) )
74 return;
75
76 // leave invalid
77 Init();
78
79 } // end of wxColour::InitFromName
80
81 wxColour::~wxColour()
82 {
83 } // end of wxColour::~wxColour
84
85 void wxColour::Set(
86 unsigned char cRed
87 , unsigned char cGreen
88 , unsigned char cBlue
89 )
90 {
91 m_cRed = cRed;
92 m_cGreen = cGreen;
93 m_cBlue = cBlue;
94 m_bIsInit = true;
95 m_vPixel = OS2RGB (m_cRed, m_cGreen, m_cBlue);
96 } // end of wxColour::Set