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 : 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 : virtual ~GalleryToolBox();
84 : };
85 :
86 :
87 : // - GalleryBrowser2 -
88 :
89 :
90 : class Gallery;
91 : class GalleryTheme;
92 : class GalleryIconView;
93 : class GalleryListView;
94 : class GalleryPreview;
95 : class Menu;
96 : class SgaObject;
97 : struct DispatchInfo;
98 :
99 : namespace svx { namespace sidebar { class GalleryControl; } }
100 :
101 : class GalleryBrowser2 : public Control, public SfxListener
102 : {
103 : friend class GalleryBrowser;
104 : friend class svx::sidebar::GalleryControl;
105 : using Control::Notify;
106 : using Window::KeyInput;
107 :
108 : private:
109 :
110 : SvtMiscOptions maMiscOptions;
111 : Gallery* mpGallery;
112 : GalleryTheme* mpCurTheme;
113 : GalleryIconView* mpIconView;
114 : GalleryListView* mpListView;
115 : GalleryPreview* mpPreview;
116 : GalleryToolBox maViewBox;
117 : FixedLine maSeparator;
118 : FixedText maInfoBar;
119 : Point maDragStartPos;
120 : sal_uIntPtr mnCurActionPos;
121 : GalleryBrowserMode meMode;
122 : GalleryBrowserMode meLastMode;
123 :
124 : com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
125 : com::sun::star::uno::Reference< com::sun::star::util::XURLTransformer > m_xTransformer;
126 :
127 : void InitSettings();
128 :
129 : void ImplUpdateViews( sal_uInt16 nSelectionId );
130 : void ImplUpdateInfoBar();
131 : sal_uIntPtr ImplGetSelectedItemId( const Point* pSelPosPixel, Point& rSelPos );
132 : void ImplSelectItemId( sal_uIntPtr nItemId );
133 :
134 : // Control
135 : virtual void Resize() SAL_OVERRIDE;
136 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
137 :
138 : // SfxListener
139 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
140 :
141 : DECL_LINK( SelectObjectHdl, void* );
142 : DECL_LINK( SelectTbxHdl, ToolBox* );
143 : DECL_LINK( MiscHdl, void* );
144 :
145 : private:
146 :
147 : static GalleryBrowserMode meInitMode;
148 :
149 : public:
150 :
151 : static OUString GetItemText( const GalleryTheme& rTheme, const SgaObject& rObj, sal_uIntPtr nItemTextFlags );
152 :
153 : public:
154 :
155 : GalleryBrowser2( vcl::Window* pParent, const ResId& rResId, Gallery* pGallery );
156 : virtual ~GalleryBrowser2();
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 : com::sun::star::uno::Reference< com::sun::star::frame::XFrame > GetFrame() const;
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: */
|