cosmetic + avoid unneeded App::instance()->display() calls
@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: MenuItem.cc,v 1.8 2004/09/01 08:00:24 akir Exp $ +// $Id: MenuItem.cc,v 1.9 2004/09/10 16:48:15 akir Exp $ #include "MenuItem.hh" #include "Command.hh"@@ -37,11 +37,13 @@ if (m_command.get() != 0)
m_command->execute(); } -void MenuItem::draw(FbDrawable &draw, +void MenuItem::draw(FbDrawable &draw, const MenuTheme &theme, bool highlight, - int x, int y, + int x, int y, unsigned int width, unsigned int height) const { + + Display *disp = App::instance()->display(); // // Icon //@@ -58,11 +60,8 @@ GC gc = theme.frameTextGC().gc();
int icon_x = x + theme.bevelWidth(); int icon_y = y + theme.bevelWidth(); // enable clip mask - XSetClipMask(FbTk::App::instance()->display(), - gc, - m_icon->pixmap->mask().drawable()); - XSetClipOrigin(FbTk::App::instance()->display(), - gc, icon_x, icon_y); + XSetClipMask(disp, gc, m_icon->pixmap->mask().drawable()); + XSetClipOrigin(disp, gc, icon_x, icon_y); draw.copyArea(m_icon->pixmap->pixmap().drawable(), gc,@@ -71,9 +70,7 @@ icon_x, icon_y,
m_icon->pixmap->width(), m_icon->pixmap->height()); // restore clip mask - XSetClipMask(FbTk::App::instance()->display(), - gc, - None); + XSetClipMask(disp, gc, None); } }@@ -90,7 +87,7 @@ //
int text_y = y, text_x = x; int text_w = theme.frameFont().textWidth(label().c_str(), label().size()); - + int height_offset = theme.itemHeight() - (theme.frameFont().height() + 2*theme.bevelWidth()); text_y = y + theme.bevelWidth() + theme.frameFont().ascent() + height_offset/2; ///2 + height/2;@@ -98,15 +95,15 @@ switch(theme.frameFontJustify()) {
case FbTk::LEFT: text_x = x + theme.bevelWidth() + height + 1; break; - + case FbTk::RIGHT: text_x = x + width - (height + theme.bevelWidth() + text_w); - break; + break; default: //center text_x = x + ((width + 1 - text_w) / 2); break; } - + theme.frameFont().drawText(draw.drawable(), // drawable theme.screenNum(), tgc.gc(),@@ -127,11 +124,8 @@ //
// ToggleItem // if (isToggleItem() && theme.unselectedPixmap().pixmap().drawable() != 0) { - XSetClipMask(FbTk::App::instance()->display(), - gc, - theme.unselectedPixmap().mask().drawable()); - XSetClipOrigin(FbTk::App::instance()->display(), - gc, sel_x, y); + XSetClipMask(disp, gc, theme.unselectedPixmap().mask().drawable()); + XSetClipOrigin(disp, gc, sel_x, y); // copy bullet pixmap to drawable draw.copyArea(theme.unselectedPixmap().pixmap().drawable(), gc,@@ -140,22 +134,17 @@ sel_x, y,
theme.unselectedPixmap().width(), theme.unselectedPixmap().height()); // disable clip mask - XSetClipMask(FbTk::App::instance()->display(), - gc, - None); + XSetClipMask(disp, gc, None); } - // + // // Submenu // if (submenu()) { if (theme.bulletPixmap().pixmap().drawable() != 0) { // enable clip mask - XSetClipMask(FbTk::App::instance()->display(), - gc, - theme.bulletPixmap().mask().drawable()); - XSetClipOrigin(FbTk::App::instance()->display(), - gc, sel_x, y); + XSetClipMask(disp, gc, theme.bulletPixmap().mask().drawable()); + XSetClipOrigin(disp, gc, sel_x, y); // copy bullet pixmap to frame draw.copyArea(theme.bulletPixmap().pixmap().drawable(), gc,@@ -164,9 +153,7 @@ sel_x, y,
theme.bulletPixmap().width(), theme.bulletPixmap().height()); // disable clip mask - XSetClipMask(FbTk::App::instance()->display(), - gc, - None); + XSetClipMask(disp, gc, None); } else { unsigned int half_w = height / 2, quarter_w = height / 4; int sel_y = y + height/4;@@ -193,11 +180,11 @@ tri[1].y = 2;
tri[2].x = 0; tri[2].y = -4; } - + draw.fillPolygon(gc, tri, 3, Convex, CoordModePrevious); break; - + case MenuTheme::DIAMOND: XPoint dia[4];@@ -233,7 +220,7 @@ if (m_icon.get() == 0)
m_icon.reset(new Icon); m_icon->filename = FbTk::StringUtil::expandFilename(filename); - m_icon->pixmap.reset(Image::load(m_icon->filename.c_str(), + m_icon->pixmap.reset(Image::load(m_icon->filename.c_str(), screen_num)); }@@ -245,8 +232,8 @@ unsigned int MenuItem::width(const MenuTheme &theme) const {
// textwidth + bevel width on each side of the text const unsigned int icon_width = height(theme); const unsigned int normal = theme.frameFont().textWidth(label().c_str(), label().size()) + - 2 * (theme.bevelWidth() + icon_width); - + 2 * (theme.bevelWidth() + icon_width); + return m_icon.get() == 0 ? normal : normal + icon_width; }
@@ -1,6 +1,6 @@
// Transparent.cc for FbTk - Fluxbox Toolkit // Copyright (c) 2003 Henrik Kinnunen (fluxgen(at)users.sourceforge.net) -// +// // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Transparent.cc,v 1.6 2004/06/07 11:46:05 rathnor Exp $ +// $Id: Transparent.cc,v 1.7 2004/09/10 16:48:15 akir Exp $ #include "Transparent.hh" #include "App.hh"@@ -47,7 +47,7 @@ // try to find a specific render format
XRenderPictFormat pic_format; pic_format.type = PictTypeDirect; pic_format.depth = 8; // alpha with bit depth 8 - pic_format.direct.alphaMask = 0xff; + pic_format.direct.alphaMask = 0xff; XRenderPictFormat *format = XRenderFindFormat(disp, PictFormatType | PictFormatDepth | PictFormatAlphaMask, &pic_format, 0);@@ -109,8 +109,8 @@
// check for RENDER support if (!s_init) { int major_opcode, first_event, first_error; - if (XQueryExtension(disp, "RENDER", - &major_opcode, + if (XQueryExtension(disp, "RENDER", + &major_opcode, &first_event, &first_error) == False) { s_render = false; } else { // we got RENDER support@@ -119,7 +119,7 @@ }
s_init = true; } - + #ifdef HAVE_XRENDER if (!s_render) return;@@ -127,13 +127,13 @@
allocAlpha(m_alpha); - XRenderPictFormat *format = - XRenderFindVisualFormat(disp, + XRenderPictFormat *format = + XRenderFindVisualFormat(disp, DefaultVisual(disp, screen_num)); if (src != 0 && format != 0) { - m_src_pic = XRenderCreatePicture(disp, src, format, + m_src_pic = XRenderCreatePicture(disp, src, format, 0, 0); }@@ -181,8 +181,8 @@ }
// create new dest pic if we have a valid dest drawable if (dest != 0) { - XRenderPictFormat *format = - XRenderFindVisualFormat(disp, + XRenderPictFormat *format = + XRenderFindVisualFormat(disp, DefaultVisual(disp, screen_num)); if (format == 0) { _FB_USES_NLS;@@ -191,7 +191,7 @@ fprintf(stderr, _FBTKTEXT(Error, NoRenderVisualFormat, "Failed to find format for screen(%d)", "XRenderFindVisualFormat failed... include %d for screen number"), screen_num);
cerr<<endl; } m_dest_pic = XRenderCreatePicture(disp, dest, format, 0, 0); - + } m_dest = dest;@@ -208,7 +208,7 @@ unsigned char old_alpha = m_alpha;
if (m_alpha_pic != 0) freeAlpha(); - Display *disp = FbTk::App::instance()->display(); + Display *disp = FbTk::App::instance()->display(); if (m_src_pic != 0) { XRenderFreePicture(disp, m_src_pic);@@ -220,8 +220,8 @@
// create new source pic if we have a valid source drawable if (m_source != 0) { - XRenderPictFormat *format = - XRenderFindVisualFormat(disp, + XRenderPictFormat *format = + XRenderFindVisualFormat(disp, DefaultVisual(disp, screen_num)); if (format == 0) { _FB_USES_NLS;@@ -229,8 +229,8 @@ cerr<<"FbTk::Transparent: ";
fprintf(stderr, _FBTKTEXT(Error, NoRenderVisualFormat, "Failed to find format for screen(%d)", "XRenderFindVisualFormat failed... include %d for screen number"), screen_num); cerr<<endl; } - m_src_pic = XRenderCreatePicture(disp, m_source, format, - 0, 0); + m_src_pic = XRenderCreatePicture(disp, m_source, format, + 0, 0); } // recreate new alpha@@ -247,13 +247,13 @@ if (m_src_pic == 0 || m_dest_pic == 0 ||
m_alpha_pic == 0 || !s_render) return; // render src+alpha to dest picture - XRenderComposite(FbTk::App::instance()->display(), - PictOpOver, + XRenderComposite(FbTk::App::instance()->display(), + PictOpOver, m_src_pic, - m_alpha_pic, - m_dest_pic, + m_alpha_pic, + m_dest_pic, src_x, src_y, - 0, 0, + 0, 0, dest_x, dest_y, width, height);@@ -284,4 +284,4 @@
}; // end namespace FbTk - +