1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #ifndef INCLUDED_SVX_GALCTRL_HXX 21 #define INCLUDED_SVX_GALCTRL_HXX 22 23 #include <vcl/graph.hxx> 24 #include <vcl/customweld.hxx> 25 #include <vcl/transfer.hxx> 26 #include <svtools/valueset.hxx> 27 #include <vcl/GraphicObject.hxx> 28 #include <svx/svxdllapi.h> 29 30 class GalleryDragDrop; 31 class GalleryTheme; 32 class GalleryBrowser2; 33 class INetURLObject; 34 35 class GalleryPreview final : public weld::CustomWidgetController 36 { 37 private: 38 39 std::unique_ptr<GalleryDragDrop> mxDragDropTargetHelper; 40 std::unique_ptr<weld::ScrolledWindow> mxScrolledWindow; 41 GraphicObject aGraphicObj; 42 tools::Rectangle aPreviewRect; 43 GalleryBrowser2* mpParent; 44 GalleryTheme* mpTheme; 45 46 bool ImplGetGraphicCenterRect( const Graphic& rGraphic, tools::Rectangle& rResultRect ) const; 47 48 // Window 49 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; 50 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; 51 virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; 52 virtual bool Command(const CommandEvent& rCEvt) override; 53 virtual bool KeyInput( const KeyEvent& rKEvt ) override; 54 55 public: 56 57 GalleryPreview(GalleryBrowser2* pParent, std::unique_ptr<weld::ScrolledWindow> xScrolledWindow); 58 void SetTheme(GalleryTheme* pTheme) { mpTheme = pTheme; } 59 virtual ~GalleryPreview() override; 60 61 virtual bool StartDrag() override; 62 63 virtual void Show() override; 64 virtual void Hide() override; 65 66 void SetGraphic( const Graphic& rGraphic ) { aGraphicObj.SetGraphic( rGraphic ); } 67 static void PreviewMedia( const INetURLObject& rURL ); 68 }; 69 70 class SVXCORE_DLLPUBLIC DialogGalleryPreview final : public weld::CustomWidgetController 71 { 72 private: 73 GraphicObject aGraphicObj; 74 tools::Rectangle aPreviewRect; 75 76 SVX_DLLPRIVATE bool ImplGetGraphicCenterRect( const Graphic& rGraphic, tools::Rectangle& rResultRect ) const; 77 78 SVX_DLLPRIVATE virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; 79 80 public: 81 82 DialogGalleryPreview(); 83 84 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; 85 void SetGraphic( const Graphic& rGraphic ) { aGraphicObj.SetGraphic( rGraphic ); } 86 bool SetGraphic( const INetURLObject& ); 87 }; 88 89 class GalleryIconView final : public ValueSet 90 { 91 private: 92 std::unique_ptr<GalleryDragDrop> mxDragDropTargetHelper; 93 94 GalleryBrowser2* mpParent; 95 GalleryTheme* mpTheme; 96 97 // ValueSet 98 virtual void UserDraw( const UserDrawEvent& rUDEvt ) override; 99 100 // Window 101 virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; 102 virtual bool Command( const CommandEvent& rCEvt ) override; 103 virtual bool KeyInput( const KeyEvent& rKEvt ) override; 104 105 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; 106 107 public: 108 109 GalleryIconView(GalleryBrowser2* pParent, std::unique_ptr<weld::ScrolledWindow> xScrolledWindow); 110 void SetTheme(GalleryTheme* pTheme) { mpTheme = pTheme; } 111 virtual ~GalleryIconView() override; 112 113 virtual bool StartDrag() override; 114 115 static void drawTransparenceBackground(vcl::RenderContext& rOut, const Point& rPos, const Size& rSize); 116 }; 117 118 #endif // INCLUDED_SVX_GALCTRL_HXX 119 120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 121
