| OLD | NEW |
| (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 XFA_FWL_BASEWIDGET_FWL_COMBOBOXIMP_H_ | |
| 8 #define XFA_FWL_BASEWIDGET_FWL_COMBOBOXIMP_H_ | |
| 9 | |
| 10 #include <memory> | |
| 11 | |
| 12 #include "xfa/fwl/basewidget/fwl_editimp.h" | |
| 13 #include "xfa/fwl/basewidget/fwl_listboximp.h" | |
| 14 | |
| 15 class CFWL_WidgetImp; | |
| 16 class CFWL_WidgetImpProperties; | |
| 17 class CFWL_WidgetImpDelegate; | |
| 18 class CFWL_ListBoxImp; | |
| 19 class CFWL_ListBoxImpDelegate; | |
| 20 class CFWL_FormProxyImp; | |
| 21 class IFWL_Widget; | |
| 22 class CFWL_ComboEditImp; | |
| 23 class CFWL_ComboEditImpDelegate; | |
| 24 class CFWL_ComboListImp; | |
| 25 class CFWL_ComboListImpDelegate; | |
| 26 class CFWL_ComboBoxImp; | |
| 27 class CFWL_ComboBoxImpDelegate; | |
| 28 class CFWL_ComboProxyImpDelegate; | |
| 29 class CFWL_ComboEditImp : public CFWL_EditImp { | |
| 30 public: | |
| 31 CFWL_ComboEditImp(const CFWL_WidgetImpProperties& properties, | |
| 32 IFWL_Widget* pOuter); | |
| 33 | |
| 34 void ClearSelected(); | |
| 35 void SetSelected(); | |
| 36 void EndCaret(); | |
| 37 void FlagFocus(FX_BOOL bSet); | |
| 38 | |
| 39 protected: | |
| 40 void SetComboBoxFocus(FX_BOOL bSet); | |
| 41 CFWL_ComboBoxImp* m_pOuter; | |
| 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 | |
| 49 protected: | |
| 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_Type GetClassID() const override; | |
| 96 FWL_Error Initialize() override; | |
| 97 FWL_Error Finalize() override; | |
| 98 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override; | |
| 99 FWL_Error ModifyStylesEx(uint32_t dwStylesExAdded, | |
| 100 uint32_t dwStylesExRemoved) override; | |
| 101 void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE) override; | |
| 102 FWL_Error Update() override; | |
| 103 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; | |
| 104 FWL_Error DrawWidget(CFX_Graphics* pGraphics, | |
| 105 const CFX_Matrix* pMatrix = nullptr) override; | |
| 106 FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override; | |
| 107 | |
| 108 int32_t GetCurSel(); | |
| 109 FWL_Error SetCurSel(int32_t iSel); | |
| 110 FWL_Error SetEditText(const CFX_WideString& wsText); | |
| 111 int32_t GetEditTextLength() const; | |
| 112 FWL_Error GetEditText(CFX_WideString& wsText, | |
| 113 int32_t nStart = 0, | |
| 114 int32_t nCount = -1) const; | |
| 115 FWL_Error SetEditSelRange(int32_t nStart, int32_t nCount = -1); | |
| 116 int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart); | |
| 117 int32_t GetEditLimit(); | |
| 118 FWL_Error SetEditLimit(int32_t nLimit); | |
| 119 FWL_Error EditDoClipboard(int32_t iCmd); | |
| 120 FX_BOOL EditRedo(const IFDE_TxtEdtDoRecord* pRecord); | |
| 121 FX_BOOL EditUndo(const IFDE_TxtEdtDoRecord* pRecord); | |
| 122 IFWL_ListBox* GetListBoxt(); | |
| 123 FX_BOOL AfterFocusShowDropList(); | |
| 124 FWL_Error OpenDropDownList(FX_BOOL bActivate); | |
| 125 FX_BOOL EditCanUndo(); | |
| 126 FX_BOOL EditCanRedo(); | |
| 127 FX_BOOL EditUndo(); | |
| 128 FX_BOOL EditRedo(); | |
| 129 FX_BOOL EditCanCopy(); | |
| 130 FX_BOOL EditCanCut(); | |
| 131 FX_BOOL EditCanSelectAll(); | |
| 132 FX_BOOL EditCopy(CFX_WideString& wsCopy); | |
| 133 FX_BOOL EditCut(CFX_WideString& wsCut); | |
| 134 FX_BOOL EditPaste(const CFX_WideString& wsPaste); | |
| 135 FX_BOOL EditSelectAll(); | |
| 136 FX_BOOL EditDelete(); | |
| 137 FX_BOOL EditDeSelect(); | |
| 138 FWL_Error GetBBox(CFX_RectF& rect); | |
| 139 FWL_Error EditModifyStylesEx(uint32_t dwStylesExAdded, | |
| 140 uint32_t dwStylesExRemoved); | |
| 141 | |
| 142 protected: | |
| 143 friend class CFWL_ComboListImp; | |
| 144 friend class CFWL_ComboEditImp; | |
| 145 friend class CFWL_ComboEditImpDelegate; | |
| 146 friend class CFWL_ComboListImpDelegate; | |
| 147 friend class CFWL_ComboBoxImpDelegate; | |
| 148 friend class CFWL_ComboProxyImpDelegate; | |
| 149 | |
| 150 void DrawStretchHandler(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix); | |
| 151 FX_FLOAT GetListHeight(); | |
| 152 void ShowDropList(FX_BOOL bActivate); | |
| 153 FX_BOOL IsDropListShowed(); | |
| 154 FX_BOOL IsDropDownStyle() const; | |
| 155 void MatchEditText(); | |
| 156 void SynchrEditText(int32_t iListItem); | |
| 157 void Layout(); | |
| 158 void ReSetTheme(); | |
| 159 void ReSetEditAlignment(); | |
| 160 void ReSetListItemAlignment(); | |
| 161 void ProcessSelChanged(FX_BOOL bLButtonUp); | |
| 162 void InitProxyForm(); | |
| 163 FWL_Error DisForm_Initialize(); | |
| 164 void DisForm_InitComboList(); | |
| 165 void DisForm_InitComboEdit(); | |
| 166 void DisForm_ShowDropList(FX_BOOL bActivate); | |
| 167 FX_BOOL DisForm_IsDropListShowed(); | |
| 168 FWL_Error DisForm_ModifyStylesEx(uint32_t dwStylesExAdded, | |
| 169 uint32_t dwStylesExRemoved); | |
| 170 FWL_Error DisForm_Update(); | |
| 171 FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy); | |
| 172 FWL_Error DisForm_DrawWidget(CFX_Graphics* pGraphics, | |
| 173 const CFX_Matrix* pMatrix = nullptr); | |
| 174 FWL_Error DisForm_GetBBox(CFX_RectF& rect); | |
| 175 void DisForm_Layout(); | |
| 176 | |
| 177 CFX_RectF m_rtClient; | |
| 178 CFX_RectF m_rtContent; | |
| 179 CFX_RectF m_rtBtn; | |
| 180 CFX_RectF m_rtList; | |
| 181 CFX_RectF m_rtProxy; | |
| 182 CFX_RectF m_rtHandler; | |
| 183 std::unique_ptr<IFWL_Edit> m_pEdit; | |
| 184 std::unique_ptr<IFWL_ListBox> m_pListBox; | |
| 185 IFWL_Form* m_pForm; | |
| 186 FX_BOOL m_bLButtonDown; | |
| 187 FX_BOOL m_bUpFormHandler; | |
| 188 int32_t m_iCurSel; | |
| 189 int32_t m_iBtnState; | |
| 190 FX_FLOAT m_fComboFormHandler; | |
| 191 FX_FLOAT m_fItemHeight; | |
| 192 FX_BOOL m_bNeedShowList; | |
| 193 CFWL_FormProxyImp* m_pProxy; | |
| 194 CFWL_ComboProxyImpDelegate* m_pListProxyDelegate; | |
| 195 }; | |
| 196 class CFWL_ComboBoxImpDelegate : public CFWL_WidgetImpDelegate { | |
| 197 public: | |
| 198 CFWL_ComboBoxImpDelegate(CFWL_ComboBoxImp* pOwner); | |
| 199 void OnProcessMessage(CFWL_Message* pMessage) override; | |
| 200 void OnProcessEvent(CFWL_Event* pEvent) override; | |
| 201 void OnDrawWidget(CFX_Graphics* pGraphics, | |
| 202 const CFX_Matrix* pMatrix = nullptr) override; | |
| 203 | |
| 204 protected: | |
| 205 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); | |
| 206 void OnLButtonDown(CFWL_MsgMouse* pMsg); | |
| 207 void OnLButtonUp(CFWL_MsgMouse* pMsg); | |
| 208 void OnMouseMove(CFWL_MsgMouse* pMsg); | |
| 209 void OnMouseLeave(CFWL_MsgMouse* pMsg); | |
| 210 void OnKey(CFWL_MsgKey* pMsg); | |
| 211 void DoSubCtrlKey(CFWL_MsgKey* pMsg); | |
| 212 | |
| 213 protected: | |
| 214 void DisForm_OnProcessMessage(CFWL_Message* pMessage); | |
| 215 void DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg); | |
| 216 void DisForm_OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); | |
| 217 void DisForm_OnKey(CFWL_MsgKey* pMsg); | |
| 218 | |
| 219 protected: | |
| 220 CFWL_ComboBoxImp* m_pOwner; | |
| 221 friend class CFWL_ComboEditImpDelegate; | |
| 222 friend class CFWL_ComboListImpDelegate; | |
| 223 }; | |
| 224 class CFWL_ComboProxyImpDelegate : public CFWL_WidgetImpDelegate { | |
| 225 public: | |
| 226 CFWL_ComboProxyImpDelegate(IFWL_Form* pForm, CFWL_ComboBoxImp* pComboBox); | |
| 227 void OnProcessMessage(CFWL_Message* pMessage) override; | |
| 228 void OnDrawWidget(CFX_Graphics* pGraphics, | |
| 229 const CFX_Matrix* pMatrix = nullptr) override; | |
| 230 void Reset() { m_bLButtonUpSelf = FALSE; } | |
| 231 | |
| 232 protected: | |
| 233 void OnLButtonDown(CFWL_MsgMouse* pMsg); | |
| 234 void OnLButtonUp(CFWL_MsgMouse* pMsg); | |
| 235 void OnMouseMove(CFWL_MsgMouse* pMsg); | |
| 236 void OnDeactive(CFWL_MsgDeactivate* pMsg); | |
| 237 void OnFocusChanged(CFWL_MsgKillFocus* pMsg, FX_BOOL bSet); | |
| 238 FX_BOOL m_bLButtonDown; | |
| 239 FX_BOOL m_bLButtonUpSelf; | |
| 240 FX_FLOAT m_fStartPos; | |
| 241 IFWL_Form* m_pForm; | |
| 242 CFWL_ComboBoxImp* m_pComboBox; | |
| 243 }; | |
| 244 | |
| 245 #endif // XFA_FWL_BASEWIDGET_FWL_COMBOBOXIMP_H_ | |
| OLD | NEW |