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

Side by Side Diff: xfa/fwl/cfwl_pushbutton.cpp

Issue 2559173002: Move xfa/fwl/core to xfa/fwl. (Closed)
Patch Set: 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
« no previous file with comments | « xfa/fwl/cfwl_pushbutton.h ('k') | xfa/fwl/cfwl_scrollbar.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/cfwl_pushbutton.h" 7 #include "xfa/fwl/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_event.h" 14 #include "xfa/fwl/cfwl_event.h"
15 #include "xfa/fwl/core/cfwl_evtmouse.h" 15 #include "xfa/fwl/cfwl_eventmouse.h"
16 #include "xfa/fwl/core/cfwl_msgkey.h" 16 #include "xfa/fwl/cfwl_messagekey.h"
17 #include "xfa/fwl/core/cfwl_msgmouse.h" 17 #include "xfa/fwl/cfwl_messagemouse.h"
18 #include "xfa/fwl/core/cfwl_notedriver.h" 18 #include "xfa/fwl/cfwl_notedriver.h"
19 #include "xfa/fwl/core/cfwl_themebackground.h" 19 #include "xfa/fwl/cfwl_themebackground.h"
20 #include "xfa/fwl/core/cfwl_themetext.h" 20 #include "xfa/fwl/cfwl_themetext.h"
21 #include "xfa/fwl/core/ifwl_themeprovider.h" 21 #include "xfa/fwl/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),
25 m_bBtnDown(false), 25 m_bBtnDown(false),
26 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), 26 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
27 m_iTTOAlign(FDE_TTOALIGNMENT_Center) { 27 m_iTTOAlign(FDE_TTOALIGNMENT_Center) {
28 m_rtClient.Set(0, 0, 0, 0); 28 m_rtClient.Set(0, 0, 0, 0);
29 m_rtCaption.Set(0, 0, 0, 0); 29 m_rtCaption.Set(0, 0, 0, 0);
30 } 30 }
31 31
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 return; 159 return;
160 160
161 switch (pMessage->GetType()) { 161 switch (pMessage->GetType()) {
162 case CFWL_Message::Type::SetFocus: 162 case CFWL_Message::Type::SetFocus:
163 OnFocusChanged(pMessage, true); 163 OnFocusChanged(pMessage, true);
164 break; 164 break;
165 case CFWL_Message::Type::KillFocus: 165 case CFWL_Message::Type::KillFocus:
166 OnFocusChanged(pMessage, false); 166 OnFocusChanged(pMessage, false);
167 break; 167 break;
168 case CFWL_Message::Type::Mouse: { 168 case CFWL_Message::Type::Mouse: {
169 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 169 CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage);
170 switch (pMsg->m_dwCmd) { 170 switch (pMsg->m_dwCmd) {
171 case FWL_MouseCommand::LeftButtonDown: 171 case FWL_MouseCommand::LeftButtonDown:
172 OnLButtonDown(pMsg); 172 OnLButtonDown(pMsg);
173 break; 173 break;
174 case FWL_MouseCommand::LeftButtonUp: 174 case FWL_MouseCommand::LeftButtonUp:
175 OnLButtonUp(pMsg); 175 OnLButtonUp(pMsg);
176 break; 176 break;
177 case FWL_MouseCommand::Move: 177 case FWL_MouseCommand::Move:
178 OnMouseMove(pMsg); 178 OnMouseMove(pMsg);
179 break; 179 break;
180 case FWL_MouseCommand::Leave: 180 case FWL_MouseCommand::Leave:
181 OnMouseLeave(pMsg); 181 OnMouseLeave(pMsg);
182 break; 182 break;
183 default: 183 default:
184 break; 184 break;
185 } 185 }
186 break; 186 break;
187 } 187 }
188 case CFWL_Message::Type::Key: { 188 case CFWL_Message::Type::Key: {
189 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); 189 CFWL_MessageKey* pKey = static_cast<CFWL_MessageKey*>(pMessage);
190 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) 190 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown)
191 OnKeyDown(pKey); 191 OnKeyDown(pKey);
192 break; 192 break;
193 } 193 }
194 default: 194 default:
195 break; 195 break;
196 } 196 }
197 CFWL_Widget::OnProcessMessage(pMessage); 197 CFWL_Widget::OnProcessMessage(pMessage);
198 } 198 }
199 199
200 void CFWL_PushButton::OnDrawWidget(CFX_Graphics* pGraphics, 200 void CFWL_PushButton::OnDrawWidget(CFX_Graphics* pGraphics,
201 const CFX_Matrix* pMatrix) { 201 const CFX_Matrix* pMatrix) {
202 DrawWidget(pGraphics, pMatrix); 202 DrawWidget(pGraphics, pMatrix);
203 } 203 }
204 204
205 void CFWL_PushButton::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { 205 void CFWL_PushButton::OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
206 if (bSet) 206 if (bSet)
207 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 207 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
208 else 208 else
209 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; 209 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
210 210
211 Repaint(&m_rtClient); 211 Repaint(&m_rtClient);
212 } 212 }
213 213
214 void CFWL_PushButton::OnLButtonDown(CFWL_MsgMouse* pMsg) { 214 void CFWL_PushButton::OnLButtonDown(CFWL_MessageMouse* pMsg) {
215 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) 215 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
216 SetFocus(true); 216 SetFocus(true);
217 217
218 m_bBtnDown = true; 218 m_bBtnDown = true;
219 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; 219 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
220 m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed; 220 m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed;
221 Repaint(&m_rtClient); 221 Repaint(&m_rtClient);
222 } 222 }
223 223
224 void CFWL_PushButton::OnLButtonUp(CFWL_MsgMouse* pMsg) { 224 void CFWL_PushButton::OnLButtonUp(CFWL_MessageMouse* pMsg) {
225 m_bBtnDown = false; 225 m_bBtnDown = false;
226 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { 226 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
227 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; 227 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
228 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; 228 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
229 } else { 229 } else {
230 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; 230 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
231 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; 231 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
232 } 232 }
233 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { 233 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
234 CFWL_Event wmClick(CFWL_Event::Type::Click, this); 234 CFWL_Event wmClick(CFWL_Event::Type::Click, this);
235 DispatchEvent(&wmClick); 235 DispatchEvent(&wmClick);
236 } 236 }
237 Repaint(&m_rtClient); 237 Repaint(&m_rtClient);
238 } 238 }
239 239
240 void CFWL_PushButton::OnMouseMove(CFWL_MsgMouse* pMsg) { 240 void CFWL_PushButton::OnMouseMove(CFWL_MessageMouse* pMsg) {
241 bool bRepaint = false; 241 bool bRepaint = false;
242 if (m_bBtnDown) { 242 if (m_bBtnDown) {
243 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { 243 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
244 if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) == 0) { 244 if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) == 0) {
245 m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed; 245 m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed;
246 bRepaint = true; 246 bRepaint = true;
247 } 247 }
248 if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) { 248 if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) {
249 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; 249 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
250 bRepaint = true; 250 bRepaint = true;
(...skipping 13 matching lines...) Expand all
264 return; 264 return;
265 if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) { 265 if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) {
266 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; 266 m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
267 bRepaint = true; 267 bRepaint = true;
268 } 268 }
269 } 269 }
270 if (bRepaint) 270 if (bRepaint)
271 Repaint(&m_rtClient); 271 Repaint(&m_rtClient);
272 } 272 }
273 273
274 void CFWL_PushButton::OnMouseLeave(CFWL_MsgMouse* pMsg) { 274 void CFWL_PushButton::OnMouseLeave(CFWL_MessageMouse* pMsg) {
275 m_bBtnDown = false; 275 m_bBtnDown = false;
276 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; 276 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
277 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; 277 m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
278 Repaint(&m_rtClient); 278 Repaint(&m_rtClient);
279 } 279 }
280 280
281 void CFWL_PushButton::OnKeyDown(CFWL_MsgKey* pMsg) { 281 void CFWL_PushButton::OnKeyDown(CFWL_MessageKey* pMsg) {
282 if (pMsg->m_dwKeyCode != FWL_VKEY_Return) 282 if (pMsg->m_dwKeyCode != FWL_VKEY_Return)
283 return; 283 return;
284 284
285 CFWL_EvtMouse wmMouse(this); 285 CFWL_EventMouse wmMouse(this);
286 wmMouse.m_dwCmd = FWL_MouseCommand::LeftButtonUp; 286 wmMouse.m_dwCmd = FWL_MouseCommand::LeftButtonUp;
287 DispatchEvent(&wmMouse); 287 DispatchEvent(&wmMouse);
288 288
289 CFWL_Event wmClick(CFWL_Event::Type::Click, this); 289 CFWL_Event wmClick(CFWL_Event::Type::Click, this);
290 DispatchEvent(&wmClick); 290 DispatchEvent(&wmClick);
291 } 291 }
OLDNEW
« no previous file with comments | « xfa/fwl/cfwl_pushbutton.h ('k') | xfa/fwl/cfwl_scrollbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698