• 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 "xfa/fwl/cfwl_edit.h"
13 #include "xfa/fwl/cfwl_scrollbar.h"
14 #include "xfa/fwl/cfwl_widget.h"
15 #include "xfa/fxbarcode/BC_Library.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_VERSION = 1 << 10,
37   FWL_BCDATTRIBUTE_ECLEVEL = 1 << 11,
38   FWL_BCDATTRIBUTE_TRUNCATED = 1 << 12
39 };
40 
41 class CFWL_Barcode : public CFWL_Edit {
42  public:
43   explicit CFWL_Barcode(const CFWL_App* pApp);
44   ~CFWL_Barcode() override;
45 
46   // CFWL_Widget
47   FWL_Type GetClassID() const override;
48   void Update() override;
49   void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
50   void OnProcessEvent(CFWL_Event* pEvent) override;
51 
52   // CFWL_Edit
53   void SetText(const CFX_WideString& wsText) override;
54 
55   void SetType(BC_TYPE type);
56   bool IsProtectedType() const;
57 
58   void SetCharEncoding(BC_CHAR_ENCODING encoding);
59   void SetModuleHeight(int32_t height);
60   void SetModuleWidth(int32_t width);
61   void SetDataLength(int32_t dataLength);
62   void SetCalChecksum(bool calChecksum);
63   void SetPrintChecksum(bool printChecksum);
64   void SetTextLocation(BC_TEXT_LOC location);
65   void SetWideNarrowRatio(int32_t ratio);
66   void SetStartChar(FX_CHAR startChar);
67   void SetEndChar(FX_CHAR endChar);
68   void SetErrorCorrectionLevel(int32_t ecLevel);
69   void SetTruncated(bool truncated);
70 
71  private:
72   void GenerateBarcodeImageCache();
73   void CreateBarcodeEngine();
74 
75   std::unique_ptr<CFX_Barcode> m_pBarcodeEngine;
76   uint32_t m_dwStatus;
77   BC_TYPE m_type;
78   BC_CHAR_ENCODING m_eCharEncoding;
79   int32_t m_nModuleHeight;
80   int32_t m_nModuleWidth;
81   int32_t m_nDataLength;
82   bool m_bCalChecksum;
83   bool m_bPrintChecksum;
84   BC_TEXT_LOC m_eTextLocation;
85   int32_t m_nWideNarrowRatio;
86   FX_CHAR m_cStartChar;
87   FX_CHAR m_cEndChar;
88   int32_t m_nECLevel;
89   bool m_bTruncated;
90   uint32_t m_dwAttributeMask;
91 };
92 
93 #endif  // XFA_FWL_CFWL_BARCODE_H_
94