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

Side by Side Diff: xfa/fxfa/app/xfa_fffield.cpp

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: Created 4 years, 1 month 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/fxfa/app/xfa_fffield.h ('k') | xfa/fxfa/app/xfa_ffimage.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/fxfa/app/xfa_fffield.h" 7 #include "xfa/fxfa/app/xfa_fffield.h"
8 8
9 #include "xfa/fwl/core/cfwl_edit.h" 9 #include "xfa/fwl/core/cfwl_edit.h"
10 #include "xfa/fwl/core/cfwl_message.h" 10 #include "xfa/fwl/core/cfwl_message.h"
(...skipping 12 matching lines...) Expand all
23 23
24 CXFA_FFField::CXFA_FFField(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) 24 CXFA_FFField::CXFA_FFField(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc)
25 : CXFA_FFWidget(pPageView, pDataAcc), m_pNormalWidget(nullptr) { 25 : CXFA_FFWidget(pPageView, pDataAcc), m_pNormalWidget(nullptr) {
26 m_rtUI.Set(0, 0, 0, 0); 26 m_rtUI.Set(0, 0, 0, 0);
27 m_rtCaption.Set(0, 0, 0, 0); 27 m_rtCaption.Set(0, 0, 0, 0);
28 } 28 }
29 CXFA_FFField::~CXFA_FFField() { 29 CXFA_FFField::~CXFA_FFField() {
30 CXFA_FFField::UnloadWidget(); 30 CXFA_FFField::UnloadWidget();
31 } 31 }
32 32
33 FX_BOOL CXFA_FFField::GetBBox(CFX_RectF& rtBox, 33 bool CXFA_FFField::GetBBox(CFX_RectF& rtBox,
34 uint32_t dwStatus, 34 uint32_t dwStatus,
35 FX_BOOL bDrawFocus) { 35 bool bDrawFocus) {
36 if (!bDrawFocus) 36 if (!bDrawFocus)
37 return CXFA_FFWidget::GetBBox(rtBox, dwStatus); 37 return CXFA_FFWidget::GetBBox(rtBox, dwStatus);
38 38
39 XFA_Element type = m_pDataAcc->GetUIType(); 39 XFA_Element type = m_pDataAcc->GetUIType();
40 if (type == XFA_Element::Button || type == XFA_Element::CheckButton || 40 if (type == XFA_Element::Button || type == XFA_Element::CheckButton ||
41 type == XFA_Element::ImageEdit || type == XFA_Element::Signature || 41 type == XFA_Element::ImageEdit || type == XFA_Element::Signature ||
42 type == XFA_Element::ChoiceList) { 42 type == XFA_Element::ChoiceList) {
43 rtBox = m_rtUI; 43 rtBox = m_rtUI;
44 CFX_Matrix mt; 44 CFX_Matrix mt;
45 GetRotateMatrix(mt); 45 GetRotateMatrix(mt);
46 mt.TransformRect(rtBox); 46 mt.TransformRect(rtBox);
47 return TRUE; 47 return true;
48 } 48 }
49 return FALSE; 49 return false;
50 } 50 }
51 51
52 void CXFA_FFField::RenderWidget(CFX_Graphics* pGS, 52 void CXFA_FFField::RenderWidget(CFX_Graphics* pGS,
53 CFX_Matrix* pMatrix, 53 CFX_Matrix* pMatrix,
54 uint32_t dwStatus) { 54 uint32_t dwStatus) {
55 if (!IsMatchVisibleStatus(dwStatus)) { 55 if (!IsMatchVisibleStatus(dwStatus)) {
56 return; 56 return;
57 } 57 }
58 CFX_Matrix mtRotate; 58 CFX_Matrix mtRotate;
59 GetRotateMatrix(mtRotate); 59 GetRotateMatrix(mtRotate);
60 if (pMatrix) { 60 if (pMatrix) {
61 mtRotate.Concat(*pMatrix); 61 mtRotate.Concat(*pMatrix);
62 } 62 }
63 CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); 63 CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus);
64 CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); 64 CXFA_Border borderUI = m_pDataAcc->GetUIBorder();
65 DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); 65 DrawBorder(pGS, borderUI, m_rtUI, &mtRotate);
66 RenderCaption(pGS, &mtRotate); 66 RenderCaption(pGS, &mtRotate);
67 DrawHighlight(pGS, &mtRotate, dwStatus, FALSE); 67 DrawHighlight(pGS, &mtRotate, dwStatus, false);
68 CFX_RectF rtWidget; 68 CFX_RectF rtWidget;
69 m_pNormalWidget->GetWidgetRect(rtWidget); 69 m_pNormalWidget->GetWidgetRect(rtWidget);
70 CFX_Matrix mt; 70 CFX_Matrix mt;
71 mt.Set(1, 0, 0, 1, rtWidget.left, rtWidget.top); 71 mt.Set(1, 0, 0, 1, rtWidget.left, rtWidget.top);
72 mt.Concat(mtRotate); 72 mt.Concat(mtRotate);
73 GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget->GetWidget(), 73 GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget->GetWidget(),
74 pGS, &mt); 74 pGS, &mt);
75 } 75 }
76 void CXFA_FFField::DrawHighlight(CFX_Graphics* pGS, 76 void CXFA_FFField::DrawHighlight(CFX_Graphics* pGS,
77 CFX_Matrix* pMatrix, 77 CFX_Matrix* pMatrix,
78 uint32_t dwStatus, 78 uint32_t dwStatus,
79 FX_BOOL bEllipse) { 79 bool bEllipse) {
80 if (m_rtUI.IsEmpty() || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { 80 if (m_rtUI.IsEmpty() || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
81 return; 81 return;
82 } 82 }
83 if ((dwStatus & XFA_WidgetStatus_Highlight) && 83 if ((dwStatus & XFA_WidgetStatus_Highlight) &&
84 m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open) { 84 m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open) {
85 CXFA_FFDoc* pDoc = GetDoc(); 85 CXFA_FFDoc* pDoc = GetDoc();
86 CFX_Color crHighlight(pDoc->GetDocEnvironment()->GetHighlightColor(pDoc)); 86 CFX_Color crHighlight(pDoc->GetDocEnvironment()->GetHighlightColor(pDoc));
87 pGS->SetFillColor(&crHighlight); 87 pGS->SetFillColor(&crHighlight);
88 CFX_Path path; 88 CFX_Path path;
89 path.Create(); 89 path.Create();
90 if (bEllipse) { 90 if (bEllipse) {
91 path.AddEllipse(m_rtUI); 91 path.AddEllipse(m_rtUI);
92 } else { 92 } else {
93 path.AddRectangle(m_rtUI.left, m_rtUI.top, m_rtUI.width, m_rtUI.height); 93 path.AddRectangle(m_rtUI.left, m_rtUI.top, m_rtUI.width, m_rtUI.height);
94 } 94 }
95 pGS->FillPath(&path, FXFILL_WINDING, pMatrix); 95 pGS->FillPath(&path, FXFILL_WINDING, pMatrix);
96 } 96 }
97 } 97 }
98 void CXFA_FFField::DrawFocus(CFX_Graphics* pGS, CFX_Matrix* pMatrix) { 98 void CXFA_FFField::DrawFocus(CFX_Graphics* pGS, CFX_Matrix* pMatrix) {
99 if (m_dwStatus & XFA_WidgetStatus_Focused) { 99 if (m_dwStatus & XFA_WidgetStatus_Focused) {
100 CFX_Color cr(0xFF000000); 100 CFX_Color cr(0xFF000000);
101 pGS->SetStrokeColor(&cr); 101 pGS->SetStrokeColor(&cr);
102 FX_FLOAT DashPattern[2] = {1, 1}; 102 FX_FLOAT DashPattern[2] = {1, 1};
103 pGS->SetLineDash(0.0f, DashPattern, 2); 103 pGS->SetLineDash(0.0f, DashPattern, 2);
104 pGS->SetLineWidth(0, FALSE); 104 pGS->SetLineWidth(0, false);
105 CFX_Path path; 105 CFX_Path path;
106 path.Create(); 106 path.Create();
107 path.AddRectangle(m_rtUI.left, m_rtUI.top, m_rtUI.width, m_rtUI.height); 107 path.AddRectangle(m_rtUI.left, m_rtUI.top, m_rtUI.width, m_rtUI.height);
108 pGS->StrokePath(&path, pMatrix); 108 pGS->StrokePath(&path, pMatrix);
109 } 109 }
110 } 110 }
111 void CXFA_FFField::SetFWLThemeProvider() { 111 void CXFA_FFField::SetFWLThemeProvider() {
112 if (m_pNormalWidget) { 112 if (m_pNormalWidget) {
113 m_pNormalWidget->GetWidget()->SetThemeProvider(GetApp()->GetFWLTheme()); 113 m_pNormalWidget->GetWidget()->SetThemeProvider(GetApp()->GetFWLTheme());
114 } 114 }
115 } 115 }
116 FX_BOOL CXFA_FFField::IsLoaded() { 116 bool CXFA_FFField::IsLoaded() {
117 return m_pNormalWidget && CXFA_FFWidget::IsLoaded(); 117 return m_pNormalWidget && CXFA_FFWidget::IsLoaded();
118 } 118 }
119 FX_BOOL CXFA_FFField::LoadWidget() { 119 bool CXFA_FFField::LoadWidget() {
120 SetFWLThemeProvider(); 120 SetFWLThemeProvider();
121 m_pDataAcc->LoadCaption(); 121 m_pDataAcc->LoadCaption();
122 PerformLayout(); 122 PerformLayout();
123 return TRUE; 123 return true;
124 } 124 }
125 void CXFA_FFField::UnloadWidget() { 125 void CXFA_FFField::UnloadWidget() {
126 delete m_pNormalWidget; 126 delete m_pNormalWidget;
127 m_pNormalWidget = nullptr; 127 m_pNormalWidget = nullptr;
128 } 128 }
129 void CXFA_FFField::SetEditScrollOffset() { 129 void CXFA_FFField::SetEditScrollOffset() {
130 XFA_Element eType = m_pDataAcc->GetUIType(); 130 XFA_Element eType = m_pDataAcc->GetUIType();
131 if (eType == XFA_Element::TextEdit || eType == XFA_Element::NumericEdit || 131 if (eType == XFA_Element::TextEdit || eType == XFA_Element::NumericEdit ||
132 eType == XFA_Element::PasswordEdit) { 132 eType == XFA_Element::PasswordEdit) {
133 FX_FLOAT fScrollOffset = 0; 133 FX_FLOAT fScrollOffset = 0;
134 CXFA_FFField* pPrev = static_cast<CXFA_FFField*>(GetPrev()); 134 CXFA_FFField* pPrev = static_cast<CXFA_FFField*>(GetPrev());
135 if (pPrev) { 135 if (pPrev) {
136 CFX_RectF rtMargin; 136 CFX_RectF rtMargin;
137 m_pDataAcc->GetUIMargin(rtMargin); 137 m_pDataAcc->GetUIMargin(rtMargin);
138 fScrollOffset = -rtMargin.top; 138 fScrollOffset = -rtMargin.top;
139 } 139 }
140 while (pPrev) { 140 while (pPrev) {
141 fScrollOffset += pPrev->m_rtUI.height; 141 fScrollOffset += pPrev->m_rtUI.height;
142 pPrev = static_cast<CXFA_FFField*>(pPrev->GetPrev()); 142 pPrev = static_cast<CXFA_FFField*>(pPrev->GetPrev());
143 } 143 }
144 ((CFWL_Edit*)m_pNormalWidget)->SetScrollOffset(fScrollOffset); 144 ((CFWL_Edit*)m_pNormalWidget)->SetScrollOffset(fScrollOffset);
145 } 145 }
146 } 146 }
147 FX_BOOL CXFA_FFField::PerformLayout() { 147 bool CXFA_FFField::PerformLayout() {
148 CXFA_FFWidget::PerformLayout(); 148 CXFA_FFWidget::PerformLayout();
149 CapPlacement(); 149 CapPlacement();
150 LayoutCaption(); 150 LayoutCaption();
151 SetFWLRect(); 151 SetFWLRect();
152 SetEditScrollOffset(); 152 SetEditScrollOffset();
153 if (m_pNormalWidget) { 153 if (m_pNormalWidget) {
154 m_pNormalWidget->Update(); 154 m_pNormalWidget->Update();
155 } 155 }
156 return TRUE; 156 return true;
157 } 157 }
158 void CXFA_FFField::CapPlacement() { 158 void CXFA_FFField::CapPlacement() {
159 CFX_RectF rtWidget; 159 CFX_RectF rtWidget;
160 GetRectWithoutRotate(rtWidget); 160 GetRectWithoutRotate(rtWidget);
161 CXFA_Margin mgWidget = m_pDataAcc->GetMargin(); 161 CXFA_Margin mgWidget = m_pDataAcc->GetMargin();
162 if (mgWidget) { 162 if (mgWidget) {
163 CXFA_LayoutItem* pItem = this; 163 CXFA_LayoutItem* pItem = this;
164 FX_FLOAT fLeftInset = 0, fRightInset = 0, fTopInset = 0, fBottomInset = 0; 164 FX_FLOAT fLeftInset = 0, fRightInset = 0, fTopInset = 0, fBottomInset = 0;
165 mgWidget.GetLeftInset(fLeftInset); 165 mgWidget.GetLeftInset(fLeftInset);
166 mgWidget.GetRightInset(fRightInset); 166 mgWidget.GetRightInset(fRightInset);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 if (rtUi.width < 1.0) 336 if (rtUi.width < 1.0)
337 rtUi.width = 1.0; 337 rtUi.width = 1.0;
338 if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { 338 if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
339 FX_FLOAT fFontSize = m_pDataAcc->GetFontSize(); 339 FX_FLOAT fFontSize = m_pDataAcc->GetFontSize();
340 if (rtUi.height < fFontSize) { 340 if (rtUi.height < fFontSize) {
341 rtUi.height = fFontSize; 341 rtUi.height = fFontSize;
342 } 342 }
343 } 343 }
344 m_pNormalWidget->SetWidgetRect(rtUi); 344 m_pNormalWidget->SetWidgetRect(rtUi);
345 } 345 }
346 FX_BOOL CXFA_FFField::OnMouseEnter() { 346 bool CXFA_FFField::OnMouseEnter() {
347 if (!m_pNormalWidget) { 347 if (!m_pNormalWidget) {
348 return FALSE; 348 return false;
349 } 349 }
350 CFWL_MsgMouse ms; 350 CFWL_MsgMouse ms;
351 ms.m_dwCmd = FWL_MouseCommand::Enter; 351 ms.m_dwCmd = FWL_MouseCommand::Enter;
352 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); 352 ms.m_pDstTarget = m_pNormalWidget->GetWidget();
353 ms.m_pSrcTarget = nullptr; 353 ms.m_pSrcTarget = nullptr;
354 TranslateFWLMessage(&ms); 354 TranslateFWLMessage(&ms);
355 return TRUE; 355 return true;
356 } 356 }
357 FX_BOOL CXFA_FFField::OnMouseExit() { 357 bool CXFA_FFField::OnMouseExit() {
358 if (!m_pNormalWidget) { 358 if (!m_pNormalWidget) {
359 return FALSE; 359 return false;
360 } 360 }
361 CFWL_MsgMouse ms; 361 CFWL_MsgMouse ms;
362 ms.m_dwCmd = FWL_MouseCommand::Leave; 362 ms.m_dwCmd = FWL_MouseCommand::Leave;
363 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); 363 ms.m_pDstTarget = m_pNormalWidget->GetWidget();
364 TranslateFWLMessage(&ms); 364 TranslateFWLMessage(&ms);
365 return TRUE; 365 return true;
366 } 366 }
367 void CXFA_FFField::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) { 367 void CXFA_FFField::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) {
368 if (!m_pNormalWidget) { 368 if (!m_pNormalWidget) {
369 return; 369 return;
370 } 370 }
371 CFX_RectF rtWidget; 371 CFX_RectF rtWidget;
372 m_pNormalWidget->GetWidgetRect(rtWidget); 372 m_pNormalWidget->GetWidgetRect(rtWidget);
373 fx -= rtWidget.left; 373 fx -= rtWidget.left;
374 fy -= rtWidget.top; 374 fy -= rtWidget.top;
375 } 375 }
376 FX_BOOL CXFA_FFField::OnLButtonDown(uint32_t dwFlags, 376 bool CXFA_FFField::OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
377 FX_FLOAT fx,
378 FX_FLOAT fy) {
379 if (!m_pNormalWidget) { 377 if (!m_pNormalWidget) {
380 return FALSE; 378 return false;
381 } 379 }
382 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || 380 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open ||
383 !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { 381 !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
384 return FALSE; 382 return false;
385 } 383 }
386 if (!PtInActiveRect(fx, fy)) { 384 if (!PtInActiveRect(fx, fy)) {
387 return FALSE; 385 return false;
388 } 386 }
389 SetButtonDown(TRUE); 387 SetButtonDown(true);
390 CFWL_MsgMouse ms; 388 CFWL_MsgMouse ms;
391 ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; 389 ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown;
392 ms.m_dwFlags = dwFlags; 390 ms.m_dwFlags = dwFlags;
393 ms.m_fx = fx; 391 ms.m_fx = fx;
394 ms.m_fy = fy; 392 ms.m_fy = fy;
395 FWLToClient(ms.m_fx, ms.m_fy); 393 FWLToClient(ms.m_fx, ms.m_fy);
396 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); 394 ms.m_pDstTarget = m_pNormalWidget->GetWidget();
397 TranslateFWLMessage(&ms); 395 TranslateFWLMessage(&ms);
398 return TRUE; 396 return true;
399 } 397 }
400 FX_BOOL CXFA_FFField::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { 398 bool CXFA_FFField::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
401 if (!m_pNormalWidget) { 399 if (!m_pNormalWidget) {
402 return FALSE; 400 return false;
403 } 401 }
404 if (!IsButtonDown()) { 402 if (!IsButtonDown()) {
405 return FALSE; 403 return false;
406 } 404 }
407 SetButtonDown(FALSE); 405 SetButtonDown(false);
408 CFWL_MsgMouse ms; 406 CFWL_MsgMouse ms;
409 ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp; 407 ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp;
410 ms.m_dwFlags = dwFlags; 408 ms.m_dwFlags = dwFlags;
411 ms.m_fx = fx; 409 ms.m_fx = fx;
412 ms.m_fy = fy; 410 ms.m_fy = fy;
413 FWLToClient(ms.m_fx, ms.m_fy); 411 FWLToClient(ms.m_fx, ms.m_fy);
414 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); 412 ms.m_pDstTarget = m_pNormalWidget->GetWidget();
415 TranslateFWLMessage(&ms); 413 TranslateFWLMessage(&ms);
416 return TRUE; 414 return true;
417 } 415 }
418 FX_BOOL CXFA_FFField::OnLButtonDblClk(uint32_t dwFlags, 416 bool CXFA_FFField::OnLButtonDblClk(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
419 FX_FLOAT fx,
420 FX_FLOAT fy) {
421 if (!m_pNormalWidget) { 417 if (!m_pNormalWidget) {
422 return FALSE; 418 return false;
423 } 419 }
424 CFWL_MsgMouse ms; 420 CFWL_MsgMouse ms;
425 ms.m_dwCmd = FWL_MouseCommand::LeftButtonDblClk; 421 ms.m_dwCmd = FWL_MouseCommand::LeftButtonDblClk;
426 ms.m_dwFlags = dwFlags; 422 ms.m_dwFlags = dwFlags;
427 ms.m_fx = fx; 423 ms.m_fx = fx;
428 ms.m_fy = fy; 424 ms.m_fy = fy;
429 FWLToClient(ms.m_fx, ms.m_fy); 425 FWLToClient(ms.m_fx, ms.m_fy);
430 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); 426 ms.m_pDstTarget = m_pNormalWidget->GetWidget();
431 TranslateFWLMessage(&ms); 427 TranslateFWLMessage(&ms);
432 return TRUE; 428 return true;
433 } 429 }
434 FX_BOOL CXFA_FFField::OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { 430 bool CXFA_FFField::OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
435 if (!m_pNormalWidget) { 431 if (!m_pNormalWidget) {
436 return FALSE; 432 return false;
437 } 433 }
438 CFWL_MsgMouse ms; 434 CFWL_MsgMouse ms;
439 ms.m_dwCmd = FWL_MouseCommand::Move; 435 ms.m_dwCmd = FWL_MouseCommand::Move;
440 ms.m_dwFlags = dwFlags; 436 ms.m_dwFlags = dwFlags;
441 ms.m_fx = fx; 437 ms.m_fx = fx;
442 ms.m_fy = fy; 438 ms.m_fy = fy;
443 FWLToClient(ms.m_fx, ms.m_fy); 439 FWLToClient(ms.m_fx, ms.m_fy);
444 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); 440 ms.m_pDstTarget = m_pNormalWidget->GetWidget();
445 TranslateFWLMessage(&ms); 441 TranslateFWLMessage(&ms);
446 return TRUE; 442 return true;
447 } 443 }
448 FX_BOOL CXFA_FFField::OnMouseWheel(uint32_t dwFlags, 444 bool CXFA_FFField::OnMouseWheel(uint32_t dwFlags,
449 int16_t zDelta, 445 int16_t zDelta,
450 FX_FLOAT fx, 446 FX_FLOAT fx,
451 FX_FLOAT fy) { 447 FX_FLOAT fy) {
452 if (!m_pNormalWidget) { 448 if (!m_pNormalWidget) {
453 return FALSE; 449 return false;
454 } 450 }
455 CFWL_MsgMouseWheel ms; 451 CFWL_MsgMouseWheel ms;
456 ms.m_dwFlags = dwFlags; 452 ms.m_dwFlags = dwFlags;
457 ms.m_fx = fx; 453 ms.m_fx = fx;
458 ms.m_fy = fy; 454 ms.m_fy = fy;
459 FWLToClient(ms.m_fx, ms.m_fy); 455 FWLToClient(ms.m_fx, ms.m_fy);
460 ms.m_fDeltaX = zDelta; 456 ms.m_fDeltaX = zDelta;
461 ms.m_fDeltaY = 0; 457 ms.m_fDeltaY = 0;
462 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); 458 ms.m_pDstTarget = m_pNormalWidget->GetWidget();
463 TranslateFWLMessage(&ms); 459 TranslateFWLMessage(&ms);
464 return TRUE; 460 return true;
465 } 461 }
466 FX_BOOL CXFA_FFField::OnRButtonDown(uint32_t dwFlags, 462 bool CXFA_FFField::OnRButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
467 FX_FLOAT fx,
468 FX_FLOAT fy) {
469 if (!m_pNormalWidget) { 463 if (!m_pNormalWidget) {
470 return FALSE; 464 return false;
471 } 465 }
472 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || 466 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open ||
473 !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { 467 !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
474 return FALSE; 468 return false;
475 } 469 }
476 if (!PtInActiveRect(fx, fy)) { 470 if (!PtInActiveRect(fx, fy)) {
477 return FALSE; 471 return false;
478 } 472 }
479 SetButtonDown(TRUE); 473 SetButtonDown(true);
480 CFWL_MsgMouse ms; 474 CFWL_MsgMouse ms;
481 ms.m_dwCmd = FWL_MouseCommand::RightButtonDown; 475 ms.m_dwCmd = FWL_MouseCommand::RightButtonDown;
482 ms.m_dwFlags = dwFlags; 476 ms.m_dwFlags = dwFlags;
483 ms.m_fx = fx; 477 ms.m_fx = fx;
484 ms.m_fy = fy; 478 ms.m_fy = fy;
485 FWLToClient(ms.m_fx, ms.m_fy); 479 FWLToClient(ms.m_fx, ms.m_fy);
486 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); 480 ms.m_pDstTarget = m_pNormalWidget->GetWidget();
487 TranslateFWLMessage(&ms); 481 TranslateFWLMessage(&ms);
488 return TRUE; 482 return true;
489 } 483 }
490 FX_BOOL CXFA_FFField::OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { 484 bool CXFA_FFField::OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
491 if (!m_pNormalWidget) { 485 if (!m_pNormalWidget) {
492 return FALSE; 486 return false;
493 } 487 }
494 if (!IsButtonDown()) { 488 if (!IsButtonDown()) {
495 return FALSE; 489 return false;
496 } 490 }
497 SetButtonDown(FALSE); 491 SetButtonDown(false);
498 CFWL_MsgMouse ms; 492 CFWL_MsgMouse ms;
499 ms.m_dwCmd = FWL_MouseCommand::RightButtonUp; 493 ms.m_dwCmd = FWL_MouseCommand::RightButtonUp;
500 ms.m_dwFlags = dwFlags; 494 ms.m_dwFlags = dwFlags;
501 ms.m_fx = fx; 495 ms.m_fx = fx;
502 ms.m_fy = fy; 496 ms.m_fy = fy;
503 FWLToClient(ms.m_fx, ms.m_fy); 497 FWLToClient(ms.m_fx, ms.m_fy);
504 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); 498 ms.m_pDstTarget = m_pNormalWidget->GetWidget();
505 TranslateFWLMessage(&ms); 499 TranslateFWLMessage(&ms);
506 return TRUE; 500 return true;
507 } 501 }
508 FX_BOOL CXFA_FFField::OnRButtonDblClk(uint32_t dwFlags, 502 bool CXFA_FFField::OnRButtonDblClk(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
509 FX_FLOAT fx,
510 FX_FLOAT fy) {
511 if (!m_pNormalWidget) { 503 if (!m_pNormalWidget) {
512 return FALSE; 504 return false;
513 } 505 }
514 CFWL_MsgMouse ms; 506 CFWL_MsgMouse ms;
515 ms.m_dwCmd = FWL_MouseCommand::RightButtonDblClk; 507 ms.m_dwCmd = FWL_MouseCommand::RightButtonDblClk;
516 ms.m_dwFlags = dwFlags; 508 ms.m_dwFlags = dwFlags;
517 ms.m_fx = fx; 509 ms.m_fx = fx;
518 ms.m_fy = fy; 510 ms.m_fy = fy;
519 FWLToClient(ms.m_fx, ms.m_fy); 511 FWLToClient(ms.m_fx, ms.m_fy);
520 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); 512 ms.m_pDstTarget = m_pNormalWidget->GetWidget();
521 TranslateFWLMessage(&ms); 513 TranslateFWLMessage(&ms);
522 return TRUE; 514 return true;
523 } 515 }
524 516
525 FX_BOOL CXFA_FFField::OnSetFocus(CXFA_FFWidget* pOldWidget) { 517 bool CXFA_FFField::OnSetFocus(CXFA_FFWidget* pOldWidget) {
526 CXFA_FFWidget::OnSetFocus(pOldWidget); 518 CXFA_FFWidget::OnSetFocus(pOldWidget);
527 if (!m_pNormalWidget) { 519 if (!m_pNormalWidget) {
528 return FALSE; 520 return false;
529 } 521 }
530 CFWL_MsgSetFocus ms; 522 CFWL_MsgSetFocus ms;
531 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); 523 ms.m_pDstTarget = m_pNormalWidget->GetWidget();
532 ms.m_pSrcTarget = nullptr; 524 ms.m_pSrcTarget = nullptr;
533 TranslateFWLMessage(&ms); 525 TranslateFWLMessage(&ms);
534 m_dwStatus |= XFA_WidgetStatus_Focused; 526 m_dwStatus |= XFA_WidgetStatus_Focused;
535 AddInvalidateRect(); 527 AddInvalidateRect();
536 return TRUE; 528 return true;
537 } 529 }
538 FX_BOOL CXFA_FFField::OnKillFocus(CXFA_FFWidget* pNewWidget) { 530 bool CXFA_FFField::OnKillFocus(CXFA_FFWidget* pNewWidget) {
539 if (!m_pNormalWidget) { 531 if (!m_pNormalWidget) {
540 return CXFA_FFWidget::OnKillFocus(pNewWidget); 532 return CXFA_FFWidget::OnKillFocus(pNewWidget);
541 } 533 }
542 CFWL_MsgKillFocus ms; 534 CFWL_MsgKillFocus ms;
543 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); 535 ms.m_pDstTarget = m_pNormalWidget->GetWidget();
544 ms.m_pSrcTarget = nullptr; 536 ms.m_pSrcTarget = nullptr;
545 TranslateFWLMessage(&ms); 537 TranslateFWLMessage(&ms);
546 m_dwStatus &= ~XFA_WidgetStatus_Focused; 538 m_dwStatus &= ~XFA_WidgetStatus_Focused;
547 AddInvalidateRect(); 539 AddInvalidateRect();
548 CXFA_FFWidget::OnKillFocus(pNewWidget); 540 CXFA_FFWidget::OnKillFocus(pNewWidget);
549 return TRUE; 541 return true;
550 } 542 }
551 FX_BOOL CXFA_FFField::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) { 543 bool CXFA_FFField::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) {
552 if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { 544 if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
553 return FALSE; 545 return false;
554 } 546 }
555 CFWL_MsgKey ms; 547 CFWL_MsgKey ms;
556 ms.m_dwCmd = FWL_KeyCommand::KeyDown; 548 ms.m_dwCmd = FWL_KeyCommand::KeyDown;
557 ms.m_dwFlags = dwFlags; 549 ms.m_dwFlags = dwFlags;
558 ms.m_dwKeyCode = dwKeyCode; 550 ms.m_dwKeyCode = dwKeyCode;
559 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); 551 ms.m_pDstTarget = m_pNormalWidget->GetWidget();
560 ms.m_pSrcTarget = nullptr; 552 ms.m_pSrcTarget = nullptr;
561 TranslateFWLMessage(&ms); 553 TranslateFWLMessage(&ms);
562 return TRUE; 554 return true;
563 } 555 }
564 FX_BOOL CXFA_FFField::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) { 556 bool CXFA_FFField::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) {
565 if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { 557 if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
566 return FALSE; 558 return false;
567 } 559 }
568 CFWL_MsgKey ms; 560 CFWL_MsgKey ms;
569 ms.m_dwCmd = FWL_KeyCommand::KeyUp; 561 ms.m_dwCmd = FWL_KeyCommand::KeyUp;
570 ms.m_dwFlags = dwFlags; 562 ms.m_dwFlags = dwFlags;
571 ms.m_dwKeyCode = dwKeyCode; 563 ms.m_dwKeyCode = dwKeyCode;
572 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); 564 ms.m_pDstTarget = m_pNormalWidget->GetWidget();
573 ms.m_pSrcTarget = nullptr; 565 ms.m_pSrcTarget = nullptr;
574 TranslateFWLMessage(&ms); 566 TranslateFWLMessage(&ms);
575 return TRUE; 567 return true;
576 } 568 }
577 FX_BOOL CXFA_FFField::OnChar(uint32_t dwChar, uint32_t dwFlags) { 569 bool CXFA_FFField::OnChar(uint32_t dwChar, uint32_t dwFlags) {
578 if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { 570 if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
579 return FALSE; 571 return false;
580 } 572 }
581 if (dwChar == FWL_VKEY_Tab) { 573 if (dwChar == FWL_VKEY_Tab) {
582 return TRUE; 574 return true;
583 } 575 }
584 if (!m_pNormalWidget) { 576 if (!m_pNormalWidget) {
585 return FALSE; 577 return false;
586 } 578 }
587 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { 579 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) {
588 return FALSE; 580 return false;
589 } 581 }
590 CFWL_MsgKey ms; 582 CFWL_MsgKey ms;
591 ms.m_dwCmd = FWL_KeyCommand::Char; 583 ms.m_dwCmd = FWL_KeyCommand::Char;
592 ms.m_dwFlags = dwFlags; 584 ms.m_dwFlags = dwFlags;
593 ms.m_dwKeyCode = dwChar; 585 ms.m_dwKeyCode = dwChar;
594 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); 586 ms.m_pDstTarget = m_pNormalWidget->GetWidget();
595 ms.m_pSrcTarget = nullptr; 587 ms.m_pSrcTarget = nullptr;
596 TranslateFWLMessage(&ms); 588 TranslateFWLMessage(&ms);
597 return TRUE; 589 return true;
598 } 590 }
599 FWL_WidgetHit CXFA_FFField::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { 591 FWL_WidgetHit CXFA_FFField::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) {
600 if (m_pNormalWidget) { 592 if (m_pNormalWidget) {
601 FX_FLOAT ffx = fx, ffy = fy; 593 FX_FLOAT ffx = fx, ffy = fy;
602 FWLToClient(ffx, ffy); 594 FWLToClient(ffx, ffy);
603 if (m_pNormalWidget->HitTest(ffx, ffy) != FWL_WidgetHit::Unknown) 595 if (m_pNormalWidget->HitTest(ffx, ffy) != FWL_WidgetHit::Unknown)
604 return FWL_WidgetHit::Client; 596 return FWL_WidgetHit::Client;
605 } 597 }
606 CFX_RectF rtBox; 598 CFX_RectF rtBox;
607 GetRectWithoutRotate(rtBox); 599 GetRectWithoutRotate(rtBox);
608 if (!rtBox.Contains(fx, fy)) 600 if (!rtBox.Contains(fx, fy))
609 return FWL_WidgetHit::Unknown; 601 return FWL_WidgetHit::Unknown;
610 if (m_rtCaption.Contains(fx, fy)) 602 if (m_rtCaption.Contains(fx, fy))
611 return FWL_WidgetHit::Titlebar; 603 return FWL_WidgetHit::Titlebar;
612 return FWL_WidgetHit::Border; 604 return FWL_WidgetHit::Border;
613 } 605 }
614 FX_BOOL CXFA_FFField::OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) { 606 bool CXFA_FFField::OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) {
615 return TRUE; 607 return true;
616 } 608 }
617 FX_BOOL CXFA_FFField::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { 609 bool CXFA_FFField::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) {
618 if (!m_pNormalWidget) { 610 if (!m_pNormalWidget) {
619 return FALSE; 611 return false;
620 } 612 }
621 CFX_RectF rtWidget; 613 CFX_RectF rtWidget;
622 m_pNormalWidget->GetWidgetRect(rtWidget); 614 m_pNormalWidget->GetWidgetRect(rtWidget);
623 if (rtWidget.Contains(fx, fy)) { 615 if (rtWidget.Contains(fx, fy)) {
624 return TRUE; 616 return true;
625 } 617 }
626 return FALSE; 618 return false;
627 } 619 }
628 void CXFA_FFField::LayoutCaption() { 620 void CXFA_FFField::LayoutCaption() {
629 CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); 621 CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout();
630 if (!pCapTextLayout) 622 if (!pCapTextLayout)
631 return; 623 return;
632 624
633 FX_FLOAT fHeight = 0; 625 FX_FLOAT fHeight = 0;
634 pCapTextLayout->Layout(CFX_SizeF(m_rtCaption.width, m_rtCaption.height), 626 pCapTextLayout->Layout(CFX_SizeF(m_rtCaption.width, m_rtCaption.height),
635 &fHeight); 627 &fHeight);
636 if (m_rtCaption.height < fHeight) 628 if (m_rtCaption.height < fHeight)
(...skipping 16 matching lines...) Expand all
653 CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); 645 CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice();
654 CFX_Matrix mt; 646 CFX_Matrix mt;
655 mt.Set(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top); 647 mt.Set(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top);
656 if (pMatrix) { 648 if (pMatrix) {
657 pMatrix->TransformRect(rtClip); 649 pMatrix->TransformRect(rtClip);
658 mt.Concat(*pMatrix); 650 mt.Concat(*pMatrix);
659 } 651 }
660 pCapTextLayout->DrawString(pRenderDevice, mt, rtClip); 652 pCapTextLayout->DrawString(pRenderDevice, mt, rtClip);
661 } 653 }
662 } 654 }
663 FX_BOOL CXFA_FFField::ProcessCommittedData() { 655 bool CXFA_FFField::ProcessCommittedData() {
664 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { 656 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) {
665 return FALSE; 657 return false;
666 } 658 }
667 if (!IsDataChanged()) { 659 if (!IsDataChanged()) {
668 return FALSE; 660 return false;
669 } 661 }
670 if (CalculateOverride() != 1) { 662 if (CalculateOverride() != 1) {
671 return FALSE; 663 return false;
672 } 664 }
673 if (!CommitData()) { 665 if (!CommitData()) {
674 return FALSE; 666 return false;
675 } 667 }
676 m_pDocView->SetChangeMark(); 668 m_pDocView->SetChangeMark();
677 m_pDocView->AddValidateWidget(m_pDataAcc); 669 m_pDocView->AddValidateWidget(m_pDataAcc);
678 return TRUE; 670 return true;
679 } 671 }
680 int32_t CXFA_FFField::CalculateOverride() { 672 int32_t CXFA_FFField::CalculateOverride() {
681 CXFA_WidgetAcc* pAcc = m_pDataAcc->GetExclGroup(); 673 CXFA_WidgetAcc* pAcc = m_pDataAcc->GetExclGroup();
682 if (!pAcc) { 674 if (!pAcc) {
683 return CalculateWidgetAcc(m_pDataAcc); 675 return CalculateWidgetAcc(m_pDataAcc);
684 } 676 }
685 if (CalculateWidgetAcc(pAcc) == 0) { 677 if (CalculateWidgetAcc(pAcc) == 0) {
686 return 0; 678 return 0;
687 } 679 }
688 CXFA_Node* pNode = pAcc->GetExclGroupFirstMember(); 680 CXFA_Node* pNode = pAcc->GetExclGroupFirstMember();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 case XFA_ATTRIBUTEENUM_Ignore: 758 case XFA_ATTRIBUTEENUM_Ignore:
767 return 0; 759 return 0;
768 case XFA_ATTRIBUTEENUM_Disabled: 760 case XFA_ATTRIBUTEENUM_Disabled:
769 pAcc->GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false); 761 pAcc->GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false);
770 default: 762 default:
771 return 1; 763 return 1;
772 } 764 }
773 } 765 }
774 return 1; 766 return 1;
775 } 767 }
776 FX_BOOL CXFA_FFField::CommitData() { 768 bool CXFA_FFField::CommitData() {
777 return FALSE; 769 return false;
778 } 770 }
779 FX_BOOL CXFA_FFField::IsDataChanged() { 771 bool CXFA_FFField::IsDataChanged() {
780 return FALSE; 772 return false;
781 } 773 }
782 void CXFA_FFField::TranslateFWLMessage(CFWL_Message* pMessage) { 774 void CXFA_FFField::TranslateFWLMessage(CFWL_Message* pMessage) {
783 GetApp()->GetWidgetMgrDelegate()->OnProcessMessageToForm(pMessage); 775 GetApp()->GetWidgetMgrDelegate()->OnProcessMessageToForm(pMessage);
784 } 776 }
785 void CXFA_FFField::OnProcessMessage(CFWL_Message* pMessage) {} 777 void CXFA_FFField::OnProcessMessage(CFWL_Message* pMessage) {}
786 778
787 void CXFA_FFField::OnProcessEvent(CFWL_Event* pEvent) { 779 void CXFA_FFField::OnProcessEvent(CFWL_Event* pEvent) {
788 switch (pEvent->GetClassID()) { 780 switch (pEvent->GetClassID()) {
789 case CFWL_EventType::Mouse: { 781 case CFWL_EventType::Mouse: {
790 CFWL_EvtMouse* event = (CFWL_EvtMouse*)pEvent; 782 CFWL_EvtMouse* event = (CFWL_EvtMouse*)pEvent;
(...skipping 27 matching lines...) Expand all
818 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); 810 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam);
819 break; 811 break;
820 } 812 }
821 default: 813 default:
822 break; 814 break;
823 } 815 }
824 } 816 }
825 817
826 void CXFA_FFField::OnDrawWidget(CFX_Graphics* pGraphics, 818 void CXFA_FFField::OnDrawWidget(CFX_Graphics* pGraphics,
827 const CFX_Matrix* pMatrix) {} 819 const CFX_Matrix* pMatrix) {}
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_fffield.h ('k') | xfa/fxfa/app/xfa_ffimage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698