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 <string> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include "rtl/ustrbuf.hxx" 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include "osl/file.h" 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include "vcl/svapp.hxx" 38*cdf0e10cSrcweir #include "vcl/window.hxx" 39*cdf0e10cSrcweir #include "vcl/timer.hxx" 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include "aqua/saldata.hxx" 42*cdf0e10cSrcweir #include "aqua/salgdi.h" 43*cdf0e10cSrcweir #include "aqua/salframe.h" 44*cdf0e10cSrcweir #include "aqua/salmenu.h" 45*cdf0e10cSrcweir #include "aqua/saltimer.h" 46*cdf0e10cSrcweir #include "aqua/salinst.h" 47*cdf0e10cSrcweir #include "aqua/salframeview.h" 48*cdf0e10cSrcweir #include "aqua/aqua11yfactory.h" 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #include "salwtype.hxx" 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #include "premac.h" 53*cdf0e10cSrcweir // needed for theming 54*cdf0e10cSrcweir // FIXME: move theming code to salnativewidgets.cxx 55*cdf0e10cSrcweir #include <Carbon/Carbon.h> 56*cdf0e10cSrcweir #include "postmac.h" 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir using namespace std; 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir // ======================================================================= 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir AquaSalFrame* AquaSalFrame::s_pCaptureFrame = NULL; 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir // ======================================================================= 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir AquaSalFrame::AquaSalFrame( SalFrame* pParent, sal_uLong salFrameStyle ) : 68*cdf0e10cSrcweir mpWindow(nil), 69*cdf0e10cSrcweir mpView(nil), 70*cdf0e10cSrcweir mpDockMenuEntry(nil), 71*cdf0e10cSrcweir mpGraphics(NULL), 72*cdf0e10cSrcweir mpParent(NULL), 73*cdf0e10cSrcweir mnMinWidth(0), 74*cdf0e10cSrcweir mnMinHeight(0), 75*cdf0e10cSrcweir mnMaxWidth(0), 76*cdf0e10cSrcweir mnMaxHeight(0), 77*cdf0e10cSrcweir mbGraphics(false), 78*cdf0e10cSrcweir mbFullScreen( false ), 79*cdf0e10cSrcweir mbShown(false), 80*cdf0e10cSrcweir mbInitShow(true), 81*cdf0e10cSrcweir mbPositioned(false), 82*cdf0e10cSrcweir mbSized(false), 83*cdf0e10cSrcweir mbPresentation( false ), 84*cdf0e10cSrcweir mnStyle( salFrameStyle ), 85*cdf0e10cSrcweir mnStyleMask( 0 ), 86*cdf0e10cSrcweir mnLastEventTime( 0 ), 87*cdf0e10cSrcweir mnLastModifierFlags( 0 ), 88*cdf0e10cSrcweir mpMenu( NULL ), 89*cdf0e10cSrcweir mnExtStyle( 0 ), 90*cdf0e10cSrcweir mePointerStyle( POINTER_ARROW ), 91*cdf0e10cSrcweir mnTrackingRectTag( 0 ), 92*cdf0e10cSrcweir mrClippingPath( 0 ), 93*cdf0e10cSrcweir mnICOptions( 0 ) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir maSysData.nSize = sizeof( SystemEnvData ); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir mpParent = dynamic_cast<AquaSalFrame*>(pParent); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir initWindowAndView(); 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir SalData* pSalData = GetSalData(); 102*cdf0e10cSrcweir pSalData->maFrames.push_front( this ); 103*cdf0e10cSrcweir pSalData->maFrameCheck.insert( this ); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir // ----------------------------------------------------------------------- 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir AquaSalFrame::~AquaSalFrame() 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir // if the frame is destroyed and has the current menubar 111*cdf0e10cSrcweir // set the default menubar 112*cdf0e10cSrcweir if( mpMenu && mpMenu->mbMenuBar && AquaSalMenu::pCurrentMenuBar == mpMenu ) 113*cdf0e10cSrcweir AquaSalMenu::setDefaultMenu(); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir // cleanup clipping stuff 116*cdf0e10cSrcweir ResetClipRegion(); 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir [SalFrameView unsetMouseFrame: this]; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir SalData* pSalData = GetSalData(); 121*cdf0e10cSrcweir pSalData->maFrames.remove( this ); 122*cdf0e10cSrcweir pSalData->maFrameCheck.erase( this ); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir DBG_ASSERT( this != s_pCaptureFrame, "capture frame destroyed" ); 125*cdf0e10cSrcweir if( this == s_pCaptureFrame ) 126*cdf0e10cSrcweir s_pCaptureFrame = NULL; 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir if ( mpGraphics ) 129*cdf0e10cSrcweir delete mpGraphics; 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir if( mpDockMenuEntry ) 132*cdf0e10cSrcweir // life cycle comment: the menu has ownership of the item, so no release 133*cdf0e10cSrcweir [AquaSalInstance::GetDynamicDockMenu() removeItem: mpDockMenuEntry]; 134*cdf0e10cSrcweir if ( mpView ) { 135*cdf0e10cSrcweir [AquaA11yFactory revokeView: mpView]; 136*cdf0e10cSrcweir [mpView release]; 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir if ( mpWindow ) 139*cdf0e10cSrcweir [mpWindow release]; 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir // ----------------------------------------------------------------------- 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir void AquaSalFrame::initWindowAndView() 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir // initialize mirroring parameters 147*cdf0e10cSrcweir // FIXME: screens changing 148*cdf0e10cSrcweir NSScreen * pScreen = [mpWindow screen]; 149*cdf0e10cSrcweir if( pScreen == nil ) 150*cdf0e10cSrcweir pScreen = [NSScreen mainScreen]; 151*cdf0e10cSrcweir maScreenRect = [pScreen frame]; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir // calculate some default geometry 154*cdf0e10cSrcweir NSRect aVisibleRect = [pScreen visibleFrame]; 155*cdf0e10cSrcweir CocoaToVCL( aVisibleRect ); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir maGeometry.nX = static_cast<int>(aVisibleRect.origin.x + aVisibleRect.size.width / 10); 158*cdf0e10cSrcweir maGeometry.nY = static_cast<int>(aVisibleRect.origin.y + aVisibleRect.size.height / 10); 159*cdf0e10cSrcweir maGeometry.nWidth = static_cast<unsigned int>(aVisibleRect.size.width * 0.8); 160*cdf0e10cSrcweir maGeometry.nHeight = static_cast<unsigned int>(aVisibleRect.size.height * 0.8); 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir // calculate style mask 163*cdf0e10cSrcweir if( (mnStyle & SAL_FRAME_STYLE_FLOAT) || 164*cdf0e10cSrcweir (mnStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) ) 165*cdf0e10cSrcweir mnStyleMask = NSBorderlessWindowMask; 166*cdf0e10cSrcweir else if( mnStyle & SAL_FRAME_STYLE_DEFAULT ) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir mnStyleMask = NSTitledWindowMask | 169*cdf0e10cSrcweir NSMiniaturizableWindowMask | 170*cdf0e10cSrcweir NSResizableWindowMask | 171*cdf0e10cSrcweir NSClosableWindowMask; 172*cdf0e10cSrcweir // make default window "maximized" 173*cdf0e10cSrcweir maGeometry.nX = static_cast<int>(aVisibleRect.origin.x); 174*cdf0e10cSrcweir maGeometry.nY = static_cast<int>(aVisibleRect.origin.y); 175*cdf0e10cSrcweir maGeometry.nWidth = static_cast<int>(aVisibleRect.size.width); 176*cdf0e10cSrcweir maGeometry.nHeight = static_cast<int>(aVisibleRect.size.height); 177*cdf0e10cSrcweir mbPositioned = mbSized = true; 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir else 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir if( (mnStyle & SAL_FRAME_STYLE_MOVEABLE) ) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir mnStyleMask |= NSTitledWindowMask; 184*cdf0e10cSrcweir if( mpParent == NULL ) 185*cdf0e10cSrcweir mnStyleMask |= NSMiniaturizableWindowMask; 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir if( (mnStyle & SAL_FRAME_STYLE_SIZEABLE) ) 188*cdf0e10cSrcweir mnStyleMask |= NSResizableWindowMask; 189*cdf0e10cSrcweir if( (mnStyle & SAL_FRAME_STYLE_CLOSEABLE) ) 190*cdf0e10cSrcweir mnStyleMask |= NSClosableWindowMask; 191*cdf0e10cSrcweir // documentation says anything other than NSBorderlessWindowMask (=0) 192*cdf0e10cSrcweir // should also include NSTitledWindowMask; 193*cdf0e10cSrcweir if( mnStyleMask != 0 ) 194*cdf0e10cSrcweir mnStyleMask |= NSTitledWindowMask; 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir // #i91990# support GUI-less (daemon) execution 198*cdf0e10cSrcweir @try 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir mpWindow = [[SalFrameWindow alloc] initWithSalFrame: this]; 201*cdf0e10cSrcweir mpView = [[SalFrameView alloc] initWithSalFrame: this]; 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir @catch ( id exception ) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir return; 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir if( (mnStyle & SAL_FRAME_STYLE_TOOLTIP) ) 209*cdf0e10cSrcweir [mpWindow setIgnoresMouseEvents: YES]; 210*cdf0e10cSrcweir else 211*cdf0e10cSrcweir [mpWindow setAcceptsMouseMovedEvents: YES]; 212*cdf0e10cSrcweir [mpWindow setHasShadow: YES]; 213*cdf0e10cSrcweir [mpWindow setDelegate: mpWindow]; 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir NSRect aRect = { { 0,0 }, { maGeometry.nWidth, maGeometry.nHeight } }; 216*cdf0e10cSrcweir mnTrackingRectTag = [mpView addTrackingRect: aRect owner: mpView userData: nil assumeInside: NO]; 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir maSysData.pView = mpView; 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir UpdateFrameGeometry(); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir [mpWindow setContentView: mpView]; 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir // ----------------------------------------------------------------------- 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir void AquaSalFrame::CocoaToVCL( NSRect& io_rRect, bool bRelativeToScreen ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir if( bRelativeToScreen ) 230*cdf0e10cSrcweir io_rRect.origin.y = maScreenRect.size.height - (io_rRect.origin.y+io_rRect.size.height); 231*cdf0e10cSrcweir else 232*cdf0e10cSrcweir io_rRect.origin.y = maGeometry.nHeight - (io_rRect.origin.y+io_rRect.size.height); 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir void AquaSalFrame::VCLToCocoa( NSRect& io_rRect, bool bRelativeToScreen ) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir if( bRelativeToScreen ) 238*cdf0e10cSrcweir io_rRect.origin.y = maScreenRect.size.height - (io_rRect.origin.y+io_rRect.size.height); 239*cdf0e10cSrcweir else 240*cdf0e10cSrcweir io_rRect.origin.y = maGeometry.nHeight - (io_rRect.origin.y+io_rRect.size.height); 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir void AquaSalFrame::CocoaToVCL( NSPoint& io_rPoint, bool bRelativeToScreen ) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir if( bRelativeToScreen ) 246*cdf0e10cSrcweir io_rPoint.y = maScreenRect.size.height - io_rPoint.y; 247*cdf0e10cSrcweir else 248*cdf0e10cSrcweir io_rPoint.y = maGeometry.nHeight - io_rPoint.y; 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir void AquaSalFrame::VCLToCocoa( NSPoint& io_rPoint, bool bRelativeToScreen ) 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir if( bRelativeToScreen ) 254*cdf0e10cSrcweir io_rPoint.y = maScreenRect.size.height - io_rPoint.y; 255*cdf0e10cSrcweir else 256*cdf0e10cSrcweir io_rPoint.y = maGeometry.nHeight - io_rPoint.y; 257*cdf0e10cSrcweir } 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir // ----------------------------------------------------------------------- 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir void AquaSalFrame::screenParametersChanged() 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir UpdateFrameGeometry(); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir if( mpGraphics ) 266*cdf0e10cSrcweir mpGraphics->updateResolution(); 267*cdf0e10cSrcweir CallCallback( SALEVENT_DISPLAYCHANGED, 0 ); 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir // ----------------------------------------------------------------------- 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir SalGraphics* AquaSalFrame::GetGraphics() 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir if ( mbGraphics ) 275*cdf0e10cSrcweir return NULL; 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir if ( !mpGraphics ) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir mpGraphics = new AquaSalGraphics; 280*cdf0e10cSrcweir mpGraphics->SetWindowGraphics( this ); 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir mbGraphics = TRUE; 284*cdf0e10cSrcweir return mpGraphics; 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir // ----------------------------------------------------------------------- 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir void AquaSalFrame::ReleaseGraphics( SalGraphics *pGraphics ) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir (void)pGraphics; 292*cdf0e10cSrcweir DBG_ASSERT( pGraphics == mpGraphics, "graphics released on wrong frame" ); 293*cdf0e10cSrcweir mbGraphics = FALSE; 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir // ----------------------------------------------------------------------- 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir sal_Bool AquaSalFrame::PostEvent( void *pData ) 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir GetSalData()->mpFirstInstance->PostUserEvent( this, SALEVENT_USEREVENT, pData ); 301*cdf0e10cSrcweir return TRUE; 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir // ----------------------------------------------------------------------- 305*cdf0e10cSrcweir void AquaSalFrame::SetTitle(const XubString& rTitle) 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir if ( !mpWindow ) 308*cdf0e10cSrcweir return; 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 311*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir NSString* pTitle = CreateNSString( rTitle ); 314*cdf0e10cSrcweir [mpWindow setTitle: pTitle]; 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir // create an entry in the dock menu 317*cdf0e10cSrcweir const sal_uLong nAppWindowStyle = (SAL_FRAME_STYLE_CLOSEABLE | SAL_FRAME_STYLE_MOVEABLE); 318*cdf0e10cSrcweir if( mpParent == NULL && 319*cdf0e10cSrcweir (mnStyle & nAppWindowStyle) == nAppWindowStyle ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir if( mpDockMenuEntry == NULL ) 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir NSMenu* pDock = AquaSalInstance::GetDynamicDockMenu(); 324*cdf0e10cSrcweir mpDockMenuEntry = [pDock insertItemWithTitle: pTitle 325*cdf0e10cSrcweir action: @selector(dockMenuItemTriggered:) 326*cdf0e10cSrcweir keyEquivalent: @"" 327*cdf0e10cSrcweir atIndex: 0]; 328*cdf0e10cSrcweir [mpDockMenuEntry setTarget: mpWindow]; 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir // TODO: image (either the generic window image or an icon 331*cdf0e10cSrcweir // check mark (for "main" window ?) 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir else 334*cdf0e10cSrcweir [mpDockMenuEntry setTitle: pTitle]; 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir if (pTitle) 338*cdf0e10cSrcweir [pTitle release]; 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir // ----------------------------------------------------------------------- 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir void AquaSalFrame::SetIcon( sal_uInt16 ) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir // ----------------------------------------------------------------------- 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir void AquaSalFrame::SetRepresentedURL( const rtl::OUString& i_rDocURL ) 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 352*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir if( i_rDocURL.indexOfAsciiL( "file:", 5 ) == 0 ) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir rtl::OUString aSysPath; 357*cdf0e10cSrcweir osl_getSystemPathFromFileURL( i_rDocURL.pData, &aSysPath.pData ); 358*cdf0e10cSrcweir NSString* pStr = CreateNSString( aSysPath ); 359*cdf0e10cSrcweir if( pStr ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir [pStr autorelease]; 362*cdf0e10cSrcweir [mpWindow setRepresentedFilename: pStr]; 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir // ----------------------------------------------------------------------- 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir void AquaSalFrame::initShow() 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir mbInitShow = false; 372*cdf0e10cSrcweir if( ! mbPositioned && ! mbFullScreen ) 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir Rectangle aScreenRect; 375*cdf0e10cSrcweir GetWorkArea( aScreenRect ); 376*cdf0e10cSrcweir if( mpParent ) // center relative to parent 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir // center on parent 379*cdf0e10cSrcweir long nNewX = mpParent->maGeometry.nX + ((long)mpParent->maGeometry.nWidth - (long)maGeometry.nWidth)/2; 380*cdf0e10cSrcweir if( nNewX < aScreenRect.Left() ) 381*cdf0e10cSrcweir nNewX = aScreenRect.Left(); 382*cdf0e10cSrcweir if( long(nNewX + maGeometry.nWidth) > aScreenRect.Right() ) 383*cdf0e10cSrcweir nNewX = aScreenRect.Right() - maGeometry.nWidth-1; 384*cdf0e10cSrcweir long nNewY = mpParent->maGeometry.nY + ((long)mpParent->maGeometry.nHeight - (long)maGeometry.nHeight)/2; 385*cdf0e10cSrcweir if( nNewY < aScreenRect.Top() ) 386*cdf0e10cSrcweir nNewY = aScreenRect.Top(); 387*cdf0e10cSrcweir if( nNewY > aScreenRect.Bottom() ) 388*cdf0e10cSrcweir nNewY = aScreenRect.Bottom() - maGeometry.nHeight-1; 389*cdf0e10cSrcweir SetPosSize( nNewX - mpParent->maGeometry.nX, 390*cdf0e10cSrcweir nNewY - mpParent->maGeometry.nY, 391*cdf0e10cSrcweir 0, 0, SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y ); 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir else if( ! (mnStyle & SAL_FRAME_STYLE_SIZEABLE) ) 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir // center on screen 396*cdf0e10cSrcweir long nNewX = (aScreenRect.GetWidth() - maGeometry.nWidth)/2; 397*cdf0e10cSrcweir long nNewY = (aScreenRect.GetHeight() - maGeometry.nHeight)/2; 398*cdf0e10cSrcweir SetPosSize( nNewX, nNewY, 0, 0, SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y ); 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir // make sure the view is present in the wrapper list before any children receive focus 403*cdf0e10cSrcweir [AquaA11yFactory registerView: mpView]; 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir void AquaSalFrame::SendPaintEvent( const Rectangle* pRect ) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir SalPaintEvent aPaintEvt( 0, 0, maGeometry.nWidth, maGeometry.nHeight, true ); 409*cdf0e10cSrcweir if( pRect ) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir aPaintEvt.mnBoundX = pRect->Left(); 412*cdf0e10cSrcweir aPaintEvt.mnBoundY = pRect->Top(); 413*cdf0e10cSrcweir aPaintEvt.mnBoundWidth = pRect->GetWidth(); 414*cdf0e10cSrcweir aPaintEvt.mnBoundHeight = pRect->GetHeight(); 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir CallCallback(SALEVENT_PAINT, &aPaintEvt); 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir // ----------------------------------------------------------------------- 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir void AquaSalFrame::Show(sal_Bool bVisible, sal_Bool bNoActivate) 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir if ( !mpWindow ) 425*cdf0e10cSrcweir return; 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 428*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir mbShown = bVisible; 431*cdf0e10cSrcweir if(bVisible) 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir if( mbInitShow ) 434*cdf0e10cSrcweir initShow(); 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir CallCallback(SALEVENT_RESIZE, 0); 437*cdf0e10cSrcweir // trigger filling our backbuffer 438*cdf0e10cSrcweir SendPaintEvent(); 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir if( bNoActivate || [mpWindow canBecomeKeyWindow] == NO ) 441*cdf0e10cSrcweir [mpWindow orderFront: NSApp]; 442*cdf0e10cSrcweir else 443*cdf0e10cSrcweir [mpWindow makeKeyAndOrderFront: NSApp]; 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir if( mpParent ) 446*cdf0e10cSrcweir { 447*cdf0e10cSrcweir /* #i92674# #i96433# we do not want an invisible parent to show up (which adding a visible 448*cdf0e10cSrcweir child implicitly does). However we also do not want a parentless toolbar. 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir HACK: try to decide when we should not insert a child to its parent 451*cdf0e10cSrcweir floaters and ownerdraw windows have not yet shown up in cases where 452*cdf0e10cSrcweir we don't want the parent to become visible 453*cdf0e10cSrcweir */ 454*cdf0e10cSrcweir if( mpParent->mbShown || (mnStyle & (SAL_FRAME_STYLE_OWNERDRAWDECORATION | SAL_FRAME_STYLE_FLOAT) ) ) 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir [mpParent->mpWindow addChildWindow: mpWindow ordered: NSWindowAbove]; 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir if( mbPresentation ) 461*cdf0e10cSrcweir [mpWindow makeMainWindow]; 462*cdf0e10cSrcweir } 463*cdf0e10cSrcweir else 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir // if the frame holding the current menubar gets hidden 466*cdf0e10cSrcweir // show the default menubar 467*cdf0e10cSrcweir if( mpMenu && mpMenu->mbMenuBar && AquaSalMenu::pCurrentMenuBar == mpMenu ) 468*cdf0e10cSrcweir AquaSalMenu::setDefaultMenu(); 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir // #i90440# #i94443# work around the focus going back to some other window 471*cdf0e10cSrcweir // if a child gets hidden for a parent window 472*cdf0e10cSrcweir if( mpParent && mpParent->mbShown && [mpWindow isKeyWindow] ) 473*cdf0e10cSrcweir [mpParent->mpWindow makeKeyAndOrderFront: NSApp]; 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir [SalFrameView unsetMouseFrame: this]; 476*cdf0e10cSrcweir if( mpParent && [mpWindow parentWindow] == mpParent->mpWindow ) 477*cdf0e10cSrcweir [mpParent->mpWindow removeChildWindow: mpWindow]; 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir [mpWindow orderOut: NSApp]; 480*cdf0e10cSrcweir } 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir // ----------------------------------------------------------------------- 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir void AquaSalFrame::Enable( sal_Bool ) 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir } 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir // ----------------------------------------------------------------------- 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir void AquaSalFrame::SetMinClientSize( long nWidth, long nHeight ) 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 494*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir mnMinWidth = nWidth; 497*cdf0e10cSrcweir mnMinHeight = nHeight; 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir if( mpWindow ) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir // Always add the decoration as the dimension concerns only 502*cdf0e10cSrcweir // the content rectangle 503*cdf0e10cSrcweir nWidth += maGeometry.nLeftDecoration + maGeometry.nRightDecoration; 504*cdf0e10cSrcweir nHeight += maGeometry.nTopDecoration + maGeometry.nBottomDecoration; 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir NSSize aSize = { nWidth, nHeight }; 507*cdf0e10cSrcweir 508*cdf0e10cSrcweir // Size of full window (content+structure) although we only 509*cdf0e10cSrcweir // have the client size in arguments 510*cdf0e10cSrcweir [mpWindow setMinSize: aSize]; 511*cdf0e10cSrcweir } 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir // ----------------------------------------------------------------------- 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir void AquaSalFrame::SetMaxClientSize( long nWidth, long nHeight ) 517*cdf0e10cSrcweir { 518*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 519*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir mnMaxWidth = nWidth; 522*cdf0e10cSrcweir mnMaxHeight = nHeight; 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir if( mpWindow ) 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir // Always add the decoration as the dimension concerns only 527*cdf0e10cSrcweir // the content rectangle 528*cdf0e10cSrcweir nWidth += maGeometry.nLeftDecoration + maGeometry.nRightDecoration; 529*cdf0e10cSrcweir nHeight += maGeometry.nTopDecoration + maGeometry.nBottomDecoration; 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir // Carbon windows can't have a size greater than 32767x32767 532*cdf0e10cSrcweir if (nWidth>32767) nWidth=32767; 533*cdf0e10cSrcweir if (nHeight>32767) nHeight=32767; 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir NSSize aSize = { nWidth, nHeight }; 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir // Size of full window (content+structure) although we only 538*cdf0e10cSrcweir // have the client size in arguments 539*cdf0e10cSrcweir [mpWindow setMaxSize: aSize]; 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir // ----------------------------------------------------------------------- 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir void AquaSalFrame::SetClientSize( long nWidth, long nHeight ) 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 548*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir if( mpWindow ) 551*cdf0e10cSrcweir { 552*cdf0e10cSrcweir NSSize aSize = { nWidth, nHeight }; 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir [mpWindow setContentSize: aSize]; 555*cdf0e10cSrcweir UpdateFrameGeometry(); 556*cdf0e10cSrcweir if( mbShown ) 557*cdf0e10cSrcweir // trigger filling our backbuffer 558*cdf0e10cSrcweir SendPaintEvent(); 559*cdf0e10cSrcweir } 560*cdf0e10cSrcweir } 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir // ----------------------------------------------------------------------- 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir void AquaSalFrame::GetClientSize( long& rWidth, long& rHeight ) 565*cdf0e10cSrcweir { 566*cdf0e10cSrcweir if( mbShown || mbInitShow ) 567*cdf0e10cSrcweir { 568*cdf0e10cSrcweir rWidth = maGeometry.nWidth; 569*cdf0e10cSrcweir rHeight = maGeometry.nHeight; 570*cdf0e10cSrcweir } 571*cdf0e10cSrcweir else 572*cdf0e10cSrcweir { 573*cdf0e10cSrcweir rWidth = 0; 574*cdf0e10cSrcweir rHeight = 0; 575*cdf0e10cSrcweir } 576*cdf0e10cSrcweir } 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir // ----------------------------------------------------------------------- 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir void AquaSalFrame::SetWindowState( const SalFrameState* pState ) 581*cdf0e10cSrcweir { 582*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 583*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir if ( mpWindow ) 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir // set normal state 588*cdf0e10cSrcweir NSRect aStateRect = [mpWindow frame]; 589*cdf0e10cSrcweir aStateRect = [NSWindow contentRectForFrameRect: aStateRect styleMask: mnStyleMask]; 590*cdf0e10cSrcweir CocoaToVCL( aStateRect ); 591*cdf0e10cSrcweir if( pState->mnMask & SAL_FRAMESTATE_MASK_X ) 592*cdf0e10cSrcweir aStateRect.origin.x = float(pState->mnX); 593*cdf0e10cSrcweir if( pState->mnMask & SAL_FRAMESTATE_MASK_Y ) 594*cdf0e10cSrcweir aStateRect.origin.y = float(pState->mnY); 595*cdf0e10cSrcweir if( pState->mnMask & SAL_FRAMESTATE_MASK_WIDTH ) 596*cdf0e10cSrcweir aStateRect.size.width = float(pState->mnWidth); 597*cdf0e10cSrcweir if( pState->mnMask & SAL_FRAMESTATE_MASK_HEIGHT ) 598*cdf0e10cSrcweir aStateRect.size.height = float(pState->mnHeight); 599*cdf0e10cSrcweir VCLToCocoa( aStateRect ); 600*cdf0e10cSrcweir aStateRect = [NSWindow frameRectForContentRect: aStateRect styleMask: mnStyleMask]; 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir [mpWindow setFrame: aStateRect display: NO]; 603*cdf0e10cSrcweir if( pState->mnState == SAL_FRAMESTATE_MINIMIZED ) 604*cdf0e10cSrcweir [mpWindow miniaturize: NSApp]; 605*cdf0e10cSrcweir else if( [mpWindow isMiniaturized] ) 606*cdf0e10cSrcweir [mpWindow deminiaturize: NSApp]; 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir /* ZOOMED is not really maximized (actually it toggles between a user set size and 610*cdf0e10cSrcweir the program specified one), but comes closest since the default behavior is 611*cdf0e10cSrcweir "maximized" if the user did not intervene 612*cdf0e10cSrcweir */ 613*cdf0e10cSrcweir if( pState->mnState == SAL_FRAMESTATE_MAXIMIZED ) 614*cdf0e10cSrcweir { 615*cdf0e10cSrcweir if(! [mpWindow isZoomed]) 616*cdf0e10cSrcweir [mpWindow zoom: NSApp]; 617*cdf0e10cSrcweir } 618*cdf0e10cSrcweir else 619*cdf0e10cSrcweir { 620*cdf0e10cSrcweir if( [mpWindow isZoomed] ) 621*cdf0e10cSrcweir [mpWindow zoom: NSApp]; 622*cdf0e10cSrcweir } 623*cdf0e10cSrcweir } 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir // get new geometry 626*cdf0e10cSrcweir UpdateFrameGeometry(); 627*cdf0e10cSrcweir 628*cdf0e10cSrcweir sal_uInt16 nEvent = 0; 629*cdf0e10cSrcweir if( pState->mnMask & (SAL_FRAMESTATE_MASK_X | SAL_FRAMESTATE_MASK_X) ) 630*cdf0e10cSrcweir { 631*cdf0e10cSrcweir mbPositioned = true; 632*cdf0e10cSrcweir nEvent = SALEVENT_MOVE; 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir if( pState->mnMask & (SAL_FRAMESTATE_MASK_WIDTH | SAL_FRAMESTATE_MASK_HEIGHT) ) 636*cdf0e10cSrcweir { 637*cdf0e10cSrcweir mbSized = true; 638*cdf0e10cSrcweir nEvent = (nEvent == SALEVENT_MOVE) ? SALEVENT_MOVERESIZE : SALEVENT_RESIZE; 639*cdf0e10cSrcweir } 640*cdf0e10cSrcweir // send event that we were moved/sized 641*cdf0e10cSrcweir if( nEvent ) 642*cdf0e10cSrcweir CallCallback( nEvent, NULL ); 643*cdf0e10cSrcweir 644*cdf0e10cSrcweir if( mbShown && mpWindow ) 645*cdf0e10cSrcweir { 646*cdf0e10cSrcweir // trigger filling our backbuffer 647*cdf0e10cSrcweir SendPaintEvent(); 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir // tell the system the views need to be updated 650*cdf0e10cSrcweir [mpWindow display]; 651*cdf0e10cSrcweir } 652*cdf0e10cSrcweir } 653*cdf0e10cSrcweir 654*cdf0e10cSrcweir // ----------------------------------------------------------------------- 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir sal_Bool AquaSalFrame::GetWindowState( SalFrameState* pState ) 657*cdf0e10cSrcweir { 658*cdf0e10cSrcweir if ( !mpWindow ) 659*cdf0e10cSrcweir return FALSE; 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 662*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir pState->mnMask = SAL_FRAMESTATE_MASK_X | 665*cdf0e10cSrcweir SAL_FRAMESTATE_MASK_Y | 666*cdf0e10cSrcweir SAL_FRAMESTATE_MASK_WIDTH | 667*cdf0e10cSrcweir SAL_FRAMESTATE_MASK_HEIGHT | 668*cdf0e10cSrcweir #if 0 669*cdf0e10cSrcweir SAL_FRAMESTATE_MASK_MAXIMIZED_X | 670*cdf0e10cSrcweir SAL_FRAMESTATE_MASK_MAXIMIZED_Y | 671*cdf0e10cSrcweir SAL_FRAMESTATE_MASK_MAXIMIZED_WIDTH | 672*cdf0e10cSrcweir SAL_FRAMESTATE_MASK_MAXIMIZED_HEIGHT | 673*cdf0e10cSrcweir #endif 674*cdf0e10cSrcweir SAL_FRAMESTATE_MASK_STATE; 675*cdf0e10cSrcweir 676*cdf0e10cSrcweir NSRect aStateRect = [mpWindow frame]; 677*cdf0e10cSrcweir aStateRect = [NSWindow contentRectForFrameRect: aStateRect styleMask: mnStyleMask]; 678*cdf0e10cSrcweir CocoaToVCL( aStateRect ); 679*cdf0e10cSrcweir pState->mnX = long(aStateRect.origin.x); 680*cdf0e10cSrcweir pState->mnY = long(aStateRect.origin.y); 681*cdf0e10cSrcweir pState->mnWidth = long(aStateRect.size.width); 682*cdf0e10cSrcweir pState->mnHeight = long(aStateRect.size.height); 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir if( [mpWindow isMiniaturized] ) 685*cdf0e10cSrcweir pState->mnState = SAL_FRAMESTATE_MINIMIZED; 686*cdf0e10cSrcweir else if( ! [mpWindow isZoomed] ) 687*cdf0e10cSrcweir pState->mnState = SAL_FRAMESTATE_NORMAL; 688*cdf0e10cSrcweir else 689*cdf0e10cSrcweir pState->mnState = SAL_FRAMESTATE_MAXIMIZED; 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir return TRUE; 692*cdf0e10cSrcweir } 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir // ----------------------------------------------------------------------- 695*cdf0e10cSrcweir 696*cdf0e10cSrcweir void AquaSalFrame::SetScreenNumber(unsigned int nScreen) 697*cdf0e10cSrcweir { 698*cdf0e10cSrcweir if ( !mpWindow ) 699*cdf0e10cSrcweir return; 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 702*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir NSArray* pScreens = [NSScreen screens]; 705*cdf0e10cSrcweir Rectangle aRet; 706*cdf0e10cSrcweir NSScreen* pScreen = nil; 707*cdf0e10cSrcweir if( pScreens && nScreen < [pScreens count] ) 708*cdf0e10cSrcweir { 709*cdf0e10cSrcweir // get new screen frame 710*cdf0e10cSrcweir pScreen = [pScreens objectAtIndex: nScreen]; 711*cdf0e10cSrcweir NSRect aNewScreen = [pScreen frame]; 712*cdf0e10cSrcweir 713*cdf0e10cSrcweir // get current screen frame 714*cdf0e10cSrcweir pScreen = [mpWindow screen]; 715*cdf0e10cSrcweir if( pScreen ) 716*cdf0e10cSrcweir { 717*cdf0e10cSrcweir NSRect aCurScreen = [pScreen frame]; 718*cdf0e10cSrcweir if( aCurScreen.origin.x != aNewScreen.origin.x || 719*cdf0e10cSrcweir aCurScreen.origin.y != aNewScreen.origin.y ) 720*cdf0e10cSrcweir { 721*cdf0e10cSrcweir NSRect aFrameRect = [mpWindow frame]; 722*cdf0e10cSrcweir aFrameRect.origin.x += aNewScreen.origin.x - aCurScreen.origin.x; 723*cdf0e10cSrcweir aFrameRect.origin.y += aNewScreen.origin.y - aCurScreen.origin.y; 724*cdf0e10cSrcweir [mpWindow setFrame: aFrameRect display: NO]; 725*cdf0e10cSrcweir UpdateFrameGeometry(); 726*cdf0e10cSrcweir } 727*cdf0e10cSrcweir } 728*cdf0e10cSrcweir } 729*cdf0e10cSrcweir } 730*cdf0e10cSrcweir 731*cdf0e10cSrcweir // ----------------------------------------------------------------------- 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir void AquaSalFrame::ShowFullScreen( sal_Bool bFullScreen, sal_Int32 nDisplay ) 734*cdf0e10cSrcweir { 735*cdf0e10cSrcweir if ( !mpWindow ) 736*cdf0e10cSrcweir return; 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 739*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir if( mbFullScreen == bFullScreen ) 742*cdf0e10cSrcweir return; 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir mbFullScreen = bFullScreen; 745*cdf0e10cSrcweir if( bFullScreen ) 746*cdf0e10cSrcweir { 747*cdf0e10cSrcweir // hide the dock and the menubar if we are on the menu screen 748*cdf0e10cSrcweir // which is always on index 0 according to documentation 749*cdf0e10cSrcweir bool bHideMenu = (nDisplay == 0); 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir NSRect aNewContentRect = { { 0, 0 }, { 0, 0 } }; 752*cdf0e10cSrcweir // get correct screen 753*cdf0e10cSrcweir NSScreen* pScreen = nil; 754*cdf0e10cSrcweir NSArray* pScreens = [NSScreen screens]; 755*cdf0e10cSrcweir if( pScreens ) 756*cdf0e10cSrcweir { 757*cdf0e10cSrcweir if( nDisplay >= 0 && (unsigned int)nDisplay < [pScreens count] ) 758*cdf0e10cSrcweir pScreen = [pScreens objectAtIndex: nDisplay]; 759*cdf0e10cSrcweir else 760*cdf0e10cSrcweir { 761*cdf0e10cSrcweir // this means span all screens 762*cdf0e10cSrcweir bHideMenu = true; 763*cdf0e10cSrcweir NSEnumerator* pEnum = [pScreens objectEnumerator]; 764*cdf0e10cSrcweir while( (pScreen = [pEnum nextObject]) != nil ) 765*cdf0e10cSrcweir { 766*cdf0e10cSrcweir NSRect aScreenRect = [pScreen frame]; 767*cdf0e10cSrcweir if( aScreenRect.origin.x < aNewContentRect.origin.x ) 768*cdf0e10cSrcweir { 769*cdf0e10cSrcweir aNewContentRect.size.width += aNewContentRect.origin.x - aScreenRect.origin.x; 770*cdf0e10cSrcweir aNewContentRect.origin.x = aScreenRect.origin.x; 771*cdf0e10cSrcweir } 772*cdf0e10cSrcweir if( aScreenRect.origin.y < aNewContentRect.origin.y ) 773*cdf0e10cSrcweir { 774*cdf0e10cSrcweir aNewContentRect.size.height += aNewContentRect.origin.y - aScreenRect.origin.y; 775*cdf0e10cSrcweir aNewContentRect.origin.y = aScreenRect.origin.y; 776*cdf0e10cSrcweir } 777*cdf0e10cSrcweir if( aScreenRect.origin.x + aScreenRect.size.width > aNewContentRect.origin.x + aNewContentRect.size.width ) 778*cdf0e10cSrcweir aNewContentRect.size.width = aScreenRect.origin.x + aScreenRect.size.width - aNewContentRect.origin.x; 779*cdf0e10cSrcweir if( aScreenRect.origin.y + aScreenRect.size.height > aNewContentRect.origin.y + aNewContentRect.size.height ) 780*cdf0e10cSrcweir aNewContentRect.size.height = aScreenRect.origin.y + aScreenRect.size.height - aNewContentRect.origin.y; 781*cdf0e10cSrcweir } 782*cdf0e10cSrcweir } 783*cdf0e10cSrcweir } 784*cdf0e10cSrcweir if( aNewContentRect.size.width == 0 && aNewContentRect.size.height == 0 ) 785*cdf0e10cSrcweir { 786*cdf0e10cSrcweir if( pScreen == nil ) 787*cdf0e10cSrcweir pScreen = [mpWindow screen]; 788*cdf0e10cSrcweir if( pScreen == nil ) 789*cdf0e10cSrcweir pScreen = [NSScreen mainScreen]; 790*cdf0e10cSrcweir 791*cdf0e10cSrcweir aNewContentRect = [pScreen frame]; 792*cdf0e10cSrcweir } 793*cdf0e10cSrcweir 794*cdf0e10cSrcweir if( bHideMenu ) 795*cdf0e10cSrcweir [NSMenu setMenuBarVisible:NO]; 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir maFullScreenRect = [mpWindow frame]; 798*cdf0e10cSrcweir { 799*cdf0e10cSrcweir [mpWindow setFrame: [NSWindow frameRectForContentRect: aNewContentRect styleMask: mnStyleMask] display: mbShown ? YES : NO]; 800*cdf0e10cSrcweir } 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir UpdateFrameGeometry(); 803*cdf0e10cSrcweir 804*cdf0e10cSrcweir if( mbShown ) 805*cdf0e10cSrcweir CallCallback( SALEVENT_MOVERESIZE, NULL ); 806*cdf0e10cSrcweir } 807*cdf0e10cSrcweir else 808*cdf0e10cSrcweir { 809*cdf0e10cSrcweir { 810*cdf0e10cSrcweir [mpWindow setFrame: maFullScreenRect display: mbShown ? YES : NO]; 811*cdf0e10cSrcweir } 812*cdf0e10cSrcweir UpdateFrameGeometry(); 813*cdf0e10cSrcweir 814*cdf0e10cSrcweir if( mbShown ) 815*cdf0e10cSrcweir CallCallback( SALEVENT_MOVERESIZE, NULL ); 816*cdf0e10cSrcweir 817*cdf0e10cSrcweir // show the dock and the menubar 818*cdf0e10cSrcweir [NSMenu setMenuBarVisible:YES]; 819*cdf0e10cSrcweir } 820*cdf0e10cSrcweir if( mbShown ) 821*cdf0e10cSrcweir // trigger filling our backbuffer 822*cdf0e10cSrcweir SendPaintEvent(); 823*cdf0e10cSrcweir } 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir // ----------------------------------------------------------------------- 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir class PreventSleepTimer : public AutoTimer 828*cdf0e10cSrcweir { 829*cdf0e10cSrcweir public: 830*cdf0e10cSrcweir PreventSleepTimer() 831*cdf0e10cSrcweir { 832*cdf0e10cSrcweir SetTimeout( 30000 ); 833*cdf0e10cSrcweir Start(); 834*cdf0e10cSrcweir } 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir virtual ~PreventSleepTimer() 837*cdf0e10cSrcweir { 838*cdf0e10cSrcweir } 839*cdf0e10cSrcweir 840*cdf0e10cSrcweir virtual void Timeout() 841*cdf0e10cSrcweir { 842*cdf0e10cSrcweir UpdateSystemActivity(OverallAct); 843*cdf0e10cSrcweir } 844*cdf0e10cSrcweir }; 845*cdf0e10cSrcweir 846*cdf0e10cSrcweir void AquaSalFrame::StartPresentation( sal_Bool bStart ) 847*cdf0e10cSrcweir { 848*cdf0e10cSrcweir if ( !mpWindow ) 849*cdf0e10cSrcweir return; 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 852*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir if( bStart ) 855*cdf0e10cSrcweir { 856*cdf0e10cSrcweir mpActivityTimer.reset( new PreventSleepTimer() ); 857*cdf0e10cSrcweir [mpWindow setLevel: NSScreenSaverWindowLevel]; 858*cdf0e10cSrcweir if( mbShown ) 859*cdf0e10cSrcweir [mpWindow makeMainWindow]; 860*cdf0e10cSrcweir } 861*cdf0e10cSrcweir else 862*cdf0e10cSrcweir { 863*cdf0e10cSrcweir mpActivityTimer.reset(); 864*cdf0e10cSrcweir [mpWindow setLevel: NSNormalWindowLevel]; 865*cdf0e10cSrcweir } 866*cdf0e10cSrcweir } 867*cdf0e10cSrcweir 868*cdf0e10cSrcweir // ----------------------------------------------------------------------- 869*cdf0e10cSrcweir 870*cdf0e10cSrcweir void AquaSalFrame::SetAlwaysOnTop( sal_Bool ) 871*cdf0e10cSrcweir { 872*cdf0e10cSrcweir } 873*cdf0e10cSrcweir 874*cdf0e10cSrcweir // ----------------------------------------------------------------------- 875*cdf0e10cSrcweir 876*cdf0e10cSrcweir void AquaSalFrame::ToTop(sal_uInt16 nFlags) 877*cdf0e10cSrcweir { 878*cdf0e10cSrcweir if ( !mpWindow ) 879*cdf0e10cSrcweir return; 880*cdf0e10cSrcweir 881*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 882*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 883*cdf0e10cSrcweir 884*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 885*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 886*cdf0e10cSrcweir 887*cdf0e10cSrcweir if( ! (nFlags & SAL_FRAME_TOTOP_RESTOREWHENMIN) ) 888*cdf0e10cSrcweir { 889*cdf0e10cSrcweir if( ! [mpWindow isVisible] || [mpWindow isMiniaturized] ) 890*cdf0e10cSrcweir return; 891*cdf0e10cSrcweir } 892*cdf0e10cSrcweir if( nFlags & SAL_FRAME_TOTOP_GRABFOCUS ) 893*cdf0e10cSrcweir [mpWindow makeKeyAndOrderFront: NSApp]; 894*cdf0e10cSrcweir else 895*cdf0e10cSrcweir [mpWindow orderFront: NSApp]; 896*cdf0e10cSrcweir } 897*cdf0e10cSrcweir 898*cdf0e10cSrcweir // ----------------------------------------------------------------------- 899*cdf0e10cSrcweir 900*cdf0e10cSrcweir NSCursor* AquaSalFrame::getCurrentCursor() const 901*cdf0e10cSrcweir { 902*cdf0e10cSrcweir NSCursor* pCursor = nil; 903*cdf0e10cSrcweir switch( mePointerStyle ) 904*cdf0e10cSrcweir { 905*cdf0e10cSrcweir case POINTER_TEXT: pCursor = [NSCursor IBeamCursor]; break; 906*cdf0e10cSrcweir case POINTER_CROSS: pCursor = [NSCursor crosshairCursor]; break; 907*cdf0e10cSrcweir case POINTER_HAND: 908*cdf0e10cSrcweir case POINTER_MOVE: pCursor = [NSCursor openHandCursor]; break; 909*cdf0e10cSrcweir case POINTER_NSIZE: pCursor = [NSCursor resizeUpCursor]; break; 910*cdf0e10cSrcweir case POINTER_SSIZE: pCursor = [NSCursor resizeDownCursor]; break; 911*cdf0e10cSrcweir case POINTER_ESIZE: pCursor = [NSCursor resizeRightCursor]; break; 912*cdf0e10cSrcweir case POINTER_WSIZE: pCursor = [NSCursor resizeLeftCursor]; break; 913*cdf0e10cSrcweir case POINTER_ARROW: pCursor = [NSCursor arrowCursor]; break; 914*cdf0e10cSrcweir case POINTER_VSPLIT: 915*cdf0e10cSrcweir case POINTER_VSIZEBAR: 916*cdf0e10cSrcweir case POINTER_WINDOW_NSIZE: 917*cdf0e10cSrcweir case POINTER_WINDOW_SSIZE: 918*cdf0e10cSrcweir pCursor = [NSCursor resizeUpDownCursor]; break; 919*cdf0e10cSrcweir case POINTER_HSPLIT: 920*cdf0e10cSrcweir case POINTER_HSIZEBAR: 921*cdf0e10cSrcweir case POINTER_WINDOW_ESIZE: 922*cdf0e10cSrcweir case POINTER_WINDOW_WSIZE: 923*cdf0e10cSrcweir pCursor = [NSCursor resizeLeftRightCursor]; break; 924*cdf0e10cSrcweir case POINTER_REFHAND: pCursor = [NSCursor pointingHandCursor]; break; 925*cdf0e10cSrcweir 926*cdf0e10cSrcweir default: 927*cdf0e10cSrcweir pCursor = GetSalData()->getCursor( mePointerStyle ); 928*cdf0e10cSrcweir if( pCursor == nil ) 929*cdf0e10cSrcweir { 930*cdf0e10cSrcweir DBG_ERROR( "unmapped cursor" ); 931*cdf0e10cSrcweir pCursor = [NSCursor arrowCursor]; 932*cdf0e10cSrcweir } 933*cdf0e10cSrcweir break; 934*cdf0e10cSrcweir } 935*cdf0e10cSrcweir return pCursor; 936*cdf0e10cSrcweir } 937*cdf0e10cSrcweir 938*cdf0e10cSrcweir void AquaSalFrame::SetPointer( PointerStyle ePointerStyle ) 939*cdf0e10cSrcweir { 940*cdf0e10cSrcweir if ( !mpWindow ) 941*cdf0e10cSrcweir return; 942*cdf0e10cSrcweir 943*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 944*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 945*cdf0e10cSrcweir 946*cdf0e10cSrcweir if( ePointerStyle >= POINTER_COUNT || ePointerStyle == mePointerStyle ) 947*cdf0e10cSrcweir return; 948*cdf0e10cSrcweir mePointerStyle = ePointerStyle; 949*cdf0e10cSrcweir 950*cdf0e10cSrcweir [mpWindow invalidateCursorRectsForView: mpView]; 951*cdf0e10cSrcweir } 952*cdf0e10cSrcweir 953*cdf0e10cSrcweir // ----------------------------------------------------------------------- 954*cdf0e10cSrcweir 955*cdf0e10cSrcweir void AquaSalFrame::SetPointerPos( long nX, long nY ) 956*cdf0e10cSrcweir { 957*cdf0e10cSrcweir // FIXME: use Cocoa functions 958*cdf0e10cSrcweir 959*cdf0e10cSrcweir // FIXME: multiscreen support 960*cdf0e10cSrcweir CGPoint aPoint = { nX + maGeometry.nX, nY + maGeometry.nY }; 961*cdf0e10cSrcweir CGDirectDisplayID mainDisplayID = CGMainDisplayID(); 962*cdf0e10cSrcweir CGDisplayMoveCursorToPoint( mainDisplayID, aPoint ); 963*cdf0e10cSrcweir } 964*cdf0e10cSrcweir 965*cdf0e10cSrcweir // ----------------------------------------------------------------------- 966*cdf0e10cSrcweir 967*cdf0e10cSrcweir void AquaSalFrame::Flush( void ) 968*cdf0e10cSrcweir { 969*cdf0e10cSrcweir if( !(mbGraphics && mpGraphics && mpView && mbShown) ) 970*cdf0e10cSrcweir return; 971*cdf0e10cSrcweir 972*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 973*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 974*cdf0e10cSrcweir 975*cdf0e10cSrcweir 976*cdf0e10cSrcweir [mpView setNeedsDisplay: YES]; 977*cdf0e10cSrcweir 978*cdf0e10cSrcweir // outside of the application's event loop (e.g. IntroWindow) 979*cdf0e10cSrcweir // nothing would trigger paint event handling 980*cdf0e10cSrcweir // => fall back to synchronous painting 981*cdf0e10cSrcweir if( ImplGetSVData()->maAppData.mnDispatchLevel <= 0 ) 982*cdf0e10cSrcweir { 983*cdf0e10cSrcweir [mpView display]; 984*cdf0e10cSrcweir } 985*cdf0e10cSrcweir } 986*cdf0e10cSrcweir 987*cdf0e10cSrcweir // ----------------------------------------------------------------------- 988*cdf0e10cSrcweir 989*cdf0e10cSrcweir void AquaSalFrame::Flush( const Rectangle& rRect ) 990*cdf0e10cSrcweir { 991*cdf0e10cSrcweir if( !(mbGraphics && mpGraphics && mpView && mbShown) ) 992*cdf0e10cSrcweir return; 993*cdf0e10cSrcweir 994*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 995*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 996*cdf0e10cSrcweir 997*cdf0e10cSrcweir NSRect aNSRect = { {rRect.Left(), rRect.Top()}, { rRect.GetWidth(), rRect.GetHeight() } }; 998*cdf0e10cSrcweir VCLToCocoa( aNSRect, false ); 999*cdf0e10cSrcweir [mpView setNeedsDisplayInRect: aNSRect]; 1000*cdf0e10cSrcweir 1001*cdf0e10cSrcweir // outside of the application's event loop (e.g. IntroWindow) 1002*cdf0e10cSrcweir // nothing would trigger paint event handling 1003*cdf0e10cSrcweir // => fall back to synchronous painting 1004*cdf0e10cSrcweir if( ImplGetSVData()->maAppData.mnDispatchLevel <= 0 ) 1005*cdf0e10cSrcweir { 1006*cdf0e10cSrcweir [mpView display]; 1007*cdf0e10cSrcweir } 1008*cdf0e10cSrcweir } 1009*cdf0e10cSrcweir 1010*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1011*cdf0e10cSrcweir 1012*cdf0e10cSrcweir void AquaSalFrame::Sync() 1013*cdf0e10cSrcweir { 1014*cdf0e10cSrcweir if( mbGraphics && mpGraphics && mpView && mbShown ) 1015*cdf0e10cSrcweir { 1016*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 1017*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 1018*cdf0e10cSrcweir 1019*cdf0e10cSrcweir [mpView setNeedsDisplay: YES]; 1020*cdf0e10cSrcweir [mpView display]; 1021*cdf0e10cSrcweir } 1022*cdf0e10cSrcweir } 1023*cdf0e10cSrcweir 1024*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1025*cdf0e10cSrcweir 1026*cdf0e10cSrcweir void AquaSalFrame::SetInputContext( SalInputContext* pContext ) 1027*cdf0e10cSrcweir { 1028*cdf0e10cSrcweir if (!pContext) 1029*cdf0e10cSrcweir { 1030*cdf0e10cSrcweir mnICOptions = 0; 1031*cdf0e10cSrcweir return; 1032*cdf0e10cSrcweir } 1033*cdf0e10cSrcweir 1034*cdf0e10cSrcweir mnICOptions = pContext->mnOptions; 1035*cdf0e10cSrcweir 1036*cdf0e10cSrcweir if(!(pContext->mnOptions & SAL_INPUTCONTEXT_TEXT)) 1037*cdf0e10cSrcweir return; 1038*cdf0e10cSrcweir } 1039*cdf0e10cSrcweir 1040*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1041*cdf0e10cSrcweir 1042*cdf0e10cSrcweir void AquaSalFrame::EndExtTextInput( sal_uInt16 ) 1043*cdf0e10cSrcweir { 1044*cdf0e10cSrcweir } 1045*cdf0e10cSrcweir 1046*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1047*cdf0e10cSrcweir 1048*cdf0e10cSrcweir XubString AquaSalFrame::GetKeyName( sal_uInt16 nKeyCode ) 1049*cdf0e10cSrcweir { 1050*cdf0e10cSrcweir static std::map< sal_uInt16, rtl::OUString > aKeyMap; 1051*cdf0e10cSrcweir if( aKeyMap.empty() ) 1052*cdf0e10cSrcweir { 1053*cdf0e10cSrcweir sal_uInt16 i; 1054*cdf0e10cSrcweir for( i = KEY_A; i <= KEY_Z; i++ ) 1055*cdf0e10cSrcweir aKeyMap[ i ] = rtl::OUString( sal_Unicode( 'A' + (i - KEY_A) ) ); 1056*cdf0e10cSrcweir for( i = KEY_0; i <= KEY_9; i++ ) 1057*cdf0e10cSrcweir aKeyMap[ i ] = rtl::OUString( sal_Unicode( '0' + (i - KEY_0) ) ); 1058*cdf0e10cSrcweir for( i = KEY_F1; i <= KEY_F26; i++ ) 1059*cdf0e10cSrcweir { 1060*cdf0e10cSrcweir rtl::OUStringBuffer aKey( 3 ); 1061*cdf0e10cSrcweir aKey.append( sal_Unicode( 'F' ) ); 1062*cdf0e10cSrcweir aKey.append( sal_Int32( i - KEY_F1 + 1 ) ); 1063*cdf0e10cSrcweir aKeyMap[ i ] = aKey.makeStringAndClear(); 1064*cdf0e10cSrcweir } 1065*cdf0e10cSrcweir 1066*cdf0e10cSrcweir aKeyMap[ KEY_DOWN ] = rtl::OUString( sal_Unicode( 0x21e3 ) ); 1067*cdf0e10cSrcweir aKeyMap[ KEY_UP ] = rtl::OUString( sal_Unicode( 0x21e1 ) ); 1068*cdf0e10cSrcweir aKeyMap[ KEY_LEFT ] = rtl::OUString( sal_Unicode( 0x21e0 ) ); 1069*cdf0e10cSrcweir aKeyMap[ KEY_RIGHT ] = rtl::OUString( sal_Unicode( 0x21e2 ) ); 1070*cdf0e10cSrcweir aKeyMap[ KEY_HOME ] = rtl::OUString( sal_Unicode( 0x2196 ) ); 1071*cdf0e10cSrcweir aKeyMap[ KEY_END ] = rtl::OUString( sal_Unicode( 0x2198 ) ); 1072*cdf0e10cSrcweir aKeyMap[ KEY_PAGEUP ] = rtl::OUString( sal_Unicode( 0x21de ) ); 1073*cdf0e10cSrcweir aKeyMap[ KEY_PAGEDOWN ] = rtl::OUString( sal_Unicode( 0x21df ) ); 1074*cdf0e10cSrcweir aKeyMap[ KEY_RETURN ] = rtl::OUString( sal_Unicode( 0x21a9 ) ); 1075*cdf0e10cSrcweir aKeyMap[ KEY_ESCAPE ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "esc" ) ); 1076*cdf0e10cSrcweir aKeyMap[ KEY_TAB ] = rtl::OUString( sal_Unicode( 0x21e5 ) ); 1077*cdf0e10cSrcweir aKeyMap[ KEY_BACKSPACE ]= rtl::OUString( sal_Unicode( 0x232b ) ); 1078*cdf0e10cSrcweir aKeyMap[ KEY_SPACE ] = rtl::OUString( sal_Unicode( 0x2423 ) ); 1079*cdf0e10cSrcweir aKeyMap[ KEY_DELETE ] = rtl::OUString( sal_Unicode( 0x2326 ) ); 1080*cdf0e10cSrcweir aKeyMap[ KEY_ADD ] = rtl::OUString( sal_Unicode( '+' ) ); 1081*cdf0e10cSrcweir aKeyMap[ KEY_SUBTRACT ] = rtl::OUString( sal_Unicode( '-' ) ); 1082*cdf0e10cSrcweir aKeyMap[ KEY_DIVIDE ] = rtl::OUString( sal_Unicode( '/' ) ); 1083*cdf0e10cSrcweir aKeyMap[ KEY_MULTIPLY ] = rtl::OUString( sal_Unicode( '*' ) ); 1084*cdf0e10cSrcweir aKeyMap[ KEY_POINT ] = rtl::OUString( sal_Unicode( '.' ) ); 1085*cdf0e10cSrcweir aKeyMap[ KEY_COMMA ] = rtl::OUString( sal_Unicode( ',' ) ); 1086*cdf0e10cSrcweir aKeyMap[ KEY_LESS ] = rtl::OUString( sal_Unicode( '<' ) ); 1087*cdf0e10cSrcweir aKeyMap[ KEY_GREATER ] = rtl::OUString( sal_Unicode( '>' ) ); 1088*cdf0e10cSrcweir aKeyMap[ KEY_EQUAL ] = rtl::OUString( sal_Unicode( '=' ) ); 1089*cdf0e10cSrcweir aKeyMap[ KEY_OPEN ] = rtl::OUString( sal_Unicode( 0x23cf ) ); 1090*cdf0e10cSrcweir 1091*cdf0e10cSrcweir /* yet unmapped KEYCODES: 1092*cdf0e10cSrcweir aKeyMap[ KEY_INSERT ] = rtl::OUString( sal_Unicode( ) ); 1093*cdf0e10cSrcweir aKeyMap[ KEY_CUT ] = rtl::OUString( sal_Unicode( ) ); 1094*cdf0e10cSrcweir aKeyMap[ KEY_COPY ] = rtl::OUString( sal_Unicode( ) ); 1095*cdf0e10cSrcweir aKeyMap[ KEY_PASTE ] = rtl::OUString( sal_Unicode( ) ); 1096*cdf0e10cSrcweir aKeyMap[ KEY_UNDO ] = rtl::OUString( sal_Unicode( ) ); 1097*cdf0e10cSrcweir aKeyMap[ KEY_REPEAT ] = rtl::OUString( sal_Unicode( ) ); 1098*cdf0e10cSrcweir aKeyMap[ KEY_FIND ] = rtl::OUString( sal_Unicode( ) ); 1099*cdf0e10cSrcweir aKeyMap[ KEY_PROPERTIES ] = rtl::OUString( sal_Unicode( ) ); 1100*cdf0e10cSrcweir aKeyMap[ KEY_FRONT ] = rtl::OUString( sal_Unicode( ) ); 1101*cdf0e10cSrcweir aKeyMap[ KEY_CONTEXTMENU ] = rtl::OUString( sal_Unicode( ) ); 1102*cdf0e10cSrcweir aKeyMap[ KEY_MENU ] = rtl::OUString( sal_Unicode( ) ); 1103*cdf0e10cSrcweir aKeyMap[ KEY_HELP ] = rtl::OUString( sal_Unicode( ) ); 1104*cdf0e10cSrcweir aKeyMap[ KEY_HANGUL_HANJA ] = rtl::OUString( sal_Unicode( ) ); 1105*cdf0e10cSrcweir aKeyMap[ KEY_DECIMAL ] = rtl::OUString( sal_Unicode( ) ); 1106*cdf0e10cSrcweir aKeyMap[ KEY_TILDE ] = rtl::OUString( sal_Unicode( ) ); 1107*cdf0e10cSrcweir aKeyMap[ KEY_QUOTELEFT ]= rtl::OUString( sal_Unicode( ) ); 1108*cdf0e10cSrcweir */ 1109*cdf0e10cSrcweir 1110*cdf0e10cSrcweir } 1111*cdf0e10cSrcweir 1112*cdf0e10cSrcweir rtl::OUStringBuffer aResult( 16 ); 1113*cdf0e10cSrcweir 1114*cdf0e10cSrcweir sal_uInt16 nUnmodifiedCode = (nKeyCode & KEY_CODE); 1115*cdf0e10cSrcweir std::map< sal_uInt16, rtl::OUString >::const_iterator it = aKeyMap.find( nUnmodifiedCode ); 1116*cdf0e10cSrcweir if( it != aKeyMap.end() ) 1117*cdf0e10cSrcweir { 1118*cdf0e10cSrcweir if( (nKeyCode & KEY_SHIFT) != 0 ) 1119*cdf0e10cSrcweir aResult.append( sal_Unicode( 0x21e7 ) ); 1120*cdf0e10cSrcweir if( (nKeyCode & KEY_MOD1) != 0 ) 1121*cdf0e10cSrcweir aResult.append( sal_Unicode( 0x2318 ) ); 1122*cdf0e10cSrcweir // we do not really handle Alt (see below) 1123*cdf0e10cSrcweir // we map it to MOD3, whichis actually Command 1124*cdf0e10cSrcweir if( (nKeyCode & (KEY_MOD2|KEY_MOD3)) != 0 ) 1125*cdf0e10cSrcweir aResult.append( sal_Unicode( 0x2303 ) ); 1126*cdf0e10cSrcweir 1127*cdf0e10cSrcweir aResult.append( it->second ); 1128*cdf0e10cSrcweir } 1129*cdf0e10cSrcweir 1130*cdf0e10cSrcweir return aResult.makeStringAndClear(); 1131*cdf0e10cSrcweir } 1132*cdf0e10cSrcweir 1133*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1134*cdf0e10cSrcweir 1135*cdf0e10cSrcweir XubString AquaSalFrame::GetSymbolKeyName( const XubString&, sal_uInt16 nKeyCode ) 1136*cdf0e10cSrcweir { 1137*cdf0e10cSrcweir return GetKeyName( nKeyCode ); 1138*cdf0e10cSrcweir } 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1141*cdf0e10cSrcweir 1142*cdf0e10cSrcweir static void getAppleScrollBarVariant(void) 1143*cdf0e10cSrcweir { 1144*cdf0e10cSrcweir bool bIsScrollbarDoubleMax = true; // default is DoubleMax 1145*cdf0e10cSrcweir 1146*cdf0e10cSrcweir CFStringRef AppleScrollBarType = CFSTR("AppleScrollBarVariant"); 1147*cdf0e10cSrcweir if( AppleScrollBarType ) 1148*cdf0e10cSrcweir { 1149*cdf0e10cSrcweir CFStringRef ScrollBarVariant = ((CFStringRef)CFPreferencesCopyAppValue( AppleScrollBarType, kCFPreferencesCurrentApplication )); 1150*cdf0e10cSrcweir if( ScrollBarVariant ) 1151*cdf0e10cSrcweir { 1152*cdf0e10cSrcweir if( CFGetTypeID( ScrollBarVariant ) == CFStringGetTypeID() ) 1153*cdf0e10cSrcweir { 1154*cdf0e10cSrcweir // TODO: check for the less important variants "DoubleMin" and "DoubleBoth" too 1155*cdf0e10cSrcweir CFStringRef DoubleMax = CFSTR("DoubleMax"); 1156*cdf0e10cSrcweir if (DoubleMax) 1157*cdf0e10cSrcweir { 1158*cdf0e10cSrcweir if ( !CFStringCompare(ScrollBarVariant, DoubleMax, kCFCompareCaseInsensitive) ) 1159*cdf0e10cSrcweir bIsScrollbarDoubleMax = true; 1160*cdf0e10cSrcweir else 1161*cdf0e10cSrcweir bIsScrollbarDoubleMax = false; 1162*cdf0e10cSrcweir CFRelease(DoubleMax); 1163*cdf0e10cSrcweir } 1164*cdf0e10cSrcweir } 1165*cdf0e10cSrcweir CFRelease( ScrollBarVariant ); 1166*cdf0e10cSrcweir } 1167*cdf0e10cSrcweir CFRelease(AppleScrollBarType); 1168*cdf0e10cSrcweir } 1169*cdf0e10cSrcweir 1170*cdf0e10cSrcweir GetSalData()->mbIsScrollbarDoubleMax = bIsScrollbarDoubleMax; 1171*cdf0e10cSrcweir 1172*cdf0e10cSrcweir CFStringRef jumpScroll = CFSTR("AppleScrollerPagingBehavior"); 1173*cdf0e10cSrcweir if( jumpScroll ) 1174*cdf0e10cSrcweir { 1175*cdf0e10cSrcweir CFBooleanRef jumpStr = ((CFBooleanRef)CFPreferencesCopyAppValue( jumpScroll, kCFPreferencesCurrentApplication )); 1176*cdf0e10cSrcweir if( jumpStr ) 1177*cdf0e10cSrcweir { 1178*cdf0e10cSrcweir if( CFGetTypeID( jumpStr ) == CFBooleanGetTypeID() ) 1179*cdf0e10cSrcweir ImplGetSVData()->maNWFData.mbScrollbarJumpPage = (jumpStr == kCFBooleanTrue); 1180*cdf0e10cSrcweir CFRelease( jumpStr ); 1181*cdf0e10cSrcweir } 1182*cdf0e10cSrcweir CFRelease( jumpScroll ); 1183*cdf0e10cSrcweir } 1184*cdf0e10cSrcweir } 1185*cdf0e10cSrcweir 1186*cdf0e10cSrcweir static Color getColor( NSColor* pSysColor, const Color& rDefault, NSWindow* pWin ) 1187*cdf0e10cSrcweir { 1188*cdf0e10cSrcweir Color aRet( rDefault ); 1189*cdf0e10cSrcweir if( pSysColor ) 1190*cdf0e10cSrcweir { 1191*cdf0e10cSrcweir // transform to RGB 1192*cdf0e10cSrcweir NSColor* pRBGColor = [pSysColor colorUsingColorSpaceName: NSDeviceRGBColorSpace device: [pWin deviceDescription]]; 1193*cdf0e10cSrcweir if( pRBGColor ) 1194*cdf0e10cSrcweir { 1195*cdf0e10cSrcweir float r = 0, g = 0, b = 0, a = 0; 1196*cdf0e10cSrcweir [pRBGColor getRed: &r green: &g blue: &b alpha: &a]; 1197*cdf0e10cSrcweir aRet = Color( int(r*255.999), int(g*255.999), int(b*255.999) ); 1198*cdf0e10cSrcweir /* 1199*cdf0e10cSrcweir do not release here; leads to duplicate free in yield 1200*cdf0e10cSrcweir it seems the converted color comes out autoreleased, although this 1201*cdf0e10cSrcweir is not documented 1202*cdf0e10cSrcweir [pRBGColor release]; 1203*cdf0e10cSrcweir */ 1204*cdf0e10cSrcweir } 1205*cdf0e10cSrcweir } 1206*cdf0e10cSrcweir return aRet; 1207*cdf0e10cSrcweir } 1208*cdf0e10cSrcweir 1209*cdf0e10cSrcweir static Font getFont( NSFont* pFont, long nDPIY, const Font& rDefault ) 1210*cdf0e10cSrcweir { 1211*cdf0e10cSrcweir Font aResult( rDefault ); 1212*cdf0e10cSrcweir if( pFont ) 1213*cdf0e10cSrcweir { 1214*cdf0e10cSrcweir aResult.SetName( GetOUString( [pFont familyName] ) ); 1215*cdf0e10cSrcweir aResult.SetHeight( static_cast<int>(([pFont pointSize] * 72.0 / (float)nDPIY)+0.5) ); 1216*cdf0e10cSrcweir aResult.SetItalic( ([pFont italicAngle] != 0.0) ? ITALIC_NORMAL : ITALIC_NONE ); 1217*cdf0e10cSrcweir // FIMXE: bold ? 1218*cdf0e10cSrcweir } 1219*cdf0e10cSrcweir 1220*cdf0e10cSrcweir return aResult; 1221*cdf0e10cSrcweir } 1222*cdf0e10cSrcweir 1223*cdf0e10cSrcweir void AquaSalFrame::getResolution( long& o_rDPIX, long& o_rDPIY ) 1224*cdf0e10cSrcweir { 1225*cdf0e10cSrcweir if( ! mpGraphics ) 1226*cdf0e10cSrcweir { 1227*cdf0e10cSrcweir GetGraphics(); 1228*cdf0e10cSrcweir ReleaseGraphics( mpGraphics ); 1229*cdf0e10cSrcweir } 1230*cdf0e10cSrcweir mpGraphics->GetResolution( o_rDPIX, o_rDPIY ); 1231*cdf0e10cSrcweir } 1232*cdf0e10cSrcweir 1233*cdf0e10cSrcweir // on OSX-Aqua the style settings are independent of the frame, so it does 1234*cdf0e10cSrcweir // not really belong here. Since the connection to the Appearance_Manager 1235*cdf0e10cSrcweir // is currently done in salnativewidgets.cxx this would be a good place. 1236*cdf0e10cSrcweir // On the other hand VCL's platform independent code currently only asks 1237*cdf0e10cSrcweir // SalFrames for system settings anyway, so moving the code somewhere else 1238*cdf0e10cSrcweir // doesn't make the anything cleaner for now 1239*cdf0e10cSrcweir void AquaSalFrame::UpdateSettings( AllSettings& rSettings ) 1240*cdf0e10cSrcweir { 1241*cdf0e10cSrcweir if ( !mpWindow ) 1242*cdf0e10cSrcweir return; 1243*cdf0e10cSrcweir 1244*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 1245*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 1246*cdf0e10cSrcweir 1247*cdf0e10cSrcweir [mpView lockFocus]; 1248*cdf0e10cSrcweir 1249*cdf0e10cSrcweir StyleSettings aStyleSettings = rSettings.GetStyleSettings(); 1250*cdf0e10cSrcweir 1251*cdf0e10cSrcweir // Background Color 1252*cdf0e10cSrcweir Color aBackgroundColor = Color( 0xEC, 0xEC, 0xEC ); 1253*cdf0e10cSrcweir aStyleSettings.Set3DColors( aBackgroundColor ); 1254*cdf0e10cSrcweir aStyleSettings.SetFaceColor( aBackgroundColor ); 1255*cdf0e10cSrcweir Color aInactiveTabColor( aBackgroundColor ); 1256*cdf0e10cSrcweir aInactiveTabColor.DecreaseLuminance( 32 ); 1257*cdf0e10cSrcweir aStyleSettings.SetInactiveTabColor( aInactiveTabColor ); 1258*cdf0e10cSrcweir 1259*cdf0e10cSrcweir aStyleSettings.SetDialogColor( aBackgroundColor ); 1260*cdf0e10cSrcweir aStyleSettings.SetLightBorderColor( aBackgroundColor ); 1261*cdf0e10cSrcweir Color aShadowColor( aStyleSettings.GetShadowColor() ); 1262*cdf0e10cSrcweir aStyleSettings.SetDarkShadowColor( aShadowColor ); 1263*cdf0e10cSrcweir aShadowColor.IncreaseLuminance( 32 ); 1264*cdf0e10cSrcweir aStyleSettings.SetShadowColor( aShadowColor ); 1265*cdf0e10cSrcweir 1266*cdf0e10cSrcweir // get the system font settings 1267*cdf0e10cSrcweir Font aAppFont = aStyleSettings.GetAppFont(); 1268*cdf0e10cSrcweir long nDPIX = 72, nDPIY = 72; 1269*cdf0e10cSrcweir getResolution( nDPIX, nDPIY ); 1270*cdf0e10cSrcweir aAppFont = getFont( [NSFont systemFontOfSize: 0], nDPIY, aAppFont ); 1271*cdf0e10cSrcweir 1272*cdf0e10cSrcweir // TODO: better mapping of aqua<->ooo font settings 1273*cdf0e10cSrcweir aStyleSettings.SetAppFont( aAppFont ); 1274*cdf0e10cSrcweir aStyleSettings.SetHelpFont( aAppFont ); 1275*cdf0e10cSrcweir aStyleSettings.SetPushButtonFont( aAppFont ); 1276*cdf0e10cSrcweir 1277*cdf0e10cSrcweir Font aTitleFont( getFont( [NSFont titleBarFontOfSize: 0], nDPIY, aAppFont ) ); 1278*cdf0e10cSrcweir aStyleSettings.SetTitleFont( aTitleFont ); 1279*cdf0e10cSrcweir aStyleSettings.SetFloatTitleFont( aTitleFont ); 1280*cdf0e10cSrcweir 1281*cdf0e10cSrcweir Font aMenuFont( getFont( [NSFont menuFontOfSize: 0], nDPIY, aAppFont ) ); 1282*cdf0e10cSrcweir aStyleSettings.SetMenuFont( aMenuFont ); 1283*cdf0e10cSrcweir 1284*cdf0e10cSrcweir aStyleSettings.SetToolFont( aAppFont ); 1285*cdf0e10cSrcweir 1286*cdf0e10cSrcweir Font aLabelFont( getFont( [NSFont labelFontOfSize: 0], nDPIY, aAppFont ) ); 1287*cdf0e10cSrcweir aStyleSettings.SetLabelFont( aLabelFont ); 1288*cdf0e10cSrcweir aStyleSettings.SetInfoFont( aLabelFont ); 1289*cdf0e10cSrcweir aStyleSettings.SetRadioCheckFont( aLabelFont ); 1290*cdf0e10cSrcweir aStyleSettings.SetFieldFont( aLabelFont ); 1291*cdf0e10cSrcweir aStyleSettings.SetGroupFont( aLabelFont ); 1292*cdf0e10cSrcweir aStyleSettings.SetIconFont( aLabelFont ); 1293*cdf0e10cSrcweir 1294*cdf0e10cSrcweir Color aHighlightColor( getColor( [NSColor selectedTextBackgroundColor], 1295*cdf0e10cSrcweir aStyleSettings.GetHighlightColor(), mpWindow ) ); 1296*cdf0e10cSrcweir aStyleSettings.SetHighlightColor( aHighlightColor ); 1297*cdf0e10cSrcweir Color aHighlightTextColor( getColor( [NSColor selectedTextColor], 1298*cdf0e10cSrcweir aStyleSettings.GetHighlightTextColor(), mpWindow ) ); 1299*cdf0e10cSrcweir aStyleSettings.SetHighlightTextColor( aHighlightTextColor ); 1300*cdf0e10cSrcweir 1301*cdf0e10cSrcweir Color aMenuHighlightColor( getColor( [NSColor selectedMenuItemColor], 1302*cdf0e10cSrcweir aStyleSettings.GetMenuHighlightColor(), mpWindow ) ); 1303*cdf0e10cSrcweir aStyleSettings.SetMenuHighlightColor( aMenuHighlightColor ); 1304*cdf0e10cSrcweir Color aMenuHighlightTextColor( getColor( [NSColor selectedMenuItemTextColor], 1305*cdf0e10cSrcweir aStyleSettings.GetMenuHighlightTextColor(), mpWindow ) ); 1306*cdf0e10cSrcweir aStyleSettings.SetMenuHighlightTextColor( aMenuHighlightTextColor ); 1307*cdf0e10cSrcweir 1308*cdf0e10cSrcweir aStyleSettings.SetMenuColor( aBackgroundColor ); 1309*cdf0e10cSrcweir Color aMenuTextColor( getColor( [NSColor textColor], 1310*cdf0e10cSrcweir aStyleSettings.GetMenuTextColor(), mpWindow ) ); 1311*cdf0e10cSrcweir aStyleSettings.SetMenuTextColor( aMenuTextColor ); 1312*cdf0e10cSrcweir aStyleSettings.SetMenuBarTextColor( aMenuTextColor ); 1313*cdf0e10cSrcweir 1314*cdf0e10cSrcweir aStyleSettings.SetCursorBlinkTime( 500 ); 1315*cdf0e10cSrcweir 1316*cdf0e10cSrcweir // no mnemonics on aqua 1317*cdf0e10cSrcweir aStyleSettings.SetOptions( aStyleSettings.GetOptions() | STYLE_OPTION_NOMNEMONICS ); 1318*cdf0e10cSrcweir 1319*cdf0e10cSrcweir getAppleScrollBarVariant(); 1320*cdf0e10cSrcweir 1321*cdf0e10cSrcweir // set scrollbar size 1322*cdf0e10cSrcweir aStyleSettings.SetScrollBarSize( static_cast<long int>([NSScroller scrollerWidth]) ); 1323*cdf0e10cSrcweir 1324*cdf0e10cSrcweir // images in menus false for MacOSX 1325*cdf0e10cSrcweir aStyleSettings.SetUseImagesInMenus( false ); 1326*cdf0e10cSrcweir 1327*cdf0e10cSrcweir rSettings.SetStyleSettings( aStyleSettings ); 1328*cdf0e10cSrcweir 1329*cdf0e10cSrcweir [mpView unlockFocus]; 1330*cdf0e10cSrcweir } 1331*cdf0e10cSrcweir 1332*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1333*cdf0e10cSrcweir 1334*cdf0e10cSrcweir const SystemEnvData* AquaSalFrame::GetSystemData() const 1335*cdf0e10cSrcweir { 1336*cdf0e10cSrcweir return &maSysData; 1337*cdf0e10cSrcweir } 1338*cdf0e10cSrcweir 1339*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1340*cdf0e10cSrcweir 1341*cdf0e10cSrcweir void AquaSalFrame::Beep( SoundType eSoundType ) 1342*cdf0e10cSrcweir { 1343*cdf0e10cSrcweir switch( eSoundType ) 1344*cdf0e10cSrcweir { 1345*cdf0e10cSrcweir case SOUND_DISABLE: 1346*cdf0e10cSrcweir // don't beep 1347*cdf0e10cSrcweir break; 1348*cdf0e10cSrcweir default: 1349*cdf0e10cSrcweir NSBeep(); 1350*cdf0e10cSrcweir break; 1351*cdf0e10cSrcweir } 1352*cdf0e10cSrcweir } 1353*cdf0e10cSrcweir 1354*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1355*cdf0e10cSrcweir 1356*cdf0e10cSrcweir void AquaSalFrame::SetPosSize(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags) 1357*cdf0e10cSrcweir { 1358*cdf0e10cSrcweir if ( !mpWindow ) 1359*cdf0e10cSrcweir return; 1360*cdf0e10cSrcweir 1361*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 1362*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 1363*cdf0e10cSrcweir 1364*cdf0e10cSrcweir sal_uInt16 nEvent = 0; 1365*cdf0e10cSrcweir 1366*cdf0e10cSrcweir if( [mpWindow isMiniaturized] ) 1367*cdf0e10cSrcweir [mpWindow deminiaturize: NSApp]; // expand the window 1368*cdf0e10cSrcweir 1369*cdf0e10cSrcweir if (nFlags & (SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y)) 1370*cdf0e10cSrcweir { 1371*cdf0e10cSrcweir mbPositioned = true; 1372*cdf0e10cSrcweir nEvent = SALEVENT_MOVE; 1373*cdf0e10cSrcweir } 1374*cdf0e10cSrcweir 1375*cdf0e10cSrcweir if (nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT)) 1376*cdf0e10cSrcweir { 1377*cdf0e10cSrcweir mbSized = true; 1378*cdf0e10cSrcweir nEvent = (nEvent == SALEVENT_MOVE) ? SALEVENT_MOVERESIZE : SALEVENT_RESIZE; 1379*cdf0e10cSrcweir } 1380*cdf0e10cSrcweir 1381*cdf0e10cSrcweir NSRect aFrameRect = [mpWindow frame]; 1382*cdf0e10cSrcweir NSRect aContentRect = [NSWindow contentRectForFrameRect: aFrameRect styleMask: mnStyleMask]; 1383*cdf0e10cSrcweir 1384*cdf0e10cSrcweir // position is always relative to parent frame 1385*cdf0e10cSrcweir NSRect aParentContentRect; 1386*cdf0e10cSrcweir 1387*cdf0e10cSrcweir if( mpParent ) 1388*cdf0e10cSrcweir { 1389*cdf0e10cSrcweir if( Application::GetSettings().GetLayoutRTL() ) 1390*cdf0e10cSrcweir { 1391*cdf0e10cSrcweir if( (nFlags & SAL_FRAME_POSSIZE_WIDTH) != 0 ) 1392*cdf0e10cSrcweir nX = mpParent->maGeometry.nWidth - nWidth-1 - nX; 1393*cdf0e10cSrcweir else 1394*cdf0e10cSrcweir nX = mpParent->maGeometry.nWidth - static_cast<long int>( aContentRect.size.width-1) - nX; 1395*cdf0e10cSrcweir } 1396*cdf0e10cSrcweir NSRect aParentFrameRect = [mpParent->mpWindow frame]; 1397*cdf0e10cSrcweir aParentContentRect = [NSWindow contentRectForFrameRect: aParentFrameRect styleMask: mpParent->mnStyleMask]; 1398*cdf0e10cSrcweir } 1399*cdf0e10cSrcweir else 1400*cdf0e10cSrcweir aParentContentRect = maScreenRect; // use screen if no parent 1401*cdf0e10cSrcweir 1402*cdf0e10cSrcweir CocoaToVCL( aContentRect ); 1403*cdf0e10cSrcweir CocoaToVCL( aParentContentRect ); 1404*cdf0e10cSrcweir 1405*cdf0e10cSrcweir bool bPaint = false; 1406*cdf0e10cSrcweir if( (nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT)) != 0 ) 1407*cdf0e10cSrcweir { 1408*cdf0e10cSrcweir if( nWidth != aContentRect.size.width || nHeight != aContentRect.size.height ) 1409*cdf0e10cSrcweir bPaint = true; 1410*cdf0e10cSrcweir } 1411*cdf0e10cSrcweir 1412*cdf0e10cSrcweir // use old window pos if no new pos requested 1413*cdf0e10cSrcweir if( (nFlags & SAL_FRAME_POSSIZE_X) != 0 ) 1414*cdf0e10cSrcweir aContentRect.origin.x = nX + aParentContentRect.origin.x; 1415*cdf0e10cSrcweir if( (nFlags & SAL_FRAME_POSSIZE_Y) != 0) 1416*cdf0e10cSrcweir aContentRect.origin.y = nY + aParentContentRect.origin.y; 1417*cdf0e10cSrcweir 1418*cdf0e10cSrcweir // use old size if no new size requested 1419*cdf0e10cSrcweir if( (nFlags & SAL_FRAME_POSSIZE_WIDTH) != 0 ) 1420*cdf0e10cSrcweir aContentRect.size.width = nWidth; 1421*cdf0e10cSrcweir if( (nFlags & SAL_FRAME_POSSIZE_HEIGHT) != 0) 1422*cdf0e10cSrcweir aContentRect.size.height = nHeight; 1423*cdf0e10cSrcweir 1424*cdf0e10cSrcweir VCLToCocoa( aContentRect ); 1425*cdf0e10cSrcweir 1426*cdf0e10cSrcweir // do not display yet, we need to update our backbuffer 1427*cdf0e10cSrcweir { 1428*cdf0e10cSrcweir [mpWindow setFrame: [NSWindow frameRectForContentRect: aContentRect styleMask: mnStyleMask] display: NO]; 1429*cdf0e10cSrcweir } 1430*cdf0e10cSrcweir 1431*cdf0e10cSrcweir UpdateFrameGeometry(); 1432*cdf0e10cSrcweir 1433*cdf0e10cSrcweir if (nEvent) 1434*cdf0e10cSrcweir CallCallback(nEvent, NULL); 1435*cdf0e10cSrcweir 1436*cdf0e10cSrcweir if( mbShown && bPaint ) 1437*cdf0e10cSrcweir { 1438*cdf0e10cSrcweir // trigger filling our backbuffer 1439*cdf0e10cSrcweir SendPaintEvent(); 1440*cdf0e10cSrcweir 1441*cdf0e10cSrcweir // now inform the system that the views need to be drawn 1442*cdf0e10cSrcweir [mpWindow display]; 1443*cdf0e10cSrcweir } 1444*cdf0e10cSrcweir } 1445*cdf0e10cSrcweir 1446*cdf0e10cSrcweir void AquaSalFrame::GetWorkArea( Rectangle& rRect ) 1447*cdf0e10cSrcweir { 1448*cdf0e10cSrcweir if ( !mpWindow ) 1449*cdf0e10cSrcweir return; 1450*cdf0e10cSrcweir 1451*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 1452*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 1453*cdf0e10cSrcweir 1454*cdf0e10cSrcweir NSScreen* pScreen = [mpWindow screen]; 1455*cdf0e10cSrcweir if( pScreen == nil ) 1456*cdf0e10cSrcweir pScreen = [NSScreen mainScreen]; 1457*cdf0e10cSrcweir NSRect aRect = [pScreen visibleFrame]; 1458*cdf0e10cSrcweir CocoaToVCL( aRect ); 1459*cdf0e10cSrcweir rRect.nLeft = static_cast<long>(aRect.origin.x); 1460*cdf0e10cSrcweir rRect.nTop = static_cast<long>(aRect.origin.y); 1461*cdf0e10cSrcweir rRect.nRight = static_cast<long>(aRect.origin.x + aRect.size.width - 1); 1462*cdf0e10cSrcweir rRect.nBottom = static_cast<long>(aRect.origin.y + aRect.size.height - 1); 1463*cdf0e10cSrcweir } 1464*cdf0e10cSrcweir 1465*cdf0e10cSrcweir SalPointerState AquaSalFrame::GetPointerState() 1466*cdf0e10cSrcweir { 1467*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 1468*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 1469*cdf0e10cSrcweir 1470*cdf0e10cSrcweir SalPointerState state; 1471*cdf0e10cSrcweir state.mnState = 0; 1472*cdf0e10cSrcweir 1473*cdf0e10cSrcweir // get position 1474*cdf0e10cSrcweir NSPoint aPt = [mpWindow mouseLocationOutsideOfEventStream]; 1475*cdf0e10cSrcweir CocoaToVCL( aPt, false ); 1476*cdf0e10cSrcweir state.maPos = Point(static_cast<long>(aPt.x), static_cast<long>(aPt.y)); 1477*cdf0e10cSrcweir 1478*cdf0e10cSrcweir NSEvent* pCur = [NSApp currentEvent]; 1479*cdf0e10cSrcweir bool bMouseEvent = false; 1480*cdf0e10cSrcweir if( pCur ) 1481*cdf0e10cSrcweir { 1482*cdf0e10cSrcweir bMouseEvent = true; 1483*cdf0e10cSrcweir switch( [pCur type] ) 1484*cdf0e10cSrcweir { 1485*cdf0e10cSrcweir case NSLeftMouseDown: state.mnState |= MOUSE_LEFT; break; 1486*cdf0e10cSrcweir case NSLeftMouseUp: break; 1487*cdf0e10cSrcweir case NSRightMouseDown: state.mnState |= MOUSE_RIGHT; break; 1488*cdf0e10cSrcweir case NSRightMouseUp: break; 1489*cdf0e10cSrcweir case NSOtherMouseDown: state.mnState |= ([pCur buttonNumber] == 2) ? MOUSE_MIDDLE : 0; break; 1490*cdf0e10cSrcweir case NSOtherMouseUp: break; 1491*cdf0e10cSrcweir case NSMouseMoved: break; 1492*cdf0e10cSrcweir case NSLeftMouseDragged: state.mnState |= MOUSE_LEFT; break; 1493*cdf0e10cSrcweir case NSRightMouseDragged: state.mnState |= MOUSE_RIGHT; break; 1494*cdf0e10cSrcweir case NSOtherMouseDragged: state.mnState |= ([pCur buttonNumber] == 2) ? MOUSE_MIDDLE : 0; break; 1495*cdf0e10cSrcweir break; 1496*cdf0e10cSrcweir default: 1497*cdf0e10cSrcweir bMouseEvent = false; 1498*cdf0e10cSrcweir break; 1499*cdf0e10cSrcweir } 1500*cdf0e10cSrcweir } 1501*cdf0e10cSrcweir if( bMouseEvent ) 1502*cdf0e10cSrcweir { 1503*cdf0e10cSrcweir unsigned int nMask = (unsigned int)[pCur modifierFlags]; 1504*cdf0e10cSrcweir if( (nMask & NSShiftKeyMask) != 0 ) 1505*cdf0e10cSrcweir state.mnState |= KEY_SHIFT; 1506*cdf0e10cSrcweir if( (nMask & NSControlKeyMask) != 0 ) 1507*cdf0e10cSrcweir state.mnState |= KEY_MOD3; 1508*cdf0e10cSrcweir if( (nMask & NSAlternateKeyMask) != 0 ) 1509*cdf0e10cSrcweir state.mnState |= KEY_MOD2; 1510*cdf0e10cSrcweir if( (nMask & NSCommandKeyMask) != 0 ) 1511*cdf0e10cSrcweir state.mnState |= KEY_MOD1; 1512*cdf0e10cSrcweir 1513*cdf0e10cSrcweir } 1514*cdf0e10cSrcweir else 1515*cdf0e10cSrcweir { 1516*cdf0e10cSrcweir // FIXME: replace Carbon by Cocoa 1517*cdf0e10cSrcweir // Cocoa does not have an equivalent for GetCurrentEventButtonState 1518*cdf0e10cSrcweir // and GetCurrentEventKeyModifiers. 1519*cdf0e10cSrcweir // we could try to get away with tracking all events for modifierKeys 1520*cdf0e10cSrcweir // and all mouse events for button state in VCL_NSApllication::sendEvent, 1521*cdf0e10cSrcweir // but it is unclear whether this will get us the same result. 1522*cdf0e10cSrcweir // leave in GetCurrentEventButtonState and GetCurrentEventKeyModifiers for now 1523*cdf0e10cSrcweir 1524*cdf0e10cSrcweir // fill in button state 1525*cdf0e10cSrcweir UInt32 nState = GetCurrentEventButtonState(); 1526*cdf0e10cSrcweir state.mnState = 0; 1527*cdf0e10cSrcweir if( nState & 1 ) 1528*cdf0e10cSrcweir state.mnState |= MOUSE_LEFT; // primary button 1529*cdf0e10cSrcweir if( nState & 2 ) 1530*cdf0e10cSrcweir state.mnState |= MOUSE_RIGHT; // secondary button 1531*cdf0e10cSrcweir if( nState & 4 ) 1532*cdf0e10cSrcweir state.mnState |= MOUSE_MIDDLE; // tertiary button 1533*cdf0e10cSrcweir 1534*cdf0e10cSrcweir // fill in modifier state 1535*cdf0e10cSrcweir nState = GetCurrentEventKeyModifiers(); 1536*cdf0e10cSrcweir if( nState & shiftKey ) 1537*cdf0e10cSrcweir state.mnState |= KEY_SHIFT; 1538*cdf0e10cSrcweir if( nState & controlKey ) 1539*cdf0e10cSrcweir state.mnState |= KEY_MOD3; 1540*cdf0e10cSrcweir if( nState & optionKey ) 1541*cdf0e10cSrcweir state.mnState |= KEY_MOD2; 1542*cdf0e10cSrcweir if( nState & cmdKey ) 1543*cdf0e10cSrcweir state.mnState |= KEY_MOD1; 1544*cdf0e10cSrcweir } 1545*cdf0e10cSrcweir 1546*cdf0e10cSrcweir 1547*cdf0e10cSrcweir return state; 1548*cdf0e10cSrcweir } 1549*cdf0e10cSrcweir 1550*cdf0e10cSrcweir bool AquaSalFrame::SetPluginParent( SystemParentData* ) 1551*cdf0e10cSrcweir { 1552*cdf0e10cSrcweir // plugin parent may be killed unexpectedly by 1553*cdf0e10cSrcweir // plugging process; 1554*cdf0e10cSrcweir 1555*cdf0e10cSrcweir //TODO: implement 1556*cdf0e10cSrcweir return sal_False; 1557*cdf0e10cSrcweir } 1558*cdf0e10cSrcweir 1559*cdf0e10cSrcweir sal_Bool AquaSalFrame::MapUnicodeToKeyCode( sal_Unicode , LanguageType , KeyCode& ) 1560*cdf0e10cSrcweir { 1561*cdf0e10cSrcweir // not supported yet 1562*cdf0e10cSrcweir return FALSE; 1563*cdf0e10cSrcweir } 1564*cdf0e10cSrcweir 1565*cdf0e10cSrcweir LanguageType AquaSalFrame::GetInputLanguage() 1566*cdf0e10cSrcweir { 1567*cdf0e10cSrcweir //TODO: implement 1568*cdf0e10cSrcweir return LANGUAGE_DONTKNOW; 1569*cdf0e10cSrcweir } 1570*cdf0e10cSrcweir 1571*cdf0e10cSrcweir void AquaSalFrame::DrawMenuBar() 1572*cdf0e10cSrcweir { 1573*cdf0e10cSrcweir } 1574*cdf0e10cSrcweir 1575*cdf0e10cSrcweir void AquaSalFrame::SetMenu( SalMenu* pSalMenu ) 1576*cdf0e10cSrcweir { 1577*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 1578*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 1579*cdf0e10cSrcweir 1580*cdf0e10cSrcweir AquaSalMenu* pMenu = static_cast<AquaSalMenu*>(pSalMenu); 1581*cdf0e10cSrcweir DBG_ASSERT( ! pMenu || pMenu->mbMenuBar, "setting non menubar on frame" ); 1582*cdf0e10cSrcweir mpMenu = pMenu; 1583*cdf0e10cSrcweir if( mpMenu ) 1584*cdf0e10cSrcweir mpMenu->setMainMenu(); 1585*cdf0e10cSrcweir } 1586*cdf0e10cSrcweir 1587*cdf0e10cSrcweir void AquaSalFrame::SetExtendedFrameStyle( SalExtStyle nStyle ) 1588*cdf0e10cSrcweir { 1589*cdf0e10cSrcweir if ( mpWindow ) 1590*cdf0e10cSrcweir { 1591*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 1592*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 1593*cdf0e10cSrcweir 1594*cdf0e10cSrcweir if( (mnExtStyle & SAL_FRAME_EXT_STYLE_DOCMODIFIED) != (nStyle & SAL_FRAME_EXT_STYLE_DOCMODIFIED) ) 1595*cdf0e10cSrcweir [mpWindow setDocumentEdited: (nStyle & SAL_FRAME_EXT_STYLE_DOCMODIFIED) ? YES : NO]; 1596*cdf0e10cSrcweir } 1597*cdf0e10cSrcweir 1598*cdf0e10cSrcweir mnExtStyle = nStyle; 1599*cdf0e10cSrcweir } 1600*cdf0e10cSrcweir 1601*cdf0e10cSrcweir void AquaSalFrame::SetBackgroundBitmap( SalBitmap* ) 1602*cdf0e10cSrcweir { 1603*cdf0e10cSrcweir //TODO: implement 1604*cdf0e10cSrcweir } 1605*cdf0e10cSrcweir 1606*cdf0e10cSrcweir SalBitmap* AquaSalFrame::SnapShot() 1607*cdf0e10cSrcweir { 1608*cdf0e10cSrcweir return mpGraphics ? mpGraphics->getBitmap( 0, 0, maGeometry.nWidth, maGeometry.nHeight ) : NULL; 1609*cdf0e10cSrcweir } 1610*cdf0e10cSrcweir 1611*cdf0e10cSrcweir SalFrame* AquaSalFrame::GetParent() const 1612*cdf0e10cSrcweir { 1613*cdf0e10cSrcweir return mpParent; 1614*cdf0e10cSrcweir } 1615*cdf0e10cSrcweir 1616*cdf0e10cSrcweir void AquaSalFrame::SetParent( SalFrame* pNewParent ) 1617*cdf0e10cSrcweir { 1618*cdf0e10cSrcweir bool bShown = mbShown; 1619*cdf0e10cSrcweir // remove from child list 1620*cdf0e10cSrcweir Show( FALSE ); 1621*cdf0e10cSrcweir mpParent = (AquaSalFrame*)pNewParent; 1622*cdf0e10cSrcweir // insert to correct parent and paint 1623*cdf0e10cSrcweir Show( bShown ); 1624*cdf0e10cSrcweir } 1625*cdf0e10cSrcweir 1626*cdf0e10cSrcweir void AquaSalFrame::UpdateFrameGeometry() 1627*cdf0e10cSrcweir { 1628*cdf0e10cSrcweir if ( !mpWindow ) 1629*cdf0e10cSrcweir { 1630*cdf0e10cSrcweir return; 1631*cdf0e10cSrcweir } 1632*cdf0e10cSrcweir 1633*cdf0e10cSrcweir // keep in mind that view and window coordinates are lower left 1634*cdf0e10cSrcweir // whereas vcl's are upper left 1635*cdf0e10cSrcweir 1636*cdf0e10cSrcweir // update screen rect 1637*cdf0e10cSrcweir NSScreen * pScreen = [mpWindow screen]; 1638*cdf0e10cSrcweir if( pScreen ) 1639*cdf0e10cSrcweir { 1640*cdf0e10cSrcweir maScreenRect = [pScreen frame]; 1641*cdf0e10cSrcweir NSArray* pScreens = [NSScreen screens]; 1642*cdf0e10cSrcweir if( pScreens ) 1643*cdf0e10cSrcweir maGeometry.nScreenNumber = [pScreens indexOfObject: pScreen]; 1644*cdf0e10cSrcweir } 1645*cdf0e10cSrcweir 1646*cdf0e10cSrcweir NSRect aFrameRect = [mpWindow frame]; 1647*cdf0e10cSrcweir NSRect aContentRect = [NSWindow contentRectForFrameRect: aFrameRect styleMask: mnStyleMask]; 1648*cdf0e10cSrcweir 1649*cdf0e10cSrcweir // release old track rect 1650*cdf0e10cSrcweir [mpView removeTrackingRect: mnTrackingRectTag]; 1651*cdf0e10cSrcweir // install the new track rect 1652*cdf0e10cSrcweir NSRect aTrackRect = { { 0, 0 }, aContentRect.size }; 1653*cdf0e10cSrcweir mnTrackingRectTag = [mpView addTrackingRect: aTrackRect owner: mpView userData: nil assumeInside: NO]; 1654*cdf0e10cSrcweir 1655*cdf0e10cSrcweir // convert to vcl convention 1656*cdf0e10cSrcweir CocoaToVCL( aFrameRect ); 1657*cdf0e10cSrcweir CocoaToVCL( aContentRect ); 1658*cdf0e10cSrcweir 1659*cdf0e10cSrcweir maGeometry.nX = static_cast<int>(aContentRect.origin.x); 1660*cdf0e10cSrcweir maGeometry.nY = static_cast<int>(aContentRect.origin.y); 1661*cdf0e10cSrcweir 1662*cdf0e10cSrcweir maGeometry.nLeftDecoration = static_cast<unsigned int>(aContentRect.origin.x - aFrameRect.origin.x); 1663*cdf0e10cSrcweir maGeometry.nRightDecoration = static_cast<unsigned int>((aFrameRect.origin.x + aFrameRect.size.width) - 1664*cdf0e10cSrcweir (aContentRect.origin.x + aContentRect.size.width)); 1665*cdf0e10cSrcweir 1666*cdf0e10cSrcweir maGeometry.nTopDecoration = static_cast<unsigned int>(aContentRect.origin.y - aFrameRect.origin.y); 1667*cdf0e10cSrcweir maGeometry.nBottomDecoration = static_cast<unsigned int>((aFrameRect.origin.y + aFrameRect.size.height) - 1668*cdf0e10cSrcweir (aContentRect.origin.y + aContentRect.size.height)); 1669*cdf0e10cSrcweir 1670*cdf0e10cSrcweir maGeometry.nWidth = static_cast<unsigned int>(aContentRect.size.width); 1671*cdf0e10cSrcweir maGeometry.nHeight = static_cast<unsigned int>(aContentRect.size.height); 1672*cdf0e10cSrcweir } 1673*cdf0e10cSrcweir 1674*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1675*cdf0e10cSrcweir 1676*cdf0e10cSrcweir void AquaSalFrame::CaptureMouse( sal_Bool bCapture ) 1677*cdf0e10cSrcweir { 1678*cdf0e10cSrcweir /* Remark: 1679*cdf0e10cSrcweir we'll try to use a pidgin version of capture mouse 1680*cdf0e10cSrcweir on MacOSX (neither carbon nor cocoa) there is a 1681*cdf0e10cSrcweir CaptureMouse equivalent (in Carbon there is TrackMouseLocation 1682*cdf0e10cSrcweir but this is useless to use since it is blocking) 1683*cdf0e10cSrcweir 1684*cdf0e10cSrcweir However on cocoa the active frame seems to get mouse events 1685*cdf0e10cSrcweir also outside the window, so we'll try to forward mouse events 1686*cdf0e10cSrcweir to the capture frame in the hope that one of our frames 1687*cdf0e10cSrcweir gets a mouse event. 1688*cdf0e10cSrcweir 1689*cdf0e10cSrcweir This will break as soon as the user activates another app, but 1690*cdf0e10cSrcweir a mouse click will normally lead to a release of the mouse anyway. 1691*cdf0e10cSrcweir 1692*cdf0e10cSrcweir Let's see how far we get this way. Alternatively we could use one 1693*cdf0e10cSrcweir large overlay window like we did for the carbon implementation, 1694*cdf0e10cSrcweir however that is resource intensive. 1695*cdf0e10cSrcweir */ 1696*cdf0e10cSrcweir 1697*cdf0e10cSrcweir if( bCapture ) 1698*cdf0e10cSrcweir s_pCaptureFrame = this; 1699*cdf0e10cSrcweir else if( ! bCapture && s_pCaptureFrame == this ) 1700*cdf0e10cSrcweir s_pCaptureFrame = NULL; 1701*cdf0e10cSrcweir } 1702*cdf0e10cSrcweir 1703*cdf0e10cSrcweir void AquaSalFrame::ResetClipRegion() 1704*cdf0e10cSrcweir { 1705*cdf0e10cSrcweir if ( !mpWindow ) 1706*cdf0e10cSrcweir { 1707*cdf0e10cSrcweir return; 1708*cdf0e10cSrcweir } 1709*cdf0e10cSrcweir 1710*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 1711*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 1712*cdf0e10cSrcweir 1713*cdf0e10cSrcweir // release old path and indicate no clipping 1714*cdf0e10cSrcweir CGPathRelease( mrClippingPath ); 1715*cdf0e10cSrcweir mrClippingPath = NULL; 1716*cdf0e10cSrcweir 1717*cdf0e10cSrcweir if( mpView && mbShown ) 1718*cdf0e10cSrcweir [mpView setNeedsDisplay: YES]; 1719*cdf0e10cSrcweir if( mpWindow ) 1720*cdf0e10cSrcweir { 1721*cdf0e10cSrcweir [mpWindow setOpaque: YES]; 1722*cdf0e10cSrcweir [mpWindow invalidateShadow]; 1723*cdf0e10cSrcweir } 1724*cdf0e10cSrcweir } 1725*cdf0e10cSrcweir 1726*cdf0e10cSrcweir void AquaSalFrame::BeginSetClipRegion( sal_uLong nRects ) 1727*cdf0e10cSrcweir { 1728*cdf0e10cSrcweir if ( !mpWindow ) 1729*cdf0e10cSrcweir { 1730*cdf0e10cSrcweir return; 1731*cdf0e10cSrcweir } 1732*cdf0e10cSrcweir 1733*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 1734*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 1735*cdf0e10cSrcweir 1736*cdf0e10cSrcweir // release old path 1737*cdf0e10cSrcweir if( mrClippingPath ) 1738*cdf0e10cSrcweir { 1739*cdf0e10cSrcweir CGPathRelease( mrClippingPath ); 1740*cdf0e10cSrcweir mrClippingPath = NULL; 1741*cdf0e10cSrcweir } 1742*cdf0e10cSrcweir 1743*cdf0e10cSrcweir if( maClippingRects.size() > SAL_CLIPRECT_COUNT && nRects < maClippingRects.size() ) 1744*cdf0e10cSrcweir { 1745*cdf0e10cSrcweir std::vector<CGRect> aEmptyVec; 1746*cdf0e10cSrcweir maClippingRects.swap( aEmptyVec ); 1747*cdf0e10cSrcweir } 1748*cdf0e10cSrcweir maClippingRects.clear(); 1749*cdf0e10cSrcweir maClippingRects.reserve( nRects ); 1750*cdf0e10cSrcweir } 1751*cdf0e10cSrcweir 1752*cdf0e10cSrcweir void AquaSalFrame::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) 1753*cdf0e10cSrcweir { 1754*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 1755*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 1756*cdf0e10cSrcweir 1757*cdf0e10cSrcweir if( nWidth && nHeight ) 1758*cdf0e10cSrcweir { 1759*cdf0e10cSrcweir NSRect aRect = { { nX, nY }, { nWidth, nHeight } }; 1760*cdf0e10cSrcweir VCLToCocoa( aRect, false ); 1761*cdf0e10cSrcweir maClippingRects.push_back( CGRectMake(aRect.origin.x, aRect.origin.y, aRect.size.width, aRect.size.height) ); 1762*cdf0e10cSrcweir } 1763*cdf0e10cSrcweir } 1764*cdf0e10cSrcweir 1765*cdf0e10cSrcweir void AquaSalFrame::EndSetClipRegion() 1766*cdf0e10cSrcweir { 1767*cdf0e10cSrcweir if ( !mpWindow ) 1768*cdf0e10cSrcweir { 1769*cdf0e10cSrcweir return; 1770*cdf0e10cSrcweir } 1771*cdf0e10cSrcweir 1772*cdf0e10cSrcweir // #i113170# may not be the main thread if called from UNO API 1773*cdf0e10cSrcweir SalData::ensureThreadAutoreleasePool(); 1774*cdf0e10cSrcweir 1775*cdf0e10cSrcweir if( ! maClippingRects.empty() ) 1776*cdf0e10cSrcweir { 1777*cdf0e10cSrcweir mrClippingPath = CGPathCreateMutable(); 1778*cdf0e10cSrcweir CGPathAddRects( mrClippingPath, NULL, &maClippingRects[0], maClippingRects.size() ); 1779*cdf0e10cSrcweir } 1780*cdf0e10cSrcweir if( mpView && mbShown ) 1781*cdf0e10cSrcweir [mpView setNeedsDisplay: YES]; 1782*cdf0e10cSrcweir if( mpWindow ) 1783*cdf0e10cSrcweir { 1784*cdf0e10cSrcweir [mpWindow setOpaque: (mrClippingPath != NULL) ? NO : YES]; 1785*cdf0e10cSrcweir [mpWindow setBackgroundColor: [NSColor clearColor]]; 1786*cdf0e10cSrcweir // shadow is invalidated when view gets drawn again 1787*cdf0e10cSrcweir } 1788*cdf0e10cSrcweir } 1789*cdf0e10cSrcweir 1790