From 8294b04f5e044e1fa506cc1ce87f9c70e39d1ef4 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Wed, 17 Dec 2003 00:43:22 +0000 Subject: using menu as observer, cleaning in menu theme --- src/FbTk/Menu.cc | 9 ++++----- src/FbTk/Menu.hh | 18 +++++------------- src/FbTk/MenuTheme.cc | 5 +---- src/FbTk/MenuTheme.hh | 17 ++++++----------- src/FbTk/Theme.hh | 3 ++- 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Menu.cc,v 1.49 2003/12/16 17:06:51 fluxgen Exp $ +// $Id: Menu.cc,v 1.50 2003/12/17 00:43:22 fluxgen Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -63,7 +63,6 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): m_screen_height(DisplayHeight(FbTk::App::instance()->display(), tm.screenNum())), m_alignment(ALIGNDONTCARE), m_border_width(0), - m_themeobserver(*this), m_need_update(true) { // setup timers @@ -78,7 +77,7 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): m_hide_timer.fireOnce(true); // make sure we get updated when the theme is reloaded - tm.addListener(m_themeobserver); + tm.reconfigSig().attach(this); title_vis = movable = @@ -1188,7 +1187,7 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { // setup show menu timer timeval timeout; timeout.tv_sec = 0; - timeout.tv_usec = theme().delayOpen(); + timeout.tv_usec = theme().delayOpen() * 1000; // transformed to usec m_submenu_timer.setTimeout(timeout); m_submenu_timer.start(); @@ -1400,7 +1399,7 @@ void Menu::closeMenu() { void Menu::startHide() { timeval timeout; timeout.tv_sec = 0; - timeout.tv_usec = theme().delayClose(); + timeout.tv_usec = theme().delayClose() * 1000; // transformed to usec m_hide_timer.setTimeout(timeout); m_hide_timer.start(); } 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Menu.hh,v 1.27 2003/12/16 17:06:52 fluxgen Exp $ +// $Id: Menu.hh,v 1.28 2003/12/17 00:43:22 fluxgen Exp $ #ifndef FBTK_MENU_HH #define FBTK_MENU_HH @@ -48,7 +48,7 @@ class ImageControl; class Transparent; /// Base class for menus -class Menu: public FbTk::EventHandler { +class Menu: public FbTk::EventHandler, protected FbTk::Observer { public: enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM }; enum { RIGHT = 1, LEFT }; @@ -174,7 +174,10 @@ protected: inline Menu *parent() { return m_parent; } inline const Menu *parent() const { return m_parent; } + void update(FbTk::Subject *) { reconfigure(); } + private: + void openSubmenu(); void closeMenu(); void startHide(); @@ -206,17 +209,6 @@ private: bevel_h; } menu; - class ThemeObserver:public Observer { - public: - ThemeObserver(FbTk::Menu &menu):m_menu(menu) { } - void update(FbTk::Subject *subj) { - m_menu.reconfigure(); - } - private: - Menu &m_menu; - }; - - ThemeObserver m_themeobserver; Drawable m_root_pm; static Menu *s_focused; ///< holds current input focused menu, so one can determine if a menu is focused 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: MenuTheme.cc,v 1.12 2003/12/12 18:18:49 fluxgen Exp $ +// $Id: MenuTheme.cc,v 1.13 2003/12/17 00:43:22 fluxgen Exp $ #include "MenuTheme.hh" @@ -100,9 +100,6 @@ void MenuTheme::reconfigTheme() { h_text_gc.setForeground(*h_text); d_text_gc.setForeground(*d_text); hilite_gc.setForeground(hilite->color()); - - // notify any listeners - m_theme_change_sig.notify(); } bool 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: MenuTheme.hh,v 1.12 2003/12/16 17:06:52 fluxgen Exp $ +// $Id: MenuTheme.hh,v 1.13 2003/12/17 00:43:22 fluxgen Exp $ #ifndef FBTK_MENUTHEME_HH #define FBTK_MENUTHEME_HH @@ -112,17 +112,13 @@ public: // get resources into menu void setMenuMode(MenuMode mode) { m_menumode = mode; } MenuMode menuMode() const { return m_menumode; } - void setDelayOpen(int usec) { m_delayopen = usec; } - void setDelayClose(int usec) { m_delayclose = usec; } + void setDelayOpen(int msec) { m_delayopen = msec; } + void setDelayClose(int msec) { m_delayclose = msec; } int delayOpen() const { return m_delayopen; } int delayClose() const { return m_delayclose; } const FbTk::Color &borderColor() const { return *m_border_color; } - FbTk::Subject &themeChangeSig() { return m_theme_change_sig; } - /// attach observer - void addListener(FbTk::Observer &obs) { m_theme_change_sig.attach(&obs); } - /// detach observer - void removeListener(FbTk::Observer &obs) { m_theme_change_sig.detach(&obs); } + private: FbTk::ThemeItem t_text, f_text, h_text, d_text; FbTk::ThemeItem title, frame, hilite; @@ -137,12 +133,11 @@ private: Display *m_display; FbTk::GContext t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc; - FbTk::Subject m_theme_change_sig; unsigned char m_alpha; MenuMode m_menumode; - unsigned int m_delayopen; ///< in usec - unsigned int m_delayclose; ///< in usec + unsigned int m_delayopen; ///< in msec + unsigned int m_delayclose; ///< in msec }; 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Theme.hh,v 1.12 2003/12/16 17:06:52 fluxgen Exp $ +// $Id: Theme.hh,v 1.13 2003/12/17 00:43:22 fluxgen Exp $ /** @file holds ThemeItem, Theme and ThemeManager which is the base for any theme @@ -106,6 +106,7 @@ public: void remove(ThemeItem &item); virtual bool fallback(ThemeItem_base &) { return false; } FbTk::Subject &reconfigSig() { return m_reconfig_sig; } + const FbTk::Subject &reconfigSig() const { return m_reconfig_sig; } private: -- cgit v0.11.2