]> Dogcows Code - chaz/openbox/blobdiff - src/Basemenu.cc
refix i18n for --disable-nls
[chaz/openbox] / src / Basemenu.cc
index ef6cf4d5f7e786acfea3b06999ed5097a1ed4256..c3052826262ede5148b1b881fbb04913757d5b73 100644 (file)
 #  include <stdio.h>
 #endif // HAVE_STDIO_H
 
-#ifdef    STDC_HEADERS
+#ifdef    HAVE_STDLIB_H
 #  include <stdlib.h>
+#endif // HAVE_STDLIB_H
+
+#ifdef    HAVE_STRING_H
 #  include <string.h>
-#endif // STDC_HEADERS
+#endif // HAVE_STRING_H
 
 #include <algorithm>
-using namespace std;
+using std::min;
+using std::max;
 
 #include "i18n.h"
 #include "openbox.h"
@@ -83,46 +87,46 @@ Basemenu::Basemenu(BScreen &scrn) : openbox(scrn.getOpenbox()), screen(scrn) {
 
   menu.bevel_w = screen.getBevelWidth();
 
-  if (i18n->multibyte())
+  if (i18n.multibyte())
     menu.width = menu.title_h = menu.item_w = menu.frame_h =
       screen.getMenuStyle()->t_fontset_extents->max_ink_extent.height +
-       (menu.bevel_w  * 2);
+      (menu.bevel_w  * 2);
   else
     menu.width = menu.title_h = menu.item_w = menu.frame_h =
       screen.getMenuStyle()->t_font->ascent +
-        screen.getMenuStyle()->t_font->descent + (menu.bevel_w * 2);
-  
+      screen.getMenuStyle()->t_font->descent + (menu.bevel_w * 2);
+
   menu.label = 0;
-  
+
   menu.sublevels =
     menu.persub =
     menu.minsub = 0;
-  
+
   MenuStyle *style = screen.getMenuStyle();
-  if (i18n->multibyte()) {
+  if (i18n.multibyte()) {
     menu.item_h = style->f_fontset_extents->max_ink_extent.height +
       (menu.bevel_w);
   } else {
     menu.item_h = style->f_font->ascent + style->f_font->descent +
-                 (menu.bevel_w);
+      (menu.bevel_w);
   }
-  
+
   menu.height = menu.title_h + screen.getBorderWidth() + menu.frame_h;
-  
+
   unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel |
-                             CWColormap | CWOverrideRedirect | CWEventMask;
+    CWColormap | CWOverrideRedirect | CWEventMask;
   XSetWindowAttributes attrib;
   attrib.background_pixmap = None;
   attrib.background_pixel = attrib.border_pixel =
-                           screen.getBorderColor()->getPixel();
+    screen.getBorderColor()->getPixel();
   attrib.colormap = screen.getColormap();
   attrib.override_redirect = True;
   attrib.event_mask = ButtonPressMask | ButtonReleaseMask |
-                      ButtonMotionMask | ExposureMask;
+    ButtonMotionMask | ExposureMask;
 
   menu.window =
     XCreateWindow(display, screen.getRootWindow(), menu.x, menu.y, menu.width,
-                 menu.height, screen.getBorderWidth(), screen.getDepth(),
+                  menu.height, screen.getBorderWidth(), screen.getDepth(),
                   InputOutput, screen.getVisual(), attrib_mask, &attrib);
   openbox.saveMenuSearch(menu.window, this);
 
@@ -132,20 +136,18 @@ Basemenu::Basemenu(BScreen &scrn) : openbox(scrn.getOpenbox()), screen(scrn) {
 
   menu.title =
     XCreateWindow(display, menu.window, 0, 0, menu.width, menu.height, 0,
-                 screen.getDepth(), InputOutput, screen.getVisual(),
-                 attrib_mask, &attrib);
+                  screen.getDepth(), InputOutput, screen.getVisual(),
+                  attrib_mask, &attrib);
   openbox.saveMenuSearch(menu.title, this);
 
   attrib.event_mask |= PointerMotionMask;
   menu.frame = XCreateWindow(display, menu.window, 0,
-                            menu.title_h + screen.getBorderWidth(),
-                            menu.width, menu.frame_h, 0,
-                            screen.getDepth(), InputOutput,
-                            screen.getVisual(), attrib_mask, &attrib);
+                             menu.title_h + screen.getBorderWidth(),
+                             menu.width, menu.frame_h, 0,
+                             screen.getDepth(), InputOutput,
+                             screen.getVisual(), attrib_mask, &attrib);
   openbox.saveMenuSearch(menu.frame, this);
 
-  menuitems = new LinkedList<BasemenuItem>;
-
   // even though this is the end of the constructor the menu is still not
   // completely created.  items must be inserted and it must be update()'d
 }
@@ -157,12 +159,9 @@ Basemenu::~Basemenu(void) {
   if (shown && shown->getWindowID() == getWindowID())
     shown = (Basemenu *) 0;
 
-  int n = menuitems->count();
-  for (int i = 0; i < n; ++i)
+  while (!menuitems.empty())
     remove(0);
 
-  delete menuitems;
-
   if (menu.label)
     delete [] menu.label;
 
@@ -196,9 +195,12 @@ int Basemenu::insert(const char *l, int function, const char *e, int pos) {
   if (e) exec = bstrdup(e);
 
   BasemenuItem *item = new BasemenuItem(label, function, exec);
-  menuitems->insert(item, pos);
+  if (pos == -1)
+    menuitems.push_back(item);
+  else
+    menuitems.insert(menuitems.begin() + pos, item);
 
-  return menuitems->count();
+  return menuitems.size();
 }
 
 
@@ -208,41 +210,48 @@ int Basemenu::insert(const char *l, Basemenu *submenu, int pos) {
   if (l) label = bstrdup(l);
 
   BasemenuItem *item = new BasemenuItem(label, submenu);
-  menuitems->insert(item, pos);
+  if (pos == -1)
+    menuitems.push_back(item);
+  else
+    menuitems.insert(menuitems.begin() + pos, item);
 
   submenu->parent = this;
 
-  return menuitems->count();
+  return menuitems.size();
 }
 
 
 int Basemenu::insert(const char **ulabel, int pos, int function) {
   BasemenuItem *item = new BasemenuItem(ulabel, function);
-  menuitems->insert(item, pos);
+  if (pos == -1)
+    menuitems.push_back(item);
+  else
+    menuitems.insert(menuitems.begin() + pos, item);
 
-  return menuitems->count();
+  return menuitems.size();
 }
 
 
 int Basemenu::remove(int index) {
-  if (index < 0 || index > menuitems->count()) return -1;
+  if (index < 0 || index > (signed)menuitems.size()) return -1;
 
-  BasemenuItem *item = menuitems->remove(index);
+  BasemenuItem *item = menuitems[index];
+  menuitems.erase(menuitems.begin() + index);
 
   if (item) {
-    if ((! internal_menu) && (item->submenu())) {
+    if ((!internal_menu) && (item->submenu())) {
       Basemenu *tmp = (Basemenu *) item->submenu();
 
       if (! tmp->internal_menu) {
-       delete tmp;
+        delete tmp;
       } else {
-       tmp->internal_hide();
+        tmp->internal_hide();
       }
     }
 
     if (item->label())
       delete [] item->label();
-    
+
     if (item->exec())
       delete [] item->exec();
 
@@ -254,52 +263,52 @@ int Basemenu::remove(int index) {
   else if (which_sub > index)
     which_sub--;
 
-  return menuitems->count();
+  return menuitems.size();
 }
 
 
 void Basemenu::update(void) {
   MenuStyle *style = screen.getMenuStyle();
-  if (i18n->multibyte()) {
+  if (i18n.multibyte()) {
     menu.item_h = style->f_fontset_extents->max_ink_extent.height +
-                 menu.bevel_w;
+      menu.bevel_w;
     menu.title_h = style->t_fontset_extents->max_ink_extent.height +
-                   (menu.bevel_w * 2);
+      (menu.bevel_w * 2);
   } else {
     menu.item_h = style->f_font->ascent + style->f_font->descent +
-                 menu.bevel_w;
+      menu.bevel_w;
     menu.title_h = style->t_font->ascent + style->t_font->descent +
-                  (menu.bevel_w * 2);
+      (menu.bevel_w * 2);
   }
-    
+
   if (title_vis) {
     const char *s = (menu.label) ? menu.label :
-                   i18n->getMessage(BasemenuSet, BasemenuOpenboxMenu,
-                                    "Openbox Menu");
+      i18n(BasemenuSet, BasemenuOpenboxMenu,
+           "Openbox Menu");
     int l = strlen(s);
-    
 
-    if (i18n->multibyte()) {
+
+    if (i18n.multibyte()) {
       XRectangle ink, logical;
       XmbTextExtents(screen.getMenuStyle()->t_fontset, s, l, &ink, &logical);
       menu.item_w = logical.width;
     } else {
       menu.item_w = XTextWidth(screen.getMenuStyle()->t_font, s, l);
     }
-    
+
     menu.item_w += (menu.bevel_w * 2);
   }  else {
     menu.item_w = 1;
   }
 
   int ii = 0;
-  LinkedListIterator<BasemenuItem> it(menuitems);
-  for (BasemenuItem *tmp = it.current(); tmp; it++, tmp = it.current()) {
-    const char *s = ((tmp->u && *tmp->u) ? *tmp->u :
-                    ((tmp->l) ? tmp->l : (const char *) 0));
+  menuitemList::const_iterator it = menuitems.begin();
+  for (; it != menuitems.end(); it++) {
+    const char *s = (((*it)->u && *(*it)->u) ? *(*it)->u :
+                     (((*it)->l) ? (*it)->l : (const char *) 0));
     int l = strlen(s);
 
-    if (i18n->multibyte()) {
+    if (i18n.multibyte()) {
       XRectangle ink, logical;
       XmbTextExtents(screen.getMenuStyle()->f_fontset, s, l, &ink, &logical);
       ii = logical.width;
@@ -311,18 +320,18 @@ void Basemenu::update(void) {
     menu.item_w = ((menu.item_w < (unsigned int) ii) ? ii : menu.item_w);
   }
 
-  if (menuitems->count()) {
+  if (menuitems.size()) {
     menu.sublevels = 1;
 
-    while (((menu.item_h * (menuitems->count() + 1) / menu.sublevels)
-           + menu.title_h + screen.getBorderWidth()) >
-          screen.getHeight())
+    while (((menu.item_h * (menuitems.size() + 1) / menu.sublevels)
+            + menu.title_h + screen.getBorderWidth()) >
+           screen.size().h())
       menu.sublevels++;
 
     if (menu.sublevels < menu.minsub) menu.sublevels = menu.minsub;
 
-    menu.persub = menuitems->count() / menu.sublevels;
-    if (menuitems->count() % menu.sublevels) menu.persub++;
+    menu.persub = menuitems.size() / menu.sublevels;
+    if (menuitems.size() % menu.sublevels) menu.persub++;
   } else {
     menu.sublevels = 0;
     menu.persub = 0;
@@ -333,7 +342,7 @@ void Basemenu::update(void) {
 
   menu.frame_h = (menu.item_h * menu.persub);
   menu.height = ((title_vis) ? menu.title_h + screen.getBorderWidth() : 0) +
-               menu.frame_h;
+    menu.frame_h;
   if (! menu.frame_h) menu.frame_h = 1;
   if (menu.height < 1) menu.height = 1;
 
@@ -345,7 +354,7 @@ void Basemenu::update(void) {
     if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
       menu.title_pixmap = None;
       XSetWindowBackground(display, menu.title,
-                          texture->getColor()->getPixel());
+                           texture->getColor()->getPixel());
     } else {
       menu.title_pixmap =
         image_ctrl->renderImage(menu.width, menu.title_h, texture);
@@ -360,7 +369,7 @@ void Basemenu::update(void) {
   if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
     menu.frame_pixmap = None;
     XSetWindowBackground(display, menu.frame,
-                        texture->getColor()->getPixel());
+                         texture->getColor()->getPixel());
   } else {
     menu.frame_pixmap =
       image_ctrl->renderImage(menu.width, menu.frame_h, texture);
@@ -394,9 +403,9 @@ void Basemenu::update(void) {
     XResizeWindow(display, menu.title, menu.width, menu.title_h);
 
   XMoveResizeWindow(display, menu.frame, 0,
-                   ((title_vis) ? menu.title_h +
-                    screen.getBorderWidth() : 0), menu.width,
-                   menu.frame_h);
+                    ((title_vis) ? menu.title_h +
+                     screen.getBorderWidth() : 0), menu.width,
+                    menu.frame_h);
 
   XClearWindow(display, menu.window);
   XClearWindow(display, menu.title);
@@ -404,7 +413,7 @@ void Basemenu::update(void) {
 
   if (title_vis && visible) redrawTitle();
 
-  for (int i = 0; visible && i < menuitems->count(); i++) {
+  for (int i = 0; visible && i < (signed)menuitems.size(); i++) {
     if (i == which_sub) {
       drawItem(i, True, 0);
       drawSubmenu(i);
@@ -427,7 +436,7 @@ void Basemenu::show(void) {
 
   if (! parent) {
     if (shown && (! shown->torn))
-       shown->hide();
+      shown->hide();
 
     shown = this;
   }
@@ -448,7 +457,7 @@ void Basemenu::hide(void) {
 
 void Basemenu::internal_hide(void) {
   if (which_sub != -1) {
-    BasemenuItem *tmp = menuitems->find(which_sub);
+    BasemenuItem *tmp = menuitems[which_sub];
     tmp->submenu()->internal_hide();
   }
 
@@ -478,12 +487,12 @@ void Basemenu::move(int x, int y) {
 
 void Basemenu::redrawTitle(void) {
   char *text = (char *) ((menu.label) ? menu.label :
-                        i18n->getMessage(BasemenuSet, BasemenuOpenboxMenu,
-                                         "Openbox Menu"));
+                         i18n(BasemenuSet, BasemenuOpenboxMenu,
+                              "Openbox Menu"));
   int dx = menu.bevel_w, len = strlen(text);
   unsigned int l;
 
-  if (i18n->multibyte()) {
+  if (i18n.multibyte()) {
     XRectangle ink, logical;
     XmbTextExtents(screen.getMenuStyle()->t_fontset, text, len, &ink, &logical);
     l = logical.width;
@@ -504,68 +513,68 @@ void Basemenu::redrawTitle(void) {
   }
 
   MenuStyle *style = screen.getMenuStyle();
-  if (i18n->multibyte())
+  if (i18n.multibyte())
     XmbDrawString(display, menu.title, style->t_fontset, style->t_text_gc, dx,
-                 (menu.bevel_w - style->t_fontset_extents->max_ink_extent.y),
-                 text, len);
+                  (menu.bevel_w - style->t_fontset_extents->max_ink_extent.y),
+                  text, len);
   else
     XDrawString(display, menu.title, style->t_text_gc, dx,
-               (style->t_font->ascent + menu.bevel_w), text, len);
+                (style->t_font->ascent + menu.bevel_w), text, len);
 }
 
 
 void Basemenu::drawSubmenu(int index) {
   if (which_sub != -1 && which_sub != index) {
-    BasemenuItem *itmp = menuitems->find(which_sub);
+    BasemenuItem *itmp = menuitems[which_sub];
 
     if (! itmp->submenu()->isTorn())
       itmp->submenu()->internal_hide();
   }
 
-  if (index >= 0 && index < menuitems->count()) {
-    BasemenuItem *item = menuitems->find(index);
+  if (index >= 0 && index < (signed)menuitems.size()) {
+    BasemenuItem *item = menuitems[index];
     if (item->submenu() && visible && (! item->submenu()->isTorn()) &&
-       item->isEnabled()) {
+        item->isEnabled()) {
       if (item->submenu()->parent != this) item->submenu()->parent = this;
       int sbl = index / menu.persub, i = index - (sbl * menu.persub),
-           x = menu.x +
-               ((menu.item_w * (sbl + 1)) + screen.getBorderWidth()), y;
-    
+      x = menu.x +
+        ((menu.item_w * (sbl + 1)) + screen.getBorderWidth()), y;
+
       if (alignment == AlignTop)
-       y = (((shifted) ? menu.y_shift : menu.y) +
-            ((title_vis) ? menu.title_h + screen.getBorderWidth() : 0) -
-            ((item->submenu()->title_vis) ?
-             item->submenu()->menu.title_h + screen.getBorderWidth() : 0));
+        y = (((shifted) ? menu.y_shift : menu.y) +
+             ((title_vis) ? menu.title_h + screen.getBorderWidth() : 0) -
+             ((item->submenu()->title_vis) ?
+              item->submenu()->menu.title_h + screen.getBorderWidth() : 0));
       else
-       y = (((shifted) ? menu.y_shift : menu.y) +
-            (menu.item_h * i) +
-            ((title_vis) ? menu.title_h + screen.getBorderWidth() : 0) -
-            ((item->submenu()->title_vis) ?
-             item->submenu()->menu.title_h + screen.getBorderWidth() : 0));
+        y = (((shifted) ? menu.y_shift : menu.y) +
+             (menu.item_h * i) +
+             ((title_vis) ? menu.title_h + screen.getBorderWidth() : 0) -
+             ((item->submenu()->title_vis) ?
+              item->submenu()->menu.title_h + screen.getBorderWidth() : 0));
 
       if (alignment == AlignBottom &&
-         (y + item->submenu()->menu.height) > ((shifted) ? menu.y_shift :
-                                               menu.y) + menu.height)
-       y = (((shifted) ? menu.y_shift : menu.y) +
-            menu.height - item->submenu()->menu.height);
-
-      if ((x + item->submenu()->getWidth()) > screen.getWidth()) {
-       x = ((shifted) ? menu.x_shift : menu.x) -
-           item->submenu()->getWidth() - screen.getBorderWidth();
+          (y + item->submenu()->menu.height) > ((shifted) ? menu.y_shift :
+                                                menu.y) + menu.height)
+        y = (((shifted) ? menu.y_shift : menu.y) +
+             menu.height - item->submenu()->menu.height);
+
+      if ((x + item->submenu()->getWidth()) > screen.size().w()) {
+        x = ((shifted) ? menu.x_shift : menu.x) -
+          item->submenu()->getWidth() - screen.getBorderWidth();
       }
-      
+
       if (x < 0) x = 0;
 
-      if ((y + item->submenu()->getHeight()) > screen.getHeight())
-       y = screen.getHeight() - item->submenu()->getHeight() -
-           (screen.getBorderWidth() * 2);
+      if ((y + item->submenu()->getHeight()) > screen.size().h())
+        y = screen.size().h() - item->submenu()->getHeight() -
+          (screen.getBorderWidth() * 2);
       if (y < 0) y = 0;
-      
+
       item->submenu()->move(x, y);
       if (! moving) drawItem(index, True);
-    
+
       if (! item->submenu()->isVisible())
-       item->submenu()->show();
+        item->submenu()->show();
       item->submenu()->moving = moving;
       which_sub = index;
     } else {
@@ -575,23 +584,21 @@ void Basemenu::drawSubmenu(int index) {
 }
 
 
-Bool Basemenu::hasSubmenu(int index) {
-  if ((index >= 0) && (index < menuitems->count()))
-    if (menuitems->find(index)->submenu())
-      return True;
-
-  return False;
+bool Basemenu::hasSubmenu(int index) {
+  if (index < 0 | index >= (signed)menuitems.size())
+    return false;
+  return (menuitems[index]->submenu());
 }
 
 
 void Basemenu::drawItem(int index, Bool highlight, Bool clear,
-                       int x, int y, unsigned int w, unsigned int h)
+                        int x, int y, unsigned int w, unsigned int h)
 {
-  if (index < 0 || index > menuitems->count()) return;
+  if (index < 0 || index > (signed)menuitems.size()) return;
 
-  BasemenuItem *item = menuitems->find(index);
+  BasemenuItem *item = menuitems[index];
   if (! item) return;
-  
+
   Bool dotext = True, dohilite = True, dosel = True;
   const char *text = (item->ulabel()) ? *item->ulabel() : item->label();
   int sbl = index / menu.persub, i = index - (sbl * menu.persub);
@@ -599,62 +606,62 @@ void Basemenu::drawItem(int index, Bool highlight, Bool clear,
   int hilite_x = item_x, hilite_y = item_y, hoff_x = 0, hoff_y = 0;
   int text_x = 0, text_y = 0, len = strlen(text), sel_x = 0, sel_y = 0;
   unsigned int hilite_w = menu.item_w, hilite_h = menu.item_h, text_w = 0,
-    text_h = 0;
+  text_h = 0;
   unsigned int half_w = menu.item_h / 2, quarter_w = menu.item_h / 4;
-  
+
   if (text) {
-    if (i18n->multibyte()) {
+    if (i18n.multibyte()) {
       XRectangle ink, logical;
       XmbTextExtents(screen.getMenuStyle()->f_fontset,
-                    text, len, &ink, &logical);
+                     text, len, &ink, &logical);
       text_w = logical.width;
       text_y = item_y + (menu.bevel_w / 2) -
-              screen.getMenuStyle()->f_fontset_extents->max_ink_extent.y;
+        screen.getMenuStyle()->f_fontset_extents->max_ink_extent.y;
     } else {
       text_w = XTextWidth(screen.getMenuStyle()->f_font, text, len);
       text_y =  item_y +
-               screen.getMenuStyle()->f_font->ascent +
-               (menu.bevel_w / 2);
+        screen.getMenuStyle()->f_font->ascent +
+        (menu.bevel_w / 2);
     }
-    
+
     switch(screen.getMenuStyle()->f_justify) {
     case BScreen::LeftJustify:
       text_x = item_x + menu.bevel_w + menu.item_h + 1;
       break;
-      
+
     case BScreen::RightJustify:
       text_x = item_x + menu.item_w - (menu.item_h + menu.bevel_w + text_w);
       break;
-      
+
     case BScreen::CenterJustify:
       text_x = item_x + ((menu.item_w + 1 - text_w) / 2);
       break;
     }
-    
+
     text_h = menu.item_h - menu.bevel_w;
   }
-  
+
   GC gc =
     ((highlight || item->isSelected()) ? screen.getMenuStyle()->h_text_gc :
      screen.getMenuStyle()->f_text_gc),
-    tgc =
+  tgc =
     ((highlight) ? screen.getMenuStyle()->h_text_gc :
      ((item->isEnabled()) ? screen.getMenuStyle()->f_text_gc :
       screen.getMenuStyle()->d_text_gc));
-  
+
   sel_x = item_x;
   if (screen.getMenuStyle()->bullet_pos == Right)
     sel_x += (menu.item_w - menu.item_h - menu.bevel_w);
   sel_x += quarter_w;
   sel_y = item_y + quarter_w;
-  
+
   if (clear) {
     XClearArea(display, menu.frame, item_x, item_y, menu.item_w, menu.item_h,
-              False);
+               False);
   } else if (! (x == y && y == -1 && w == h && h == 0)) {
     // calculate the which part of the hilite to redraw
     if (! (max(item_x, x) <= (signed) min(item_x + menu.item_w, x + w) &&
-          max(item_y, y) <= (signed) min(item_y + menu.item_h, y + h))) {
+           max(item_y, y) <= (signed) min(item_y + menu.item_h, y + h))) {
       dohilite = False;
     } else {
       hilite_x = max(item_x, x);
@@ -664,44 +671,44 @@ void Basemenu::drawItem(int index, Bool highlight, Bool clear,
       hoff_x = hilite_x % menu.item_w;
       hoff_y = hilite_y % menu.item_h;
     }
-    
+
     // check if we need to redraw the text    
     int text_ry = item_y + (menu.bevel_w / 2);
     if (! (max(text_x, x) <= (signed) min(text_x + text_w, x + w) &&
-          max(text_ry, y) <= (signed) min(text_ry + text_h, y + h)))
+           max(text_ry, y) <= (signed) min(text_ry + text_h, y + h)))
       dotext = False;
-    
+
     // check if we need to redraw the select pixmap/menu bullet
     if (! (max(sel_x, x) <= (signed) min(sel_x + half_w, x + w) &&
-          max(sel_y, y) <= (signed) min(sel_y + half_w, y + h)))
+           max(sel_y, y) <= (signed) min(sel_y + half_w, y + h)))
       dosel = False;
   }
-  
+
   if (dohilite && highlight && (menu.hilite_pixmap != ParentRelative)) {
     if (menu.hilite_pixmap)
       XCopyArea(display, menu.hilite_pixmap, menu.frame,
-               screen.getMenuStyle()->hilite_gc, hoff_x, hoff_y,
-               hilite_w, hilite_h, hilite_x, hilite_y);
+                screen.getMenuStyle()->hilite_gc, hoff_x, hoff_y,
+                hilite_w, hilite_h, hilite_x, hilite_y);
     else
       XFillRectangle(display, menu.frame,
-                    screen.getMenuStyle()->hilite_gc,
-                    hilite_x, hilite_y, hilite_w, hilite_h);
+                     screen.getMenuStyle()->hilite_gc,
+                     hilite_x, hilite_y, hilite_w, hilite_h);
   } else if (dosel && item->isSelected() &&
-                        (menu.sel_pixmap != ParentRelative)) {
+             (menu.sel_pixmap != ParentRelative)) {
     if (menu.sel_pixmap)
       XCopyArea(display, menu.sel_pixmap, menu.frame,
-               screen.getMenuStyle()->hilite_gc, 0, 0,
-               half_w, half_w, sel_x, sel_y);
+                screen.getMenuStyle()->hilite_gc, 0, 0,
+                half_w, half_w, sel_x, sel_y);
     else
       XFillRectangle(display, menu.frame,
-                    screen.getMenuStyle()->hilite_gc,
-                    sel_x, sel_y, half_w, half_w);
+                     screen.getMenuStyle()->hilite_gc,
+                     sel_x, sel_y, half_w, half_w);
   }
-  
+
   if (dotext && text) {
-    if (i18n->multibyte())
+    if (i18n.multibyte())
       XmbDrawString(display, menu.frame, screen.getMenuStyle()->f_fontset,
-                   tgc, text_x, text_y, text, len);
+                    tgc, text_x, text_y, text, len);
     else
       XDrawString(display, menu.frame, tgc, text_x, text_y, text, len);
   }
@@ -717,24 +724,24 @@ void Basemenu::drawItem(int index, Bool highlight, Bool clear,
 
       if (screen.getMenuStyle()->bullet_pos == Right) {
         tri[0].x = sel_x + quarter_w - 2;
-       tri[0].y = sel_y + quarter_w - 2;
+        tri[0].y = sel_y + quarter_w - 2;
         tri[1].x = 4;
-       tri[1].y = 2;
+        tri[1].y = 2;
         tri[2].x = -4;
-       tri[2].y = 2;
+        tri[2].y = 2;
       } else {
         tri[0].x = sel_x + quarter_w - 2;
-       tri[0].y = item_y + half_w;
+        tri[0].y = item_y + half_w;
         tri[1].x = 4;
-       tri[1].y = 2;
+        tri[1].y = 2;
         tri[2].x = 0;
-       tri[2].y = -4;
+        tri[2].y = -4;
       }
-      
+
       XFillPolygon(display, menu.frame, gc, tri, 3, Convex,
                    CoordModePrevious);
       break;
-      
+
     case Diamond:
       XPoint dia[4];
 
@@ -764,8 +771,8 @@ void Basemenu::setLabel(const char *l) {
 }
 
 
-void Basemenu::setItemSelected(int index, Bool sel) {
-  if (index < 0 || index >= menuitems->count()) return;
+void Basemenu::setItemSelected(int index, bool sel) {
+  if (index < 0 || index >= (signed)menuitems.size()) return;
 
   BasemenuItem *item = find(index);
   if (! item) return;
@@ -775,18 +782,18 @@ void Basemenu::setItemSelected(int index, Bool sel) {
 }
 
 
-Bool Basemenu::isItemSelected(int index) {
-  if (index < 0 || index >= menuitems->count()) return False;
+bool Basemenu::isItemSelected(int index) {
+  if (index < 0 || index >= (signed)menuitems.size()) return false;
 
   BasemenuItem *item = find(index);
-  if (! item) return False;
+  if (! item) return false;
 
   return item->isSelected();
 }
 
 
-void Basemenu::setItemEnabled(int index, Bool enable) {
-  if (index < 0 || index >= menuitems->count()) return;
+void Basemenu::setItemEnabled(int index, bool enable) {
+  if (index < 0 || index >= (signed)menuitems.size()) return;
 
   BasemenuItem *item = find(index);
   if (! item) return;
@@ -796,8 +803,8 @@ void Basemenu::setItemEnabled(int index, Bool enable) {
 }
 
 
-Bool Basemenu::isItemEnabled(int index) {
-  if (index < 0 || index >= menuitems->count()) return False;
+bool Basemenu::isItemEnabled(int index) {
+  if (index < 0 || index >= (signed)menuitems.size()) return false;
 
   BasemenuItem *item = find(index);
   if (! item) return False;
@@ -811,16 +818,16 @@ void Basemenu::buttonPressEvent(XButtonEvent *be) {
     int sbl = (be->x / menu.item_w), i = (be->y / menu.item_h);
     int w = (sbl * menu.persub) + i;
 
-    if (w < menuitems->count() && w >= 0) {
+    if (w < (signed)menuitems.size() && w >= 0) {
       which_press = i;
       which_sbl = sbl;
 
-      BasemenuItem *item = menuitems->find(w);
+      BasemenuItem *item = menuitems[w];
 
       if (item->submenu())
-       drawSubmenu(w);
+        drawSubmenu(w);
       else
-       drawItem(w, (item->isEnabled()), True);
+        drawItem(w, (item->isEnabled()), True);
     }
   } else {
     menu.x_move = be->x_root - menu.x;
@@ -833,34 +840,34 @@ void Basemenu::buttonReleaseEvent(XButtonEvent *re) {
   if (re->window == menu.title) {
     if (moving) {
       moving = False;
-      
+
       if (which_sub != -1)
-       drawSubmenu(which_sub);
+        drawSubmenu(which_sub);
     }
-    
+
     if (re->x >= 0 && re->x <= (signed) menu.width &&
-       re->y >= 0 && re->y <= (signed) menu.title_h)
+        re->y >= 0 && re->y <= (signed) menu.title_h)
       if (re->button == 3)
-       hide();
+        hide();
   } else if (re->window == menu.frame &&
-            re->x >= 0 && re->x < (signed) menu.width &&
-            re->y >= 0 && re->y < (signed) menu.frame_h) {
+             re->x >= 0 && re->x < (signed) menu.width &&
+             re->y >= 0 && re->y < (signed) menu.frame_h) {
     if (re->button == 3) {
       hide();
     } else {
       int sbl = (re->x / menu.item_w), i = (re->y / menu.item_h),
-          ix = sbl * menu.item_w, iy = i * menu.item_h,
-           w = (sbl * menu.persub) + i,
-           p = (which_sbl * menu.persub) + which_press;
+      ix = sbl * menu.item_w, iy = i * menu.item_h,
+      w = (sbl * menu.persub) + i,
+      p = (which_sbl * menu.persub) + which_press;
 
-      if (w < menuitems->count() && w >= 0) {
-       drawItem(p, (p == which_sub), True);
+      if (w < (signed)menuitems.size() && w >= 0) {
+        drawItem(p, (p == which_sub), True);
 
         if  (p == w && isItemEnabled(w)) {
-         if (re->x > ix && re->x < (signed) (ix + menu.item_w) &&
-             re->y > iy && re->y < (signed) (iy + menu.item_h)) {
-           itemSelected(re->button, w);
-         }
+          if (re->x > ix && re->x < (signed) (ix + menu.item_w) &&
+              re->y > iy && re->y < (signed) (iy + menu.item_h)) {
+            itemSelected(re->button, w);
+          }
         }
       } else
         drawItem(p, False, True);
@@ -873,55 +880,55 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) {
   if (me->window == menu.title && (me->state & Button1Mask)) {
     if (movable) {
       if (! moving) {
-       if (parent && (! torn)) {
-         parent->drawItem(parent->which_sub, False, True);
-         parent->which_sub = -1;
-       }
+        if (parent && (! torn)) {
+          parent->drawItem(parent->which_sub, False, True);
+          parent->which_sub = -1;
+        }
 
         moving = torn = True;
 
-       if (which_sub != -1)
-         drawSubmenu(which_sub);
+        if (which_sub != -1)
+          drawSubmenu(which_sub);
       } else {
-       menu.x = me->x_root - menu.x_move,
-       menu.y = me->y_root - menu.y_move;
-       
-       XMoveWindow(display, menu.window, menu.x, menu.y);
-         
-       if (which_sub != -1)
-         drawSubmenu(which_sub);
+        menu.x = me->x_root - menu.x_move,
+        menu.y = me->y_root - menu.y_move;
+
+        XMoveWindow(display, menu.window, menu.x, menu.y);
+
+        if (which_sub != -1)
+          drawSubmenu(which_sub);
       }
     }
   } else if ((! (me->state & Button1Mask)) && me->window == menu.frame &&
-            me->x >= 0 && me->x < (signed) menu.width &&
-            me->y >= 0 && me->y < (signed) menu.frame_h) {
+             me->x >= 0 && me->x < (signed) menu.width &&
+             me->y >= 0 && me->y < (signed) menu.frame_h) {
     int sbl = (me->x / menu.item_w), i = (me->y / menu.item_h),
-         w = (sbl * menu.persub) + i;
+    w = (sbl * menu.persub) + i;
 
     if ((i != which_press || sbl != which_sbl) &&
-       (w < menuitems->count() && w >= 0)) {
+        (w < (signed)menuitems.size() && w >= 0)) {
       if (which_press != -1 && which_sbl != -1) {
-       int p = (which_sbl * menu.persub) + which_press;
-       BasemenuItem *item = menuitems->find(p);
-
-       drawItem(p, False, True);
-       if (item->submenu())
-         if (item->submenu()->isVisible() &&
-             (! item->submenu()->isTorn())) {
-           item->submenu()->internal_hide();
-           which_sub = -1;
-         }
+        int p = (which_sbl * menu.persub) + which_press;
+        BasemenuItem *item = menuitems[p];
+
+        drawItem(p, False, True);
+        if (item->submenu())
+          if (item->submenu()->isVisible() &&
+              (! item->submenu()->isTorn())) {
+            item->submenu()->internal_hide();
+            which_sub = -1;
+          }
       }
 
       which_press = i;
       which_sbl = sbl;
 
-      BasemenuItem *itmp = menuitems->find(w);
+      BasemenuItem *itmp = menuitems[w];
 
       if (itmp->submenu())
-       drawSubmenu(w);
+        drawSubmenu(w);
       else
-       drawItem(w, (itmp->isEnabled()), True);
+        drawItem(w, (itmp->isEnabled()), True);
     }
   }
 }
@@ -936,24 +943,24 @@ void Basemenu::exposeEvent(XExposeEvent *ee) {
     // items down in that sublevel
 
     int sbl = (ee->x / menu.item_w), id = (ee->y / menu.item_h),
-      // next... figure out how many sublevels over the redraw spans
-      sbl_d = ((ee->x + ee->width) / menu.item_w),
-      // then we see how many items down to redraw
-      id_d = ((ee->y + ee->height) / menu.item_h);
+    // next... figure out how many sublevels over the redraw spans
+    sbl_d = ((ee->x + ee->width) / menu.item_w),
+    // then we see how many items down to redraw
+    id_d = ((ee->y + ee->height) / menu.item_h);
 
     if (id_d > menu.persub) id_d = menu.persub;
 
     // draw the sublevels and the number of items the exposure spans
-    LinkedListIterator<BasemenuItem> it(menuitems);
+    menuitemList::const_iterator it = menuitems.begin();
     int i, ii;
     for (i = sbl; i <= sbl_d; i++) {
       // set the iterator to the first item in the sublevel needing redrawing
-      it.set(id + (i * menu.persub));
-      for (ii = id; ii <= id_d && it.current(); it++, ii++) {
-       int index = ii + (i * menu.persub);
-       // redraw the item
-       drawItem(index, (which_sub == index), False,
-                ee->x, ee->y, ee->width, ee->height);
+      it = menuitems.begin() + (id + (i * menu.persub));
+      for (ii = id; ii <= id_d && it != menuitems.end(); it++, ii++) {
+        int index = ii + (i * menu.persub);
+        // redraw the item
+        drawItem(index, (which_sub == index), False,
+                 ee->x, ee->y, ee->width, ee->height);
       }
     }
   }
@@ -963,8 +970,8 @@ void Basemenu::exposeEvent(XExposeEvent *ee) {
 void Basemenu::enterNotifyEvent(XCrossingEvent *ce) {
   if (ce->window == menu.frame) {
     menu.x_shift = menu.x, menu.y_shift = menu.y;
-    if (menu.x + menu.width > screen.getWidth()) {
-      menu.x_shift = screen.getWidth() - menu.width -
+    if (menu.x + menu.width > screen.size().w()) {
+      menu.x_shift = screen.size().w() - menu.width -
         screen.getBorderWidth();
       shifted = True;
     } else if (menu.x < 0) {
@@ -972,8 +979,8 @@ void Basemenu::enterNotifyEvent(XCrossingEvent *ce) {
       shifted = True;
     }
 
-    if (menu.y + menu.height > screen.getHeight()) {
-      menu.y_shift = screen.getHeight() - menu.height -
+    if (menu.y + menu.height > screen.size().h()) {
+      menu.y_shift = screen.size().h() - menu.height -
         screen.getBorderWidth();
       shifted = True;
     } else if (menu.y + (signed) menu.title_h < 0) {
@@ -985,17 +992,17 @@ void Basemenu::enterNotifyEvent(XCrossingEvent *ce) {
       XMoveWindow(display, menu.window, menu.x_shift, menu.y_shift);
 
     if (which_sub != -1) {
-      BasemenuItem *tmp = menuitems->find(which_sub);
+      BasemenuItem *tmp = menuitems[which_sub];
       if (tmp->submenu()->isVisible()) {
-       int sbl = (ce->x / menu.item_w), i = (ce->y / menu.item_h),
-         w = (sbl * menu.persub) + i;
+        int sbl = (ce->x / menu.item_w), i = (ce->y / menu.item_h),
+        w = (sbl * menu.persub) + i;
 
-       if (w != which_sub && (! tmp->submenu()->isTorn())) {
-         tmp->submenu()->internal_hide();
+        if (w != which_sub && (! tmp->submenu()->isTorn())) {
+          tmp->submenu()->internal_hide();
 
-         drawItem(which_sub, False, True);
-         which_sub = -1;
-       }
+          drawItem(which_sub, False, True);
+          which_sub = -1;
+        }
       }
     }
   }
@@ -1004,7 +1011,7 @@ void Basemenu::enterNotifyEvent(XCrossingEvent *ce) {
 
 void Basemenu::leaveNotifyEvent(XCrossingEvent *ce) {
   if (ce->window == menu.frame) {
-    if (which_press != -1 && which_sbl != -1 && menuitems->count() > 0) {
+    if (which_press != -1 && which_sbl != -1 && menuitems.size() > 0) {
       int p = (which_sbl * menu.persub) + which_press;
 
       drawItem(p, (p == which_sub), True);
@@ -1024,9 +1031,9 @@ void Basemenu::leaveNotifyEvent(XCrossingEvent *ce) {
 
 void Basemenu::reconfigure(void) {
   XSetWindowBackground(display, menu.window,
-                      screen.getBorderColor()->getPixel());
+                       screen.getBorderColor()->getPixel());
   XSetWindowBorder(display, menu.window,
-                  screen.getBorderColor()->getPixel());
+                   screen.getBorderColor()->getPixel());
   XSetWindowBorderWidth(display, menu.window, screen.getBorderWidth());
 
   menu.bevel_w = screen.getBevelWidth();
This page took 0.055359 seconds and 4 git commands to generate.