]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/cocoa/font.h | |
3 | // Purpose: wxFont class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_FONT_H_ | |
13 | #define _WX_FONT_H_ | |
14 | ||
15 | // ---------------------------------------------------------------------------- | |
16 | // wxFont | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | DECLARE_WXCOCOA_OBJC_CLASS(NSFont); | |
20 | ||
21 | // Internal class that bridges us with code like wxSystemSettings | |
22 | class wxCocoaFontFactory; | |
23 | // We have c-tors/methods taking pointers of these | |
24 | class wxFontRefData; | |
25 | ||
26 | /*! @discussion | |
27 | wxCocoa's implementation of wxFont is very incomplete. In particular, | |
28 | a lot of work needs to be done on wxNativeFontInfo which is currently | |
29 | using the totally generic implementation. | |
30 | ||
31 | See the documentation in src/cocoa/font.mm for more implementatoin details. | |
32 | */ | |
33 | class WXDLLIMPEXP_CORE wxFont : public wxFontBase | |
34 | { | |
35 | friend class wxCocoaFontFactory; | |
36 | public: | |
37 | /*! @abstract Default construction of invalid font for 2-step construct then Create process. | |
38 | */ | |
39 | wxFont() { } | |
40 | ||
41 | wxFont(const wxFontInfo& info) | |
42 | { | |
43 | Create(info.GetPointSize(), | |
44 | info.GetFamily(), | |
45 | info.GetStyle(), | |
46 | info.GetWeight(), | |
47 | info.IsUnderlined(), | |
48 | info.GetFaceName(), | |
49 | info.GetEncoding()); | |
50 | ||
51 | if ( info.IsUsingSizeInPixels() ) | |
52 | SetPixelSize(info.GetPixelSize()); | |
53 | } | |
54 | ||
55 | /*! @abstract Platform-independent construction with individual properties | |
56 | */ | |
57 | #if FUTURE_WXWIN_COMPATIBILITY_3_0 | |
58 | wxFont(int size, | |
59 | int family, | |
60 | int style, | |
61 | int weight, | |
62 | bool underlined = FALSE, | |
63 | const wxString& face = wxEmptyString, | |
64 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
65 | { | |
66 | (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding); | |
67 | } | |
68 | #endif | |
69 | wxFont(int size, | |
70 | wxFontFamily family, | |
71 | wxFontStyle style, | |
72 | wxFontWeight weight, | |
73 | bool underlined = FALSE, | |
74 | const wxString& face = wxEmptyString, | |
75 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
76 | { | |
77 | (void)Create(size, family, style, weight, underlined, face, encoding); | |
78 | } | |
79 | ||
80 | wxFont(const wxSize& pixelSize, | |
81 | wxFontFamily family, | |
82 | wxFontStyle style, | |
83 | wxFontWeight weight, | |
84 | bool underlined = false, | |
85 | const wxString& face = wxEmptyString, | |
86 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
87 | { | |
88 | Create(10, family, style, weight, underlined, face, encoding); | |
89 | SetPixelSize(pixelSize); | |
90 | } | |
91 | ||
92 | /*! @abstract Construction with opaque wxNativeFontInfo | |
93 | */ | |
94 | wxFont(const wxNativeFontInfo& info) | |
95 | { | |
96 | (void)Create(info); | |
97 | } | |
98 | ||
99 | /*! @abstract Construction with platform-dependent font descriptor string. | |
100 | @param fontDesc Usually the result of wxNativeFontInfo::ToUserString() | |
101 | */ | |
102 | wxFont(const wxString& fontDesc); | |
103 | ||
104 | // NOTE: Copy c-tor and assignment from wxObject is fine | |
105 | ||
106 | bool Create(int size, | |
107 | wxFontFamily family, | |
108 | wxFontStyle style, | |
109 | wxFontWeight weight, | |
110 | bool underlined = FALSE, | |
111 | const wxString& face = wxEmptyString, | |
112 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
113 | ||
114 | bool Create(const wxNativeFontInfo& info); | |
115 | ||
116 | virtual ~wxFont(); | |
117 | ||
118 | // implement base class pure virtuals | |
119 | virtual int GetPointSize() const; | |
120 | virtual wxFontStyle GetStyle() const; | |
121 | virtual wxFontWeight GetWeight() const; | |
122 | virtual bool GetUnderlined() const; | |
123 | virtual wxString GetFaceName() const; | |
124 | virtual wxFontEncoding GetEncoding() const; | |
125 | virtual const wxNativeFontInfo *GetNativeFontInfo() const; | |
126 | ||
127 | virtual void SetPointSize(int pointSize); | |
128 | virtual void SetFamily(wxFontFamily family); | |
129 | virtual void SetStyle(wxFontStyle style); | |
130 | virtual void SetWeight(wxFontWeight weight); | |
131 | virtual bool SetFaceName(const wxString& faceName); | |
132 | virtual void SetUnderlined(bool underlined); | |
133 | virtual void SetEncoding(wxFontEncoding encoding); | |
134 | ||
135 | wxDECLARE_COMMON_FONT_METHODS(); | |
136 | ||
137 | // implementation only from now on | |
138 | // ------------------------------- | |
139 | ||
140 | /*! @abstract Defined on some ports (not including this one) in wxGDIObject | |
141 | @discussion | |
142 | The intention here I suppose is to allow one to create a wxFont without yet | |
143 | creating the underlying native object. There's no point not to create the | |
144 | NSFont immediately in wxCocoa so this is useless. | |
145 | This method came from the stub code copied in the early days of wxCocoa. | |
146 | FIXME(1): Remove this in trunk. FIXME(2): Is it really a good idea for this to | |
147 | be part of the public API for wxGDIObject? | |
148 | */ | |
149 | virtual bool RealizeResource(); | |
150 | ||
151 | protected: | |
152 | /*! @abstract Internal constructor with ref data | |
153 | @discussion | |
154 | Takes ownership of @a refData. That is, it is assumed that refData has either just been | |
155 | created using new (which initializes its m_refCount to 1) or if you are sharing a ref that | |
156 | you have called IncRef on it before passing it to this method. | |
157 | */ | |
158 | explicit wxFont(wxFontRefData *refData) | |
159 | { Create(refData); } | |
160 | bool Create(wxFontRefData *refData); | |
161 | ||
162 | virtual wxGDIRefData *CreateGDIRefData() const; | |
163 | virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; | |
164 | ||
165 | virtual wxFontFamily DoGetFamily() const; | |
166 | ||
167 | private: | |
168 | DECLARE_DYNAMIC_CLASS(wxFont) | |
169 | }; | |
170 | ||
171 | #endif | |
172 | // _WX_FONT_H_ |