Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / svx / inc / galbrws2.hxx
blobcbfef1097bfc002722dc794942d5873fe3514ef1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/lstbox.hxx>
24 #include <vcl/button.hxx>
25 #include <vcl/fixed.hxx>
26 #include <vcl/timer.hxx>
27 #include <vcl/toolbox.hxx>
28 #include <svtools/transfer.hxx>
29 #include <svl/lstner.hxx>
30 #include <svx/galctrl.hxx>
31 #include <svtools/miscopt.hxx>
33 #include <com/sun/star/frame/XDispatch.hpp>
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <com/sun/star/util/XURLTransformer.hpp>
38 enum GalleryBrowserMode
40 GALLERYBROWSERMODE_NONE = 0,
41 GALLERYBROWSERMODE_ICON = 1,
42 GALLERYBROWSERMODE_LIST = 2,
43 GALLERYBROWSERMODE_PREVIEW = 3
47 enum class GalleryBrowserTravel
49 First, Last, Previous, Next
52 enum class GalleryItemFlags {
53 ThemeName = 0x0001,
54 Title = 0x0002,
55 Path = 0x0004
57 namespace o3tl
59 template<> struct typed_flags<GalleryItemFlags> : is_typed_flags<GalleryItemFlags, 0x0007> {};
63 class GalleryToolBox : public ToolBox
65 private:
67 virtual void KeyInput( const KeyEvent& rKEvt ) override;
69 public:
71 GalleryToolBox( GalleryBrowser2* pParent );
75 class Gallery;
76 class GalleryTheme;
77 class GalleryIconView;
78 class GalleryListView;
79 class GalleryPreview;
80 class Menu;
81 class SgaObject;
82 struct DispatchInfo;
84 namespace svx { namespace sidebar { class GalleryControl; } }
86 class GalleryBrowser2 : public Control, public SfxListener
88 friend class GalleryBrowser;
89 friend class svx::sidebar::GalleryControl;
90 using Window::KeyInput;
92 private:
94 SvtMiscOptions maMiscOptions;
95 Gallery* mpGallery;
96 GalleryTheme* mpCurTheme;
97 VclPtr<GalleryIconView> mpIconView;
98 VclPtr<GalleryListView> mpListView;
99 VclPtr<GalleryPreview> mpPreview;
100 VclPtr<GalleryToolBox> maViewBox;
101 VclPtr<FixedLine> maSeparator;
102 VclPtr<FixedText> maInfoBar;
103 sal_uInt32 mnCurActionPos;
104 GalleryBrowserMode meMode;
105 GalleryBrowserMode meLastMode;
107 css::uno::Reference< css::uno::XComponentContext > m_xContext;
108 css::uno::Reference< css::util::XURLTransformer > m_xTransformer;
110 void InitSettings();
112 void ImplUpdateViews( sal_uInt16 nSelectionId );
113 void ImplUpdateInfoBar();
114 sal_uInt32 ImplGetSelectedItemId( const Point* pSelPosPixel, Point& rSelPos );
115 void ImplSelectItemId(sal_uInt32 nItemId);
117 // Control
118 virtual void Resize() override;
119 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
121 // SfxListener
122 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
124 DECL_LINK( SelectObjectHdl, GalleryListView*, void );
125 DECL_LINK( SelectObjectValueSetHdl, ValueSet*, void );
126 DECL_LINK( SelectTbxHdl, ToolBox*, void );
127 DECL_LINK( MiscHdl, LinkParamNone*, void );
129 private:
131 static GalleryBrowserMode meInitMode;
133 public:
135 static OUString GetItemText( const GalleryTheme& rTheme, const SgaObject& rObj, GalleryItemFlags nItemTextFlags );
137 public:
139 GalleryBrowser2(vcl::Window* pParent, Gallery* pGallery);
140 virtual ~GalleryBrowser2() override;
141 virtual void dispose() override;
143 void SelectTheme( const OUString& rThemeName );
145 GalleryBrowserMode GetMode() const { return meMode; }
146 void SetMode( GalleryBrowserMode eMode );
148 vcl::Window* GetViewWindow() const;
150 void Travel( GalleryBrowserTravel eTravel );
152 INetURLObject GetURL() const;
153 OUString GetFilterName() const;
155 sal_Int8 AcceptDrop( DropTargetHelper& rTarget );
156 sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
157 void StartDrag( const Point* pDragPoint = nullptr );
158 void TogglePreview();
159 void ShowContextMenu( const Point* pContextPoint );
160 bool KeyInput( const KeyEvent& rEvt, vcl::Window* pWindow );
162 static css::uno::Reference< css::frame::XFrame > GetFrame();
163 const css::uno::Reference< css::util::XURLTransformer >& GetURLTransformer() const { return m_xTransformer; }
165 void Execute(const OString &rIdent);
166 void DispatchAdd(const css::uno::Reference<css::frame::XDispatch> &rxDispatch,
167 const css::util::URL &rURL);
169 DECL_STATIC_LINK( GalleryBrowser2, AsyncDispatch_Impl, void*, void );
172 #endif
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */