From: Scott Moynes Date: Sat, 14 Sep 2002 05:43:57 +0000 (+0000) Subject: added a configure flag for enabling/disabling bitmap buttons X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=e0d619e309a7fe6de1524b2574ecc9d77aee5a35;p=chaz%2Fopenbox added a configure flag for enabling/disabling bitmap buttons --- diff --git a/configure.in b/configure.in index 016dc9b2..5e490070 100644 --- a/configure.in +++ b/configure.in @@ -249,6 +249,25 @@ if test x$TIMEDCACHE = "xyes"; then AC_DEFINE(TIMEDCACHE,1,Use timed pixmap cache) fi +dnl Check for bitmapped buttons +BITMAPBUTTONS="" +AC_MSG_CHECKING([whether to include bitmappable buttons]) +AC_ARG_ENABLE( + bitmap-buttons, +[ --enable-bitmap-buttons include bitmappable buttons [default=yes]], + if test x$enableval = "xyes"; then + AC_MSG_RESULT([yes]) + BITMAPBUTTONS="yes" + else + AC_MSG_RESULT([no]) + fi, + AC_MSG_RESULT([yes]) + BITMAPBUTTONS="yes" +) +if test x$BITMAPBUTTONS = "xyes"; then + AC_DEFINE(BITMAPBUTTONS,1,Include bitmappable buttons) +fi + dnl Determine the return type of signal handlers AC_TYPE_SIGNAL diff --git a/src/Basemenu.cc b/src/Basemenu.cc index e54ef19c..322576c5 100644 --- a/src/Basemenu.cc +++ b/src/Basemenu.cc @@ -621,6 +621,7 @@ void Basemenu::drawItem(int index, bool highlight, bool clear, } if (dooppsel && item->isSelected()) { +#ifdef BITMAPBUTTONS if ( style->tick_image.mask != None) { XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), oppsel_x, item_y + menu.item_h/2 - style->tick_image.h/2); @@ -637,6 +638,7 @@ void Basemenu::drawItem(int index, bool highlight, bool clear, XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0); } else { +#endif // BITMAPBUTTONS XPoint pts[6]; pts[0].x = oppsel_x + 0; @@ -660,7 +662,9 @@ void Basemenu::drawItem(int index, bool highlight, bool clear, XFillPolygon(display, menu.frame, pen.gc(), pts, 6, Nonconvex, CoordModePrevious); +#ifdef BITMAPBUTTONS } +#endif // BITMAPBUTTONS } if (dotext && text) { @@ -672,6 +676,7 @@ void Basemenu::drawItem(int index, bool highlight, bool clear, } if (dosel && item->submenu()) { +#ifdef BITMAPBUTTONS if ( style->bullet_image.mask != None) { XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), sel_x, item_y + menu.item_h/2 - style->bullet_image.h/2); @@ -687,6 +692,7 @@ void Basemenu::drawItem(int index, bool highlight, bool clear, XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0); } else { +#endif // BITMAPBUTTONS const int bullet_size = 3; switch (screen->getMenuStyle()->bullet) { @@ -734,7 +740,9 @@ void Basemenu::drawItem(int index, bool highlight, bool clear, CoordModePrevious); break; } +#ifdef BITMAPBUTTONS } +#endif // BITMAPBUTTONS } } diff --git a/src/Screen.cc b/src/Screen.cc index ea27d506..987f923b 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -339,6 +339,7 @@ BScreen::~BScreen(void) { if (resource.tstyle.font) delete resource.tstyle.font; +#ifdef BITMAPBUTTONS if (resource.wstyle.close_button.mask != None) XFreePixmap(blackbox->getXDisplay(), resource.wstyle.close_button.mask); if (resource.wstyle.max_button.mask != None) @@ -363,6 +364,7 @@ BScreen::~BScreen(void) { 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; +#endif // BITMAPBUTTONS XFreeGC(blackbox->getXDisplay(), opGC); } @@ -1062,6 +1064,7 @@ void BScreen::LoadStyle(void) { resource.wstyle.b_pressed = readDatabaseTexture("window.button.pressed", "black", style); +#ifdef BITMAPBUTTONS if (resource.wstyle.close_button.mask != None) XFreePixmap(blackbox->getXDisplay(), resource.wstyle.close_button.mask); if (resource.wstyle.max_button.mask != None) @@ -1083,6 +1086,7 @@ void BScreen::LoadStyle(void) { style); readDatabaseMask("window.button.stick.mask", resource.wstyle.stick_button, style); +#endif // BITMAPBUTTONS // we create the window.frame texture by hand because it exists only to // make the code cleaner and is not actually used for display @@ -1124,10 +1128,12 @@ void BScreen::LoadStyle(void) { resource.wstyle.h_unfocus = resource.wstyle.f_unfocus; // load toolbar config +#ifdef BITMAPBUTTONS 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); +#endif // BITMAPBUTTONS resource.tstyle.toolbar = readDatabaseTexture("toolbar", "black", style); @@ -1149,10 +1155,13 @@ void BScreen::LoadStyle(void) { readDatabaseColor("toolbar.clock.textColor", "white", style); resource.tstyle.b_pic = readDatabaseColor("toolbar.button.picColor", "black", style); + +#ifdef BITMAPBUTTONS readDatabaseMask("toolbar.button.left.mask", resource.tstyle.left_button, style); readDatabaseMask("toolbar.button.right.mask", resource.tstyle.right_button, style); +#endif // BITMAPBUTTONS resource.tstyle.justify = LeftJustify; if (style.getValue("toolbar.justify", s)) { @@ -1171,10 +1180,12 @@ void BScreen::LoadStyle(void) { } // load menu config +#ifdef BITMAPBUTTONS 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); +#endif // BITMAPBUTTONS resource.mstyle.title = readDatabaseTexture("menu.title", "white", style); @@ -1190,8 +1201,11 @@ void BScreen::LoadStyle(void) { readDatabaseColor("menu.frame.disableColor", "black", style); resource.mstyle.h_text = readDatabaseColor("menu.hilite.textColor", "black", style); + +#ifdef BITMAPBUTTONS readDatabaseMask("menu.arrow.mask", resource.mstyle.bullet_image, style); readDatabaseMask("menu.selected.mask", resource.mstyle.tick_image, style); +#endif // BITMAPBUTTONS resource.mstyle.t_justify = LeftJustify; if (style.getValue("menu.title.justify", s)) { @@ -2629,6 +2643,7 @@ void BScreen::toggleFocusModel(FocusModel model) { std::mem_fun(&BlackboxWindow::grabButtons)); } +#ifdef BITMAPBUTTONS void BScreen::readDatabaseMask(const string &rname, PixmapMask &pixmapMask, const Configuration &style) { string s; @@ -2655,6 +2670,7 @@ void BScreen::readDatabaseMask(const string &rname, PixmapMask &pixmapMask, pixmapMask.mask = None; pixmapMask.w = pixmapMask.h = 0; } +#endif // BITMAPSUCCESS BTexture BScreen::readDatabaseTexture(const string &rname, const string &default_color, diff --git a/src/Screen.hh b/src/Screen.hh index 9c1a185c..517e186c 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -61,10 +61,12 @@ struct Strut; enum TextJustify { LeftJustify = 1, RightJustify, CenterJustify }; +#ifdef BITMAPBUTTONS struct PixmapMask { Pixmap mask; unsigned int w, h; }; +#endif // BITMAPBUTTONS struct WindowStyle { BColor l_text_focus, l_text_unfocus, b_pic_focus, @@ -72,8 +74,9 @@ struct WindowStyle { 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; +#ifdef BITMAPBUTTONS PixmapMask close_button, max_button, icon_button, stick_button; - +#endif // BITMAPBUTTONS BFont *font; TextJustify justify; @@ -86,7 +89,9 @@ struct ToolbarStyle { 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 +#ifdef BITMAPBUTTONS + PixmapMask left_button, right_button; +#endif // BITMAPBUTTONS BFont *font; @@ -99,8 +104,10 @@ struct ToolbarStyle { struct MenuStyle { BColor t_text, f_text, h_text, d_text; BTexture title, frame, hilite; - + +#ifdef BITMAPBUTTONS PixmapMask bullet_image, tick_image; +#endif // BITMAPBUTTONS BFont *t_font, *f_font; @@ -191,9 +198,12 @@ private: bool parseMenuFile(FILE *file, Rootmenu *menu); +#ifdef BITMAPBUTTONS void readDatabaseMask(const string &rname, PixmapMask &pixmapMask, const Configuration &style); +#endif // BITMAPBUTTONS + BTexture readDatabaseTexture(const std::string &rname, const std::string &default_color, const Configuration &style); diff --git a/src/Toolbar.cc b/src/Toolbar.cc index d7dc36a4..d2e2f15f 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -633,16 +633,8 @@ void Toolbar::drawArrow(Drawable surface, bool left) const { if (left) { - 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 { +#ifdef BITMAPBUTTONS + if (style->left_button.mask != None) { XSetClipMask(blackbox->getXDisplay(), pen.gc(), style->left_button.mask); XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), (frame.button_w - style->left_button.w)/2, @@ -655,18 +647,22 @@ void Toolbar::drawArrow(Drawable surface, bool left) const { XSetClipMask(blackbox->getXDisplay(), pen.gc(), None); XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0); - } - } else { - if (style->right_button.mask == None) { + } else { +#endif // BITMAPBUTTONS 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; + 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 { +#ifdef BITMAPBUTTONS + } +#endif // BITMAPBUTTONS + } else { +#ifdef BITMAPBUTTONS + if (style->right_button.mask != None) { XSetClipMask(blackbox->getXDisplay(), pen.gc(), style->right_button.mask); XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), @@ -681,7 +677,19 @@ void Toolbar::drawArrow(Drawable surface, bool left) const { XSetClipMask(blackbox->getXDisplay(), pen.gc(), None); XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0); + } else { +#endif // BITMAPBUTTONS + 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); +#ifdef BITMAPBUTTONS } +#endif } } diff --git a/src/Window.cc b/src/Window.cc index a5263384..3005674b 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -2618,7 +2618,7 @@ void BlackboxWindow::redrawIconifyButton(bool pressed) const { XClearWindow(blackbox->getXDisplay(), frame.iconify_button); BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : screen->getWindowStyle()->b_pic_unfocus); - +#ifdef BITMAPBUTTONS PixmapMask pm = screen->getWindowStyle()->icon_button; if (screen->getWindowStyle()->icon_button.mask != None) { @@ -2633,10 +2633,12 @@ void BlackboxWindow::redrawIconifyButton(bool pressed) const { XSetClipMask(blackbox->getXDisplay(), pen.gc(), None); XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0); } else { - +#endif // BITMAPBUTTONS XDrawRectangle(blackbox->getXDisplay(), frame.iconify_button, pen.gc(), 2, (frame.button_w - 5), (frame.button_w - 5), 2); +#ifdef BITMAPBUTTONS } +#endif // BITMAPBUTTONS } @@ -2669,7 +2671,8 @@ void BlackboxWindow::redrawMaximizeButton(bool pressed) const { BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : screen->getWindowStyle()->b_pic_unfocus); - + +#ifdef BITMAPBUTTONS PixmapMask pm = screen->getWindowStyle()->max_button; if (pm.mask != None) { @@ -2684,11 +2687,14 @@ void BlackboxWindow::redrawMaximizeButton(bool pressed) const { XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 ); XSetClipMask( blackbox->getXDisplay(), pen.gc(), None ); } else { +#endif // BITMAPBUTTONS 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); +#ifdef BITMAPBUTTONS } +#endif // BITMAPBUTTONS } @@ -2721,7 +2727,8 @@ void BlackboxWindow::redrawCloseButton(bool pressed) const { BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : screen->getWindowStyle()->b_pic_unfocus); - + +#ifdef BITMAPBUTTONS PixmapMask pm = screen->getWindowStyle()->close_button; if (pm.mask != None) { @@ -2737,11 +2744,14 @@ void BlackboxWindow::redrawCloseButton(bool pressed) const { XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 ); XSetClipMask( blackbox->getXDisplay(), pen.gc(), None ); } else { +#endif // BITMAPBUTTONS XDrawLine(blackbox->getXDisplay(), frame.close_button, pen.gc(), 2, 2, (frame.button_w - 3), (frame.button_w - 3)); XDrawLine(blackbox->getXDisplay(), frame.close_button, pen.gc(), 2, (frame.button_w - 3), (frame.button_w - 3), 2); +#ifdef BITMAPBUTTONS } +#endif // BITMAPBUTTONS } void BlackboxWindow::redrawStickyButton(bool pressed) const { @@ -2773,7 +2783,8 @@ void BlackboxWindow::redrawStickyButton(bool pressed) const { BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : screen->getWindowStyle()->b_pic_unfocus); - + +#ifdef BITMAPBUTTONS PixmapMask pm = screen->getWindowStyle()->stick_button; if (pm.mask != None) { @@ -2789,9 +2800,12 @@ void BlackboxWindow::redrawStickyButton(bool pressed) const { XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 ); XSetClipMask( blackbox->getXDisplay(), pen.gc(), None ); } else { +#endif // BITMAPBUTTONS XFillRectangle(blackbox->getXDisplay(), frame.stick_button, pen.gc(), frame.button_w/2 - 1, frame.button_w/2 -1, 2, 2 ); +#ifdef BITMAPBUTTONS } +#endif } void BlackboxWindow::mapRequestEvent(const XMapRequestEvent *re) {