added pixmap for bullet and selected and unselected

This commit is contained in:
fluxgen 2003-08-27 14:14:04 +00:00
parent 097fcff44f
commit 2be2a2b5cc
2 changed files with 174 additions and 167 deletions

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Menu.cc,v 1.35 2003/08/24 16:57:38 fluxgen Exp $
// $Id: Menu.cc,v 1.36 2003/08/27 14:14:04 fluxgen Exp $
//use GNU extensions
#ifndef _GNU_SOURCE
@ -820,21 +820,18 @@ void Menu::drawItem(unsigned int index, bool highlight, bool clear, bool render_
sel_y = item_y + quarter_w;
if (clear) {
GC def_gc = XCreateGC(m_display, menu.frame.window(), 0, 0);
FbTk::GContext def_gc(menu.frame.window());
if (menu.frame_pixmap == 0) {
XSetForeground(m_display, def_gc, m_theme.frameTexture().color().pixel());
m_frame_pm.fillRectangle(def_gc, item_x, item_y, menu.item_w, menu.item_h);
def_gc.setForeground(m_theme.frameTexture().color());
m_frame_pm.fillRectangle(def_gc.gc(), item_x, item_y, menu.item_w, menu.item_h);
} else {
m_frame_pm.copyArea(menu.frame_pixmap, def_gc,
m_frame_pm.copyArea(menu.frame_pixmap, def_gc.gc(),
item_x, item_y,
item_x, item_y,
menu.item_w, menu.item_h);
}
XFreeGC(m_display, def_gc);
} else if (! (x == y && y == -1 && w == h && h == 0)) {
// calculate the which part of the hilite to redraw
if (! (std::max(item_x, x) <= (signed) std::min(item_x + menu.item_w, x + w) &&
@ -875,8 +872,28 @@ void Menu::drawItem(unsigned int index, bool highlight, bool clear, bool render_
}
if (dosel && item->isSelected() &&
(menu.sel_pixmap != ParentRelative)) {
if (item->isToggleItem() && item->isSelected() &&
menu.sel_pixmap != ParentRelative) {
if (m_theme.selectedPixmap().pixmap().drawable()) {
// enable clip mask
XSetClipMask(FbTk::App::instance()->display(),
gc,
m_theme.selectedPixmap().mask().drawable());
XSetClipOrigin(FbTk::App::instance()->display(),
gc, sel_x, item_y);
// copy bullet pixmap to frame
m_frame_pm.copyArea(m_theme.selectedPixmap().pixmap().drawable(),
gc,
0, 0,
sel_x, item_y,
m_theme.selectedPixmap().width(),
m_theme.selectedPixmap().height());
// disable clip mask
XSetClipMask(FbTk::App::instance()->display(),
gc,
None);
} else {
if (menu.sel_pixmap) {
m_frame_pm.copyArea(highlight ? menu.frame_pixmap : menu.sel_pixmap,
m_theme.hiliteGC(),
@ -887,7 +904,26 @@ void Menu::drawItem(unsigned int index, bool highlight, bool clear, bool render_
m_frame_pm.fillRectangle(m_theme.hiliteGC(),
sel_x, sel_y, half_w, half_w);
}
}
} else if (item->isToggleItem() && m_theme.unselectedPixmap().pixmap().drawable() != 0) {
// enable clip mask
XSetClipMask(FbTk::App::instance()->display(),
gc,
m_theme.unselectedPixmap().mask().drawable());
XSetClipOrigin(FbTk::App::instance()->display(),
gc, sel_x, item_y);
// copy bullet pixmap to frame
m_frame_pm.copyArea(m_theme.unselectedPixmap().pixmap().drawable(),
gc,
0, 0,
sel_x, item_y,
m_theme.unselectedPixmap().width(),
m_theme.unselectedPixmap().height());
// disable clip mask
XSetClipMask(FbTk::App::instance()->display(),
gc,
None);
}
if (dotext && text) {
@ -899,6 +935,25 @@ void Menu::drawItem(unsigned int index, bool highlight, bool clear, bool render_
}
if (dosel && item->submenu()) {
if (m_theme.bulletPixmap().pixmap().drawable() != 0) {
// enable clip mask
XSetClipMask(FbTk::App::instance()->display(),
gc,
m_theme.bulletPixmap().mask().drawable());
XSetClipOrigin(FbTk::App::instance()->display(),
gc, sel_x, item_y);
// copy bullet pixmap to frame
m_frame_pm.copyArea(m_theme.bulletPixmap().pixmap().drawable(),
gc,
0, 0,
sel_x, item_y,
m_theme.bulletPixmap().width(),
m_theme.bulletPixmap().height());
// disable clip mask
XSetClipMask(FbTk::App::instance()->display(),
gc,
None);
} else {
switch (m_theme.bullet()) {
case MenuTheme::SQUARE:
m_frame_pm.drawRectangle(gc, sel_x, sel_y, half_w, half_w);
@ -946,43 +1001,18 @@ void Menu::drawItem(unsigned int index, bool highlight, bool clear, bool render_
break;
}
}
}
XClearArea(m_display, menu.frame.window(),
item_x, item_y,
menu.item_w, menu.item_h, False);
// if (m_trans->alpha() != alpha())
// m_trans->setAlpha(alpha());
menu.title.setAlpha(alpha());
menu.frame.setAlpha(alpha());
menu.window.setAlpha(alpha());
menu.frame.updateTransparent(item_x, item_y,
menu.item_w, menu.item_h);
/*
if (m_trans.get() && render_trans) {
if (m_trans->alpha() != 255) {
Pixmap root_pm = getRootPixmap(menu.window.screenNumber());
if (m_root_pm != root_pm) {
m_trans->setSource(root_pm, menu.window.screenNumber());
m_root_pm = root_pm;
}
m_trans->setDest(menu.frame.window(), menu.frame.screenNumber());
m_trans->render(menu.window.x() + menu.frame.x() + item_x +
menu.window.borderWidth(),
menu.window.y() + menu.frame.y() + item_y +
menu.window.borderWidth(),
item_x, item_y,
menu.item_w, menu.item_h);
}
}
XSync(m_display, False);
*/
}
void Menu::setLabel(const char *labelstr) {

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: MenuTheme.cc,v 1.9 2003/08/16 12:23:17 fluxgen Exp $
// $Id: MenuTheme.cc,v 1.10 2003/08/27 14:12:45 fluxgen Exp $
#include "MenuTheme.hh"
@ -51,41 +51,33 @@ MenuTheme::MenuTheme(int screen_num):
m_border_width(*this, "borderWidth", "BorderWidth"),
m_bevel_width(*this, "bevelWidth", "BevelWidth"),
m_border_color(*this, "borderColor", "BorderColor"),
m_bullet_pixmap(*this, "menu.submenu.pixmap", "Menu.Submenu.Pixmap"),
m_selected_pixmap(*this, "menu.selected.pixmap", "Menu.Selected.Pixmap"),
m_unselected_pixmap(*this, "menu.unselected.pixmap", "Menu.Unselected.Pixmap"),
m_display(FbTk::App::instance()->display()),
m_alpha(255)
{
t_text_gc(RootWindow(m_display, screen_num)),
f_text_gc(RootWindow(m_display, screen_num)),
h_text_gc(RootWindow(m_display, screen_num)),
d_text_gc(RootWindow(m_display, screen_num)),
hilite_gc(RootWindow(m_display, screen_num)),
m_alpha(255) {
// set default values
*m_border_width = 0;
*m_bevel_width = 0;
Window rootwindow = RootWindow(m_display, screen_num);
XGCValues gcv;
unsigned long gc_value_mask = GCForeground;
gcv.foreground = t_text->pixel();
t_text_gc.setForeground(*t_text);
f_text_gc.setForeground(*f_text);
h_text_gc.setForeground(*h_text);
d_text_gc.setForeground(*d_text);
hilite_gc.setForeground(hilite->color());
t_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv);
gcv.foreground = f_text->pixel();
f_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv);
gcv.foreground = h_text->pixel();
h_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv);
gcv.foreground = d_text->pixel();
d_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv);
gcv.foreground = hilite->color().pixel();
hilite_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv);
}
MenuTheme::~MenuTheme() {
XFreeGC(m_display, t_text_gc);
XFreeGC(m_display, f_text_gc);
XFreeGC(m_display, h_text_gc);
XFreeGC(m_display, d_text_gc);
XFreeGC(m_display, hilite_gc);
}
void MenuTheme::reconfigTheme() {
@ -95,30 +87,15 @@ void MenuTheme::reconfigTheme() {
if (*m_border_width > 20)
*m_border_width = 20;
XGCValues gcv;
unsigned long gc_value_mask = GCForeground;
m_bullet_pixmap->scale(frameFont().height(), frameFont().height());
m_selected_pixmap->scale(frameFont().height(), frameFont().height());
m_unselected_pixmap->scale(frameFont().height(), frameFont().height());
gcv.foreground = t_text->pixel();
XChangeGC(m_display, t_text_gc,
gc_value_mask, &gcv);
gcv.foreground = f_text->pixel();
XChangeGC(m_display, f_text_gc,
gc_value_mask, &gcv);
gcv.foreground = h_text->pixel();
XChangeGC(m_display, h_text_gc,
gc_value_mask, &gcv);
gcv.foreground = d_text->pixel();
XChangeGC(m_display, d_text_gc,
gc_value_mask, &gcv);
gcv.foreground = hilite->color().pixel();
XChangeGC(m_display, hilite_gc,
gc_value_mask, &gcv);
t_text_gc.setForeground(*t_text);
f_text_gc.setForeground(*f_text);
h_text_gc.setForeground(*h_text);
d_text_gc.setForeground(*d_text);
hilite_gc.setForeground(hilite->color());
// notify any listeners
m_theme_change_sig.notify();