]> Dogcows Code - chaz/openbox/blob - src/font.hh
add comment for later
[chaz/openbox] / src / font.hh
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 // Font.hh for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
23
24 #ifndef __Font_hh
25 #define __Font_hh
26
27 extern "C" {
28 #include <X11/Xlib.h>
29
30 #include <X11/Xft/Xft.h>
31 }
32
33 #include <assert.h>
34
35 #include <string>
36
37 class BGCCache;
38 class BGCCacheItem;
39 class BColor;
40
41 #include "screen.hh"
42
43 class BFont {
44 /*
45 * static members
46 */
47 private:
48 static std::string _fallback_font;
49
50 public:
51 // the fallback is only used for X fonts, not for Xft fonts, since it is
52 // assumed that X fonts will be the fallback from Xft.
53 inline static std::string fallbackFont(void) { return _fallback_font; }
54 inline static void setFallbackFont(const std::string &f)
55 { _fallback_font = f; }
56
57 /*
58 * instance members
59 */
60 private:
61 Display *_display;
62 BScreen *_screen;
63
64 std::string _family;
65 bool _simplename; // true if not spec'd as a -*-* string
66 int _size;
67 bool _bold;
68 bool _italic;
69
70 bool _antialias;
71 bool _shadow;
72 unsigned char _offset;
73 unsigned char _tint;
74
75 XftFont *_xftfont;
76
77 bool createXftFont(void);
78
79 bool _valid;
80
81 public:
82 // loads an Xft font
83 BFont(Display *d, BScreen *screen, const std::string &family, int size,
84 bool bold, bool italic, bool shadow, unsigned char offset,
85 unsigned char tint, bool antialias = True);
86 virtual ~BFont(void);
87
88 inline bool valid(void) const { return _valid; }
89
90 inline std::string family(void) const { assert(_valid); return _family; }
91 inline int size(void) const { assert(_valid); return _size; }
92 inline bool bold(void) const { assert(_valid); return _bold; }
93 inline bool italic(void) const { assert(_valid); return _italic; }
94
95 unsigned int height(void) const;
96 unsigned int maxCharWidth(void) const;
97
98 unsigned int measureString(const std::string &string) const;
99
100 void drawString(Drawable d, int x, int y, const BColor &color,
101 const std::string &string) const;
102 };
103
104 #endif // __Font_hh
This page took 0.040715 seconds and 4 git commands to generate.