OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef FPDFSDK_FXEDIT_INCLUDE_FXET_LIST_H_ | 7 #ifndef FPDFSDK_FXEDIT_INCLUDE_FXET_LIST_H_ |
8 #define FPDFSDK_FXEDIT_INCLUDE_FXET_LIST_H_ | 8 #define FPDFSDK_FXEDIT_INCLUDE_FXET_LIST_H_ |
9 | 9 |
| 10 #include "core/fxcrt/include/fx_coordinates.h" |
10 #include "fpdfsdk/fxedit/include/fx_edit.h" | 11 #include "fpdfsdk/fxedit/include/fx_edit.h" |
11 | 12 |
12 class IFX_Edit; | 13 class CFX_Edit; |
13 | 14 class CFX_Edit_Iterator; |
14 class CLST_Size { | 15 class CPWL_List_Notify; |
15 public: | |
16 CLST_Size() : x(0.0f), y(0.0f) {} | |
17 | |
18 CLST_Size(FX_FLOAT other_x, FX_FLOAT other_y) { | |
19 x = other_x; | |
20 y = other_y; | |
21 } | |
22 | |
23 void Default() { | |
24 x = 0.0f; | |
25 y = 0.0f; | |
26 } | |
27 | |
28 FX_BOOL operator!=(const CLST_Size& size) const { | |
29 return FXSYS_memcmp(this, &size, sizeof(CLST_Size)) != 0; | |
30 } | |
31 | |
32 FX_FLOAT x, y; | |
33 }; | |
34 | 16 |
35 class CLST_Rect : public CFX_FloatRect { | 17 class CLST_Rect : public CFX_FloatRect { |
36 public: | 18 public: |
37 CLST_Rect() { left = top = right = bottom = 0.0f; } | 19 CLST_Rect() { left = top = right = bottom = 0.0f; } |
38 | 20 |
39 CLST_Rect(FX_FLOAT other_left, | 21 CLST_Rect(FX_FLOAT other_left, |
40 FX_FLOAT other_top, | 22 FX_FLOAT other_top, |
41 FX_FLOAT other_right, | 23 FX_FLOAT other_right, |
42 FX_FLOAT other_bottom) { | 24 FX_FLOAT other_bottom) { |
43 left = other_left; | 25 left = other_left; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 bottom - point.y); | 94 bottom - point.y); |
113 } | 95 } |
114 }; | 96 }; |
115 | 97 |
116 class CFX_ListItem final { | 98 class CFX_ListItem final { |
117 public: | 99 public: |
118 CFX_ListItem(); | 100 CFX_ListItem(); |
119 ~CFX_ListItem(); | 101 ~CFX_ListItem(); |
120 | 102 |
121 void SetFontMap(IPVT_FontMap* pFontMap); | 103 void SetFontMap(IPVT_FontMap* pFontMap); |
122 IFX_Edit* GetEdit() const; | 104 CFX_Edit* GetEdit() const; |
123 | 105 |
124 void SetRect(const CLST_Rect& rect); | 106 void SetRect(const CLST_Rect& rect); |
125 void SetSelect(FX_BOOL bSelected); | 107 void SetSelect(FX_BOOL bSelected); |
126 void SetText(const FX_WCHAR* text); | 108 void SetText(const FX_WCHAR* text); |
127 void SetFontSize(FX_FLOAT fFontSize); | 109 void SetFontSize(FX_FLOAT fFontSize); |
128 CFX_WideString GetText() const; | 110 CFX_WideString GetText() const; |
129 | 111 |
130 CLST_Rect GetRect() const; | 112 CLST_Rect GetRect() const; |
131 FX_BOOL IsSelected() const; | 113 FX_BOOL IsSelected() const; |
132 FX_FLOAT GetItemHeight() const; | 114 FX_FLOAT GetItemHeight() const; |
133 uint16_t GetFirstChar() const; | 115 uint16_t GetFirstChar() const; |
134 | 116 |
135 private: | 117 private: |
136 IFX_Edit_Iterator* GetIterator() const; | 118 CFX_Edit_Iterator* GetIterator() const; |
137 | 119 |
138 IFX_Edit* m_pEdit; | 120 std::unique_ptr<CFX_Edit> m_pEdit; |
139 FX_BOOL m_bSelected; | 121 FX_BOOL m_bSelected; |
140 CLST_Rect m_rcListItem; | 122 CLST_Rect m_rcListItem; |
141 }; | 123 }; |
142 | 124 |
143 class CFX_ListContainer { | 125 class CFX_ListContainer { |
144 public: | 126 public: |
145 CFX_ListContainer(); | 127 CFX_ListContainer(); |
146 virtual ~CFX_ListContainer(); | 128 virtual ~CFX_ListContainer(); |
| 129 |
147 virtual void SetPlateRect(const CFX_FloatRect& rect); | 130 virtual void SetPlateRect(const CFX_FloatRect& rect); |
148 | 131 |
149 CFX_FloatRect GetPlateRect() const { return m_rcPlate; } | 132 CFX_FloatRect GetPlateRect() const { return m_rcPlate; } |
150 void SetContentRect(const CLST_Rect& rect) { m_rcContent = rect; } | 133 void SetContentRect(const CLST_Rect& rect) { m_rcContent = rect; } |
151 CLST_Rect GetContentRect() const { return m_rcContent; } | 134 CLST_Rect GetContentRect() const { return m_rcContent; } |
152 CFX_FloatPoint GetBTPoint() const { | 135 CFX_FloatPoint GetBTPoint() const { |
153 return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top); | 136 return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top); |
154 } | 137 } |
155 CFX_FloatPoint GetETPoint() const { | 138 CFX_FloatPoint GetETPoint() const { |
156 return CFX_FloatPoint(m_rcPlate.right, m_rcPlate.bottom); | 139 return CFX_FloatPoint(m_rcPlate.right, m_rcPlate.bottom); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) | 176 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) |
194 return CFX_ArrayTemplate<TYPE>::GetAt(nIndex); | 177 return CFX_ArrayTemplate<TYPE>::GetAt(nIndex); |
195 return nullptr; | 178 return nullptr; |
196 } | 179 } |
197 void RemoveAt(int32_t nIndex) { | 180 void RemoveAt(int32_t nIndex) { |
198 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) | 181 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) |
199 CFX_ArrayTemplate<TYPE>::RemoveAt(nIndex); | 182 CFX_ArrayTemplate<TYPE>::RemoveAt(nIndex); |
200 } | 183 } |
201 }; | 184 }; |
202 | 185 |
203 class CFX_List : protected CFX_ListContainer, public IFX_List { | |
204 public: | |
205 CFX_List(); | |
206 ~CFX_List() override; | |
207 | |
208 // IFX_List: | |
209 void SetFontMap(IPVT_FontMap* pFontMap) override; | |
210 void SetFontSize(FX_FLOAT fFontSize) override; | |
211 CFX_FloatRect GetPlateRect() const override; | |
212 CFX_FloatRect GetContentRect() const override; | |
213 FX_FLOAT GetFontSize() const override; | |
214 IFX_Edit* GetItemEdit(int32_t nIndex) const override; | |
215 int32_t GetCount() const override; | |
216 FX_BOOL IsItemSelected(int32_t nIndex) const override; | |
217 FX_FLOAT GetFirstHeight() const override; | |
218 void SetMultipleSel(FX_BOOL bMultiple) override; | |
219 FX_BOOL IsMultipleSel() const override; | |
220 FX_BOOL IsValid(int32_t nItemIndex) const override; | |
221 int32_t FindNext(int32_t nIndex, FX_WCHAR nChar) const override; | |
222 void Empty() override; | |
223 CFX_FloatRect GetItemRect(int32_t nIndex) const override; | |
224 int32_t GetItemIndex(const CFX_FloatPoint& point) const override; | |
225 int32_t GetFirstSelected() const override; | |
226 | |
227 protected: | |
228 void AddItem(const FX_WCHAR* str); | |
229 virtual void ReArrange(int32_t nItemIndex); | |
230 CFX_WideString GetItemText(int32_t nIndex) const; | |
231 void SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected); | |
232 int32_t GetLastSelected() const; | |
233 FX_WCHAR Toupper(FX_WCHAR c) const; | |
234 | |
235 private: | |
236 CLST_ArrayTemplate<CFX_ListItem*> m_aListItems; | |
237 FX_FLOAT m_fFontSize; | |
238 IPVT_FontMap* m_pFontMap; | |
239 FX_BOOL m_bMultiple; | |
240 }; | |
241 | |
242 struct CPLST_Select_Item { | 186 struct CPLST_Select_Item { |
243 CPLST_Select_Item(int32_t other_nItemIndex, int32_t other_nState) { | 187 CPLST_Select_Item(int32_t other_nItemIndex, int32_t other_nState) { |
244 nItemIndex = other_nItemIndex; | 188 nItemIndex = other_nItemIndex; |
245 nState = other_nState; | 189 nState = other_nState; |
246 } | 190 } |
247 | 191 |
248 int32_t nItemIndex; | 192 int32_t nItemIndex; |
249 int32_t nState; // 0:normal select -1:to deselect 1: to select | 193 int32_t nState; // 0:normal select -1:to deselect 1: to select |
250 }; | 194 }; |
251 | 195 |
(...skipping 12 matching lines...) Expand all Loading... |
264 int32_t GetCount() const; | 208 int32_t GetCount() const; |
265 int32_t GetItemIndex(int32_t nIndex) const; | 209 int32_t GetItemIndex(int32_t nIndex) const; |
266 int32_t GetState(int32_t nIndex) const; | 210 int32_t GetState(int32_t nIndex) const; |
267 void Done(); | 211 void Done(); |
268 void DeselectAll(); | 212 void DeselectAll(); |
269 | 213 |
270 private: | 214 private: |
271 CFX_ArrayTemplate<CPLST_Select_Item*> m_aItems; | 215 CFX_ArrayTemplate<CPLST_Select_Item*> m_aItems; |
272 }; | 216 }; |
273 | 217 |
274 class CFX_ListCtrl : public CFX_List { | 218 class CFX_ListCtrl : protected CFX_ListContainer { |
275 public: | 219 public: |
276 CFX_ListCtrl(); | 220 CFX_ListCtrl(); |
277 ~CFX_ListCtrl() override; | 221 ~CFX_ListCtrl() override; |
278 | 222 |
279 // CFX_List | 223 // CFX_ListContainer |
280 void SetNotify(IFX_List_Notify* pNotify) override; | |
281 void OnMouseDown(const CFX_FloatPoint& point, | |
282 FX_BOOL bShift, | |
283 FX_BOOL bCtrl) override; | |
284 void OnMouseMove(const CFX_FloatPoint& point, | |
285 FX_BOOL bShift, | |
286 FX_BOOL bCtrl) override; | |
287 void OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) override; | |
288 void OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) override; | |
289 void OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) override; | |
290 void OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl) override; | |
291 void OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl) override; | |
292 void OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl) override; | |
293 void OnVK(int32_t nItemIndex, FX_BOOL bShift, FX_BOOL bCtrl) override; | |
294 FX_BOOL OnChar(uint16_t nChar, FX_BOOL bShift, FX_BOOL bCtrl) override; | |
295 void SetPlateRect(const CFX_FloatRect& rect) override; | 224 void SetPlateRect(const CFX_FloatRect& rect) override; |
296 void SetScrollPos(const CFX_FloatPoint& point) override; | |
297 void ScrollToListItem(int32_t nItemIndex) override; | |
298 CFX_FloatRect GetItemRect(int32_t nIndex) const override; | |
299 int32_t GetCaret() const override; | |
300 int32_t GetSelect() const override; | |
301 int32_t GetTopItem() const override; | |
302 CFX_FloatRect GetContentRect() const override; | |
303 int32_t GetItemIndex(const CFX_FloatPoint& point) const override; | |
304 void AddString(const FX_WCHAR* str) override; | |
305 void SetTopItem(int32_t nIndex) override; | |
306 void Select(int32_t nItemIndex) override; | |
307 void SetCaret(int32_t nItemIndex) override; | |
308 void Empty() override; | |
309 void Cancel() override; | |
310 CFX_WideString GetText() const override; | |
311 void ReArrange(int32_t nItemIndex) override; | |
312 | 225 |
313 virtual CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const; | 226 void SetNotify(CPWL_List_Notify* pNotify); |
314 virtual CFX_FloatPoint OutToIn(const CFX_FloatPoint& point) const; | 227 void OnMouseDown(const CFX_FloatPoint& point, FX_BOOL bShift, FX_BOOL bCtrl); |
315 virtual CFX_FloatRect InToOut(const CFX_FloatRect& rect) const; | 228 void OnMouseMove(const CFX_FloatPoint& point, FX_BOOL bShift, FX_BOOL bCtrl); |
316 virtual CFX_FloatRect OutToIn(const CFX_FloatRect& rect) const; | 229 void OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl); |
| 230 void OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl); |
| 231 void OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl); |
| 232 void OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl); |
| 233 void OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl); |
| 234 void OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl); |
| 235 void OnVK(int32_t nItemIndex, FX_BOOL bShift, FX_BOOL bCtrl); |
| 236 FX_BOOL OnChar(uint16_t nChar, FX_BOOL bShift, FX_BOOL bCtrl); |
| 237 |
| 238 void SetScrollPos(const CFX_FloatPoint& point); |
| 239 void ScrollToListItem(int32_t nItemIndex); |
| 240 CFX_FloatRect GetItemRect(int32_t nIndex) const; |
| 241 int32_t GetCaret() const; |
| 242 int32_t GetSelect() const; |
| 243 int32_t GetTopItem() const; |
| 244 CFX_FloatRect GetContentRect() const; |
| 245 int32_t GetItemIndex(const CFX_FloatPoint& point) const; |
| 246 void AddString(const FX_WCHAR* str); |
| 247 void SetTopItem(int32_t nIndex); |
| 248 void Select(int32_t nItemIndex); |
| 249 void SetCaret(int32_t nItemIndex); |
| 250 void Empty(); |
| 251 void Cancel(); |
| 252 CFX_WideString GetText() const; |
| 253 |
| 254 void SetFontMap(IPVT_FontMap* pFontMap); |
| 255 void SetFontSize(FX_FLOAT fFontSize); |
| 256 CFX_FloatRect GetPlateRect() const; |
| 257 FX_FLOAT GetFontSize() const; |
| 258 CFX_Edit* GetItemEdit(int32_t nIndex) const; |
| 259 int32_t GetCount() const; |
| 260 FX_BOOL IsItemSelected(int32_t nIndex) const; |
| 261 FX_FLOAT GetFirstHeight() const; |
| 262 void SetMultipleSel(FX_BOOL bMultiple); |
| 263 FX_BOOL IsMultipleSel() const; |
| 264 FX_BOOL IsValid(int32_t nItemIndex) const; |
| 265 int32_t FindNext(int32_t nIndex, FX_WCHAR nChar) const; |
| 266 int32_t GetFirstSelected() const; |
| 267 |
| 268 CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const; |
| 269 CFX_FloatPoint OutToIn(const CFX_FloatPoint& point) const; |
| 270 CFX_FloatRect InToOut(const CFX_FloatRect& rect) const; |
| 271 CFX_FloatRect OutToIn(const CFX_FloatRect& rect) const; |
317 | 272 |
318 private: | 273 private: |
| 274 void ReArrange(int32_t nItemIndex); |
| 275 CFX_FloatRect GetItemRectInternal(int32_t nIndex) const; |
| 276 CFX_FloatRect GetContentRectInternal() const; |
319 void SetMultipleSelect(int32_t nItemIndex, FX_BOOL bSelected); | 277 void SetMultipleSelect(int32_t nItemIndex, FX_BOOL bSelected); |
320 void SetSingleSelect(int32_t nItemIndex); | 278 void SetSingleSelect(int32_t nItemIndex); |
321 void InvalidateItem(int32_t nItemIndex); | 279 void InvalidateItem(int32_t nItemIndex); |
322 void SelectItems(); | 280 void SelectItems(); |
323 FX_BOOL IsItemVisible(int32_t nItemIndex) const; | 281 FX_BOOL IsItemVisible(int32_t nItemIndex) const; |
324 void SetScrollInfo(); | 282 void SetScrollInfo(); |
325 void SetScrollPosY(FX_FLOAT fy); | 283 void SetScrollPosY(FX_FLOAT fy); |
| 284 void AddItem(const FX_WCHAR* str); |
| 285 CFX_WideString GetItemText(int32_t nIndex) const; |
| 286 void SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected); |
| 287 int32_t GetLastSelected() const; |
| 288 FX_WCHAR Toupper(FX_WCHAR c) const; |
326 | 289 |
327 private: | 290 CPWL_List_Notify* m_pNotify; |
328 IFX_List_Notify* m_pNotify; | |
329 FX_BOOL m_bNotifyFlag; | 291 FX_BOOL m_bNotifyFlag; |
330 CFX_FloatPoint m_ptScrollPos; | 292 CFX_FloatPoint m_ptScrollPos; |
331 CPLST_Select m_aSelItems; // for multiple | 293 CPLST_Select m_aSelItems; // for multiple |
332 int32_t m_nSelItem; // for single | 294 int32_t m_nSelItem; // for single |
333 int32_t m_nFootIndex; // for multiple | 295 int32_t m_nFootIndex; // for multiple |
334 FX_BOOL m_bCtrlSel; // for multiple | 296 FX_BOOL m_bCtrlSel; // for multiple |
335 int32_t m_nCaretIndex; // for multiple | 297 int32_t m_nCaretIndex; // for multiple |
| 298 CLST_ArrayTemplate<CFX_ListItem*> m_aListItems; |
| 299 FX_FLOAT m_fFontSize; |
| 300 IPVT_FontMap* m_pFontMap; |
| 301 FX_BOOL m_bMultiple; |
336 }; | 302 }; |
337 | 303 |
338 #endif // FPDFSDK_FXEDIT_INCLUDE_FXET_LIST_H_ | 304 #endif // FPDFSDK_FXEDIT_INCLUDE_FXET_LIST_H_ |
OLD | NEW |