]> git.saurik.com Git - wxWidgets.git/blame - include/wx/x11/font.h
Use correct extensions in wxDynamicLibrary::CanonicalizeName() on OS X.
[wxWidgets.git] / include / wx / x11 / font.h
CommitLineData
83df96d6 1/////////////////////////////////////////////////////////////////////////////
1b88201f 2// Name: wx/x11/font.h
83df96d6
JS
3// Purpose: wxFont class
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
1b88201f 9// Licence: wxWindows licence
83df96d6
JS
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_FONT_H_
13#define _WX_FONT_H_
14
83df96d6
JS
15class wxXFont;
16
17// Font
968eb2ef 18class WXDLLIMPEXP_CORE wxFont : public wxFontBase
83df96d6
JS
19{
20public:
21 // ctors and such
f8855e47 22 wxFont() { }
9045ad9d 23
b960795e
VZ
24 wxFont(const wxFontInfo& info)
25 {
26 Create(info.GetPointSize(),
27 info.GetFamily(),
28 info.GetStyle(),
29 info.GetWeight(),
30 info.IsUnderlined(),
31 info.GetFaceName(),
32 info.GetEncoding());
33
34 if ( info.IsUsingSizeInPixels() )
35 SetPixelSize(info.GetPixelSize());
36 }
37
0c14b6c3 38#if FUTURE_WXWIN_COMPATIBILITY_3_0
83df96d6 39 wxFont(int size,
0c14b6c3
FM
40 int family,
41 int style,
42 int weight,
43 bool underlined = false,
44 const wxString& face = wxEmptyString,
45 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
83df96d6 46 {
0c14b6c3 47 (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding);
83df96d6 48 }
0c14b6c3 49#endif
9045ad9d 50
0c14b6c3
FM
51 wxFont(int size,
52 wxFontFamily family,
53 wxFontStyle style,
54 wxFontWeight weight,
55 bool underlined = false,
56 const wxString& face = wxEmptyString,
57 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
58 {
59 Create(size, family, style, weight, underlined, face, encoding);
60 }
03647350 61
b5791cc7
FM
62 wxFont(const wxSize& pixelSize,
63 wxFontFamily family,
64 wxFontStyle style,
65 wxFontWeight weight,
66 bool underlined = false,
67 const wxString& face = wxEmptyString,
68 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
69 {
70 Create(10, family, style, weight, underlined, face, encoding);
71 SetPixelSize(pixelSize);
72 }
03647350 73
83df96d6 74 bool Create(int size,
0c14b6c3
FM
75 wxFontFamily family,
76 wxFontStyle style,
77 wxFontWeight weight,
78 bool underlined = false,
79 const wxString& face = wxEmptyString,
80 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
81
82 wxFont(const wxNativeFontInfo& info);
2b5f62a0
VZ
83
84 // FIXME: I added the ! to make it compile;
85 // is this right? - JACS
9045ad9d 86#if !wxUSE_UNICODE
83df96d6
JS
87 bool Create(const wxString& fontname,
88 wxFontEncoding fontenc = wxFONTENCODING_DEFAULT);
2b5f62a0
VZ
89#endif
90 // DELETEME: no longer seems to be implemented.
91 // bool Create(const wxNativeFontInfo& fontinfo);
9045ad9d 92
83df96d6 93 virtual ~wxFont();
9045ad9d 94
83df96d6
JS
95 // implement base class pure virtuals
96 virtual int GetPointSize() const;
0c14b6c3
FM
97 virtual wxFontStyle GetStyle() const;
98 virtual wxFontWeight GetWeight() const;
83df96d6
JS
99 virtual bool GetUnderlined() const;
100 virtual wxString GetFaceName() const;
101 virtual wxFontEncoding GetEncoding() const;
3bf5a59b 102 virtual const wxNativeFontInfo *GetNativeFontInfo() const;
9045ad9d 103
2b5f62a0 104 virtual bool IsFixedWidth() const;
9045ad9d 105
83df96d6 106 virtual void SetPointSize(int pointSize);
0c14b6c3
FM
107 virtual void SetFamily(wxFontFamily family);
108 virtual void SetStyle(wxFontStyle style);
109 virtual void SetWeight(wxFontWeight weight);
85ab460e 110 virtual bool SetFaceName(const wxString& faceName);
83df96d6
JS
111 virtual void SetUnderlined(bool underlined);
112 virtual void SetEncoding(wxFontEncoding encoding);
9045ad9d 113
f76c0758 114 wxDECLARE_COMMON_FONT_METHODS();
0c14b6c3 115
2b5f62a0
VZ
116 // Implementation
117
118#if wxUSE_PANGO
119#else
83df96d6
JS
120 // Find an existing, or create a new, XFontStruct
121 // based on this wxFont and the given scale. Append the
122 // font to list in the private data for future reference.
9045ad9d 123
83df96d6
JS
124 // TODO This is a fairly basic implementation, that doesn't
125 // allow for different facenames, and also doesn't do a mapping
126 // between 'standard' facenames (e.g. Arial, Helvetica, Times Roman etc.)
127 // and the fonts that are available on a particular system.
128 // Maybe we need to scan the user's machine to build up a profile
129 // of the fonts and a mapping file.
9045ad9d 130
83df96d6
JS
131 // Return font struct, and optionally the Motif font list
132 wxXFont *GetInternalFont(double scale = 1.0,
133 WXDisplay* display = NULL) const;
9045ad9d 134
bc797f4c 135 // Helper function for convenient access of the above.
83df96d6
JS
136 WXFontStructPtr GetFontStruct(double scale = 1.0,
137 WXDisplay* display = NULL) const;
2b5f62a0 138#endif
9045ad9d 139
83df96d6 140protected:
8f884a0d
VZ
141 virtual wxGDIRefData *CreateGDIRefData() const;
142 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
143
9045ad9d 144 virtual void DoSetNativeFontInfo( const wxNativeFontInfo& info );
59b7da02 145 virtual wxFontFamily DoGetFamily() const;
9045ad9d 146
83df96d6 147 void Unshare();
9045ad9d 148
83df96d6
JS
149private:
150 DECLARE_DYNAMIC_CLASS(wxFont)
151};
152
153#endif
1b88201f 154 // _WX_FONT_H_