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/search/search_component.h" 17 18 #include "core/components/search/search_element.h" 19 20 namespace OHOS::Ace { 21 SearchComponent()22SearchComponent::SearchComponent() 23 { 24 if (!declaration_) { 25 declaration_ = AceType::MakeRefPtr<SearchDeclaration>(); 26 declaration_->Init(); 27 } 28 } 29 CreateRenderNode()30RefPtr<RenderNode> SearchComponent::CreateRenderNode() 31 { 32 return RenderSearch::Create(); 33 } 34 CreateElement()35RefPtr<Element> SearchComponent::CreateElement() 36 { 37 return AceType::MakeRefPtr<SearchElement>(); 38 } 39 SetCloseIconSize(const Dimension & closeIconSize)40void SearchComponent::SetCloseIconSize(const Dimension& closeIconSize) 41 { 42 declaration_->SetCloseIconSize(closeIconSize); 43 } 44 GetCloseIconSize() const45const Dimension& SearchComponent::GetCloseIconSize() const 46 { 47 return declaration_->GetCloseIconSize(); 48 } 49 SetCloseIconHotZoneHorizontal(const Dimension & closeIconHotZoneHorizontal)50void SearchComponent::SetCloseIconHotZoneHorizontal(const Dimension& closeIconHotZoneHorizontal) 51 { 52 declaration_->SetCloseIconHotZoneHorizontal(closeIconHotZoneHorizontal); 53 } 54 GetCloseIconHotZoneHorizontal() const55const Dimension& SearchComponent::GetCloseIconHotZoneHorizontal() const 56 { 57 return declaration_->GetCloseIconHotZoneHorizontal(); 58 } 59 GetSearchText() const60const std::string& SearchComponent::GetSearchText() const 61 { 62 return declaration_->GetSearchText(); 63 } 64 SetSearchText(const std::string & searchText)65void SearchComponent::SetSearchText(const std::string& searchText) 66 { 67 declaration_->SetSearchText(searchText); 68 } 69 GetCloseIconSrc() const70const std::string& SearchComponent::GetCloseIconSrc() const 71 { 72 return declaration_->GetCloseIconSrc(); 73 } 74 SetCloseIconSrc(const std::string & closeIconSrc)75void SearchComponent::SetCloseIconSrc(const std::string& closeIconSrc) 76 { 77 declaration_->SetCloseIconSrc(closeIconSrc); 78 } 79 SetChangeEventId(const EventMarker & changeEventId)80void SearchComponent::SetChangeEventId(const EventMarker& changeEventId) 81 { 82 declaration_->SetChangeEventId(changeEventId); 83 } 84 GetChangeEventId() const85const EventMarker& SearchComponent::GetChangeEventId() const 86 { 87 return declaration_->GetChangeEventId(); 88 } 89 SetSubmitEventId(const EventMarker & submitEventId)90void SearchComponent::SetSubmitEventId(const EventMarker& submitEventId) 91 { 92 declaration_->SetSubmitEventId(submitEventId); 93 } 94 GetSubmitEventId() const95const EventMarker& SearchComponent::GetSubmitEventId() const 96 { 97 return declaration_->GetSubmitEventId(); 98 } 99 GetTextEditController() const100RefPtr<TextEditController> SearchComponent::GetTextEditController() const 101 { 102 return declaration_->GetTextEditController(); 103 } 104 SetTextEditController(const RefPtr<TextEditController> & controller)105void SearchComponent::SetTextEditController(const RefPtr<TextEditController>& controller) 106 { 107 declaration_->SetTextEditController(controller); 108 } 109 SetSubmitEvent(const std::function<void (const std::string &)> & event)110void SearchComponent::SetSubmitEvent(const std::function<void(const std::string&)>& event) 111 { 112 declaration_->SetSubmitEvent(event); 113 } 114 GetSubmitEvent() const115const std::function<void(const std::string&)>& SearchComponent::GetSubmitEvent() const 116 { 117 return declaration_->GetSubmitEvent(); 118 } 119 GetDecoration() const120RefPtr<Decoration> SearchComponent::GetDecoration() const 121 { 122 return declaration_->GetDecoration(); 123 } 124 SetDecoration(const RefPtr<Decoration> & decoration)125void SearchComponent::SetDecoration(const RefPtr<Decoration>& decoration) 126 { 127 declaration_->SetDecoration(decoration); 128 } 129 GetHoverColor() const130const Color& SearchComponent::GetHoverColor() const 131 { 132 return declaration_->GetHoverColor(); 133 } 134 SetHoverColor(const Color & hoverColor)135void SearchComponent::SetHoverColor(const Color& hoverColor) 136 { 137 declaration_->SetHoverColor(hoverColor); 138 } 139 GetPressColor() const140const Color& SearchComponent::GetPressColor() const 141 { 142 return declaration_->GetPressColor(); 143 } 144 SetPressColor(const Color & pressColor)145void SearchComponent::SetPressColor(const Color& pressColor) 146 { 147 declaration_->SetPressColor(pressColor); 148 } 149 SetPlaceHoldStyle(const TextStyle & style)150void SearchComponent::SetPlaceHoldStyle(const TextStyle& style) 151 { 152 declaration_->SetPlaceHoldStyle(style); 153 } 154 GetPlaceHoldStyle() const155const TextStyle& SearchComponent::GetPlaceHoldStyle() const 156 { 157 return declaration_->GetPlaceHoldStyle(); 158 } 159 SetEditingStyle(const TextStyle & style)160void SearchComponent::SetEditingStyle(const TextStyle& style) 161 { 162 declaration_->SetEditingStyle(style); 163 } 164 GetEditingStyle() const165const TextStyle& SearchComponent::GetEditingStyle() const 166 { 167 return declaration_->GetEditingStyle(); 168 } 169 SetDeclaration(const RefPtr<SearchDeclaration> & declaration)170void SearchComponent::SetDeclaration(const RefPtr<SearchDeclaration>& declaration) 171 { 172 if (declaration) { 173 declaration_ = declaration; 174 } 175 } 176 177 } // namespace OHOS::Ace 178