K. Moon | 832a694 | 2022-10-31 20:11:31 +0000 | [diff] [blame] | 1 | // Copyright 2014 The PDFium Authors |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 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 | |
dsinclair | 447b1f3 | 2016-12-08 10:06:32 -0800 | [diff] [blame] | 7 | #ifndef XFA_FWL_CFWL_BARCODE_H_ |
| 8 | #define XFA_FWL_CFWL_BARCODE_H_ |
Dan Sinclair | c7cd809 | 2016-02-18 15:02:55 -0500 | [diff] [blame] | 9 | |
Tom Sepez | fc24185 | 2021-08-10 23:16:32 +0000 | [diff] [blame] | 10 | #include <stdint.h> |
| 11 | |
dsinclair | 2c489cc | 2016-11-23 16:17:20 -0800 | [diff] [blame] | 12 | #include <memory> |
Dan Sinclair | 880962c | 2016-02-23 09:09:24 -0500 | [diff] [blame] | 13 | |
Dan Sinclair | e778668 | 2017-03-29 15:18:41 -0400 | [diff] [blame] | 14 | #include "fxbarcode/BC_Library.h" |
Lei Zhang | 455cf86 | 2021-10-08 01:01:50 +0000 | [diff] [blame] | 15 | #include "third_party/abseil-cpp/absl/types/optional.h" |
dsinclair | 447b1f3 | 2016-12-08 10:06:32 -0800 | [diff] [blame] | 16 | #include "xfa/fwl/cfwl_edit.h" |
dsinclair | 2c489cc | 2016-11-23 16:17:20 -0800 | [diff] [blame] | 17 | |
dsinclair | 2c489cc | 2016-11-23 16:17:20 -0800 | [diff] [blame] | 18 | class CFX_Barcode; |
dsinclair | 2c489cc | 2016-11-23 16:17:20 -0800 | [diff] [blame] | 19 | |
Tom Sepez | 5586545 | 2018-08-27 20:18:04 +0000 | [diff] [blame] | 20 | class CFWL_Barcode final : public CFWL_Edit { |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 21 | public: |
Tom Sepez | f78f19c5 | 2020-08-20 18:55:34 +0000 | [diff] [blame] | 22 | CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED; |
dsinclair | 0ca71ec | 2016-10-19 07:59:25 -0700 | [diff] [blame] | 23 | ~CFWL_Barcode() override; |
weili | 5d8e5aa | 2016-08-08 17:30:37 -0700 | [diff] [blame] | 24 | |
dsinclair | 2c489cc | 2016-11-23 16:17:20 -0800 | [diff] [blame] | 25 | // CFWL_Widget |
| 26 | FWL_Type GetClassID() const override; |
| 27 | void Update() override; |
Tom Sepez | 45eae7b | 2020-10-13 22:50:53 +0000 | [diff] [blame] | 28 | void DrawWidget(CFGAS_GEGraphics* pGraphics, |
| 29 | const CFX_Matrix& matrix) override; |
dsinclair | 2c489cc | 2016-11-23 16:17:20 -0800 | [diff] [blame] | 30 | void OnProcessEvent(CFWL_Event* pEvent) override; |
dsinclair | 2085538 | 2016-10-31 07:29:34 -0700 | [diff] [blame] | 31 | |
dsinclair | 2c489cc | 2016-11-23 16:17:20 -0800 | [diff] [blame] | 32 | // CFWL_Edit |
Lei Zhang | b600f15 | 2019-01-25 23:21:50 +0000 | [diff] [blame] | 33 | void SetText(const WideString& wsText) override; |
| 34 | void SetTextSkipNotify(const WideString& wsText) override; |
weili | 4ce94e1 | 2016-06-18 06:21:57 -0700 | [diff] [blame] | 35 | |
dsinclair | c64b76c | 2016-11-14 09:01:37 -0800 | [diff] [blame] | 36 | void SetType(BC_TYPE type); |
dsinclair | 2c489cc | 2016-11-23 16:17:20 -0800 | [diff] [blame] | 37 | bool IsProtectedType() const; |
dsinclair | c64b76c | 2016-11-14 09:01:37 -0800 | [diff] [blame] | 38 | |
| 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 Zhang | 1badb85 | 2017-04-20 15:58:56 -0700 | [diff] [blame] | 46 | void SetWideNarrowRatio(int8_t ratio); |
Dan Sinclair | 812e96c | 2017-03-13 16:43:37 -0400 | [diff] [blame] | 47 | void SetStartChar(char startChar); |
| 48 | void SetEndChar(char endChar); |
dsinclair | c64b76c | 2016-11-14 09:01:37 -0800 | [diff] [blame] | 49 | void SetErrorCorrectionLevel(int32_t ecLevel); |
dsinclair | c64b76c | 2016-11-14 09:01:37 -0800 | [diff] [blame] | 50 | |
dsinclair | eb3f68c | 2016-11-07 10:28:47 -0800 | [diff] [blame] | 51 | private: |
Lei Zhang | 41f22be | 2019-01-25 23:18:50 +0000 | [diff] [blame] | 52 | enum class Status : uint8_t { |
| 53 | kNormal, |
| 54 | kNeedUpdate, |
| 55 | kEncodeSuccess, |
| 56 | }; |
| 57 | |
Tom Sepez | 0a9d974 | 2020-09-01 21:40:52 +0000 | [diff] [blame] | 58 | explicit CFWL_Barcode(CFWL_App* pApp); |
Tom Sepez | f78f19c5 | 2020-08-20 18:55:34 +0000 | [diff] [blame] | 59 | |
dsinclair | 2c489cc | 2016-11-23 16:17:20 -0800 | [diff] [blame] | 60 | void GenerateBarcodeImageCache(); |
| 61 | void CreateBarcodeEngine(); |
| 62 | |
Tom Sepez | d1ecfa8 | 2021-08-24 21:26:33 +0000 | [diff] [blame] | 63 | BC_TYPE m_type = BC_TYPE::kUnknown; |
Tom Sepez | c58babd | 2020-01-14 20:04:16 +0000 | [diff] [blame] | 64 | Status m_eStatus = Status::kNormal; |
Lei Zhang | 3a0fdd6 | 2021-10-08 00:11:11 +0000 | [diff] [blame] | 65 | 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 Sepez | c58babd | 2020-01-14 20:04:16 +0000 | [diff] [blame] | 76 | std::unique_ptr<CFX_Barcode> m_pBarcodeEngine; |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 77 | }; |
Dan Sinclair | c7cd809 | 2016-02-18 15:02:55 -0500 | [diff] [blame] | 78 | |
dsinclair | 447b1f3 | 2016-12-08 10:06:32 -0800 | [diff] [blame] | 79 | #endif // XFA_FWL_CFWL_BARCODE_H_ |