From e8a2f155e8d5a082a8c04f291e65c137c20a05cb Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Thu, 27 Dec 2007 21:47:55 -0800 Subject: moved Container to FbTk --- src/CompareWindow.hh | 34 ---- src/Container.cc | 526 -------------------------------------------------- src/Container.hh | 119 ------------ src/FbTk/Container.cc | 524 +++++++++++++++++++++++++++++++++++++++++++++++++ src/FbTk/Container.hh | 118 +++++++++++ src/FbTk/Makefile.am | 1 + src/FbWinFrame.cc | 25 ++- src/FbWinFrame.hh | 8 +- src/IconbarTool.cc | 34 ++-- src/IconbarTool.hh | 10 +- src/Makefile.am | 1 - 11 files changed, 681 insertions(+), 719 deletions(-) delete mode 100644 src/CompareWindow.hh delete mode 100644 src/Container.cc delete mode 100644 src/Container.hh create mode 100644 src/FbTk/Container.cc create mode 100644 src/FbTk/Container.hh diff --git a/src/CompareWindow.hh b/src/CompareWindow.hh deleted file mode 100644 index 48c1dfd..0000000 --- a/src/CompareWindow.hh +++ /dev/null @@ -1,34 +0,0 @@ -// CompareWindow.hh for Fluxbox - an X11 Window manager -// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) -// 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$ - - -#ifndef COMPAREWINDOW_HH -#define COMPAREWINDOW_HH - -#include "FbTk/CompareEqual.hh" -#include "FbTk/FbWindow.hh" - -typedef FbTk::CompareEqual_base CompareWindow; - -#endif // COMPAREWINDOW_HH diff --git a/src/Container.cc b/src/Container.cc deleted file mode 100644 index e2d01c7..0000000 --- a/src/Container.cc +++ /dev/null @@ -1,526 +0,0 @@ -// Container.cc -// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) -// 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$ - -#include "Container.hh" - -#include "FbTk/Button.hh" -#include "FbTk/EventManager.hh" -#include "CompareWindow.hh" - -#include - -Container::Container(const FbTk::FbWindow &parent): - FbTk::FbWindow(parent, 0, 0, 1, 1, ExposureMask), - m_orientation(FbTk::ROT0), - m_align(RELATIVE), - m_max_size_per_client(60), - m_max_total_size(0), - m_update_lock(false) { - FbTk::EventManager::instance()->add(*this, *this); -} - -Container::~Container() { - // ~FbWindow cleans event manager -} - -void Container::resize(unsigned int width, unsigned int height) { - // do we need to resize? - if (FbTk::FbWindow::width() == width && - FbTk::FbWindow::height() == height) - return; - - FbTk::FbWindow::resize(width, height); - repositionItems(); -} - -void Container::moveResize(int x, int y, - unsigned int width, unsigned int height) { - FbTk::FbWindow::moveResize(x, y, width, height); - repositionItems(); -} - -#ifdef NOT_USED -void Container::move(int x, int y) { - FbTk::FbWindow::move(x, y); - // no need to reposition -} - -void Container::insertItems(ItemList &item_list, int pos) { - - // make sure all items have parent == this - ItemList::iterator it = m_item_list.begin(); - ItemList::iterator it_end = m_item_list.end(); - for (; it != it_end; ++it) { - if ((*it)->parent() != this) - return; - } - - if (pos > size() || pos < 0) { - // insert last - m_item_list.splice(m_item_list.end(), item_list); - } else if (pos == 0) { - // insert first - m_item_list.splice(m_item_list.begin(), item_list); - } else { - // find insert point - for (it = m_item_list.begin(); pos != 0; ++it, --pos) - continue; - m_item_list.splice(it, item_list); - } - - m_item_list.unique(); - - // update position - repositionItems(); -} -#endif - -void Container::insertItem(Item item, int pos) { - if (find(item) != -1) - return; - - // it must be a child of this window - if (item->parent() != this) - return; - - item->setOrientation(m_orientation); - if (pos >= size() || pos < 0) { - m_item_list.push_back(item); - } else if (pos == 0) { - m_item_list.push_front(item); - } else { - ItemList::iterator it = m_item_list.begin(); - for (; pos != 0; ++it, --pos) - continue; - - m_item_list.insert(it, item); - } - - // make sure we dont have duplicate items - m_item_list.unique(); - - repositionItems(); -} - -void Container::moveItem(Item item, int movement) { - - int index = find(item); - const size_t size = m_item_list.size(); - - if (index < 0 || (movement % static_cast(size)) == 0) { - return; - } - - int newindex = (index + movement) % static_cast(size); - if (newindex < 0) // neg wrap - newindex += size; - - ItemList::iterator it = std::find(m_item_list.begin(), - m_item_list.end(), - item); - m_item_list.erase(it); - - for (it = m_item_list.begin(); newindex >= 0; ++it, --newindex) { - if (newindex == 0) { - break; - } - } - - m_item_list.insert(it, item); - repositionItems(); -} - -// returns true if something was done -bool Container::moveItemTo(Item item, int x, int y) { - Window parent_return=0, - root_return=0, - *children_return = NULL; - - unsigned int nchildren_return; - - // get the root window - if (!XQueryTree(display(), window(), - &root_return, &parent_return, &children_return, &nchildren_return)) - parent_return = parent_return; - - if (children_return != NULL) - XFree(children_return); - - int dest_x = 0, dest_y = 0; - Window itemwin = 0; - if (!XTranslateCoordinates(display(), - root_return, window(), - x, y, &dest_x, &dest_y, - &itemwin)) - return false; - - ItemList::iterator it = find_if(m_item_list.begin(), - m_item_list.end(), - CompareWindow(&FbTk::FbWindow::window, - itemwin)); - // not found :( - if (it == m_item_list.end()) - return false; - - Window child_return = 0; - //make x and y relative to our item - if (!XTranslateCoordinates(display(), - window(), itemwin, - dest_x, dest_y, &x, &y, - &child_return)) - return false; - return true; -} - -bool Container::removeItem(Item item) { - ItemList::iterator it = m_item_list.begin(); - ItemList::iterator it_end = m_item_list.end(); - for (; it != it_end && (*it) != item; ++it); - - if (it == it_end) - return false; - - m_item_list.erase(it); - repositionItems(); - return true; -} - -bool Container::removeItem(int index) { - if (index < 0 || index > size()) - return false; - - ItemList::iterator it = m_item_list.begin(); - for (; index != 0; ++it, --index) - continue; - - m_item_list.erase(it); - - repositionItems(); - return true; -} - -void Container::removeAll() { - m_item_list.clear(); - if (!m_update_lock) { - clear(); - } - -} - -int Container::find(ConstItem item) { - ItemList::iterator it = m_item_list.begin(); - ItemList::iterator it_end = m_item_list.end(); - int index = 0; - for (; it != it_end; ++it, ++index) { - if ((*it) == item) - break; - } - - if (it == it_end) - return -1; - - return index; -} - -void Container::setMaxSizePerClient(unsigned int size) { - if (size != m_max_size_per_client) { - m_max_size_per_client = size; - repositionItems(); - } -} - -void Container::setMaxTotalSize(unsigned int size) { - if (m_max_total_size == size) - return; - - m_max_total_size = size; - - repositionItems(); - return; -} - -void Container::setAlignment(Container::Alignment a) { - m_align = a; -} - -void Container::exposeEvent(XExposeEvent &event) { - if (!m_update_lock) { - clearArea(event.x, event.y, event.width, event.height); - } -} - -bool Container::tryExposeEvent(XExposeEvent &event) { - if (event.window == window()) { - exposeEvent(event); - return true; - } - - ItemList::iterator it = find_if(m_item_list.begin(), - m_item_list.end(), - CompareWindow(&FbTk::FbWindow::window, - event.window)); - // not found :( - if (it == m_item_list.end()) - return false; - - (*it)->exposeEvent(event); - return true; -} - -bool Container::tryButtonPressEvent(XButtonEvent &event) { - if (event.window == window()) { - // we don't have a buttonrelease event atm - return true; - } - - ItemList::iterator it = find_if(m_item_list.begin(), - m_item_list.end(), - CompareWindow(&FbTk::FbWindow::window, - event.window)); - // not found :( - if (it == m_item_list.end()) - return false; - - (*it)->buttonPressEvent(event); - return true; -} - -bool Container::tryButtonReleaseEvent(XButtonEvent &event) { - if (event.window == window()) { - // we don't have a buttonrelease event atm - return true; - } - - ItemList::iterator it = find_if(m_item_list.begin(), - m_item_list.end(), - CompareWindow(&FbTk::FbWindow::window, - event.window)); - // not found :( - if (it == m_item_list.end()) - return false; - - (*it)->buttonReleaseEvent(event); - return true; -} - -void Container::repositionItems() { - if (empty() || m_update_lock) - return; - - /** - NOTE: all calculations here are done in non-rotated space - */ - - unsigned int max_width_per_client = maxWidthPerClient(); - unsigned int borderW = m_item_list.front()->borderWidth(); - size_t num_items = m_item_list.size(); - - unsigned int total_width; - unsigned int cur_width; - unsigned int height; - - // unrotate - if (m_orientation == FbTk::ROT0 || m_orientation == FbTk::ROT180) { - total_width = cur_width = width(); - height = this->height(); - } else { - total_width = cur_width = this->height(); - height = width(); - } - - // if we have a max total size, then we must also resize ourself - // within that bound - Alignment align = alignment(); - if (m_max_total_size && (align == RIGHT || align == LEFT)) { - total_width = (max_width_per_client + borderW) * num_items - borderW; - if (total_width > m_max_total_size) { - total_width = m_max_total_size; - if (m_max_total_size > ((num_items - 1)*borderW)) { // don't go negative with unsigned nums - max_width_per_client = ( m_max_total_size - (num_items - 1)*borderW ) / num_items; - } else - max_width_per_client = 1; - } - - if (total_width != cur_width) { - // calling Container::resize here risks infinite loops - unsigned int neww = total_width, newh = height; - translateSize(m_orientation, neww, newh); - if (align == RIGHT && m_orientation != FbTk::ROT270 || align == LEFT && m_orientation == FbTk::ROT270) { - int deltax = 0; - int deltay = 0; - if (m_orientation == FbTk::ROT0 || m_orientation == FbTk::ROT180) - deltax = - (total_width - cur_width); - else - deltay = - (total_width - cur_width); - - FbTk::FbWindow::moveResize(x() + deltax, y() + deltay, neww, newh); - } else { - FbTk::FbWindow::resize(neww, newh); - } - } - } - - - ItemList::iterator it = m_item_list.begin(); - const ItemList::iterator it_end = m_item_list.end(); - - int rounding_error = 0; - - if (align == RELATIVE || total_width == m_max_total_size) { - rounding_error = total_width - ((max_width_per_client + borderW)* num_items - borderW); - } - - int next_x = -borderW; // zero so the border of the first shows - int extra = 0; - int direction = 1; - if (align == RIGHT) { - direction = -1; - next_x = total_width - max_width_per_client - borderW; - } - - int tmpx, tmpy; - unsigned int tmpw, tmph; - for (; it != it_end; ++it, next_x += direction*(max_width_per_client + borderW + extra)) { - // we only need to do error stuff with alignment RELATIVE - // OR with max_total_size triggered - if (rounding_error) { - --rounding_error; - extra = 1; - //counter for different direction - if (align == RIGHT && !extra) - --next_x; - } else { - if (extra && align == RIGHT) // last extra - ++next_x; - extra = 0; - } - // rotate the x and y coords - tmpx = next_x; - tmpy = -borderW; - tmpw = max_width_per_client + extra; - tmph = height; - - FbTk::translateCoords(m_orientation, tmpx, tmpy, total_width, height); - FbTk::translatePosition(m_orientation, tmpx, tmpy, tmpw, tmph, borderW); - FbTk::translateSize(m_orientation, tmpw, tmph); - - // resize each clients including border in size - (*it)->moveResize(tmpx, tmpy, - tmpw, tmph); - - // moveresize does a clear - } - -} - - -unsigned int Container::maxWidthPerClient() const { - switch (alignment()) { - case RIGHT: - case LEFT: - return m_max_size_per_client; - break; - case RELATIVE: - if (size() == 0) - return width(); - else { - unsigned int borderW = m_item_list.front()->borderWidth(); - // there're count-1 borders to fit in with the windows - // -> 1 per window plus end - unsigned int w = width(), h = height(); - translateSize(m_orientation, w, h); - if (w < (size()-1)*borderW) - return 1; - else - return (w - (size() - 1) * borderW) / size(); - } - break; - } - - // this will never happen anyway - return 1; -} - -void Container::for_each(std::mem_fun_t function) { - std::for_each(m_item_list.begin(), - m_item_list.end(), - function); -} - -void Container::setAlpha(unsigned char alpha) { - FbTk::FbWindow::setAlpha(alpha); - ItemList::iterator it = m_item_list.begin(); - ItemList::iterator it_end = m_item_list.end(); - for (; it != it_end; ++it) - (*it)->setAlpha(alpha); -} - -void Container::parentMoved() { - FbTk::FbWindow::parentMoved(); - ItemList::iterator it = m_item_list.begin(); - ItemList::iterator it_end = m_item_list.end(); - for (; it != it_end; ++it) - (*it)->parentMoved(); -} - -void Container::invalidateBackground() { - FbTk::FbWindow::invalidateBackground(); - ItemList::iterator it = m_item_list.begin(); - ItemList::iterator it_end = m_item_list.end(); - for (; it != it_end; ++it) - (*it)->invalidateBackground(); -} - -void Container::clear() { - ItemList::iterator it = m_item_list.begin(); - ItemList::iterator it_end = m_item_list.end(); - for (; it != it_end; ++it) - (*it)->clear(); - -} - -void Container::setOrientation(FbTk::Orientation orient) { - if (m_orientation == orient) - return; - - FbTk::FbWindow::invalidateBackground(); - - ItemList::iterator it = m_item_list.begin(); - ItemList::iterator it_end = m_item_list.end(); - for (; it != it_end; ++it) - (*it)->setOrientation(orient); - - if ((m_orientation == FbTk::ROT0 || m_orientation == FbTk::ROT180) && - (orient == FbTk::ROT90 || orient == FbTk::ROT270) || - (m_orientation == FbTk::ROT90 || m_orientation == FbTk::ROT270) && - (orient == FbTk::ROT0 || orient == FbTk::ROT180)) { - // flip width and height - m_orientation = orient; - resize(height(), width()); - } else { - m_orientation = orient; - repositionItems(); - } - -} diff --git a/src/Container.hh b/src/Container.hh deleted file mode 100644 index 69da43d..0000000 --- a/src/Container.hh +++ /dev/null @@ -1,119 +0,0 @@ -// Container.hh -// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) -// 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$ - -#ifndef CONTAINER_HH -#define CONTAINER_HH - -#include "FbTk/FbWindow.hh" -#include "FbTk/EventHandler.hh" -#include "FbTk/NotCopyable.hh" -#include "FbTk/Text.hh" // for Orientation - -namespace FbTk { - class Button; -} - -#include -#include - -class Container:public FbTk::FbWindow, public FbTk::EventHandler, private FbTk::NotCopyable { -public: - // LEFT, RIGHT => fixed total width, fixed icon size - // RELATIVE => fixed total width, relative/variable icon size - enum Alignment { LEFT, RELATIVE, RIGHT }; - typedef FbTk::Button * Item; - typedef const FbTk::Button * ConstItem; - typedef std::list ItemList; - - explicit Container(const FbTk::FbWindow &parent); - virtual ~Container(); - - // manipulators - - void resize(unsigned int width, unsigned int height); - void moveResize(int x, int y, - unsigned int width, unsigned int height); - -#ifdef NOT_USED - void insertItems(ItemList &list, int position=-1); -#endif - void insertItem(Item item, int pos = -1); - bool removeItem(int item); // return true if something was removed - bool removeItem(Item item); // return true if something was removed - void removeAll(); - void moveItem(Item item, int movement); // wraps around - bool moveItemTo(Item item, int x, int y); - int find(ConstItem item); - void setMaxSizePerClient(unsigned int size); - void setMaxTotalSize(unsigned int size); - void setAlignment(Alignment a); - void setOrientation(FbTk::Orientation orient); - - Item back() { return m_item_list.back(); } - - /// force update - inline void update() { repositionItems(); } - /// so we can add items without having an graphic update for each item - inline void setUpdateLock(bool value) { m_update_lock = value; } - - /// event handler - void exposeEvent(XExposeEvent &event); - // for use when embedded in something that may passthrough - bool tryExposeEvent(XExposeEvent &event); - bool tryButtonPressEvent(XButtonEvent &event); - bool tryButtonReleaseEvent(XButtonEvent &event); - - void parentMoved(); - void invalidateBackground(); - - /// accessors - inline Alignment alignment() const { return m_align; } - inline FbTk::Orientation orientation() const { return m_orientation; } - inline int size() const { return m_item_list.size(); } - inline bool empty() const { return m_item_list.empty(); } - unsigned int maxWidthPerClient() const; - inline bool updateLock() const { return m_update_lock; } - - void for_each(std::mem_fun_t function); - void setAlpha(unsigned char alpha); // set alpha on all windows - - ItemList::iterator begin() { return m_item_list.begin(); } - ItemList::iterator end() { return m_item_list.end(); } - - void clear(); // clear all windows - -private: - void repositionItems(); - - FbTk::Orientation m_orientation; - - Alignment m_align; - unsigned int m_max_size_per_client; - unsigned int m_max_total_size; - ItemList m_item_list; - bool m_update_lock; -}; - -#endif // CONTAINER_HH - diff --git a/src/FbTk/Container.cc b/src/FbTk/Container.cc new file mode 100644 index 0000000..9da25c6 --- /dev/null +++ b/src/FbTk/Container.cc @@ -0,0 +1,524 @@ +// Container.cc +// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) +// 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. + +#include "Container.hh" + +#include "Button.hh" +#include "EventManager.hh" +#include "CompareEqual.hh" + +#include + +namespace FbTk { + +typedef CompareEqual_base CompareWindow; + +Container::Container(const FbWindow &parent): + FbWindow(parent, 0, 0, 1, 1, ExposureMask), + m_orientation(ROT0), + m_align(RELATIVE), + m_max_size_per_client(60), + m_max_total_size(0), + m_update_lock(false) { + EventManager::instance()->add(*this, *this); +} + +Container::~Container() { + // ~FbWindow cleans event manager +} + +void Container::resize(unsigned int width, unsigned int height) { + // do we need to resize? + if (FbWindow::width() == width && + FbWindow::height() == height) + return; + + FbWindow::resize(width, height); + repositionItems(); +} + +void Container::moveResize(int x, int y, + unsigned int width, unsigned int height) { + FbWindow::moveResize(x, y, width, height); + repositionItems(); +} + +#ifdef NOT_USED +void Container::insertItems(ItemList &item_list, int pos) { + + // make sure all items have parent == this + ItemList::iterator it = m_item_list.begin(); + ItemList::iterator it_end = m_item_list.end(); + for (; it != it_end; ++it) { + if ((*it)->parent() != this) + return; + } + + if (pos > size() || pos < 0) { + // insert last + m_item_list.splice(m_item_list.end(), item_list); + } else if (pos == 0) { + // insert first + m_item_list.splice(m_item_list.begin(), item_list); + } else { + // find insert point + for (it = m_item_list.begin(); pos != 0; ++it, --pos) + continue; + m_item_list.splice(it, item_list); + } + + m_item_list.unique(); + + // update position + repositionItems(); +} +#endif + +void Container::insertItem(Item item, int pos) { + if (find(item) != -1) + return; + + // it must be a child of this window + if (item->parent() != this) + return; + + item->setOrientation(m_orientation); + if (pos >= size() || pos < 0) { + m_item_list.push_back(item); + } else if (pos == 0) { + m_item_list.push_front(item); + } else { + ItemList::iterator it = m_item_list.begin(); + for (; pos != 0; ++it, --pos) + continue; + + m_item_list.insert(it, item); + } + + // make sure we dont have duplicate items + m_item_list.unique(); + + repositionItems(); +} + +void Container::moveItem(Item item, int movement) { + + int index = find(item); + const size_t size = m_item_list.size(); + + if (index < 0 || (movement % static_cast(size)) == 0) { + return; + } + + int newindex = (index + movement) % static_cast(size); + if (newindex < 0) // neg wrap + newindex += size; + + ItemList::iterator it = std::find(m_item_list.begin(), + m_item_list.end(), + item); + m_item_list.erase(it); + + for (it = m_item_list.begin(); newindex >= 0; ++it, --newindex) { + if (newindex == 0) { + break; + } + } + + m_item_list.insert(it, item); + repositionItems(); +} + +// returns true if something was done +bool Container::moveItemTo(Item item, int x, int y) { + Window parent_return=0, + root_return=0, + *children_return = NULL; + + unsigned int nchildren_return; + + // get the root window + if (!XQueryTree(display(), window(), + &root_return, &parent_return, &children_return, &nchildren_return)) + parent_return = parent_return; + + if (children_return != NULL) + XFree(children_return); + + int dest_x = 0, dest_y = 0; + Window itemwin = 0; + if (!XTranslateCoordinates(display(), + root_return, window(), + x, y, &dest_x, &dest_y, + &itemwin)) + return false; + + ItemList::iterator it = find_if(m_item_list.begin(), + m_item_list.end(), + CompareWindow(&FbWindow::window, + itemwin)); + // not found :( + if (it == m_item_list.end()) + return false; + + Window child_return = 0; + //make x and y relative to our item + if (!XTranslateCoordinates(display(), + window(), itemwin, + dest_x, dest_y, &x, &y, + &child_return)) + return false; + return true; +} + +bool Container::removeItem(Item item) { + ItemList::iterator it = m_item_list.begin(); + ItemList::iterator it_end = m_item_list.end(); + for (; it != it_end && (*it) != item; ++it); + + if (it == it_end) + return false; + + m_item_list.erase(it); + repositionItems(); + return true; +} + +bool Container::removeItem(int index) { + if (index < 0 || index > size()) + return false; + + ItemList::iterator it = m_item_list.begin(); + for (; index != 0; ++it, --index) + continue; + + m_item_list.erase(it); + + repositionItems(); + return true; +} + +void Container::removeAll() { + m_item_list.clear(); + if (!m_update_lock) { + clear(); + } + +} + +int Container::find(ConstItem item) { + ItemList::iterator it = m_item_list.begin(); + ItemList::iterator it_end = m_item_list.end(); + int index = 0; + for (; it != it_end; ++it, ++index) { + if ((*it) == item) + break; + } + + if (it == it_end) + return -1; + + return index; +} + +void Container::setMaxSizePerClient(unsigned int size) { + if (size != m_max_size_per_client) { + m_max_size_per_client = size; + repositionItems(); + } +} + +void Container::setMaxTotalSize(unsigned int size) { + if (m_max_total_size == size) + return; + + m_max_total_size = size; + + repositionItems(); + return; +} + +void Container::setAlignment(Container::Alignment a) { + m_align = a; +} + +void Container::exposeEvent(XExposeEvent &event) { + if (!m_update_lock) { + clearArea(event.x, event.y, event.width, event.height); + } +} + +bool Container::tryExposeEvent(XExposeEvent &event) { + if (event.window == window()) { + exposeEvent(event); + return true; + } + + ItemList::iterator it = find_if(m_item_list.begin(), + m_item_list.end(), + CompareWindow(&FbWindow::window, + event.window)); + // not found :( + if (it == m_item_list.end()) + return false; + + (*it)->exposeEvent(event); + return true; +} + +bool Container::tryButtonPressEvent(XButtonEvent &event) { + if (event.window == window()) { + // we don't have a buttonrelease event atm + return true; + } + + ItemList::iterator it = find_if(m_item_list.begin(), + m_item_list.end(), + CompareWindow(&FbWindow::window, + event.window)); + // not found :( + if (it == m_item_list.end()) + return false; + + (*it)->buttonPressEvent(event); + return true; +} + +bool Container::tryButtonReleaseEvent(XButtonEvent &event) { + if (event.window == window()) { + // we don't have a buttonrelease event atm + return true; + } + + ItemList::iterator it = find_if(m_item_list.begin(), + m_item_list.end(), + CompareWindow(&FbWindow::window, + event.window)); + // not found :( + if (it == m_item_list.end()) + return false; + + (*it)->buttonReleaseEvent(event); + return true; +} + +void Container::repositionItems() { + if (empty() || m_update_lock) + return; + + /** + NOTE: all calculations here are done in non-rotated space + */ + + unsigned int max_width_per_client = maxWidthPerClient(); + unsigned int borderW = m_item_list.front()->borderWidth(); + size_t num_items = m_item_list.size(); + + unsigned int total_width; + unsigned int cur_width; + unsigned int height; + + // unrotate + if (m_orientation == ROT0 || m_orientation == ROT180) { + total_width = cur_width = width(); + height = this->height(); + } else { + total_width = cur_width = this->height(); + height = width(); + } + + // if we have a max total size, then we must also resize ourself + // within that bound + Alignment align = alignment(); + if (m_max_total_size && (align == RIGHT || align == LEFT)) { + total_width = (max_width_per_client + borderW) * num_items - borderW; + if (total_width > m_max_total_size) { + total_width = m_max_total_size; + if (m_max_total_size > ((num_items - 1)*borderW)) { // don't go negative with unsigned nums + max_width_per_client = ( m_max_total_size - (num_items - 1)*borderW ) / num_items; + } else + max_width_per_client = 1; + } + if (total_width != cur_width) { + // calling Container::resize here risks infinite loops + unsigned int neww = total_width, newh = height; + translateSize(m_orientation, neww, newh); + if (align == RIGHT && m_orientation != ROT270 || align == LEFT && m_orientation == ROT270) { + int deltax = 0; + int deltay = 0; + if (m_orientation == ROT0 || m_orientation == ROT180) + deltax = - (total_width - cur_width); + else + deltay = - (total_width - cur_width); + + FbWindow::moveResize(x() + deltax, y() + deltay, neww, newh); + } else { + FbWindow::resize(neww, newh); + } + } + } + + + ItemList::iterator it = m_item_list.begin(); + const ItemList::iterator it_end = m_item_list.end(); + + int rounding_error = 0; + + if (align == RELATIVE || total_width == m_max_total_size) { + rounding_error = total_width - ((max_width_per_client + borderW)* num_items - borderW); + } + + int next_x = -borderW; // zero so the border of the first shows + int extra = 0; + int direction = 1; + if (align == RIGHT) { + direction = -1; + next_x = total_width - max_width_per_client - borderW; + } + + int tmpx, tmpy; + unsigned int tmpw, tmph; + for (; it != it_end; ++it, next_x += direction*(max_width_per_client + borderW + extra)) { + // we only need to do error stuff with alignment RELATIVE + // OR with max_total_size triggered + if (rounding_error) { + --rounding_error; + extra = 1; + //counter for different direction + if (align == RIGHT && !extra) + --next_x; + } else { + if (extra && align == RIGHT) // last extra + ++next_x; + extra = 0; + } + // rotate the x and y coords + tmpx = next_x; + tmpy = -borderW; + tmpw = max_width_per_client + extra; + tmph = height; + + translateCoords(m_orientation, tmpx, tmpy, total_width, height); + translatePosition(m_orientation, tmpx, tmpy, tmpw, tmph, borderW); + translateSize(m_orientation, tmpw, tmph); + + // resize each clients including border in size + (*it)->moveResize(tmpx, tmpy, + tmpw, tmph); + + // moveresize does a clear + } + +} + + +unsigned int Container::maxWidthPerClient() const { + switch (alignment()) { + case RIGHT: + case LEFT: + return m_max_size_per_client; + break; + case RELATIVE: + if (size() == 0) + return width(); + else { + unsigned int borderW = m_item_list.front()->borderWidth(); + // there're count-1 borders to fit in with the windows + // -> 1 per window plus end + unsigned int w = width(), h = height(); + translateSize(m_orientation, w, h); + if (w < (size()-1)*borderW) + return 1; + else + return (w - (size() - 1) * borderW) / size(); + } + break; + } + + // this will never happen anyway + return 1; +} + +void Container::for_each(std::mem_fun_t function) { + std::for_each(m_item_list.begin(), + m_item_list.end(), + function); +} + +void Container::setAlpha(unsigned char alpha) { + FbWindow::setAlpha(alpha); + ItemList::iterator it = m_item_list.begin(); + ItemList::iterator it_end = m_item_list.end(); + for (; it != it_end; ++it) + (*it)->setAlpha(alpha); +} + +void Container::parentMoved() { + FbWindow::parentMoved(); + ItemList::iterator it = m_item_list.begin(); + ItemList::iterator it_end = m_item_list.end(); + for (; it != it_end; ++it) + (*it)->parentMoved(); +} + +void Container::invalidateBackground() { + FbWindow::invalidateBackground(); + ItemList::iterator it = m_item_list.begin(); + ItemList::iterator it_end = m_item_list.end(); + for (; it != it_end; ++it) + (*it)->invalidateBackground(); +} + +void Container::clear() { + ItemList::iterator it = m_item_list.begin(); + ItemList::iterator it_end = m_item_list.end(); + for (; it != it_end; ++it) + (*it)->clear(); + +} + +void Container::setOrientation(Orientation orient) { + if (m_orientation == orient) + return; + + FbWindow::invalidateBackground(); + + ItemList::iterator it = m_item_list.begin(); + ItemList::iterator it_end = m_item_list.end(); + for (; it != it_end; ++it) + (*it)->setOrientation(orient); + + if ((m_orientation == ROT0 || m_orientation == ROT180) && + (orient == ROT90 || orient == ROT270) || + (m_orientation == ROT90 || m_orientation == ROT270) && + (orient == ROT0 || orient == ROT180)) { + // flip width and height + m_orientation = orient; + resize(height(), width()); + } else { + m_orientation = orient; + repositionItems(); + } + +} + +}; // end namespace FbTk diff --git a/src/FbTk/Container.hh b/src/FbTk/Container.hh new file mode 100644 index 0000000..7fb1e32 --- /dev/null +++ b/src/FbTk/Container.hh @@ -0,0 +1,118 @@ +// Container.hh +// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) +// 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. + +#ifndef FBTK_CONTAINER_HH +#define FBTK_CONTAINER_HH + +#include "FbWindow.hh" +#include "EventHandler.hh" +#include "NotCopyable.hh" +#include "Text.hh" // for Orientation + +#include +#include + +namespace FbTk { + +class Button; + +class Container: public FbWindow, public EventHandler, private NotCopyable { +public: + // LEFT, RIGHT => fixed total width, fixed icon size + // RELATIVE => fixed total width, relative/variable icon size + enum Alignment { LEFT, RELATIVE, RIGHT }; + typedef Button * Item; + typedef const Button * ConstItem; + typedef std::list ItemList; + + explicit Container(const FbWindow &parent); + virtual ~Container(); + + // manipulators + + void resize(unsigned int width, unsigned int height); + void moveResize(int x, int y, + unsigned int width, unsigned int height); + +#ifdef NOT_USED + void insertItems(ItemList &list, int position=-1); +#endif + void insertItem(Item item, int pos = -1); + bool removeItem(int item); // return true if something was removed + bool removeItem(Item item); // return true if something was removed + void removeAll(); + void moveItem(Item item, int movement); // wraps around + bool moveItemTo(Item item, int x, int y); + int find(ConstItem item); + void setMaxSizePerClient(unsigned int size); + void setMaxTotalSize(unsigned int size); + void setAlignment(Alignment a); + void setOrientation(Orientation orient); + + Item back() { return m_item_list.back(); } + + /// force update + inline void update() { repositionItems(); } + /// so we can add items without having an graphic update for each item + inline void setUpdateLock(bool value) { m_update_lock = value; } + + /// event handler + void exposeEvent(XExposeEvent &event); + // for use when embedded in something that may passthrough + bool tryExposeEvent(XExposeEvent &event); + bool tryButtonPressEvent(XButtonEvent &event); + bool tryButtonReleaseEvent(XButtonEvent &event); + + void parentMoved(); + void invalidateBackground(); + + /// accessors + inline Alignment alignment() const { return m_align; } + inline Orientation orientation() const { return m_orientation; } + inline int size() const { return m_item_list.size(); } + inline bool empty() const { return m_item_list.empty(); } + unsigned int maxWidthPerClient() const; + inline bool updateLock() const { return m_update_lock; } + + void for_each(std::mem_fun_t function); + void setAlpha(unsigned char alpha); // set alpha on all windows + + ItemList::iterator begin() { return m_item_list.begin(); } + ItemList::iterator end() { return m_item_list.end(); } + + void clear(); // clear all windows + +private: + void repositionItems(); + + Orientation m_orientation; + + Alignment m_align; + unsigned int m_max_size_per_client; + unsigned int m_max_total_size; + ItemList m_item_list; + bool m_update_lock; +}; + +}; // end namespace FbTk + +#endif // FBTK_CONTAINER_HH diff --git a/src/FbTk/Makefile.am b/src/FbTk/Makefile.am index 75733a7..b3dd277 100644 --- a/src/FbTk/Makefile.am +++ b/src/FbTk/Makefile.am @@ -36,6 +36,7 @@ libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \ XFontImp.cc XFontImp.hh \ Button.hh Button.cc \ TextButton.hh TextButton.cc \ + Container.hh Container.cc \ Layer.hh LayerItem.hh MultLayers.cc MultLayers.hh \ XLayer.cc XLayer.hh XLayerItem.cc XLayerItem.hh \ Resource.hh Resource.cc \ diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 2c59798..7734497 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -29,12 +29,11 @@ #include "FbTk/SimpleCommand.hh" #include "FbTk/Compose.hh" #include "FbTk/Transparent.hh" -#include "CompareWindow.hh" +#include "FbTk/CompareEqual.hh" #include "FbWinFrameTheme.hh" #include "Screen.hh" #include "IconButton.hh" -#include "Container.hh" #ifdef SHAPE #include "Shape.hh" @@ -150,7 +149,7 @@ bool FbWinFrame::setTabMode(TabMode tabmode) { } else { m_tab_container.setUpdateLock(true); - m_tab_container.setAlignment(Container::RELATIVE); + m_tab_container.setAlignment(FbTk::Container::RELATIVE); m_tab_container.setOrientation(FbTk::ROT0); if (m_tab_container.parent()->window() == m_screen.rootWindow().window()) { m_layeritem.removeWindow(m_tab_container); @@ -336,7 +335,7 @@ void FbWinFrame::alignTabs() { case TOPLEFT: if (orig_orient != FbTk::ROT0) m_tab_container.hide(); m_tab_container.setOrientation(FbTk::ROT0); - m_tab_container.setAlignment(Container::LEFT); + m_tab_container.setAlignment(FbTk::Container::LEFT); m_tab_container.setMaxTotalSize(m_window.width()); tabx = x(); taby = y() - yOffset(); @@ -344,7 +343,7 @@ void FbWinFrame::alignTabs() { case TOPRIGHT: if (orig_orient != FbTk::ROT0) m_tab_container.hide(); m_tab_container.setOrientation(FbTk::ROT0); - m_tab_container.setAlignment(Container::RIGHT); + m_tab_container.setAlignment(FbTk::Container::RIGHT); m_tab_container.setMaxTotalSize(m_window.width()); tabx = x() + width() - m_tab_container.width(); taby = y() - yOffset(); @@ -352,7 +351,7 @@ void FbWinFrame::alignTabs() { case LEFTTOP: if (orig_orient != FbTk::ROT270) m_tab_container.hide(); m_tab_container.setOrientation(FbTk::ROT270); - m_tab_container.setAlignment(Container::RIGHT); + m_tab_container.setAlignment(FbTk::Container::RIGHT); m_tab_container.setMaxTotalSize(m_window.height()); tabx = x() - xOffset(); taby = y(); @@ -360,7 +359,7 @@ void FbWinFrame::alignTabs() { case LEFTBOTTOM: if (orig_orient != FbTk::ROT270) m_tab_container.hide(); m_tab_container.setOrientation(FbTk::ROT270); - m_tab_container.setAlignment(Container::LEFT); + m_tab_container.setAlignment(FbTk::Container::LEFT); m_tab_container.setMaxTotalSize(m_window.height()); tabx = x() - xOffset(); taby = y() + height() - m_tab_container.height(); @@ -368,7 +367,7 @@ void FbWinFrame::alignTabs() { case RIGHTTOP: if (orig_orient != FbTk::ROT90) m_tab_container.hide(); m_tab_container.setOrientation(FbTk::ROT90); - m_tab_container.setAlignment(Container::LEFT); + m_tab_container.setAlignment(FbTk::Container::LEFT); m_tab_container.setMaxTotalSize(m_window.height()); tabx = x() + width() + m_window.borderWidth(); taby = y(); @@ -376,7 +375,7 @@ void FbWinFrame::alignTabs() { case RIGHTBOTTOM: if (orig_orient != FbTk::ROT90) m_tab_container.hide(); m_tab_container.setOrientation(FbTk::ROT90); - m_tab_container.setAlignment(Container::RIGHT); + m_tab_container.setAlignment(FbTk::Container::RIGHT); m_tab_container.setMaxTotalSize(m_window.height()); tabx = x() + width() + m_window.borderWidth(); taby = y() + height() - m_tab_container.height(); @@ -384,7 +383,7 @@ void FbWinFrame::alignTabs() { case BOTTOMLEFT: if (orig_orient != FbTk::ROT0) m_tab_container.hide(); m_tab_container.setOrientation(FbTk::ROT0); - m_tab_container.setAlignment(Container::LEFT); + m_tab_container.setAlignment(FbTk::Container::LEFT); m_tab_container.setMaxTotalSize(m_window.width()); tabx = x(); taby = y() + height() + m_window.borderWidth(); @@ -392,7 +391,7 @@ void FbWinFrame::alignTabs() { case BOTTOMRIGHT: if (orig_orient != FbTk::ROT0) m_tab_container.hide(); m_tab_container.setOrientation(FbTk::ROT0); - m_tab_container.setAlignment(Container::RIGHT); + m_tab_container.setAlignment(FbTk::Container::RIGHT); m_tab_container.setMaxTotalSize(m_window.width()); tabx = x() + width() - m_tab_container.width(); taby = y() + height() + m_window.borderWidth(); @@ -1453,8 +1452,8 @@ void FbWinFrame::applyTabContainer() { m_tab_container.setBackgroundColor(*tabcontainer_color); // and the labelbuttons in it - Container::ItemList::iterator btn_it = m_tab_container.begin(); - Container::ItemList::iterator btn_it_end = m_tab_container.end(); + FbTk::Container::ItemList::iterator btn_it = m_tab_container.begin(); + FbTk::Container::ItemList::iterator btn_it_end = m_tab_container.end(); for (; btn_it != btn_it_end; ++btn_it) { IconButton *btn = static_cast(*btn_it); btn->reconfigTheme(); diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 7b561ee..69ff020 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -33,7 +33,7 @@ #include "FbTk/XLayerItem.hh" #include "FbTk/TextButton.hh" #include "FbTk/DefaultValue.hh" -#include "Container.hh" +#include "FbTk/Container.hh" #include "Shape.hh" #include @@ -246,8 +246,8 @@ public: inline const FbTk::FbWindow &label() const { return m_label; } inline FbTk::FbWindow &label() { return m_label; } - inline const Container &tabcontainer() const { return m_tab_container; } - inline Container &tabcontainer() { return m_tab_container; } + inline const FbTk::Container &tabcontainer() const { return m_tab_container; } + inline FbTk::Container &tabcontainer() { return m_tab_container; } /// @return clientarea window inline const FbTk::FbWindow &clientArea() const { return m_clientarea; } @@ -332,7 +332,7 @@ private: FbTk::XLayerItem m_layeritem; FbTk::FbWindow m_titlebar; ///< titlebar window - Container m_tab_container; ///< Holds tabs + FbTk::Container m_tab_container; ///< Holds tabs FbTk::TextButton m_label; ///< holds title FbTk::FbWindow m_handle; ///< handle between grips FbTk::FbWindow m_grip_right, ///< rightgrip diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 294754c..de56569 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -69,31 +69,31 @@ using std::endl; namespace FbTk { template<> -void FbTk::Resource::setDefaultValue() { - m_value = Container::RELATIVE; +void FbTk::Resource::setDefaultValue() { + m_value = FbTk::Container::RELATIVE; } template<> -string FbTk::Resource::getString() const { +string FbTk::Resource::getString() const { switch (m_value) { - case Container::LEFT: + case FbTk::Container::LEFT: return string("Left"); - case Container::RIGHT: + case FbTk::Container::RIGHT: return string("Right"); - case Container::RELATIVE: + case FbTk::Container::RELATIVE: return string("Relative"); } return string("Left"); } template<> -void FbTk::Resource::setFromString(const char *str) { +void FbTk::Resource::setFromString(const char *str) { if (strcasecmp(str, "Left") == 0) - m_value = Container::LEFT; + m_value = FbTk::Container::LEFT; else if (strcasecmp(str, "Right") == 0) - m_value = Container::RIGHT; + m_value = FbTk::Container::RIGHT; else if (strcasecmp(str, "Relative") == 0) - m_value = Container::RELATIVE; + m_value = FbTk::Container::RELATIVE; else setDefaultValue(); } @@ -124,7 +124,7 @@ private: class ToolbarAlignMenuItem: public FbTk::MenuItem { public: ToolbarAlignMenuItem(const FbTk::FbString &label, IconbarTool &handler, - Container::Alignment mode, + FbTk::Container::Alignment mode, FbTk::RefCount &cmd): FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) { setCloseOnClick(false); @@ -137,7 +137,7 @@ public: private: IconbarTool &m_handler; - Container::Alignment m_mode; + FbTk::Container::Alignment m_mode; }; void setupModeMenu(FbTk::Menu &menu, IconbarTool &handler) { @@ -194,17 +194,17 @@ void setupModeMenu(FbTk::Menu &menu, IconbarTool &handler) { menu.insert(new ToolbarAlignMenuItem( _FB_XTEXT(Align, Left, "Left", "Align to the left"), handler, - Container::LEFT, saverc_cmd)); + FbTk::Container::LEFT, saverc_cmd)); menu.insert(new ToolbarAlignMenuItem( _FB_XTEXT(Align, Relative, "Relative", "Align relative to the width"), handler, - Container::RELATIVE, saverc_cmd)); + FbTk::Container::RELATIVE, saverc_cmd)); menu.insert(new ToolbarAlignMenuItem( _FB_XTEXT(Align, Right, "Right", "Align to the right"), handler, - Container::RIGHT, saverc_cmd)); + FbTk::Container::RIGHT, saverc_cmd)); menu.insert(new FbTk::MenuSeparator()); @@ -266,7 +266,7 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, m_mode("none"), m_rc_mode(screen.resourceManager(), "{static groups} (workspace)", screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"), - m_rc_alignment(screen.resourceManager(), Container::LEFT, + m_rc_alignment(screen.resourceManager(), FbTk::Container::LEFT, screen.name() + ".iconbar.alignment", screen.altName() + ".Iconbar.Alignment"), m_rc_client_width(screen.resourceManager(), 70, screen.name() + ".iconbar.iconWidth", screen.altName() + ".Iconbar.IconWidth"), @@ -331,7 +331,7 @@ void IconbarTool::hide() { m_icon_container.hide(); } -void IconbarTool::setAlignment(Container::Alignment align) { +void IconbarTool::setAlignment(FbTk::Container::Alignment align) { *m_rc_alignment = align; update(0); m_menu.reconfigure(); diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh index e1bebe3..3111875 100644 --- a/src/IconbarTool.hh +++ b/src/IconbarTool.hh @@ -26,10 +26,10 @@ #define ICONBARTOOL_HH #include "ToolbarItem.hh" -#include "Container.hh" #include "FbMenu.hh" #include "FocusableList.hh" +#include "FbTk/Container.hh" #include "FbTk/CachedPixmap.hh" #include "FbTk/Observer.hh" #include "FbTk/Resource.hh" @@ -60,7 +60,7 @@ public: void update(FbTk::Subject *subj); void show(); void hide(); - void setAlignment(Container::Alignment a); + void setAlignment(FbTk::Container::Alignment a); void setMode(std::string mode); void parentMoved() { m_icon_container.parentMoved(); } @@ -71,7 +71,7 @@ public: std::string mode() const { return *m_rc_mode; } void setOrientation(FbTk::Orientation orient); - Container::Alignment alignment() const { return m_icon_container.alignment(); } + FbTk::Container::Alignment alignment() const { return m_icon_container.alignment(); } const BScreen &screen() const { return m_screen; } private: @@ -99,7 +99,7 @@ private: void updateList(); BScreen &m_screen; - Container m_icon_container; + FbTk::Container m_icon_container; IconbarTheme &m_theme; FbTk::CachedPixmap m_empty_pm; ///< pixmap for empty container @@ -108,7 +108,7 @@ private: IconMap m_icons; std::string m_mode; FbTk::Resource m_rc_mode; - FbTk::Resource m_rc_alignment; ///< alignment of buttons + FbTk::Resource m_rc_alignment; ///< alignment of buttons FbTk::Resource m_rc_client_width; ///< size of client button in LEFT/RIGHT mode FbTk::Resource m_rc_client_padding; ///< padding of the text FbTk::Resource m_rc_use_pixmap; ///< if iconbar should use win pixmap or not diff --git a/src/Makefile.am b/src/Makefile.am index 6b29c1a..d7ed54d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -119,7 +119,6 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \ WorkspaceCmd.hh WorkspaceCmd.cc \ Shape.hh Shape.cc \ MenuTheme.hh MenuTheme.cc \ - Container.hh Container.cc \ CommandDialog.hh CommandDialog.cc SendToMenu.hh SendToMenu.cc \ AlphaMenu.hh AlphaMenu.cc ObjectResource.hh \ CompareWindow.hh \ -- cgit v0.11.2