]>
Commit | Line | Data |
---|---|---|
e9576ca5 | 1 | ///////////////////////////////////////////////////////////////////////////// |
edc536d3 | 2 | // Name: src/mac/carbon/colour.cpp |
e9576ca5 | 3 | // Purpose: wxColour class |
a31a5f85 | 4 | // Author: Stefan Csomor |
e9576ca5 | 5 | // Modified by: |
a31a5f85 | 6 | // Created: 1998-01-01 |
e9576ca5 | 7 | // RCS-ID: $Id$ |
a31a5f85 | 8 | // Copyright: (c) Stefan Csomor |
edc536d3 | 9 | // Licence: wxWindows licence |
e9576ca5 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
a8e9860d SC |
12 | #include "wx/wxprec.h" |
13 | ||
e9576ca5 SC |
14 | #include "wx/gdicmn.h" |
15 | #include "wx/colour.h" | |
16 | ||
e9576ca5 | 17 | IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject) |
e9576ca5 SC |
18 | |
19 | // Colour | |
20 | ||
76a5e5d2 SC |
21 | #include "wx/mac/private.h" |
22 | ||
23 | static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ; | |
aad6765c | 24 | static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) |
519cb848 | 25 | { |
76a5e5d2 | 26 | RGBColor* col = (RGBColor*) color ; |
e40298d5 JS |
27 | col->red = (red << 8) + red; |
28 | col->blue = (blue << 8) + blue; | |
29 | col->green = (green << 8) + green; | |
519cb848 SC |
30 | } |
31 | ||
564a150b | 32 | void wxColour::Init() |
e9576ca5 | 33 | { |
aad6765c | 34 | m_isInit = false; |
564a150b VZ |
35 | m_red = |
36 | m_blue = | |
37 | m_green = 0; | |
aad6765c | 38 | |
e40298d5 | 39 | wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; |
e9576ca5 SC |
40 | } |
41 | ||
e9576ca5 | 42 | wxColour::wxColour (const wxColour& col) |
d84afea9 | 43 | : wxObject() |
e9576ca5 SC |
44 | { |
45 | m_red = col.m_red; | |
46 | m_green = col.m_green; | |
47 | m_blue = col.m_blue; | |
48 | m_isInit = col.m_isInit; | |
519cb848 | 49 | |
76a5e5d2 | 50 | memcpy( &m_pixel , &col.m_pixel , 6 ) ; |
519cb848 SC |
51 | } |
52 | ||
e9576ca5 SC |
53 | wxColour& wxColour::operator =(const wxColour& col) |
54 | { | |
e40298d5 JS |
55 | m_red = col.m_red; |
56 | m_green = col.m_green; | |
57 | m_blue = col.m_blue; | |
58 | m_isInit = col.m_isInit; | |
aad6765c | 59 | |
e40298d5 | 60 | memcpy( &m_pixel , &col.m_pixel , 6 ) ; |
aad6765c | 61 | |
e40298d5 | 62 | return *this; |
e9576ca5 SC |
63 | } |
64 | ||
564a150b | 65 | void wxColour::InitFromName(const wxString& name) |
e9576ca5 | 66 | { |
aad6765c | 67 | if ( wxTheColourDatabase ) |
e9576ca5 | 68 | { |
aad6765c JS |
69 | wxColour col = wxTheColourDatabase->Find(name); |
70 | if ( col.Ok() ) | |
71 | { | |
72 | *this = col; | |
73 | return; | |
74 | } | |
e9576ca5 | 75 | } |
aad6765c JS |
76 | |
77 | // leave invalid | |
78 | Init(); | |
e9576ca5 SC |
79 | } |
80 | ||
81 | wxColour::~wxColour () | |
82 | { | |
83 | } | |
84 | ||
85 | void wxColour::Set (unsigned char r, unsigned char g, unsigned char b) | |
86 | { | |
87 | m_red = r; | |
88 | m_green = g; | |
89 | m_blue = b; | |
aad6765c | 90 | m_isInit = true; |
519cb848 | 91 | |
e40298d5 | 92 | wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; |
e9576ca5 | 93 | } |
76a5e5d2 SC |
94 | |
95 | void wxColour::Set( const WXCOLORREF* color ) | |
aad6765c | 96 | { |
76a5e5d2 SC |
97 | RGBColor* col = (RGBColor*) color ; |
98 | memcpy( &m_pixel , color , 6 ) ; | |
99 | m_red = col->red>>8 ; | |
100 | m_blue = col->blue>>8 ; | |
101 | m_green = col->green>>8 ; | |
d84afea9 | 102 | } |