diff options
author | fluxgen <fluxgen> | 2003-02-15 01:48:16 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-02-15 01:48:16 (GMT) |
commit | 80a8703272f3b7c872279634add72218209ac64c (patch) | |
tree | 6de5155be74213e50c905c4241028f74353ded66 | |
parent | 483f82fbb8be0d2d9101b71dd3f31122f1c29cb3 (diff) | |
download | fluxbox-80a8703272f3b7c872279634add72218209ac64c.zip fluxbox-80a8703272f3b7c872279634add72218209ac64c.tar.bz2 |
added theme observer
-rw-r--r-- | src/FbTk/Menu.cc | 19 | ||||
-rw-r--r-- | src/FbTk/Menu.hh | 16 |
2 files changed, 29 insertions, 6 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index b727588..d0267cb 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.8 2003/02/03 13:41:19 fluxgen Exp $ | 25 | // $Id: Menu.cc,v 1.9 2003/02/15 01:48:16 fluxgen Exp $ |
26 | 26 | ||
27 | //use GNU extensions | 27 | //use GNU extensions |
28 | #ifndef _GNU_SOURCE | 28 | #ifndef _GNU_SOURCE |
@@ -60,7 +60,11 @@ Menu::Menu(MenuTheme &tm, int screen_num, ImageControl &imgctrl): | |||
60 | m_screen_width(DisplayWidth(m_display, screen_num)), | 60 | m_screen_width(DisplayWidth(m_display, screen_num)), |
61 | m_screen_height(DisplayHeight(m_display, screen_num)), | 61 | m_screen_height(DisplayHeight(m_display, screen_num)), |
62 | m_alignment(ALIGNDONTCARE), | 62 | m_alignment(ALIGNDONTCARE), |
63 | m_border_width(0) { | 63 | m_border_width(0), |
64 | m_themeobserver(*this) { | ||
65 | |||
66 | // make sure we get updated when the theme is reloaded | ||
67 | tm.addListener(m_themeobserver); | ||
64 | 68 | ||
65 | title_vis = | 69 | title_vis = |
66 | movable = | 70 | movable = |
@@ -105,7 +109,8 @@ Menu::Menu(MenuTheme &tm, int screen_num, ImageControl &imgctrl): | |||
105 | unsigned long attrib_mask = CWOverrideRedirect | CWEventMask; | 109 | unsigned long attrib_mask = CWOverrideRedirect | CWEventMask; |
106 | XSetWindowAttributes attrib; | 110 | XSetWindowAttributes attrib; |
107 | attrib.override_redirect = True; | 111 | attrib.override_redirect = True; |
108 | attrib.event_mask = ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | KeyPressMask | ExposureMask; | 112 | attrib.event_mask = ButtonPressMask | ButtonReleaseMask | |
113 | ButtonMotionMask | KeyPressMask | ExposureMask; | ||
109 | 114 | ||
110 | //create menu window | 115 | //create menu window |
111 | menu.window = XCreateWindow(m_display, RootWindow(m_display, screen_num), | 116 | menu.window = XCreateWindow(m_display, RootWindow(m_display, screen_num), |
@@ -917,10 +922,16 @@ void Menu::exposeEvent(XExposeEvent &ee) { | |||
917 | if (ee.window == menu.title) { | 922 | if (ee.window == menu.title) { |
918 | redrawTitle(); | 923 | redrawTitle(); |
919 | } else if (ee.window == menu.frame) { | 924 | } else if (ee.window == menu.frame) { |
925 | if (menuitems.size() == 0) | ||
926 | return; | ||
927 | |||
920 | // this is a compilicated algorithm... lets do it step by step... | 928 | // this is a compilicated algorithm... lets do it step by step... |
921 | // first... we see in which sub level the expose starts... and how many | 929 | // first... we see in which sub level the expose starts... and how many |
922 | // items down in that sublevel | 930 | // items down in that sublevel |
923 | 931 | if (menu.item_w == 0) | |
932 | menu.item_w = 1; | ||
933 | if (menu.item_h == 0) | ||
934 | menu.item_h = 1; | ||
924 | unsigned int sbl = (ee.x / menu.item_w), id = (ee.y / menu.item_h), | 935 | unsigned int sbl = (ee.x / menu.item_w), id = (ee.y / menu.item_h), |
925 | // next... figure out how many sublevels over the redraw spans | 936 | // next... figure out how many sublevels over the redraw spans |
926 | sbl_d = ((ee.x + ee.width) / menu.item_w), | 937 | sbl_d = ((ee.x + ee.width) / menu.item_w), |
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 1360528..1ae9b8f 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.7 2003/02/03 13:40:52 fluxgen Exp $ | 25 | // $Id: Menu.hh,v 1.8 2003/02/15 01:47:43 fluxgen Exp $ |
26 | 26 | ||
27 | #ifndef FBTK_MENU_HH | 27 | #ifndef FBTK_MENU_HH |
28 | #define FBTK_MENU_HH | 28 | #define FBTK_MENU_HH |
@@ -35,6 +35,7 @@ | |||
35 | #include "EventHandler.hh" | 35 | #include "EventHandler.hh" |
36 | #include "RefCount.hh" | 36 | #include "RefCount.hh" |
37 | #include "Command.hh" | 37 | #include "Command.hh" |
38 | #include "Observer.hh" | ||
38 | #include "XLayerItem.hh" | 39 | #include "XLayerItem.hh" |
39 | 40 | ||
40 | namespace FbTk { | 41 | namespace FbTk { |
@@ -151,7 +152,7 @@ protected: | |||
151 | inline Menu *parent() { return m_parent; } | 152 | inline Menu *parent() { return m_parent; } |
152 | inline const Menu *parent() const { return m_parent; } | 153 | inline const Menu *parent() const { return m_parent; } |
153 | 154 | ||
154 | private: | 155 | private: |
155 | typedef std::vector<MenuItem *> Menuitems; | 156 | typedef std::vector<MenuItem *> Menuitems; |
156 | const MenuTheme &m_theme; | 157 | const MenuTheme &m_theme; |
157 | Display *m_display; | 158 | Display *m_display; |
@@ -178,6 +179,17 @@ private: | |||
178 | bevel_h; | 179 | bevel_h; |
179 | } menu; | 180 | } menu; |
180 | 181 | ||
182 | class ThemeObserver:public Observer { | ||
183 | public: | ||
184 | ThemeObserver(FbTk::Menu &menu):m_menu(menu) { } | ||
185 | void update(FbTk::Subject *subj) { | ||
186 | m_menu.reconfigure(); | ||
187 | } | ||
188 | private: | ||
189 | Menu &m_menu; | ||
190 | }; | ||
191 | |||
192 | ThemeObserver m_themeobserver; | ||
181 | }; | 193 | }; |
182 | 194 | ||
183 | }; // end namespace FbTk | 195 | }; // end namespace FbTk |