aboutsummaryrefslogtreecommitdiff
path: root/src/Container.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/Container.hh')
-rw-r--r--src/Container.hh72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/Container.hh b/src/Container.hh
new file mode 100644
index 0000000..ffa7d93
--- /dev/null
+++ b/src/Container.hh
@@ -0,0 +1,72 @@
1// Container.hh
2// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
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// $Id: Container.hh,v 1.2 2003/08/13 09:39:16 fluxgen Exp $
24
25#ifndef CONTAINER_HH
26#define CONTAINER_HH
27
28#include "FbTk/FbWindow.hh"
29#include "FbTk/EventHandler.hh"
30#include "FbTk/NotCopyable.hh"
31
32#include <list>
33
34class Container:public FbTk::FbWindow, public FbTk::EventHandler, private FbTk::NotCopyable {
35public:
36 typedef FbTk::FbWindow * Item;
37 typedef std::list<Item> ItemList;
38
39 explicit Container(const FbTk::FbWindow &parent);
40 virtual ~Container();
41
42 // manipulators
43
44 void resize(unsigned int width, unsigned int height);
45 void moveResize(int x, int y,
46 unsigned int width, unsigned int height);
47
48 void insertItems(ItemList &list, int position=-1);
49 void insertItem(Item item, int pos = -1);
50 void removeItem(int item);
51 void removeAll();
52 int find(Item item);
53 void setSelected(int index);
54
55 // event handler
56 void exposeEvent(XExposeEvent &event);
57
58 // accessors
59 int size() const { return m_item_list.size(); }
60 const Item selected() const { return m_selected; }
61 Item selected() { return m_selected; }
62 unsigned int maxWidthPerClient() const;
63 unsigned int maxHeightPerClient() const { return (size() == 0 ? height() : height()/size()); }
64private:
65 void repositionItems();
66
67 ItemList m_item_list;
68 Item m_selected;
69};
70
71#endif // CONTAINER_HH
72