1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVX_GALCTRL_HXX
21 #define INCLUDED_SVX_GALCTRL_HXX
23 #include <vcl/graph.hxx>
24 #include <vcl/customweld.hxx>
25 #include <vcl/transfer.hxx>
26 #include <svtools/valueset.hxx>
27 #include <svtools/brwbox.hxx>
28 #include <vcl/GraphicObject.hxx>
29 #include <svx/svxdllapi.h>
32 class GalleryBrowser2
;
35 class SVX_DLLPUBLIC GalleryPreview
: public vcl::Window
, public DropTargetHelper
, public DragSourceHelper
39 GraphicObject aGraphicObj
;
40 tools::Rectangle aPreviewRect
;
41 GalleryTheme
* const mpTheme
;
43 SVX_DLLPRIVATE
bool ImplGetGraphicCenterRect( const Graphic
& rGraphic
, tools::Rectangle
& rResultRect
) const;
44 SVX_DLLPRIVATE
void InitSettings();
47 SVX_DLLPRIVATE
virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
48 SVX_DLLPRIVATE
virtual Size
GetOptimalSize() const override
;
49 SVX_DLLPRIVATE
virtual void MouseButtonDown(const MouseEvent
& rMEvt
) override
;
50 SVX_DLLPRIVATE
virtual void Command(const CommandEvent
& rCEvt
) override
;
51 SVX_DLLPRIVATE
virtual void KeyInput( const KeyEvent
& rKEvt
) override
;
52 SVX_DLLPRIVATE
virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
56 SVX_DLLPRIVATE
virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
) override
;
57 SVX_DLLPRIVATE
virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
) override
;
60 SVX_DLLPRIVATE
virtual void StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
) override
;
64 GalleryPreview(vcl::Window
* pParent
,
65 WinBits nStyle
= WB_TABSTOP
| WB_BORDER
,
66 GalleryTheme
* pTheme
= nullptr);
68 void SetGraphic( const Graphic
& rGraphic
) { aGraphicObj
.SetGraphic( rGraphic
); }
69 static void PreviewMedia( const INetURLObject
& rURL
);
72 class SVX_DLLPUBLIC SvxGalleryPreview
: public weld::CustomWidgetController
75 GraphicObject aGraphicObj
;
76 tools::Rectangle aPreviewRect
;
78 SVX_DLLPRIVATE
bool ImplGetGraphicCenterRect( const Graphic
& rGraphic
, tools::Rectangle
& rResultRect
) const;
80 SVX_DLLPRIVATE
virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
86 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
87 void SetGraphic( const Graphic
& rGraphic
) { aGraphicObj
.SetGraphic( rGraphic
); }
88 bool SetGraphic( const INetURLObject
& );
91 class GalleryIconView
: public ValueSet
, public DropTargetHelper
, public DragSourceHelper
93 using ValueSet::StartDrag
;
97 GalleryTheme
* mpTheme
;
102 virtual void UserDraw( const UserDrawEvent
& rUDEvt
) override
;
105 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
106 virtual void Command( const CommandEvent
& rCEvt
) override
;
107 virtual void KeyInput( const KeyEvent
& rKEvt
) override
;
108 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
111 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
) override
;
112 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
) override
;
115 virtual void StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
) override
;
119 GalleryIconView( GalleryBrowser2
* pParent
, GalleryTheme
* pTheme
);
122 class GalleryListView
: public BrowseBox
124 using BrowseBox::AcceptDrop
;
125 using BrowseBox::ExecuteDrop
;
129 Link
<GalleryListView
*,void> maSelectHdl
;
130 GalleryTheme
* mpTheme
;
136 virtual bool SeekRow( long nRow
) override
;
137 virtual void PaintField( vcl::RenderContext
& rDev
, const tools::Rectangle
& rRect
, sal_uInt16 nColumnId
) const override
;
138 virtual void DoubleClick( const BrowserMouseEvent
& rEvt
) override
;
139 virtual void Select() override
;
140 virtual sal_Int8
AcceptDrop( const BrowserAcceptDropEvent
& rEvt
) override
;
141 virtual sal_Int8
ExecuteDrop( const BrowserExecuteDropEvent
& rEvt
) override
;
142 virtual void KeyInput( const KeyEvent
& rKEvt
) override
;
145 virtual void Command( const CommandEvent
& rCEvt
) override
;
146 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
149 virtual void StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
) override
;
153 GalleryListView( GalleryBrowser2
* pParent
, GalleryTheme
* pTheme
);
155 void SetSelectHdl( const Link
<GalleryListView
*,void>& rSelectHdl
) { maSelectHdl
= rSelectHdl
; }
157 /** GetCellText returns the text at the given position
159 the number of the row
163 the text out of the cell
165 virtual OUString
GetCellText(long _nRow
, sal_uInt16 _nColId
) const override
;
167 // from IAccessibleTableProvider
168 virtual tools::Rectangle
GetFieldCharacterBounds(sal_Int32 _nRow
,sal_Int32 _nColumnPos
,sal_Int32 nIndex
) override
;
169 virtual sal_Int32
GetFieldIndexAtPoint(sal_Int32 _nRow
,sal_Int32 _nColumnPos
,const Point
& _rPoint
) override
;
172 #endif // INCLUDED_SVX_GALCTRL_HXX
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */