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 #ifndef OHOS_ACELITE_INPUT_CHECKBOX_COMPONENT_H 16 #define OHOS_ACELITE_INPUT_CHECKBOX_COMPONENT_H 17 #include "component.h" 18 #include "key_parser.h" 19 #include "non_copyable.h" 20 #include "ui_checkbox.h" 21 22 namespace OHOS { 23 namespace ACELite { 24 class InputCheckboxComponent final : public Component { 25 public: 26 ACE_DISALLOW_COPY_AND_MOVE(InputCheckboxComponent); 27 InputCheckboxComponent() = delete; InputCheckboxComponent(jerry_value_t options,jerry_value_t children,AppStyleManager * manager)28 InputCheckboxComponent(jerry_value_t options, jerry_value_t children, AppStyleManager *manager) 29 : Component(options, children, manager), 30 changeListener_(nullptr), 31 clickListener_(nullptr), 32 normalBackGroundImg_(nullptr), 33 pressedBackGroundImg_(nullptr) 34 { 35 SetComponentName(K_INPUT); 36 } 37 ~InputCheckboxComponent() override; 38 bool SetPrivateAttribute(uint16_t attrKeyId, jerry_value_t attrValue) override; 39 bool RegisterPrivateEventListener(uint16_t eventTypeId, jerry_value_t funcValue, bool isStopPropagation) override; 40 bool ApplyPrivateStyle(const AppStyleItem *style) override; 41 void PostRender() override; 42 43 protected: GetComponentRootView()44 UIView *GetComponentRootView() const override 45 { 46 return const_cast<UICheckBox *>(&checkbox_); 47 } 48 49 private: 50 void DealEvent(); 51 UICheckBox checkbox_; 52 StateChangeListener *changeListener_; 53 ViewOnClickListener *clickListener_; 54 char *normalBackGroundImg_; 55 char *pressedBackGroundImg_; 56 }; 57 } // namespace ACELite 58 } // namespace OHOS 59 #endif // OHOS_ACELITE_INPUT_CHECKBOX_COMPONENT_H 60