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

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

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: Created 4 years, 1 month 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/core/ifwl_datetimepicker.h" 7 #include "xfa/fwl/core/ifwl_datetimepicker.h"
8 8
9 #include "third_party/base/ptr_util.h" 9 #include "third_party/base/ptr_util.h"
10 #include "xfa/fwl/core/cfwl_message.h" 10 #include "xfa/fwl/core/cfwl_message.h"
(...skipping 14 matching lines...) Expand all
25 } // namespace 25 } // namespace
26 26
27 IFWL_DateTimePicker::IFWL_DateTimePicker( 27 IFWL_DateTimePicker::IFWL_DateTimePicker(
28 const IFWL_App* app, 28 const IFWL_App* app,
29 const CFWL_WidgetImpProperties& properties) 29 const CFWL_WidgetImpProperties& properties)
30 : IFWL_Widget(app, properties, nullptr), 30 : IFWL_Widget(app, properties, nullptr),
31 m_iBtnState(1), 31 m_iBtnState(1),
32 m_iYear(-1), 32 m_iYear(-1),
33 m_iMonth(-1), 33 m_iMonth(-1),
34 m_iDay(-1), 34 m_iDay(-1),
35 m_bLBtnDown(FALSE) { 35 m_bLBtnDown(false) {
36 m_rtBtn.Set(0, 0, 0, 0); 36 m_rtBtn.Set(0, 0, 0, 0);
37 37
38 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; 38 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat;
39 CFWL_WidgetImpProperties propMonth; 39 CFWL_WidgetImpProperties propMonth;
40 propMonth.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border; 40 propMonth.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border;
41 propMonth.m_dwStates = FWL_WGTSTATE_Invisible; 41 propMonth.m_dwStates = FWL_WGTSTATE_Invisible;
42 propMonth.m_pDataProvider = &m_MonthCalendarDP; 42 propMonth.m_pDataProvider = &m_MonthCalendarDP;
43 propMonth.m_pParent = this; 43 propMonth.m_pParent = this;
44 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; 44 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider;
45 45
46 m_pMonthCal.reset(new IFWL_DateTimeCalendar(m_pOwnerApp, propMonth, this)); 46 m_pMonthCal.reset(new IFWL_DateTimeCalendar(m_pOwnerApp, propMonth, this));
47 CFX_RectF rtMonthCal; 47 CFX_RectF rtMonthCal;
48 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); 48 m_pMonthCal->GetWidgetRect(rtMonthCal, true);
49 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); 49 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height);
50 m_pMonthCal->SetWidgetRect(rtMonthCal); 50 m_pMonthCal->SetWidgetRect(rtMonthCal);
51 CFWL_WidgetImpProperties propEdit; 51 CFWL_WidgetImpProperties propEdit;
52 propEdit.m_pParent = this; 52 propEdit.m_pParent = this;
53 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; 53 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider;
54 54
55 m_pEdit.reset(new IFWL_DateTimeEdit(m_pOwnerApp, propEdit, this)); 55 m_pEdit.reset(new IFWL_DateTimeEdit(m_pOwnerApp, propEdit, this));
56 RegisterEventTarget(m_pMonthCal.get()); 56 RegisterEventTarget(m_pMonthCal.get());
57 RegisterEventTarget(m_pEdit.get()); 57 RegisterEventTarget(m_pEdit.get());
58 } 58 }
59 59
60 IFWL_DateTimePicker::~IFWL_DateTimePicker() { 60 IFWL_DateTimePicker::~IFWL_DateTimePicker() {
61 UnregisterEventTarget(); 61 UnregisterEventTarget();
62 } 62 }
63 63
64 FWL_Type IFWL_DateTimePicker::GetClassID() const { 64 FWL_Type IFWL_DateTimePicker::GetClassID() const {
65 return FWL_Type::DateTimePicker; 65 return FWL_Type::DateTimePicker;
66 } 66 }
67 67
68 FWL_Error IFWL_DateTimePicker::GetWidgetRect(CFX_RectF& rect, 68 FWL_Error IFWL_DateTimePicker::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
69 FX_BOOL bAutoSize) {
70 if (m_pWidgetMgr->IsFormDisabled()) { 69 if (m_pWidgetMgr->IsFormDisabled()) {
71 return DisForm_GetWidgetRect(rect, bAutoSize); 70 return DisForm_GetWidgetRect(rect, bAutoSize);
72 } 71 }
73 if (bAutoSize) { 72 if (bAutoSize) {
74 rect.Set(0, 0, kDateTimePickerWidth, kDateTimePickerHeight); 73 rect.Set(0, 0, kDateTimePickerWidth, kDateTimePickerHeight);
75 IFWL_Widget::GetWidgetRect(rect, TRUE); 74 IFWL_Widget::GetWidgetRect(rect, true);
76 } else { 75 } else {
77 rect = m_pProperties->m_rtWidget; 76 rect = m_pProperties->m_rtWidget;
78 } 77 }
79 return FWL_Error::Succeeded; 78 return FWL_Error::Succeeded;
80 } 79 }
81 80
82 FWL_Error IFWL_DateTimePicker::Update() { 81 FWL_Error IFWL_DateTimePicker::Update() {
83 if (m_pWidgetMgr->IsFormDisabled()) { 82 if (m_pWidgetMgr->IsFormDisabled()) {
84 return DisForm_Update(); 83 return DisForm_Update();
85 } 84 }
(...skipping 21 matching lines...) Expand all
107 if (!(m_pMonthCal->GetThemeProvider())) { 106 if (!(m_pMonthCal->GetThemeProvider())) {
108 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider); 107 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider);
109 } 108 }
110 if (m_pProperties->m_pDataProvider) { 109 if (m_pProperties->m_pDataProvider) {
111 IFWL_DateTimePickerDP* pData = 110 IFWL_DateTimePickerDP* pData =
112 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider); 111 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider);
113 pData->GetToday(this, m_MonthCalendarDP.m_iCurYear, 112 pData->GetToday(this, m_MonthCalendarDP.m_iCurYear,
114 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay); 113 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay);
115 } 114 }
116 CFX_RectF rtMonthCal; 115 CFX_RectF rtMonthCal;
117 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); 116 m_pMonthCal->GetWidgetRect(rtMonthCal, true);
118 CFX_RectF rtPopUp; 117 CFX_RectF rtPopUp;
119 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, 118 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight,
120 rtMonthCal.width, rtMonthCal.height); 119 rtMonthCal.width, rtMonthCal.height);
121 m_pMonthCal->SetWidgetRect(rtPopUp); 120 m_pMonthCal->SetWidgetRect(rtPopUp);
122 m_pMonthCal->Update(); 121 m_pMonthCal->Update();
123 return FWL_Error::Succeeded; 122 return FWL_Error::Succeeded;
124 } 123 }
125 124
126 int32_t IFWL_DateTimePicker::CountSelRanges() { 125 int32_t IFWL_DateTimePicker::CountSelRanges() {
127 return GetDataTimeEdit()->CountSelRanges(); 126 return GetDataTimeEdit()->CountSelRanges();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 211
213 FWL_Error IFWL_DateTimePicker::GetEditText(CFX_WideString& wsText, 212 FWL_Error IFWL_DateTimePicker::GetEditText(CFX_WideString& wsText,
214 int32_t nStart, 213 int32_t nStart,
215 int32_t nCount) const { 214 int32_t nCount) const {
216 if (m_pEdit) { 215 if (m_pEdit) {
217 return m_pEdit->GetText(wsText, nStart, nCount); 216 return m_pEdit->GetText(wsText, nStart, nCount);
218 } 217 }
219 return FWL_Error::Indefinite; 218 return FWL_Error::Indefinite;
220 } 219 }
221 220
222 FX_BOOL IFWL_DateTimePicker::CanUndo() { 221 bool IFWL_DateTimePicker::CanUndo() {
223 return m_pEdit->CanUndo(); 222 return m_pEdit->CanUndo();
224 } 223 }
225 224
226 FX_BOOL IFWL_DateTimePicker::CanRedo() { 225 bool IFWL_DateTimePicker::CanRedo() {
227 return m_pEdit->CanRedo(); 226 return m_pEdit->CanRedo();
228 } 227 }
229 228
230 FX_BOOL IFWL_DateTimePicker::Undo() { 229 bool IFWL_DateTimePicker::Undo() {
231 return m_pEdit->Undo(); 230 return m_pEdit->Undo();
232 } 231 }
233 232
234 FX_BOOL IFWL_DateTimePicker::Redo() { 233 bool IFWL_DateTimePicker::Redo() {
235 return m_pEdit->Redo(); 234 return m_pEdit->Redo();
236 } 235 }
237 236
238 FX_BOOL IFWL_DateTimePicker::CanCopy() { 237 bool IFWL_DateTimePicker::CanCopy() {
239 int32_t nCount = m_pEdit->CountSelRanges(); 238 int32_t nCount = m_pEdit->CountSelRanges();
240 return nCount > 0; 239 return nCount > 0;
241 } 240 }
242 241
243 FX_BOOL IFWL_DateTimePicker::CanCut() { 242 bool IFWL_DateTimePicker::CanCut() {
244 if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) { 243 if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) {
245 return FALSE; 244 return false;
246 } 245 }
247 int32_t nCount = m_pEdit->CountSelRanges(); 246 int32_t nCount = m_pEdit->CountSelRanges();
248 return nCount > 0; 247 return nCount > 0;
249 } 248 }
250 249
251 FX_BOOL IFWL_DateTimePicker::CanSelectAll() { 250 bool IFWL_DateTimePicker::CanSelectAll() {
252 return m_pEdit->GetTextLength() > 0; 251 return m_pEdit->GetTextLength() > 0;
253 } 252 }
254 253
255 FX_BOOL IFWL_DateTimePicker::Copy(CFX_WideString& wsCopy) { 254 bool IFWL_DateTimePicker::Copy(CFX_WideString& wsCopy) {
256 return m_pEdit->Copy(wsCopy); 255 return m_pEdit->Copy(wsCopy);
257 } 256 }
258 257
259 FX_BOOL IFWL_DateTimePicker::Cut(CFX_WideString& wsCut) { 258 bool IFWL_DateTimePicker::Cut(CFX_WideString& wsCut) {
260 return m_pEdit->Cut(wsCut); 259 return m_pEdit->Cut(wsCut);
261 } 260 }
262 261
263 FX_BOOL IFWL_DateTimePicker::Paste(const CFX_WideString& wsPaste) { 262 bool IFWL_DateTimePicker::Paste(const CFX_WideString& wsPaste) {
264 return m_pEdit->Paste(wsPaste); 263 return m_pEdit->Paste(wsPaste);
265 } 264 }
266 265
267 FX_BOOL IFWL_DateTimePicker::SelectAll() { 266 bool IFWL_DateTimePicker::SelectAll() {
268 return m_pEdit->AddSelRange(0) == FWL_Error::Succeeded; 267 return m_pEdit->AddSelRange(0) == FWL_Error::Succeeded;
269 } 268 }
270 269
271 FX_BOOL IFWL_DateTimePicker::Delete() { 270 bool IFWL_DateTimePicker::Delete() {
272 return m_pEdit->ClearText() == FWL_Error::Succeeded; 271 return m_pEdit->ClearText() == FWL_Error::Succeeded;
273 } 272 }
274 273
275 FX_BOOL IFWL_DateTimePicker::DeSelect() { 274 bool IFWL_DateTimePicker::DeSelect() {
276 return m_pEdit->ClearSelections() == FWL_Error::Succeeded; 275 return m_pEdit->ClearSelections() == FWL_Error::Succeeded;
277 } 276 }
278 277
279 FWL_Error IFWL_DateTimePicker::GetBBox(CFX_RectF& rect) { 278 FWL_Error IFWL_DateTimePicker::GetBBox(CFX_RectF& rect) {
280 if (m_pWidgetMgr->IsFormDisabled()) { 279 if (m_pWidgetMgr->IsFormDisabled()) {
281 return DisForm_GetBBox(rect); 280 return DisForm_GetBBox(rect);
282 } 281 }
283 rect = m_pProperties->m_rtWidget; 282 rect = m_pProperties->m_rtWidget;
284 if (IsMonthCalendarShowed()) { 283 if (IsMonthCalendarShowed()) {
285 CFX_RectF rtMonth; 284 CFX_RectF rtMonth;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 FWL_STYLEEXT_DTP_ShortDateFormat) { 327 FWL_STYLEEXT_DTP_ShortDateFormat) {
329 wsText.Format(L"%d-%d-%d", iYear, iMonth, iDay); 328 wsText.Format(L"%d-%d-%d", iYear, iMonth, iDay);
330 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_LongDateFormat) == 329 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_LongDateFormat) ==
331 FWL_STYLEEXT_DTP_LongDateFormat) { 330 FWL_STYLEEXT_DTP_LongDateFormat) {
332 wsText.Format(L"%d Year %d Month %d Day", iYear, iMonth, iDay); 331 wsText.Format(L"%d Year %d Month %d Day", iYear, iMonth, iDay);
333 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat) == 332 } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat) ==
334 FWL_STYLEEXT_DTP_TimeFormat) { 333 FWL_STYLEEXT_DTP_TimeFormat) {
335 } 334 }
336 } 335 }
337 336
338 void IFWL_DateTimePicker::ShowMonthCalendar(FX_BOOL bActivate) { 337 void IFWL_DateTimePicker::ShowMonthCalendar(bool bActivate) {
339 if (m_pWidgetMgr->IsFormDisabled()) { 338 if (m_pWidgetMgr->IsFormDisabled()) {
340 return DisForm_ShowMonthCalendar(bActivate); 339 return DisForm_ShowMonthCalendar(bActivate);
341 } 340 }
342 if (IsMonthCalendarShowed() == bActivate) { 341 if (IsMonthCalendarShowed() == bActivate) {
343 return; 342 return;
344 } 343 }
345 if (!m_pForm) { 344 if (!m_pForm) {
346 InitProxyForm(); 345 InitProxyForm();
347 } 346 }
348 if (bActivate) { 347 if (bActivate) {
349 CFX_RectF rtMonth; 348 CFX_RectF rtMonth;
350 m_pMonthCal->GetWidgetRect(rtMonth); 349 m_pMonthCal->GetWidgetRect(rtMonth);
351 CFX_RectF rtAnchor; 350 CFX_RectF rtAnchor;
352 rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, 351 rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width,
353 m_pProperties->m_rtWidget.height); 352 m_pProperties->m_rtWidget.height);
354 GetPopupPos(0, rtMonth.height, rtAnchor, rtMonth); 353 GetPopupPos(0, rtMonth.height, rtAnchor, rtMonth);
355 m_pForm->SetWidgetRect(rtMonth); 354 m_pForm->SetWidgetRect(rtMonth);
356 rtMonth.left = rtMonth.top = 0; 355 rtMonth.left = rtMonth.top = 0;
357 m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate); 356 m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate);
358 m_pMonthCal->SetWidgetRect(rtMonth); 357 m_pMonthCal->SetWidgetRect(rtMonth);
359 m_pMonthCal->Update(); 358 m_pMonthCal->Update();
360 m_pForm->DoModal(); 359 m_pForm->DoModal();
361 } else { 360 } else {
362 m_pForm->EndDoModal(); 361 m_pForm->EndDoModal();
363 } 362 }
364 } 363 }
365 364
366 FX_BOOL IFWL_DateTimePicker::IsMonthCalendarShowed() { 365 bool IFWL_DateTimePicker::IsMonthCalendarShowed() {
367 if (m_pWidgetMgr->IsFormDisabled()) { 366 if (m_pWidgetMgr->IsFormDisabled()) {
368 return DisForm_IsMonthCalendarShowed(); 367 return DisForm_IsMonthCalendarShowed();
369 } 368 }
370 if (!m_pForm) 369 if (!m_pForm)
371 return FALSE; 370 return false;
372 return !(m_pForm->GetStates() & FWL_WGTSTATE_Invisible); 371 return !(m_pForm->GetStates() & FWL_WGTSTATE_Invisible);
373 } 372 }
374 373
375 void IFWL_DateTimePicker::ReSetEditAlignment() { 374 void IFWL_DateTimePicker::ReSetEditAlignment() {
376 if (!m_pEdit) 375 if (!m_pEdit)
377 return; 376 return;
378 uint32_t dwStylExes = m_pProperties->m_dwStyleExes; 377 uint32_t dwStylExes = m_pProperties->m_dwStyleExes;
379 uint32_t dwAdd = 0; 378 uint32_t dwAdd = 0;
380 switch (dwStylExes & FWL_STYLEEXT_DTP_EditHAlignMask) { 379 switch (dwStylExes & FWL_STYLEEXT_DTP_EditHAlignMask) {
381 case FWL_STYLEEXT_DTP_EditHCenter: { 380 case FWL_STYLEEXT_DTP_EditHCenter: {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 CFWL_WidgetImpProperties propMonth; 462 CFWL_WidgetImpProperties propMonth;
464 propMonth.m_dwStyles = 463 propMonth.m_dwStyles =
465 FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken; 464 FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken;
466 propMonth.m_dwStates = FWL_WGTSTATE_Invisible; 465 propMonth.m_dwStates = FWL_WGTSTATE_Invisible;
467 propMonth.m_pParent = this; 466 propMonth.m_pParent = this;
468 propMonth.m_pDataProvider = &m_MonthCalendarDP; 467 propMonth.m_pDataProvider = &m_MonthCalendarDP;
469 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; 468 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider;
470 469
471 m_pMonthCal.reset(new IFWL_DateTimeCalendar(m_pOwnerApp, propMonth, this)); 470 m_pMonthCal.reset(new IFWL_DateTimeCalendar(m_pOwnerApp, propMonth, this));
472 CFX_RectF rtMonthCal; 471 CFX_RectF rtMonthCal;
473 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); 472 m_pMonthCal->GetWidgetRect(rtMonthCal, true);
474 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); 473 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height);
475 m_pMonthCal->SetWidgetRect(rtMonthCal); 474 m_pMonthCal->SetWidgetRect(rtMonthCal);
476 } 475 }
477 476
478 void IFWL_DateTimePicker::DisForm_InitDateTimeEdit() { 477 void IFWL_DateTimePicker::DisForm_InitDateTimeEdit() {
479 if (m_pEdit) { 478 if (m_pEdit) {
480 return; 479 return;
481 } 480 }
482 CFWL_WidgetImpProperties propEdit; 481 CFWL_WidgetImpProperties propEdit;
483 propEdit.m_pParent = this; 482 propEdit.m_pParent = this;
484 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; 483 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider;
485 484
486 m_pEdit.reset(new IFWL_DateTimeEdit(m_pOwnerApp, propEdit, this)); 485 m_pEdit.reset(new IFWL_DateTimeEdit(m_pOwnerApp, propEdit, this));
487 } 486 }
488 487
489 FX_BOOL IFWL_DateTimePicker::DisForm_IsMonthCalendarShowed() { 488 bool IFWL_DateTimePicker::DisForm_IsMonthCalendarShowed() {
490 if (!m_pMonthCal) 489 if (!m_pMonthCal)
491 return FALSE; 490 return false;
492 return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible); 491 return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible);
493 } 492 }
494 493
495 void IFWL_DateTimePicker::DisForm_ShowMonthCalendar(FX_BOOL bActivate) { 494 void IFWL_DateTimePicker::DisForm_ShowMonthCalendar(bool bActivate) {
496 FX_BOOL bShowed = IsMonthCalendarShowed(); 495 bool bShowed = IsMonthCalendarShowed();
497 if (bShowed == bActivate) { 496 if (bShowed == bActivate) {
498 return; 497 return;
499 } 498 }
500 if (bActivate) { 499 if (bActivate) {
501 CFX_RectF rtMonthCal; 500 CFX_RectF rtMonthCal;
502 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); 501 m_pMonthCal->GetWidgetRect(rtMonthCal, true);
503 FX_FLOAT fPopupMin = rtMonthCal.height; 502 FX_FLOAT fPopupMin = rtMonthCal.height;
504 FX_FLOAT fPopupMax = rtMonthCal.height; 503 FX_FLOAT fPopupMax = rtMonthCal.height;
505 CFX_RectF rtAnchor(m_pProperties->m_rtWidget); 504 CFX_RectF rtAnchor(m_pProperties->m_rtWidget);
506 rtAnchor.width = rtMonthCal.width; 505 rtAnchor.width = rtMonthCal.width;
507 rtMonthCal.left = m_rtClient.left; 506 rtMonthCal.left = m_rtClient.left;
508 rtMonthCal.top = rtAnchor.Height(); 507 rtMonthCal.top = rtAnchor.Height();
509 GetPopupPos(fPopupMin, fPopupMax, rtAnchor, rtMonthCal); 508 GetPopupPos(fPopupMin, fPopupMax, rtAnchor, rtMonthCal);
510 m_pMonthCal->SetWidgetRect(rtMonthCal); 509 m_pMonthCal->SetWidgetRect(rtMonthCal);
511 if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0) { 510 if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0) {
512 m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay); 511 m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay);
(...skipping 27 matching lines...) Expand all
540 if (rect.Contains(fx, fy)) 539 if (rect.Contains(fx, fy))
541 return FWL_WidgetHit::Client; 540 return FWL_WidgetHit::Client;
542 if (IsMonthCalendarShowed()) { 541 if (IsMonthCalendarShowed()) {
543 m_pMonthCal->GetWidgetRect(rect); 542 m_pMonthCal->GetWidgetRect(rect);
544 if (rect.Contains(fx, fy)) 543 if (rect.Contains(fx, fy))
545 return FWL_WidgetHit::Client; 544 return FWL_WidgetHit::Client;
546 } 545 }
547 return FWL_WidgetHit::Unknown; 546 return FWL_WidgetHit::Unknown;
548 } 547 }
549 548
550 FX_BOOL IFWL_DateTimePicker::DisForm_IsNeedShowButton() { 549 bool IFWL_DateTimePicker::DisForm_IsNeedShowButton() {
551 FX_BOOL bFocus = m_pProperties->m_dwStates & FWL_WGTSTATE_Focused || 550 bool bFocus = m_pProperties->m_dwStates & FWL_WGTSTATE_Focused ||
552 m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused || 551 m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused ||
553 m_pEdit->GetStates() & FWL_WGTSTATE_Focused; 552 m_pEdit->GetStates() & FWL_WGTSTATE_Focused;
554 return bFocus; 553 return bFocus;
555 } 554 }
556 555
557 FWL_Error IFWL_DateTimePicker::DisForm_Update() { 556 FWL_Error IFWL_DateTimePicker::DisForm_Update() {
558 if (m_iLock) 557 if (m_iLock)
559 return FWL_Error::Indefinite; 558 return FWL_Error::Indefinite;
560 if (!m_pProperties->m_pThemeProvider) 559 if (!m_pProperties->m_pThemeProvider)
561 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 560 m_pProperties->m_pThemeProvider = GetAvailableTheme();
562 561
563 m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider); 562 m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider);
(...skipping 10 matching lines...) Expand all
574 pData->GetToday(this, m_MonthCalendarDP.m_iCurYear, 573 pData->GetToday(this, m_MonthCalendarDP.m_iCurYear,
575 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay); 574 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay);
576 } 575 }
577 FX_FLOAT* pWidth = static_cast<FX_FLOAT*>( 576 FX_FLOAT* pWidth = static_cast<FX_FLOAT*>(
578 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 577 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
579 if (!pWidth) 578 if (!pWidth)
580 return FWL_Error::Succeeded; 579 return FWL_Error::Succeeded;
581 580
582 m_fBtn = *pWidth; 581 m_fBtn = *pWidth;
583 CFX_RectF rtMonthCal; 582 CFX_RectF rtMonthCal;
584 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); 583 m_pMonthCal->GetWidgetRect(rtMonthCal, true);
585 CFX_RectF rtPopUp; 584 CFX_RectF rtPopUp;
586 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, 585 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight,
587 rtMonthCal.width, rtMonthCal.height); 586 rtMonthCal.width, rtMonthCal.height);
588 m_pMonthCal->SetWidgetRect(rtPopUp); 587 m_pMonthCal->SetWidgetRect(rtPopUp);
589 m_pMonthCal->Update(); 588 m_pMonthCal->Update();
590 return FWL_Error::Succeeded; 589 return FWL_Error::Succeeded;
591 } 590 }
592 591
593 FWL_Error IFWL_DateTimePicker::DisForm_GetWidgetRect(CFX_RectF& rect, 592 FWL_Error IFWL_DateTimePicker::DisForm_GetWidgetRect(CFX_RectF& rect,
594 FX_BOOL bAutoSize) { 593 bool bAutoSize) {
595 rect = m_pProperties->m_rtWidget; 594 rect = m_pProperties->m_rtWidget;
596 if (DisForm_IsNeedShowButton()) { 595 if (DisForm_IsNeedShowButton()) {
597 rect.width += m_fBtn; 596 rect.width += m_fBtn;
598 } 597 }
599 return FWL_Error::Succeeded; 598 return FWL_Error::Succeeded;
600 } 599 }
601 600
602 FWL_Error IFWL_DateTimePicker::DisForm_GetBBox(CFX_RectF& rect) { 601 FWL_Error IFWL_DateTimePicker::DisForm_GetBBox(CFX_RectF& rect) {
603 rect = m_pProperties->m_rtWidget; 602 rect = m_pProperties->m_rtWidget;
604 if (DisForm_IsNeedShowButton()) { 603 if (DisForm_IsNeedShowButton()) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 } 639 }
641 return FWL_Error::Succeeded; 640 return FWL_Error::Succeeded;
642 } 641 }
643 642
644 void IFWL_DateTimePicker::OnProcessMessage(CFWL_Message* pMessage) { 643 void IFWL_DateTimePicker::OnProcessMessage(CFWL_Message* pMessage) {
645 if (!pMessage) 644 if (!pMessage)
646 return; 645 return;
647 646
648 switch (pMessage->GetClassID()) { 647 switch (pMessage->GetClassID()) {
649 case CFWL_MessageType::SetFocus: 648 case CFWL_MessageType::SetFocus:
650 OnFocusChanged(pMessage, TRUE); 649 OnFocusChanged(pMessage, true);
651 break; 650 break;
652 case CFWL_MessageType::KillFocus: 651 case CFWL_MessageType::KillFocus:
653 OnFocusChanged(pMessage, FALSE); 652 OnFocusChanged(pMessage, false);
654 break; 653 break;
655 case CFWL_MessageType::Mouse: { 654 case CFWL_MessageType::Mouse: {
656 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); 655 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage);
657 switch (pMouse->m_dwCmd) { 656 switch (pMouse->m_dwCmd) {
658 case FWL_MouseCommand::LeftButtonDown: 657 case FWL_MouseCommand::LeftButtonDown:
659 OnLButtonDown(pMouse); 658 OnLButtonDown(pMouse);
660 break; 659 break;
661 case FWL_MouseCommand::LeftButtonUp: 660 case FWL_MouseCommand::LeftButtonUp:
662 OnLButtonUp(pMouse); 661 OnLButtonUp(pMouse);
663 break; 662 break;
(...skipping 20 matching lines...) Expand all
684 } 683 }
685 684
686 IFWL_Widget::OnProcessMessage(pMessage); 685 IFWL_Widget::OnProcessMessage(pMessage);
687 } 686 }
688 687
689 void IFWL_DateTimePicker::OnDrawWidget(CFX_Graphics* pGraphics, 688 void IFWL_DateTimePicker::OnDrawWidget(CFX_Graphics* pGraphics,
690 const CFX_Matrix* pMatrix) { 689 const CFX_Matrix* pMatrix) {
691 DrawWidget(pGraphics, pMatrix); 690 DrawWidget(pGraphics, pMatrix);
692 } 691 }
693 692
694 void IFWL_DateTimePicker::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { 693 void IFWL_DateTimePicker::OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
695 if (!pMsg) 694 if (!pMsg)
696 return; 695 return;
697 if (m_pWidgetMgr->IsFormDisabled()) 696 if (m_pWidgetMgr->IsFormDisabled())
698 return DisForm_OnFocusChanged(pMsg, bSet); 697 return DisForm_OnFocusChanged(pMsg, bSet);
699 698
700 if (bSet) { 699 if (bSet) {
701 m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); 700 m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused);
702 Repaint(&m_rtClient); 701 Repaint(&m_rtClient);
703 } else { 702 } else {
704 m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); 703 m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
705 Repaint(&m_rtClient); 704 Repaint(&m_rtClient);
706 } 705 }
707 if (pMsg->m_pSrcTarget == m_pMonthCal.get() && IsMonthCalendarShowed()) { 706 if (pMsg->m_pSrcTarget == m_pMonthCal.get() && IsMonthCalendarShowed()) {
708 ShowMonthCalendar(FALSE); 707 ShowMonthCalendar(false);
709 } 708 }
710 Repaint(&m_rtClient); 709 Repaint(&m_rtClient);
711 } 710 }
712 711
713 void IFWL_DateTimePicker::OnLButtonDown(CFWL_MsgMouse* pMsg) { 712 void IFWL_DateTimePicker::OnLButtonDown(CFWL_MsgMouse* pMsg) {
714 if (!pMsg) 713 if (!pMsg)
715 return; 714 return;
716 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) 715 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
717 SetFocus(TRUE); 716 SetFocus(true);
718 if (m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 717 if (m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
719 if (IsMonthCalendarShowed()) { 718 if (IsMonthCalendarShowed()) {
720 ShowMonthCalendar(FALSE); 719 ShowMonthCalendar(false);
721 CFWL_Event_DtpCloseUp ev; 720 CFWL_Event_DtpCloseUp ev;
722 DispatchEvent(&ev); 721 DispatchEvent(&ev);
723 } else { 722 } else {
724 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat)) { 723 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat)) {
725 ShowMonthCalendar(TRUE); 724 ShowMonthCalendar(true);
726 CFWL_Event_DtpDropDown ev; 725 CFWL_Event_DtpDropDown ev;
727 DispatchEvent(&ev); 726 DispatchEvent(&ev);
728 } 727 }
729 m_bLBtnDown = TRUE; 728 m_bLBtnDown = true;
730 Repaint(&m_rtClient); 729 Repaint(&m_rtClient);
731 } 730 }
732 } 731 }
733 } 732 }
734 733
735 void IFWL_DateTimePicker::OnLButtonUp(CFWL_MsgMouse* pMsg) { 734 void IFWL_DateTimePicker::OnLButtonUp(CFWL_MsgMouse* pMsg) {
736 if (!pMsg) 735 if (!pMsg)
737 return; 736 return;
738 737
739 m_bLBtnDown = FALSE; 738 m_bLBtnDown = false;
740 if (m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) 739 if (m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy))
741 m_iBtnState = CFWL_PartState_Hovered; 740 m_iBtnState = CFWL_PartState_Hovered;
742 else 741 else
743 m_iBtnState = CFWL_PartState_Normal; 742 m_iBtnState = CFWL_PartState_Normal;
744 Repaint(&m_rtBtn); 743 Repaint(&m_rtBtn);
745 } 744 }
746 745
747 void IFWL_DateTimePicker::OnMouseMove(CFWL_MsgMouse* pMsg) { 746 void IFWL_DateTimePicker::OnMouseMove(CFWL_MsgMouse* pMsg) {
748 if (!m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) 747 if (!m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy))
749 m_iBtnState = CFWL_PartState_Normal; 748 m_iBtnState = CFWL_PartState_Normal;
750 749
751 Repaint(&m_rtBtn); 750 Repaint(&m_rtBtn);
752 } 751 }
753 752
754 void IFWL_DateTimePicker::OnMouseLeave(CFWL_MsgMouse* pMsg) { 753 void IFWL_DateTimePicker::OnMouseLeave(CFWL_MsgMouse* pMsg) {
755 if (!pMsg) 754 if (!pMsg)
756 return; 755 return;
757 m_iBtnState = CFWL_PartState_Normal; 756 m_iBtnState = CFWL_PartState_Normal;
758 Repaint(&m_rtBtn); 757 Repaint(&m_rtBtn);
759 } 758 }
760 759
761 void IFWL_DateTimePicker::DisForm_OnFocusChanged(CFWL_Message* pMsg, 760 void IFWL_DateTimePicker::DisForm_OnFocusChanged(CFWL_Message* pMsg,
762 FX_BOOL bSet) { 761 bool bSet) {
763 CFX_RectF rtInvalidate(m_rtBtn); 762 CFX_RectF rtInvalidate(m_rtBtn);
764 if (bSet) { 763 if (bSet) {
765 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 764 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
766 if (m_pEdit && !(m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly)) { 765 if (m_pEdit && !(m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly)) {
767 m_rtBtn.Set(m_pProperties->m_rtWidget.width, 0, m_fBtn, 766 m_rtBtn.Set(m_pProperties->m_rtWidget.width, 0, m_fBtn,
768 m_pProperties->m_rtWidget.height - 1); 767 m_pProperties->m_rtWidget.height - 1);
769 } 768 }
770 rtInvalidate = m_rtBtn; 769 rtInvalidate = m_rtBtn;
771 pMsg->m_pDstTarget = m_pEdit.get(); 770 pMsg->m_pDstTarget = m_pEdit.get();
772 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); 771 m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
773 } else { 772 } else {
774 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; 773 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
775 m_rtBtn.Set(0, 0, 0, 0); 774 m_rtBtn.Set(0, 0, 0, 0);
776 if (DisForm_IsMonthCalendarShowed()) 775 if (DisForm_IsMonthCalendarShowed())
777 ShowMonthCalendar(FALSE); 776 ShowMonthCalendar(false);
778 if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { 777 if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
779 pMsg->m_pSrcTarget = m_pEdit.get(); 778 pMsg->m_pSrcTarget = m_pEdit.get();
780 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); 779 m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
781 } 780 }
782 } 781 }
783 rtInvalidate.Inflate(2, 2); 782 rtInvalidate.Inflate(2, 2);
784 Repaint(&rtInvalidate); 783 Repaint(&rtInvalidate);
785 } 784 }
786 785
787 IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::CFWL_MonthCalendarImpDP() { 786 IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::CFWL_MonthCalendarImpDP() {
(...skipping 15 matching lines...) Expand all
803 802
804 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurMonth( 803 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurMonth(
805 IFWL_Widget* pWidget) { 804 IFWL_Widget* pWidget) {
806 return m_iCurMonth; 805 return m_iCurMonth;
807 } 806 }
808 807
809 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurYear( 808 int32_t IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::GetCurYear(
810 IFWL_Widget* pWidget) { 809 IFWL_Widget* pWidget) {
811 return m_iCurYear; 810 return m_iCurYear;
812 } 811 }
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