diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/LayerMenu.hh | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/src/LayerMenu.hh b/src/LayerMenu.hh new file mode 100644 index 0000000..1a48878 --- /dev/null +++ b/src/LayerMenu.hh | |||
@@ -0,0 +1,98 @@ | |||
1 | // LayerMenu.hh for Fluxbox - fluxbox toolkit | ||
2 | // Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) | ||
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: LayerMenu.hh,v 1.1 2003/02/18 22:09:02 rathnor Exp $ | ||
24 | |||
25 | #ifndef LAYERMENU_HH | ||
26 | #define LAYERMENU_HH | ||
27 | |||
28 | #include "MenuItem.hh" | ||
29 | #include "FbMenu.hh" | ||
30 | |||
31 | class Fluxbox; | ||
32 | |||
33 | // provides a generic way for giving an object a layer menu | ||
34 | |||
35 | // this class holds the layermenu items | ||
36 | template <typename ItemType> | ||
37 | class LayerMenuItem : public FbTk::MenuItem { | ||
38 | public: | ||
39 | LayerMenuItem(const char *label, ItemType *object, int layernum): | ||
40 | FbTk::MenuItem(label), m_object(object), m_layernum(layernum) {} | ||
41 | |||
42 | bool isEnabled() const { return m_object->getLayerItem().getLayerNum() != m_layernum; } ; | ||
43 | void click(int button, int time) { | ||
44 | m_object->moveToLayer(m_layernum); | ||
45 | } | ||
46 | |||
47 | private: | ||
48 | ItemType *m_object; | ||
49 | int m_layernum; | ||
50 | }; | ||
51 | |||
52 | |||
53 | /* create a layer menu inside from the given menu */ | ||
54 | template <typename ItemType> | ||
55 | class LayerMenu : public FbMenu { | ||
56 | public: | ||
57 | LayerMenu(FbTk::MenuTheme &tm, int screen_num, FbTk::ImageControl &imgctrl, | ||
58 | FbTk::XLayer &layer, ItemType *item); | ||
59 | |||
60 | private: | ||
61 | ItemType *m_object; | ||
62 | }; | ||
63 | |||
64 | |||
65 | template <typename ItemType> | ||
66 | LayerMenu<ItemType>::LayerMenu(FbTk::MenuTheme &tm, int screen_num, FbTk::ImageControl &imgctrl, | ||
67 | FbTk::XLayer &layer, ItemType *item): | ||
68 | FbMenu(tm, screen_num, imgctrl, layer), | ||
69 | m_object(item) | ||
70 | { | ||
71 | |||
72 | Fluxbox *fluxbox = Fluxbox::instance(); | ||
73 | |||
74 | struct { | ||
75 | int set; | ||
76 | int base; | ||
77 | const char *default_str; | ||
78 | int layernum; | ||
79 | } layer_menuitems[] = { | ||
80 | //TODO: nls | ||
81 | {0, 0, "Above Dock", fluxbox->getAboveDockLayer()}, | ||
82 | {0, 0, "Dock", fluxbox->getDockLayer()}, | ||
83 | {0, 0, "Top", fluxbox->getTopLayer()}, | ||
84 | {0, 0, "Normal", fluxbox->getNormalLayer()}, | ||
85 | {0, 0, "Bottom", fluxbox->getBottomLayer()}, | ||
86 | {0, 0, "Desktop", fluxbox->getDesktopLayer()}, | ||
87 | }; | ||
88 | |||
89 | for (size_t i=0; i < 6; ++i) { | ||
90 | // TODO: fetch nls string | ||
91 | insert(new LayerMenuItem<ItemType>( | ||
92 | layer_menuitems[i].default_str, | ||
93 | m_object, layer_menuitems[i].layernum)); | ||
94 | } | ||
95 | update(); | ||
96 | } | ||
97 | |||
98 | #endif // LAYERMENU_HH | ||