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

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

Issue 2530993002: Cleanup FWL Event and Message code. (Closed)
Patch Set: Review feedback Created 4 years 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
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/cfwl_spinbutton.h" 7 #include "xfa/fwl/core/cfwl_spinbutton.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "third_party/base/ptr_util.h" 12 #include "third_party/base/ptr_util.h"
13 #include "xfa/fwl/core/cfwl_evtclick.h" 13 #include "xfa/fwl/core/cfwl_event.h"
14 #include "xfa/fwl/core/cfwl_msgkey.h" 14 #include "xfa/fwl/core/cfwl_msgkey.h"
15 #include "xfa/fwl/core/cfwl_msgmouse.h" 15 #include "xfa/fwl/core/cfwl_msgmouse.h"
16 #include "xfa/fwl/core/cfwl_notedriver.h" 16 #include "xfa/fwl/core/cfwl_notedriver.h"
17 #include "xfa/fwl/core/cfwl_themebackground.h" 17 #include "xfa/fwl/core/cfwl_themebackground.h"
18 #include "xfa/fwl/core/cfwl_timerinfo.h" 18 #include "xfa/fwl/core/cfwl_timerinfo.h"
19 #include "xfa/fwl/core/cfwl_widgetproperties.h" 19 #include "xfa/fwl/core/cfwl_widgetproperties.h"
20 #include "xfa/fwl/core/ifwl_themeprovider.h" 20 #include "xfa/fwl/core/ifwl_themeprovider.h"
21 21
22 namespace { 22 namespace {
23 23
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 params.m_matrix.Concat(*pMatrix); 154 params.m_matrix.Concat(*pMatrix);
155 155
156 params.m_rtPart = m_rtDnButton; 156 params.m_rtPart = m_rtDnButton;
157 pTheme->DrawBackground(&params); 157 pTheme->DrawBackground(&params);
158 } 158 }
159 159
160 void CFWL_SpinButton::OnProcessMessage(CFWL_Message* pMessage) { 160 void CFWL_SpinButton::OnProcessMessage(CFWL_Message* pMessage) {
161 if (!pMessage) 161 if (!pMessage)
162 return; 162 return;
163 163
164 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); 164 switch (pMessage->GetType()) {
165 switch (dwMsgCode) { 165 case CFWL_Message::Type::SetFocus: {
166 case CFWL_MessageType::SetFocus: {
167 OnFocusChanged(pMessage, true); 166 OnFocusChanged(pMessage, true);
168 break; 167 break;
169 } 168 }
170 case CFWL_MessageType::KillFocus: { 169 case CFWL_Message::Type::KillFocus: {
171 OnFocusChanged(pMessage, false); 170 OnFocusChanged(pMessage, false);
172 break; 171 break;
173 } 172 }
174 case CFWL_MessageType::Mouse: { 173 case CFWL_Message::Type::Mouse: {
175 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 174 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
176 switch (pMsg->m_dwCmd) { 175 switch (pMsg->m_dwCmd) {
177 case FWL_MouseCommand::LeftButtonDown: 176 case FWL_MouseCommand::LeftButtonDown:
178 OnLButtonDown(pMsg); 177 OnLButtonDown(pMsg);
179 break; 178 break;
180 case FWL_MouseCommand::LeftButtonUp: 179 case FWL_MouseCommand::LeftButtonUp:
181 OnLButtonUp(pMsg); 180 OnLButtonUp(pMsg);
182 break; 181 break;
183 case FWL_MouseCommand::Move: 182 case FWL_MouseCommand::Move:
184 OnMouseMove(pMsg); 183 OnMouseMove(pMsg);
185 break; 184 break;
186 case FWL_MouseCommand::Leave: 185 case FWL_MouseCommand::Leave:
187 OnMouseLeave(pMsg); 186 OnMouseLeave(pMsg);
188 break; 187 break;
189 default: 188 default:
190 break; 189 break;
191 } 190 }
192 break; 191 break;
193 } 192 }
194 case CFWL_MessageType::Key: { 193 case CFWL_Message::Type::Key: {
195 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); 194 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage);
196 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) 195 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown)
197 OnKeyDown(pKey); 196 OnKeyDown(pKey);
198 break; 197 break;
199 } 198 }
200 default: 199 default:
201 break; 200 break;
202 } 201 }
203 CFWL_Widget::OnProcessMessage(pMessage); 202 CFWL_Widget::OnProcessMessage(pMessage);
204 } 203 }
(...skipping 25 matching lines...) Expand all
230 return; 229 return;
231 if (bUpPress) { 230 if (bUpPress) {
232 m_iButtonIndex = 0; 231 m_iButtonIndex = 0;
233 m_dwUpState = CFWL_PartState_Pressed; 232 m_dwUpState = CFWL_PartState_Pressed;
234 } 233 }
235 if (bDnPress) { 234 if (bDnPress) {
236 m_iButtonIndex = 1; 235 m_iButtonIndex = 1;
237 m_dwDnState = CFWL_PartState_Pressed; 236 m_dwDnState = CFWL_PartState_Pressed;
238 } 237 }
239 238
240 CFWL_EvtClick wmPosChanged; 239 CFWL_Event wmPosChanged(CFWL_Event::Type::Click, this);
241 wmPosChanged.m_pSrcTarget = this;
242 DispatchEvent(&wmPosChanged); 240 DispatchEvent(&wmPosChanged);
243 241
244 Repaint(bUpPress ? &m_rtUpButton : &m_rtDnButton); 242 Repaint(bUpPress ? &m_rtUpButton : &m_rtDnButton);
245 m_pTimerInfo = m_Timer.StartTimer(kElapseTime, true); 243 m_pTimerInfo = m_Timer.StartTimer(kElapseTime, true);
246 } 244 }
247 245
248 void CFWL_SpinButton::OnLButtonUp(CFWL_MsgMouse* pMsg) { 246 void CFWL_SpinButton::OnLButtonUp(CFWL_MsgMouse* pMsg) {
249 if (m_pProperties->m_dwStates & CFWL_PartState_Disabled) 247 if (m_pProperties->m_dwStates & CFWL_PartState_Disabled)
250 return; 248 return;
251 249
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 bool bDown = 350 bool bDown =
353 pMsg->m_dwKeyCode == FWL_VKEY_Down || pMsg->m_dwKeyCode == FWL_VKEY_Right; 351 pMsg->m_dwKeyCode == FWL_VKEY_Down || pMsg->m_dwKeyCode == FWL_VKEY_Right;
354 if (!bUp && !bDown) 352 if (!bUp && !bDown)
355 return; 353 return;
356 354
357 bool bUpEnable = IsButtonEnabled(true); 355 bool bUpEnable = IsButtonEnabled(true);
358 bool bDownEnable = IsButtonEnabled(false); 356 bool bDownEnable = IsButtonEnabled(false);
359 if (!bUpEnable && !bDownEnable) 357 if (!bUpEnable && !bDownEnable)
360 return; 358 return;
361 359
362 CFWL_EvtClick wmPosChanged; 360 CFWL_Event wmPosChanged(CFWL_Event::Type::Click, this);
363 wmPosChanged.m_pSrcTarget = this;
364 DispatchEvent(&wmPosChanged); 361 DispatchEvent(&wmPosChanged);
365 362
366 Repaint(bUpEnable ? &m_rtUpButton : &m_rtDnButton); 363 Repaint(bUpEnable ? &m_rtUpButton : &m_rtDnButton);
367 } 364 }
368 365
369 CFWL_SpinButton::Timer::Timer(CFWL_SpinButton* pToolTip) 366 CFWL_SpinButton::Timer::Timer(CFWL_SpinButton* pToolTip)
370 : CFWL_Timer(pToolTip) {} 367 : CFWL_Timer(pToolTip) {}
371 368
372 void CFWL_SpinButton::Timer::Run(CFWL_TimerInfo* pTimerInfo) { 369 void CFWL_SpinButton::Timer::Run(CFWL_TimerInfo* pTimerInfo) {
373 CFWL_SpinButton* pButton = static_cast<CFWL_SpinButton*>(m_pWidget); 370 CFWL_SpinButton* pButton = static_cast<CFWL_SpinButton*>(m_pWidget);
374 371
375 if (!pButton->m_pTimerInfo) 372 if (!pButton->m_pTimerInfo)
376 return; 373 return;
377 374
378 CFWL_EvtClick wmPosChanged; 375 CFWL_Event wmPosChanged(CFWL_Event::Type::Click, pButton);
379 wmPosChanged.m_pSrcTarget = pButton;
380 pButton->DispatchEvent(&wmPosChanged); 376 pButton->DispatchEvent(&wmPosChanged);
381 } 377 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698