]>
Commit | Line | Data |
---|---|---|
9b6dbb09 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: font.h | |
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 | |
65571936 | 9 | // Licence: wxWindows licence |
9b6dbb09 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_FONT_H_ | |
13 | #define _WX_FONT_H_ | |
14 | ||
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
83df96d6 | 16 | #pragma interface "font.h" |
9b6dbb09 JS |
17 | #endif |
18 | ||
a2e91a93 VZ |
19 | class wxXFont; |
20 | ||
93ccaed8 VZ |
21 | // Font |
22 | class wxFont : public wxFontBase | |
f97c9854 JS |
23 | { |
24 | public: | |
93ccaed8 VZ |
25 | // ctors and such |
26 | wxFont() { Init(); } | |
27 | wxFont(const wxFont& font) { Init(); Ref(font); } | |
9045ad9d | 28 | |
93ccaed8 | 29 | wxFont(int size, |
83df96d6 JS |
30 | int family, |
31 | int style, | |
32 | int weight, | |
96be256b | 33 | bool underlined = false, |
83df96d6 JS |
34 | const wxString& face = wxEmptyString, |
35 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
93ccaed8 VZ |
36 | { |
37 | Init(); | |
9045ad9d | 38 | |
93ccaed8 VZ |
39 | (void)Create(size, family, style, weight, underlined, face, encoding); |
40 | } | |
9045ad9d | 41 | |
98c9fc2d | 42 | wxFont(const wxNativeFontInfo& info); |
9045ad9d | 43 | |
93ccaed8 | 44 | bool Create(int size, |
83df96d6 JS |
45 | int family, |
46 | int style, | |
47 | int weight, | |
96be256b | 48 | bool underlined = false, |
83df96d6 JS |
49 | const wxString& face = wxEmptyString, |
50 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
9045ad9d | 51 | |
563f868d GD |
52 | // wxMOTIF-specific |
53 | bool Create(const wxString& fontname, | |
83df96d6 | 54 | wxFontEncoding fontenc = wxFONTENCODING_DEFAULT); |
563f868d | 55 | bool Create(const wxNativeFontInfo& fontinfo); |
9045ad9d | 56 | |
93ccaed8 | 57 | virtual ~wxFont(); |
9045ad9d | 58 | |
93ccaed8 VZ |
59 | // assignment |
60 | wxFont& operator=(const wxFont& font); | |
9045ad9d | 61 | |
93ccaed8 VZ |
62 | // implement base class pure virtuals |
63 | virtual int GetPointSize() const; | |
64 | virtual int GetFamily() const; | |
65 | virtual int GetStyle() const; | |
66 | virtual int GetWeight() const; | |
67 | virtual bool GetUnderlined() const; | |
68 | virtual wxString GetFaceName() const; | |
69 | virtual wxFontEncoding GetEncoding() const; | |
3bf5a59b | 70 | virtual const wxNativeFontInfo *GetNativeFontInfo() const; |
9045ad9d | 71 | |
93ccaed8 VZ |
72 | virtual void SetPointSize(int pointSize); |
73 | virtual void SetFamily(int family); | |
74 | virtual void SetStyle(int style); | |
75 | virtual void SetWeight(int weight); | |
76 | virtual void SetFaceName(const wxString& faceName); | |
77 | virtual void SetUnderlined(bool underlined); | |
78 | virtual void SetEncoding(wxFontEncoding encoding); | |
9045ad9d | 79 | |
93ccaed8 | 80 | // Implementation |
9045ad9d | 81 | |
93ccaed8 VZ |
82 | // Find an existing, or create a new, XFontStruct |
83 | // based on this wxFont and the given scale. Append the | |
84 | // font to list in the private data for future reference. | |
9045ad9d | 85 | |
93ccaed8 VZ |
86 | // TODO This is a fairly basic implementation, that doesn't |
87 | // allow for different facenames, and also doesn't do a mapping | |
88 | // between 'standard' facenames (e.g. Arial, Helvetica, Times Roman etc.) | |
89 | // and the fonts that are available on a particular system. | |
90 | // Maybe we need to scan the user's machine to build up a profile | |
91 | // of the fonts and a mapping file. | |
9045ad9d | 92 | |
93ccaed8 | 93 | // Return font struct, and optionally the Motif font list |
a2e91a93 | 94 | wxXFont *GetInternalFont(double scale = 1.0, |
83df96d6 | 95 | WXDisplay* display = NULL) const; |
9045ad9d | 96 | |
93ccaed8 VZ |
97 | // These two are helper functions for convenient access of the above. |
98 | WXFontStructPtr GetFontStruct(double scale = 1.0, | |
83df96d6 | 99 | WXDisplay* display = NULL) const; |
93ccaed8 | 100 | WXFontList GetFontList(double scale = 1.0, |
83df96d6 | 101 | WXDisplay* display = NULL) const; |
da494b40 MB |
102 | #if __WXMOTIF20__ |
103 | WXRenderTable GetRenderTable(WXDisplay* display) const; | |
104 | #endif | |
105 | // returns either a XmFontList or XmRendition, depending | |
106 | // on Motif version | |
107 | WXFontType GetFontType(WXDisplay* display) const; | |
108 | static WXString GetFontTag(); | |
9b6dbb09 | 109 | protected: |
9045ad9d VZ |
110 | virtual void DoSetNativeFontInfo( const wxNativeFontInfo& info ); |
111 | ||
93ccaed8 VZ |
112 | // common part of all ctors |
113 | void Init(); | |
9045ad9d | 114 | |
93ccaed8 | 115 | // VZ: IMHO, we don't need it at all... |
96be256b | 116 | bool RealizeResource() { return true; } |
93ccaed8 | 117 | void Unshare(); |
9045ad9d | 118 | |
93ccaed8 VZ |
119 | private: |
120 | DECLARE_DYNAMIC_CLASS(wxFont) | |
9b6dbb09 JS |
121 | }; |
122 | ||
123 | #endif | |
83df96d6 | 124 | // _WX_FONT_H_ |