]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/pen.h
Works a little better when you remember to say "virtual"
[wxWidgets.git] / include / wx / mac / pen.h
CommitLineData
0dbd6262 1/////////////////////////////////////////////////////////////////////////////
4f535231 2// Name: wx/mac/pen.h
0dbd6262 3// Purpose: wxPen class
a31a5f85 4// Author: Stefan Csomor
0dbd6262 5// Modified by:
a31a5f85 6// Created: 1998-01-01
0dbd6262 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
e40298d5 9// Licence: wxWindows licence
0dbd6262
SC
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_PEN_H_
13#define _WX_PEN_H_
14
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
0dbd6262
SC
16#pragma interface "pen.h"
17#endif
18
19#include "wx/gdiobj.h"
20#include "wx/colour.h"
21#include "wx/bitmap.h"
22
0dbd6262
SC
23class WXDLLEXPORT wxPen;
24
25class WXDLLEXPORT wxPenRefData: public wxGDIRefData
26{
27 friend class WXDLLEXPORT wxPen;
28public:
29 wxPenRefData();
30 wxPenRefData(const wxPenRefData& data);
31 ~wxPenRefData();
32
f2af4afb
GD
33 wxPenRefData& operator=(const wxPenRefData& data);
34
0dbd6262
SC
35protected:
36 int m_width;
37 int m_style;
38 int m_join ;
39 int m_cap ;
40 wxBitmap m_stipple ;
41 int m_nbDash ;
05adb9d2 42 wxDash * m_dash ;
0dbd6262
SC
43 wxColour m_colour;
44/* TODO: implementation
45 WXHPEN m_hPen;
46*/
47};
48
49#define M_PENDATA ((wxPenRefData *)m_refData)
50
51// Pen
52class WXDLLEXPORT wxPen: public wxGDIObject
53{
54 DECLARE_DYNAMIC_CLASS(wxPen)
55public:
56 wxPen();
4f535231 57 wxPen(const wxColour& col, int width = 1, int style = wxSOLID);
0dbd6262 58 wxPen(const wxBitmap& stipple, int width);
f2af4afb
GD
59 wxPen(const wxPen& pen)
60 : wxGDIObject()
61 { Ref(pen); }
0dbd6262
SC
62 ~wxPen();
63
64 inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; }
65 inline bool operator == (const wxPen& pen) { return m_refData == pen.m_refData; }
66 inline bool operator != (const wxPen& pen) { return m_refData != pen.m_refData; }
67
68 virtual bool Ok() const { return (m_refData != NULL) ; }
69
70 // Override in order to recreate the pen
71 void SetColour(const wxColour& col) ;
72 void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
73
74 void SetWidth(int width) ;
75 void SetStyle(int style) ;
76 void SetStipple(const wxBitmap& stipple) ;
77 void SetDashes(int nb_dashes, const wxDash *dash) ;
78 void SetJoin(int join) ;
79 void SetCap(int cap) ;
80
81 inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); };
82 inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); };
83 inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); };
84 inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); };
85 inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); };
05adb9d2
SC
86 inline int GetDashes(wxDash **ptr) const {
87 *ptr = (M_PENDATA ? M_PENDATA->m_dash : (wxDash*) NULL); return (M_PENDATA ? M_PENDATA->m_nbDash : 0);
0dbd6262
SC
88 }
89
90 inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); };
91
92// Implementation
93
94 // Useful helper: create the brush resource
95 bool RealizeResource();
96
97 // When setting properties, we must make sure we're not changing
98 // another object
99 void Unshare();
100};
101
102#endif
103 // _WX_PEN_H_