1 /* 2 * Copyright (c) 2020-2021 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 /** 17 * @addtogroup UI_Theme 18 * @{ 19 * 20 * @brief Defines UI themes. 21 * 22 * @since 1.0 23 * @version 1.0 24 */ 25 26 /** 27 * @file theme.h 28 * 29 * @brief Declares the base class used to define the functions related to the styles of different components. 30 * 31 * @since 1.0 32 * @version 1.0 33 */ 34 35 #ifndef GRAPHIC_LITE_THEME_H 36 #define GRAPHIC_LITE_THEME_H 37 38 #include "components/ui_view.h" 39 #include "gfx_utils/style.h" 40 41 namespace OHOS { 42 /** 43 * @brief Stores styles of a button in its different states. 44 */ 45 struct ButtonStyle { 46 /** Style when released */ 47 Style released; 48 /** Style when pressed */ 49 Style pressed; 50 /** Style when inactive */ 51 Style inactive; 52 }; 53 54 /** 55 * @brief Defines the theme class used to define the functions related to the styles of different components. 56 * 57 * @since 1.0 58 * @version 1.0 59 */ 60 class Theme : public HeapBase { 61 public: 62 /** 63 * @brief A constructor used to create a <b>Theme</b> instance. 64 * 65 * @since 1.0 66 * @version 1.0 67 */ 68 Theme(); 69 70 /** 71 * @brief A destructor used to delete the <b>Theme</b> instance. 72 * 73 * @since 1.0 74 * @version 1.0 75 */ ~Theme()76 virtual ~Theme(){}; 77 78 /** 79 * @brief Obtains the basic style. 80 * 81 * @return Returns the basic style. 82 * @since 1.0 83 * @version 1.0 84 */ GetMainStyle()85 Style& GetMainStyle() 86 { 87 return basicStyle_; 88 } 89 90 /** 91 * @brief Obtains the style of this button. 92 * 93 * @return Returns the button style. 94 * @since 1.0 95 * @version 1.0 96 */ GetButtonStyle()97 ButtonStyle& GetButtonStyle() 98 { 99 return buttonStyle_; 100 } 101 102 /** 103 * @brief Obtains the style of this label. 104 * 105 * @return Returns the label style. 106 * @since 1.0 107 * @version 1.0 108 */ GetLabelStyle()109 Style& GetLabelStyle() 110 { 111 return labelStyle_; 112 } 113 114 /** 115 * @brief Obtains the background style of this picker. 116 * 117 * @return Returns the background style of this picker. 118 * @since 1.0 119 * @version 1.0 120 */ GetPickerBackgroundStyle()121 Style& GetPickerBackgroundStyle() 122 { 123 return pickerBackgroundStyle_; 124 } 125 126 /** 127 * @brief Obtains the highlight style of this picker. 128 * 129 * @return Returns the highlight style of this picker. 130 * @since 1.0 131 * @version 1.0 132 */ GetPickerHighlightStyle()133 Style& GetPickerHighlightStyle() 134 { 135 return pickerHighlightStyle_; 136 } 137 138 /** 139 * @brief Obtains the background style of this progress bar. 140 * 141 * @return Returns the background style of this progress bar. 142 * @since 1.0 143 * @version 1.0 144 */ GetProgressBackgroundStyle()145 Style& GetProgressBackgroundStyle() 146 { 147 return progressBackgroundStyle_; 148 } 149 150 /** 151 * @brief Obtains the foreground style of this progress bar. 152 * 153 * @return Returns the foreground style of this progress bar. 154 * @since 1.0 155 * @version 1.0 156 */ GetProgressForegroundStyle()157 Style& GetProgressForegroundStyle() 158 { 159 return progressForegroundStyle_; 160 } 161 162 /** 163 * @brief Obtains the style of this slider knob. 164 * 165 * @return Returns the style of this slider knob. 166 * @since 1.0 167 * @version 1.0 168 */ GetSliderKnobStyle()169 Style& GetSliderKnobStyle() 170 { 171 return sliderKnobStyle_; 172 } 173 174 protected: 175 Style basicStyle_; 176 ButtonStyle buttonStyle_; 177 Style labelStyle_; 178 Style pickerBackgroundStyle_; 179 Style pickerHighlightStyle_; 180 Style progressBackgroundStyle_; 181 Style progressForegroundStyle_; 182 Style sliderKnobStyle_; 183 184 virtual void InitBasicStyle(); 185 virtual void InitButtonStyle(); 186 virtual void InitLabelStyle(); 187 virtual void InitPickerStyle(); 188 virtual void InitProgressStyle(); 189 virtual void InitSliderStyle(); 190 }; 191 } // namespace OHOS 192 #endif // GRAPHIC_LITE_THEME_H 193