]> git.saurik.com Git - wxWidgets.git/blame - src/qt/brush.cpp
Applied patch for non-Latin keyboards.
[wxWidgets.git] / src / qt / brush.cpp
CommitLineData
7c78e7c7
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: brush.cpp
01b2eeec
KB
3// Purpose: wxBrush
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
7c78e7c7
RR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "brush.h"
14#endif
15
01b2eeec
KB
16#include "wx/setup.h"
17#include "wx/utils.h"
7c78e7c7
RR
18#include "wx/brush.h"
19
01b2eeec 20IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
7c78e7c7 21
01b2eeec 22wxBrushRefData::wxBrushRefData()
7c78e7c7 23{
01b2eeec
KB
24 m_style = wxSOLID;
25// TODO: null data
26}
7c78e7c7 27
01b2eeec 28wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
7c78e7c7 29{
01b2eeec
KB
30 m_style = data.m_style;
31 m_stipple = data.m_stipple;
32 m_colour = data.m_colour;
33/* TODO: null data
34 m_hBrush = 0;
35*/
36}
7c78e7c7 37
01b2eeec 38wxBrushRefData::~wxBrushRefData()
7c78e7c7 39{
01b2eeec
KB
40// TODO: delete data
41}
42
43// Brushes
44wxBrush::wxBrush()
7c78e7c7 45{
01b2eeec
KB
46 if ( wxTheBrushList )
47 wxTheBrushList->AddBrush(this);
48}
49
50wxBrush::~wxBrush()
7c78e7c7 51{
01b2eeec
KB
52 if ( wxTheBrushList )
53 wxTheBrushList->RemoveBrush(this);
54}
7c78e7c7 55
01b2eeec 56wxBrush::wxBrush(const wxColour& col, int Style)
7c78e7c7 57{
01b2eeec 58 m_refData = new wxBrushRefData;
7c78e7c7 59
01b2eeec
KB
60 M_BRUSHDATA->m_colour = col;
61 M_BRUSHDATA->m_style = Style;
62
63 RealizeResource();
64
65 if ( wxTheBrushList )
66 wxTheBrushList->AddBrush(this);
67}
68
69wxBrush::wxBrush(const wxString& col, int Style)
7c78e7c7 70{
01b2eeec
KB
71 m_refData = new wxBrushRefData;
72
73 // Implicit conversion from string to wxColour via colour database
74 M_BRUSHDATA->m_colour = col;
75 M_BRUSHDATA->m_style = Style;
7c78e7c7 76
01b2eeec
KB
77 RealizeResource();
78
79 if ( wxTheBrushList )
80 wxTheBrushList->AddBrush(this);
81}
82
83wxBrush::wxBrush(const wxBitmap& stipple)
7c78e7c7 84{
01b2eeec
KB
85 m_refData = new wxBrushRefData;
86
87 M_BRUSHDATA->m_style = wxSTIPPLE;
88 M_BRUSHDATA->m_stipple = stipple;
89
90 RealizeResource();
91
92 if ( wxTheBrushList )
93 wxTheBrushList->AddBrush(this);
94}
95
96void wxBrush::Unshare()
7c78e7c7 97{
01b2eeec
KB
98 // Don't change shared data
99 if (!m_refData)
100 {
101 m_refData = new wxBrushRefData();
102 }
103 else
104 {
105 wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
106 UnRef();
107 m_refData = ref;
108 }
109}
7c78e7c7 110
01b2eeec 111void wxBrush::SetColour(const wxColour& col)
7c78e7c7 112{
01b2eeec
KB
113 Unshare();
114
115 M_BRUSHDATA->m_colour = col;
7c78e7c7 116
01b2eeec
KB
117 RealizeResource();
118}
119
120void wxBrush::SetColour(const wxString& col)
7c78e7c7 121{
01b2eeec
KB
122 Unshare();
123
124 M_BRUSHDATA->m_colour = col;
125
126 RealizeResource();
127}
7c78e7c7 128
01b2eeec 129void wxBrush::SetColour(const unsigned char r, const unsigned char g, const unsigned char b)
7c78e7c7 130{
01b2eeec 131 Unshare();
7c78e7c7 132
01b2eeec
KB
133 M_BRUSHDATA->m_colour.Set(r, g, b);
134
135 RealizeResource();
136}
137
138void wxBrush::SetStyle(int Style)
7c78e7c7 139{
01b2eeec
KB
140 Unshare();
141
142 M_BRUSHDATA->m_style = Style;
143
144 RealizeResource();
145}
7c78e7c7 146
01b2eeec 147void wxBrush::SetStipple(const wxBitmap& Stipple)
7c78e7c7 148{
01b2eeec 149 Unshare();
7c78e7c7 150
01b2eeec
KB
151 M_BRUSHDATA->m_stipple = Stipple;
152
153 RealizeResource();
154}
155
156void wxBrush::RealizeResource()
157{
158// TODO: create the brush
159}
7c78e7c7 160