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