]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/stubs/pen.h
compilation fix for builds when WXWIN_COMPATIBILITY_2 is not defined
[wxWidgets.git] / include / wx / stubs / pen.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: pen.h
3// Purpose: wxPen class
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_PEN_H_
13#define _WX_PEN_H_
14
15#ifdef __GNUG__
16#pragma interface "pen.h"
17#endif
18
19#include "wx/gdiobj.h"
20#include "wx/colour.h"
21#include "wx/bitmap.h"
22
23// PORTERS, NB: this typedef is the platform specific type for dashes..
24// change all occurences of XSTUBX in pen.h and pen.cpp to something
25// meaningful for your port (eg. wxMSWDash, wxGTKDash) and change the
26// type from long to whatever your platform requires.
27
28typedef long wxXSTUBXDash;
29
30// wxDash is typedef'd in gdicmn.h and is the type that should be used
31// for all public interfaces. Convert parameters to the wxXSTUBXDash
32// type for use inside the platform specific methods, and cast them
33// back to wxDash again before passing back to the user. -- RL
34
35class WXDLLEXPORT wxPen;
36
37class WXDLLEXPORT wxPenRefData: public wxGDIRefData
38{
39 friend class WXDLLEXPORT wxPen;
40public:
41 wxPenRefData();
42 wxPenRefData(const wxPenRefData& data);
43 ~wxPenRefData();
44
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 wxXSTUBXDash *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, int style);
68 wxPen(const wxBitmap& stipple, int width);
69 inline wxPen(const wxPen& pen) { Ref(pen); }
70 ~wxPen();
71
72 inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; }
73 inline bool operator == (const wxPen& pen) { return m_refData == pen.m_refData; }
74 inline bool operator != (const wxPen& pen) { return m_refData != pen.m_refData; }
75
76 virtual bool Ok() const { return (m_refData != NULL) ; }
77
78 // Override in order to recreate the pen
79 void SetColour(const wxColour& col) ;
80 void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
81
82 void SetWidth(int width) ;
83 void SetStyle(int style) ;
84 void SetStipple(const wxBitmap& stipple) ;
85 void SetDashes(int nb_dashes, const wxDash *dash) ;
86 void SetJoin(int join) ;
87 void SetCap(int cap) ;
88
89 inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); };
90 inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); };
91 inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); };
92 inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); };
93 inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); };
94 inline int GetDashes(wxDash **ptr) const
95 {
96 *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*)NULL);
97 return (M_PENDATA ? M_PENDATA->m_nbDash : 0);
98 }
99
100 inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); };
101
102// Implementation
103
104 // Useful helper: create the brush resource
105 bool RealizeResource();
106
107 // When setting properties, we must make sure we're not changing
108 // another object
109 void Unshare();
110};
111
112#endif
113 // _WX_PEN_H_