aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--src/FbTk/Menu.cc7
-rw-r--r--src/FbTk/MenuItem.hh22
-rw-r--r--src/IntResMenuItem.cc14
-rw-r--r--src/IntResMenuItem.hh2
-rw-r--r--src/Screen.cc6
-rw-r--r--src/Slit.cc2
-rw-r--r--src/ToggleMenu.hh7
-rw-r--r--src/Toolbar.cc4
9 files changed, 49 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index e8c3321..c763691 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
1(Format: Year/Month/Day) 1(Format: Year/Month/Day)
2Changes for 0.9.13 2Changes for 0.9.13
3*05/05/03: 3*05/05/03:
4 * Fix drawing of no-title menus, plus updating of int menu items (Simon)
5 IntResMenuItem.hh/cc MenuItem.hh Menu.cc Screen.cc ToggleMenu.hh
6 Toolbar.cc Slit.cc
4 * Code cleaning. (Henrik) 7 * Code cleaning. (Henrik)
5 Fluxbox::associateClient; creates tab and 8 Fluxbox::associateClient; creates tab and
6 maps WinClient to label button. 9 maps WinClient to label button.
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index fbf7e45..e0e3e7f 100644
--- a/src/FbTk/Menu.cc
+++ b/src/FbTk/Menu.cc
@@ -475,7 +475,7 @@ void Menu::updateMenu(int active_index) {
475 } 475 }
476 476
477 menu.frame.moveResize(0, ((m_title_vis) ? menu.title.y() + menu.title.height() + 477 menu.frame.moveResize(0, ((m_title_vis) ? menu.title.y() + menu.title.height() +
478 menu.title.borderWidth()*2 : 1), 478 menu.title.borderWidth()*2 : 0),
479 width(), menu.frame_h); 479 width(), menu.frame_h);
480 480
481 if (m_title_vis && m_need_update) { 481 if (m_title_vis && m_need_update) {
@@ -927,6 +927,8 @@ void Menu::motionNotifyEvent(XMotionEvent &me) {
927 } 927 }
928 928
929 m_moving = m_torn = true; 929 m_moving = m_torn = true;
930 // clear current highlighted item
931 clearItem(m_active_index);
930 932
931 if (m_which_sub >= 0) 933 if (m_which_sub >= 0)
932 drawSubmenu(m_which_sub); 934 drawSubmenu(m_which_sub);
@@ -1238,7 +1240,8 @@ void Menu::clearItem(int index, bool clear) {
1238 int item_x = (sbl * item_w), item_y = (i * item_h); 1240 int item_x = (sbl * item_w), item_y = (i * item_h);
1239 bool highlight = (index == m_active_index); 1241 bool highlight = (index == m_active_index);
1240 1242
1241 if (highlight) { 1243 // don't highlight if moving, doesn't work with alpha on
1244 if (highlight && !m_moving) {
1242 highlightItem(index); 1245 highlightItem(index);
1243 return; 1246 return;
1244 } else if (clear) 1247 } else if (clear)
diff --git a/src/FbTk/MenuItem.hh b/src/FbTk/MenuItem.hh
index 20da8f7..b3b2f6b 100644
--- a/src/FbTk/MenuItem.hh
+++ b/src/FbTk/MenuItem.hh
@@ -42,6 +42,7 @@ class MenuItem {
42public: 42public:
43 MenuItem() 43 MenuItem()
44 : m_label(""), 44 : m_label(""),
45 m_menu(0),
45 m_submenu(0), 46 m_submenu(0),
46 m_enabled(true), 47 m_enabled(true),
47 m_selected(false), 48 m_selected(false),
@@ -50,14 +51,25 @@ public:
50 explicit MenuItem( 51 explicit MenuItem(
51 const char *label) 52 const char *label)
52 : m_label(label ? label : ""), 53 : m_label(label ? label : ""),
54 m_menu(0),
55 m_submenu(0),
56 m_enabled(true),
57 m_selected(false),
58 m_toggle_item(false)
59 { }
60
61 MenuItem(const char *label, Menu &host_menu)
62 : m_label(label ? label : ""),
63 m_menu(&host_menu),
53 m_submenu(0), 64 m_submenu(0),
54 m_enabled(true), 65 m_enabled(true),
55 m_selected(false), 66 m_selected(false),
56 m_toggle_item(false) 67 m_toggle_item(false)
57 { } 68 { }
58 /// create a menu item with a specific command to be executed on click 69 /// create a menu item with a specific command to be executed on click
59 MenuItem(const char *label, RefCount<Command> &cmd): 70 MenuItem(const char *label, RefCount<Command> &cmd, Menu *menu = 0):
60 m_label(label ? label : ""), 71 m_label(label ? label : ""),
72 m_menu(menu),
61 m_submenu(0), 73 m_submenu(0),
62 m_command(cmd), 74 m_command(cmd),
63 m_enabled(true), 75 m_enabled(true),
@@ -66,8 +78,9 @@ public:
66 78
67 } 79 }
68 80
69 MenuItem(const char *label, Menu *submenu) 81 MenuItem(const char *label, Menu *submenu, Menu *host_menu = 0)
70 : m_label(label ? label : "") 82 : m_label(label ? label : "")
83 , m_menu(host_menu)
71 , m_submenu(submenu) 84 , m_submenu(submenu)
72 , m_enabled(true) 85 , m_enabled(true)
73 , m_selected(false), 86 , m_selected(false),
@@ -110,9 +123,13 @@ public:
110 RefCount<Command> &command() { return m_command; } 123 RefCount<Command> &command() { return m_command; }
111 const RefCount<Command> &command() const { return m_command; } 124 const RefCount<Command> &command() const { return m_command; }
112 //@} 125 //@}
126
127 void setMenu(Menu &menu) { m_menu = &menu; }
128 Menu *menu() { return m_menu; }
113 129
114private: 130private:
115 std::string m_label; ///< label of this item 131 std::string m_label; ///< label of this item
132 Menu *m_menu; ///< the menu we live in
116 Menu *m_submenu; ///< a submenu, 0 if we don't have one 133 Menu *m_submenu; ///< a submenu, 0 if we don't have one
117 RefCount<Command> m_command; ///< command to be executed 134 RefCount<Command> m_command; ///< command to be executed
118 bool m_enabled, m_selected; 135 bool m_enabled, m_selected;
@@ -123,6 +140,7 @@ private:
123 std::string filename; 140 std::string filename;
124 }; 141 };
125 std::auto_ptr<Icon> m_icon; 142 std::auto_ptr<Icon> m_icon;
143
126}; 144};
127 145
128} // end namespace FbTk 146} // end namespace FbTk
diff --git a/src/IntResMenuItem.cc b/src/IntResMenuItem.cc
index a1595a6..30aead1 100644
--- a/src/IntResMenuItem.cc
+++ b/src/IntResMenuItem.cc
@@ -21,8 +21,11 @@
21 21
22// $Id$ 22// $Id$
23 23
24#include "FbTk/Menu.hh"
25
24#include "IntResMenuItem.hh" 26#include "IntResMenuItem.hh"
25#include "PixmapWithMask.hh" 27#include "PixmapWithMask.hh"
28
26#ifdef HAVE_CSTDIO 29#ifdef HAVE_CSTDIO
27 #include <cstdio> 30 #include <cstdio>
28#else 31#else
@@ -41,8 +44,8 @@ std::string appendIntValue(const std::string &label, int value) {
41 44
42}; 45};
43 46
44IntResMenuItem::IntResMenuItem(const char *label, FbTk::Resource<int> &res, int min_val, int max_val): 47IntResMenuItem::IntResMenuItem(const char *label, FbTk::Resource<int> &res, int min_val, int max_val, FbTk::Menu &host_menu):
45 FbTk::MenuItem(label), m_org_label(FbTk::MenuItem::label()), 48 FbTk::MenuItem(label, host_menu), m_org_label(FbTk::MenuItem::label()),
46 m_max(max_val), m_min(min_val), m_res(res) { 49 m_max(max_val), m_min(min_val), m_res(res) {
47 setLabel(appendIntValue(m_org_label, *m_res).c_str()); 50 setLabel(appendIntValue(m_org_label, *m_res).c_str());
48} 51}
@@ -72,4 +75,11 @@ void IntResMenuItem::click(int button, int time) {
72 setLabel(appendIntValue(m_org_label, *m_res).c_str()); 75 setLabel(appendIntValue(m_org_label, *m_res).c_str());
73 // call other commands 76 // call other commands
74 FbTk::MenuItem::click(button, time); 77 FbTk::MenuItem::click(button, time);
78
79 // show new value, which for us means forcing a full menu update
80 // since the text is drawn onto the background!
81 if (menu()) {
82 menu()->frameWindow().updateBackground(false);
83 menu()->clearWindow();
84 }
75} 85}
diff --git a/src/IntResMenuItem.hh b/src/IntResMenuItem.hh
index cfbdd54..7e82be1 100644
--- a/src/IntResMenuItem.hh
+++ b/src/IntResMenuItem.hh
@@ -30,7 +30,7 @@
30/// Changes an resource integer value between min and max 30/// Changes an resource integer value between min and max
31class IntResMenuItem: public FbTk::MenuItem { 31class IntResMenuItem: public FbTk::MenuItem {
32public: 32public:
33 IntResMenuItem(const char *label, FbTk::Resource<int> &res, int min_val, int max_val); 33 IntResMenuItem(const char *label, FbTk::Resource<int> &res, int min_val, int max_val, FbTk::Menu &host_menu);
34 34
35 void click(int button, int time); 35 void click(int button, int time);
36 36
diff --git a/src/Screen.cc b/src/Screen.cc
index 36ab193..68ae3a4 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -1829,17 +1829,17 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
1829 } 1829 }
1830 1830
1831 FbTk::MenuItem *focused_alpha_item = new IntResMenuItem(_FBTEXT(Configmenu, FocusedAlpha, "Focused Window Alpha", "Transparency level of the focused window"), 1831 FbTk::MenuItem *focused_alpha_item = new IntResMenuItem(_FBTEXT(Configmenu, FocusedAlpha, "Focused Window Alpha", "Transparency level of the focused window"),
1832 resource.focused_alpha, 0, 255); 1832 resource.focused_alpha, 0, 255, *alpha_menu);
1833 focused_alpha_item->setCommand(saverc_cmd); 1833 focused_alpha_item->setCommand(saverc_cmd);
1834 alpha_menu->insert(focused_alpha_item); 1834 alpha_menu->insert(focused_alpha_item);
1835 1835
1836 FbTk::MenuItem *unfocused_alpha_item = new IntResMenuItem(_FBTEXT(Configmenu, UnfocusedAlpha, "Unfocused Window Alpha", "Transparency level of unfocused windows"), 1836 FbTk::MenuItem *unfocused_alpha_item = new IntResMenuItem(_FBTEXT(Configmenu, UnfocusedAlpha, "Unfocused Window Alpha", "Transparency level of unfocused windows"),
1837 resource.unfocused_alpha, 0, 255); 1837 resource.unfocused_alpha, 0, 255, *alpha_menu);
1838 unfocused_alpha_item->setCommand(saverc_cmd); 1838 unfocused_alpha_item->setCommand(saverc_cmd);
1839 alpha_menu->insert(unfocused_alpha_item); 1839 alpha_menu->insert(unfocused_alpha_item);
1840 1840
1841 FbTk::MenuItem *menu_alpha_item = new IntResMenuItem(_FBTEXT(Configmenu, MenuAlpha, "Menu Alpha", "Transparency level of menu"), 1841 FbTk::MenuItem *menu_alpha_item = new IntResMenuItem(_FBTEXT(Configmenu, MenuAlpha, "Menu Alpha", "Transparency level of menu"),
1842 resource.menu_alpha, 0, 255); 1842 resource.menu_alpha, 0, 255, *alpha_menu);
1843 menu_alpha_item->setCommand(saverc_cmd); 1843 menu_alpha_item->setCommand(saverc_cmd);
1844 alpha_menu->insert(menu_alpha_item); 1844 alpha_menu->insert(menu_alpha_item);
1845 1845
diff --git a/src/Slit.cc b/src/Slit.cc
index 9221377..eb26320 100644
--- a/src/Slit.cc
+++ b/src/Slit.cc
@@ -1257,7 +1257,7 @@ void Slit::setupMenu() {
1257 FbTk::MenuItem *alpha_menuitem = 1257 FbTk::MenuItem *alpha_menuitem =
1258 new IntResMenuItem(_FBTEXT(Common, Alpha, "Alpha", "Transparency level"), 1258 new IntResMenuItem(_FBTEXT(Common, Alpha, "Alpha", "Transparency level"),
1259 m_rc_alpha, 1259 m_rc_alpha,
1260 0, 255); 1260 0, 255, m_slitmenu);
1261 // setup command for alpha value 1261 // setup command for alpha value
1262 MacroCommand *alpha_macrocmd = new MacroCommand(); 1262 MacroCommand *alpha_macrocmd = new MacroCommand();
1263 RefCount<Command> alpha_cmd(new SimpleCommand<Slit>(*this, &Slit::updateAlpha)); 1263 RefCount<Command> alpha_cmd(new SimpleCommand<Slit>(*this, &Slit::updateAlpha));
diff --git a/src/ToggleMenu.hh b/src/ToggleMenu.hh
index f506df8..794c016 100644
--- a/src/ToggleMenu.hh
+++ b/src/ToggleMenu.hh
@@ -48,11 +48,8 @@ public:
48 // so that the last toggled item gets redrawn as 48 // so that the last toggled item gets redrawn as
49 // not toggled. 49 // not toggled.
50 if (ev.window == frameWindow()) { 50 if (ev.window == frameWindow()) {
51 // force full foreground update (by setting bg to same thing) 51 // force full foreground update
52 frameWindow().parentMoved(); 52 frameWindow().updateBackground(false);
53// for (size_t i = 0; i < numberOfItems(); ++i) {
54// clearItem(i);
55// }
56 } 53 }
57 54
58 } 55 }
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index dad91aa..0f16140 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -796,7 +796,7 @@ void Toolbar::setupMenus() {
796 796
797 MenuItem *toolbar_menuitem = new IntResMenuItem(_FBTEXT(Toolbar, WidthPercent, "Toolbar width percent", "Percentage of screen width taken by toolbar"), 797 MenuItem *toolbar_menuitem = new IntResMenuItem(_FBTEXT(Toolbar, WidthPercent, "Toolbar width percent", "Percentage of screen width taken by toolbar"),
798 m_rc_width_percent, 798 m_rc_width_percent,
799 0, 100); // min/max value 799 0, 100, menu()); // min/max value
800 800
801 801
802 RefCommand reconfig_toolbar(new ToolbarCommand(*this, &Toolbar::reconfigure)); 802 RefCommand reconfig_toolbar(new ToolbarCommand(*this, &Toolbar::reconfigure));
@@ -886,7 +886,7 @@ void Toolbar::setupMenus() {
886 FbTk::MenuItem *alpha_menuitem = 886 FbTk::MenuItem *alpha_menuitem =
887 new IntResMenuItem(_FBTEXT(Common, Alpha, "Alpha", "Transparency level"), 887 new IntResMenuItem(_FBTEXT(Common, Alpha, "Alpha", "Transparency level"),
888 m_rc_alpha, 888 m_rc_alpha,
889 0, 255); 889 0, 255, menu());
890 // setup command for alpha value 890 // setup command for alpha value
891 MacroCommand *alpha_macrocmd = new MacroCommand(); 891 MacroCommand *alpha_macrocmd = new MacroCommand();
892 RefCount<Command> alpha_cmd(new SimpleCommand<Toolbar>(*this, &Toolbar::updateAlpha)); 892 RefCount<Command> alpha_cmd(new SimpleCommand<Toolbar>(*this, &Toolbar::updateAlpha));