Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / include / fwl / lightwidget / barcode.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _FWL_BARCODE_LIGHT_H\r
8 #define _FWL_BARCODE_LIGHT_H\r
9 class CFWL_Widget;\r
10 class CFWL_WidgetProperties;\r
11 class IFWL_BarcodeDP;\r
12 class CFWL_Edit;\r
13 class CFWL_Barcode;\r
14 class CFWL_BarcodeDP;\r
15 class CFWL_Barcode : public CFWL_Edit\r
16 {\r
17 public:\r
18     static CFWL_Barcode* Create();\r
19     FWL_ERR     Initialize(const CFWL_WidgetProperties *pProperties = NULL);\r
20     void                SetType(BC_TYPE type);\r
21     FX_BOOL             IsProtectedType();\r
22 public:\r
23     void                SetCharEncoding(BC_CHAR_ENCODING encoding)\r
24     {\r
25         m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_CHARENCODING;\r
26         m_barcodeData.m_eCharEncoding = encoding;\r
27     }\r
28     void                SetModuleHeight(FX_INT32 height)\r
29     {\r
30         m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_MODULEHEIGHT;\r
31         m_barcodeData.m_nModuleHeight = height;\r
32     }\r
33     void                SetModuleWidth(FX_INT32 width)\r
34     {\r
35         m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_MODULEWIDTH;\r
36         m_barcodeData.m_nModuleWidth = width;\r
37     }\r
38     void                SetDataLength(FX_INT32 dataLength)\r
39     {\r
40         m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_DATALENGTH;\r
41         m_barcodeData.m_nDataLength = dataLength;\r
42         ((IFWL_Barcode*)m_pImp)->SetLimit(dataLength);\r
43     }\r
44     void                SetCalChecksum(FX_INT32 calChecksum)\r
45     {\r
46         m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_CALCHECKSUM;\r
47         m_barcodeData.m_nCalChecksum = calChecksum;\r
48     }\r
49     void                SetPrintChecksum(FX_BOOL printChecksum)\r
50     {\r
51         m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_PRINTCHECKSUM;\r
52         m_barcodeData.m_bPrintChecksum = printChecksum;\r
53     }\r
54     void                SetTextLocation(BC_TEXT_LOC location)\r
55     {\r
56         m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_TEXTLOCATION;\r
57         m_barcodeData.m_eTextLocation = location;\r
58     }\r
59     void                SetWideNarrowRatio(FX_INT32 ratio)\r
60     {\r
61         m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_WIDENARROWRATIO;\r
62         m_barcodeData.m_nWideNarrowRatio = ratio;\r
63     }\r
64     void                SetStartChar(FX_CHAR startChar)\r
65     {\r
66         m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_STARTCHAR;\r
67         m_barcodeData.m_cStartChar = startChar;\r
68     }\r
69     void                SetEndChar(FX_CHAR endChar)\r
70     {\r
71         m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_ENDCHAR;\r
72         m_barcodeData.m_cEndChar = endChar;\r
73     }\r
74     void                SetVersion(FX_INT32 version)\r
75     {\r
76         m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_VERSION;\r
77         m_barcodeData.m_nVersion = version;\r
78     }\r
79     void                SetErrorCorrectionLevel(FX_INT32 ecLevel)\r
80     {\r
81         m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_ECLEVEL;\r
82         m_barcodeData.m_nECLevel = ecLevel;\r
83     }\r
84     void                SetTruncated(FX_BOOL truncated)\r
85     {\r
86         m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_TRUNCATED;\r
87         m_barcodeData.m_bTruncated = truncated;\r
88     }\r
89     void                ResetBarcodeAttributes()\r
90     {\r
91         m_barcodeData.m_dwAttributeMask = 0;\r
92     }\r
93 protected:\r
94     CFWL_Barcode();\r
95     virtual ~CFWL_Barcode();\r
96     class CFWL_BarcodeDP : public IFWL_BarcodeDP\r
97     {\r
98     public:\r
99         virtual FWL_ERR                         GetCaption(IFWL_Widget *pWidget, CFX_WideString &wsCaption);\r
100         BC_CHAR_ENCODING                        m_eCharEncoding;\r
101         virtual BC_CHAR_ENCODING        GetCharEncoding()\r
102         {\r
103             return m_eCharEncoding;\r
104         }\r
105         FX_INT32                                        m_nModuleHeight, m_nModuleWidth;\r
106         virtual FX_INT32                        GetModuleHeight()\r
107         {\r
108             return m_nModuleHeight;\r
109         }\r
110         virtual FX_INT32                        GetModuleWidth()\r
111         {\r
112             return m_nModuleWidth;\r
113         }\r
114         FX_INT32                                        m_nDataLength;\r
115         virtual FX_INT32                        GetDataLength()\r
116         {\r
117             return m_nDataLength;\r
118         }\r
119         FX_INT32                                        m_nCalChecksum;\r
120         virtual FX_INT32                        GetCalChecksum()\r
121         {\r
122             return m_nCalChecksum;\r
123         }\r
124         FX_BOOL                                         m_bPrintChecksum;\r
125         virtual FX_BOOL                         GetPrintChecksum()\r
126         {\r
127             return m_bPrintChecksum;\r
128         }\r
129 \r
130         BC_TEXT_LOC                                     m_eTextLocation;\r
131         virtual BC_TEXT_LOC                     GetTextLocation()\r
132         {\r
133             return m_eTextLocation;\r
134         }\r
135         FX_INT32                                        m_nWideNarrowRatio;\r
136         virtual FX_INT32                        GetWideNarrowRatio()\r
137         {\r
138             return m_nWideNarrowRatio;\r
139         }\r
140         FX_CHAR                                         m_cStartChar, m_cEndChar;\r
141         virtual FX_CHAR                         GetStartChar()\r
142         {\r
143             return m_cStartChar;\r
144         }\r
145         virtual FX_CHAR                         GetEndChar()\r
146         {\r
147             return m_cEndChar;\r
148         }\r
149         FX_INT32                                        m_nVersion;\r
150         virtual FX_INT32                        GetVersion()\r
151         {\r
152             return m_nVersion;\r
153         }\r
154         FX_INT32                                        m_nECLevel;\r
155         virtual FX_INT32                        GetErrorCorrectionLevel()\r
156         {\r
157             return m_nECLevel;\r
158         }\r
159         FX_BOOL                                         m_bTruncated;\r
160         virtual FX_BOOL                         GetTruncated()\r
161         {\r
162             return m_bTruncated;\r
163         }\r
164         FX_DWORD                                        m_dwAttributeMask;\r
165         virtual FX_DWORD                        GetBarcodeAttributeMask()\r
166         {\r
167             return m_dwAttributeMask;\r
168         }\r
169     public:\r
170         CFWL_BarcodeDP()\r
171             : m_dwAttributeMask(0)\r
172         {\r
173         }\r
174     };\r
175     CFWL_BarcodeDP m_barcodeData;\r
176 };\r
177 #endif\r