summaryrefslogtreecommitdiff
path: root/src/Container.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/Container.hh')
-rw-r--r--src/Container.hh78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/Container.hh b/src/Container.hh
new file mode 100644
index 0000000..474e55b
--- /dev/null
+++ b/src/Container.hh
@@ -0,0 +1,78 @@
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.1 2003/08/11 15:28:33 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 ContainerTheme;
35
36namespace FbTk {
37class Button;
38};
39
40class Container:public FbTk::FbWindow, public FbTk::EventHandler, private FbTk::NotCopyable {
41public:
42 typedef FbTk::Button * Item;
43 typedef std::list<Item> ItemList;
44
45 explicit Container(const FbTk::FbWindow &parent);
46 virtual ~Container();
47
48 // manipulators
49
50 void resize(unsigned int width, unsigned int height);
51 void moveResize(int x, int y,
52 unsigned int width, unsigned int height);
53
54 void insertItems(ItemList &list, int position=-1);
55 void insertItem(Item item, int pos = -1);
56 void removeItem(int item);
57 void removeAll();
58 int find(Item item);
59 void setSelected(int index);
60
61 // event handler
62 void exposeEvent(XExposeEvent &event);
63
64 // accessors
65 int size() const { return m_item_list.size(); }
66 const Item selected() const { return m_selected; }
67 Item selected() { return m_selected; }
68 unsigned int maxWidthPerClient() const { return (size() == 0 ? width() : width()/size()); }
69 unsigned int maxHeightPerClient() const { return (size() == 0 ? height() : height()/size()); }
70private:
71 void repositionItems();
72
73 ItemList m_item_list;
74 Item m_selected;
75};
76
77#endif // CONTAINER_HH
78