]> Dogcows Code - chaz/openbox/blobdiff - src/Basemenu.cc
sync with bb-cvs
[chaz/openbox] / src / Basemenu.cc
index 775d49a882983f87e8b737c0cc7a22d0219a6c3a..ac605cb7ed6bea922003b120f66753cca40186c4 100644 (file)
@@ -86,8 +86,7 @@ Basemenu::Basemenu(BScreen *scrn) {
 
   menu.frame_pixmap =
     menu.title_pixmap =
-    menu.hilite_pixmap =
-    menu.sel_pixmap = None;
+    menu.hilite_pixmap = None;
 
   menu.bevel_w = screen->getBevelWidth();
 
@@ -152,7 +151,7 @@ Basemenu::~Basemenu(void) {
   MenuItems::const_iterator it = menuitems.begin();
   while (it != menuitems.end()) {
     BasemenuItem *item = *it;
-    if ((! internal_menu)) {
+    if (! internal_menu) {
       Basemenu *tmp = (Basemenu *) item->submenu();
       if (tmp) {
         if (! tmp->internal_menu) {
@@ -176,9 +175,6 @@ Basemenu::~Basemenu(void) {
   if (menu.hilite_pixmap)
     image_ctrl->removeImage(menu.hilite_pixmap);
 
-  if (menu.sel_pixmap)
-    image_ctrl->removeImage(menu.sel_pixmap);
-
   blackbox->removeMenuSearch(menu.title);
   XDestroyWindow(display, menu.title);
 
@@ -228,7 +224,7 @@ int Basemenu::remove(int index) {
   BasemenuItem *item = find(index);
   if (! item) return -1;
 
-  if ((! internal_menu)) {
+  if (! internal_menu) {
     Basemenu *tmp = (Basemenu *) item->submenu();
     if (tmp) {
       if (! tmp->internal_menu) {
@@ -341,16 +337,6 @@ void Basemenu::update(void) {
   }
   if (tmp) image_ctrl->removeImage(tmp);
 
-  tmp = menu.sel_pixmap;
-  if (texture->texture() == (BTexture::Flat | BTexture::Solid)) {
-    menu.sel_pixmap = None;
-  } else {
-    int hw = menu.item_h / 2;
-    menu.sel_pixmap =
-      image_ctrl->renderImage(hw, hw, *texture);
-  }
-  if (tmp) image_ctrl->removeImage(tmp);
-
   XResizeWindow(display, menu.window, menu.width, menu.height);
 
   if (title_vis)
@@ -399,10 +385,10 @@ void Basemenu::show(void) {
 
 
 void Basemenu::hide(void) {
-  if ((! torn) && hide_tree && parent && parent->isVisible()) {
+  if (! torn && hide_tree && parent && parent->isVisible()) {
     Basemenu *p = parent;
 
-    while (p->isVisible() && (! p->torn) && p->parent) p = p->parent;
+    while (p->isVisible() && ! p->torn && p->parent) p = p->parent;
     p->internal_hide();
   } else {
     internal_hide();
@@ -415,7 +401,7 @@ void Basemenu::internal_hide(void) {
   if (tmp)
     tmp->submenu()->internal_hide();
 
-  if (parent && (! torn)) {
+  if (parent && ! torn) {
     parent->drawItem(parent->which_sub, False, True);
 
     parent->which_sub = -1;
@@ -571,8 +557,11 @@ void Basemenu::drawItem(int index, bool highlight, bool clear,
   }
 
   MenuStyle *style = screen->getMenuStyle();
-  BPen pen((highlight || item->isSelected()) ? style->h_text : style->f_text),
-      hipen(style->hilite.color());
+  BPen hipen(style->hilite.color());
+  // match the text color
+  BPen pen((highlight ? style->h_text :
+            (item->isEnabled() ? style->f_text :
+             style->d_text)));
 
 
   sel_x = item_x;
@@ -618,13 +607,39 @@ void Basemenu::drawItem(int index, bool highlight, bool clear,
     else
       XFillRectangle(display, menu.frame, hipen.gc(),
                      hilite_x, hilite_y, hilite_w, hilite_h);
-  } else if (dosel && item->isSelected() &&
-             (menu.sel_pixmap != ParentRelative)) {
-    if (menu.sel_pixmap)
-      XCopyArea(display, menu.sel_pixmap, menu.frame, hipen.gc(), 0, 0,
-                half_w, half_w, sel_x, sel_y);
-    else
-      XFillRectangle(display, menu.frame, hipen.gc(), sel_x, sel_y, half_w, half_w);
+  }
+  
+  if (dosel && item->isSelected()) {
+      XPoint pts[6];
+
+      // put the check mark on the opposite side of the menu
+      int x = sel_x;
+      if (screen->getMenuStyle()->bullet_pos == Right)
+        x -= (menu.item_w - menu.item_h - menu.bevel_w);
+      else
+        x += (menu.item_w - menu.item_h - menu.bevel_w);
+
+      pts[0].x = x + 0;
+      pts[0].y = sel_y + 2;
+      
+      pts[1].x = 0;
+      pts[1].y = 3;
+      
+      pts[2].x = 2;
+      pts[2].y = 3;
+      
+      pts[3].x = 5;
+      pts[3].y = -5;
+      
+      
+      pts[4].x = 0;
+      pts[4].y = -3;
+      
+      pts[5].x = -5;
+      pts[5].y = 5;
+
+      XFillPolygon(display, menu.frame, pen.gc(), pts, 6, Nonconvex,
+                   CoordModePrevious);
   }
 
   if (dotext && text) {
@@ -798,7 +813,7 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) {
   if (me->window == menu.title && (me->state & Button1Mask)) {
     if (movable) {
       if (! moving) {
-        if (parent && (! torn)) {
+        if (parent && ! torn) {
           parent->drawItem(parent->which_sub, False, True);
           parent->which_sub = -1;
         }
@@ -817,7 +832,7 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) {
           drawSubmenu(which_sub);
       }
     }
-  } else if ((! (me->state & Button1Mask)) && me->window == menu.frame &&
+  } else if (! (me->state & Button1Mask) && me->window == menu.frame &&
              me->x >= 0 && me->x < static_cast<signed>(menu.width) &&
              me->y >= 0 && me->y < static_cast<signed>(menu.frame_h)) {
     int sbl = (me->x / menu.item_w), i = (me->y / menu.item_h),
@@ -832,7 +847,7 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) {
         drawItem(p, False, True);
         if (item->submenu())
           if (item->submenu()->isVisible() &&
-              (! item->submenu()->isTorn())) {
+              ! item->submenu()->isTorn()) {
             item->submenu()->internal_hide();
             which_sub = -1;
           }
@@ -916,7 +931,7 @@ void Basemenu::enterNotifyEvent(XCrossingEvent *ce) {
         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())) {
+        if (w != which_sub && ! tmp->submenu()->isTorn()) {
           tmp->submenu()->internal_hide();
 
           drawItem(which_sub, False, True);
This page took 0.027677 seconds and 4 git commands to generate.