aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-04-28 22:30:34 (GMT)
committerfluxgen <fluxgen>2003-04-28 22:30:34 (GMT)
commit556b74b33332accd6fa9066182df2555c6abd9a4 (patch)
tree42573ecd4a72373e4f3bdd9ff9f430795f79daef /src
parent39e05f49d0fe58b42b36495950412e8d6b7673a2 (diff)
downloadfluxbox-556b74b33332accd6fa9066182df2555c6abd9a4.zip
fluxbox-556b74b33332accd6fa9066182df2555c6abd9a4.tar.bz2
handles close, maximize, iconify, shade and stick theme pixmaps
Diffstat (limited to 'src')
-rw-r--r--src/WinButtonTheme.cc103
-rw-r--r--src/WinButtonTheme.hh85
2 files changed, 188 insertions, 0 deletions
diff --git a/src/WinButtonTheme.cc b/src/WinButtonTheme.cc
new file mode 100644
index 0000000..4a98f98
--- /dev/null
+++ b/src/WinButtonTheme.cc
@@ -0,0 +1,103 @@
1// WinButtonTheme.cc for Fluxbox - an X11 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: WinButtonTheme.cc,v 1.1 2003/04/28 22:30:34 fluxgen Exp $
23
24#include "WinButtonTheme.hh"
25
26#include "App.hh"
27
28#ifdef HAVE_CONFIG_H
29#include "config.h"
30#endif // HAVE_CONFIG_H
31
32#ifdef HAVE_XPM
33#include <X11/xpm.h>
34#endif // HAVE_XPM
35
36// not used
37template <>
38void FbTk::ThemeItem<WinButtonTheme::PixmapWithMask>::
39load() { }
40
41template <>
42void FbTk::ThemeItem<WinButtonTheme::PixmapWithMask>::
43setDefaultValue() {
44 // create empty pixmap
45 (*this)->pixmap = FbTk::FbPixmap(); // pixmap
46 (*this)->mask = FbTk::FbPixmap(); // mask
47 (*this)->pixmap_scaled = FbTk::FbPixmap();
48 (*this)->mask_scaled = FbTk::FbPixmap();
49}
50
51template <>
52void FbTk::ThemeItem<WinButtonTheme::PixmapWithMask>::
53setFromString(const char *str) {
54 if (str == 0)
55 setDefaultValue();
56 else {
57#ifdef HAVE_XPM
58 XpmAttributes xpm_attr;
59 xpm_attr.valuemask = 0;
60 Display *dpy = FbTk::App::instance()->display();
61 Pixmap pm = 0, mask = 0;
62 int retvalue = XpmReadFileToPixmap(dpy,
63 //!! TODO need the right root window
64 RootWindow(dpy, 0),
65 const_cast<char *>(str),
66 &pm,
67 &mask, &xpm_attr);
68 if (retvalue == 0) { // success
69 (*this)->pixmap = pm;
70 (*this)->mask = mask;
71 } else { // failure
72 setDefaultValue();
73 }
74#else
75 setDefaultValue();
76#endif // HAVE_XPM
77
78 }
79}
80
81WinButtonTheme::WinButtonTheme(int screen_num):
82 FbTk::Theme(screen_num),
83 m_close_pm(*this, "window.close.pixmap", "Window.Close.Pixmap"),
84 m_close_pressed_pm(*this, "window.close.pressed.pixmap", "Window.Close.Pressed.Pixmap"),
85 m_maximize_pm(*this, "window.maximize.pixmap", "Window.Maximize.Pixmap"),
86 m_maximize_pressed_pm(*this, "window.maximize.pressed.pixmap", "Window.Maximize.Pressed.Pixmap"),
87 m_iconify_pm(*this, "window.iconify.pixmap", "Window.Iconify.Pixmap"),
88 m_iconify_pressed_pm(*this, "window.iconify.pressed.pixmap", "Window.Iconify.Pressed.Pixmap"),
89 m_shade_pm(*this, "window.shade.pixmap", "Window.Shade.Pixmap"),
90 m_shade_pressed_pm(*this, "window.shade.pressed.pixmap", "Window.Shade.Pressed.Pixmap"),
91 m_stick_pm(*this, "window.stick.pixmap", "Window.Stick.Pixmap"),
92 m_stick_pressed_pm(*this, "window.stick.pressed.pixmap", "Window.Stick.Pressed.Pixmap") {
93
94}
95
96WinButtonTheme::~WinButtonTheme() {
97
98}
99
100void WinButtonTheme::reconfigTheme() {
101 reconfigSig().notify();
102}
103
diff --git a/src/WinButtonTheme.hh b/src/WinButtonTheme.hh
new file mode 100644
index 0000000..6cbe69c
--- /dev/null
+++ b/src/WinButtonTheme.hh
@@ -0,0 +1,85 @@
1// WinButtonTheme.hh for Fluxbox - an X11 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: WinButtonTheme.hh,v 1.1 2003/04/28 22:30:34 fluxgen Exp $
23
24#ifndef WINBUTTONTHEME_HH
25#define WINBUTTONTHEME_HH
26
27#include "Theme.hh"
28#include "Subject.hh"
29#include "FbPixmap.hh"
30
31class WinButtonTheme: public FbTk::Theme {
32public:
33 struct PixmapWithMask {
34 FbTk::FbPixmap pixmap;
35 FbTk::FbPixmap pixmap_scaled;
36 FbTk::FbPixmap mask;
37 FbTk::FbPixmap mask_scaled;
38 };
39
40 explicit WinButtonTheme(int screen_num);
41 ~WinButtonTheme();
42
43 void reconfigTheme();
44
45 inline const PixmapWithMask &closePixmap() const { return *m_close_pm; }
46 inline PixmapWithMask &closePixmap() { return *m_close_pm; }
47
48 inline const PixmapWithMask &closePressedPixmap() const { return *m_close_pressed_pm; }
49 inline PixmapWithMask &closePressedPixmap() { return *m_close_pressed_pm; }
50
51 inline const PixmapWithMask &maximizePixmap() const { return *m_maximize_pm; }
52 inline PixmapWithMask &maximizePixmap() { return *m_maximize_pm; }
53
54 inline const PixmapWithMask &maximizePressedPixmap() const { return *m_maximize_pressed_pm; }
55 inline PixmapWithMask &maximizePressedPixmap() { return *m_maximize_pressed_pm; }
56
57 inline const PixmapWithMask &iconifyPixmap() const { return *m_iconify_pm; }
58 inline PixmapWithMask &iconifyPixmap() { return *m_iconify_pm; }
59
60 inline const PixmapWithMask &iconifyPressedPixmap() const { return *m_iconify_pressed_pm; }
61 inline PixmapWithMask &iconifyPressedPixmap() { return *m_iconify_pressed_pm; }
62
63 inline const PixmapWithMask &stickPixmap() const { return *m_stick_pm; }
64 inline PixmapWithMask &stickPixmap() { return *m_stick_pm; }
65
66 inline const PixmapWithMask &stickPressedPixmap() const { return *m_stick_pressed_pm; }
67 inline PixmapWithMask &stickPressedPixmap() { return *m_stick_pressed_pm; }
68
69 inline const PixmapWithMask &shadePixmap() const { return *m_shade_pm; }
70 inline PixmapWithMask &shadePixmap() { return *m_shade_pm; }
71
72 inline const PixmapWithMask &shadePressedPixmap() const { return *m_shade_pressed_pm; }
73 inline PixmapWithMask &shadePressedPixmap() { return *m_shade_pressed_pm; }
74 FbTk::Subject &reconfigSig() { return m_reconf_sig; }
75private:
76 FbTk::Subject m_reconf_sig;
77
78 FbTk::ThemeItem<PixmapWithMask> m_close_pm, m_close_pressed_pm;
79 FbTk::ThemeItem<PixmapWithMask> m_maximize_pm, m_maximize_pressed_pm;
80 FbTk::ThemeItem<PixmapWithMask> m_iconify_pm, m_iconify_pressed_pm;
81 FbTk::ThemeItem<PixmapWithMask> m_shade_pm, m_shade_pressed_pm;
82 FbTk::ThemeItem<PixmapWithMask> m_stick_pm, m_stick_pressed_pm;
83};
84
85#endif // WINBUTTONTHEME_HH