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