]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/pen.h
TIFF code 1.
[wxWidgets.git] / include / wx / os2 / pen.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: pen.h
3 // Purpose: wxPen class
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/10/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_PEN_H_
13 #define _WX_PEN_H_
14
15 #include "wx/gdiobj.h"
16 #include "wx/bitmap.h"
17
18 typedef long wxDash ;
19
20 class WXDLLEXPORT wxPen;
21
22 class WXDLLEXPORT wxPenRefData: public wxGDIRefData
23 {
24 friend class WXDLLEXPORT wxPen;
25 public:
26 wxPenRefData();
27 wxPenRefData(const wxPenRefData& data);
28 ~wxPenRefData();
29
30 protected:
31 int m_width;
32 int m_style;
33 int m_join ;
34 int m_cap ;
35 wxBitmap m_stipple ;
36 int m_nbDash ;
37 wxDash * m_dash ;
38 wxColour m_colour;
39 WXHPEN m_hPen;
40 };
41
42 #define M_PENDATA ((wxPenRefData *)m_refData)
43
44 // Pen
45 class WXDLLEXPORT wxPen: public wxGDIObject
46 {
47 DECLARE_DYNAMIC_CLASS(wxPen)
48 public:
49 wxPen();
50 wxPen(const wxColour& col, int width, int style);
51 wxPen(const wxBitmap& stipple, int width);
52 inline wxPen(const wxPen& pen) { Ref(pen); }
53 ~wxPen();
54
55 inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; }
56 inline bool operator == (const wxPen& pen) { return m_refData == pen.m_refData; }
57 inline bool operator != (const wxPen& pen) { return m_refData != pen.m_refData; }
58
59 virtual bool Ok() const { return (m_refData != NULL) ; }
60
61 // Override in order to recreate the pen
62 void SetColour(const wxColour& col) ;
63 void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
64
65 void SetWidth(int width) ;
66 void SetStyle(int style) ;
67 void SetStipple(const wxBitmap& stipple) ;
68 void SetDashes(int nb_dashes, const wxDash *dash) ;
69 void SetJoin(int join) ;
70 void SetCap(int cap) ;
71
72 inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); };
73 inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); };
74 inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); };
75 inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); };
76 inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); };
77 inline int GetDashes(wxDash **ptr) const {
78 *ptr = (M_PENDATA ? M_PENDATA->m_dash : (wxDash*) NULL); return (M_PENDATA ? M_PENDATA->m_nbDash : 0);
79 }
80
81 inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); };
82
83 // Implementation
84
85 // Useful helper: create the brush resource
86 bool RealizeResource();
87 bool FreeResource(bool force = FALSE);
88 WXHANDLE GetResourceHandle() ;
89 bool IsFree() const;
90 void Unshare();
91 };
92
93 #endif
94 // _WX_PEN_H_