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