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

Side by Side Diff: xfa/src/fwl/basewidget/fwl_pushbuttonimp.cpp

Issue 1803723002: Move xfa/src up to xfa/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months 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/src/fwl/basewidget/fwl_pushbuttonimp.h ('k') | xfa/src/fwl/basewidget/fwl_scrollbarimp.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/src/fwl/basewidget/fwl_pushbuttonimp.h"
8
9 #include "xfa/include/fwl/basewidget/fwl_pushbutton.h"
10 #include "xfa/src/fde/tto/fde_textout.h"
11 #include "xfa/src/fwl/core/fwl_noteimp.h"
12 #include "xfa/src/fwl/core/fwl_targetimp.h"
13 #include "xfa/src/fwl/core/fwl_widgetimp.h"
14
15 // static
16 IFWL_PushButton* IFWL_PushButton::Create(
17 const CFWL_WidgetImpProperties& properties,
18 IFWL_Widget* pOuter) {
19 IFWL_PushButton* pPushButton = new IFWL_PushButton;
20 CFWL_PushButtonImp* pPushButtonImpl =
21 new CFWL_PushButtonImp(properties, pOuter);
22 pPushButton->SetImpl(pPushButtonImpl);
23 pPushButtonImpl->SetInterface(pPushButton);
24 return pPushButton;
25 }
26 IFWL_PushButton::IFWL_PushButton() {}
27
28 CFWL_PushButtonImp::CFWL_PushButtonImp(
29 const CFWL_WidgetImpProperties& properties,
30 IFWL_Widget* pOuter)
31 : CFWL_WidgetImp(properties, pOuter),
32 m_bBtnDown(FALSE),
33 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
34 m_iTTOAlign(FDE_TTOALIGNMENT_Center) {
35 m_rtClient.Set(0, 0, 0, 0);
36 m_rtCaption.Set(0, 0, 0, 0);
37 }
38 CFWL_PushButtonImp::~CFWL_PushButtonImp() {}
39 FWL_ERR CFWL_PushButtonImp::GetClassName(CFX_WideString& wsClass) const {
40 wsClass = FWL_CLASS_PushButton;
41 return FWL_ERR_Succeeded;
42 }
43 FX_DWORD CFWL_PushButtonImp::GetClassID() const {
44 return FWL_CLASSHASH_PushButton;
45 }
46 FWL_ERR CFWL_PushButtonImp::Initialize() {
47 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
48 return FWL_ERR_Indefinite;
49 m_pDelegate = new CFWL_PushButtonImpDelegate(this);
50 return FWL_ERR_Succeeded;
51 }
52 FWL_ERR CFWL_PushButtonImp::Finalize() {
53 delete m_pDelegate;
54 m_pDelegate = nullptr;
55 return CFWL_WidgetImp::Finalize();
56 }
57 FWL_ERR CFWL_PushButtonImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
58 if (bAutoSize) {
59 rect.Set(0, 0, 0, 0);
60 if (m_pProperties->m_pThemeProvider == NULL) {
61 m_pProperties->m_pThemeProvider = GetAvailableTheme();
62 }
63 CFX_WideString wsCaption;
64 IFWL_PushButtonDP* pData =
65 static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider);
66 if (pData) {
67 pData->GetCaption(m_pInterface, wsCaption);
68 }
69 int32_t iLen = wsCaption.GetLength();
70 if (iLen > 0) {
71 CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider);
72 rect.Set(0, 0, sz.x, sz.y);
73 }
74 FX_FLOAT* fcaption =
75 static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_PSB_Margin));
76 rect.Inflate(*fcaption, *fcaption);
77 CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
78 } else {
79 rect = m_pProperties->m_rtWidget;
80 }
81 return FWL_ERR_Succeeded;
82 }
83 FWL_ERR CFWL_PushButtonImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet) {
84 if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) {
85 m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled;
86 return FWL_ERR_Succeeded;
87 }
88 return CFWL_WidgetImp::SetStates(dwStates, bSet);
89 }
90 FWL_ERR CFWL_PushButtonImp::Update() {
91 if (IsLocked()) {
92 return FWL_ERR_Indefinite;
93 }
94 if (!m_pProperties->m_pThemeProvider) {
95 m_pProperties->m_pThemeProvider = GetAvailableTheme();
96 }
97 UpdateTextOutStyles();
98 GetClientRect(m_rtClient);
99 m_rtCaption = m_rtClient;
100 FX_FLOAT* fcaption =
101 static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_PSB_Margin));
102 m_rtCaption.Inflate(-*fcaption, -*fcaption);
103 return FWL_ERR_Succeeded;
104 }
105 FWL_ERR CFWL_PushButtonImp::DrawWidget(CFX_Graphics* pGraphics,
106 const CFX_Matrix* pMatrix) {
107 if (!pGraphics)
108 return FWL_ERR_Indefinite;
109 if (!m_pProperties->m_pThemeProvider)
110 return FWL_ERR_Indefinite;
111 IFWL_PushButtonDP* pData =
112 static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider);
113 CFX_DIBitmap* pPicture = NULL;
114 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
115 if (HasBorder()) {
116 DrawBorder(pGraphics, FWL_PART_PSB_Border, m_pProperties->m_pThemeProvider,
117 pMatrix);
118 }
119 if (HasEdge()) {
120 DrawEdge(pGraphics, FWL_PART_PSB_Edge, m_pProperties->m_pThemeProvider,
121 pMatrix);
122 }
123 DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix);
124 CFX_Matrix matrix;
125 matrix.Concat(*pMatrix);
126 FX_FLOAT iPicwidth = 0;
127 FX_FLOAT ipicheight = 0;
128 CFX_WideString wsCaption;
129 if (pData) {
130 pData->GetCaption(m_pInterface, wsCaption);
131 }
132 CFX_RectF rtText;
133 rtText.Set(0, 0, 0, 0);
134 if (!wsCaption.IsEmpty()) {
135 CalcTextRect(wsCaption, pTheme, 0, m_iTTOAlign, rtText);
136 }
137 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_PSB_ModeMask) {
138 case FWL_STYLEEXT_PSB_TextOnly:
139 DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix);
140 break;
141 case FWL_STYLEEXT_PSB_IconOnly:
142 if (pData) {
143 pPicture = pData->GetPicture(m_pInterface);
144 }
145 if (pPicture) {
146 CFX_PointF point;
147 switch (m_iTTOAlign) {
148 case 0: {
149 point.x = m_rtClient.left;
150 point.y = m_rtClient.top;
151 break;
152 }
153 case 1: {
154 point.x = m_rtClient.left +
155 (m_rtClient.width / 2 - pPicture->GetWidth() / 2);
156 point.y = m_rtClient.top;
157 break;
158 }
159 case 2:
160 point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth();
161 point.y = m_rtClient.top;
162 break;
163 case 4:
164 point.x = m_rtClient.left;
165 point.y = m_rtClient.top + m_rtClient.height / 2 -
166 pPicture->GetHeight() / 2;
167 break;
168 case 5:
169 point.x = m_rtClient.left +
170 (m_rtClient.width / 2 - pPicture->GetWidth() / 2);
171 point.y = m_rtClient.top + m_rtClient.height / 2 -
172 pPicture->GetHeight() / 2;
173 break;
174 case 6:
175 point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth();
176 point.y = m_rtClient.top + m_rtClient.height / 2 -
177 pPicture->GetHeight() / 2;
178 break;
179 case 8:
180 point.x = m_rtClient.left;
181 point.y =
182 m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
183 break;
184 case 9:
185 point.x = m_rtClient.left +
186 (m_rtClient.width / 2 - pPicture->GetWidth() / 2);
187 point.y =
188 m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
189 break;
190 case 10:
191 point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth();
192 point.y =
193 m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
194 break;
195 }
196 pGraphics->DrawImage(pPicture, point, &matrix);
197 }
198 break;
199 case FWL_STYLEEXT_PSB_TextIcon:
200 if (pPicture) {
201 CFX_PointF point;
202 switch (m_iTTOAlign) {
203 case 0: {
204 point.x = m_rtClient.left;
205 point.y = m_rtClient.top;
206 iPicwidth = (FX_FLOAT)(pPicture->GetWidth() - 7);
207 ipicheight =
208 pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2;
209 break;
210 }
211 case 1: {
212 point.x =
213 m_rtClient.left + (m_rtClient.width / 2 -
214 (pPicture->GetWidth() + rtText.width) / 2);
215 point.y = m_rtClient.top;
216 iPicwidth = pPicture->GetWidth() -
217 ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) +
218 rtText.width / 2 - 7;
219 ipicheight =
220 pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2;
221 break;
222 }
223 case 2:
224 point.x = m_rtClient.left + m_rtClient.width -
225 pPicture->GetWidth() - rtText.width;
226 point.y = m_rtClient.top;
227 iPicwidth = m_rtClient.left + m_rtClient.width - point.x -
228 pPicture->GetWidth() - rtText.width + 7;
229 ipicheight =
230 pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2;
231 break;
232 case 4:
233 point.x = m_rtClient.left;
234 point.y = m_rtClient.top + m_rtClient.height / 2 -
235 pPicture->GetHeight() / 2;
236 iPicwidth = m_rtClient.left + pPicture->GetWidth() - 7;
237 break;
238 case 5:
239 point.x =
240 m_rtClient.left + (m_rtClient.width / 2 -
241 (pPicture->GetWidth() + rtText.width) / 2);
242 point.y = m_rtClient.top + m_rtClient.height / 2 -
243 pPicture->GetHeight() / 2;
244 iPicwidth = pPicture->GetWidth() -
245 ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) +
246 rtText.width / 2 - 7;
247 break;
248 case 6:
249 point.x = m_rtClient.left + m_rtClient.width -
250 pPicture->GetWidth() - rtText.width;
251 point.y = m_rtClient.top + m_rtClient.height / 2 -
252 pPicture->GetHeight() / 2;
253 iPicwidth = m_rtClient.left + m_rtClient.width - point.x -
254 pPicture->GetWidth() - rtText.width + 7;
255 break;
256 case 8:
257 point.x = m_rtClient.left;
258 point.y =
259 m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
260 iPicwidth = (FX_FLOAT)(pPicture->GetWidth() - 7);
261 ipicheight -= rtText.height / 2;
262 break;
263 case 9:
264 point.x =
265 m_rtClient.left + (m_rtClient.width / 2 -
266 (pPicture->GetWidth() + rtText.width) / 2);
267 point.y =
268 m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
269 iPicwidth = pPicture->GetWidth() -
270 ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) +
271 rtText.width / 2 - 7;
272 ipicheight -= rtText.height / 2;
273 break;
274 case 10:
275 point.x = m_rtClient.left + m_rtClient.width -
276 pPicture->GetWidth() - rtText.width;
277 point.y =
278 m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
279 iPicwidth = m_rtClient.left + m_rtClient.width - point.x -
280 pPicture->GetWidth() - rtText.width + 7;
281 ipicheight -= rtText.height / 2;
282 break;
283 }
284 pGraphics->DrawImage(pPicture, point, &matrix);
285 }
286 matrix.e += m_rtClient.left + iPicwidth;
287 matrix.f += m_rtClient.top + ipicheight;
288 DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix);
289 break;
290 }
291 return FWL_ERR_Succeeded;
292 }
293 void CFWL_PushButtonImp::DrawBkground(CFX_Graphics* pGraphics,
294 IFWL_ThemeProvider* pTheme,
295 const CFX_Matrix* pMatrix) {
296 CFWL_ThemeBackground param;
297 param.m_pWidget = m_pInterface;
298 param.m_iPart = FWL_PART_PSB_Background;
299 param.m_dwStates = GetPartStates();
300 param.m_pGraphics = pGraphics;
301 if (pMatrix) {
302 param.m_matrix.Concat(*pMatrix);
303 }
304 param.m_rtPart = m_rtClient;
305 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
306 param.m_pData = &m_rtCaption;
307 }
308 pTheme->DrawBackground(&param);
309 }
310 void CFWL_PushButtonImp::DrawText(CFX_Graphics* pGraphics,
311 IFWL_ThemeProvider* pTheme,
312 const CFX_Matrix* pMatrix) {
313 if (!m_pProperties->m_pDataProvider)
314 return;
315 CFX_WideString wsCaption;
316 m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption);
317 if (wsCaption.IsEmpty()) {
318 return;
319 }
320 CFWL_ThemeText param;
321 param.m_pWidget = m_pInterface;
322 param.m_iPart = FWL_PART_PSB_Caption;
323 param.m_dwStates = GetPartStates();
324 param.m_pGraphics = pGraphics;
325 if (pMatrix) {
326 param.m_matrix.Concat(*pMatrix);
327 }
328 param.m_rtPart = m_rtCaption;
329 param.m_wsText = wsCaption;
330 param.m_dwTTOStyles = m_dwTTOStyles;
331 param.m_iTTOAlign = m_iTTOAlign;
332 pTheme->DrawText(&param);
333 }
334 FX_DWORD CFWL_PushButtonImp::GetPartStates() {
335 FX_DWORD dwStates = FWL_PARTSTATE_PSB_Normal;
336 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
337 dwStates |= FWL_PARTSTATE_PSB_Focused;
338 }
339 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
340 dwStates = FWL_PARTSTATE_PSB_Disabled;
341 } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) {
342 dwStates |= FWL_PARTSTATE_PSB_Pressed;
343 } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) {
344 dwStates |= FWL_PARTSTATE_PSB_Hovered;
345 } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Default) {
346 dwStates |= FWL_PARTSTATE_PSB_Default;
347 }
348 return dwStates;
349 }
350 void CFWL_PushButtonImp::UpdateTextOutStyles() {
351 m_iTTOAlign = FDE_TTOALIGNMENT_Center;
352 switch (m_pProperties->m_dwStyleExes &
353 (FWL_STYLEEXT_PSB_HLayoutMask | FWL_STYLEEXT_PSB_VLayoutMask)) {
354 case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_Top: {
355 m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
356 break;
357 }
358 case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_Top: {
359 m_iTTOAlign = FDE_TTOALIGNMENT_TopCenter;
360 break;
361 }
362 case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_Top: {
363 m_iTTOAlign = FDE_TTOALIGNMENT_TopRight;
364 break;
365 }
366 case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_VCenter: {
367 m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
368 break;
369 }
370 case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_VCenter: {
371 m_iTTOAlign = FDE_TTOALIGNMENT_Center;
372 break;
373 }
374 case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_VCenter: {
375 m_iTTOAlign = FDE_TTOALIGNMENT_CenterRight;
376 break;
377 }
378 case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_Bottom: {
379 m_iTTOAlign = FDE_TTOALIGNMENT_BottomLeft;
380 break;
381 }
382 case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_Bottom: {
383 m_iTTOAlign = FDE_TTOALIGNMENT_BottomCenter;
384 break;
385 }
386 case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_Bottom: {
387 m_iTTOAlign = FDE_TTOALIGNMENT_BottomRight;
388 break;
389 }
390 default: {}
391 }
392 m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
393 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) {
394 m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
395 }
396 }
397 CFWL_PushButtonImpDelegate::CFWL_PushButtonImpDelegate(
398 CFWL_PushButtonImp* pOwner)
399 : m_pOwner(pOwner) {}
400 int32_t CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
401 if (!pMessage)
402 return 0;
403 if (!m_pOwner->IsEnabled()) {
404 return 1;
405 }
406 int32_t iRet = 1;
407 FX_DWORD dwMsgCode = pMessage->GetClassID();
408 switch (dwMsgCode) {
409 case FWL_MSGHASH_SetFocus:
410 case FWL_MSGHASH_KillFocus: {
411 OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
412 break;
413 }
414 case FWL_MSGHASH_Mouse: {
415 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
416 FX_DWORD dwCmd = pMsg->m_dwCmd;
417 switch (dwCmd) {
418 case FWL_MSGMOUSECMD_LButtonDown: {
419 OnLButtonDown(pMsg);
420 break;
421 }
422 case FWL_MSGMOUSECMD_LButtonUp: {
423 OnLButtonUp(pMsg);
424 break;
425 }
426 case FWL_MSGMOUSECMD_MouseMove: {
427 OnMouseMove(pMsg);
428 break;
429 }
430 case FWL_MSGMOUSECMD_MouseLeave: {
431 OnMouseLeave(pMsg);
432 break;
433 }
434 default: {}
435 }
436 break;
437 }
438 case FWL_MSGHASH_Key: {
439 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage);
440 if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) {
441 OnKeyDown(pKey);
442 }
443 break;
444 }
445 default: {
446 iRet = 0;
447 break;
448 }
449 }
450 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
451 return iRet;
452 }
453 FWL_ERR CFWL_PushButtonImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
454 return FWL_ERR_Succeeded;
455 }
456 FWL_ERR CFWL_PushButtonImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
457 const CFX_Matrix* pMatrix) {
458 return m_pOwner->DrawWidget(pGraphics, pMatrix);
459 }
460 void CFWL_PushButtonImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
461 FX_BOOL bSet) {
462 if (bSet) {
463 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
464 } else {
465 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
466 }
467 m_pOwner->Repaint(&m_pOwner->m_rtClient);
468 }
469 void CFWL_PushButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
470 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
471 m_pOwner->SetFocus(TRUE);
472 }
473 m_pOwner->m_bBtnDown = TRUE;
474 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
475 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed;
476 m_pOwner->Repaint(&m_pOwner->m_rtClient);
477 }
478 void CFWL_PushButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
479 m_pOwner->m_bBtnDown = FALSE;
480 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
481 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
482 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
483 } else {
484 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
485 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
486 }
487 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
488 CFWL_EvtClick wmClick;
489 wmClick.m_pSrcTarget = m_pOwner->m_pInterface;
490 m_pOwner->DispatchEvent(&wmClick);
491 }
492 m_pOwner->Repaint(&m_pOwner->m_rtClient);
493 }
494 void CFWL_PushButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
495 FX_BOOL bRepaint = FALSE;
496 if (m_pOwner->m_bBtnDown) {
497 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
498 if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) == 0) {
499 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed;
500 bRepaint = TRUE;
501 }
502 if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) {
503 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
504 bRepaint = TRUE;
505 }
506 } else {
507 if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) {
508 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
509 bRepaint = TRUE;
510 }
511 if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) {
512 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
513 bRepaint = TRUE;
514 }
515 }
516 } else {
517 if (!m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
518 return;
519 }
520 if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) {
521 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
522 bRepaint = TRUE;
523 }
524 }
525 if (bRepaint) {
526 m_pOwner->Repaint(&m_pOwner->m_rtClient);
527 }
528 }
529 void CFWL_PushButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
530 m_pOwner->m_bBtnDown = FALSE;
531 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
532 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
533 m_pOwner->Repaint(&m_pOwner->m_rtClient);
534 }
535 void CFWL_PushButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
536 if (pMsg->m_dwKeyCode == FWL_VKEY_Return) {
537 CFWL_EvtMouse wmMouse;
538 wmMouse.m_pSrcTarget = m_pOwner->m_pInterface;
539 wmMouse.m_dwCmd = FWL_MSGMOUSECMD_LButtonUp;
540 m_pOwner->DispatchEvent(&wmMouse);
541 CFWL_EvtClick wmClick;
542 wmClick.m_pSrcTarget = m_pOwner->m_pInterface;
543 m_pOwner->DispatchEvent(&wmClick);
544 return;
545 }
546 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) {
547 return;
548 }
549 m_pOwner->DispatchKeyEvent(pMsg);
550 }
OLDNEW
« no previous file with comments | « xfa/src/fwl/basewidget/fwl_pushbuttonimp.h ('k') | xfa/src/fwl/basewidget/fwl_scrollbarimp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698