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_TEXT_TEXT_BASE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_TEXT_BASE_H 18 19 #include "base/memory/ace_type.h" 20 #include "core/components_ng/manager/select_overlay/selection_host.h" 21 #include "core/components_ng/pattern/text_field/text_selector.h" 22 #include "core/components_ng/render/drawing.h" 23 #include "core/components_ng/render/paragraph.h" 24 25 namespace OHOS::Ace::NG { 26 using ParagraphT = std::variant<std::shared_ptr<RSParagraph>, RefPtr<Paragraph>>; 27 28 enum class MouseStatus { PRESSED, RELEASED, MOVE, NONE }; 29 30 class TextBase : public virtual SelectionHost { 31 DECLARE_ACE_TYPE(TextBase, SelectionHost); 32 33 public: 34 TextBase() = default; 35 ~TextBase() override = default; 36 GetContentOffset()37 virtual OffsetF GetContentOffset() 38 { 39 return OffsetF(0, 0); 40 } 41 IsSelected()42 virtual bool IsSelected() const 43 { 44 return textSelector_.IsValid() && !textSelector_.StartEqualToDest(); 45 } 46 GetMouseStatus()47 MouseStatus GetMouseStatus() const 48 { 49 return mouseStatus_; 50 } 51 52 protected: 53 TextSelector textSelector_; 54 MouseStatus mouseStatus_ = MouseStatus::NONE; 55 ACE_DISALLOW_COPY_AND_MOVE(TextBase); 56 }; 57 } // namespace OHOS::Ace::NG 58 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_TEXT_BASE_H 59