Line data Source code
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_INC_GALBRWS2_HXX
21 : #define INCLUDED_SVX_INC_GALBRWS2_HXX
22 :
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>
32 :
33 : #include <com/sun/star/frame/XDispatch.hpp>
34 : #include <com/sun/star/uno/XComponentContext.hpp>
35 : #include <com/sun/star/util/XURLTransformer.hpp>
36 :
37 :
38 : // - GalleryBrowserMode -
39 :
40 :
41 : enum GalleryBrowserMode
42 : {
43 : GALLERYBROWSERMODE_NONE = 0,
44 : GALLERYBROWSERMODE_ICON = 1,
45 : GALLERYBROWSERMODE_LIST = 2,
46 : GALLERYBROWSERMODE_PREVIEW = 3
47 : };
48 :
49 :
50 : // - GalleryTravel -
51 :
52 :
53 : enum GalleryBrowserTravel
54 : {
55 : GALLERYBROWSERTRAVEL_CURRENT = 0,
56 : GALLERYBROWSERTRAVEL_FIRST = 1,
57 : GALLERYBROWSERTRAVEL_LAST = 2,
58 : GALLERYBROWSERTRAVEL_PREVIOUS = 3,
59 : GALLERYBROWSERTRAVEL_NEXT = 4
60 : };
61 :
62 :
63 : // - GalleryItemTextFlags -
64 :
65 :
66 : #define GALLERY_ITEM_THEMENAME 0x00000001
67 : #define GALLERY_ITEM_TITLE 0x00000002
68 : #define GALLERY_ITEM_PATH 0x00000004
69 :
70 :
71 : // - GalleryToolBox -
72 :
73 :
74 0 : class GalleryToolBox : public ToolBox
75 : {
76 : private:
77 :
78 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
79 :
80 : public:
81 :
82 : GalleryToolBox( GalleryBrowser2* pParent );
83 : };
84 :
85 :
86 : // - GalleryBrowser2 -
87 :
88 :
89 : class Gallery;
90 : class GalleryTheme;
91 : class GalleryIconView;
92 : class GalleryListView;
93 : class GalleryPreview;
94 : class Menu;
95 : class SgaObject;
96 : struct DispatchInfo;
97 :
98 : namespace svx { namespace sidebar { class GalleryControl; } }
99 :
100 : class GalleryBrowser2 : public Control, public SfxListener
101 : {
102 : friend class GalleryBrowser;
103 : friend class svx::sidebar::GalleryControl;
104 : using Control::Notify;
105 : using Window::KeyInput;
106 :
107 : private:
108 :
109 : SvtMiscOptions maMiscOptions;
110 : Gallery* mpGallery;
111 : GalleryTheme* mpCurTheme;
112 : VclPtr<GalleryIconView> mpIconView;
113 : VclPtr<GalleryListView> mpListView;
114 : VclPtr<GalleryPreview> mpPreview;
115 : VclPtr<GalleryToolBox> maViewBox;
116 : VclPtr<FixedLine> maSeparator;
117 : VclPtr<FixedText> maInfoBar;
118 : Point maDragStartPos;
119 : sal_uIntPtr mnCurActionPos;
120 : GalleryBrowserMode meMode;
121 : GalleryBrowserMode meLastMode;
122 :
123 : com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
124 : com::sun::star::uno::Reference< com::sun::star::util::XURLTransformer > m_xTransformer;
125 :
126 : void InitSettings();
127 :
128 : void ImplUpdateViews( sal_uInt16 nSelectionId );
129 : void ImplUpdateInfoBar();
130 : sal_uIntPtr ImplGetSelectedItemId( const Point* pSelPosPixel, Point& rSelPos );
131 : void ImplSelectItemId( sal_uIntPtr nItemId );
132 :
133 : // Control
134 : virtual void Resize() SAL_OVERRIDE;
135 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
136 :
137 : // SfxListener
138 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
139 :
140 : DECL_LINK( SelectObjectHdl, void* );
141 : DECL_LINK_TYPED( SelectTbxHdl, ToolBox*, void );
142 : DECL_LINK( MiscHdl, void* );
143 :
144 : private:
145 :
146 : static GalleryBrowserMode meInitMode;
147 :
148 : public:
149 :
150 : static OUString GetItemText( const GalleryTheme& rTheme, const SgaObject& rObj, sal_uIntPtr nItemTextFlags );
151 :
152 : public:
153 :
154 : GalleryBrowser2(vcl::Window* pParent, Gallery* pGallery);
155 : virtual ~GalleryBrowser2();
156 : virtual void dispose() SAL_OVERRIDE;
157 :
158 : void SelectTheme( const OUString& rThemeName );
159 :
160 0 : GalleryBrowserMode GetMode() const { return meMode; }
161 : void SetMode( GalleryBrowserMode eMode );
162 :
163 : vcl::Window* GetViewWindow() const;
164 :
165 : void Travel( GalleryBrowserTravel eTravel );
166 :
167 : INetURLObject GetURL() const;
168 : OUString GetFilterName() const;
169 : Graphic GetGraphic() const;
170 :
171 : sal_Int8 AcceptDrop( DropTargetHelper& rTarget, const AcceptDropEvent& rEvt );
172 : sal_Int8 ExecuteDrop( DropTargetHelper& rTarget, const ExecuteDropEvent& rEvt );
173 : void StartDrag( vcl::Window* pWindow, const Point* pDragPoint = NULL );
174 : void TogglePreview( vcl::Window* pWindow, const Point* pPreviewPoint = NULL );
175 : void ShowContextMenu( vcl::Window* pWindow, const Point* pContextPoint = NULL );
176 : bool KeyInput( const KeyEvent& rEvt, vcl::Window* pWindow );
177 :
178 : static com::sun::star::uno::Reference< com::sun::star::frame::XFrame > GetFrame();
179 : com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > GetUNOContext() const { return m_xContext; }
180 0 : com::sun::star::uno::Reference< com::sun::star::util::XURLTransformer > GetURLTransformer() const { return m_xTransformer; }
181 :
182 : void Execute( sal_uInt16 nId );
183 : void Dispatch( sal_uInt16 nId,
184 : const com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > &rxDispatch = com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >(),
185 : const com::sun::star::util::URL &rURL = com::sun::star::util::URL() );
186 :
187 : DECL_STATIC_LINK( GalleryBrowser2, AsyncDispatch_Impl, DispatchInfo* );
188 : };
189 :
190 : #endif
191 :
192 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|