1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: taskmisc.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
36 #ifndef _TOOLS_LIST_HXX
37 #include <tools/list.hxx>
39 #include <tools/debug.hxx>
40 #include <vcl/help.hxx>
42 #include <taskbar.hxx>
44 // =======================================================================
46 TaskButtonBar::TaskButtonBar( Window
* pParent
, WinBits nWinStyle
) :
47 ToolBox( pParent
, nWinStyle
| WB_3DLOOK
)
49 SetAlign( WINDOWALIGN_BOTTOM
);
50 SetButtonType( BUTTON_SYMBOLTEXT
);
53 // -----------------------------------------------------------------------
55 TaskButtonBar::~TaskButtonBar()
59 // -----------------------------------------------------------------------
61 void TaskButtonBar::RequestHelp( const HelpEvent
& rHEvt
)
63 ToolBox::RequestHelp( rHEvt
);
66 // =======================================================================
68 WindowArrange::WindowArrange()
73 // -----------------------------------------------------------------------
75 WindowArrange::~WindowArrange()
80 // -----------------------------------------------------------------------
82 static USHORT
ImplCeilSqareRoot( USHORT nVal
)
86 // Ueberlauf verhindern
87 if ( nVal
> 0xFE * 0xFE )
90 for ( i
=0; i
*i
< nVal
; i
++ )
96 // -----------------------------------------------------------------------
98 static void ImplPosSizeWindow( Window
* pWindow
,
99 long nX
, long nY
, long nWidth
, long nHeight
)
105 pWindow
->SetPosSizePixel( nX
, nY
, nWidth
, nHeight
);
108 // -----------------------------------------------------------------------
110 void WindowArrange::ImplTile( const Rectangle
& rRect
)
112 USHORT nCount
= (USHORT
)mpWinList
->Count();
128 long nX
= rRect
.Left();
129 long nY
= rRect
.Top();
130 long nWidth
= rRect
.GetWidth();
131 long nHeight
= rRect
.GetHeight();
133 long nRectWidth
= nWidth
;
134 long nRectHeight
= nHeight
;
138 nCols
= ImplCeilSqareRoot( nCount
);
139 nOffset
= (nCols
*nCols
) - nCount
;
140 if ( nOffset
>= nCols
)
143 nOffset
= nOffset
- nCols
;
151 nOverWidth
= nRectWidth
-(nWidth
*nCols
);
153 pWindow
= (Window
*)mpWinList
->First();
154 for ( i
= 0; i
< nCols
; i
++ )
157 nActRows
= nRows
- 1;
162 if ( nOverWidth
> 0 )
168 nHeight
= nRectHeight
/ nActRows
;
171 nOverHeight
= nRectHeight
-(nHeight
*nActRows
);
172 for ( j
= 0; j
< nActRows
; j
++ )
174 // Ueberhang verteilen
175 nTempHeight
= nHeight
;
176 if ( nOverHeight
> 0 )
181 ImplPosSizeWindow( pWindow
, nX
, nY
, nTempWidth
, nTempHeight
);
184 pWindow
= (Window
*)mpWinList
->Next();
197 // -----------------------------------------------------------------------
199 void WindowArrange::ImplHorz( const Rectangle
& rRect
)
201 long nCount
= (long)mpWinList
->Count();
202 long nX
= rRect
.Left();
203 long nY
= rRect
.Top();
204 long nWidth
= rRect
.GetWidth();
205 long nHeight
= rRect
.GetHeight();
206 long nRectHeight
= nHeight
;
214 nOver
= nRectHeight
- (nCount
*nHeight
);
215 pWindow
= (Window
*)mpWinList
->First();
218 nTempHeight
= nHeight
;
224 ImplPosSizeWindow( pWindow
, nX
, nY
, nWidth
, nTempHeight
);
227 pWindow
= (Window
*)mpWinList
->Next();
231 // -----------------------------------------------------------------------
233 void WindowArrange::ImplVert( const Rectangle
& rRect
)
235 long nCount
= (long)mpWinList
->Count();
236 long nX
= rRect
.Left();
237 long nY
= rRect
.Top();
238 long nWidth
= rRect
.GetWidth();
239 long nHeight
= rRect
.GetHeight();
240 long nRectWidth
= nWidth
;
248 nOver
= nRectWidth
- (nCount
*nWidth
);
249 pWindow
= (Window
*)mpWinList
->First();
258 ImplPosSizeWindow( pWindow
, nX
, nY
, nTempWidth
, nHeight
);
261 pWindow
= (Window
*)mpWinList
->Next();
265 // -----------------------------------------------------------------------
267 void WindowArrange::ImplCascade( const Rectangle
& rRect
)
269 long nX
= rRect
.Left();
270 long nY
= rRect
.Top();
271 long nWidth
= rRect
.GetWidth();
272 long nHeight
= rRect
.GetHeight();
273 long nRectWidth
= nWidth
;
274 long nRectHeight
= nHeight
;
277 sal_Int32 nLeftBorder
;
278 sal_Int32 nTopBorder
;
279 sal_Int32 nRightBorder
;
280 sal_Int32 nBottomBorder
;
281 long nStartOverWidth
;
282 long nStartOverHeight
;
284 long nOverHeight
= 0;
293 // Border-Fenster suchen um den Versatz zu ermitteln
294 pTempWindow
= (Window
*)mpWinList
->First();
295 pTempWindow
->GetBorder( nLeftBorder
, nTopBorder
, nRightBorder
, nBottomBorder
);
296 while ( !nTopBorder
)
298 Window
* pBrdWin
= pTempWindow
->GetWindow( WINDOW_REALPARENT
);
299 if ( !pBrdWin
|| (pBrdWin
->GetWindow( WINDOW_CLIENT
) != pTempWindow
) )
301 pTempWindow
= pBrdWin
;
302 pTempWindow
->GetBorder( nLeftBorder
, nTopBorder
, nRightBorder
, nBottomBorder
);
308 nCascadeWins
= nRectHeight
/ 3 / nOff
;
311 nWidth
-= nCascadeWins
*nOff
;
312 nHeight
-= nCascadeWins
*nOff
;
318 nStartOverWidth
= nRectWidth
-(nWidth
+(nCascadeWins
*nOff
));
319 nStartOverHeight
= nRectHeight
-(nHeight
+(nCascadeWins
*nOff
));
322 pWindow
= (Window
*)mpWinList
->First();
327 nOverWidth
= nStartOverWidth
;
328 nOverHeight
= nStartOverHeight
;
332 nTempX
= nX
+ (i
*nOff
);
333 nTempY
= nY
+ (i
*nOff
);
335 // Ueberhang verteilen
337 if ( nOverWidth
> 0 )
342 nTempHeight
= nHeight
;
343 if ( nOverHeight
> 0 )
349 ImplPosSizeWindow( pWindow
, nTempX
, nTempY
, nTempWidth
, nTempHeight
);
351 if ( i
< nCascadeWins
)
356 pWindow
= (Window
*)mpWinList
->Next();
360 // -----------------------------------------------------------------------
362 void WindowArrange::Arrange( USHORT nType
, const Rectangle
& rRect
)
364 if ( !mpWinList
->Count() )
369 case WINDOWARRANGE_TILE
:
372 case WINDOWARRANGE_HORZ
:
375 case WINDOWARRANGE_VERT
:
378 case WINDOWARRANGE_CASCADE
:
379 ImplCascade( rRect
);