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_CORE_IFWL_COMBOBOX_H_ | 7 #ifndef XFA_FWL_CORE_IFWL_COMBOBOX_H_ |
8 #define XFA_FWL_CORE_IFWL_COMBOBOX_H_ | 8 #define XFA_FWL_CORE_IFWL_COMBOBOX_H_ |
9 | 9 |
| 10 #include "xfa/fwl/core/ifwl_comboboxproxy.h" |
| 11 #include "xfa/fwl/core/ifwl_comboedit.h" |
10 #include "xfa/fwl/core/ifwl_combolist.h" | 12 #include "xfa/fwl/core/ifwl_combolist.h" |
11 #include "xfa/fwl/core/ifwl_form.h" | 13 #include "xfa/fwl/core/ifwl_form.h" |
12 #include "xfa/fwl/core/ifwl_listbox.h" | 14 #include "xfa/fwl/core/ifwl_listbox.h" |
13 #include "xfa/fxgraphics/cfx_graphics.h" | 15 #include "xfa/fxgraphics/cfx_graphics.h" |
14 | 16 |
15 class CFWL_WidgetProperties; | 17 class CFWL_WidgetProperties; |
16 class IFWL_ComboBox; | 18 class IFWL_ComboBox; |
17 class IFWL_ComboBoxProxy; | 19 class IFWL_ComboBoxProxy; |
18 class IFWL_ComboEdit; | |
19 class IFWL_FormProxy; | 20 class IFWL_FormProxy; |
20 class IFWL_ListBox; | 21 class IFWL_ListBox; |
21 class IFWL_Widget; | 22 class IFWL_Widget; |
22 | 23 |
23 #define FWL_STYLEEXT_CMB_DropList (0L << 0) | 24 #define FWL_STYLEEXT_CMB_DropList (0L << 0) |
24 #define FWL_STYLEEXT_CMB_DropDown (1L << 0) | 25 #define FWL_STYLEEXT_CMB_DropDown (1L << 0) |
25 #define FWL_STYLEEXT_CMB_Sort (1L << 1) | 26 #define FWL_STYLEEXT_CMB_Sort (1L << 1) |
26 #define FWL_STYLEEXT_CMB_ListDrag (1L << 2) | 27 #define FWL_STYLEEXT_CMB_ListDrag (1L << 2) |
27 #define FWL_STYLEEXT_CMB_OwnerDraw (1L << 3) | 28 #define FWL_STYLEEXT_CMB_OwnerDraw (1L << 3) |
28 #define FWL_STYLEEXT_CMB_EditHNear (0L << 4) | 29 #define FWL_STYLEEXT_CMB_EditHNear (0L << 4) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 void Update() override; | 93 void Update() override; |
93 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; | 94 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; |
94 void DrawWidget(CFX_Graphics* pGraphics, | 95 void DrawWidget(CFX_Graphics* pGraphics, |
95 const CFX_Matrix* pMatrix = nullptr) override; | 96 const CFX_Matrix* pMatrix = nullptr) override; |
96 void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override; | 97 void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override; |
97 void OnProcessMessage(CFWL_Message* pMessage) override; | 98 void OnProcessMessage(CFWL_Message* pMessage) override; |
98 void OnProcessEvent(CFWL_Event* pEvent) override; | 99 void OnProcessEvent(CFWL_Event* pEvent) override; |
99 void OnDrawWidget(CFX_Graphics* pGraphics, | 100 void OnDrawWidget(CFX_Graphics* pGraphics, |
100 const CFX_Matrix* pMatrix) override; | 101 const CFX_Matrix* pMatrix) override; |
101 | 102 |
102 int32_t GetCurSel() const; | 103 int32_t GetCurSel() const { return m_iCurSel; } |
103 void SetCurSel(int32_t iSel); | 104 void SetCurSel(int32_t iSel); |
104 | 105 |
105 void SetEditText(const CFX_WideString& wsText); | 106 void SetEditText(const CFX_WideString& wsText); |
106 void GetEditText(CFX_WideString& wsText, | 107 void GetEditText(CFX_WideString& wsText, |
107 int32_t nStart = 0, | 108 int32_t nStart = 0, |
108 int32_t nCount = -1) const; | 109 int32_t nCount = -1) const; |
109 | 110 |
110 void OpenDropDownList(bool bActivate); | 111 void OpenDropDownList(bool bActivate); |
111 | 112 |
112 bool EditCanUndo(); | 113 bool EditCanUndo() const { return m_pEdit->CanUndo(); } |
113 bool EditCanRedo(); | 114 bool EditCanRedo() const { return m_pEdit->CanRedo(); } |
114 bool EditUndo(); | 115 bool EditUndo() { return m_pEdit->Undo(); } |
115 bool EditRedo(); | 116 bool EditRedo() { return m_pEdit->Redo(); } |
116 bool EditCanCopy(); | 117 bool EditCanCopy() const { return m_pEdit->CountSelRanges() > 0; } |
117 bool EditCanCut(); | 118 bool EditCanCut() const { |
118 bool EditCanSelectAll(); | 119 if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) |
119 bool EditCopy(CFX_WideString& wsCopy); | 120 return false; |
120 bool EditCut(CFX_WideString& wsCut); | 121 return EditCanCopy(); |
121 bool EditPaste(const CFX_WideString& wsPaste); | 122 } |
122 bool EditSelectAll(); | 123 bool EditCanSelectAll() const { return m_pEdit->GetTextLength() > 0; } |
123 bool EditDelete(); | 124 bool EditCopy(CFX_WideString& wsCopy) const { return m_pEdit->Copy(wsCopy); } |
124 bool EditDeSelect(); | 125 bool EditCut(CFX_WideString& wsCut) { return m_pEdit->Cut(wsCut); } |
| 126 bool EditPaste(const CFX_WideString& wsPaste) { |
| 127 return m_pEdit->Paste(wsPaste); |
| 128 } |
| 129 void EditSelectAll() { m_pEdit->AddSelRange(0); } |
| 130 void EditDelete() { m_pEdit->ClearText(); } |
| 131 void EditDeSelect() { m_pEdit->ClearSelections(); } |
125 | 132 |
126 void GetBBox(CFX_RectF& rect); | 133 void GetBBox(CFX_RectF& rect) const; |
127 void EditModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved); | 134 void EditModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved); |
128 | 135 |
129 void DrawStretchHandler(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix); | 136 void DrawStretchHandler(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix); |
130 bool IsDropListVisible(); | 137 bool IsDropListVisible() const { |
131 | 138 return m_pComboBoxProxy && |
| 139 !(m_pComboBoxProxy->GetStates() & FWL_WGTSTATE_Invisible); |
| 140 } |
132 void ShowDropList(bool bActivate); | 141 void ShowDropList(bool bActivate); |
133 | 142 |
134 IFWL_ComboEdit* GetComboEdit() const { return m_pEdit.get(); } | 143 IFWL_ComboEdit* GetComboEdit() const { return m_pEdit.get(); } |
135 | 144 |
136 void ProcessSelChanged(bool bLButtonUp); | 145 void ProcessSelChanged(bool bLButtonUp); |
137 int32_t GetCurrentSelection() const { return m_iCurSel; } | 146 int32_t GetCurrentSelection() const { return m_iCurSel; } |
138 | 147 |
139 private: | 148 private: |
140 FX_FLOAT GetListHeight(); | 149 FX_FLOAT GetListHeight(); |
141 bool IsDropDownStyle() const { | 150 bool IsDropDownStyle() const { |
(...skipping 11 matching lines...) Expand all Loading... |
153 void DisForm_ShowDropList(bool bActivate); | 162 void DisForm_ShowDropList(bool bActivate); |
154 bool DisForm_IsDropListVisible() const { | 163 bool DisForm_IsDropListVisible() const { |
155 return !(m_pListBox->GetStates() & FWL_WGTSTATE_Invisible); | 164 return !(m_pListBox->GetStates() & FWL_WGTSTATE_Invisible); |
156 } | 165 } |
157 void DisForm_ModifyStylesEx(uint32_t dwStylesExAdded, | 166 void DisForm_ModifyStylesEx(uint32_t dwStylesExAdded, |
158 uint32_t dwStylesExRemoved); | 167 uint32_t dwStylesExRemoved); |
159 void DisForm_Update(); | 168 void DisForm_Update(); |
160 FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy); | 169 FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy); |
161 void DisForm_DrawWidget(CFX_Graphics* pGraphics, | 170 void DisForm_DrawWidget(CFX_Graphics* pGraphics, |
162 const CFX_Matrix* pMatrix = nullptr); | 171 const CFX_Matrix* pMatrix = nullptr); |
163 void DisForm_GetBBox(CFX_RectF& rect); | 172 void DisForm_GetBBox(CFX_RectF& rect) const; |
164 void DisForm_Layout(); | 173 void DisForm_Layout(); |
165 void OnFocusChanged(CFWL_Message* pMsg, bool bSet = true); | 174 void OnFocusChanged(CFWL_Message* pMsg, bool bSet = true); |
166 void OnLButtonDown(CFWL_MsgMouse* pMsg); | 175 void OnLButtonDown(CFWL_MsgMouse* pMsg); |
167 void OnLButtonUp(CFWL_MsgMouse* pMsg); | 176 void OnLButtonUp(CFWL_MsgMouse* pMsg); |
168 void OnMouseMove(CFWL_MsgMouse* pMsg); | 177 void OnMouseMove(CFWL_MsgMouse* pMsg); |
169 void OnMouseLeave(CFWL_MsgMouse* pMsg); | 178 void OnMouseLeave(CFWL_MsgMouse* pMsg); |
170 void OnKey(CFWL_MsgKey* pMsg); | 179 void OnKey(CFWL_MsgKey* pMsg); |
171 void DoSubCtrlKey(CFWL_MsgKey* pMsg); | 180 void DoSubCtrlKey(CFWL_MsgKey* pMsg); |
172 void DisForm_OnProcessMessage(CFWL_Message* pMessage); | 181 void DisForm_OnProcessMessage(CFWL_Message* pMessage); |
173 void DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg); | 182 void DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg); |
174 void DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet = true); | 183 void DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet = true); |
175 void DisForm_OnKey(CFWL_MsgKey* pMsg); | 184 void DisForm_OnKey(CFWL_MsgKey* pMsg); |
176 | 185 |
177 CFX_RectF m_rtClient; | 186 CFX_RectF m_rtClient; |
178 CFX_RectF m_rtContent; | 187 CFX_RectF m_rtContent; |
179 CFX_RectF m_rtBtn; | 188 CFX_RectF m_rtBtn; |
180 CFX_RectF m_rtList; | 189 CFX_RectF m_rtList; |
181 CFX_RectF m_rtProxy; | 190 CFX_RectF m_rtProxy; |
182 CFX_RectF m_rtHandler; | 191 CFX_RectF m_rtHandler; |
183 std::unique_ptr<IFWL_ComboEdit> m_pEdit; | 192 std::unique_ptr<IFWL_ComboEdit> m_pEdit; |
184 std::unique_ptr<IFWL_ComboList> m_pListBox; | 193 std::unique_ptr<IFWL_ComboList> m_pListBox; |
185 IFWL_ComboBoxProxy* m_pComboBoxProxy; | 194 IFWL_ComboBoxProxy* m_pComboBoxProxy; // Can this be a unique_ptr? |
186 bool m_bLButtonDown; | 195 bool m_bLButtonDown; |
187 bool m_bUpFormHandler; | 196 bool m_bUpFormHandler; |
188 int32_t m_iCurSel; | 197 int32_t m_iCurSel; |
189 int32_t m_iBtnState; | 198 int32_t m_iBtnState; |
190 FX_FLOAT m_fComboFormHandler; | 199 FX_FLOAT m_fComboFormHandler; |
191 FX_FLOAT m_fItemHeight; | 200 FX_FLOAT m_fItemHeight; |
192 }; | 201 }; |
193 | 202 |
194 #endif // XFA_FWL_CORE_IFWL_COMBOBOX_H_ | 203 #endif // XFA_FWL_CORE_IFWL_COMBOBOX_H_ |
OLD | NEW |