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_SD_SOURCE_UI_INC_NAVIGATR_HXX
21 : #define INCLUDED_SD_SOURCE_UI_INC_NAVIGATR_HXX
22 :
23 : #include <vcl/window.hxx>
24 : #include <vcl/lstbox.hxx>
25 : #include <vcl/toolbox.hxx>
26 : #include <sfx2/ctrlitem.hxx>
27 : #include "sdtreelb.hxx"
28 : #include "pres.hxx"
29 :
30 : #define NAVSTATE_NONE 0x00000000
31 :
32 : #define NAVBTN_PEN_ENABLED 0x00000010
33 : #define NAVBTN_PEN_DISABLED 0x00000020
34 : #define NAVBTN_PEN_CHECKED 0x00000040
35 : #define NAVBTN_PEN_UNCHECKED 0x00000080
36 :
37 : #define NAVTLB_UPDATE 0x00000100
38 :
39 : #define NAVBTN_FIRST_ENABLED 0x00001000
40 : #define NAVBTN_FIRST_DISABLED 0x00002000
41 : #define NAVBTN_PREV_ENABLED 0x00004000
42 : #define NAVBTN_PREV_DISABLED 0x00008000
43 :
44 : #define NAVBTN_LAST_ENABLED 0x00010000
45 : #define NAVBTN_LAST_DISABLED 0x00020000
46 : #define NAVBTN_NEXT_ENABLED 0x00040000
47 : #define NAVBTN_NEXT_DISABLED 0x00080000
48 :
49 : // forward
50 : namespace sd {
51 : class DrawDocShell;
52 : class NavigatorChildWindow;
53 : }
54 : class Menu;
55 : class SdNavigatorControllerItem;
56 : class SdPageNameControllerItem;
57 :
58 :
59 :
60 : class NavDocInfo
61 : {
62 : public:
63 0 : NavDocInfo()
64 : : bName(false)
65 : , bActive(false)
66 0 : , mpDocShell(NULL)
67 : {
68 0 : }
69 :
70 0 : sal_Bool HasName() { return( (sal_Bool) bName ); }
71 0 : sal_Bool IsActive() { return( (sal_Bool) bActive ); }
72 :
73 0 : void SetName( sal_Bool bOn = sal_True ) { bName = bOn; }
74 0 : void SetActive( sal_Bool bOn = sal_True ) { bActive = bOn; }
75 :
76 : private:
77 : friend class SdNavigatorWin;
78 : sal_Bool bName : 1;
79 : sal_Bool bActive : 1;
80 : ::sd::DrawDocShell* mpDocShell;
81 : };
82 :
83 :
84 :
85 : class SdNavigatorWin
86 : : public Window
87 : {
88 : public:
89 : typedef ::boost::function<void(void)> UpdateRequestFunctor;
90 :
91 : /** Create a new instance of the navigator.
92 : @param bUseActiveUpdate
93 : When <TRUE/>, the default, then the SdNavigatorWin object
94 : will make a SID_NAVIGATOR_INIT call whenever it thinks an
95 : update is necessary. When <FALSE/> the navigator will
96 : rely on others to trigger updates.
97 : */
98 : SdNavigatorWin(
99 : ::Window* pParent,
100 : ::sd::NavigatorChildWindow* pChildWinContext,
101 : const SdResId& rSdResId,
102 : SfxBindings* pBindings,
103 : const UpdateRequestFunctor& rUpdateRequest);
104 : virtual ~SdNavigatorWin();
105 :
106 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
107 :
108 : void InitTreeLB( const SdDrawDocument* pDoc );
109 : void RefreshDocumentLB( const OUString* pDocName = NULL );
110 :
111 : bool InsertFile(const OUString& rFileName);
112 :
113 : NavigatorDragType GetNavigatorDragType();
114 : void SetNavigatorDragType(NavigatorDragType eType) { meDragType = eType; }
115 :
116 : protected:
117 : virtual void Resize() SAL_OVERRIDE;
118 : virtual bool Notify(NotifyEvent& rNEvt) SAL_OVERRIDE;
119 :
120 :
121 : private:
122 : friend class ::sd::NavigatorChildWindow;
123 : friend class SdNavigatorControllerItem;
124 : friend class SdPageNameControllerItem;
125 :
126 : ToolBox maToolbox;
127 : SdPageObjsTLB maTlbObjects;
128 : ListBox maLbDocs;
129 :
130 : ::sd::NavigatorChildWindow* mpChildWinContext;
131 : Size maSize;
132 : Size maMinSize;
133 : sal_Bool mbDocImported;
134 : OUString maDropFileName;
135 : NavigatorDragType meDragType;
136 : std::vector<NavDocInfo> maDocList;
137 : SfxBindings* mpBindings;
138 : SdNavigatorControllerItem* mpNavigatorCtrlItem;
139 : SdPageNameControllerItem* mpPageNameCtrlItem;
140 :
141 : ImageList maImageList;
142 :
143 : /** This flag controls whether all shapes or only the named shapes are
144 : shown.
145 : */
146 : // bool mbShowAllShapes;
147 :
148 : sal_uInt16 GetDragTypeSdResId( NavigatorDragType eDT, sal_Bool bImage = sal_False );
149 : NavDocInfo* GetDocInfo();
150 :
151 : DECL_LINK( GetFocusObjectsHdl, void * );
152 : DECL_LINK( SelectToolboxHdl, void * );
153 : DECL_LINK(ClickToolboxHdl, void *);
154 : DECL_LINK( DropdownClickToolBoxHdl, ToolBox * );
155 : DECL_LINK( ClickPageHdl, void * );
156 : DECL_LINK( ClickObjectHdl, void * );
157 : DECL_LINK( SelectDocumentHdl, void * );
158 : DECL_LINK( MenuSelectHdl, Menu * );
159 : DECL_LINK( ShapeFilterCallback, Menu * );
160 :
161 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
162 : void SetDragImage();
163 : void ApplyImageList();
164 : public:
165 : //when object is marked , fresh the corresponding entry tree .
166 : sd::DrawDocShell* GetDrawDocShell(const SdDrawDocument*);
167 : void FreshTree ( const SdDrawDocument* pDoc );
168 : void FreshEntry( );
169 : };
170 :
171 :
172 :
173 :
174 : /**
175 : * ControllerItem for Navigator
176 : */
177 0 : class SdNavigatorControllerItem : public SfxControllerItem
178 : {
179 : public:
180 : SdNavigatorControllerItem( sal_uInt16, SdNavigatorWin*, SfxBindings*,
181 : const SdNavigatorWin::UpdateRequestFunctor& rUpdateRequest);
182 :
183 : protected:
184 : virtual void StateChanged( sal_uInt16 nSId, SfxItemState eState,
185 : const SfxPoolItem* pState ) SAL_OVERRIDE;
186 :
187 : private:
188 : SdNavigatorWin* pNavigatorWin;
189 : const SdNavigatorWin::UpdateRequestFunctor maUpdateRequest;
190 : };
191 :
192 :
193 :
194 : /**
195 : * ControllerItem for Navigator to show the page in the TreeLB
196 : */
197 0 : class SdPageNameControllerItem : public SfxControllerItem
198 : {
199 : public:
200 : SdPageNameControllerItem( sal_uInt16, SdNavigatorWin*, SfxBindings*,
201 : const SdNavigatorWin::UpdateRequestFunctor& rUpdateRequest);
202 :
203 : protected:
204 : virtual void StateChanged( sal_uInt16 nSId, SfxItemState eState,
205 : const SfxPoolItem* pState ) SAL_OVERRIDE;
206 :
207 : private:
208 : SdNavigatorWin* pNavigatorWin;
209 : const SdNavigatorWin::UpdateRequestFunctor maUpdateRequest;
210 : };
211 :
212 : #endif
213 :
214 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|