Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fwl / src / basewidget / include / fwl_comboboximp.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _FWL_COMBOBOX_IMP_H\r
8 #define _FWL_COMBOBOX_IMP_H\r
9 class CFWL_WidgetImp;\r
10 class CFWL_WidgetImpProperties;\r
11 class CFWL_WidgetImpDelegate;\r
12 class CFWL_EditImp;\r
13 class CFWL_EditImpDelegate;\r
14 class CFWL_ListBoxImp;\r
15 class CFWL_ListBoxImpDelegate;\r
16 class CFWL_FormProxyImp;\r
17 class IFWL_Widget;\r
18 class CFWL_ComboEdit;\r
19 class CFWL_ComboEditDelegate;\r
20 class CFWL_ComboList;\r
21 class CFWL_ComboListDelegate;\r
22 class CFWL_ComboBoxImp;\r
23 class CFWL_ComboBoxImpDelegate;\r
24 class CFWL_ComboProxyImpDelegate;\r
25 class CFWL_ComboEdit : public CFWL_EditImp\r
26 {\r
27 public:\r
28     CFWL_ComboEdit(IFWL_Widget *pOuter);\r
29     CFWL_ComboEdit(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);\r
30 \r
31     void        ClearSelected();\r
32     void        SetSelected();\r
33     void        EndCaret();\r
34     void        FlagFocus(FX_BOOL bSet);\r
35 protected:\r
36     void        SetComboBoxFocus(FX_BOOL bSet);\r
37     CFWL_ComboBoxImp    *m_pOuter;\r
38     friend class CFWL_ComboEditDelegate;\r
39 };\r
40 class CFWL_ComboEditDelegate : public CFWL_EditImpDelegate\r
41 {\r
42 public:\r
43     CFWL_ComboEditDelegate(CFWL_ComboEdit *pOwner);\r
44     virtual FX_INT32    OnProcessMessage(CFWL_Message *pMessage);\r
45 protected:\r
46     CFWL_ComboEdit *m_pOwner;\r
47 };\r
48 class CFWL_ComboList : public CFWL_ListBoxImp\r
49 {\r
50 public:\r
51     CFWL_ComboList(IFWL_Widget *pOuter);\r
52     CFWL_ComboList(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter);\r
53     virtual FWL_ERR Initialize();\r
54     virtual FWL_ERR Finalize();\r
55     FX_INT32    MatchItem(const CFX_WideString &wsMatch);\r
56     void                ChangeSelected(FX_INT32 iSel);\r
57     FX_INT32    CountItems();\r
58     void                GetItemRect(FX_INT32 nIndex, CFX_RectF &rtItem);\r
59     void                ClientToOuter(FX_FLOAT &fx, FX_FLOAT &fy);\r
60     void                SetFocus(FX_BOOL bSet);\r
61     FX_BOOL             m_bNotifyOwner;\r
62     friend class CFWL_ComboListDelegate;\r
63     friend class CFWL_ComboBoxImp;\r
64 };\r
65 class CFWL_ComboListDelegate : public CFWL_ListBoxImpDelegate\r
66 {\r
67 public:\r
68     CFWL_ComboListDelegate(CFWL_ComboList *pOwner);\r
69     virtual FX_INT32    OnProcessMessage(CFWL_Message *pMessage);\r
70 protected:\r
71     void                OnDropListFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);\r
72     FX_INT32    OnDropListMouseMove(CFWL_MsgMouse *pMsg);\r
73     FX_INT32    OnDropListLButtonDown(CFWL_MsgMouse *pMsg);\r
74     FX_INT32    OnDropListLButtonUp(CFWL_MsgMouse *pMsg);\r
75     FX_INT32    OnDropListKey(CFWL_MsgKey *pKey);\r
76     void                OnDropListKeyDown(CFWL_MsgKey *pKey);\r
77     CFWL_ComboList *m_pOwner;\r
78 };\r
79 class CFWL_ComboBoxImp : public CFWL_WidgetImp\r
80 {\r
81 public:\r
82     CFWL_ComboBoxImp(IFWL_Widget *pOuter = NULL);\r
83     CFWL_ComboBoxImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);\r
84     virtual ~CFWL_ComboBoxImp();\r
85     virtual FWL_ERR             GetClassName(CFX_WideString &wsClass) const;\r
86     virtual FX_DWORD    GetClassID() const;\r
87     virtual FWL_ERR             Initialize();\r
88     virtual FWL_ERR             Finalize();\r
89     virtual FWL_ERR             GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);\r
90     virtual FWL_ERR             ModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved);\r
91     virtual FWL_ERR             SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE);\r
92     virtual     FWL_ERR         Update();\r
93     virtual FX_DWORD    HitTest(FX_FLOAT fx, FX_FLOAT fy);\r
94     virtual FWL_ERR             DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);\r
95     virtual FWL_ERR             SetThemeProvider(IFWL_ThemeProvider *pThemeProvider);\r
96     virtual FX_INT32    GetCurSel();\r
97     virtual FWL_ERR             SetCurSel(FX_INT32 iSel);\r
98     virtual FWL_ERR             SetEditText(const CFX_WideString &wsText);\r
99     virtual FX_INT32    GetEditTextLength() const;\r
100     virtual FWL_ERR             GetEditText(CFX_WideString &wsText, FX_INT32 nStart = 0, FX_INT32 nCount = -1) const;\r
101     virtual FWL_ERR             SetEditSelRange(FX_INT32 nStart, FX_INT32 nCount = -1);\r
102     virtual FX_INT32    GetEditSelRange(FX_INT32 nIndex, FX_INT32 &nStart);\r
103     virtual FX_INT32    GetEditLimit();\r
104     virtual FWL_ERR             SetEditLimit(FX_INT32 nLimit);\r
105     virtual FWL_ERR             EditDoClipboard(FX_INT32 iCmd);\r
106     virtual FX_BOOL             EditRedo(FX_BSTR bsRecord);\r
107     virtual FX_BOOL             EditUndo(FX_BSTR bsRecord);\r
108     virtual IFWL_ListBox*  GetListBoxt();\r
109     virtual FX_BOOL AfterFocusShowDropList();\r
110     virtual FX_ERR      OpenDropDownList(FX_BOOL bActivate);\r
111     virtual FX_BOOL             EditCanUndo();\r
112     virtual FX_BOOL             EditCanRedo();\r
113     virtual FX_BOOL             EditUndo();\r
114     virtual FX_BOOL             EditRedo();\r
115     virtual FX_BOOL             EditCanCopy();\r
116     virtual FX_BOOL             EditCanCut();\r
117     virtual FX_BOOL             EditCanSelectAll();\r
118     virtual FX_BOOL             EditCopy(CFX_WideString &wsCopy);\r
119     virtual FX_BOOL             EditCut(CFX_WideString &wsCut);\r
120     virtual FX_BOOL             EditPaste(const CFX_WideString &wsPaste);\r
121     virtual FX_BOOL             EditSelectAll();\r
122     virtual FX_BOOL             EditDelete();\r
123     virtual FX_BOOL             EditDeSelect();\r
124     virtual FWL_ERR             GetBBox(CFX_RectF &rect);\r
125     virtual FWL_ERR             EditModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved);\r
126 protected:\r
127     void                DrawStretchHandler(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix);\r
128     FX_FLOAT    GetListHeight();\r
129     void                ShowDropList(FX_BOOL bActivate);\r
130     FX_BOOL             IsDropListShowed();\r
131     FX_BOOL             IsDropDownStyle() const;\r
132     void                MatchEditText();\r
133     void                SynchrEditText(FX_INT32 iListItem);\r
134     void                Layout();\r
135     void                ReSetTheme();\r
136     void                ReSetEditAlignment();\r
137     void                ReSetListItemAlignment();\r
138     void                ProcessSelChanged(FX_BOOL bLButtonUp);\r
139     void                InitProxyForm();\r
140 protected:\r
141     FWL_ERR             DisForm_Initialize();\r
142     void                DisForm_InitComboList();\r
143     void                DisForm_InitComboEdit();\r
144     void                DisForm_ShowDropList(FX_BOOL bActivate);\r
145     FX_BOOL             DisForm_IsDropListShowed();\r
146     FWL_ERR             DisForm_ModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved);\r
147     FWL_ERR             DisForm_Update();\r
148     FX_DWORD    DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy);\r
149     FWL_ERR             DisForm_DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);\r
150     FWL_ERR             DisForm_GetBBox(CFX_RectF &rect);\r
151     void                DisForm_Layout();\r
152 protected:\r
153     CFX_RectF           m_rtClient;\r
154     CFX_RectF           m_rtContent;\r
155     CFX_RectF           m_rtBtn;\r
156     CFX_RectF           m_rtList;\r
157     CFX_RectF           m_rtProxy;\r
158     CFX_RectF           m_rtHandler;\r
159     IFWL_Edit           *m_pEdit;\r
160     IFWL_ListBox        *m_pListBox;\r
161     IFWL_Form           *m_pForm;\r
162     FX_BOOL                     m_bLButtonDown;\r
163     FX_BOOL                     m_bUpFormHandler;\r
164     FX_INT32            m_iCurSel;\r
165     FX_INT32            m_iBtnState;\r
166     FX_FLOAT        m_fComboFormHandler;\r
167     FX_FLOAT        m_fItemHeight;\r
168     FX_BOOL                     m_bNeedShowList;\r
169     CFWL_FormProxyImp *m_pProxy;\r
170     CFWL_ComboProxyImpDelegate *m_pListProxyDelegate;\r
171 \r
172     friend class CFWL_ComboList;\r
173     friend class CFWL_ComboEdit;\r
174     friend class CFWL_ComboEditDelegate;\r
175     friend class CFWL_ComboListDelegate;\r
176     friend class CFWL_ComboBoxImpDelegate;\r
177     friend class CFWL_ComboProxyImpDelegate;\r
178 };\r
179 class CFWL_ComboBoxImpDelegate : public CFWL_WidgetImpDelegate\r
180 {\r
181 public:\r
182     CFWL_ComboBoxImpDelegate(CFWL_ComboBoxImp *pOwner);\r
183     virtual FX_INT32    OnProcessMessage(CFWL_Message *pMessage);\r
184     virtual FWL_ERR             OnProcessEvent(CFWL_Event *pEvent);\r
185     virtual FWL_ERR             OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);\r
186 \r
187 protected:\r
188     void        OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);\r
189     void        OnLButtonDown(CFWL_MsgMouse *pMsg);\r
190     void        OnLButtonUp(CFWL_MsgMouse *pMsg);\r
191     void        OnMouseMove(CFWL_MsgMouse *pMsg);\r
192     void        OnMouseLeave(CFWL_MsgMouse *pMsg);\r
193     void        OnKey(CFWL_MsgKey *pMsg);\r
194     void        DoSubCtrlKey(CFWL_MsgKey *pMsg);\r
195 protected:\r
196     FX_INT32    DisForm_OnProcessMessage(CFWL_Message *pMessage);\r
197     void                DisForm_OnLButtonDown(CFWL_MsgMouse *pMsg);\r
198     void                DisForm_OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);\r
199     void                DisForm_OnKey(CFWL_MsgKey *pMsg);\r
200 protected:\r
201     CFWL_ComboBoxImp *m_pOwner;\r
202     friend class CFWL_ComboEditDelegate;\r
203     friend class CFWL_ComboListDelegate;\r
204 };\r
205 class CFWL_ComboProxyImpDelegate : public CFWL_WidgetImpDelegate\r
206 {\r
207 public:\r
208     CFWL_ComboProxyImpDelegate(IFWL_Form *pForm, CFWL_ComboBoxImp *pComboBox);\r
209     virtual FX_INT32    OnProcessMessage(CFWL_Message *pMessage);\r
210     virtual FWL_ERR             OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);\r
211     void        Reset()\r
212     {\r
213         m_bLButtonUpSelf = FALSE;\r
214     }\r
215 protected:\r
216     void        OnLButtonDown(CFWL_MsgMouse *pMsg);\r
217     void        OnLButtonUp(CFWL_MsgMouse *pMsg);\r
218     void        OnMouseMove(CFWL_MsgMouse *pMsg);\r
219     void    OnDeactive(CFWL_MsgDeactivate *pMsg);\r
220     void        OnFocusChanged(CFWL_MsgKillFocus *pMsg, FX_BOOL bSet );\r
221     FX_BOOL                     m_bLButtonDown;\r
222     FX_BOOL                     m_bLButtonUpSelf;\r
223     FX_FLOAT            m_fStartPos;\r
224     IFWL_Form                   *m_pForm;\r
225     CFWL_ComboBoxImp    *m_pComboBox;\r
226 };\r
227 #endif\r