summaryrefslogtreecommitdiff
path: root/xfa/fwl/basewidget/fwl_comboboximp.h
blob: 6fa097a4c0a1e3d4b19c9a321f35e04780b3ad94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef XFA_FWL_BASEWIDGET_FWL_COMBOBOXIMP_H_
#define XFA_FWL_BASEWIDGET_FWL_COMBOBOXIMP_H_

#include <memory>

#include "xfa/fwl/basewidget/fwl_editimp.h"
#include "xfa/fwl/basewidget/fwl_listboximp.h"

class CFWL_WidgetImp;
class CFWL_WidgetImpProperties;
class CFWL_WidgetImpDelegate;
class CFWL_ListBoxImp;
class CFWL_ListBoxImpDelegate;
class CFWL_FormProxyImp;
class IFWL_Widget;
class CFWL_ComboEditImp;
class CFWL_ComboEditImpDelegate;
class CFWL_ComboListImp;
class CFWL_ComboListImpDelegate;
class CFWL_ComboBoxImp;
class CFWL_ComboBoxImpDelegate;
class CFWL_ComboProxyImpDelegate;
class CFWL_ComboEditImp : public CFWL_EditImp {
 public:
  CFWL_ComboEditImp(const CFWL_WidgetImpProperties& properties,
                    IFWL_Widget* pOuter);

  void ClearSelected();
  void SetSelected();
  void EndCaret();
  void FlagFocus(FX_BOOL bSet);

 protected:
  void SetComboBoxFocus(FX_BOOL bSet);
  CFWL_ComboBoxImp* m_pOuter;
  friend class CFWL_ComboEditImpDelegate;
};
class CFWL_ComboEditImpDelegate : public CFWL_EditImpDelegate {
 public:
  CFWL_ComboEditImpDelegate(CFWL_ComboEditImp* pOwner);
  void OnProcessMessage(CFWL_Message* pMessage) override;

 protected:
  CFWL_ComboEditImp* m_pOwner;
};
class CFWL_ComboListImp : public CFWL_ListBoxImp {
 public:
  CFWL_ComboListImp(const CFWL_WidgetImpProperties& properties,
                    IFWL_Widget* pOuter);
  virtual FWL_Error Initialize();
  virtual FWL_Error Finalize();
  int32_t MatchItem(const CFX_WideString& wsMatch);
  void ChangeSelected(int32_t iSel);
  int32_t CountItems();
  void GetItemRect(int32_t nIndex, CFX_RectF& rtItem);
  void ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy);
  void SetFocus(FX_BOOL bSet);
  FX_BOOL m_bNotifyOwner;
  friend class CFWL_ComboListImpDelegate;
  friend class CFWL_ComboBoxImp;
};
class CFWL_ComboListImpDelegate : public CFWL_ListBoxImpDelegate {
 public:
  CFWL_ComboListImpDelegate(CFWL_ComboListImp* pOwner);
  void OnProcessMessage(CFWL_Message* pMessage) override;

 protected:
  void OnDropListFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
  int32_t OnDropListMouseMove(CFWL_MsgMouse* pMsg);
  int32_t OnDropListLButtonDown(CFWL_MsgMouse* pMsg);
  int32_t OnDropListLButtonUp(CFWL_MsgMouse* pMsg);
  int32_t OnDropListKey(CFWL_MsgKey* pKey);
  void OnDropListKeyDown(CFWL_MsgKey* pKey);
  CFWL_ComboListImp* m_pOwner;
};
class CFWL_ComboBoxImp : public CFWL_WidgetImp {
 public:
  CFWL_ComboBoxImp(const CFWL_WidgetImpProperties& properties,
                   IFWL_Widget* pOuter);
  virtual ~CFWL_ComboBoxImp();
  virtual FWL_Error GetClassName(CFX_WideString& wsClass) const;
  virtual uint32_t GetClassID() const;
  virtual FWL_Error Initialize();
  virtual FWL_Error Finalize();
  virtual FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
  virtual FWL_Error ModifyStylesEx(uint32_t dwStylesExAdded,
                                   uint32_t dwStylesExRemoved);
  virtual void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE);
  virtual FWL_Error Update();
  virtual FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy);
  virtual FWL_Error DrawWidget(CFX_Graphics* pGraphics,
                               const CFX_Matrix* pMatrix = NULL);
  virtual FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
  virtual int32_t GetCurSel();
  virtual FWL_Error SetCurSel(int32_t iSel);
  virtual FWL_Error SetEditText(const CFX_WideString& wsText);
  virtual int32_t GetEditTextLength() const;
  virtual FWL_Error GetEditText(CFX_WideString& wsText,
                                int32_t nStart = 0,
                                int32_t nCount = -1) const;
  virtual FWL_Error SetEditSelRange(int32_t nStart, int32_t nCount = -1);
  virtual int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart);
  virtual int32_t GetEditLimit();
  virtual FWL_Error SetEditLimit(int32_t nLimit);
  virtual FWL_Error EditDoClipboard(int32_t iCmd);
  virtual FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord);
  virtual FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord);
  virtual IFWL_ListBox* GetListBoxt();
  virtual FX_BOOL AfterFocusShowDropList();
  virtual FWL_Error OpenDropDownList(FX_BOOL bActivate);
  virtual FX_BOOL EditCanUndo();
  virtual FX_BOOL EditCanRedo();
  virtual FX_BOOL EditUndo();
  virtual FX_BOOL EditRedo();
  virtual FX_BOOL EditCanCopy();
  virtual FX_BOOL EditCanCut();
  virtual FX_BOOL EditCanSelectAll();
  virtual FX_BOOL EditCopy(CFX_WideString& wsCopy);
  virtual FX_BOOL EditCut(CFX_WideString& wsCut);
  virtual FX_BOOL EditPaste(const CFX_WideString& wsPaste);
  virtual FX_BOOL EditSelectAll();
  virtual FX_BOOL EditDelete();
  virtual FX_BOOL EditDeSelect();
  virtual FWL_Error GetBBox(CFX_RectF& rect);
  virtual FWL_Error EditModifyStylesEx(uint32_t dwStylesExAdded,
                                       uint32_t dwStylesExRemoved);

 protected:
  void DrawStretchHandler(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix);
  FX_FLOAT GetListHeight();
  void ShowDropList(FX_BOOL bActivate);
  FX_BOOL IsDropListShowed();
  FX_BOOL IsDropDownStyle() const;
  void MatchEditText();
  void SynchrEditText(int32_t iListItem);
  void Layout();
  void ReSetTheme();
  void ReSetEditAlignment();
  void ReSetListItemAlignment();
  void ProcessSelChanged(FX_BOOL bLButtonUp);
  void InitProxyForm();
  FWL_Error DisForm_Initialize();
  void DisForm_InitComboList();
  void DisForm_InitComboEdit();
  void DisForm_ShowDropList(FX_BOOL bActivate);
  FX_BOOL DisForm_IsDropListShowed();
  FWL_Error DisForm_ModifyStylesEx(uint32_t dwStylesExAdded,
                                   uint32_t dwStylesExRemoved);
  FWL_Error DisForm_Update();
  FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy);
  FWL_Error DisForm_DrawWidget(CFX_Graphics* pGraphics,
                               const CFX_Matrix* pMatrix = NULL);
  FWL_Error DisForm_GetBBox(CFX_RectF& rect);
  void DisForm_Layout();

  CFX_RectF m_rtClient;
  CFX_RectF m_rtContent;
  CFX_RectF m_rtBtn;
  CFX_RectF m_rtList;
  CFX_RectF m_rtProxy;
  CFX_RectF m_rtHandler;
  std::unique_ptr<IFWL_Edit> m_pEdit;
  std::unique_ptr<IFWL_ListBox> m_pListBox;
  IFWL_Form* m_pForm;
  FX_BOOL m_bLButtonDown;
  FX_BOOL m_bUpFormHandler;
  int32_t m_iCurSel;
  int32_t m_iBtnState;
  FX_FLOAT m_fComboFormHandler;
  FX_FLOAT m_fItemHeight;
  FX_BOOL m_bNeedShowList;
  CFWL_FormProxyImp* m_pProxy;
  CFWL_ComboProxyImpDelegate* m_pListProxyDelegate;

  friend class CFWL_ComboListImp;
  friend class CFWL_ComboEditImp;
  friend class CFWL_ComboEditImpDelegate;
  friend class CFWL_ComboListImpDelegate;
  friend class CFWL_ComboBoxImpDelegate;
  friend class CFWL_ComboProxyImpDelegate;
};
class CFWL_ComboBoxImpDelegate : public CFWL_WidgetImpDelegate {
 public:
  CFWL_ComboBoxImpDelegate(CFWL_ComboBoxImp* pOwner);
  void OnProcessMessage(CFWL_Message* pMessage) override;
  void OnProcessEvent(CFWL_Event* pEvent) override;
  void OnDrawWidget(CFX_Graphics* pGraphics,
                    const CFX_Matrix* pMatrix = NULL) override;

 protected:
  void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
  void OnLButtonDown(CFWL_MsgMouse* pMsg);
  void OnLButtonUp(CFWL_MsgMouse* pMsg);
  void OnMouseMove(CFWL_MsgMouse* pMsg);
  void OnMouseLeave(CFWL_MsgMouse* pMsg);
  void OnKey(CFWL_MsgKey* pMsg);
  void DoSubCtrlKey(CFWL_MsgKey* pMsg);

 protected:
  void DisForm_OnProcessMessage(CFWL_Message* pMessage);
  void DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg);
  void DisForm_OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
  void DisForm_OnKey(CFWL_MsgKey* pMsg);

 protected:
  CFWL_ComboBoxImp* m_pOwner;
  friend class CFWL_ComboEditImpDelegate;
  friend class CFWL_ComboListImpDelegate;
};
class CFWL_ComboProxyImpDelegate : public CFWL_WidgetImpDelegate {
 public:
  CFWL_ComboProxyImpDelegate(IFWL_Form* pForm, CFWL_ComboBoxImp* pComboBox);
  void OnProcessMessage(CFWL_Message* pMessage) override;
  void OnDrawWidget(CFX_Graphics* pGraphics,
                    const CFX_Matrix* pMatrix = NULL) override;
  void Reset() { m_bLButtonUpSelf = FALSE; }

 protected:
  void OnLButtonDown(CFWL_MsgMouse* pMsg);
  void OnLButtonUp(CFWL_MsgMouse* pMsg);
  void OnMouseMove(CFWL_MsgMouse* pMsg);
  void OnDeactive(CFWL_MsgDeactivate* pMsg);
  void OnFocusChanged(CFWL_MsgKillFocus* pMsg, FX_BOOL bSet);
  FX_BOOL m_bLButtonDown;
  FX_BOOL m_bLButtonUpSelf;
  FX_FLOAT m_fStartPos;
  IFWL_Form* m_pForm;
  CFWL_ComboBoxImp* m_pComboBox;
};

#endif  // XFA_FWL_BASEWIDGET_FWL_COMBOBOXIMP_H_