• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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_RICH_EDITOR_RICH_EDITOR_PAINT_METHOD_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_RICH_EDITOR_RICH_EDITOR_PAINT_METHOD_H
18 
19 #include "core/components_ng/pattern/rich_editor/paragraph_manager.h"
20 #include "core/components_ng/pattern/text/text_content_modifier.h"
21 #include "core/components_ng/pattern/text/text_overlay_modifier.h"
22 #include "core/components_ng/pattern/text/text_paint_method.h"
23 
24 namespace OHOS::Ace::NG {
25 class ACE_EXPORT RichEditorPaintMethod : public TextPaintMethod {
26     DECLARE_ACE_TYPE(RichEditorPaintMethod, TextPaintMethod);
27 public:
28     RichEditorPaintMethod(const WeakPtr<Pattern>& pattern, const ParagraphManager* pManager, float baselineOffset,
29         const RefPtr<TextContentModifier>& contentMod, const RefPtr<TextOverlayModifier>& overlayMod);
30 
31     ~RichEditorPaintMethod() override = default;
32     void UpdateContentModifier(PaintWrapper* paintWrapper) override;
33     void UpdateOverlayModifier(PaintWrapper* paintWrapper) override;
34     void SetCaretState(PaintWrapper* paintWrapper);
35     void SetPreviewTextDecoration(PaintWrapper* paintWrapper);
36     void SetCaretOffsetAndHeight(PaintWrapper* paintWrapper);
37 
38 private:
39     static std::vector<RectF> CalculateSelectedRect(
40         const std::vector<std::pair<std::vector<RectF>, ParagraphStyle>>& selectedRects, float contentWidth);
41     const ParagraphManager* pManager_;
42     ACE_DISALLOW_COPY_AND_MOVE(RichEditorPaintMethod);
43 };
44 } // namespace OHOS::Ace::NG
45 
46 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_RICH_EDITOR_RICH_EDITOR_PAINT_METHOD_H
47