aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-11 15:49:56 (GMT)
committerfluxgen <fluxgen>2003-08-11 15:49:56 (GMT)
commit334a78fa7ad59941e7aeb261113dbcb72635b534 (patch)
treec51042facbd363c2bf10846d5016c9960682607f /src
parent86f934e73e528938122aff549bdefa9756ff80be (diff)
downloadfluxbox-334a78fa7ad59941e7aeb261113dbcb72635b534.zip
fluxbox-334a78fa7ad59941e7aeb261113dbcb72635b534.tar.bz2
theme item for iconbutton
Diffstat (limited to 'src')
-rw-r--r--src/IconButtonTheme.cc68
-rw-r--r--src/IconButtonTheme.hh63
2 files changed, 131 insertions, 0 deletions
diff --git a/src/IconButtonTheme.cc b/src/IconButtonTheme.cc
new file mode 100644
index 0000000..d881329
--- /dev/null
+++ b/src/IconButtonTheme.cc
@@ -0,0 +1,68 @@
1// IconButtonTheme.cc
2// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3// and Simon Bowden (rathnor at users.sourceforge.net)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a
6// copy of this software and associated documentation files (the "Software"),
7// to deal in the Software without restriction, including without limitation
8// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9// and/or sell copies of the Software, and to permit persons to whom the
10// Software is furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE.
22
23// $Id: IconButtonTheme.cc,v 1.1 2003/08/11 15:49:56 fluxgen Exp $
24
25#include "IconButtonTheme.hh"
26
27#include "FbTk/App.hh"
28
29IconButtonTheme::IconButtonTheme(int screen_num):
30 FbTk::Theme(screen_num),
31 m_selected_texture(*this, "iconButton.selected", "IconButton.Selected"),
32 m_unselected_texture(*this, "iconButton.unselected", "IconButton.Unselected"),
33 m_selected_font(*this, "iconButton.selectedFont", "IconButton.SelectedFont"),
34 m_unselected_font(*this, "iconButton.unselectedFont", "IconButton.UnselectedFont"),
35 m_selected_color(*this, "iconButton.selectedTextColor", "IconButton.SelectedTextColor"),
36 m_unselected_color(*this, "iconButton.unselectedTextColor", "IconButton.UnselectedTextColor") {
37
38 // load default font
39 selectedFont().load("fixed");
40 unselectedFont().load("fixed");
41
42 // create graphic context
43 Display *disp = FbTk::App::instance()->display();
44 m_selected_gc = XCreateGC(disp, RootWindow(disp, screen_num), 0, 0);
45 m_unselected_gc = XCreateGC(disp, RootWindow(disp, screen_num), 0, 0);
46}
47
48IconButtonTheme::~IconButtonTheme() {
49 Display *disp = FbTk::App::instance()->display();
50 XFreeGC(disp, m_selected_gc);
51 XFreeGC(disp, m_unselected_gc);
52}
53
54void IconButtonTheme::reconfigTheme() {
55
56 XGCValues gcv;
57 unsigned long gc_value_mask = GCForeground;
58 Display *disp = FbTk::App::instance()->display();
59
60 gcv.foreground = m_selected_color->pixel();
61 XChangeGC(disp, m_selected_gc, gc_value_mask, &gcv);
62
63 gcv.foreground = m_unselected_color->pixel();
64 XChangeGC(disp, m_unselected_gc, gc_value_mask, &gcv);
65
66 m_theme_change.notify();
67}
68
diff --git a/src/IconButtonTheme.hh b/src/IconButtonTheme.hh
new file mode 100644
index 0000000..ba78212
--- /dev/null
+++ b/src/IconButtonTheme.hh
@@ -0,0 +1,63 @@
1// IconButtonTheme.hh
2// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3// and Simon Bowden (rathnor at users.sourceforge.net)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a
6// copy of this software and associated documentation files (the "Software"),
7// to deal in the Software without restriction, including without limitation
8// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9// and/or sell copies of the Software, and to permit persons to whom the
10// Software is furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE.
22
23// $Id: IconButtonTheme.hh,v 1.1 2003/08/11 15:49:56 fluxgen Exp $
24
25#ifndef ICONBUTTONTHEME_HH
26#define ICONBUTTONTHEME_HH
27
28#include "FbTk/Theme.hh"
29#include "FbTk/Font.hh"
30#include "FbTk/Color.hh"
31#include "FbTk/Texture.hh"
32#include "FbTk/Subject.hh"
33
34class IconButtonTheme: public FbTk::Theme {
35public:
36 explicit IconButtonTheme(int screen_num);
37 virtual ~IconButtonTheme();
38
39 void reconfigTheme();
40
41 const FbTk::Texture &selectedTexture() const { return *m_selected_texture; }
42 const FbTk::Texture &unselectedTexture() const { return *m_unselected_texture; }
43
44 FbTk::Font &selectedFont() { return *m_selected_font; }
45 const FbTk::Font &selectedFont() const { return *m_selected_font; }
46 FbTk::Font &unselectedFont() { return *m_unselected_font; }
47 const FbTk::Font &unselectedFont() const { return *m_unselected_font; }
48
49 GC selectedGC() const { return m_selected_gc; }
50 GC unselectedGC() const { return m_unselected_gc; }
51
52 FbTk::Subject &themeChangeSig() { return m_theme_change; }
53
54private:
55 FbTk::ThemeItem<FbTk::Texture> m_selected_texture, m_unselected_texture;
56 FbTk::ThemeItem<FbTk::Font> m_selected_font, m_unselected_font;
57 FbTk::ThemeItem<FbTk::Color> m_selected_color, m_unselected_color;
58 GC m_selected_gc, m_unselected_gc;
59
60 FbTk::Subject m_theme_change;
61};
62
63#endif // ICONBUTTONTHEME_HH