diff options
author | fluxgen <fluxgen> | 2001-12-11 20:47:02 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2001-12-11 20:47:02 (GMT) |
commit | 18830ac9add80cbd3bf7369307d7e35a519dca9b (patch) | |
tree | 4759a5434a34ba317fe77bbf8b0ed9bb57bb6018 /src/Theme.hh | |
parent | 1523b48bff07dead084af3064ad11c79a9b25df0 (diff) | |
download | fluxbox-18830ac9add80cbd3bf7369307d7e35a519dca9b.zip fluxbox-18830ac9add80cbd3bf7369307d7e35a519dca9b.tar.bz2 |
Initial revision
Diffstat (limited to 'src/Theme.hh')
-rw-r--r-- | src/Theme.hh | 162 |
1 files changed, 162 insertions, 0 deletions
diff --git a/src/Theme.hh b/src/Theme.hh new file mode 100644 index 0000000..c090a19 --- /dev/null +++ b/src/Theme.hh | |||
@@ -0,0 +1,162 @@ | |||
1 | // Theme.hh for fluxbox | ||
2 | // Copyright (c) 2001 Henrik Kinnunen (fluxgen@linuxmail.org) | ||
3 | // | ||
4 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | // copy of this software and associated documentation files (the "Software"), | ||
6 | // to deal in the Software without restriction, including without limitation | ||
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | // and/or sell copies of the Software, and to permit persons to whom the | ||
9 | // Software is furnished to do so, subject to the following conditions: | ||
10 | // | ||
11 | // The above copyright notice and this permission notice shall be included in | ||
12 | // all copies or substantial portions of the Software. | ||
13 | // | ||
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | // 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 | ||
18 | // 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 | ||
20 | // 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 | |||
45 | #ifndef _THEME_HH_ | ||
46 | #define _THEME_HH_ | ||
47 | |||
48 | |||
49 | #include "Image.hh" | ||
50 | #include <X11/Xlib.h> | ||
51 | #include <X11/Xresource.h> | ||
52 | |||
53 | #include "Rotated.hh" // TODO: should bake this into misc.hh some day | ||
54 | |||
55 | typedef struct FFont | ||
56 | { | ||
57 | enum FontJustify {Left=0, Right, Center}; | ||
58 | |||
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 | |||
88 | } WindowStyle; | ||
89 | |||
90 | typedef struct ToolbarStyle { | ||
91 | BColor l_text, w_text, c_text, b_pic; | ||
92 | BTexture toolbar, label, window, button, pressed, clock; | ||
93 | GC l_text_gc, w_text_gc, c_text_gc, b_pic_gc; | ||
94 | FFont font; | ||
95 | |||
96 | } ToolbarStyle; | ||
97 | |||
98 | typedef struct MenuStyle { | ||
99 | BColor t_text, f_text, h_text, d_text; | ||
100 | BTexture title, frame, hilite; | ||
101 | GC t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc; | ||
102 | FFont titlefont, framefont; | ||
103 | int bullet, bullet_pos; | ||
104 | } MenuStyle; | ||
105 | |||
106 | //singleton class | ||
107 | class Theme | ||
108 | { | ||
109 | public: | ||
110 | Theme(Display *display, Colormap colormap, int screennum, BImageControl *ic, const char *filename); | ||
111 | ~Theme(); | ||
112 | |||
113 | void load(const char *filename); | ||
114 | void reconfigure(); | ||
115 | inline WindowStyle *getWindowStyle(void) { return &m_windowstyle; } | ||
116 | inline MenuStyle *getMenuStyle(void) { return &m_menustyle; } | ||
117 | inline ToolbarStyle *getToolbarStyle(void) { return &m_toolbarstyle; } | ||
118 | inline const unsigned int & getBevelWidth(void) const { return m_bevel_width; } | ||
119 | inline const unsigned int & getBorderWidth(void) const { return m_border_width; } | ||
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: | ||
125 | |||
126 | void loadMenuStyle(); | ||
127 | void loadWindowStyle(); | ||
128 | void loadTabStyle(); | ||
129 | void loadToolbarStyle(); | ||
130 | void loadRootCommand(); | ||
131 | void loadMisc(); | ||
132 | void freeMenuStyle(); | ||
133 | void freeWindowStyle(); | ||
134 | void freeTabStyle(); | ||
135 | void freeToolbarStyle(); | ||
136 | |||
137 | bool readDatabaseTexture(char *, char *, BTexture *, unsigned long); | ||
138 | bool readDatabaseColor(char *, char *, BColor *, unsigned long); | ||
139 | |||
140 | void readDatabaseFontSet(char *, char *, XFontSet *); | ||
141 | XFontSet createFontSet(char *); | ||
142 | void readDatabaseFont(char *, char *, XFontStruct **); | ||
143 | |||
144 | static const char *getFontElement(const char *pattern, char *buf, int bufsiz, ...); | ||
145 | static const char *getFontSize(const char *pattern, int *size); | ||
146 | |||
147 | |||
148 | WindowStyle m_windowstyle; | ||
149 | MenuStyle m_menustyle; | ||
150 | ToolbarStyle m_toolbarstyle; | ||
151 | unsigned int m_bevel_width, m_border_width, m_handle_width, m_frame_width; | ||
152 | BColor m_border_color; | ||
153 | GC m_opgc; | ||
154 | BImageControl *m_imagecontrol; | ||
155 | Display *m_display; | ||
156 | XrmDatabase m_database; | ||
157 | Colormap m_colormap; | ||
158 | int m_screennum; | ||
159 | }; | ||
160 | |||
161 | |||
162 | #endif //_THEME_HH_ | ||