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

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

Issue 2432423002: Merge the CFWL_*Imp classes into the IFWL_* classes. (Closed)
Patch Set: Review feedback Created 4 years, 2 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/fwl/core/ifwl_pushbutton.h ('k') | xfa/fwl/core/ifwl_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/basewidget/fwl_pushbuttonimp.h" 7 #include "xfa/fwl/core/ifwl_pushbutton.h"
8 8
9 #include "xfa/fde/tto/fde_textout.h" 9 #include "xfa/fde/tto/fde_textout.h"
10 #include "xfa/fwl/basewidget/ifwl_pushbutton.h"
11 #include "xfa/fwl/core/cfwl_message.h" 10 #include "xfa/fwl/core/cfwl_message.h"
12 #include "xfa/fwl/core/cfwl_themebackground.h" 11 #include "xfa/fwl/core/cfwl_themebackground.h"
13 #include "xfa/fwl/core/cfwl_themetext.h" 12 #include "xfa/fwl/core/cfwl_themetext.h"
14 #include "xfa/fwl/core/fwl_noteimp.h" 13 #include "xfa/fwl/core/fwl_noteimp.h"
15 #include "xfa/fwl/core/fwl_widgetimp.h" 14 #include "xfa/fwl/core/ifwl_pushbutton.h"
16 #include "xfa/fwl/core/ifwl_themeprovider.h" 15 #include "xfa/fwl/core/ifwl_themeprovider.h"
17 16
18 // static 17 // static
19 IFWL_PushButton* IFWL_PushButton::Create( 18 IFWL_PushButton* IFWL_PushButton::Create(
20 const CFWL_WidgetImpProperties& properties, 19 const CFWL_WidgetImpProperties& properties,
21 IFWL_Widget* pOuter) { 20 IFWL_Widget* pOuter) {
22 IFWL_PushButton* pPushButton = new IFWL_PushButton; 21 return new IFWL_PushButton(properties, pOuter);
23 CFWL_PushButtonImp* pPushButtonImpl =
24 new CFWL_PushButtonImp(properties, pOuter);
25 pPushButton->SetImpl(pPushButtonImpl);
26 pPushButtonImpl->SetInterface(pPushButton);
27 return pPushButton;
28 } 22 }
29 IFWL_PushButton::IFWL_PushButton() {}
30 23
31 CFWL_PushButtonImp::CFWL_PushButtonImp( 24 IFWL_PushButton::IFWL_PushButton(const CFWL_WidgetImpProperties& properties,
32 const CFWL_WidgetImpProperties& properties, 25 IFWL_Widget* pOuter)
33 IFWL_Widget* pOuter) 26 : IFWL_Widget(properties, pOuter),
34 : CFWL_WidgetImp(properties, pOuter),
35 m_bBtnDown(FALSE), 27 m_bBtnDown(FALSE),
36 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), 28 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
37 m_iTTOAlign(FDE_TTOALIGNMENT_Center) { 29 m_iTTOAlign(FDE_TTOALIGNMENT_Center) {
38 m_rtClient.Set(0, 0, 0, 0); 30 m_rtClient.Set(0, 0, 0, 0);
39 m_rtCaption.Set(0, 0, 0, 0); 31 m_rtCaption.Set(0, 0, 0, 0);
40 } 32 }
41 33
42 CFWL_PushButtonImp::~CFWL_PushButtonImp() {} 34 IFWL_PushButton::~IFWL_PushButton() {}
43 35
44 FWL_Error CFWL_PushButtonImp::GetClassName(CFX_WideString& wsClass) const { 36 FWL_Error IFWL_PushButton::GetClassName(CFX_WideString& wsClass) const {
45 wsClass = FWL_CLASS_PushButton; 37 wsClass = FWL_CLASS_PushButton;
46 return FWL_Error::Succeeded; 38 return FWL_Error::Succeeded;
47 } 39 }
48 40
49 FWL_Type CFWL_PushButtonImp::GetClassID() const { 41 FWL_Type IFWL_PushButton::GetClassID() const {
50 return FWL_Type::PushButton; 42 return FWL_Type::PushButton;
51 } 43 }
52 44
53 FWL_Error CFWL_PushButtonImp::Initialize() { 45 FWL_Error IFWL_PushButton::Initialize() {
54 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) 46 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
55 return FWL_Error::Indefinite; 47 return FWL_Error::Indefinite;
56 48
57 m_pDelegate = new CFWL_PushButtonImpDelegate(this); 49 m_pDelegate = new CFWL_PushButtonImpDelegate(this);
58 return FWL_Error::Succeeded; 50 return FWL_Error::Succeeded;
59 } 51 }
60 52
61 FWL_Error CFWL_PushButtonImp::Finalize() { 53 FWL_Error IFWL_PushButton::Finalize() {
62 delete m_pDelegate; 54 delete m_pDelegate;
63 m_pDelegate = nullptr; 55 m_pDelegate = nullptr;
64 return CFWL_WidgetImp::Finalize(); 56 return IFWL_Widget::Finalize();
65 } 57 }
66 FWL_Error CFWL_PushButtonImp::GetWidgetRect(CFX_RectF& rect, 58
67 FX_BOOL bAutoSize) { 59 FWL_Error IFWL_PushButton::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
68 if (bAutoSize) { 60 if (bAutoSize) {
69 rect.Set(0, 0, 0, 0); 61 rect.Set(0, 0, 0, 0);
70 if (!m_pProperties->m_pThemeProvider) { 62 if (!m_pProperties->m_pThemeProvider) {
71 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 63 m_pProperties->m_pThemeProvider = GetAvailableTheme();
72 } 64 }
73 CFX_WideString wsCaption; 65 CFX_WideString wsCaption;
74 IFWL_PushButtonDP* pData = 66 IFWL_PushButtonDP* pData =
75 static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider); 67 static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider);
76 if (pData) { 68 if (pData) {
77 pData->GetCaption(m_pInterface, wsCaption); 69 pData->GetCaption(this, wsCaption);
78 } 70 }
79 int32_t iLen = wsCaption.GetLength(); 71 int32_t iLen = wsCaption.GetLength();
80 if (iLen > 0) { 72 if (iLen > 0) {
81 CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider); 73 CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider);
82 rect.Set(0, 0, sz.x, sz.y); 74 rect.Set(0, 0, sz.x, sz.y);
83 } 75 }
84 FX_FLOAT* fcaption = 76 FX_FLOAT* fcaption =
85 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin)); 77 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin));
86 rect.Inflate(*fcaption, *fcaption); 78 rect.Inflate(*fcaption, *fcaption);
87 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); 79 IFWL_Widget::GetWidgetRect(rect, TRUE);
88 } else { 80 } else {
89 rect = m_pProperties->m_rtWidget; 81 rect = m_pProperties->m_rtWidget;
90 } 82 }
91 return FWL_Error::Succeeded; 83 return FWL_Error::Succeeded;
92 } 84 }
93 85
94 void CFWL_PushButtonImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { 86 void IFWL_PushButton::SetStates(uint32_t dwStates, FX_BOOL bSet) {
95 if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) { 87 if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) {
96 m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled; 88 m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled;
97 return; 89 return;
98 } 90 }
99 CFWL_WidgetImp::SetStates(dwStates, bSet); 91 IFWL_Widget::SetStates(dwStates, bSet);
100 } 92 }
101 93
102 FWL_Error CFWL_PushButtonImp::Update() { 94 FWL_Error IFWL_PushButton::Update() {
103 if (IsLocked()) { 95 if (IsLocked()) {
104 return FWL_Error::Indefinite; 96 return FWL_Error::Indefinite;
105 } 97 }
106 if (!m_pProperties->m_pThemeProvider) { 98 if (!m_pProperties->m_pThemeProvider) {
107 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 99 m_pProperties->m_pThemeProvider = GetAvailableTheme();
108 } 100 }
109 UpdateTextOutStyles(); 101 UpdateTextOutStyles();
110 GetClientRect(m_rtClient); 102 GetClientRect(m_rtClient);
111 m_rtCaption = m_rtClient; 103 m_rtCaption = m_rtClient;
112 FX_FLOAT* fcaption = 104 FX_FLOAT* fcaption =
113 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin)); 105 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin));
114 m_rtCaption.Inflate(-*fcaption, -*fcaption); 106 m_rtCaption.Inflate(-*fcaption, -*fcaption);
115 return FWL_Error::Succeeded; 107 return FWL_Error::Succeeded;
116 } 108 }
117 FWL_Error CFWL_PushButtonImp::DrawWidget(CFX_Graphics* pGraphics, 109
118 const CFX_Matrix* pMatrix) { 110 FWL_Error IFWL_PushButton::DrawWidget(CFX_Graphics* pGraphics,
111 const CFX_Matrix* pMatrix) {
119 if (!pGraphics) 112 if (!pGraphics)
120 return FWL_Error::Indefinite; 113 return FWL_Error::Indefinite;
121 if (!m_pProperties->m_pThemeProvider) 114 if (!m_pProperties->m_pThemeProvider)
122 return FWL_Error::Indefinite; 115 return FWL_Error::Indefinite;
123 IFWL_PushButtonDP* pData = 116 IFWL_PushButtonDP* pData =
124 static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider); 117 static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider);
125 CFX_DIBitmap* pPicture = nullptr; 118 CFX_DIBitmap* pPicture = nullptr;
126 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 119 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
127 if (HasBorder()) { 120 if (HasBorder()) {
128 DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider, 121 DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider,
129 pMatrix); 122 pMatrix);
130 } 123 }
131 if (HasEdge()) { 124 if (HasEdge()) {
132 DrawEdge(pGraphics, CFWL_Part::Edge, m_pProperties->m_pThemeProvider, 125 DrawEdge(pGraphics, CFWL_Part::Edge, m_pProperties->m_pThemeProvider,
133 pMatrix); 126 pMatrix);
134 } 127 }
135 DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); 128 DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix);
136 CFX_Matrix matrix; 129 CFX_Matrix matrix;
137 matrix.Concat(*pMatrix); 130 matrix.Concat(*pMatrix);
138 FX_FLOAT iPicwidth = 0; 131 FX_FLOAT iPicwidth = 0;
139 FX_FLOAT ipicheight = 0; 132 FX_FLOAT ipicheight = 0;
140 CFX_WideString wsCaption; 133 CFX_WideString wsCaption;
141 if (pData) { 134 if (pData) {
142 pData->GetCaption(m_pInterface, wsCaption); 135 pData->GetCaption(this, wsCaption);
143 } 136 }
144 CFX_RectF rtText; 137 CFX_RectF rtText;
145 rtText.Set(0, 0, 0, 0); 138 rtText.Set(0, 0, 0, 0);
146 if (!wsCaption.IsEmpty()) { 139 if (!wsCaption.IsEmpty()) {
147 CalcTextRect(wsCaption, pTheme, 0, m_iTTOAlign, rtText); 140 CalcTextRect(wsCaption, pTheme, 0, m_iTTOAlign, rtText);
148 } 141 }
149 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_PSB_ModeMask) { 142 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_PSB_ModeMask) {
150 case FWL_STYLEEXT_PSB_TextOnly: 143 case FWL_STYLEEXT_PSB_TextOnly:
151 DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix); 144 DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix);
152 break; 145 break;
153 case FWL_STYLEEXT_PSB_IconOnly: 146 case FWL_STYLEEXT_PSB_IconOnly:
154 if (pData) { 147 if (pData) {
155 pPicture = pData->GetPicture(m_pInterface); 148 pPicture = pData->GetPicture(this);
156 } 149 }
157 if (pPicture) { 150 if (pPicture) {
158 CFX_PointF point; 151 CFX_PointF point;
159 switch (m_iTTOAlign) { 152 switch (m_iTTOAlign) {
160 case 0: { 153 case 0: {
161 point.x = m_rtClient.left; 154 point.x = m_rtClient.left;
162 point.y = m_rtClient.top; 155 point.y = m_rtClient.top;
163 break; 156 break;
164 } 157 }
165 case 1: { 158 case 1: {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 } 288 }
296 pGraphics->DrawImage(pPicture, point, &matrix); 289 pGraphics->DrawImage(pPicture, point, &matrix);
297 } 290 }
298 matrix.e += m_rtClient.left + iPicwidth; 291 matrix.e += m_rtClient.left + iPicwidth;
299 matrix.f += m_rtClient.top + ipicheight; 292 matrix.f += m_rtClient.top + ipicheight;
300 DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix); 293 DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix);
301 break; 294 break;
302 } 295 }
303 return FWL_Error::Succeeded; 296 return FWL_Error::Succeeded;
304 } 297 }
305 void CFWL_PushButtonImp::DrawBkground(CFX_Graphics* pGraphics, 298
306 IFWL_ThemeProvider* pTheme, 299 void IFWL_PushButton::DrawBkground(CFX_Graphics* pGraphics,
307 const CFX_Matrix* pMatrix) { 300 IFWL_ThemeProvider* pTheme,
301 const CFX_Matrix* pMatrix) {
308 CFWL_ThemeBackground param; 302 CFWL_ThemeBackground param;
309 param.m_pWidget = m_pInterface; 303 param.m_pWidget = this;
310 param.m_iPart = CFWL_Part::Background; 304 param.m_iPart = CFWL_Part::Background;
311 param.m_dwStates = GetPartStates(); 305 param.m_dwStates = GetPartStates();
312 param.m_pGraphics = pGraphics; 306 param.m_pGraphics = pGraphics;
313 if (pMatrix) { 307 if (pMatrix) {
314 param.m_matrix.Concat(*pMatrix); 308 param.m_matrix.Concat(*pMatrix);
315 } 309 }
316 param.m_rtPart = m_rtClient; 310 param.m_rtPart = m_rtClient;
317 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { 311 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
318 param.m_pData = &m_rtCaption; 312 param.m_pData = &m_rtCaption;
319 } 313 }
320 pTheme->DrawBackground(&param); 314 pTheme->DrawBackground(&param);
321 } 315 }
322 void CFWL_PushButtonImp::DrawText(CFX_Graphics* pGraphics, 316
323 IFWL_ThemeProvider* pTheme, 317 void IFWL_PushButton::DrawText(CFX_Graphics* pGraphics,
324 const CFX_Matrix* pMatrix) { 318 IFWL_ThemeProvider* pTheme,
319 const CFX_Matrix* pMatrix) {
325 if (!m_pProperties->m_pDataProvider) 320 if (!m_pProperties->m_pDataProvider)
326 return; 321 return;
327 CFX_WideString wsCaption; 322 CFX_WideString wsCaption;
328 m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); 323 m_pProperties->m_pDataProvider->GetCaption(this, wsCaption);
329 if (wsCaption.IsEmpty()) { 324 if (wsCaption.IsEmpty()) {
330 return; 325 return;
331 } 326 }
332 CFWL_ThemeText param; 327 CFWL_ThemeText param;
333 param.m_pWidget = m_pInterface; 328 param.m_pWidget = this;
334 param.m_iPart = CFWL_Part::Caption; 329 param.m_iPart = CFWL_Part::Caption;
335 param.m_dwStates = GetPartStates(); 330 param.m_dwStates = GetPartStates();
336 param.m_pGraphics = pGraphics; 331 param.m_pGraphics = pGraphics;
337 if (pMatrix) { 332 if (pMatrix) {
338 param.m_matrix.Concat(*pMatrix); 333 param.m_matrix.Concat(*pMatrix);
339 } 334 }
340 param.m_rtPart = m_rtCaption; 335 param.m_rtPart = m_rtCaption;
341 param.m_wsText = wsCaption; 336 param.m_wsText = wsCaption;
342 param.m_dwTTOStyles = m_dwTTOStyles; 337 param.m_dwTTOStyles = m_dwTTOStyles;
343 param.m_iTTOAlign = m_iTTOAlign; 338 param.m_iTTOAlign = m_iTTOAlign;
344 pTheme->DrawText(&param); 339 pTheme->DrawText(&param);
345 } 340 }
346 uint32_t CFWL_PushButtonImp::GetPartStates() { 341
342 uint32_t IFWL_PushButton::GetPartStates() {
347 uint32_t dwStates = CFWL_PartState_Normal; 343 uint32_t dwStates = CFWL_PartState_Normal;
348 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { 344 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
349 dwStates |= CFWL_PartState_Focused; 345 dwStates |= CFWL_PartState_Focused;
350 } 346 }
351 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { 347 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
352 dwStates = CFWL_PartState_Disabled; 348 dwStates = CFWL_PartState_Disabled;
353 } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) { 349 } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) {
354 dwStates |= CFWL_PartState_Pressed; 350 dwStates |= CFWL_PartState_Pressed;
355 } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) { 351 } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) {
356 dwStates |= CFWL_PartState_Hovered; 352 dwStates |= CFWL_PartState_Hovered;
357 } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Default) { 353 } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Default) {
358 dwStates |= CFWL_PartState_Default; 354 dwStates |= CFWL_PartState_Default;
359 } 355 }
360 return dwStates; 356 return dwStates;
361 } 357 }
362 void CFWL_PushButtonImp::UpdateTextOutStyles() { 358
359 void IFWL_PushButton::UpdateTextOutStyles() {
363 m_iTTOAlign = FDE_TTOALIGNMENT_Center; 360 m_iTTOAlign = FDE_TTOALIGNMENT_Center;
364 switch (m_pProperties->m_dwStyleExes & 361 switch (m_pProperties->m_dwStyleExes &
365 (FWL_STYLEEXT_PSB_HLayoutMask | FWL_STYLEEXT_PSB_VLayoutMask)) { 362 (FWL_STYLEEXT_PSB_HLayoutMask | FWL_STYLEEXT_PSB_VLayoutMask)) {
366 case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_Top: { 363 case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_Top: {
367 m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; 364 m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
368 break; 365 break;
369 } 366 }
370 case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_Top: { 367 case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_Top: {
371 m_iTTOAlign = FDE_TTOALIGNMENT_TopCenter; 368 m_iTTOAlign = FDE_TTOALIGNMENT_TopCenter;
372 break; 369 break;
(...skipping 27 matching lines...) Expand all
400 break; 397 break;
401 } 398 }
402 default: {} 399 default: {}
403 } 400 }
404 m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; 401 m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
405 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { 402 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) {
406 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; 403 m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
407 } 404 }
408 } 405 }
409 406
410 CFWL_PushButtonImpDelegate::CFWL_PushButtonImpDelegate( 407 CFWL_PushButtonImpDelegate::CFWL_PushButtonImpDelegate(IFWL_PushButton* pOwner)
411 CFWL_PushButtonImp* pOwner)
412 : m_pOwner(pOwner) {} 408 : m_pOwner(pOwner) {}
413 409
414 void CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { 410 void CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
415 if (!pMessage) 411 if (!pMessage)
416 return; 412 return;
417 if (!m_pOwner->IsEnabled()) 413 if (!m_pOwner->IsEnabled())
418 return; 414 return;
419 415
420 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); 416 CFWL_MessageType dwMsgCode = pMessage->GetClassID();
421 switch (dwMsgCode) { 417 switch (dwMsgCode) {
(...skipping 28 matching lines...) Expand all
450 break; 446 break;
451 } 447 }
452 break; 448 break;
453 } 449 }
454 case CFWL_MessageType::Key: { 450 case CFWL_MessageType::Key: {
455 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); 451 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage);
456 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) 452 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown)
457 OnKeyDown(pKey); 453 OnKeyDown(pKey);
458 break; 454 break;
459 } 455 }
460 default: { 456 default: { break; }
461 break;
462 }
463 } 457 }
464 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); 458 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
465 } 459 }
466 460
467 void CFWL_PushButtonImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} 461 void CFWL_PushButtonImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {}
468 462
469 void CFWL_PushButtonImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, 463 void CFWL_PushButtonImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
470 const CFX_Matrix* pMatrix) { 464 const CFX_Matrix* pMatrix) {
471 m_pOwner->DrawWidget(pGraphics, pMatrix); 465 m_pOwner->DrawWidget(pGraphics, pMatrix);
472 } 466 }
473 467
474 void CFWL_PushButtonImpDelegate::OnFocusChanged(CFWL_Message* pMsg, 468 void CFWL_PushButtonImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
475 FX_BOOL bSet) { 469 FX_BOOL bSet) {
476 if (bSet) { 470 if (bSet) {
477 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 471 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
478 } else { 472 } else {
479 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; 473 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
480 } 474 }
481 m_pOwner->Repaint(&m_pOwner->m_rtClient); 475 m_pOwner->Repaint(&m_pOwner->m_rtClient);
482 } 476 }
477
483 void CFWL_PushButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { 478 void CFWL_PushButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
484 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { 479 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
485 m_pOwner->SetFocus(TRUE); 480 m_pOwner->SetFocus(TRUE);
486 } 481 }
487 m_pOwner->m_bBtnDown = TRUE; 482 m_pOwner->m_bBtnDown = TRUE;
488 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; 483 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
489 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed; 484 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed;
490 m_pOwner->Repaint(&m_pOwner->m_rtClient); 485 m_pOwner->Repaint(&m_pOwner->m_rtClient);
491 } 486 }
487
492 void CFWL_PushButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { 488 void CFWL_PushButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
493 m_pOwner->m_bBtnDown = FALSE; 489 m_pOwner->m_bBtnDown = FALSE;
494 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { 490 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
495 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; 491 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
496 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; 492 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
497 } else { 493 } else {
498 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; 494 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
499 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; 495 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
500 } 496 }
501 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { 497 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
502 CFWL_EvtClick wmClick; 498 CFWL_EvtClick wmClick;
503 wmClick.m_pSrcTarget = m_pOwner->m_pInterface; 499 wmClick.m_pSrcTarget = m_pOwner;
504 m_pOwner->DispatchEvent(&wmClick); 500 m_pOwner->DispatchEvent(&wmClick);
505 } 501 }
506 m_pOwner->Repaint(&m_pOwner->m_rtClient); 502 m_pOwner->Repaint(&m_pOwner->m_rtClient);
507 } 503 }
504
508 void CFWL_PushButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { 505 void CFWL_PushButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
509 FX_BOOL bRepaint = FALSE; 506 FX_BOOL bRepaint = FALSE;
510 if (m_pOwner->m_bBtnDown) { 507 if (m_pOwner->m_bBtnDown) {
511 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { 508 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
512 if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) == 0) { 509 if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) == 0) {
513 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed; 510 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed;
514 bRepaint = TRUE; 511 bRepaint = TRUE;
515 } 512 }
516 if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) { 513 if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) {
517 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; 514 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
(...skipping 15 matching lines...) Expand all
533 } 530 }
534 if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) { 531 if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) {
535 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered; 532 m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
536 bRepaint = TRUE; 533 bRepaint = TRUE;
537 } 534 }
538 } 535 }
539 if (bRepaint) { 536 if (bRepaint) {
540 m_pOwner->Repaint(&m_pOwner->m_rtClient); 537 m_pOwner->Repaint(&m_pOwner->m_rtClient);
541 } 538 }
542 } 539 }
540
543 void CFWL_PushButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { 541 void CFWL_PushButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
544 m_pOwner->m_bBtnDown = FALSE; 542 m_pOwner->m_bBtnDown = FALSE;
545 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered; 543 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
546 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed; 544 m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
547 m_pOwner->Repaint(&m_pOwner->m_rtClient); 545 m_pOwner->Repaint(&m_pOwner->m_rtClient);
548 } 546 }
547
549 void CFWL_PushButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { 548 void CFWL_PushButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
550 if (pMsg->m_dwKeyCode == FWL_VKEY_Return) { 549 if (pMsg->m_dwKeyCode == FWL_VKEY_Return) {
551 CFWL_EvtMouse wmMouse; 550 CFWL_EvtMouse wmMouse;
552 wmMouse.m_pSrcTarget = m_pOwner->m_pInterface; 551 wmMouse.m_pSrcTarget = m_pOwner;
553 wmMouse.m_dwCmd = FWL_MouseCommand::LeftButtonUp; 552 wmMouse.m_dwCmd = FWL_MouseCommand::LeftButtonUp;
554 m_pOwner->DispatchEvent(&wmMouse); 553 m_pOwner->DispatchEvent(&wmMouse);
555 CFWL_EvtClick wmClick; 554 CFWL_EvtClick wmClick;
556 wmClick.m_pSrcTarget = m_pOwner->m_pInterface; 555 wmClick.m_pSrcTarget = m_pOwner;
557 m_pOwner->DispatchEvent(&wmClick); 556 m_pOwner->DispatchEvent(&wmClick);
558 return; 557 return;
559 } 558 }
560 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) { 559 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) {
561 return; 560 return;
562 } 561 }
563 m_pOwner->DispatchKeyEvent(pMsg); 562 m_pOwner->DispatchKeyEvent(pMsg);
564 } 563 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_pushbutton.h ('k') | xfa/fwl/core/ifwl_scrollbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698