soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SListViewItemLocator.h
1#ifndef __SLISTVIEWITEMLOCATOR__H__
2#define __SLISTVIEWITEMLOCATOR__H__
3
4#include "interface/SListViewItemLocator-i.h"
5#include "control/STree.h"
6
7SNSBEGIN
8
9/**
10 * @class SListViewItemLocatorFix
11 * @brief 固定高度的列表视图项定位器
12 */
13class SOUI_EXP SListViewItemLocatorFix : public TObjRefImpl<IListViewItemLocator> {
14 public:
15 /**
16 * @brief 构造函数
17 * @param nItemHei 每个项的高度
18 * @param nDividerSize 分隔符的高度(默认为0)
19 */
21
22 public:
23 /**
24 * @brief 设置适配器
25 * @param pAdapter 列表适配器对象指针
26 */
27 STDMETHOD_(void, SetAdapter)(THIS_ ILvAdapter *pAdapter) OVERRIDE;
28
29 /**
30 * @brief 数据集发生变化时调用
31 */
32 STDMETHOD_(void, OnDataSetChanged)(THIS) OVERRIDE
33 {
34 }
35
36 /**
37 * @brief 检查是否为固定高度
38 * @return 固定高度返回TRUE,否则返回FALSE
39 */
40 STDMETHOD_(BOOL, IsFixHeight)(THIS) SCONST OVERRIDE;
41
42 /**
43 * @brief 获取指定项的高度
44 * @param iItem 项索引
45 * @return 项的高度
46 */
47 STDMETHOD_(int, GetItemHeight)(THIS_ int iItem) SCONST OVERRIDE;
48
49 /**
50 * @brief 设置指定项的高度
51 * @param iItem 项索引
52 * @param nHeight 新的高度
53 */
54 STDMETHOD_(void, SetItemHeight)(THIS_ int iItem, int nHeight) OVERRIDE;
55
56 /**
57 * @brief 获取总高度
58 * @return 总高度
59 */
60 STDMETHOD_(int, GetTotalHeight)(THIS) OVERRIDE;
61
62 /**
63 * @brief 将项索引转换为位置
64 * @param iItem 项索引
65 * @return 位置
66 */
67 STDMETHOD_(int, Item2Position)(THIS_ int iItem) OVERRIDE;
68
69 /**
70 * @brief 将位置转换为项索引
71 * @param position 位置
72 * @return 项索引
73 */
74 STDMETHOD_(int, Position2Item)(THIS_ int position) OVERRIDE;
75
76 /**
77 * @brief 获取滚动行大小
78 * @return 滚动行大小
79 */
80 STDMETHOD_(int, GetScrollLineSize)(THIS) SCONST OVERRIDE;
81
82 /**
83 * @brief 获取分隔符大小
84 * @return 分隔符大小
85 */
86 STDMETHOD_(int, GetDividerSize)(THIS) SCONST OVERRIDE;
87
88 /**
89 * @brief 设置缩放比例
90 * @param nScale 缩放比例
91 */
92 STDMETHOD_(void, SetScale)(THIS_ int nScale) OVERRIDE;
93
94 protected:
95 /**
96 * @brief 获取固定项的高度
97 * @return 固定项的高度
98 */
99 int GetFixItemHeight() const;
100
101 SLayoutSize m_nItemHeight; ///< 每个项的高度
102 SLayoutSize m_nDividerSize; ///< 分隔符的高度
103 int m_nScale; ///< 缩放比例
104 SAutoRefPtr<ILvAdapter> m_adapter; ///< 列表适配器对象指针
105};
106
107/**
108 * @class SListViewItemLocatorFlex
109 * @brief 可变高度的列表视图项定位器
110 */
111class SOUI_EXP SListViewItemLocatorFlex : public TObjRefImpl<IListViewItemLocator> {
112 public:
113 /**
114 * @brief 构造函数
115 * @param nItemHei 每个项的高度
116 * @param nDividerSize 分隔符的高度(默认为0)
117 */
119
120 /**
121 * @brief 析构函数
122 */
124
125 /**
126 * @brief 设置适配器
127 * @param pAdapter 列表适配器对象指针
128 */
129 STDMETHOD_(void, SetAdapter)(THIS_ ILvAdapter *pAdapter) OVERRIDE;
130
131 /**
132 * @brief 数据集发生变化时调用
133 */
134 STDMETHOD_(void, OnDataSetChanged)(THIS) OVERRIDE;
135
136 /**
137 * @brief 检查是否为固定高度
138 * @return 固定高度返回TRUE,否则返回FALSE
139 */
140 STDMETHOD_(BOOL, IsFixHeight)(THIS) SCONST OVERRIDE;
141
142 /**
143 * @brief 获取指定项的高度
144 * @param iItem 项索引
145 * @return 项的高度
146 */
147 STDMETHOD_(int, GetItemHeight)(THIS_ int iItem) SCONST OVERRIDE;
148
149 /**
150 * @brief 设置指定项的高度
151 * @param iItem 项索引
152 * @param nHeight 新的高度
153 */
154 STDMETHOD_(void, SetItemHeight)(THIS_ int iItem, int nHeight) OVERRIDE;
155
156 /**
157 * @brief 获取总高度
158 * @return 总高度
159 */
160 STDMETHOD_(int, GetTotalHeight)(THIS) OVERRIDE;
161
162 /**
163 * @brief 将项索引转换为位置
164 * @param iItem 项索引
165 * @return 位置
166 */
167 STDMETHOD_(int, Item2Position)(THIS_ int iItem) OVERRIDE;
168
169 /**
170 * @brief 将位置转换为项索引
171 * @param position 位置
172 * @return 项索引
173 */
174 STDMETHOD_(int, Position2Item)(THIS_ int position) OVERRIDE;
175
176 /**
177 * @brief 获取滚动行大小
178 * @return 滚动行大小
179 */
180 STDMETHOD_(int, GetScrollLineSize)(THIS) SCONST OVERRIDE;
181
182 /**
183 * @brief 获取分隔符大小
184 * @return 分隔符大小
185 */
186 STDMETHOD_(int, GetDividerSize)(THIS) SCONST OVERRIDE;
187
188 /**
189 * @brief 设置缩放比例
190 * @param nScale 缩放比例
191 */
192 STDMETHOD_(void, SetScale)(THIS_ int nScale) OVERRIDE;
193
194 protected:
195 /**
196 * @brief 初始化索引
197 * @param hParent 父项句柄
198 * @param nItems 项数量
199 * @param nSubBranchSize 子分支大小
200 */
201 void InitIndex(HSTREEITEM hParent, int nItems, int nSubBranchSize);
202
203 /**
204 * @brief 获取固定项的高度
205 * @return 固定项的高度
206 */
207 int GetFixItemHeight() const;
208
209 /**
210 * @brief 获取索引深度
211 * @return 索引深度
212 */
213 int GetIndexDeep() const;
214
215 /**
216 * @brief 清除索引
217 */
218 void Clear();
219
220 /**
221 * @brief 将分支转换为偏移量
222 * @param hBranch 分支句柄
223 * @return 偏移量
224 */
225 int Branch2Offset(HSTREEITEM hBranch) const;
226
227 /**
228 * @brief 将分支转换为索引
229 * @param hBranch 分支句柄
230 * @return 索引
231 */
232 int Branch2Index(HSTREEITEM hBranch) const;
233
234 /**
235 * @brief 将偏移量转换为分支
236 * @param hParent 父项句柄
237 * @param nOffset 偏移量
238 * @return 分支句柄
239 */
240 HSTREEITEM Offset2Branch(HSTREEITEM hParent, int nOffset);
241
242 SLayoutSize m_nItemHeight; ///< 每个项的高度
243 SLayoutSize m_nDividerSize; ///< 分隔符的高度
244 int m_nScale; ///< 缩放比例
245
246 /**
247 * @struct BranchInfo
248 * @brief 分支信息结构
249 */
251 {
252 int nBranchHei; ///< 分支高度
253 int nBranchSize; ///< 分支中包含的节点数量
254 };
255
256 CSTree<BranchInfo> m_itemPosIndex; ///< 记录分支高度
257
258 /**
259 * @class SegmentInfo
260 * @brief 段信息类
261 */
263 public:
264 /**
265 * @brief 构造函数
266 * @param nItems 项数量
267 * @param hBranch 分支句柄
268 */
269 SegmentInfo(int nItems, HSTREEITEM hBranch)
270 : hItem(hBranch)
271 {
272 this->nItems = nItems;
273 pItemHeight = new int[nItems];
274 memset(pItemHeight, 0xff, nItems * sizeof(int));
275 }
276
277 /**
278 * @brief 析构函数
279 */
281 {
282 if (pItemHeight)
283 delete[] pItemHeight;
284 }
285
286 HSTREEITEM hItem; ///< 分支句柄
287 int nItems; ///< 项数量
288 int *pItemHeight; ///< 段中每一个项的高度
289 };
290
291 SArray<SegmentInfo *> m_segments; ///< 段信息数组
292 SAutoRefPtr<ILvAdapter> m_adapter; ///< 列表适配器对象指针
293};
294
295SNSEND
296
297#endif // __SLISTVIEWITEMLOCATOR__H__
Tree template for general data types.
Template class for a tree structure.
Definition STree.h:56
Smart pointer class for managing COM-style reference-counted objects.
布局大小类
Definition SLayoutSize.h:10
void OnDataSetChanged() OVERRIDE
数据集发生变化时调用
SListViewItemLocatorFix(SLayoutSize nItemHei, SLayoutSize nDividerSize=SLayoutSize())
构造函数
SAutoRefPtr< ILvAdapter > m_adapter
列表适配器对象指针
void SetAdapter(ILvAdapter *pAdapter) OVERRIDE
设置适配器
SLayoutSize m_nDividerSize
分隔符的高度
SLayoutSize m_nItemHeight
每个项的高度
SegmentInfo(int nItems, HSTREEITEM hBranch)
构造函数
int * pItemHeight
段中每一个项的高度
int GetDividerSize() SCONST OVERRIDE
获取分隔符大小
SAutoRefPtr< ILvAdapter > m_adapter
列表适配器对象指针
void SetAdapter(ILvAdapter *pAdapter) OVERRIDE
设置适配器
SListViewItemLocatorFlex(SLayoutSize nItemHei, SLayoutSize nDividerSize=SLayoutSize())
构造函数
void InitIndex(HSTREEITEM hParent, int nItems, int nSubBranchSize)
初始化索引
int Position2Item(int position) OVERRIDE
将位置转换为项索引
int GetIndexDeep() const
获取索引深度
BOOL IsFixHeight() SCONST OVERRIDE
检查是否为固定高度
SLayoutSize m_nItemHeight
每个项的高度
int Item2Position(int iItem) OVERRIDE
将项索引转换为位置
int GetTotalHeight() OVERRIDE
获取总高度
int Branch2Offset(HSTREEITEM hBranch) const
将分支转换为偏移量
void OnDataSetChanged() OVERRIDE
数据集发生变化时调用
int GetFixItemHeight() const
获取固定项的高度
HSTREEITEM Offset2Branch(HSTREEITEM hParent, int nOffset)
将偏移量转换为分支
SArray< SegmentInfo * > m_segments
段信息数组
void SetItemHeight(int iItem, int nHeight) OVERRIDE
设置指定项的高度
SLayoutSize m_nDividerSize
分隔符的高度
void SetScale(int nScale) OVERRIDE
设置缩放比例
int GetScrollLineSize() SCONST OVERRIDE
获取滚动行大小
int Branch2Index(HSTREEITEM hBranch) const
将分支转换为索引
CSTree< BranchInfo > m_itemPosIndex
记录分支高度
int GetItemHeight(int iItem) SCONST OVERRIDE
获取指定项的高度
int nBranchSize
分支中包含的节点数量