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