1 // LayerItem.hh for FbTk - fluxbox toolkit
2 // Copyright (c) 2003 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 #ifndef FBTK_LAYERITEM_HH
24 #define FBTK_LAYERITEM_HH
25 
26 #include "Layer.hh"
27 #include "NotCopyable.hh"
28 #include <vector>
29 #include <cstdlib> // size_t
30 
31 namespace FbTk {
32 
33 class FbWindow;
34 
35 class LayerItem : private NotCopyable {
36 public:
37     typedef std::vector<FbWindow *> Windows;
38 
39     LayerItem(FbWindow &win, Layer &layer);
40     ~LayerItem();
41 
42     void setLayer(Layer &layer);
43 
44     void raise();
45     void lower();
46     void tempRaise(); // this raise gets reverted by a restack()
47 
48     // send to next layer up
49     void raiseLayer();
50     void lowerLayer();
51     void moveToLayer(int layernum);
52 
53     // this is needed for step and cycle functions
54     // (you need to know the next one visible, otherwise nothing may appear to happen)
55     // not yet implemented
visible() const56     bool visible() const { return true; }
57 
getLayer() const58     const Layer &getLayer() const { return *m_layer; }
getLayer()59     Layer &getLayer() { return *m_layer; }
getLayerNum()60     int getLayerNum() { return m_layer->getLayerNum(); }
61 
62     // an LayerItem holds several windows that are equivalent in a layer
63     // (i.e. if one is raised, then they should all be).
64     void addWindow(FbWindow &win);
65     void removeWindow(FbWindow &win);
66 
67     // using this you can bring one window to the top of this item (equivalent to add then remove)
68     void bringToTop(FbWindow &win);
69 
getWindows()70     Windows &getWindows() { return m_windows; }
numWindows() const71     size_t numWindows() const { return m_windows.size(); }
72 
73 private:
74     Layer *m_layer;
75     Windows m_windows;
76 };
77 
78 }
79 
80 #endif // FBTK_LAYERITEM_HH
81