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 : class NavDocInfo
59 : {
60 : public:
61 4 : NavDocInfo()
62 : : bName(false)
63 : , bActive(false)
64 4 : , mpDocShell(NULL)
65 : {
66 4 : }
67 :
68 0 : bool HasName() { return bName; }
69 3 : bool IsActive() { return bActive; }
70 :
71 4 : void SetName( bool bOn = true ) { bName = bOn; }
72 4 : void SetActive( bool bOn = true ) { bActive = bOn; }
73 :
74 : private:
75 : friend class SdNavigatorWin;
76 : bool bName : 1;
77 : bool bActive : 1;
78 : ::sd::DrawDocShell* mpDocShell;
79 : };
80 :
81 : class SdNavigatorWin
82 : : public vcl::Window
83 : {
84 : public:
85 : typedef ::boost::function<void()> UpdateRequestFunctor;
86 :
87 : /** Create a new instance of the navigator.
88 : @param bUseActiveUpdate
89 : When <TRUE/>, the default, then the SdNavigatorWin object
90 : will make a SID_NAVIGATOR_INIT call whenever it thinks an
91 : update is necessary. When <FALSE/> the navigator will
92 : rely on others to trigger updates.
93 : */
94 : SdNavigatorWin(
95 : vcl::Window* pParent,
96 : ::sd::NavigatorChildWindow* pChildWinContext,
97 : const SdResId& rSdResId,
98 : SfxBindings* pBindings);
99 : void SetUpdateRequestFunctor(const UpdateRequestFunctor& rUpdateRequest);
100 : virtual ~SdNavigatorWin();
101 : virtual void dispose() SAL_OVERRIDE;
102 :
103 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
104 :
105 : void InitTreeLB( const SdDrawDocument* pDoc );
106 : void RefreshDocumentLB( const OUString* pDocName = NULL );
107 :
108 : bool InsertFile(const OUString& rFileName);
109 :
110 : NavigatorDragType GetNavigatorDragType();
111 : void SetNavigatorDragType(NavigatorDragType eType) { meDragType = eType; }
112 :
113 : protected:
114 : virtual void Resize() SAL_OVERRIDE;
115 : virtual bool Notify(NotifyEvent& rNEvt) SAL_OVERRIDE;
116 :
117 : private:
118 : friend class ::sd::NavigatorChildWindow;
119 : friend class SdNavigatorControllerItem;
120 : friend class SdPageNameControllerItem;
121 :
122 : VclPtr<ToolBox> maToolbox;
123 : VclPtr<SdPageObjsTLB> maTlbObjects;
124 : VclPtr<ListBox> maLbDocs;
125 :
126 : ::sd::NavigatorChildWindow* mpChildWinContext;
127 : Size maSize;
128 : Size maMinSize;
129 : bool mbDocImported;
130 : OUString maDropFileName;
131 : NavigatorDragType meDragType;
132 : std::vector<NavDocInfo> maDocList;
133 : SfxBindings* mpBindings;
134 : SdNavigatorControllerItem* mpNavigatorCtrlItem;
135 : SdPageNameControllerItem* mpPageNameCtrlItem;
136 :
137 : ImageList maImageList;
138 :
139 : /** This flag controls whether all shapes or only the named shapes are
140 : shown.
141 : */
142 : // bool mbShowAllShapes;
143 :
144 : static sal_uInt16 GetDragTypeSdResId( NavigatorDragType eDT, bool bImage = false );
145 : NavDocInfo* GetDocInfo();
146 :
147 : DECL_LINK( GetFocusObjectsHdl, void * );
148 : DECL_LINK_TYPED( SelectToolboxHdl, ToolBox *, void );
149 : DECL_LINK_TYPED( DropdownClickToolBoxHdl, ToolBox *, void );
150 : DECL_LINK( ClickPageHdl, void * );
151 : DECL_LINK( ClickObjectHdl, void * );
152 : DECL_LINK( SelectDocumentHdl, void * );
153 : DECL_LINK( MenuSelectHdl, Menu * );
154 : DECL_LINK( ShapeFilterCallback, Menu * );
155 :
156 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
157 : void SetDragImage();
158 : void ApplyImageList();
159 : public:
160 : //when object is marked , fresh the corresponding entry tree .
161 : static sd::DrawDocShell* GetDrawDocShell(const SdDrawDocument*);
162 : void FreshTree ( const SdDrawDocument* pDoc );
163 : void FreshEntry( );
164 : };
165 :
166 : /**
167 : * ControllerItem for Navigator
168 : */
169 2 : class SdNavigatorControllerItem : public SfxControllerItem
170 : {
171 : public:
172 : SdNavigatorControllerItem( sal_uInt16, SdNavigatorWin*, SfxBindings*,
173 : const SdNavigatorWin::UpdateRequestFunctor& rUpdateRequest);
174 :
175 : protected:
176 : virtual void StateChanged( sal_uInt16 nSId, SfxItemState eState,
177 : const SfxPoolItem* pState ) SAL_OVERRIDE;
178 :
179 : private:
180 : VclPtr<SdNavigatorWin> pNavigatorWin;
181 : const SdNavigatorWin::UpdateRequestFunctor maUpdateRequest;
182 : };
183 :
184 : /**
185 : * ControllerItem for Navigator to show the page in the TreeLB
186 : */
187 2 : class SdPageNameControllerItem : public SfxControllerItem
188 : {
189 : public:
190 : SdPageNameControllerItem( sal_uInt16, SdNavigatorWin*, SfxBindings*,
191 : const SdNavigatorWin::UpdateRequestFunctor& rUpdateRequest);
192 :
193 : protected:
194 : virtual void StateChanged( sal_uInt16 nSId, SfxItemState eState,
195 : const SfxPoolItem* pState ) SAL_OVERRIDE;
196 :
197 : private:
198 : VclPtr<SdNavigatorWin> pNavigatorWin;
199 : const SdNavigatorWin::UpdateRequestFunctor maUpdateRequest;
200 : };
201 :
202 : #endif
203 :
204 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|