-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathListview.hpp
More file actions
139 lines (121 loc) · 5.11 KB
/
Listview.hpp
File metadata and controls
139 lines (121 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//
// AmigaOS MUI C++ wrapper
//
// (c) 2022-2026 TDolphin
//
#pragma once
#include "Group.hpp"
#include "List.hpp"
#include "ValueTypes/Listview/DragType.hpp"
#include "ValueTypes/Listview/MultiSelect.hpp"
#include "ValueTypes/Listview/ScrollerPos.hpp"
namespace MUI
{
/// @brief Wrapper for list view handling around a list object.
///
/// Listview attaches a scrollbar and input handling to a list object.
class Listview : public Group
{
public:
explicit Listview(Object *pMuiObject)
: Group(pMuiObject)
{
}
Listview(const Root &root)
: Group(root.muiObject())
{
}
// instanceOf
const static std::string className;
static inline bool instanceOf(Object *pMuiObject)
{
return MUI::instanceOf(pMuiObject, className.c_str());
}
static inline bool instanceOf(const Root &object)
{
return MUI::instanceOf(object.muiObject(), className.c_str());
}
// is/get/set (attributes), all setters return object reference
#ifdef MUIA_Listview_AgainClick
/// @brief [ @b MUIA_Listview_AgainClick ]
/// This attribute is set to true whenever the user clicks on the same entry again,
/// but not necessarily within the system double click time.
bool isAgainClick() const;
#endif
/// @brief [ @b MUIA_Listview_ClickColumn ]
/// For multi column lists, this returns the clicked column number.
long getClickColumn() const;
/// @brief [ @b MUIA_Listview_DefClickColumn ]
/// Defines/returns default click column used when RETURN is pressed on keyboard control.
long getDefClickColumn() const;
/// @brief [ @b MUIA_Listview_DoubleClick ]
/// This attribute is set to true whenever the user double clicks an entry.
bool isDoubleClick() const;
/// @brief [ @b MUIA_Listview_DragType ]
/// Returns the configured drag type for dragging items out of the listview.
enum Listview_DragType getDragType() const;
/// @brief [ @b MUIA_Listview_List ]
/// Returns the underlying list object pointer used as child.
Object *getListObject() const;
/// @brief [ @b MUIA_Listview_List ]
/// Returns the underlying list object as wrapper.
List getList() const;
/// @brief [ @b MUIA_Listview_SelectChange ]
/// This attribute is set to true whenever selection state of one or more items changes.
bool isSelectChange() const;
/// @brief [ @b MUIA_Listview_DefClickColumn ]
/// Sets default click column used when RETURN is pressed on keyboard control.
Listview &setDefClickColumn(const long defClickColumn);
/// @brief [ @b MUIA_Listview_DragType ]
/// Configures whether dragging items out of the listview is enabled and how it behaves.
Listview &setDragType(const Listview_DragType dragType);
};
template <typename T, typename U> class ListviewBuilderTemplate : public GroupBuilderTemplate<T, U>
{
bool hasListObject { false };
public:
ListviewBuilderTemplate(const std::string &uniqueId = MUI::EmptyUniqueId, const std::string &muiClassName = MUIC_Listview)
: GroupBuilderTemplate<T, U>(uniqueId, muiClassName)
{
}
#ifdef MUIA_Listview_AgainClick
/// @brief [ @b MUIA_Listview_AgainClick ]
/// Enables reporting clicks on the same entry again.
T &tagAgainClick(const bool againClick);
#endif
/// @brief [ @b MUIA_Listview_DefClickColumn ]
/// Sets default click column used when RETURN is pressed on keyboard control.
T &tagDefClickColumn(const long defClickColumn);
/// @brief [ @b MUIA_Listview_DoubleClick ]
/// Enables reporting double click events on entries.
T &tagDoubleClick(const bool doubleClick);
/// @brief [ @b MUIA_Listview_DragType ]
/// Configures whether dragging items out of the listview is enabled.
T &tagDragType(const enum Listview_DragType dragType);
/// @brief [ @b MUIA_Listview_Input ]
/// Setting this to false makes the listview read-only.
T &tagInput(const bool input);
/// @brief [ @b MUIA_Listview_List ]
/// Assign list child as wrapper object.
T &tagList(const MUI::List &list);
/// @brief [ @b MUIA_Listview_List ]
/// Assign list child as raw object pointer.
T &tagList(const Object *pList);
/// @brief [ @b MUIA_Listview_MultiSelect ]
/// Configures multi selection behavior.
T &tagMultiSelect(const enum Listview_MultiSelect multiSelect);
/// @brief [ @b MUIA_Listview_ScrollerPos ]
/// Configures scrollbar placement for the listview.
T &tagScrollerPos(const enum Listview_ScrollerPos scrollerPos);
protected:
bool Validate() const override;
};
class ListviewBuilder : public ListviewBuilderTemplate<ListviewBuilder, Listview>
{
public:
ListviewBuilder();
};
}
#define MUI_LISTVIEW_TPP_INCLUDE
#include "Listview.tpp"
#undef MUI_LISTVIEW_TPP_INCLUDE