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 <svtools/miscopt.hxx>
31 : #include "svx/galbrws.hxx"
32 :
33 : #include <com/sun/star/frame/XDispatch.hpp>
34 : #include <com/sun/star/util/XURLTransformer.hpp>
35 :
36 :
37 : // - GalleryBrowserMode -
38 :
39 :
40 : enum GalleryBrowserMode
41 : {
42 : GALLERYBROWSERMODE_NONE = 0,
43 : GALLERYBROWSERMODE_ICON = 1,
44 : GALLERYBROWSERMODE_LIST = 2,
45 : GALLERYBROWSERMODE_PREVIEW = 3
46 : };
47 :
48 :
49 : // - GalleryTravel -
50 :
51 :
52 : enum GalleryBrowserTravel
53 : {
54 : GALLERYBROWSERTRAVEL_CURRENT = 0,
55 : GALLERYBROWSERTRAVEL_FIRST = 1,
56 : GALLERYBROWSERTRAVEL_LAST = 2,
57 : GALLERYBROWSERTRAVEL_PREVIOUS = 3,
58 : GALLERYBROWSERTRAVEL_NEXT = 4
59 : };
60 :
61 :
62 : // - GalleryItemTextFlags -
63 :
64 :
65 : #define GALLERY_ITEM_THEMENAME 0x00000001
66 : #define GALLERY_ITEM_TITLE 0x00000002
67 : #define GALLERY_ITEM_PATH 0x00000004
68 :
69 :
70 : // - GalleryToolBox -
71 :
72 :
73 : class GalleryToolBox : public ToolBox
74 : {
75 : private:
76 :
77 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
78 :
79 : public:
80 :
81 : GalleryToolBox( GalleryBrowser2* pParent );
82 : virtual ~GalleryToolBox();
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 : GalleryIconView* mpIconView;
113 : GalleryListView* mpListView;
114 : GalleryPreview* mpPreview;
115 : GalleryToolBox maViewBox;
116 : FixedLine maSeparator;
117 : 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( SelectTbxHdl, ToolBox* );
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( Window* pParent, const ResId& rResId, Gallery* pGallery );
155 : virtual ~GalleryBrowser2();
156 :
157 : void SelectTheme( const OUString& rThemeName );
158 :
159 0 : GalleryBrowserMode GetMode() const { return meMode; }
160 : void SetMode( GalleryBrowserMode eMode );
161 :
162 : Window* GetViewWindow() const;
163 :
164 : void Travel( GalleryBrowserTravel eTravel );
165 :
166 : INetURLObject GetURL() const;
167 : OUString GetFilterName() const;
168 : Graphic GetGraphic() const;
169 :
170 : sal_Int8 AcceptDrop( DropTargetHelper& rTarget, const AcceptDropEvent& rEvt );
171 : sal_Int8 ExecuteDrop( DropTargetHelper& rTarget, const ExecuteDropEvent& rEvt );
172 : void StartDrag( Window* pWindow, const Point* pDragPoint = NULL );
173 : void TogglePreview( Window* pWindow, const Point* pPreviewPoint = NULL );
174 : void ShowContextMenu( Window* pWindow, const Point* pContextPoint = NULL );
175 : sal_Bool KeyInput( const KeyEvent& rEvt, Window* pWindow );
176 :
177 : com::sun::star::uno::Reference< com::sun::star::frame::XFrame > GetFrame() const;
178 : com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > GetUNOContext() const { return m_xContext; }
179 0 : com::sun::star::uno::Reference< com::sun::star::util::XURLTransformer > GetURLTransformer() const { return m_xTransformer; }
180 :
181 : void Execute( sal_uInt16 nId );
182 : void Dispatch( sal_uInt16 nId,
183 : const com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > &rxDispatch = com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >(),
184 : const com::sun::star::util::URL &rURL = com::sun::star::util::URL() );
185 :
186 : DECL_STATIC_LINK( GalleryBrowser2, AsyncDispatch_Impl, DispatchInfo* );
187 : };
188 :
189 : #endif
190 :
191 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|