Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: fpdfsdk/include/fxedit/fxet_list.h

Issue 1863163002: Move code from fpdfsdk/include to the sub directories. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/include/fxedit/fxet_edit.h ('k') | fpdfsdk/include/jsapi/fxjs_v8.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef FPDFSDK_INCLUDE_FXEDIT_FXET_LIST_H_
8 #define FPDFSDK_INCLUDE_FXEDIT_FXET_LIST_H_
9
10 #include "fpdfsdk/include/fxedit/fx_edit.h"
11
12 class IFX_Edit;
13
14 class CLST_Size {
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
35 class CLST_Rect : public CFX_FloatRect {
36 public:
37 CLST_Rect() { left = top = right = bottom = 0.0f; }
38
39 CLST_Rect(FX_FLOAT other_left,
40 FX_FLOAT other_top,
41 FX_FLOAT other_right,
42 FX_FLOAT other_bottom) {
43 left = other_left;
44 top = other_top;
45 right = other_right;
46 bottom = other_bottom;
47 }
48
49 CLST_Rect(const CFX_FloatRect& rect) {
50 left = rect.left;
51 top = rect.top;
52 right = rect.right;
53 bottom = rect.bottom;
54 }
55
56 ~CLST_Rect() {}
57
58 void Default() { left = top = right = bottom = 0.0f; }
59
60 const CLST_Rect operator=(const CFX_FloatRect& rect) {
61 left = rect.left;
62 top = rect.top;
63 right = rect.right;
64 bottom = rect.bottom;
65
66 return *this;
67 }
68
69 bool operator==(const CLST_Rect& rect) const {
70 return FXSYS_memcmp(this, &rect, sizeof(CLST_Rect)) == 0;
71 }
72
73 bool operator!=(const CLST_Rect& rect) const { return !(*this == rect); }
74
75 FX_FLOAT Width() const { return right - left; }
76
77 FX_FLOAT Height() const {
78 if (top > bottom)
79 return top - bottom;
80 return bottom - top;
81 }
82
83 CFX_FloatPoint LeftTop() const { return CFX_FloatPoint(left, top); }
84
85 CFX_FloatPoint RightBottom() const { return CFX_FloatPoint(right, bottom); }
86
87 const CLST_Rect operator+=(const CFX_FloatPoint& point) {
88 left += point.x;
89 right += point.x;
90 top += point.y;
91 bottom += point.y;
92
93 return *this;
94 }
95
96 const CLST_Rect operator-=(const CFX_FloatPoint& point) {
97 left -= point.x;
98 right -= point.x;
99 top -= point.y;
100 bottom -= point.y;
101
102 return *this;
103 }
104
105 CLST_Rect operator+(const CFX_FloatPoint& point) const {
106 return CLST_Rect(left + point.x, top + point.y, right + point.x,
107 bottom + point.y);
108 }
109
110 CLST_Rect operator-(const CFX_FloatPoint& point) const {
111 return CLST_Rect(left - point.x, top - point.y, right - point.x,
112 bottom - point.y);
113 }
114 };
115
116 class CFX_ListItem {
117 public:
118 CFX_ListItem();
119 virtual ~CFX_ListItem();
120
121 void SetFontMap(IPVT_FontMap* pFontMap);
122 IFX_Edit_Iterator* GetIterator() const;
123 IFX_Edit* GetEdit() const;
124
125 public:
126 void SetRect(const CLST_Rect& rect);
127 void SetSelect(FX_BOOL bSelected);
128 void SetCaret(FX_BOOL bCaret);
129 void SetText(const FX_WCHAR* text);
130 void SetFontSize(FX_FLOAT fFontSize);
131 CFX_WideString GetText() const;
132
133 CLST_Rect GetRect() const;
134 FX_BOOL IsSelected() const;
135 FX_BOOL IsCaret() const;
136 FX_FLOAT GetItemHeight() const;
137 uint16_t GetFirstChar() const;
138
139 private:
140 IFX_Edit* m_pEdit;
141 FX_BOOL m_bSelected;
142 FX_BOOL m_bCaret;
143 CLST_Rect m_rcListItem;
144 };
145
146 class CFX_ListContainer {
147 public:
148 CFX_ListContainer()
149 : m_rcPlate(0.0f, 0.0f, 0.0f, 0.0f),
150 m_rcContent(0.0f, 0.0f, 0.0f, 0.0f) {}
151 virtual ~CFX_ListContainer() {}
152 virtual void SetPlateRect(const CFX_FloatRect& rect) { m_rcPlate = rect; }
153 CFX_FloatRect GetPlateRect() const { return m_rcPlate; }
154 void SetContentRect(const CLST_Rect& rect) { m_rcContent = rect; }
155 CLST_Rect GetContentRect() const { return m_rcContent; }
156 CFX_FloatPoint GetBTPoint() const {
157 return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top);
158 }
159 CFX_FloatPoint GetETPoint() const {
160 return CFX_FloatPoint(m_rcPlate.right, m_rcPlate.bottom);
161 }
162
163 public:
164 CFX_FloatPoint InnerToOuter(const CFX_FloatPoint& point) const {
165 return CFX_FloatPoint(point.x + GetBTPoint().x, GetBTPoint().y - point.y);
166 }
167 CFX_FloatPoint OuterToInner(const CFX_FloatPoint& point) const {
168 return CFX_FloatPoint(point.x - GetBTPoint().x, GetBTPoint().y - point.y);
169 }
170 CFX_FloatRect InnerToOuter(const CLST_Rect& rect) const {
171 CFX_FloatPoint ptLeftTop =
172 InnerToOuter(CFX_FloatPoint(rect.left, rect.top));
173 CFX_FloatPoint ptRightBottom =
174 InnerToOuter(CFX_FloatPoint(rect.right, rect.bottom));
175 return CFX_FloatRect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x,
176 ptLeftTop.y);
177 }
178 CLST_Rect OuterToInner(const CFX_FloatRect& rect) const {
179 CFX_FloatPoint ptLeftTop =
180 OuterToInner(CFX_FloatPoint(rect.left, rect.top));
181 CFX_FloatPoint ptRightBottom =
182 OuterToInner(CFX_FloatPoint(rect.right, rect.bottom));
183 return CLST_Rect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x,
184 ptRightBottom.y);
185 }
186
187 private:
188 CFX_FloatRect m_rcPlate;
189 CLST_Rect m_rcContent; // positive forever!
190 };
191
192 template <class TYPE>
193 class CLST_ArrayTemplate : public CFX_ArrayTemplate<TYPE> {
194 public:
195 FX_BOOL IsEmpty() { return CFX_ArrayTemplate<TYPE>::GetSize() <= 0; }
196 TYPE GetAt(int32_t nIndex) const {
197 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize())
198 return CFX_ArrayTemplate<TYPE>::GetAt(nIndex);
199 return NULL;
200 }
201 void RemoveAt(int32_t nIndex) {
202 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize())
203 CFX_ArrayTemplate<TYPE>::RemoveAt(nIndex);
204 }
205 };
206
207 class CFX_List : protected CFX_ListContainer, public IFX_List {
208 public:
209 CFX_List();
210 ~CFX_List() override;
211
212 // IFX_List:
213 void SetFontMap(IPVT_FontMap* pFontMap) override;
214 void SetFontSize(FX_FLOAT fFontSize) override;
215 CFX_FloatRect GetPlateRect() const override;
216 CFX_FloatRect GetContentRect() const override;
217 FX_FLOAT GetFontSize() const override;
218 IFX_Edit* GetItemEdit(int32_t nIndex) const override;
219 int32_t GetCount() const override;
220 FX_BOOL IsItemSelected(int32_t nIndex) const override;
221 FX_FLOAT GetFirstHeight() const override;
222 void SetMultipleSel(FX_BOOL bMultiple) override;
223 FX_BOOL IsMultipleSel() const override;
224 FX_BOOL IsValid(int32_t nItemIndex) const override;
225 int32_t FindNext(int32_t nIndex, FX_WCHAR nChar) const override;
226 void Empty() override;
227 CFX_FloatRect GetItemRect(int32_t nIndex) const override;
228 int32_t GetItemIndex(const CFX_FloatPoint& point) const override;
229 int32_t GetFirstSelected() const override;
230
231 protected:
232 void AddItem(const FX_WCHAR* str);
233 virtual void ReArrange(int32_t nItemIndex);
234 CFX_WideString GetItemText(int32_t nIndex) const;
235 void SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected);
236 void SetItemCaret(int32_t nItemIndex, FX_BOOL bCaret);
237 int32_t GetLastSelected() const;
238 FX_WCHAR Toupper(FX_WCHAR c) const;
239
240 private:
241 CLST_ArrayTemplate<CFX_ListItem*> m_aListItems;
242 FX_FLOAT m_fFontSize;
243 IPVT_FontMap* m_pFontMap;
244 FX_BOOL m_bMultiple;
245 };
246
247 struct CPLST_Select_Item {
248 CPLST_Select_Item(int32_t other_nItemIndex, int32_t other_nState) {
249 nItemIndex = other_nItemIndex;
250 nState = other_nState;
251 }
252
253 int32_t nItemIndex;
254 int32_t nState; // 0:normal select -1:to deselect 1: to select
255 };
256
257 class CPLST_Select {
258 public:
259 CPLST_Select();
260 virtual ~CPLST_Select();
261
262 public:
263 void Add(int32_t nItemIndex);
264 void Add(int32_t nBeginIndex, int32_t nEndIndex);
265 void Sub(int32_t nItemIndex);
266 void Sub(int32_t nBeginIndex, int32_t nEndIndex);
267 FX_BOOL IsExist(int32_t nItemIndex) const;
268 int32_t Find(int32_t nItemIndex) const;
269 int32_t GetCount() const;
270 int32_t GetItemIndex(int32_t nIndex) const;
271 int32_t GetState(int32_t nIndex) const;
272 void Done();
273 void DeselectAll();
274
275 private:
276 CFX_ArrayTemplate<CPLST_Select_Item*> m_aItems;
277 };
278
279 class CFX_ListCtrl : public CFX_List {
280 public:
281 CFX_ListCtrl();
282 ~CFX_ListCtrl() override;
283
284 // CFX_List
285 void SetNotify(IFX_List_Notify* pNotify) override;
286 void OnMouseDown(const CFX_FloatPoint& point,
287 FX_BOOL bShift,
288 FX_BOOL bCtrl) override;
289 void OnMouseMove(const CFX_FloatPoint& point,
290 FX_BOOL bShift,
291 FX_BOOL bCtrl) override;
292 void OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) override;
293 void OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) override;
294 void OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) override;
295 void OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl) override;
296 void OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl) override;
297 void OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl) override;
298 void OnVK(int32_t nItemIndex, FX_BOOL bShift, FX_BOOL bCtrl) override;
299 FX_BOOL OnChar(uint16_t nChar, FX_BOOL bShift, FX_BOOL bCtrl) override;
300 void SetPlateRect(const CFX_FloatRect& rect) override;
301 void SetScrollPos(const CFX_FloatPoint& point) override;
302 void ScrollToListItem(int32_t nItemIndex) override;
303 CFX_FloatRect GetItemRect(int32_t nIndex) const override;
304 int32_t GetCaret() const override { return m_nCaretIndex; }
305 int32_t GetSelect() const override { return m_nSelItem; }
306 int32_t GetTopItem() const override;
307 CFX_FloatRect GetContentRect() const override;
308 int32_t GetItemIndex(const CFX_FloatPoint& point) const override;
309 void AddString(const FX_WCHAR* str) override;
310 void SetTopItem(int32_t nIndex) override;
311 void Select(int32_t nItemIndex) override;
312 void SetCaret(int32_t nItemIndex) override;
313 void Empty() override;
314 void Cancel() override;
315 CFX_WideString GetText() const override;
316 void ReArrange(int32_t nItemIndex) override;
317
318 virtual CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const;
319 virtual CFX_FloatPoint OutToIn(const CFX_FloatPoint& point) const;
320 virtual CFX_FloatRect InToOut(const CFX_FloatRect& rect) const;
321 virtual CFX_FloatRect OutToIn(const CFX_FloatRect& rect) const;
322
323 private:
324 void SetMultipleSelect(int32_t nItemIndex, FX_BOOL bSelected);
325 void SetSingleSelect(int32_t nItemIndex);
326 void InvalidateItem(int32_t nItemIndex);
327 void SelectItems();
328 FX_BOOL IsItemVisible(int32_t nItemIndex) const;
329 void SetScrollInfo();
330 void SetScrollPosY(FX_FLOAT fy);
331
332 private:
333 IFX_List_Notify* m_pNotify;
334 FX_BOOL m_bNotifyFlag;
335 CFX_FloatPoint m_ptScrollPos;
336 CPLST_Select m_aSelItems; // for multiple
337 int32_t m_nSelItem; // for single
338 int32_t m_nFootIndex; // for multiple
339 FX_BOOL m_bCtrlSel; // for multiple
340 int32_t m_nCaretIndex; // for multiple
341 };
342
343 #endif // FPDFSDK_INCLUDE_FXEDIT_FXET_LIST_H_
OLDNEW
« no previous file with comments | « fpdfsdk/include/fxedit/fxet_edit.h ('k') | fpdfsdk/include/jsapi/fxjs_v8.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698