aboutsummaryrefslogtreecommitdiff
path: root/src/FbWinFrameTheme.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbWinFrameTheme.cc')
-rw-r--r--src/FbWinFrameTheme.cc139
1 files changed, 139 insertions, 0 deletions
diff --git a/src/FbWinFrameTheme.cc b/src/FbWinFrameTheme.cc
new file mode 100644
index 0000000..296257e
--- /dev/null
+++ b/src/FbWinFrameTheme.cc
@@ -0,0 +1,139 @@
1// FbWinFrameTheme.cc for Fluxbox Window Manager
2// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
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// $Id: FbWinFrameTheme.cc,v 1.16 2004/01/02 13:04:26 fluxgen Exp $
23
24#include "FbWinFrameTheme.hh"
25#include "App.hh"
26
27#include <X11/cursorfont.h>
28
29#include <iostream>
30using namespace std;
31
32FbWinFrameTheme::FbWinFrameTheme(int screen_num):
33 FbTk::Theme(screen_num),
34 m_label_focus(*this, "window.label.focus", "Window.Label.Focus"),
35 m_label_unfocus(*this, "window.label.unfocus", "Window.Label.Unfocus"),
36 m_label_active(*this, "window.label.active", "Window.Label.Active"),
37
38 m_title_focus(*this, "window.title.focus", "Window.Title.Focus"),
39 m_title_unfocus(*this, "window.title.unfocus", "Window.Title.Unfocus"),
40
41 m_handle_focus(*this, "window.handle.focus", "Window.Handle.Focus"),
42 m_handle_unfocus(*this, "window.handle.unfocus", "Window.Handle.Unfocus"),
43
44 m_button_focus(*this, "window.button.focus", "Window.Button.Focus"),
45 m_button_unfocus(*this, "window.button.unfocus", "Window.Button.Unfocus"),
46 m_button_pressed(*this, "window.button.pressed", "Window.Button.Pressed"),
47
48 m_grip_focus(*this, "window.grip.focus", "Window.Grip.Focus"),
49 m_grip_unfocus(*this, "window.grip.unfocus", "Window.Grip.Unfocus"),
50
51 m_label_focus_color(*this, "window.label.focus.textColor", "Window.Label.Focus.TextColor"),
52 m_label_unfocus_color(*this, "window.label.unfocus.textColor", "Window.Label.Unfocus.TextColor"),
53 m_label_active_color(*this, "window.label.active.textColor", "Window.Label.Active.TextColor"),
54
55 m_frame_focus_color(*this, "window.frame.focusColor", "Window.Frame.FocusColor"),
56 m_frame_unfocus_color(*this, "window.frame.unfocusColor", "Window.Frame.UnfocusColor"),
57
58 m_button_focus_color(*this, "window.button.focus.picColor", "Window.Button.Focus.PicColor"),
59 m_button_unfocus_color(*this, "window.button.unfocus.picColor", "Window.Button.Unfocus.PicColor"),
60
61 m_font(*this, "window.font", "Window.Font"),
62 m_textjustify(*this, "window.justify", "Window.Justify"),
63 m_shape_place(*this, "window.roundCorners", "Window.RoundCorners"),
64 m_alpha(*this, "window.alpha", "Window.Alpha"),
65 m_title_height(*this, "window.title.height", "Window.Title.Height"),
66 m_bevel_width(*this, "window.bevelWidth", "Window.BevelWidth"),
67 m_handle_width(*this, "window.handleWidth", "Window.handleWidth"),
68 m_border(*this, "window", "Window"), // for window.border*
69 m_label_text_focus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)),
70 m_label_text_unfocus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)),
71 m_label_text_active_gc(RootWindow(FbTk::App::instance()->display(), screen_num)),
72 m_button_pic_focus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)),
73 m_button_pic_unfocus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)) {
74
75 *m_title_height = 0;
76 // set defaults
77 m_font->load("fixed");
78 *m_alpha = 255;
79
80 // create cursors
81 Display *disp = FbTk::App::instance()->display();
82 m_cursor_move = XCreateFontCursor(disp, XC_fleur);
83 m_cursor_lower_left_angle = XCreateFontCursor(disp, XC_ll_angle);
84 m_cursor_lower_right_angle = XCreateFontCursor(disp, XC_lr_angle);
85 m_cursor_upper_right_angle = XCreateFontCursor(disp, XC_ur_angle);
86 m_cursor_upper_left_angle = XCreateFontCursor(disp, XC_ul_angle);
87
88 reconfigTheme();
89}
90
91FbWinFrameTheme::~FbWinFrameTheme() {
92
93}
94
95bool FbWinFrameTheme::fallback(FbTk::ThemeItem_base &item) {
96 if (item.name() == "window.borderWidth")
97 return FbTk::ThemeManager::instance().loadItem(item, "borderWidth", "BorderWidth");
98 else if (item.name() == "window.borderColor")
99 return FbTk::ThemeManager::instance().loadItem(item, "borderColor", "BorderColor");
100 else if (item.name() == "window.bevelWidth")
101 return FbTk::ThemeManager::instance().loadItem(item, "bevelWidth", "bevelWidth");
102 else if (item.name() == "window.handleWidth")
103 return FbTk::ThemeManager::instance().loadItem(item, "handleWidth", "HandleWidth");
104 else if (item.name() == "window.label.active") {
105 // copy texture
106 *m_label_active = *m_label_unfocus;
107 return true;
108 } else if (item.name() == "window.label.active.textColor") {
109 return FbTk::ThemeManager::instance().loadItem(item, "window.label.unfocus.textColor",
110 "Window.Label.Unfocus.TextColor");
111 }
112
113
114 return false;
115}
116
117void FbWinFrameTheme::reconfigTheme() {
118 if (*m_alpha > 255)
119 *m_alpha = 255;
120 else if (*m_alpha < 0)
121 *m_alpha = 0;
122
123 if (*m_bevel_width > 20)
124 *m_bevel_width = 20;
125 else if (*m_bevel_width < 0)
126 *m_bevel_width = 0;
127
128 if (*m_handle_width > 200)
129 *m_handle_width = 200;
130 else if (*m_handle_width < 0)
131 *m_handle_width = 1;
132
133 m_label_text_focus_gc.setForeground(*m_label_focus_color);
134 m_label_text_unfocus_gc.setForeground(*m_label_unfocus_color);
135 m_label_text_active_gc.setForeground(*m_label_active_color);
136 m_button_pic_focus_gc.setForeground(*m_button_focus_color);
137 m_button_pic_unfocus_gc.setForeground(*m_button_unfocus_color);
138}
139