00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef XINERAMA_HH
00026 #define XINERAMA_HH
00027
00028 #include "MenuItem.hh"
00029 #include "FbMenu.hh"
00030 #include "RefCount.hh"
00031 #include "SimpleCommand.hh"
00032
00033 #include "fluxbox.hh"
00034
00035
00036
00037
00038
00039
00041 template <typename ItemType>
00042 class XineramaHeadMenuItem : public FbTk::MenuItem {
00043 public:
00044 XineramaHeadMenuItem(const char *label, ItemType &object, int headnum,
00045 FbTk::RefCount<FbTk::Command> &cmd):
00046 FbTk::MenuItem(label,cmd), m_object(object), m_headnum(headnum) {}
00047 XineramaHeadMenuItem(const char *label, ItemType &object, int headnum):
00048 FbTk::MenuItem(label), m_object(object), m_headnum(headnum) {}
00049
00050 bool isEnabled() const { return m_object.getOnHead() != m_headnum; }
00051 void click(int button, int time) {
00052 m_object.saveOnHead(m_headnum);
00053 FbTk::MenuItem::click(button, time);
00054 }
00055
00056 private:
00057 ItemType &m_object;
00058 int m_headnum;
00059 };
00060
00061
00063 template <typename ItemType>
00064 class XineramaHeadMenu : public FbMenu {
00065 public:
00066 XineramaHeadMenu(MenuTheme &tm, BScreen &screen, FbTk::ImageControl &imgctrl,
00067 FbTk::XLayer &layer, ItemType &item, const char * title);
00068
00069 private:
00070 ItemType &m_object;
00071 };
00072
00073
00074 template <typename ItemType>
00075 XineramaHeadMenu<ItemType>::XineramaHeadMenu(MenuTheme &tm, BScreen &screen, FbTk::ImageControl &imgctrl,
00076 FbTk::XLayer &layer, ItemType &item, const char * title = 0):
00077 FbMenu(tm, imgctrl, layer),
00078 m_object(item)
00079 {
00080 if (title)
00081 setLabel(title);
00082 FbTk::RefCount<FbTk::Command> saverc_cmd(new FbTk::SimpleCommand<Fluxbox>(
00083 *Fluxbox::instance(),
00084 &Fluxbox::save_rc));
00085 char tname[128];
00086 for (int i=1; i <= screen.numHeads(); ++i) {
00087
00088
00089
00090
00091
00092
00093
00094
00095 sprintf(tname, "Head %d", i);
00096 insert(new XineramaHeadMenuItem<ItemType>(
00097 tname, m_object, i, saverc_cmd));
00098 }
00099
00100 insert(new XineramaHeadMenuItem<ItemType>(
00101 "All Heads", m_object, 0, saverc_cmd));
00102 update();
00103 }
00104
00105 #endif // XINERAMA_HH