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