• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "xfa/fwl/cfwl_scrollbar.h"
15 #include "xfa/fwl/cfwl_widget.h"
16 
17 class CFWL_WidgetProperties;
18 class CFX_Barcode;
19 class CFWL_Widget;
20 
21 #define XFA_BCS_NeedUpdate 0x0001
22 #define XFA_BCS_EncodeSuccess 0x0002
23 
24 enum FWL_BCDAttribute {
25   FWL_BCDATTRIBUTE_NONE = 0,
26   FWL_BCDATTRIBUTE_CHARENCODING = 1 << 0,
27   FWL_BCDATTRIBUTE_MODULEHEIGHT = 1 << 1,
28   FWL_BCDATTRIBUTE_MODULEWIDTH = 1 << 2,
29   FWL_BCDATTRIBUTE_DATALENGTH = 1 << 3,
30   FWL_BCDATTRIBUTE_CALCHECKSUM = 1 << 4,
31   FWL_BCDATTRIBUTE_PRINTCHECKSUM = 1 << 5,
32   FWL_BCDATTRIBUTE_TEXTLOCATION = 1 << 6,
33   FWL_BCDATTRIBUTE_WIDENARROWRATIO = 1 << 7,
34   FWL_BCDATTRIBUTE_STARTCHAR = 1 << 8,
35   FWL_BCDATTRIBUTE_ENDCHAR = 1 << 9,
36   FWL_BCDATTRIBUTE_ECLEVEL = 1 << 10,
37   FWL_BCDATTRIBUTE_TRUNCATED = 1 << 11,
38 };
39 
40 class CFWL_Barcode : public CFWL_Edit {
41  public:
42   explicit CFWL_Barcode(const CFWL_App* pApp);
43   ~CFWL_Barcode() override;
44 
45   // CFWL_Widget
46   FWL_Type GetClassID() const override;
47   void Update() override;
48   void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
49   void OnProcessEvent(CFWL_Event* pEvent) override;
50 
51   // CFWL_Edit
52   void SetText(const WideString& wsText) override;
53 
54   void SetType(BC_TYPE type);
55   bool IsProtectedType() const;
56 
57   void SetCharEncoding(BC_CHAR_ENCODING encoding);
58   void SetModuleHeight(int32_t height);
59   void SetModuleWidth(int32_t width);
60   void SetDataLength(int32_t dataLength);
61   void SetCalChecksum(bool calChecksum);
62   void SetPrintChecksum(bool printChecksum);
63   void SetTextLocation(BC_TEXT_LOC location);
64   void SetWideNarrowRatio(int8_t ratio);
65   void SetStartChar(char startChar);
66   void SetEndChar(char endChar);
67   void SetErrorCorrectionLevel(int32_t ecLevel);
68   void SetTruncated(bool truncated);
69 
70  private:
71   void GenerateBarcodeImageCache();
72   void CreateBarcodeEngine();
73 
74   std::unique_ptr<CFX_Barcode> m_pBarcodeEngine;
75   uint32_t m_dwStatus;
76   BC_TYPE m_type;
77   BC_CHAR_ENCODING m_eCharEncoding;
78   int32_t m_nModuleHeight;
79   int32_t m_nModuleWidth;
80   int32_t m_nDataLength;
81   bool m_bCalChecksum;
82   bool m_bPrintChecksum;
83   BC_TEXT_LOC m_eTextLocation;
84   int8_t m_nWideNarrowRatio;
85   char m_cStartChar;
86   char m_cEndChar;
87   int32_t m_nECLevel;
88   bool m_bTruncated;
89   uint32_t m_dwAttributeMask;
90 };
91 
92 #endif  // XFA_FWL_CFWL_BARCODE_H_
93