]>
Commit | Line | Data |
---|---|---|
e9576ca5 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: colour.cpp | |
3 | // Purpose: wxColour class | |
4 | // Author: AUTHOR | |
5 | // Modified by: | |
6 | // Created: ??/??/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) AUTHOR | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "colour.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/gdicmn.h" | |
17 | #include "wx/colour.h" | |
18 | ||
2f1ae414 | 19 | #if !USE_SHARED_LIBRARY |
e9576ca5 | 20 | IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject) |
2f1ae414 | 21 | #endif |
e9576ca5 SC |
22 | |
23 | // Colour | |
24 | ||
76a5e5d2 SC |
25 | #include "wx/mac/private.h" |
26 | ||
27 | static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ; | |
28 | static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) | |
519cb848 | 29 | { |
76a5e5d2 | 30 | RGBColor* col = (RGBColor*) color ; |
519cb848 SC |
31 | col->red = (red << 8) + red; |
32 | col->blue = (blue << 8) + blue; | |
33 | col->green = (green << 8) + green; | |
34 | } | |
35 | ||
e9576ca5 SC |
36 | wxColour::wxColour () |
37 | { | |
519cb848 SC |
38 | m_isInit = FALSE; |
39 | m_red = m_blue = m_green = 0; | |
40 | ||
41 | wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; | |
e9576ca5 SC |
42 | } |
43 | ||
44 | wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b) | |
45 | { | |
46 | m_red = r; | |
47 | m_green = g; | |
48 | m_blue = b; | |
49 | m_isInit = TRUE; | |
519cb848 SC |
50 | |
51 | wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; | |
e9576ca5 SC |
52 | } |
53 | ||
54 | wxColour::wxColour (const wxColour& col) | |
d84afea9 | 55 | : wxObject() |
e9576ca5 SC |
56 | { |
57 | m_red = col.m_red; | |
58 | m_green = col.m_green; | |
59 | m_blue = col.m_blue; | |
60 | m_isInit = col.m_isInit; | |
519cb848 | 61 | |
76a5e5d2 | 62 | memcpy( &m_pixel , &col.m_pixel , 6 ) ; |
519cb848 SC |
63 | } |
64 | ||
65 | wxColour::wxColour (const wxColour* col) | |
66 | { | |
67 | m_red = col->m_red; | |
68 | m_green = col->m_green; | |
69 | m_blue = col->m_blue; | |
70 | m_isInit = col->m_isInit; | |
71 | ||
76a5e5d2 | 72 | memcpy( &m_pixel , &col->m_pixel , 6 ) ; |
e9576ca5 SC |
73 | } |
74 | ||
75 | wxColour& wxColour::operator =(const wxColour& col) | |
76 | { | |
77 | m_red = col.m_red; | |
78 | m_green = col.m_green; | |
79 | m_blue = col.m_blue; | |
80 | m_isInit = col.m_isInit; | |
519cb848 | 81 | |
76a5e5d2 | 82 | memcpy( &m_pixel , &col.m_pixel , 6 ) ; |
519cb848 | 83 | |
e9576ca5 SC |
84 | return *this; |
85 | } | |
86 | ||
87 | void wxColour::InitFromName(const wxString& col) | |
88 | { | |
89 | wxColour *the_colour = wxTheColourDatabase->FindColour (col); | |
90 | if (the_colour) | |
91 | { | |
92 | m_red = the_colour->Red (); | |
93 | m_green = the_colour->Green (); | |
94 | m_blue = the_colour->Blue (); | |
95 | m_isInit = TRUE; | |
96 | } | |
97 | else | |
98 | { | |
99 | m_red = 0; | |
100 | m_green = 0; | |
101 | m_blue = 0; | |
102 | m_isInit = FALSE; | |
103 | } | |
519cb848 SC |
104 | |
105 | wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; | |
e9576ca5 SC |
106 | } |
107 | ||
108 | wxColour::~wxColour () | |
109 | { | |
110 | } | |
111 | ||
112 | void wxColour::Set (unsigned char r, unsigned char g, unsigned char b) | |
113 | { | |
114 | m_red = r; | |
115 | m_green = g; | |
116 | m_blue = b; | |
117 | m_isInit = TRUE; | |
519cb848 SC |
118 | |
119 | wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; | |
e9576ca5 | 120 | } |
76a5e5d2 SC |
121 | |
122 | void wxColour::Set( const WXCOLORREF* color ) | |
123 | { | |
124 | RGBColor* col = (RGBColor*) color ; | |
125 | memcpy( &m_pixel , color , 6 ) ; | |
126 | m_red = col->red>>8 ; | |
127 | m_blue = col->blue>>8 ; | |
128 | m_green = col->green>>8 ; | |
d84afea9 | 129 | } |