1 /*
2  * Copyright (C) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ACCESSIBILITY_CAPTION_H
17 #define ACCESSIBILITY_CAPTION_H
18 
19 #include "accessibility_def.h"
20 
21 namespace OHOS {
22 namespace AccessibilityConfig {
23 class CaptionProperty {
24 public:
25     /**
26      * @brief The constructor of CaptionProperty
27      */
28     CaptionProperty() = default;
29 
30     /**
31      * @brief The deconstructor of CaptionProperty
32      */
33     ~CaptionProperty() = default;
34 
35     /**
36      * @brief Check property
37      * @param property The value of property
38      */
39     bool CheckProperty(const std::string &property);
40 
41     /**
42      * @brief Set font family
43      * @param family Font family
44      */
45     void SetFontFamily(const std::string &family);
46 
47     /**
48      * @brief Get font family
49      * @return Font family
50      */
51     const std::string &GetFontFamily() const;
52 
53     /**
54      * @brief Set font scale
55      * @param scale Font scale
56      */
57     void SetFontScale(int32_t scale);
58 
59     /**
60      * @brief Get font scale
61      * @return Font scale
62      */
63     int32_t GetFontScale() const;
64 
65     /**
66      * @brief Set font color
67      * @param color Font color
68      */
69     void SetFontColor(uint32_t color);
70 
71     /**
72      * @brief Get font color
73      * @return Font color
74      */
75     uint32_t GetFontColor() const;
76 
77     /**
78      * @brief Set font edge type
79      * @param type The type of font edge
80      */
81     void SetFontEdgeType(const std::string &type);
82 
83     /**
84      * @brief Get font edge type
85      * @return The type of font edge
86      */
87     const std::string &GetFontEdgeType() const;
88 
89     /**
90      * @brief Set window color
91      * @param color The color of window
92      */
93     void SetWindowColor(uint32_t color);
94 
95     /**
96      * @brief Get window color
97      * @return The color of window
98      */
99     uint32_t GetWindowColor() const;
100 
101     /**
102      * @brief Set background color
103      * @param color The color of background
104      */
105     void SetBackgroundColor(uint32_t color);
106 
107     /**
108      * @brief Get background color
109      * @return The color of background
110      */
111     uint32_t GetBackgroundColor() const;
112 
113 protected:
114     std::string fontFamily_ = "default";
115     int32_t fontScale_ = 75;    // font size
116     uint32_t fontColor_ = 0xff000000;
117     std::string fontEdgeType_ = "none";
118     uint32_t backgroundColor_ = 0xff000000;
119     uint32_t windowColor_ = 0xff000000;
120 
121 private:
122     bool HasBackgroundColor();
123     bool HasTextColor();
124     bool HasEdgeType();
125     bool HasEdgeColor();
126     bool HasWindowColor();
127 };
128 
129 enum CaptionObserverType : int32_t {
130     CAPTION_ENABLE = 0,
131     CAPTION_PROPERTY,
132 };
133 class CaptionObserver {
134 public:
135     /**
136      * @brief The deconstructor of CaptionObserver
137      */
138     virtual ~CaptionObserver() = default;
139 
140     /**
141      * @brief Called when the accessibility state changed.
142      * @param enable true:the accessibility state is enabled;false:the accessibility state is disabled
143      */
144     virtual void OnStateChanged(const bool& enable) = 0;
145 
146     /**
147      * @brief Called when the caption property changed.
148      * @param caption current caption property.
149      */
150     virtual void OnPropertyChanged(const CaptionProperty& caption) = 0;
151 };
152 } // namespace Accessibility
153 } // namespace OHOS
154 #endif // ACCESSIBILITY_CAPTION_H