]>
Commit | Line | Data |
---|---|---|
e9576ca5 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: colour.cpp | |
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 |
65571936 | 9 | // Licence: wxWindows licence |
e9576ca5 SC |
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 ) ; | |
aad6765c | 28 | static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) |
519cb848 | 29 | { |
76a5e5d2 | 30 | RGBColor* col = (RGBColor*) color ; |
e40298d5 JS |
31 | col->red = (red << 8) + red; |
32 | col->blue = (blue << 8) + blue; | |
33 | col->green = (green << 8) + green; | |
519cb848 SC |
34 | } |
35 | ||
564a150b | 36 | void wxColour::Init() |
e9576ca5 | 37 | { |
aad6765c | 38 | m_isInit = false; |
564a150b VZ |
39 | m_red = |
40 | m_blue = | |
41 | m_green = 0; | |
aad6765c | 42 | |
e40298d5 | 43 | wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; |
e9576ca5 SC |
44 | } |
45 | ||
e9576ca5 | 46 | wxColour::wxColour (const wxColour& col) |
d84afea9 | 47 | : wxObject() |
e9576ca5 SC |
48 | { |
49 | m_red = col.m_red; | |
50 | m_green = col.m_green; | |
51 | m_blue = col.m_blue; | |
52 | m_isInit = col.m_isInit; | |
519cb848 | 53 | |
76a5e5d2 | 54 | memcpy( &m_pixel , &col.m_pixel , 6 ) ; |
519cb848 SC |
55 | } |
56 | ||
57 | wxColour::wxColour (const wxColour* col) | |
58 | { | |
59 | m_red = col->m_red; | |
60 | m_green = col->m_green; | |
61 | m_blue = col->m_blue; | |
62 | m_isInit = col->m_isInit; | |
63 | ||
76a5e5d2 | 64 | memcpy( &m_pixel , &col->m_pixel , 6 ) ; |
e9576ca5 SC |
65 | } |
66 | ||
67 | wxColour& wxColour::operator =(const wxColour& col) | |
68 | { | |
e40298d5 JS |
69 | m_red = col.m_red; |
70 | m_green = col.m_green; | |
71 | m_blue = col.m_blue; | |
72 | m_isInit = col.m_isInit; | |
aad6765c | 73 | |
e40298d5 | 74 | memcpy( &m_pixel , &col.m_pixel , 6 ) ; |
aad6765c | 75 | |
e40298d5 | 76 | return *this; |
e9576ca5 SC |
77 | } |
78 | ||
564a150b | 79 | void wxColour::InitFromName(const wxString& name) |
e9576ca5 | 80 | { |
aad6765c | 81 | if ( wxTheColourDatabase ) |
e9576ca5 | 82 | { |
aad6765c JS |
83 | wxColour col = wxTheColourDatabase->Find(name); |
84 | if ( col.Ok() ) | |
85 | { | |
86 | *this = col; | |
87 | return; | |
88 | } | |
e9576ca5 | 89 | } |
aad6765c JS |
90 | |
91 | // leave invalid | |
92 | Init(); | |
e9576ca5 SC |
93 | } |
94 | ||
95 | wxColour::~wxColour () | |
96 | { | |
97 | } | |
98 | ||
99 | void wxColour::Set (unsigned char r, unsigned char g, unsigned char b) | |
100 | { | |
101 | m_red = r; | |
102 | m_green = g; | |
103 | m_blue = b; | |
aad6765c | 104 | m_isInit = true; |
519cb848 | 105 | |
e40298d5 | 106 | wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; |
e9576ca5 | 107 | } |
76a5e5d2 SC |
108 | |
109 | void wxColour::Set( const WXCOLORREF* color ) | |
aad6765c | 110 | { |
76a5e5d2 SC |
111 | RGBColor* col = (RGBColor*) color ; |
112 | memcpy( &m_pixel , color , 6 ) ; | |
113 | m_red = col->red>>8 ; | |
114 | m_blue = col->blue>>8 ; | |
115 | m_green = col->green>>8 ; | |
d84afea9 | 116 | } |