]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/pen.h
moving common code
[wxWidgets.git] / include / wx / mac / carbon / pen.h
CommitLineData
8cf73271 1/////////////////////////////////////////////////////////////////////////////
46562151 2// Name: wx/mac/carbon/pen.h
8cf73271
SC
3// Purpose: wxPen class
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
65571936 9// Licence: wxWindows licence
8cf73271
SC
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_PEN_H_
13#define _WX_PEN_H_
14
8cf73271
SC
15#include "wx/gdiobj.h"
16#include "wx/colour.h"
17#include "wx/bitmap.h"
18
b5dbe15d 19class WXDLLIMPEXP_FWD_CORE wxPen;
8cf73271
SC
20
21class WXDLLEXPORT wxPenRefData: public wxGDIRefData
22{
b5dbe15d 23 friend class WXDLLIMPEXP_FWD_CORE wxPen;
8cf73271
SC
24public:
25 wxPenRefData();
26 wxPenRefData(const wxPenRefData& data);
d3c7fc99 27 virtual ~wxPenRefData();
8cf73271
SC
28
29 wxPenRefData& operator=(const wxPenRefData& data);
30
55ccdb93
VZ
31 bool operator==(const wxPenRefData& data) const
32 {
33 // we intentionally don't compare m_hPen fields here
34 return m_style == data.m_style &&
35 m_width == data.m_width &&
36 m_join == data.m_join &&
37 m_cap == data.m_cap &&
38 m_colour == data.m_colour &&
a3ab1c18 39 (m_style != wxSTIPPLE || m_stipple.IsSameAs(data.m_stipple)) &&
55ccdb93
VZ
40 (m_style != wxUSER_DASH ||
41 (m_nbDash == data.m_nbDash &&
42 memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
43 }
44
8cf73271
SC
45protected:
46 int m_width;
47 int m_style;
48 int m_join ;
49 int m_cap ;
50 wxBitmap m_stipple ;
51 int m_nbDash ;
52 wxDash * m_dash ;
53 wxColour m_colour;
54/* TODO: implementation
55 WXHPEN m_hPen;
56*/
57};
58
59#define M_PENDATA ((wxPenRefData *)m_refData)
60
61// Pen
62class WXDLLEXPORT wxPen: public wxGDIObject
63{
64 DECLARE_DYNAMIC_CLASS(wxPen)
65public:
66 wxPen();
67 wxPen(const wxColour& col, int width = 1, int style = wxSOLID);
68 wxPen(const wxBitmap& stipple, int width);
d3c7fc99 69 virtual ~wxPen();
8cf73271 70
55ccdb93
VZ
71 inline bool operator == (const wxPen& pen) const
72 {
73 const wxPenRefData *penData = (wxPenRefData *)pen.m_refData;
74
75 // an invalid pen is only equal to another invalid pen
76 return m_refData ? penData && *M_PENDATA == *penData : !penData;
77 }
78
2e573683 79 inline bool operator != (const wxPen& pen) const { return !(*this == pen); }
8cf73271 80
b7cacb43
VZ
81 virtual bool Ok() const { return IsOk(); }
82 virtual bool IsOk() const { return (m_refData != NULL) ; }
8cf73271
SC
83
84 // Override in order to recreate the pen
85 void SetColour(const wxColour& col) ;
1a1498c0 86 void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
8cf73271
SC
87
88 void SetWidth(int width) ;
89 void SetStyle(int style) ;
90 void SetStipple(const wxBitmap& stipple) ;
91 void SetDashes(int nb_dashes, const wxDash *dash) ;
92 void SetJoin(int join) ;
93 void SetCap(int cap) ;
94
95 inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); };
96 inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); };
97 inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); };
98 inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); };
99 inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); };
100 inline int GetDashes(wxDash **ptr) const {
101 *ptr = (M_PENDATA ? M_PENDATA->m_dash : (wxDash*) NULL); return (M_PENDATA ? M_PENDATA->m_nbDash : 0);
102 }
103
104 inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); };
105
106// Implementation
107
108 // Useful helper: create the brush resource
109 bool RealizeResource();
110
83dcd781
PC
111private:
112 void Unshare();
8cf73271
SC
113};
114
115#endif
116 // _WX_PEN_H_