1 /* 2 * Copyright (c) 2022-2024 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_PATTERN_TEXT_PICKER_TEXT_PICKER_PAINT_METHOD_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_PICKER_TEXT_PICKER_PAINT_METHOD_H 18 19 #include "base/geometry/ng/size_t.h" 20 #include "base/memory/ace_type.h" 21 #include "base/memory/referenced.h" 22 #include "base/utils/macros.h" 23 #include "base/utils/utils.h" 24 #include "core/components/common/properties/color.h" 25 #include "core/components_ng/pattern/pattern.h" 26 #include "core/components_ng/pattern/text_picker/textpicker_properties.h" 27 #include "core/components_ng/render/divider_painter.h" 28 #include "core/components_ng/render/node_paint_method.h" 29 #include "core/components_ng/pattern/picker_utils/picker_paint_method_utils.h" 30 31 namespace OHOS::Ace::NG { 32 33 class ACE_EXPORT TextPickerPaintMethod : public NodePaintMethod { 34 DECLARE_ACE_TYPE(TextPickerPaintMethod, NodePaintMethod) 35 public: 36 TextPickerPaintMethod() = default; ~TextPickerPaintMethod()37 ~TextPickerPaintMethod() override 38 { 39 if (circleUtils_) { 40 delete circleUtils_; 41 } 42 } 43 TextPickerPaintMethod(const WeakPtr<Pattern> & pattern)44 TextPickerPaintMethod(const WeakPtr<Pattern>& pattern) 45 { 46 pattern_ = pattern; 47 } 48 GetDefaultPickerItemHeight()49 double GetDefaultPickerItemHeight() const 50 { 51 return defaultPickerItemHeight_; 52 } 53 SetDefaultPickerItemHeight(double defaultPickerItemHeight)54 void SetDefaultPickerItemHeight(double defaultPickerItemHeight) 55 { 56 defaultPickerItemHeight_ = defaultPickerItemHeight; 57 } 58 SetEnabled(bool enabled)59 void SetEnabled(bool enabled) 60 { 61 enabled_ = enabled; 62 } 63 64 CanvasDrawFunction GetContentDrawFunction(PaintWrapper* paintWrapper) override; 65 CanvasDrawFunction GetForegroundDrawFunction(PaintWrapper* paintWrapper) override; 66 void PaintDividerLines(RSCanvas& canvas, const RectF& contentRect, const DividerInfo &info, 67 bool isDefaultLine = true); 68 69 private: 70 double defaultPickerItemHeight_ = 0.0; 71 bool enabled_ = true; 72 73 WeakPtr<Pattern> pattern_; 74 75 bool NeedPaintDividerLines(const RectF &contentRect, const ItemDivider ÷r, double dividerHeight, 76 DividerInfo& info); 77 void PaintDefaultDividerLines(RSCanvas& canvas, const RectF &contentRect, double dividerHeight); 78 void PaintCustomDividerLines(RSCanvas& canvas, const RectF &contentRect, const RectF &frameRect, 79 const ItemDivider ÷r, double dividerHeight); 80 void PaintLine(const OffsetF& offset, const DividerInfo &info, RSCanvas& canvas); 81 bool SetStrokeWidth(const ItemDivider ÷r, double dividerHeight, DividerInfo& info); 82 PickerPaintMethodCircleUtils *circleUtils_ = NULL; 83 }; 84 } // namespace OHOS::Ace::NG 85 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_PICKER_TEXT_PICKER_PAINT_METHOD_H 86