diff options
Diffstat (limited to 'src/Theme.hh')
-rw-r--r-- | src/Theme.hh | 187 |
1 files changed, 91 insertions, 96 deletions
diff --git a/src/Theme.hh b/src/Theme.hh index c090a19..adabc39 100644 --- a/src/Theme.hh +++ b/src/Theme.hh | |||
@@ -1,5 +1,8 @@ | |||
1 | // Theme.hh for fluxbox | 1 | // Theme.hh for fluxbox |
2 | // Copyright (c) 2001 Henrik Kinnunen (fluxgen@linuxmail.org) | 2 | // Copyright (c) 2001-2002 Henrik Kinnunen (fluxgen@linuxmail.org) |
3 | // | ||
4 | // A lot of the base code is taken from Screen.hh in Blackbox 0.61.1 | ||
5 | // Screen.cc - Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) | ||
3 | // | 6 | // |
4 | // Permission is hereby granted, free of charge, to any person obtaining a | 7 | // Permission is hereby granted, free of charge, to any person obtaining a |
5 | // copy of this software and associated documentation files (the "Software"), | 8 | // copy of this software and associated documentation files (the "Software"), |
@@ -13,114 +16,104 @@ | |||
13 | // | 16 | // |
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 20 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
21 | // | ||
22 | // A lot of the base code is taken from Screen.hh in Blackbox 0.61.1 | ||
23 | // and Brad Hughes (bhuges@tcac.net) should get alot of credit for it | ||
24 | // And for license-hunters here's the license and copyright for Screen.cc | ||
25 | // Screen.cc - Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) | ||
26 | // | ||
27 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
28 | // copy of this software and associated documentation files (the "Software"), | ||
29 | // to deal in the Software without restriction, including without limitation | ||
30 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
31 | // and/or sell copies of the Software, and to permit persons to whom the | ||
32 | // Software is furnished to do so, subject to the following conditions: | ||
33 | // | ||
34 | // The above copyright notice and this permission notice shall be included in | ||
35 | // all copies or substantial portions of the Software. | ||
36 | // | ||
37 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
38 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
39 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
40 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
41 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
42 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
43 | // DEALINGS IN THE SOFTWARE. | ||
44 | 24 | ||
45 | #ifndef _THEME_HH_ | 25 | // $Id: Theme.hh,v 1.17 2002/10/29 16:06:23 fluxgen Exp $ |
46 | #define _THEME_HH_ | ||
47 | 26 | ||
27 | #ifndef THEME_HH | ||
28 | #define THEME_HH | ||
48 | 29 | ||
49 | #include "Image.hh" | 30 | #include "Image.hh" |
31 | #include "DrawUtil.hh" | ||
32 | #include "Font.hh" | ||
33 | |||
50 | #include <X11/Xlib.h> | 34 | #include <X11/Xlib.h> |
51 | #include <X11/Xresource.h> | 35 | #include <X11/Xresource.h> |
52 | 36 | ||
53 | #include "Rotated.hh" // TODO: should bake this into misc.hh some day | 37 | #include <string> |
54 | 38 | /** | |
55 | typedef struct FFont | 39 | Main theme class, holds themes for |
56 | { | 40 | Window, toolbar, slit, menu and the rootCommand, for a specific screen. |
57 | enum FontJustify {Left=0, Right, Center}; | 41 | */ |
42 | class Theme { | ||
43 | public: | ||
44 | |||
45 | Theme(Display *display, Window rootwindow, Colormap colormap, | ||
46 | int screennum, BImageControl *ic, const char *filename, const char *rootcommand); | ||
47 | ~Theme(); | ||
58 | 48 | ||
59 | XFontSet set; | ||
60 | XFontSetExtents *set_extents; | ||
61 | XFontStruct *fontstruct; | ||
62 | FontJustify justify; | ||
63 | } FFont; | ||
64 | |||
65 | typedef struct LabelStyle | ||
66 | { | ||
67 | BTexture l_focus, l_unfocus, | ||
68 | t_focus, t_unfocus; | ||
69 | GC l_text_focus_gc, l_text_unfocus_gc; | ||
70 | FFont font; | ||
71 | BColor l_text_focus, l_text_unfocus; | ||
72 | } LabelStyle; | ||
73 | |||
74 | typedef struct WindowStyle:public LabelStyle { | ||
75 | BColor f_focus, f_unfocus, b_pic_focus, | ||
76 | b_pic_unfocus; | ||
77 | BTexture h_focus, h_unfocus, | ||
78 | b_focus, b_unfocus, b_pressed, g_focus, g_unfocus; | ||
79 | GC b_pic_focus_gc, b_pic_unfocus_gc; | ||
80 | |||
81 | struct t_tab:public LabelStyle { | ||
82 | BColor border_color; | ||
83 | unsigned int border_width; | ||
84 | unsigned int border_width_2x; | ||
85 | XRotFontStruct *rot_font; | ||
86 | } tab; | ||
87 | 49 | ||
88 | } WindowStyle; | 50 | typedef struct MenuStyle { |
89 | 51 | MenuStyle():titlefont("fixed"), | |
90 | typedef struct ToolbarStyle { | 52 | framefont("fixed") { } |
91 | BColor l_text, w_text, c_text, b_pic; | 53 | FbTk::Color t_text, f_text, h_text, d_text; |
92 | BTexture toolbar, label, window, button, pressed, clock; | 54 | FbTk::Texture title, frame, hilite; |
93 | GC l_text_gc, w_text_gc, c_text_gc, b_pic_gc; | 55 | GC t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc; |
94 | FFont font; | 56 | FbTk::Font titlefont, framefont; |
95 | 57 | DrawUtil::Font::FontJustify framefont_justify; | |
96 | } ToolbarStyle; | 58 | DrawUtil::Font::FontJustify titlefont_justify; |
59 | int bullet, bullet_pos; | ||
60 | } MenuStyle; | ||
61 | |||
62 | typedef struct LabelStyle { | ||
63 | LabelStyle(const char *fontname="fixed"):font(fontname) { } | ||
97 | 64 | ||
98 | typedef struct MenuStyle { | 65 | FbTk::Texture l_focus, l_unfocus, |
99 | BColor t_text, f_text, h_text, d_text; | 66 | t_focus, t_unfocus; |
100 | BTexture title, frame, hilite; | 67 | GC l_text_focus_gc, l_text_unfocus_gc; |
101 | GC t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc; | 68 | FbTk::Font font; |
102 | FFont titlefont, framefont; | 69 | DrawUtil::Font::FontJustify justify; |
103 | int bullet, bullet_pos; | 70 | FbTk::Color l_text_focus, l_text_unfocus; |
104 | } MenuStyle; | 71 | } LabelStyle; |
105 | 72 | ||
106 | //singleton class | 73 | |
107 | class Theme | 74 | typedef struct WindowStyle:public LabelStyle { |
108 | { | 75 | FbTk::Color f_focus, f_unfocus, b_pic_focus, |
109 | public: | 76 | b_pic_unfocus; |
110 | Theme(Display *display, Colormap colormap, int screennum, BImageControl *ic, const char *filename); | 77 | FbTk::Texture h_focus, h_unfocus, |
111 | ~Theme(); | 78 | b_focus, b_unfocus, b_pressed, g_focus, g_unfocus; |
79 | GC b_pic_focus_gc, b_pic_unfocus_gc; | ||
80 | |||
81 | struct t_tab:public LabelStyle { | ||
82 | FbTk::Color border_color; | ||
83 | unsigned int border_width; | ||
84 | unsigned int border_width_2x; | ||
85 | DrawUtil::XRotFontStruct *rot_font; | ||
86 | } tab; | ||
87 | |||
88 | } WindowStyle; | ||
112 | 89 | ||
90 | |||
91 | typedef struct ToolbarStyle { | ||
92 | ToolbarStyle():font("fixed") { } // default font 'fixed' | ||
93 | FbTk::Color l_text, w_text, c_text, b_pic; | ||
94 | FbTk::Texture toolbar, label, window, button, pressed, clock; | ||
95 | GC l_text_gc, w_text_gc, c_text_gc, b_pic_gc; | ||
96 | FbTk::Font font; | ||
97 | DrawUtil::Font::FontJustify justify; | ||
98 | } ToolbarStyle; | ||
99 | |||
100 | inline WindowStyle &getWindowStyle() { return m_windowstyle; } | ||
101 | inline MenuStyle &getMenuStyle() { return m_menustyle; } | ||
102 | inline ToolbarStyle &getToolbarStyle() { return m_toolbarstyle; } | ||
103 | inline const FbTk::Texture &getSlitTexture() const { return m_slit_texture; } | ||
104 | inline unsigned int getBevelWidth() const { return m_bevel_width; } | ||
105 | inline unsigned int getBorderWidth() const { return m_border_width; } | ||
106 | inline unsigned int getHandleWidth() const { return m_handle_width; } | ||
107 | inline unsigned int getFrameWidth() const { return m_frame_width; } | ||
108 | inline GC getOpGC() const { return m_opgc; } | ||
109 | inline const FbTk::Color &getBorderColor() const { return m_border_color; } | ||
113 | void load(const char *filename); | 110 | void load(const char *filename); |
114 | void reconfigure(); | 111 | void reconfigure(bool antialias = false); |
115 | inline WindowStyle *getWindowStyle(void) { return &m_windowstyle; } | 112 | |
116 | inline MenuStyle *getMenuStyle(void) { return &m_menustyle; } | 113 | inline void setRootCommand(const std::string &command) { m_rootcommand = command; } |
117 | inline ToolbarStyle *getToolbarStyle(void) { return &m_toolbarstyle; } | 114 | |
118 | inline const unsigned int & getBevelWidth(void) const { return m_bevel_width; } | 115 | |
119 | inline const unsigned int & getBorderWidth(void) const { return m_border_width; } | 116 | |
120 | inline const unsigned int & getHandleWidth(void) const { return m_handle_width; } | ||
121 | inline const unsigned int & getFrameWidth(void) const { return m_frame_width; } | ||
122 | inline const GC &getOpGC(void) const { return m_opgc; } | ||
123 | inline const BColor & getBorderColor(void) const { return m_border_color; } | ||
124 | private: | 117 | private: |
125 | 118 | ||
126 | void loadMenuStyle(); | 119 | void loadMenuStyle(); |
@@ -133,9 +126,9 @@ private: | |||
133 | void freeWindowStyle(); | 126 | void freeWindowStyle(); |
134 | void freeTabStyle(); | 127 | void freeTabStyle(); |
135 | void freeToolbarStyle(); | 128 | void freeToolbarStyle(); |
136 | 129 | void loadFontFromDatabase(FbTk::Font &dest, const char *name, const char *altname); | |
137 | bool readDatabaseTexture(char *, char *, BTexture *, unsigned long); | 130 | bool readDatabaseTexture(char *, char *, FbTk::Texture *, unsigned long); |
138 | bool readDatabaseColor(char *, char *, BColor *, unsigned long); | 131 | bool readDatabaseColor(char *, char *, FbTk::Color *, unsigned long); |
139 | 132 | ||
140 | void readDatabaseFontSet(char *, char *, XFontSet *); | 133 | void readDatabaseFontSet(char *, char *, XFontSet *); |
141 | XFontSet createFontSet(char *); | 134 | XFontSet createFontSet(char *); |
@@ -149,13 +142,15 @@ private: | |||
149 | MenuStyle m_menustyle; | 142 | MenuStyle m_menustyle; |
150 | ToolbarStyle m_toolbarstyle; | 143 | ToolbarStyle m_toolbarstyle; |
151 | unsigned int m_bevel_width, m_border_width, m_handle_width, m_frame_width; | 144 | unsigned int m_bevel_width, m_border_width, m_handle_width, m_frame_width; |
152 | BColor m_border_color; | 145 | FbTk::Color m_border_color; |
153 | GC m_opgc; | 146 | GC m_opgc; |
154 | BImageControl *m_imagecontrol; | 147 | BImageControl *m_imagecontrol; |
155 | Display *m_display; | 148 | Display *m_display; |
156 | XrmDatabase m_database; | 149 | XrmDatabase m_database; |
157 | Colormap m_colormap; | 150 | Colormap m_colormap; |
158 | int m_screennum; | 151 | int m_screennum; |
152 | std::string m_rootcommand; | ||
153 | FbTk::Texture m_slit_texture; | ||
159 | }; | 154 | }; |
160 | 155 | ||
161 | 156 | ||