aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/MenuIcon.cc
diff options
context:
space:
mode:
authormarkt <markt>2007-10-13 21:51:37 (GMT)
committermarkt <markt>2007-10-13 21:51:37 (GMT)
commita59428d67a95a9df16554962f0a6257d6378328a (patch)
treef856ed9300c34f7a17d499f22d895610cfbc08e5 /src/FbTk/MenuIcon.cc
parent41b5c6dadb1f474675660cef18b812d4c2338ed2 (diff)
downloadfluxbox-a59428d67a95a9df16554962f0a6257d6378328a.zip
fluxbox-a59428d67a95a9df16554962f0a6257d6378328a.tar.bz2
merged changes from pre-devel
Diffstat (limited to 'src/FbTk/MenuIcon.cc')
-rw-r--r--src/FbTk/MenuIcon.cc96
1 files changed, 0 insertions, 96 deletions
diff --git a/src/FbTk/MenuIcon.cc b/src/FbTk/MenuIcon.cc
deleted file mode 100644
index d64d876..0000000
--- a/src/FbTk/MenuIcon.cc
+++ /dev/null
@@ -1,96 +0,0 @@
1// MenuIcon.cc for FbTk - Fluxbox ToolKit
2// Copyright (c) 2004 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
3// and Simon Bowden (rathnor at users.sourceforge.net)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a
6// copy of this software and associated documentation files (the "Software"),
7// to deal in the Software without restriction, including without limitation
8// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9// and/or sell copies of the Software, and to permit persons to whom the
10// Software is furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE.
22
23// $Id$
24
25#include "MenuIcon.hh"
26
27#include "MenuTheme.hh"
28#include "Image.hh"
29#include "App.hh"
30
31namespace FbTk {
32
33MenuIcon::MenuIcon(const std::string &filename, FbString &label, int screen_num):
34 MenuItem(label),
35 m_filename(filename) {
36 FbTk::PixmapWithMask *pm = Image::load(filename.c_str(), screen_num);
37 if (pm != 0) {
38 m_pixmap = pm->pixmap().release();
39 m_mask = pm->mask().release();
40 delete pm;
41 }
42
43}
44
45void MenuIcon::updateTheme(const MenuTheme &theme) {
46 FbTk::PixmapWithMask *pm = Image::load(m_filename.c_str(), theme.screenNum());
47 if (pm != 0) {
48 m_pixmap = pm->pixmap().release();
49 m_mask = pm->mask().release();
50 delete pm;
51 }
52}
53
54void MenuIcon::draw(FbDrawable &drawable,
55 const MenuTheme &theme,
56 bool highlight, bool draw_foreground, bool draw_background,
57 int x, int y,
58 unsigned int width, unsigned int height) const {
59
60 // all background
61 if (draw_background) {
62 Display *disp = FbTk::App::instance()->display();
63 if (height - 2*theme.bevelWidth() != m_pixmap.height() &&
64 !m_filename.empty()) {
65 unsigned int scale_size = height - 2*theme.bevelWidth();
66 m_pixmap.scale(scale_size, scale_size);
67 m_mask.scale(scale_size, scale_size);
68 }
69
70 if (m_pixmap.drawable() != 0) {
71 GC gc = theme.frameTextGC().gc();
72
73 // enable clip mask
74 XSetClipMask(disp, gc, m_mask.drawable());
75 XSetClipOrigin(disp, gc, x + theme.bevelWidth(), y + theme.bevelWidth());
76
77 drawable.copyArea(m_pixmap.drawable(),
78 gc,
79 0, 0,
80 x + theme.bevelWidth(), y + theme.bevelWidth(),
81 m_pixmap.width(), m_pixmap.height());
82
83 // restore clip mask
84 XSetClipMask(disp, gc, None);
85 }
86 }
87 FbTk::MenuItem::draw(drawable, theme, highlight,
88 draw_background, draw_foreground, x, y, width, height);
89}
90
91unsigned int MenuIcon::width(const MenuTheme &theme) const {
92 return MenuItem::width(theme) + 2 * (theme.bevelWidth() + height(theme));
93}
94
95} // end namespace FbTk
96