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

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

Issue 2491103002: IFWL method and param cleanup (Closed)
Patch Set: Review feedback 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/fwl/core/ifwl_barcode.h ('k') | xfa/fwl/core/ifwl_combobox.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/ifwl_barcode.h" 7 #include "xfa/fwl/core/ifwl_barcode.h"
8 8
9 #include "third_party/base/ptr_util.h" 9 #include "third_party/base/ptr_util.h"
10 #include "xfa/fgas/font/fgas_gefont.h" 10 #include "xfa/fgas/font/fgas_gefont.h"
(...skipping 27 matching lines...) Expand all
38 if (!pGraphics) 38 if (!pGraphics)
39 return; 39 return;
40 if (!m_pProperties->m_pThemeProvider) 40 if (!m_pProperties->m_pThemeProvider)
41 return; 41 return;
42 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { 42 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
43 GenerateBarcodeImageCache(); 43 GenerateBarcodeImageCache();
44 if (!m_pBarcodeEngine || (m_dwStatus & XFA_BCS_EncodeSuccess) == 0) { 44 if (!m_pBarcodeEngine || (m_dwStatus & XFA_BCS_EncodeSuccess) == 0) {
45 return; 45 return;
46 } 46 }
47 CFX_Matrix mt; 47 CFX_Matrix mt;
48 mt.e = m_rtClient.left; 48 mt.e = GetRTClient().left;
49 mt.f = m_rtClient.top; 49 mt.f = GetRTClient().top;
50 if (pMatrix) { 50 if (pMatrix) {
51 mt.Concat(*pMatrix); 51 mt.Concat(*pMatrix);
52 } 52 }
53 int32_t errorCode = 0; 53 int32_t errorCode = 0;
54 m_pBarcodeEngine->RenderDevice(pGraphics->GetRenderDevice(), pMatrix, 54 m_pBarcodeEngine->RenderDevice(pGraphics->GetRenderDevice(), pMatrix,
55 errorCode); 55 errorCode);
56 return; 56 return;
57 } 57 }
58 IFWL_Edit::DrawWidget(pGraphics, pMatrix); 58 IFWL_Edit::DrawWidget(pGraphics, pMatrix);
59 } 59 }
60 void IFWL_Barcode::GenerateBarcodeImageCache() { 60 void IFWL_Barcode::GenerateBarcodeImageCache() {
61 if ((m_dwStatus & XFA_BCS_NeedUpdate) == 0) 61 if ((m_dwStatus & XFA_BCS_NeedUpdate) == 0)
62 return; 62 return;
63 m_dwStatus = 0; 63 m_dwStatus = 0;
64 CreateBarcodeEngine(); 64 CreateBarcodeEngine();
65 IFWL_BarcodeDP* pData = 65 IFWL_BarcodeDP* pData =
66 static_cast<IFWL_BarcodeDP*>(m_pProperties->m_pDataProvider); 66 static_cast<IFWL_BarcodeDP*>(m_pProperties->m_pDataProvider);
67 if (!pData) 67 if (!pData)
68 return; 68 return;
69 if (!m_pBarcodeEngine) 69 if (!m_pBarcodeEngine)
70 return; 70 return;
71 CFX_WideString wsText; 71 CFX_WideString wsText;
72 if (GetText(wsText) != FWL_Error::Succeeded) 72 GetText(wsText);
73 return; 73
74 CFWL_ThemePart part; 74 CFWL_ThemePart part;
75 part.m_pWidget = this; 75 part.m_pWidget = this;
76 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); 76 IFWL_ThemeProvider* pTheme = GetAvailableTheme();
77 CFGAS_GEFont* pFont = static_cast<CFGAS_GEFont*>( 77 CFGAS_GEFont* pFont = static_cast<CFGAS_GEFont*>(
78 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Font)); 78 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Font));
79 CFX_Font* pCXFont = pFont ? pFont->GetDevFont() : nullptr; 79 CFX_Font* pCXFont = pFont ? pFont->GetDevFont() : nullptr;
80 if (pCXFont) { 80 if (pCXFont) {
81 m_pBarcodeEngine->SetFont(pCXFont); 81 m_pBarcodeEngine->SetFont(pCXFont);
82 } 82 }
83 FX_FLOAT* pFontSize = static_cast<FX_FLOAT*>( 83 FX_FLOAT* pFontSize = static_cast<FX_FLOAT*>(
84 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::FontSize)); 84 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::FontSize));
85 if (pFontSize) { 85 if (pFontSize) {
86 m_pBarcodeEngine->SetFontSize(*pFontSize); 86 m_pBarcodeEngine->SetFontSize(*pFontSize);
87 } 87 }
88 FX_ARGB* pFontColor = static_cast<FX_ARGB*>( 88 FX_ARGB* pFontColor = static_cast<FX_ARGB*>(
89 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TextColor)); 89 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TextColor));
90 if (pFontColor) { 90 if (pFontColor) {
91 m_pBarcodeEngine->SetFontColor(*pFontColor); 91 m_pBarcodeEngine->SetFontColor(*pFontColor);
92 } 92 }
93 m_pBarcodeEngine->SetHeight(int32_t(m_rtClient.height)); 93 m_pBarcodeEngine->SetHeight(int32_t(GetRTClient().height));
94 m_pBarcodeEngine->SetWidth(int32_t(m_rtClient.width)); 94 m_pBarcodeEngine->SetWidth(int32_t(GetRTClient().width));
95 uint32_t dwAttributeMask = pData->GetBarcodeAttributeMask(); 95 uint32_t dwAttributeMask = pData->GetBarcodeAttributeMask();
96 if (dwAttributeMask & FWL_BCDATTRIBUTE_CHARENCODING) { 96 if (dwAttributeMask & FWL_BCDATTRIBUTE_CHARENCODING) {
97 m_pBarcodeEngine->SetCharEncoding(pData->GetCharEncoding()); 97 m_pBarcodeEngine->SetCharEncoding(pData->GetCharEncoding());
98 } 98 }
99 if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEHEIGHT) { 99 if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEHEIGHT) {
100 m_pBarcodeEngine->SetModuleHeight(pData->GetModuleHeight()); 100 m_pBarcodeEngine->SetModuleHeight(pData->GetModuleHeight());
101 } 101 }
102 if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEWIDTH) { 102 if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEWIDTH) {
103 m_pBarcodeEngine->SetModuleWidth(pData->GetModuleWidth()); 103 m_pBarcodeEngine->SetModuleWidth(pData->GetModuleWidth());
104 } 104 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 149
150 void IFWL_Barcode::SetType(BC_TYPE type) { 150 void IFWL_Barcode::SetType(BC_TYPE type) {
151 if (m_type == type) 151 if (m_type == type)
152 return; 152 return;
153 153
154 m_pBarcodeEngine.reset(); 154 m_pBarcodeEngine.reset();
155 m_type = type; 155 m_type = type;
156 m_dwStatus = XFA_BCS_NeedUpdate; 156 m_dwStatus = XFA_BCS_NeedUpdate;
157 } 157 }
158 FWL_Error IFWL_Barcode::SetText(const CFX_WideString& wsText) { 158 void IFWL_Barcode::SetText(const CFX_WideString& wsText) {
159 m_pBarcodeEngine.reset(); 159 m_pBarcodeEngine.reset();
160 m_dwStatus = XFA_BCS_NeedUpdate; 160 m_dwStatus = XFA_BCS_NeedUpdate;
161 return IFWL_Edit::SetText(wsText); 161 IFWL_Edit::SetText(wsText);
162 } 162 }
163 bool IFWL_Barcode::IsProtectedType() { 163 bool IFWL_Barcode::IsProtectedType() {
164 if (!m_pBarcodeEngine) { 164 if (!m_pBarcodeEngine) {
165 return true; 165 return true;
166 } 166 }
167 BC_TYPE tEngineType = m_pBarcodeEngine->GetType(); 167 BC_TYPE tEngineType = m_pBarcodeEngine->GetType();
168 if (tEngineType == BC_QR_CODE || tEngineType == BC_PDF417 || 168 if (tEngineType == BC_QR_CODE || tEngineType == BC_PDF417 ||
169 tEngineType == BC_DATAMATRIX) { 169 tEngineType == BC_DATAMATRIX) {
170 return true; 170 return true;
171 } 171 }
172 return false; 172 return false;
173 } 173 }
174 174
175 void IFWL_Barcode::OnProcessEvent(CFWL_Event* pEvent) { 175 void IFWL_Barcode::OnProcessEvent(CFWL_Event* pEvent) {
176 if (pEvent->GetClassID() == CFWL_EventType::TextChanged) { 176 if (pEvent->GetClassID() == CFWL_EventType::TextChanged) {
177 m_pBarcodeEngine.reset(); 177 m_pBarcodeEngine.reset();
178 m_dwStatus = XFA_BCS_NeedUpdate; 178 m_dwStatus = XFA_BCS_NeedUpdate;
179 } 179 }
180 IFWL_Edit::OnProcessEvent(pEvent); 180 IFWL_Edit::OnProcessEvent(pEvent);
181 } 181 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_barcode.h ('k') | xfa/fwl/core/ifwl_combobox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698