~/.openbox/menu. If the default, or the file you
specify does not exist, the global menu is tried.
And if the global menu also does not exist, a
- simple, internal menu is used instead.
\ No newline at end of file
+ simple, internal menu is used instead.
XFillRectangle(display, menu.frame, hipen.gc(),
hilite_x, hilite_y, hilite_w, hilite_h);
}
-
+
if (dooppsel && item->isSelected()) {
+ if ( style->tick_image.mask != None) {
+ XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+ oppsel_x, item_y + menu.item_h/2 - style->tick_image.h/2);
+ XSetClipMask(blackbox->getXDisplay(), pen.gc(),
+ style->tick_image.mask);
+
+ cout << oppsel_x << ' ' << sel_x << endl;
+ XFillRectangle(blackbox->getXDisplay(), menu.frame, pen.gc(),
+ oppsel_x, item_y + menu.item_h/2 - style->tick_image.h/2,
+ style->tick_image.w,
+ style->tick_image.h);
+
+ XSetClipMask(blackbox->getXDisplay(), pen.gc(), None);
+
+ XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+ 0, 0);
+ } else {
XPoint pts[6];
pts[0].x = oppsel_x + 0;
XFillPolygon(display, menu.frame, pen.gc(), pts, 6, Nonconvex,
CoordModePrevious);
+ }
}
if (dotext && text) {
}
if (dosel && item->submenu()) {
- const int bullet_size = 3;
-
- switch (screen->getMenuStyle()->bullet) {
- case Square:
- XDrawRectangle(display, menu.frame, pen.gc(), sel_x, sel_y,
- bullet_size * 2, bullet_size * 2);
- break;
-
- case Triangle:
- XPoint tri[3];
+ if ( style->bullet_image.mask != None) {
+ XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+ sel_x, item_y + menu.item_h/2 - style->bullet_image.h/2);
+ XSetClipMask(blackbox->getXDisplay(), pen.gc(),
+ style->bullet_image.mask);
+
+ XFillRectangle(blackbox->getXDisplay(), menu.frame, pen.gc(),
+ sel_x, item_y + menu.item_h/2 - style->bullet_image.h/2,
+ sel_x + style->bullet_image.w,
+ item_y + menu.item_h/2 + style->bullet_image.h/2);
+
+ XSetClipMask(blackbox->getXDisplay(), pen.gc(), None);
+
+ XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+ 0, 0);
+ } else {
+ const int bullet_size = 3;
+
+ switch (screen->getMenuStyle()->bullet) {
+ case Square:
+ XDrawRectangle(display, menu.frame, pen.gc(), sel_x, sel_y,
+ bullet_size * 2, bullet_size * 2);
+ break;
+
+ case Triangle:
+ XPoint tri[3];
+
+ if (screen->getMenuStyle()->bullet_pos == Right) {
+ tri[0].x = sel_x + quarter_w - bullet_size;
+ tri[0].y = sel_y + quarter_w - bullet_size;
+ tri[1].x = 2 * bullet_size;
+ tri[1].y = bullet_size;
+ tri[2].x = -(2 * bullet_size);
+ tri[2].y = bullet_size;
+ } else {
+ tri[0].x = sel_x + quarter_w - bullet_size;
+ tri[0].y = item_y + half_w;
+ tri[1].x = 2 * bullet_size;
+ tri[1].y = bullet_size;
+ tri[2].x = 0;
+ tri[2].y = -(2 * bullet_size);
+ }
- if (screen->getMenuStyle()->bullet_pos == Right) {
- tri[0].x = sel_x + quarter_w - bullet_size;
- tri[0].y = sel_y + quarter_w - bullet_size;
- tri[1].x = 2 * bullet_size;
- tri[1].y = bullet_size;
- tri[2].x = -(2 * bullet_size);
- tri[2].y = bullet_size;
- } else {
- tri[0].x = sel_x + quarter_w - bullet_size;
- tri[0].y = item_y + half_w;
- tri[1].x = 2 * bullet_size;
- tri[1].y = bullet_size;
- tri[2].x = 0;
- tri[2].y = -(2 * bullet_size);
+ XFillPolygon(display, menu.frame, pen.gc(), tri, 3, Convex,
+ CoordModePrevious);
+ break;
+
+ case Diamond:
+ XPoint dia[4];
+
+ dia[0].x = sel_x + quarter_w - bullet_size;
+ dia[0].y = item_y + half_w;
+ dia[1].x = bullet_size;
+ dia[1].y = -bullet_size;
+ dia[2].x = bullet_size;
+ dia[2].y = bullet_size;
+ dia[3].x = -bullet_size;
+ dia[3].y = bullet_size;
+
+ XFillPolygon(display, menu.frame, pen.gc(), dia, 4, Convex,
+ CoordModePrevious);
+ break;
}
-
- XFillPolygon(display, menu.frame, pen.gc(), tri, 3, Convex,
- CoordModePrevious);
- break;
-
- case Diamond:
- XPoint dia[4];
-
- dia[0].x = sel_x + quarter_w - bullet_size;
- dia[0].y = item_y + half_w;
- dia[1].x = bullet_size;
- dia[1].y = -bullet_size;
- dia[2].x = bullet_size;
- dia[2].y = bullet_size;
- dia[3].x = -bullet_size;
- dia[3].y = bullet_size;
-
- XFillPolygon(display, menu.frame, pen.gc(), dia, 4, Convex,
- CoordModePrevious);
- break;
}
}
}
if (resource.tstyle.font)
delete resource.tstyle.font;
+ if (resource.wstyle.close_button.mask != None)
+ XFreePixmap(blackbox->getXDisplay(), resource.wstyle.close_button.mask);
+ if (resource.wstyle.max_button.mask != None)
+ XFreePixmap(blackbox->getXDisplay(), resource.wstyle.max_button.mask);
+ if (resource.wstyle.icon_button.mask != None)
+ XFreePixmap(blackbox->getXDisplay(), resource.wstyle.icon_button.mask);
+ if (resource.wstyle.stick_button.mask != None)
+ XFreePixmap(blackbox->getXDisplay(), resource.wstyle.stick_button.mask);
+
+ if (resource.tstyle.left_button.mask != None)
+ XFreePixmap(blackbox->getXDisplay(), resource.tstyle.left_button.mask);
+ if (resource.tstyle.right_button.mask != None)
+ XFreePixmap(blackbox->getXDisplay(), resource.tstyle.right_button.mask);
+
+ if (resource.mstyle.bullet_image.mask != None)
+ XFreePixmap(blackbox->getXDisplay(), resource.mstyle.bullet_image.mask);
+ if (resource.mstyle.tick_image.mask != None)
+ XFreePixmap(blackbox->getXDisplay(), resource.mstyle.tick_image.mask);
+
+ resource.wstyle.max_button.mask = resource.wstyle.close_button.mask =
+ resource.wstyle.icon_button.mask =
+ resource.wstyle.stick_button.mask = None;
+ resource.tstyle.left_button.mask = resource.tstyle.right_button.mask = None;
+ resource.mstyle.bullet_image.mask = resource.mstyle.tick_image.mask = None;
+
XFreeGC(blackbox->getXDisplay(), opGC);
}
resource.wstyle.b_pressed =
readDatabaseTexture("window.button.pressed", "black", style);
+ if (resource.wstyle.close_button.mask != None)
+ XFreePixmap(blackbox->getXDisplay(), resource.wstyle.close_button.mask);
+ if (resource.wstyle.max_button.mask != None)
+ XFreePixmap(blackbox->getXDisplay(), resource.wstyle.max_button.mask);
+ if (resource.wstyle.icon_button.mask != None)
+ XFreePixmap(blackbox->getXDisplay(), resource.wstyle.icon_button.mask);
+ if (resource.wstyle.stick_button.mask != None)
+ XFreePixmap(blackbox->getXDisplay(), resource.wstyle.stick_button.mask);
+
+ resource.wstyle.close_button.mask = resource.wstyle.max_button.mask =
+ resource.wstyle.icon_button.mask =
+ resource.wstyle.icon_button.mask = None;
+
+ readDatabaseMask("window.button.close_mask", resource.wstyle.close_button,
+ style);
+ readDatabaseMask("window.button.max_mask", resource.wstyle.max_button,
+ style);
+ readDatabaseMask("window.button.icon_mask", resource.wstyle.icon_button,
+ style);
+ readDatabaseMask("window.button.stick_mask", resource.wstyle.stick_button,
+ style);
+
// we create the window.frame texture by hand because it exists only to
// make the code cleaner and is not actually used for display
BColor color = readDatabaseColor("window.frame.focusColor", "white", style);
if (resource.wstyle.h_unfocus.texture() == BTexture::Parent_Relative)
resource.wstyle.h_unfocus = resource.wstyle.f_unfocus;
-// load toolbar config
+ // load toolbar config
+ if (resource.tstyle.left_button.mask != None)
+ XFreePixmap(blackbox->getXDisplay(), resource.tstyle.left_button.mask);
+ if (resource.tstyle.right_button.mask != None)
+ XFreePixmap(blackbox->getXDisplay(), resource.tstyle.right_button.mask);
+
resource.tstyle.toolbar =
readDatabaseTexture("toolbar", "black", style);
resource.tstyle.label =
readDatabaseColor("toolbar.clock.textColor", "white", style);
resource.tstyle.b_pic =
readDatabaseColor("toolbar.button.picColor", "black", style);
-
+ readDatabaseMask("toolbar.button.left_mask", resource.tstyle.left_button,
+ style);
+ readDatabaseMask("toolbar.button.right_mask", resource.tstyle.right_button,
+ style);
+
resource.tstyle.justify = LeftJustify;
if (style.getValue("toolbar.justify", s)) {
if (s == "right" || s == "Right")
}
// load menu config
+ if (resource.mstyle.bullet_image.mask != None)
+ XFreePixmap(blackbox->getXDisplay(), resource.mstyle.bullet_image.mask);
+ if (resource.mstyle.tick_image.mask != None)
+ XFreePixmap(blackbox->getXDisplay(), resource.mstyle.tick_image.mask);
+
resource.mstyle.title =
readDatabaseTexture("menu.title", "white", style);
resource.mstyle.frame =
readDatabaseColor("menu.frame.disableColor", "black", style);
resource.mstyle.h_text =
readDatabaseColor("menu.hilite.textColor", "black", style);
-
+ readDatabaseMask("menu.bullet.mask", resource.mstyle.bullet_image, style);
+ readDatabaseMask("menu.selected.mask", resource.mstyle.tick_image, style);
+
resource.mstyle.t_justify = LeftJustify;
if (style.getValue("menu.title.justify", s)) {
if (s == "right" || s == "Right")
std::mem_fun(&BlackboxWindow::grabButtons));
}
+void BScreen::readDatabaseMask(const string &rname, PixmapMask &pixmapMask,
+ const Configuration &style) {
+ string s;
+ int hx, hy; //ignored
+ int ret = BitmapOpenFailed; //default to failure.
+
+ if (style.getValue(rname, s))
+ {
+ if (s[0] != '/' && s[0] != '~')
+ {
+ std::string xbmFile = std::string("~/.openbox/buttons/") + s;
+ ret = XReadBitmapFile(blackbox->getXDisplay(), getRootWindow(),
+ expandTilde(xbmFile).c_str(), &pixmapMask.w,
+ &pixmapMask.h, &pixmapMask.mask, &hx, &hy);
+ } else
+ ret = XReadBitmapFile(blackbox->getXDisplay(), getRootWindow(),
+ expandTilde(s).c_str(), &pixmapMask.w,
+ &pixmapMask.h, &pixmapMask.mask, &hx, &hy);
+
+ if (ret == BitmapSuccess)
+ return;
+ }
+
+ pixmapMask.mask = None;
+ pixmapMask.w = pixmapMask.h = 0;
+}
BTexture BScreen::readDatabaseTexture(const string &rname,
const string &default_color,
enum TextJustify { LeftJustify = 1, RightJustify, CenterJustify };
+struct PixmapMask {
+ Pixmap mask;
+ unsigned int w, h;
+};
+
struct WindowStyle {
BColor l_text_focus, l_text_unfocus, b_pic_focus,
b_pic_unfocus;
BTexture f_focus, f_unfocus, t_focus, t_unfocus, l_focus, l_unfocus,
h_focus, h_unfocus, b_focus, b_unfocus, b_pressed, g_focus, g_unfocus;
+ PixmapMask close_button, max_button, icon_button, stick_button;
+
BFont *font;
TextJustify justify;
BColor l_text, w_text, c_text, b_pic;
BTexture toolbar, label, window, button, pressed, clock;
+ PixmapMask left_button, right_button; //these should probably be the same
+
BFont *font;
TextJustify justify;
BColor t_text, f_text, h_text, d_text;
BTexture title, frame, hilite;
+ PixmapMask bullet_image, tick_image;
+
BFont *t_font, *f_font;
TextJustify t_justify, f_justify;
bool parseMenuFile(FILE *file, Rootmenu *menu);
+ void readDatabaseMask(const string &rname,
+ PixmapMask &pixmapMask,
+ const Configuration &style);
BTexture readDatabaseTexture(const std::string &rname,
const std::string &default_color,
const Configuration &style);
void Toolbar::drawArrow(Drawable surface, bool left) const {
+ ToolbarStyle *style = screen->getToolbarStyle();
+
+ BPen pen(style->b_pic);
+
int hh = frame.button_w / 2, hw = frame.button_w / 2;
XPoint pts[3];
const int bullet_size = 3;
+
if (left) {
- pts[0].x = hw - bullet_size;
- pts[0].y = hh;
- pts[1].x = 2 * bullet_size;
- pts[1].y = bullet_size;
- pts[2].x = 0;
- pts[2].y = -(2 * bullet_size);
+ if (style->left_button.mask == None) {
+ pts[0].x = hw - bullet_size;
+ pts[0].y = hh;
+ pts[1].x = 2 * bullet_size;
+ pts[1].y = bullet_size;
+ pts[2].x = 0;
+ pts[2].y = -(2 * bullet_size);
+ XFillPolygon(display, surface, pen.gc(), pts, 3, Convex,
+ CoordModePrevious);
+ } else {
+ XSetClipMask(blackbox->getXDisplay(), pen.gc(), style->left_button.mask);
+ XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+ (frame.button_w - style->left_button.w)/2,
+ (frame.button_w - style->left_button.h)/2);
+
+ XFillRectangle(blackbox->getXDisplay(), surface, pen.gc(),
+ (frame.button_w - style->left_button.w)/2,
+ (frame.button_w - style->left_button.h)/2,
+ (frame.button_w + style->left_button.w)/2,
+ (frame.button_w + style->left_button.h)/2);
+
+ XSetClipMask(blackbox->getXDisplay(), pen.gc(), None);
+ XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0);
+ }
} else {
- pts[0].x = hw - bullet_size;
- pts[0].y = hh - bullet_size;
- pts[1].x = (2 * bullet_size);
- pts[1].y = bullet_size;
- pts[2].x = -(2 * bullet_size);
- pts[2].y = bullet_size;
+ if (style->right_button.mask == None) {
+ pts[0].x = hw - bullet_size;
+ pts[0].y = hh - bullet_size;
+ pts[1].x = (2 * bullet_size);
+ pts[1].y = bullet_size;
+ pts[2].x = -(2 * bullet_size);
+ pts[2].y = bullet_size;
+ XFillPolygon(display, surface, pen.gc(), pts, 3, Convex,
+ CoordModePrevious);
+ } else {
+ XSetClipMask(blackbox->getXDisplay(), pen.gc(),
+ style->right_button.mask);
+ XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+ (frame.button_w - style->right_button.w)/2,
+ (frame.button_w - style->right_button.h)/2);
+
+ XFillRectangle(blackbox->getXDisplay(), surface, pen.gc(),
+ (frame.button_w - style->right_button.w)/2,
+ (frame.button_w - style->right_button.h)/2,
+ (frame.button_w + style->right_button.w)/2,
+ (frame.button_w + style->right_button.h)/2);
+
+ XSetClipMask(blackbox->getXDisplay(), pen.gc(), None);
+ XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0);
+ }
}
-
- BPen pen(screen->getToolbarStyle()->b_pic);
- XFillPolygon(display, surface, pen.gc(), pts, 3, Convex, CoordModePrevious);
}
if (frame.stick_button)
destroyStickyButton();
-
+
if (frame.ftitle)
screen->getImageControl()->removeImage(frame.ftitle);
XSetWindowBackground(blackbox->getXDisplay(),
frame.iconify_button, frame.pbutton_pixel);
}
- XClearWindow(blackbox->getXDisplay(), frame.iconify_button);
+ XClearWindow(blackbox->getXDisplay(), frame.iconify_button);
BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
- screen->getWindowStyle()->b_pic_unfocus);
- XDrawRectangle(blackbox->getXDisplay(), frame.iconify_button, pen.gc(),
- 2, (frame.button_w - 5), (frame.button_w - 5), 2);
+ screen->getWindowStyle()->b_pic_unfocus);
+
+ PixmapMask pm = screen->getWindowStyle()->icon_button;
+
+ if (screen->getWindowStyle()->icon_button.mask != None) {
+ XSetClipMask(blackbox->getXDisplay(), pen.gc(), pm.mask);
+ XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+ (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2);
+
+ XFillRectangle(blackbox->getXDisplay(), frame.iconify_button, pen.gc(),
+ (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2,
+ (frame.button_w + pm.w)/2, (frame.button_w + pm.h)/2);
+
+ XSetClipMask(blackbox->getXDisplay(), pen.gc(), None);
+ XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0);
+ } else {
+
+ XDrawRectangle(blackbox->getXDisplay(), frame.iconify_button, pen.gc(),
+ 2, (frame.button_w - 5), (frame.button_w - 5), 2);
+ }
}
BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
screen->getWindowStyle()->b_pic_unfocus);
- XDrawRectangle(blackbox->getXDisplay(), frame.maximize_button, pen.gc(),
- 2, 2, (frame.button_w - 5), (frame.button_w - 5));
- XDrawLine(blackbox->getXDisplay(), frame.maximize_button, pen.gc(),
- 2, 3, (frame.button_w - 3), 3);
+
+ PixmapMask pm = screen->getWindowStyle()->max_button;
+
+ if (pm.mask != None) {
+ XSetClipMask(blackbox->getXDisplay(), pen.gc(), pm.mask);
+ XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+ (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2);
+
+ XFillRectangle(blackbox->getXDisplay(), frame.maximize_button, pen.gc(),
+ (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2,
+ (frame.button_w + pm.w)/2, (frame.button_w + pm.h)/2);
+
+ XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 );
+ XSetClipMask( blackbox->getXDisplay(), pen.gc(), None );
+ } else {
+ XDrawRectangle(blackbox->getXDisplay(), frame.maximize_button, pen.gc(),
+ 2, 2, (frame.button_w - 5), (frame.button_w - 5));
+ XDrawLine(blackbox->getXDisplay(), frame.maximize_button, pen.gc(),
+ 2, 3, (frame.button_w - 3), 3);
+ }
}
if (! pressed) {
if (flags.focused) {
if (frame.fbutton)
- XSetWindowBackgroundPixmap(blackbox->getXDisplay(), frame.close_button,
- frame.fbutton);
+ XSetWindowBackgroundPixmap(blackbox->getXDisplay(),
+ frame.close_button, frame.fbutton);
else
XSetWindowBackground(blackbox->getXDisplay(), frame.close_button,
frame.fbutton_pixel);
BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
screen->getWindowStyle()->b_pic_unfocus);
+
+ PixmapMask pm = screen->getWindowStyle()->stick_button;
+
+ if (pm.mask != None) {
+ XSetClipMask(blackbox->getXDisplay(), pen.gc(), pm.mask);
+ XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+ (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2);
+
+ XFillRectangle(blackbox->getXDisplay(), frame.stick_button, pen.gc(),
+ (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2,
+ (frame.button_w + pm.w)/2, (frame.button_w + pm.h)/2);
+
- XFillRectangle(blackbox->getXDisplay(), frame.stick_button, pen.gc(),
- frame.button_w/2 - 1, frame.button_w/2 -1, 2, 2 );
+ XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 );
+ XSetClipMask( blackbox->getXDisplay(), pen.gc(), None );
+ } else {
+ XFillRectangle(blackbox->getXDisplay(), frame.stick_button, pen.gc(),
+ frame.button_w/2 - 1, frame.button_w/2 -1, 2, 2 );
+ }
}
void BlackboxWindow::mapRequestEvent(const XMapRequestEvent *re) {