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_CFX_BARCODE_H_
8 #define XFA_FWL_CFX_BARCODE_H_
9 
10 #include <memory>
11 
12 #include "core/fxcrt/fx_coordinates.h"
13 #include "core/fxcrt/fx_string.h"
14 #include "core/fxcrt/fx_system.h"
15 #include "core/fxge/fx_dib.h"
16 #include "fxbarcode/BC_Library.h"
17 
18 class CBC_CodeBase;
19 class CFX_Font;
20 class CFX_RenderDevice;
21 class CFX_Matrix;
22 
23 class CFX_Barcode {
24  public:
25   CFX_Barcode();
26   ~CFX_Barcode();
27 
28   bool Create(BC_TYPE type);
29   BC_TYPE GetType();
30   bool Encode(const WideStringView& contents);
31 
32   bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix);
33 
34   bool SetCharEncoding(BC_CHAR_ENCODING encoding);
35 
36   bool SetModuleHeight(int32_t moduleHeight);
37   bool SetModuleWidth(int32_t moduleWidth);
38 
39   bool SetHeight(int32_t height);
40   bool SetWidth(int32_t width);
41 
42   bool SetPrintChecksum(bool checksum);
43   bool SetDataLength(int32_t length);
44   bool SetCalChecksum(bool state);
45 
46   bool SetFont(CFX_Font* pFont);
47   bool SetFontSize(float size);
48   bool SetFontColor(FX_ARGB color);
49 
50   bool SetTextLocation(BC_TEXT_LOC location);
51 
52   bool SetWideNarrowRatio(int8_t ratio);
53   bool SetStartChar(char start);
54   bool SetEndChar(char end);
55   bool SetErrorCorrectionLevel(int32_t level);
56   bool SetTruncated(bool truncated);
57 
58  private:
59   std::unique_ptr<CBC_CodeBase> m_pBCEngine;
60 };
61 
62 #endif  // XFA_FWL_CFX_BARCODE_H_
63