aboutsummaryrefslogtreecommitdiff
path: root/src/LayerMenu.hh
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2005-06-23 03:07:25 (GMT)
committerfluxgen <fluxgen>2005-06-23 03:07:25 (GMT)
commit5373f6d840abaa49685c15fee2f411e77472a7da (patch)
tree46da25845eac32769bad85c264e4edf335cc1783 /src/LayerMenu.hh
parent18cf5862495aa6f37110c90286bb6c315a145526 (diff)
downloadfluxbox_pavel-5373f6d840abaa49685c15fee2f411e77472a7da.zip
fluxbox_pavel-5373f6d840abaa49685c15fee2f411e77472a7da.tar.bz2
moved window menu from FluxboxWindow to BScreen
Diffstat (limited to 'src/LayerMenu.hh')
-rw-r--r--src/LayerMenu.hh75
1 files changed, 15 insertions, 60 deletions
diff --git a/src/LayerMenu.hh b/src/LayerMenu.hh
index e6a3dc6..e22ba30 100644
--- a/src/LayerMenu.hh
+++ b/src/LayerMenu.hh
@@ -25,91 +25,46 @@
25#ifndef LAYERMENU_HH 25#ifndef LAYERMENU_HH
26#define LAYERMENU_HH 26#define LAYERMENU_HH
27 27
28#include "MenuItem.hh" 28
29#include "ToggleMenu.hh" 29#include "ToggleMenu.hh"
30#include "RefCount.hh"
31#include "SimpleCommand.hh"
32#include "I18n.hh"
33 30
34#include "fluxbox.hh" 31#include "FbTk/MenuItem.hh"
32
33class LayerObject {
34public:
35 virtual void moveToLayer(int layer_number) = 0;
36 virtual int layerNumber() const = 0;
37};
35 38
36// provides a generic way for giving an object a layer menu
37 39
38/// this class holds the layermenu items 40/// this class holds the layermenu items
39template <typename ItemType>
40class LayerMenuItem : public FbTk::MenuItem { 41class LayerMenuItem : public FbTk::MenuItem {
41public: 42public:
42 LayerMenuItem(const char *label, ItemType *object, int layernum, 43 LayerMenuItem(const char *label, LayerObject *object, int layernum,
43 FbTk::RefCount<FbTk::Command> &cmd): 44 FbTk::RefCount<FbTk::Command> &cmd):
44 FbTk::MenuItem(label,cmd), m_object(object), m_layernum(layernum) {} 45 FbTk::MenuItem(label, cmd), m_object(object), m_layernum(layernum) {}
45 LayerMenuItem(const char *label, ItemType *object, int layernum): 46
47 LayerMenuItem(const char *label, LayerObject *object, int layernum):
46 FbTk::MenuItem(label), m_object(object), m_layernum(layernum) {} 48 FbTk::MenuItem(label), m_object(object), m_layernum(layernum) {}
47 49
48 bool isEnabled() const { return m_object->layerItem().getLayerNum() != m_layernum; } 50 bool isEnabled() const { return m_object->layerNumber() != m_layernum; }
49 void click(int button, int time) { 51 void click(int button, int time) {
50 m_object->moveToLayer(m_layernum); 52 m_object->moveToLayer(m_layernum);
51 FbTk::MenuItem::click(button, time); 53 FbTk::MenuItem::click(button, time);
52 } 54 }
53 55
54private: 56private:
55 ItemType *m_object; 57 LayerObject *m_object;
56 int m_layernum; 58 int m_layernum;
57}; 59};
58 60
59 61
60/// Create a layer menu inside from the given menu 62/// Create a layer menu inside from the given menu
61template <typename ItemType>
62class LayerMenu : public ToggleMenu { 63class LayerMenu : public ToggleMenu {
63public: 64public:
64 LayerMenu(MenuTheme &tm, FbTk::ImageControl &imgctrl, 65 LayerMenu(MenuTheme &tm, FbTk::ImageControl &imgctrl,
65 FbTk::XLayer &layer, ItemType *item, bool save_rc); 66 FbTk::XLayer &layer, LayerObject *item, bool save_rc);
66
67 67
68private:
69 ItemType *m_object;
70}; 68};
71 69
72
73template <typename ItemType>
74LayerMenu<ItemType>::LayerMenu(MenuTheme &tm, FbTk::ImageControl &imgctrl,
75 FbTk::XLayer &layer, ItemType *item, bool save_rc):
76 ToggleMenu(tm, imgctrl, layer),
77 m_object(item)
78{
79 _FB_USES_NLS;
80
81 Fluxbox *fluxbox = Fluxbox::instance();
82
83 struct {
84 int set;
85 int base;
86 const char *default_str;
87 int layernum;
88 } layer_menuitems[] = {
89 //TODO: nls
90 {0, 0, _FBTEXT(Layer, AboveDock, "Above Dock", "Layer above dock"), fluxbox->getAboveDockLayer()},
91 {0, 0, _FBTEXT(Layer, Dock, "Dock", "Layer dock"), fluxbox->getDockLayer()},
92 {0, 0, _FBTEXT(Layer, Top, "Top", "Layer top"), fluxbox->getTopLayer()},
93 {0, 0, _FBTEXT(Layer, Normal, "Normal", "Layer normal"), fluxbox->getNormalLayer()},
94 {0, 0, _FBTEXT(Layer, Bottom, "Bottom", "Layer bottom"), fluxbox->getBottomLayer()},
95 {0, 0, _FBTEXT(Layer, Desktop, "Desktop", "Layer desktop"), fluxbox->getDesktopLayer()},
96 };
97
98 FbTk::RefCount<FbTk::Command> saverc_cmd(new FbTk::SimpleCommand<Fluxbox>(
99 *Fluxbox::instance(),
100 &Fluxbox::save_rc));
101
102 for (size_t i=0; i < 6; ++i) {
103 // TODO: fetch nls string
104 if (save_rc) {
105 insert(new LayerMenuItem<ItemType>(layer_menuitems[i].default_str,
106 m_object, layer_menuitems[i].layernum, saverc_cmd));
107 } else {
108 insert(new LayerMenuItem<ItemType>(layer_menuitems[i].default_str,
109 m_object, layer_menuitems[i].layernum));
110 }
111 }
112 updateMenu();
113}
114
115#endif // LAYERMENU_HH 70#endif // LAYERMENU_HH