summaryrefslogtreecommitdiff
path: root/src/Basemenu.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Basemenu.cc')
-rw-r--r--src/Basemenu.cc68
1 files changed, 35 insertions, 33 deletions
diff --git a/src/Basemenu.cc b/src/Basemenu.cc
index 713b2f7..559bb97 100644
--- a/src/Basemenu.cc
+++ b/src/Basemenu.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: Basemenu.cc,v 1.12 2002/03/19 14:30:42 fluxgen Exp $ 25// $Id: Basemenu.cc,v 1.13 2002/03/20 14:10:03 fluxgen Exp $
26 26
27// stupid macros needed to access some functions in version 2 of the GNU C 27// stupid macros needed to access some functions in version 2 of the GNU C
28// library 28// library
@@ -236,8 +236,8 @@ int Basemenu::insert(const char **ulabel, int pos, int function) {
236} 236}
237 237
238 238
239int Basemenu::remove(int index) { 239int Basemenu::remove(unsigned int index) {
240 if (index < 0 || index >= menuitems.size()) { 240 if (index >= menuitems.size()) {
241 #ifdef DEBUG 241 #ifdef DEBUG
242 std::cout << "Bad index (" << index << ") given to Basemenu::remove()" 242 std::cout << "Bad index (" << index << ") given to Basemenu::remove()"
243 << " -- should be between 0 and " << menuitems.size()-1 243 << " -- should be between 0 and " << menuitems.size()-1
@@ -264,9 +264,9 @@ int Basemenu::remove(int index) {
264 delete item; 264 delete item;
265 } 265 }
266 266
267 if (which_sub == index) 267 if (static_cast<unsigned int>(which_sub) == index)
268 which_sub = -1; 268 which_sub = -1;
269 else if (which_sub > index) 269 else if (static_cast<unsigned int>(which_sub) > index)
270 which_sub--; 270 which_sub--;
271 271
272 return menuitems.size(); 272 return menuitems.size();
@@ -426,13 +426,14 @@ void Basemenu::update(void) {
426 426
427 if (title_vis && visible) redrawTitle(); 427 if (title_vis && visible) redrawTitle();
428 428
429 int i = 0; 429 unsigned int i = 0;
430 for (i = 0; visible && i < menuitems.size(); i++) 430 for (i = 0; visible && i < menuitems.size(); i++) {
431 if (i == which_sub) { 431 if (i == (unsigned int)which_sub) {
432 drawItem(i, True, 0); 432 drawItem(i, True, 0);
433 drawSubmenu(i); 433 drawSubmenu(i);
434 } else 434 } else
435 drawItem(i, False, 0); 435 drawItem(i, False, 0);
436 }
436 437
437 if (parent && visible) 438 if (parent && visible)
438 parent->drawSubmenu(parent->which_sub); 439 parent->drawSubmenu(parent->which_sub);
@@ -541,15 +542,16 @@ void Basemenu::redrawTitle(void) {
541} 542}
542 543
543 544
544void Basemenu::drawSubmenu(int index) { 545void Basemenu::drawSubmenu(unsigned int index) {
545 if (which_sub >= 0 && which_sub != index) { 546 if (which_sub >= 0 && static_cast<unsigned int>(which_sub) != index &&
547 static_cast<unsigned int>(which_sub) < menuitems.size()) {
546 BasemenuItem *itmp = menuitems[which_sub]; 548 BasemenuItem *itmp = menuitems[which_sub];
547 549
548 if (! itmp->submenu()->isTorn()) 550 if (! itmp->submenu()->isTorn())
549 itmp->submenu()->internal_hide(); 551 itmp->submenu()->internal_hide();
550 } 552 }
551 553
552 if (index >= 0 && index < menuitems.size()) { 554 if (index < menuitems.size()) {
553 BasemenuItem *item = menuitems[index]; 555 BasemenuItem *item = menuitems[index];
554 if (item->submenu() && visible && (! item->submenu()->isTorn()) && 556 if (item->submenu() && visible && (! item->submenu()->isTorn()) &&
555 item->isEnabled()) { 557 item->isEnabled()) {
@@ -648,26 +650,26 @@ void Basemenu::drawSubmenu(int index) {
648} 650}
649 651
650 652
651Bool Basemenu::hasSubmenu(int index) { 653bool Basemenu::hasSubmenu(unsigned int index) {
652 if ((index >= 0) && (index < menuitems.size())) 654 if (index < menuitems.size())
653 if (menuitems[index]->submenu()) 655 if (menuitems[index]->submenu())
654 return True; 656 return true;
655 else 657 else
656 return False; 658 return false;
657 else 659 else
658 return False; 660 return false;
659} 661}
660 662
661 663
662void Basemenu::drawItem(int index, Bool highlight, Bool clear, 664void Basemenu::drawItem(unsigned int index, bool highlight, bool clear,
663 int x, int y, unsigned int w, unsigned int h) 665 int x, int y, unsigned int w, unsigned int h)
664{ 666{
665 if (index < 0 || index > menuitems.size()) return; 667 if (index >= menuitems.size()) return;
666 668
667 BasemenuItem *item = menuitems[index]; 669 BasemenuItem *item = menuitems[index];
668 if (! item) return; 670 if (! item) return;
669 671
670 Bool dotext = True, dohilite = True, dosel = True; 672 bool dotext = true, dohilite = true, dosel = true;
671 const char *text = item->label(); 673 const char *text = item->label();
672 int sbl = index / menu.persub, i = index - (sbl * menu.persub); 674 int sbl = index / menu.persub, i = index - (sbl * menu.persub);
673 int item_x = (sbl * menu.item_w), item_y = (i * menu.item_h); 675 int item_x = (sbl * menu.item_w), item_y = (i * menu.item_h);
@@ -843,39 +845,39 @@ void Basemenu::setLabel(const char *l) {
843} 845}
844 846
845 847
846void Basemenu::setItemSelected(int index, Bool sel) { 848void Basemenu::setItemSelected(unsigned int index, bool sel) {
847 if (index < 0 || index >= menuitems.size()) return; 849 if (index >= menuitems.size()) return;
848 850
849 BasemenuItem *item = find(index); 851 BasemenuItem *item = find(index);
850 if (! item) return; 852 if (! item) return;
851 853
852 item->setSelected(sel); 854 item->setSelected(sel);
853 if (visible) drawItem(index, (index == which_sub), True); 855 if (visible) drawItem(index, (index == (unsigned int)which_sub), true);
854} 856}
855 857
856 858
857Bool Basemenu::isItemSelected(int index) { 859bool Basemenu::isItemSelected(unsigned int index) {
858 if (index < 0 || index >= menuitems.size()) return False; 860 if (index >= menuitems.size()) return false;
859 861
860 BasemenuItem *item = find(index); 862 BasemenuItem *item = find(index);
861 if (! item) return False; 863 if (! item) return false;
862 864
863 return item->isSelected(); 865 return item->isSelected();
864} 866}
865 867
866 868
867void Basemenu::setItemEnabled(int index, Bool enable) { 869void Basemenu::setItemEnabled(unsigned int index, bool enable) {
868 if (index < 0 || index >= menuitems.size()) return; 870 if (index >= menuitems.size()) return;
869 871
870 BasemenuItem *item = find(index); 872 BasemenuItem *item = find(index);
871 if (! item) return; 873 if (! item) return;
872 874
873 item->setEnabled(enable); 875 item->setEnabled(enable);
874 if (visible) drawItem(index, (index == which_sub), True); 876 if (visible) drawItem(index, (index == static_cast<unsigned int>(which_sub)), True);
875} 877}
876 878
877 879
878Bool Basemenu::isItemEnabled(int index) { 880bool Basemenu::isItemEnabled(unsigned int index) {
879 if (index < 0 || index >= menuitems.size()) return False; 881 if (index < 0 || index >= menuitems.size()) return False;
880 882
881 BasemenuItem *item = find(index); 883 BasemenuItem *item = find(index);
@@ -890,7 +892,7 @@ void Basemenu::buttonPressEvent(XButtonEvent *be) {
890 int sbl = (be->x / menu.item_w), i = (be->y / menu.item_h); 892 int sbl = (be->x / menu.item_w), i = (be->y / menu.item_h);
891 int w = (sbl * menu.persub) + i; 893 int w = (sbl * menu.persub) + i;
892 894
893 if (w < menuitems.size() && w >= 0) { 895 if (w < static_cast<int>(menuitems.size()) && w >= 0) {
894 which_press = i; 896 which_press = i;
895 which_sbl = sbl; 897 which_sbl = sbl;
896 898
@@ -933,7 +935,7 @@ void Basemenu::buttonReleaseEvent(XButtonEvent *re) {
933 w = (sbl * menu.persub) + i, 935 w = (sbl * menu.persub) + i,
934 p = (which_sbl * menu.persub) + which_press; 936 p = (which_sbl * menu.persub) + which_press;
935 937
936 if (w < menuitems.size() && w >= 0) { 938 if (w < static_cast<int>(menuitems.size()) && w >= 0) {
937 drawItem(p, (p == which_sub), True); 939 drawItem(p, (p == which_sub), True);
938 940
939 if (p == w && isItemEnabled(w)) { 941 if (p == w && isItemEnabled(w)) {
@@ -979,7 +981,7 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) {
979 w = (sbl * menu.persub) + i; 981 w = (sbl * menu.persub) + i;
980 982
981 if ((i != which_press || sbl != which_sbl) && 983 if ((i != which_press || sbl != which_sbl) &&
982 (w < menuitems.size() && w >= 0)) { 984 (w < static_cast<int>(menuitems.size()) && w >= 0)) {
983 if (which_press != -1 && which_sbl != -1) { 985 if (which_press != -1 && which_sbl != -1) {
984 int p = (which_sbl * menu.persub) + which_press; 986 int p = (which_sbl * menu.persub) + which_press;
985 BasemenuItem *item = menuitems[p]; 987 BasemenuItem *item = menuitems[p];
@@ -1029,7 +1031,7 @@ void Basemenu::exposeEvent(XExposeEvent *ee) {
1029 for (i = sbl; i <= sbl_d; i++) { 1031 for (i = sbl; i <= sbl_d; i++) {
1030 // set the iterator to the first item in the sublevel needing redrawing 1032 // set the iterator to the first item in the sublevel needing redrawing
1031 int index = id + i * menu.persub; 1033 int index = id + i * menu.persub;
1032 if (index < menuitems.size() && index >= 0) { 1034 if (index < static_cast<int>(menuitems.size()) && index >= 0) {
1033 Menuitems::iterator it = menuitems.begin() + index; 1035 Menuitems::iterator it = menuitems.begin() + index;
1034 Menuitems::iterator it_end = menuitems.end(); 1036 Menuitems::iterator it_end = menuitems.end();
1035 for (ii = id; ii <= id_d && it != it_end; ++it, ii++) { 1037 for (ii = id; ii <= id_d && it != it_end; ++it, ii++) {