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

Side by Side Diff: xfa/fwl/core/cfwl_pushbutton.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_pushbutton.h" 7 #include "xfa/fwl/core/cfwl_pushbutton.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/fde/tto/fde_textout.h" 13 #include "xfa/fde/tto/fde_textout.h"
14 #include "xfa/fwl/core/cfwl_evtclick.h" 14 #include "xfa/fwl/core/cfwl_event.h"
15 #include "xfa/fwl/core/cfwl_evtmouse.h" 15 #include "xfa/fwl/core/cfwl_evtmouse.h"
16 #include "xfa/fwl/core/cfwl_msgkey.h" 16 #include "xfa/fwl/core/cfwl_msgkey.h"
17 #include "xfa/fwl/core/cfwl_msgmouse.h" 17 #include "xfa/fwl/core/cfwl_msgmouse.h"
18 #include "xfa/fwl/core/cfwl_notedriver.h" 18 #include "xfa/fwl/core/cfwl_notedriver.h"
19 #include "xfa/fwl/core/cfwl_themebackground.h" 19 #include "xfa/fwl/core/cfwl_themebackground.h"
20 #include "xfa/fwl/core/cfwl_themetext.h" 20 #include "xfa/fwl/core/cfwl_themetext.h"
21 #include "xfa/fwl/core/ifwl_themeprovider.h" 21 #include "xfa/fwl/core/ifwl_themeprovider.h"
22 22
23 CFWL_PushButton::CFWL_PushButton(const CFWL_App* app) 23 CFWL_PushButton::CFWL_PushButton(const CFWL_App* app)
24 : CFWL_Widget(app, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr), 24 : CFWL_Widget(app, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr),
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) 167 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading)
168 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; 168 m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
169 } 169 }
170 170
171 void CFWL_PushButton::OnProcessMessage(CFWL_Message* pMessage) { 171 void CFWL_PushButton::OnProcessMessage(CFWL_Message* pMessage) {
172 if (!pMessage) 172 if (!pMessage)
173 return; 173 return;
174 if (!IsEnabled()) 174 if (!IsEnabled())
175 return; 175 return;
176 176
177 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); 177 switch (pMessage->GetType()) {
178 switch (dwMsgCode) { 178 case CFWL_Message::Type::SetFocus:
179 case CFWL_MessageType::SetFocus:
180 OnFocusChanged(pMessage, true); 179 OnFocusChanged(pMessage, true);
181 break; 180 break;
182 case CFWL_MessageType::KillFocus: 181 case CFWL_Message::Type::KillFocus:
183 OnFocusChanged(pMessage, false); 182 OnFocusChanged(pMessage, false);
184 break; 183 break;
185 case CFWL_MessageType::Mouse: { 184 case CFWL_Message::Type::Mouse: {
186 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 185 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
187 switch (pMsg->m_dwCmd) { 186 switch (pMsg->m_dwCmd) {
188 case FWL_MouseCommand::LeftButtonDown: 187 case FWL_MouseCommand::LeftButtonDown:
189 OnLButtonDown(pMsg); 188 OnLButtonDown(pMsg);
190 break; 189 break;
191 case FWL_MouseCommand::LeftButtonUp: 190 case FWL_MouseCommand::LeftButtonUp:
192 OnLButtonUp(pMsg); 191 OnLButtonUp(pMsg);
193 break; 192 break;
194 case FWL_MouseCommand::Move: 193 case FWL_MouseCommand::Move:
195 OnMouseMove(pMsg); 194 OnMouseMove(pMsg);
196 break; 195 break;
197 case FWL_MouseCommand::Leave: 196 case FWL_MouseCommand::Leave:
198 OnMouseLeave(pMsg); 197 OnMouseLeave(pMsg);
199 break; 198 break;
200 default: 199 default:
201 break; 200 break;
202 } 201 }
203 break; 202 break;
204 } 203 }
205 case CFWL_MessageType::Key: { 204 case CFWL_Message::Type::Key: {
206 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); 205 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage);
207 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) 206 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown)
208 OnKeyDown(pKey); 207 OnKeyDown(pKey);
209 break; 208 break;
210 } 209 }
211 default: 210 default:
212 break; 211 break;
213 } 212 }
214 CFWL_Widget::OnProcessMessage(pMessage); 213 CFWL_Widget::OnProcessMessage(pMessage);
215 } 214 }
(...skipping 25 matching lines...) Expand all
241 void CFWL_PushButton::OnLButtonUp(CFWL_MsgMouse* pMsg) { 240 void CFWL_PushButton::OnLButtonUp(CFWL_MsgMouse* pMsg) {
242 m_bBtnDown = false; 241 m_bBtnDown = false;
243 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { 242 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
244 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; 243 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
245 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; 244 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
246 } else { 245 } else {
247 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; 246 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
248 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; 247 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
249 } 248 }
250 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { 249 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
251 CFWL_EvtClick wmClick; 250 CFWL_Event wmClick(CFWL_Event::Type::Click, this);
252 wmClick.m_pSrcTarget = this;
253 DispatchEvent(&wmClick); 251 DispatchEvent(&wmClick);
254 } 252 }
255 Repaint(&m_rtClient); 253 Repaint(&m_rtClient);
256 } 254 }
257 255
258 void CFWL_PushButton::OnMouseMove(CFWL_MsgMouse* pMsg) { 256 void CFWL_PushButton::OnMouseMove(CFWL_MsgMouse* pMsg) {
259 bool bRepaint = false; 257 bool bRepaint = false;
260 if (m_bBtnDown) { 258 if (m_bBtnDown) {
261 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { 259 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
262 if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) == 0) { 260 if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) == 0) {
(...skipping 27 matching lines...) Expand all
290 } 288 }
291 289
292 void CFWL_PushButton::OnMouseLeave(CFWL_MsgMouse* pMsg) { 290 void CFWL_PushButton::OnMouseLeave(CFWL_MsgMouse* pMsg) {
293 m_bBtnDown = false; 291 m_bBtnDown = false;
294 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; 292 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
295 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; 293 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
296 Repaint(&m_rtClient); 294 Repaint(&m_rtClient);
297 } 295 }
298 296
299 void CFWL_PushButton::OnKeyDown(CFWL_MsgKey* pMsg) { 297 void CFWL_PushButton::OnKeyDown(CFWL_MsgKey* pMsg) {
300 if (pMsg->m_dwKeyCode == FWL_VKEY_Return) { 298 if (pMsg->m_dwKeyCode != FWL_VKEY_Return)
301 CFWL_EvtMouse wmMouse;
302 wmMouse.m_pSrcTarget = this;
303 wmMouse.m_dwCmd = FWL_MouseCommand::LeftButtonUp;
304 DispatchEvent(&wmMouse);
305 CFWL_EvtClick wmClick;
306 wmClick.m_pSrcTarget = this;
307 DispatchEvent(&wmClick);
308 return;
309 }
310 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab)
311 return; 299 return;
312 300
313 DispatchKeyEvent(pMsg); 301 CFWL_EvtMouse wmMouse(this);
302 wmMouse.m_dwCmd = FWL_MouseCommand::LeftButtonUp;
303 DispatchEvent(&wmMouse);
304
305 CFWL_Event wmClick(CFWL_Event::Type::Click, this);
306 DispatchEvent(&wmClick);
314 } 307 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698