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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_MENU_MENU_ITEM_MODEL_NG_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_MENU_MENU_ITEM_MODEL_NG_H 18 19 #include "core/components_ng/pattern/menu/menu_item/menu_item_model.h" 20 21 namespace OHOS::Ace::NG { 22 class ACE_EXPORT MenuItemModelNG : public OHOS::Ace::MenuItemModel { 23 public: 24 void Create(const RefPtr<NG::UINode>& customNode) override; 25 void Create(const MenuItemProperties& props) override; 26 void SetSelected(bool isSelected = false) override; 27 void SetSelectIcon(bool isShow = false) override; 28 void SetSelectIconSrc(const std::string& src) override; 29 void SetOnChange(std::function<void(bool)>&& onChange) override; 30 void SetFontSize(const Dimension& fontSize) override; 31 void SetFontWeight(FontWeight weight) override; 32 void SetFontStyle(Ace::FontStyle style) override; 33 void SetFontColor(const std::optional<Color>& color) override; 34 void SetFontFamily(const std::vector<std::string> &families) override; 35 void SetLabelFontSize(const Dimension& fontSize) override; 36 void SetLabelFontWeight(FontWeight weight) override; 37 void SetLabelFontStyle(Ace::FontStyle style) override; 38 void SetLabelFontColor(const std::optional<Color>& color) override; 39 void SetLabelFontFamily(const std::vector<std::string> &families) override; 40 void SetSelectedChangeEvent(std::function<void(bool)>&& selectedChangeEvent) override; 41 void SetSelectIconSymbol(std::function<void(WeakPtr<NG::FrameNode>)>&& symbolApply) override; 42 43 static void SetSelected(FrameNode* frameNode, bool isSelected = false); 44 static void SetLabelFontColor(FrameNode* frameNode, const std::optional<Color>& color); 45 static void SetLabelFontSize(FrameNode* frameNode, const Dimension& fontSize); 46 static void SetLabelFontWeight(FrameNode* frameNode, FontWeight weight); 47 static void SetLabelFontFamily(FrameNode* frameNode, const std::vector<std::string>& families); 48 static void SetLabelFontStyle(FrameNode* frameNode, Ace::FontStyle style); 49 static void SetFontColor(FrameNode* frameNode, const std::optional<Color>& color); 50 static void SetFontSize(FrameNode* frameNode, const Dimension& fontSize); 51 static void SetFontWeight(FrameNode* frameNode, FontWeight weight); 52 static void SetFontFamily(FrameNode* frameNode, const std::vector<std::string>& families); 53 static void SetFontStyle(FrameNode* frameNode, Ace::FontStyle style); 54 static void SetSelectIcon(FrameNode* frameNode, bool isShow = false); 55 static void SetSelectIconSrc(FrameNode* frameNode, const std::string& src); 56 static void SetSelectIconSymbol(FrameNode* frameNode, std::function<void(WeakPtr<NG::FrameNode>)>&& symbolApply); 57 58 private: 59 void UpdateMenuProperty(const RefPtr<NG::FrameNode>& menuItem, const MenuItemProperties& menuItemProps); 60 }; 61 } // namespace OHOS::Ace::NG 62 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_MENU_MENU_ITEM_MODEL_NG_H 63