• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_BUTTON_MODEL_IMPL_H
17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_BUTTON_MODEL_IMPL_H
18 
19 #include "core/components/button/button_component.h"
20 #include "core/components/text/text_component.h"
21 #include "core/components_ng/pattern/button/button_model.h"
22 
23 namespace OHOS::Ace::Framework {
24 class ButtonModelImpl : public OHOS::Ace::ButtonModel {
25 public:
26     void SetFontSize(const Dimension& fontSize) override;
27     void SetFontWeight(const Ace::FontWeight& fontWeight) override;
28     void SetFontStyle(const Ace::FontStyle& fontStyle) override;
29     void SetFontFamily(const std::vector<std::string>& fontFamily) override;
30     void SetFontColor(const Color& textColor) override;
31     void SetType(const int value) override;
32     void SetStateEffect(const bool stateEffect) override;
33     void CreateWithLabel(const CreateWithPara& para, std::list<RefPtr<Component>>& buttonChildren) override;
34     void Create(const CreateWithPara& para, std::list<RefPtr<Component>>& buttonChildren) override;
35     void CreateWithChild(const CreateWithPara& para) override;
36     void Padding(const NG::PaddingProperty& paddingNew, const Edge& paddingOld) override;
37     void OnClick(GestureEventFunc&& tapEventFunc, ClickEventFunc&& clickEventFunc, double distanceThreshold) override;
38     void BackgroundColor(const Color& color, const bool& colorFlag) override;
39     void SetWidth(const Dimension& width) override;
40     void SetHeight(const Dimension& height) override;
41     void SetAspectRatio(const double& ratio) override;
42     void SetSize(const std::optional<Dimension>& width, const std::optional<Dimension>& height) override;
43     void SetBorderRadius(const Dimension& radius) override;
SetBorderRadius(const std::optional<Dimension> & radiusTopLeft,const std::optional<Dimension> & radiusTopRight,const std::optional<Dimension> & radiusBottomLeft,const std::optional<Dimension> & radiusBottomRight)44     void SetBorderRadius(const std::optional<Dimension>& radiusTopLeft, const std::optional<Dimension>& radiusTopRight,
45         const std::optional<Dimension>& radiusBottomLeft,
46         const std::optional<Dimension>& radiusBottomRight) override {};
47     void SetRemoteMessage(RemoteCallback&& remoteCallback) override;
CreateWithColorResourceObj(const RefPtr<ResourceObject> & resObj,const ButtonColorType buttonColorType)48     void CreateWithColorResourceObj(const RefPtr<ResourceObject>& resObj,
49         const ButtonColorType buttonColorType) override {};
CreateWithStringResourceObj(const RefPtr<ResourceObject> & resObj,const ButtonStringType buttonStringType)50     void CreateWithStringResourceObj(const RefPtr<ResourceObject>& resObj,
51         const ButtonStringType buttonStringType) override {};
CreateWithDimensionFpResourceObj(const RefPtr<ResourceObject> & resObj,const ButtonDimensionType buttonDimensionType)52     void CreateWithDimensionFpResourceObj(const RefPtr<ResourceObject>& resObj,
53         const ButtonDimensionType buttonDimensionType) override {};
CreateWithDoubleResourceObj(const RefPtr<ResourceObject> & resObj,const ButtonDoubleType buttonDoubleType)54     void CreateWithDoubleResourceObj(const RefPtr<ResourceObject>& resObj,
55         const ButtonDoubleType buttonDoubleType) override {};
CreateWithFamiliesResourceObj(const RefPtr<ResourceObject> & resObj,const ButtonStringType buttonStringType)56     void CreateWithFamiliesResourceObj(const RefPtr<ResourceObject>& resObj,
57         const ButtonStringType buttonStringType) override {};
58 
59 private:
60     static RefPtr<TextComponent> GetTextComponent();
61     static void ResetButtonHeight();
62     static void SetTypeAndStateEffect(const std::optional<ButtonType>& type, const std::optional<bool>& stateEffect,
63         const RefPtr<ButtonComponent>& buttonComponent);
64     static void SetDefaultAttributes(const RefPtr<ButtonComponent>& buttonComponent);
65 };
66 } // namespace OHOS::Ace::Framework
67 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_BUTTON_MODEL_IMPL_H
68