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