]>
Commit | Line | Data |
---|---|---|
32b8ec41 | 1 | ///////////////////////////////////////////////////////////////////////////// |
f96f3362 | 2 | // Name: wx/mgl/fontutil.h |
32b8ec41 VZ |
3 | // Purpose: font-related helper functions for MGL |
4 | // Author: Vaclav Slavik | |
5 | // Created: 2001/05/01 | |
6 | // RCS-ID: $Id$ | |
8f7b34a8 | 7 | // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com) |
32b8ec41 VZ |
8 | // Licence: wxWindows license |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_MGL_FONTUTIL_H_ | |
12 | #define _WX_MGL_FONTUTIL_H_ | |
13 | ||
32b8ec41 VZ |
14 | #include "wx/list.h" |
15 | ||
16 | struct font_info_t; | |
17 | struct font_lib_t; | |
18 | struct font_t; | |
19 | ||
20 | class wxMGLFontInstance; | |
21 | class wxMGLFontInstanceList; | |
22 | class wxMGLFontLibrary; | |
23 | class wxMGLFontFamily; | |
24 | ||
25 | enum | |
26 | { | |
27 | wxFONTFACE_REGULAR = 0, | |
28 | wxFONTFACE_ITALIC = 1, | |
29 | wxFONTFACE_BOLD = 2, // = (regular | bold) | |
30 | wxFONTFACE_BOLD_ITALIC = 3, // = (italic | bold) | |
31 | ||
32 | wxFONTFACE_MAX | |
33 | }; | |
34 | ||
35 | // structure representing particular loaded font instance: | |
36 | class wxMGLFontInstance | |
37 | { | |
38 | public: | |
39 | wxMGLFontInstance(wxMGLFontLibrary *fontLib, float pt, bool slant, bool aa); | |
40 | ~wxMGLFontInstance(); | |
41 | ||
42 | struct font_t *GetMGLfont_t() const { return m_font; } | |
43 | ||
44 | float GetPt() const { return m_pt; } | |
45 | bool GetSlant() const { return m_slant; } | |
46 | bool GetAA() const { return m_aa; } | |
47 | ||
48 | private: | |
49 | wxMGLFontLibrary *m_fontLib; | |
50 | font_t *m_font; | |
51 | float m_pt; | |
52 | bool m_slant; | |
53 | bool m_aa; | |
54 | }; | |
55 | ||
56 | // structure representing loaded font library: | |
57 | class wxMGLFontLibrary | |
58 | { | |
59 | public: | |
60 | wxMGLFontLibrary(const wxString& filename, int type); | |
61 | ~wxMGLFontLibrary(); | |
62 | ||
63 | wxMGLFontInstance *GetFontInstance(wxFont *font, float scale, bool aa); | |
64 | ||
65 | void IncRef(); | |
66 | void DecRef(); | |
67 | ||
68 | struct font_lib_t *GetMGLfont_lib_t() const { return m_fontLib; } | |
69 | ||
70 | private: | |
71 | font_lib_t *m_fontLib; | |
72 | int m_type; | |
73 | wxString m_fileName; | |
74 | size_t m_refs; | |
75 | wxMGLFontInstanceList *m_instances; | |
76 | }; | |
77 | ||
78 | // structure representing native MGL font family | |
79 | class wxMGLFontFamily : public wxObject | |
80 | { | |
81 | public: | |
82 | wxMGLFontFamily(const font_info_t *info); | |
83 | virtual ~wxMGLFontFamily(); | |
84 | ||
85 | wxString GetName() const { return m_name; } | |
86 | const font_info_t *GetInfo() const { return m_fontInfo; } | |
87 | ||
88 | bool HasFace(int type) const; | |
89 | wxMGLFontLibrary *GetLibrary(int type) const | |
90 | { return m_fontLibs[type]; } | |
91 | ||
92 | private: | |
93 | wxString m_name; | |
94 | const font_info_t *m_fontInfo; | |
95 | wxMGLFontLibrary *m_fontLibs[wxFONTFACE_MAX]; | |
96 | }; | |
97 | ||
98 | WX_DECLARE_LIST(wxMGLFontFamily, wxMGLFontFamilyList); | |
99 | ||
100 | class wxFontsManager | |
101 | { | |
102 | public: | |
103 | wxFontsManager(); | |
104 | ~wxFontsManager(); | |
105 | ||
106 | void AddFamily(const font_info_t *info); | |
107 | ||
108 | // return info about font with given name: | |
109 | wxMGLFontFamily *GetFamily(const wxString& name) const; | |
110 | // return list of all families | |
111 | wxMGLFontFamilyList *GetFamilyList() { return m_list; } | |
112 | ||
113 | wxMGLFontLibrary *GetFontLibrary(wxFont *font); | |
114 | ||
115 | private: | |
116 | wxHashTable *m_hash; | |
117 | wxMGLFontFamilyList *m_list; | |
118 | }; | |
119 | ||
120 | extern wxFontsManager *wxTheFontsManager; | |
121 | ||
32b8ec41 | 122 | #endif // _WX_MGL_FONTUTIL_H_ |