news download themes documentation links










Xinerama.hh

00001 // Xinerama.hh for Fluxbox - helpful tools for multiple heads
00002 // Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
00003 //                and Simon Bowden    (rathnor at users.sourceforge.net)
00004 //
00005 // Permission is hereby granted, free of charge, to any person obtaining a
00006 // copy of this software and associated documentation files (the "Software"),
00007 // to deal in the Software without restriction, including without limitation
00008 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
00009 // and/or sell copies of the Software, and to permit persons to whom the
00010 // Software is furnished to do so, subject to the following conditions:
00011 //
00012 // The above copyright notice and this permission notice shall be included in
00013 // all copies or substantial portions of the Software.
00014 //
00015 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00018 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00019 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00020 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00021 // DEALINGS IN THE SOFTWARE.
00022 
00023 // $Id: Xinerama.hh,v 1.7 2003/12/10 23:08:03 fluxgen Exp $
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 // provides a generic way for giving an object a xinerama head menu
00036 // The object must have two functions:
00037 // int getOnHead(), and
00038 // void setOnHead(int)
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         // TODO: nls
00088 /*
00089         sprintf(tname, I18n::instance()->
00090                 getMessage(
00091                     FBNLS::ScreenSet, 
00092                     FBNLS::XineramaDefaultHeadFormat,
00093                     "Head %d"), i); //m_id starts at 0
00094 */
00095         sprintf(tname, "Head %d", i);
00096         insert(new XineramaHeadMenuItem<ItemType>(
00097                    tname, m_object, i, saverc_cmd));
00098     }
00099     // TODO: nls
00100     insert(new XineramaHeadMenuItem<ItemType>(
00101                "All Heads", m_object, 0, saverc_cmd));
00102     update();
00103 }
00104 
00105 #endif // XINERAMA_HH

Fluxbox CVS-Jan-2003




      



Got comments about the page? Send them to webmaster.
If you have general Fluxbox related questions ask them on our irc channel or mailing lists.

Show Source








Designed by aLEczapKA