diff options
author | markt <markt> | 2007-10-13 21:51:37 (GMT) |
---|---|---|
committer | markt <markt> | 2007-10-13 21:51:37 (GMT) |
commit | a59428d67a95a9df16554962f0a6257d6378328a (patch) | |
tree | f856ed9300c34f7a17d499f22d895610cfbc08e5 /src/FbTk | |
parent | 41b5c6dadb1f474675660cef18b812d4c2338ed2 (diff) | |
download | fluxbox_lack-a59428d67a95a9df16554962f0a6257d6378328a.zip fluxbox_lack-a59428d67a95a9df16554962f0a6257d6378328a.tar.bz2 |
merged changes from pre-devel
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/ITypeAheadable.hh | 2 | ||||
-rw-r--r-- | src/FbTk/Makefile.am | 1 | ||||
-rw-r--r-- | src/FbTk/Menu.cc | 8 | ||||
-rw-r--r-- | src/FbTk/Menu.hh | 6 | ||||
-rw-r--r-- | src/FbTk/MenuIcon.cc | 96 | ||||
-rw-r--r-- | src/FbTk/MenuIcon.hh | 54 | ||||
-rw-r--r-- | src/FbTk/MenuItem.cc | 21 | ||||
-rw-r--r-- | src/FbTk/MenuItem.hh | 3 | ||||
-rw-r--r-- | src/FbTk/TypeAhead.hh | 2 |
9 files changed, 25 insertions, 168 deletions
diff --git a/src/FbTk/ITypeAheadable.hh b/src/FbTk/ITypeAheadable.hh index 1b0bd03..c998f98 100644 --- a/src/FbTk/ITypeAheadable.hh +++ b/src/FbTk/ITypeAheadable.hh | |||
@@ -19,6 +19,8 @@ | |||
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$ | ||
23 | |||
22 | #ifndef FBTK_ITYPEAHEADABLE_HH | 24 | #ifndef FBTK_ITYPEAHEADABLE_HH |
23 | #define FBTK_ITYPEAHEADABLE_HH | 25 | #define FBTK_ITYPEAHEADABLE_HH |
24 | 26 | ||
diff --git a/src/FbTk/Makefile.am b/src/FbTk/Makefile.am index fadc998..d98c8f6 100644 --- a/src/FbTk/Makefile.am +++ b/src/FbTk/Makefile.am | |||
@@ -49,7 +49,6 @@ libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \ | |||
49 | GContext.hh GContext.cc \ | 49 | GContext.hh GContext.cc \ |
50 | KeyUtil.hh KeyUtil.cc \ | 50 | KeyUtil.hh KeyUtil.cc \ |
51 | MenuSeparator.hh MenuSeparator.cc \ | 51 | MenuSeparator.hh MenuSeparator.cc \ |
52 | MenuIcon.hh MenuIcon.cc \ | ||
53 | stringstream.hh \ | 52 | stringstream.hh \ |
54 | TypeAhead.hh SearchResult.hh SearchResult.cc ITypeAheadable.hh \ | 53 | TypeAhead.hh SearchResult.hh SearchResult.cc ITypeAheadable.hh \ |
55 | Select2nd.hh \ | 54 | Select2nd.hh \ |
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index b0fcb4b..23efcfe 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc | |||
@@ -357,10 +357,6 @@ void Menu::enterSubmenu() { | |||
357 | submenu->cycleItems(false); | 357 | submenu->cycleItems(false); |
358 | } | 358 | } |
359 | 359 | ||
360 | void Menu::enterParent() { | ||
361 | internal_hide(); | ||
362 | } | ||
363 | |||
364 | void Menu::disableTitle() { | 360 | void Menu::disableTitle() { |
365 | setTitleVisibility(false); | 361 | setTitleVisibility(false); |
366 | } | 362 | } |
@@ -1033,7 +1029,7 @@ void Menu::keyPressEvent(XKeyEvent &event) { | |||
1033 | break; | 1029 | break; |
1034 | case XK_Left: // enter parent if we have one | 1030 | case XK_Left: // enter parent if we have one |
1035 | resetTypeAhead(); | 1031 | resetTypeAhead(); |
1036 | enterParent(); | 1032 | internal_hide(); |
1037 | break; | 1033 | break; |
1038 | case XK_Right: // enter submenu if we have one | 1034 | case XK_Right: // enter submenu if we have one |
1039 | resetTypeAhead(); | 1035 | resetTypeAhead(); |
@@ -1046,7 +1042,7 @@ void Menu::keyPressEvent(XKeyEvent &event) { | |||
1046 | break; | 1042 | break; |
1047 | case XK_BackSpace: | 1043 | case XK_BackSpace: |
1048 | if (m_type_ahead.stringSize() == 0) { | 1044 | if (m_type_ahead.stringSize() == 0) { |
1049 | enterParent(); | 1045 | internal_hide(); |
1050 | break; | 1046 | break; |
1051 | } | 1047 | } |
1052 | 1048 | ||
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 34df40a..06af08d 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh | |||
@@ -49,7 +49,8 @@ class MenuItem; | |||
49 | class ImageControl; | 49 | class ImageControl; |
50 | 50 | ||
51 | /// Base class for menus | 51 | /// Base class for menus |
52 | class Menu: public FbTk::EventHandler, FbTk::FbWindowRenderer, protected FbTk::Observer { | 52 | class Menu: public FbTk::EventHandler, FbTk::FbWindowRenderer, |
53 | public FbTk::Observer { | ||
53 | public: | 54 | public: |
54 | enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM }; | 55 | enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM }; |
55 | enum { RIGHT = 1, LEFT }; | 56 | enum { RIGHT = 1, LEFT }; |
@@ -91,7 +92,6 @@ public: | |||
91 | /// cycle through menuitems | 92 | /// cycle through menuitems |
92 | void cycleItems(bool reverse); | 93 | void cycleItems(bool reverse); |
93 | void enterSubmenu(); | 94 | void enterSubmenu(); |
94 | void enterParent(); | ||
95 | 95 | ||
96 | void disableTitle(); | 96 | void disableTitle(); |
97 | void enableTitle(); | 97 | void enableTitle(); |
@@ -193,7 +193,7 @@ protected: | |||
193 | 193 | ||
194 | virtual void internal_hide(bool first = true); | 194 | virtual void internal_hide(bool first = true); |
195 | 195 | ||
196 | void update(FbTk::Subject *); | 196 | virtual void update(FbTk::Subject *); |
197 | 197 | ||
198 | private: | 198 | private: |
199 | 199 | ||
diff --git a/src/FbTk/MenuIcon.cc b/src/FbTk/MenuIcon.cc deleted file mode 100644 index d64d876..0000000 --- a/src/FbTk/MenuIcon.cc +++ /dev/null | |||
@@ -1,96 +0,0 @@ | |||
1 | // MenuIcon.cc for FbTk - Fluxbox ToolKit | ||
2 | // Copyright (c) 2004 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) | ||
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$ | ||
24 | |||
25 | #include "MenuIcon.hh" | ||
26 | |||
27 | #include "MenuTheme.hh" | ||
28 | #include "Image.hh" | ||
29 | #include "App.hh" | ||
30 | |||
31 | namespace FbTk { | ||
32 | |||
33 | MenuIcon::MenuIcon(const std::string &filename, FbString &label, int screen_num): | ||
34 | MenuItem(label), | ||
35 | m_filename(filename) { | ||
36 | FbTk::PixmapWithMask *pm = Image::load(filename.c_str(), screen_num); | ||
37 | if (pm != 0) { | ||
38 | m_pixmap = pm->pixmap().release(); | ||
39 | m_mask = pm->mask().release(); | ||
40 | delete pm; | ||
41 | } | ||
42 | |||
43 | } | ||
44 | |||
45 | void MenuIcon::updateTheme(const MenuTheme &theme) { | ||
46 | FbTk::PixmapWithMask *pm = Image::load(m_filename.c_str(), theme.screenNum()); | ||
47 | if (pm != 0) { | ||
48 | m_pixmap = pm->pixmap().release(); | ||
49 | m_mask = pm->mask().release(); | ||
50 | delete pm; | ||
51 | } | ||
52 | } | ||
53 | |||
54 | void MenuIcon::draw(FbDrawable &drawable, | ||
55 | const MenuTheme &theme, | ||
56 | bool highlight, bool draw_foreground, bool draw_background, | ||
57 | int x, int y, | ||
58 | unsigned int width, unsigned int height) const { | ||
59 | |||
60 | // all background | ||
61 | if (draw_background) { | ||
62 | Display *disp = FbTk::App::instance()->display(); | ||
63 | if (height - 2*theme.bevelWidth() != m_pixmap.height() && | ||
64 | !m_filename.empty()) { | ||
65 | unsigned int scale_size = height - 2*theme.bevelWidth(); | ||
66 | m_pixmap.scale(scale_size, scale_size); | ||
67 | m_mask.scale(scale_size, scale_size); | ||
68 | } | ||
69 | |||
70 | if (m_pixmap.drawable() != 0) { | ||
71 | GC gc = theme.frameTextGC().gc(); | ||
72 | |||
73 | // enable clip mask | ||
74 | XSetClipMask(disp, gc, m_mask.drawable()); | ||
75 | XSetClipOrigin(disp, gc, x + theme.bevelWidth(), y + theme.bevelWidth()); | ||
76 | |||
77 | drawable.copyArea(m_pixmap.drawable(), | ||
78 | gc, | ||
79 | 0, 0, | ||
80 | x + theme.bevelWidth(), y + theme.bevelWidth(), | ||
81 | m_pixmap.width(), m_pixmap.height()); | ||
82 | |||
83 | // restore clip mask | ||
84 | XSetClipMask(disp, gc, None); | ||
85 | } | ||
86 | } | ||
87 | FbTk::MenuItem::draw(drawable, theme, highlight, | ||
88 | draw_background, draw_foreground, x, y, width, height); | ||
89 | } | ||
90 | |||
91 | unsigned int MenuIcon::width(const MenuTheme &theme) const { | ||
92 | return MenuItem::width(theme) + 2 * (theme.bevelWidth() + height(theme)); | ||
93 | } | ||
94 | |||
95 | } // end namespace FbTk | ||
96 | |||
diff --git a/src/FbTk/MenuIcon.hh b/src/FbTk/MenuIcon.hh deleted file mode 100644 index 90cf320..0000000 --- a/src/FbTk/MenuIcon.hh +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | // MenuIcon.hh for FbTk - Fluxbox ToolKit | ||
2 | // Copyright (c) 2004 Henrik Kinnunen (fluxgen at fluxbox dot org) | ||
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$ | ||
24 | |||
25 | #ifndef MENUICON_HH | ||
26 | #define MENUICON_HH | ||
27 | |||
28 | #include "MenuItem.hh" | ||
29 | #include "FbPixmap.hh" | ||
30 | |||
31 | #include <string> | ||
32 | |||
33 | namespace FbTk { | ||
34 | |||
35 | class MenuIcon: public MenuItem { | ||
36 | public: | ||
37 | MenuIcon(const std::string &filename, FbString &label, int screen_num); | ||
38 | void draw(FbDrawable &drawable, | ||
39 | const MenuTheme &theme, | ||
40 | bool highlight, | ||
41 | bool draw_foreground, bool draw_background, | ||
42 | int x, int y, | ||
43 | unsigned int width, unsigned int height) const; | ||
44 | unsigned int width(const MenuTheme &item) const; | ||
45 | void updateTheme(const MenuTheme &theme); | ||
46 | private: | ||
47 | mutable FbPixmap m_pixmap, m_mask; | ||
48 | const std::string m_filename; | ||
49 | }; | ||
50 | |||
51 | } // end namespace FbTk | ||
52 | |||
53 | #endif // MENUICON_HH | ||
54 | |||
diff --git a/src/FbTk/MenuItem.cc b/src/FbTk/MenuItem.cc index bc80ca0..2576d2b 100644 --- a/src/FbTk/MenuItem.cc +++ b/src/FbTk/MenuItem.cc | |||
@@ -93,27 +93,32 @@ void MenuItem::draw(FbDrawable &draw, | |||
93 | // Icon | 93 | // Icon |
94 | // | 94 | // |
95 | if (draw_background) { | 95 | if (draw_background) { |
96 | if (m_icon.get() != 0 && m_icon->pixmap.get() != 0) { | 96 | if (icon() != 0) { |
97 | // copy pixmap, so we don't resize the original | ||
98 | FbPixmap tmp_pixmap, tmp_mask; | ||
99 | tmp_pixmap.copy(icon()->pixmap()); | ||
100 | tmp_mask.copy(icon()->mask()); | ||
101 | |||
97 | // scale pixmap to right size | 102 | // scale pixmap to right size |
98 | if (height - 2*theme.bevelWidth() != m_icon->pixmap->height() && | 103 | if (height - 2*theme.bevelWidth() != tmp_pixmap.height()) { |
99 | !m_icon->filename.empty()) { | ||
100 | unsigned int scale_size = height - 2*theme.bevelWidth(); | 104 | unsigned int scale_size = height - 2*theme.bevelWidth(); |
101 | m_icon->pixmap->scale(scale_size, scale_size); | 105 | tmp_pixmap.scale(scale_size, scale_size); |
106 | tmp_mask.scale(scale_size, scale_size); | ||
102 | } | 107 | } |
103 | 108 | ||
104 | if (m_icon->pixmap->pixmap().drawable() != 0) { | 109 | if (tmp_pixmap.drawable() != 0) { |
105 | GC gc = theme.frameTextGC().gc(); | 110 | GC gc = theme.frameTextGC().gc(); |
106 | int icon_x = x + theme.bevelWidth(); | 111 | int icon_x = x + theme.bevelWidth(); |
107 | int icon_y = y + theme.bevelWidth(); | 112 | int icon_y = y + theme.bevelWidth(); |
108 | // enable clip mask | 113 | // enable clip mask |
109 | XSetClipMask(disp, gc, m_icon->pixmap->mask().drawable()); | 114 | XSetClipMask(disp, gc, tmp_mask.drawable()); |
110 | XSetClipOrigin(disp, gc, icon_x, icon_y); | 115 | XSetClipOrigin(disp, gc, icon_x, icon_y); |
111 | 116 | ||
112 | draw.copyArea(m_icon->pixmap->pixmap().drawable(), | 117 | draw.copyArea(tmp_pixmap.drawable(), |
113 | gc, | 118 | gc, |
114 | 0, 0, | 119 | 0, 0, |
115 | icon_x, icon_y, | 120 | icon_x, icon_y, |
116 | m_icon->pixmap->width(), m_icon->pixmap->height()); | 121 | tmp_pixmap.width(), tmp_pixmap.height()); |
117 | 122 | ||
118 | // restore clip mask | 123 | // restore clip mask |
119 | XSetClipMask(disp, gc, None); | 124 | XSetClipMask(disp, gc, None); |
diff --git a/src/FbTk/MenuItem.hh b/src/FbTk/MenuItem.hh index afb6be9..7fac8c7 100644 --- a/src/FbTk/MenuItem.hh +++ b/src/FbTk/MenuItem.hh | |||
@@ -101,6 +101,9 @@ public: | |||
101 | */ | 101 | */ |
102 | //@{ | 102 | //@{ |
103 | virtual const std::string &label() const { return m_label; } | 103 | virtual const std::string &label() const { return m_label; } |
104 | virtual const PixmapWithMask *icon() const { | ||
105 | return m_icon.get() ? m_icon->pixmap.get() : 0; | ||
106 | } | ||
104 | virtual const Menu *submenu() const { return m_submenu; } | 107 | virtual const Menu *submenu() const { return m_submenu; } |
105 | virtual bool isEnabled() const { return m_enabled; } | 108 | virtual bool isEnabled() const { return m_enabled; } |
106 | virtual bool isSelected() const { return m_selected; } | 109 | virtual bool isSelected() const { return m_selected; } |
diff --git a/src/FbTk/TypeAhead.hh b/src/FbTk/TypeAhead.hh index 15246b9..b28c803 100644 --- a/src/FbTk/TypeAhead.hh +++ b/src/FbTk/TypeAhead.hh | |||
@@ -103,6 +103,8 @@ public: | |||
103 | 103 | ||
104 | if (!m_search_results.empty()) | 104 | if (!m_search_results.empty()) |
105 | fillValues(m_search_results.back().result(), last_matched); | 105 | fillValues(m_search_results.back().result(), last_matched); |
106 | else | ||
107 | return *m_ref; | ||
106 | return last_matched; | 108 | return last_matched; |
107 | } | 109 | } |
108 | 110 | ||