1 /* 2 * Copyright (c) 2021-2022 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_BASE_WINDOW_ACE_DRAG_WINDOW_H 17 #define FOUNDATION_ACE_FRAMEWORKS_BASE_WINDOW_ACE_DRAG_WINDOW_H 18 19 #include "base/geometry/offset.h" 20 #include "base/image/pixel_map.h" 21 #include "base/memory/ace_type.h" 22 23 #ifndef USE_GRAPHIC_TEXT_GINE 24 namespace txt { 25 class Paragraph; 26 } 27 #else 28 namespace OHOS::Rosen { 29 class Typography; 30 } 31 #endif 32 33 namespace OHOS::Ace { 34 35 class RenderText; 36 37 namespace NG { 38 class FrameNode; 39 class Paragraph; 40 class TextPattern; 41 } // namespace NG 42 43 class ACE_EXPORT DragWindow : public AceType { 44 DECLARE_ACE_TYPE(DragWindow, AceType); 45 46 public: 47 struct DragWindowParams { 48 std::string windowName; 49 int32_t x = 0; 50 int32_t y = 0; 51 uint32_t width = 0; 52 uint32_t height = 0; 53 int32_t parentWindowId = -1; 54 }; 55 static RefPtr<DragWindow> CreateDragWindow( 56 const std::string& windowName, int32_t x, int32_t y, uint32_t width, uint32_t height); 57 static RefPtr<DragWindow> CreateDragWindow(const DragWindowParams& params); 58 59 static RefPtr<DragWindow> CreateTextDragWindow( 60 const std::string& windowName, int32_t x, int32_t y, uint32_t width, uint32_t height); 61 virtual void MoveTo(int32_t x, int32_t y) const = 0; 62 virtual void TextDragWindowMove(double x, double y) const = 0; 63 virtual void Destroy() const = 0; 64 virtual void DrawPixelMap(const RefPtr<PixelMap>& pixelmap) = 0; 65 virtual void DrawFrameNode(const RefPtr<NG::FrameNode>& rootNode) = 0; 66 #ifndef USE_ROSEN_DRAWING 67 virtual void DrawImage(void* skImage) = 0; 68 #else 69 virtual void DrawImage(void* drawingImage) = 0; 70 #endif 71 #ifndef USE_GRAPHIC_TEXT_GINE 72 virtual void DrawText( 73 std::shared_ptr<txt::Paragraph> paragraph, const Offset& offset, const RefPtr<RenderText>& renderText) = 0; 74 #else 75 virtual void DrawText( 76 std::shared_ptr<Rosen::Typography> paragraph_, const Offset& offset, const RefPtr<RenderText>& renderText) = 0; 77 #endif 78 virtual void DrawTextNG(const RefPtr<NG::Paragraph>& paragraph, const RefPtr<NG::TextPattern>& textPattern) = 0; 79 SetOffset(int32_t offsetX,int32_t offsetY)80 void SetOffset(int32_t offsetX, int32_t offsetY) 81 { 82 offsetX_ = offsetX; 83 offsetY_ = offsetY; 84 } 85 SetSize(int32_t width,int32_t height)86 void SetSize(int32_t width, int32_t height) 87 { 88 width_ = width; 89 height_ = height; 90 } 91 92 protected: 93 int32_t width_ = 0; 94 int32_t height_ = 0; 95 int32_t offsetX_ = 0; 96 int32_t offsetY_ = 0; 97 }; 98 } // namespace OHOS::Ace 99 100 #endif // FOUNDATION_ACE_FRAMEWORKS_BASE_WINDOW_ACE_DRAG_WINDOW_H 101