OLD | NEW |
| (Empty) |
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_LIGHTWIDGET_CFWL_BARCODE_H_ | |
8 #define XFA_FWL_LIGHTWIDGET_CFWL_BARCODE_H_ | |
9 | |
10 #include "xfa/fwl/core/fwl_error.h" | |
11 #include "xfa/fwl/core/ifwl_barcode.h" | |
12 #include "xfa/fwl/lightwidget/cfwl_edit.h" | |
13 | |
14 class CFWL_Widget; | |
15 class CFWL_WidgetProperties; | |
16 | |
17 class CFWL_Barcode : public CFWL_Edit { | |
18 public: | |
19 CFWL_Barcode(); | |
20 ~CFWL_Barcode() override; | |
21 | |
22 IFWL_Barcode* GetWidget() override; | |
23 const IFWL_Barcode* GetWidget() const override; | |
24 | |
25 FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr); | |
26 void SetType(BC_TYPE type); | |
27 FX_BOOL IsProtectedType(); | |
28 | |
29 void SetCharEncoding(BC_CHAR_ENCODING encoding) { | |
30 m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_CHARENCODING; | |
31 m_barcodeData.m_eCharEncoding = encoding; | |
32 } | |
33 void SetModuleHeight(int32_t height) { | |
34 m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_MODULEHEIGHT; | |
35 m_barcodeData.m_nModuleHeight = height; | |
36 } | |
37 void SetModuleWidth(int32_t width) { | |
38 m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_MODULEWIDTH; | |
39 m_barcodeData.m_nModuleWidth = width; | |
40 } | |
41 void SetDataLength(int32_t dataLength) { | |
42 m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_DATALENGTH; | |
43 m_barcodeData.m_nDataLength = dataLength; | |
44 GetWidget()->SetLimit(dataLength); | |
45 } | |
46 void SetCalChecksum(int32_t calChecksum) { | |
47 m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_CALCHECKSUM; | |
48 m_barcodeData.m_nCalChecksum = calChecksum; | |
49 } | |
50 void SetPrintChecksum(FX_BOOL printChecksum) { | |
51 m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_PRINTCHECKSUM; | |
52 m_barcodeData.m_bPrintChecksum = printChecksum; | |
53 } | |
54 void SetTextLocation(BC_TEXT_LOC location) { | |
55 m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_TEXTLOCATION; | |
56 m_barcodeData.m_eTextLocation = location; | |
57 } | |
58 void SetWideNarrowRatio(int32_t ratio) { | |
59 m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_WIDENARROWRATIO; | |
60 m_barcodeData.m_nWideNarrowRatio = ratio; | |
61 } | |
62 void SetStartChar(FX_CHAR startChar) { | |
63 m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_STARTCHAR; | |
64 m_barcodeData.m_cStartChar = startChar; | |
65 } | |
66 void SetEndChar(FX_CHAR endChar) { | |
67 m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_ENDCHAR; | |
68 m_barcodeData.m_cEndChar = endChar; | |
69 } | |
70 void SetVersion(int32_t version) { | |
71 m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_VERSION; | |
72 m_barcodeData.m_nVersion = version; | |
73 } | |
74 void SetErrorCorrectionLevel(int32_t ecLevel) { | |
75 m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_ECLEVEL; | |
76 m_barcodeData.m_nECLevel = ecLevel; | |
77 } | |
78 void SetTruncated(FX_BOOL truncated) { | |
79 m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_TRUNCATED; | |
80 m_barcodeData.m_bTruncated = truncated; | |
81 } | |
82 void ResetBarcodeAttributes() { | |
83 m_barcodeData.m_dwAttributeMask = FWL_BCDATTRIBUTE_NONE; | |
84 } | |
85 | |
86 protected: | |
87 class CFWL_BarcodeDP : public IFWL_BarcodeDP { | |
88 public: | |
89 CFWL_BarcodeDP(); | |
90 | |
91 // IFWL_DataProvider | |
92 FWL_Error GetCaption(IFWL_Widget* pWidget, | |
93 CFX_WideString& wsCaption) override; | |
94 | |
95 // IFWL_BarcodeDP | |
96 BC_CHAR_ENCODING GetCharEncoding() override; | |
97 int32_t GetModuleHeight() override; | |
98 int32_t GetModuleWidth() override; | |
99 int32_t GetDataLength() override; | |
100 int32_t GetCalChecksum() override; | |
101 FX_BOOL GetPrintChecksum() override; | |
102 BC_TEXT_LOC GetTextLocation() override; | |
103 int32_t GetWideNarrowRatio() override; | |
104 FX_CHAR GetStartChar() override; | |
105 FX_CHAR GetEndChar() override; | |
106 int32_t GetVersion() override; | |
107 int32_t GetErrorCorrectionLevel() override; | |
108 FX_BOOL GetTruncated() override; | |
109 uint32_t GetBarcodeAttributeMask() override; | |
110 | |
111 BC_CHAR_ENCODING m_eCharEncoding; | |
112 int32_t m_nModuleHeight, m_nModuleWidth; | |
113 int32_t m_nDataLength; | |
114 int32_t m_nCalChecksum; | |
115 FX_BOOL m_bPrintChecksum; | |
116 BC_TEXT_LOC m_eTextLocation; | |
117 int32_t m_nWideNarrowRatio; | |
118 FX_CHAR m_cStartChar, m_cEndChar; | |
119 int32_t m_nVersion; | |
120 int32_t m_nECLevel; | |
121 FX_BOOL m_bTruncated; | |
122 uint32_t m_dwAttributeMask; | |
123 }; | |
124 | |
125 CFWL_BarcodeDP m_barcodeData; | |
126 }; | |
127 | |
128 #endif // XFA_FWL_LIGHTWIDGET_CFWL_BARCODE_H_ | |
OLD | NEW |