aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2011-01-15 20:31:37 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2011-01-15 20:31:37 (GMT)
commitbb480030f54947b19b761f37dd3c4756b361b5e1 (patch)
treeb5934dc12278b7b48d96f82dd31061c8fc554fcf
parentaccb8c3fa34b67ff59ecc2ea791eb10e1dcb90fc (diff)
downloadfluxbox-bb480030f54947b19b761f37dd3c4756b361b5e1.zip
fluxbox-bb480030f54947b19b761f37dd3c4756b361b5e1.tar.bz2
small refactoring of FbTk/Menu code
* removed useless struct _menu * code deduplication via renderMenuPixmap() * improved documentation: - 'sublevel' actually means 'column' - 'persub' means 'row_per_column'
-rw-r--r--src/FbTk/Menu.cc422
-rw-r--r--src/FbTk/Menu.hh57
-rw-r--r--src/Screen.cc2
-rw-r--r--src/Slit.cc2
4 files changed, 254 insertions, 229 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index 5d93bbd..f46efb0 100644
--- a/src/FbTk/Menu.cc
+++ b/src/FbTk/Menu.cc
@@ -75,6 +75,26 @@ using std::cout;
75using std::endl; 75using std::endl;
76#endif // DEBUG 76#endif // DEBUG
77 77
78namespace {
79
80// if 'win' is given, 'pm' is used as the backGroundPixmap
81void renderMenuPixmap(Pixmap& pm, FbTk::FbWindow* win, int width, int height, const FbTk::Texture& tex, FbTk::ImageControl& img_ctrl) {
82
83 img_ctrl.removeImage(pm);
84 if (!tex.usePixmap()) {
85 pm = None;
86 if (win)
87 win->setBackgroundColor(tex.color());
88 } else {
89 pm = img_ctrl.renderImage(width, height, tex);
90 if (win)
91 win->setBackgroundPixmap(pm);
92 }
93}
94
95} // end of anonymous namespace
96
97
78namespace FbTk { 98namespace FbTk {
79 99
80Menu *Menu::shown = 0; 100Menu *Menu::shown = 0;
@@ -118,84 +138,85 @@ Menu::Menu(FbTk::ThemeProxy<MenuTheme> &tm, ImageControl &imgctrl):
118 138
119 m_type_ahead.init(menuitems); 139 m_type_ahead.init(menuitems);
120 140
121 menu.x_move = 141 m_x_move =
122 menu.y_move = 0; 142 m_y_move = 0;
123 143
124 m_which_sub = -1; 144 m_which_sub = -1;
125 145
126 menu.frame_pixmap = 146 m_frame_pixmap =
127 menu.title_pixmap = 147 m_title_pixmap =
128 menu.hilite_pixmap = None; 148 m_hilite_pixmap = None;
129 149
130 menu.item_w = menu.frame_h = 150 m_item_w = m_frame_h =
131 theme()->titleFont().height() + theme()->bevelWidth() * 2; 151 theme()->titleFont().height() + theme()->bevelWidth() * 2;
132 152
133 menu.sublevels = 153 m_columns =
134 menu.persub = 154 m_rows_per_column =
135 menu.minsub = 0; 155 m_min_columns = 0;
136 156
157 FbTk::EventManager &evm = *FbTk::EventManager::instance();
137 long event_mask = ButtonPressMask | ButtonReleaseMask | 158 long event_mask = ButtonPressMask | ButtonReleaseMask |
138 ButtonMotionMask | KeyPressMask | ExposureMask | FocusChangeMask; 159 ButtonMotionMask | KeyPressMask | ExposureMask | FocusChangeMask;
160
139 // create menu window 161 // create menu window
140 menu.window = FbTk::FbWindow(tm->screenNum(), 162 m_window = FbTk::FbWindow(tm->screenNum(),
141 0, 0, 10, 10, 163 0, 0, 10, 10,
142 event_mask, 164 event_mask,
143 true, // override redirect 165 true, // override redirect
144 true); // save_under 166 true); // save_under
145 167
146 // initialize 'shape' here AFTER we created menu.window aka fbwindow() 168 // initialize 'shape' here AFTER we created m_window aka fbwindow()
147 m_shape.reset(new Shape(fbwindow(), tm->shapePlaces())); 169 m_shape.reset(new Shape(fbwindow(), tm->shapePlaces()));
148 170
171 evm.add(*this, m_window);
172
149 // strip focus change mask from attrib, since we should only use it with main window 173 // strip focus change mask from attrib, since we should only use it with main window
150 event_mask ^= FocusChangeMask; 174 event_mask ^= FocusChangeMask;
151 175
152 FbTk::EventManager &evm = *FbTk::EventManager::instance();
153 evm.add(*this, menu.window);
154
155
156 event_mask |= EnterWindowMask | LeaveWindowMask; 176 event_mask |= EnterWindowMask | LeaveWindowMask;
177
157 //create menu title 178 //create menu title
158 menu.title = FbTk::FbWindow(menu.window, // parent 179 m_title = FbTk::FbWindow(m_window, // parent
159 0, 0, width(), theme()->titleHeight(), // pos and size 180 0, 0, width(), theme()->titleHeight(), // pos and size
160 event_mask, // mask 181 event_mask, // mask
161 false, // override redirect 182 false, // override redirect
162 true); // save under 183 true); // save under
163 184
164 evm.add(*this, menu.title); 185 evm.add(*this, m_title);
165 menu.title.setRenderer(*this); 186 m_title.setRenderer(*this);
166 187
167 event_mask |= PointerMotionMask; 188 event_mask |= PointerMotionMask;
168 menu.frame = FbTk::FbWindow(menu.window, // parent 189 m_frame = FbTk::FbWindow(m_window, // parent
169 0, theme()->titleHeight(), // pos 190 0, theme()->titleHeight(), // pos
170 width(), menu.frame_h ? menu.frame_h : 1, // size 191 width(), m_frame_h ? m_frame_h : 1, // size
171 event_mask, // mask 192 event_mask, // mask
172 false, // override redirect 193 false, // override redirect
173 true); // save under 194 true); // save under
174 evm.add(*this, menu.frame); 195 evm.add(*this, m_frame);
175 menu.frame.setRenderer(*this); 196 m_frame.setRenderer(*this);
176 197
177 menu.title.raise(); 198 m_title.raise();
178 199
179 reconfigure(); 200 reconfigure();
180} 201}
181 202
182Menu::~Menu() { 203Menu::~Menu() {
183 204
184 menu.window.hide(); 205 m_window.hide();
185 206
186 if (shown && shown->window() == window()) 207 if (shown && shown->window() == window())
187 shown = 0; 208 shown = 0;
188 209
189 removeAll(); 210 removeAll();
190 211
191 if (menu.title_pixmap) 212 if (m_title_pixmap)
192 m_image_ctrl.removeImage(menu.title_pixmap); 213 m_image_ctrl.removeImage(m_title_pixmap);
193 214
194 if (menu.frame_pixmap) 215 if (m_frame_pixmap)
195 m_image_ctrl.removeImage(menu.frame_pixmap); 216 m_image_ctrl.removeImage(m_frame_pixmap);
196 217
197 if (menu.hilite_pixmap) 218 if (m_hilite_pixmap)
198 m_image_ctrl.removeImage(menu.hilite_pixmap); 219 m_image_ctrl.removeImage(m_hilite_pixmap);
199 220
200 if (s_focused == this) 221 if (s_focused == this)
201 s_focused = 0; 222 s_focused = 0;
@@ -290,11 +311,11 @@ void Menu::removeAll() {
290} 311}
291 312
292void Menu::raise() { 313void Menu::raise() {
293 menu.window.raise(); 314 m_window.raise();
294} 315}
295 316
296void Menu::lower() { 317void Menu::lower() {
297 menu.window.lower(); 318 m_window.lower();
298} 319}
299 320
300void Menu::cycleItems(bool reverse) { 321void Menu::cycleItems(bool reverse) {
@@ -342,7 +363,7 @@ void Menu::setActiveIndex(int new_index) {
342 if (validIndex(old_active_index) && 363 if (validIndex(old_active_index) &&
343 menuitems[old_active_index] != 0) { 364 menuitems[old_active_index] != 0) {
344 if (menuitems[old_active_index]->submenu()) { 365 if (menuitems[old_active_index]->submenu()) {
345 // we need to do this explicitly on the menu.window 366 // we need to do this explicitly on the m_window
346 // since it might hide the parent if we use Menu::hide 367 // since it might hide the parent if we use Menu::hide
347 menuitems[old_active_index]->submenu()->internal_hide(); 368 menuitems[old_active_index]->submenu()->internal_hide();
348 } 369 }
@@ -378,10 +399,10 @@ void Menu::enableTitle() {
378 399
379void Menu::updateMenu() { 400void Menu::updateMenu() {
380 if (m_title_vis) { 401 if (m_title_vis) {
381 menu.item_w = theme()->titleFont().textWidth(menu.label); 402 m_item_w = theme()->titleFont().textWidth(m_label);
382 menu.item_w += (theme()->bevelWidth() * 2); 403 m_item_w += (theme()->bevelWidth() * 2);
383 } else 404 } else
384 menu.item_w = 1; 405 m_item_w = 1;
385 406
386 if (validIndex(m_active_index) && !menuitems[m_active_index]->isEnabled()) { 407 if (validIndex(m_active_index) && !menuitems[m_active_index]->isEnabled()) {
387 // find the nearest enabled menuitem and highlight it 408 // find the nearest enabled menuitem and highlight it
@@ -403,68 +424,62 @@ void Menu::updateMenu() {
403 Menuitems::iterator it_end = menuitems.end(); 424 Menuitems::iterator it_end = menuitems.end();
404 for (; it != it_end; ++it) { 425 for (; it != it_end; ++it) {
405 ii = (*it)->width(theme()); 426 ii = (*it)->width(theme());
406 menu.item_w = (ii > menu.item_w ? ii : menu.item_w); 427 m_item_w = (ii > m_item_w ? ii : m_item_w);
407 } 428 }
408 429
409 if (menu.item_w < 1) 430 if (m_item_w < 1)
410 menu.item_w = 1; 431 m_item_w = 1;
411 432
412 if (!menuitems.empty()) { 433 if (!menuitems.empty()) {
413 menu.sublevels = 1; 434 m_columns = 1;
414 435
415 while (theme()->itemHeight() * (menuitems.size() + 1) / menu.sublevels + 436 while (theme()->itemHeight() * (menuitems.size() + 1) / m_columns +
416 theme()->titleHeight() + theme()->borderWidth() > m_screen_height) { 437 theme()->titleHeight() + theme()->borderWidth() > m_screen_height) {
417 menu.sublevels++; 438 m_columns++;
418 } 439 }
419 440
420 if (menu.sublevels < menu.minsub) 441 if (m_columns < m_min_columns)
421 menu.sublevels = menu.minsub; 442 m_columns = m_min_columns;
422 443
423 menu.persub = menuitems.size() / menu.sublevels; 444 m_rows_per_column = menuitems.size() / m_columns;
424 if (menuitems.size() % menu.sublevels) menu.persub++; 445 if (menuitems.size() % m_columns) m_rows_per_column++;
425 } else { 446 } else {
426 menu.sublevels = 0; 447 m_columns = 0;
427 menu.persub = 0; 448 m_rows_per_column = 0;
428 } 449 }
429 450
430 int itmp = (theme()->itemHeight() * menu.persub); 451 int itmp = (theme()->itemHeight() * m_rows_per_column);
431 menu.frame_h = itmp < 1 ? 1 : itmp; 452 m_frame_h = itmp < 1 ? 1 : itmp;
432 453
433 unsigned int new_width = (menu.sublevels * menu.item_w); 454 unsigned int new_width = (m_columns * m_item_w);
434 unsigned int new_height = menu.frame_h; 455 unsigned int new_height = m_frame_h;
435 456
436 if (m_title_vis) 457 if (m_title_vis)
437 new_height += theme()->titleHeight() + ((menu.frame_h > 0)?menu.title.borderWidth():0); 458 new_height += theme()->titleHeight() + ((m_frame_h > 0)?m_title.borderWidth():0);
438 459
439 460
440 if (new_width == 0) 461 if (new_width == 0)
441 new_width = menu.item_w; 462 new_width = m_item_w;
442 463
443 if (new_height < 1) 464 if (new_height < 1)
444 new_height = 1; 465 new_height = 1;
445 466
446 // must update main window size whether visible or not 467 // must update main window size whether visible or not
447 // the rest can wait until the end 468 // the rest can wait until the end
448 if (menu.window.width() != new_width) 469 if (m_window.width() != new_width)
449 m_need_update = true; 470 m_need_update = true;
450 471
451 menu.window.resize(new_width, new_height); 472 m_window.resize(new_width, new_height);
452 473
453 if (!isVisible()) 474 if (!isVisible())
454 return; 475 return;
455 476
456 if (menu.frame.alpha() != alpha()) 477 if (m_frame.alpha() != alpha())
457 menu.frame.setAlpha(alpha()); 478 m_frame.setAlpha(alpha());
458 479
459 Pixmap tmp = menu.hilite_pixmap; 480 renderMenuPixmap(m_hilite_pixmap, NULL,
460 const FbTk::Texture &hilite_tex = theme()->hiliteTexture(); 481 m_item_w, theme()->itemHeight(),
461 if (!hilite_tex.usePixmap()) { 482 theme()->hiliteTexture(), m_image_ctrl);
462 menu.hilite_pixmap = None;
463 } else
464 menu.hilite_pixmap =
465 m_image_ctrl.renderImage(menu.item_w, theme()->itemHeight(), hilite_tex);
466 if (tmp)
467 m_image_ctrl.removeImage(tmp);
468 483
469 484
470 if (!theme()->selectedPixmap().pixmap().drawable()) { 485 if (!theme()->selectedPixmap().pixmap().drawable()) {
@@ -490,46 +505,24 @@ void Menu::updateMenu() {
490 } 505 }
491 506
492 if (m_title_vis) { 507 if (m_title_vis) {
493 menu.title.moveResize(-menu.title.borderWidth(), -menu.title.borderWidth(), 508 m_title.moveResize(-m_title.borderWidth(), -m_title.borderWidth(),
494 width() + menu.title.borderWidth(), theme()->titleHeight()); 509 width() + m_title.borderWidth(), theme()->titleHeight());
495 } 510 }
496 511
497 menu.frame.moveResize(0, ((m_title_vis) ? menu.title.y() + menu.title.height() + 512 m_frame.moveResize(0, ((m_title_vis) ? m_title.y() + m_title.height() +
498 menu.title.borderWidth()*2 : 0), 513 m_title.borderWidth()*2 : 0),
499 width(), menu.frame_h); 514 width(), m_frame_h);
500 515
501 if (m_title_vis && m_need_update) { 516 if (m_title_vis && m_need_update) {
502 tmp = menu.title_pixmap; 517 renderMenuPixmap(m_title_pixmap, &m_title,
503 const FbTk::Texture &tex = theme()->titleTexture(); 518 width(), theme()->titleHeight(),
504 if (!tex.usePixmap()) { 519 theme()->titleTexture(), m_image_ctrl);
505 menu.title_pixmap = None;
506 menu.title.setBackgroundColor(tex.color());
507 } else {
508 menu.title_pixmap =
509 m_image_ctrl.renderImage(width(), theme()->titleHeight(), tex);
510 // set pixmap that we have as real face to the user
511 menu.title.setBackgroundPixmap(menu.title_pixmap);
512 }
513
514 if (tmp)
515 m_image_ctrl.removeImage(tmp);
516 } 520 }
517 521
518 tmp = menu.frame_pixmap;
519 const FbTk::Texture &frame_tex = theme()->frameTexture();
520 if (m_need_update) { 522 if (m_need_update) {
521 if (!frame_tex.usePixmap()) { 523 renderMenuPixmap(m_frame_pixmap, &m_frame,
522 menu.frame_pixmap = None; 524 width(), m_frame_h,
523 menu.frame.setBackgroundColor(frame_tex.color()); 525 theme()->frameTexture(), m_image_ctrl);
524 } else {
525 menu.frame_pixmap =
526 m_image_ctrl.renderImage(width(), menu.frame_h, frame_tex);
527 menu.frame.setBackgroundPixmap(menu.frame_pixmap);
528 }
529
530 if (tmp)
531 m_image_ctrl.removeImage(tmp);
532
533 } 526 }
534 527
535 clearWindow(); 528 clearWindow();
@@ -551,8 +544,8 @@ void Menu::show() {
551 m_type_ahead.reset(); 544 m_type_ahead.reset();
552 m_matches.clear(); 545 m_matches.clear();
553 546
554 menu.window.showSubwindows(); 547 m_window.showSubwindows();
555 menu.window.show(); 548 m_window.show();
556 raise(); 549 raise();
557 550
558 if (shown && shown != this) 551 if (shown && shown != this)
@@ -591,13 +584,13 @@ void Menu::grabInputFocus() {
591 s_focused = this; 584 s_focused = this;
592 585
593 // grab input focus 586 // grab input focus
594 menu.window.setInputFocus(RevertToPointerRoot, CurrentTime); 587 m_window.setInputFocus(RevertToPointerRoot, CurrentTime);
595} 588}
596 589
597 590
598void Menu::clearWindow() { 591void Menu::clearWindow() {
599 menu.title.clear(); 592 m_title.clear();
600 menu.frame.clear(); 593 m_frame.clear();
601 594
602 // clear foreground bits of frame items 595 // clear foreground bits of frame items
603 for (size_t i = 0; i < menuitems.size(); i++) { 596 for (size_t i = 0; i < menuitems.size(); i++) {
@@ -642,7 +635,7 @@ void Menu::internal_hide(bool first) {
642 m_parent->grabInputFocus(); 635 m_parent->grabInputFocus();
643 636
644 m_parent = 0; 637 m_parent = 0;
645 menu.window.hide(); 638 m_window.hide();
646} 639}
647 640
648 641
@@ -650,10 +643,10 @@ void Menu::move(int x, int y) {
650 if (x == this->x() && y == this->y()) 643 if (x == this->x() && y == this->y())
651 return; 644 return;
652 645
653 menu.window.move(x, y); 646 m_window.move(x, y);
654 // potentially transparent children 647 // potentially transparent children
655 menu.title.parentMoved(); 648 m_title.parentMoved();
656 menu.frame.parentMoved(); 649 m_frame.parentMoved();
657 650
658 if (!isVisible()) 651 if (!isVisible())
659 return; 652 return;
@@ -671,7 +664,7 @@ void Menu::redrawTitle(FbDrawable &drawable) {
671 664
672 const FbTk::Font &font = theme()->titleFont(); 665 const FbTk::Font &font = theme()->titleFont();
673 int dx = theme()->bevelWidth(); 666 int dx = theme()->bevelWidth();
674 unsigned int l = font.textWidth(menu.label) + theme()->bevelWidth()*2; 667 unsigned int l = font.textWidth(m_label) + theme()->bevelWidth()*2;
675 668
676 switch (theme()->titleFontJustify()) { 669 switch (theme()->titleFontJustify()) {
677 case FbTk::RIGHT: 670 case FbTk::RIGHT:
@@ -687,7 +680,7 @@ void Menu::redrawTitle(FbDrawable &drawable) {
687 680
688 // difference between height based on font, and style-set height 681 // difference between height based on font, and style-set height
689 int height_offset = theme()->titleHeight() - (font.height() + 2*theme()->bevelWidth()); 682 int height_offset = theme()->titleHeight() - (font.height() + 2*theme()->bevelWidth());
690 font.drawText(drawable, screenNumber(), theme()->titleTextGC().gc(), menu.label, 683 font.drawText(drawable, screenNumber(), theme()->titleTextGC().gc(), m_label,
691 dx, font.ascent() + theme()->bevelWidth() + height_offset/2); // position 684 dx, font.ascent() + theme()->bevelWidth() + height_offset/2); // position
692} 685}
693 686
@@ -713,19 +706,20 @@ void Menu::drawSubmenu(unsigned int index) {
713 706
714 item->submenu()->setScreen(m_screen_x, m_screen_y, m_screen_width, m_screen_height); 707 item->submenu()->setScreen(m_screen_x, m_screen_y, m_screen_width, m_screen_height);
715 708
716 int sbl = index / menu.persub, i = index - (sbl * menu.persub); 709 int column = index / m_rows_per_column;
717 int new_x = x() + ((menu.item_w * (sbl + 1)) + menu.window.borderWidth()); 710 int row = index - (column * m_rows_per_column);
711 int new_x = x() + ((m_item_w * (column + 1)) + m_window.borderWidth());
718 int new_y; 712 int new_y;
719 713
720 if (m_alignment == ALIGNTOP) { 714 if (m_alignment == ALIGNTOP) {
721 new_y = (y() + ((m_title_vis) ? theme()->titleHeight() + menu.title.borderWidth() : 0) - 715 new_y = (y() + ((m_title_vis) ? theme()->titleHeight() + m_title.borderWidth() : 0) -
722 ((item->submenu()->m_title_vis) ? 716 ((item->submenu()->m_title_vis) ?
723 item->submenu()->theme()->titleHeight() + menu.window.borderWidth() : 0)); 717 item->submenu()->theme()->titleHeight() + m_window.borderWidth() : 0));
724 } else { 718 } else {
725 new_y = (y() + (theme()->itemHeight() * i) + 719 new_y = (y() + (theme()->itemHeight() * row) +
726 ((m_title_vis) ? theme()->titleHeight() + menu.window.borderWidth() : 0) - 720 ((m_title_vis) ? theme()->titleHeight() + m_window.borderWidth() : 0) -
727 ((item->submenu()->m_title_vis) ? 721 ((item->submenu()->m_title_vis) ?
728 item->submenu()->theme()->titleHeight() + menu.window.borderWidth() : 0)); 722 item->submenu()->theme()->titleHeight() + m_window.borderWidth() : 0));
729 } 723 }
730 724
731 if (m_alignment == ALIGNBOTTOM && 725 if (m_alignment == ALIGNBOTTOM &&
@@ -736,7 +730,7 @@ void Menu::drawSubmenu(unsigned int index) {
736 int borderw = item->submenu()->fbwindow().borderWidth(); 730 int borderw = item->submenu()->fbwindow().borderWidth();
737 731
738 if ((new_x + item->submenu()->width()) + 2*borderw > m_screen_x + m_screen_width) { 732 if ((new_x + item->submenu()->width()) + 2*borderw > m_screen_x + m_screen_width) {
739 new_x = x() - item->submenu()->width() - menu.window.borderWidth(); 733 new_x = x() - item->submenu()->width() - m_window.borderWidth();
740 } 734 }
741 735
742 if (new_x < m_screen_x) 736 if (new_x < m_screen_x)
@@ -744,7 +738,7 @@ void Menu::drawSubmenu(unsigned int index) {
744 738
745 if ((new_y + item->submenu()->height()) > m_screen_y + m_screen_height) { 739 if ((new_y + item->submenu()->height()) > m_screen_y + m_screen_height) {
746 new_y = m_screen_y + m_screen_height - item->submenu()->height() - 740 new_y = m_screen_y + m_screen_height - item->submenu()->height() -
747 menu.window.borderWidth() * 2; 741 m_window.borderWidth() * 2;
748 } 742 }
749 743
750 item->submenu()->m_moving = m_moving; 744 item->submenu()->m_moving = m_moving;
@@ -773,14 +767,16 @@ int Menu::drawItem(FbDrawable &drawable, unsigned int index,
773 bool highlight, bool exclusive_drawable) { 767 bool highlight, bool exclusive_drawable) {
774 768
775 if (index >= menuitems.size() || menuitems.size() == 0 || 769 if (index >= menuitems.size() || menuitems.size() == 0 ||
776 menu.persub == 0) 770 m_rows_per_column == 0)
777 return 0; 771 return 0;
778 772
779 MenuItem *item = menuitems[index]; 773 MenuItem *item = menuitems[index];
780 if (! item) return 0; 774 if (! item) return 0;
781 775
782 int sbl = index / menu.persub, i = index - (sbl * menu.persub); 776 int column = index / m_rows_per_column;
783 int item_x = (sbl * menu.item_w), item_y = (i * theme()->itemHeight()); 777 int row = index - (column * m_rows_per_column);
778 int item_x = (column * m_item_w);
779 int item_y = (row * theme()->itemHeight());
784 780
785 if (exclusive_drawable) 781 if (exclusive_drawable)
786 item_x = item_y = 0; 782 item_x = item_y = 0;
@@ -788,14 +784,14 @@ int Menu::drawItem(FbDrawable &drawable, unsigned int index,
788 item->draw(drawable, theme(), highlight, 784 item->draw(drawable, theme(), highlight,
789 exclusive_drawable, true, // draw fg, draw bg 785 exclusive_drawable, true, // draw fg, draw bg
790 item_x, item_y, 786 item_x, item_y,
791 menu.item_w, theme()->itemHeight()); 787 m_item_w, theme()->itemHeight());
792 788
793 return item_y; 789 return item_y;
794} 790}
795 791
796void Menu::setLabel(const FbTk::BiDiString &labelstr) { 792void Menu::setLabel(const FbTk::BiDiString &labelstr) {
797 //make sure we don't send 0 to std::string 793 //make sure we don't send 0 to std::string
798 menu.label = labelstr; 794 m_label = labelstr;
799 reconfigure(); 795 reconfigure();
800} 796}
801 797
@@ -807,7 +803,6 @@ void Menu::setItemSelected(unsigned int index, bool sel) {
807 if (! item) return; 803 if (! item) return;
808 804
809 item->setSelected(sel); 805 item->setSelected(sel);
810
811} 806}
812 807
813 808
@@ -829,7 +824,6 @@ void Menu::setItemEnabled(unsigned int index, bool enable) {
829 if (! item) return; 824 if (! item) return;
830 825
831 item->setEnabled(enable); 826 item->setEnabled(enable);
832
833} 827}
834 828
835 829
@@ -860,7 +854,7 @@ void Menu::handleEvent(XEvent &event) {
860 s_focused = 0; 854 s_focused = 0;
861 // I don't know why, but I get a FocusIn event when closing the menu with 855 // I don't know why, but I get a FocusIn event when closing the menu with
862 // the mouse over it -- probably an xorg bug, but it's easy to address here 856 // the mouse over it -- probably an xorg bug, but it's easy to address here
863 } else if (event.type == FocusIn && m_visible) { 857 } else if (event.type == FocusIn && isVisible()) {
864 if (s_focused != this) 858 if (s_focused != this)
865 s_focused = this; 859 s_focused = this;
866 // if there's a submenu open, focus it instead 860 // if there's a submenu open, focus it instead
@@ -871,16 +865,17 @@ void Menu::handleEvent(XEvent &event) {
871} 865}
872 866
873void Menu::buttonPressEvent(XButtonEvent &be) { 867void Menu::buttonPressEvent(XButtonEvent &be) {
874 if (be.window == menu.title) { 868 if (be.window == m_title) {
875 grabInputFocus(); 869 grabInputFocus();
876 m_closing = (be.button == 3); 870 m_closing = (be.button == 3);
877 } else 871 } else
878 m_closing = false; 872 m_closing = false;
879 873
880 if (be.window == menu.frame && menu.item_w != 0) { 874 if (be.window == m_frame && m_item_w != 0) {
881 875
882 int sbl = (be.x / menu.item_w), i = (be.y / theme()->itemHeight()); 876 int column = (be.x / m_item_w);
883 int w = (sbl * menu.persub) + i; 877 int i = (be.y / theme()->itemHeight());
878 int w = (column * m_rows_per_column) + i;
884 879
885 if (validIndex(w) && isItemSelectable(static_cast<unsigned int>(w))) { 880 if (validIndex(w) && isItemSelectable(static_cast<unsigned int>(w))) {
886 MenuItem *item = menuitems[w]; 881 MenuItem *item = menuitems[w];
@@ -891,14 +886,14 @@ void Menu::buttonPressEvent(XButtonEvent &be) {
891 } 886 }
892 } 887 }
893 } else { 888 } else {
894 menu.x_move = be.x_root - x(); 889 m_x_move = be.x_root - x();
895 menu.y_move = be.y_root - y(); 890 m_y_move = be.y_root - y();
896 } 891 }
897} 892}
898 893
899 894
900void Menu::buttonReleaseEvent(XButtonEvent &re) { 895void Menu::buttonReleaseEvent(XButtonEvent &re) {
901 if (re.window == menu.title) { 896 if (re.window == m_title) {
902 if (m_moving) { 897 if (m_moving) {
903 m_moving = false; 898 m_moving = false;
904 899
@@ -908,8 +903,8 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) {
908 903
909 if (alpha() < 255) { 904 if (alpha() < 255) {
910 // update these since we've (probably) moved 905 // update these since we've (probably) moved
911 menu.title.parentMoved(); 906 m_title.parentMoved();
912 menu.frame.parentMoved(); 907 m_frame.parentMoved();
913 clearWindow(); 908 clearWindow();
914 } 909 }
915 } 910 }
@@ -917,15 +912,17 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) {
917 if (re.button == 3 && m_closing) 912 if (re.button == 3 && m_closing)
918 internal_hide(); 913 internal_hide();
919 914
920 } else if (re.window == menu.frame) { 915 } else if (re.window == m_frame) {
921 916
922 int sbl = (re.x / menu.item_w), i = (re.y / theme()->itemHeight()), 917 int column = (re.x / m_item_w);
923 ix = sbl * menu.item_w, iy = i * theme()->itemHeight(), 918 int i = (re.y / theme()->itemHeight());
924 w = (sbl * menu.persub) + i; 919 int ix = column * m_item_w;
920 int iy = i * theme()->itemHeight();
921 int w = (column * m_rows_per_column) + i;
925 922
926 if (validIndex(w) && isItemSelectable(static_cast<unsigned int>(w))) { 923 if (validIndex(w) && isItemSelectable(static_cast<unsigned int>(w))) {
927 if (m_active_index == w && isItemEnabled(w) && 924 if (m_active_index == w && isItemEnabled(w) &&
928 re.x > ix && re.x < (signed) (ix + menu.item_w) && 925 re.x > ix && re.x < (signed) (ix + m_item_w) &&
929 re.y > iy && re.y < (signed) (iy + theme()->itemHeight())) { 926 re.y > iy && re.y < (signed) (iy + theme()->itemHeight())) {
930 menuitems[w]->click(re.button, re.time, re.state); 927 menuitems[w]->click(re.button, re.time, re.state);
931 } else { 928 } else {
@@ -941,7 +938,7 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) {
941 938
942void Menu::motionNotifyEvent(XMotionEvent &me) { 939void Menu::motionNotifyEvent(XMotionEvent &me) {
943 // if draging the with the titlebar: 940 // if draging the with the titlebar:
944 if (me.window == menu.title && (me.state & Button1Mask)) { 941 if (me.window == m_title && (me.state & Button1Mask)) {
945 stopHide(); 942 stopHide();
946 943
947 if (! m_moving) { 944 if (! m_moving) {
@@ -958,14 +955,14 @@ void Menu::motionNotifyEvent(XMotionEvent &me) {
958 } else { 955 } else {
959 // we dont call ::move here 'cause we dont want to update transparency 956 // we dont call ::move here 'cause we dont want to update transparency
960 // while draging the menu (which is slow) 957 // while draging the menu (which is slow)
961 menu.window.move(me.x_root - menu.x_move, me.y_root - menu.y_move); 958 m_window.move(me.x_root - m_x_move, me.y_root - m_y_move);
962 } 959 }
963 960
964 } else if (!(me.state & Button1Mask) && me.window == menu.frame) { 961 } else if (!(me.state & Button1Mask) && me.window == m_frame) {
965 stopHide(); 962 stopHide();
966 int sbl = (me.x / menu.item_w), 963 int column = (me.x / m_item_w);
967 i = (me.y / theme()->itemHeight()), 964 int i = (me.y / theme()->itemHeight());
968 w = (sbl * menu.persub) + i; 965 int w = (column * m_rows_per_column) + i;
969 966
970 if (w == m_active_index || !validIndex(w)) 967 if (w == m_active_index || !validIndex(w))
971 return; 968 return;
@@ -994,12 +991,8 @@ void Menu::motionNotifyEvent(XMotionEvent &me) {
994 991
995 } 992 }
996 993
997 if (itmp->submenu()) { 994 if (itmp->submenu()) { // start submenu open delay
998 // start submenu open delay 995 m_submenu_timer.setTimeout(0, theme()->getDelay() * 1000);
999 timeval timeout;
1000 timeout.tv_sec = 0;
1001 timeout.tv_usec = theme()->getDelay() * 1000; // transformed to usec
1002 m_submenu_timer.setTimeout(timeout);
1003 m_submenu_timer.start(); 996 m_submenu_timer.start();
1004 } else if (isItemSelectable(w)){ 997 } else if (isItemSelectable(w)){
1005 // else normal menu item 998 // else normal menu item
@@ -1012,32 +1005,37 @@ void Menu::motionNotifyEvent(XMotionEvent &me) {
1012 1005
1013 1006
1014void Menu::exposeEvent(XExposeEvent &ee) { 1007void Menu::exposeEvent(XExposeEvent &ee) {
1015 if (ee.window == menu.title) { 1008 if (ee.window == m_title) {
1016 menu.title.clearArea(ee.x, ee.y, ee.width, ee.height); 1009 m_title.clearArea(ee.x, ee.y, ee.width, ee.height);
1017 } else if (ee.window == menu.frame) { 1010 } else if (ee.window == m_frame) {
1011
1018 // find where to clear 1012 // find where to clear
1019 // this is a compilicated algorithm... lets do it step by step... 1013 // this is a compilicated algorithm... lets do it step by step...
1020 // first... we see in which sub level the expose starts... and how many 1014 // first... we see in which column the expose starts... and how many
1021 // items down in that sublevel 1015 // items down in that column
1016 int column = (ee.x / m_item_w);
1017 int id = (ee.y / theme()->itemHeight());
1018
1019 // next... figure out how many sublevels over the redrawspans
1020 int column_d = ((ee.x + ee.width) / m_item_w);
1022 1021
1023 int sbl = (ee.x / menu.item_w), id = (ee.y / theme()->itemHeight()), 1022 // then we see how many items down to redraw
1024 // next... figure out how many sublevels over the redrawspans 1023 int id_d = ((ee.y + ee.height) / theme()->itemHeight());
1025 sbl_d = ((ee.x + ee.width) / menu.item_w),
1026 // then we see how many items down to redraw
1027 id_d = ((ee.y + ee.height) / theme()->itemHeight());
1028 1024
1029 if (id_d > menu.persub) id_d = menu.persub; 1025 if (id_d > m_rows_per_column)
1030 // draw the sublevels and the number of items the exposure spans 1026 id_d = m_rows_per_column;
1027
1028 // draw the columns and the number of items the exposure spans
1031 int i, ii; 1029 int i, ii;
1032 for (i = sbl; i <= sbl_d; i++) { 1030 for (i = column; i <= column_d; i++) {
1033 // set the iterator to the first item in the sublevel needing redrawing 1031 // set the iterator to the first item in the column needing redrawing
1034 int index = id + i * menu.persub; 1032 int index = id + i * m_rows_per_column;
1035 1033
1036 if (index < static_cast<int>(menuitems.size()) && index >= 0) { 1034 if (index < static_cast<int>(menuitems.size()) && index >= 0) {
1037 Menuitems::iterator it = menuitems.begin() + index; 1035 Menuitems::iterator it = menuitems.begin() + index;
1038 Menuitems::iterator it_end = menuitems.end(); 1036 Menuitems::iterator it_end = menuitems.end();
1039 for (ii = id; ii <= id_d && it != it_end; ++it, ii++) { 1037 for (ii = id; ii <= id_d && it != it_end; ++it, ii++) {
1040 int index = ii + (i * menu.persub); 1038 int index = ii + (i * m_rows_per_column);
1041 // redraw the item 1039 // redraw the item
1042 clearItem(index); 1040 clearItem(index);
1043 } 1041 }
@@ -1065,10 +1063,10 @@ void Menu::keyPressEvent(XKeyEvent &event) {
1065 break; 1063 break;
1066 case XK_Left: // enter parent if we have one 1064 case XK_Left: // enter parent if we have one
1067 resetTypeAhead(); 1065 resetTypeAhead();
1068 if (menu.sublevels > 1 && m_active_index >= menu.persub) { 1066 if (m_columns > 1 && m_active_index >= m_rows_per_column) {
1069 int new_index = m_active_index - menu.persub; 1067 int new_index = m_active_index - m_rows_per_column;
1070 while (new_index >= 0 && !isItemEnabled(new_index)) 1068 while (new_index >= 0 && !isItemEnabled(new_index))
1071 new_index -= menu.persub; 1069 new_index -= m_rows_per_column;
1072 if (new_index >= 0) 1070 if (new_index >= 0)
1073 setActiveIndex(new_index); 1071 setActiveIndex(new_index);
1074 } else 1072 } else
@@ -1076,11 +1074,11 @@ void Menu::keyPressEvent(XKeyEvent &event) {
1076 break; 1074 break;
1077 case XK_Right: // enter submenu if we have one 1075 case XK_Right: // enter submenu if we have one
1078 resetTypeAhead(); 1076 resetTypeAhead();
1079 if (menu.sublevels > 1 && validIndex(m_active_index) && 1077 if (m_columns > 1 && validIndex(m_active_index) &&
1080 validIndex(m_active_index + menu.persub)) { 1078 validIndex(m_active_index + m_rows_per_column)) {
1081 int new_index = m_active_index + menu.persub; 1079 int new_index = m_active_index + m_rows_per_column;
1082 while (validIndex(new_index) && !isItemEnabled(new_index)) 1080 while (validIndex(new_index) && !isItemEnabled(new_index))
1083 new_index += menu.persub; 1081 new_index += m_rows_per_column;
1084 if (validIndex(new_index)) 1082 if (validIndex(new_index))
1085 setActiveIndex(new_index); 1083 setActiveIndex(new_index);
1086 } else 1084 } else
@@ -1094,8 +1092,8 @@ void Menu::keyPressEvent(XKeyEvent &event) {
1094 case XK_BackSpace: 1092 case XK_BackSpace:
1095 if (m_type_ahead.stringSize() == 0) { 1093 if (m_type_ahead.stringSize() == 0) {
1096 internal_hide(); 1094 internal_hide();
1097 break; 1095 break;
1098 } 1096 }
1099 1097
1100 m_type_ahead.putBackSpace(); 1098 m_type_ahead.putBackSpace();
1101 drawTypeAheadItems(); 1099 drawTypeAheadItems();
@@ -1157,23 +1155,23 @@ void Menu::reconfigure() {
1157 m_shape->setPlaces(theme()->shapePlaces()); 1155 m_shape->setPlaces(theme()->shapePlaces());
1158 1156
1159 if (FbTk::Transparent::haveComposite()) { 1157 if (FbTk::Transparent::haveComposite()) {
1160 menu.window.setOpaque(alpha()); 1158 m_window.setOpaque(alpha());
1161 menu.title.setAlpha(255); 1159 m_title.setAlpha(255);
1162 menu.frame.setAlpha(255); 1160 m_frame.setAlpha(255);
1163 } else { 1161 } else {
1164 menu.window.setOpaque(255); 1162 m_window.setOpaque(255);
1165 menu.title.setAlpha(alpha()); 1163 m_title.setAlpha(alpha());
1166 menu.frame.setAlpha(alpha()); 1164 m_frame.setAlpha(alpha());
1167 } 1165 }
1168 1166
1169 m_need_update = true; // redraw items 1167 m_need_update = true; // redraw items
1170 1168
1171 menu.window.setBorderColor(theme()->borderColor()); 1169 m_window.setBorderColor(theme()->borderColor());
1172 menu.title.setBorderColor(theme()->borderColor()); 1170 m_title.setBorderColor(theme()->borderColor());
1173 menu.frame.setBorderColor(theme()->borderColor()); 1171 m_frame.setBorderColor(theme()->borderColor());
1174 1172
1175 menu.window.setBorderWidth(theme()->borderWidth()); 1173 m_window.setBorderWidth(theme()->borderWidth());
1176 menu.title.setBorderWidth(theme()->borderWidth()); 1174 m_title.setBorderWidth(theme()->borderWidth());
1177 1175
1178 updateMenu(); 1176 updateMenu();
1179} 1177}
@@ -1237,9 +1235,9 @@ void Menu::setScreen(int x, int y, int w, int h) {
1237 1235
1238// Render the foreground objects of given window onto given pixmap 1236// Render the foreground objects of given window onto given pixmap
1239void Menu::renderForeground(FbWindow &win, FbDrawable &drawable) { 1237void Menu::renderForeground(FbWindow &win, FbDrawable &drawable) {
1240 if (&win == &menu.frame) { 1238 if (&win == &m_frame) {
1241 redrawFrame(drawable); 1239 redrawFrame(drawable);
1242 } else if (&win == &menu.title) { 1240 } else if (&win == &m_title) {
1243 redrawTitle(drawable); 1241 redrawTitle(drawable);
1244 } 1242 }
1245} 1243}
@@ -1252,9 +1250,12 @@ void Menu::clearItem(int index, bool clear, int search_index) {
1252 if (!validIndex(index)) 1250 if (!validIndex(index))
1253 return; 1251 return;
1254 1252
1255 int sbl = index / menu.persub, i = index - (sbl * menu.persub); 1253 int column = index / m_rows_per_column;
1256 unsigned int item_w = menu.item_w, item_h = theme()->itemHeight(); 1254 int row = index - (column * m_rows_per_column);
1257 int item_x = (sbl * item_w), item_y = (i * item_h); 1255 unsigned int item_w = m_item_w;
1256 unsigned int item_h = theme()->itemHeight();
1257 int item_x = (column * item_w);
1258 int item_y = (row * item_h);
1258 bool highlight = (index == m_active_index && isItemSelectable(index)); 1259 bool highlight = (index == m_active_index && isItemSelectable(index));
1259 1260
1260 if (search_index < 0) 1261 if (search_index < 0)
@@ -1269,12 +1270,12 @@ void Menu::clearItem(int index, bool clear, int search_index) {
1269 drawLine(index, m_type_ahead.stringSize()); 1270 drawLine(index, m_type_ahead.stringSize());
1270 return; 1271 return;
1271 } else if (clear) 1272 } else if (clear)
1272 menu.frame.clearArea(item_x, item_y, item_w, item_h); 1273 m_frame.clearArea(item_x, item_y, item_w, item_h);
1273 1274
1274 MenuItem *item = menuitems[index]; 1275 MenuItem *item = menuitems[index];
1275 if (! item) return; 1276 if (! item) return;
1276 1277
1277 item->draw(menu.frame, theme(), highlight, 1278 item->draw(m_frame, theme(), highlight,
1278 true, false, item_x, item_y, 1279 true, false, item_x, item_y,
1279 item_w, item_h); 1280 item_w, item_h);
1280 1281
@@ -1284,14 +1285,17 @@ void Menu::clearItem(int index, bool clear, int search_index) {
1284 1285
1285// Area must have been cleared before calling highlight 1286// Area must have been cleared before calling highlight
1286void Menu::highlightItem(int index) { 1287void Menu::highlightItem(int index) {
1287 int sbl = index / menu.persub, i = index - (sbl * menu.persub); 1288 int column = index / m_rows_per_column;
1288 unsigned int item_w = menu.item_w, item_h = theme()->itemHeight(); 1289 int row = index - (column * m_rows_per_column);
1289 int item_x = (sbl * menu.item_w), item_y = (i * item_h); 1290 unsigned int item_w = m_item_w;
1291 unsigned int item_h = theme()->itemHeight();
1292 int item_x = (column * m_item_w);
1293 int item_y = (row * item_h);
1290 1294
1291 FbPixmap buffer = FbPixmap(menu.frame, item_w, item_h, menu.frame.depth()); 1295 FbPixmap buffer = FbPixmap(m_frame, item_w, item_h, m_frame.depth());
1292 1296
1293 bool parent_rel = menu.hilite_pixmap == ParentRelative; 1297 bool parent_rel = m_hilite_pixmap == ParentRelative;
1294 Pixmap pixmap = parent_rel ? menu.frame_pixmap : menu.hilite_pixmap; 1298 Pixmap pixmap = parent_rel ? m_frame_pixmap : m_hilite_pixmap;
1295 int pixmap_x = parent_rel ? item_x : 0, pixmap_y = parent_rel ? item_y : 0; 1299 int pixmap_x = parent_rel ? item_x : 0, pixmap_y = parent_rel ? item_y : 0;
1296 if (pixmap) { 1300 if (pixmap) {
1297 buffer.copyArea(pixmap, 1301 buffer.copyArea(pixmap,
@@ -1302,11 +1306,11 @@ void Menu::highlightItem(int index) {
1302 buffer.fillRectangle(theme()->hiliteGC().gc(), 1306 buffer.fillRectangle(theme()->hiliteGC().gc(),
1303 0, 0, item_w, item_h); 1307 0, 0, item_w, item_h);
1304 } 1308 }
1305 menu.frame.updateTransparent(item_x, item_y, item_w, item_h, buffer.drawable(), true); 1309 m_frame.updateTransparent(item_x, item_y, item_w, item_h, buffer.drawable(), true);
1306 1310
1307 drawItem(buffer, index, true, true); 1311 drawItem(buffer, index, true, true);
1308 1312
1309 menu.frame.copyArea(buffer.drawable(), theme()->hiliteGC().gc(), 1313 m_frame.copyArea(buffer.drawable(), theme()->hiliteGC().gc(),
1310 0, 0, 1314 0, 0,
1311 item_x, item_y, 1315 item_x, item_y,
1312 item_w, item_h); 1316 item_w, item_h);
@@ -1338,11 +1342,13 @@ void Menu::drawLine(int index, int size){
1338 if (!validIndex(index)) 1342 if (!validIndex(index))
1339 return; 1343 return;
1340 1344
1341 int sbl = index / menu.persub, i = index - (sbl * menu.persub); 1345 int column = index / m_rows_per_column;
1342 int item_x = (sbl * menu.item_w), item_y = (i * theme()->itemHeight()); 1346 int row = index - (column * m_rows_per_column);
1347 int item_x = (column * m_item_w);
1348 int item_y = (row * theme()->itemHeight());
1343 1349
1344 FbTk::MenuItem *item = find(index); 1350 FbTk::MenuItem *item = find(index);
1345 item->drawLine(menu.frame, theme(), size, item_x, item_y, menu.item_w); 1351 item->drawLine(m_frame, theme(), size, item_x, item_y, m_item_w);
1346} 1352}
1347 1353
1348void Menu::hideShownMenu() { 1354void Menu::hideShownMenu() {
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh
index a7bb982..161a4ac 100644
--- a/src/FbTk/Menu.hh
+++ b/src/FbTk/Menu.hh
@@ -114,7 +114,7 @@ public:
114 virtual void updateMenu(); 114 virtual void updateMenu();
115 void setItemSelected(unsigned int index, bool val); 115 void setItemSelected(unsigned int index, bool val);
116 void setItemEnabled(unsigned int index, bool val); 116 void setItemEnabled(unsigned int index, bool val);
117 void setMinimumSublevels(int m) { menu.minsub = m; } 117 void setMinimumColumns(int columns) { m_min_columns = columns; }
118 virtual void drawSubmenu(unsigned int index); 118 virtual void drawSubmenu(unsigned int index);
119 /// show menu 119 /// show menu
120 virtual void show(); 120 virtual void show();
@@ -130,17 +130,17 @@ public:
130 bool isTorn() const { return m_torn; } 130 bool isTorn() const { return m_torn; }
131 bool isVisible() const { return m_visible; } 131 bool isVisible() const { return m_visible; }
132 bool isMoving() const { return m_moving; } 132 bool isMoving() const { return m_moving; }
133 int screenNumber() const { return menu.window.screenNumber(); } 133 int screenNumber() const { return m_window.screenNumber(); }
134 Window window() const { return menu.window.window(); } 134 Window window() const { return m_window.window(); }
135 FbWindow &fbwindow() { return menu.window; } 135 FbWindow &fbwindow() { return m_window; }
136 const FbWindow &fbwindow() const { return menu.window; } 136 const FbWindow &fbwindow() const { return m_window; }
137 FbWindow &titleWindow() { return menu.title; } 137 FbWindow &titleWindow() { return m_title; }
138 FbWindow &frameWindow() { return menu.frame; } 138 FbWindow &frameWindow() { return m_frame; }
139 const FbTk::BiDiString &label() const { return menu.label; } 139 const FbTk::BiDiString &label() const { return m_label; }
140 int x() const { return menu.window.x(); } 140 int x() const { return m_window.x(); }
141 int y() const { return menu.window.y(); } 141 int y() const { return m_window.y(); }
142 unsigned int width() const { return menu.window.width(); } 142 unsigned int width() const { return m_window.width(); }
143 unsigned int height() const { return menu.window.height(); } 143 unsigned int height() const { return m_window.height(); }
144 size_t numberOfItems() const { return menuitems.size(); } 144 size_t numberOfItems() const { return menuitems.size(); }
145 int currentSubmenu() const { return m_which_sub; } 145 int currentSubmenu() const { return m_which_sub; }
146 146
@@ -221,18 +221,37 @@ private:
221 int m_which_sub; 221 int m_which_sub;
222 Alignment m_alignment; 222 Alignment m_alignment;
223 223
224 struct _menu { 224 // the menu window
225 Pixmap frame_pixmap, title_pixmap, hilite_pixmap; 225 FbTk::FbWindow m_window;
226 FbTk::FbWindow window, frame, title; 226 Pixmap m_hilite_pixmap;
227 227
228 FbTk::BiDiString label; 228 // the title
229 int x_move, y_move, sublevels, persub, minsub, grab_x, grab_y; 229 FbTk::FbWindow m_title;
230 Pixmap m_title_pixmap;
231 FbTk::BiDiString m_label;
230 232
231 unsigned int frame_h, item_w; 233 // area for the menuitems
232 } menu; 234 FbTk::FbWindow m_frame;
235 Pixmap m_frame_pixmap;
236 unsigned int m_frame_h;
237
238 int m_x_move;
239 int m_y_move;
240 int m_grab_x;
241 int m_grab_y;
242
243 // the menuitems are rendered in a grid with
244 // 'm_columns' (a minimum of 'm_min_columns') and
245 // a max of 'm_rows_per_column'
246 int m_columns;
247 int m_rows_per_column;
248 int m_min_columns;
249
250 unsigned int m_item_w;
233 251
234 int m_active_index; ///< current highlighted index 252 int m_active_index; ///< current highlighted index
235 253
254 // the corners
236 std::auto_ptr<FbTk::Shape> m_shape; 255 std::auto_ptr<FbTk::Shape> m_shape;
237 256
238 Drawable m_root_pm; 257 Drawable m_root_pm;
diff --git a/src/Screen.cc b/src/Screen.cc
index 9bf9711..1f53edc 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -1647,7 +1647,7 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
1647 { _FB_XTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), FbWinFrame::BOTTOMRIGHT} 1647 { _FB_XTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), FbWinFrame::BOTTOMRIGHT}
1648 }; 1648 };
1649 1649
1650 tabplacement_menu->setMinimumSublevels(3); 1650 tabplacement_menu->setMinimumColumns(3);
1651 // create items in sub menu 1651 // create items in sub menu
1652 for (size_t i=0; i< sizeof(place_menu)/sizeof(PlacementP); ++i) { 1652 for (size_t i=0; i< sizeof(place_menu)/sizeof(PlacementP); ++i) {
1653 const PlacementP& p = place_menu[i]; 1653 const PlacementP& p = place_menu[i];
diff --git a/src/Slit.cc b/src/Slit.cc
index acbd922..bdd1a28 100644
--- a/src/Slit.cc
+++ b/src/Slit.cc
@@ -1241,7 +1241,7 @@ void Slit::setupMenu() {
1241 1241
1242 // setup sub menu 1242 // setup sub menu
1243 placement_menu->setLabel(_FB_XTEXT(Slit, Placement, "Slit Placement", "Slit Placement")); 1243 placement_menu->setLabel(_FB_XTEXT(Slit, Placement, "Slit Placement", "Slit Placement"));
1244 placement_menu->setMinimumSublevels(3); 1244 placement_menu->setMinimumColumns(3);
1245 m_layermenu->setInternalMenu(); 1245 m_layermenu->setInternalMenu();
1246 m_clientlist_menu.setInternalMenu(); 1246 m_clientlist_menu.setInternalMenu();
1247 m_slitmenu.setInternalMenu(); 1247 m_slitmenu.setInternalMenu();