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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CLOCK_CLOCK_COMPONENT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CLOCK_CLOCK_COMPONENT_H 18 19 #include "core/components/clock/clock_element.h" 20 #include "core/components/clock/render_clock.h" 21 #include "core/components/declaration/clock/clock_declaration.h" 22 23 namespace OHOS::Ace { 24 25 class ClockComponent : public ComponentGroup { 26 DECLARE_ACE_TYPE(ClockComponent, ComponentGroup); 27 28 public: 29 ClockComponent(); 30 ~ClockComponent() override = default; 31 CreateRenderNode()32 RefPtr<RenderNode> CreateRenderNode() override 33 { 34 return RenderClock::Create(); 35 } 36 CreateElement()37 RefPtr<Element> CreateElement() override 38 { 39 return AceType::MakeRefPtr<ClockElement>(); 40 } 41 void SetClockFaceSrc(const std::string& clockFaceSrc); 42 void SetClockFaceNightSrc(const std::string& clockFaceNightSrc); 43 void SetHourHandSrc(const std::string& hourHandSrc); 44 void SetHourHandNightSrc(const std::string& hourHandNightSrc); 45 void SetMinuteHandSrc(const std::string& minuteHandSrc); 46 void SetMinuteHandNightSrc(const std::string& minuteHandNightSrc); 47 void SetSecondHandSrc(const std::string& secondHandSrc); 48 void SetSecondHandNightSrc(const std::string& secondHandNightSrc); 49 void SetHoursWest(double hoursWest); 50 void SetDigitColor(const std::string& digitColor); 51 void SetDigitColorNight(const std::string& digitColorNight); 52 void SetDefaultSize(const Dimension& defaultSize); 53 void SetDigitSizeRatio(double digitSizeRatio); 54 void SetDigitRadiusRatio(double digitRadiusRatio); 55 void SetFontFamilies(const std::vector<std::string>& fontFamilies); 56 void SetShowDigit(bool showDigit); 57 void SetOnHourChangeEvent(const EventMarker& onHourChangeEvent); 58 const std::string& GetClockFaceSrc() const; 59 const std::string& GetClockFaceNightSrc() const; 60 const std::string& GetHourHandSrc() const; 61 const std::string& GetHourHandNightSrc() const; 62 const std::string& GetMinuteHandSrc() const; 63 const std::string& GetMinuteHandNightSrc() const; 64 const std::string& GetSecondHandSrc() const; 65 const std::string& GetSecondHandNightSrc() const; 66 double GetHoursWest() const; 67 const Color& GetDigitColor() const; 68 const Color& GetDigitColorNight() const; 69 const Dimension& GetDefaultSize() const; 70 double GetDigitSizeRatio() const; 71 double GetDigitRadiusRatio() const; 72 const std::vector<std::string>& GetFontFamilies() const; 73 bool GetShowDigit() const; 74 const EventMarker& GetOnHourChangeEvent() const; 75 76 void SetDeclaration(const RefPtr<ClockDeclaration>& declaration); 77 const RefPtr<ClockDeclaration>& GetDeclaration() const; 78 79 private: 80 RefPtr<ClockDeclaration> declaration_; 81 }; 82 83 } // namespace OHOS::Ace 84 85 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CLOCK_CLOCK_COMPONENT_H 86