aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Container.hh
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2007-12-28 05:47:55 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2007-12-28 05:47:55 (GMT)
commite8a2f155e8d5a082a8c04f291e65c137c20a05cb (patch)
tree4107154a6c73d518b604aab43371c994ae172624 /src/FbTk/Container.hh
parent00ceefd8846bda6f4dc43a5a990086545ea28727 (diff)
downloadfluxbox_pavel-e8a2f155e8d5a082a8c04f291e65c137c20a05cb.zip
fluxbox_pavel-e8a2f155e8d5a082a8c04f291e65c137c20a05cb.tar.bz2
moved Container to FbTk
Diffstat (limited to 'src/FbTk/Container.hh')
-rw-r--r--src/FbTk/Container.hh118
1 files changed, 118 insertions, 0 deletions
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 @@
1// Container.hh
2// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
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#ifndef FBTK_CONTAINER_HH
24#define FBTK_CONTAINER_HH
25
26#include "FbWindow.hh"
27#include "EventHandler.hh"
28#include "NotCopyable.hh"
29#include "Text.hh" // for Orientation
30
31#include <list>
32#include <functional>
33
34namespace FbTk {
35
36class Button;
37
38class Container: public FbWindow, public EventHandler, private NotCopyable {
39public:
40 // LEFT, RIGHT => fixed total width, fixed icon size
41 // RELATIVE => fixed total width, relative/variable icon size
42 enum Alignment { LEFT, RELATIVE, RIGHT };
43 typedef Button * Item;
44 typedef const Button * ConstItem;
45 typedef std::list<Item> ItemList;
46
47 explicit Container(const FbWindow &parent);
48 virtual ~Container();
49
50 // manipulators
51
52 void resize(unsigned int width, unsigned int height);
53 void moveResize(int x, int y,
54 unsigned int width, unsigned int height);
55
56#ifdef NOT_USED
57 void insertItems(ItemList &list, int position=-1);
58#endif
59 void insertItem(Item item, int pos = -1);
60 bool removeItem(int item); // return true if something was removed
61 bool removeItem(Item item); // return true if something was removed
62 void removeAll();
63 void moveItem(Item item, int movement); // wraps around
64 bool moveItemTo(Item item, int x, int y);
65 int find(ConstItem item);
66 void setMaxSizePerClient(unsigned int size);
67 void setMaxTotalSize(unsigned int size);
68 void setAlignment(Alignment a);
69 void setOrientation(Orientation orient);
70
71 Item back() { return m_item_list.back(); }
72
73 /// force update
74 inline void update() { repositionItems(); }
75 /// so we can add items without having an graphic update for each item
76 inline void setUpdateLock(bool value) { m_update_lock = value; }
77
78 /// event handler
79 void exposeEvent(XExposeEvent &event);
80 // for use when embedded in something that may passthrough
81 bool tryExposeEvent(XExposeEvent &event);
82 bool tryButtonPressEvent(XButtonEvent &event);
83 bool tryButtonReleaseEvent(XButtonEvent &event);
84
85 void parentMoved();
86 void invalidateBackground();
87
88 /// accessors
89 inline Alignment alignment() const { return m_align; }
90 inline Orientation orientation() const { return m_orientation; }
91 inline int size() const { return m_item_list.size(); }
92 inline bool empty() const { return m_item_list.empty(); }
93 unsigned int maxWidthPerClient() const;
94 inline bool updateLock() const { return m_update_lock; }
95
96 void for_each(std::mem_fun_t<void, FbWindow> function);
97 void setAlpha(unsigned char alpha); // set alpha on all windows
98
99 ItemList::iterator begin() { return m_item_list.begin(); }
100 ItemList::iterator end() { return m_item_list.end(); }
101
102 void clear(); // clear all windows
103
104private:
105 void repositionItems();
106
107 Orientation m_orientation;
108
109 Alignment m_align;
110 unsigned int m_max_size_per_client;
111 unsigned int m_max_total_size;
112 ItemList m_item_list;
113 bool m_update_lock;
114};
115
116}; // end namespace FbTk
117
118#endif // FBTK_CONTAINER_HH