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_INC_GALBRWS2_HXX
21 #define INCLUDED_SVX_INC_GALBRWS2_HXX
23 #include <vcl/button.hxx>
24 #include <vcl/fixed.hxx>
25 #include <vcl/timer.hxx>
26 #include <vcl/toolbox.hxx>
27 #include <vcl/transfer.hxx>
28 #include <svl/lstner.hxx>
29 #include <svx/galctrl.hxx>
30 #include <svtools/miscopt.hxx>
32 #include <com/sun/star/frame/XDispatch.hpp>
33 #include <com/sun/star/uno/XComponentContext.hpp>
34 #include <com/sun/star/util/XURLTransformer.hpp>
37 enum GalleryBrowserMode
39 GALLERYBROWSERMODE_NONE
= 0,
40 GALLERYBROWSERMODE_ICON
= 1,
41 GALLERYBROWSERMODE_LIST
= 2,
42 GALLERYBROWSERMODE_PREVIEW
= 3
46 enum class GalleryBrowserTravel
48 First
, Last
, Previous
, Next
51 enum class GalleryItemFlags
{
57 template<> struct typed_flags
<GalleryItemFlags
> : is_typed_flags
<GalleryItemFlags
, 0x0006> {};
61 class GalleryToolBox
: public ToolBox
65 virtual void KeyInput( const KeyEvent
& rKEvt
) override
;
69 GalleryToolBox( GalleryBrowser2
* pParent
);
75 class GalleryIconView
;
76 class GalleryListView
;
82 namespace svx
{ namespace sidebar
{ class GalleryControl
; } }
84 class GalleryBrowser2
: public Control
, public SfxListener
86 friend class GalleryBrowser
;
87 friend class svx::sidebar::GalleryControl
;
88 using Window::KeyInput
;
92 SvtMiscOptions maMiscOptions
;
94 GalleryTheme
* mpCurTheme
;
95 VclPtr
<GalleryIconView
> mpIconView
;
96 VclPtr
<GalleryListView
> mpListView
;
97 VclPtr
<GalleryPreview
> mpPreview
;
98 VclPtr
<GalleryToolBox
> maViewBox
;
99 VclPtr
<FixedLine
> maSeparator
;
100 VclPtr
<FixedText
> maInfoBar
;
101 sal_uInt32 mnCurActionPos
;
102 GalleryBrowserMode meMode
;
103 GalleryBrowserMode meLastMode
;
105 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
106 css::uno::Reference
< css::util::XURLTransformer
> m_xTransformer
;
110 void ImplUpdateViews( sal_uInt16 nSelectionId
);
111 void ImplUpdateInfoBar();
112 sal_uInt32
ImplGetSelectedItemId( const Point
* pSelPosPixel
, Point
& rSelPos
);
113 void ImplSelectItemId(sal_uInt32 nItemId
);
116 virtual void Resize() override
;
117 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
120 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
122 DECL_LINK( SelectObjectHdl
, GalleryListView
*, void );
123 DECL_LINK( SelectObjectValueSetHdl
, ValueSet
*, void );
124 DECL_LINK( SelectTbxHdl
, ToolBox
*, void );
125 DECL_LINK( MiscHdl
, LinkParamNone
*, void );
129 static GalleryBrowserMode meInitMode
;
133 static OUString
GetItemText( const SgaObject
& rObj
, GalleryItemFlags nItemTextFlags
);
137 GalleryBrowser2(vcl::Window
* pParent
, Gallery
* pGallery
);
138 virtual ~GalleryBrowser2() override
;
139 virtual void dispose() override
;
141 void SelectTheme( const OUString
& rThemeName
);
143 GalleryBrowserMode
GetMode() const { return meMode
; }
144 void SetMode( GalleryBrowserMode eMode
);
146 vcl::Window
* GetViewWindow() const;
148 void Travel( GalleryBrowserTravel eTravel
);
150 INetURLObject
GetURL() const;
151 OUString
GetFilterName() const;
153 sal_Int8
AcceptDrop( DropTargetHelper
& rTarget
);
154 sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
);
155 void StartDrag( const Point
* pDragPoint
= nullptr );
156 void TogglePreview();
157 void ShowContextMenu( const Point
* pContextPoint
);
158 bool KeyInput( const KeyEvent
& rEvt
, vcl::Window
* pWindow
);
160 static css::uno::Reference
< css::frame::XFrame
> GetFrame();
161 const css::uno::Reference
< css::util::XURLTransformer
>& GetURLTransformer() const { return m_xTransformer
; }
163 void Execute(const OString
&rIdent
);
164 void DispatchAdd(const css::uno::Reference
<css::frame::XDispatch
> &rxDispatch
,
165 const css::util::URL
&rURL
);
167 DECL_STATIC_LINK( GalleryBrowser2
, AsyncDispatch_Impl
, void*, void );
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */