aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-22 21:35:40 (GMT)
committerfluxgen <fluxgen>2003-08-22 21:35:40 (GMT)
commitdc3f13d2fc3e731e8929ec782cad1c1e2191802e (patch)
tree569639abb07294799706568ba4585a7577d6fb94
parent834645f54563fc9a73a845e83ad687700ffecee1 (diff)
downloadfluxbox_paul-dc3f13d2fc3e731e8929ec782cad1c1e2191802e.zip
fluxbox_paul-dc3f13d2fc3e731e8929ec782cad1c1e2191802e.tar.bz2
fixed new image loading
-rw-r--r--src/WinButton.cc70
-rw-r--r--src/WinButtonTheme.cc55
-rw-r--r--src/WinButtonTheme.hh91
3 files changed, 79 insertions, 137 deletions
diff --git a/src/WinButton.cc b/src/WinButton.cc
index 01684fb..2534296 100644
--- a/src/WinButton.cc
+++ b/src/WinButton.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22/// $Id: WinButton.cc,v 1.9 2003/08/22 15:04:18 fluxgen Exp $ 22/// $Id: WinButton.cc,v 1.10 2003/08/22 21:33:13 fluxgen Exp $
23 23
24#include "WinButton.hh" 24#include "WinButton.hh"
25#include "App.hh" 25#include "App.hh"
@@ -52,23 +52,23 @@ void WinButton::drawType() {
52 52
53 switch (m_type) { 53 switch (m_type) {
54 case MAXIMIZE: 54 case MAXIMIZE:
55 if (m_theme.maximizePixmap().pixmap.drawable() != 0) { 55 if (m_theme.maximizePixmap().pixmap().drawable() != 0) {
56 if (pressed()) { 56 if (pressed()) {
57 FbTk::FbWindow::setBackgroundPixmap(m_theme. 57 FbTk::FbWindow::setBackgroundPixmap(m_theme.
58 maximizePressedPixmap(). 58 maximizePressedPixmap().
59 pixmap.drawable()); 59 pixmap().drawable());
60 } else if (m_theme.maximizePixmap().pixmap.drawable()) { 60 } else if (m_theme.maximizePixmap().pixmap().drawable()) {
61 // check focus 61 // check focus
62 if (!m_listen_to.isFocused() && 62 if (!m_listen_to.isFocused() &&
63 m_theme.maximizeUnfocusPixmap().pixmap.drawable() != 0) { 63 m_theme.maximizeUnfocusPixmap().pixmap().drawable() != 0) {
64 // not focused 64 // not focused
65 FbTk::FbWindow::setBackgroundPixmap(m_theme. 65 FbTk::FbWindow::setBackgroundPixmap(m_theme.
66 maximizeUnfocusPixmap(). 66 maximizeUnfocusPixmap().
67 pixmap.drawable()); 67 pixmap().drawable());
68 } else { // focused 68 } else { // focused
69 FbTk::FbWindow::setBackgroundPixmap(m_theme. 69 FbTk::FbWindow::setBackgroundPixmap(m_theme.
70 maximizePixmap(). 70 maximizePixmap().
71 pixmap.drawable()); 71 pixmap().drawable());
72 } 72 }
73 } 73 }
74 74
@@ -84,23 +84,23 @@ void WinButton::drawType() {
84 } 84 }
85 break; 85 break;
86 case MINIMIZE: 86 case MINIMIZE:
87 if (m_theme.iconifyPixmap().pixmap.drawable() != 0) { 87 if (m_theme.iconifyPixmap().pixmap().drawable() != 0) {
88 if (pressed()) { 88 if (pressed()) {
89 FbTk::FbWindow::setBackgroundPixmap(m_theme. 89 FbTk::FbWindow::setBackgroundPixmap(m_theme.
90 iconifyPressedPixmap(). 90 iconifyPressedPixmap().
91 pixmap.drawable()); 91 pixmap().drawable());
92 } else if (m_theme.iconifyPixmap().pixmap.drawable()){ 92 } else if (m_theme.iconifyPixmap().pixmap().drawable()){
93 // check focus 93 // check focus
94 if (!m_listen_to.isFocused() && 94 if (!m_listen_to.isFocused() &&
95 m_theme.iconifyUnfocusPixmap().pixmap.drawable() != 0) { 95 m_theme.iconifyUnfocusPixmap().pixmap().drawable() != 0) {
96 // not focused 96 // not focused
97 FbTk::FbWindow::setBackgroundPixmap(m_theme. 97 FbTk::FbWindow::setBackgroundPixmap(m_theme.
98 iconifyUnfocusPixmap(). 98 iconifyUnfocusPixmap().
99 pixmap.drawable()); 99 pixmap().drawable());
100 } else { // focused 100 } else { // focused
101 FbTk::FbWindow::setBackgroundPixmap(m_theme. 101 FbTk::FbWindow::setBackgroundPixmap(m_theme.
102 iconifyPixmap(). 102 iconifyPixmap().
103 pixmap.drawable()); 103 pixmap().drawable());
104 } 104 }
105 } 105 }
106 106
@@ -114,41 +114,41 @@ void WinButton::drawType() {
114 } 114 }
115 break; 115 break;
116 case STICK: 116 case STICK:
117 if (m_theme.stickPixmap().pixmap.drawable() != 0) { 117 if (m_theme.stickPixmap().pixmap().drawable() != 0) {
118 if (m_listen_to.isStuck() && 118 if (m_listen_to.isStuck() &&
119 m_theme.stuckPixmap().pixmap.drawable() && 119 m_theme.stuckPixmap().pixmap().drawable() &&
120 ! pressed()) { // we're using the same pixmap for pressed as in not stuck 120 ! pressed()) { // we're using the same pixmap for pressed as in not stuck
121 // check focus 121 // check focus
122 if (!m_listen_to.isFocused() && 122 if (!m_listen_to.isFocused() &&
123 m_theme.stuckUnfocusPixmap().pixmap.drawable() != 0) { 123 m_theme.stuckUnfocusPixmap().pixmap().drawable() != 0) {
124 // not focused 124 // not focused
125 FbTk::FbWindow::setBackgroundPixmap(m_theme. 125 FbTk::FbWindow::setBackgroundPixmap(m_theme.
126 stuckUnfocusPixmap(). 126 stuckUnfocusPixmap().
127 pixmap.drawable()); 127 pixmap().drawable());
128 } else { // focused 128 } else { // focused
129 FbTk::FbWindow::setBackgroundPixmap(m_theme. 129 FbTk::FbWindow::setBackgroundPixmap(m_theme.
130 stuckPixmap(). 130 stuckPixmap().
131 pixmap.drawable()); 131 pixmap().drawable());
132 } 132 }
133 } else { // not stuck 133 } else { // not stuck
134 134
135 if (pressed()) { 135 if (pressed()) {
136 FbTk::FbWindow::setBackgroundPixmap(m_theme. 136 FbTk::FbWindow::setBackgroundPixmap(m_theme.
137 stickPressedPixmap(). 137 stickPressedPixmap().
138 pixmap.drawable()); 138 pixmap().drawable());
139 139
140 } else if (m_theme.stickPixmap().pixmap.drawable()) { 140 } else if (m_theme.stickPixmap().pixmap().drawable()) {
141 // check focus 141 // check focus
142 if (!m_listen_to.isFocused() && 142 if (!m_listen_to.isFocused() &&
143 m_theme.stickUnfocusPixmap().pixmap.drawable() != 0) { 143 m_theme.stickUnfocusPixmap().pixmap().drawable() != 0) {
144 // not focused 144 // not focused
145 FbTk::FbWindow::setBackgroundPixmap(m_theme. 145 FbTk::FbWindow::setBackgroundPixmap(m_theme.
146 stickUnfocusPixmap(). 146 stickUnfocusPixmap().
147 pixmap.drawable()); 147 pixmap().drawable());
148 } else { // focused 148 } else { // focused
149 FbTk::FbWindow::setBackgroundPixmap(m_theme. 149 FbTk::FbWindow::setBackgroundPixmap(m_theme.
150 stickPixmap(). 150 stickPixmap().
151 pixmap.drawable()); 151 pixmap().drawable());
152 } 152 }
153 153
154 } 154 }
@@ -172,24 +172,24 @@ void WinButton::drawType() {
172 break; 172 break;
173 case CLOSE: 173 case CLOSE:
174 174
175 if (m_theme.closePixmap().pixmap.drawable() != 0) { 175 if (m_theme.closePixmap().pixmap().drawable() != 0) {
176 if (pressed()) { 176 if (pressed()) {
177 FbTk::FbWindow::setBackgroundPixmap(m_theme. 177 FbTk::FbWindow::setBackgroundPixmap(m_theme.
178 closePressedPixmap(). 178 closePressedPixmap().
179 pixmap.drawable()); 179 pixmap().drawable());
180 180
181 } else if (m_theme.closePixmap().pixmap.drawable()) { 181 } else if (m_theme.closePixmap().pixmap().drawable()) {
182 // check focus 182 // check focus
183 if (!m_listen_to.isFocused() && 183 if (!m_listen_to.isFocused() &&
184 m_theme.closeUnfocusPixmap().pixmap.drawable() != 0) { 184 m_theme.closeUnfocusPixmap().pixmap().drawable() != 0) {
185 // not focused 185 // not focused
186 FbTk::FbWindow::setBackgroundPixmap(m_theme. 186 FbTk::FbWindow::setBackgroundPixmap(m_theme.
187 closeUnfocusPixmap(). 187 closeUnfocusPixmap().
188 pixmap.drawable()); 188 pixmap().drawable());
189 } else { // focused 189 } else { // focused
190 FbTk::FbWindow::setBackgroundPixmap(m_theme. 190 FbTk::FbWindow::setBackgroundPixmap(m_theme.
191 closePixmap(). 191 closePixmap().
192 pixmap.drawable()); 192 pixmap().drawable());
193 } 193 }
194 } 194 }
195 195
@@ -207,23 +207,23 @@ void WinButton::drawType() {
207 } 207 }
208 break; 208 break;
209 case SHADE: 209 case SHADE:
210 if (m_theme.shadePixmap().pixmap.drawable() != 0) { 210 if (m_theme.shadePixmap().pixmap().drawable() != 0) {
211 if (pressed()) { 211 if (pressed()) {
212 FbTk::FbWindow::setBackgroundPixmap(m_theme. 212 FbTk::FbWindow::setBackgroundPixmap(m_theme.
213 shadePressedPixmap(). 213 shadePressedPixmap().
214 pixmap.drawable()); 214 pixmap().drawable());
215 } else if (m_theme.shadePixmap().pixmap.drawable()) { 215 } else if (m_theme.shadePixmap().pixmap().drawable()) {
216 // check focus 216 // check focus
217 if (!m_listen_to.isFocused() && 217 if (!m_listen_to.isFocused() &&
218 m_theme.shadeUnfocusPixmap().pixmap.drawable() != 0) { 218 m_theme.shadeUnfocusPixmap().pixmap().drawable() != 0) {
219 // not focused 219 // not focused
220 FbTk::FbWindow::setBackgroundPixmap(m_theme. 220 FbTk::FbWindow::setBackgroundPixmap(m_theme.
221 shadeUnfocusPixmap(). 221 shadeUnfocusPixmap().
222 pixmap.drawable()); 222 pixmap().drawable());
223 } else { // focused 223 } else { // focused
224 FbTk::FbWindow::setBackgroundPixmap(m_theme. 224 FbTk::FbWindow::setBackgroundPixmap(m_theme.
225 shadePixmap(). 225 shadePixmap().
226 pixmap.drawable()); 226 pixmap().drawable());
227 } 227 }
228 } 228 }
229 229
diff --git a/src/WinButtonTheme.cc b/src/WinButtonTheme.cc
index b8628eb..74d37c8 100644
--- a/src/WinButtonTheme.cc
+++ b/src/WinButtonTheme.cc
@@ -19,62 +19,15 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: WinButtonTheme.cc,v 1.5 2003/08/22 15:19:39 fluxgen Exp $ 22// $Id: WinButtonTheme.cc,v 1.6 2003/08/22 21:35:40 fluxgen Exp $
23 23
24#include "WinButtonTheme.hh" 24#include "WinButtonTheme.hh"
25 25
26#include "FbTk/App.hh" 26#include "FbTk/App.hh"
27#include "FbWinFrameTheme.hh" 27#include "FbTk/Image.hh"
28 28#include "FbTk/PixmapWithMask.hh"
29#ifdef HAVE_CONFIG_H
30#include "config.h"
31#endif // HAVE_CONFIG_H
32
33#ifdef HAVE_XPM
34#include <X11/xpm.h>
35#endif // HAVE_XPM
36
37// not used
38template <>
39void FbTk::ThemeItem<WinButtonTheme::PixmapWithMask>::
40load() { }
41
42template <>
43void FbTk::ThemeItem<WinButtonTheme::PixmapWithMask>::
44setDefaultValue() {
45 // create empty pixmap
46 (*this)->pixmap = FbTk::FbPixmap(); // pixmap
47 (*this)->mask = FbTk::FbPixmap(); // mask
48}
49 29
50template <> 30#include "FbWinFrameTheme.hh"
51void FbTk::ThemeItem<WinButtonTheme::PixmapWithMask>::
52setFromString(const char *str) {
53 if (str == 0)
54 setDefaultValue();
55 else {
56#ifdef HAVE_XPM
57 XpmAttributes xpm_attr;
58 xpm_attr.valuemask = 0;
59 Display *dpy = FbTk::App::instance()->display();
60 Pixmap pm = 0, mask = 0;
61 int retvalue = XpmReadFileToPixmap(dpy,
62 RootWindow(dpy, m_tm.screenNum()),
63 const_cast<char *>(str),
64 &pm,
65 &mask, &xpm_attr);
66 if (retvalue == 0) { // success
67 (*this)->pixmap = pm;
68 (*this)->mask = mask;
69 } else { // failure
70 setDefaultValue();
71 }
72#else
73 setDefaultValue();
74#endif // HAVE_XPM
75
76 }
77}
78 31
79WinButtonTheme::WinButtonTheme(int screen_num, const FbWinFrameTheme &frame_theme): 32WinButtonTheme::WinButtonTheme(int screen_num, const FbWinFrameTheme &frame_theme):
80 FbTk::Theme(screen_num), 33 FbTk::Theme(screen_num),
diff --git a/src/WinButtonTheme.hh b/src/WinButtonTheme.hh
index dea88cf..0e959ca 100644
--- a/src/WinButtonTheme.hh
+++ b/src/WinButtonTheme.hh
@@ -19,75 +19,64 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: WinButtonTheme.hh,v 1.3 2003/08/22 14:48:10 fluxgen Exp $ 22// $Id: WinButtonTheme.hh,v 1.4 2003/08/22 21:35:40 fluxgen Exp $
23 23
24#ifndef WINBUTTONTHEME_HH 24#ifndef WINBUTTONTHEME_HH
25#define WINBUTTONTHEME_HH 25#define WINBUTTONTHEME_HH
26 26
27#include "Theme.hh" 27#include "Theme.hh"
28#include "FbPixmap.hh" 28#include "FbTk/PixmapWithMask.hh"
29 29
30class FbWinFrameTheme; 30class FbWinFrameTheme;
31 31
32class WinButtonTheme: public FbTk::Theme { 32class WinButtonTheme: public FbTk::Theme {
33public: 33public:
34 /// holds pixmap and a mask
35 struct PixmapWithMask {
36 /// scale both pixmap and mask to specified size
37 void scale(unsigned int width, unsigned int height) {
38 pixmap.scale(width, height);
39 mask.scale(width, height);
40 }
41 FbTk::FbPixmap pixmap;
42 FbTk::FbPixmap mask;
43 };
44
45 WinButtonTheme(int screen_num, const FbWinFrameTheme &frame_theme); 34 WinButtonTheme(int screen_num, const FbWinFrameTheme &frame_theme);
46 ~WinButtonTheme(); 35 ~WinButtonTheme();
47 36
48 void reconfigTheme(); 37 void reconfigTheme();
49 38
50 inline const PixmapWithMask &closePixmap() const { return *m_close_pm; } 39 inline const FbTk::PixmapWithMask &closePixmap() const { return *m_close_pm; }
51 inline PixmapWithMask &closePixmap() { return *m_close_pm; } 40 inline FbTk::PixmapWithMask &closePixmap() { return *m_close_pm; }
52 inline PixmapWithMask &closeUnfocusPixmap() { return *m_close_unfocus_pm; } 41 inline FbTk::PixmapWithMask &closeUnfocusPixmap() { return *m_close_unfocus_pm; }
53 inline const PixmapWithMask &closePressedPixmap() const { return *m_close_pressed_pm; } 42 inline const FbTk::PixmapWithMask &closePressedPixmap() const { return *m_close_pressed_pm; }
54 inline PixmapWithMask &closePressedPixmap() { return *m_close_pressed_pm; } 43 inline FbTk::PixmapWithMask &closePressedPixmap() { return *m_close_pressed_pm; }
55 44
56 inline const PixmapWithMask &maximizePixmap() const { return *m_maximize_pm; } 45 inline const FbTk::PixmapWithMask &maximizePixmap() const { return *m_maximize_pm; }
57 inline PixmapWithMask &maximizePixmap() { return *m_maximize_pm; } 46 inline FbTk::PixmapWithMask &maximizePixmap() { return *m_maximize_pm; }
58 inline PixmapWithMask &maximizeUnfocusPixmap() { return *m_maximize_unfocus_pm; } 47 inline FbTk::PixmapWithMask &maximizeUnfocusPixmap() { return *m_maximize_unfocus_pm; }
59 inline const PixmapWithMask &maximizePressedPixmap() const { return *m_maximize_pressed_pm; } 48 inline const FbTk::PixmapWithMask &maximizePressedPixmap() const { return *m_maximize_pressed_pm; }
60 inline PixmapWithMask &maximizePressedPixmap() { return *m_maximize_pressed_pm; } 49 inline FbTk::PixmapWithMask &maximizePressedPixmap() { return *m_maximize_pressed_pm; }
61 50
62 inline const PixmapWithMask &iconifyPixmap() const { return *m_iconify_pm; } 51 inline const FbTk::PixmapWithMask &iconifyPixmap() const { return *m_iconify_pm; }
63 inline PixmapWithMask &iconifyPixmap() { return *m_iconify_pm; } 52 inline FbTk::PixmapWithMask &iconifyPixmap() { return *m_iconify_pm; }
64 inline PixmapWithMask &iconifyUnfocusPixmap() { return *m_iconify_unfocus_pm; } 53 inline FbTk::PixmapWithMask &iconifyUnfocusPixmap() { return *m_iconify_unfocus_pm; }
65 inline const PixmapWithMask &iconifyPressedPixmap() const { return *m_iconify_pressed_pm; } 54 inline const FbTk::PixmapWithMask &iconifyPressedPixmap() const { return *m_iconify_pressed_pm; }
66 inline PixmapWithMask &iconifyPressedPixmap() { return *m_iconify_pressed_pm; } 55 inline FbTk::PixmapWithMask &iconifyPressedPixmap() { return *m_iconify_pressed_pm; }
67 56
68 inline const PixmapWithMask &stickPixmap() const { return *m_stick_pm; } 57 inline const FbTk::PixmapWithMask &stickPixmap() const { return *m_stick_pm; }
69 inline PixmapWithMask &stickPixmap() { return *m_stick_pm; } 58 inline FbTk::PixmapWithMask &stickPixmap() { return *m_stick_pm; }
70 inline PixmapWithMask &stickUnfocusPixmap() { return *m_stick_unfocus_pm; } 59 inline FbTk::PixmapWithMask &stickUnfocusPixmap() { return *m_stick_unfocus_pm; }
71 inline const PixmapWithMask &stickPressedPixmap() const { return *m_stick_pressed_pm; } 60 inline const FbTk::PixmapWithMask &stickPressedPixmap() const { return *m_stick_pressed_pm; }
72 inline PixmapWithMask &stickPressedPixmap() { return *m_stick_pressed_pm; } 61 inline FbTk::PixmapWithMask &stickPressedPixmap() { return *m_stick_pressed_pm; }
73 62
74 inline PixmapWithMask &stuckPixmap() { return *m_stuck_pm; } 63 inline FbTk::PixmapWithMask &stuckPixmap() { return *m_stuck_pm; }
75 inline PixmapWithMask &stuckUnfocusPixmap() { return *m_stuck_unfocus_pm; } 64 inline FbTk::PixmapWithMask &stuckUnfocusPixmap() { return *m_stuck_unfocus_pm; }
76 65
77 inline const PixmapWithMask &shadePixmap() const { return *m_shade_pm; } 66 inline const FbTk::PixmapWithMask &shadePixmap() const { return *m_shade_pm; }
78 inline PixmapWithMask &shadePixmap() { return *m_shade_pm; } 67 inline FbTk::PixmapWithMask &shadePixmap() { return *m_shade_pm; }
79 inline PixmapWithMask &shadeUnfocusPixmap() { return *m_shade_unfocus_pm; } 68 inline FbTk::PixmapWithMask &shadeUnfocusPixmap() { return *m_shade_unfocus_pm; }
80 inline const PixmapWithMask &shadePressedPixmap() const { return *m_shade_pressed_pm; } 69 inline const FbTk::PixmapWithMask &shadePressedPixmap() const { return *m_shade_pressed_pm; }
81 inline PixmapWithMask &shadePressedPixmap() { return *m_shade_pressed_pm; } 70 inline FbTk::PixmapWithMask &shadePressedPixmap() { return *m_shade_pressed_pm; }
82 71
83private: 72private:
84 73
85 FbTk::ThemeItem<PixmapWithMask> m_close_pm, m_close_unfocus_pm, m_close_pressed_pm; 74 FbTk::ThemeItem<FbTk::PixmapWithMask> m_close_pm, m_close_unfocus_pm, m_close_pressed_pm;
86 FbTk::ThemeItem<PixmapWithMask> m_maximize_pm, m_maximize_unfocus_pm, m_maximize_pressed_pm; 75 FbTk::ThemeItem<FbTk::PixmapWithMask> m_maximize_pm, m_maximize_unfocus_pm, m_maximize_pressed_pm;
87 FbTk::ThemeItem<PixmapWithMask> m_iconify_pm, m_iconify_unfocus_pm, m_iconify_pressed_pm; 76 FbTk::ThemeItem<FbTk::PixmapWithMask> m_iconify_pm, m_iconify_unfocus_pm, m_iconify_pressed_pm;
88 FbTk::ThemeItem<PixmapWithMask> m_shade_pm, m_shade_unfocus_pm, m_shade_pressed_pm; 77 FbTk::ThemeItem<FbTk::PixmapWithMask> m_shade_pm, m_shade_unfocus_pm, m_shade_pressed_pm;
89 FbTk::ThemeItem<PixmapWithMask> m_stick_pm, m_stick_unfocus_pm, m_stick_pressed_pm; 78 FbTk::ThemeItem<FbTk::PixmapWithMask> m_stick_pm, m_stick_unfocus_pm, m_stick_pressed_pm;
90 FbTk::ThemeItem<PixmapWithMask> m_stuck_pm, m_stuck_unfocus_pm; 79 FbTk::ThemeItem<FbTk::PixmapWithMask> m_stuck_pm, m_stuck_unfocus_pm;
91 80
92 const FbWinFrameTheme &m_frame_theme; 81 const FbWinFrameTheme &m_frame_theme;
93}; 82};