1 // Layer.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_LAYER_HH 24 #define FBTK_LAYER_HH 25 26 #include <vector> 27 #include <list> 28 29 namespace FbTk { 30 31 class MultLayers; 32 class LayerItem; 33 34 class Layer { 35 public: 36 37 Layer(MultLayers &manager, int layernum); 38 ~Layer(); 39 40 typedef std::list<LayerItem *> ItemList; 41 typedef std::list<LayerItem *>::iterator iterator; 42 43 //typedef std::list<LayerItem *>::reverse_iterator reverse_iterator; 44 setLayerNum(int layernum)45 void setLayerNum(int layernum) { m_layernum = layernum; }; getLayerNum()46 int getLayerNum() { return m_layernum; }; 47 // Put all items on the same layer (called when layer item added to) 48 void alignItem(LayerItem &item); 49 int countWindows(); 50 void stackBelowItem(LayerItem &item, LayerItem *above); 51 LayerItem *getLowestItem(); itemList() const52 const ItemList &itemList() const { return m_items; } itemList()53 ItemList &itemList() { return m_items; } 54 55 // we redefine these as Layer has special optimisations, and X restacking needs 56 iterator insert(LayerItem &item, unsigned int pos=0); 57 void remove(LayerItem &item); 58 59 // bring to top of layer 60 void raise(LayerItem &item); 61 void lower(LayerItem &item); 62 63 // raise it, but don't make it permanent (i.e. restack will revert) 64 void tempRaise(LayerItem &item); 65 66 // send to next layer up 67 void raiseLayer(LayerItem &item); 68 void lowerLayer(LayerItem &item); 69 void moveToLayer(LayerItem &item, int layernum); 70 71 static void restack(const std::vector<Layer*>& layers); 72 73 private: 74 void restack(); 75 void restackAndTempRaise(LayerItem &item); 76 77 MultLayers &m_manager; 78 int m_layernum; 79 bool m_needs_restack; 80 ItemList m_items; 81 }; 82 83 } // namespace FbTk 84 85 #endif // FBTK_LAYER_HH 86