• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/render_search.h"
19 #include "core/components/search/search_element.h"
20 
21 namespace OHOS::Ace {
22 
SearchComponent()23 SearchComponent::SearchComponent()
24 {
25     if (!declaration_) {
26         declaration_ = AceType::MakeRefPtr<SearchDeclaration>();
27         declaration_->Init();
28     }
29 }
30 
CreateRenderNode()31 RefPtr<RenderNode> SearchComponent::CreateRenderNode()
32 {
33     return RenderSearch::Create();
34 }
35 
CreateElement()36 RefPtr<Element> SearchComponent::CreateElement()
37 {
38     return AceType::MakeRefPtr<SearchElement>();
39 }
40 
SetCloseIconSize(const Dimension & closeIconSize)41 void SearchComponent::SetCloseIconSize(const Dimension& closeIconSize)
42 {
43     declaration_->SetCloseIconSize(closeIconSize);
44 }
45 
GetCloseIconSize() const46 const Dimension& SearchComponent::GetCloseIconSize() const
47 {
48     return declaration_->GetCloseIconSize();
49 }
50 
SetCloseIconHotZoneHorizontal(const Dimension & closeIconHotZoneHorizontal)51 void SearchComponent::SetCloseIconHotZoneHorizontal(const Dimension& closeIconHotZoneHorizontal)
52 {
53     declaration_->SetCloseIconHotZoneHorizontal(closeIconHotZoneHorizontal);
54 }
55 
GetCloseIconHotZoneHorizontal() const56 const Dimension& SearchComponent::GetCloseIconHotZoneHorizontal() const
57 {
58     return declaration_->GetCloseIconHotZoneHorizontal();
59 }
60 
GetSearchText() const61 const std::string& SearchComponent::GetSearchText() const
62 {
63     return declaration_->GetSearchText();
64 }
65 
SetSearchText(const std::string & searchText)66 void SearchComponent::SetSearchText(const std::string& searchText)
67 {
68     declaration_->SetSearchText(searchText);
69 }
70 
GetCloseIconSrc() const71 const std::string& SearchComponent::GetCloseIconSrc() const
72 {
73     return declaration_->GetCloseIconSrc();
74 }
75 
SetCloseIconSrc(const std::string & closeIconSrc)76 void SearchComponent::SetCloseIconSrc(const std::string& closeIconSrc)
77 {
78     declaration_->SetCloseIconSrc(closeIconSrc);
79 }
80 
SetChangeEventId(const EventMarker & changeEventId)81 void SearchComponent::SetChangeEventId(const EventMarker& changeEventId)
82 {
83     declaration_->SetChangeEventId(changeEventId);
84 }
85 
GetChangeEventId() const86 const EventMarker& SearchComponent::GetChangeEventId() const
87 {
88     return declaration_->GetChangeEventId();
89 }
90 
SetSubmitEventId(const EventMarker & submitEventId)91 void SearchComponent::SetSubmitEventId(const EventMarker& submitEventId)
92 {
93     declaration_->SetSubmitEventId(submitEventId);
94 }
95 
GetSubmitEventId() const96 const EventMarker& SearchComponent::GetSubmitEventId() const
97 {
98     return declaration_->GetSubmitEventId();
99 }
100 
GetTextEditController() const101 RefPtr<TextEditController> SearchComponent::GetTextEditController() const
102 {
103     return declaration_->GetTextEditController();
104 }
105 
SetTextEditController(const RefPtr<TextEditController> & controller)106 void SearchComponent::SetTextEditController(const RefPtr<TextEditController>& controller)
107 {
108     declaration_->SetTextEditController(controller);
109 }
110 
SetSubmitEvent(const std::function<void (const std::string &)> & event)111 void SearchComponent::SetSubmitEvent(const std::function<void(const std::string&)>& event)
112 {
113     declaration_->SetSubmitEvent(event);
114 }
115 
GetSubmitEvent() const116 const std::function<void(const std::string&)>& SearchComponent::GetSubmitEvent() const
117 {
118     return declaration_->GetSubmitEvent();
119 }
120 
GetDecoration() const121 RefPtr<Decoration> SearchComponent::GetDecoration() const
122 {
123     return declaration_->GetDecoration();
124 }
125 
SetDecoration(const RefPtr<Decoration> & decoration)126 void SearchComponent::SetDecoration(const RefPtr<Decoration>& decoration)
127 {
128     declaration_->SetDecoration(decoration);
129 }
130 
GetHoverColor() const131 const Color& SearchComponent::GetHoverColor() const
132 {
133     return declaration_->GetHoverColor();
134 }
135 
SetHoverColor(const Color & hoverColor)136 void SearchComponent::SetHoverColor(const Color& hoverColor)
137 {
138     declaration_->SetHoverColor(hoverColor);
139 }
140 
GetPressColor() const141 const Color& SearchComponent::GetPressColor() const
142 {
143     return declaration_->GetPressColor();
144 }
145 
SetPressColor(const Color & pressColor)146 void SearchComponent::SetPressColor(const Color& pressColor)
147 {
148     declaration_->SetPressColor(pressColor);
149 }
150 
SetPlaceHoldStyle(const TextStyle & style)151 void SearchComponent::SetPlaceHoldStyle(const TextStyle& style)
152 {
153     declaration_->SetPlaceHoldStyle(style);
154 }
155 
GetPlaceHoldStyle() const156 const TextStyle& SearchComponent::GetPlaceHoldStyle() const
157 {
158     return declaration_->GetPlaceHoldStyle();
159 }
160 
SetEditingStyle(const TextStyle & style)161 void SearchComponent::SetEditingStyle(const TextStyle& style)
162 {
163     declaration_->SetEditingStyle(style);
164 }
165 
GetEditingStyle() const166 const TextStyle& SearchComponent::GetEditingStyle() const
167 {
168     return declaration_->GetEditingStyle();
169 }
170 
SetDeclaration(const RefPtr<SearchDeclaration> & declaration)171 void SearchComponent::SetDeclaration(const RefPtr<SearchDeclaration>& declaration)
172 {
173     if (declaration) {
174         declaration_ = declaration;
175     }
176 }
177 
178 } // namespace OHOS::Ace
179