1 /*
2  * Copyright (c) 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 #include "core/components/clock/clock_component.h"
17 
18 namespace OHOS::Ace {
19 
ClockComponent()20 ClockComponent::ClockComponent()
21 {
22     if (!declaration_) {
23         declaration_ = AceType::MakeRefPtr<ClockDeclaration>();
24         declaration_->Init();
25     }
26 }
27 
SetClockFaceSrc(const std::string & clockFaceSrc)28 void ClockComponent::SetClockFaceSrc(const std::string& clockFaceSrc)
29 {
30     declaration_->SetClockFaceSrc(clockFaceSrc);
31 }
32 
GetClockFaceSrc() const33 const std::string& ClockComponent::GetClockFaceSrc() const
34 {
35     return declaration_->GetClockFaceSrc();
36 }
37 
SetClockFaceNightSrc(const std::string & clockFaceNightSrc)38 void ClockComponent::SetClockFaceNightSrc(const std::string& clockFaceNightSrc)
39 {
40     declaration_->SetClockFaceNightSrc(clockFaceNightSrc);
41 }
42 
GetClockFaceNightSrc() const43 const std::string& ClockComponent::GetClockFaceNightSrc() const
44 {
45     return declaration_->GetClockFaceNightSrc();
46 }
47 
SetHourHandSrc(const std::string & hourHandSrc)48 void ClockComponent::SetHourHandSrc(const std::string& hourHandSrc)
49 {
50     declaration_->SetHourHandSrc(hourHandSrc);
51 }
52 
GetHourHandSrc() const53 const std::string& ClockComponent::GetHourHandSrc() const
54 {
55     return declaration_->GetHourHandSrc();
56 }
57 
SetHourHandNightSrc(const std::string & hourHandNightSrc)58 void ClockComponent::SetHourHandNightSrc(const std::string& hourHandNightSrc)
59 {
60     declaration_->SetHourHandNightSrc(hourHandNightSrc);
61 }
62 
GetHourHandNightSrc() const63 const std::string& ClockComponent::GetHourHandNightSrc() const
64 {
65     return declaration_->GetHourHandNightSrc();
66 }
67 
SetMinuteHandSrc(const std::string & minuteHandSrc)68 void ClockComponent::SetMinuteHandSrc(const std::string& minuteHandSrc)
69 {
70     declaration_->SetMinuteHandSrc(minuteHandSrc);
71 }
72 
GetMinuteHandSrc() const73 const std::string& ClockComponent::GetMinuteHandSrc() const
74 {
75     return declaration_->GetMinuteHandSrc();
76 }
77 
SetMinuteHandNightSrc(const std::string & minuteHandNightSrc)78 void ClockComponent::SetMinuteHandNightSrc(const std::string& minuteHandNightSrc)
79 {
80     declaration_->SetMinuteHandNightSrc(minuteHandNightSrc);
81 }
82 
GetMinuteHandNightSrc() const83 const std::string& ClockComponent::GetMinuteHandNightSrc() const
84 {
85     return declaration_->GetMinuteHandNightSrc();
86 }
87 
SetSecondHandSrc(const std::string & secondHandSrc)88 void ClockComponent::SetSecondHandSrc(const std::string& secondHandSrc)
89 {
90     declaration_->SetSecondHandSrc(secondHandSrc);
91 }
92 
GetSecondHandSrc() const93 const std::string& ClockComponent::GetSecondHandSrc() const
94 {
95     return declaration_->GetSecondHandSrc();
96 }
97 
SetSecondHandNightSrc(const std::string & secondHandNightSrc)98 void ClockComponent::SetSecondHandNightSrc(const std::string& secondHandNightSrc)
99 {
100     declaration_->SetSecondHandNightSrc(secondHandNightSrc);
101 }
102 
GetSecondHandNightSrc() const103 const std::string& ClockComponent::GetSecondHandNightSrc() const
104 {
105     return declaration_->GetSecondHandNightSrc();
106 }
107 
SetHoursWest(double hoursWest)108 void ClockComponent::SetHoursWest(double hoursWest)
109 {
110     declaration_->SetHoursWest(hoursWest);
111 }
112 
GetHoursWest() const113 double ClockComponent::GetHoursWest() const
114 {
115     return declaration_->GetHoursWest();
116 }
117 
SetDigitColor(const std::string & digitColor)118 void ClockComponent::SetDigitColor(const std::string& digitColor)
119 {
120     declaration_->SetDigitColor(digitColor);
121 }
122 
GetDigitColor() const123 const Color& ClockComponent::GetDigitColor() const
124 {
125     return declaration_->GetDigitColor();
126 }
127 
SetDigitColorNight(const std::string & digitColorNight)128 void ClockComponent::SetDigitColorNight(const std::string& digitColorNight)
129 {
130     declaration_->SetDigitColorNight(digitColorNight);
131 }
132 
GetDigitColorNight() const133 const Color& ClockComponent::GetDigitColorNight() const
134 {
135     return declaration_->GetDigitColorNight();
136 }
137 
SetDefaultSize(const Dimension & defaultSize)138 void ClockComponent::SetDefaultSize(const Dimension& defaultSize)
139 {
140     declaration_->SetDefaultSize(defaultSize);
141 }
142 
GetDefaultSize() const143 const Dimension& ClockComponent::GetDefaultSize() const
144 {
145     return declaration_->GetDefaultSize();
146 }
147 
SetDigitSizeRatio(double digitSizeRatio)148 void ClockComponent::SetDigitSizeRatio(double digitSizeRatio)
149 {
150     declaration_->SetDigitSizeRatio(digitSizeRatio);
151 }
152 
GetDigitSizeRatio() const153 double ClockComponent::GetDigitSizeRatio() const
154 {
155     return declaration_->GetDigitSizeRatio();
156 }
157 
SetDigitRadiusRatio(double digitRadiusRatio)158 void ClockComponent::SetDigitRadiusRatio(double digitRadiusRatio)
159 {
160     declaration_->SetDigitRadiusRatio(digitRadiusRatio);
161 }
162 
GetDigitRadiusRatio() const163 double ClockComponent::GetDigitRadiusRatio() const
164 {
165     return declaration_->GetDigitRadiusRatio();
166 }
167 
GetFontFamilies() const168 const std::vector<std::string>& ClockComponent::GetFontFamilies() const
169 {
170     return declaration_->GetFontFamilies();
171 }
172 
SetFontFamilies(const std::vector<std::string> & fontFamilies)173 void ClockComponent::SetFontFamilies(const std::vector<std::string>& fontFamilies)
174 {
175     declaration_->SetFontFamilies(fontFamilies);
176 }
177 
GetShowDigit() const178 bool ClockComponent::GetShowDigit() const
179 {
180     return declaration_->GetShowDigit();
181 }
182 
SetShowDigit(bool showDigit)183 void ClockComponent::SetShowDigit(bool showDigit)
184 {
185     declaration_->SetShowDigit(showDigit);
186 }
187 
SetOnHourChangeEvent(const EventMarker & onHourChangeEvent)188 void ClockComponent::SetOnHourChangeEvent(const EventMarker& onHourChangeEvent)
189 {
190     declaration_->SetOnHourChangeEvent(onHourChangeEvent);
191 }
192 
GetOnHourChangeEvent() const193 const EventMarker& ClockComponent::GetOnHourChangeEvent() const
194 {
195     return declaration_->GetOnHourChangeEvent();
196 }
197 
GetDeclaration() const198 const RefPtr<ClockDeclaration>& ClockComponent::GetDeclaration() const
199 {
200     return declaration_;
201 }
202 
SetDeclaration(const RefPtr<ClockDeclaration> & declaration)203 void ClockComponent::SetDeclaration(const RefPtr<ClockDeclaration>& declaration)
204 {
205     declaration_ = declaration;
206 }
207 
208 } // namespace OHOS::Ace
209