2 * Copyright 2011, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef GROUP_LIST_VIEW_H
6 #define GROUP_LIST_VIEW_H
13 class GroupListModel
{
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
{
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
,
37 class GroupListView
: public BView
{
39 GroupListView(const char* name
,
40 GroupListModel
* model
= NULL
,
41 enum orientation orientation
= B_VERTICAL
,
43 virtual ~GroupListView();
45 GroupListModel
* Model() const
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
,
61 virtual void AttachedToWindow();
62 virtual void MessageReceived(BMessage
* message
);
63 virtual void MouseDown(BPoint point
);
64 virtual void Draw(BRect updateRect
);
67 void _Draw(BLayoutItem
* item
, BRect updateRect
);
68 BLayoutItem
* _ItemAt(BLayoutItem
* item
, BPoint point
);
71 GroupListModel
* fModel
;
72 ListItemRenderer
* fItemRenderer
;
73 ListItemRenderer
* fGroupRenderer
;
75 BMessage
* fSelectionMessage
;
76 BMessenger fSelectionTarget
;
80 #endif // GROUP_LIST_VIEW_H