blob: 45da19c25e456462f1fedd1174f1362bc94aada8 [file] [log] [blame]
K. Moon832a6942022-10-31 20:11:31 +00001// Copyright 2014 The PDFium Authors
Tom Sepez99ffdb02016-01-26 14:51:21 -08002// 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
dsinclair447b1f32016-12-08 10:06:32 -08007#ifndef XFA_FWL_CFWL_BARCODE_H_
8#define XFA_FWL_CFWL_BARCODE_H_
Dan Sinclairc7cd8092016-02-18 15:02:55 -05009
Tom Sepezfc241852021-08-10 23:16:32 +000010#include <stdint.h>
11
dsinclair2c489cc2016-11-23 16:17:20 -080012#include <memory>
Dan Sinclair880962c2016-02-23 09:09:24 -050013
Dan Sinclaire7786682017-03-29 15:18:41 -040014#include "fxbarcode/BC_Library.h"
Lei Zhang455cf862021-10-08 01:01:50 +000015#include "third_party/abseil-cpp/absl/types/optional.h"
dsinclair447b1f32016-12-08 10:06:32 -080016#include "xfa/fwl/cfwl_edit.h"
dsinclair2c489cc2016-11-23 16:17:20 -080017
dsinclair2c489cc2016-11-23 16:17:20 -080018class CFX_Barcode;
dsinclair2c489cc2016-11-23 16:17:20 -080019
Tom Sepez55865452018-08-27 20:18:04 +000020class CFWL_Barcode final : public CFWL_Edit {
Tom Sepez99ffdb02016-01-26 14:51:21 -080021 public:
Tom Sepezf78f19c52020-08-20 18:55:34 +000022 CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
dsinclair0ca71ec2016-10-19 07:59:25 -070023 ~CFWL_Barcode() override;
weili5d8e5aa2016-08-08 17:30:37 -070024
dsinclair2c489cc2016-11-23 16:17:20 -080025 // CFWL_Widget
26 FWL_Type GetClassID() const override;
27 void Update() override;
Tom Sepez45eae7b2020-10-13 22:50:53 +000028 void DrawWidget(CFGAS_GEGraphics* pGraphics,
29 const CFX_Matrix& matrix) override;
dsinclair2c489cc2016-11-23 16:17:20 -080030 void OnProcessEvent(CFWL_Event* pEvent) override;
dsinclair20855382016-10-31 07:29:34 -070031
dsinclair2c489cc2016-11-23 16:17:20 -080032 // CFWL_Edit
Lei Zhangb600f152019-01-25 23:21:50 +000033 void SetText(const WideString& wsText) override;
34 void SetTextSkipNotify(const WideString& wsText) override;
weili4ce94e12016-06-18 06:21:57 -070035
dsinclairc64b76c2016-11-14 09:01:37 -080036 void SetType(BC_TYPE type);
dsinclair2c489cc2016-11-23 16:17:20 -080037 bool IsProtectedType() const;
dsinclairc64b76c2016-11-14 09:01:37 -080038
39 void SetCharEncoding(BC_CHAR_ENCODING encoding);
40 void SetModuleHeight(int32_t height);
41 void SetModuleWidth(int32_t width);
42 void SetDataLength(int32_t dataLength);
43 void SetCalChecksum(bool calChecksum);
44 void SetPrintChecksum(bool printChecksum);
45 void SetTextLocation(BC_TEXT_LOC location);
Lei Zhang1badb852017-04-20 15:58:56 -070046 void SetWideNarrowRatio(int8_t ratio);
Dan Sinclair812e96c2017-03-13 16:43:37 -040047 void SetStartChar(char startChar);
48 void SetEndChar(char endChar);
dsinclairc64b76c2016-11-14 09:01:37 -080049 void SetErrorCorrectionLevel(int32_t ecLevel);
dsinclairc64b76c2016-11-14 09:01:37 -080050
dsinclaireb3f68c2016-11-07 10:28:47 -080051 private:
Lei Zhang41f22be2019-01-25 23:18:50 +000052 enum class Status : uint8_t {
53 kNormal,
54 kNeedUpdate,
55 kEncodeSuccess,
56 };
57
Tom Sepez0a9d9742020-09-01 21:40:52 +000058 explicit CFWL_Barcode(CFWL_App* pApp);
Tom Sepezf78f19c52020-08-20 18:55:34 +000059
dsinclair2c489cc2016-11-23 16:17:20 -080060 void GenerateBarcodeImageCache();
61 void CreateBarcodeEngine();
62
Tom Sepezd1ecfa82021-08-24 21:26:33 +000063 BC_TYPE m_type = BC_TYPE::kUnknown;
Tom Sepezc58babd2020-01-14 20:04:16 +000064 Status m_eStatus = Status::kNormal;
Lei Zhang3a0fdd62021-10-08 00:11:11 +000065 absl::optional<BC_TEXT_LOC> m_eTextLocation;
66 absl::optional<BC_CHAR_ENCODING> m_eCharEncoding;
67 absl::optional<bool> m_bCalChecksum;
68 absl::optional<bool> m_bPrintChecksum;
69 absl::optional<char> m_cStartChar;
70 absl::optional<char> m_cEndChar;
71 absl::optional<int8_t> m_nWideNarrowRatio;
72 absl::optional<int32_t> m_nModuleHeight;
73 absl::optional<int32_t> m_nModuleWidth;
74 absl::optional<int32_t> m_nDataLength;
75 absl::optional<int32_t> m_nECLevel;
Tom Sepezc58babd2020-01-14 20:04:16 +000076 std::unique_ptr<CFX_Barcode> m_pBarcodeEngine;
Tom Sepez99ffdb02016-01-26 14:51:21 -080077};
Dan Sinclairc7cd8092016-02-18 15:02:55 -050078
dsinclair447b1f32016-12-08 10:06:32 -080079#endif // XFA_FWL_CFWL_BARCODE_H_