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"
18CFWL_Barcode::CFWL_Barcode(CFWL_App* app)
32 GenerateBarcodeImageCache();
41 GenerateBarcodeImageCache();
42 if (!m_pBarcodeEngine || m_eStatus != Status::kEncodeSuccess)
51 m_pBarcodeEngine->RenderDevice(pGraphics->GetRenderDevice(), matrix);
61 m_pBarcodeEngine.reset();
63 m_eStatus = Status::kNeedUpdate;
67 m_pBarcodeEngine.reset();
68 m_eStatus = Status::kNeedUpdate;
73 m_pBarcodeEngine.reset();
74 m_eStatus = Status::kNeedUpdate;
79 if (!m_pBarcodeEngine)
82 BC_TYPE tEngineType = m_pBarcodeEngine->GetType();
89 m_pBarcodeEngine.reset();
90 m_eStatus = Status::kNeedUpdate;
96 m_nModuleHeight = height;
100 m_nModuleWidth = width;
104 m_nDataLength = dataLength;
109 m_bCalChecksum = calChecksum;
113 m_bPrintChecksum = printChecksum;
117 m_eTextLocation = location;
121 m_nWideNarrowRatio = ratio;
125 m_cStartChar = startChar;
129 m_cEndChar = endChar;
133 m_nECLevel = ecLevel;
136void CFWL_Barcode::GenerateBarcodeImageCache() {
137 if (m_eStatus != Status::kNeedUpdate)
140 m_eStatus = Status::kNormal;
141 CreateBarcodeEngine();
142 if (!m_pBarcodeEngine)
147 if (RetainPtr<CFGAS_GEFont> pFont = pTheme->GetFont(part)) {
148 if (CFX_Font* pCXFont = pFont->GetDevFont())
149 m_pBarcodeEngine->SetFont(pCXFont);
151 m_pBarcodeEngine->SetFontSize(pTheme->GetFontSize(part));
152 m_pBarcodeEngine->SetFontColor(pTheme->GetTextColor(part));
153 m_pBarcodeEngine->SetHeight(int32_t(GetRTClient().height));
154 m_pBarcodeEngine->SetWidth(int32_t(GetRTClient().width));
155 if (m_nModuleHeight.has_value())
156 m_pBarcodeEngine->SetModuleHeight(m_nModuleHeight.value());
157 if (m_nModuleWidth.has_value())
158 m_pBarcodeEngine->SetModuleWidth(m_nModuleWidth.value());
159 if (m_nDataLength.has_value())
160 m_pBarcodeEngine->SetDataLength(m_nDataLength.value());
161 if (m_bCalChecksum.has_value())
162 m_pBarcodeEngine->SetCalChecksum(m_bCalChecksum.value());
163 if (m_bPrintChecksum.has_value())
164 m_pBarcodeEngine->SetPrintChecksum(m_bPrintChecksum.value());
165 if (m_eTextLocation.has_value())
166 m_pBarcodeEngine->SetTextLocation(m_eTextLocation.value());
167 if (m_nWideNarrowRatio.has_value())
168 m_pBarcodeEngine->SetWideNarrowRatio(m_nWideNarrowRatio.value());
169 if (m_cStartChar.has_value())
170 m_pBarcodeEngine->SetStartChar(m_cStartChar.value());
171 if (m_cEndChar.has_value())
172 m_pBarcodeEngine->SetEndChar(m_cEndChar.value());
173 if (m_nECLevel.has_value())
174 m_pBarcodeEngine->SetErrorCorrectionLevel(m_nECLevel.value());
176 m_eStatus = m_pBarcodeEngine->Encode(GetText().AsStringView())
177 ? Status::kEncodeSuccess
181void CFWL_Barcode::CreateBarcodeEngine() {
182 if (m_pBarcodeEngine || m_type == BC_TYPE::kUnknown)
185 m_pBarcodeEngine = CFX_Barcode::Create(m_type);
void Concat(const CFX_Matrix &right)
void SetModuleWidth(int32_t width)
void SetModuleHeight(int32_t height)
void SetType(BC_TYPE type)
void DrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
void SetCalChecksum(bool calChecksum)
void SetErrorCorrectionLevel(int32_t ecLevel)
void OnProcessEvent(CFWL_Event *pEvent) override
void SetWideNarrowRatio(int8_t ratio)
void SetEndChar(char endChar)
void SetDataLength(int32_t dataLength)
void SetStartChar(char startChar)
void SetTextSkipNotify(const WideString &wsText) override
FWL_Type GetClassID() const override
void SetPrintChecksum(bool printChecksum)
void SetText(const WideString &wsText) override
bool IsProtectedType() const
void SetTextLocation(BC_TEXT_LOC location)
virtual void SetTextSkipNotify(const WideString &wsText)
void DrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
CFWL_Edit(CFWL_App *app, const Properties &properties, CFWL_Widget *pOuter)
const CFX_RectF & GetRTClient() const
void SetLimit(int32_t nLimit)
virtual void SetText(const WideString &wsText)
void OnProcessEvent(CFWL_Event *pEvent) override
fxcrt::WideString WideString