| 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_BASEWIDGET_FWL_COMBOBOXIMP_H_ | 7 #ifndef XFA_FWL_CORE_IFWL_COMBOBOX_H_ |
| 8 #define XFA_FWL_BASEWIDGET_FWL_COMBOBOXIMP_H_ | 8 #define XFA_FWL_CORE_IFWL_COMBOBOX_H_ |
| 9 | 9 |
| 10 #include <memory> | 10 #include "xfa/fwl/core/ifwl_form.h" |
| 11 #include "xfa/fwl/core/ifwl_listbox.h" |
| 12 #include "xfa/fxgraphics/cfx_graphics.h" |
| 11 | 13 |
| 12 #include "xfa/fwl/basewidget/fwl_editimp.h" | 14 class CFWL_ComboBoxImpDelegate; |
| 13 #include "xfa/fwl/basewidget/fwl_listboximp.h" | 15 class CFWL_ComboEditImpDelegate; |
| 14 | 16 class CFWL_ComboListImpDelegate; |
| 15 class CFWL_WidgetImp; | 17 class CFWL_ComboProxyImpDelegate; |
| 18 class CFWL_ListBoxImpDelegate; |
| 16 class CFWL_WidgetImpProperties; | 19 class CFWL_WidgetImpProperties; |
| 17 class CFWL_WidgetImpDelegate; | 20 class CFWL_WidgetImpDelegate; |
| 18 class CFWL_ListBoxImp; | 21 class IFWL_ComboBox; |
| 19 class CFWL_ListBoxImpDelegate; | 22 class IFWL_ComboEdit; |
| 20 class CFWL_FormProxyImp; | 23 class IFWL_ComboList; |
| 24 class IFWL_FormProxy; |
| 25 class IFWL_ListBox; |
| 21 class IFWL_Widget; | 26 class IFWL_Widget; |
| 22 class CFWL_ComboEditImp; | 27 |
| 23 class CFWL_ComboEditImpDelegate; | 28 #define FWL_CLASS_ComboBox L"FWL_COMBOBOX" |
| 24 class CFWL_ComboListImp; | 29 #define FWL_STYLEEXT_CMB_DropList (0L << 0) |
| 25 class CFWL_ComboListImpDelegate; | 30 #define FWL_STYLEEXT_CMB_DropDown (1L << 0) |
| 26 class CFWL_ComboBoxImp; | 31 #define FWL_STYLEEXT_CMB_Sort (1L << 1) |
| 27 class CFWL_ComboBoxImpDelegate; | 32 #define FWL_STYLEEXT_CMB_ListDrag (1L << 2) |
| 28 class CFWL_ComboProxyImpDelegate; | 33 #define FWL_STYLEEXT_CMB_OwnerDraw (1L << 3) |
| 29 class CFWL_ComboEditImp : public CFWL_EditImp { | 34 #define FWL_STYLEEXT_CMB_EditHNear (0L << 4) |
| 35 #define FWL_STYLEEXT_CMB_EditHCenter (1L << 4) |
| 36 #define FWL_STYLEEXT_CMB_EditHFar (2L << 4) |
| 37 #define FWL_STYLEEXT_CMB_EditVNear (0L << 6) |
| 38 #define FWL_STYLEEXT_CMB_EditVCenter (1L << 6) |
| 39 #define FWL_STYLEEXT_CMB_EditVFar (2L << 6) |
| 40 #define FWL_STYLEEXT_CMB_EditJustified (1L << 8) |
| 41 #define FWL_STYLEEXT_CMB_EditDistributed (2L << 8) |
| 42 #define FWL_STYLEEXT_CMB_EditHAlignMask (3L << 4) |
| 43 #define FWL_STYLEEXT_CMB_EditVAlignMask (3L << 6) |
| 44 #define FWL_STYLEEXT_CMB_EditHAlignModeMask (3L << 8) |
| 45 #define FWL_STYLEEXT_CMB_ListItemLeftAlign (0L << 10) |
| 46 #define FWL_STYLEEXT_CMB_ListItemCenterAlign (1L << 10) |
| 47 #define FWL_STYLEEXT_CMB_ListItemRightAlign (2L << 10) |
| 48 #define FWL_STYLEEXT_CMB_ListItemAlignMask (3L << 10) |
| 49 #define FWL_STYLEEXT_CMB_ListItemText (0L << 12) |
| 50 #define FWL_STYLEEXT_CMB_ListItemIconText (1L << 12) |
| 51 #define FWL_STYLEEXT_CMB_ReadOnly (1L << 13) |
| 52 |
| 53 FWL_EVENT_DEF(CFWL_EvtCmbPreDropDown, CFWL_EventType::PreDropDown) |
| 54 |
| 55 FWL_EVENT_DEF(CFWL_EvtCmbPostDropDown, CFWL_EventType::PostDropDown) |
| 56 |
| 57 FWL_EVENT_DEF(CFWL_EvtCmbCloseUp, CFWL_EventType::CloseUp) |
| 58 |
| 59 FWL_EVENT_DEF(CFWL_EvtCmbEditChanged, |
| 60 CFWL_EventType::EditChanged, |
| 61 int32_t nChangeType; |
| 62 CFX_WideString wsInsert; |
| 63 CFX_WideString wsDelete;) |
| 64 |
| 65 FWL_EVENT_DEF(CFWL_EvtCmbSelChanged, |
| 66 CFWL_EventType::SelectChanged, |
| 67 CFX_Int32Array iArraySels; |
| 68 FX_BOOL bLButtonUp;) |
| 69 |
| 70 FWL_EVENT_DEF(CFWL_EvtCmbHoverChanged, |
| 71 CFWL_EventType::HoverChanged, |
| 72 int32_t m_iCurHover;) |
| 73 |
| 74 FWL_EVENT_DEF(CFWL_EvtCmbDrawItem, |
| 75 CFWL_EventType::DrawItem, |
| 76 CFX_Graphics* m_pGraphics; |
| 77 CFX_Matrix m_matrix; |
| 78 int32_t m_index; |
| 79 CFX_RectF m_rtItem;) |
| 80 |
| 81 class IFWL_ComboBoxDP : public IFWL_ListBoxDP { |
| 30 public: | 82 public: |
| 31 CFWL_ComboEditImp(const CFWL_WidgetImpProperties& properties, | 83 virtual FX_FLOAT GetListHeight(IFWL_Widget* pWidget) = 0; |
| 32 IFWL_Widget* pOuter); | 84 }; |
| 33 | 85 |
| 34 void ClearSelected(); | 86 class IFWL_ComboBox : public IFWL_Widget { |
| 35 void SetSelected(); | 87 public: |
| 36 void EndCaret(); | 88 static IFWL_ComboBox* Create(const CFWL_WidgetImpProperties& properties); |
| 37 void FlagFocus(FX_BOOL bSet); | |
| 38 | 89 |
| 39 protected: | 90 IFWL_ComboBox(const CFWL_WidgetImpProperties& properties, |
| 40 void SetComboBoxFocus(FX_BOOL bSet); | 91 IFWL_Widget* pOuter); |
| 41 CFWL_ComboBoxImp* m_pOuter; | 92 ~IFWL_ComboBox() override; |
| 42 friend class CFWL_ComboEditImpDelegate; | |
| 43 }; | |
| 44 class CFWL_ComboEditImpDelegate : public CFWL_EditImpDelegate { | |
| 45 public: | |
| 46 CFWL_ComboEditImpDelegate(CFWL_ComboEditImp* pOwner); | |
| 47 void OnProcessMessage(CFWL_Message* pMessage) override; | |
| 48 | 93 |
| 49 protected: | 94 // IFWL_Widget |
| 50 CFWL_ComboEditImp* m_pOwner; | |
| 51 }; | |
| 52 class CFWL_ComboListImp : public CFWL_ListBoxImp { | |
| 53 public: | |
| 54 CFWL_ComboListImp(const CFWL_WidgetImpProperties& properties, | |
| 55 IFWL_Widget* pOuter); | |
| 56 | |
| 57 // CFWL_WidgetImp | |
| 58 FWL_Error Initialize() override; | |
| 59 FWL_Error Finalize() override; | |
| 60 | |
| 61 int32_t MatchItem(const CFX_WideString& wsMatch); | |
| 62 void ChangeSelected(int32_t iSel); | |
| 63 int32_t CountItems(); | |
| 64 void GetItemRect(int32_t nIndex, CFX_RectF& rtItem); | |
| 65 void ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy); | |
| 66 void SetFocus(FX_BOOL bSet); | |
| 67 | |
| 68 FX_BOOL m_bNotifyOwner; | |
| 69 | |
| 70 friend class CFWL_ComboListImpDelegate; | |
| 71 friend class CFWL_ComboBoxImp; | |
| 72 }; | |
| 73 class CFWL_ComboListImpDelegate : public CFWL_ListBoxImpDelegate { | |
| 74 public: | |
| 75 CFWL_ComboListImpDelegate(CFWL_ComboListImp* pOwner); | |
| 76 void OnProcessMessage(CFWL_Message* pMessage) override; | |
| 77 | |
| 78 protected: | |
| 79 void OnDropListFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); | |
| 80 int32_t OnDropListMouseMove(CFWL_MsgMouse* pMsg); | |
| 81 int32_t OnDropListLButtonDown(CFWL_MsgMouse* pMsg); | |
| 82 int32_t OnDropListLButtonUp(CFWL_MsgMouse* pMsg); | |
| 83 int32_t OnDropListKey(CFWL_MsgKey* pKey); | |
| 84 void OnDropListKeyDown(CFWL_MsgKey* pKey); | |
| 85 CFWL_ComboListImp* m_pOwner; | |
| 86 }; | |
| 87 class CFWL_ComboBoxImp : public CFWL_WidgetImp { | |
| 88 public: | |
| 89 CFWL_ComboBoxImp(const CFWL_WidgetImpProperties& properties, | |
| 90 IFWL_Widget* pOuter); | |
| 91 ~CFWL_ComboBoxImp() override; | |
| 92 | |
| 93 // CFWL_WidgetImp | |
| 94 FWL_Error GetClassName(CFX_WideString& wsClass) const override; | 95 FWL_Error GetClassName(CFX_WideString& wsClass) const override; |
| 95 FWL_Type GetClassID() const override; | 96 FWL_Type GetClassID() const override; |
| 96 FWL_Error Initialize() override; | 97 FWL_Error Initialize() override; |
| 97 FWL_Error Finalize() override; | 98 FWL_Error Finalize() override; |
| 98 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override; | 99 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override; |
| 99 FWL_Error ModifyStylesEx(uint32_t dwStylesExAdded, | 100 FWL_Error ModifyStylesEx(uint32_t dwStylesExAdded, |
| 100 uint32_t dwStylesExRemoved) override; | 101 uint32_t dwStylesExRemoved) override; |
| 101 void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE) override; | 102 void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE) override; |
| 102 FWL_Error Update() override; | 103 FWL_Error Update() override; |
| 103 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; | 104 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 133 FX_BOOL EditCut(CFX_WideString& wsCut); | 134 FX_BOOL EditCut(CFX_WideString& wsCut); |
| 134 FX_BOOL EditPaste(const CFX_WideString& wsPaste); | 135 FX_BOOL EditPaste(const CFX_WideString& wsPaste); |
| 135 FX_BOOL EditSelectAll(); | 136 FX_BOOL EditSelectAll(); |
| 136 FX_BOOL EditDelete(); | 137 FX_BOOL EditDelete(); |
| 137 FX_BOOL EditDeSelect(); | 138 FX_BOOL EditDeSelect(); |
| 138 FWL_Error GetBBox(CFX_RectF& rect); | 139 FWL_Error GetBBox(CFX_RectF& rect); |
| 139 FWL_Error EditModifyStylesEx(uint32_t dwStylesExAdded, | 140 FWL_Error EditModifyStylesEx(uint32_t dwStylesExAdded, |
| 140 uint32_t dwStylesExRemoved); | 141 uint32_t dwStylesExRemoved); |
| 141 | 142 |
| 142 protected: | 143 protected: |
| 143 friend class CFWL_ComboListImp; | 144 friend class CFWL_ComboBoxImpDelegate; |
| 144 friend class CFWL_ComboEditImp; | |
| 145 friend class CFWL_ComboEditImpDelegate; | 145 friend class CFWL_ComboEditImpDelegate; |
| 146 friend class CFWL_ComboListImpDelegate; | 146 friend class CFWL_ComboListImpDelegate; |
| 147 friend class CFWL_ComboBoxImpDelegate; | |
| 148 friend class CFWL_ComboProxyImpDelegate; | 147 friend class CFWL_ComboProxyImpDelegate; |
| 148 friend class IFWL_ComboEdit; |
| 149 friend class IFWL_ComboList; |
| 149 | 150 |
| 150 void DrawStretchHandler(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix); | 151 void DrawStretchHandler(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix); |
| 151 FX_FLOAT GetListHeight(); | 152 FX_FLOAT GetListHeight(); |
| 152 void ShowDropList(FX_BOOL bActivate); | 153 void ShowDropList(FX_BOOL bActivate); |
| 153 FX_BOOL IsDropListShowed(); | 154 FX_BOOL IsDropListShowed(); |
| 154 FX_BOOL IsDropDownStyle() const; | 155 FX_BOOL IsDropDownStyle() const; |
| 155 void MatchEditText(); | 156 void MatchEditText(); |
| 156 void SynchrEditText(int32_t iListItem); | 157 void SynchrEditText(int32_t iListItem); |
| 157 void Layout(); | 158 void Layout(); |
| 158 void ReSetTheme(); | 159 void ReSetTheme(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 173 const CFX_Matrix* pMatrix = nullptr); | 174 const CFX_Matrix* pMatrix = nullptr); |
| 174 FWL_Error DisForm_GetBBox(CFX_RectF& rect); | 175 FWL_Error DisForm_GetBBox(CFX_RectF& rect); |
| 175 void DisForm_Layout(); | 176 void DisForm_Layout(); |
| 176 | 177 |
| 177 CFX_RectF m_rtClient; | 178 CFX_RectF m_rtClient; |
| 178 CFX_RectF m_rtContent; | 179 CFX_RectF m_rtContent; |
| 179 CFX_RectF m_rtBtn; | 180 CFX_RectF m_rtBtn; |
| 180 CFX_RectF m_rtList; | 181 CFX_RectF m_rtList; |
| 181 CFX_RectF m_rtProxy; | 182 CFX_RectF m_rtProxy; |
| 182 CFX_RectF m_rtHandler; | 183 CFX_RectF m_rtHandler; |
| 183 std::unique_ptr<IFWL_Edit> m_pEdit; | 184 std::unique_ptr<IFWL_ComboEdit> m_pEdit; |
| 184 std::unique_ptr<IFWL_ListBox> m_pListBox; | 185 std::unique_ptr<IFWL_ComboList> m_pListBox; |
| 185 IFWL_Form* m_pForm; | 186 IFWL_FormProxy* m_pForm; |
| 186 FX_BOOL m_bLButtonDown; | 187 FX_BOOL m_bLButtonDown; |
| 187 FX_BOOL m_bUpFormHandler; | 188 FX_BOOL m_bUpFormHandler; |
| 188 int32_t m_iCurSel; | 189 int32_t m_iCurSel; |
| 189 int32_t m_iBtnState; | 190 int32_t m_iBtnState; |
| 190 FX_FLOAT m_fComboFormHandler; | 191 FX_FLOAT m_fComboFormHandler; |
| 191 FX_FLOAT m_fItemHeight; | 192 FX_FLOAT m_fItemHeight; |
| 192 FX_BOOL m_bNeedShowList; | 193 FX_BOOL m_bNeedShowList; |
| 193 CFWL_FormProxyImp* m_pProxy; | |
| 194 CFWL_ComboProxyImpDelegate* m_pListProxyDelegate; | 194 CFWL_ComboProxyImpDelegate* m_pListProxyDelegate; |
| 195 }; | 195 }; |
| 196 |
| 196 class CFWL_ComboBoxImpDelegate : public CFWL_WidgetImpDelegate { | 197 class CFWL_ComboBoxImpDelegate : public CFWL_WidgetImpDelegate { |
| 197 public: | 198 public: |
| 198 CFWL_ComboBoxImpDelegate(CFWL_ComboBoxImp* pOwner); | 199 CFWL_ComboBoxImpDelegate(IFWL_ComboBox* pOwner); |
| 199 void OnProcessMessage(CFWL_Message* pMessage) override; | 200 void OnProcessMessage(CFWL_Message* pMessage) override; |
| 200 void OnProcessEvent(CFWL_Event* pEvent) override; | 201 void OnProcessEvent(CFWL_Event* pEvent) override; |
| 201 void OnDrawWidget(CFX_Graphics* pGraphics, | 202 void OnDrawWidget(CFX_Graphics* pGraphics, |
| 202 const CFX_Matrix* pMatrix = nullptr) override; | 203 const CFX_Matrix* pMatrix = nullptr) override; |
| 203 | 204 |
| 204 protected: | 205 protected: |
| 205 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); | 206 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); |
| 206 void OnLButtonDown(CFWL_MsgMouse* pMsg); | 207 void OnLButtonDown(CFWL_MsgMouse* pMsg); |
| 207 void OnLButtonUp(CFWL_MsgMouse* pMsg); | 208 void OnLButtonUp(CFWL_MsgMouse* pMsg); |
| 208 void OnMouseMove(CFWL_MsgMouse* pMsg); | 209 void OnMouseMove(CFWL_MsgMouse* pMsg); |
| 209 void OnMouseLeave(CFWL_MsgMouse* pMsg); | 210 void OnMouseLeave(CFWL_MsgMouse* pMsg); |
| 210 void OnKey(CFWL_MsgKey* pMsg); | 211 void OnKey(CFWL_MsgKey* pMsg); |
| 211 void DoSubCtrlKey(CFWL_MsgKey* pMsg); | 212 void DoSubCtrlKey(CFWL_MsgKey* pMsg); |
| 212 | |
| 213 protected: | |
| 214 void DisForm_OnProcessMessage(CFWL_Message* pMessage); | 213 void DisForm_OnProcessMessage(CFWL_Message* pMessage); |
| 215 void DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg); | 214 void DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg); |
| 216 void DisForm_OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); | 215 void DisForm_OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); |
| 217 void DisForm_OnKey(CFWL_MsgKey* pMsg); | 216 void DisForm_OnKey(CFWL_MsgKey* pMsg); |
| 218 | 217 |
| 219 protected: | 218 IFWL_ComboBox* m_pOwner; |
| 220 CFWL_ComboBoxImp* m_pOwner; | |
| 221 friend class CFWL_ComboEditImpDelegate; | 219 friend class CFWL_ComboEditImpDelegate; |
| 222 friend class CFWL_ComboListImpDelegate; | 220 friend class CFWL_ComboListImpDelegate; |
| 223 }; | 221 }; |
| 222 |
| 224 class CFWL_ComboProxyImpDelegate : public CFWL_WidgetImpDelegate { | 223 class CFWL_ComboProxyImpDelegate : public CFWL_WidgetImpDelegate { |
| 225 public: | 224 public: |
| 226 CFWL_ComboProxyImpDelegate(IFWL_Form* pForm, CFWL_ComboBoxImp* pComboBox); | 225 CFWL_ComboProxyImpDelegate(IFWL_Form* pForm, IFWL_ComboBox* pComboBox); |
| 227 void OnProcessMessage(CFWL_Message* pMessage) override; | 226 void OnProcessMessage(CFWL_Message* pMessage) override; |
| 228 void OnDrawWidget(CFX_Graphics* pGraphics, | 227 void OnDrawWidget(CFX_Graphics* pGraphics, |
| 229 const CFX_Matrix* pMatrix = nullptr) override; | 228 const CFX_Matrix* pMatrix = nullptr) override; |
| 230 void Reset() { m_bLButtonUpSelf = FALSE; } | 229 void Reset() { m_bLButtonUpSelf = FALSE; } |
| 231 | 230 |
| 232 protected: | 231 protected: |
| 233 void OnLButtonDown(CFWL_MsgMouse* pMsg); | 232 void OnLButtonDown(CFWL_MsgMouse* pMsg); |
| 234 void OnLButtonUp(CFWL_MsgMouse* pMsg); | 233 void OnLButtonUp(CFWL_MsgMouse* pMsg); |
| 235 void OnMouseMove(CFWL_MsgMouse* pMsg); | 234 void OnMouseMove(CFWL_MsgMouse* pMsg); |
| 236 void OnDeactive(CFWL_MsgDeactivate* pMsg); | 235 void OnDeactive(CFWL_MsgDeactivate* pMsg); |
| 237 void OnFocusChanged(CFWL_MsgKillFocus* pMsg, FX_BOOL bSet); | 236 void OnFocusChanged(CFWL_MsgKillFocus* pMsg, FX_BOOL bSet); |
| 238 FX_BOOL m_bLButtonDown; | 237 FX_BOOL m_bLButtonDown; |
| 239 FX_BOOL m_bLButtonUpSelf; | 238 FX_BOOL m_bLButtonUpSelf; |
| 240 FX_FLOAT m_fStartPos; | 239 FX_FLOAT m_fStartPos; |
| 241 IFWL_Form* m_pForm; | 240 IFWL_Form* m_pForm; |
| 242 CFWL_ComboBoxImp* m_pComboBox; | 241 IFWL_ComboBox* m_pComboBox; |
| 243 }; | 242 }; |
| 244 | 243 |
| 245 #endif // XFA_FWL_BASEWIDGET_FWL_COMBOBOXIMP_H_ | 244 #endif // XFA_FWL_CORE_IFWL_COMBOBOX_H_ |
| OLD | NEW |