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 : #include <svids.hrc>
21 : #include <svdata.hxx>
22 : #include <brdwin.hxx>
23 : #include <window.h>
24 :
25 : #include <vcl/event.hxx>
26 : #include <vcl/decoview.hxx>
27 : #include <vcl/syswin.hxx>
28 : #include <vcl/dockwin.hxx>
29 : #include <vcl/floatwin.hxx>
30 : #include <vcl/bitmap.hxx>
31 : #include <vcl/gradient.hxx>
32 : #include <vcl/image.hxx>
33 : #include <vcl/virdev.hxx>
34 : #include <vcl/help.hxx>
35 : #include <vcl/edit.hxx>
36 : #include <vcl/metric.hxx>
37 : #include <vcl/settings.hxx>
38 :
39 : using namespace ::com::sun::star::uno;
40 :
41 : // useful caption height for title bar buttons
42 : #define MIN_CAPTION_HEIGHT 18
43 :
44 0 : static void ImplGetPinImage( sal_uInt16 nStyle, bool bPinIn, Image& rImage )
45 : {
46 : // load ImageList if not available yet
47 0 : ImplSVData* pSVData = ImplGetSVData();
48 0 : if ( !pSVData->maCtrlData.mpPinImgList )
49 : {
50 0 : ResMgr* pResMgr = ImplGetResMgr();
51 0 : pSVData->maCtrlData.mpPinImgList = new ImageList();
52 0 : if( pResMgr )
53 : {
54 0 : Color aMaskColor( 0x00, 0x00, 0xFF );
55 : pSVData->maCtrlData.mpPinImgList->InsertFromHorizontalBitmap
56 : ( ResId( SV_RESID_BITMAP_PIN, *pResMgr ), 4,
57 0 : &aMaskColor, NULL, NULL, 0);
58 : }
59 : }
60 :
61 : // get and return Image
62 : sal_uInt16 nId;
63 0 : if ( nStyle & BUTTON_DRAW_PRESSED )
64 : {
65 0 : if ( bPinIn )
66 0 : nId = 4;
67 : else
68 0 : nId = 3;
69 : }
70 : else
71 : {
72 0 : if ( bPinIn )
73 0 : nId = 2;
74 : else
75 0 : nId = 1;
76 : }
77 0 : rImage = pSVData->maCtrlData.mpPinImgList->GetImage( nId );
78 0 : }
79 :
80 0 : void Window::ImplCalcSymbolRect( Rectangle& rRect )
81 : {
82 : // Add border, not shown in the non-default representation,
83 : // as we want to use it for small buttons
84 0 : rRect.Left()--;
85 0 : rRect.Top()--;
86 0 : rRect.Right()++;
87 0 : rRect.Bottom()++;
88 :
89 : // we leave 5% room between the symbol and the button border
90 0 : long nExtraWidth = ((rRect.GetWidth()*50)+500)/1000;
91 0 : long nExtraHeight = ((rRect.GetHeight()*50)+500)/1000;
92 0 : rRect.Left() += nExtraWidth;
93 0 : rRect.Right() -= nExtraWidth;
94 0 : rRect.Top() += nExtraHeight;
95 0 : rRect.Bottom() -= nExtraHeight;
96 0 : }
97 :
98 0 : static void ImplDrawBrdWinSymbol( OutputDevice* pDev,
99 : const Rectangle& rRect, SymbolType eSymbol )
100 : {
101 : // we leave 5% room between the symbol and the button border
102 0 : DecorationView aDecoView( pDev );
103 0 : Rectangle aTempRect = rRect;
104 0 : Window::ImplCalcSymbolRect( aTempRect );
105 : aDecoView.DrawSymbol( aTempRect, eSymbol,
106 0 : pDev->GetSettings().GetStyleSettings().GetButtonTextColor(), 0 );
107 0 : }
108 :
109 0 : static void ImplDrawBrdWinSymbolButton( OutputDevice* pDev,
110 : const Rectangle& rRect,
111 : SymbolType eSymbol, sal_uInt16 nState )
112 : {
113 0 : bool bMouseOver = (nState & BUTTON_DRAW_HIGHLIGHT) != 0;
114 0 : nState &= ~BUTTON_DRAW_HIGHLIGHT;
115 :
116 0 : Rectangle aTempRect;
117 0 : Window *pWin = dynamic_cast< Window* >(pDev);
118 0 : if( pWin )
119 : {
120 0 : if( bMouseOver )
121 : {
122 : // provide a bright background for selection effect
123 0 : pWin->SetFillColor( pDev->GetSettings().GetStyleSettings().GetWindowColor() );
124 0 : pWin->SetLineColor();
125 0 : pWin->DrawRect( rRect );
126 0 : pWin->DrawSelectionBackground( rRect, 2, (nState & BUTTON_DRAW_PRESSED) ? true : false,
127 0 : true, false );
128 : }
129 0 : aTempRect = rRect;
130 0 : aTempRect.Left()+=3;
131 0 : aTempRect.Right()-=4;
132 0 : aTempRect.Top()+=3;
133 0 : aTempRect.Bottom()-=4;
134 : }
135 : else
136 : {
137 0 : DecorationView aDecoView( pDev );
138 0 : aTempRect = aDecoView.DrawButton( rRect, nState|BUTTON_DRAW_FLAT );
139 : }
140 0 : ImplDrawBrdWinSymbol( pDev, aTempRect, eSymbol );
141 0 : }
142 :
143 : // - ImplBorderWindowView -
144 :
145 0 : ImplBorderWindowView::~ImplBorderWindowView()
146 : {
147 0 : }
148 :
149 0 : bool ImplBorderWindowView::MouseMove( const MouseEvent& )
150 : {
151 0 : return false;
152 : }
153 :
154 0 : bool ImplBorderWindowView::MouseButtonDown( const MouseEvent& )
155 : {
156 0 : return false;
157 : }
158 :
159 0 : bool ImplBorderWindowView::Tracking( const TrackingEvent& )
160 : {
161 0 : return false;
162 : }
163 :
164 0 : OUString ImplBorderWindowView::RequestHelp( const Point&, Rectangle& )
165 : {
166 0 : return OUString();
167 : }
168 :
169 0 : Rectangle ImplBorderWindowView::GetMenuRect() const
170 : {
171 0 : return Rectangle();
172 : }
173 :
174 0 : void ImplBorderWindowView::ImplInitTitle( ImplBorderFrameData* pData )
175 : {
176 0 : ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
177 :
178 0 : if ( !(pBorderWindow->GetStyle() & (WB_MOVEABLE | WB_POPUP)) ||
179 0 : (pData->mnTitleType == BORDERWINDOW_TITLE_NONE) )
180 : {
181 0 : pData->mnTitleType = BORDERWINDOW_TITLE_NONE;
182 0 : pData->mnTitleHeight = 0;
183 : }
184 : else
185 : {
186 0 : const StyleSettings& rStyleSettings = pData->mpOutDev->GetSettings().GetStyleSettings();
187 0 : if ( pData->mnTitleType == BORDERWINDOW_TITLE_TEAROFF )
188 0 : pData->mnTitleHeight = rStyleSettings.GetTearOffTitleHeight();
189 : else
190 : {
191 0 : if ( pData->mnTitleType == BORDERWINDOW_TITLE_SMALL )
192 : {
193 0 : pBorderWindow->SetPointFont( rStyleSettings.GetFloatTitleFont() );
194 0 : pData->mnTitleHeight = rStyleSettings.GetFloatTitleHeight();
195 : }
196 : else // pData->mnTitleType == BORDERWINDOW_TITLE_NORMAL
197 : {
198 0 : pBorderWindow->SetPointFont( rStyleSettings.GetTitleFont() );
199 0 : pData->mnTitleHeight = rStyleSettings.GetTitleHeight();
200 : }
201 0 : long nTextHeight = pBorderWindow->GetTextHeight();
202 0 : if ( nTextHeight > pData->mnTitleHeight )
203 0 : pData->mnTitleHeight = nTextHeight;
204 : }
205 : }
206 0 : }
207 :
208 0 : sal_uInt16 ImplBorderWindowView::ImplHitTest( ImplBorderFrameData* pData, const Point& rPos )
209 : {
210 0 : ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
211 :
212 0 : if ( pData->maTitleRect.IsInside( rPos ) )
213 : {
214 0 : if ( pData->maCloseRect.IsInside( rPos ) )
215 0 : return BORDERWINDOW_HITTEST_CLOSE;
216 0 : else if ( pData->maRollRect.IsInside( rPos ) )
217 0 : return BORDERWINDOW_HITTEST_ROLL;
218 0 : else if ( pData->maMenuRect.IsInside( rPos ) )
219 0 : return BORDERWINDOW_HITTEST_MENU;
220 0 : else if ( pData->maDockRect.IsInside( rPos ) )
221 0 : return BORDERWINDOW_HITTEST_DOCK;
222 0 : else if ( pData->maHideRect.IsInside( rPos ) )
223 0 : return BORDERWINDOW_HITTEST_HIDE;
224 0 : else if ( pData->maHelpRect.IsInside( rPos ) )
225 0 : return BORDERWINDOW_HITTEST_HELP;
226 0 : else if ( pData->maPinRect.IsInside( rPos ) )
227 0 : return BORDERWINDOW_HITTEST_PIN;
228 : else
229 0 : return BORDERWINDOW_HITTEST_TITLE;
230 : }
231 :
232 0 : if ( (pBorderWindow->GetStyle() & WB_SIZEABLE) &&
233 0 : !pBorderWindow->mbRollUp )
234 : {
235 0 : long nSizeWidth = pData->mnNoTitleTop+pData->mnTitleHeight;
236 0 : if ( nSizeWidth < 16 )
237 0 : nSizeWidth = 16;
238 :
239 : // no corner resize for floating toolbars, which would lead to jumps while formatting
240 : // setting nSizeWidth = 0 will only return pure left,top,right,bottom
241 0 : if( pBorderWindow->GetStyle() & (WB_OWNERDRAWDECORATION | WB_POPUP) )
242 0 : nSizeWidth = 0;
243 :
244 0 : if ( rPos.X() < pData->mnLeftBorder )
245 : {
246 0 : if ( rPos.Y() < nSizeWidth )
247 0 : return BORDERWINDOW_HITTEST_TOPLEFT;
248 0 : else if ( rPos.Y() >= pData->mnHeight-nSizeWidth )
249 0 : return BORDERWINDOW_HITTEST_BOTTOMLEFT;
250 : else
251 0 : return BORDERWINDOW_HITTEST_LEFT;
252 : }
253 0 : else if ( rPos.X() >= pData->mnWidth-pData->mnRightBorder )
254 : {
255 0 : if ( rPos.Y() < nSizeWidth )
256 0 : return BORDERWINDOW_HITTEST_TOPRIGHT;
257 0 : else if ( rPos.Y() >= pData->mnHeight-nSizeWidth )
258 0 : return BORDERWINDOW_HITTEST_BOTTOMRIGHT;
259 : else
260 0 : return BORDERWINDOW_HITTEST_RIGHT;
261 : }
262 0 : else if ( rPos.Y() < pData->mnNoTitleTop )
263 : {
264 0 : if ( rPos.X() < nSizeWidth )
265 0 : return BORDERWINDOW_HITTEST_TOPLEFT;
266 0 : else if ( rPos.X() >= pData->mnWidth-nSizeWidth )
267 0 : return BORDERWINDOW_HITTEST_TOPRIGHT;
268 : else
269 0 : return BORDERWINDOW_HITTEST_TOP;
270 : }
271 0 : else if ( rPos.Y() >= pData->mnHeight-pData->mnBottomBorder )
272 : {
273 0 : if ( rPos.X() < nSizeWidth )
274 0 : return BORDERWINDOW_HITTEST_BOTTOMLEFT;
275 0 : else if ( rPos.X() >= pData->mnWidth-nSizeWidth )
276 0 : return BORDERWINDOW_HITTEST_BOTTOMRIGHT;
277 : else
278 0 : return BORDERWINDOW_HITTEST_BOTTOM;
279 : }
280 : }
281 :
282 0 : return 0;
283 : }
284 :
285 0 : bool ImplBorderWindowView::ImplMouseMove( ImplBorderFrameData* pData, const MouseEvent& rMEvt )
286 : {
287 0 : sal_uInt16 oldCloseState = pData->mnCloseState;
288 0 : sal_uInt16 oldMenuState = pData->mnMenuState;
289 0 : pData->mnCloseState &= ~BUTTON_DRAW_HIGHLIGHT;
290 0 : pData->mnMenuState &= ~BUTTON_DRAW_HIGHLIGHT;
291 :
292 0 : Point aMousePos = rMEvt.GetPosPixel();
293 0 : sal_uInt16 nHitTest = ImplHitTest( pData, aMousePos );
294 0 : PointerStyle ePtrStyle = POINTER_ARROW;
295 0 : if ( nHitTest & BORDERWINDOW_HITTEST_LEFT )
296 0 : ePtrStyle = POINTER_WINDOW_WSIZE;
297 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_RIGHT )
298 0 : ePtrStyle = POINTER_WINDOW_ESIZE;
299 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_TOP )
300 0 : ePtrStyle = POINTER_WINDOW_NSIZE;
301 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_BOTTOM )
302 0 : ePtrStyle = POINTER_WINDOW_SSIZE;
303 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_TOPLEFT )
304 0 : ePtrStyle = POINTER_WINDOW_NWSIZE;
305 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_BOTTOMRIGHT )
306 0 : ePtrStyle = POINTER_WINDOW_SESIZE;
307 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_TOPRIGHT )
308 0 : ePtrStyle = POINTER_WINDOW_NESIZE;
309 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_BOTTOMLEFT )
310 0 : ePtrStyle = POINTER_WINDOW_SWSIZE;
311 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_CLOSE )
312 0 : pData->mnCloseState |= BUTTON_DRAW_HIGHLIGHT;
313 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_MENU )
314 0 : pData->mnMenuState |= BUTTON_DRAW_HIGHLIGHT;
315 0 : pData->mpBorderWindow->SetPointer( Pointer( ePtrStyle ) );
316 :
317 0 : if( pData->mnCloseState != oldCloseState )
318 0 : pData->mpBorderWindow->Invalidate( pData->maCloseRect );
319 0 : if( pData->mnMenuState != oldMenuState )
320 0 : pData->mpBorderWindow->Invalidate( pData->maMenuRect );
321 :
322 0 : return true;
323 : }
324 :
325 0 : bool ImplBorderWindowView::ImplMouseButtonDown( ImplBorderFrameData* pData, const MouseEvent& rMEvt )
326 : {
327 0 : ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
328 :
329 0 : if ( rMEvt.IsLeft() || rMEvt.IsRight() )
330 : {
331 0 : pData->maMouseOff = rMEvt.GetPosPixel();
332 0 : pData->mnHitTest = ImplHitTest( pData, pData->maMouseOff );
333 0 : if ( pData->mnHitTest )
334 : {
335 0 : sal_uInt16 nDragFullTest = 0;
336 0 : bool bTracking = true;
337 0 : bool bHitTest = true;
338 :
339 0 : if ( pData->mnHitTest & BORDERWINDOW_HITTEST_CLOSE )
340 : {
341 0 : pData->mnCloseState |= BUTTON_DRAW_PRESSED;
342 0 : DrawWindow( BORDERWINDOW_DRAW_CLOSE );
343 : }
344 0 : else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_ROLL )
345 : {
346 0 : pData->mnRollState |= BUTTON_DRAW_PRESSED;
347 0 : DrawWindow( BORDERWINDOW_DRAW_ROLL );
348 : }
349 0 : else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_DOCK )
350 : {
351 0 : pData->mnDockState |= BUTTON_DRAW_PRESSED;
352 0 : DrawWindow( BORDERWINDOW_DRAW_DOCK );
353 : }
354 0 : else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_MENU )
355 : {
356 0 : pData->mnMenuState |= BUTTON_DRAW_PRESSED;
357 0 : DrawWindow( BORDERWINDOW_DRAW_MENU );
358 :
359 : // call handler already on mouse down
360 0 : if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
361 : {
362 0 : SystemWindow* pClientWindow = (SystemWindow*)(pBorderWindow->ImplGetClientWindow());
363 0 : pClientWindow->TitleButtonClick( TITLE_BUTTON_MENU );
364 : }
365 : }
366 0 : else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_HIDE )
367 : {
368 0 : pData->mnHideState |= BUTTON_DRAW_PRESSED;
369 0 : DrawWindow( BORDERWINDOW_DRAW_HIDE );
370 : }
371 0 : else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_HELP )
372 : {
373 0 : pData->mnHelpState |= BUTTON_DRAW_PRESSED;
374 0 : DrawWindow( BORDERWINDOW_DRAW_HELP );
375 : }
376 0 : else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_PIN )
377 : {
378 0 : pData->mnPinState |= BUTTON_DRAW_PRESSED;
379 0 : DrawWindow( BORDERWINDOW_DRAW_PIN );
380 : }
381 : else
382 : {
383 0 : if ( rMEvt.GetClicks() == 1 )
384 : {
385 0 : if ( bTracking )
386 : {
387 0 : Point aPos = pBorderWindow->GetPosPixel();
388 0 : Size aSize = pBorderWindow->GetOutputSizePixel();
389 0 : pData->mnTrackX = aPos.X();
390 0 : pData->mnTrackY = aPos.Y();
391 0 : pData->mnTrackWidth = aSize.Width();
392 0 : pData->mnTrackHeight = aSize.Height();
393 :
394 0 : if ( pData->mnHitTest & BORDERWINDOW_HITTEST_TITLE )
395 0 : nDragFullTest = DRAGFULL_OPTION_WINDOWMOVE;
396 : else
397 0 : nDragFullTest = DRAGFULL_OPTION_WINDOWSIZE;
398 : }
399 : }
400 : else
401 : {
402 0 : bTracking = false;
403 :
404 0 : if ( (pData->mnHitTest & BORDERWINDOW_DRAW_TITLE) &&
405 0 : ((rMEvt.GetClicks() % 2) == 0) )
406 : {
407 0 : pData->mnHitTest = 0;
408 0 : bHitTest = false;
409 :
410 0 : if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
411 : {
412 0 : SystemWindow* pClientWindow = (SystemWindow*)(pBorderWindow->ImplGetClientWindow());
413 : if ( true /*pBorderWindow->mbDockBtn*/ ) // always perform docking on double click, no button required
414 0 : pClientWindow->TitleButtonClick( TITLE_BUTTON_DOCKING );
415 : else if ( pBorderWindow->GetStyle() & WB_ROLLABLE )
416 : {
417 : if ( pClientWindow->IsRollUp() )
418 : pClientWindow->RollDown();
419 : else
420 : pClientWindow->RollUp();
421 : pClientWindow->Roll();
422 : }
423 : }
424 : }
425 : }
426 : }
427 :
428 0 : if ( bTracking )
429 : {
430 0 : pData->mbDragFull = false;
431 0 : if ( nDragFullTest )
432 0 : pData->mbDragFull = true; // always fulldrag for proper docking, ignore system settings
433 0 : pBorderWindow->StartTracking();
434 : }
435 0 : else if ( bHitTest )
436 0 : pData->mnHitTest = 0;
437 : }
438 : }
439 :
440 0 : return true;
441 : }
442 :
443 0 : bool ImplBorderWindowView::ImplTracking( ImplBorderFrameData* pData, const TrackingEvent& rTEvt )
444 : {
445 0 : ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
446 :
447 0 : if ( rTEvt.IsTrackingEnded() )
448 : {
449 0 : sal_uInt16 nHitTest = pData->mnHitTest;
450 0 : pData->mnHitTest = 0;
451 :
452 0 : if ( nHitTest & BORDERWINDOW_HITTEST_CLOSE )
453 : {
454 0 : if ( pData->mnCloseState & BUTTON_DRAW_PRESSED )
455 : {
456 0 : pData->mnCloseState &= ~BUTTON_DRAW_PRESSED;
457 0 : DrawWindow( BORDERWINDOW_DRAW_CLOSE );
458 :
459 : // do not call a Click-Handler when aborting
460 0 : if ( !rTEvt.IsTrackingCanceled() )
461 : {
462 : // dispatch to correct window type (why is Close() not virtual ??? )
463 : // TODO: make Close() virtual
464 0 : Window *pWin = pBorderWindow->ImplGetClientWindow()->ImplGetWindow();
465 0 : SystemWindow *pSysWin = dynamic_cast<SystemWindow* >(pWin);
466 0 : DockingWindow *pDockWin = dynamic_cast<DockingWindow*>(pWin);
467 0 : if ( pSysWin )
468 0 : pSysWin->Close();
469 0 : else if ( pDockWin )
470 0 : pDockWin->Close();
471 : }
472 : }
473 : }
474 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_ROLL )
475 : {
476 0 : if ( pData->mnRollState & BUTTON_DRAW_PRESSED )
477 : {
478 0 : pData->mnRollState &= ~BUTTON_DRAW_PRESSED;
479 0 : DrawWindow( BORDERWINDOW_DRAW_ROLL );
480 :
481 : // do not call a Click-Handler when aborting
482 0 : if ( !rTEvt.IsTrackingCanceled() )
483 : {
484 0 : if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
485 : {
486 0 : SystemWindow* pClientWindow = (SystemWindow*)(pBorderWindow->ImplGetClientWindow());
487 0 : if ( pClientWindow->IsRollUp() )
488 0 : pClientWindow->RollDown();
489 : else
490 0 : pClientWindow->RollUp();
491 0 : pClientWindow->Roll();
492 : }
493 : }
494 : }
495 : }
496 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_DOCK )
497 : {
498 0 : if ( pData->mnDockState & BUTTON_DRAW_PRESSED )
499 : {
500 0 : pData->mnDockState &= ~BUTTON_DRAW_PRESSED;
501 0 : DrawWindow( BORDERWINDOW_DRAW_DOCK );
502 :
503 : // do not call a Click-Handler when aborting
504 0 : if ( !rTEvt.IsTrackingCanceled() )
505 : {
506 0 : if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
507 : {
508 0 : SystemWindow* pClientWindow = (SystemWindow*)(pBorderWindow->ImplGetClientWindow());
509 0 : pClientWindow->TitleButtonClick( TITLE_BUTTON_DOCKING );
510 : }
511 : }
512 : }
513 : }
514 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_MENU )
515 : {
516 0 : if ( pData->mnMenuState & BUTTON_DRAW_PRESSED )
517 : {
518 0 : pData->mnMenuState &= ~BUTTON_DRAW_PRESSED;
519 0 : DrawWindow( BORDERWINDOW_DRAW_MENU );
520 :
521 : // handler already called on mouse down
522 : }
523 : }
524 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_HIDE )
525 : {
526 0 : if ( pData->mnHideState & BUTTON_DRAW_PRESSED )
527 : {
528 0 : pData->mnHideState &= ~BUTTON_DRAW_PRESSED;
529 0 : DrawWindow( BORDERWINDOW_DRAW_HIDE );
530 :
531 : // do not call a Click-Handler when aborting
532 0 : if ( !rTEvt.IsTrackingCanceled() )
533 : {
534 0 : if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
535 : {
536 0 : SystemWindow* pClientWindow = (SystemWindow*)(pBorderWindow->ImplGetClientWindow());
537 0 : pClientWindow->TitleButtonClick( TITLE_BUTTON_HIDE );
538 : }
539 : }
540 : }
541 : }
542 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_HELP )
543 : {
544 0 : if ( pData->mnHelpState & BUTTON_DRAW_PRESSED )
545 : {
546 0 : pData->mnHelpState &= ~BUTTON_DRAW_PRESSED;
547 0 : DrawWindow( BORDERWINDOW_DRAW_HELP );
548 :
549 : // do not call a Click-Handler when aborting
550 0 : if ( !rTEvt.IsTrackingCanceled() )
551 : {
552 : }
553 : }
554 : }
555 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_PIN )
556 : {
557 0 : if ( pData->mnPinState & BUTTON_DRAW_PRESSED )
558 : {
559 0 : pData->mnPinState &= ~BUTTON_DRAW_PRESSED;
560 0 : DrawWindow( BORDERWINDOW_DRAW_PIN );
561 :
562 : // do not call a Click-Handler when aborting
563 0 : if ( !rTEvt.IsTrackingCanceled() )
564 : {
565 0 : if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
566 : {
567 0 : SystemWindow* pClientWindow = (SystemWindow*)(pBorderWindow->ImplGetClientWindow());
568 0 : pClientWindow->SetPin( !pClientWindow->IsPinned() );
569 0 : pClientWindow->Pin();
570 : }
571 : }
572 : }
573 : }
574 : else
575 : {
576 0 : if ( pData->mbDragFull )
577 : {
578 : // restore old state when aborting
579 0 : if ( rTEvt.IsTrackingCanceled() )
580 0 : pBorderWindow->SetPosSizePixel( Point( pData->mnTrackX, pData->mnTrackY ), Size( pData->mnTrackWidth, pData->mnTrackHeight ) );
581 : }
582 : else
583 : {
584 0 : pBorderWindow->HideTracking();
585 0 : if ( !rTEvt.IsTrackingCanceled() )
586 0 : pBorderWindow->SetPosSizePixel( Point( pData->mnTrackX, pData->mnTrackY ), Size( pData->mnTrackWidth, pData->mnTrackHeight ) );
587 : }
588 :
589 0 : if ( !rTEvt.IsTrackingCanceled() )
590 : {
591 0 : if ( pBorderWindow->ImplGetClientWindow()->ImplIsFloatingWindow() )
592 : {
593 0 : if ( ((FloatingWindow*)pBorderWindow->ImplGetClientWindow())->IsInPopupMode() )
594 0 : ((FloatingWindow*)pBorderWindow->ImplGetClientWindow())->EndPopupMode( FLOATWIN_POPUPMODEEND_TEAROFF );
595 : }
596 : }
597 : }
598 : }
599 0 : else if ( !rTEvt.GetMouseEvent().IsSynthetic() )
600 : {
601 0 : Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
602 :
603 0 : if ( pData->mnHitTest & BORDERWINDOW_HITTEST_CLOSE )
604 : {
605 0 : if ( pData->maCloseRect.IsInside( aMousePos ) )
606 : {
607 0 : if ( !(pData->mnCloseState & BUTTON_DRAW_PRESSED) )
608 : {
609 0 : pData->mnCloseState |= BUTTON_DRAW_PRESSED;
610 0 : DrawWindow( BORDERWINDOW_DRAW_CLOSE );
611 : }
612 : }
613 : else
614 : {
615 0 : if ( pData->mnCloseState & BUTTON_DRAW_PRESSED )
616 : {
617 0 : pData->mnCloseState &= ~BUTTON_DRAW_PRESSED;
618 0 : DrawWindow( BORDERWINDOW_DRAW_CLOSE );
619 : }
620 : }
621 : }
622 0 : else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_ROLL )
623 : {
624 0 : if ( pData->maRollRect.IsInside( aMousePos ) )
625 : {
626 0 : if ( !(pData->mnRollState & BUTTON_DRAW_PRESSED) )
627 : {
628 0 : pData->mnRollState |= BUTTON_DRAW_PRESSED;
629 0 : DrawWindow( BORDERWINDOW_DRAW_ROLL );
630 : }
631 : }
632 : else
633 : {
634 0 : if ( pData->mnRollState & BUTTON_DRAW_PRESSED )
635 : {
636 0 : pData->mnRollState &= ~BUTTON_DRAW_PRESSED;
637 0 : DrawWindow( BORDERWINDOW_DRAW_ROLL );
638 : }
639 : }
640 : }
641 0 : else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_DOCK )
642 : {
643 0 : if ( pData->maDockRect.IsInside( aMousePos ) )
644 : {
645 0 : if ( !(pData->mnDockState & BUTTON_DRAW_PRESSED) )
646 : {
647 0 : pData->mnDockState |= BUTTON_DRAW_PRESSED;
648 0 : DrawWindow( BORDERWINDOW_DRAW_DOCK );
649 : }
650 : }
651 : else
652 : {
653 0 : if ( pData->mnDockState & BUTTON_DRAW_PRESSED )
654 : {
655 0 : pData->mnDockState &= ~BUTTON_DRAW_PRESSED;
656 0 : DrawWindow( BORDERWINDOW_DRAW_DOCK );
657 : }
658 : }
659 : }
660 0 : else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_MENU )
661 : {
662 0 : if ( pData->maMenuRect.IsInside( aMousePos ) )
663 : {
664 0 : if ( !(pData->mnMenuState & BUTTON_DRAW_PRESSED) )
665 : {
666 0 : pData->mnMenuState |= BUTTON_DRAW_PRESSED;
667 0 : DrawWindow( BORDERWINDOW_DRAW_MENU );
668 :
669 : }
670 : }
671 : else
672 : {
673 0 : if ( pData->mnMenuState & BUTTON_DRAW_PRESSED )
674 : {
675 0 : pData->mnMenuState &= ~BUTTON_DRAW_PRESSED;
676 0 : DrawWindow( BORDERWINDOW_DRAW_MENU );
677 : }
678 : }
679 : }
680 0 : else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_HIDE )
681 : {
682 0 : if ( pData->maHideRect.IsInside( aMousePos ) )
683 : {
684 0 : if ( !(pData->mnHideState & BUTTON_DRAW_PRESSED) )
685 : {
686 0 : pData->mnHideState |= BUTTON_DRAW_PRESSED;
687 0 : DrawWindow( BORDERWINDOW_DRAW_HIDE );
688 : }
689 : }
690 : else
691 : {
692 0 : if ( pData->mnHideState & BUTTON_DRAW_PRESSED )
693 : {
694 0 : pData->mnHideState &= ~BUTTON_DRAW_PRESSED;
695 0 : DrawWindow( BORDERWINDOW_DRAW_HIDE );
696 : }
697 : }
698 : }
699 0 : else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_HELP )
700 : {
701 0 : if ( pData->maHelpRect.IsInside( aMousePos ) )
702 : {
703 0 : if ( !(pData->mnHelpState & BUTTON_DRAW_PRESSED) )
704 : {
705 0 : pData->mnHelpState |= BUTTON_DRAW_PRESSED;
706 0 : DrawWindow( BORDERWINDOW_DRAW_HELP );
707 : }
708 : }
709 : else
710 : {
711 0 : if ( pData->mnHelpState & BUTTON_DRAW_PRESSED )
712 : {
713 0 : pData->mnHelpState &= ~BUTTON_DRAW_PRESSED;
714 0 : DrawWindow( BORDERWINDOW_DRAW_HELP );
715 : }
716 : }
717 : }
718 0 : else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_PIN )
719 : {
720 0 : if ( pData->maPinRect.IsInside( aMousePos ) )
721 : {
722 0 : if ( !(pData->mnPinState & BUTTON_DRAW_PRESSED) )
723 : {
724 0 : pData->mnPinState |= BUTTON_DRAW_PRESSED;
725 0 : DrawWindow( BORDERWINDOW_DRAW_PIN );
726 : }
727 : }
728 : else
729 : {
730 0 : if ( pData->mnPinState & BUTTON_DRAW_PRESSED )
731 : {
732 0 : pData->mnPinState &= ~BUTTON_DRAW_PRESSED;
733 0 : DrawWindow( BORDERWINDOW_DRAW_PIN );
734 : }
735 : }
736 : }
737 : else
738 : {
739 : /*
740 : // adjusting mousepos not required, we allow the whole screen (no desktop anymore...)
741 : Point aFrameMousePos = pBorderWindow->ImplOutputToFrame( aMousePos );
742 : Size aFrameSize = pBorderWindow->ImplGetFrameWindow()->GetOutputSizePixel();
743 : if ( aFrameMousePos.X() < 0 )
744 : aFrameMousePos.X() = 0;
745 : if ( aFrameMousePos.Y() < 0 )
746 : aFrameMousePos.Y() = 0;
747 : if ( aFrameMousePos.X() > aFrameSize.Width()-1 )
748 : aFrameMousePos.X() = aFrameSize.Width()-1;
749 : if ( aFrameMousePos.Y() > aFrameSize.Height()-1 )
750 : aFrameMousePos.Y() = aFrameSize.Height()-1;
751 : aMousePos = pBorderWindow->ImplFrameToOutput( aFrameMousePos );
752 : */
753 :
754 0 : aMousePos.X() -= pData->maMouseOff.X();
755 0 : aMousePos.Y() -= pData->maMouseOff.Y();
756 :
757 0 : if ( pData->mnHitTest & BORDERWINDOW_HITTEST_TITLE )
758 : {
759 0 : pData->mpBorderWindow->SetPointer( Pointer( POINTER_MOVE ) );
760 :
761 0 : Point aPos = pBorderWindow->GetPosPixel();
762 0 : aPos.X() += aMousePos.X();
763 0 : aPos.Y() += aMousePos.Y();
764 0 : if ( pData->mbDragFull )
765 : {
766 0 : pBorderWindow->SetPosPixel( aPos );
767 0 : pBorderWindow->ImplUpdateAll();
768 0 : pBorderWindow->ImplGetFrameWindow()->ImplUpdateAll();
769 : }
770 : else
771 : {
772 0 : pData->mnTrackX = aPos.X();
773 0 : pData->mnTrackY = aPos.Y();
774 0 : pBorderWindow->ShowTracking( Rectangle( pBorderWindow->ScreenToOutputPixel( aPos ), pBorderWindow->GetOutputSizePixel() ), SHOWTRACK_BIG );
775 : }
776 : }
777 : else
778 : {
779 0 : Point aOldPos = pBorderWindow->GetPosPixel();
780 0 : Size aSize = pBorderWindow->GetSizePixel();
781 0 : Rectangle aNewRect( aOldPos, aSize );
782 0 : long nOldWidth = aSize.Width();
783 0 : long nOldHeight = aSize.Height();
784 0 : long nBorderWidth = pData->mnLeftBorder+pData->mnRightBorder;
785 0 : long nBorderHeight = pData->mnTopBorder+pData->mnBottomBorder;
786 0 : long nMinWidth = pBorderWindow->mnMinWidth+nBorderWidth;
787 0 : long nMinHeight = pBorderWindow->mnMinHeight+nBorderHeight;
788 0 : long nMinWidth2 = nBorderWidth;
789 0 : long nMaxWidth = pBorderWindow->mnMaxWidth+nBorderWidth;
790 0 : long nMaxHeight = pBorderWindow->mnMaxHeight+nBorderHeight;
791 :
792 0 : if ( pData->mnTitleHeight )
793 : {
794 0 : nMinWidth2 += 4;
795 :
796 0 : if ( pBorderWindow->GetStyle() & WB_CLOSEABLE )
797 0 : nMinWidth2 += pData->maCloseRect.GetWidth();
798 : }
799 0 : if ( nMinWidth2 > nMinWidth )
800 0 : nMinWidth = nMinWidth2;
801 0 : if ( pData->mnHitTest & (BORDERWINDOW_HITTEST_LEFT | BORDERWINDOW_HITTEST_TOPLEFT | BORDERWINDOW_HITTEST_BOTTOMLEFT) )
802 : {
803 0 : aNewRect.Left() += aMousePos.X();
804 0 : if ( aNewRect.GetWidth() < nMinWidth )
805 0 : aNewRect.Left() = aNewRect.Right()-nMinWidth+1;
806 0 : else if ( aNewRect.GetWidth() > nMaxWidth )
807 0 : aNewRect.Left() = aNewRect.Right()-nMaxWidth+1;
808 : }
809 0 : else if ( pData->mnHitTest & (BORDERWINDOW_HITTEST_RIGHT | BORDERWINDOW_HITTEST_TOPRIGHT | BORDERWINDOW_HITTEST_BOTTOMRIGHT) )
810 : {
811 0 : aNewRect.Right() += aMousePos.X();
812 0 : if ( aNewRect.GetWidth() < nMinWidth )
813 0 : aNewRect.Right() = aNewRect.Left()+nMinWidth+1;
814 0 : else if ( aNewRect.GetWidth() > nMaxWidth )
815 0 : aNewRect.Right() = aNewRect.Left()+nMaxWidth+1;
816 : }
817 0 : if ( pData->mnHitTest & (BORDERWINDOW_HITTEST_TOP | BORDERWINDOW_HITTEST_TOPLEFT | BORDERWINDOW_HITTEST_TOPRIGHT) )
818 : {
819 0 : aNewRect.Top() += aMousePos.Y();
820 0 : if ( aNewRect.GetHeight() < nMinHeight )
821 0 : aNewRect.Top() = aNewRect.Bottom()-nMinHeight+1;
822 0 : else if ( aNewRect.GetHeight() > nMaxHeight )
823 0 : aNewRect.Top() = aNewRect.Bottom()-nMaxHeight+1;
824 : }
825 0 : else if ( pData->mnHitTest & (BORDERWINDOW_HITTEST_BOTTOM | BORDERWINDOW_HITTEST_BOTTOMLEFT | BORDERWINDOW_HITTEST_BOTTOMRIGHT) )
826 : {
827 0 : aNewRect.Bottom() += aMousePos.Y();
828 0 : if ( aNewRect.GetHeight() < nMinHeight )
829 0 : aNewRect.Bottom() = aNewRect.Top()+nMinHeight+1;
830 0 : else if ( aNewRect.GetHeight() > nMaxHeight )
831 0 : aNewRect.Bottom() = aNewRect.Top()+nMaxHeight+1;
832 : }
833 :
834 : // call Resizing-Handler for SystemWindows
835 0 : if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
836 : {
837 : // adjust size for Resizing-call
838 0 : aSize = aNewRect.GetSize();
839 0 : aSize.Width() -= nBorderWidth;
840 0 : aSize.Height() -= nBorderHeight;
841 0 : ((SystemWindow*)pBorderWindow->ImplGetClientWindow())->Resizing( aSize );
842 0 : aSize.Width() += nBorderWidth;
843 0 : aSize.Height() += nBorderHeight;
844 0 : if ( aSize.Width() < nMinWidth )
845 0 : aSize.Width() = nMinWidth;
846 0 : if ( aSize.Height() < nMinHeight )
847 0 : aSize.Height() = nMinHeight;
848 0 : if ( aSize.Width() > nMaxWidth )
849 0 : aSize.Width() = nMaxWidth;
850 0 : if ( aSize.Height() > nMaxHeight )
851 0 : aSize.Height() = nMaxHeight;
852 0 : if ( pData->mnHitTest & (BORDERWINDOW_HITTEST_LEFT | BORDERWINDOW_HITTEST_TOPLEFT | BORDERWINDOW_HITTEST_BOTTOMLEFT) )
853 0 : aNewRect.Left() = aNewRect.Right()-aSize.Width()+1;
854 : else
855 0 : aNewRect.Right() = aNewRect.Left()+aSize.Width()-1;
856 0 : if ( pData->mnHitTest & (BORDERWINDOW_HITTEST_TOP | BORDERWINDOW_HITTEST_TOPLEFT | BORDERWINDOW_HITTEST_TOPRIGHT) )
857 0 : aNewRect.Top() = aNewRect.Bottom()-aSize.Height()+1;
858 : else
859 0 : aNewRect.Bottom() = aNewRect.Top()+aSize.Height()-1;
860 : }
861 :
862 0 : if ( pData->mbDragFull )
863 : {
864 : // no move (only resize) if position did not change
865 0 : if( aOldPos != aNewRect.TopLeft() )
866 0 : pBorderWindow->setPosSizePixel( aNewRect.Left(), aNewRect.Top(),
867 0 : aNewRect.GetWidth(), aNewRect.GetHeight(), WINDOW_POSSIZE_POSSIZE );
868 : else
869 0 : pBorderWindow->setPosSizePixel( aNewRect.Left(), aNewRect.Top(),
870 0 : aNewRect.GetWidth(), aNewRect.GetHeight(), WINDOW_POSSIZE_SIZE );
871 :
872 0 : pBorderWindow->ImplUpdateAll();
873 0 : pBorderWindow->ImplGetFrameWindow()->ImplUpdateAll();
874 0 : if ( pData->mnHitTest & (BORDERWINDOW_HITTEST_RIGHT | BORDERWINDOW_HITTEST_TOPRIGHT | BORDERWINDOW_HITTEST_BOTTOMRIGHT) )
875 0 : pData->maMouseOff.X() += aNewRect.GetWidth()-nOldWidth;
876 0 : if ( pData->mnHitTest & (BORDERWINDOW_HITTEST_BOTTOM | BORDERWINDOW_HITTEST_BOTTOMLEFT | BORDERWINDOW_HITTEST_BOTTOMRIGHT) )
877 0 : pData->maMouseOff.Y() += aNewRect.GetHeight()-nOldHeight;
878 : }
879 : else
880 : {
881 0 : pData->mnTrackX = aNewRect.Left();
882 0 : pData->mnTrackY = aNewRect.Top();
883 0 : pData->mnTrackWidth = aNewRect.GetWidth();
884 0 : pData->mnTrackHeight = aNewRect.GetHeight();
885 0 : pBorderWindow->ShowTracking( Rectangle( pBorderWindow->ScreenToOutputPixel( aNewRect.TopLeft() ), aNewRect.GetSize() ), SHOWTRACK_BIG );
886 : }
887 : }
888 : }
889 : }
890 :
891 0 : return true;
892 : }
893 :
894 0 : OUString ImplBorderWindowView::ImplRequestHelp( ImplBorderFrameData* pData,
895 : const Point& rPos,
896 : Rectangle& rHelpRect )
897 : {
898 0 : sal_uInt16 nHelpId = 0;
899 0 : OUString aHelpStr;
900 0 : sal_uInt16 nHitTest = ImplHitTest( pData, rPos );
901 0 : if ( nHitTest )
902 : {
903 0 : if ( nHitTest & BORDERWINDOW_HITTEST_CLOSE )
904 : {
905 0 : nHelpId = SV_HELPTEXT_CLOSE;
906 0 : rHelpRect = pData->maCloseRect;
907 : }
908 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_ROLL )
909 : {
910 0 : if ( pData->mpBorderWindow->mbRollUp )
911 0 : nHelpId = SV_HELPTEXT_ROLLDOWN;
912 : else
913 0 : nHelpId = SV_HELPTEXT_ROLLUP;
914 0 : rHelpRect = pData->maRollRect;
915 : }
916 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_DOCK )
917 : {
918 0 : nHelpId = SV_HELPTEXT_MAXIMIZE;
919 0 : rHelpRect = pData->maDockRect;
920 : }
921 : /* no help string available
922 : else if ( nHitTest & BORDERWINDOW_HITTEST_MENU )
923 : {
924 : nHelpId = SV_HELPTEXT_MENU;
925 : rHelpRect = pData->maMenuRect;
926 : }*/
927 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_HIDE )
928 : {
929 0 : nHelpId = SV_HELPTEXT_MINIMIZE;
930 0 : rHelpRect = pData->maHideRect;
931 : }
932 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_HELP )
933 : {
934 0 : nHelpId = SV_HELPTEXT_HELP;
935 0 : rHelpRect = pData->maHelpRect;
936 : }
937 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_PIN )
938 : {
939 0 : nHelpId = SV_HELPTEXT_ALWAYSVISIBLE;
940 0 : rHelpRect = pData->maPinRect;
941 : }
942 0 : else if ( nHitTest & BORDERWINDOW_HITTEST_TITLE )
943 : {
944 0 : if( !pData->maTitleRect.IsEmpty() )
945 : {
946 : // tooltip only if title truncated
947 0 : if( pData->mbTitleClipped )
948 : {
949 0 : rHelpRect = pData->maTitleRect;
950 : // no help id, use window title as help string
951 0 : aHelpStr = pData->mpBorderWindow->GetText();
952 : }
953 : }
954 : }
955 : }
956 :
957 0 : if( nHelpId && ImplGetResMgr() )
958 0 : aHelpStr = ResId(nHelpId, *ImplGetResMgr()).toString();
959 :
960 0 : return aHelpStr;
961 : }
962 :
963 0 : long ImplBorderWindowView::ImplCalcTitleWidth( const ImplBorderFrameData* pData ) const
964 : {
965 : // title is not visible therefore no width
966 0 : if ( !pData->mnTitleHeight )
967 0 : return 0;
968 :
969 0 : ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
970 0 : long nTitleWidth = pBorderWindow->GetTextWidth( pBorderWindow->GetText() )+6;
971 0 : nTitleWidth += pData->maPinRect.GetWidth();
972 0 : nTitleWidth += pData->maCloseRect.GetWidth();
973 0 : nTitleWidth += pData->maRollRect.GetWidth();
974 0 : nTitleWidth += pData->maDockRect.GetWidth();
975 0 : nTitleWidth += pData->maMenuRect.GetWidth();
976 0 : nTitleWidth += pData->maHideRect.GetWidth();
977 0 : nTitleWidth += pData->maHelpRect.GetWidth();
978 0 : nTitleWidth += pData->mnLeftBorder+pData->mnRightBorder;
979 0 : return nTitleWidth;
980 : }
981 :
982 : // - ImplNoBorderWindowView -
983 :
984 0 : ImplNoBorderWindowView::ImplNoBorderWindowView( ImplBorderWindow* )
985 : {
986 0 : }
987 :
988 0 : void ImplNoBorderWindowView::Init( OutputDevice*, long, long )
989 : {
990 0 : }
991 :
992 0 : void ImplNoBorderWindowView::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
993 : sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
994 : {
995 0 : rLeftBorder = 0;
996 0 : rTopBorder = 0;
997 0 : rRightBorder = 0;
998 0 : rBottomBorder = 0;
999 0 : }
1000 :
1001 0 : long ImplNoBorderWindowView::CalcTitleWidth() const
1002 : {
1003 0 : return 0;
1004 : }
1005 :
1006 0 : void ImplNoBorderWindowView::DrawWindow( sal_uInt16, OutputDevice*, const Point* )
1007 : {
1008 0 : }
1009 :
1010 : // - ImplSmallBorderWindowView -
1011 0 : ImplSmallBorderWindowView::ImplSmallBorderWindowView( ImplBorderWindow* pBorderWindow )
1012 : : mpBorderWindow(pBorderWindow)
1013 : , mpOutDev(NULL)
1014 : , mnWidth(0)
1015 : , mnHeight(0)
1016 : , mnLeftBorder(0)
1017 : , mnTopBorder(0)
1018 : , mnRightBorder(0)
1019 : , mnBottomBorder(0)
1020 0 : , mbNWFBorder(false)
1021 : {
1022 0 : }
1023 :
1024 0 : void ImplSmallBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHeight )
1025 : {
1026 0 : mpOutDev = pDev;
1027 0 : mnWidth = nWidth;
1028 0 : mnHeight = nHeight;
1029 0 : mbNWFBorder = false;
1030 :
1031 0 : Window *pWin = NULL, *pCtrl = NULL;
1032 0 : if (mpOutDev->GetOutDevType() == OUTDEV_WINDOW)
1033 0 : pWin = (Window*) mpOutDev;
1034 :
1035 0 : if (pWin)
1036 0 : pCtrl = mpBorderWindow->GetWindow(WINDOW_CLIENT);
1037 :
1038 0 : long nOrigLeftBorder = mnLeftBorder;
1039 0 : long nOrigTopBorder = mnTopBorder;
1040 0 : long nOrigRightBorder = mnRightBorder;
1041 0 : long nOrigBottomBorder = mnBottomBorder;
1042 :
1043 0 : sal_uInt16 nBorderStyle = mpBorderWindow->GetBorderStyle();
1044 0 : if ( nBorderStyle & WINDOW_BORDER_NOBORDER )
1045 : {
1046 0 : mnLeftBorder = 0;
1047 0 : mnTopBorder = 0;
1048 0 : mnRightBorder = 0;
1049 0 : mnBottomBorder = 0;
1050 : }
1051 : else
1052 : {
1053 : // FIXME: this is currently only on OS X, check with other
1054 : // platforms
1055 0 : if( ImplGetSVData()->maNWFData.mbNoFocusRects && !( nBorderStyle & WINDOW_BORDER_NWF ) )
1056 : {
1057 : // for native widget drawing we must find out what
1058 : // control this border belongs to
1059 0 : ControlType aCtrlType = 0;
1060 0 : if (pCtrl)
1061 : {
1062 0 : switch( pCtrl->GetType() )
1063 : {
1064 : case WINDOW_LISTBOX:
1065 0 : if( pCtrl->GetStyle() & WB_DROPDOWN )
1066 : {
1067 0 : aCtrlType = CTRL_LISTBOX;
1068 0 : mbNWFBorder = true;
1069 : }
1070 0 : break;
1071 : case WINDOW_COMBOBOX:
1072 0 : if( pCtrl->GetStyle() & WB_DROPDOWN )
1073 : {
1074 0 : aCtrlType = CTRL_COMBOBOX;
1075 0 : mbNWFBorder = true;
1076 : }
1077 0 : break;
1078 : case WINDOW_MULTILINEEDIT:
1079 0 : aCtrlType = CTRL_MULTILINE_EDITBOX;
1080 0 : mbNWFBorder = true;
1081 0 : break;
1082 : case WINDOW_EDIT:
1083 : case WINDOW_PATTERNFIELD:
1084 : case WINDOW_METRICFIELD:
1085 : case WINDOW_CURRENCYFIELD:
1086 : case WINDOW_DATEFIELD:
1087 : case WINDOW_TIMEFIELD:
1088 : case WINDOW_LONGCURRENCYFIELD:
1089 : case WINDOW_NUMERICFIELD:
1090 : case WINDOW_SPINFIELD:
1091 : case WINDOW_CALCINPUTLINE:
1092 0 : mbNWFBorder = true;
1093 0 : aCtrlType = (pCtrl->GetStyle() & WB_SPIN) ? CTRL_SPINBOX : CTRL_EDITBOX;
1094 0 : break;
1095 : default:
1096 0 : break;
1097 : }
1098 : }
1099 0 : if( mbNWFBorder )
1100 : {
1101 0 : ImplControlValue aControlValue;
1102 0 : Rectangle aCtrlRegion( (const Point&)Point(), Size( mnWidth < 10 ? 10 : mnWidth, mnHeight < 10 ? 10 : mnHeight ) );
1103 0 : Rectangle aBounds( aCtrlRegion );
1104 0 : Rectangle aContent( aCtrlRegion );
1105 0 : if( pWin->GetNativeControlRegion( aCtrlType, PART_ENTIRE_CONTROL, aCtrlRegion,
1106 : CTRL_STATE_ENABLED, aControlValue, OUString(),
1107 0 : aBounds, aContent ) )
1108 : {
1109 0 : mnLeftBorder = aContent.Left() - aBounds.Left();
1110 0 : mnRightBorder = aBounds.Right() - aContent.Right();
1111 0 : mnTopBorder = aContent.Top() - aBounds.Top();
1112 0 : mnBottomBorder = aBounds.Bottom() - aContent.Bottom();
1113 0 : if( mnWidth && mnHeight )
1114 : {
1115 :
1116 0 : mpBorderWindow->SetPaintTransparent( true );
1117 0 : mpBorderWindow->SetBackground();
1118 0 : pCtrl->SetPaintTransparent( true );
1119 :
1120 0 : Window* pCompoundParent = NULL;
1121 0 : if( pWin->GetParent() && pWin->GetParent()->IsCompoundControl() )
1122 0 : pCompoundParent = pWin->GetParent();
1123 :
1124 0 : if( pCompoundParent )
1125 0 : pCompoundParent->SetPaintTransparent( true );
1126 :
1127 0 : if( mnWidth < aBounds.GetWidth() || mnHeight < aBounds.GetHeight() )
1128 : {
1129 0 : if( ! pCompoundParent ) // compound controls have to fix themselves
1130 : {
1131 0 : Point aPos( mpBorderWindow->GetPosPixel() );
1132 0 : if( mnWidth < aBounds.GetWidth() )
1133 0 : aPos.X() -= (aBounds.GetWidth() - mnWidth) / 2;
1134 0 : if( mnHeight < aBounds.GetHeight() )
1135 0 : aPos.Y() -= (aBounds.GetHeight() - mnHeight) / 2;
1136 0 : mpBorderWindow->SetPosSizePixel( aPos, aBounds.GetSize() );
1137 : }
1138 : }
1139 : }
1140 : }
1141 : else
1142 0 : mbNWFBorder = false;
1143 : }
1144 : }
1145 :
1146 0 : if( ! mbNWFBorder )
1147 : {
1148 0 : sal_uInt16 nStyle = FRAME_DRAW_NODRAW;
1149 : // move border outside if border was converted or if the BorderWindow is a frame window,
1150 0 : if ( mpBorderWindow->mbSmallOutBorder )
1151 0 : nStyle |= FRAME_DRAW_DOUBLEOUT;
1152 0 : else if ( nBorderStyle & WINDOW_BORDER_NWF )
1153 0 : nStyle |= FRAME_DRAW_NWF;
1154 : else
1155 0 : nStyle |= FRAME_DRAW_DOUBLEIN;
1156 0 : if ( nBorderStyle & WINDOW_BORDER_MONO )
1157 0 : nStyle |= FRAME_DRAW_MONO;
1158 :
1159 0 : DecorationView aDecoView( mpOutDev );
1160 0 : Rectangle aRect( 0, 0, 10, 10 );
1161 0 : Rectangle aCalcRect = aDecoView.DrawFrame( aRect, nStyle );
1162 0 : mnLeftBorder = aCalcRect.Left();
1163 0 : mnTopBorder = aCalcRect.Top();
1164 0 : mnRightBorder = aRect.Right()-aCalcRect.Right();
1165 0 : mnBottomBorder = aRect.Bottom()-aCalcRect.Bottom();
1166 : }
1167 : }
1168 :
1169 0 : if (pCtrl)
1170 : {
1171 : //fdo#57090 If the borders have changed, then trigger a queue_resize on
1172 : //the bordered window, which will resync its borders at that point
1173 0 : if (nOrigLeftBorder != mnLeftBorder ||
1174 0 : nOrigTopBorder != mnTopBorder ||
1175 0 : nOrigRightBorder != mnRightBorder ||
1176 0 : nOrigBottomBorder != mnBottomBorder)
1177 : {
1178 0 : pCtrl->queue_resize();
1179 : }
1180 : }
1181 0 : }
1182 :
1183 0 : void ImplSmallBorderWindowView::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
1184 : sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
1185 : {
1186 0 : rLeftBorder = mnLeftBorder;
1187 0 : rTopBorder = mnTopBorder;
1188 0 : rRightBorder = mnRightBorder;
1189 0 : rBottomBorder = mnBottomBorder;
1190 0 : }
1191 :
1192 0 : long ImplSmallBorderWindowView::CalcTitleWidth() const
1193 : {
1194 0 : return 0;
1195 : }
1196 :
1197 0 : void ImplSmallBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice*, const Point* )
1198 : {
1199 0 : sal_uInt16 nBorderStyle = mpBorderWindow->GetBorderStyle();
1200 0 : if ( nBorderStyle & WINDOW_BORDER_NOBORDER )
1201 0 : return;
1202 :
1203 0 : bool bNativeOK = false;
1204 : // for native widget drawing we must find out what
1205 : // control this border belongs to
1206 0 : Window *pWin = NULL, *pCtrl = NULL;
1207 0 : if( mpOutDev->GetOutDevType() == OUTDEV_WINDOW )
1208 0 : pWin = (Window*) mpOutDev;
1209 :
1210 0 : ControlType aCtrlType = 0;
1211 0 : ControlPart aCtrlPart = PART_ENTIRE_CONTROL;
1212 :
1213 0 : if( pWin && (pCtrl = mpBorderWindow->GetWindow( WINDOW_CLIENT )) != NULL )
1214 : {
1215 0 : switch( pCtrl->GetType() )
1216 : {
1217 : case WINDOW_MULTILINEEDIT:
1218 0 : aCtrlType = CTRL_MULTILINE_EDITBOX;
1219 0 : break;
1220 : case WINDOW_EDIT:
1221 : case WINDOW_PATTERNFIELD:
1222 : case WINDOW_METRICFIELD:
1223 : case WINDOW_CURRENCYFIELD:
1224 : case WINDOW_DATEFIELD:
1225 : case WINDOW_TIMEFIELD:
1226 : case WINDOW_LONGCURRENCYFIELD:
1227 : case WINDOW_NUMERICFIELD:
1228 : case WINDOW_SPINFIELD:
1229 : case WINDOW_CALCINPUTLINE:
1230 0 : if( pCtrl->GetStyle() & WB_SPIN )
1231 0 : aCtrlType = CTRL_SPINBOX;
1232 : else
1233 0 : aCtrlType = CTRL_EDITBOX;
1234 0 : break;
1235 :
1236 : case WINDOW_LISTBOX:
1237 : case WINDOW_MULTILISTBOX:
1238 : case WINDOW_TREELISTBOX:
1239 0 : aCtrlType = CTRL_LISTBOX;
1240 0 : if( pCtrl->GetStyle() & WB_DROPDOWN )
1241 0 : aCtrlPart = PART_ENTIRE_CONTROL;
1242 : else
1243 0 : aCtrlPart = PART_WINDOW;
1244 0 : break;
1245 :
1246 : case WINDOW_LISTBOXWINDOW:
1247 0 : aCtrlType = CTRL_LISTBOX;
1248 0 : aCtrlPart = PART_WINDOW;
1249 0 : break;
1250 :
1251 : case WINDOW_COMBOBOX:
1252 : case WINDOW_PATTERNBOX:
1253 : case WINDOW_NUMERICBOX:
1254 : case WINDOW_METRICBOX:
1255 : case WINDOW_CURRENCYBOX:
1256 : case WINDOW_DATEBOX:
1257 : case WINDOW_TIMEBOX:
1258 : case WINDOW_LONGCURRENCYBOX:
1259 0 : if( pCtrl->GetStyle() & WB_DROPDOWN )
1260 : {
1261 0 : aCtrlType = CTRL_COMBOBOX;
1262 0 : aCtrlPart = PART_ENTIRE_CONTROL;
1263 : }
1264 : else
1265 : {
1266 0 : aCtrlType = CTRL_LISTBOX;
1267 0 : aCtrlPart = PART_WINDOW;
1268 : }
1269 0 : break;
1270 :
1271 : default:
1272 0 : break;
1273 : }
1274 : }
1275 :
1276 0 : if ( aCtrlType && pCtrl->IsNativeControlSupported(aCtrlType, aCtrlPart) )
1277 : {
1278 0 : ImplControlValue aControlValue;
1279 0 : ControlState nState = CTRL_STATE_ENABLED;
1280 :
1281 0 : if ( !pWin->IsEnabled() )
1282 0 : nState &= ~CTRL_STATE_ENABLED;
1283 0 : if ( pWin->HasFocus() )
1284 0 : nState |= CTRL_STATE_FOCUSED;
1285 0 : else if( mbNWFBorder )
1286 : {
1287 : // FIXME: this is curently only on OS X, see if other platforms can profit
1288 :
1289 : // FIXME: for OS X focus rings all controls need to support GetNativeControlRegion
1290 : // for the dropdown style
1291 0 : if( pCtrl->HasFocus() || pCtrl->HasChildPathFocus() )
1292 0 : nState |= CTRL_STATE_FOCUSED;
1293 : }
1294 :
1295 0 : bool bMouseOver = false;
1296 0 : Window *pCtrlChild = pCtrl->GetWindow( WINDOW_FIRSTCHILD );
1297 0 : while( pCtrlChild && !(bMouseOver = pCtrlChild->IsMouseOver()) )
1298 0 : pCtrlChild = pCtrlChild->GetWindow( WINDOW_NEXT );
1299 :
1300 0 : if( bMouseOver )
1301 0 : nState |= CTRL_STATE_ROLLOVER;
1302 :
1303 0 : Point aPoint;
1304 0 : Rectangle aCtrlRegion( aPoint, Size( mnWidth, mnHeight ) );
1305 :
1306 0 : Rectangle aBoundingRgn( aPoint, Size( mnWidth, mnHeight ) );
1307 0 : Rectangle aContentRgn( aCtrlRegion );
1308 0 : if( ! ImplGetSVData()->maNWFData.mbCanDrawWidgetAnySize &&
1309 : pWin->GetNativeControlRegion( aCtrlType, aCtrlPart, aCtrlRegion,
1310 : nState, aControlValue, OUString(),
1311 0 : aBoundingRgn, aContentRgn ))
1312 : {
1313 0 : aCtrlRegion=aContentRgn;
1314 : }
1315 :
1316 : bNativeOK = pWin->DrawNativeControl( aCtrlType, aCtrlPart, aCtrlRegion, nState,
1317 0 : aControlValue, OUString() );
1318 :
1319 : // if the native theme draws the spinbuttons in one call, make sure the proper settings
1320 : // are passed, this might force a redraw though.... (TODO: improve)
1321 0 : if ( (aCtrlType == CTRL_SPINBOX) && !pCtrl->IsNativeControlSupported( CTRL_SPINBOX, PART_BUTTON_UP ) )
1322 : {
1323 0 : Edit *pEdit = ((Edit*) pCtrl)->GetSubEdit();
1324 0 : if ( pEdit )
1325 0 : pCtrl->Paint( Rectangle() ); // make sure the buttons are also drawn as they might overwrite the border
1326 0 : }
1327 : }
1328 :
1329 0 : if( bNativeOK )
1330 0 : return;
1331 :
1332 0 : if ( nDrawFlags & BORDERWINDOW_DRAW_FRAME )
1333 : {
1334 0 : sal_uInt16 nStyle = 0;
1335 : // move border outside if border was converted or if the border window is a frame window,
1336 0 : if ( mpBorderWindow->mbSmallOutBorder )
1337 0 : nStyle |= FRAME_DRAW_DOUBLEOUT;
1338 0 : else if ( nBorderStyle & WINDOW_BORDER_NWF )
1339 0 : nStyle |= FRAME_DRAW_NWF;
1340 : else
1341 0 : nStyle |= FRAME_DRAW_DOUBLEIN;
1342 0 : if ( nBorderStyle & WINDOW_BORDER_MONO )
1343 0 : nStyle |= FRAME_DRAW_MONO;
1344 0 : if ( nBorderStyle & WINDOW_BORDER_MENU )
1345 0 : nStyle |= FRAME_DRAW_MENU;
1346 : // tell DrawFrame that we're drawing a window border of a frame window to avoid round corners
1347 0 : if( pWin && pWin == pWin->ImplGetFrameWindow() )
1348 0 : nStyle |= FRAME_DRAW_WINDOWBORDER;
1349 :
1350 0 : DecorationView aDecoView( mpOutDev );
1351 0 : Point aTmpPoint;
1352 0 : Rectangle aInRect( aTmpPoint, Size( mnWidth, mnHeight ) );
1353 0 : aDecoView.DrawFrame( aInRect, nStyle );
1354 : }
1355 : }
1356 :
1357 : // - ImplStdBorderWindowView -
1358 :
1359 0 : ImplStdBorderWindowView::ImplStdBorderWindowView( ImplBorderWindow* pBorderWindow )
1360 : {
1361 0 : maFrameData.mpBorderWindow = pBorderWindow;
1362 0 : maFrameData.mbDragFull = false;
1363 0 : maFrameData.mnHitTest = 0;
1364 0 : maFrameData.mnPinState = 0;
1365 0 : maFrameData.mnCloseState = 0;
1366 0 : maFrameData.mnRollState = 0;
1367 0 : maFrameData.mnDockState = 0;
1368 0 : maFrameData.mnMenuState = 0;
1369 0 : maFrameData.mnHideState = 0;
1370 0 : maFrameData.mnHelpState = 0;
1371 0 : maFrameData.mbTitleClipped = false;
1372 :
1373 0 : mpATitleVirDev = NULL;
1374 0 : mpDTitleVirDev = NULL;
1375 0 : }
1376 :
1377 0 : ImplStdBorderWindowView::~ImplStdBorderWindowView()
1378 : {
1379 0 : delete mpATitleVirDev;
1380 0 : delete mpDTitleVirDev;
1381 0 : }
1382 :
1383 0 : bool ImplStdBorderWindowView::MouseMove( const MouseEvent& rMEvt )
1384 : {
1385 0 : return ImplMouseMove( &maFrameData, rMEvt );
1386 : }
1387 :
1388 0 : bool ImplStdBorderWindowView::MouseButtonDown( const MouseEvent& rMEvt )
1389 : {
1390 0 : return ImplMouseButtonDown( &maFrameData, rMEvt );
1391 : }
1392 :
1393 0 : bool ImplStdBorderWindowView::Tracking( const TrackingEvent& rTEvt )
1394 : {
1395 0 : return ImplTracking( &maFrameData, rTEvt );
1396 : }
1397 :
1398 0 : OUString ImplStdBorderWindowView::RequestHelp( const Point& rPos, Rectangle& rHelpRect )
1399 : {
1400 0 : return ImplRequestHelp( &maFrameData, rPos, rHelpRect );
1401 : }
1402 :
1403 0 : Rectangle ImplStdBorderWindowView::GetMenuRect() const
1404 : {
1405 0 : return maFrameData.maMenuRect;
1406 : }
1407 :
1408 0 : void ImplStdBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHeight )
1409 : {
1410 0 : ImplBorderFrameData* pData = &maFrameData;
1411 0 : ImplBorderWindow* pBorderWindow = maFrameData.mpBorderWindow;
1412 0 : const StyleSettings& rStyleSettings = pDev->GetSettings().GetStyleSettings();
1413 0 : DecorationView aDecoView( pDev );
1414 0 : Rectangle aRect( 0, 0, 10, 10 );
1415 0 : Rectangle aCalcRect = aDecoView.DrawFrame( aRect, FRAME_DRAW_DOUBLEOUT | FRAME_DRAW_NODRAW );
1416 :
1417 0 : pData->mpOutDev = pDev;
1418 0 : pData->mnWidth = nWidth;
1419 0 : pData->mnHeight = nHeight;
1420 :
1421 0 : pData->mnTitleType = pBorderWindow->mnTitleType;
1422 0 : pData->mbFloatWindow = pBorderWindow->mbFloatWindow;
1423 :
1424 0 : if ( !(pBorderWindow->GetStyle() & (WB_MOVEABLE | WB_POPUP)) || (pData->mnTitleType == BORDERWINDOW_TITLE_NONE) )
1425 0 : pData->mnBorderSize = 0;
1426 0 : else if ( pData->mnTitleType == BORDERWINDOW_TITLE_TEAROFF )
1427 0 : pData->mnBorderSize = 0;
1428 : else
1429 0 : pData->mnBorderSize = rStyleSettings.GetBorderSize();
1430 0 : pData->mnLeftBorder = aCalcRect.Left();
1431 0 : pData->mnTopBorder = aCalcRect.Top();
1432 0 : pData->mnRightBorder = aRect.Right()-aCalcRect.Right();
1433 0 : pData->mnBottomBorder = aRect.Bottom()-aCalcRect.Bottom();
1434 0 : pData->mnLeftBorder += pData->mnBorderSize;
1435 0 : pData->mnTopBorder += pData->mnBorderSize;
1436 0 : pData->mnRightBorder += pData->mnBorderSize;
1437 0 : pData->mnBottomBorder += pData->mnBorderSize;
1438 0 : pData->mnNoTitleTop = pData->mnTopBorder;
1439 :
1440 0 : ImplInitTitle( &maFrameData );
1441 0 : if ( pData->mnTitleHeight )
1442 : {
1443 : // to improve symbol display force a minum title height
1444 0 : if( pData->mnTitleHeight < MIN_CAPTION_HEIGHT )
1445 0 : pData->mnTitleHeight = MIN_CAPTION_HEIGHT;
1446 :
1447 : // set a proper background for drawing
1448 : // highlighted buttons in the title
1449 0 : pBorderWindow->SetBackground( rStyleSettings.GetFaceColor() );
1450 :
1451 0 : pData->maTitleRect.Left() = pData->mnLeftBorder;
1452 0 : pData->maTitleRect.Right() = nWidth-pData->mnRightBorder-1;
1453 0 : pData->maTitleRect.Top() = pData->mnTopBorder;
1454 0 : pData->maTitleRect.Bottom() = pData->maTitleRect.Top()+pData->mnTitleHeight-1;
1455 :
1456 0 : if ( pData->mnTitleType & (BORDERWINDOW_TITLE_NORMAL | BORDERWINDOW_TITLE_SMALL) )
1457 : {
1458 0 : long nLeft = pData->maTitleRect.Left();
1459 0 : long nRight = pData->maTitleRect.Right();
1460 0 : long nItemTop = pData->maTitleRect.Top();
1461 0 : long nItemBottom = pData->maTitleRect.Bottom();
1462 0 : nLeft += 1;
1463 0 : nRight -= 3;
1464 0 : nItemTop += 2;
1465 0 : nItemBottom -= 2;
1466 :
1467 0 : if ( pBorderWindow->GetStyle() & WB_PINABLE )
1468 : {
1469 0 : Image aImage;
1470 0 : ImplGetPinImage( 0, false, aImage );
1471 0 : pData->maPinRect.Top() = nItemTop;
1472 0 : pData->maPinRect.Bottom() = nItemBottom;
1473 0 : pData->maPinRect.Left() = nLeft;
1474 0 : pData->maPinRect.Right() = pData->maPinRect.Left()+aImage.GetSizePixel().Width();
1475 0 : nLeft += pData->maPinRect.GetWidth()+3;
1476 : }
1477 :
1478 0 : if ( pBorderWindow->GetStyle() & WB_CLOSEABLE )
1479 : {
1480 0 : pData->maCloseRect.Top() = nItemTop;
1481 0 : pData->maCloseRect.Bottom() = nItemBottom;
1482 0 : pData->maCloseRect.Right() = nRight;
1483 0 : pData->maCloseRect.Left() = pData->maCloseRect.Right()-pData->maCloseRect.GetHeight()+1;
1484 0 : nRight -= pData->maCloseRect.GetWidth()+3;
1485 : }
1486 :
1487 0 : if ( pBorderWindow->mbMenuBtn )
1488 : {
1489 0 : pData->maMenuRect.Top() = nItemTop;
1490 0 : pData->maMenuRect.Bottom() = nItemBottom;
1491 0 : pData->maMenuRect.Right() = nRight;
1492 0 : pData->maMenuRect.Left() = pData->maMenuRect.Right()-pData->maMenuRect.GetHeight()+1;
1493 0 : nRight -= pData->maMenuRect.GetWidth();
1494 : }
1495 :
1496 0 : if ( pBorderWindow->mbDockBtn )
1497 : {
1498 0 : pData->maDockRect.Top() = nItemTop;
1499 0 : pData->maDockRect.Bottom() = nItemBottom;
1500 0 : pData->maDockRect.Right() = nRight;
1501 0 : pData->maDockRect.Left() = pData->maDockRect.Right()-pData->maDockRect.GetHeight()+1;
1502 0 : nRight -= pData->maDockRect.GetWidth();
1503 0 : if ( !pBorderWindow->mbHideBtn &&
1504 0 : !(pBorderWindow->GetStyle() & WB_ROLLABLE) )
1505 0 : nRight -= 3;
1506 : }
1507 :
1508 0 : if ( pBorderWindow->mbHideBtn )
1509 : {
1510 0 : pData->maHideRect.Top() = nItemTop;
1511 0 : pData->maHideRect.Bottom() = nItemBottom;
1512 0 : pData->maHideRect.Right() = nRight;
1513 0 : pData->maHideRect.Left() = pData->maHideRect.Right()-pData->maHideRect.GetHeight()+1;
1514 0 : nRight -= pData->maHideRect.GetWidth();
1515 0 : if ( !(pBorderWindow->GetStyle() & WB_ROLLABLE) )
1516 0 : nRight -= 3;
1517 : }
1518 :
1519 0 : if ( pBorderWindow->GetStyle() & WB_ROLLABLE )
1520 : {
1521 0 : pData->maRollRect.Top() = nItemTop;
1522 0 : pData->maRollRect.Bottom() = nItemBottom;
1523 0 : pData->maRollRect.Right() = nRight;
1524 0 : pData->maRollRect.Left() = pData->maRollRect.Right()-pData->maRollRect.GetHeight()+1;
1525 0 : nRight -= pData->maRollRect.GetWidth();
1526 : }
1527 : }
1528 : else
1529 : {
1530 0 : pData->maPinRect.SetEmpty();
1531 0 : pData->maCloseRect.SetEmpty();
1532 0 : pData->maDockRect.SetEmpty();
1533 0 : pData->maMenuRect.SetEmpty();
1534 0 : pData->maHideRect.SetEmpty();
1535 0 : pData->maRollRect.SetEmpty();
1536 0 : pData->maHelpRect.SetEmpty();
1537 : }
1538 :
1539 0 : pData->mnTopBorder += pData->mnTitleHeight;
1540 : }
1541 : else
1542 : {
1543 0 : pData->maTitleRect.SetEmpty();
1544 0 : pData->maPinRect.SetEmpty();
1545 0 : pData->maCloseRect.SetEmpty();
1546 0 : pData->maDockRect.SetEmpty();
1547 0 : pData->maMenuRect.SetEmpty();
1548 0 : pData->maHideRect.SetEmpty();
1549 0 : pData->maRollRect.SetEmpty();
1550 0 : pData->maHelpRect.SetEmpty();
1551 : }
1552 0 : }
1553 :
1554 0 : void ImplStdBorderWindowView::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
1555 : sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
1556 : {
1557 0 : rLeftBorder = maFrameData.mnLeftBorder;
1558 0 : rTopBorder = maFrameData.mnTopBorder;
1559 0 : rRightBorder = maFrameData.mnRightBorder;
1560 0 : rBottomBorder = maFrameData.mnBottomBorder;
1561 0 : }
1562 :
1563 0 : long ImplStdBorderWindowView::CalcTitleWidth() const
1564 : {
1565 0 : return ImplCalcTitleWidth( &maFrameData );
1566 : }
1567 :
1568 0 : void ImplStdBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice* pOutDev, const Point* pOffset )
1569 : {
1570 0 : ImplBorderFrameData* pData = &maFrameData;
1571 0 : OutputDevice* pDev = pOutDev ? pOutDev : pData->mpOutDev;
1572 0 : ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
1573 0 : Point aTmpPoint = pOffset ? Point(*pOffset) : Point();
1574 0 : Rectangle aInRect( aTmpPoint, Size( pData->mnWidth, pData->mnHeight ) );
1575 0 : const StyleSettings& rStyleSettings = pData->mpOutDev->GetSettings().GetStyleSettings();
1576 0 : DecorationView aDecoView( pDev );
1577 0 : Color aFaceColor( rStyleSettings.GetFaceColor() );
1578 0 : Color aFrameColor( aFaceColor );
1579 :
1580 0 : aFrameColor.DecreaseContrast( (sal_uInt8) (0.50 * 255));
1581 :
1582 : // Draw Frame
1583 0 : if ( nDrawFlags & BORDERWINDOW_DRAW_FRAME )
1584 : {
1585 0 : Region oldClipRgn( pDev->GetClipRegion( ) );
1586 :
1587 : // for popups, don't draw part of the frame
1588 0 : if ( pData->mnTitleType == BORDERWINDOW_TITLE_POPUP )
1589 : {
1590 0 : FloatingWindow *pWin = dynamic_cast< FloatingWindow* >( pData->mpBorderWindow->GetWindow( WINDOW_CLIENT ) );
1591 0 : if ( pWin )
1592 : {
1593 0 : Region aClipRgn( aInRect );
1594 0 : Rectangle aItemClipRect( pWin->ImplGetItemEdgeClipRect() );
1595 0 : if( !aItemClipRect.IsEmpty() )
1596 : {
1597 0 : aItemClipRect.SetPos( pData->mpBorderWindow->AbsoluteScreenToOutputPixel( aItemClipRect.TopLeft() ) );
1598 0 : aClipRgn.Exclude( aItemClipRect );
1599 0 : pDev->SetClipRegion( aClipRgn );
1600 0 : }
1601 : }
1602 : }
1603 :
1604 : // single line frame
1605 0 : pDev->SetLineColor( aFrameColor );
1606 0 : pDev->SetFillColor();
1607 0 : pDev->DrawRect( aInRect );
1608 0 : ++aInRect.Left();
1609 0 : --aInRect.Right();
1610 0 : ++aInRect.Top();
1611 0 : --aInRect.Bottom();
1612 :
1613 : // restore
1614 0 : if ( pData->mnTitleType == BORDERWINDOW_TITLE_POPUP )
1615 0 : pDev->SetClipRegion( oldClipRgn );
1616 : }
1617 : else
1618 0 : aInRect = aDecoView.DrawFrame( aInRect, FRAME_DRAW_DOUBLEOUT | FRAME_DRAW_NODRAW);
1619 :
1620 : // Draw Border
1621 0 : pDev->SetLineColor();
1622 0 : long nBorderSize = pData->mnBorderSize;
1623 0 : if ( (nDrawFlags & BORDERWINDOW_DRAW_BORDER) && nBorderSize )
1624 : {
1625 0 : pDev->SetFillColor( rStyleSettings.GetFaceColor() );
1626 0 : pDev->DrawRect( Rectangle( Point( aInRect.Left(), aInRect.Top() ),
1627 0 : Size( aInRect.GetWidth(), nBorderSize ) ) );
1628 0 : pDev->DrawRect( Rectangle( Point( aInRect.Left(), aInRect.Top()+nBorderSize ),
1629 0 : Size( nBorderSize, aInRect.GetHeight()-nBorderSize ) ) );
1630 0 : pDev->DrawRect( Rectangle( Point( aInRect.Left(), aInRect.Bottom()-nBorderSize+1 ),
1631 0 : Size( aInRect.GetWidth(), nBorderSize ) ) );
1632 0 : pDev->DrawRect( Rectangle( Point( aInRect.Right()-nBorderSize+1, aInRect.Top()+nBorderSize ),
1633 0 : Size( nBorderSize, aInRect.GetHeight()-nBorderSize ) ) );
1634 : }
1635 :
1636 : // Draw Title
1637 0 : if ( (nDrawFlags & BORDERWINDOW_DRAW_TITLE) && !pData->maTitleRect.IsEmpty() )
1638 : {
1639 0 : aInRect = pData->maTitleRect;
1640 :
1641 : // use no gradient anymore, just a static titlecolor
1642 0 : if ( pData->mnTitleType != BORDERWINDOW_TITLE_POPUP )
1643 0 : pDev->SetFillColor( aFrameColor );
1644 : else
1645 0 : pDev->SetFillColor( aFaceColor );
1646 :
1647 0 : pDev->SetTextColor( rStyleSettings.GetButtonTextColor() );
1648 0 : Rectangle aTitleRect( pData->maTitleRect );
1649 0 : if( pOffset )
1650 0 : aTitleRect.Move( pOffset->X(), pOffset->Y() );
1651 0 : pDev->DrawRect( aTitleRect );
1652 :
1653 0 : if ( pData->mnTitleType != BORDERWINDOW_TITLE_TEAROFF )
1654 : {
1655 0 : aInRect.Left() += 2;
1656 0 : aInRect.Right() -= 2;
1657 :
1658 0 : if ( !pData->maPinRect.IsEmpty() )
1659 0 : aInRect.Left() = pData->maPinRect.Right()+2;
1660 :
1661 0 : if ( !pData->maHelpRect.IsEmpty() )
1662 0 : aInRect.Right() = pData->maHelpRect.Left()-2;
1663 0 : else if ( !pData->maRollRect.IsEmpty() )
1664 0 : aInRect.Right() = pData->maRollRect.Left()-2;
1665 0 : else if ( !pData->maHideRect.IsEmpty() )
1666 0 : aInRect.Right() = pData->maHideRect.Left()-2;
1667 0 : else if ( !pData->maDockRect.IsEmpty() )
1668 0 : aInRect.Right() = pData->maDockRect.Left()-2;
1669 0 : else if ( !pData->maMenuRect.IsEmpty() )
1670 0 : aInRect.Right() = pData->maMenuRect.Left()-2;
1671 0 : else if ( !pData->maCloseRect.IsEmpty() )
1672 0 : aInRect.Right() = pData->maCloseRect.Left()-2;
1673 :
1674 0 : if ( pOffset )
1675 0 : aInRect.Move( pOffset->X(), pOffset->Y() );
1676 :
1677 0 : sal_uInt16 nTextStyle = TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER | TEXT_DRAW_ENDELLIPSIS | TEXT_DRAW_CLIP;
1678 :
1679 : // must show tooltip ?
1680 0 : TextRectInfo aInfo;
1681 0 : pDev->GetTextRect( aInRect, pBorderWindow->GetText(), nTextStyle, &aInfo );
1682 0 : pData->mbTitleClipped = aInfo.IsEllipses();
1683 :
1684 0 : pDev->DrawText( aInRect, pBorderWindow->GetText(), nTextStyle );
1685 : }
1686 : }
1687 :
1688 0 : if ( ((nDrawFlags & BORDERWINDOW_DRAW_CLOSE) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
1689 0 : !pData->maCloseRect.IsEmpty() )
1690 : {
1691 0 : Rectangle aSymbolRect( pData->maCloseRect );
1692 0 : if ( pOffset )
1693 0 : aSymbolRect.Move( pOffset->X(), pOffset->Y() );
1694 0 : ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, SYMBOL_CLOSE, pData->mnCloseState );
1695 : }
1696 0 : if ( ((nDrawFlags & BORDERWINDOW_DRAW_DOCK) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
1697 0 : !pData->maDockRect.IsEmpty() )
1698 : {
1699 0 : Rectangle aSymbolRect( pData->maDockRect );
1700 0 : if ( pOffset )
1701 0 : aSymbolRect.Move( pOffset->X(), pOffset->Y() );
1702 0 : ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, SYMBOL_DOCK, pData->mnDockState );
1703 : }
1704 0 : if ( ((nDrawFlags & BORDERWINDOW_DRAW_MENU) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
1705 0 : !pData->maMenuRect.IsEmpty() )
1706 : {
1707 0 : Rectangle aSymbolRect( pData->maMenuRect );
1708 0 : if ( pOffset )
1709 0 : aSymbolRect.Move( pOffset->X(), pOffset->Y() );
1710 0 : ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, SYMBOL_MENU, pData->mnMenuState );
1711 : }
1712 0 : if ( ((nDrawFlags & BORDERWINDOW_DRAW_HIDE) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
1713 0 : !pData->maHideRect.IsEmpty() )
1714 : {
1715 0 : Rectangle aSymbolRect( pData->maHideRect );
1716 0 : if ( pOffset )
1717 0 : aSymbolRect.Move( pOffset->X(), pOffset->Y() );
1718 0 : ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, SYMBOL_HIDE, pData->mnHideState );
1719 : }
1720 0 : if ( ((nDrawFlags & BORDERWINDOW_DRAW_ROLL) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
1721 0 : !pData->maRollRect.IsEmpty() )
1722 : {
1723 : SymbolType eType;
1724 0 : if ( pBorderWindow->mbRollUp )
1725 0 : eType = SYMBOL_ROLLDOWN;
1726 : else
1727 0 : eType = SYMBOL_ROLLUP;
1728 0 : Rectangle aSymbolRect( pData->maRollRect );
1729 0 : if ( pOffset )
1730 0 : aSymbolRect.Move( pOffset->X(), pOffset->Y() );
1731 0 : ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, eType, pData->mnRollState );
1732 : }
1733 :
1734 0 : if ( ((nDrawFlags & BORDERWINDOW_DRAW_HELP) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
1735 0 : !pData->maHelpRect.IsEmpty() )
1736 : {
1737 0 : Rectangle aSymbolRect( pData->maHelpRect );
1738 0 : if ( pOffset )
1739 0 : aSymbolRect.Move( pOffset->X(), pOffset->Y() );
1740 0 : ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, SYMBOL_HELP, pData->mnHelpState );
1741 : }
1742 0 : if ( ((nDrawFlags & BORDERWINDOW_DRAW_PIN) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
1743 0 : !pData->maPinRect.IsEmpty() )
1744 : {
1745 0 : Image aImage;
1746 0 : ImplGetPinImage( pData->mnPinState, pBorderWindow->mbPinned, aImage );
1747 0 : Size aImageSize = aImage.GetSizePixel();
1748 0 : long nRectHeight = pData->maPinRect.GetHeight();
1749 0 : Point aPos( pData->maPinRect.TopLeft() );
1750 0 : if ( pOffset )
1751 0 : aPos.Move( pOffset->X(), pOffset->Y() );
1752 0 : if ( nRectHeight < aImageSize.Height() )
1753 : {
1754 0 : pDev->DrawImage( aPos, Size( aImageSize.Width(), nRectHeight ), aImage );
1755 : }
1756 : else
1757 : {
1758 0 : aPos.Y() += (nRectHeight-aImageSize.Height())/2;
1759 0 : pDev->DrawImage( aPos, aImage );
1760 0 : }
1761 : }
1762 0 : }
1763 :
1764 0 : void ImplBorderWindow::ImplInit( Window* pParent,
1765 : WinBits nStyle, sal_uInt16 nTypeStyle,
1766 : const ::com::sun::star::uno::Any& )
1767 : {
1768 0 : ImplInit( pParent, nStyle, nTypeStyle, NULL );
1769 0 : }
1770 :
1771 0 : void ImplBorderWindow::ImplInit( Window* pParent,
1772 : WinBits nStyle, sal_uInt16 nTypeStyle,
1773 : SystemParentData* pSystemParentData
1774 : )
1775 : {
1776 : // remove all unwanted WindowBits
1777 0 : WinBits nOrgStyle = nStyle;
1778 0 : WinBits nTestStyle = (WB_MOVEABLE | WB_SIZEABLE | WB_ROLLABLE | WB_PINABLE | WB_CLOSEABLE | WB_STANDALONE | WB_DIALOGCONTROL | WB_NODIALOGCONTROL | WB_SYSTEMFLOATWIN | WB_INTROWIN | WB_DEFAULTWIN | WB_TOOLTIPWIN | WB_NOSHADOW | WB_OWNERDRAWDECORATION | WB_SYSTEMCHILDWINDOW | WB_NEEDSFOCUS | WB_POPUP);
1779 0 : if ( nTypeStyle & BORDERWINDOW_STYLE_APP )
1780 0 : nTestStyle |= WB_APP;
1781 0 : nStyle &= nTestStyle;
1782 :
1783 0 : mpWindowImpl->mbBorderWin = true;
1784 0 : mbSmallOutBorder = false;
1785 0 : if ( nTypeStyle & BORDERWINDOW_STYLE_FRAME )
1786 : {
1787 0 : if( (nStyle & WB_SYSTEMCHILDWINDOW) )
1788 : {
1789 0 : mpWindowImpl->mbOverlapWin = true;
1790 0 : mpWindowImpl->mbFrame = true;
1791 0 : mbFrameBorder = false;
1792 : }
1793 0 : else if( (nStyle & (WB_OWNERDRAWDECORATION | WB_POPUP)) )
1794 : {
1795 0 : mpWindowImpl->mbOverlapWin = true;
1796 0 : mpWindowImpl->mbFrame = true;
1797 0 : mbFrameBorder = (nOrgStyle & WB_NOBORDER) ? false : true;
1798 : }
1799 : else
1800 : {
1801 0 : mpWindowImpl->mbOverlapWin = true;
1802 0 : mpWindowImpl->mbFrame = true;
1803 0 : mbFrameBorder = false;
1804 : // closeable windows may have a border as well, eg. system floating windows without caption
1805 0 : if ( (nOrgStyle & (WB_BORDER | WB_NOBORDER | WB_MOVEABLE | WB_SIZEABLE/* | WB_CLOSEABLE*/)) == WB_BORDER )
1806 0 : mbSmallOutBorder = true;
1807 : }
1808 : }
1809 0 : else if ( nTypeStyle & BORDERWINDOW_STYLE_OVERLAP )
1810 : {
1811 0 : mpWindowImpl->mbOverlapWin = true;
1812 0 : mbFrameBorder = true;
1813 : }
1814 : else
1815 0 : mbFrameBorder = false;
1816 :
1817 0 : if ( nTypeStyle & BORDERWINDOW_STYLE_FLOAT )
1818 0 : mbFloatWindow = true;
1819 : else
1820 0 : mbFloatWindow = false;
1821 :
1822 0 : Window::ImplInit( pParent, nStyle, pSystemParentData );
1823 0 : SetBackground();
1824 0 : SetTextFillColor();
1825 :
1826 0 : mpMenuBarWindow = NULL;
1827 0 : mnMinWidth = 0;
1828 0 : mnMinHeight = 0;
1829 0 : mnMaxWidth = SHRT_MAX;
1830 0 : mnMaxHeight = SHRT_MAX;
1831 0 : mnRollHeight = 0;
1832 0 : mnOrgMenuHeight = 0;
1833 0 : mbPinned = false;
1834 0 : mbRollUp = false;
1835 0 : mbMenuHide = false;
1836 0 : mbDockBtn = false;
1837 0 : mbMenuBtn = false;
1838 0 : mbHideBtn = false;
1839 0 : mbDisplayActive = IsActive();
1840 :
1841 0 : if ( nTypeStyle & BORDERWINDOW_STYLE_FLOAT )
1842 0 : mnTitleType = BORDERWINDOW_TITLE_SMALL;
1843 : else
1844 0 : mnTitleType = BORDERWINDOW_TITLE_NORMAL;
1845 0 : mnBorderStyle = WINDOW_BORDER_NORMAL;
1846 0 : InitView();
1847 0 : }
1848 :
1849 0 : ImplBorderWindow::ImplBorderWindow( Window* pParent,
1850 : SystemParentData* pSystemParentData,
1851 : WinBits nStyle, sal_uInt16 nTypeStyle
1852 0 : ) : Window( WINDOW_BORDERWINDOW )
1853 : {
1854 0 : ImplInit( pParent, nStyle, nTypeStyle, pSystemParentData );
1855 0 : }
1856 :
1857 0 : ImplBorderWindow::ImplBorderWindow( Window* pParent, WinBits nStyle ,
1858 : sal_uInt16 nTypeStyle ) :
1859 0 : Window( WINDOW_BORDERWINDOW )
1860 : {
1861 0 : ImplInit( pParent, nStyle, nTypeStyle, ::com::sun::star::uno::Any() );
1862 0 : }
1863 :
1864 0 : ImplBorderWindow::~ImplBorderWindow()
1865 : {
1866 0 : delete mpBorderView;
1867 0 : }
1868 :
1869 0 : void ImplBorderWindow::MouseMove( const MouseEvent& rMEvt )
1870 : {
1871 0 : mpBorderView->MouseMove( rMEvt );
1872 0 : }
1873 :
1874 0 : void ImplBorderWindow::MouseButtonDown( const MouseEvent& rMEvt )
1875 : {
1876 0 : mpBorderView->MouseButtonDown( rMEvt );
1877 0 : }
1878 :
1879 0 : void ImplBorderWindow::Tracking( const TrackingEvent& rTEvt )
1880 : {
1881 0 : mpBorderView->Tracking( rTEvt );
1882 0 : }
1883 :
1884 0 : void ImplBorderWindow::Paint( const Rectangle& )
1885 : {
1886 0 : mpBorderView->DrawWindow( BORDERWINDOW_DRAW_ALL );
1887 0 : }
1888 :
1889 0 : void ImplBorderWindow::Draw( const Rectangle&, OutputDevice* pOutDev, const Point& rPos )
1890 : {
1891 0 : mpBorderView->DrawWindow( BORDERWINDOW_DRAW_ALL, pOutDev, &rPos );
1892 0 : }
1893 :
1894 0 : void ImplBorderWindow::Activate()
1895 : {
1896 0 : SetDisplayActive( true );
1897 0 : Window::Activate();
1898 0 : }
1899 :
1900 0 : void ImplBorderWindow::Deactivate()
1901 : {
1902 : // remove active windows from the ruler, also ignore the Deactivate
1903 : // if a menu becomes active
1904 0 : if ( GetActivateMode() && !ImplGetSVData()->maWinData.mbNoDeactivate )
1905 0 : SetDisplayActive( false );
1906 0 : Window::Deactivate();
1907 0 : }
1908 :
1909 0 : void ImplBorderWindow::RequestHelp( const HelpEvent& rHEvt )
1910 : {
1911 : // no keyboard help for border window
1912 0 : if ( rHEvt.GetMode() & (HELPMODE_BALLOON | HELPMODE_QUICK) && !rHEvt.KeyboardActivated() )
1913 : {
1914 0 : Point aMousePosPixel = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
1915 0 : Rectangle aHelpRect;
1916 0 : OUString aHelpStr( mpBorderView->RequestHelp( aMousePosPixel, aHelpRect ) );
1917 :
1918 : // retrieve rectangle
1919 0 : if ( !aHelpStr.isEmpty() )
1920 : {
1921 0 : aHelpRect.SetPos( OutputToScreenPixel( aHelpRect.TopLeft() ) );
1922 0 : if ( rHEvt.GetMode() & HELPMODE_BALLOON )
1923 0 : Help::ShowBalloon( this, aHelpRect.Center(), aHelpRect, aHelpStr );
1924 : else
1925 0 : Help::ShowQuickHelp( this, aHelpRect, aHelpStr );
1926 0 : return;
1927 0 : }
1928 : }
1929 :
1930 0 : Window::RequestHelp( rHEvt );
1931 : }
1932 :
1933 0 : void ImplBorderWindow::Resize()
1934 : {
1935 0 : Size aSize = GetOutputSizePixel();
1936 :
1937 0 : if ( !mbRollUp )
1938 : {
1939 0 : Window* pClientWindow = ImplGetClientWindow();
1940 :
1941 0 : if ( mpMenuBarWindow )
1942 : {
1943 : sal_Int32 nLeftBorder;
1944 : sal_Int32 nTopBorder;
1945 : sal_Int32 nRightBorder;
1946 : sal_Int32 nBottomBorder;
1947 0 : long nMenuHeight = mpMenuBarWindow->GetSizePixel().Height();
1948 0 : if ( mbMenuHide )
1949 : {
1950 0 : if ( nMenuHeight )
1951 0 : mnOrgMenuHeight = nMenuHeight;
1952 0 : nMenuHeight = 0;
1953 : }
1954 : else
1955 : {
1956 0 : if ( !nMenuHeight )
1957 0 : nMenuHeight = mnOrgMenuHeight;
1958 : }
1959 0 : mpBorderView->GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder );
1960 : mpMenuBarWindow->setPosSizePixel( nLeftBorder,
1961 : nTopBorder,
1962 0 : aSize.Width()-nLeftBorder-nRightBorder,
1963 : nMenuHeight,
1964 : WINDOW_POSSIZE_POS |
1965 0 : WINDOW_POSSIZE_WIDTH | WINDOW_POSSIZE_HEIGHT );
1966 : }
1967 :
1968 : GetBorder( pClientWindow->mpWindowImpl->mnLeftBorder, pClientWindow->mpWindowImpl->mnTopBorder,
1969 0 : pClientWindow->mpWindowImpl->mnRightBorder, pClientWindow->mpWindowImpl->mnBottomBorder );
1970 : pClientWindow->ImplPosSizeWindow( pClientWindow->mpWindowImpl->mnLeftBorder,
1971 : pClientWindow->mpWindowImpl->mnTopBorder,
1972 0 : aSize.Width()-pClientWindow->mpWindowImpl->mnLeftBorder-pClientWindow->mpWindowImpl->mnRightBorder,
1973 0 : aSize.Height()-pClientWindow->mpWindowImpl->mnTopBorder-pClientWindow->mpWindowImpl->mnBottomBorder,
1974 : WINDOW_POSSIZE_X | WINDOW_POSSIZE_Y |
1975 0 : WINDOW_POSSIZE_WIDTH | WINDOW_POSSIZE_HEIGHT );
1976 : }
1977 :
1978 : // UpdateView
1979 0 : mpBorderView->Init( this, aSize.Width(), aSize.Height() );
1980 0 : InvalidateBorder();
1981 :
1982 0 : Window::Resize();
1983 0 : }
1984 :
1985 0 : void ImplBorderWindow::StateChanged( StateChangedType nType )
1986 : {
1987 0 : if ( (nType == STATE_CHANGE_TEXT) ||
1988 0 : (nType == STATE_CHANGE_IMAGE) ||
1989 : (nType == STATE_CHANGE_DATA) )
1990 : {
1991 0 : if ( IsReallyVisible() && mbFrameBorder )
1992 : {
1993 0 : if ( HasPaintEvent() )
1994 0 : InvalidateBorder();
1995 : else
1996 0 : mpBorderView->DrawWindow( BORDERWINDOW_DRAW_TITLE );
1997 : }
1998 : }
1999 :
2000 0 : Window::StateChanged( nType );
2001 0 : }
2002 :
2003 0 : void ImplBorderWindow::DataChanged( const DataChangedEvent& rDCEvt )
2004 : {
2005 0 : if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
2006 0 : (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
2007 0 : ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
2008 0 : (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
2009 : {
2010 0 : if ( !mpWindowImpl->mbFrame || (GetStyle() & (WB_OWNERDRAWDECORATION | WB_POPUP)) )
2011 0 : UpdateView( true, ImplGetWindow()->GetOutputSizePixel() );
2012 : }
2013 :
2014 0 : Window::DataChanged( rDCEvt );
2015 0 : }
2016 :
2017 0 : void ImplBorderWindow::InitView()
2018 : {
2019 0 : if ( mbSmallOutBorder )
2020 0 : mpBorderView = new ImplSmallBorderWindowView( this );
2021 0 : else if ( mpWindowImpl->mbFrame )
2022 : {
2023 0 : if( mbFrameBorder )
2024 0 : mpBorderView = new ImplStdBorderWindowView( this );
2025 : else
2026 0 : mpBorderView = new ImplNoBorderWindowView( this );
2027 : }
2028 0 : else if ( !mbFrameBorder )
2029 0 : mpBorderView = new ImplSmallBorderWindowView( this );
2030 : else
2031 0 : mpBorderView = new ImplStdBorderWindowView( this );
2032 0 : Size aSize = GetOutputSizePixel();
2033 0 : mpBorderView->Init( this, aSize.Width(), aSize.Height() );
2034 0 : }
2035 :
2036 0 : void ImplBorderWindow::UpdateView( bool bNewView, const Size& rNewOutSize )
2037 : {
2038 : sal_Int32 nLeftBorder;
2039 : sal_Int32 nTopBorder;
2040 : sal_Int32 nRightBorder;
2041 : sal_Int32 nBottomBorder;
2042 0 : Size aOldSize = GetSizePixel();
2043 0 : Size aOutputSize = rNewOutSize;
2044 :
2045 0 : if ( bNewView )
2046 : {
2047 0 : delete mpBorderView;
2048 0 : InitView();
2049 : }
2050 : else
2051 : {
2052 0 : Size aSize = aOutputSize;
2053 0 : mpBorderView->GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder );
2054 0 : aSize.Width() += nLeftBorder+nRightBorder;
2055 0 : aSize.Height() += nTopBorder+nBottomBorder;
2056 0 : mpBorderView->Init( this, aSize.Width(), aSize.Height() );
2057 : }
2058 :
2059 0 : Window* pClientWindow = ImplGetClientWindow();
2060 0 : if ( pClientWindow )
2061 : {
2062 : GetBorder( pClientWindow->mpWindowImpl->mnLeftBorder, pClientWindow->mpWindowImpl->mnTopBorder,
2063 0 : pClientWindow->mpWindowImpl->mnRightBorder, pClientWindow->mpWindowImpl->mnBottomBorder );
2064 : }
2065 0 : GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder );
2066 0 : if ( aOldSize.Width() || aOldSize.Height() )
2067 : {
2068 0 : aOutputSize.Width() += nLeftBorder+nRightBorder;
2069 0 : aOutputSize.Height() += nTopBorder+nBottomBorder;
2070 0 : if ( aOutputSize == GetSizePixel() )
2071 0 : InvalidateBorder();
2072 : else
2073 0 : SetSizePixel( aOutputSize );
2074 : }
2075 0 : }
2076 :
2077 0 : void ImplBorderWindow::InvalidateBorder()
2078 : {
2079 0 : if ( IsReallyVisible() )
2080 : {
2081 : // invalidate only if we have a border
2082 : sal_Int32 nLeftBorder;
2083 : sal_Int32 nTopBorder;
2084 : sal_Int32 nRightBorder;
2085 : sal_Int32 nBottomBorder;
2086 0 : mpBorderView->GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder );
2087 0 : if ( nLeftBorder || nTopBorder || nRightBorder || nBottomBorder )
2088 : {
2089 0 : Rectangle aWinRect( Point( 0, 0 ), GetOutputSizePixel() );
2090 0 : Region aRegion( aWinRect );
2091 0 : aWinRect.Left() += nLeftBorder;
2092 0 : aWinRect.Top() += nTopBorder;
2093 0 : aWinRect.Right() -= nRightBorder;
2094 0 : aWinRect.Bottom() -= nBottomBorder;
2095 : // no output area anymore, now invalidate all
2096 0 : if ( (aWinRect.Right() < aWinRect.Left()) ||
2097 0 : (aWinRect.Bottom() < aWinRect.Top()) )
2098 0 : Invalidate( INVALIDATE_NOCHILDREN );
2099 : else
2100 : {
2101 0 : aRegion.Exclude( aWinRect );
2102 0 : Invalidate( aRegion, INVALIDATE_NOCHILDREN );
2103 0 : }
2104 : }
2105 : }
2106 0 : }
2107 :
2108 0 : void ImplBorderWindow::SetDisplayActive( bool bActive )
2109 : {
2110 0 : if ( mbDisplayActive != bActive )
2111 : {
2112 0 : mbDisplayActive = bActive;
2113 0 : if ( mbFrameBorder )
2114 0 : InvalidateBorder();
2115 : }
2116 0 : }
2117 :
2118 0 : void ImplBorderWindow::SetTitleType( sal_uInt16 nTitleType, const Size& rSize )
2119 : {
2120 0 : mnTitleType = nTitleType;
2121 0 : UpdateView( false, rSize );
2122 0 : }
2123 :
2124 0 : void ImplBorderWindow::SetBorderStyle( sal_uInt16 nStyle )
2125 : {
2126 0 : if ( !mbFrameBorder && (mnBorderStyle != nStyle) )
2127 : {
2128 0 : mnBorderStyle = nStyle;
2129 0 : UpdateView( false, ImplGetWindow()->GetOutputSizePixel() );
2130 : }
2131 0 : }
2132 :
2133 0 : void ImplBorderWindow::SetPin( bool bPin )
2134 : {
2135 0 : mbPinned = bPin;
2136 0 : InvalidateBorder();
2137 0 : }
2138 :
2139 0 : void ImplBorderWindow::SetRollUp( bool bRollUp, const Size& rSize )
2140 : {
2141 0 : mbRollUp = bRollUp;
2142 0 : mnRollHeight = rSize.Height();
2143 0 : UpdateView( false, rSize );
2144 0 : }
2145 :
2146 0 : void ImplBorderWindow::SetCloser()
2147 : {
2148 0 : SetStyle( GetStyle() | WB_CLOSEABLE );
2149 0 : Size aSize = GetOutputSizePixel();
2150 0 : mpBorderView->Init( this, aSize.Width(), aSize.Height() );
2151 0 : InvalidateBorder();
2152 0 : }
2153 :
2154 0 : void ImplBorderWindow::SetDockButton( bool bDockButton )
2155 : {
2156 0 : mbDockBtn = bDockButton;
2157 0 : Size aSize = GetOutputSizePixel();
2158 0 : mpBorderView->Init( this, aSize.Width(), aSize.Height() );
2159 0 : InvalidateBorder();
2160 0 : }
2161 :
2162 0 : void ImplBorderWindow::SetHideButton( bool bHideButton )
2163 : {
2164 0 : mbHideBtn = bHideButton;
2165 0 : Size aSize = GetOutputSizePixel();
2166 0 : mpBorderView->Init( this, aSize.Width(), aSize.Height() );
2167 0 : InvalidateBorder();
2168 0 : }
2169 :
2170 0 : void ImplBorderWindow::SetMenuButton( bool bMenuButton )
2171 : {
2172 0 : mbMenuBtn = bMenuButton;
2173 0 : Size aSize = GetOutputSizePixel();
2174 0 : mpBorderView->Init( this, aSize.Width(), aSize.Height() );
2175 0 : InvalidateBorder();
2176 0 : }
2177 :
2178 0 : void ImplBorderWindow::UpdateMenuHeight()
2179 : {
2180 0 : Resize();
2181 0 : }
2182 :
2183 0 : void ImplBorderWindow::SetMenuBarWindow( Window* pWindow )
2184 : {
2185 0 : mpMenuBarWindow = pWindow;
2186 0 : UpdateMenuHeight();
2187 0 : if ( pWindow )
2188 0 : pWindow->Show();
2189 0 : }
2190 :
2191 0 : void ImplBorderWindow::SetMenuBarMode( bool bHide )
2192 : {
2193 0 : mbMenuHide = bHide;
2194 0 : UpdateMenuHeight();
2195 0 : }
2196 :
2197 0 : void ImplBorderWindow::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
2198 : sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
2199 : {
2200 0 : mpBorderView->GetBorder( rLeftBorder, rTopBorder, rRightBorder, rBottomBorder );
2201 0 : if ( mpMenuBarWindow && !mbMenuHide )
2202 0 : rTopBorder += mpMenuBarWindow->GetSizePixel().Height();
2203 0 : }
2204 :
2205 0 : long ImplBorderWindow::CalcTitleWidth() const
2206 : {
2207 0 : return mpBorderView->CalcTitleWidth();
2208 : }
2209 :
2210 0 : Rectangle ImplBorderWindow::GetMenuRect() const
2211 : {
2212 0 : return mpBorderView->GetMenuRect();
2213 : }
2214 :
2215 0 : Size ImplBorderWindow::GetOptimalSize() const
2216 : {
2217 0 : const Window* pClientWindow = ImplGetClientWindow();
2218 0 : if (pClientWindow)
2219 0 : return pClientWindow->GetOptimalSize();
2220 0 : return Size(mnMinWidth, mnMinHeight);
2221 : }
2222 :
2223 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|