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

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

Issue 2491443003: Fold IFWL_DateTimeCalendar into IFWL_MonthCalendar (Closed)
Patch Set: Rebase to master 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_datetimecalendar.h ('k') | xfa/fwl/core/ifwl_datetimepicker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "xfa/fwl/core/ifwl_datetimecalendar.h"
8
9 #include "third_party/base/ptr_util.h"
10 #include "xfa/fwl/core/cfwl_widgetmgr.h"
11 #include "xfa/fwl/core/ifwl_datetimepicker.h"
12 #include "xfa/fwl/core/ifwl_formproxy.h"
13
14 IFWL_DateTimeCalendar::IFWL_DateTimeCalendar(
15 const IFWL_App* app,
16 std::unique_ptr<CFWL_WidgetProperties> properties,
17 IFWL_Widget* pOuter)
18 : IFWL_MonthCalendar(app, std::move(properties), pOuter), m_bFlag(false) {}
19
20 void IFWL_DateTimeCalendar::OnProcessMessage(CFWL_Message* pMessage) {
21 CFWL_MessageType dwCode = pMessage->GetClassID();
22 if (dwCode == CFWL_MessageType::SetFocus ||
23 dwCode == CFWL_MessageType::KillFocus) {
24 IFWL_Widget* pOuter = GetOuter();
25 pOuter->GetDelegate()->OnProcessMessage(pMessage);
26 return;
27 }
28 if (dwCode == CFWL_MessageType::Mouse) {
29 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
30 if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonDown)
31 OnLButtonDownEx(pMsg);
32 else if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonUp)
33 OnLButtonUpEx(pMsg);
34 return;
35 }
36 IFWL_MonthCalendar::OnProcessMessage(pMessage);
37 }
38
39 void IFWL_DateTimeCalendar::OnLButtonDownEx(CFWL_MsgMouse* pMsg) {
40 if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
41 m_iLBtnPartStates = CFWL_PartState_Pressed;
42 PrevMonth();
43 Repaint(&m_rtClient);
44 } else if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
45 m_iRBtnPartStates |= CFWL_PartState_Pressed;
46 NextMonth();
47 Repaint(&m_rtClient);
48 } else if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
49 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) == 0) {
50 JumpToToday();
51 Repaint(&m_rtClient);
52 }
53 } else {
54 IFWL_DateTimePicker* pIPicker = static_cast<IFWL_DateTimePicker*>(m_pOuter);
55 if (pIPicker->IsMonthCalendarShowed())
56 m_bFlag = 1;
57 }
58 }
59
60 void IFWL_DateTimeCalendar::OnLButtonUpEx(CFWL_MsgMouse* pMsg) {
61 if (m_pWidgetMgr->IsFormDisabled())
62 return DisForm_OnLButtonUpEx(pMsg);
63 if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
64 m_iLBtnPartStates = 0;
65 Repaint(&m_rtLBtn);
66 return;
67 }
68 if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
69 m_iRBtnPartStates = 0;
70 Repaint(&m_rtRBtn);
71 return;
72 }
73 if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy))
74 return;
75
76 int32_t iOldSel = 0;
77 if (m_arrSelDays.GetSize() > 0)
78 iOldSel = m_arrSelDays[0];
79
80 int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
81 CFX_RectF rt;
82 IFWL_DateTimePicker* pIPicker = static_cast<IFWL_DateTimePicker*>(m_pOuter);
83 pIPicker->GetFormProxy()->GetWidgetRect(rt);
84 rt.Set(0, 0, rt.width, rt.height);
85 if (iCurSel > 0) {
86 FWL_DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1);
87 CFX_RectF rtInvalidate(lpDatesInfo->rect);
88 if (iOldSel > 0 && iOldSel <= m_arrDates.GetSize()) {
89 lpDatesInfo = m_arrDates.GetAt(iOldSel - 1);
90 rtInvalidate.Union(lpDatesInfo->rect);
91 }
92 AddSelDay(iCurSel);
93 if (!m_pOuter)
94 return;
95
96 pIPicker->ProcessSelChanged(m_iCurYear, m_iCurMonth, iCurSel);
97 pIPicker->ShowMonthCalendar(false);
98 } else if (m_bFlag && (!rt.Contains(pMsg->m_fx, pMsg->m_fy))) {
99 pIPicker->ShowMonthCalendar(false);
100 }
101 m_bFlag = 0;
102 }
103
104 void IFWL_DateTimeCalendar::OnMouseMoveEx(CFWL_MsgMouse* pMsg) {
105 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect)
106 return;
107
108 bool bRepaint = false;
109 CFX_RectF rtInvalidate;
110 rtInvalidate.Set(0, 0, 0, 0);
111 if (m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
112 int32_t iHover = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
113 bRepaint = m_iHovered != iHover;
114 if (bRepaint) {
115 if (m_iHovered > 0)
116 GetDayRect(m_iHovered, rtInvalidate);
117 if (iHover > 0) {
118 CFX_RectF rtDay;
119 GetDayRect(iHover, rtDay);
120 if (rtInvalidate.IsEmpty())
121 rtInvalidate = rtDay;
122 else
123 rtInvalidate.Union(rtDay);
124 }
125 }
126 m_iHovered = iHover;
127 CFWL_Event_DtpHoverChanged ev;
128 ev.hoverday = iHover;
129 DispatchEvent(&ev);
130 } else {
131 bRepaint = m_iHovered > 0;
132 if (bRepaint)
133 GetDayRect(m_iHovered, rtInvalidate);
134
135 m_iHovered = -1;
136 }
137 if (bRepaint && !rtInvalidate.IsEmpty())
138 Repaint(&rtInvalidate);
139 }
140
141 void IFWL_DateTimeCalendar::DisForm_OnProcessMessage(CFWL_Message* pMessage) {
142 if (pMessage->GetClassID() == CFWL_MessageType::Mouse) {
143 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
144 if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonUp) {
145 DisForm_OnLButtonUpEx(pMsg);
146 return;
147 }
148 }
149 IFWL_MonthCalendar::OnProcessMessage(pMessage);
150 }
151
152 void IFWL_DateTimeCalendar::DisForm_OnLButtonUpEx(CFWL_MsgMouse* pMsg) {
153 if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
154 m_iLBtnPartStates = 0;
155 Repaint(&(m_rtLBtn));
156 return;
157 }
158 if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
159 m_iRBtnPartStates = 0;
160 Repaint(&(m_rtRBtn));
161 return;
162 }
163 if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy))
164 return;
165
166 int32_t iOldSel = 0;
167 if (m_arrSelDays.GetSize() > 0)
168 iOldSel = m_arrSelDays[0];
169
170 int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
171 if (iCurSel > 0) {
172 FWL_DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1);
173 CFX_RectF rtInvalidate(lpDatesInfo->rect);
174 if (iOldSel > 0 && iOldSel <= m_arrDates.GetSize()) {
175 lpDatesInfo = m_arrDates.GetAt(iOldSel - 1);
176 rtInvalidate.Union(lpDatesInfo->rect);
177 }
178 AddSelDay(iCurSel);
179 IFWL_DateTimePicker* pDateTime =
180 static_cast<IFWL_DateTimePicker*>(m_pOuter);
181 pDateTime->ProcessSelChanged(m_iCurYear, m_iCurMonth, iCurSel);
182 pDateTime->ShowMonthCalendar(false);
183 }
184 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_datetimecalendar.h ('k') | xfa/fwl/core/ifwl_datetimepicker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698