xref: /aoo42x/main/svx/inc/galbrws2.hxx (revision 02c50d82)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVX_GALBRWS2_HXX_
25 #define _SVX_GALBRWS2_HXX_
26 
27 #include <vcl/lstbox.hxx>
28 #include <vcl/button.hxx>
29 #include <vcl/fixed.hxx>
30 #include <vcl/timer.hxx>
31 #include <vcl/toolbox.hxx>
32 #include <svtools/transfer.hxx>
33 #include <svl/lstner.hxx>
34 #include <svtools/miscopt.hxx>
35 #include "svx/galbrws.hxx"
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 );
79 
80 public:
81 
82                     GalleryToolBox( GalleryBrowser2* pParent );
83                     ~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 
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 	sal_Bool				mbCurActionIsLinkage;
123 
124     void                InitSettings();
125 
126 	void				ImplUpdateViews( sal_uInt16 nSelectionId );
127 	void				ImplUpdateInfoBar();
128     sal_uIntPtr               ImplGetSelectedItemId( const Point* pSelPosPixel, Point& rSelPos );
129     void                ImplSelectItemId( sal_uIntPtr nItemId );
130     void                ImplExecute( sal_uInt16 nId );
131 
132 	// Control
133 	virtual void		Resize();
134     virtual void        DataChanged( const DataChangedEvent& rDCEvt );
135 
136 	// SfxListener
137 	virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
138 
139 						DECL_LINK( MenuSelectHdl, Menu* pMenu );
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 String		GetItemText( const GalleryTheme& rTheme, const SgaObject& rObj, sal_uIntPtr nItemTextFlags );
151 
152 public:
153 
154 						GalleryBrowser2( Window* pParent, const ResId& rResId, Gallery* pGallery );
155 						~GalleryBrowser2();
156 
157 	void				SelectTheme( const String& rThemeName );
158 
159     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 	String				GetFilterName() const;
168 	Graphic				GetGraphic() const;
169 	sal_Bool				GetVCDrawModel( FmFormModel& rModel ) const;
170 	sal_Bool				IsLinkage() const;
171 
172 	sal_Int8			AcceptDrop( DropTargetHelper& rTarget, const AcceptDropEvent& rEvt );
173 	sal_Int8			ExecuteDrop( DropTargetHelper& rTarget, const ExecuteDropEvent& rEvt );
174     void                StartDrag( Window* pWindow, const Point* pDragPoint = NULL );
175     void                TogglePreview( Window* pWindow, const Point* pPreviewPoint = NULL );
176     void                ShowContextMenu( Window* pWindow, const Point* pContextPoint = NULL );
177     sal_Bool                KeyInput( const KeyEvent& rEvt, Window* pWindow );
178 };
179 
180 #endif
181