Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | Related Pages

box.h

00001 /*
00002   libwftk - Worldforge Toolkit - a widget library
00003   Copyright (C) 2003 Ron Steinke <rsteinke@w-link.net>
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009   
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014   
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the
00017   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018   Boston, MA  02111-1307, SA.
00019 */
00020 
00021 #ifndef _WFTK_BOX_H
00022 #define _WFTK_BOX_H
00023 
00024 #include <wftk/screenarea.h>
00025 
00026 namespace wftk {
00027 
00037 class Box : public ScreenArea
00038 {
00039  public:
00044   enum Orientation {
00045     LEFT_TO_RIGHT,
00046     RIGHT_TO_LEFT,
00047     TOP_TO_BOTTOM,
00048     BOTTOM_TO_TOP
00049   };
00050 
00052   explicit Box(Orientation);
00053 
00055   Orientation orientation() const {return orientation_;}
00057   void setOrientation(Orientation);
00058 
00060   typedef std::list<ScreenArea*> ChildList;
00061 
00063   class iterator {
00064    public:
00066     iterator& operator++() {++iter_; return *this;}
00068     iterator operator++(int) {iterator tmp = *this; ++iter_; return tmp;}
00070     iterator& operator--() {--iter_; return *this;}
00072     iterator operator--(int) {iterator tmp = *this; --iter_; return tmp;}
00073 
00075     operator ScreenArea*() {return *iter_;}
00077     operator ScreenArea*() const {return *iter_;}
00078 
00080     ScreenArea& operator*() const {return **iter_;}
00082     ScreenArea* operator->() const {return *iter_;}
00083 
00084    private:
00085     friend class Box;
00086     iterator(const ChildList::iterator& iter) : iter_(iter) {}
00087 
00088     ChildList::iterator iter_;
00089   };
00090 
00092   iterator begin() {return children_.begin();}
00094   iterator end() {return children_.end();}
00095 
00097   void pack(ScreenArea*, const iterator&);
00099   void erase(const iterator&);
00100 
00112   void packFront(ScreenArea* sa) {pack(sa, begin());}
00124   void packBack(ScreenArea* sa) {pack(sa, end());}
00126   void clear();
00127 
00129   iterator find(ScreenArea&);
00130 
00131  protected:
00133   virtual void setPackingInfo();
00135   virtual void handleResize(Uint16 w, Uint16 h);
00136  private:
00137   Orientation orientation_;
00138   // This is different from ScreenArea's list. ScreenArea keeps
00139   // front-to-back info, this keeps left-to-right (or whatever).
00140   ChildList children_;
00141 
00143   PackingInfo::Weights weights_;
00144 };
00145 
00146 } // namespace wftk
00147 
00148 #endif // _WFTK_BOX_H

Generated Tue Oct 26 19:02:12 2004.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.