aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Menu.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2004-01-08 22:07:58 (GMT)
committerfluxgen <fluxgen>2004-01-08 22:07:58 (GMT)
commitf25aab19562fe50c36fac186f2eb5bd3383e2173 (patch)
tree6b509dfbf50285a378122812a78f7c6a319b4b46 /src/FbTk/Menu.cc
parent5643caa65520c7410a87e6daaa55e3b7adb005f8 (diff)
downloadfluxbox-f25aab19562fe50c36fac186f2eb5bd3383e2173.zip
fluxbox-f25aab19562fe50c36fac186f2eb5bd3383e2173.tar.bz2
cleaning
Diffstat (limited to 'src/FbTk/Menu.cc')
-rw-r--r--src/FbTk/Menu.cc37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index 47dd372..d0caf9e 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.51 2003/12/18 18:03:23 fluxgen Exp $ 25// $Id: Menu.cc,v 1.52 2004/01/08 22:07:00 fluxgen Exp $
26 26
27//use GNU extensions 27//use GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -57,8 +57,8 @@ Menu *Menu::s_focused = 0;
57 57
58Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): 58Menu::Menu(MenuTheme &tm, ImageControl &imgctrl):
59 m_theme(tm), 59 m_theme(tm),
60 m_image_ctrl(imgctrl),
61 m_parent(0), 60 m_parent(0),
61 m_image_ctrl(imgctrl),
62 m_screen_width(DisplayWidth(FbTk::App::instance()->display(), tm.screenNum())), 62 m_screen_width(DisplayWidth(FbTk::App::instance()->display(), tm.screenNum())),
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),
@@ -253,13 +253,13 @@ void Menu::lower() {
253} 253}
254 254
255void Menu::nextItem() { 255void Menu::nextItem() {
256 if (which_press == menuitems.size() - 1) 256 if (which_press >= 0 && which_press == static_cast<signed>(menuitems.size() - 1))
257 return; 257 return;
258 258
259 int old_which_press = which_press; 259 int old_which_press = which_press;
260 260
261 if (old_which_press >= 0 && 261 if (old_which_press >= 0 &&
262 old_which_press < menuitems.size() && 262 old_which_press < static_cast<signed>(menuitems.size()) &&
263 menuitems[old_which_press] != 0) { 263 menuitems[old_which_press] != 0) {
264 if (menuitems[old_which_press]->submenu()) { 264 if (menuitems[old_which_press]->submenu()) {
265 // we need to do this explicitly on the menu.window 265 // we need to do this explicitly on the menu.window
@@ -271,9 +271,9 @@ void Menu::nextItem() {
271 271
272 // restore old in case we changed which_press 272 // restore old in case we changed which_press
273 which_press = old_which_press; 273 which_press = old_which_press;
274 if (which_press < 0 || which_press >= menuitems.size()) 274 if (which_press < 0 || which_press >= static_cast<signed>(menuitems.size()))
275 which_press = 0; 275 which_press = 0;
276 else if (which_press < menuitems.size() - 1) 276 else if (which_press > 0 && which_press < static_cast<signed>(menuitems.size() - 1))
277 which_press++; 277 which_press++;
278 278
279 279
@@ -291,7 +291,7 @@ void Menu::prevItem() {
291 291
292 int old_which_press = which_press; 292 int old_which_press = which_press;
293 293
294 if (old_which_press >= 0 && old_which_press < menuitems.size()) { 294 if (old_which_press >= 0 && old_which_press < static_cast<signed>(menuitems.size())) {
295 if (menuitems[old_which_press]->submenu()) { 295 if (menuitems[old_which_press]->submenu()) {
296 // we need to do this explicitly on the menu.window 296 // we need to do this explicitly on the menu.window
297 // since it might hide the parent if we use Menu::hide 297 // since it might hide the parent if we use Menu::hide
@@ -302,7 +302,7 @@ void Menu::prevItem() {
302 // restore old in case we changed which_press 302 // restore old in case we changed which_press
303 which_press = old_which_press; 303 which_press = old_which_press;
304 304
305 if (which_press < 0 || which_press >= menuitems.size()) 305 if (which_press < 0 || which_press >= static_cast<signed>(menuitems.size()))
306 which_press = 0; 306 which_press = 0;
307 else if (which_press - 1 >= 0) 307 else if (which_press - 1 >= 0)
308 which_press--; 308 which_press--;
@@ -317,7 +317,7 @@ void Menu::prevItem() {
317} 317}
318 318
319void Menu::enterSubmenu() { 319void Menu::enterSubmenu() {
320 if (which_press < 0 || which_press >= menuitems.size()) 320 if (which_press < 0 || which_press >= static_cast<signed>(menuitems.size()))
321 return; 321 return;
322 322
323 Menu *submenu = menuitems[which_press]->submenu(); 323 Menu *submenu = menuitems[which_press]->submenu();
@@ -330,7 +330,7 @@ void Menu::enterSubmenu() {
330} 330}
331 331
332void Menu::enterParent() { 332void Menu::enterParent() {
333 if (which_press < 0 || which_press >= menuitems.size() || parent() == 0) 333 if (which_press < 0 || which_press >= static_cast<signed>(menuitems.size()) || parent() == 0)
334 return; 334 return;
335 335
336 Menu *submenu = menuitems[which_press]->submenu(); 336 Menu *submenu = menuitems[which_press]->submenu();
@@ -517,7 +517,7 @@ void Menu::update(int active_index) {
517 if (i == (unsigned int)which_sub) { 517 if (i == (unsigned int)which_sub) {
518 drawItem(i, true, true, false); 518 drawItem(i, true, true, false);
519 } else 519 } else
520 drawItem(i, (i == active_index && isItemEnabled(i)), true, false); 520 drawItem(i, (static_cast<signed>(i) == active_index && isItemEnabled(i)), true, false);
521 } 521 }
522 522
523 if (m_parent && visible) 523 if (m_parent && visible)
@@ -1214,19 +1214,20 @@ void Menu::exposeEvent(XExposeEvent &ee) {
1214 sbl_d = ((ee.x + ee.width) / menu.item_w), 1214 sbl_d = ((ee.x + ee.width) / menu.item_w),
1215 // then we see how many items down to redraw 1215 // then we see how many items down to redraw
1216 id_d = ((ee.y + ee.height) / menu.item_h); 1216 id_d = ((ee.y + ee.height) / menu.item_h);
1217 if (id_d > menu.persub) id_d = menu.persub; 1217 if (static_cast<signed>(id_d) > menu.persub)
1218 id_d = menu.persub;
1218 1219
1219 // draw the sublevels and the number of items the exposure spans 1220 // draw the sublevels and the number of items the exposure spans
1220 unsigned int i, ii; 1221 unsigned int i, ii;
1221 for (i = sbl; i <= sbl_d; i++) { 1222 for (i = sbl; i <= sbl_d; i++) {
1222 // set the iterator to the first item in the sublevel needing redrawing 1223 // set the iterator to the first item in the sublevel needing redrawing
1223 unsigned int index = id + i * menu.persub; 1224 unsigned int index = id + i * menu.persub;
1224 if (index < static_cast<int>(menuitems.size())) { 1225 if (index < menuitems.size()) {
1225 Menuitems::iterator it = menuitems.begin() + index; 1226 Menuitems::iterator it = menuitems.begin() + index;
1226 Menuitems::iterator it_end = menuitems.end(); 1227 Menuitems::iterator it_end = menuitems.end();
1227 for (ii = id; ii <= id_d && it != it_end; ++it, ii++) { 1228 for (ii = id; ii <= id_d && it != it_end; ++it, ii++) {
1228 unsigned int index = ii + (i * menu.persub); 1229 unsigned int index = ii + (i * menu.persub);
1229 drawItem(index, (which_sub == index), true, true, 1230 drawItem(index, (which_sub == static_cast<signed>(index)), true, true,
1230 ee.x, ee.y, ee.width, ee.height); 1231 ee.x, ee.y, ee.width, ee.height);
1231 } 1232 }
1232 } 1233 }
@@ -1323,7 +1324,7 @@ void Menu::keyPressEvent(XKeyEvent &event) {
1323 break; 1324 break;
1324 case XK_Return: 1325 case XK_Return:
1325 // send fake button 1 click 1326 // send fake button 1 click
1326 if (which_press >= 0 && which_press < menuitems.size()) { 1327 if (which_press >= 0 && which_press < static_cast<signed>(menuitems.size())) {
1327 menuitems[which_press]->click(1, event.time); 1328 menuitems[which_press]->click(1, event.time);
1328 itemSelected(1, which_press); 1329 itemSelected(1, which_press);
1329 m_need_update = true; 1330 m_need_update = true;
@@ -1372,12 +1373,12 @@ void Menu::renderTransFrame() {
1372} 1373}
1373 1374
1374void Menu::openSubmenu() { 1375void Menu::openSubmenu() {
1375 if (!isVisible() || which_press < 0 || which_press >= menuitems.size() || 1376 if (!isVisible() || which_press < 0 || which_press >= static_cast<signed>(menuitems.size()) ||
1376 which_sbl < 0 || which_sbl >= menuitems.size()) 1377 which_sbl < 0 || which_sbl >= static_cast<signed>(menuitems.size()))
1377 return; 1378 return;
1378 1379
1379 int item = which_sbl * menu.persub + which_press; 1380 int item = which_sbl * menu.persub + which_press;
1380 if (item < 0 || item >= menuitems.size()) 1381 if (item < 0 || item >= static_cast<signed>(menuitems.size()))
1381 return; 1382 return;
1382 1383
1383 drawItem(item, true); 1384 drawItem(item, true);