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 style of this edit text.
116      *
117      * @return Returns the edit text style.
118      */
GetEditTextStyle()119     Style& GetEditTextStyle()
120     {
121         return editTextStyle_;
122     }
123 
124     /**
125      * @brief Obtains the background style of this picker.
126      *
127      * @return Returns the background style of this picker.
128      * @since 1.0
129      * @version 1.0
130      */
GetPickerBackgroundStyle()131     Style& GetPickerBackgroundStyle()
132     {
133         return pickerBackgroundStyle_;
134     }
135 
136     /**
137      * @brief Obtains the highlight style of this picker.
138      *
139      * @return Returns the highlight style of this picker.
140      * @since 1.0
141      * @version 1.0
142      */
GetPickerHighlightStyle()143     Style& GetPickerHighlightStyle()
144     {
145         return pickerHighlightStyle_;
146     }
147 
148     /**
149      * @brief Obtains the background style of this progress bar.
150      *
151      * @return Returns the background style of this progress bar.
152      * @since 1.0
153      * @version 1.0
154      */
GetProgressBackgroundStyle()155     Style& GetProgressBackgroundStyle()
156     {
157         return progressBackgroundStyle_;
158     }
159 
160     /**
161      * @brief Obtains the foreground style of this progress bar.
162      *
163      * @return Returns the foreground style of this progress bar.
164      * @since 1.0
165      * @version 1.0
166      */
GetProgressForegroundStyle()167     Style& GetProgressForegroundStyle()
168     {
169         return progressForegroundStyle_;
170     }
171 
172     /**
173      * @brief Obtains the style of this slider knob.
174      *
175      * @return Returns the style of this slider knob.
176      * @since 1.0
177      * @version 1.0
178      */
GetSliderKnobStyle()179     Style& GetSliderKnobStyle()
180     {
181         return sliderKnobStyle_;
182     }
183 
184 protected:
185     Style basicStyle_;
186     ButtonStyle buttonStyle_;
187     Style labelStyle_;
188     Style editTextStyle_;
189     Style pickerBackgroundStyle_;
190     Style pickerHighlightStyle_;
191     Style progressBackgroundStyle_;
192     Style progressForegroundStyle_;
193     Style sliderKnobStyle_;
194 
195     virtual void InitBasicStyle();
196     virtual void InitButtonStyle();
197     virtual void InitLabelStyle();
198     virtual void InitEditTextStyle();
199     virtual void InitPickerStyle();
200     virtual void InitProgressStyle();
201     virtual void InitSliderStyle();
202 };
203 } // namespace OHOS
204 #endif // GRAPHIC_LITE_THEME_H
205