Merge to XFA: Use stdint.h types throughout PDFium.
[pdfium.git] / xfa / src / fwl / src / basewidget / include / fwl_datetimepickerimp.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_DATETIMEPICKER_IMP_H\r
8 #define _FWL_DATETIMEPICKER_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_MonthCalendarImp;\r
15 class CFWL_MonthCalendarImpDelegate;\r
16 class CFWL_FormProxyImp;\r
17 class CFWL_DateTimeEdit;\r
18 class CFWL_DateTimeEditDelegate;\r
19 class CFWL_DateTimeCalendar;\r
20 class CFWL_DateTimeCalendarDelegate;\r
21 class CFWL_DateTimePickerImp;\r
22 class CFWL_DateTimePickerImpDelegate;\r
23 class IFWL_DateTimeForm : public IFWL_Form\r
24 {\r
25 public:\r
26     FWL_ERR     Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);\r
27 };\r
28 class IFWL_DateTimeCalender : public IFWL_MonthCalendar\r
29 {\r
30 public:\r
31     FWL_ERR     Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);\r
32 };\r
33 class IFWL_DateTimeEdit : public IFWL_Edit\r
34 {\r
35 public:\r
36     FWL_ERR     Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);\r
37 };\r
38 class CFWL_DateTimeEdit : public CFWL_EditImp\r
39 {\r
40 public:\r
41     CFWL_DateTimeEdit(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter);\r
42     virtual FWL_ERR Initialize();\r
43     virtual FWL_ERR Finalize();\r
44 protected:\r
45     friend class CFWL_DateTimeEditDelegate;\r
46 };\r
47 class CFWL_DateTimeEditDelegate : public CFWL_EditImpDelegate\r
48 {\r
49 public:\r
50     CFWL_DateTimeEditDelegate(CFWL_DateTimeEdit *pOwner);\r
51     virtual int32_t     OnProcessMessage(CFWL_Message *pMessage);\r
52 private:\r
53     int32_t     DisForm_OnProcessMessage(CFWL_Message *pMessage);\r
54 \r
55 protected:\r
56     CFWL_DateTimeEdit   *m_pOwner;\r
57 };\r
58 class CFWL_DateTimeCalendar : public CFWL_MonthCalendarImp\r
59 {\r
60 public:\r
61     CFWL_DateTimeCalendar(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter);\r
62     virtual FWL_ERR Initialize();\r
63     virtual FWL_ERR Finalize();\r
64 protected:\r
65     friend class CFWL_DateTimeCalendarDelegate;\r
66 };\r
67 class CFWL_DateTimeCalendarDelegate : public CFWL_MonthCalendarImpDelegate\r
68 {\r
69 public:\r
70     CFWL_DateTimeCalendarDelegate(CFWL_DateTimeCalendar *pOwner);\r
71     virtual int32_t     OnProcessMessage(CFWL_Message *pMessage);\r
72     void OnLButtonDownEx(CFWL_MsgMouse *pMsg);\r
73     void OnLButtonUpEx(CFWL_MsgMouse *pMsg);\r
74     void OnMouseMoveEx(CFWL_MsgMouse *pMsg);\r
75 private:\r
76     int32_t     DisForm_OnProcessMessage(CFWL_Message *pMessage);\r
77     void                DisForm_OnLButtonUpEx(CFWL_MsgMouse *pMsg);\r
78 protected:\r
79     CFWL_DateTimeCalendar       *m_pOwner;\r
80     FX_BOOL m_bFlag;\r
81 };\r
82 class CFWL_DateTimePickerImp : public CFWL_WidgetImp\r
83 {\r
84 public:\r
85     CFWL_DateTimePickerImp(IFWL_Widget *pOuter = NULL);\r
86     CFWL_DateTimePickerImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);\r
87     virtual ~CFWL_DateTimePickerImp();\r
88     virtual FWL_ERR             GetClassName(CFX_WideString &wsClass) const;\r
89     virtual FX_DWORD    GetClassID() const;\r
90     virtual FWL_ERR             Initialize();\r
91     virtual FWL_ERR             Finalize();\r
92     virtual FWL_ERR             GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);\r
93     virtual     FWL_ERR         Update();\r
94     virtual FX_DWORD    HitTest(FX_FLOAT fx, FX_FLOAT fy);\r
95     virtual FWL_ERR             DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);\r
96     virtual FWL_ERR             SetThemeProvider(IFWL_ThemeProvider *pTP);\r
97     virtual FWL_ERR             GetCurSel(int32_t &iYear, int32_t &iMonth, int32_t &iDay);\r
98     virtual FWL_ERR             SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay);\r
99     virtual FWL_ERR             SetEditText(const CFX_WideString &wsText);\r
100     virtual FWL_ERR             GetEditText(CFX_WideString &wsText, int32_t nStart = 0, int32_t nCount = -1) const;\r
101 public:\r
102     virtual FX_BOOL             CanUndo();\r
103     virtual FX_BOOL             CanRedo();\r
104     virtual FX_BOOL             Undo();\r
105     virtual FX_BOOL             Redo();\r
106     virtual FX_BOOL             CanCopy();\r
107     virtual FX_BOOL             CanCut();\r
108     virtual FX_BOOL             CanSelectAll();\r
109     virtual FX_BOOL             Copy(CFX_WideString &wsCopy);\r
110     virtual FX_BOOL             Cut(CFX_WideString &wsCut);\r
111     virtual FX_BOOL             Paste(const CFX_WideString &wsPaste);\r
112     virtual FX_BOOL             SelectAll();\r
113     virtual FX_BOOL             Delete();\r
114     virtual FX_BOOL             DeSelect();\r
115     virtual FWL_ERR             GetBBox(CFX_RectF &rect);\r
116     virtual FWL_ERR             SetEditLimit(int32_t nLimit);\r
117     virtual FWL_ERR             ModifyEditStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved);\r
118 public:\r
119     IFWL_DateTimeEdit*  GetDataTimeEdit();\r
120 protected:\r
121     void        DrawDropDownButton(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);\r
122     void        FormatDateString(int32_t iYear, int32_t iMonth, int32_t iDay, CFX_WideString &wsText);\r
123     void        ShowMonthCalendar(FX_BOOL bActivate);\r
124     FX_BOOL     IsMonthCalendarShowed();\r
125     void        ReSetEditAlignment();\r
126     void        InitProxyForm();\r
127     void        ProcessSelChanged(int32_t iYear, int32_t iMonth, int32_t iDay);\r
128 private:\r
129     FWL_ERR             DisForm_Initialize();\r
130     void                DisForm_InitDateTimeCalendar();\r
131     void                DisForm_InitDateTimeEdit();\r
132     FX_BOOL             DisForm_IsMonthCalendarShowed();\r
133     void                DisForm_ShowMonthCalendar(FX_BOOL bActivate);\r
134     FX_DWORD    DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy);\r
135     FX_BOOL             DisForm_IsNeedShowButton();\r
136     FWL_ERR             DisForm_Update();\r
137     FWL_ERR             DisForm_GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);\r
138     FWL_ERR             DisForm_GetBBox(CFX_RectF &rect);\r
139     FWL_ERR             DisForm_DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);\r
140 protected:\r
141 \r
142     CFX_RectF                           m_rtBtn;\r
143     CFX_RectF                           m_rtClient;\r
144     int32_t                             m_iBtnState;\r
145     int32_t                             m_iYear;\r
146     int32_t                             m_iMonth;\r
147     int32_t                             m_iDay;\r
148     FX_BOOL                                     m_bLBtnDown;\r
149     IFWL_DateTimeEdit           *m_pEdit;\r
150     IFWL_DateTimeCalender       *m_pMonthCal;\r
151     IFWL_DateTimeForm           *m_pForm;\r
152     FX_FLOAT                            m_fBtn;\r
153     class CFWL_MonthCalendarImpDP : public IFWL_MonthCalendarDP\r
154     {\r
155     public:\r
156         CFWL_MonthCalendarImpDP()\r
157         {\r
158             m_iCurYear = 2010;\r
159             m_iCurMonth = 3;\r
160             m_iCurDay = 29;\r
161         }\r
162         virtual FWL_ERR GetCaption(IFWL_Widget *pWidget, CFX_WideString &wsCaption)\r
163         {\r
164             return FWL_ERR_Succeeded;\r
165         }\r
166         virtual int32_t         GetCurDay(IFWL_Widget *pWidget)\r
167         {\r
168             return m_iCurDay;\r
169         }\r
170         virtual int32_t         GetCurMonth(IFWL_Widget *pWidget)\r
171         {\r
172             return m_iCurMonth;\r
173         }\r
174         virtual int32_t         GetCurYear(IFWL_Widget *pWidget)\r
175         {\r
176             return m_iCurYear;\r
177         }\r
178         int32_t m_iCurDay;\r
179         int32_t m_iCurYear;\r
180         int32_t m_iCurMonth;\r
181     };\r
182 \r
183     CFWL_MonthCalendarImpDP m_MonthCalendarDP;\r
184     friend class CFWL_DateTimeEditDelegate;\r
185     friend class CFWL_DateTimeCalendar;\r
186     friend class CFWL_DateTimeCalendarDelegate;\r
187     friend class CFWL_DateTimePickerImpDelegate;\r
188 };\r
189 class CFWL_DateTimePickerImpDelegate : public CFWL_WidgetImpDelegate\r
190 {\r
191 public:\r
192     CFWL_DateTimePickerImpDelegate(CFWL_DateTimePickerImp *pOwner);\r
193     virtual int32_t     OnProcessMessage(CFWL_Message *pMessage);\r
194     virtual FWL_ERR             OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);\r
195 protected:\r
196     void        OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);\r
197     void        OnLButtonDown(CFWL_MsgMouse *pMsg);\r
198     void        OnLButtonUp(CFWL_MsgMouse *pMsg);\r
199     void        OnMouseMove(CFWL_MsgMouse *pMsg);\r
200     void        OnMouseLeave(CFWL_MsgMouse *pMsg);\r
201 \r
202     CFWL_DateTimePickerImp *m_pOwner;\r
203 private:\r
204     void                DisForm_OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);\r
205 };\r
206 #endif\r