+
+ /*
+ * set menu width
+ *
+ * the item width depends on the size of its label (ext.xOff),
+ * and it is only used to calculate the width of the menu (which
+ * is equal to the width of the largest item).
+ *
+ * the horizontal padding appears 4 times through the width of a
+ * item: before and after its icon, and before and after its triangle
+ * if the iflag is set (icons are disabled) then the horizontal
+ * padding appears before the label and around the triangle.
+ */
+ itemwidth = ext.xOff + config.triangle_width + config.horzpadding * 3;
+ itemwidth += (iflag) ? 0 : config.iconsize + config.horzpadding;
+ menu->w = MAX(menu->w, itemwidth);
+
+ /* create icon */
+ if (item->file != NULL && !iflag) {
+ item->icon = loadicon(item->file);
+
+ item->sel = XCreatePixmap(dpy, menu->win,
+ config.iconsize, config.iconsize,
+ DefaultDepth(dpy, screen));
+ XSetForeground(dpy, dc.gc, dc.selected[ColorBG].pixel);
+ XFillRectangle(dpy, item->sel, dc.gc, 0, 0,
+ config.iconsize, config.iconsize);
+ imlib_context_set_drawable(item->sel);
+ imlib_context_set_image(item->icon);
+ imlib_render_image_on_drawable(0, 0);
+
+ item->unsel = XCreatePixmap(dpy, menu->win,
+ config.iconsize, config.iconsize,
+ DefaultDepth(dpy, screen));
+ XSetForeground(dpy, dc.gc, dc.normal[ColorBG].pixel);
+ XFillRectangle(dpy, item->unsel, dc.gc, 0, 0,
+ config.iconsize, config.iconsize);
+ imlib_context_set_drawable(item->unsel);
+ imlib_context_set_image(item->icon);
+ imlib_render_image_on_drawable(0, 0);
+ }