]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: colour.cpp | |
3 | // Purpose: wxColour class | |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Stefan Csomor | |
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 | ||
19 | IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject) | |
20 | ||
21 | // Colour | |
22 | ||
23 | #include "wx/mac/private.h" | |
24 | ||
25 | static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ; | |
26 | static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) | |
27 | { | |
28 | RGBColor* col = (RGBColor*) color ; | |
29 | col->red = (red << 8) + red; | |
30 | col->blue = (blue << 8) + blue; | |
31 | col->green = (green << 8) + green; | |
32 | } | |
33 | ||
34 | void wxColour::Init() | |
35 | { | |
36 | m_isInit = false; | |
37 | m_red = | |
38 | m_blue = | |
39 | m_green = 0; | |
40 | ||
41 | wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; | |
42 | } | |
43 | ||
44 | wxColour::wxColour (const wxColour& col) | |
45 | : wxObject() | |
46 | { | |
47 | m_red = col.m_red; | |
48 | m_green = col.m_green; | |
49 | m_blue = col.m_blue; | |
50 | m_isInit = col.m_isInit; | |
51 | ||
52 | memcpy( &m_pixel , &col.m_pixel , 6 ) ; | |
53 | } | |
54 | ||
55 | wxColour::wxColour (const wxColour* col) | |
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; | |
61 | ||
62 | memcpy( &m_pixel , &col->m_pixel , 6 ) ; | |
63 | } | |
64 | ||
65 | wxColour& wxColour::operator =(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 | ||
72 | memcpy( &m_pixel , &col.m_pixel , 6 ) ; | |
73 | ||
74 | return *this; | |
75 | } | |
76 | ||
77 | void wxColour::InitFromName(const wxString& name) | |
78 | { | |
79 | if ( wxTheColourDatabase ) | |
80 | { | |
81 | wxColour col = wxTheColourDatabase->Find(name); | |
82 | if ( col.Ok() ) | |
83 | { | |
84 | *this = col; | |
85 | return; | |
86 | } | |
87 | } | |
88 | ||
89 | // leave invalid | |
90 | Init(); | |
91 | } | |
92 | ||
93 | wxColour::~wxColour () | |
94 | { | |
95 | } | |
96 | ||
97 | void wxColour::Set (unsigned char r, unsigned char g, unsigned char b) | |
98 | { | |
99 | m_red = r; | |
100 | m_green = g; | |
101 | m_blue = b; | |
102 | m_isInit = true; | |
103 | ||
104 | wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; | |
105 | } | |
106 | ||
107 | void wxColour::Set( const WXCOLORREF* color ) | |
108 | { | |
109 | RGBColor* col = (RGBColor*) color ; | |
110 | memcpy( &m_pixel , color , 6 ) ; | |
111 | m_red = col->red>>8 ; | |
112 | m_blue = col->blue>>8 ; | |
113 | m_green = col->green>>8 ; | |
114 | } |