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 XFA_FWL_LIGHTWIDGET_CFWL_COMBOBOX_H_ | 7 #ifndef XFA_FWL_LIGHTWIDGET_CFWL_COMBOBOX_H_ |
8 #define XFA_FWL_LIGHTWIDGET_CFWL_COMBOBOX_H_ | 8 #define XFA_FWL_LIGHTWIDGET_CFWL_COMBOBOX_H_ |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "xfa/fwl/basewidget/ifwl_combobox.h" | 13 #include "xfa/fwl/basewidget/ifwl_combobox.h" |
14 #include "xfa/fwl/lightwidget/cfwl_widget.h" | 14 #include "xfa/fwl/lightwidget/cfwl_widget.h" |
15 | 15 |
16 class CFWL_WidgetProperties; | 16 class CFWL_WidgetProperties; |
17 class IFWL_ComboBoxDP; | 17 class IFWL_ComboBoxDP; |
18 class CFWL_ComboBoxDP; | 18 class CFWL_ComboBoxDP; |
19 class CFWL_ComboBoxItem; | 19 class CFWL_ComboBoxItem; |
20 | 20 |
21 class CFWL_ComboBox : public CFWL_Widget { | 21 class CFWL_ComboBox : public CFWL_Widget { |
22 public: | 22 public: |
23 static CFWL_ComboBox* Create(); | 23 static CFWL_ComboBox* Create(); |
24 FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); | 24 FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = NULL); |
25 int32_t AddString(const CFX_WideStringC& wsText); | 25 int32_t AddString(const CFX_WideStringC& wsText); |
26 int32_t AddString(const CFX_WideStringC& wsText, CFX_DIBitmap* pIcon); | 26 int32_t AddString(const CFX_WideStringC& wsText, CFX_DIBitmap* pIcon); |
27 bool RemoveAt(int32_t iIndex); // Returns false iff |iIndex| out of range. | 27 bool RemoveAt(int32_t iIndex); // Returns false iff |iIndex| out of range. |
28 void RemoveAll(); | 28 void RemoveAll(); |
29 int32_t CountItems(); | 29 int32_t CountItems(); |
30 FWL_ERR GetTextByIndex(int32_t iIndex, CFX_WideString& wsText); | 30 FWL_Error GetTextByIndex(int32_t iIndex, CFX_WideString& wsText); |
31 int32_t GetCurSel(); | 31 int32_t GetCurSel(); |
32 FWL_ERR SetCurSel(int32_t iSel); | 32 FWL_Error SetCurSel(int32_t iSel); |
33 FWL_ERR SetEditText(const CFX_WideString& wsText); | 33 FWL_Error SetEditText(const CFX_WideString& wsText); |
34 int32_t GetEditTextLength() const; | 34 int32_t GetEditTextLength() const; |
35 FWL_ERR GetEditText(CFX_WideString& wsText, | 35 FWL_Error GetEditText(CFX_WideString& wsText, |
36 int32_t nStart = 0, | 36 int32_t nStart = 0, |
37 int32_t nCount = -1) const; | 37 int32_t nCount = -1) const; |
38 FWL_ERR SetEditSelRange(int32_t nStart, int32_t nCount = -1); | 38 FWL_Error SetEditSelRange(int32_t nStart, int32_t nCount = -1); |
39 int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart); | 39 int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart); |
40 int32_t GetEditLimit(); | 40 int32_t GetEditLimit(); |
41 FWL_ERR SetEditLimit(int32_t nLimit); | 41 FWL_Error SetEditLimit(int32_t nLimit); |
42 FWL_ERR EditDoClipboard(int32_t iCmd); | 42 FWL_Error EditDoClipboard(int32_t iCmd); |
43 FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord); | 43 FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord); |
44 FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord); | 44 FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord); |
45 FWL_ERR SetMaxListHeight(FX_FLOAT fMaxHeight); | 45 FWL_Error SetMaxListHeight(FX_FLOAT fMaxHeight); |
46 FWL_ERR SetItemData(int32_t iIndex, void* pData); | 46 FWL_Error SetItemData(int32_t iIndex, void* pData); |
47 void* GetItemData(int32_t iIndex); | 47 void* GetItemData(int32_t iIndex); |
48 FWL_ERR SetListTheme(IFWL_ThemeProvider* pTheme); | 48 FWL_Error SetListTheme(IFWL_ThemeProvider* pTheme); |
49 FX_BOOL AfterFocusShowDropList(); | 49 FX_BOOL AfterFocusShowDropList(); |
50 FWL_ERR OpenDropDownList(FX_BOOL bActivate); | 50 FWL_Error OpenDropDownList(FX_BOOL bActivate); |
51 | 51 |
52 FX_BOOL EditCanUndo(); | 52 FX_BOOL EditCanUndo(); |
53 FX_BOOL EditCanRedo(); | 53 FX_BOOL EditCanRedo(); |
54 FX_BOOL EditUndo(); | 54 FX_BOOL EditUndo(); |
55 FX_BOOL EditRedo(); | 55 FX_BOOL EditRedo(); |
56 FX_BOOL EditCanCopy(); | 56 FX_BOOL EditCanCopy(); |
57 FX_BOOL EditCanCut(); | 57 FX_BOOL EditCanCut(); |
58 FX_BOOL EditCanSelectAll(); | 58 FX_BOOL EditCanSelectAll(); |
59 FX_BOOL EditCopy(CFX_WideString& wsCopy); | 59 FX_BOOL EditCopy(CFX_WideString& wsCopy); |
60 FX_BOOL EditCut(CFX_WideString& wsCut); | 60 FX_BOOL EditCut(CFX_WideString& wsCut); |
61 FX_BOOL EditPaste(const CFX_WideString& wsPaste); | 61 FX_BOOL EditPaste(const CFX_WideString& wsPaste); |
62 FX_BOOL EditSelectAll(); | 62 FX_BOOL EditSelectAll(); |
63 FX_BOOL EditDelete(); | 63 FX_BOOL EditDelete(); |
64 FX_BOOL EditDeSelect(); | 64 FX_BOOL EditDeSelect(); |
65 FWL_ERR GetBBox(CFX_RectF& rect); | 65 FWL_Error GetBBox(CFX_RectF& rect); |
66 FWL_ERR EditModifyStylesEx(uint32_t dwStylesExAdded, | 66 FWL_Error EditModifyStylesEx(uint32_t dwStylesExAdded, |
67 uint32_t dwStylesExRemoved); | 67 uint32_t dwStylesExRemoved); |
68 CFWL_ComboBox(); | 68 CFWL_ComboBox(); |
69 virtual ~CFWL_ComboBox(); | 69 virtual ~CFWL_ComboBox(); |
70 | 70 |
71 protected: | 71 protected: |
72 class CFWL_ComboBoxDP : public IFWL_ComboBoxDP { | 72 class CFWL_ComboBoxDP : public IFWL_ComboBoxDP { |
73 public: | 73 public: |
74 CFWL_ComboBoxDP(); | 74 CFWL_ComboBoxDP(); |
75 ~CFWL_ComboBoxDP(); | 75 ~CFWL_ComboBoxDP(); |
76 virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, | 76 virtual FWL_Error GetCaption(IFWL_Widget* pWidget, |
77 CFX_WideString& wsCaption) { | 77 CFX_WideString& wsCaption) { |
78 return FWL_ERR_Succeeded; | 78 return FWL_Error::Succeeded; |
79 } | 79 } |
80 | 80 |
81 virtual int32_t CountItems(IFWL_Widget* pWidget); | 81 virtual int32_t CountItems(IFWL_Widget* pWidget); |
82 virtual FWL_HLISTITEM GetItem(IFWL_Widget* pWidget, int32_t nIndex); | 82 virtual FWL_HLISTITEM GetItem(IFWL_Widget* pWidget, int32_t nIndex); |
83 virtual int32_t GetItemIndex(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); | 83 virtual int32_t GetItemIndex(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); |
84 virtual FX_BOOL SetItemIndex(IFWL_Widget* pWidget, | 84 virtual FX_BOOL SetItemIndex(IFWL_Widget* pWidget, |
85 FWL_HLISTITEM hItem, | 85 FWL_HLISTITEM hItem, |
86 int32_t nIndex); | 86 int32_t nIndex); |
87 | 87 |
88 virtual uint32_t GetItemStyles(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); | 88 virtual uint32_t GetItemStyles(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); |
89 virtual FWL_ERR GetItemText(IFWL_Widget* pWidget, | 89 virtual FWL_Error GetItemText(IFWL_Widget* pWidget, |
90 FWL_HLISTITEM hItem, | 90 FWL_HLISTITEM hItem, |
91 CFX_WideString& wsText); | 91 CFX_WideString& wsText); |
92 virtual FWL_ERR GetItemRect(IFWL_Widget* pWidget, | 92 virtual FWL_Error GetItemRect(IFWL_Widget* pWidget, |
93 FWL_HLISTITEM hItem, | 93 FWL_HLISTITEM hItem, |
94 CFX_RectF& rtItem); | 94 CFX_RectF& rtItem); |
95 virtual void* GetItemData(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); | 95 virtual void* GetItemData(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); |
96 virtual FWL_ERR SetItemStyles(IFWL_Widget* pWidget, | 96 virtual FWL_Error SetItemStyles(IFWL_Widget* pWidget, |
| 97 FWL_HLISTITEM hItem, |
| 98 uint32_t dwStyle); |
| 99 virtual FWL_Error SetItemText(IFWL_Widget* pWidget, |
97 FWL_HLISTITEM hItem, | 100 FWL_HLISTITEM hItem, |
98 uint32_t dwStyle); | 101 const FX_WCHAR* pszText); |
99 virtual FWL_ERR SetItemText(IFWL_Widget* pWidget, | 102 virtual FWL_Error SetItemRect(IFWL_Widget* pWidget, |
100 FWL_HLISTITEM hItem, | 103 FWL_HLISTITEM hItem, |
101 const FX_WCHAR* pszText); | 104 const CFX_RectF& rtItem); |
102 virtual FWL_ERR SetItemRect(IFWL_Widget* pWidget, | |
103 FWL_HLISTITEM hItem, | |
104 const CFX_RectF& rtItem); | |
105 virtual FX_FLOAT GetItemHeight(IFWL_Widget* pWidget); | 105 virtual FX_FLOAT GetItemHeight(IFWL_Widget* pWidget); |
106 virtual CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget, | 106 virtual CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget, |
107 FWL_HLISTITEM hItem); | 107 FWL_HLISTITEM hItem); |
108 virtual FWL_ERR GetItemCheckRect(IFWL_Widget* pWidget, | 108 virtual FWL_Error GetItemCheckRect(IFWL_Widget* pWidget, |
109 FWL_HLISTITEM hItem, | 109 FWL_HLISTITEM hItem, |
110 CFX_RectF& rtCheck); | 110 CFX_RectF& rtCheck); |
111 virtual FWL_ERR SetItemCheckRect(IFWL_Widget* pWidget, | 111 virtual FWL_Error SetItemCheckRect(IFWL_Widget* pWidget, |
112 FWL_HLISTITEM hItem, | 112 FWL_HLISTITEM hItem, |
113 const CFX_RectF& rtCheck); | 113 const CFX_RectF& rtCheck); |
114 virtual uint32_t GetItemCheckState(IFWL_Widget* pWidget, | 114 virtual uint32_t GetItemCheckState(IFWL_Widget* pWidget, |
115 FWL_HLISTITEM hItem); | 115 FWL_HLISTITEM hItem); |
116 virtual FWL_ERR SetItemCheckState(IFWL_Widget* pWidget, | 116 virtual FWL_Error SetItemCheckState(IFWL_Widget* pWidget, |
117 FWL_HLISTITEM hItem, | 117 FWL_HLISTITEM hItem, |
118 uint32_t dwCheckState); | 118 uint32_t dwCheckState); |
119 virtual FX_FLOAT GetListHeight(IFWL_Widget* pWidget); | 119 virtual FX_FLOAT GetListHeight(IFWL_Widget* pWidget); |
120 | 120 |
121 std::vector<std::unique_ptr<CFWL_ComboBoxItem>> m_ItemArray; | 121 std::vector<std::unique_ptr<CFWL_ComboBoxItem>> m_ItemArray; |
122 FX_FLOAT m_fMaxListHeight; | 122 FX_FLOAT m_fMaxListHeight; |
123 FX_FLOAT m_fItemHeight; | 123 FX_FLOAT m_fItemHeight; |
124 }; | 124 }; |
125 CFWL_ComboBoxDP m_comboBoxData; | 125 CFWL_ComboBoxDP m_comboBoxData; |
126 }; | 126 }; |
127 | 127 |
128 class CFWL_ComboBoxItem { | 128 class CFWL_ComboBoxItem { |
129 public: | 129 public: |
130 CFWL_ComboBoxItem() { | 130 CFWL_ComboBoxItem() { |
131 m_pDIB = NULL; | 131 m_pDIB = NULL; |
132 m_pData = NULL; | 132 m_pData = NULL; |
133 } | 133 } |
134 CFX_RectF m_rtItem; | 134 CFX_RectF m_rtItem; |
135 uint32_t m_dwStyles; | 135 uint32_t m_dwStyles; |
136 CFX_WideString m_wsText; | 136 CFX_WideString m_wsText; |
137 CFX_DIBitmap* m_pDIB; | 137 CFX_DIBitmap* m_pDIB; |
138 uint32_t m_dwCheckState; | 138 uint32_t m_dwCheckState; |
139 CFX_RectF m_rtCheckBox; | 139 CFX_RectF m_rtCheckBox; |
140 void* m_pData; | 140 void* m_pData; |
141 }; | 141 }; |
142 | 142 |
143 #endif // XFA_FWL_LIGHTWIDGET_CFWL_COMBOBOX_H_ | 143 #endif // XFA_FWL_LIGHTWIDGET_CFWL_COMBOBOX_H_ |
OLD | NEW |