1 // Copyright 2014 The PDFium Authors 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 <stdint.h> 11 12 #include <memory> 13 14 #include "fxbarcode/BC_Library.h" 15 #include "third_party/abseil-cpp/absl/types/optional.h" 16 #include "xfa/fwl/cfwl_edit.h" 17 18 class CFX_Barcode; 19 20 class CFWL_Barcode final : public CFWL_Edit { 21 public: 22 CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED; 23 ~CFWL_Barcode() override; 24 25 // CFWL_Widget 26 FWL_Type GetClassID() const override; 27 void Update() override; 28 void DrawWidget(CFGAS_GEGraphics* pGraphics, 29 const CFX_Matrix& matrix) override; 30 void OnProcessEvent(CFWL_Event* pEvent) override; 31 32 // CFWL_Edit 33 void SetText(const WideString& wsText) override; 34 void SetTextSkipNotify(const WideString& wsText) override; 35 36 void SetType(BC_TYPE type); 37 bool IsProtectedType() const; 38 39 void SetCharEncoding(BC_CHAR_ENCODING encoding); 40 void SetModuleHeight(int32_t height); 41 void SetModuleWidth(int32_t width); 42 void SetDataLength(int32_t dataLength); 43 void SetCalChecksum(bool calChecksum); 44 void SetPrintChecksum(bool printChecksum); 45 void SetTextLocation(BC_TEXT_LOC location); 46 void SetWideNarrowRatio(int8_t ratio); 47 void SetStartChar(char startChar); 48 void SetEndChar(char endChar); 49 void SetErrorCorrectionLevel(int32_t ecLevel); 50 51 private: 52 enum class Status : uint8_t { 53 kNormal, 54 kNeedUpdate, 55 kEncodeSuccess, 56 }; 57 58 explicit CFWL_Barcode(CFWL_App* pApp); 59 60 void GenerateBarcodeImageCache(); 61 void CreateBarcodeEngine(); 62 63 BC_TYPE m_type = BC_TYPE::kUnknown; 64 Status m_eStatus = Status::kNormal; 65 absl::optional<BC_TEXT_LOC> m_eTextLocation; 66 absl::optional<BC_CHAR_ENCODING> m_eCharEncoding; 67 absl::optional<bool> m_bCalChecksum; 68 absl::optional<bool> m_bPrintChecksum; 69 absl::optional<char> m_cStartChar; 70 absl::optional<char> m_cEndChar; 71 absl::optional<int8_t> m_nWideNarrowRatio; 72 absl::optional<int32_t> m_nModuleHeight; 73 absl::optional<int32_t> m_nModuleWidth; 74 absl::optional<int32_t> m_nDataLength; 75 absl::optional<int32_t> m_nECLevel; 76 std::unique_ptr<CFX_Barcode> m_pBarcodeEngine; 77 }; 78 79 #endif // XFA_FWL_CFWL_BARCODE_H_ 80