1 /* 2 * Copyright (c) 2025 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 "ui/view/components/text.h" 17 18 #include "interfaces/inner_api/ace_kit/src/view/frame_node_impl.h" 19 #include "ui/base/referenced.h" 20 #include "ui/view_stack/view_stack_processor.h" 21 22 #include "core/components_ng/pattern/text/text_model_ng.h" 23 24 namespace OHOS::Ace::Kit { 25 Text(const std::u16string & content)26Text::Text(const std::u16string& content) 27 { 28 int32_t nodeId = Ace::Kit::ViewStackProcessor::ClaimNodeId(); 29 auto aceNode = NG::TextModelNG::CreateFrameNode(nodeId, content); 30 node_ = AceType::MakeRefPtr<FrameNodeImpl>(aceNode); 31 } 32 33 Text::~Text() = default; 34 Create(const std::u16string & content)35RefPtr<Text> Text::Create(const std::u16string& content) 36 { 37 return Referenced::MakeRefPtr<Text>(content); 38 } 39 SetTextColor(const Color & value)40void Text::SetTextColor(const Color& value) 41 { 42 NG::TextModelNG::SetTextColor(reinterpret_cast<AceNode*>(node_->GetHandle()), value); 43 } 44 SetFontSize(const Dimension & value)45void Text::SetFontSize(const Dimension& value) 46 { 47 NG::TextModelNG::SetFontSize(reinterpret_cast<AceNode*>(node_->GetHandle()), value); 48 } 49 50 } // namespace OHOS::Ace::Kit 51