btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / switcher / GroupListView.h
blob831b55e07f9e399435c3557c5a1f6df843a62ca2
1 /*
2 * Copyright 2011, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef GROUP_LIST_VIEW_H
6 #define GROUP_LIST_VIEW_H
9 #include <GroupView.h>
10 #include <Roster.h>
13 class GroupListModel {
14 public:
15 virtual int32 CountItems() = 0;
16 virtual void* ItemAt(int32 index) = 0;
18 virtual int32 CountGroups() = 0;
19 virtual void* GroupAt(int32 index) = 0;
20 virtual void* GroupForItemAt(int32 index) = 0;
24 class ListItemRenderer {
25 public:
26 virtual void SetTo(BView* owner, void* item) = 0;
28 virtual BSize MinSize() = 0;
29 virtual BSize MaxSize() = 0;
30 virtual BSize PreferredSize() = 0;
32 virtual void Draw(BView* owner, BRect frame, int32 index,
33 bool selected) = 0;
37 class GroupListView : public BView {
38 public:
39 GroupListView(const char* name,
40 GroupListModel* model = NULL,
41 enum orientation orientation = B_VERTICAL,
42 float spacing = 0);
43 virtual ~GroupListView();
45 GroupListModel* Model() const
46 { return fModel; }
47 virtual void SetModel(GroupListModel* model);
49 ListItemRenderer* ItemRenderer() const
50 { return fItemRenderer; }
51 virtual void SetItemRenderer(ListItemRenderer* renderer);
52 ListItemRenderer* GroupRenderer() const
53 { return fGroupRenderer; }
54 virtual void SetGroupRenderer(ListItemRenderer* renderer);
56 BMessage* SelectionMessage() const
57 { return fSelectionMessage; }
58 virtual void SetSelectionMessage(BMessage* message,
59 BMessenger target);
61 virtual void AttachedToWindow();
62 virtual void MessageReceived(BMessage* message);
63 virtual void MouseDown(BPoint point);
64 virtual void Draw(BRect updateRect);
66 private:
67 void _Draw(BLayoutItem* item, BRect updateRect);
68 BLayoutItem* _ItemAt(BLayoutItem* item, BPoint point);
70 private:
71 GroupListModel* fModel;
72 ListItemRenderer* fItemRenderer;
73 ListItemRenderer* fGroupRenderer;
75 BMessage* fSelectionMessage;
76 BMessenger fSelectionTarget;
80 #endif // GROUP_LIST_VIEW_H