Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: xfa/fwl/core/ifwl_datetimepicker.cpp

Issue 2432423002: Merge the CFWL_*Imp classes into the IFWL_* classes. (Closed)
Patch Set: Review feedback Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fwl/core/ifwl_datetimepicker.h ('k') | xfa/fwl/core/ifwl_edit.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "xfa/fwl/basewidget/fwl_datetimepickerimp.h" 7 #include "xfa/fwl/core/ifwl_datetimepicker.h"
8 8
9 #include "xfa/fwl/basewidget/fwl_editimp.h"
10 #include "xfa/fwl/basewidget/fwl_formproxyimp.h"
11 #include "xfa/fwl/basewidget/fwl_monthcalendarimp.h"
12 #include "xfa/fwl/basewidget/ifwl_spinbutton.h"
13 #include "xfa/fwl/core/cfwl_message.h" 9 #include "xfa/fwl/core/cfwl_message.h"
14 #include "xfa/fwl/core/cfwl_themebackground.h" 10 #include "xfa/fwl/core/cfwl_themebackground.h"
15 #include "xfa/fwl/core/cfwl_widgetmgr.h" 11 #include "xfa/fwl/core/cfwl_widgetmgr.h"
16 #include "xfa/fwl/core/fwl_formimp.h"
17 #include "xfa/fwl/core/fwl_noteimp.h" 12 #include "xfa/fwl/core/fwl_noteimp.h"
18 #include "xfa/fwl/core/fwl_widgetimp.h" 13 #include "xfa/fwl/core/ifwl_datetimecalendar.h"
14 #include "xfa/fwl/core/ifwl_datetimeedit.h"
15 #include "xfa/fwl/core/ifwl_formproxy.h"
16 #include "xfa/fwl/core/ifwl_spinbutton.h"
19 #include "xfa/fwl/core/ifwl_themeprovider.h" 17 #include "xfa/fwl/core/ifwl_themeprovider.h"
20 18
21 namespace { 19 namespace {
22 20
23 const int kDateTimePickerWidth = 100; 21 const int kDateTimePickerWidth = 100;
24 const int kDateTimePickerHeight = 20; 22 const int kDateTimePickerHeight = 20;
25 23
26 } // namespace 24 } // namespace
27 25
28 // static 26 // static
29 IFWL_DateTimePicker* IFWL_DateTimePicker::Create( 27 IFWL_DateTimePicker* IFWL_DateTimePicker::Create(
30 const CFWL_WidgetImpProperties& properties, 28 const CFWL_WidgetImpProperties& properties,
31 IFWL_Widget* pOuter) { 29 IFWL_Widget* pOuter) {
32 IFWL_DateTimePicker* pDateTimePicker = new IFWL_DateTimePicker; 30 return new IFWL_DateTimePicker(properties, pOuter);
33 CFWL_DateTimePickerImp* pDateTimePickerImpl =
34 new CFWL_DateTimePickerImp(properties, pOuter);
35 pDateTimePicker->SetImpl(pDateTimePickerImpl);
36 pDateTimePickerImpl->SetInterface(pDateTimePicker);
37 return pDateTimePicker;
38 } 31 }
39 32
40 // Static 33 IFWL_DateTimePicker::IFWL_DateTimePicker(
41 IFWL_DateTimeForm* IFWL_DateTimeForm::Create(
42 const CFWL_WidgetImpProperties& properties,
43 IFWL_Widget* pOuter) {
44 IFWL_DateTimeForm* pDateTimeForm = new IFWL_DateTimeForm;
45 CFWL_FormProxyImp* pFormProxyImpl = new CFWL_FormProxyImp(properties, pOuter);
46 pDateTimeForm->SetImpl(pFormProxyImpl);
47 pFormProxyImpl->SetInterface(pDateTimeForm);
48 return pDateTimeForm;
49 }
50
51 // static
52 IFWL_DateTimeCalender* IFWL_DateTimeCalender::Create(
53 const CFWL_WidgetImpProperties& properties,
54 IFWL_Widget* pOuter) {
55 IFWL_DateTimeCalender* pDateTimeCalendar = new IFWL_DateTimeCalender;
56 CFWL_DateTimeCalendar* pDateTimeCalendarImpl =
57 new CFWL_DateTimeCalendar(properties, pOuter);
58 pDateTimeCalendar->SetImpl(pDateTimeCalendarImpl);
59 pDateTimeCalendarImpl->SetInterface(pDateTimeCalendar);
60 return pDateTimeCalendar;
61 }
62
63 // static
64 IFWL_DateTimeEdit* IFWL_DateTimeEdit::Create(
65 const CFWL_WidgetImpProperties& properties,
66 IFWL_Widget* pOuter) {
67 IFWL_DateTimeEdit* pDateTimeEdit = new IFWL_DateTimeEdit;
68 CFWL_DateTimeEdit* pDateTimeEditImpl =
69 new CFWL_DateTimeEdit(properties, pOuter);
70 pDateTimeEdit->SetImpl(pDateTimeEditImpl);
71 pDateTimeEditImpl->SetInterface(pDateTimeEdit);
72 return pDateTimeEdit;
73 }
74
75 IFWL_DateTimePicker::IFWL_DateTimePicker() {}
76 int32_t IFWL_DateTimePicker::CountSelRanges() {
77 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())
78 ->GetDataTimeEdit()
79 ->CountSelRanges();
80 }
81 int32_t IFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) {
82 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())
83 ->GetDataTimeEdit()
84 ->GetSelRange(nIndex, nStart);
85 }
86 FWL_Error IFWL_DateTimePicker::GetCurSel(int32_t& iYear,
87 int32_t& iMonth,
88 int32_t& iDay) {
89 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())
90 ->GetCurSel(iYear, iMonth, iDay);
91 }
92 FWL_Error IFWL_DateTimePicker::SetCurSel(int32_t iYear,
93 int32_t iMonth,
94 int32_t iDay) {
95 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())
96 ->SetCurSel(iYear, iMonth, iDay);
97 }
98 FWL_Error IFWL_DateTimePicker::SetEditText(const CFX_WideString& wsText) {
99 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->SetEditText(wsText);
100 }
101 FWL_Error IFWL_DateTimePicker::GetEditText(CFX_WideString& wsText,
102 int32_t nStart,
103 int32_t nCount) const {
104 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())
105 ->GetEditText(wsText, nStart, nCount);
106 }
107 FX_BOOL IFWL_DateTimePicker::CanUndo() {
108 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanUndo();
109 }
110 FX_BOOL IFWL_DateTimePicker::CanRedo() {
111 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanRedo();
112 }
113 FX_BOOL IFWL_DateTimePicker::Undo() {
114 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Undo();
115 }
116 FX_BOOL IFWL_DateTimePicker::Redo() {
117 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Redo();
118 }
119 FX_BOOL IFWL_DateTimePicker::CanCopy() {
120 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanCopy();
121 }
122 FX_BOOL IFWL_DateTimePicker::CanCut() {
123 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanCut();
124 }
125 FX_BOOL IFWL_DateTimePicker::CanSelectAll() {
126 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanSelectAll();
127 }
128 FX_BOOL IFWL_DateTimePicker::Copy(CFX_WideString& wsCopy) {
129 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Copy(wsCopy);
130 }
131 FX_BOOL IFWL_DateTimePicker::Cut(CFX_WideString& wsCut) {
132 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Cut(wsCut);
133 }
134 FX_BOOL IFWL_DateTimePicker::Paste(const CFX_WideString& wsPaste) {
135 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Paste(wsPaste);
136 }
137 FX_BOOL IFWL_DateTimePicker::SelectAll() {
138 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->SelectAll();
139 }
140 FX_BOOL IFWL_DateTimePicker::Delete() {
141 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Delete();
142 }
143 FX_BOOL IFWL_DateTimePicker::DeSelect() {
144 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->DeSelect();
145 }
146 FWL_Error IFWL_DateTimePicker::GetBBox(CFX_RectF& rect) {
147 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->GetBBox(rect);
148 }
149 FWL_Error IFWL_DateTimePicker::SetEditLimit(int32_t nLimit) {
150 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->SetEditLimit(nLimit);
151 }
152 FWL_Error IFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded,
153 uint32_t dwStylesExRemoved) {
154 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())
155 ->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved);
156 }
157 CFWL_DateTimeEdit::CFWL_DateTimeEdit(const CFWL_WidgetImpProperties& properties,
158 IFWL_Widget* pOuter)
159 : CFWL_EditImp(properties, pOuter) {}
160 FWL_Error CFWL_DateTimeEdit::Initialize() {
161 m_pDelegate = new CFWL_DateTimeEditImpDelegate(this);
162 if (CFWL_EditImp::Initialize() != FWL_Error::Succeeded)
163 return FWL_Error::Indefinite;
164 return FWL_Error::Succeeded;
165 }
166 FWL_Error CFWL_DateTimeEdit::Finalize() {
167 delete m_pDelegate;
168 m_pDelegate = nullptr;
169 return CFWL_EditImp::Finalize();
170 }
171
172 CFWL_DateTimeEditImpDelegate::CFWL_DateTimeEditImpDelegate(
173 CFWL_DateTimeEdit* pOwner)
174 : CFWL_EditImpDelegate(pOwner), m_pOwner(pOwner) {}
175
176 void CFWL_DateTimeEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
177 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
178 DisForm_OnProcessMessage(pMessage);
179 return;
180 }
181
182 CFWL_MessageType dwHashCode = pMessage->GetClassID();
183 if (dwHashCode == CFWL_MessageType::SetFocus ||
184 dwHashCode == CFWL_MessageType::KillFocus) {
185 IFWL_Widget* pOuter = m_pOwner->GetOuter();
186 IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(nullptr);
187 pDelegate->OnProcessMessage(pMessage);
188 }
189 }
190
191 void CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage(
192 CFWL_Message* pMessage) {
193 CFWL_MessageType dwHashCode = pMessage->GetClassID();
194 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
195 if (dwHashCode == CFWL_MessageType::Mouse) {
196 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage);
197 if (pMouse->m_dwCmd == FWL_MouseCommand::LeftButtonDown ||
198 pMouse->m_dwCmd == FWL_MouseCommand::RightButtonDown) {
199 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
200 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
201 }
202 CFWL_DateTimePickerImp* pDateTime =
203 static_cast<CFWL_DateTimePickerImp*>(m_pOwner->m_pOuter->GetImpl());
204 if (pDateTime->IsMonthCalendarShowed()) {
205 CFX_RectF rtInvalidate;
206 pDateTime->GetWidgetRect(rtInvalidate);
207 pDateTime->ShowMonthCalendar(FALSE);
208 rtInvalidate.Offset(-rtInvalidate.left, -rtInvalidate.top);
209 pDateTime->Repaint(&rtInvalidate);
210 }
211 }
212 }
213 }
214 CFWL_EditImpDelegate::OnProcessMessage(pMessage);
215 }
216
217 CFWL_DateTimeCalendar::CFWL_DateTimeCalendar(
218 const CFWL_WidgetImpProperties& properties, 34 const CFWL_WidgetImpProperties& properties,
219 IFWL_Widget* pOuter) 35 IFWL_Widget* pOuter)
220 : CFWL_MonthCalendarImp(properties, pOuter) {} 36 : IFWL_Widget(properties, pOuter),
221 FWL_Error CFWL_DateTimeCalendar::Initialize() {
222 if (CFWL_MonthCalendarImp::Initialize() != FWL_Error::Succeeded)
223 return FWL_Error::Indefinite;
224 delete m_pDelegate;
225 m_pDelegate = new CFWL_DateTimeCalendarImpDelegate(this);
226 return FWL_Error::Succeeded;
227 }
228 FWL_Error CFWL_DateTimeCalendar::Finalize() {
229 delete m_pDelegate;
230 m_pDelegate = nullptr;
231 return CFWL_MonthCalendarImp::Finalize();
232 }
233
234 CFWL_DateTimeCalendarImpDelegate::CFWL_DateTimeCalendarImpDelegate(
235 CFWL_DateTimeCalendar* pOwner)
236 : CFWL_MonthCalendarImpDelegate(pOwner), m_pOwner(pOwner) {
237 m_bFlag = FALSE;
238 }
239
240 void CFWL_DateTimeCalendarImpDelegate::OnProcessMessage(
241 CFWL_Message* pMessage) {
242 CFWL_MessageType dwCode = pMessage->GetClassID();
243 if (dwCode == CFWL_MessageType::SetFocus ||
244 dwCode == CFWL_MessageType::KillFocus) {
245 IFWL_Widget* pOuter = m_pOwner->GetOuter();
246 IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(nullptr);
247 pDelegate->OnProcessMessage(pMessage);
248 return;
249 }
250 if (dwCode == CFWL_MessageType::Mouse) {
251 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
252 if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonDown)
253 OnLButtonDownEx(pMsg);
254 else if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonUp)
255 OnLButtonUpEx(pMsg);
256 return;
257 }
258 CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage);
259 }
260
261 void CFWL_DateTimeCalendarImpDelegate::OnLButtonDownEx(CFWL_MsgMouse* pMsg) {
262 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
263 m_pOwner->m_iLBtnPartStates = CFWL_PartState_Pressed;
264 m_pOwner->PrevMonth();
265 m_pOwner->Repaint(&m_pOwner->m_rtClient);
266 } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
267 m_pOwner->m_iRBtnPartStates |= CFWL_PartState_Pressed;
268 m_pOwner->NextMonth();
269 m_pOwner->Repaint(&m_pOwner->m_rtClient);
270 } else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
271 if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) ==
272 0) {
273 m_pOwner->JumpToToday();
274 m_pOwner->Repaint(&m_pOwner->m_rtClient);
275 }
276 } else {
277 IFWL_DateTimePicker* pIPicker =
278 static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter);
279 CFWL_DateTimePickerImp* pPicker =
280 static_cast<CFWL_DateTimePickerImp*>(pIPicker->GetImpl());
281 if (pPicker->IsMonthCalendarShowed()) {
282 m_bFlag = 1;
283 }
284 }
285 }
286 void CFWL_DateTimeCalendarImpDelegate::OnLButtonUpEx(CFWL_MsgMouse* pMsg) {
287 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
288 return DisForm_OnLButtonUpEx(pMsg);
289 }
290 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
291 m_pOwner->m_iLBtnPartStates = 0;
292 m_pOwner->Repaint(&m_pOwner->m_rtLBtn);
293 return;
294 }
295 if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
296 m_pOwner->m_iRBtnPartStates = 0;
297 m_pOwner->Repaint(&m_pOwner->m_rtRBtn);
298 return;
299 }
300 if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
301 return;
302 }
303 int32_t iOldSel = 0;
304 if (m_pOwner->m_arrSelDays.GetSize() > 0) {
305 iOldSel = m_pOwner->m_arrSelDays[0];
306 }
307 int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
308 CFX_RectF rt;
309 IFWL_DateTimePicker* pIPicker =
310 static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter);
311 CFWL_DateTimePickerImp* pPicker =
312 static_cast<CFWL_DateTimePickerImp*>(pIPicker->GetImpl());
313 pPicker->m_pForm->GetWidgetRect(rt);
314 rt.Set(0, 0, rt.width, rt.height);
315 if (iCurSel > 0) {
316 FWL_DATEINFO* lpDatesInfo = m_pOwner->m_arrDates.GetAt(iCurSel - 1);
317 CFX_RectF rtInvalidate(lpDatesInfo->rect);
318 if (iOldSel > 0 && iOldSel <= m_pOwner->m_arrDates.GetSize()) {
319 lpDatesInfo = m_pOwner->m_arrDates.GetAt(iOldSel - 1);
320 rtInvalidate.Union(lpDatesInfo->rect);
321 }
322 m_pOwner->AddSelDay(iCurSel);
323 if (!m_pOwner->m_pOuter)
324 return;
325 pPicker->ProcessSelChanged(m_pOwner->m_iCurYear, m_pOwner->m_iCurMonth,
326 iCurSel);
327 pPicker->ShowMonthCalendar(FALSE);
328 } else if (m_bFlag && (!rt.Contains(pMsg->m_fx, pMsg->m_fy))) {
329 pPicker->ShowMonthCalendar(FALSE);
330 }
331 m_bFlag = 0;
332 }
333 void CFWL_DateTimeCalendarImpDelegate::OnMouseMoveEx(CFWL_MsgMouse* pMsg) {
334 if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) {
335 return;
336 }
337 FX_BOOL bRepaint = FALSE;
338 CFX_RectF rtInvalidate;
339 rtInvalidate.Set(0, 0, 0, 0);
340 if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
341 int32_t iHover = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
342 bRepaint = m_pOwner->m_iHovered != iHover;
343 if (bRepaint) {
344 if (m_pOwner->m_iHovered > 0) {
345 m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
346 }
347 if (iHover > 0) {
348 CFX_RectF rtDay;
349 m_pOwner->GetDayRect(iHover, rtDay);
350 if (rtInvalidate.IsEmpty()) {
351 rtInvalidate = rtDay;
352 } else {
353 rtInvalidate.Union(rtDay);
354 }
355 }
356 }
357 m_pOwner->m_iHovered = iHover;
358 CFWL_Event_DtpHoverChanged ev;
359 ev.hoverday = iHover;
360 m_pOwner->DispatchEvent(&ev);
361 } else {
362 bRepaint = m_pOwner->m_iHovered > 0;
363 if (bRepaint) {
364 m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
365 }
366 m_pOwner->m_iHovered = -1;
367 }
368 if (bRepaint && !rtInvalidate.IsEmpty()) {
369 m_pOwner->Repaint(&rtInvalidate);
370 }
371 }
372
373 void CFWL_DateTimeCalendarImpDelegate::DisForm_OnProcessMessage(
374 CFWL_Message* pMessage) {
375 if (pMessage->GetClassID() == CFWL_MessageType::Mouse) {
376 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
377 if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonUp) {
378 DisForm_OnLButtonUpEx(pMsg);
379 return;
380 }
381 }
382 CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage);
383 }
384
385 void CFWL_DateTimeCalendarImpDelegate::DisForm_OnLButtonUpEx(
386 CFWL_MsgMouse* pMsg) {
387 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
388 m_pOwner->m_iLBtnPartStates = 0;
389 m_pOwner->Repaint(&(m_pOwner->m_rtLBtn));
390 return;
391 }
392 if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
393 m_pOwner->m_iRBtnPartStates = 0;
394 m_pOwner->Repaint(&(m_pOwner->m_rtRBtn));
395 return;
396 }
397 if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
398 return;
399 }
400 int32_t iOldSel = 0;
401 if (m_pOwner->m_arrSelDays.GetSize() > 0) {
402 iOldSel = m_pOwner->m_arrSelDays[0];
403 }
404 int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
405 if (iCurSel > 0) {
406 FWL_DATEINFO* lpDatesInfo = m_pOwner->m_arrDates.GetAt(iCurSel - 1);
407 CFX_RectF rtInvalidate(lpDatesInfo->rect);
408 if (iOldSel > 0 && iOldSel <= m_pOwner->m_arrDates.GetSize()) {
409 lpDatesInfo = m_pOwner->m_arrDates.GetAt(iOldSel - 1);
410 rtInvalidate.Union(lpDatesInfo->rect);
411 }
412 m_pOwner->AddSelDay(iCurSel);
413 CFWL_DateTimePickerImp* pDateTime =
414 static_cast<CFWL_DateTimePickerImp*>(m_pOwner->m_pOuter->GetImpl());
415 pDateTime->ProcessSelChanged(m_pOwner->m_iCurYear, m_pOwner->m_iCurMonth,
416 iCurSel);
417 pDateTime->ShowMonthCalendar(FALSE);
418 }
419 }
420
421 CFWL_DateTimePickerImp::CFWL_DateTimePickerImp(
422 const CFWL_WidgetImpProperties& properties,
423 IFWL_Widget* pOuter)
424 : CFWL_WidgetImp(properties, pOuter),
425 m_iBtnState(1), 37 m_iBtnState(1),
426 m_iYear(-1), 38 m_iYear(-1),
427 m_iMonth(-1), 39 m_iMonth(-1),
428 m_iDay(-1), 40 m_iDay(-1),
429 m_bLBtnDown(FALSE) { 41 m_bLBtnDown(FALSE) {
430 m_rtBtn.Set(0, 0, 0, 0); 42 m_rtBtn.Set(0, 0, 0, 0);
431 } 43 }
432 44
433 CFWL_DateTimePickerImp::~CFWL_DateTimePickerImp() {} 45 IFWL_DateTimePicker::~IFWL_DateTimePicker() {}
434 46
435 FWL_Error CFWL_DateTimePickerImp::GetClassName(CFX_WideString& wsClass) const { 47 FWL_Error IFWL_DateTimePicker::GetClassName(CFX_WideString& wsClass) const {
436 wsClass = FWL_CLASS_DateTimePicker; 48 wsClass = FWL_CLASS_DateTimePicker;
437 return FWL_Error::Succeeded; 49 return FWL_Error::Succeeded;
438 } 50 }
439 51
440 FWL_Type CFWL_DateTimePickerImp::GetClassID() const { 52 FWL_Type IFWL_DateTimePicker::GetClassID() const {
441 return FWL_Type::DateTimePicker; 53 return FWL_Type::DateTimePicker;
442 } 54 }
443 55
444 FWL_Error CFWL_DateTimePickerImp::Initialize() { 56 FWL_Error IFWL_DateTimePicker::Initialize() {
445 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) 57 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
446 return FWL_Error::Indefinite; 58 return FWL_Error::Indefinite;
447 59
448 m_pDelegate = new CFWL_DateTimePickerImpDelegate(this); 60 m_pDelegate = new CFWL_DateTimePickerImpDelegate(this);
449 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; 61 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat;
450 CFWL_WidgetImpProperties propMonth; 62 CFWL_WidgetImpProperties propMonth;
451 propMonth.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border; 63 propMonth.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border;
452 propMonth.m_dwStates = FWL_WGTSTATE_Invisible; 64 propMonth.m_dwStates = FWL_WGTSTATE_Invisible;
453 propMonth.m_pDataProvider = &m_MonthCalendarDP; 65 propMonth.m_pDataProvider = &m_MonthCalendarDP;
454 propMonth.m_pParent = m_pInterface; 66 propMonth.m_pParent = this;
455 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; 67 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider;
456 m_pMonthCal.reset(IFWL_DateTimeCalender::Create(propMonth, m_pInterface)); 68 m_pMonthCal.reset(IFWL_DateTimeCalendar::Create(propMonth, this));
457 m_pMonthCal->Initialize(); 69 m_pMonthCal->Initialize();
458 CFX_RectF rtMonthCal; 70 CFX_RectF rtMonthCal;
459 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); 71 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
460 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); 72 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height);
461 m_pMonthCal->SetWidgetRect(rtMonthCal); 73 m_pMonthCal->SetWidgetRect(rtMonthCal);
462 CFWL_WidgetImpProperties propEdit; 74 CFWL_WidgetImpProperties propEdit;
463 propEdit.m_pParent = m_pInterface; 75 propEdit.m_pParent = this;
464 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; 76 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider;
465 m_pEdit.reset(IFWL_DateTimeEdit::Create(propEdit, m_pInterface)); 77 m_pEdit.reset(IFWL_DateTimeEdit::Create(propEdit, this));
466 m_pEdit->Initialize(); 78 m_pEdit->Initialize();
467 RegisterEventTarget(m_pMonthCal.get()); 79 RegisterEventTarget(m_pMonthCal.get());
468 RegisterEventTarget(m_pEdit.get()); 80 RegisterEventTarget(m_pEdit.get());
469 return FWL_Error::Succeeded; 81 return FWL_Error::Succeeded;
470 } 82 }
471 83
472 FWL_Error CFWL_DateTimePickerImp::Finalize() { 84 FWL_Error IFWL_DateTimePicker::Finalize() {
473 if (m_pEdit) { 85 if (m_pEdit) {
474 m_pEdit->Finalize(); 86 m_pEdit->Finalize();
475 } 87 }
476 if (m_pMonthCal) { 88 if (m_pMonthCal) {
477 m_pMonthCal->Finalize(); 89 m_pMonthCal->Finalize();
478 } 90 }
479 if (m_pForm) { 91 if (m_pForm) {
480 m_pForm->Finalize(); 92 m_pForm->Finalize();
481 } 93 }
482 UnregisterEventTarget(); 94 UnregisterEventTarget();
483 delete m_pDelegate; 95 delete m_pDelegate;
484 m_pDelegate = nullptr; 96 m_pDelegate = nullptr;
485 return CFWL_WidgetImp::Finalize(); 97 return IFWL_Widget::Finalize();
486 } 98 }
487 FWL_Error CFWL_DateTimePickerImp::GetWidgetRect(CFX_RectF& rect, 99
488 FX_BOOL bAutoSize) { 100 FWL_Error IFWL_DateTimePicker::GetWidgetRect(CFX_RectF& rect,
101 FX_BOOL bAutoSize) {
489 if (m_pWidgetMgr->IsFormDisabled()) { 102 if (m_pWidgetMgr->IsFormDisabled()) {
490 return DisForm_GetWidgetRect(rect, bAutoSize); 103 return DisForm_GetWidgetRect(rect, bAutoSize);
491 } 104 }
492 if (bAutoSize) { 105 if (bAutoSize) {
493 rect.Set(0, 0, kDateTimePickerWidth, kDateTimePickerHeight); 106 rect.Set(0, 0, kDateTimePickerWidth, kDateTimePickerHeight);
494 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); 107 IFWL_Widget::GetWidgetRect(rect, TRUE);
495 } else { 108 } else {
496 rect = m_pProperties->m_rtWidget; 109 rect = m_pProperties->m_rtWidget;
497 } 110 }
498 return FWL_Error::Succeeded; 111 return FWL_Error::Succeeded;
499 } 112 }
500 FWL_Error CFWL_DateTimePickerImp::Update() { 113
114 FWL_Error IFWL_DateTimePicker::Update() {
501 if (m_pWidgetMgr->IsFormDisabled()) { 115 if (m_pWidgetMgr->IsFormDisabled()) {
502 return DisForm_Update(); 116 return DisForm_Update();
503 } 117 }
504 if (m_iLock) { 118 if (m_iLock) {
505 return FWL_Error::Indefinite; 119 return FWL_Error::Indefinite;
506 } 120 }
507 if (!m_pProperties->m_pThemeProvider) { 121 if (!m_pProperties->m_pThemeProvider) {
508 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 122 m_pProperties->m_pThemeProvider = GetAvailableTheme();
509 } 123 }
510 m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider); 124 m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider);
(...skipping 10 matching lines...) Expand all
521 m_rtClient.height); 135 m_rtClient.height);
522 m_pEdit->SetWidgetRect(rtEdit); 136 m_pEdit->SetWidgetRect(rtEdit);
523 ReSetEditAlignment(); 137 ReSetEditAlignment();
524 m_pEdit->Update(); 138 m_pEdit->Update();
525 if (!(m_pMonthCal->GetThemeProvider())) { 139 if (!(m_pMonthCal->GetThemeProvider())) {
526 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider); 140 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider);
527 } 141 }
528 if (m_pProperties->m_pDataProvider) { 142 if (m_pProperties->m_pDataProvider) {
529 IFWL_DateTimePickerDP* pData = 143 IFWL_DateTimePickerDP* pData =
530 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider); 144 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider);
531 pData->GetToday(m_pInterface, m_MonthCalendarDP.m_iCurYear, 145 pData->GetToday(this, m_MonthCalendarDP.m_iCurYear,
532 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay); 146 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay);
533 } 147 }
534 CFX_RectF rtMonthCal; 148 CFX_RectF rtMonthCal;
535 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); 149 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
536 CFX_RectF rtPopUp; 150 CFX_RectF rtPopUp;
537 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, 151 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight,
538 rtMonthCal.width, rtMonthCal.height); 152 rtMonthCal.width, rtMonthCal.height);
539 m_pMonthCal->SetWidgetRect(rtPopUp); 153 m_pMonthCal->SetWidgetRect(rtPopUp);
540 m_pMonthCal->Update(); 154 m_pMonthCal->Update();
541 return FWL_Error::Succeeded; 155 return FWL_Error::Succeeded;
542 } 156 }
543 FWL_WidgetHit CFWL_DateTimePickerImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { 157
158 int32_t IFWL_DateTimePicker::CountSelRanges() {
159 return GetDataTimeEdit()->CountSelRanges();
160 }
161
162 int32_t IFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) {
163 return GetDataTimeEdit()->GetSelRange(nIndex, nStart);
164 }
165
166 FWL_WidgetHit IFWL_DateTimePicker::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
544 if (m_pWidgetMgr->IsFormDisabled()) 167 if (m_pWidgetMgr->IsFormDisabled())
545 return DisForm_HitTest(fx, fy); 168 return DisForm_HitTest(fx, fy);
546 if (m_rtClient.Contains(fx, fy)) 169 if (m_rtClient.Contains(fx, fy))
547 return FWL_WidgetHit::Client; 170 return FWL_WidgetHit::Client;
548 if (IsMonthCalendarShowed()) { 171 if (IsMonthCalendarShowed()) {
549 CFX_RectF rect; 172 CFX_RectF rect;
550 m_pMonthCal->GetWidgetRect(rect); 173 m_pMonthCal->GetWidgetRect(rect);
551 if (rect.Contains(fx, fy)) 174 if (rect.Contains(fx, fy))
552 return FWL_WidgetHit::Client; 175 return FWL_WidgetHit::Client;
553 } 176 }
554 return FWL_WidgetHit::Unknown; 177 return FWL_WidgetHit::Unknown;
555 } 178 }
556 FWL_Error CFWL_DateTimePickerImp::DrawWidget(CFX_Graphics* pGraphics, 179
557 const CFX_Matrix* pMatrix) { 180 FWL_Error IFWL_DateTimePicker::DrawWidget(CFX_Graphics* pGraphics,
181 const CFX_Matrix* pMatrix) {
558 if (!pGraphics) 182 if (!pGraphics)
559 return FWL_Error::Indefinite; 183 return FWL_Error::Indefinite;
560 if (!m_pProperties->m_pThemeProvider) 184 if (!m_pProperties->m_pThemeProvider)
561 return FWL_Error::Indefinite; 185 return FWL_Error::Indefinite;
562 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 186 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
563 if (HasBorder()) { 187 if (HasBorder()) {
564 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); 188 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
565 } 189 }
566 if (HasEdge()) { 190 if (HasEdge()) {
567 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); 191 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
568 } 192 }
569 if (!m_rtBtn.IsEmpty()) { 193 if (!m_rtBtn.IsEmpty()) {
570 DrawDropDownButton(pGraphics, pTheme, pMatrix); 194 DrawDropDownButton(pGraphics, pTheme, pMatrix);
571 } 195 }
572 if (m_pWidgetMgr->IsFormDisabled()) { 196 if (m_pWidgetMgr->IsFormDisabled()) {
573 return DisForm_DrawWidget(pGraphics, pMatrix); 197 return DisForm_DrawWidget(pGraphics, pMatrix);
574 } 198 }
575 return FWL_Error::Succeeded; 199 return FWL_Error::Succeeded;
576 } 200 }
577 FWL_Error CFWL_DateTimePickerImp::SetThemeProvider(IFWL_ThemeProvider* pTP) { 201
202 FWL_Error IFWL_DateTimePicker::SetThemeProvider(IFWL_ThemeProvider* pTP) {
578 m_pProperties->m_pThemeProvider = pTP; 203 m_pProperties->m_pThemeProvider = pTP;
579 m_pMonthCal->SetThemeProvider(pTP); 204 m_pMonthCal->SetThemeProvider(pTP);
580 return FWL_Error::Succeeded; 205 return FWL_Error::Succeeded;
581 } 206 }
582 FWL_Error CFWL_DateTimePickerImp::GetCurSel(int32_t& iYear, 207
583 int32_t& iMonth, 208 FWL_Error IFWL_DateTimePicker::GetCurSel(int32_t& iYear,
584 int32_t& iDay) { 209 int32_t& iMonth,
210 int32_t& iDay) {
585 iYear = m_iYear; 211 iYear = m_iYear;
586 iMonth = m_iMonth; 212 iMonth = m_iMonth;
587 iDay = m_iDay; 213 iDay = m_iDay;
588 return FWL_Error::Succeeded; 214 return FWL_Error::Succeeded;
589 } 215 }
590 FWL_Error CFWL_DateTimePickerImp::SetCurSel(int32_t iYear, 216
591 int32_t iMonth, 217 FWL_Error IFWL_DateTimePicker::SetCurSel(int32_t iYear,
592 int32_t iDay) { 218 int32_t iMonth,
219 int32_t iDay) {
593 if (iYear <= 0 || iYear >= 3000) 220 if (iYear <= 0 || iYear >= 3000)
594 return FWL_Error::Indefinite; 221 return FWL_Error::Indefinite;
595 if (iMonth <= 0 || iMonth >= 13) 222 if (iMonth <= 0 || iMonth >= 13)
596 return FWL_Error::Indefinite; 223 return FWL_Error::Indefinite;
597 if (iDay <= 0 || iDay >= 32) 224 if (iDay <= 0 || iDay >= 32)
598 return FWL_Error::Indefinite; 225 return FWL_Error::Indefinite;
599 m_iYear = iYear; 226 m_iYear = iYear;
600 m_iMonth = iMonth; 227 m_iMonth = iMonth;
601 m_iDay = iDay; 228 m_iDay = iDay;
602 m_pMonthCal->SetSelect(iYear, iMonth, iDay); 229 m_pMonthCal->SetSelect(iYear, iMonth, iDay);
603 return FWL_Error::Succeeded; 230 return FWL_Error::Succeeded;
604 } 231 }
605 232
606 FWL_Error CFWL_DateTimePickerImp::SetEditText(const CFX_WideString& wsText) { 233 FWL_Error IFWL_DateTimePicker::SetEditText(const CFX_WideString& wsText) {
607 if (!m_pEdit) 234 if (!m_pEdit)
608 return FWL_Error::Indefinite; 235 return FWL_Error::Indefinite;
609 236
610 FWL_Error iRet = m_pEdit->SetText(wsText); 237 FWL_Error iRet = m_pEdit->SetText(wsText);
611 Repaint(&m_rtClient); 238 Repaint(&m_rtClient);
612 CFWL_Event_DtpEditChanged ev; 239 CFWL_Event_DtpEditChanged ev;
613 ev.m_wsText = wsText; 240 ev.m_wsText = wsText;
614 DispatchEvent(&ev); 241 DispatchEvent(&ev);
615 return iRet; 242 return iRet;
616 } 243 }
617 244
618 FWL_Error CFWL_DateTimePickerImp::GetEditText(CFX_WideString& wsText, 245 FWL_Error IFWL_DateTimePicker::GetEditText(CFX_WideString& wsText,
619 int32_t nStart, 246 int32_t nStart,
620 int32_t nCount) const { 247 int32_t nCount) const {
621 if (m_pEdit) { 248 if (m_pEdit) {
622 return m_pEdit->GetText(wsText, nStart, nCount); 249 return m_pEdit->GetText(wsText, nStart, nCount);
623 } 250 }
624 return FWL_Error::Indefinite; 251 return FWL_Error::Indefinite;
625 } 252 }
626 FX_BOOL CFWL_DateTimePickerImp::CanUndo() { 253
254 FX_BOOL IFWL_DateTimePicker::CanUndo() {
627 return m_pEdit->CanUndo(); 255 return m_pEdit->CanUndo();
628 } 256 }
629 FX_BOOL CFWL_DateTimePickerImp::CanRedo() { 257
258 FX_BOOL IFWL_DateTimePicker::CanRedo() {
630 return m_pEdit->CanRedo(); 259 return m_pEdit->CanRedo();
631 } 260 }
632 FX_BOOL CFWL_DateTimePickerImp::Undo() { 261
262 FX_BOOL IFWL_DateTimePicker::Undo() {
633 return m_pEdit->Undo(); 263 return m_pEdit->Undo();
634 } 264 }
635 FX_BOOL CFWL_DateTimePickerImp::Redo() { 265
266 FX_BOOL IFWL_DateTimePicker::Redo() {
636 return m_pEdit->Redo(); 267 return m_pEdit->Redo();
637 } 268 }
638 FX_BOOL CFWL_DateTimePickerImp::CanCopy() { 269
270 FX_BOOL IFWL_DateTimePicker::CanCopy() {
639 int32_t nCount = m_pEdit->CountSelRanges(); 271 int32_t nCount = m_pEdit->CountSelRanges();
640 return nCount > 0; 272 return nCount > 0;
641 } 273 }
642 FX_BOOL CFWL_DateTimePickerImp::CanCut() { 274
275 FX_BOOL IFWL_DateTimePicker::CanCut() {
643 if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) { 276 if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) {
644 return FALSE; 277 return FALSE;
645 } 278 }
646 int32_t nCount = m_pEdit->CountSelRanges(); 279 int32_t nCount = m_pEdit->CountSelRanges();
647 return nCount > 0; 280 return nCount > 0;
648 } 281 }
649 FX_BOOL CFWL_DateTimePickerImp::CanSelectAll() { 282
283 FX_BOOL IFWL_DateTimePicker::CanSelectAll() {
650 return m_pEdit->GetTextLength() > 0; 284 return m_pEdit->GetTextLength() > 0;
651 } 285 }
652 FX_BOOL CFWL_DateTimePickerImp::Copy(CFX_WideString& wsCopy) { 286
287 FX_BOOL IFWL_DateTimePicker::Copy(CFX_WideString& wsCopy) {
653 return m_pEdit->Copy(wsCopy); 288 return m_pEdit->Copy(wsCopy);
654 } 289 }
655 FX_BOOL CFWL_DateTimePickerImp::Cut(CFX_WideString& wsCut) { 290
291 FX_BOOL IFWL_DateTimePicker::Cut(CFX_WideString& wsCut) {
656 return m_pEdit->Cut(wsCut); 292 return m_pEdit->Cut(wsCut);
657 } 293 }
658 FX_BOOL CFWL_DateTimePickerImp::Paste(const CFX_WideString& wsPaste) { 294
295 FX_BOOL IFWL_DateTimePicker::Paste(const CFX_WideString& wsPaste) {
659 return m_pEdit->Paste(wsPaste); 296 return m_pEdit->Paste(wsPaste);
660 } 297 }
661 FX_BOOL CFWL_DateTimePickerImp::SelectAll() { 298
299 FX_BOOL IFWL_DateTimePicker::SelectAll() {
662 return m_pEdit->AddSelRange(0) == FWL_Error::Succeeded; 300 return m_pEdit->AddSelRange(0) == FWL_Error::Succeeded;
663 } 301 }
664 FX_BOOL CFWL_DateTimePickerImp::Delete() { 302
303 FX_BOOL IFWL_DateTimePicker::Delete() {
665 return m_pEdit->ClearText() == FWL_Error::Succeeded; 304 return m_pEdit->ClearText() == FWL_Error::Succeeded;
666 } 305 }
667 FX_BOOL CFWL_DateTimePickerImp::DeSelect() { 306
307 FX_BOOL IFWL_DateTimePicker::DeSelect() {
668 return m_pEdit->ClearSelections() == FWL_Error::Succeeded; 308 return m_pEdit->ClearSelections() == FWL_Error::Succeeded;
669 } 309 }
670 FWL_Error CFWL_DateTimePickerImp::GetBBox(CFX_RectF& rect) { 310
311 FWL_Error IFWL_DateTimePicker::GetBBox(CFX_RectF& rect) {
671 if (m_pWidgetMgr->IsFormDisabled()) { 312 if (m_pWidgetMgr->IsFormDisabled()) {
672 return DisForm_GetBBox(rect); 313 return DisForm_GetBBox(rect);
673 } 314 }
674 rect = m_pProperties->m_rtWidget; 315 rect = m_pProperties->m_rtWidget;
675 if (IsMonthCalendarShowed()) { 316 if (IsMonthCalendarShowed()) {
676 CFX_RectF rtMonth; 317 CFX_RectF rtMonth;
677 m_pMonthCal->GetWidgetRect(rtMonth); 318 m_pMonthCal->GetWidgetRect(rtMonth);
678 rtMonth.Offset(m_pProperties->m_rtWidget.left, 319 rtMonth.Offset(m_pProperties->m_rtWidget.left,
679 m_pProperties->m_rtWidget.top); 320 m_pProperties->m_rtWidget.top);
680 rect.Union(rtMonth); 321 rect.Union(rtMonth);
681 } 322 }
682 return FWL_Error::Succeeded; 323 return FWL_Error::Succeeded;
683 } 324 }
684 FWL_Error CFWL_DateTimePickerImp::SetEditLimit(int32_t nLimit) { 325
326 FWL_Error IFWL_DateTimePicker::SetEditLimit(int32_t nLimit) {
685 return m_pEdit->SetLimit(nLimit); 327 return m_pEdit->SetLimit(nLimit);
686 } 328 }
687 FWL_Error CFWL_DateTimePickerImp::ModifyEditStylesEx( 329
688 uint32_t dwStylesExAdded, 330 FWL_Error IFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded,
689 uint32_t dwStylesExRemoved) { 331 uint32_t dwStylesExRemoved) {
690 return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 332 return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
691 } 333 }
692 void CFWL_DateTimePickerImp::DrawDropDownButton(CFX_Graphics* pGraphics, 334
693 IFWL_ThemeProvider* pTheme, 335 void IFWL_DateTimePicker::DrawDropDownButton(CFX_Graphics* pGraphics,
694 const CFX_Matrix* pMatrix) { 336 IFWL_ThemeProvider* pTheme,
337 const CFX_Matrix* pMatrix) {
695 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_Spin) == 338 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_Spin) ==
696 FWL_STYLEEXT_DTP_Spin) { 339 FWL_STYLEEXT_DTP_Spin) {
697 CFWL_WidgetImpProperties prop; 340 CFWL_WidgetImpProperties prop;
698 prop.m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; 341 prop.m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert;
699 prop.m_pParent = m_pInterface; 342 prop.m_pParent = this;
700 prop.m_rtWidget = m_rtBtn; 343 prop.m_rtWidget = m_rtBtn;
701 IFWL_SpinButton* pSpin = IFWL_SpinButton::Create(prop, m_pInterface); 344 IFWL_SpinButton* pSpin = IFWL_SpinButton::Create(prop, this);
702 pSpin->Initialize(); 345 pSpin->Initialize();
703 } else { 346 } else {
704 CFWL_ThemeBackground param; 347 CFWL_ThemeBackground param;
705 param.m_pWidget = m_pInterface; 348 param.m_pWidget = this;
706 param.m_iPart = CFWL_Part::DropDownButton; 349 param.m_iPart = CFWL_Part::DropDownButton;
707 param.m_dwStates = m_iBtnState; 350 param.m_dwStates = m_iBtnState;
708 param.m_pGraphics = pGraphics; 351 param.m_pGraphics = pGraphics;
709 param.m_rtPart = m_rtBtn; 352 param.m_rtPart = m_rtBtn;
710 if (pMatrix) { 353 if (pMatrix) {
711 param.m_matrix.Concat(*pMatrix); 354 param.m_matrix.Concat(*pMatrix);
712 } 355 }
713 pTheme->DrawBackground(&param); 356 pTheme->DrawBackground(&param);
714 } 357 }
715 } 358 }
716 void CFWL_DateTimePickerImp::FormatDateString(int32_t iYear, 359
717 int32_t iMonth, 360 void IFWL_DateTimePicker::FormatDateString(int32_t iYear,
718 int32_t iDay, 361 int32_t iMonth,
719 CFX_WideString& wsText) { 362 int32_t iDay,
363 CFX_WideString& wsText) {
720 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_ShortDateFormat) == 364 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_ShortDateFormat) ==
721 FWL_STYLEEXT_DTP_ShortDateFormat) { 365 FWL_STYLEEXT_DTP_ShortDateFormat) {
722 wsText.Format(L"%d-%d-%d", iYear, iMonth, iDay); 366 wsText.Format(L"%d-%d-%d", iYear, iMonth, iDay);
723 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_LongDateFormat) == 367 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_LongDateFormat) ==
724 FWL_STYLEEXT_DTP_LongDateFormat) { 368 FWL_STYLEEXT_DTP_LongDateFormat) {
725 wsText.Format(L"%d Year %d Month %d Day", iYear, iMonth, iDay); 369 wsText.Format(L"%d Year %d Month %d Day", iYear, iMonth, iDay);
726 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat) == 370 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat) ==
727 FWL_STYLEEXT_DTP_TimeFormat) { 371 FWL_STYLEEXT_DTP_TimeFormat) {
728 } 372 }
729 } 373 }
730 void CFWL_DateTimePickerImp::ShowMonthCalendar(FX_BOOL bActivate) { 374
375 void IFWL_DateTimePicker::ShowMonthCalendar(FX_BOOL bActivate) {
731 if (m_pWidgetMgr->IsFormDisabled()) { 376 if (m_pWidgetMgr->IsFormDisabled()) {
732 return DisForm_ShowMonthCalendar(bActivate); 377 return DisForm_ShowMonthCalendar(bActivate);
733 } 378 }
734 if (IsMonthCalendarShowed() == bActivate) { 379 if (IsMonthCalendarShowed() == bActivate) {
735 return; 380 return;
736 } 381 }
737 if (!m_pForm) { 382 if (!m_pForm) {
738 InitProxyForm(); 383 InitProxyForm();
739 } 384 }
740 if (bActivate) { 385 if (bActivate) {
741 CFX_RectF rtMonth; 386 CFX_RectF rtMonth;
742 m_pMonthCal->GetWidgetRect(rtMonth); 387 m_pMonthCal->GetWidgetRect(rtMonth);
743 CFX_RectF rtAnchor; 388 CFX_RectF rtAnchor;
744 rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, 389 rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width,
745 m_pProperties->m_rtWidget.height); 390 m_pProperties->m_rtWidget.height);
746 GetPopupPos(0, rtMonth.height, rtAnchor, rtMonth); 391 GetPopupPos(0, rtMonth.height, rtAnchor, rtMonth);
747 m_pForm->SetWidgetRect(rtMonth); 392 m_pForm->SetWidgetRect(rtMonth);
748 rtMonth.left = rtMonth.top = 0; 393 rtMonth.left = rtMonth.top = 0;
749 m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate); 394 m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate);
750 m_pMonthCal->SetWidgetRect(rtMonth); 395 m_pMonthCal->SetWidgetRect(rtMonth);
751 m_pMonthCal->Update(); 396 m_pMonthCal->Update();
752 m_pForm->DoModal(); 397 m_pForm->DoModal();
753 } else { 398 } else {
754 m_pForm->EndDoModal(); 399 m_pForm->EndDoModal();
755 } 400 }
756 } 401 }
757 FX_BOOL CFWL_DateTimePickerImp::IsMonthCalendarShowed() { 402
403 FX_BOOL IFWL_DateTimePicker::IsMonthCalendarShowed() {
758 if (m_pWidgetMgr->IsFormDisabled()) { 404 if (m_pWidgetMgr->IsFormDisabled()) {
759 return DisForm_IsMonthCalendarShowed(); 405 return DisForm_IsMonthCalendarShowed();
760 } 406 }
761 if (!m_pForm) 407 if (!m_pForm)
762 return FALSE; 408 return FALSE;
763 return !(m_pForm->GetStates() & FWL_WGTSTATE_Invisible); 409 return !(m_pForm->GetStates() & FWL_WGTSTATE_Invisible);
764 } 410 }
765 void CFWL_DateTimePickerImp::ReSetEditAlignment() { 411
412 void IFWL_DateTimePicker::ReSetEditAlignment() {
766 if (!m_pEdit) 413 if (!m_pEdit)
767 return; 414 return;
768 uint32_t dwStylExes = m_pProperties->m_dwStyleExes; 415 uint32_t dwStylExes = m_pProperties->m_dwStyleExes;
769 uint32_t dwAdd = 0; 416 uint32_t dwAdd = 0;
770 switch (dwStylExes & FWL_STYLEEXT_DTP_EditHAlignMask) { 417 switch (dwStylExes & FWL_STYLEEXT_DTP_EditHAlignMask) {
771 case FWL_STYLEEXT_DTP_EditHCenter: { 418 case FWL_STYLEEXT_DTP_EditHCenter: {
772 dwAdd |= FWL_STYLEEXT_EDT_HCenter; 419 dwAdd |= FWL_STYLEEXT_EDT_HCenter;
773 break; 420 break;
774 } 421 }
775 case FWL_STYLEEXT_DTP_EditHFar: { 422 case FWL_STYLEEXT_DTP_EditHFar: {
(...skipping 16 matching lines...) Expand all
792 if (dwStylExes & FWL_STYLEEXT_DTP_EditJustified) { 439 if (dwStylExes & FWL_STYLEEXT_DTP_EditJustified) {
793 dwAdd |= FWL_STYLEEXT_EDT_Justified; 440 dwAdd |= FWL_STYLEEXT_EDT_Justified;
794 } 441 }
795 if (dwStylExes & FWL_STYLEEXT_DTP_EditDistributed) { 442 if (dwStylExes & FWL_STYLEEXT_DTP_EditDistributed) {
796 dwAdd |= FWL_STYLEEXT_EDT_Distributed; 443 dwAdd |= FWL_STYLEEXT_EDT_Distributed;
797 } 444 }
798 m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask | 445 m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask |
799 FWL_STYLEEXT_EDT_HAlignModeMask | 446 FWL_STYLEEXT_EDT_HAlignModeMask |
800 FWL_STYLEEXT_EDT_VAlignMask); 447 FWL_STYLEEXT_EDT_VAlignMask);
801 } 448 }
802 void CFWL_DateTimePickerImp::ProcessSelChanged(int32_t iYear, 449
803 int32_t iMonth, 450 void IFWL_DateTimePicker::ProcessSelChanged(int32_t iYear,
804 int32_t iDay) { 451 int32_t iMonth,
452 int32_t iDay) {
805 m_iYear = iYear; 453 m_iYear = iYear;
806 m_iMonth = iMonth; 454 m_iMonth = iMonth;
807 m_iDay = iDay; 455 m_iDay = iDay;
808 CFX_WideString wsText; 456 CFX_WideString wsText;
809 FormatDateString(m_iYear, m_iMonth, m_iDay, wsText); 457 FormatDateString(m_iYear, m_iMonth, m_iDay, wsText);
810 m_pEdit->SetText(wsText); 458 m_pEdit->SetText(wsText);
811 m_pEdit->Update(); 459 m_pEdit->Update();
812 Repaint(&m_rtClient); 460 Repaint(&m_rtClient);
813 CFWL_Event_DtpSelectChanged ev; 461 CFWL_Event_DtpSelectChanged ev;
814 ev.m_pSrcTarget = m_pInterface; 462 ev.m_pSrcTarget = this;
815 ev.iYear = m_iYear; 463 ev.iYear = m_iYear;
816 ev.iMonth = m_iMonth; 464 ev.iMonth = m_iMonth;
817 ev.iDay = m_iDay; 465 ev.iDay = m_iDay;
818 DispatchEvent(&ev); 466 DispatchEvent(&ev);
819 } 467 }
820 void CFWL_DateTimePickerImp::InitProxyForm() { 468
469 void IFWL_DateTimePicker::InitProxyForm() {
821 if (m_pForm) 470 if (m_pForm)
822 return; 471 return;
823 if (!m_pMonthCal) 472 if (!m_pMonthCal)
824 return; 473 return;
825 CFWL_WidgetImpProperties propForm; 474 CFWL_WidgetImpProperties propForm;
826 propForm.m_dwStyles = FWL_WGTSTYLE_Popup; 475 propForm.m_dwStyles = FWL_WGTSTYLE_Popup;
827 propForm.m_dwStates = FWL_WGTSTATE_Invisible; 476 propForm.m_dwStates = FWL_WGTSTATE_Invisible;
828 propForm.m_pOwner = m_pInterface; 477 propForm.m_pOwner = this;
829 m_pForm.reset(IFWL_DateTimeForm::Create(propForm, m_pMonthCal.get())); 478 m_pForm.reset(IFWL_FormProxy::Create(propForm, m_pMonthCal.get()));
830 m_pForm->Initialize(); 479 m_pForm->Initialize();
831 m_pMonthCal->SetParent(m_pForm.get()); 480 m_pMonthCal->SetParent(m_pForm.get());
832 } 481 }
833 IFWL_DateTimeEdit* CFWL_DateTimePickerImp::GetDataTimeEdit() { 482
483 IFWL_DateTimeEdit* IFWL_DateTimePicker::GetDataTimeEdit() {
834 return m_pEdit.get(); 484 return m_pEdit.get();
835 } 485 }
836 FWL_Error CFWL_DateTimePickerImp::DisForm_Initialize() { 486
487 FWL_Error IFWL_DateTimePicker::DisForm_Initialize() {
837 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; 488 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat;
838 DisForm_InitDateTimeCalendar(); 489 DisForm_InitDateTimeCalendar();
839 DisForm_InitDateTimeEdit(); 490 DisForm_InitDateTimeEdit();
840 RegisterEventTarget(m_pMonthCal.get()); 491 RegisterEventTarget(m_pMonthCal.get());
841 RegisterEventTarget(m_pEdit.get()); 492 RegisterEventTarget(m_pEdit.get());
842 return FWL_Error::Succeeded; 493 return FWL_Error::Succeeded;
843 } 494 }
844 void CFWL_DateTimePickerImp::DisForm_InitDateTimeCalendar() { 495
496 void IFWL_DateTimePicker::DisForm_InitDateTimeCalendar() {
845 if (m_pMonthCal) { 497 if (m_pMonthCal) {
846 return; 498 return;
847 } 499 }
848 CFWL_WidgetImpProperties propMonth; 500 CFWL_WidgetImpProperties propMonth;
849 propMonth.m_dwStyles = 501 propMonth.m_dwStyles =
850 FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken; 502 FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken;
851 propMonth.m_dwStates = FWL_WGTSTATE_Invisible; 503 propMonth.m_dwStates = FWL_WGTSTATE_Invisible;
852 propMonth.m_pParent = m_pInterface; 504 propMonth.m_pParent = this;
853 propMonth.m_pDataProvider = &m_MonthCalendarDP; 505 propMonth.m_pDataProvider = &m_MonthCalendarDP;
854 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; 506 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider;
855 m_pMonthCal.reset(IFWL_DateTimeCalender::Create(propMonth, m_pInterface)); 507 m_pMonthCal.reset(IFWL_DateTimeCalendar::Create(propMonth, this));
856 m_pMonthCal->Initialize(); 508 m_pMonthCal->Initialize();
857 CFX_RectF rtMonthCal; 509 CFX_RectF rtMonthCal;
858 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); 510 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
859 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); 511 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height);
860 m_pMonthCal->SetWidgetRect(rtMonthCal); 512 m_pMonthCal->SetWidgetRect(rtMonthCal);
861 } 513 }
862 void CFWL_DateTimePickerImp::DisForm_InitDateTimeEdit() { 514
515 void IFWL_DateTimePicker::DisForm_InitDateTimeEdit() {
863 if (m_pEdit) { 516 if (m_pEdit) {
864 return; 517 return;
865 } 518 }
866 CFWL_WidgetImpProperties propEdit; 519 CFWL_WidgetImpProperties propEdit;
867 propEdit.m_pParent = m_pInterface; 520 propEdit.m_pParent = this;
868 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; 521 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider;
869 m_pEdit.reset(IFWL_DateTimeEdit::Create(propEdit, m_pInterface)); 522 m_pEdit.reset(IFWL_DateTimeEdit::Create(propEdit, this));
870 m_pEdit->Initialize(); 523 m_pEdit->Initialize();
871 } 524 }
872 FX_BOOL CFWL_DateTimePickerImp::DisForm_IsMonthCalendarShowed() { 525
526 FX_BOOL IFWL_DateTimePicker::DisForm_IsMonthCalendarShowed() {
873 if (!m_pMonthCal) 527 if (!m_pMonthCal)
874 return FALSE; 528 return FALSE;
875 return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible); 529 return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible);
876 } 530 }
877 void CFWL_DateTimePickerImp::DisForm_ShowMonthCalendar(FX_BOOL bActivate) { 531
532 void IFWL_DateTimePicker::DisForm_ShowMonthCalendar(FX_BOOL bActivate) {
878 FX_BOOL bShowed = IsMonthCalendarShowed(); 533 FX_BOOL bShowed = IsMonthCalendarShowed();
879 if (bShowed == bActivate) { 534 if (bShowed == bActivate) {
880 return; 535 return;
881 } 536 }
882 if (bActivate) { 537 if (bActivate) {
883 CFX_RectF rtMonthCal; 538 CFX_RectF rtMonthCal;
884 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); 539 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
885 FX_FLOAT fPopupMin = rtMonthCal.height; 540 FX_FLOAT fPopupMin = rtMonthCal.height;
886 FX_FLOAT fPopupMax = rtMonthCal.height; 541 FX_FLOAT fPopupMax = rtMonthCal.height;
887 CFX_RectF rtAnchor(m_pProperties->m_rtWidget); 542 CFX_RectF rtAnchor(m_pProperties->m_rtWidget);
(...skipping 16 matching lines...) Expand all
904 pDelegate->OnProcessMessage(&msg); 559 pDelegate->OnProcessMessage(&msg);
905 } 560 }
906 CFX_RectF rtInvalidate, rtCal; 561 CFX_RectF rtInvalidate, rtCal;
907 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, 562 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width,
908 m_pProperties->m_rtWidget.height); 563 m_pProperties->m_rtWidget.height);
909 m_pMonthCal->GetWidgetRect(rtCal); 564 m_pMonthCal->GetWidgetRect(rtCal);
910 rtInvalidate.Union(rtCal); 565 rtInvalidate.Union(rtCal);
911 rtInvalidate.Inflate(2, 2); 566 rtInvalidate.Inflate(2, 2);
912 Repaint(&rtInvalidate); 567 Repaint(&rtInvalidate);
913 } 568 }
914 FWL_WidgetHit CFWL_DateTimePickerImp::DisForm_HitTest(FX_FLOAT fx, 569
915 FX_FLOAT fy) { 570 FWL_WidgetHit IFWL_DateTimePicker::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) {
916 CFX_RectF rect; 571 CFX_RectF rect;
917 rect.Set(0, 0, m_pProperties->m_rtWidget.width, 572 rect.Set(0, 0, m_pProperties->m_rtWidget.width,
918 m_pProperties->m_rtWidget.height); 573 m_pProperties->m_rtWidget.height);
919 if (rect.Contains(fx, fy)) 574 if (rect.Contains(fx, fy))
920 return FWL_WidgetHit::Edit; 575 return FWL_WidgetHit::Edit;
921 if (DisForm_IsNeedShowButton()) 576 if (DisForm_IsNeedShowButton())
922 rect.width += m_fBtn; 577 rect.width += m_fBtn;
923 if (rect.Contains(fx, fy)) 578 if (rect.Contains(fx, fy))
924 return FWL_WidgetHit::Client; 579 return FWL_WidgetHit::Client;
925 if (IsMonthCalendarShowed()) { 580 if (IsMonthCalendarShowed()) {
926 m_pMonthCal->GetWidgetRect(rect); 581 m_pMonthCal->GetWidgetRect(rect);
927 if (rect.Contains(fx, fy)) 582 if (rect.Contains(fx, fy))
928 return FWL_WidgetHit::Client; 583 return FWL_WidgetHit::Client;
929 } 584 }
930 return FWL_WidgetHit::Unknown; 585 return FWL_WidgetHit::Unknown;
931 } 586 }
932 FX_BOOL CFWL_DateTimePickerImp::DisForm_IsNeedShowButton() { 587
588 FX_BOOL IFWL_DateTimePicker::DisForm_IsNeedShowButton() {
933 FX_BOOL bFocus = m_pProperties->m_dwStates & FWL_WGTSTATE_Focused || 589 FX_BOOL bFocus = m_pProperties->m_dwStates & FWL_WGTSTATE_Focused ||
934 m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused || 590 m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused ||
935 m_pEdit->GetStates() & FWL_WGTSTATE_Focused; 591 m_pEdit->GetStates() & FWL_WGTSTATE_Focused;
936 return bFocus; 592 return bFocus;
937 } 593 }
938 594
939 FWL_Error CFWL_DateTimePickerImp::DisForm_Update() { 595 FWL_Error IFWL_DateTimePicker::DisForm_Update() {
940 if (m_iLock) 596 if (m_iLock)
941 return FWL_Error::Indefinite; 597 return FWL_Error::Indefinite;
942 if (!m_pProperties->m_pThemeProvider) 598 if (!m_pProperties->m_pThemeProvider)
943 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 599 m_pProperties->m_pThemeProvider = GetAvailableTheme();
944 600
945 m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider); 601 m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider);
946 GetClientRect(m_rtClient); 602 GetClientRect(m_rtClient);
947 m_pEdit->SetWidgetRect(m_rtClient); 603 m_pEdit->SetWidgetRect(m_rtClient);
948 ReSetEditAlignment(); 604 ReSetEditAlignment();
949 m_pEdit->Update(); 605 m_pEdit->Update();
950 if (!m_pMonthCal->GetThemeProvider()) 606 if (!m_pMonthCal->GetThemeProvider())
951 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider); 607 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider);
952 608
953 if (m_pProperties->m_pDataProvider) { 609 if (m_pProperties->m_pDataProvider) {
954 IFWL_DateTimePickerDP* pData = 610 IFWL_DateTimePickerDP* pData =
955 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider); 611 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider);
956 pData->GetToday(m_pInterface, m_MonthCalendarDP.m_iCurYear, 612 pData->GetToday(this, m_MonthCalendarDP.m_iCurYear,
957 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay); 613 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay);
958 } 614 }
959 FX_FLOAT* pWidth = static_cast<FX_FLOAT*>( 615 FX_FLOAT* pWidth = static_cast<FX_FLOAT*>(
960 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 616 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
961 if (!pWidth) 617 if (!pWidth)
962 return FWL_Error::Succeeded; 618 return FWL_Error::Succeeded;
963 619
964 m_fBtn = *pWidth; 620 m_fBtn = *pWidth;
965 CFX_RectF rtMonthCal; 621 CFX_RectF rtMonthCal;
966 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); 622 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
967 CFX_RectF rtPopUp; 623 CFX_RectF rtPopUp;
968 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, 624 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight,
969 rtMonthCal.width, rtMonthCal.height); 625 rtMonthCal.width, rtMonthCal.height);
970 m_pMonthCal->SetWidgetRect(rtPopUp); 626 m_pMonthCal->SetWidgetRect(rtPopUp);
971 m_pMonthCal->Update(); 627 m_pMonthCal->Update();
972 return FWL_Error::Succeeded; 628 return FWL_Error::Succeeded;
973 } 629 }
974 630
975 FWL_Error CFWL_DateTimePickerImp::DisForm_GetWidgetRect(CFX_RectF& rect, 631 FWL_Error IFWL_DateTimePicker::DisForm_GetWidgetRect(CFX_RectF& rect,
976 FX_BOOL bAutoSize) { 632 FX_BOOL bAutoSize) {
977 rect = m_pProperties->m_rtWidget; 633 rect = m_pProperties->m_rtWidget;
978 if (DisForm_IsNeedShowButton()) { 634 if (DisForm_IsNeedShowButton()) {
979 rect.width += m_fBtn; 635 rect.width += m_fBtn;
980 } 636 }
981 return FWL_Error::Succeeded; 637 return FWL_Error::Succeeded;
982 } 638 }
983 FWL_Error CFWL_DateTimePickerImp::DisForm_GetBBox(CFX_RectF& rect) { 639
640 FWL_Error IFWL_DateTimePicker::DisForm_GetBBox(CFX_RectF& rect) {
984 rect = m_pProperties->m_rtWidget; 641 rect = m_pProperties->m_rtWidget;
985 if (DisForm_IsNeedShowButton()) { 642 if (DisForm_IsNeedShowButton()) {
986 rect.width += m_fBtn; 643 rect.width += m_fBtn;
987 } 644 }
988 if (IsMonthCalendarShowed()) { 645 if (IsMonthCalendarShowed()) {
989 CFX_RectF rtMonth; 646 CFX_RectF rtMonth;
990 m_pMonthCal->GetWidgetRect(rtMonth); 647 m_pMonthCal->GetWidgetRect(rtMonth);
991 rtMonth.Offset(m_pProperties->m_rtWidget.left, 648 rtMonth.Offset(m_pProperties->m_rtWidget.left,
992 m_pProperties->m_rtWidget.top); 649 m_pProperties->m_rtWidget.top);
993 rect.Union(rtMonth); 650 rect.Union(rtMonth);
994 } 651 }
995 return FWL_Error::Succeeded; 652 return FWL_Error::Succeeded;
996 } 653 }
997 FWL_Error CFWL_DateTimePickerImp::DisForm_DrawWidget( 654
998 CFX_Graphics* pGraphics, 655 FWL_Error IFWL_DateTimePicker::DisForm_DrawWidget(CFX_Graphics* pGraphics,
999 const CFX_Matrix* pMatrix) { 656 const CFX_Matrix* pMatrix) {
1000 if (!pGraphics) 657 if (!pGraphics)
1001 return FWL_Error::Indefinite; 658 return FWL_Error::Indefinite;
1002 if (m_pEdit) { 659 if (m_pEdit) {
1003 CFX_RectF rtEdit; 660 CFX_RectF rtEdit;
1004 m_pEdit->GetWidgetRect(rtEdit); 661 m_pEdit->GetWidgetRect(rtEdit);
1005 CFX_Matrix mt; 662 CFX_Matrix mt;
1006 mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top); 663 mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top);
1007 if (pMatrix) { 664 if (pMatrix) {
1008 mt.Concat(*pMatrix); 665 mt.Concat(*pMatrix);
1009 } 666 }
1010 m_pEdit->DrawWidget(pGraphics, &mt); 667 m_pEdit->DrawWidget(pGraphics, &mt);
1011 } 668 }
1012 if (IsMonthCalendarShowed()) { 669 if (IsMonthCalendarShowed()) {
1013 CFX_RectF rtMonth; 670 CFX_RectF rtMonth;
1014 m_pMonthCal->GetWidgetRect(rtMonth); 671 m_pMonthCal->GetWidgetRect(rtMonth);
1015 CFX_Matrix mt; 672 CFX_Matrix mt;
1016 mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top); 673 mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top);
1017 if (pMatrix) { 674 if (pMatrix) {
1018 mt.Concat(*pMatrix); 675 mt.Concat(*pMatrix);
1019 } 676 }
1020 m_pMonthCal->DrawWidget(pGraphics, &mt); 677 m_pMonthCal->DrawWidget(pGraphics, &mt);
1021 } 678 }
1022 return FWL_Error::Succeeded; 679 return FWL_Error::Succeeded;
1023 } 680 }
1024 681
1025 CFWL_DateTimePickerImpDelegate::CFWL_DateTimePickerImpDelegate( 682 CFWL_DateTimePickerImpDelegate::CFWL_DateTimePickerImpDelegate(
1026 CFWL_DateTimePickerImp* pOwner) 683 IFWL_DateTimePicker* pOwner)
1027 : m_pOwner(pOwner) {} 684 : m_pOwner(pOwner) {}
1028 685
1029 void CFWL_DateTimePickerImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { 686 void CFWL_DateTimePickerImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
1030 if (!pMessage) 687 if (!pMessage)
1031 return; 688 return;
1032 689
1033 switch (pMessage->GetClassID()) { 690 switch (pMessage->GetClassID()) {
1034 case CFWL_MessageType::SetFocus: { 691 case CFWL_MessageType::SetFocus: {
1035 OnFocusChanged(pMessage, TRUE); 692 OnFocusChanged(pMessage, TRUE);
1036 break; 693 break;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 } else { 754 } else {
1098 m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); 755 m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
1099 m_pOwner->Repaint(&m_pOwner->m_rtClient); 756 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1100 } 757 }
1101 if (pMsg->m_pSrcTarget == m_pOwner->m_pMonthCal.get() && 758 if (pMsg->m_pSrcTarget == m_pOwner->m_pMonthCal.get() &&
1102 m_pOwner->IsMonthCalendarShowed()) { 759 m_pOwner->IsMonthCalendarShowed()) {
1103 m_pOwner->ShowMonthCalendar(FALSE); 760 m_pOwner->ShowMonthCalendar(FALSE);
1104 } 761 }
1105 m_pOwner->Repaint(&m_pOwner->m_rtClient); 762 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1106 } 763 }
764
1107 void CFWL_DateTimePickerImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { 765 void CFWL_DateTimePickerImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
1108 if (!pMsg) 766 if (!pMsg)
1109 return; 767 return;
1110 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { 768 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
1111 m_pOwner->SetFocus(TRUE); 769 m_pOwner->SetFocus(TRUE);
1112 } 770 }
1113 if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 771 if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
1114 if (m_pOwner->IsMonthCalendarShowed()) { 772 if (m_pOwner->IsMonthCalendarShowed()) {
1115 m_pOwner->ShowMonthCalendar(FALSE); 773 m_pOwner->ShowMonthCalendar(FALSE);
1116 CFWL_Event_DtpCloseUp ev; 774 CFWL_Event_DtpCloseUp ev;
1117 m_pOwner->DispatchEvent(&ev); 775 m_pOwner->DispatchEvent(&ev);
1118 } else { 776 } else {
1119 if (!(m_pOwner->m_pProperties->m_dwStyleExes & 777 if (!(m_pOwner->m_pProperties->m_dwStyleExes &
1120 FWL_STYLEEXT_DTP_TimeFormat)) { 778 FWL_STYLEEXT_DTP_TimeFormat)) {
1121 m_pOwner->ShowMonthCalendar(TRUE); 779 m_pOwner->ShowMonthCalendar(TRUE);
1122 CFWL_Event_DtpDropDown ev; 780 CFWL_Event_DtpDropDown ev;
1123 m_pOwner->DispatchEvent(&ev); 781 m_pOwner->DispatchEvent(&ev);
1124 } else { 782 } else {
1125 } 783 }
1126 m_pOwner->m_bLBtnDown = TRUE; 784 m_pOwner->m_bLBtnDown = TRUE;
1127 m_pOwner->Repaint(&m_pOwner->m_rtClient); 785 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1128 } 786 }
1129 } 787 }
1130 } 788 }
789
1131 void CFWL_DateTimePickerImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { 790 void CFWL_DateTimePickerImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
1132 if (!pMsg) 791 if (!pMsg)
1133 return; 792 return;
1134 m_pOwner->m_bLBtnDown = FALSE; 793 m_pOwner->m_bLBtnDown = FALSE;
1135 if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 794 if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
1136 m_pOwner->m_iBtnState = CFWL_PartState_Hovered; 795 m_pOwner->m_iBtnState = CFWL_PartState_Hovered;
1137 } else { 796 } else {
1138 m_pOwner->m_iBtnState = CFWL_PartState_Normal; 797 m_pOwner->m_iBtnState = CFWL_PartState_Normal;
1139 } 798 }
1140 m_pOwner->Repaint(&m_pOwner->m_rtBtn); 799 m_pOwner->Repaint(&m_pOwner->m_rtBtn);
1141 } 800 }
801
1142 void CFWL_DateTimePickerImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { 802 void CFWL_DateTimePickerImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
1143 if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 803 if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
1144 } else { 804 } else {
1145 m_pOwner->m_iBtnState = CFWL_PartState_Normal; 805 m_pOwner->m_iBtnState = CFWL_PartState_Normal;
1146 } 806 }
1147 m_pOwner->Repaint(&m_pOwner->m_rtBtn); 807 m_pOwner->Repaint(&m_pOwner->m_rtBtn);
1148 } 808 }
809
1149 void CFWL_DateTimePickerImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { 810 void CFWL_DateTimePickerImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
1150 if (!pMsg) 811 if (!pMsg)
1151 return; 812 return;
1152 m_pOwner->m_iBtnState = CFWL_PartState_Normal; 813 m_pOwner->m_iBtnState = CFWL_PartState_Normal;
1153 m_pOwner->Repaint(&m_pOwner->m_rtBtn); 814 m_pOwner->Repaint(&m_pOwner->m_rtBtn);
1154 } 815 }
816
1155 void CFWL_DateTimePickerImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg, 817 void CFWL_DateTimePickerImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg,
1156 FX_BOOL bSet) { 818 FX_BOOL bSet) {
1157 CFX_RectF rtInvalidate(m_pOwner->m_rtBtn); 819 CFX_RectF rtInvalidate(m_pOwner->m_rtBtn);
1158 if (bSet) { 820 if (bSet) {
1159 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 821 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
1160 if (m_pOwner->m_pEdit && 822 if (m_pOwner->m_pEdit &&
1161 !(m_pOwner->m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly)) { 823 !(m_pOwner->m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly)) {
1162 m_pOwner->m_rtBtn.Set(m_pOwner->m_pProperties->m_rtWidget.width, 0, 824 m_pOwner->m_rtBtn.Set(m_pOwner->m_pProperties->m_rtWidget.width, 0,
1163 m_pOwner->m_fBtn, 825 m_pOwner->m_fBtn,
1164 m_pOwner->m_pProperties->m_rtWidget.height - 1); 826 m_pOwner->m_pProperties->m_rtWidget.height - 1);
(...skipping 11 matching lines...) Expand all
1176 if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { 838 if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
1177 pMsg->m_pSrcTarget = m_pOwner->m_pEdit.get(); 839 pMsg->m_pSrcTarget = m_pOwner->m_pEdit.get();
1178 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(nullptr); 840 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(nullptr);
1179 pDelegate->OnProcessMessage(pMsg); 841 pDelegate->OnProcessMessage(pMsg);
1180 } 842 }
1181 } 843 }
1182 rtInvalidate.Inflate(2, 2); 844 rtInvalidate.Inflate(2, 2);
1183 m_pOwner->Repaint(&rtInvalidate); 845 m_pOwner->Repaint(&rtInvalidate);
1184 } 846 }
1185 847
1186 CFWL_DateTimePickerImp::CFWL_MonthCalendarImpDP::CFWL_MonthCalendarImpDP() { 848 IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::CFWL_MonthCalendarImpDP() {
1187 m_iCurYear = 2010; 849 m_iCurYear = 2010;
1188 m_iCurMonth = 3; 850 m_iCurMonth = 3;
1189 m_iCurDay = 29; 851 m_iCurDay = 29;
1190 } 852 }
1191 853
1192 FWL_Error CFWL_DateTimePickerImp::CFWL_MonthCalendarImpDP::GetCaption( 854 FWL_Error IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCaption(
1193 IFWL_Widget* pWidget, 855 IFWL_Widget* pWidget,
1194 CFX_WideString& wsCaption) { 856 CFX_WideString& wsCaption) {
1195 return FWL_Error::Succeeded; 857 return FWL_Error::Succeeded;
1196 } 858 }
1197 859
1198 int32_t CFWL_DateTimePickerImp::CFWL_MonthCalendarImpDP::GetCurDay( 860 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurDay(
1199 IFWL_Widget* pWidget) { 861 IFWL_Widget* pWidget) {
1200 return m_iCurDay; 862 return m_iCurDay;
1201 } 863 }
1202 864
1203 int32_t CFWL_DateTimePickerImp::CFWL_MonthCalendarImpDP::GetCurMonth( 865 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurMonth(
1204 IFWL_Widget* pWidget) { 866 IFWL_Widget* pWidget) {
1205 return m_iCurMonth; 867 return m_iCurMonth;
1206 } 868 }
1207 869
1208 int32_t CFWL_DateTimePickerImp::CFWL_MonthCalendarImpDP::GetCurYear( 870 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurYear(
1209 IFWL_Widget* pWidget) { 871 IFWL_Widget* pWidget) {
1210 return m_iCurYear; 872 return m_iCurYear;
1211 } 873 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_datetimepicker.h ('k') | xfa/fwl/core/ifwl_edit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698