aboutsummaryrefslogtreecommitdiff
path: root/src/AlphaMenu.hh
diff options
context:
space:
mode:
authorsimonb <simonb>2007-01-07 14:20:31 (GMT)
committersimonb <simonb>2007-01-07 14:20:31 (GMT)
commit93ec253f0d6790e79017f74ae5413ef0363b5cb1 (patch)
treebb6ae26d09275b5a73503cebc052b30ff8735bb6 /src/AlphaMenu.hh
parent440c69afa436150f2a797aa8f192d68090832c5c (diff)
downloadfluxbox-93ec253f0d6790e79017f74ae5413ef0363b5cb1.zip
fluxbox-93ec253f0d6790e79017f74ae5413ef0363b5cb1.tar.bz2
forgot to svn add the files
Diffstat (limited to 'src/AlphaMenu.hh')
-rw-r--r--src/AlphaMenu.hh92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/AlphaMenu.hh b/src/AlphaMenu.hh
new file mode 100644
index 0000000..78dda9a
--- /dev/null
+++ b/src/AlphaMenu.hh
@@ -0,0 +1,92 @@
1// AlphaMenu.hh for Fluxbox
2// Copyright (c) 2007 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#ifndef ALPHAMENU_HH
26#define ALPHAMENU_HH
27
28#include "ToggleMenu.hh"
29#include "FbTk/MenuItem.hh"
30#include "ObjectResource.hh"
31
32class AlphaObject {
33public:
34
35 virtual int getFocusedAlpha() const = 0;
36 virtual int getUnfocusedAlpha() const = 0;
37 virtual bool getUseDefaultAlpha() const = 0;
38
39 virtual void setFocusedAlpha(int alpha) = 0;
40 virtual void setUnfocusedAlpha(int alpha) = 0;
41 virtual void setUseDefaultAlpha(bool use_default) = 0;
42
43 virtual ~AlphaObject() {};
44};
45
46
47class AlphaMenu : public ToggleMenu {
48public:
49 AlphaMenu(MenuTheme &tm, FbTk::ImageControl &imgctrl,
50 FbTk::XLayer &layer, AlphaObject &object);
51
52 // we override these to update the menu when the active window changes
53 void move(int x, int y);
54 void show();
55
56 ObjectResource<AlphaObject, int> m_focused_alpha_resource;
57 ObjectResource<AlphaObject, int> m_unfocused_alpha_resource;
58
59};
60
61class AlphaMenuSelectItem : public FbTk::MenuItem {
62
63public:
64 AlphaMenuSelectItem(const FbTk::FbString &label, AlphaObject *object, AlphaMenu &parent):
65 FbTk::MenuItem(label), m_object(object), m_parent(parent) {
66 setToggleItem(true);
67 }
68
69 bool isSelected() const { return m_object->getUseDefaultAlpha(); }
70 void click(int button, int time) {
71 bool newval = !m_object->getUseDefaultAlpha();
72 m_object->setUseDefaultAlpha(newval);
73 // items 1 and 2 (the focused/unfocused values) are only enabled if we don't use default values
74 m_parent.setItemEnabled(1, !newval);
75 m_parent.setItemEnabled(2, !newval);
76 m_parent.show(); // cheat to refreshing the window
77 FbTk::MenuItem::click(button, time);
78 }
79
80 void updateLabel() {
81 bool val = m_object->getUseDefaultAlpha();
82 m_parent.setItemEnabled(1, !val);
83 m_parent.setItemEnabled(2, !val);
84 m_parent.updateMenu();
85 }
86
87private:
88 AlphaObject *m_object;
89 AlphaMenu &m_parent;
90};
91
92#endif // ALPHAMENU_HH