00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef CONTAINER_HH
00026 #define CONTAINER_HH
00027
00028 #include "FbTk/FbWindow.hh"
00029 #include "FbTk/EventHandler.hh"
00030 #include "FbTk/NotCopyable.hh"
00031
00032 #include <list>
00033
00034 class Container:public FbTk::FbWindow, public FbTk::EventHandler, private FbTk::NotCopyable {
00035 public:
00036 enum Alignment { LEFT, RELATIVE, RIGHT };
00037 typedef FbTk::FbWindow * Item;
00038 typedef std::list<Item> ItemList;
00039
00040 explicit Container(const FbTk::FbWindow &parent);
00041 virtual ~Container();
00042
00043
00044
00045 void resize(unsigned int width, unsigned int height);
00046 void moveResize(int x, int y,
00047 unsigned int width, unsigned int height);
00048
00049 void insertItems(ItemList &list, int position=-1);
00050 void insertItem(Item item, int pos = -1);
00051 void removeItem(int item);
00052 void removeAll();
00053 int find(Item item);
00054 void setSelected(int index);
00055 void setMaxSizePerClient(unsigned int size);
00056 void setAlignment(Alignment a);
00057
00058 Item back() { return m_item_list.back(); }
00059
00061 inline void update() { repositionItems(); }
00063 inline void setUpdateLock(bool value) { m_update_lock = value; }
00064
00066 void exposeEvent(XExposeEvent &event);
00067
00069 inline Alignment alignment() const { return m_align; }
00070 inline int size() const { return m_item_list.size(); }
00071 inline const Item selected() const { return m_selected; }
00072 inline Item selected() { return m_selected; }
00073 unsigned int maxWidthPerClient() const;
00074 inline unsigned int maxHeightPerClient() const { return (size() == 0 ? height() : height()/size()); }
00075 inline bool updateLock() const { return m_update_lock; }
00076
00077 private:
00078 void repositionItems();
00079
00080 Alignment m_align;
00081 unsigned int m_max_size_per_client;
00082 ItemList m_item_list;
00083 Item m_selected;
00084 bool m_update_lock;
00085 };
00086
00087 #endif // CONTAINER_HH
00088