merge the formfield patch from ooo-build
[ooovba.git] / vcl / source / window / brdwin.cxx
blobae223b577bfbb43756025898fefb6bd7f73a0922
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: brdwin.cxx,v $
10 * $Revision: 1.36 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
33 #ifndef _SV_SVIDS_HRC
34 #include <vcl/svids.hrc>
35 #endif
36 #include <vcl/svdata.hxx>
37 #include <vcl/event.hxx>
38 #include <vcl/decoview.hxx>
39 #include <vcl/syswin.hxx>
40 #include <vcl/dockwin.hxx>
41 #include <vcl/floatwin.hxx>
42 #include <vcl/bitmap.hxx>
43 #include <vcl/gradient.hxx>
44 #include <vcl/image.hxx>
45 #include <vcl/virdev.hxx>
46 #include <vcl/help.hxx>
47 #include <vcl/edit.hxx>
48 #include <vcl/brdwin.hxx>
49 #include <vcl/window.h>
50 #include <vcl/metric.hxx>
51 #include <tools/debug.hxx>
53 using namespace ::com::sun::star::uno;
55 // useful caption height for title bar buttons
56 #define MIN_CAPTION_HEIGHT 18
58 // =======================================================================
60 static void ImplGetPinImage( USHORT nStyle, BOOL bPinIn, Image& rImage )
62 // ImageListe laden, wenn noch nicht vorhanden
63 ImplSVData* pSVData = ImplGetSVData();
64 if ( !pSVData->maCtrlData.mpPinImgList )
66 ResMgr* pResMgr = ImplGetResMgr();
67 pSVData->maCtrlData.mpPinImgList = new ImageList();
68 if( pResMgr )
70 Color aMaskColor( 0x00, 0x00, 0xFF );
71 pSVData->maCtrlData.mpPinImgList->InsertFromHorizontalBitmap
72 ( ResId( SV_RESID_BITMAP_PIN, *pResMgr ), 4,
73 &aMaskColor, NULL, NULL, 0);
77 // Image ermitteln und zurueckgeben
78 USHORT nId;
79 if ( nStyle & BUTTON_DRAW_PRESSED )
81 if ( bPinIn )
82 nId = 4;
83 else
84 nId = 3;
86 else
88 if ( bPinIn )
89 nId = 2;
90 else
91 nId = 1;
93 rImage = pSVData->maCtrlData.mpPinImgList->GetImage( nId );
96 // -----------------------------------------------------------------------
98 void Window::ImplCalcSymbolRect( Rectangle& rRect )
100 // Den Rand den der Button in der nicht Default-Darstellung freilaesst,
101 // dazuaddieren, da wir diesen bei kleinen Buttons mit ausnutzen wollen
102 rRect.Left()--;
103 rRect.Top()--;
104 rRect.Right()++;
105 rRect.Bottom()++;
107 // Zwischen dem Symbol und dem Button-Rand lassen wir 5% Platz
108 long nExtraWidth = ((rRect.GetWidth()*50)+500)/1000;
109 long nExtraHeight = ((rRect.GetHeight()*50)+500)/1000;
110 rRect.Left() += nExtraWidth;
111 rRect.Right() -= nExtraWidth;
112 rRect.Top() += nExtraHeight;
113 rRect.Bottom() -= nExtraHeight;
116 // -----------------------------------------------------------------------
118 static void ImplDrawBrdWinSymbol( OutputDevice* pDev,
119 const Rectangle& rRect, SymbolType eSymbol )
121 // Zwischen dem Symbol und dem Button lassen wir 5% Platz
122 DecorationView aDecoView( pDev );
123 Rectangle aTempRect = rRect;
124 Window::ImplCalcSymbolRect( aTempRect );
125 aDecoView.DrawSymbol( aTempRect, eSymbol,
126 pDev->GetSettings().GetStyleSettings().GetButtonTextColor(), 0 );
129 // -----------------------------------------------------------------------
131 static void ImplDrawBrdWinSymbolButton( OutputDevice* pDev,
132 const Rectangle& rRect,
133 SymbolType eSymbol, USHORT nState )
135 BOOL bMouseOver = (nState & BUTTON_DRAW_HIGHLIGHT) != 0;
136 nState &= ~BUTTON_DRAW_HIGHLIGHT;
138 Rectangle aTempRect;
139 Window *pWin = dynamic_cast< Window* >(pDev);
140 if( pWin )
142 if( bMouseOver )
144 // provide a bright background for selection effect
145 pWin->SetFillColor( pDev->GetSettings().GetStyleSettings().GetWindowColor() );
146 pWin->SetLineColor();
147 pWin->DrawRect( rRect );
148 pWin->DrawSelectionBackground( rRect, 2, (nState & BUTTON_DRAW_PRESSED) ? TRUE : FALSE,
149 TRUE, FALSE );
151 aTempRect = rRect;
152 aTempRect.nLeft+=3;
153 aTempRect.nRight-=4;
154 aTempRect.nTop+=3;
155 aTempRect.nBottom-=4;
157 else
159 DecorationView aDecoView( pDev );
160 aTempRect = aDecoView.DrawButton( rRect, nState|BUTTON_DRAW_FLAT );
162 ImplDrawBrdWinSymbol( pDev, aTempRect, eSymbol );
166 // =======================================================================
168 // ------------------------
169 // - ImplBorderWindowView -
170 // ------------------------
172 ImplBorderWindowView::~ImplBorderWindowView()
176 // -----------------------------------------------------------------------
178 BOOL ImplBorderWindowView::MouseMove( const MouseEvent& )
180 return FALSE;
183 // -----------------------------------------------------------------------
185 BOOL ImplBorderWindowView::MouseButtonDown( const MouseEvent& )
187 return FALSE;
190 // -----------------------------------------------------------------------
192 BOOL ImplBorderWindowView::Tracking( const TrackingEvent& )
194 return FALSE;
197 // -----------------------------------------------------------------------
199 String ImplBorderWindowView::RequestHelp( const Point&, Rectangle& )
201 return String();
204 // -----------------------------------------------------------------------
206 Rectangle ImplBorderWindowView::GetMenuRect() const
208 return Rectangle();
211 // -----------------------------------------------------------------------
213 void ImplBorderWindowView::ImplInitTitle( ImplBorderFrameData* pData )
215 ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
217 if ( !(pBorderWindow->GetStyle() & WB_MOVEABLE) ||
218 (pData->mnTitleType == BORDERWINDOW_TITLE_NONE) )
220 pData->mnTitleType = BORDERWINDOW_TITLE_NONE;
221 pData->mnTitleHeight = 0;
223 else
225 const StyleSettings& rStyleSettings = pData->mpOutDev->GetSettings().GetStyleSettings();
226 if ( pData->mnTitleType == BORDERWINDOW_TITLE_TEAROFF )
227 pData->mnTitleHeight = rStyleSettings.GetTearOffTitleHeight();
228 else
230 if ( pData->mnTitleType == BORDERWINDOW_TITLE_SMALL )
232 pBorderWindow->SetPointFont( rStyleSettings.GetFloatTitleFont() );
233 pData->mnTitleHeight = rStyleSettings.GetFloatTitleHeight();
235 else // pData->mnTitleType == BORDERWINDOW_TITLE_NORMAL
237 pBorderWindow->SetPointFont( rStyleSettings.GetTitleFont() );
238 pData->mnTitleHeight = rStyleSettings.GetTitleHeight();
240 long nTextHeight = pBorderWindow->GetTextHeight();
241 if ( nTextHeight > pData->mnTitleHeight )
242 pData->mnTitleHeight = nTextHeight;
247 // -----------------------------------------------------------------------
249 USHORT ImplBorderWindowView::ImplHitTest( ImplBorderFrameData* pData, const Point& rPos )
251 ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
253 if ( pData->maTitleRect.IsInside( rPos ) )
255 if ( pData->maCloseRect.IsInside( rPos ) )
256 return BORDERWINDOW_HITTEST_CLOSE;
257 else if ( pData->maRollRect.IsInside( rPos ) )
258 return BORDERWINDOW_HITTEST_ROLL;
259 else if ( pData->maMenuRect.IsInside( rPos ) )
260 return BORDERWINDOW_HITTEST_MENU;
261 else if ( pData->maDockRect.IsInside( rPos ) )
262 return BORDERWINDOW_HITTEST_DOCK;
263 else if ( pData->maHideRect.IsInside( rPos ) )
264 return BORDERWINDOW_HITTEST_HIDE;
265 else if ( pData->maHelpRect.IsInside( rPos ) )
266 return BORDERWINDOW_HITTEST_HELP;
267 else if ( pData->maPinRect.IsInside( rPos ) )
268 return BORDERWINDOW_HITTEST_PIN;
269 else
270 return BORDERWINDOW_HITTEST_TITLE;
273 if ( (pBorderWindow->GetStyle() & WB_SIZEABLE) &&
274 !pBorderWindow->mbRollUp )
276 long nSizeWidth = pData->mnNoTitleTop+pData->mnTitleHeight;
277 if ( nSizeWidth < 16 )
278 nSizeWidth = 16;
280 // no corner resize for floating toolbars, which would lead to jumps while formatting
281 // setting nSizeWidth = 0 will only return pure left,top,right,bottom
282 if( pBorderWindow->GetStyle() & WB_OWNERDRAWDECORATION )
283 nSizeWidth = 0;
285 if ( rPos.X() < pData->mnLeftBorder )
287 if ( rPos.Y() < nSizeWidth )
288 return BORDERWINDOW_HITTEST_TOPLEFT;
289 else if ( rPos.Y() >= pData->mnHeight-nSizeWidth )
290 return BORDERWINDOW_HITTEST_BOTTOMLEFT;
291 else
292 return BORDERWINDOW_HITTEST_LEFT;
294 else if ( rPos.X() >= pData->mnWidth-pData->mnRightBorder )
296 if ( rPos.Y() < nSizeWidth )
297 return BORDERWINDOW_HITTEST_TOPRIGHT;
298 else if ( rPos.Y() >= pData->mnHeight-nSizeWidth )
299 return BORDERWINDOW_HITTEST_BOTTOMRIGHT;
300 else
301 return BORDERWINDOW_HITTEST_RIGHT;
303 else if ( rPos.Y() < pData->mnNoTitleTop )
305 if ( rPos.X() < nSizeWidth )
306 return BORDERWINDOW_HITTEST_TOPLEFT;
307 else if ( rPos.X() >= pData->mnWidth-nSizeWidth )
308 return BORDERWINDOW_HITTEST_TOPRIGHT;
309 else
310 return BORDERWINDOW_HITTEST_TOP;
312 else if ( rPos.Y() >= pData->mnHeight-pData->mnBottomBorder )
314 if ( rPos.X() < nSizeWidth )
315 return BORDERWINDOW_HITTEST_BOTTOMLEFT;
316 else if ( rPos.X() >= pData->mnWidth-nSizeWidth )
317 return BORDERWINDOW_HITTEST_BOTTOMRIGHT;
318 else
319 return BORDERWINDOW_HITTEST_BOTTOM;
323 return 0;
326 // -----------------------------------------------------------------------
328 BOOL ImplBorderWindowView::ImplMouseMove( ImplBorderFrameData* pData, const MouseEvent& rMEvt )
330 USHORT oldCloseState = pData->mnCloseState;
331 USHORT oldMenuState = pData->mnMenuState;
332 pData->mnCloseState &= ~BUTTON_DRAW_HIGHLIGHT;
333 pData->mnMenuState &= ~BUTTON_DRAW_HIGHLIGHT;
335 Point aMousePos = rMEvt.GetPosPixel();
336 USHORT nHitTest = ImplHitTest( pData, aMousePos );
337 PointerStyle ePtrStyle = POINTER_ARROW;
338 if ( nHitTest & BORDERWINDOW_HITTEST_LEFT )
339 ePtrStyle = POINTER_WINDOW_WSIZE;
340 else if ( nHitTest & BORDERWINDOW_HITTEST_RIGHT )
341 ePtrStyle = POINTER_WINDOW_ESIZE;
342 else if ( nHitTest & BORDERWINDOW_HITTEST_TOP )
343 ePtrStyle = POINTER_WINDOW_NSIZE;
344 else if ( nHitTest & BORDERWINDOW_HITTEST_BOTTOM )
345 ePtrStyle = POINTER_WINDOW_SSIZE;
346 else if ( nHitTest & BORDERWINDOW_HITTEST_TOPLEFT )
347 ePtrStyle = POINTER_WINDOW_NWSIZE;
348 else if ( nHitTest & BORDERWINDOW_HITTEST_BOTTOMRIGHT )
349 ePtrStyle = POINTER_WINDOW_SESIZE;
350 else if ( nHitTest & BORDERWINDOW_HITTEST_TOPRIGHT )
351 ePtrStyle = POINTER_WINDOW_NESIZE;
352 else if ( nHitTest & BORDERWINDOW_HITTEST_BOTTOMLEFT )
353 ePtrStyle = POINTER_WINDOW_SWSIZE;
354 else if ( nHitTest & BORDERWINDOW_HITTEST_CLOSE )
355 pData->mnCloseState |= BUTTON_DRAW_HIGHLIGHT;
356 else if ( nHitTest & BORDERWINDOW_HITTEST_MENU )
357 pData->mnMenuState |= BUTTON_DRAW_HIGHLIGHT;
358 pData->mpBorderWindow->SetPointer( Pointer( ePtrStyle ) );
360 if( pData->mnCloseState != oldCloseState )
361 pData->mpBorderWindow->Invalidate( pData->maCloseRect );
362 if( pData->mnMenuState != oldMenuState )
363 pData->mpBorderWindow->Invalidate( pData->maMenuRect );
365 return TRUE;
368 // -----------------------------------------------------------------------
370 BOOL ImplBorderWindowView::ImplMouseButtonDown( ImplBorderFrameData* pData, const MouseEvent& rMEvt )
372 ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
374 if ( rMEvt.IsLeft() || rMEvt.IsRight() )
376 pData->maMouseOff = rMEvt.GetPosPixel();
377 pData->mnHitTest = ImplHitTest( pData, pData->maMouseOff );
378 USHORT nDragFullTest = 0;
379 if ( pData->mnHitTest )
381 BOOL bTracking = TRUE;
382 BOOL bHitTest = TRUE;
384 if ( pData->mnHitTest & BORDERWINDOW_HITTEST_CLOSE )
386 pData->mnCloseState |= BUTTON_DRAW_PRESSED;
387 DrawWindow( BORDERWINDOW_DRAW_CLOSE );
389 else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_ROLL )
391 pData->mnRollState |= BUTTON_DRAW_PRESSED;
392 DrawWindow( BORDERWINDOW_DRAW_ROLL );
394 else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_DOCK )
396 pData->mnDockState |= BUTTON_DRAW_PRESSED;
397 DrawWindow( BORDERWINDOW_DRAW_DOCK );
399 else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_MENU )
401 pData->mnMenuState |= BUTTON_DRAW_PRESSED;
402 DrawWindow( BORDERWINDOW_DRAW_MENU );
404 // call handler already on mouse down
405 if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
407 SystemWindow* pClientWindow = (SystemWindow*)(pBorderWindow->ImplGetClientWindow());
408 pClientWindow->TitleButtonClick( TITLE_BUTTON_MENU );
411 else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_HIDE )
413 pData->mnHideState |= BUTTON_DRAW_PRESSED;
414 DrawWindow( BORDERWINDOW_DRAW_HIDE );
416 else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_HELP )
418 pData->mnHelpState |= BUTTON_DRAW_PRESSED;
419 DrawWindow( BORDERWINDOW_DRAW_HELP );
421 else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_PIN )
423 pData->mnPinState |= BUTTON_DRAW_PRESSED;
424 DrawWindow( BORDERWINDOW_DRAW_PIN );
426 else
428 if ( rMEvt.GetClicks() == 1 )
430 if ( bTracking )
432 Point aPos = pBorderWindow->GetPosPixel();
433 Size aSize = pBorderWindow->GetOutputSizePixel();
434 pData->mnTrackX = aPos.X();
435 pData->mnTrackY = aPos.Y();
436 pData->mnTrackWidth = aSize.Width();
437 pData->mnTrackHeight = aSize.Height();
439 if ( pData->mnHitTest & BORDERWINDOW_HITTEST_TITLE )
440 nDragFullTest = DRAGFULL_OPTION_WINDOWMOVE;
441 else
442 nDragFullTest = DRAGFULL_OPTION_WINDOWSIZE;
445 else
447 bTracking = FALSE;
449 if ( (pData->mnHitTest & BORDERWINDOW_DRAW_TITLE) &&
450 ((rMEvt.GetClicks() % 2) == 0) )
452 pData->mnHitTest = 0;
453 bHitTest = FALSE;
455 if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
457 SystemWindow* pClientWindow = (SystemWindow*)(pBorderWindow->ImplGetClientWindow());
458 if ( TRUE /*pBorderWindow->mbDockBtn*/ ) // always perform docking on double click, no button required
459 pClientWindow->TitleButtonClick( TITLE_BUTTON_DOCKING );
460 else if ( pBorderWindow->GetStyle() & WB_ROLLABLE )
462 if ( pClientWindow->IsRollUp() )
463 pClientWindow->RollDown();
464 else
465 pClientWindow->RollUp();
466 pClientWindow->Roll();
473 if ( bTracking )
475 pData->mbDragFull = FALSE;
476 if ( nDragFullTest )
477 pData->mbDragFull = TRUE; // always fulldrag for proper docking, ignore system settings
478 pBorderWindow->StartTracking();
480 else if ( bHitTest )
481 pData->mnHitTest = 0;
485 return TRUE;
488 // -----------------------------------------------------------------------
490 BOOL ImplBorderWindowView::ImplTracking( ImplBorderFrameData* pData, const TrackingEvent& rTEvt )
492 ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
494 if ( rTEvt.IsTrackingEnded() )
496 USHORT nHitTest = pData->mnHitTest;
497 pData->mnHitTest = 0;
499 if ( nHitTest & BORDERWINDOW_HITTEST_CLOSE )
501 if ( pData->mnCloseState & BUTTON_DRAW_PRESSED )
503 pData->mnCloseState &= ~BUTTON_DRAW_PRESSED;
504 DrawWindow( BORDERWINDOW_DRAW_CLOSE );
506 // Bei Abbruch kein Click-Handler rufen
507 if ( !rTEvt.IsTrackingCanceled() )
509 // dispatch to correct window type (why is Close() not virtual ??? )
510 // TODO: make Close() virtual
511 Window *pWin = pBorderWindow->ImplGetClientWindow()->ImplGetWindow();
512 SystemWindow *pSysWin = dynamic_cast<SystemWindow* >(pWin);
513 DockingWindow *pDockWin = dynamic_cast<DockingWindow*>(pWin);
514 if ( pSysWin )
515 pSysWin->Close();
516 else if ( pDockWin )
517 pDockWin->Close();
521 else if ( nHitTest & BORDERWINDOW_HITTEST_ROLL )
523 if ( pData->mnRollState & BUTTON_DRAW_PRESSED )
525 pData->mnRollState &= ~BUTTON_DRAW_PRESSED;
526 DrawWindow( BORDERWINDOW_DRAW_ROLL );
528 // Bei Abbruch kein Click-Handler rufen
529 if ( !rTEvt.IsTrackingCanceled() )
531 if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
533 SystemWindow* pClientWindow = (SystemWindow*)(pBorderWindow->ImplGetClientWindow());
534 if ( pClientWindow->IsRollUp() )
535 pClientWindow->RollDown();
536 else
537 pClientWindow->RollUp();
538 pClientWindow->Roll();
543 else if ( nHitTest & BORDERWINDOW_HITTEST_DOCK )
545 if ( pData->mnDockState & BUTTON_DRAW_PRESSED )
547 pData->mnDockState &= ~BUTTON_DRAW_PRESSED;
548 DrawWindow( BORDERWINDOW_DRAW_DOCK );
550 // Bei Abbruch kein Click-Handler rufen
551 if ( !rTEvt.IsTrackingCanceled() )
553 if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
555 SystemWindow* pClientWindow = (SystemWindow*)(pBorderWindow->ImplGetClientWindow());
556 pClientWindow->TitleButtonClick( TITLE_BUTTON_DOCKING );
561 else if ( nHitTest & BORDERWINDOW_HITTEST_MENU )
563 if ( pData->mnMenuState & BUTTON_DRAW_PRESSED )
565 pData->mnMenuState &= ~BUTTON_DRAW_PRESSED;
566 DrawWindow( BORDERWINDOW_DRAW_MENU );
568 // handler already called on mouse down
571 else if ( nHitTest & BORDERWINDOW_HITTEST_HIDE )
573 if ( pData->mnHideState & BUTTON_DRAW_PRESSED )
575 pData->mnHideState &= ~BUTTON_DRAW_PRESSED;
576 DrawWindow( BORDERWINDOW_DRAW_HIDE );
578 // Bei Abbruch kein Click-Handler rufen
579 if ( !rTEvt.IsTrackingCanceled() )
581 if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
583 SystemWindow* pClientWindow = (SystemWindow*)(pBorderWindow->ImplGetClientWindow());
584 pClientWindow->TitleButtonClick( TITLE_BUTTON_HIDE );
589 else if ( nHitTest & BORDERWINDOW_HITTEST_HELP )
591 if ( pData->mnHelpState & BUTTON_DRAW_PRESSED )
593 pData->mnHelpState &= ~BUTTON_DRAW_PRESSED;
594 DrawWindow( BORDERWINDOW_DRAW_HELP );
596 // Bei Abbruch kein Click-Handler rufen
597 if ( !rTEvt.IsTrackingCanceled() )
602 else if ( nHitTest & BORDERWINDOW_HITTEST_PIN )
604 if ( pData->mnPinState & BUTTON_DRAW_PRESSED )
606 pData->mnPinState &= ~BUTTON_DRAW_PRESSED;
607 DrawWindow( BORDERWINDOW_DRAW_PIN );
609 // Bei Abbruch kein Click-Handler rufen
610 if ( !rTEvt.IsTrackingCanceled() )
612 if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
614 SystemWindow* pClientWindow = (SystemWindow*)(pBorderWindow->ImplGetClientWindow());
615 pClientWindow->SetPin( !pClientWindow->IsPined() );
616 pClientWindow->Pin();
621 else
623 if ( pData->mbDragFull )
625 // Bei Abbruch alten Zustand wieder herstellen
626 if ( rTEvt.IsTrackingCanceled() )
627 pBorderWindow->SetPosSizePixel( Point( pData->mnTrackX, pData->mnTrackY ), Size( pData->mnTrackWidth, pData->mnTrackHeight ) );
629 else
631 pBorderWindow->HideTracking();
632 if ( !rTEvt.IsTrackingCanceled() )
633 pBorderWindow->SetPosSizePixel( Point( pData->mnTrackX, pData->mnTrackY ), Size( pData->mnTrackWidth, pData->mnTrackHeight ) );
636 if ( !rTEvt.IsTrackingCanceled() )
638 if ( pBorderWindow->ImplGetClientWindow()->ImplIsFloatingWindow() )
640 if ( ((FloatingWindow*)pBorderWindow->ImplGetClientWindow())->IsInPopupMode() )
641 ((FloatingWindow*)pBorderWindow->ImplGetClientWindow())->EndPopupMode( FLOATWIN_POPUPMODEEND_TEAROFF );
646 else if ( !rTEvt.GetMouseEvent().IsSynthetic() )
648 Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
650 if ( pData->mnHitTest & BORDERWINDOW_HITTEST_CLOSE )
652 if ( pData->maCloseRect.IsInside( aMousePos ) )
654 if ( !(pData->mnCloseState & BUTTON_DRAW_PRESSED) )
656 pData->mnCloseState |= BUTTON_DRAW_PRESSED;
657 DrawWindow( BORDERWINDOW_DRAW_CLOSE );
660 else
662 if ( pData->mnCloseState & BUTTON_DRAW_PRESSED )
664 pData->mnCloseState &= ~BUTTON_DRAW_PRESSED;
665 DrawWindow( BORDERWINDOW_DRAW_CLOSE );
669 else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_ROLL )
671 if ( pData->maRollRect.IsInside( aMousePos ) )
673 if ( !(pData->mnRollState & BUTTON_DRAW_PRESSED) )
675 pData->mnRollState |= BUTTON_DRAW_PRESSED;
676 DrawWindow( BORDERWINDOW_DRAW_ROLL );
679 else
681 if ( pData->mnRollState & BUTTON_DRAW_PRESSED )
683 pData->mnRollState &= ~BUTTON_DRAW_PRESSED;
684 DrawWindow( BORDERWINDOW_DRAW_ROLL );
688 else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_DOCK )
690 if ( pData->maDockRect.IsInside( aMousePos ) )
692 if ( !(pData->mnDockState & BUTTON_DRAW_PRESSED) )
694 pData->mnDockState |= BUTTON_DRAW_PRESSED;
695 DrawWindow( BORDERWINDOW_DRAW_DOCK );
698 else
700 if ( pData->mnDockState & BUTTON_DRAW_PRESSED )
702 pData->mnDockState &= ~BUTTON_DRAW_PRESSED;
703 DrawWindow( BORDERWINDOW_DRAW_DOCK );
707 else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_MENU )
709 if ( pData->maMenuRect.IsInside( aMousePos ) )
711 if ( !(pData->mnMenuState & BUTTON_DRAW_PRESSED) )
713 pData->mnMenuState |= BUTTON_DRAW_PRESSED;
714 DrawWindow( BORDERWINDOW_DRAW_MENU );
718 else
720 if ( pData->mnMenuState & BUTTON_DRAW_PRESSED )
722 pData->mnMenuState &= ~BUTTON_DRAW_PRESSED;
723 DrawWindow( BORDERWINDOW_DRAW_MENU );
727 else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_HIDE )
729 if ( pData->maHideRect.IsInside( aMousePos ) )
731 if ( !(pData->mnHideState & BUTTON_DRAW_PRESSED) )
733 pData->mnHideState |= BUTTON_DRAW_PRESSED;
734 DrawWindow( BORDERWINDOW_DRAW_HIDE );
737 else
739 if ( pData->mnHideState & BUTTON_DRAW_PRESSED )
741 pData->mnHideState &= ~BUTTON_DRAW_PRESSED;
742 DrawWindow( BORDERWINDOW_DRAW_HIDE );
746 else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_HELP )
748 if ( pData->maHelpRect.IsInside( aMousePos ) )
750 if ( !(pData->mnHelpState & BUTTON_DRAW_PRESSED) )
752 pData->mnHelpState |= BUTTON_DRAW_PRESSED;
753 DrawWindow( BORDERWINDOW_DRAW_HELP );
756 else
758 if ( pData->mnHelpState & BUTTON_DRAW_PRESSED )
760 pData->mnHelpState &= ~BUTTON_DRAW_PRESSED;
761 DrawWindow( BORDERWINDOW_DRAW_HELP );
765 else if ( pData->mnHitTest & BORDERWINDOW_HITTEST_PIN )
767 if ( pData->maPinRect.IsInside( aMousePos ) )
769 if ( !(pData->mnPinState & BUTTON_DRAW_PRESSED) )
771 pData->mnPinState |= BUTTON_DRAW_PRESSED;
772 DrawWindow( BORDERWINDOW_DRAW_PIN );
775 else
777 if ( pData->mnPinState & BUTTON_DRAW_PRESSED )
779 pData->mnPinState &= ~BUTTON_DRAW_PRESSED;
780 DrawWindow( BORDERWINDOW_DRAW_PIN );
784 else
787 // adjusting mousepos not required, we allow the whole screen (no desktop anymore...)
788 Point aFrameMousePos = pBorderWindow->ImplOutputToFrame( aMousePos );
789 Size aFrameSize = pBorderWindow->ImplGetFrameWindow()->GetOutputSizePixel();
790 if ( aFrameMousePos.X() < 0 )
791 aFrameMousePos.X() = 0;
792 if ( aFrameMousePos.Y() < 0 )
793 aFrameMousePos.Y() = 0;
794 if ( aFrameMousePos.X() > aFrameSize.Width()-1 )
795 aFrameMousePos.X() = aFrameSize.Width()-1;
796 if ( aFrameMousePos.Y() > aFrameSize.Height()-1 )
797 aFrameMousePos.Y() = aFrameSize.Height()-1;
798 aMousePos = pBorderWindow->ImplFrameToOutput( aFrameMousePos );
801 aMousePos.X() -= pData->maMouseOff.X();
802 aMousePos.Y() -= pData->maMouseOff.Y();
804 if ( pData->mnHitTest & BORDERWINDOW_HITTEST_TITLE )
806 pData->mpBorderWindow->SetPointer( Pointer( POINTER_MOVE ) );
808 Point aPos = pBorderWindow->GetPosPixel();
809 aPos.X() += aMousePos.X();
810 aPos.Y() += aMousePos.Y();
811 if ( pData->mbDragFull )
813 pBorderWindow->SetPosPixel( aPos );
814 pBorderWindow->ImplUpdateAll();
815 pBorderWindow->ImplGetFrameWindow()->ImplUpdateAll();
817 else
819 pData->mnTrackX = aPos.X();
820 pData->mnTrackY = aPos.Y();
821 pBorderWindow->ShowTracking( Rectangle( pBorderWindow->ScreenToOutputPixel( aPos ), pBorderWindow->GetOutputSizePixel() ), SHOWTRACK_BIG );
824 else
826 Point aOldPos = pBorderWindow->GetPosPixel();
827 Size aSize = pBorderWindow->GetSizePixel();
828 Rectangle aNewRect( aOldPos, aSize );
829 long nOldWidth = aSize.Width();
830 long nOldHeight = aSize.Height();
831 long nBorderWidth = pData->mnLeftBorder+pData->mnRightBorder;
832 long nBorderHeight = pData->mnTopBorder+pData->mnBottomBorder;
833 long nMinWidth = pBorderWindow->mnMinWidth+nBorderWidth;
834 long nMinHeight = pBorderWindow->mnMinHeight+nBorderHeight;
835 long nMinWidth2 = nBorderWidth;
836 long nMaxWidth = pBorderWindow->mnMaxWidth+nBorderWidth;
837 long nMaxHeight = pBorderWindow->mnMaxHeight+nBorderHeight;
839 if ( pData->mnTitleHeight )
841 nMinWidth2 += 4;
843 if ( pBorderWindow->GetStyle() & WB_CLOSEABLE )
844 nMinWidth2 += pData->maCloseRect.GetWidth();
846 if ( nMinWidth2 > nMinWidth )
847 nMinWidth = nMinWidth2;
848 if ( pData->mnHitTest & (BORDERWINDOW_HITTEST_LEFT | BORDERWINDOW_HITTEST_TOPLEFT | BORDERWINDOW_HITTEST_BOTTOMLEFT) )
850 aNewRect.Left() += aMousePos.X();
851 if ( aNewRect.GetWidth() < nMinWidth )
852 aNewRect.Left() = aNewRect.Right()-nMinWidth+1;
853 else if ( aNewRect.GetWidth() > nMaxWidth )
854 aNewRect.Left() = aNewRect.Right()-nMaxWidth+1;
856 else if ( pData->mnHitTest & (BORDERWINDOW_HITTEST_RIGHT | BORDERWINDOW_HITTEST_TOPRIGHT | BORDERWINDOW_HITTEST_BOTTOMRIGHT) )
858 aNewRect.Right() += aMousePos.X();
859 if ( aNewRect.GetWidth() < nMinWidth )
860 aNewRect.Right() = aNewRect.Left()+nMinWidth+1;
861 else if ( aNewRect.GetWidth() > nMaxWidth )
862 aNewRect.Right() = aNewRect.Left()+nMaxWidth+1;
864 if ( pData->mnHitTest & (BORDERWINDOW_HITTEST_TOP | BORDERWINDOW_HITTEST_TOPLEFT | BORDERWINDOW_HITTEST_TOPRIGHT) )
866 aNewRect.Top() += aMousePos.Y();
867 if ( aNewRect.GetHeight() < nMinHeight )
868 aNewRect.Top() = aNewRect.Bottom()-nMinHeight+1;
869 else if ( aNewRect.GetHeight() > nMaxHeight )
870 aNewRect.Top() = aNewRect.Bottom()-nMaxHeight+1;
872 else if ( pData->mnHitTest & (BORDERWINDOW_HITTEST_BOTTOM | BORDERWINDOW_HITTEST_BOTTOMLEFT | BORDERWINDOW_HITTEST_BOTTOMRIGHT) )
874 aNewRect.Bottom() += aMousePos.Y();
875 if ( aNewRect.GetHeight() < nMinHeight )
876 aNewRect.Bottom() = aNewRect.Top()+nMinHeight+1;
877 else if ( aNewRect.GetHeight() > nMaxHeight )
878 aNewRect.Bottom() = aNewRect.Top()+nMaxHeight+1;
881 // call Resizing-Handler for SystemWindows
882 if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
884 // adjust size for Resizing-call
885 aSize = aNewRect.GetSize();
886 aSize.Width() -= nBorderWidth;
887 aSize.Height() -= nBorderHeight;
888 ((SystemWindow*)pBorderWindow->ImplGetClientWindow())->Resizing( aSize );
889 aSize.Width() += nBorderWidth;
890 aSize.Height() += nBorderHeight;
891 if ( aSize.Width() < nMinWidth )
892 aSize.Width() = nMinWidth;
893 if ( aSize.Height() < nMinHeight )
894 aSize.Height() = nMinHeight;
895 if ( aSize.Width() > nMaxWidth )
896 aSize.Width() = nMaxWidth;
897 if ( aSize.Height() > nMaxHeight )
898 aSize.Height() = nMaxHeight;
899 if ( pData->mnHitTest & (BORDERWINDOW_HITTEST_LEFT | BORDERWINDOW_HITTEST_TOPLEFT | BORDERWINDOW_HITTEST_BOTTOMLEFT) )
900 aNewRect.Left() = aNewRect.Right()-aSize.Width()+1;
901 else
902 aNewRect.Right() = aNewRect.Left()+aSize.Width()-1;
903 if ( pData->mnHitTest & (BORDERWINDOW_HITTEST_TOP | BORDERWINDOW_HITTEST_TOPLEFT | BORDERWINDOW_HITTEST_TOPRIGHT) )
904 aNewRect.Top() = aNewRect.Bottom()-aSize.Height()+1;
905 else
906 aNewRect.Bottom() = aNewRect.Top()+aSize.Height()-1;
909 if ( pData->mbDragFull )
911 // no move (only resize) if position did not change
912 if( aOldPos != aNewRect.TopLeft() )
913 pBorderWindow->SetPosSizePixel( aNewRect.Left(), aNewRect.Top(),
914 aNewRect.GetWidth(), aNewRect.GetHeight(), WINDOW_POSSIZE_POSSIZE );
915 else
916 pBorderWindow->SetPosSizePixel( aNewRect.Left(), aNewRect.Top(),
917 aNewRect.GetWidth(), aNewRect.GetHeight(), WINDOW_POSSIZE_SIZE );
919 pBorderWindow->ImplUpdateAll();
920 pBorderWindow->ImplGetFrameWindow()->ImplUpdateAll();
921 if ( pData->mnHitTest & (BORDERWINDOW_HITTEST_RIGHT | BORDERWINDOW_HITTEST_TOPRIGHT | BORDERWINDOW_HITTEST_BOTTOMRIGHT) )
922 pData->maMouseOff.X() += aNewRect.GetWidth()-nOldWidth;
923 if ( pData->mnHitTest & (BORDERWINDOW_HITTEST_BOTTOM | BORDERWINDOW_HITTEST_BOTTOMLEFT | BORDERWINDOW_HITTEST_BOTTOMRIGHT) )
924 pData->maMouseOff.Y() += aNewRect.GetHeight()-nOldHeight;
926 else
928 pData->mnTrackX = aNewRect.Left();
929 pData->mnTrackY = aNewRect.Top();
930 pData->mnTrackWidth = aNewRect.GetWidth();
931 pData->mnTrackHeight = aNewRect.GetHeight();
932 pBorderWindow->ShowTracking( Rectangle( pBorderWindow->ScreenToOutputPixel( aNewRect.TopLeft() ), aNewRect.GetSize() ), SHOWTRACK_BIG );
938 return TRUE;
941 // -----------------------------------------------------------------------
943 String ImplBorderWindowView::ImplRequestHelp( ImplBorderFrameData* pData,
944 const Point& rPos,
945 Rectangle& rHelpRect )
947 USHORT nHelpId = 0;
948 String aHelpStr;
949 USHORT nHitTest = ImplHitTest( pData, rPos );
950 if ( nHitTest )
952 if ( nHitTest & BORDERWINDOW_HITTEST_CLOSE )
954 nHelpId = SV_HELPTEXT_CLOSE;
955 rHelpRect = pData->maCloseRect;
957 else if ( nHitTest & BORDERWINDOW_HITTEST_ROLL )
959 if ( pData->mpBorderWindow->mbRollUp )
960 nHelpId = SV_HELPTEXT_ROLLDOWN;
961 else
962 nHelpId = SV_HELPTEXT_ROLLUP;
963 rHelpRect = pData->maRollRect;
965 else if ( nHitTest & BORDERWINDOW_HITTEST_DOCK )
967 nHelpId = SV_HELPTEXT_MAXIMIZE;
968 rHelpRect = pData->maDockRect;
970 /* no help string available
971 else if ( nHitTest & BORDERWINDOW_HITTEST_MENU )
973 nHelpId = SV_HELPTEXT_MENU;
974 rHelpRect = pData->maMenuRect;
976 else if ( nHitTest & BORDERWINDOW_HITTEST_HIDE )
978 nHelpId = SV_HELPTEXT_MINIMIZE;
979 rHelpRect = pData->maHideRect;
981 else if ( nHitTest & BORDERWINDOW_HITTEST_HELP )
983 nHelpId = SV_HELPTEXT_HELP;
984 rHelpRect = pData->maHelpRect;
986 else if ( nHitTest & BORDERWINDOW_HITTEST_PIN )
988 nHelpId = SV_HELPTEXT_ALWAYSVISIBLE;
989 rHelpRect = pData->maPinRect;
991 else if ( nHitTest & BORDERWINDOW_HITTEST_TITLE )
993 if( !pData->maTitleRect.IsEmpty() )
995 // tooltip only if title truncated
996 if( pData->mbTitleClipped )
998 rHelpRect = pData->maTitleRect;
999 // no help id, use window title as help string
1000 aHelpStr = pData->mpBorderWindow->GetText();
1006 if( nHelpId && ImplGetResMgr() )
1007 aHelpStr = String( ResId( nHelpId, *ImplGetResMgr() ) );
1009 return aHelpStr;
1012 // -----------------------------------------------------------------------
1014 long ImplBorderWindowView::ImplCalcTitleWidth( const ImplBorderFrameData* pData ) const
1016 // kein sichtbarer Title, dann auch keine Breite
1017 if ( !pData->mnTitleHeight )
1018 return 0;
1020 ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
1021 long nTitleWidth = pBorderWindow->GetTextWidth( pBorderWindow->GetText() )+6;
1022 nTitleWidth += pData->maPinRect.GetWidth();
1023 nTitleWidth += pData->maCloseRect.GetWidth();
1024 nTitleWidth += pData->maRollRect.GetWidth();
1025 nTitleWidth += pData->maDockRect.GetWidth();
1026 nTitleWidth += pData->maMenuRect.GetWidth();
1027 nTitleWidth += pData->maHideRect.GetWidth();
1028 nTitleWidth += pData->maHelpRect.GetWidth();
1029 nTitleWidth += pData->mnLeftBorder+pData->mnRightBorder;
1030 return nTitleWidth;
1033 // =======================================================================
1035 // --------------------------
1036 // - ImplNoBorderWindowView -
1037 // --------------------------
1039 ImplNoBorderWindowView::ImplNoBorderWindowView( ImplBorderWindow* )
1043 // -----------------------------------------------------------------------
1045 void ImplNoBorderWindowView::Init( OutputDevice*, long, long )
1049 // -----------------------------------------------------------------------
1051 void ImplNoBorderWindowView::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
1052 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
1054 rLeftBorder = 0;
1055 rTopBorder = 0;
1056 rRightBorder = 0;
1057 rBottomBorder = 0;
1060 // -----------------------------------------------------------------------
1062 long ImplNoBorderWindowView::CalcTitleWidth() const
1064 return 0;
1067 // -----------------------------------------------------------------------
1069 void ImplNoBorderWindowView::DrawWindow( USHORT, OutputDevice*, const Point* )
1073 // =======================================================================
1075 // -----------------------------
1076 // - ImplSmallBorderWindowView -
1077 // -----------------------------
1079 // =======================================================================
1081 ImplSmallBorderWindowView::ImplSmallBorderWindowView( ImplBorderWindow* pBorderWindow )
1083 mpBorderWindow = pBorderWindow;
1086 // -----------------------------------------------------------------------
1088 void ImplSmallBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHeight )
1090 mpOutDev = pDev;
1091 mnWidth = nWidth;
1092 mnHeight = nHeight;
1093 mbNWFBorder = false;
1095 USHORT nBorderStyle = mpBorderWindow->GetBorderStyle();
1096 if ( nBorderStyle & WINDOW_BORDER_NOBORDER )
1098 mnLeftBorder = 0;
1099 mnTopBorder = 0;
1100 mnRightBorder = 0;
1101 mnBottomBorder = 0;
1103 else
1105 // FIXME: this is currently only on aqua, check with other
1106 // platforms
1107 if( ImplGetSVData()->maNWFData.mbNoFocusRects )
1109 // for native widget drawing we must find out what
1110 // control this border belongs to
1111 Window *pWin = NULL, *pCtrl = NULL;
1112 if( mpOutDev->GetOutDevType() == OUTDEV_WINDOW )
1113 pWin = (Window*) mpOutDev;
1115 ControlType aCtrlType = 0;
1116 if( pWin && (pCtrl = mpBorderWindow->GetWindow( WINDOW_CLIENT )) != NULL )
1118 switch( pCtrl->GetType() )
1120 case WINDOW_LISTBOX:
1121 if( pCtrl->GetStyle() & WB_DROPDOWN )
1123 aCtrlType = CTRL_LISTBOX;
1124 mbNWFBorder = true;
1126 break;
1127 case WINDOW_COMBOBOX:
1128 if( pCtrl->GetStyle() & WB_DROPDOWN )
1130 aCtrlType = CTRL_COMBOBOX;
1131 mbNWFBorder = true;
1133 break;
1134 case WINDOW_MULTILINEEDIT:
1135 aCtrlType = CTRL_MULTILINE_EDITBOX;
1136 mbNWFBorder = true;
1137 break;
1138 case WINDOW_EDIT:
1139 case WINDOW_PATTERNFIELD:
1140 case WINDOW_METRICFIELD:
1141 case WINDOW_CURRENCYFIELD:
1142 case WINDOW_DATEFIELD:
1143 case WINDOW_TIMEFIELD:
1144 case WINDOW_LONGCURRENCYFIELD:
1145 case WINDOW_NUMERICFIELD:
1146 case WINDOW_SPINFIELD:
1147 mbNWFBorder = true;
1148 aCtrlType = (pCtrl->GetStyle() & WB_SPIN) ? CTRL_SPINBOX : CTRL_EDITBOX;
1149 break;
1150 default:
1151 break;
1154 if( mbNWFBorder )
1156 ImplControlValue aControlValue;
1157 Region aCtrlRegion( Rectangle( (const Point&)Point(), Size( mnWidth < 10 ? 10 : mnWidth, mnHeight < 10 ? 10 : mnHeight ) ) );
1158 Region aBoundingRgn( aCtrlRegion );
1159 Region aContentRgn( aCtrlRegion );
1160 if( pWin->GetNativeControlRegion( aCtrlType, PART_ENTIRE_CONTROL, aCtrlRegion,
1161 CTRL_STATE_ENABLED, aControlValue, rtl::OUString(),
1162 aBoundingRgn, aContentRgn ) )
1164 Rectangle aBounds( aBoundingRgn.GetBoundRect() );
1165 Rectangle aContent( aContentRgn.GetBoundRect() );
1166 mnLeftBorder = aContent.Left() - aBounds.Left();
1167 mnRightBorder = aBounds.Right() - aContent.Right();
1168 mnTopBorder = aContent.Top() - aBounds.Top();
1169 mnBottomBorder = aBounds.Bottom() - aContent.Bottom();
1170 if( mnWidth && mnHeight )
1173 mpBorderWindow->SetPaintTransparent( TRUE );
1174 mpBorderWindow->SetBackground();
1175 pCtrl->SetPaintTransparent( TRUE );
1177 Window* pCompoundParent = NULL;
1178 if( pWin->GetParent() && pWin->GetParent()->IsCompoundControl() )
1179 pCompoundParent = pWin->GetParent();
1181 if( pCompoundParent )
1182 pCompoundParent->SetPaintTransparent( TRUE );
1184 if( mnWidth < aBounds.GetWidth() || mnHeight < aBounds.GetHeight() )
1186 if( ! pCompoundParent ) // compound controls have to fix themselves
1188 Point aPos( mpBorderWindow->GetPosPixel() );
1189 if( mnWidth < aBounds.GetWidth() )
1190 aPos.X() -= (aBounds.GetWidth() - mnWidth) / 2;
1191 if( mnHeight < aBounds.GetHeight() )
1192 aPos.Y() -= (aBounds.GetHeight() - mnHeight) / 2;
1193 mpBorderWindow->SetPosSizePixel( aPos, aBounds.GetSize() );
1198 else
1199 mbNWFBorder = false;
1203 if( ! mbNWFBorder )
1205 USHORT nStyle = FRAME_DRAW_NODRAW;
1206 // Wenn Border umgesetzt wurde oder BorderWindow ein Frame-Fenster
1207 // ist, dann Border nach aussen
1208 if ( (nBorderStyle & WINDOW_BORDER_DOUBLEOUT) || mpBorderWindow->mbSmallOutBorder )
1209 nStyle |= FRAME_DRAW_DOUBLEOUT;
1210 else
1211 nStyle |= FRAME_DRAW_DOUBLEIN;
1212 if ( nBorderStyle & WINDOW_BORDER_MONO )
1213 nStyle |= FRAME_DRAW_MONO;
1215 DecorationView aDecoView( mpOutDev );
1216 Rectangle aRect( 0, 0, 10, 10 );
1217 Rectangle aCalcRect = aDecoView.DrawFrame( aRect, nStyle );
1218 mnLeftBorder = aCalcRect.Left();
1219 mnTopBorder = aCalcRect.Top();
1220 mnRightBorder = aRect.Right()-aCalcRect.Right();
1221 mnBottomBorder = aRect.Bottom()-aCalcRect.Bottom();
1226 // -----------------------------------------------------------------------
1228 void ImplSmallBorderWindowView::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
1229 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
1231 rLeftBorder = mnLeftBorder;
1232 rTopBorder = mnTopBorder;
1233 rRightBorder = mnRightBorder;
1234 rBottomBorder = mnBottomBorder;
1237 // -----------------------------------------------------------------------
1239 long ImplSmallBorderWindowView::CalcTitleWidth() const
1241 return 0;
1244 // -----------------------------------------------------------------------
1246 void ImplSmallBorderWindowView::DrawWindow( USHORT nDrawFlags, OutputDevice*, const Point* )
1248 USHORT nBorderStyle = mpBorderWindow->GetBorderStyle();
1249 if ( nBorderStyle & WINDOW_BORDER_NOBORDER )
1250 return;
1252 BOOL bNativeOK = FALSE;
1253 // for native widget drawing we must find out what
1254 // control this border belongs to
1255 Window *pWin = NULL, *pCtrl = NULL;
1256 if( mpOutDev->GetOutDevType() == OUTDEV_WINDOW )
1257 pWin = (Window*) mpOutDev;
1259 ControlType aCtrlType = 0;
1260 ControlPart aCtrlPart = PART_ENTIRE_CONTROL;
1262 if( pWin && (pCtrl = mpBorderWindow->GetWindow( WINDOW_CLIENT )) != NULL )
1264 switch( pCtrl->GetType() )
1266 case WINDOW_MULTILINEEDIT:
1267 aCtrlType = CTRL_MULTILINE_EDITBOX;
1268 break;
1269 case WINDOW_EDIT:
1270 case WINDOW_PATTERNFIELD:
1271 case WINDOW_METRICFIELD:
1272 case WINDOW_CURRENCYFIELD:
1273 case WINDOW_DATEFIELD:
1274 case WINDOW_TIMEFIELD:
1275 case WINDOW_LONGCURRENCYFIELD:
1276 case WINDOW_NUMERICFIELD:
1277 case WINDOW_SPINFIELD:
1278 if( pCtrl->GetStyle() & WB_SPIN )
1279 aCtrlType = CTRL_SPINBOX;
1280 else
1281 aCtrlType = CTRL_EDITBOX;
1282 break;
1284 case WINDOW_LISTBOX:
1285 case WINDOW_MULTILISTBOX:
1286 case WINDOW_TREELISTBOX:
1287 aCtrlType = CTRL_LISTBOX;
1288 if( pCtrl->GetStyle() & WB_DROPDOWN )
1289 aCtrlPart = PART_ENTIRE_CONTROL;
1290 else
1291 aCtrlPart = PART_WINDOW;
1292 break;
1294 case WINDOW_LISTBOXWINDOW:
1295 aCtrlType = CTRL_LISTBOX;
1296 aCtrlPart = PART_WINDOW;
1297 break;
1299 case WINDOW_COMBOBOX:
1300 case WINDOW_PATTERNBOX:
1301 case WINDOW_NUMERICBOX:
1302 case WINDOW_METRICBOX:
1303 case WINDOW_CURRENCYBOX:
1304 case WINDOW_DATEBOX:
1305 case WINDOW_TIMEBOX:
1306 case WINDOW_LONGCURRENCYBOX:
1307 if( pCtrl->GetStyle() & WB_DROPDOWN )
1309 aCtrlType = CTRL_COMBOBOX;
1310 aCtrlPart = PART_ENTIRE_CONTROL;
1312 else
1314 aCtrlType = CTRL_LISTBOX;
1315 aCtrlPart = PART_WINDOW;
1317 break;
1319 default:
1320 break;
1324 if ( aCtrlType && pCtrl->IsNativeControlSupported(aCtrlType, aCtrlPart) )
1326 ImplControlValue aControlValue;
1327 ControlState nState = CTRL_STATE_ENABLED;
1329 if ( !pWin->IsEnabled() )
1330 nState &= ~CTRL_STATE_ENABLED;
1331 if ( pWin->HasFocus() )
1332 nState |= CTRL_STATE_FOCUSED;
1333 else if( mbNWFBorder )
1335 // FIXME: this is curently only on aqua, see if other platforms can profit
1337 // FIXME: for aqua focus rings all controls need to support GetNativeControlRegion
1338 // for the dropdown style
1339 if( pCtrl->HasFocus() || pCtrl->HasChildPathFocus() )
1340 nState |= CTRL_STATE_FOCUSED;
1343 BOOL bMouseOver = FALSE;
1344 Window *pCtrlChild = pCtrl->GetWindow( WINDOW_FIRSTCHILD );
1345 while( pCtrlChild && (bMouseOver = pCtrlChild->IsMouseOver()) == FALSE )
1346 pCtrlChild = pCtrlChild->GetWindow( WINDOW_NEXT );
1348 if( bMouseOver )
1349 nState |= CTRL_STATE_ROLLOVER;
1351 Point aPoint;
1352 Region aCtrlRegion( Rectangle( aPoint, Size( mnWidth, mnHeight ) ) );
1354 Region aBoundingRgn( Rectangle( aPoint, Size( mnWidth, mnHeight ) ) );
1355 Region aContentRgn=aCtrlRegion;
1356 if(pWin->GetNativeControlRegion( aCtrlType, aCtrlPart, aCtrlRegion,
1357 nState, aControlValue, rtl::OUString(), aBoundingRgn, aContentRgn )) {
1358 aCtrlRegion=aContentRgn;
1361 bNativeOK = pWin->DrawNativeControl( aCtrlType, aCtrlPart, aCtrlRegion, nState,
1362 aControlValue, rtl::OUString() );
1364 // if the native theme draws the spinbuttons in one call, make sure the proper settings
1365 // are passed, this might force a redraw though.... (TODO: improve)
1366 if ( (aCtrlType == CTRL_SPINBOX) && !pCtrl->IsNativeControlSupported( CTRL_SPINBOX, PART_BUTTON_UP ) )
1368 Edit *pEdit = ((Edit*) pCtrl)->GetSubEdit();
1369 if ( pEdit )
1370 pCtrl->Paint( Rectangle() ); // make sure the buttons are also drawn as they might overwrite the border
1374 if( bNativeOK )
1375 return;
1377 if ( nDrawFlags & BORDERWINDOW_DRAW_FRAME )
1379 if ( nBorderStyle & WINDOW_BORDER_ACTIVE )
1381 Color aColor = mpOutDev->GetSettings().GetStyleSettings().GetHighlightColor();
1382 mpOutDev->SetLineColor();
1383 mpOutDev->SetFillColor( aColor );
1384 mpOutDev->DrawRect( Rectangle( 0, 0, mnWidth-1, mnTopBorder ) );
1385 mpOutDev->DrawRect( Rectangle( 0, mnHeight-mnBottomBorder, mnWidth-1, mnHeight-1 ) );
1386 mpOutDev->DrawRect( Rectangle( 0, 0, mnLeftBorder, mnHeight-1 ) );
1387 mpOutDev->DrawRect( Rectangle( mnWidth-mnRightBorder, 0, mnWidth-1, mnHeight-1 ) );
1389 else
1391 USHORT nStyle = 0;
1392 // Wenn Border umgesetzt wurde oder BorderWindow ein Frame-Fenster
1393 // ist, dann Border nach aussen
1394 if ( (nBorderStyle & WINDOW_BORDER_DOUBLEOUT) || mpBorderWindow->mbSmallOutBorder )
1395 nStyle |= FRAME_DRAW_DOUBLEOUT;
1396 else
1397 nStyle |= FRAME_DRAW_DOUBLEIN;
1398 if ( nBorderStyle & WINDOW_BORDER_MONO )
1399 nStyle |= FRAME_DRAW_MONO;
1400 if ( nBorderStyle & WINDOW_BORDER_MENU )
1401 nStyle |= FRAME_DRAW_MENU;
1402 // tell DrawFrame that we're drawing a window border of a frame window to avoid round corners
1403 if( pWin && pWin == pWin->ImplGetFrameWindow() )
1404 nStyle |= FRAME_DRAW_WINDOWBORDER;
1406 DecorationView aDecoView( mpOutDev );
1407 Point aTmpPoint;
1408 Rectangle aInRect( aTmpPoint, Size( mnWidth, mnHeight ) );
1409 aDecoView.DrawFrame( aInRect, nStyle );
1414 // =======================================================================
1416 // ---------------------------
1417 // - ImplStdBorderWindowView -
1418 // ---------------------------
1420 ImplStdBorderWindowView::ImplStdBorderWindowView( ImplBorderWindow* pBorderWindow )
1422 maFrameData.mpBorderWindow = pBorderWindow;
1423 maFrameData.mbDragFull = FALSE;
1424 maFrameData.mnHitTest = 0;
1425 maFrameData.mnPinState = 0;
1426 maFrameData.mnCloseState = 0;
1427 maFrameData.mnRollState = 0;
1428 maFrameData.mnDockState = 0;
1429 maFrameData.mnMenuState = 0;
1430 maFrameData.mnHideState = 0;
1431 maFrameData.mnHelpState = 0;
1432 maFrameData.mbTitleClipped = 0;
1434 mpATitleVirDev = NULL;
1435 mpDTitleVirDev = NULL;
1438 // -----------------------------------------------------------------------
1440 ImplStdBorderWindowView::~ImplStdBorderWindowView()
1442 if ( mpATitleVirDev )
1443 delete mpATitleVirDev;
1444 if ( mpDTitleVirDev )
1445 delete mpDTitleVirDev;
1448 // -----------------------------------------------------------------------
1450 BOOL ImplStdBorderWindowView::MouseMove( const MouseEvent& rMEvt )
1452 return ImplMouseMove( &maFrameData, rMEvt );
1455 // -----------------------------------------------------------------------
1457 BOOL ImplStdBorderWindowView::MouseButtonDown( const MouseEvent& rMEvt )
1459 return ImplMouseButtonDown( &maFrameData, rMEvt );
1462 // -----------------------------------------------------------------------
1464 BOOL ImplStdBorderWindowView::Tracking( const TrackingEvent& rTEvt )
1466 return ImplTracking( &maFrameData, rTEvt );
1469 // -----------------------------------------------------------------------
1471 String ImplStdBorderWindowView::RequestHelp( const Point& rPos, Rectangle& rHelpRect )
1473 return ImplRequestHelp( &maFrameData, rPos, rHelpRect );
1476 // -----------------------------------------------------------------------
1478 Rectangle ImplStdBorderWindowView::GetMenuRect() const
1480 return maFrameData.maMenuRect;
1483 // -----------------------------------------------------------------------
1485 void ImplStdBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHeight )
1487 ImplBorderFrameData* pData = &maFrameData;
1488 ImplBorderWindow* pBorderWindow = maFrameData.mpBorderWindow;
1489 const StyleSettings& rStyleSettings = pDev->GetSettings().GetStyleSettings();
1490 DecorationView aDecoView( pDev );
1491 Rectangle aRect( 0, 0, 10, 10 );
1492 Rectangle aCalcRect = aDecoView.DrawFrame( aRect, FRAME_DRAW_DOUBLEOUT | FRAME_DRAW_NODRAW );
1494 pData->mpOutDev = pDev;
1495 pData->mnWidth = nWidth;
1496 pData->mnHeight = nHeight;
1498 pData->mnTitleType = pBorderWindow->mnTitleType;
1499 pData->mbFloatWindow = pBorderWindow->mbFloatWindow;
1501 if ( !(pBorderWindow->GetStyle() & WB_MOVEABLE) || (pData->mnTitleType == BORDERWINDOW_TITLE_NONE) )
1502 pData->mnBorderSize = 0;
1503 else if ( pData->mnTitleType == BORDERWINDOW_TITLE_TEAROFF )
1504 pData->mnBorderSize = 0;
1505 else
1506 pData->mnBorderSize = rStyleSettings.GetBorderSize();
1507 pData->mnLeftBorder = aCalcRect.Left();
1508 pData->mnTopBorder = aCalcRect.Top();
1509 pData->mnRightBorder = aRect.Right()-aCalcRect.Right();
1510 pData->mnBottomBorder = aRect.Bottom()-aCalcRect.Bottom();
1511 pData->mnLeftBorder += pData->mnBorderSize;
1512 pData->mnTopBorder += pData->mnBorderSize;
1513 pData->mnRightBorder += pData->mnBorderSize;
1514 pData->mnBottomBorder += pData->mnBorderSize;
1515 pData->mnNoTitleTop = pData->mnTopBorder;
1517 ImplInitTitle( &maFrameData );
1518 if ( pData->mnTitleHeight )
1520 // to improve symbol display force a minum title height
1521 if( pData->mnTitleHeight < MIN_CAPTION_HEIGHT )
1522 pData->mnTitleHeight = MIN_CAPTION_HEIGHT;
1524 // set a proper background for drawing
1525 // highlighted buttons in the title
1526 pBorderWindow->SetBackground( rStyleSettings.GetWindowColor() );
1528 pData->maTitleRect.Left() = pData->mnLeftBorder;
1529 pData->maTitleRect.Right() = nWidth-pData->mnRightBorder-1;
1530 pData->maTitleRect.Top() = pData->mnTopBorder;
1531 pData->maTitleRect.Bottom() = pData->maTitleRect.Top()+pData->mnTitleHeight-1;
1533 if ( pData->mnTitleType & (BORDERWINDOW_TITLE_NORMAL | BORDERWINDOW_TITLE_SMALL) )
1535 long nLeft = pData->maTitleRect.Left();
1536 long nRight = pData->maTitleRect.Right();
1537 long nItemTop = pData->maTitleRect.Top();
1538 long nItemBottom = pData->maTitleRect.Bottom();
1539 nLeft += 1;
1540 nRight -= 3;
1541 nItemTop += 2;
1542 nItemBottom -= 2;
1544 if ( pBorderWindow->GetStyle() & WB_PINABLE )
1546 Image aImage;
1547 ImplGetPinImage( 0, 0, aImage );
1548 pData->maPinRect.Top() = nItemTop;
1549 pData->maPinRect.Bottom() = nItemBottom;
1550 pData->maPinRect.Left() = nLeft;
1551 pData->maPinRect.Right() = pData->maPinRect.Left()+aImage.GetSizePixel().Width();
1552 nLeft += pData->maPinRect.GetWidth()+3;
1555 if ( pBorderWindow->GetStyle() & WB_CLOSEABLE )
1557 pData->maCloseRect.Top() = nItemTop;
1558 pData->maCloseRect.Bottom() = nItemBottom;
1559 pData->maCloseRect.Right() = nRight;
1560 pData->maCloseRect.Left() = pData->maCloseRect.Right()-pData->maCloseRect.GetHeight()+1;
1561 nRight -= pData->maCloseRect.GetWidth()+3;
1564 if ( pBorderWindow->mbMenuBtn )
1566 pData->maMenuRect.Top() = nItemTop;
1567 pData->maMenuRect.Bottom() = nItemBottom;
1568 pData->maMenuRect.Right() = nRight;
1569 pData->maMenuRect.Left() = pData->maMenuRect.Right()-pData->maMenuRect.GetHeight()+1;
1570 nRight -= pData->maMenuRect.GetWidth();
1573 if ( pBorderWindow->mbDockBtn )
1575 pData->maDockRect.Top() = nItemTop;
1576 pData->maDockRect.Bottom() = nItemBottom;
1577 pData->maDockRect.Right() = nRight;
1578 pData->maDockRect.Left() = pData->maDockRect.Right()-pData->maDockRect.GetHeight()+1;
1579 nRight -= pData->maDockRect.GetWidth();
1580 if ( !pBorderWindow->mbHideBtn &&
1581 !(pBorderWindow->GetStyle() & WB_ROLLABLE) )
1582 nRight -= 3;
1585 if ( pBorderWindow->mbHideBtn )
1587 pData->maHideRect.Top() = nItemTop;
1588 pData->maHideRect.Bottom() = nItemBottom;
1589 pData->maHideRect.Right() = nRight;
1590 pData->maHideRect.Left() = pData->maHideRect.Right()-pData->maHideRect.GetHeight()+1;
1591 nRight -= pData->maHideRect.GetWidth();
1592 if ( !(pBorderWindow->GetStyle() & WB_ROLLABLE) )
1593 nRight -= 3;
1596 if ( pBorderWindow->GetStyle() & WB_ROLLABLE )
1598 pData->maRollRect.Top() = nItemTop;
1599 pData->maRollRect.Bottom() = nItemBottom;
1600 pData->maRollRect.Right() = nRight;
1601 pData->maRollRect.Left() = pData->maRollRect.Right()-pData->maRollRect.GetHeight()+1;
1602 nRight -= pData->maRollRect.GetWidth();
1605 if ( pBorderWindow->mbHelpBtn )
1607 pData->maHelpRect.Top() = nItemTop;
1608 pData->maHelpRect.Bottom() = nItemBottom;
1609 pData->maHelpRect.Right() = nRight;
1610 pData->maHelpRect.Left() = pData->maHelpRect.Right()-pData->maHelpRect.GetHeight()+1;
1611 nRight -= pData->maHelpRect.GetWidth()+3;
1614 else
1616 pData->maPinRect.SetEmpty();
1617 pData->maCloseRect.SetEmpty();
1618 pData->maDockRect.SetEmpty();
1619 pData->maMenuRect.SetEmpty();
1620 pData->maHideRect.SetEmpty();
1621 pData->maRollRect.SetEmpty();
1622 pData->maHelpRect.SetEmpty();
1625 pData->mnTopBorder += pData->mnTitleHeight;
1627 else
1629 pData->maTitleRect.SetEmpty();
1630 pData->maPinRect.SetEmpty();
1631 pData->maCloseRect.SetEmpty();
1632 pData->maDockRect.SetEmpty();
1633 pData->maMenuRect.SetEmpty();
1634 pData->maHideRect.SetEmpty();
1635 pData->maRollRect.SetEmpty();
1636 pData->maHelpRect.SetEmpty();
1640 // -----------------------------------------------------------------------
1642 void ImplStdBorderWindowView::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
1643 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
1645 rLeftBorder = maFrameData.mnLeftBorder;
1646 rTopBorder = maFrameData.mnTopBorder;
1647 rRightBorder = maFrameData.mnRightBorder;
1648 rBottomBorder = maFrameData.mnBottomBorder;
1651 // -----------------------------------------------------------------------
1653 long ImplStdBorderWindowView::CalcTitleWidth() const
1655 return ImplCalcTitleWidth( &maFrameData );
1658 // -----------------------------------------------------------------------
1660 void ImplStdBorderWindowView::DrawWindow( USHORT nDrawFlags, OutputDevice* pOutDev, const Point* pOffset )
1662 ImplBorderFrameData* pData = &maFrameData;
1663 OutputDevice* pDev = pOutDev ? pOutDev : pData->mpOutDev;
1664 ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
1665 Point aTmpPoint = pOffset ? Point(*pOffset) : Point();
1666 Rectangle aInRect( aTmpPoint, Size( pData->mnWidth, pData->mnHeight ) );
1667 const StyleSettings& rStyleSettings = pData->mpOutDev->GetSettings().GetStyleSettings();
1668 DecorationView aDecoView( pDev );
1669 Color aFrameColor( rStyleSettings.GetFaceColor() );
1671 aFrameColor.DecreaseContrast( (UINT8) (0.50 * 255));
1673 // Draw Frame
1674 if ( nDrawFlags & BORDERWINDOW_DRAW_FRAME )
1676 // single line frame
1677 pDev->SetLineColor( aFrameColor );
1678 pDev->SetFillColor();
1679 pDev->DrawRect( aInRect );
1680 aInRect.nLeft++; aInRect.nRight--;
1681 aInRect.nTop++; aInRect.nBottom--;
1683 else
1684 aInRect = aDecoView.DrawFrame( aInRect, FRAME_DRAW_DOUBLEOUT | FRAME_DRAW_NODRAW);
1686 // Draw Border
1687 pDev->SetLineColor();
1688 long nBorderSize = pData->mnBorderSize;
1689 if ( (nDrawFlags & BORDERWINDOW_DRAW_BORDER) && nBorderSize )
1691 pDev->SetFillColor( rStyleSettings.GetFaceColor() );
1692 pDev->DrawRect( Rectangle( Point( aInRect.Left(), aInRect.Top() ),
1693 Size( aInRect.GetWidth(), nBorderSize ) ) );
1694 pDev->DrawRect( Rectangle( Point( aInRect.Left(), aInRect.Top()+nBorderSize ),
1695 Size( nBorderSize, aInRect.GetHeight()-nBorderSize ) ) );
1696 pDev->DrawRect( Rectangle( Point( aInRect.Left(), aInRect.Bottom()-nBorderSize+1 ),
1697 Size( aInRect.GetWidth(), nBorderSize ) ) );
1698 pDev->DrawRect( Rectangle( Point( aInRect.Right()-nBorderSize+1, aInRect.Top()+nBorderSize ),
1699 Size( nBorderSize, aInRect.GetHeight()-nBorderSize ) ) );
1702 // Draw Title
1703 if ( (nDrawFlags & BORDERWINDOW_DRAW_TITLE) && !pData->maTitleRect.IsEmpty() )
1705 aInRect = pData->maTitleRect;
1707 // use no gradient anymore, just a static titlecolor
1708 pDev->SetFillColor( aFrameColor );
1709 pDev->SetTextColor( rStyleSettings.GetButtonTextColor() );
1710 Rectangle aTitleRect( pData->maTitleRect );
1711 if( pOffset )
1712 aTitleRect.Move( pOffset->X(), pOffset->Y() );
1713 pDev->DrawRect( aTitleRect );
1716 if ( pData->mnTitleType != BORDERWINDOW_TITLE_TEAROFF )
1718 aInRect.Left() += 2;
1719 aInRect.Right() -= 2;
1721 if ( !pData->maPinRect.IsEmpty() )
1722 aInRect.Left() = pData->maPinRect.Right()+2;
1724 if ( !pData->maHelpRect.IsEmpty() )
1725 aInRect.Right() = pData->maHelpRect.Left()-2;
1726 else if ( !pData->maRollRect.IsEmpty() )
1727 aInRect.Right() = pData->maRollRect.Left()-2;
1728 else if ( !pData->maHideRect.IsEmpty() )
1729 aInRect.Right() = pData->maHideRect.Left()-2;
1730 else if ( !pData->maDockRect.IsEmpty() )
1731 aInRect.Right() = pData->maDockRect.Left()-2;
1732 else if ( !pData->maMenuRect.IsEmpty() )
1733 aInRect.Right() = pData->maMenuRect.Left()-2;
1734 else if ( !pData->maCloseRect.IsEmpty() )
1735 aInRect.Right() = pData->maCloseRect.Left()-2;
1737 if ( pOffset )
1738 aInRect.Move( pOffset->X(), pOffset->Y() );
1740 USHORT nTextStyle = TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER | TEXT_DRAW_ENDELLIPSIS | TEXT_DRAW_CLIP;
1742 // must show tooltip ?
1743 TextRectInfo aInfo;
1744 pDev->GetTextRect( aInRect, pBorderWindow->GetText(), nTextStyle, &aInfo );
1745 pData->mbTitleClipped = aInfo.IsEllipses();
1747 pDev->DrawText( aInRect, pBorderWindow->GetText(), nTextStyle );
1751 if ( ((nDrawFlags & BORDERWINDOW_DRAW_CLOSE) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
1752 !pData->maCloseRect.IsEmpty() )
1754 Rectangle aSymbolRect( pData->maCloseRect );
1755 if ( pOffset )
1756 aSymbolRect.Move( pOffset->X(), pOffset->Y() );
1757 ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, SYMBOL_CLOSE, pData->mnCloseState );
1759 if ( ((nDrawFlags & BORDERWINDOW_DRAW_DOCK) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
1760 !pData->maDockRect.IsEmpty() )
1762 Rectangle aSymbolRect( pData->maDockRect );
1763 if ( pOffset )
1764 aSymbolRect.Move( pOffset->X(), pOffset->Y() );
1765 ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, SYMBOL_DOCK, pData->mnDockState );
1767 if ( ((nDrawFlags & BORDERWINDOW_DRAW_MENU) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
1768 !pData->maMenuRect.IsEmpty() )
1770 Rectangle aSymbolRect( pData->maMenuRect );
1771 if ( pOffset )
1772 aSymbolRect.Move( pOffset->X(), pOffset->Y() );
1773 ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, SYMBOL_MENU, pData->mnMenuState );
1775 if ( ((nDrawFlags & BORDERWINDOW_DRAW_HIDE) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
1776 !pData->maHideRect.IsEmpty() )
1778 Rectangle aSymbolRect( pData->maHideRect );
1779 if ( pOffset )
1780 aSymbolRect.Move( pOffset->X(), pOffset->Y() );
1781 ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, SYMBOL_HIDE, pData->mnHideState );
1783 if ( ((nDrawFlags & BORDERWINDOW_DRAW_ROLL) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
1784 !pData->maRollRect.IsEmpty() )
1786 SymbolType eType;
1787 if ( pBorderWindow->mbRollUp )
1788 eType = SYMBOL_ROLLDOWN;
1789 else
1790 eType = SYMBOL_ROLLUP;
1791 Rectangle aSymbolRect( pData->maRollRect );
1792 if ( pOffset )
1793 aSymbolRect.Move( pOffset->X(), pOffset->Y() );
1794 ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, eType, pData->mnRollState );
1797 if ( ((nDrawFlags & BORDERWINDOW_DRAW_HELP) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
1798 !pData->maHelpRect.IsEmpty() )
1800 Rectangle aSymbolRect( pData->maHelpRect );
1801 if ( pOffset )
1802 aSymbolRect.Move( pOffset->X(), pOffset->Y() );
1803 ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, SYMBOL_HELP, pData->mnHelpState );
1805 if ( ((nDrawFlags & BORDERWINDOW_DRAW_PIN) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
1806 !pData->maPinRect.IsEmpty() )
1808 Image aImage;
1809 ImplGetPinImage( pData->mnPinState, pBorderWindow->mbPined, aImage );
1810 Size aImageSize = aImage.GetSizePixel();
1811 long nRectHeight = pData->maPinRect.GetHeight();
1812 Point aPos( pData->maPinRect.TopLeft() );
1813 if ( pOffset )
1814 aPos.Move( pOffset->X(), pOffset->Y() );
1815 if ( nRectHeight < aImageSize.Height() )
1817 pDev->DrawImage( aPos, Size( aImageSize.Width(), nRectHeight ), aImage );
1819 else
1821 aPos.Y() += (nRectHeight-aImageSize.Height())/2;
1822 pDev->DrawImage( aPos, aImage );
1828 // =======================================================================
1829 void ImplBorderWindow::ImplInit( Window* pParent,
1830 WinBits nStyle, USHORT nTypeStyle,
1831 const ::com::sun::star::uno::Any& )
1833 ImplInit( pParent, nStyle, nTypeStyle, NULL );
1836 void ImplBorderWindow::ImplInit( Window* pParent,
1837 WinBits nStyle, USHORT nTypeStyle,
1838 SystemParentData* pSystemParentData
1841 // Alle WindowBits entfernen, die wir nicht haben wollen
1842 WinBits nOrgStyle = nStyle;
1843 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);
1844 if ( nTypeStyle & BORDERWINDOW_STYLE_APP )
1845 nTestStyle |= WB_APP;
1846 nStyle &= nTestStyle;
1848 mpWindowImpl->mbBorderWin = TRUE;
1849 mbSmallOutBorder = FALSE;
1850 if ( nTypeStyle & BORDERWINDOW_STYLE_FRAME )
1852 if( (nStyle & WB_SYSTEMCHILDWINDOW) )
1854 mpWindowImpl->mbOverlapWin = TRUE;
1855 mpWindowImpl->mbFrame = TRUE;
1856 mbFrameBorder = FALSE;
1858 else if( (nStyle & WB_OWNERDRAWDECORATION) )
1860 mpWindowImpl->mbOverlapWin = TRUE;
1861 mpWindowImpl->mbFrame = TRUE;
1862 mbFrameBorder = (nOrgStyle & WB_NOBORDER) ? FALSE : TRUE;
1864 else
1866 mpWindowImpl->mbOverlapWin = TRUE;
1867 mpWindowImpl->mbFrame = TRUE;
1868 mbFrameBorder = FALSE;
1869 // closeable windows may have a border as well, eg. system floating windows without caption
1870 if ( (nOrgStyle & (WB_BORDER | WB_NOBORDER | WB_MOVEABLE | WB_SIZEABLE/* | WB_CLOSEABLE*/)) == WB_BORDER )
1871 mbSmallOutBorder = TRUE;
1874 else if ( nTypeStyle & BORDERWINDOW_STYLE_OVERLAP )
1876 mpWindowImpl->mbOverlapWin = TRUE;
1877 mbFrameBorder = TRUE;
1879 else
1880 mbFrameBorder = FALSE;
1882 if ( nTypeStyle & BORDERWINDOW_STYLE_FLOAT )
1883 mbFloatWindow = TRUE;
1884 else
1885 mbFloatWindow = FALSE;
1887 Window::ImplInit( pParent, nStyle, pSystemParentData );
1888 SetBackground();
1889 SetTextFillColor();
1891 mpMenuBarWindow = NULL;
1892 mnMinWidth = 0;
1893 mnMinHeight = 0;
1894 mnMaxWidth = SHRT_MAX;
1895 mnMaxHeight = SHRT_MAX;
1896 mnRollHeight = 0;
1897 mnOrgMenuHeight = 0;
1898 mbPined = FALSE;
1899 mbRollUp = FALSE;
1900 mbMenuHide = FALSE;
1901 mbDockBtn = FALSE;
1902 mbMenuBtn = FALSE;
1903 mbHideBtn = FALSE;
1904 mbHelpBtn = FALSE;
1905 mbDisplayActive = IsActive();
1907 if ( nTypeStyle & BORDERWINDOW_STYLE_FLOAT )
1908 mnTitleType = BORDERWINDOW_TITLE_SMALL;
1909 else
1910 mnTitleType = BORDERWINDOW_TITLE_NORMAL;
1911 mnBorderStyle = WINDOW_BORDER_NORMAL;
1912 InitView();
1915 // =======================================================================
1917 ImplBorderWindow::ImplBorderWindow( Window* pParent,
1918 SystemParentData* pSystemParentData,
1919 WinBits nStyle, USHORT nTypeStyle
1920 ) : Window( WINDOW_BORDERWINDOW )
1922 ImplInit( pParent, nStyle, nTypeStyle, pSystemParentData );
1925 // -----------------------------------------------------------------------
1927 ImplBorderWindow::ImplBorderWindow( Window* pParent, WinBits nStyle ,
1928 USHORT nTypeStyle ) :
1929 Window( WINDOW_BORDERWINDOW )
1931 ImplInit( pParent, nStyle, nTypeStyle, ::com::sun::star::uno::Any() );
1934 ImplBorderWindow::ImplBorderWindow( Window* pParent,
1935 WinBits nStyle, USHORT nTypeStyle,
1936 const ::com::sun::star::uno::Any& aSystemToken ) :
1937 Window( WINDOW_BORDERWINDOW )
1939 ImplInit( pParent, nStyle, nTypeStyle, aSystemToken );
1942 // -----------------------------------------------------------------------
1944 ImplBorderWindow::~ImplBorderWindow()
1946 delete mpBorderView;
1949 // -----------------------------------------------------------------------
1951 void ImplBorderWindow::MouseMove( const MouseEvent& rMEvt )
1953 mpBorderView->MouseMove( rMEvt );
1956 // -----------------------------------------------------------------------
1958 void ImplBorderWindow::MouseButtonDown( const MouseEvent& rMEvt )
1960 mpBorderView->MouseButtonDown( rMEvt );
1963 // -----------------------------------------------------------------------
1965 void ImplBorderWindow::Tracking( const TrackingEvent& rTEvt )
1967 mpBorderView->Tracking( rTEvt );
1970 // -----------------------------------------------------------------------
1972 void ImplBorderWindow::Paint( const Rectangle& )
1974 mpBorderView->DrawWindow( BORDERWINDOW_DRAW_ALL );
1977 void ImplBorderWindow::Draw( const Rectangle&, OutputDevice* pOutDev, const Point& rPos )
1979 mpBorderView->DrawWindow( BORDERWINDOW_DRAW_ALL, pOutDev, &rPos );
1982 // -----------------------------------------------------------------------
1984 void ImplBorderWindow::Activate()
1986 SetDisplayActive( TRUE );
1987 Window::Activate();
1990 // -----------------------------------------------------------------------
1992 void ImplBorderWindow::Deactivate()
1994 // Fenster die immer Active sind, nehmen wir von dieser Regel aus,
1995 // genauso, wenn ein Menu aktiv wird, ignorieren wir das Deactivate
1996 if ( GetActivateMode() && !ImplGetSVData()->maWinData.mbNoDeactivate )
1997 SetDisplayActive( FALSE );
1998 Window::Deactivate();
2001 // -----------------------------------------------------------------------
2003 void ImplBorderWindow::RequestHelp( const HelpEvent& rHEvt )
2005 // no keyboard help for border win
2006 if ( rHEvt.GetMode() & (HELPMODE_BALLOON | HELPMODE_QUICK) && !rHEvt.KeyboardActivated() )
2008 Point aMousePosPixel = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
2009 Rectangle aHelpRect;
2010 String aHelpStr( mpBorderView->RequestHelp( aMousePosPixel, aHelpRect ) );
2012 // Rechteck ermitteln
2013 if ( aHelpStr.Len() )
2015 aHelpRect.SetPos( OutputToScreenPixel( aHelpRect.TopLeft() ) );
2016 if ( rHEvt.GetMode() & HELPMODE_BALLOON )
2017 Help::ShowBalloon( this, aHelpRect.Center(), aHelpRect, aHelpStr );
2018 else
2019 Help::ShowQuickHelp( this, aHelpRect, aHelpStr );
2020 return;
2024 Window::RequestHelp( rHEvt );
2027 // -----------------------------------------------------------------------
2029 void ImplBorderWindow::Resize()
2031 Size aSize = GetOutputSizePixel();
2033 if ( !mbRollUp )
2035 Window* pClientWindow = ImplGetClientWindow();
2037 if ( mpMenuBarWindow )
2039 sal_Int32 nLeftBorder;
2040 sal_Int32 nTopBorder;
2041 sal_Int32 nRightBorder;
2042 sal_Int32 nBottomBorder;
2043 long nMenuHeight = mpMenuBarWindow->GetSizePixel().Height();
2044 if ( mbMenuHide )
2046 if ( nMenuHeight )
2047 mnOrgMenuHeight = nMenuHeight;
2048 nMenuHeight = 0;
2050 else
2052 if ( !nMenuHeight )
2053 nMenuHeight = mnOrgMenuHeight;
2055 mpBorderView->GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder );
2056 mpMenuBarWindow->SetPosSizePixel( nLeftBorder,
2057 nTopBorder,
2058 aSize.Width()-nLeftBorder-nRightBorder,
2059 nMenuHeight,
2060 WINDOW_POSSIZE_POS |
2061 WINDOW_POSSIZE_WIDTH | WINDOW_POSSIZE_HEIGHT );
2064 GetBorder( pClientWindow->mpWindowImpl->mnLeftBorder, pClientWindow->mpWindowImpl->mnTopBorder,
2065 pClientWindow->mpWindowImpl->mnRightBorder, pClientWindow->mpWindowImpl->mnBottomBorder );
2066 pClientWindow->ImplPosSizeWindow( pClientWindow->mpWindowImpl->mnLeftBorder,
2067 pClientWindow->mpWindowImpl->mnTopBorder,
2068 aSize.Width()-pClientWindow->mpWindowImpl->mnLeftBorder-pClientWindow->mpWindowImpl->mnRightBorder,
2069 aSize.Height()-pClientWindow->mpWindowImpl->mnTopBorder-pClientWindow->mpWindowImpl->mnBottomBorder,
2070 WINDOW_POSSIZE_X | WINDOW_POSSIZE_Y |
2071 WINDOW_POSSIZE_WIDTH | WINDOW_POSSIZE_HEIGHT );
2074 // UpdateView
2075 mpBorderView->Init( this, aSize.Width(), aSize.Height() );
2076 InvalidateBorder();
2078 Window::Resize();
2081 // -----------------------------------------------------------------------
2083 void ImplBorderWindow::StateChanged( StateChangedType nType )
2085 if ( (nType == STATE_CHANGE_TEXT) ||
2086 (nType == STATE_CHANGE_IMAGE) ||
2087 (nType == STATE_CHANGE_DATA) )
2089 if ( IsReallyVisible() && mbFrameBorder )
2091 if ( HasPaintEvent() )
2092 InvalidateBorder();
2093 else
2094 mpBorderView->DrawWindow( BORDERWINDOW_DRAW_TITLE );
2098 Window::StateChanged( nType );
2101 // -----------------------------------------------------------------------
2103 void ImplBorderWindow::DataChanged( const DataChangedEvent& rDCEvt )
2105 if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
2106 (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
2107 ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
2108 (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
2110 if ( !mpWindowImpl->mbFrame || (GetStyle() & WB_OWNERDRAWDECORATION) )
2111 UpdateView( TRUE, ImplGetWindow()->GetOutputSizePixel() );
2114 Window::DataChanged( rDCEvt );
2117 // -----------------------------------------------------------------------
2119 void ImplBorderWindow::InitView()
2121 if ( mbSmallOutBorder )
2122 mpBorderView = new ImplSmallBorderWindowView( this );
2123 else if ( mpWindowImpl->mbFrame )
2125 if( mbFrameBorder )
2126 mpBorderView = new ImplStdBorderWindowView( this );
2127 else
2128 mpBorderView = new ImplNoBorderWindowView( this );
2130 else if ( !mbFrameBorder )
2131 mpBorderView = new ImplSmallBorderWindowView( this );
2132 else
2133 mpBorderView = new ImplStdBorderWindowView( this );
2134 Size aSize = GetOutputSizePixel();
2135 mpBorderView->Init( this, aSize.Width(), aSize.Height() );
2138 // -----------------------------------------------------------------------
2140 void ImplBorderWindow::UpdateView( BOOL bNewView, const Size& rNewOutSize )
2142 sal_Int32 nLeftBorder;
2143 sal_Int32 nTopBorder;
2144 sal_Int32 nRightBorder;
2145 sal_Int32 nBottomBorder;
2146 Size aOldSize = GetSizePixel();
2147 Size aOutputSize = rNewOutSize;
2149 if ( bNewView )
2151 delete mpBorderView;
2152 InitView();
2154 else
2156 Size aSize = aOutputSize;
2157 mpBorderView->GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder );
2158 aSize.Width() += nLeftBorder+nRightBorder;
2159 aSize.Height() += nTopBorder+nBottomBorder;
2160 mpBorderView->Init( this, aSize.Width(), aSize.Height() );
2163 Window* pClientWindow = ImplGetClientWindow();
2164 if ( pClientWindow )
2166 GetBorder( pClientWindow->mpWindowImpl->mnLeftBorder, pClientWindow->mpWindowImpl->mnTopBorder,
2167 pClientWindow->mpWindowImpl->mnRightBorder, pClientWindow->mpWindowImpl->mnBottomBorder );
2169 GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder );
2170 if ( aOldSize.Width() || aOldSize.Height() )
2172 aOutputSize.Width() += nLeftBorder+nRightBorder;
2173 aOutputSize.Height() += nTopBorder+nBottomBorder;
2174 if ( aOutputSize == GetSizePixel() )
2175 InvalidateBorder();
2176 else
2177 SetSizePixel( aOutputSize );
2181 // -----------------------------------------------------------------------
2183 void ImplBorderWindow::InvalidateBorder()
2185 if ( IsReallyVisible() )
2187 // Nur wenn wir einen Border haben, muessen wir auch invalidieren
2188 sal_Int32 nLeftBorder;
2189 sal_Int32 nTopBorder;
2190 sal_Int32 nRightBorder;
2191 sal_Int32 nBottomBorder;
2192 mpBorderView->GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder );
2193 if ( nLeftBorder || nTopBorder || nRightBorder || nBottomBorder )
2195 Rectangle aWinRect( Point( 0, 0 ), GetOutputSizePixel() );
2196 Region aRegion( aWinRect );
2197 aWinRect.Left() += nLeftBorder;
2198 aWinRect.Top() += nTopBorder;
2199 aWinRect.Right() -= nRightBorder;
2200 aWinRect.Bottom() -= nBottomBorder;
2201 // kein Output-Bereich mehr, dann alles invalidieren
2202 if ( (aWinRect.Right() < aWinRect.Left()) ||
2203 (aWinRect.Bottom() < aWinRect.Top()) )
2204 Invalidate( INVALIDATE_NOCHILDREN );
2205 else
2207 aRegion.Exclude( aWinRect );
2208 Invalidate( aRegion, INVALIDATE_NOCHILDREN );
2214 // -----------------------------------------------------------------------
2216 void ImplBorderWindow::SetDisplayActive( BOOL bActive )
2218 if ( mbDisplayActive != bActive )
2220 mbDisplayActive = bActive;
2221 if ( mbFrameBorder )
2222 InvalidateBorder();
2226 // -----------------------------------------------------------------------
2228 void ImplBorderWindow::SetTitleType( USHORT nTitleType, const Size& rSize )
2230 mnTitleType = nTitleType;
2231 UpdateView( FALSE, rSize );
2234 // -----------------------------------------------------------------------
2236 void ImplBorderWindow::SetBorderStyle( USHORT nStyle )
2238 if ( !mbFrameBorder && (mnBorderStyle != nStyle) )
2240 mnBorderStyle = nStyle;
2241 UpdateView( FALSE, ImplGetWindow()->GetOutputSizePixel() );
2245 // -----------------------------------------------------------------------
2247 void ImplBorderWindow::SetPin( BOOL bPin )
2249 mbPined = bPin;
2250 InvalidateBorder();
2253 // -----------------------------------------------------------------------
2255 void ImplBorderWindow::SetRollUp( BOOL bRollUp, const Size& rSize )
2257 mbRollUp = bRollUp;
2258 mnRollHeight = rSize.Height();
2259 UpdateView( FALSE, rSize );
2262 // -----------------------------------------------------------------------
2264 void ImplBorderWindow::SetCloser()
2266 SetStyle( GetStyle() | WB_CLOSEABLE );
2267 Size aSize = GetOutputSizePixel();
2268 mpBorderView->Init( this, aSize.Width(), aSize.Height() );
2269 InvalidateBorder();
2272 // -----------------------------------------------------------------------
2274 void ImplBorderWindow::SetDockButton( BOOL bDockButton )
2276 mbDockBtn = bDockButton;
2277 Size aSize = GetOutputSizePixel();
2278 mpBorderView->Init( this, aSize.Width(), aSize.Height() );
2279 InvalidateBorder();
2282 // -----------------------------------------------------------------------
2284 void ImplBorderWindow::SetHideButton( BOOL bHideButton )
2286 mbHideBtn = bHideButton;
2287 Size aSize = GetOutputSizePixel();
2288 mpBorderView->Init( this, aSize.Width(), aSize.Height() );
2289 InvalidateBorder();
2292 // -----------------------------------------------------------------------
2294 void ImplBorderWindow::SetHelpButton( BOOL bHelpButton )
2296 mbHelpBtn = bHelpButton;
2297 Size aSize = GetOutputSizePixel();
2298 mpBorderView->Init( this, aSize.Width(), aSize.Height() );
2299 InvalidateBorder();
2302 // -----------------------------------------------------------------------
2304 void ImplBorderWindow::SetMenuButton( BOOL bMenuButton )
2306 mbMenuBtn = bMenuButton;
2307 Size aSize = GetOutputSizePixel();
2308 mpBorderView->Init( this, aSize.Width(), aSize.Height() );
2309 InvalidateBorder();
2312 // -----------------------------------------------------------------------
2314 void ImplBorderWindow::UpdateMenuHeight()
2316 Resize();
2319 // -----------------------------------------------------------------------
2321 void ImplBorderWindow::SetMenuBarWindow( Window* pWindow )
2323 mpMenuBarWindow = pWindow;
2324 UpdateMenuHeight();
2325 if ( pWindow )
2326 pWindow->Show();
2329 // -----------------------------------------------------------------------
2331 void ImplBorderWindow::SetMenuBarMode( BOOL bHide )
2333 mbMenuHide = bHide;
2334 UpdateMenuHeight();
2337 // -----------------------------------------------------------------------
2339 void ImplBorderWindow::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
2340 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
2342 mpBorderView->GetBorder( rLeftBorder, rTopBorder, rRightBorder, rBottomBorder );
2343 if ( mpMenuBarWindow && !mbMenuHide )
2344 rTopBorder += mpMenuBarWindow->GetSizePixel().Height();
2347 // -----------------------------------------------------------------------
2349 long ImplBorderWindow::CalcTitleWidth() const
2351 return mpBorderView->CalcTitleWidth();
2354 Rectangle ImplBorderWindow::GetMenuRect() const
2356 return mpBorderView->GetMenuRect();