summaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/Menu.cc9
-rw-r--r--src/FbTk/Menu.hh18
-rw-r--r--src/FbTk/MenuTheme.cc5
-rw-r--r--src/FbTk/MenuTheme.hh17
-rw-r--r--src/FbTk/Theme.hh3
5 files changed, 18 insertions, 34 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index 2ef5793..bb0b352 100644
--- a/src/FbTk/Menu.cc
+++ b/src/FbTk/Menu.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Menu.cc,v 1.49 2003/12/16 17:06:51 fluxgen Exp $ 25// $Id: Menu.cc,v 1.50 2003/12/17 00:43:22 fluxgen Exp $
26 26
27//use GNU extensions 27//use GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -63,7 +63,6 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl):
63 m_screen_height(DisplayHeight(FbTk::App::instance()->display(), tm.screenNum())), 63 m_screen_height(DisplayHeight(FbTk::App::instance()->display(), tm.screenNum())),
64 m_alignment(ALIGNDONTCARE), 64 m_alignment(ALIGNDONTCARE),
65 m_border_width(0), 65 m_border_width(0),
66 m_themeobserver(*this),
67 m_need_update(true) { 66 m_need_update(true) {
68 67
69 // setup timers 68 // setup timers
@@ -78,7 +77,7 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl):
78 m_hide_timer.fireOnce(true); 77 m_hide_timer.fireOnce(true);
79 78
80 // make sure we get updated when the theme is reloaded 79 // make sure we get updated when the theme is reloaded
81 tm.addListener(m_themeobserver); 80 tm.reconfigSig().attach(this);
82 81
83 title_vis = 82 title_vis =
84 movable = 83 movable =
@@ -1188,7 +1187,7 @@ void Menu::motionNotifyEvent(XMotionEvent &me) {
1188 // setup show menu timer 1187 // setup show menu timer
1189 timeval timeout; 1188 timeval timeout;
1190 timeout.tv_sec = 0; 1189 timeout.tv_sec = 0;
1191 timeout.tv_usec = theme().delayOpen(); 1190 timeout.tv_usec = theme().delayOpen() * 1000; // transformed to usec
1192 m_submenu_timer.setTimeout(timeout); 1191 m_submenu_timer.setTimeout(timeout);
1193 m_submenu_timer.start(); 1192 m_submenu_timer.start();
1194 1193
@@ -1400,7 +1399,7 @@ void Menu::closeMenu() {
1400void Menu::startHide() { 1399void Menu::startHide() {
1401 timeval timeout; 1400 timeval timeout;
1402 timeout.tv_sec = 0; 1401 timeout.tv_sec = 0;
1403 timeout.tv_usec = theme().delayClose(); 1402 timeout.tv_usec = theme().delayClose() * 1000; // transformed to usec
1404 m_hide_timer.setTimeout(timeout); 1403 m_hide_timer.setTimeout(timeout);
1405 m_hide_timer.start(); 1404 m_hide_timer.start();
1406} 1405}
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh
index 600ecb6..d1c6c6e 100644
--- a/src/FbTk/Menu.hh
+++ b/src/FbTk/Menu.hh
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Menu.hh,v 1.27 2003/12/16 17:06:52 fluxgen Exp $ 25// $Id: Menu.hh,v 1.28 2003/12/17 00:43:22 fluxgen Exp $
26 26
27#ifndef FBTK_MENU_HH 27#ifndef FBTK_MENU_HH
28#define FBTK_MENU_HH 28#define FBTK_MENU_HH
@@ -48,7 +48,7 @@ class ImageControl;
48class Transparent; 48class Transparent;
49 49
50/// Base class for menus 50/// Base class for menus
51class Menu: public FbTk::EventHandler { 51class Menu: public FbTk::EventHandler, protected FbTk::Observer {
52public: 52public:
53 enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM }; 53 enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM };
54 enum { RIGHT = 1, LEFT }; 54 enum { RIGHT = 1, LEFT };
@@ -174,7 +174,10 @@ protected:
174 inline Menu *parent() { return m_parent; } 174 inline Menu *parent() { return m_parent; }
175 inline const Menu *parent() const { return m_parent; } 175 inline const Menu *parent() const { return m_parent; }
176 176
177 void update(FbTk::Subject *) { reconfigure(); }
178
177private: 179private:
180
178 void openSubmenu(); 181 void openSubmenu();
179 void closeMenu(); 182 void closeMenu();
180 void startHide(); 183 void startHide();
@@ -206,17 +209,6 @@ private:
206 bevel_h; 209 bevel_h;
207 } menu; 210 } menu;
208 211
209 class ThemeObserver:public Observer {
210 public:
211 ThemeObserver(FbTk::Menu &menu):m_menu(menu) { }
212 void update(FbTk::Subject *subj) {
213 m_menu.reconfigure();
214 }
215 private:
216 Menu &m_menu;
217 };
218
219 ThemeObserver m_themeobserver;
220 Drawable m_root_pm; 212 Drawable m_root_pm;
221 static Menu *s_focused; ///< holds current input focused menu, so one can determine if a menu is focused 213 static Menu *s_focused; ///< holds current input focused menu, so one can determine if a menu is focused
222 FbPixmap m_frame_pm; 214 FbPixmap m_frame_pm;
diff --git a/src/FbTk/MenuTheme.cc b/src/FbTk/MenuTheme.cc
index aea922f..2dd6564 100644
--- a/src/FbTk/MenuTheme.cc
+++ b/src/FbTk/MenuTheme.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: MenuTheme.cc,v 1.12 2003/12/12 18:18:49 fluxgen Exp $ 22// $Id: MenuTheme.cc,v 1.13 2003/12/17 00:43:22 fluxgen Exp $
23 23
24#include "MenuTheme.hh" 24#include "MenuTheme.hh"
25 25
@@ -100,9 +100,6 @@ void MenuTheme::reconfigTheme() {
100 h_text_gc.setForeground(*h_text); 100 h_text_gc.setForeground(*h_text);
101 d_text_gc.setForeground(*d_text); 101 d_text_gc.setForeground(*d_text);
102 hilite_gc.setForeground(hilite->color()); 102 hilite_gc.setForeground(hilite->color());
103
104 // notify any listeners
105 m_theme_change_sig.notify();
106} 103}
107 104
108bool MenuTheme::fallback(ThemeItem_base &item) { 105bool MenuTheme::fallback(ThemeItem_base &item) {
diff --git a/src/FbTk/MenuTheme.hh b/src/FbTk/MenuTheme.hh
index 951ab55..dfac7b1 100644
--- a/src/FbTk/MenuTheme.hh
+++ b/src/FbTk/MenuTheme.hh
@@ -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: MenuTheme.hh,v 1.12 2003/12/16 17:06:52 fluxgen Exp $ 22// $Id: MenuTheme.hh,v 1.13 2003/12/17 00:43:22 fluxgen Exp $
23 23
24#ifndef FBTK_MENUTHEME_HH 24#ifndef FBTK_MENUTHEME_HH
25#define FBTK_MENUTHEME_HH 25#define FBTK_MENUTHEME_HH
@@ -112,17 +112,13 @@ public:
112 // get resources into menu 112 // get resources into menu
113 void setMenuMode(MenuMode mode) { m_menumode = mode; } 113 void setMenuMode(MenuMode mode) { m_menumode = mode; }
114 MenuMode menuMode() const { return m_menumode; } 114 MenuMode menuMode() const { return m_menumode; }
115 void setDelayOpen(int usec) { m_delayopen = usec; } 115 void setDelayOpen(int msec) { m_delayopen = msec; }
116 void setDelayClose(int usec) { m_delayclose = usec; } 116 void setDelayClose(int msec) { m_delayclose = msec; }
117 int delayOpen() const { return m_delayopen; } 117 int delayOpen() const { return m_delayopen; }
118 int delayClose() const { return m_delayclose; } 118 int delayClose() const { return m_delayclose; }
119 119
120 const FbTk::Color &borderColor() const { return *m_border_color; } 120 const FbTk::Color &borderColor() const { return *m_border_color; }
121 FbTk::Subject &themeChangeSig() { return m_theme_change_sig; } 121
122 /// attach observer
123 void addListener(FbTk::Observer &obs) { m_theme_change_sig.attach(&obs); }
124 /// detach observer
125 void removeListener(FbTk::Observer &obs) { m_theme_change_sig.detach(&obs); }
126private: 122private:
127 FbTk::ThemeItem<FbTk::Color> t_text, f_text, h_text, d_text; 123 FbTk::ThemeItem<FbTk::Color> t_text, f_text, h_text, d_text;
128 FbTk::ThemeItem<FbTk::Texture> title, frame, hilite; 124 FbTk::ThemeItem<FbTk::Texture> title, frame, hilite;
@@ -137,12 +133,11 @@ private:
137 133
138 Display *m_display; 134 Display *m_display;
139 FbTk::GContext t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc; 135 FbTk::GContext t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc;
140 FbTk::Subject m_theme_change_sig;
141 136
142 unsigned char m_alpha; 137 unsigned char m_alpha;
143 MenuMode m_menumode; 138 MenuMode m_menumode;
144 unsigned int m_delayopen; ///< in usec 139 unsigned int m_delayopen; ///< in msec
145 unsigned int m_delayclose; ///< in usec 140 unsigned int m_delayclose; ///< in msec
146 141
147}; 142};
148 143
diff --git a/src/FbTk/Theme.hh b/src/FbTk/Theme.hh
index e5c0394..b0f422a 100644
--- a/src/FbTk/Theme.hh
+++ b/src/FbTk/Theme.hh
@@ -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: Theme.hh,v 1.12 2003/12/16 17:06:52 fluxgen Exp $ 22// $Id: Theme.hh,v 1.13 2003/12/17 00:43:22 fluxgen Exp $
23 23
24/** 24/**
25 @file holds ThemeItem<T>, Theme and ThemeManager which is the base for any theme 25 @file holds ThemeItem<T>, Theme and ThemeManager which is the base for any theme
@@ -106,6 +106,7 @@ public:
106 void remove(ThemeItem<T> &item); 106 void remove(ThemeItem<T> &item);
107 virtual bool fallback(ThemeItem_base &) { return false; } 107 virtual bool fallback(ThemeItem_base &) { return false; }
108 FbTk::Subject &reconfigSig() { return m_reconfig_sig; } 108 FbTk::Subject &reconfigSig() { return m_reconfig_sig; }
109 const FbTk::Subject &reconfigSig() const { return m_reconfig_sig; }
109 110
110 111
111private: 112private: