7#include "xfa/fwl/cfwl_barcode.h"
9#include "fxbarcode/cfx_barcode.h"
10#include "xfa/fgas/font/cfgas_gefont.h"
11#include "xfa/fwl/cfwl_notedriver.h"
12#include "xfa/fwl/cfwl_themepart.h"
13#include "xfa/fwl/ifwl_themeprovider.h"
14#include "xfa/fwl/theme/cfwl_utils.h"
16CFWL_Barcode::CFWL_Barcode(CFWL_App* app)
30 GenerateBarcodeImageCache();
39 GenerateBarcodeImageCache();
40 if (!m_pBarcodeEngine || m_eStatus != Status::kEncodeSuccess)
49 m_pBarcodeEngine->RenderDevice(pGraphics->GetRenderDevice(), matrix);
59 m_pBarcodeEngine.reset();
61 m_eStatus = Status::kNeedUpdate;
64void CFWL_Barcode::
SetText(
const WideString& wsText) {
65 m_pBarcodeEngine.reset();
66 m_eStatus = Status::kNeedUpdate;
71 m_pBarcodeEngine.reset();
72 m_eStatus = Status::kNeedUpdate;
77 if (!m_pBarcodeEngine)
80 BC_TYPE tEngineType = m_pBarcodeEngine->GetType();
87 m_pBarcodeEngine.reset();
88 m_eStatus = Status::kNeedUpdate;
94 m_eCharEncoding = encoding;
98 m_nModuleHeight = height;
102 m_nModuleWidth = width;
106 m_nDataLength = dataLength;
111 m_bCalChecksum = calChecksum;
115 m_bPrintChecksum = printChecksum;
119 m_eTextLocation = location;
123 m_nWideNarrowRatio = ratio;
127 m_cStartChar = startChar;
131 m_cEndChar = endChar;
135 m_nECLevel = ecLevel;
138void CFWL_Barcode::GenerateBarcodeImageCache() {
139 if (m_eStatus != Status::kNeedUpdate)
142 m_eStatus = Status::kNormal;
143 CreateBarcodeEngine();
144 if (!m_pBarcodeEngine)
149 if (RetainPtr<CFGAS_GEFont> pFont = pTheme->GetFont(part)) {
150 if (CFX_Font* pCXFont = pFont->GetDevFont())
151 m_pBarcodeEngine->SetFont(pCXFont);
153 m_pBarcodeEngine->SetFontSize(pTheme->GetFontSize(part));
154 m_pBarcodeEngine->SetFontColor(pTheme->GetTextColor(part));
155 m_pBarcodeEngine->SetHeight(int32_t(GetRTClient().height));
156 m_pBarcodeEngine->SetWidth(int32_t(GetRTClient().width));
157 if (m_eCharEncoding.has_value())
158 m_pBarcodeEngine->SetCharEncoding(m_eCharEncoding.value());
159 if (m_nModuleHeight.has_value())
160 m_pBarcodeEngine->SetModuleHeight(m_nModuleHeight.value());
161 if (m_nModuleWidth.has_value())
162 m_pBarcodeEngine->SetModuleWidth(m_nModuleWidth.value());
163 if (m_nDataLength.has_value())
164 m_pBarcodeEngine->SetDataLength(m_nDataLength.value());
165 if (m_bCalChecksum.has_value())
166 m_pBarcodeEngine->SetCalChecksum(m_bCalChecksum.value());
167 if (m_bPrintChecksum.has_value())
168 m_pBarcodeEngine->SetPrintChecksum(m_bPrintChecksum.value());
169 if (m_eTextLocation.has_value())
170 m_pBarcodeEngine->SetTextLocation(m_eTextLocation.value());
171 if (m_nWideNarrowRatio.has_value())
172 m_pBarcodeEngine->SetWideNarrowRatio(m_nWideNarrowRatio.value());
173 if (m_cStartChar.has_value())
174 m_pBarcodeEngine->SetStartChar(m_cStartChar.value());
175 if (m_cEndChar.has_value())
176 m_pBarcodeEngine->SetEndChar(m_cEndChar.value());
177 if (m_nECLevel.has_value())
178 m_pBarcodeEngine->SetErrorCorrectionLevel(m_nECLevel.value());
180 m_eStatus = m_pBarcodeEngine->Encode(GetText().AsStringView())
181 ? Status::kEncodeSuccess
185void CFWL_Barcode::CreateBarcodeEngine() {
186 if (m_pBarcodeEngine || m_type == BC_TYPE::kUnknown)
189 m_pBarcodeEngine = CFX_Barcode::Create(m_type);
void SetDataLength(int32_t dataLength)
FWL_Type GetClassID() const override
void SetType(BC_TYPE type)
void SetCalChecksum(bool calChecksum)
void SetWideNarrowRatio(int8_t ratio)
void OnProcessEvent(CFWL_Event *pEvent) override
void DrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
void SetPrintChecksum(bool printChecksum)
void SetTextLocation(BC_TEXT_LOC location)
void SetStartChar(char startChar)
void SetText(const WideString &wsText) override
void SetEndChar(char endChar)
void SetModuleHeight(int32_t height)
void SetErrorCorrectionLevel(int32_t ecLevel)
void SetTextSkipNotify(const WideString &wsText) override
void SetModuleWidth(int32_t width)
bool IsProtectedType() const
void SetCharEncoding(BC_CHAR_ENCODING encoding)
virtual void SetText(const WideString &wsText)
void SetLimit(int32_t nLimit)
const CFX_RectF & GetRTClient() const
void DrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
CFWL_Edit(CFWL_App *app, const Properties &properties, CFWL_Widget *pOuter)
void OnProcessEvent(CFWL_Event *pEvent) override
virtual void SetTextSkipNotify(const WideString &wsText)
void Concat(const CFX_Matrix &right)