Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SV_DOCKWIN_HXX
30 : : #define _SV_DOCKWIN_HXX
31 : :
32 : : #include <tools/solar.h>
33 : : #include <vcl/dllapi.h>
34 : : #include <vcl/floatwin.hxx>
35 : : #include <vector>
36 : :
37 : : // data to be sent with docking events
38 : : struct DockingData
39 : : {
40 : : Point maMousePos; // in
41 : : Rectangle maTrackRect; // in/out
42 : : sal_Bool mbFloating; // out
43 : : sal_Bool mbLivemode; // in
44 : : sal_Bool mbInteractive; // in
45 : :
46 : : DockingData() {};
47 : 0 : DockingData( const Point& rPt, const Rectangle& rRect, sal_Bool b) :
48 : 0 : maMousePos( rPt ), maTrackRect( rRect ), mbFloating( b ), mbLivemode( sal_False ), mbInteractive( sal_True )
49 : 0 : {};
50 : : };
51 : :
52 : : struct EndDockingData
53 : : {
54 : : Rectangle maWindowRect; // in
55 : : sal_Bool mbFloating; // in
56 : : sal_Bool mbCancelled; // in
57 : :
58 : : EndDockingData() {};
59 : 0 : EndDockingData( const Rectangle& rRect, sal_Bool b, sal_Bool bCancelled ) :
60 : 0 : maWindowRect( rRect ), mbFloating( b ), mbCancelled( bCancelled )
61 : 0 : {};
62 : : };
63 : :
64 : : struct EndPopupModeData
65 : : {
66 : : Point maFloatingPos; // in
67 : : sal_Bool mbTearoff; // in
68 : :
69 : : EndPopupModeData() {};
70 : 0 : EndPopupModeData( const Point& rPos, sal_Bool bTearoff ) :
71 : 0 : maFloatingPos( rPos ), mbTearoff( bTearoff )
72 : 0 : {};
73 : : };
74 : :
75 : : /** ImplDockingWindowWrapper
76 : : *
77 : : * ImplDockingWindowWrapper obsoletes the DockingWindow class.
78 : : * It is better because it can make a "normal window" dockable.
79 : : * All DockingWindows should be converted the new class.
80 : : */
81 : :
82 : : class ImplDockingWindowWrapper
83 : : {
84 : : friend class Window;
85 : : friend class DockingManager;
86 : : friend class DockingWindow;
87 : :
88 : : private:
89 : :
90 : : // the original 'Docking'window
91 : : Window *mpDockingWindow;
92 : :
93 : : // the original DockingWindow members
94 : : FloatingWindow* mpFloatWin;
95 : : Window* mpOldBorderWin;
96 : : Window* mpParent;
97 : : Point maFloatPos;
98 : : Point maDockPos;
99 : : Point maMouseOff;
100 : : Point maMouseStart;
101 : : Size maRollUpOutSize;
102 : : Size maMinOutSize;
103 : : Size maMaxOutSize;
104 : : Rectangle maDragArea;
105 : : long mnTrackX;
106 : : long mnTrackY;
107 : : long mnTrackWidth;
108 : : long mnTrackHeight;
109 : : sal_Int32 mnDockLeft;
110 : : sal_Int32 mnDockTop;
111 : : sal_Int32 mnDockRight;
112 : : sal_Int32 mnDockBottom;
113 : : WinBits mnFloatBits;
114 : : sal_Bool mbDockCanceled:1,
115 : : mbFloatPrevented:1,
116 : : mbDockable:1,
117 : : mbDocking:1,
118 : : mbDragFull:1,
119 : : mbLastFloatMode:1,
120 : : mbStartFloat:1,
121 : : mbTrackDock:1,
122 : : mbPined:1,
123 : : mbRollUp:1,
124 : : mbDockBtn:1,
125 : : mbHideBtn:1,
126 : : mbStartDockingEnabled:1,
127 : : mbLocked:1;
128 : :
129 : : void ImplInitData();
130 : :
131 : : DECL_LINK( PopupModeEnd, void* );
132 : 0 : void ImplEnableStartDocking( sal_Bool bEnable = sal_True ) { mbStartDockingEnabled = bEnable; }
133 : 0 : sal_Bool ImplStartDockingEnabled() { return mbStartDockingEnabled; }
134 : :
135 : : public:
136 : : ImplDockingWindowWrapper( const Window *pWindow );
137 : : virtual ~ImplDockingWindowWrapper();
138 : :
139 : 3709 : Window* GetWindow() { return mpDockingWindow; }
140 : : sal_Bool ImplStartDocking( const Point& rPos );
141 : :
142 : : // those methods actually call the corresponding handlers
143 : : void StartDocking( const Point& rPos, Rectangle& rRect );
144 : : sal_Bool Docking( const Point& rPos, Rectangle& rRect );
145 : : void EndDocking( const Rectangle& rRect, sal_Bool bFloatMode );
146 : : sal_Bool PrepareToggleFloatingMode();
147 : : void ToggleFloatingMode();
148 : :
149 : : void SetDragArea( const Rectangle& rRect );
150 : : Rectangle GetDragArea() const;
151 : :
152 : : void Lock();
153 : : void Unlock();
154 : : sal_Bool IsLocked() const;
155 : :
156 : : void StartPopupMode( ToolBox* pParentToolBox, sal_uLong nPopupModeFlags );
157 : : sal_Bool IsInPopupMode() const;
158 : :
159 : : void TitleButtonClick( sal_uInt16 nButton );
160 : : void Pin();
161 : : void Roll();
162 : : void PopupModeEnd();
163 : : void Resizing( Size& rSize );
164 : : sal_Bool Close();
165 : : void Tracking( const TrackingEvent& rTEvt );
166 : : long Notify( NotifyEvent& rNEvt );
167 : :
168 : : void ShowTitleButton( sal_uInt16 nButton, sal_Bool bVisible = sal_True );
169 : :
170 : : void SetMinOutputSizePixel( const Size& rSize );
171 : :
172 : : void SetMaxOutputSizePixel( const Size& rSize );
173 : :
174 : 0 : sal_Bool IsDocking() const { return mbDocking; }
175 : 0 : sal_Bool IsDockable() const { return mbDockable; }
176 : 0 : sal_Bool IsDockingCanceled() const { return mbDockCanceled; }
177 : : sal_Bool IsFloatingPrevented() const { return mbFloatPrevented; }
178 : :
179 : : void SetFloatingMode( sal_Bool bFloatMode = sal_False );
180 : : sal_Bool IsFloatingMode() const;
181 : 129718 : FloatingWindow* GetFloatingWindow() const { return mpFloatWin; }
182 : :
183 : : void SetFloatStyle( WinBits nWinStyle );
184 : : WinBits GetFloatStyle() const;
185 : :
186 : : virtual void SetPosSizePixel( long nX, long nY,
187 : : long nWidth, long nHeight,
188 : : sal_uInt16 nFlags = WINDOW_POSSIZE_ALL );
189 : : void SetPosSizePixel( const Point& rNewPos,
190 : : const Size& rNewSize )
191 : : { mpDockingWindow->SetPosSizePixel( rNewPos, rNewSize ); }
192 : : Point GetPosPixel() const;
193 : : Size GetSizePixel() const;
194 : : };
195 : :
196 : : class VCL_DLLPUBLIC DockingManager
197 : : {
198 : : protected:
199 : : ::std::vector<ImplDockingWindowWrapper *> mDockingWindows;
200 : :
201 : : public:
202 : : DockingManager();
203 : : ~DockingManager();
204 : :
205 : : void AddWindow( const Window *pWin );
206 : : void RemoveWindow( const Window *pWin );
207 : :
208 : : ImplDockingWindowWrapper* GetDockingWindowWrapper( const Window *pWin );
209 : : sal_Bool IsDockable( const Window *pWin );
210 : :
211 : : sal_Bool IsFloating( const Window *pWin );
212 : : void SetFloatingMode( const Window *pWin, sal_Bool bFloating );
213 : :
214 : : void Lock( const Window *pWin );
215 : : void Unlock( const Window *pWin );
216 : : sal_Bool IsLocked( const Window *pWin );
217 : :
218 : : void StartPopupMode( ToolBox *pParentToolBox, const Window *pWin );
219 : : void StartPopupMode( ToolBox *pParentToolBox, const Window *pWin, sal_uLong nPopupModeFlags );
220 : :
221 : : sal_Bool IsInPopupMode( const Window *pWin );
222 : : void EndPopupMode( const Window *pWin );
223 : :
224 : : // required because those methods are not virtual in Window (!!!) and must
225 : : // be availbale from the toolkit
226 : : void SetPosSizePixel( Window *pWin, long nX, long nY,
227 : : long nWidth, long nHeight,
228 : : sal_uInt16 nFlags = WINDOW_POSSIZE_ALL );
229 : : Rectangle GetPosSizePixel( const Window *pWin );
230 : : };
231 : :
232 : : // -----------------
233 : : // - DockingWindow -
234 : : // -----------------
235 : :
236 : : class VCL_DLLPUBLIC DockingWindow : public Window
237 : : {
238 : : class ImplData;
239 : : private:
240 : : FloatingWindow* mpFloatWin;
241 : : Window* mpOldBorderWin;
242 : : ImplData* mpImplData;
243 : : Point maFloatPos;
244 : : Point maDockPos;
245 : : Point maMouseOff;
246 : : Point maMouseStart;
247 : : Size maRollUpOutSize;
248 : : Size maMinOutSize;
249 : : long mnTrackX;
250 : : long mnTrackY;
251 : : long mnTrackWidth;
252 : : long mnTrackHeight;
253 : : sal_Int32 mnDockLeft;
254 : : sal_Int32 mnDockTop;
255 : : sal_Int32 mnDockRight;
256 : : sal_Int32 mnDockBottom;
257 : : WinBits mnFloatBits;
258 : : sal_Bool mbDockCanceled:1,
259 : : mbDockPrevented:1,
260 : : mbFloatPrevented:1,
261 : : mbDockable:1,
262 : : mbDocking:1,
263 : : mbDragFull:1,
264 : : mbLastFloatMode:1,
265 : : mbStartFloat:1,
266 : : mbTrackDock:1,
267 : : mbPined:1,
268 : : mbRollUp:1,
269 : : mbDockBtn:1,
270 : : mbHideBtn:1;
271 : :
272 : : SAL_DLLPRIVATE void ImplInitDockingWindowData();
273 : :
274 : : // Copy assignment is forbidden and not implemented.
275 : : SAL_DLLPRIVATE DockingWindow (const DockingWindow &);
276 : : SAL_DLLPRIVATE DockingWindow & operator= (const DockingWindow &);
277 : :
278 : : protected:
279 : : using Window::ImplInit;
280 : : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
281 : : SAL_DLLPRIVATE void ImplInitSettings();
282 : : SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
283 : :
284 : : public:
285 : : SAL_DLLPRIVATE sal_Bool ImplStartDocking( const Point& rPos );
286 : :
287 : : protected:
288 : : DockingWindow( WindowType nType );
289 : :
290 : : public:
291 : : DockingWindow( Window* pParent, WinBits nStyle = WB_STDDOCKWIN );
292 : : DockingWindow( Window* pParent, const ResId& rResId );
293 : : ~DockingWindow();
294 : :
295 : : virtual void StartDocking();
296 : : virtual sal_Bool Docking( const Point& rPos, Rectangle& rRect );
297 : : virtual void EndDocking( const Rectangle& rRect, sal_Bool bFloatMode );
298 : : virtual sal_Bool PrepareToggleFloatingMode();
299 : : virtual void ToggleFloatingMode();
300 : :
301 : : virtual void TitleButtonClick( sal_uInt16 nButton );
302 : : virtual void Pin();
303 : : virtual void Roll();
304 : : virtual void PopupModeEnd();
305 : : virtual void Resizing( Size& rSize );
306 : : virtual sal_Bool Close();
307 : : virtual void Tracking( const TrackingEvent& rTEvt );
308 : : virtual long Notify( NotifyEvent& rNEvt );
309 : : virtual void StateChanged( StateChangedType nType );
310 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
311 : :
312 : : void SetPin( sal_Bool bPin );
313 : : sal_Bool IsPined() const;
314 : :
315 : : void RollUp();
316 : : void RollDown();
317 : : sal_Bool IsRollUp() const;
318 : :
319 : : void SetRollUpOutputSizePixel( const Size& rSize );
320 : : Size GetRollUpOutputSizePixel() const;
321 : :
322 : : void SetMinOutputSizePixel( const Size& rSize );
323 : : const Size& GetMinOutputSizePixel() const;
324 : :
325 : : void SetMaxOutputSizePixel( const Size& rSize );
326 : :
327 : 0 : sal_Bool IsDocking() const { return mbDocking; }
328 : 0 : sal_Bool IsDockable() const { return mbDockable; }
329 : 0 : sal_Bool IsDockingCanceled() const { return mbDockCanceled; }
330 : 0 : sal_Bool IsDockingPrevented() const { return mbDockPrevented; }
331 : : sal_Bool IsFloatingPrevented() const { return mbFloatPrevented; }
332 : :
333 : : void SetFloatingMode( sal_Bool bFloatMode = sal_False );
334 : : sal_Bool IsFloatingMode() const;
335 : 1957 : FloatingWindow* GetFloatingWindow() const { return mpFloatWin; }
336 : :
337 : : void SetFloatingPos( const Point& rNewPos );
338 : : Point GetFloatingPos() const;
339 : :
340 : : void SetFloatStyle( WinBits nWinStyle );
341 : : WinBits GetFloatStyle() const;
342 : :
343 : : virtual void SetPosSizePixel( long nX, long nY,
344 : : long nWidth, long nHeight,
345 : : sal_uInt16 nFlags = WINDOW_POSSIZE_ALL );
346 : 12123 : void SetPosSizePixel( const Point& rNewPos,
347 : : const Size& rNewSize )
348 : 12123 : { Window::SetPosSizePixel( rNewPos, rNewSize ); }
349 : : Point GetPosPixel() const;
350 : : Size GetSizePixel() const;
351 : : void SetOutputSizePixel( const Size& rNewSize );
352 : : Size GetOutputSizePixel() const;
353 : : };
354 : :
355 : : inline void DockingWindow::SetPin( sal_Bool bPin )
356 : : {
357 : : if ( mpFloatWin )
358 : : mpFloatWin->SetPin( bPin );
359 : : mbPined = bPin;
360 : : }
361 : :
362 : : inline sal_Bool DockingWindow::IsPined() const
363 : : {
364 : : if ( mpFloatWin )
365 : : return mpFloatWin->IsPined();
366 : : return mbPined;
367 : : }
368 : :
369 : : inline void DockingWindow::RollUp()
370 : : {
371 : : if ( mpFloatWin )
372 : : mpFloatWin->RollUp();
373 : : mbRollUp = sal_True;
374 : : }
375 : :
376 : 0 : inline void DockingWindow::RollDown()
377 : : {
378 : 0 : if ( mpFloatWin )
379 : 0 : mpFloatWin->RollDown();
380 : 0 : mbRollUp = sal_False;
381 : 0 : }
382 : :
383 : 0 : inline sal_Bool DockingWindow::IsRollUp() const
384 : : {
385 : 0 : if ( mpFloatWin )
386 : 0 : return mpFloatWin->IsRollUp();
387 : 0 : return mbRollUp;
388 : : }
389 : :
390 : : inline void DockingWindow::SetRollUpOutputSizePixel( const Size& rSize )
391 : : {
392 : : if ( mpFloatWin )
393 : : mpFloatWin->SetRollUpOutputSizePixel( rSize );
394 : : maRollUpOutSize = rSize;
395 : : }
396 : :
397 : : inline Size DockingWindow::GetRollUpOutputSizePixel() const
398 : : {
399 : : if ( mpFloatWin )
400 : : return mpFloatWin->GetRollUpOutputSizePixel();
401 : : return maRollUpOutSize;
402 : : }
403 : :
404 : 120 : inline void DockingWindow::SetMinOutputSizePixel( const Size& rSize )
405 : : {
406 [ - + ]: 120 : if ( mpFloatWin )
407 : 0 : mpFloatWin->SetMinOutputSizePixel( rSize );
408 : 120 : maMinOutSize = rSize;
409 : 120 : }
410 : :
411 : 0 : inline const Size& DockingWindow::GetMinOutputSizePixel() const
412 : : {
413 : 0 : if ( mpFloatWin )
414 : 0 : return mpFloatWin->GetMinOutputSizePixel();
415 : 0 : return maMinOutSize;
416 : : }
417 : :
418 : 312 : inline void DockingWindow::SetFloatingPos( const Point& rNewPos )
419 : : {
420 [ - + ]: 312 : if ( mpFloatWin )
421 : 0 : mpFloatWin->SetPosPixel( rNewPos );
422 : : else
423 : 312 : maFloatPos = rNewPos;
424 : 312 : }
425 : :
426 : :
427 : : #endif // _SV_DOCKWIN_HXX
428 : :
429 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|