New Layer System

This commit is contained in:
rathnor 2003-01-16 12:41:27 +00:00
parent 00e1014666
commit 000fe76aae
9 changed files with 758 additions and 0 deletions

201
src/FbTk/Layer.hh Normal file
View file

@ -0,0 +1,201 @@
// Layer.hh for FbTk - fluxbox toolkit
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
// and Simon Bowden (rathnor at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Layer.hh,v 1.1 2003/01/16 12:41:27 rathnor Exp $
#ifndef FBTK_LAYERTEMPLATE_HH
#define FBTK_LAYERTEMPLATE_HH
/*#include "Layer.hh"*/
#include <vector>
#include <algorithm>
#include <iostream>
namespace FbTk {
template <typename ItemType, typename Container = std::vector<ItemType *> >
class Layer {
public:
typedef Container ListType;
typedef typename Container::iterator iterator;
typedef typename Container::reverse_iterator reverse_iterator;
virtual ~Layer() { }
/// insert in top by default
virtual iterator insert(ItemType &item, unsigned int pos=0);
/// remove item from list
virtual void remove(ItemType &item);
/// cycle all item upwards
virtual void cycleUp();
/// cycle all items downwards
virtual void cycleDown();
/// move item to top
virtual void raise(ItemType &item);
/// move item to bottom
virtual void lower(ItemType &item);
/// raise a specific item one step
virtual void stepUp(ItemType &item);
/// lower a specific item one step
virtual void stepDown(ItemType &item);
virtual void restack();
/// @return layer item on specific position, on failure 0
ItemType *getItem(unsigned int position);
/// @return number of elements in layer
unsigned int size() const { return m_list.size(); }
/// @return layer list
const ListType &itemList() const { return m_list; }
/// @return layer list
ListType &itemList() { return m_list; }
private:
ListType m_list;
};
template <typename ItemType, typename Container>
typename Container::iterator Layer<ItemType, Container>::insert(ItemType &item, unsigned int position) {
// make sure we don't alreay have it in the list
if (std::find(itemList().begin(), itemList().end(), &item) != itemList().end())
return m_list.end();
if (position > size())
position = size();
iterator it = m_list.begin();
for (unsigned int i=0; i<position; ++it, ++i)
continue;
m_list.insert(it, &item);
restack();
return it++;
}
template <typename ItemType, typename Container>
void Layer<ItemType, Container>::remove(ItemType &item) {
iterator it = std::find(itemList().begin(), itemList().end(), &item);
if (it != itemList().end())
m_list.erase(it);
}
template <typename ItemType, typename Container>
void Layer<ItemType, Container>::cycleUp() {
if (size() == 0)
return;
iterator it = itemList().begin();
it++;
rotate(itemList().begin(), it, itemList().end());
restack();
}
template <typename ItemType, typename Container>
void Layer<ItemType, Container>::cycleDown() {
if (size() == 0)
return;
// save last item and remove it from list
ItemType *last_item = itemList().back();
itemList().pop_back();
// add last item to front
itemList().insert(itemList().begin(), last_item);
restack();
}
template <typename ItemType, typename Container>
void Layer<ItemType, Container>::stepUp(ItemType &item) {
iterator it =
find(itemList().begin(), itemList().end(), &item);
if (it == itemList().end())
return;
if (it == itemList().begin()) // we can't raise it more
return;
iterator new_pos = it;
new_pos--;
ItemType *textitem = *it;
// remove item from list
itemList().erase(it);
// insert above last pos
itemList().insert(new_pos, textitem);
restack();
}
template <typename ItemType, typename Container>
void Layer<ItemType, Container>::stepDown(ItemType &item) {
iterator it =
find(itemList().begin(), itemList().end(), &item);
if (it == itemList().end()) // we didn't find the item in our list
return;
if (*it == itemList().back()) // it's already at the bottom
return;
iterator new_pos = it;
new_pos++;
ItemType *textitem = *it;
// remove from list
itemList().erase(it);
// insert on the new place
itemList().insert(new_pos, textitem);
restack();
}
template <typename ItemType, typename Container>
void Layer<ItemType, Container>::raise(ItemType &item) {
if (&item == itemList().front()) // already at the bottom
return;
remove(item);
insert(item, 0);
restack();
}
template <typename ItemType, typename Container>
void Layer<ItemType, Container>::lower(ItemType &item) {
if (&item == itemList().back()) // already at the bottom
return;
remove(item);
insert(item, size());
restack();
}
template <typename ItemType, typename Container>
ItemType *Layer<ItemType, Container>::getItem(unsigned int position) {
if (position >= m_list.size())
return 0;
iterator it = m_list.begin();
iterator it_end = m_list.end();
for (unsigned int i=0; i < position && it != it_end; i++);
if (it == it_end) return 0;
else
return *it;
}
template <typename ItemType, typename Container>
void Layer<ItemType, Container>::restack() {
}
}; // end namespace FbTk
#endif // FBTK_LAYERTEMPLATE_HH

43
src/FbTk/LayerItem.hh Normal file
View file

@ -0,0 +1,43 @@
// LayerItem.hh for fluxbox
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
// and Simon Bowden (rathnor at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: LayerItem.hh,v 1.1 2003/01/16 12:41:27 rathnor Exp $
#ifndef FBTK_LAYERITEM_HH
#define FBTK_LAYERITEM_HH
namespace FbTk {
/// pure interface class, an item in layer
class LayerItem {
public:
virtual ~LayerItem() { }
virtual void raise() = 0;
virtual void lower() = 0;
virtual void stepUp() = 0;
virtual void stepDown() = 0;
};
}; // end namespace FbTk
#endif // FBTK_LAYERITEM_HH

View file

@ -18,5 +18,7 @@ libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \
Texture.cc Texture.hh TextureRender.hh TextureRender.cc Theme.hh Theme.cc Timer.hh Timer.cc \
XFontImp.cc XFontImp.hh \
Button.hh Button.cc \
Layer.hh LayerItem.hh MultLayers.cc MultLayers.hh \
XLayer.cc XLayer.hh XLayerItem.cc XLayerItem.hh \
${xft_SOURCE} \
${xmb_SOURCE}

83
src/FbTk/MultLayers.cc Normal file
View file

@ -0,0 +1,83 @@
// MultLayers.cc for FbTk - fluxbox toolkit
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
// and Simon Bowden (rathnor at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: MultLayers.cc,v 1.1 2003/01/16 12:41:27 rathnor Exp $
#include "MultLayers.hh"
#include "XLayer.hh"
#include "XLayerItem.hh"
using namespace FbTk;
MultLayers::MultLayers(int numlayers) :
m_numlayers(numlayers), m_layers(numlayers) {
for (int i=0; i < numlayers; i++) {
m_layers[i] = new XLayer(*this, i);
}
}
MultLayers::~MultLayers() {
// TODO delete all the layers
}
XLayerItem *MultLayers::getLowestItemAboveLayer(int layernum) {
if (layernum >= (m_numlayers) || layernum <= 0)
return 0;
layernum--; // next one up
XLayerItem *item = 0;
while (layernum >= 0 && (item = m_layers[layernum]->getLowestItem()) == 0) layernum--;
return item;
}
void MultLayers::addToTop(XLayerItem &item, int layernum) {
if (layernum < 0 || layernum >= m_numlayers) return;
m_layers[layernum]->insert(item);
}
/* raise the item one level */
void MultLayers::raise(XLayerItem &item) {
// get the layer it is in
XLayer *curr_layer = item.getLayer();
if (!curr_layer || curr_layer->getLayerNum() == 0 || m_numlayers == 1) {
// do nothing
return;
}
curr_layer->remove(item);
m_layers[curr_layer->getLayerNum()-1]->insert(item);
}
/* lower the item one level */
void MultLayers::lower(XLayerItem &item) {
// get the layer it is in
XLayer *curr_layer = item.getLayer();
if (!curr_layer || curr_layer->getLayerNum() >= (m_numlayers-1) || m_numlayers == 1) {
// do nothing
return;
}
curr_layer->remove(item);
m_layers[curr_layer->getLayerNum()+1]->insert(item);
}

54
src/FbTk/MultLayers.hh Normal file
View file

@ -0,0 +1,54 @@
// MultLayers.hh for FbTk - fluxbox toolkit
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
// and Simon Bowden (rathnor at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: MultLayers.hh,v 1.1 2003/01/16 12:41:27 rathnor Exp $
#ifndef FBTK_MULTLAYERS_HH
#define FBTK_MULTLAYERS_HH
#include <vector>
namespace FbTk {
class XLayerItem;
class XLayer;
class MultLayers {
public:
MultLayers(int numlayers);
~MultLayers();
XLayerItem *getLowestItemAboveLayer(int layernum);
void addToTop(XLayerItem &item, int layernum);
//void move(XLayerItem &item, int layernum);
void raise(XLayerItem &item);
void lower(XLayerItem &item);
//void moveToTop(XLayerItem &item);
//void moveToBottom(XLayerItem &item);
private:
int m_numlayers;
std::vector<XLayer *> m_layers;
};
};
#endif // FBTK_MULTLAYERS_HH

186
src/FbTk/XLayer.cc Normal file
View file

@ -0,0 +1,186 @@
// XLayer.cc for FbTk - fluxbox toolkit
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
// and Simon Bowden (rathnor at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: XLayer.cc,v 1.1 2003/01/16 12:41:27 rathnor Exp $
#include "XLayer.hh"
#include "XLayerItem.hh"
#include "App.hh"
#include <iostream>
using namespace std;
using namespace FbTk;
XLayer::XLayer(MultLayers &manager, int layernum):
m_manager(manager), m_layernum(layernum) {
}
XLayer::~XLayer() {
}
void XLayer::restack() {
int numWindows = size();
Window *winlist = new Window[numWindows];
typedef FbTk::Layer<XLayerItem> BaseClass;
iterator it = itemList().begin();
iterator it_end = itemList().end();
for (size_t i=0; it != it_end; ++it, i++) {
winlist[i] = (*it)->window();
}
XRestackWindows(FbTk::App::instance()->display(), winlist, numWindows);
delete [] winlist;
}
void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) {
// little optimisation
if (!above) { // must need to go right to top
XRaiseWindow(FbTk::App::instance()->display(), item->window());
return;
}
Window * winlist = new Window[2];
winlist[0] = above->window();
winlist[1] = item->window();
XRestackWindows(FbTk::App::instance()->display(), winlist, 2);
delete [] winlist;
}
XLayer::iterator XLayer::insert(XLayerItem &item, unsigned int pos) {
#ifdef DEBUG
if (pos != 0)
cerr<<__FILE__<<"("<<__LINE__<<"): Insert using non-zero position not valid in XLayer"<<endl;
#endif // DEBUG
itemList().push_front(&item);
item.setLayer(*this);
// restack below next window up
item.setLayerIterator(itemList().begin());
stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum));
return itemList().begin();
}
void XLayer::remove(XLayerItem &item) {
itemList().erase(item.getLayerIterator());
}
void XLayer::cycleUp() {
// need to find highest visible window, and move it to bottom
iterator it = itemList().begin();
iterator it_end = itemList().end();
while (it != it_end && !(*it)->visible()) ++it;
// if there is something to do
if (it != it_end) {
lower(**it);
}
}
void XLayer::cycleDown() {
// need to find highest visible window, and move it to bottom
reverse_iterator it = itemList().rbegin();
reverse_iterator it_end = itemList().rend();
while (it != it_end && !(*it)->visible()) ++it;
// if there is something to do
if (it != it_end) {
raise(**it);
}
}
void XLayer::stepUp(XLayerItem &item) {
// need to find next visible window upwards, and put it above that
if (&item == itemList().front()) return; // nothing to do
// TODO: is there a better way of doing this?
iterator it = item.getLayerIterator();
it--;
while ((*it) != itemList().front() && !(*it)->visible()) --it;
if (*it == itemList().front() && !(*it)->visible()) {
// reached front item, but it wasn't visible, therefore it was already raised
//moveToBottom(item);
} else {
// it is the next visible item down, we need to be above it.
itemList().erase(item.getLayerIterator());
//itemList().insert(it, item);
item.setLayerIterator(it = itemList().insert(it, &item));
if (*it == itemList().front()) {
stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum));
} else {
it--;
stackBelowItem(&item, *it);
}
}
}
void XLayer::stepDown(XLayerItem &item) {
// need to find next visible window down, and put it below that
if (&item == itemList().back()) return; // nothing to do
iterator it = item.getLayerIterator();
it++;
iterator it_end = itemList().end();
while (it != it_end && !(*it)->visible()) ++it;
if (it != it_end) {
stackBelowItem(&item, *it);
}
}
void XLayer::raise(XLayerItem &item) {
// assume it is already in this layer
if (&item == itemList().front())
return; // nothing to do
itemList().erase(item.getLayerIterator());
itemList().push_front(&item);
item.setLayerIterator(itemList().begin());
stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum));
}
void XLayer::lower(XLayerItem &item) {
// assume already in this layer
if (&item == itemList().back())
return; // nothing to do
itemList().erase(item.getLayerIterator());
itemList().push_back(&item);
iterator it = itemList().end();
it--;
item.setLayerIterator(it);
it--;
stackBelowItem(&item, *it); // must exist, otherwise item must == itemList().back()
}
XLayerItem *XLayer::getLowestItem() {
if (itemList().empty()) return 0;
else return itemList().back();
}

70
src/FbTk/XLayer.hh Normal file
View file

@ -0,0 +1,70 @@
// XLayer.hh for FbTk - fluxbox toolkit
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
// and Simon Bowden (rathnor at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: XLayer.hh,v 1.1 2003/01/16 12:41:27 rathnor Exp $
#ifndef FBTK_XLAYER_HH
#define FBTK_XLAYER_HH
#include <list>
#include "Layer.hh"
#include "MultLayers.hh"
namespace FbTk {
class XLayerItem;
class XLayer : public FbTk::Layer<XLayerItem, std::list<XLayerItem *> > {
public:
XLayer(MultLayers &manager, int layernum);
~XLayer();
//typedef std::list<XLayerItem *>::iterator iterator;
//typedef std::list<XLayerItem *>::reverse_iterator reverse_iterator;
void setLayerNum(int layernum) { m_layernum = layernum; };
int getLayerNum() { return m_layernum; };
void restack();
void stackBelowItem(XLayerItem *item, XLayerItem *above);
XLayerItem *getLowestItem();
// we redefine these as XLayer has special optimisations, and X restacking needs
iterator insert(XLayerItem &item, unsigned int pos=0);
void remove(XLayerItem &item);
void cycleUp();
void cycleDown();
void raise(XLayerItem &item);
void lower(XLayerItem &item);
void stepUp(XLayerItem &item);
void stepDown(XLayerItem &item);
private:
MultLayers &m_manager;
int m_layernum;
};
};
#endif // FBTK_XLAYER_HH

62
src/FbTk/XLayerItem.cc Normal file
View file

@ -0,0 +1,62 @@
// XLayerItem.cc for FbTk - fluxbox toolkit
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
// and Simon Bowden (rathnor at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: XLayerItem.cc,v 1.1 2003/01/16 12:41:27 rathnor Exp $
#include "XLayerItem.hh"
#include "XLayer.hh"
using namespace FbTk;
XLayerItem::XLayerItem() :
m_layer(0), m_layeriterator(0) {}
/*
XLayerItem::XLayerItem(XLayer &layer):
m_layer(&layer) {
m_layeriterator = layer.insert(*this);
}*/
XLayerItem::~XLayerItem() {
m_layer->remove(*this);
}
void XLayerItem::setLayer(XLayer &layer) {
// make sure we don't try to set the same layer
m_layer = &layer;
}
void XLayerItem::raise() {
m_layer->raise(*this);
}
void XLayerItem::lower() {
m_layer->lower(*this);
}
void XLayerItem::stepUp() {
m_layer->stepUp(*this);
}
void XLayerItem::stepDown() {
m_layer->stepDown(*this);
}

57
src/FbTk/XLayerItem.hh Normal file
View file

@ -0,0 +1,57 @@
// XLayerItem.hh for FbTk - fluxbox toolkit
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
// and Simon Bowden (rathnor at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: XLayerItem.hh,v 1.1 2003/01/16 12:41:27 rathnor Exp $
#ifndef FBTK_XLAYERITEM_HH
#define FBTK_XLAYERITEM_HH
#include "LayerItem.hh"
#include "XLayer.hh"
#include <X11/Xlib.h>
namespace FbTk {
class XLayerItem : public LayerItem {
public:
XLayerItem();
~XLayerItem();
void setLayer(XLayer &layer);
XLayer *getLayer() const { return m_layer; }
void raise();
void lower();
void stepUp();
void stepDown();
XLayer::iterator getLayerIterator() const { return m_layeriterator; };
void setLayerIterator(XLayer::iterator it) { m_layeriterator = it; };
virtual Window window() const = 0;
virtual bool visible() const = 0 ;
private:
XLayer *m_layer;
XLayer::iterator m_layeriterator;
};
};
#endif // FBTK_XLAYERITEM_HH