aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-12-18 18:03:23 (GMT)
committerfluxgen <fluxgen>2003-12-18 18:03:23 (GMT)
commitbb02a522fbc7c47ebd1ddacafd466ccf59e58915 (patch)
treeb55b5d4ae07eaf0794cb6e9b97b478cded7413e1 /src/FbTk
parent8735c6a08bdab11172ec6e4c35271a4b8c374fc7 (diff)
downloadfluxbox-bb02a522fbc7c47ebd1ddacafd466ccf59e58915.zip
fluxbox-bb02a522fbc7c47ebd1ddacafd466ccf59e58915.tar.bz2
code cleaning
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/Menu.cc79
-rw-r--r--src/FbTk/Menu.hh8
2 files changed, 41 insertions, 46 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index bb0b352..47dd372 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.50 2003/12/17 00:43:22 fluxgen Exp $ 25// $Id: Menu.cc,v 1.51 2003/12/18 18:03:23 fluxgen Exp $
26 26
27//use GNU extensions 27//use GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -89,9 +89,9 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl):
89 torn = 89 torn =
90 visible = false; 90 visible = false;
91 91
92 menu.x = 92
93 menu.y = 93
94 menu.x_shift = 94 menu.x_shift =
95 menu.y_shift = 95 menu.y_shift =
96 menu.x_move = 96 menu.x_move =
97 menu.y_move = 0; 97 menu.y_move = 0;
@@ -600,8 +600,6 @@ void Menu::internal_hide() {
600 600
601void Menu::move(int x, int y) { 601void Menu::move(int x, int y) {
602 602
603 menu.x = x;
604 menu.y = y;
605 menu.window.move(x, y); 603 menu.window.move(x, y);
606 604
607 if (which_sub != -1) 605 if (which_sub != -1)
@@ -663,47 +661,47 @@ void Menu::drawSubmenu(unsigned int index) {
663 if (item->submenu()->m_parent != this) 661 if (item->submenu()->m_parent != this)
664 item->submenu()->m_parent = this; 662 item->submenu()->m_parent = this;
665 663
666 int sbl = index / menu.persub, i = index - (sbl * menu.persub), 664 int sbl = index / menu.persub, i = index - (sbl * menu.persub);
667 x = menu.x + 665 int new_x = x() + ((menu.item_w * (sbl + 1)) + menu.window.borderWidth());
668 ((menu.item_w * (sbl + 1)) + menu.window.borderWidth()), y; 666 int new_y;
669 667
670 if (m_alignment == ALIGNTOP) { 668 if (m_alignment == ALIGNTOP) {
671 y = (((shifted) ? menu.y_shift : menu.y) + 669 new_y = (((shifted) ? menu.y_shift : y()) +
672 ((title_vis) ? menu.title_h + menu.title.borderWidth() : 0) - 670 ((title_vis) ? menu.title_h + menu.title.borderWidth() : 0) -
673 ((item->submenu()->title_vis) ? 671 ((item->submenu()->title_vis) ?
674 item->submenu()->menu.title_h + menu.window.borderWidth() : 0)); 672 item->submenu()->menu.title_h + menu.window.borderWidth() : 0));
675 } else { 673 } else {
676 y = (((shifted) ? menu.y_shift : menu.y) + 674 new_y = (((shifted) ? menu.y_shift : y()) +
677 (menu.item_h * i) + 675 (menu.item_h * i) +
678 ((title_vis) ? menu.title_h + menu.window.borderWidth() : 0) - 676 ((title_vis) ? menu.title_h + menu.window.borderWidth() : 0) -
679 ((item->submenu()->title_vis) ? 677 ((item->submenu()->title_vis) ?
680 item->submenu()->menu.title_h + menu.window.borderWidth() : 0)); 678 item->submenu()->menu.title_h + menu.window.borderWidth() : 0));
681 } 679 }
682 680
683 if (m_alignment == ALIGNBOTTOM && 681 if (m_alignment == ALIGNBOTTOM &&
684 (y + item->submenu()->height()) > ((shifted) ? menu.y_shift : 682 (new_y + item->submenu()->height()) > ((shifted) ? menu.y_shift :
685 menu.y) + height()) { 683 y()) + height()) {
686 y = (((shifted) ? menu.y_shift : menu.y) + 684 new_y = (((shifted) ? menu.y_shift : y()) +
687 height() - item->submenu()->height()); 685 height() - item->submenu()->height());
688 } 686 }
689 687
690 if ((x + item->submenu()->width()) > m_screen_width) { 688 if ((new_x + item->submenu()->width()) > m_screen_width) {
691 x = ((shifted) ? menu.x_shift : menu.x) - 689 new_x = ((shifted) ? menu.x_shift : x()) -
692 item->submenu()->width() - menu.window.borderWidth(); 690 item->submenu()->width() - menu.window.borderWidth();
693 } 691 }
694 692
695 if (x < 0) 693 if (new_x < 0)
696 x = 0; 694 new_x = 0;
697 695
698 if ((y + item->submenu()->height()) > m_screen_height) { 696 if ((new_y + item->submenu()->height()) > m_screen_height) {
699 y = m_screen_height - item->submenu()->height() - 697 new_y = m_screen_height - item->submenu()->height() -
700 menu.window.borderWidth() * 2; 698 menu.window.borderWidth() * 2;
701 } 699 }
702 700
703 if (y < 0) 701 if (new_y < 0)
704 y = 0; 702 new_y = 0;
705 703
706 item->submenu()->move(x, y); 704 item->submenu()->move(new_x, new_y);
707 if (! moving) 705 if (! moving)
708 drawItem(index, true); 706 drawItem(index, true);
709 707
@@ -1068,8 +1066,8 @@ void Menu::buttonPressEvent(XButtonEvent &be) {
1068 drawItem(w, item->isEnabled(), true, true); 1066 drawItem(w, item->isEnabled(), true, true);
1069 } 1067 }
1070 } else { 1068 } else {
1071 menu.x_move = be.x_root - menu.x; 1069 menu.x_move = be.x_root - x();
1072 menu.y_move = be.y_root - menu.y; 1070 menu.y_move = be.y_root - y();
1073 } 1071 }
1074} 1072}
1075 1073
@@ -1133,10 +1131,7 @@ void Menu::motionNotifyEvent(XMotionEvent &me) {
1133 if (which_sub >= 0) 1131 if (which_sub >= 0)
1134 drawSubmenu(which_sub); 1132 drawSubmenu(which_sub);
1135 } else { 1133 } else {
1136 menu.x = me.x_root - menu.x_move, 1134 menu.window.move(me.x_root - menu.x_move, me.y_root - menu.y_move);
1137 menu.y = me.y_root - menu.y_move;
1138
1139 menu.window.move(menu.x, menu.y);
1140 1135
1141 // if (which_sub >= 0) 1136 // if (which_sub >= 0)
1142 // drawSubmenu(which_sub); 1137 // drawSubmenu(which_sub);
@@ -1245,19 +1240,19 @@ void Menu::enterNotifyEvent(XCrossingEvent &ce) {
1245 if (menu.frame != ce.window) 1240 if (menu.frame != ce.window)
1246 return; 1241 return;
1247 1242
1248 menu.x_shift = menu.x, menu.y_shift = menu.y; 1243 menu.x_shift = x(), menu.y_shift = y();
1249 if (menu.x + width() > m_screen_width) { 1244 if (x() + width() > m_screen_width) {
1250 menu.x_shift = m_screen_width - width() - 2*m_border_width; 1245 menu.x_shift = m_screen_width - width() - 2*m_border_width;
1251 shifted = true; 1246 shifted = true;
1252 } else if (menu.x < 0) { 1247 } else if (x() < 0) {
1253 menu.x_shift = 0; //-m_border_width; 1248 menu.x_shift = 0; //-m_border_width;
1254 shifted = true; 1249 shifted = true;
1255 } 1250 }
1256 1251
1257 if (menu.y + height() + 2*m_border_width > m_screen_height) { 1252 if (y() + height() + 2*m_border_width > m_screen_height) {
1258 menu.y_shift = m_screen_height - height() - 2*m_border_width; 1253 menu.y_shift = m_screen_height - height() - 2*m_border_width;
1259 shifted = true; 1254 shifted = true;
1260 } else if (menu.y + (signed) menu.title_h < 0) { 1255 } else if (y() + (signed) menu.title_h < 0) {
1261 menu.y_shift = 0; // -m_border_width;; 1256 menu.y_shift = 0; // -m_border_width;;
1262 shifted = true; 1257 shifted = true;
1263 } 1258 }
@@ -1295,7 +1290,7 @@ void Menu::leaveNotifyEvent(XCrossingEvent &ce) {
1295 } 1290 }
1296 1291
1297 if (shifted) { 1292 if (shifted) {
1298 menu.window.move(menu.x, menu.y); 1293 // menu.window.move(menu.x, menu.y);
1299 shifted = false; 1294 shifted = false;
1300 } 1295 }
1301} 1296}
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh
index d1c6c6e..7c8b6ef 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.28 2003/12/17 00:43:22 fluxgen Exp $ 25// $Id: Menu.hh,v 1.29 2003/12/18 18:03:23 fluxgen Exp $
26 26
27#ifndef FBTK_MENU_HH 27#ifndef FBTK_MENU_HH
28#define FBTK_MENU_HH 28#define FBTK_MENU_HH
@@ -140,8 +140,8 @@ public:
140 inline FbWindow &titleWindow() { return menu.title; } 140 inline FbWindow &titleWindow() { return menu.title; }
141 inline FbWindow &frameWindow() { return menu.frame; } 141 inline FbWindow &frameWindow() { return menu.frame; }
142 inline const std::string &label() const { return menu.label; } 142 inline const std::string &label() const { return menu.label; }
143 inline int x() const { return menu.x; } 143 inline int x() const { return menu.window.x(); }
144 inline int y() const { return menu.y; } 144 inline int y() const { return menu.window.y(); }
145 inline unsigned int width() const { return menu.window.width(); } 145 inline unsigned int width() const { return menu.window.width(); }
146 inline unsigned int height() const { return menu.window.height(); } 146 inline unsigned int height() const { return menu.window.height(); }
147 inline unsigned int numberOfItems() const { return menuitems.size(); } 147 inline unsigned int numberOfItems() const { return menuitems.size(); }
@@ -203,7 +203,7 @@ private:
203 FbTk::FbWindow window, frame, title; 203 FbTk::FbWindow window, frame, title;
204 204
205 std::string label; 205 std::string label;
206 int x, y, x_move, y_move, x_shift, y_shift, sublevels, persub, minsub, 206 int x_move, y_move, x_shift, y_shift, sublevels, persub, minsub,
207 grab_x, grab_y; 207 grab_x, grab_y;
208 unsigned int title_h, frame_h, item_w, item_h, bevel_w, 208 unsigned int title_h, frame_h, item_w, item_h, bevel_w,
209 bevel_h; 209 bevel_h;