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_FXFA_CXFA_FFBARCODE_H_
8 #define XFA_FXFA_CXFA_FFBARCODE_H_
9 
10 #include "core/fxcrt/unowned_ptr.h"
11 #include "fxbarcode/BC_Library.h"
12 #include "xfa/fxfa/cxfa_ffpageview.h"
13 #include "xfa/fxfa/cxfa_fftextedit.h"
14 
15 enum class BarcodeType {
16   aztec,
17   codabar,
18   code11,
19   code128,
20   code128A,
21   code128B,
22   code128C,
23   code128SSCC,
24   code2Of5Industrial,
25   code2Of5Interleaved,
26   code2Of5Matrix,
27   code2Of5Standard,
28   code3Of9,
29   code3Of9extended,
30   code49,
31   code93,
32   dataMatrix,
33   ean13,
34   ean13add2,
35   ean13add5,
36   ean13pwcd,
37   ean8,
38   ean8add2,
39   ean8add5,
40   fim,
41   logmars,
42   maxicode,
43   msi,
44   pdf417,
45   pdf417macro,
46   plessey,
47   postAUSCust2,
48   postAUSCust3,
49   postAUSReplyPaid,
50   postAUSStandard,
51   postUKRM4SCC,
52   postUS5Zip,
53   postUSDPBC,
54   postUSIMB,
55   postUSStandard,
56   QRCode,
57   rfid,
58   rss14,
59   rss14Expanded,
60   rss14Limited,
61   rss14Stacked,
62   rss14StackedOmni,
63   rss14Truncated,
64   telepen,
65   ucc128,
66   ucc128random,
67   ucc128sscc,
68   upcA,
69   upcAadd2,
70   upcAadd5,
71   upcApwcd,
72   upcE,
73   upcEadd2,
74   upcEadd5,
75   upcean2,
76   upcean5,
77   upsMaxicode
78 };
79 
80 struct BarCodeInfo {
81   uint32_t uHash;     // |pName| hashed as if wide string.
82   const char* pName;  // Raw, POD struct.
83   BarcodeType eName;
84   BC_TYPE eBCType;
85 };
86 
87 class CXFA_Barcode;
88 
89 class CXFA_FFBarcode final : public CXFA_FFTextEdit {
90  public:
91   static const BarCodeInfo* GetBarcodeTypeByName(const WideString& wsName);
92 
93   CXFA_FFBarcode(CXFA_Node* pNode, CXFA_Barcode* barcode);
94   ~CXFA_FFBarcode() override;
95 
96   // CXFA_FFTextEdit
97   bool LoadWidget() override;
98   void RenderWidget(CXFA_Graphics* pGS,
99                     const CFX_Matrix& matrix,
100                     HighlightOption highlight) override;
101   void UpdateWidgetProperty() override;
102   bool AcceptsFocusOnButtonDown(uint32_t dwFlags,
103                                 const CFX_PointF& point,
104                                 FWL_MouseCommand command) override;
105 
106  private:
107   UnownedPtr<CXFA_Barcode> const barcode_;
108 };
109 
110 #endif  // XFA_FXFA_CXFA_FFBARCODE_H_
111