aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/MultLayers.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-01-16 12:41:27 (GMT)
committerrathnor <rathnor>2003-01-16 12:41:27 (GMT)
commit000fe76aae9c19c0c799da7bfdfc377f4bd59793 (patch)
tree17896b42de7f1cbbbc636dc8af2e3264a22dd5a9 /src/FbTk/MultLayers.cc
parent00e10146668a4a04f13838d6df651870589b19e2 (diff)
downloadfluxbox-000fe76aae9c19c0c799da7bfdfc377f4bd59793.zip
fluxbox-000fe76aae9c19c0c799da7bfdfc377f4bd59793.tar.bz2
New Layer System
Diffstat (limited to 'src/FbTk/MultLayers.cc')
-rw-r--r--src/FbTk/MultLayers.cc83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/FbTk/MultLayers.cc b/src/FbTk/MultLayers.cc
new file mode 100644
index 0000000..a7a2e60
--- /dev/null
+++ b/src/FbTk/MultLayers.cc
@@ -0,0 +1,83 @@
1// MultLayers.cc for FbTk - fluxbox toolkit
2// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
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// $Id: MultLayers.cc,v 1.1 2003/01/16 12:41:27 rathnor Exp $
24
25#include "MultLayers.hh"
26#include "XLayer.hh"
27#include "XLayerItem.hh"
28
29using namespace FbTk;
30
31MultLayers::MultLayers(int numlayers) :
32 m_numlayers(numlayers), m_layers(numlayers) {
33 for (int i=0; i < numlayers; i++) {
34 m_layers[i] = new XLayer(*this, i);
35 }
36}
37
38MultLayers::~MultLayers() {
39 // TODO delete all the layers
40}
41
42
43XLayerItem *MultLayers::getLowestItemAboveLayer(int layernum) {
44 if (layernum >= (m_numlayers) || layernum <= 0)
45 return 0;
46
47 layernum--; // next one up
48 XLayerItem *item = 0;
49 while (layernum >= 0 && (item = m_layers[layernum]->getLowestItem()) == 0) layernum--;
50 return item;
51
52}
53
54void MultLayers::addToTop(XLayerItem &item, int layernum) {
55 if (layernum < 0 || layernum >= m_numlayers) return;
56 m_layers[layernum]->insert(item);
57}
58
59/* raise the item one level */
60void MultLayers::raise(XLayerItem &item) {
61 // get the layer it is in
62 XLayer *curr_layer = item.getLayer();
63 if (!curr_layer || curr_layer->getLayerNum() == 0 || m_numlayers == 1) {
64 // do nothing
65 return;
66 }
67
68 curr_layer->remove(item);
69 m_layers[curr_layer->getLayerNum()-1]->insert(item);
70}
71
72/* lower the item one level */
73void MultLayers::lower(XLayerItem &item) {
74 // get the layer it is in
75 XLayer *curr_layer = item.getLayer();
76 if (!curr_layer || curr_layer->getLayerNum() >= (m_numlayers-1) || m_numlayers == 1) {
77 // do nothing
78 return;
79 }
80
81 curr_layer->remove(item);
82 m_layers[curr_layer->getLayerNum()+1]->insert(item);
83}