]> git.saurik.com Git - wxWidgets.git/blame - src/mac/classic/colour.cpp
Fixed OpenWatcom (strange) scope related crash.
[wxWidgets.git] / src / mac / classic / colour.cpp
CommitLineData
2646f485 1/////////////////////////////////////////////////////////////////////////////
edc536d3 2// Name: src/mac/classic/colour.cpp
2646f485
SC
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
edc536d3 9// Licence: wxWindows licence
2646f485
SC
10/////////////////////////////////////////////////////////////////////////////
11
40989e46
WS
12#include "wx/wxprec.h"
13
2646f485
SC
14#include "wx/colour.h"
15
40989e46
WS
16#include "wx/gdicmn.h"
17
2646f485 18IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
2646f485
SC
19
20// Colour
21
22#include "wx/mac/private.h"
23
24static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ;
25static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
26{
27 RGBColor* col = (RGBColor*) color ;
28 col->red = (red << 8) + red;
29 col->blue = (blue << 8) + blue;
30 col->green = (green << 8) + green;
31}
32
33void wxColour::Init()
34{
35 m_isInit = false;
36 m_red =
37 m_blue =
38 m_green = 0;
39
40 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
41}
42
43wxColour::wxColour (const wxColour& col)
44 : wxObject()
45{
46 m_red = col.m_red;
47 m_green = col.m_green;
48 m_blue = col.m_blue;
49 m_isInit = col.m_isInit;
50
51 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
52}
53
54wxColour::wxColour (const wxColour* col)
55{
56 m_red = col->m_red;
57 m_green = col->m_green;
58 m_blue = col->m_blue;
59 m_isInit = col->m_isInit;
60
61 memcpy( &m_pixel , &col->m_pixel , 6 ) ;
62}
63
64wxColour& wxColour::operator =(const wxColour& col)
65{
66 m_red = col.m_red;
67 m_green = col.m_green;
68 m_blue = col.m_blue;
69 m_isInit = col.m_isInit;
70
71 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
72
73 return *this;
74}
75
2646f485
SC
76wxColour::~wxColour ()
77{
78}
79
40989e46 80void wxColour::InitWith (unsigned char r, unsigned char g, unsigned char b)
2646f485
SC
81{
82 m_red = r;
83 m_green = g;
84 m_blue = b;
85 m_isInit = true;
86
87 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
88}
89
90void wxColour::Set( const WXCOLORREF* color )
91{
92 RGBColor* col = (RGBColor*) color ;
93 memcpy( &m_pixel , color , 6 ) ;
94 m_red = col->red>>8 ;
95 m_blue = col->blue>>8 ;
96 m_green = col->green>>8 ;
97}