1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_vcl.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <svdata.hxx> 32*cdf0e10cSrcweir #include <brdwin.hxx> 33*cdf0e10cSrcweir #include <window.h> 34*cdf0e10cSrcweir #include <salframe.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <vcl/svapp.hxx> 37*cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 38*cdf0e10cSrcweir #include <vcl/event.hxx> 39*cdf0e10cSrcweir #include <vcl/toolbox.hxx> 40*cdf0e10cSrcweir #include <vcl/floatwin.hxx> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #include <tools/rc.h> 43*cdf0e10cSrcweir #include <tools/debug.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir // ======================================================================= 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir class FloatingWindow::ImplData 49*cdf0e10cSrcweir { 50*cdf0e10cSrcweir public: 51*cdf0e10cSrcweir ImplData(); 52*cdf0e10cSrcweir ~ImplData(); 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir ToolBox* mpBox; 55*cdf0e10cSrcweir Rectangle maItemEdgeClipRect; // used to clip the common edge between a toolbar item and the border of this window 56*cdf0e10cSrcweir }; 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir FloatingWindow::ImplData::ImplData() 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir mpBox = NULL; 61*cdf0e10cSrcweir } 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir FloatingWindow::ImplData::~ImplData() 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir Rectangle& FloatingWindow::ImplGetItemEdgeClipRect() 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir return mpImplData->maItemEdgeClipRect; 70*cdf0e10cSrcweir } 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir // ======================================================================= 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir void FloatingWindow::ImplInit( Window* pParent, WinBits nStyle ) 75*cdf0e10cSrcweir { 76*cdf0e10cSrcweir mpImplData = new ImplData; 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir mpWindowImpl->mbFloatWin = sal_True; 79*cdf0e10cSrcweir mbInCleanUp = sal_False; 80*cdf0e10cSrcweir mbGrabFocus = sal_False; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir DBG_ASSERT( pParent, "FloatWindow::FloatingWindow(): - pParent == NULL!" ); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir if ( !pParent ) 85*cdf0e10cSrcweir pParent = ImplGetSVData()->maWinData.mpAppWin; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir DBG_ASSERT( pParent, "FloatWindow::FloatingWindow(): - pParent == NULL and no AppWindow exists" ); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir // no Border, then we dont need a border window 90*cdf0e10cSrcweir if ( !nStyle ) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir mpWindowImpl->mbOverlapWin = sal_True; 93*cdf0e10cSrcweir nStyle |= WB_DIALOGCONTROL; 94*cdf0e10cSrcweir SystemWindow::ImplInit( pParent, nStyle, NULL ); 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir else 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir if ( !(nStyle & WB_NODIALOGCONTROL) ) 99*cdf0e10cSrcweir nStyle |= WB_DIALOGCONTROL; 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir if( nStyle & (WB_MOVEABLE | WB_SIZEABLE | WB_ROLLABLE | WB_CLOSEABLE | WB_STANDALONE) 102*cdf0e10cSrcweir && !(nStyle & WB_OWNERDRAWDECORATION) ) 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir WinBits nFloatWinStyle = nStyle; 105*cdf0e10cSrcweir // #99154# floaters are not closeable by default anymore, eg fullscreen floater 106*cdf0e10cSrcweir // nFloatWinStyle |= WB_CLOSEABLE; 107*cdf0e10cSrcweir mpWindowImpl->mbFrame = sal_True; 108*cdf0e10cSrcweir mpWindowImpl->mbOverlapWin = sal_True; 109*cdf0e10cSrcweir SystemWindow::ImplInit( pParent, nFloatWinStyle & ~WB_BORDER, NULL ); 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir else 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir ImplBorderWindow* pBorderWin; 114*cdf0e10cSrcweir sal_uInt16 nBorderStyle = BORDERWINDOW_STYLE_BORDER | BORDERWINDOW_STYLE_FLOAT; 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir if( nStyle & WB_OWNERDRAWDECORATION ) nBorderStyle |= BORDERWINDOW_STYLE_FRAME; 117*cdf0e10cSrcweir else nBorderStyle |= BORDERWINDOW_STYLE_OVERLAP; 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir if ( (nStyle & WB_SYSTEMWINDOW) && !(nStyle & (WB_MOVEABLE | WB_SIZEABLE)) ) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir nBorderStyle |= BORDERWINDOW_STYLE_FRAME; 122*cdf0e10cSrcweir nStyle |= WB_CLOSEABLE; // make undecorated floaters closeable 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir pBorderWin = new ImplBorderWindow( pParent, nStyle, nBorderStyle ); 125*cdf0e10cSrcweir SystemWindow::ImplInit( pBorderWin, nStyle & ~WB_BORDER, NULL ); 126*cdf0e10cSrcweir pBorderWin->mpWindowImpl->mpClientWindow = this; 127*cdf0e10cSrcweir pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder ); 128*cdf0e10cSrcweir pBorderWin->SetDisplayActive( sal_True ); 129*cdf0e10cSrcweir mpWindowImpl->mpBorderWindow = pBorderWin; 130*cdf0e10cSrcweir mpWindowImpl->mpRealParent = pParent; 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir SetActivateMode( 0 ); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir mpNextFloat = NULL; 136*cdf0e10cSrcweir mpFirstPopupModeWin = NULL; 137*cdf0e10cSrcweir mnPostId = 0; 138*cdf0e10cSrcweir mnTitle = (nStyle & WB_MOVEABLE) ? FLOATWIN_TITLE_NORMAL : FLOATWIN_TITLE_NONE; 139*cdf0e10cSrcweir mnOldTitle = mnTitle; 140*cdf0e10cSrcweir mnPopupModeFlags = 0; 141*cdf0e10cSrcweir mbInPopupMode = sal_False; 142*cdf0e10cSrcweir mbPopupMode = sal_False; 143*cdf0e10cSrcweir mbPopupModeCanceled = sal_False; 144*cdf0e10cSrcweir mbPopupModeTearOff = sal_False; 145*cdf0e10cSrcweir mbMouseDown = sal_False; 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir ImplInitSettings(); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir // ----------------------------------------------------------------------- 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir void FloatingWindow::ImplInitSettings() 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir Color aColor; 157*cdf0e10cSrcweir if ( IsControlBackground() ) 158*cdf0e10cSrcweir aColor = GetControlBackground(); 159*cdf0e10cSrcweir else if ( Window::GetStyle() & WB_3DLOOK ) 160*cdf0e10cSrcweir aColor = rStyleSettings.GetFaceColor(); 161*cdf0e10cSrcweir else 162*cdf0e10cSrcweir aColor = rStyleSettings.GetWindowColor(); 163*cdf0e10cSrcweir SetBackground( aColor ); 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir // ======================================================================= 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir FloatingWindow::FloatingWindow( Window* pParent, WinBits nStyle ) : 169*cdf0e10cSrcweir SystemWindow( WINDOW_FLOATINGWINDOW ) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir ImplInit( pParent, nStyle ); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir // ----------------------------------------------------------------------- 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir FloatingWindow::FloatingWindow( Window* pParent, const ResId& rResId ) : 177*cdf0e10cSrcweir SystemWindow( WINDOW_FLOATINGWINDOW ) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir rResId.SetRT( RSC_FLOATINGWINDOW ); 180*cdf0e10cSrcweir WinBits nStyle = ImplInitRes( rResId ); 181*cdf0e10cSrcweir ImplInit( pParent, nStyle ); 182*cdf0e10cSrcweir ImplLoadRes( rResId ); 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir if ( !(nStyle & WB_HIDE) ) 185*cdf0e10cSrcweir Show(); 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir // ----------------------------------------------------------------------- 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir void FloatingWindow::ImplLoadRes( const ResId& rResId ) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir SystemWindow::ImplLoadRes( rResId ); 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir sal_uLong nObjMask = ReadLongRes(); 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir if ( (RSC_FLOATINGWINDOW_WHMAPMODE | RSC_FLOATINGWINDOW_WIDTH | 197*cdf0e10cSrcweir RSC_FLOATINGWINDOW_HEIGHT) & nObjMask ) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir // Groessenangabe aus der Resource verwenden 200*cdf0e10cSrcweir Size aSize; 201*cdf0e10cSrcweir MapUnit eSizeMap = MAP_PIXEL; 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir if ( RSC_FLOATINGWINDOW_WHMAPMODE & nObjMask ) 204*cdf0e10cSrcweir eSizeMap = (MapUnit) ReadShortRes(); 205*cdf0e10cSrcweir if ( RSC_FLOATINGWINDOW_WIDTH & nObjMask ) 206*cdf0e10cSrcweir aSize.Width() = ReadShortRes(); 207*cdf0e10cSrcweir if ( RSC_FLOATINGWINDOW_HEIGHT & nObjMask ) 208*cdf0e10cSrcweir aSize.Height() = ReadShortRes(); 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir SetRollUpOutputSizePixel( LogicToPixel( aSize, eSizeMap ) ); 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir if (nObjMask & RSC_FLOATINGWINDOW_ZOOMIN ) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir if ( ReadShortRes() ) 216*cdf0e10cSrcweir RollUp(); 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir } 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir // ----------------------------------------------------------------------- 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir FloatingWindow::~FloatingWindow() 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir if( mbPopupModeCanceled ) 225*cdf0e10cSrcweir // indicates that ESC key was pressed 226*cdf0e10cSrcweir // will be handled in Window::ImplGrabFocus() 227*cdf0e10cSrcweir SetDialogControlFlags( GetDialogControlFlags() | WINDOW_DLGCTRL_FLOATWIN_POPUPMODEEND_CANCEL ); 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir if ( IsInPopupMode() ) 230*cdf0e10cSrcweir EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL | FLOATWIN_POPUPMODEEND_CLOSEALL | FLOATWIN_POPUPMODEEND_DONTCALLHDL ); 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir if ( mnPostId ) 233*cdf0e10cSrcweir Application::RemoveUserEvent( mnPostId ); 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir delete mpImplData; 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir // ----------------------------------------------------------------------- 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir Point FloatingWindow::CalcFloatingPosition( Window* pWindow, const Rectangle& rRect, sal_uLong nFlags, sal_uInt16& rArrangeIndex ) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir return ImplCalcPos( pWindow, rRect, nFlags, rArrangeIndex ); 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir // ----------------------------------------------------------------------- 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir Point FloatingWindow::ImplCalcPos( Window* pWindow, 248*cdf0e10cSrcweir const Rectangle& rRect, sal_uLong nFlags, 249*cdf0e10cSrcweir sal_uInt16& rArrangeIndex ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir // Fenster-Position ermitteln 252*cdf0e10cSrcweir Point aPos; 253*cdf0e10cSrcweir Size aSize = pWindow->GetSizePixel(); 254*cdf0e10cSrcweir Rectangle aScreenRect = pWindow->ImplGetFrameWindow()->GetDesktopRectPixel(); 255*cdf0e10cSrcweir FloatingWindow *pFloatingWindow = dynamic_cast<FloatingWindow*>( pWindow ); 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir // convert.... 258*cdf0e10cSrcweir Window* pW = pWindow; 259*cdf0e10cSrcweir if ( pW->mpWindowImpl->mpRealParent ) 260*cdf0e10cSrcweir pW = pW->mpWindowImpl->mpRealParent; 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir Rectangle normRect( rRect ); // rRect is already relative to top-level window 263*cdf0e10cSrcweir normRect.SetPos( pW->ScreenToOutputPixel( normRect.TopLeft() ) ); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir sal_Bool bRTL = Application::GetSettings().GetLayoutRTL(); 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir Rectangle devRect( pW->OutputToAbsoluteScreenPixel( normRect.TopLeft() ), 268*cdf0e10cSrcweir pW->OutputToAbsoluteScreenPixel( normRect.BottomRight() ) ); 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir Rectangle devRectRTL( devRect ); 271*cdf0e10cSrcweir if( bRTL ) 272*cdf0e10cSrcweir // create a rect that can be compared to desktop coordinates 273*cdf0e10cSrcweir devRectRTL = pW->ImplOutputToUnmirroredAbsoluteScreenPixel( normRect ); 274*cdf0e10cSrcweir if( Application::GetScreenCount() > 1 && ! Application::IsMultiDisplay() ) 275*cdf0e10cSrcweir aScreenRect = Application::GetScreenPosSizePixel( 276*cdf0e10cSrcweir Application::GetBestScreen( bRTL ? devRectRTL : devRect ) ); 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir sal_uInt16 nArrangeAry[5]; 280*cdf0e10cSrcweir sal_uInt16 nArrangeIndex; 281*cdf0e10cSrcweir sal_Bool bBreak; 282*cdf0e10cSrcweir Point e1,e2; // the common edge between the item rect and the floating window 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir if ( nFlags & FLOATWIN_POPUPMODE_LEFT ) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir nArrangeAry[0] = FLOATWIN_POPUPMODE_LEFT; 287*cdf0e10cSrcweir nArrangeAry[1] = FLOATWIN_POPUPMODE_RIGHT; 288*cdf0e10cSrcweir nArrangeAry[2] = FLOATWIN_POPUPMODE_UP; 289*cdf0e10cSrcweir nArrangeAry[3] = FLOATWIN_POPUPMODE_DOWN; 290*cdf0e10cSrcweir nArrangeAry[4] = FLOATWIN_POPUPMODE_LEFT; 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir else if ( nFlags & FLOATWIN_POPUPMODE_RIGHT ) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir nArrangeAry[0] = FLOATWIN_POPUPMODE_RIGHT; 295*cdf0e10cSrcweir nArrangeAry[1] = FLOATWIN_POPUPMODE_LEFT; 296*cdf0e10cSrcweir nArrangeAry[2] = FLOATWIN_POPUPMODE_UP; 297*cdf0e10cSrcweir nArrangeAry[3] = FLOATWIN_POPUPMODE_DOWN; 298*cdf0e10cSrcweir nArrangeAry[4] = FLOATWIN_POPUPMODE_RIGHT; 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir else if ( nFlags & FLOATWIN_POPUPMODE_UP ) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir nArrangeAry[0] = FLOATWIN_POPUPMODE_UP; 303*cdf0e10cSrcweir nArrangeAry[1] = FLOATWIN_POPUPMODE_DOWN; 304*cdf0e10cSrcweir nArrangeAry[2] = FLOATWIN_POPUPMODE_RIGHT; 305*cdf0e10cSrcweir nArrangeAry[3] = FLOATWIN_POPUPMODE_LEFT; 306*cdf0e10cSrcweir nArrangeAry[4] = FLOATWIN_POPUPMODE_UP; 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir else 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir nArrangeAry[0] = FLOATWIN_POPUPMODE_DOWN; 311*cdf0e10cSrcweir nArrangeAry[1] = FLOATWIN_POPUPMODE_UP; 312*cdf0e10cSrcweir nArrangeAry[2] = FLOATWIN_POPUPMODE_RIGHT; 313*cdf0e10cSrcweir nArrangeAry[3] = FLOATWIN_POPUPMODE_LEFT; 314*cdf0e10cSrcweir nArrangeAry[4] = FLOATWIN_POPUPMODE_DOWN; 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir if ( nFlags & FLOATWIN_POPUPMODE_NOAUTOARRANGE ) 317*cdf0e10cSrcweir nArrangeIndex = 4; 318*cdf0e10cSrcweir else 319*cdf0e10cSrcweir nArrangeIndex = 0; 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir for ( ; nArrangeIndex < 5; nArrangeIndex++ ) 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir bBreak = sal_True; 324*cdf0e10cSrcweir switch ( nArrangeAry[nArrangeIndex] ) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir case FLOATWIN_POPUPMODE_LEFT: 328*cdf0e10cSrcweir aPos.X() = devRect.Left()-aSize.Width()+1; 329*cdf0e10cSrcweir aPos.Y() = devRect.Top(); 330*cdf0e10cSrcweir aPos.Y() -= pWindow->mpWindowImpl->mnTopBorder; 331*cdf0e10cSrcweir if( bRTL ) // --- RTL --- we're comparing screen coordinates here 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir if( (devRectRTL.Right()+aSize.Width()) > aScreenRect.Right() ) 334*cdf0e10cSrcweir bBreak = sal_False; 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir else 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir if ( aPos.X() < aScreenRect.Left() ) 339*cdf0e10cSrcweir bBreak = sal_False; 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir if( bBreak ) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir e1 = devRect.TopLeft(); 344*cdf0e10cSrcweir e2 = devRect.BottomLeft(); 345*cdf0e10cSrcweir // set non-zero width 346*cdf0e10cSrcweir e2.X()++; 347*cdf0e10cSrcweir // don't clip corners 348*cdf0e10cSrcweir e1.Y()++; 349*cdf0e10cSrcweir e2.Y()--; 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir break; 352*cdf0e10cSrcweir case FLOATWIN_POPUPMODE_RIGHT: 353*cdf0e10cSrcweir aPos = devRect.TopRight(); 354*cdf0e10cSrcweir aPos.Y() -= pWindow->mpWindowImpl->mnTopBorder; 355*cdf0e10cSrcweir if( bRTL ) // --- RTL --- we're comparing screen coordinates here 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir if( (devRectRTL.Left() - aSize.Width()) < aScreenRect.Left() ) 358*cdf0e10cSrcweir bBreak = sal_False; 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir else 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir if ( aPos.X()+aSize.Width() > aScreenRect.Right() ) 363*cdf0e10cSrcweir bBreak = sal_False; 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir if( bBreak ) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir e1 = devRect.TopRight(); 368*cdf0e10cSrcweir e2 = devRect.BottomRight(); 369*cdf0e10cSrcweir // set non-zero width 370*cdf0e10cSrcweir e2.X()++; 371*cdf0e10cSrcweir // don't clip corners 372*cdf0e10cSrcweir e1.Y()++; 373*cdf0e10cSrcweir e2.Y()--; 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir break; 376*cdf0e10cSrcweir case FLOATWIN_POPUPMODE_UP: 377*cdf0e10cSrcweir aPos.X() = devRect.Left(); 378*cdf0e10cSrcweir aPos.Y() = devRect.Top()-aSize.Height()+1; 379*cdf0e10cSrcweir if ( aPos.Y() < aScreenRect.Top() ) 380*cdf0e10cSrcweir bBreak = sal_False; 381*cdf0e10cSrcweir if( bBreak ) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir e1 = devRect.TopLeft(); 384*cdf0e10cSrcweir e2 = devRect.TopRight(); 385*cdf0e10cSrcweir // set non-zero height 386*cdf0e10cSrcweir e2.Y()++; 387*cdf0e10cSrcweir // don't clip corners 388*cdf0e10cSrcweir e1.X()++; 389*cdf0e10cSrcweir e2.X()--; 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir break; 392*cdf0e10cSrcweir case FLOATWIN_POPUPMODE_DOWN: 393*cdf0e10cSrcweir aPos = devRect.BottomLeft(); 394*cdf0e10cSrcweir if ( aPos.Y()+aSize.Height() > aScreenRect.Bottom() ) 395*cdf0e10cSrcweir bBreak = sal_False; 396*cdf0e10cSrcweir if( bBreak ) 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir e1 = devRect.BottomLeft(); 399*cdf0e10cSrcweir e2 = devRect.BottomRight(); 400*cdf0e10cSrcweir // set non-zero height 401*cdf0e10cSrcweir e2.Y()++; 402*cdf0e10cSrcweir // don't clip corners 403*cdf0e10cSrcweir e1.X()++; 404*cdf0e10cSrcweir e2.X()--; 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir break; 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir // Evt. noch anpassen 410*cdf0e10cSrcweir if ( bBreak && !(nFlags & FLOATWIN_POPUPMODE_NOAUTOARRANGE) ) 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir if ( (nArrangeAry[nArrangeIndex] == FLOATWIN_POPUPMODE_LEFT) || 413*cdf0e10cSrcweir (nArrangeAry[nArrangeIndex] == FLOATWIN_POPUPMODE_RIGHT) ) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir if ( aPos.Y()+aSize.Height() > aScreenRect.Bottom() ) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir aPos.Y() = devRect.Bottom()-aSize.Height()+1; 418*cdf0e10cSrcweir if ( aPos.Y() < aScreenRect.Top() ) 419*cdf0e10cSrcweir aPos.Y() = aScreenRect.Top(); 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir else 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir if( bRTL ) // --- RTL --- we're comparing screen coordinates here 425*cdf0e10cSrcweir { 426*cdf0e10cSrcweir if( devRectRTL.Right()-aSize.Width()+1 < aScreenRect.Left() ) 427*cdf0e10cSrcweir aPos.X() -= aScreenRect.Left() - devRectRTL.Right() + aSize.Width() - 1; 428*cdf0e10cSrcweir else if( aPos.X() + aSize.Width() > aScreenRect.Right() ) 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir aPos.X() -= aSize.Width()-2; // popup to left instead 431*cdf0e10cSrcweir aPos.Y() -= 2; 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir else if ( aPos.X()+aSize.Width() > aScreenRect.Right() ) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir aPos.X() = devRect.Right()-aSize.Width()+1; 437*cdf0e10cSrcweir if ( aPos.X() < aScreenRect.Left() ) 438*cdf0e10cSrcweir aPos.X() = aScreenRect.Left(); 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir if ( bBreak ) 444*cdf0e10cSrcweir break; 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir if ( nArrangeIndex > 4 ) 447*cdf0e10cSrcweir nArrangeIndex = 4; 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir rArrangeIndex = nArrangeIndex; 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir aPos = pW->AbsoluteScreenToOutputPixel( aPos ); 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir // store a cliprect that can be used to clip the common edge of the itemrect and the floating window 454*cdf0e10cSrcweir if( pFloatingWindow ) 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir pFloatingWindow->mpImplData->maItemEdgeClipRect = 457*cdf0e10cSrcweir Rectangle( e1, e2 ); 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir // caller expects cordinates relative to top-level win 461*cdf0e10cSrcweir return pW->OutputToScreenPixel( aPos ); 462*cdf0e10cSrcweir } 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir // ----------------------------------------------------------------------- 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir FloatingWindow* FloatingWindow::ImplFloatHitTest( Window* pReference, const Point& rPos, sal_uInt16& rHitTest ) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir FloatingWindow* pWin = this; 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir Point aAbsolute( rPos ); 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir // compare coordinates in absolute screen coordinates 473*cdf0e10cSrcweir if( pReference->ImplHasMirroredGraphics() ) 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir if(!pReference->IsRTLEnabled() ) 476*cdf0e10cSrcweir // --- RTL --- re-mirror back to get device coordiantes 477*cdf0e10cSrcweir pReference->ImplReMirror( aAbsolute ); 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir Rectangle aRect( pReference->ScreenToOutputPixel(aAbsolute), Size(1,1) ) ; 480*cdf0e10cSrcweir aRect = pReference->ImplOutputToUnmirroredAbsoluteScreenPixel( aRect ); 481*cdf0e10cSrcweir aAbsolute = aRect.TopLeft(); 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir else 484*cdf0e10cSrcweir aAbsolute = Point( pReference->OutputToAbsoluteScreenPixel( 485*cdf0e10cSrcweir pReference->ScreenToOutputPixel(rPos) ) ); 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir do 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir // compute the floating window's size in absolute screen coordinates 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir // use the border window to have the exact position 492*cdf0e10cSrcweir Window *pBorderWin = pWin->GetWindow( WINDOW_BORDER ); 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir Point aPt; // the top-left corner in output coordinates ie (0,0) 495*cdf0e10cSrcweir Rectangle devRect( pBorderWin->ImplOutputToUnmirroredAbsoluteScreenPixel( Rectangle( aPt, pBorderWin->GetSizePixel()) ) ) ; 496*cdf0e10cSrcweir if ( devRect.IsInside( aAbsolute ) ) 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir rHitTest = IMPL_FLOATWIN_HITTEST_WINDOW; 499*cdf0e10cSrcweir return pWin; 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir // test, if mouse is in rectangle, (this is typically the rect of the active 503*cdf0e10cSrcweir // toolbox item or similar) 504*cdf0e10cSrcweir // note: maFloatRect is set in FloatingWindow::StartPopupMode() and 505*cdf0e10cSrcweir // is already in absolute device coordinates 506*cdf0e10cSrcweir if ( pWin->maFloatRect.IsInside( aAbsolute ) ) 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir rHitTest = IMPL_FLOATWIN_HITTEST_RECT; 509*cdf0e10cSrcweir return pWin; 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir pWin = pWin->mpNextFloat; 513*cdf0e10cSrcweir } 514*cdf0e10cSrcweir while ( pWin ); 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir rHitTest = IMPL_FLOATWIN_HITTEST_OUTSIDE; 517*cdf0e10cSrcweir return NULL; 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir // ----------------------------------------------------------------------- 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir FloatingWindow* FloatingWindow::ImplFindLastLevelFloat() 523*cdf0e10cSrcweir { 524*cdf0e10cSrcweir FloatingWindow* pWin = this; 525*cdf0e10cSrcweir FloatingWindow* pLastFoundWin = pWin; 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir do 528*cdf0e10cSrcweir { 529*cdf0e10cSrcweir if ( pWin->GetPopupModeFlags() & FLOATWIN_POPUPMODE_NEWLEVEL ) 530*cdf0e10cSrcweir pLastFoundWin = pWin; 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir pWin = pWin->mpNextFloat; 533*cdf0e10cSrcweir } 534*cdf0e10cSrcweir while ( pWin ); 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir return pLastFoundWin; 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir // ----------------------------------------------------------------------- 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir sal_Bool FloatingWindow::ImplIsFloatPopupModeWindow( const Window* pWindow ) 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir FloatingWindow* pWin = this; 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir do 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir if ( pWin->mpFirstPopupModeWin == pWindow ) 548*cdf0e10cSrcweir return sal_True; 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir pWin = pWin->mpNextFloat; 551*cdf0e10cSrcweir } 552*cdf0e10cSrcweir while ( pWin ); 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir return sal_False; 555*cdf0e10cSrcweir } 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir // ----------------------------------------------------------------------- 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir IMPL_LINK( FloatingWindow, ImplEndPopupModeHdl, void*, EMPTYARG ) 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir mnPostId = 0; 562*cdf0e10cSrcweir mnPopupModeFlags = 0; 563*cdf0e10cSrcweir mbPopupMode = sal_False; 564*cdf0e10cSrcweir PopupModeEnd(); 565*cdf0e10cSrcweir return 0; 566*cdf0e10cSrcweir } 567*cdf0e10cSrcweir 568*cdf0e10cSrcweir // ----------------------------------------------------------------------- 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir long FloatingWindow::Notify( NotifyEvent& rNEvt ) 571*cdf0e10cSrcweir { 572*cdf0e10cSrcweir // Zuerst Basisklasse rufen wegen TabSteuerung 573*cdf0e10cSrcweir long nRet = SystemWindow::Notify( rNEvt ); 574*cdf0e10cSrcweir if ( !nRet ) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir if ( rNEvt.GetType() == EVENT_KEYINPUT ) 577*cdf0e10cSrcweir { 578*cdf0e10cSrcweir const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); 579*cdf0e10cSrcweir KeyCode aKeyCode = pKEvt->GetKeyCode(); 580*cdf0e10cSrcweir sal_uInt16 nKeyCode = aKeyCode.GetCode(); 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir if ( (nKeyCode == KEY_ESCAPE) && (GetStyle() & WB_CLOSEABLE) ) 583*cdf0e10cSrcweir { 584*cdf0e10cSrcweir Close(); 585*cdf0e10cSrcweir return sal_True; 586*cdf0e10cSrcweir } 587*cdf0e10cSrcweir } 588*cdf0e10cSrcweir } 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir return nRet; 591*cdf0e10cSrcweir } 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir // ----------------------------------------------------------------------- 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir void FloatingWindow::StateChanged( StateChangedType nType ) 596*cdf0e10cSrcweir { 597*cdf0e10cSrcweir SystemWindow::StateChanged( nType ); 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir ImplInitSettings(); 602*cdf0e10cSrcweir Invalidate(); 603*cdf0e10cSrcweir } 604*cdf0e10cSrcweir } 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir // ----------------------------------------------------------------------- 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir void FloatingWindow::DataChanged( const DataChangedEvent& rDCEvt ) 609*cdf0e10cSrcweir { 610*cdf0e10cSrcweir SystemWindow::DataChanged( rDCEvt ); 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 613*cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 614*cdf0e10cSrcweir { 615*cdf0e10cSrcweir ImplInitSettings(); 616*cdf0e10cSrcweir Invalidate(); 617*cdf0e10cSrcweir } 618*cdf0e10cSrcweir } 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir // ----------------------------------------------------------------------- 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir void FloatingWindow::ImplCallPopupModeEnd() 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir // PopupMode wurde beendet 625*cdf0e10cSrcweir mbInPopupMode = sal_False; 626*cdf0e10cSrcweir 627*cdf0e10cSrcweir // Handler asyncron rufen 628*cdf0e10cSrcweir if ( !mnPostId ) 629*cdf0e10cSrcweir Application::PostUserEvent( mnPostId, LINK( this, FloatingWindow, ImplEndPopupModeHdl ) ); 630*cdf0e10cSrcweir } 631*cdf0e10cSrcweir 632*cdf0e10cSrcweir // ----------------------------------------------------------------------- 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir void FloatingWindow::PopupModeEnd() 635*cdf0e10cSrcweir { 636*cdf0e10cSrcweir maPopupModeEndHdl.Call( this ); 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir // ----------------------------------------------------------------------- 640*cdf0e10cSrcweir 641*cdf0e10cSrcweir void FloatingWindow::SetTitleType( sal_uInt16 nTitle ) 642*cdf0e10cSrcweir { 643*cdf0e10cSrcweir if ( (mnTitle != nTitle) && mpWindowImpl->mpBorderWindow ) 644*cdf0e10cSrcweir { 645*cdf0e10cSrcweir mnTitle = nTitle; 646*cdf0e10cSrcweir Size aOutSize = GetOutputSizePixel(); 647*cdf0e10cSrcweir sal_uInt16 nTitleStyle; 648*cdf0e10cSrcweir if ( nTitle == FLOATWIN_TITLE_NORMAL ) 649*cdf0e10cSrcweir nTitleStyle = BORDERWINDOW_TITLE_SMALL; 650*cdf0e10cSrcweir else if ( nTitle == FLOATWIN_TITLE_TEAROFF ) 651*cdf0e10cSrcweir nTitleStyle = BORDERWINDOW_TITLE_TEAROFF; 652*cdf0e10cSrcweir else // nTitle == FLOATWIN_TITLE_NONE 653*cdf0e10cSrcweir nTitleStyle = BORDERWINDOW_TITLE_NONE; 654*cdf0e10cSrcweir ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetTitleType( nTitleStyle, aOutSize ); 655*cdf0e10cSrcweir ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder ); 656*cdf0e10cSrcweir } 657*cdf0e10cSrcweir } 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir // ----------------------------------------------------------------------- 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir void FloatingWindow::StartPopupMode( const Rectangle& rRect, sal_uLong nFlags ) 662*cdf0e10cSrcweir { 663*cdf0e10cSrcweir // avoid flickering 664*cdf0e10cSrcweir if ( IsVisible() ) 665*cdf0e10cSrcweir Show( sal_False, SHOW_NOFOCUSCHANGE ); 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir if ( IsRollUp() ) 668*cdf0e10cSrcweir RollDown(); 669*cdf0e10cSrcweir 670*cdf0e10cSrcweir // remove title 671*cdf0e10cSrcweir mnOldTitle = mnTitle; 672*cdf0e10cSrcweir if ( nFlags & FLOATWIN_POPUPMODE_ALLOWTEAROFF ) 673*cdf0e10cSrcweir SetTitleType( FLOATWIN_TITLE_TEAROFF ); 674*cdf0e10cSrcweir else 675*cdf0e10cSrcweir SetTitleType( FLOATWIN_TITLE_NONE ); 676*cdf0e10cSrcweir 677*cdf0e10cSrcweir // avoid close on focus change for decorated floating windows only 678*cdf0e10cSrcweir if( mpWindowImpl->mbFrame && (GetStyle() & WB_MOVEABLE) ) 679*cdf0e10cSrcweir nFlags |= FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE; 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir // #102010# For debugging Accessibility 682*cdf0e10cSrcweir static const char* pEnv = getenv("SAL_FLOATWIN_NOAPPFOCUSCLOSE" ); 683*cdf0e10cSrcweir if( pEnv && *pEnv ) 684*cdf0e10cSrcweir nFlags |= FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE; 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir // compute window position according to flags and arrangement 687*cdf0e10cSrcweir sal_uInt16 nArrangeIndex; 688*cdf0e10cSrcweir SetPosPixel( ImplCalcPos( this, rRect, nFlags, nArrangeIndex ) ); 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir // set data and display window 691*cdf0e10cSrcweir // convert maFloatRect to absolute device coordinates 692*cdf0e10cSrcweir // so they can be compared across different frames 693*cdf0e10cSrcweir // !!! rRect is expected to be in screen coordinates of the parent frame window !!! 694*cdf0e10cSrcweir maFloatRect = rRect; 695*cdf0e10cSrcweir if( GetParent()->ImplHasMirroredGraphics() ) 696*cdf0e10cSrcweir { 697*cdf0e10cSrcweir maFloatRect.SetPos( GetParent()->ScreenToOutputPixel( rRect.TopLeft() ) ); 698*cdf0e10cSrcweir maFloatRect = GetParent()->ImplOutputToUnmirroredAbsoluteScreenPixel( maFloatRect ); 699*cdf0e10cSrcweir } 700*cdf0e10cSrcweir else 701*cdf0e10cSrcweir maFloatRect.SetPos( GetParent()->OutputToAbsoluteScreenPixel( GetParent()->ScreenToOutputPixel( rRect.TopLeft() ) ) ); 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir maFloatRect.Left() -= 2; 704*cdf0e10cSrcweir maFloatRect.Top() -= 2; 705*cdf0e10cSrcweir maFloatRect.Right() += 2; 706*cdf0e10cSrcweir maFloatRect.Bottom() += 2; 707*cdf0e10cSrcweir mnPopupModeFlags = nFlags; 708*cdf0e10cSrcweir mbInPopupMode = sal_True; 709*cdf0e10cSrcweir mbPopupMode = sal_True; 710*cdf0e10cSrcweir mbPopupModeCanceled = sal_False; 711*cdf0e10cSrcweir mbPopupModeTearOff = sal_False; 712*cdf0e10cSrcweir mbMouseDown = sal_False; 713*cdf0e10cSrcweir 714*cdf0e10cSrcweir mbOldSaveBackMode = IsSaveBackgroundEnabled(); 715*cdf0e10cSrcweir EnableSaveBackground(); 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir // add FloatingWindow to list of windows that are in popup mode 718*cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 719*cdf0e10cSrcweir mpNextFloat = pSVData->maWinData.mpFirstFloat; 720*cdf0e10cSrcweir pSVData->maWinData.mpFirstFloat = this; 721*cdf0e10cSrcweir if( nFlags & FLOATWIN_POPUPMODE_GRABFOCUS ) 722*cdf0e10cSrcweir { 723*cdf0e10cSrcweir // force key input even without focus (useful for menues) 724*cdf0e10cSrcweir mbGrabFocus = sal_True; 725*cdf0e10cSrcweir } 726*cdf0e10cSrcweir Show( sal_True, SHOW_NOACTIVATE ); 727*cdf0e10cSrcweir } 728*cdf0e10cSrcweir 729*cdf0e10cSrcweir // ----------------------------------------------------------------------- 730*cdf0e10cSrcweir 731*cdf0e10cSrcweir void FloatingWindow::StartPopupMode( ToolBox* pBox, sal_uLong nFlags ) 732*cdf0e10cSrcweir { 733*cdf0e10cSrcweir // get selected button 734*cdf0e10cSrcweir sal_uInt16 nItemId = pBox->GetDownItemId(); 735*cdf0e10cSrcweir if ( !nItemId ) 736*cdf0e10cSrcweir return; 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir mpImplData->mpBox = pBox; 739*cdf0e10cSrcweir pBox->ImplFloatControl( sal_True, this ); 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir // retrieve some data from the ToolBox 742*cdf0e10cSrcweir Rectangle aRect = pBox->GetItemRect( nItemId ); 743*cdf0e10cSrcweir Point aPos; 744*cdf0e10cSrcweir // convert to parent's screen coordinates 745*cdf0e10cSrcweir aPos = GetParent()->OutputToScreenPixel( GetParent()->AbsoluteScreenToOutputPixel( pBox->OutputToAbsoluteScreenPixel( aRect.TopLeft() ) ) ); 746*cdf0e10cSrcweir aRect.SetPos( aPos ); 747*cdf0e10cSrcweir 748*cdf0e10cSrcweir nFlags |= 749*cdf0e10cSrcweir FLOATWIN_POPUPMODE_NOFOCUSCLOSE | 750*cdf0e10cSrcweir // FLOATWIN_POPUPMODE_NOMOUSECLOSE | 751*cdf0e10cSrcweir FLOATWIN_POPUPMODE_ALLMOUSEBUTTONCLOSE | 752*cdf0e10cSrcweir // FLOATWIN_POPUPMODE_NOMOUSERECTCLOSE | // #105968# floating toolboxes should close when clicked in (parent's) float rect 753*cdf0e10cSrcweir FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE; 754*cdf0e10cSrcweir // | FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE; 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir /* 757*cdf0e10cSrcweir * FLOATWIN_POPUPMODE_NOKEYCLOSE | 758*cdf0e10cSrcweir * don't set since it disables closing floaters with escape 759*cdf0e10cSrcweir */ 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir // Flags fuer Positionierung bestimmen 762*cdf0e10cSrcweir if ( !(nFlags & (FLOATWIN_POPUPMODE_DOWN | FLOATWIN_POPUPMODE_UP | 763*cdf0e10cSrcweir FLOATWIN_POPUPMODE_LEFT | FLOATWIN_POPUPMODE_RIGHT | 764*cdf0e10cSrcweir FLOATWIN_POPUPMODE_NOAUTOARRANGE)) ) 765*cdf0e10cSrcweir { 766*cdf0e10cSrcweir if ( pBox->IsHorizontal() ) 767*cdf0e10cSrcweir nFlags |= FLOATWIN_POPUPMODE_DOWN; 768*cdf0e10cSrcweir else 769*cdf0e10cSrcweir nFlags |= FLOATWIN_POPUPMODE_RIGHT; 770*cdf0e10cSrcweir } 771*cdf0e10cSrcweir 772*cdf0e10cSrcweir // FloatingModus starten 773*cdf0e10cSrcweir StartPopupMode( aRect, nFlags ); 774*cdf0e10cSrcweir } 775*cdf0e10cSrcweir 776*cdf0e10cSrcweir // ----------------------------------------------------------------------- 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir void FloatingWindow::ImplEndPopupMode( sal_uInt16 nFlags, sal_uLong nFocusId ) 779*cdf0e10cSrcweir { 780*cdf0e10cSrcweir if ( !mbInPopupMode ) 781*cdf0e10cSrcweir return; 782*cdf0e10cSrcweir 783*cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir mbInCleanUp = sal_True; // prevent killing this window due to focus change while working with it 786*cdf0e10cSrcweir 787*cdf0e10cSrcweir // Bei allen nachfolgenden PopupMode-Fenster den Modus auch beenden 788*cdf0e10cSrcweir while ( pSVData->maWinData.mpFirstFloat && pSVData->maWinData.mpFirstFloat != this ) 789*cdf0e10cSrcweir pSVData->maWinData.mpFirstFloat->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL ); 790*cdf0e10cSrcweir 791*cdf0e10cSrcweir 792*cdf0e10cSrcweir // Fenster aus der Liste austragen 793*cdf0e10cSrcweir pSVData->maWinData.mpFirstFloat = mpNextFloat; 794*cdf0e10cSrcweir mpNextFloat = NULL; 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir sal_uLong nPopupModeFlags = mnPopupModeFlags; 797*cdf0e10cSrcweir 798*cdf0e10cSrcweir // Wenn nicht abgerissen wurde, dann Fenster wieder Hiden 799*cdf0e10cSrcweir if ( !(nFlags & FLOATWIN_POPUPMODEEND_TEAROFF) || 800*cdf0e10cSrcweir !(nPopupModeFlags & FLOATWIN_POPUPMODE_ALLOWTEAROFF) ) 801*cdf0e10cSrcweir { 802*cdf0e10cSrcweir Show( sal_False, SHOW_NOFOCUSCHANGE ); 803*cdf0e10cSrcweir 804*cdf0e10cSrcweir // Focus evt. auf ein entsprechendes FloatingWindow weiterschalten 805*cdf0e10cSrcweir if ( nFocusId ) 806*cdf0e10cSrcweir Window::EndSaveFocus( nFocusId ); 807*cdf0e10cSrcweir else if ( pSVData->maWinData.mpFocusWin && pSVData->maWinData.mpFirstFloat && 808*cdf0e10cSrcweir ImplIsWindowOrChild( pSVData->maWinData.mpFocusWin ) ) 809*cdf0e10cSrcweir pSVData->maWinData.mpFirstFloat->GrabFocus(); 810*cdf0e10cSrcweir mbPopupModeTearOff = sal_False; 811*cdf0e10cSrcweir } 812*cdf0e10cSrcweir else 813*cdf0e10cSrcweir { 814*cdf0e10cSrcweir mbPopupModeTearOff = sal_True; 815*cdf0e10cSrcweir if ( nFocusId ) 816*cdf0e10cSrcweir Window::EndSaveFocus( nFocusId, sal_False ); 817*cdf0e10cSrcweir } 818*cdf0e10cSrcweir EnableSaveBackground( mbOldSaveBackMode ); 819*cdf0e10cSrcweir 820*cdf0e10cSrcweir mbPopupModeCanceled = (nFlags & FLOATWIN_POPUPMODEEND_CANCEL) != 0; 821*cdf0e10cSrcweir 822*cdf0e10cSrcweir // Gegebenenfalls den Title wieder herstellen 823*cdf0e10cSrcweir SetTitleType( mnOldTitle ); 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir // ToolBox wieder auf normal schalten 826*cdf0e10cSrcweir if ( mpImplData->mpBox ) 827*cdf0e10cSrcweir { 828*cdf0e10cSrcweir mpImplData->mpBox->ImplFloatControl( sal_False, this ); 829*cdf0e10cSrcweir mpImplData->mpBox = NULL; 830*cdf0e10cSrcweir } 831*cdf0e10cSrcweir 832*cdf0e10cSrcweir // Je nach Parameter den PopupModeEnd-Handler rufen 833*cdf0e10cSrcweir if ( !(nFlags & FLOATWIN_POPUPMODEEND_DONTCALLHDL) ) 834*cdf0e10cSrcweir ImplCallPopupModeEnd(); 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir // Je nach Parameter die restlichen Fenster auch noch schliessen 837*cdf0e10cSrcweir if ( nFlags & FLOATWIN_POPUPMODEEND_CLOSEALL ) 838*cdf0e10cSrcweir { 839*cdf0e10cSrcweir if ( !(nPopupModeFlags & FLOATWIN_POPUPMODE_NEWLEVEL) ) 840*cdf0e10cSrcweir { 841*cdf0e10cSrcweir if ( pSVData->maWinData.mpFirstFloat ) 842*cdf0e10cSrcweir { 843*cdf0e10cSrcweir FloatingWindow* pLastLevelFloat = pSVData->maWinData.mpFirstFloat->ImplFindLastLevelFloat(); 844*cdf0e10cSrcweir pLastLevelFloat->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL | FLOATWIN_POPUPMODEEND_CLOSEALL ); 845*cdf0e10cSrcweir } 846*cdf0e10cSrcweir } 847*cdf0e10cSrcweir } 848*cdf0e10cSrcweir 849*cdf0e10cSrcweir mbInCleanUp = sal_False; 850*cdf0e10cSrcweir } 851*cdf0e10cSrcweir 852*cdf0e10cSrcweir // ----------------------------------------------------------------------- 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir void FloatingWindow::EndPopupMode( sal_uInt16 nFlags ) 855*cdf0e10cSrcweir { 856*cdf0e10cSrcweir ImplEndPopupMode( nFlags ); 857*cdf0e10cSrcweir } 858*cdf0e10cSrcweir 859*cdf0e10cSrcweir // ----------------------------------------------------------------------- 860*cdf0e10cSrcweir 861*cdf0e10cSrcweir void FloatingWindow::AddPopupModeWindow( Window* pWindow ) 862*cdf0e10cSrcweir { 863*cdf0e10cSrcweir // !!! bisher erst 1 Fenster und noch keine Liste 864*cdf0e10cSrcweir mpFirstPopupModeWin = pWindow; 865*cdf0e10cSrcweir } 866*cdf0e10cSrcweir 867*cdf0e10cSrcweir // ----------------------------------------------------------------------- 868*cdf0e10cSrcweir 869*cdf0e10cSrcweir void FloatingWindow::RemovePopupModeWindow( Window* pWindow ) 870*cdf0e10cSrcweir { 871*cdf0e10cSrcweir // !!! bisher erst 1 Fenster und noch keine Liste 872*cdf0e10cSrcweir if ( mpFirstPopupModeWin == pWindow ) 873*cdf0e10cSrcweir mpFirstPopupModeWin = NULL; 874*cdf0e10cSrcweir } 875*cdf0e10cSrcweir 876