1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef XFA_FWL_CFWL_BARCODE_H_ 8 #define XFA_FWL_CFWL_BARCODE_H_ 9 10 #include <memory> 11 12 #include "fxbarcode/BC_Library.h" 13 #include "xfa/fwl/cfwl_edit.h" 14 15 class CFX_Barcode; 16 17 enum FWL_BCDAttribute { 18 FWL_BCDATTRIBUTE_NONE = 0, 19 FWL_BCDATTRIBUTE_CHARENCODING = 1 << 0, 20 FWL_BCDATTRIBUTE_MODULEHEIGHT = 1 << 1, 21 FWL_BCDATTRIBUTE_MODULEWIDTH = 1 << 2, 22 FWL_BCDATTRIBUTE_DATALENGTH = 1 << 3, 23 FWL_BCDATTRIBUTE_CALCHECKSUM = 1 << 4, 24 FWL_BCDATTRIBUTE_PRINTCHECKSUM = 1 << 5, 25 FWL_BCDATTRIBUTE_TEXTLOCATION = 1 << 6, 26 FWL_BCDATTRIBUTE_WIDENARROWRATIO = 1 << 7, 27 FWL_BCDATTRIBUTE_STARTCHAR = 1 << 8, 28 FWL_BCDATTRIBUTE_ENDCHAR = 1 << 9, 29 FWL_BCDATTRIBUTE_ECLEVEL = 1 << 10, 30 }; 31 32 class CFWL_Barcode final : public CFWL_Edit { 33 public: 34 explicit CFWL_Barcode(const CFWL_App* pApp); 35 ~CFWL_Barcode() override; 36 37 // CFWL_Widget 38 FWL_Type GetClassID() const override; 39 void Update() override; 40 void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override; 41 void OnProcessEvent(CFWL_Event* pEvent) override; 42 43 // CFWL_Edit 44 void SetText(const WideString& wsText) override; 45 void SetTextSkipNotify(const WideString& wsText) override; 46 47 void SetType(BC_TYPE type); 48 bool IsProtectedType() const; 49 50 void SetCharEncoding(BC_CHAR_ENCODING encoding); 51 void SetModuleHeight(int32_t height); 52 void SetModuleWidth(int32_t width); 53 void SetDataLength(int32_t dataLength); 54 void SetCalChecksum(bool calChecksum); 55 void SetPrintChecksum(bool printChecksum); 56 void SetTextLocation(BC_TEXT_LOC location); 57 void SetWideNarrowRatio(int8_t ratio); 58 void SetStartChar(char startChar); 59 void SetEndChar(char endChar); 60 void SetErrorCorrectionLevel(int32_t ecLevel); 61 62 private: 63 enum class Status : uint8_t { 64 kNormal, 65 kNeedUpdate, 66 kEncodeSuccess, 67 }; 68 69 void GenerateBarcodeImageCache(); 70 void CreateBarcodeEngine(); 71 72 BC_TYPE m_type = BC_UNKNOWN; 73 BC_CHAR_ENCODING m_eCharEncoding = CHAR_ENCODING_UTF8; 74 BC_TEXT_LOC m_eTextLocation = BC_TEXT_LOC_NONE; 75 Status m_eStatus = Status::kNormal; 76 bool m_bCalChecksum = false; 77 bool m_bPrintChecksum = false; 78 char m_cStartChar = 0; 79 char m_cEndChar = 0; 80 int8_t m_nWideNarrowRatio = 1; 81 int32_t m_nModuleHeight = -1; 82 int32_t m_nModuleWidth = -1; 83 int32_t m_nDataLength = 0; 84 int32_t m_nECLevel = 0; 85 uint32_t m_dwAttributeMask = 0; 86 std::unique_ptr<CFX_Barcode> m_pBarcodeEngine; 87 }; 88 89 #endif // XFA_FWL_CFWL_BARCODE_H_ 90