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