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 <string> 20 #include "parcel.h" 21 22 namespace OHOS { 23 namespace Accessibility { 24 enum CaptionMode : int { 25 CAPTION_BLACK_WHITE = 0, // CAPTION_background_foreground 26 CAPTION_WHITE_BLACK, 27 CAPTION_BLACK_YELLOW, 28 CAPTION_BLUE_YELLOW, 29 CAPTION_CUSTOM, 30 CAPTION_MODE_MAX, 31 }; 32 33 enum CaptionEdge : int { 34 CAPTION_EDGE_NONEB = 0, 35 CAPTION_EDGE_OUTLINE, 36 CAPTION_EDGE_DROP_SHADOW, 37 CAPTION_EDGE_RAISED, 38 CAPTION_EDGE_DEPRESSED, 39 }; 40 41 class CaptionProperty : public Parcelable { 42 public: 43 CaptionProperty() = default; 44 ~CaptionProperty() = default; 45 bool CheckProperty(const std::string& property); 46 47 void SetFontFamily(std::string family); 48 std::string GetFontFamily() const; 49 50 int GetFontScale() const; 51 void SetFontScale(int scale); 52 53 void SetFontColor(uint32_t color); 54 uint32_t GetFontColor() const; 55 56 void SetFontEdgeType(std::string type); 57 std::string GetFontEdgeType() const; 58 59 void SetWindowColor(uint32_t color); 60 uint32_t GetWindowColor() const; 61 62 void SetBackgroundColor(uint32_t color); 63 uint32_t GetBackgroundColor() const; 64 65 /** 66 * @brief read this sequenceable object from a Parcel. 67 * @param parcel Indicates the Parcel object into which the sequenceable 68 * object has been marshaled. 69 * @return Return true if read successfully, else return false. 70 */ 71 bool ReadFromParcel(Parcel& parcel); 72 73 /** 74 * @brief Marshals this sequenceable object into a Parcel. 75 * @param parcel Indicates the Parcel object to which the sequenceable 76 * object will be marshaled. 77 * @return Return true if Marshal successfully, else return false. 78 */ 79 virtual bool Marshalling(Parcel& parcel) const override; 80 81 /** 82 * @brief Unmarshals this sequenceable object from a Parcel. 83 * @param parcel Indicates the Parcel object into which the sequenceable 84 * object has been marshaled. 85 * @return Return a sequenceable object of CaptionProperty. 86 */ 87 static CaptionProperty* Unmarshalling(Parcel& parcel); 88 89 private: 90 bool HasBackgroundColor(); 91 bool HasTextColor(); 92 bool HasEdgeType(); 93 bool HasEdgeColor(); 94 bool HasWindowColor(); 95 96 std::string fontFamily_ = "default"; 97 int fontScale_ = 75; // font size 98 uint32_t fontColor_ = 0xff000000; 99 std::string fontEdgeType_ = "none"; 100 uint32_t backgroundColor_ = 0xff000000; 101 uint32_t windowColor_ = 0xff000000; 102 }; 103 104 enum CaptionObserverType : int { 105 CAPTION_ENABLE = 0, 106 CAPTION_PROPERTY, 107 }; 108 class CaptionObserver { 109 public: 110 /** 111 * @brief Destruct 112 * @param 113 * @return 114 */ 115 virtual ~CaptionObserver() = default; 116 117 /** 118 * @brief Called when the caption property changed. 119 * @param caption current caption property. 120 * @return 121 */ 122 virtual void OnCaptionStateChanged(const bool& enable) = 0; 123 virtual void OnCaptionPropertyChanged(const CaptionProperty& caption) = 0; 124 }; 125 } // namespace Accessibility 126 } // namespace OHOS 127 #endif // ACCESSIBILITY_CAPTION_H