1323de322SAndrew Rist/************************************************************** 2cdf0e10cSrcweir * 3323de322SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4323de322SAndrew Rist * or more contributor license agreements. See the NOTICE file 5323de322SAndrew Rist * distributed with this work for additional information 6323de322SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7323de322SAndrew Rist * to you under the Apache License, Version 2.0 (the 8323de322SAndrew Rist * "License"); you may not use this file except in compliance 9323de322SAndrew Rist * with the License. You may obtain a copy of the License at 10323de322SAndrew Rist * 11323de322SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12323de322SAndrew Rist * 13323de322SAndrew Rist * Unless required by applicable law or agreed to in writing, 14323de322SAndrew Rist * software distributed under the License is distributed on an 15323de322SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16323de322SAndrew Rist * KIND, either express or implied. See the License for the 17323de322SAndrew Rist * specific language governing permissions and limitations 18323de322SAndrew Rist * under the License. 19323de322SAndrew Rist * 20323de322SAndrew Rist *************************************************************/ 21323de322SAndrew Rist 22323de322SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir// MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir#include "precompiled_vcl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir#include <sal/alloca.h> 28cdf0e10cSrcweir 29cdf0e10cSrcweir#include "vcl/window.hxx" 30cdf0e10cSrcweir#include "vcl/svapp.hxx" 31cdf0e10cSrcweir 32cdf0e10cSrcweir#include "aqua/salinst.h" 33cdf0e10cSrcweir#include "aqua/salgdi.h" 34cdf0e10cSrcweir#include "aqua/salframe.h" 35cdf0e10cSrcweir#include "aqua/salframeview.h" 36cdf0e10cSrcweir#include "aqua/aqua11yfactory.h" 37cdf0e10cSrcweir 38cdf0e10cSrcweir#define WHEEL_EVENT_FACTOR 1.5 39cdf0e10cSrcweir 40b9aaf9d4SHerbert Dürr// for allowing fullscreen support on deployment targets < OSX 10.7 41b9aaf9d4SHerbert Dürr#if !defined(MAC_OS_X_VERSION_10_7) 42b9aaf9d4SHerbert Dürr #define NSWindowCollectionBehaviorFullScreenPrimary (1 << 7) 43b9aaf9d4SHerbert Dürr #define NSWindowCollectionBehaviorFullScreenAuxiliary (1 << 8) 44b9aaf9d4SHerbert Dürr// #define NSFullScreenWindowMask (1 << 14) 45b9aaf9d4SHerbert Dürr#endif 46b9aaf9d4SHerbert Dürr 47b9aaf9d4SHerbert Dürr 48cdf0e10cSrcweirstatic sal_uInt16 ImplGetModifierMask( unsigned int nMask ) 49cdf0e10cSrcweir{ 50cdf0e10cSrcweir sal_uInt16 nRet = 0; 51cdf0e10cSrcweir if( (nMask & NSShiftKeyMask) != 0 ) 52cdf0e10cSrcweir nRet |= KEY_SHIFT; 53cdf0e10cSrcweir if( (nMask & NSControlKeyMask) != 0 ) 54cdf0e10cSrcweir nRet |= KEY_MOD3; 55cdf0e10cSrcweir if( (nMask & NSAlternateKeyMask) != 0 ) 56cdf0e10cSrcweir nRet |= KEY_MOD2; 57cdf0e10cSrcweir if( (nMask & NSCommandKeyMask) != 0 ) 58cdf0e10cSrcweir nRet |= KEY_MOD1; 59cdf0e10cSrcweir return nRet; 60cdf0e10cSrcweir} 61cdf0e10cSrcweir 62cdf0e10cSrcweirstatic sal_uInt16 ImplMapCharCode( sal_Unicode aCode ) 63cdf0e10cSrcweir{ 64cdf0e10cSrcweir static sal_uInt16 aKeyCodeMap[ 128 ] = 65cdf0e10cSrcweir { 66cdf0e10cSrcweir 0, 0, 0, 0, 0, 0, 0, 0, 67cdf0e10cSrcweir KEY_BACKSPACE, KEY_TAB, KEY_RETURN, 0, 0, KEY_RETURN, 0, 0, 68cdf0e10cSrcweir 0, 0, 0, 0, 0, 0, 0, 0, 69cdf0e10cSrcweir 0, KEY_TAB, 0, KEY_ESCAPE, 0, 0, 0, 0, 70cdf0e10cSrcweir KEY_SPACE, 0, 0, 0, 0, 0, 0, 0, 71cdf0e10cSrcweir 0, 0, KEY_MULTIPLY, KEY_ADD, KEY_COMMA, KEY_SUBTRACT, KEY_POINT, KEY_DIVIDE, 72cdf0e10cSrcweir KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, 73cdf0e10cSrcweir KEY_8, KEY_9, 0, 0, KEY_LESS, KEY_EQUAL, KEY_GREATER, 0, 74cdf0e10cSrcweir 0, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, 75cdf0e10cSrcweir KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, 76cdf0e10cSrcweir KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, 77cdf0e10cSrcweir KEY_X, KEY_Y, KEY_Z, 0, 0, 0, 0, 0, 78cdf0e10cSrcweir KEY_QUOTELEFT, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, 79cdf0e10cSrcweir KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, 80cdf0e10cSrcweir KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, 81cdf0e10cSrcweir KEY_X, KEY_Y, KEY_Z, 0, 0, 0, KEY_TILDE, KEY_BACKSPACE 82cdf0e10cSrcweir }; 83cdf0e10cSrcweir 84cdf0e10cSrcweir // Note: the mapping 0x7f should by rights be KEY_DELETE 85cdf0e10cSrcweir // however if you press "backspace" 0x7f is reported 86cdf0e10cSrcweir // whereas for "delete" 0xf728 gets reported 87cdf0e10cSrcweir 88cdf0e10cSrcweir // Note: the mapping of 0x19 to KEY_TAB is because for unknown reasons 89cdf0e10cSrcweir // tab alone is reported as 0x09 (as expected) but shift-tab is 90cdf0e10cSrcweir // reported as 0x19 (end of medium) 91cdf0e10cSrcweir 92cdf0e10cSrcweir static sal_uInt16 aFunctionKeyCodeMap[ 128 ] = 93cdf0e10cSrcweir { 94cdf0e10cSrcweir KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_F1, KEY_F2, KEY_F3, KEY_F4, 95cdf0e10cSrcweir KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, 96cdf0e10cSrcweir KEY_F13, KEY_F14, KEY_F15, KEY_F16, KEY_F17, KEY_F18, KEY_F19, KEY_F20, 97cdf0e10cSrcweir KEY_F21, KEY_F22, KEY_F23, KEY_F24, KEY_F25, KEY_F26, 0, 0, 98cdf0e10cSrcweir 0, 0, 0, 0, 0, 0, 0, KEY_INSERT, 99cdf0e10cSrcweir KEY_DELETE, KEY_HOME, 0, KEY_END, KEY_PAGEUP, KEY_PAGEDOWN, 0, 0, 100cdf0e10cSrcweir 0, 0, 0, 0, 0, KEY_MENU, 0, 0, 101cdf0e10cSrcweir 0, 0, 0, 0, 0, 0, 0, 0, 102cdf0e10cSrcweir 0, 0, 0, KEY_UNDO, KEY_REPEAT, KEY_FIND, KEY_HELP, 0, 103cdf0e10cSrcweir 0, 0, 0, 0, 0, 0, 0, 0, 104cdf0e10cSrcweir 0, 0, 0, 0, 0, 0, 0, 0, 105cdf0e10cSrcweir 0, 0, 0, 0, 0, 0, 0, 0, 106cdf0e10cSrcweir 0, 0, 0, 0, 0, 0, 0, 0, 107cdf0e10cSrcweir 0, 0, 0, 0, 0, 0, 0, 0, 108cdf0e10cSrcweir 0, 0, 0, 0, 0, 0, 0, 0, 109cdf0e10cSrcweir 0, 0, 0, 0, 0, 0, 0, 0 110cdf0e10cSrcweir }; 111cdf0e10cSrcweir 112cdf0e10cSrcweir sal_uInt16 nKeyCode = 0; 113cdf0e10cSrcweir if( aCode < sizeof( aKeyCodeMap) / sizeof( aKeyCodeMap[0] ) ) 114cdf0e10cSrcweir nKeyCode = aKeyCodeMap[ aCode ]; 115cdf0e10cSrcweir else if( aCode >= 0xf700 && aCode < 0xf780 ) 116cdf0e10cSrcweir nKeyCode = aFunctionKeyCodeMap[ aCode - 0xf700 ]; 117cdf0e10cSrcweir return nKeyCode; 118cdf0e10cSrcweir} 119cdf0e10cSrcweir 120cdf0e10cSrcweir// store the frame the mouse last entered 121cdf0e10cSrcweirstatic AquaSalFrame* s_pMouseFrame = NULL; 122cdf0e10cSrcweir// store the last pressed button for enter/exit events 123cdf0e10cSrcweir// which lack that information 124cdf0e10cSrcweirstatic sal_uInt16 s_nLastButton = 0; 125cdf0e10cSrcweir 126cdf0e10cSrcweir// combinations of keys we need to handle ourselves 127cdf0e10cSrcweirstatic const struct ExceptionalKey 128cdf0e10cSrcweir{ 129cdf0e10cSrcweir const sal_uInt16 nKeyCode; 130cdf0e10cSrcweir const unsigned int nModifierMask; 131cdf0e10cSrcweir} aExceptionalKeys[] = 132cdf0e10cSrcweir{ 133cdf0e10cSrcweir { KEY_D, NSControlKeyMask | NSShiftKeyMask | NSAlternateKeyMask }, 134cdf0e10cSrcweir { KEY_D, NSCommandKeyMask | NSShiftKeyMask | NSAlternateKeyMask } 135cdf0e10cSrcweir}; 136cdf0e10cSrcweir 137cdf0e10cSrcweirstatic AquaSalFrame* getMouseContainerFrame() 138cdf0e10cSrcweir{ 1392dae3561SHerbert Dürr NSInteger nWindows = 0; 140cdf0e10cSrcweir NSCountWindows( &nWindows ); 1412dae3561SHerbert Dürr NSInteger* pWindows = (NSInteger*)alloca( nWindows * sizeof(NSInteger) ); 142cdf0e10cSrcweir // note: NSWindowList is supposed to be in z-order front to back 143cdf0e10cSrcweir NSWindowList( nWindows, pWindows ); 144cdf0e10cSrcweir AquaSalFrame* pDispatchFrame = NULL; 145cdf0e10cSrcweir for(int i = 0; i < nWindows && ! pDispatchFrame; i++ ) 146cdf0e10cSrcweir { 147cdf0e10cSrcweir NSWindow* pWin = [NSApp windowWithWindowNumber: pWindows[i]]; 148cdf0e10cSrcweir if( pWin && [pWin isMemberOfClass: [SalFrameWindow class]] && [(SalFrameWindow*)pWin containsMouse] ) 149cdf0e10cSrcweir pDispatchFrame = [(SalFrameWindow*)pWin getSalFrame]; 150cdf0e10cSrcweir } 151cdf0e10cSrcweir return pDispatchFrame; 152cdf0e10cSrcweir} 153cdf0e10cSrcweir 154cdf0e10cSrcweir@implementation SalFrameWindow 155cdf0e10cSrcweir-(id)initWithSalFrame: (AquaSalFrame*)pFrame 156cdf0e10cSrcweir{ 157cdf0e10cSrcweir mDraggingDestinationHandler = nil; 158cdf0e10cSrcweir mpFrame = pFrame; 159cd426cceSHerbert Dürr NSRect aRect = NSMakeRect( pFrame->maGeometry.nX, pFrame->maGeometry.nY, 160cd426cceSHerbert Dürr pFrame->maGeometry.nWidth, pFrame->maGeometry.nHeight); 161cdf0e10cSrcweir pFrame->VCLToCocoa( aRect ); 162cdf0e10cSrcweir NSWindow* pNSWindow = [super initWithContentRect: aRect styleMask: mpFrame->getStyleMask() backing: NSBackingStoreBuffered defer: NO ]; 163cdf0e10cSrcweir [pNSWindow useOptimizedDrawing: YES]; // OSX recommendation when there are no overlapping subviews within the receiver 164b9aaf9d4SHerbert Dürr 1656669cefeSHerbert Dürr // enable OSX>=10.7 fullscreen options if available and useful 166b9aaf9d4SHerbert Dürr bool bAllowFullScreen = (0 == (mpFrame->mnStyle & (SAL_FRAME_STYLE_DIALOG | SAL_FRAME_STYLE_TOOLTIP | SAL_FRAME_STYLE_SYSTEMCHILD | SAL_FRAME_STYLE_FLOAT | SAL_FRAME_STYLE_TOOLWINDOW | SAL_FRAME_STYLE_INTRO))); 167b9aaf9d4SHerbert Dürr bAllowFullScreen &= (0 == (~mpFrame->mnStyle & (SAL_FRAME_STYLE_SIZEABLE))); 168b9aaf9d4SHerbert Dürr bAllowFullScreen &= (mpFrame->mpParent == NULL); 169b9aaf9d4SHerbert Dürr const SEL setCollectionBehavior = @selector(setCollectionBehavior:); 170b9aaf9d4SHerbert Dürr if( bAllowFullScreen && [pNSWindow respondsToSelector: setCollectionBehavior]) 171b9aaf9d4SHerbert Dürr { 172c1f635d7SHerbert Dürr const int bMode= (bAllowFullScreen ? NSWindowCollectionBehaviorFullScreenPrimary : NSWindowCollectionBehaviorFullScreenAuxiliary); 173c1f635d7SHerbert Dürr [pNSWindow performSelector:setCollectionBehavior withObject:(id)bMode]; 174b9aaf9d4SHerbert Dürr } 175b9aaf9d4SHerbert Dürr 1766669cefeSHerbert Dürr // disable OSX>=10.7 window restoration until we support it directly 1776669cefeSHerbert Dürr const SEL setRestorable = @selector(setRestorable:); 1780376cbd9SHerbert Dürr if( [pNSWindow respondsToSelector: setRestorable]) { 179c1f635d7SHerbert Dürr [pNSWindow performSelector:setRestorable withObject:(id)NO]; 1800376cbd9SHerbert Dürr } 1816669cefeSHerbert Dürr 182cdf0e10cSrcweir return pNSWindow; 183cdf0e10cSrcweir} 184cdf0e10cSrcweir 185cdf0e10cSrcweir-(AquaSalFrame*)getSalFrame 186cdf0e10cSrcweir{ 187cdf0e10cSrcweir return mpFrame; 188cdf0e10cSrcweir} 189cdf0e10cSrcweir 190cdf0e10cSrcweir-(void)displayIfNeeded 191cdf0e10cSrcweir{ 192cdf0e10cSrcweir if( GetSalData() && GetSalData()->mpFirstInstance ) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir vos::IMutex* pMutex = GetSalData()->mpFirstInstance->GetYieldMutex(); 195cdf0e10cSrcweir if( pMutex ) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir pMutex->acquire(); 198cdf0e10cSrcweir [super displayIfNeeded]; 199cdf0e10cSrcweir pMutex->release(); 200cdf0e10cSrcweir } 201cdf0e10cSrcweir } 202cdf0e10cSrcweir} 203cdf0e10cSrcweir 204cdf0e10cSrcweir-(BOOL)containsMouse 205cdf0e10cSrcweir{ 206cdf0e10cSrcweir // is this event actually inside that NSWindow ? 207cdf0e10cSrcweir NSPoint aPt = [NSEvent mouseLocation]; 208cdf0e10cSrcweir NSRect aFrameRect = [self frame]; 209cdf0e10cSrcweir BOOL bInRect = NSPointInRect( aPt, aFrameRect ); 210cdf0e10cSrcweir return bInRect; 211cdf0e10cSrcweir} 212cdf0e10cSrcweir 213cdf0e10cSrcweir-(BOOL)canBecomeKeyWindow 214cdf0e10cSrcweir{ 215cdf0e10cSrcweir if( (mpFrame->mnStyle & 216cdf0e10cSrcweir ( SAL_FRAME_STYLE_FLOAT | 217cdf0e10cSrcweir SAL_FRAME_STYLE_TOOLTIP | 218cdf0e10cSrcweir SAL_FRAME_STYLE_INTRO 219cdf0e10cSrcweir )) == 0 ) 220cdf0e10cSrcweir return YES; 221cdf0e10cSrcweir if( (mpFrame->mnStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) != 0 ) 222cdf0e10cSrcweir return YES; 223cdf0e10cSrcweir if( mpFrame->mbFullScreen ) 224cdf0e10cSrcweir return YES; 225cdf0e10cSrcweir if( (mpFrame->mnStyle & SAL_FRAME_STYLE_FLOAT_FOCUSABLE) ) 226cdf0e10cSrcweir return YES; 227cdf0e10cSrcweir return [super canBecomeKeyWindow]; 228cdf0e10cSrcweir} 229cdf0e10cSrcweir 230cdf0e10cSrcweir-(void)windowDidBecomeKey: (NSNotification*)pNotification 231cdf0e10cSrcweir{ 232cdf0e10cSrcweir (void)pNotification; 233cdf0e10cSrcweir YIELD_GUARD; 234cdf0e10cSrcweir 235cdf0e10cSrcweir if( mpFrame && AquaSalFrame::isAlive( mpFrame ) ) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir static const sal_uLong nGuessDocument = SAL_FRAME_STYLE_MOVEABLE| 238cdf0e10cSrcweir SAL_FRAME_STYLE_SIZEABLE| 239cdf0e10cSrcweir SAL_FRAME_STYLE_CLOSEABLE; 240cdf0e10cSrcweir 241cdf0e10cSrcweir if( mpFrame->mpMenu ) 242cdf0e10cSrcweir mpFrame->mpMenu->setMainMenu(); 243cdf0e10cSrcweir else if( ! mpFrame->mpParent && 244cdf0e10cSrcweir ( (mpFrame->mnStyle & nGuessDocument) == nGuessDocument || // set default menu for e.g. help 245cdf0e10cSrcweir mpFrame->mbFullScreen ) ) // ser default menu for e.g. presentation 246cdf0e10cSrcweir { 247cdf0e10cSrcweir AquaSalMenu::setDefaultMenu(); 248cdf0e10cSrcweir } 249cdf0e10cSrcweir #if 0 250cdf0e10cSrcweir // FIXME: we should disable menus while in modal mode 251cdf0e10cSrcweir // however from down here there is currently no reliable way to 252cdf0e10cSrcweir // find out when to do this 253cdf0e10cSrcweir if( (mpFrame->mpParent && mpFrame->mpParent->GetWindow()->IsInModalMode()) ) 254cdf0e10cSrcweir AquaSalMenu::enableMainMenu( false ); 255cdf0e10cSrcweir #endif 256cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_GETFOCUS, 0 ); 257cdf0e10cSrcweir mpFrame->SendPaintEvent(); // repaint controls as active 258cdf0e10cSrcweir } 259cdf0e10cSrcweir} 260cdf0e10cSrcweir 261cdf0e10cSrcweir-(void)windowDidResignKey: (NSNotification*)pNotification 262cdf0e10cSrcweir{ 263cdf0e10cSrcweir (void)pNotification; 264cdf0e10cSrcweir YIELD_GUARD; 265cdf0e10cSrcweir 266cdf0e10cSrcweir if( mpFrame && AquaSalFrame::isAlive( mpFrame ) ) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir mpFrame->CallCallback(SALEVENT_LOSEFOCUS, 0); 269cdf0e10cSrcweir mpFrame->SendPaintEvent(); // repaint controls as inactive 270cdf0e10cSrcweir } 271cdf0e10cSrcweir} 272cdf0e10cSrcweir 273cdf0e10cSrcweir-(void)windowDidChangeScreen: (NSNotification*)pNotification 274cdf0e10cSrcweir{ 275cdf0e10cSrcweir (void)pNotification; 276cdf0e10cSrcweir YIELD_GUARD; 277cdf0e10cSrcweir 278cdf0e10cSrcweir if( mpFrame && AquaSalFrame::isAlive( mpFrame ) ) 279cdf0e10cSrcweir mpFrame->screenParametersChanged(); 280cdf0e10cSrcweir} 281cdf0e10cSrcweir 282cdf0e10cSrcweir-(void)windowDidMove: (NSNotification*)pNotification 283cdf0e10cSrcweir{ 284cdf0e10cSrcweir (void)pNotification; 285cdf0e10cSrcweir YIELD_GUARD; 286cdf0e10cSrcweir 287cdf0e10cSrcweir if( mpFrame && AquaSalFrame::isAlive( mpFrame ) ) 288cdf0e10cSrcweir { 289cdf0e10cSrcweir mpFrame->UpdateFrameGeometry(); 290cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_MOVE, 0 ); 291cdf0e10cSrcweir } 292cdf0e10cSrcweir} 293cdf0e10cSrcweir 294cdf0e10cSrcweir-(void)windowDidResize: (NSNotification*)pNotification 295cdf0e10cSrcweir{ 296cdf0e10cSrcweir (void)pNotification; 297cdf0e10cSrcweir YIELD_GUARD; 298cdf0e10cSrcweir 299cdf0e10cSrcweir if( mpFrame && AquaSalFrame::isAlive( mpFrame ) ) 300cdf0e10cSrcweir { 301cdf0e10cSrcweir mpFrame->UpdateFrameGeometry(); 302cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_RESIZE, 0 ); 303cdf0e10cSrcweir mpFrame->SendPaintEvent(); 304cdf0e10cSrcweir } 305cdf0e10cSrcweir} 306cdf0e10cSrcweir 307cdf0e10cSrcweir-(void)windowDidMiniaturize: (NSNotification*)pNotification 308cdf0e10cSrcweir{ 309cdf0e10cSrcweir (void)pNotification; 310cdf0e10cSrcweir YIELD_GUARD; 311cdf0e10cSrcweir 312cdf0e10cSrcweir if( mpFrame && AquaSalFrame::isAlive( mpFrame ) ) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir mpFrame->mbShown = false; 315cdf0e10cSrcweir mpFrame->UpdateFrameGeometry(); 316cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_RESIZE, 0 ); 317cdf0e10cSrcweir } 318cdf0e10cSrcweir} 319cdf0e10cSrcweir 320cdf0e10cSrcweir-(void)windowDidDeminiaturize: (NSNotification*)pNotification 321cdf0e10cSrcweir{ 322cdf0e10cSrcweir (void)pNotification; 323cdf0e10cSrcweir YIELD_GUARD; 324cdf0e10cSrcweir 325cdf0e10cSrcweir if( mpFrame && AquaSalFrame::isAlive( mpFrame ) ) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir mpFrame->mbShown = true; 328cdf0e10cSrcweir mpFrame->UpdateFrameGeometry(); 329cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_RESIZE, 0 ); 330cdf0e10cSrcweir } 331cdf0e10cSrcweir} 332cdf0e10cSrcweir 333cdf0e10cSrcweir-(BOOL)windowShouldClose: (NSNotification*)pNotification 334cdf0e10cSrcweir{ 335cdf0e10cSrcweir (void)pNotification; 336cdf0e10cSrcweir YIELD_GUARD; 337cdf0e10cSrcweir 338cdf0e10cSrcweir BOOL bRet = YES; 339cdf0e10cSrcweir if( mpFrame && AquaSalFrame::isAlive( mpFrame ) ) 340cdf0e10cSrcweir { 341cdf0e10cSrcweir // #i84461# end possible input 342cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_ENDEXTTEXTINPUT, 0 ); 343cdf0e10cSrcweir if( AquaSalFrame::isAlive( mpFrame ) ) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_CLOSE, 0 ); 346cdf0e10cSrcweir bRet = NO; // application will close the window or not, AppKit shouldn't 347cdf0e10cSrcweir } 348cdf0e10cSrcweir } 349cdf0e10cSrcweir 350cdf0e10cSrcweir return bRet; 351cdf0e10cSrcweir} 352cdf0e10cSrcweir 353b9aaf9d4SHerbert Dürr-(void)windowDidEnterFullScreen: (NSNotification*)pNotification 354b9aaf9d4SHerbert Dürr{ 355b9aaf9d4SHerbert Dürr YIELD_GUARD; 356b9aaf9d4SHerbert Dürr 357b9aaf9d4SHerbert Dürr if( !mpFrame || !AquaSalFrame::isAlive( mpFrame)) 358b9aaf9d4SHerbert Dürr return; 359b9aaf9d4SHerbert Dürr mpFrame->mbFullScreen = true; 360b9aaf9d4SHerbert Dürr (void)pNotification; 361b9aaf9d4SHerbert Dürr} 362b9aaf9d4SHerbert Dürr 363b9aaf9d4SHerbert Dürr-(void)windowDidExitFullScreen: (NSNotification*)pNotification 364b9aaf9d4SHerbert Dürr{ 365b9aaf9d4SHerbert Dürr YIELD_GUARD; 366b9aaf9d4SHerbert Dürr 367b9aaf9d4SHerbert Dürr if( !mpFrame || !AquaSalFrame::isAlive( mpFrame)) 368b9aaf9d4SHerbert Dürr return; 369b9aaf9d4SHerbert Dürr mpFrame->mbFullScreen = false; 370b9aaf9d4SHerbert Dürr (void)pNotification; 371b9aaf9d4SHerbert Dürr} 372b9aaf9d4SHerbert Dürr 373cdf0e10cSrcweir-(void)dockMenuItemTriggered: (id)sender 374cdf0e10cSrcweir{ 375cdf0e10cSrcweir (void)sender; 376cdf0e10cSrcweir YIELD_GUARD; 377cdf0e10cSrcweir 378cdf0e10cSrcweir if( mpFrame && AquaSalFrame::isAlive( mpFrame ) ) 379cdf0e10cSrcweir mpFrame->ToTop( SAL_FRAME_TOTOP_RESTOREWHENMIN | SAL_FRAME_TOTOP_GRABFOCUS ); 380cdf0e10cSrcweir} 381cdf0e10cSrcweir 382cdf0e10cSrcweir-(::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessibleContext >)accessibleContext 383cdf0e10cSrcweir{ 384cdf0e10cSrcweir return mpFrame -> GetWindow() -> GetAccessible() -> getAccessibleContext(); 385cdf0e10cSrcweir} 386cdf0e10cSrcweir 387cdf0e10cSrcweir-(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender 388cdf0e10cSrcweir{ 389cdf0e10cSrcweir return [mDraggingDestinationHandler draggingEntered: sender]; 390cdf0e10cSrcweir} 391cdf0e10cSrcweir 392cdf0e10cSrcweir-(NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender 393cdf0e10cSrcweir{ 394cdf0e10cSrcweir return [mDraggingDestinationHandler draggingUpdated: sender]; 395cdf0e10cSrcweir} 396cdf0e10cSrcweir 397cdf0e10cSrcweir-(void)draggingExited:(id <NSDraggingInfo>)sender 398cdf0e10cSrcweir{ 399cdf0e10cSrcweir [mDraggingDestinationHandler draggingExited: sender]; 400cdf0e10cSrcweir} 401cdf0e10cSrcweir 402cdf0e10cSrcweir-(BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender 403cdf0e10cSrcweir{ 404cdf0e10cSrcweir return [mDraggingDestinationHandler prepareForDragOperation: sender]; 405cdf0e10cSrcweir} 406cdf0e10cSrcweir 407cdf0e10cSrcweir-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender 408cdf0e10cSrcweir{ 409cdf0e10cSrcweir return [mDraggingDestinationHandler performDragOperation: sender]; 410cdf0e10cSrcweir} 411cdf0e10cSrcweir 412cdf0e10cSrcweir-(void)concludeDragOperation:(id <NSDraggingInfo>)sender 413cdf0e10cSrcweir{ 414cdf0e10cSrcweir [mDraggingDestinationHandler concludeDragOperation: sender]; 415cdf0e10cSrcweir} 416cdf0e10cSrcweir 417cdf0e10cSrcweir-(void)registerDraggingDestinationHandler:(id)theHandler 418cdf0e10cSrcweir{ 419cdf0e10cSrcweir mDraggingDestinationHandler = theHandler; 420cdf0e10cSrcweir} 421cdf0e10cSrcweir 422cdf0e10cSrcweir-(void)unregisterDraggingDestinationHandler:(id)theHandler 423cdf0e10cSrcweir{ 424cdf0e10cSrcweir (void)theHandler; 425cdf0e10cSrcweir mDraggingDestinationHandler = nil; 426cdf0e10cSrcweir} 427cdf0e10cSrcweir 428cdf0e10cSrcweir@end 429cdf0e10cSrcweir 430cdf0e10cSrcweir@implementation SalFrameView 431cdf0e10cSrcweir+(void)unsetMouseFrame: (AquaSalFrame*)pFrame 432cdf0e10cSrcweir{ 433cdf0e10cSrcweir if( pFrame == s_pMouseFrame ) 434cdf0e10cSrcweir s_pMouseFrame = NULL; 435cdf0e10cSrcweir} 436cdf0e10cSrcweir 437cdf0e10cSrcweir-(id)initWithSalFrame: (AquaSalFrame*)pFrame 438cdf0e10cSrcweir{ 439bde8a4bdSHerbert Dürr if ((self = [super initWithFrame: [NSWindow contentRectForFrameRect: [pFrame->getNSWindow() frame] styleMask: pFrame->mnStyleMask]]) != nil) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir mDraggingDestinationHandler = nil; 442cdf0e10cSrcweir mpFrame = pFrame; 443cdf0e10cSrcweir mMarkedRange = NSMakeRange(NSNotFound, 0); 444cdf0e10cSrcweir mSelectedRange = NSMakeRange(NSNotFound, 0); 445cdf0e10cSrcweir mpReferenceWrapper = nil; 446cdf0e10cSrcweir mpMouseEventListener = nil; 447cdf0e10cSrcweir mpLastSuperEvent = nil; 448cdf0e10cSrcweir } 449cdf0e10cSrcweir 450cdf0e10cSrcweir mfLastMagnifyTime = 0.0; 451cdf0e10cSrcweir return self; 452cdf0e10cSrcweir} 453cdf0e10cSrcweir 454cdf0e10cSrcweir-(AquaSalFrame*)getSalFrame 455cdf0e10cSrcweir{ 456cdf0e10cSrcweir return mpFrame; 457cdf0e10cSrcweir} 458cdf0e10cSrcweir 459cdf0e10cSrcweir-(void)resetCursorRects 460cdf0e10cSrcweir{ 461cdf0e10cSrcweir if( mpFrame && AquaSalFrame::isAlive( mpFrame ) ) 462cdf0e10cSrcweir { 463cdf0e10cSrcweir // FIXME: does this leak the returned NSCursor of getCurrentCursor ? 46401367266SHerbert Dürr const NSRect aRect = { NSZeroPoint, NSMakeSize( mpFrame->maGeometry.nWidth, mpFrame->maGeometry.nHeight) }; 465cdf0e10cSrcweir [self addCursorRect: aRect cursor: mpFrame->getCurrentCursor()]; 466cdf0e10cSrcweir } 467cdf0e10cSrcweir} 468cdf0e10cSrcweir 469cdf0e10cSrcweir-(BOOL)acceptsFirstResponder 470cdf0e10cSrcweir{ 471cdf0e10cSrcweir return YES; 472cdf0e10cSrcweir} 473cdf0e10cSrcweir 474cdf0e10cSrcweir-(BOOL)acceptsFirstMouse: (NSEvent*)pEvent 475cdf0e10cSrcweir{ 476cdf0e10cSrcweir (void)pEvent; 477cdf0e10cSrcweir return YES; 478cdf0e10cSrcweir} 479cdf0e10cSrcweir 480cdf0e10cSrcweir-(BOOL)isOpaque 481cdf0e10cSrcweir{ 482457e662bSHerbert Dürr if( !mpFrame) 483457e662bSHerbert Dürr return YES; 484457e662bSHerbert Dürr if( !AquaSalFrame::isAlive( mpFrame)) 485457e662bSHerbert Dürr return YES; 486457e662bSHerbert Dürr if( !mpFrame->getClipPath()) 487457e662bSHerbert Dürr return YES; 488457e662bSHerbert Dürr return NO; 489cdf0e10cSrcweir} 490cdf0e10cSrcweir 491cdf0e10cSrcweir// helper class similar to a vos::OGuard for the SalYieldMutex 49286e1cf34SPedro Giffuni// the difference is that it only does tryToAcquire instead of acquire 493cdf0e10cSrcweir// so dreaded deadlocks like #i93512# are prevented 494cdf0e10cSrcweirclass TryGuard 495cdf0e10cSrcweir{ 496cdf0e10cSrcweirpublic: 497cdf0e10cSrcweir TryGuard() { mbGuarded = ImplSalYieldMutexTryToAcquire(); } 498cdf0e10cSrcweir ~TryGuard() { if( mbGuarded ) ImplSalYieldMutexRelease(); } 499cdf0e10cSrcweir bool IsGuarded() { return mbGuarded; } 500cdf0e10cSrcweirprivate: 501cdf0e10cSrcweir bool mbGuarded; 502cdf0e10cSrcweir}; 503cdf0e10cSrcweir 504cdf0e10cSrcweir-(void)drawRect: (NSRect)aRect 505cdf0e10cSrcweir{ 506cdf0e10cSrcweir // HOTFIX: #i93512# prevent deadlocks if any other thread already has the SalYieldMutex 507cdf0e10cSrcweir TryGuard aTryGuard; 508cdf0e10cSrcweir if( !aTryGuard.IsGuarded() ) 509cdf0e10cSrcweir { 510cdf0e10cSrcweir // NOTE: the mpFrame access below is not guarded yet! 511cdf0e10cSrcweir // TODO: mpFrame et al need to be guarded by an independent mutex 512cdf0e10cSrcweir AquaSalGraphics* pGraphics = (mpFrame && AquaSalFrame::isAlive(mpFrame)) ? mpFrame->mpGraphics : NULL; 513cdf0e10cSrcweir if( pGraphics ) 514cdf0e10cSrcweir { 515cdf0e10cSrcweir // we did not get the mutex so we cannot draw now => request to redraw later 516cdf0e10cSrcweir // convert the NSRect to a CGRect for Refreshrect() 517cdf0e10cSrcweir const CGRect aCGRect = {{aRect.origin.x,aRect.origin.y},{aRect.size.width,aRect.size.height}}; 518cdf0e10cSrcweir pGraphics->RefreshRect( aCGRect ); 519cdf0e10cSrcweir } 520cdf0e10cSrcweir return; 521cdf0e10cSrcweir } 522cdf0e10cSrcweir 523cdf0e10cSrcweir if( mpFrame && AquaSalFrame::isAlive( mpFrame ) ) 524cdf0e10cSrcweir { 525cdf0e10cSrcweir if( mpFrame->mpGraphics ) 526cdf0e10cSrcweir { 527cdf0e10cSrcweir mpFrame->mpGraphics->UpdateWindow( aRect ); 528cdf0e10cSrcweir if( mpFrame->getClipPath() ) 529bde8a4bdSHerbert Dürr [mpFrame->getNSWindow() invalidateShadow]; 530cdf0e10cSrcweir } 531cdf0e10cSrcweir } 532cdf0e10cSrcweir} 533cdf0e10cSrcweir 534cdf0e10cSrcweir-(void)sendMouseEventToFrame: (NSEvent*)pEvent button:(sal_uInt16)nButton eventtype:(sal_uInt16)nEvent 535cdf0e10cSrcweir{ 536cdf0e10cSrcweir YIELD_GUARD; 537cdf0e10cSrcweir 538cdf0e10cSrcweir AquaSalFrame* pDispatchFrame = AquaSalFrame::GetCaptureFrame(); 539cdf0e10cSrcweir bool bIsCaptured = false; 540cdf0e10cSrcweir if( pDispatchFrame ) 541cdf0e10cSrcweir { 542cdf0e10cSrcweir bIsCaptured = true; 543cdf0e10cSrcweir if( nEvent == SALEVENT_MOUSELEAVE ) // no leave events if mouse is captured 544cdf0e10cSrcweir nEvent = SALEVENT_MOUSEMOVE; 545cdf0e10cSrcweir } 546cdf0e10cSrcweir else if( s_pMouseFrame ) 547cdf0e10cSrcweir pDispatchFrame = s_pMouseFrame; 548cdf0e10cSrcweir else 549cdf0e10cSrcweir pDispatchFrame = mpFrame; 550cdf0e10cSrcweir 551cdf0e10cSrcweir /* #i81645# Cocoa reports mouse events while a button is pressed 552cdf0e10cSrcweir to the window in which it was first pressed. This is reasonable and fine and 553cdf0e10cSrcweir gets one around most cases where on other platforms one uses CaptureMouse or XGrabPointer, 554cdf0e10cSrcweir however vcl expects mouse events to occur in the window the mouse is over, unless the 555cdf0e10cSrcweir mouse is explicitly captured. So we need to find the window the mouse is actually 556cdf0e10cSrcweir over for conformance with other platforms. 557cdf0e10cSrcweir */ 558cdf0e10cSrcweir if( ! bIsCaptured && nButton && pDispatchFrame && AquaSalFrame::isAlive( pDispatchFrame ) ) 559cdf0e10cSrcweir { 560cdf0e10cSrcweir // is this event actually inside that NSWindow ? 561cdf0e10cSrcweir NSPoint aPt = [NSEvent mouseLocation]; 562bde8a4bdSHerbert Dürr NSRect aFrameRect = [pDispatchFrame->getNSWindow() frame]; 563cdf0e10cSrcweir 564cdf0e10cSrcweir if ( ! NSPointInRect( aPt, aFrameRect ) ) 565cdf0e10cSrcweir { 566cdf0e10cSrcweir // no, it is not 567cdf0e10cSrcweir // now we need to find the one it may be in 568cdf0e10cSrcweir /* #i93756# we ant to get enumerate the application windows in z-order 569cdf0e10cSrcweir to check if any contains the mouse. This could be elegantly done with this 570cdf0e10cSrcweir code: 571cdf0e10cSrcweir 572cdf0e10cSrcweir // use NSApp to check windows in ZOrder whether they contain the mouse pointer 573cdf0e10cSrcweir NSWindow* pWindow = [NSApp makeWindowsPerform: @selector(containsMouse) inOrder: YES]; 574cdf0e10cSrcweir if( pWindow && [pWindow isMemberOfClass: [SalFrameWindow class]] ) 575cdf0e10cSrcweir pDispatchFrame = [(SalFrameWindow*)pWindow getSalFrame]; 576cdf0e10cSrcweir 577cdf0e10cSrcweir However if a non SalFrameWindow is on screen (like e.g. the file dialog) 578cdf0e10cSrcweir it can be hit with the containsMouse selector, which it doesn't support. 579cdf0e10cSrcweir Sadly NSApplication:makeWindowsPerform does not check (for performance reasons 580cdf0e10cSrcweir I assume) whether a window supports a selector before sending it. 581cdf0e10cSrcweir */ 582cdf0e10cSrcweir AquaSalFrame* pMouseFrame = getMouseContainerFrame(); 583cdf0e10cSrcweir if( pMouseFrame ) 584cdf0e10cSrcweir pDispatchFrame = pMouseFrame; 585cdf0e10cSrcweir } 586cdf0e10cSrcweir } 587cdf0e10cSrcweir 588cdf0e10cSrcweir if( pDispatchFrame && AquaSalFrame::isAlive( pDispatchFrame ) ) 589cdf0e10cSrcweir { 590cdf0e10cSrcweir pDispatchFrame->mnLastEventTime = static_cast<sal_uLong>( [pEvent timestamp] * 1000.0 ); 591cdf0e10cSrcweir pDispatchFrame->mnLastModifierFlags = [pEvent modifierFlags]; 592cdf0e10cSrcweir 593cdf0e10cSrcweir NSPoint aPt = [NSEvent mouseLocation]; 594cdf0e10cSrcweir pDispatchFrame->CocoaToVCL( aPt ); 595cdf0e10cSrcweir 596cdf0e10cSrcweir sal_uInt16 nModMask = ImplGetModifierMask( [pEvent modifierFlags] ); 597cdf0e10cSrcweir // #i82284# emulate ctrl left 598cdf0e10cSrcweir if( nModMask == KEY_MOD3 && nButton == MOUSE_LEFT ) 599cdf0e10cSrcweir { 600cdf0e10cSrcweir nModMask = 0; 601cdf0e10cSrcweir nButton = MOUSE_RIGHT; 602cdf0e10cSrcweir } 603cdf0e10cSrcweir 604cdf0e10cSrcweir SalMouseEvent aEvent; 605cdf0e10cSrcweir aEvent.mnTime = pDispatchFrame->mnLastEventTime; 606cdf0e10cSrcweir aEvent.mnX = static_cast<long>(aPt.x) - pDispatchFrame->maGeometry.nX; 607cdf0e10cSrcweir aEvent.mnY = static_cast<long>(aPt.y) - pDispatchFrame->maGeometry.nY; 608cdf0e10cSrcweir aEvent.mnButton = nButton; 609cdf0e10cSrcweir aEvent.mnCode = aEvent.mnButton | nModMask; 610cdf0e10cSrcweir 611cdf0e10cSrcweir // --- RTL --- (mirror mouse pos) 612cdf0e10cSrcweir if( Application::GetSettings().GetLayoutRTL() ) 613cdf0e10cSrcweir aEvent.mnX = pDispatchFrame->maGeometry.nWidth-1-aEvent.mnX; 614cdf0e10cSrcweir 615cdf0e10cSrcweir pDispatchFrame->CallCallback( nEvent, &aEvent ); 616cdf0e10cSrcweir } 617cdf0e10cSrcweir} 618cdf0e10cSrcweir 619cdf0e10cSrcweir-(void)mouseDown: (NSEvent*)pEvent 620cdf0e10cSrcweir{ 621cdf0e10cSrcweir if ( mpMouseEventListener != nil && 622cdf0e10cSrcweir [mpMouseEventListener respondsToSelector: @selector(mouseDown:)]) 623cdf0e10cSrcweir { 624cdf0e10cSrcweir [mpMouseEventListener mouseDown: [pEvent copyWithZone: NULL]]; 625cdf0e10cSrcweir } 626cdf0e10cSrcweir 627cdf0e10cSrcweir s_nLastButton = MOUSE_LEFT; 628cdf0e10cSrcweir [self sendMouseEventToFrame:pEvent button:MOUSE_LEFT eventtype:SALEVENT_MOUSEBUTTONDOWN]; 629cdf0e10cSrcweir} 630cdf0e10cSrcweir 631cdf0e10cSrcweir-(void)mouseDragged: (NSEvent*)pEvent 632cdf0e10cSrcweir{ 633cdf0e10cSrcweir if ( mpMouseEventListener != nil && 634cdf0e10cSrcweir [mpMouseEventListener respondsToSelector: @selector(mouseDragged:)]) 635cdf0e10cSrcweir { 636cdf0e10cSrcweir [mpMouseEventListener mouseDragged: [pEvent copyWithZone: NULL]]; 637cdf0e10cSrcweir } 638cdf0e10cSrcweir s_nLastButton = MOUSE_LEFT; 639cdf0e10cSrcweir [self sendMouseEventToFrame:pEvent button:MOUSE_LEFT eventtype:SALEVENT_MOUSEMOVE]; 640cdf0e10cSrcweir} 641cdf0e10cSrcweir 642cdf0e10cSrcweir-(void)mouseUp: (NSEvent*)pEvent 643cdf0e10cSrcweir{ 644cdf0e10cSrcweir s_nLastButton = 0; 645cdf0e10cSrcweir [self sendMouseEventToFrame:pEvent button:MOUSE_LEFT eventtype:SALEVENT_MOUSEBUTTONUP]; 646cdf0e10cSrcweir} 647cdf0e10cSrcweir 648cdf0e10cSrcweir-(void)mouseMoved: (NSEvent*)pEvent 649cdf0e10cSrcweir{ 650cdf0e10cSrcweir s_nLastButton = 0; 651cdf0e10cSrcweir [self sendMouseEventToFrame:pEvent button:0 eventtype:SALEVENT_MOUSEMOVE]; 652cdf0e10cSrcweir} 653cdf0e10cSrcweir 654cdf0e10cSrcweir-(void)mouseEntered: (NSEvent*)pEvent 655cdf0e10cSrcweir{ 656cdf0e10cSrcweir s_pMouseFrame = mpFrame; 657cdf0e10cSrcweir 658cdf0e10cSrcweir // #i107215# the only mouse events we get when inactive are enter/exit 659cdf0e10cSrcweir // actually we would like to have all of them, but better none than some 660cdf0e10cSrcweir if( [NSApp isActive] ) 661cdf0e10cSrcweir [self sendMouseEventToFrame:pEvent button:s_nLastButton eventtype:SALEVENT_MOUSEMOVE]; 662cdf0e10cSrcweir} 663cdf0e10cSrcweir 664cdf0e10cSrcweir-(void)mouseExited: (NSEvent*)pEvent 665cdf0e10cSrcweir{ 666cdf0e10cSrcweir if( s_pMouseFrame == mpFrame ) 667cdf0e10cSrcweir s_pMouseFrame = NULL; 668cdf0e10cSrcweir 669cdf0e10cSrcweir // #i107215# the only mouse events we get when inactive are enter/exit 670cdf0e10cSrcweir // actually we would like to have all of them, but better none than some 671cdf0e10cSrcweir if( [NSApp isActive] ) 672cdf0e10cSrcweir [self sendMouseEventToFrame:pEvent button:s_nLastButton eventtype:SALEVENT_MOUSELEAVE]; 673cdf0e10cSrcweir} 674cdf0e10cSrcweir 675cdf0e10cSrcweir-(void)rightMouseDown: (NSEvent*)pEvent 676cdf0e10cSrcweir{ 677cdf0e10cSrcweir s_nLastButton = MOUSE_RIGHT; 678cdf0e10cSrcweir [self sendMouseEventToFrame:pEvent button:MOUSE_RIGHT eventtype:SALEVENT_MOUSEBUTTONDOWN]; 679cdf0e10cSrcweir} 680cdf0e10cSrcweir 681cdf0e10cSrcweir-(void)rightMouseDragged: (NSEvent*)pEvent 682cdf0e10cSrcweir{ 683cdf0e10cSrcweir s_nLastButton = MOUSE_RIGHT; 684cdf0e10cSrcweir [self sendMouseEventToFrame:pEvent button:MOUSE_RIGHT eventtype:SALEVENT_MOUSEMOVE]; 685cdf0e10cSrcweir} 686cdf0e10cSrcweir 687cdf0e10cSrcweir-(void)rightMouseUp: (NSEvent*)pEvent 688cdf0e10cSrcweir{ 689cdf0e10cSrcweir s_nLastButton = 0; 690cdf0e10cSrcweir [self sendMouseEventToFrame:pEvent button:MOUSE_RIGHT eventtype:SALEVENT_MOUSEBUTTONUP]; 691cdf0e10cSrcweir} 692cdf0e10cSrcweir 693cdf0e10cSrcweir-(void)otherMouseDown: (NSEvent*)pEvent 694cdf0e10cSrcweir{ 695cdf0e10cSrcweir if( [pEvent buttonNumber] == 2 ) 696cdf0e10cSrcweir { 697cdf0e10cSrcweir s_nLastButton = MOUSE_MIDDLE; 698cdf0e10cSrcweir [self sendMouseEventToFrame:pEvent button:MOUSE_MIDDLE eventtype:SALEVENT_MOUSEBUTTONDOWN]; 699cdf0e10cSrcweir } 700cdf0e10cSrcweir else 701cdf0e10cSrcweir s_nLastButton = 0; 702cdf0e10cSrcweir} 703cdf0e10cSrcweir 704cdf0e10cSrcweir-(void)otherMouseDragged: (NSEvent*)pEvent 705cdf0e10cSrcweir{ 706cdf0e10cSrcweir if( [pEvent buttonNumber] == 2 ) 707cdf0e10cSrcweir { 708cdf0e10cSrcweir s_nLastButton = MOUSE_MIDDLE; 709cdf0e10cSrcweir [self sendMouseEventToFrame:pEvent button:MOUSE_MIDDLE eventtype:SALEVENT_MOUSEMOVE]; 710cdf0e10cSrcweir } 711cdf0e10cSrcweir else 712cdf0e10cSrcweir s_nLastButton = 0; 713cdf0e10cSrcweir} 714cdf0e10cSrcweir 715cdf0e10cSrcweir-(void)otherMouseUp: (NSEvent*)pEvent 716cdf0e10cSrcweir{ 717cdf0e10cSrcweir s_nLastButton = 0; 718cdf0e10cSrcweir if( [pEvent buttonNumber] == 2 ) 719cdf0e10cSrcweir [self sendMouseEventToFrame:pEvent button:MOUSE_MIDDLE eventtype:SALEVENT_MOUSEBUTTONUP]; 720cdf0e10cSrcweir} 721cdf0e10cSrcweir 722cdf0e10cSrcweir- (void)magnifyWithEvent: (NSEvent*)pEvent 723cdf0e10cSrcweir{ 724cdf0e10cSrcweir YIELD_GUARD; 725cdf0e10cSrcweir 726cdf0e10cSrcweir // TODO: ?? -(float)magnification; 727cdf0e10cSrcweir if( AquaSalFrame::isAlive( mpFrame ) ) 728cdf0e10cSrcweir { 729cdf0e10cSrcweir const NSTimeInterval fMagnifyTime = [pEvent timestamp]; 730cdf0e10cSrcweir mpFrame->mnLastEventTime = static_cast<sal_uLong>( fMagnifyTime * 1000.0 ); 731cdf0e10cSrcweir mpFrame->mnLastModifierFlags = [pEvent modifierFlags]; 732cdf0e10cSrcweir 733cdf0e10cSrcweir // check if this is a new series of magnify events 734cdf0e10cSrcweir static const NSTimeInterval fMaxDiffTime = 0.3; 735cdf0e10cSrcweir const bool bNewSeries = (fMagnifyTime - mfLastMagnifyTime > fMaxDiffTime); 736cdf0e10cSrcweir 737cdf0e10cSrcweir if( bNewSeries ) 738cdf0e10cSrcweir mfMagnifyDeltaSum = 0.0; 739cdf0e10cSrcweir mfMagnifyDeltaSum += [pEvent deltaZ]; 740cdf0e10cSrcweir 741cdf0e10cSrcweir mfLastMagnifyTime = [pEvent timestamp]; 742cdf0e10cSrcweir // TODO: change to 0.1 when COMMAND_WHEEL_ZOOM handlers allow finer zooming control 743cdf0e10cSrcweir static const float fMagnifyFactor = 0.25; 744cdf0e10cSrcweir static const float fMinMagnifyStep = 15.0 / fMagnifyFactor; 745cdf0e10cSrcweir if( fabs(mfMagnifyDeltaSum) <= fMinMagnifyStep ) 746cdf0e10cSrcweir return; 747cdf0e10cSrcweir 748cdf0e10cSrcweir // adapt NSEvent-sensitivity to application expectations 749cdf0e10cSrcweir // TODO: rather make COMMAND_WHEEL_ZOOM handlers smarter 750cdf0e10cSrcweir const float fDeltaZ = mfMagnifyDeltaSum * fMagnifyFactor; 751cdf0e10cSrcweir int nDeltaZ = FRound( fDeltaZ ); 752cdf0e10cSrcweir if( !nDeltaZ ) 753cdf0e10cSrcweir { 754cdf0e10cSrcweir // handle new series immediately 755cdf0e10cSrcweir if( !bNewSeries ) 756cdf0e10cSrcweir return; 757cdf0e10cSrcweir nDeltaZ = (fDeltaZ >= 0.0) ? +1 : -1; 758cdf0e10cSrcweir } 759cdf0e10cSrcweir // eventually give credit for delta sum 760cdf0e10cSrcweir mfMagnifyDeltaSum -= nDeltaZ / fMagnifyFactor; 761cdf0e10cSrcweir 762cdf0e10cSrcweir NSPoint aPt = [NSEvent mouseLocation]; 763cdf0e10cSrcweir mpFrame->CocoaToVCL( aPt ); 764cdf0e10cSrcweir 765cdf0e10cSrcweir SalWheelMouseEvent aEvent; 766cdf0e10cSrcweir aEvent.mnTime = mpFrame->mnLastEventTime; 767cdf0e10cSrcweir aEvent.mnX = static_cast<long>(aPt.x) - mpFrame->maGeometry.nX; 768cdf0e10cSrcweir aEvent.mnY = static_cast<long>(aPt.y) - mpFrame->maGeometry.nY; 769cdf0e10cSrcweir aEvent.mnCode = ImplGetModifierMask( mpFrame->mnLastModifierFlags ); 770cdf0e10cSrcweir aEvent.mnCode |= KEY_MOD1; // we want zooming, no scrolling 771cdf0e10cSrcweir aEvent.mbDeltaIsPixel = TRUE; 772cdf0e10cSrcweir 773cdf0e10cSrcweir // --- RTL --- (mirror mouse pos) 774cdf0e10cSrcweir if( Application::GetSettings().GetLayoutRTL() ) 775cdf0e10cSrcweir aEvent.mnX = mpFrame->maGeometry.nWidth-1-aEvent.mnX; 776cdf0e10cSrcweir 777cdf0e10cSrcweir aEvent.mnDelta = nDeltaZ; 778cdf0e10cSrcweir aEvent.mnNotchDelta = (nDeltaZ >= 0) ? +1 : -1; 779cdf0e10cSrcweir if( aEvent.mnDelta == 0 ) 780cdf0e10cSrcweir aEvent.mnDelta = aEvent.mnNotchDelta; 781cdf0e10cSrcweir aEvent.mbHorz = FALSE; 782cdf0e10cSrcweir aEvent.mnScrollLines = nDeltaZ; 783cdf0e10cSrcweir if( aEvent.mnScrollLines == 0 ) 784cdf0e10cSrcweir aEvent.mnScrollLines = 1; 785cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_WHEELMOUSE, &aEvent ); 786cdf0e10cSrcweir } 787cdf0e10cSrcweir} 788cdf0e10cSrcweir 789cdf0e10cSrcweir- (void)rotateWithEvent: (NSEvent*)pEvent 790cdf0e10cSrcweir{ 791cdf0e10cSrcweir //Rotation : -(float)rotation; 792cdf0e10cSrcweir // TODO: create new CommandType so rotation is available to the applications 793cdf0e10cSrcweir (void)pEvent; 794cdf0e10cSrcweir} 795cdf0e10cSrcweir 796cdf0e10cSrcweir- (void)swipeWithEvent: (NSEvent*)pEvent 797cdf0e10cSrcweir{ 798cdf0e10cSrcweir YIELD_GUARD; 799cdf0e10cSrcweir 800cdf0e10cSrcweir if( AquaSalFrame::isAlive( mpFrame ) ) 801cdf0e10cSrcweir { 802cdf0e10cSrcweir mpFrame->mnLastEventTime = static_cast<sal_uLong>( [pEvent timestamp] * 1000.0 ); 803cdf0e10cSrcweir mpFrame->mnLastModifierFlags = [pEvent modifierFlags]; 804cdf0e10cSrcweir 805cdf0e10cSrcweir // merge pending scroll wheel events 806*09c47e18SHerbert Dürr CGFloat dX = 0.0; 807*09c47e18SHerbert Dürr CGFloat dY = 0.0; 808cdf0e10cSrcweir for(;;) 809cdf0e10cSrcweir { 810cdf0e10cSrcweir dX += [pEvent deltaX]; 811cdf0e10cSrcweir dY += [pEvent deltaY]; 812cdf0e10cSrcweir NSEvent* pNextEvent = [NSApp nextEventMatchingMask: NSScrollWheelMask 813cdf0e10cSrcweir untilDate: nil inMode: NSDefaultRunLoopMode dequeue: YES ]; 814cdf0e10cSrcweir if( !pNextEvent ) 815cdf0e10cSrcweir break; 816cdf0e10cSrcweir pEvent = pNextEvent; 817cdf0e10cSrcweir } 818cdf0e10cSrcweir 819cdf0e10cSrcweir NSPoint aPt = [NSEvent mouseLocation]; 820cdf0e10cSrcweir mpFrame->CocoaToVCL( aPt ); 821cdf0e10cSrcweir 822cdf0e10cSrcweir SalWheelMouseEvent aEvent; 823cdf0e10cSrcweir aEvent.mnTime = mpFrame->mnLastEventTime; 824cdf0e10cSrcweir aEvent.mnX = static_cast<long>(aPt.x) - mpFrame->maGeometry.nX; 825cdf0e10cSrcweir aEvent.mnY = static_cast<long>(aPt.y) - mpFrame->maGeometry.nY; 826cdf0e10cSrcweir aEvent.mnCode = ImplGetModifierMask( mpFrame->mnLastModifierFlags ); 827cdf0e10cSrcweir aEvent.mbDeltaIsPixel = TRUE; 828cdf0e10cSrcweir 829cdf0e10cSrcweir // --- RTL --- (mirror mouse pos) 830cdf0e10cSrcweir if( Application::GetSettings().GetLayoutRTL() ) 831cdf0e10cSrcweir aEvent.mnX = mpFrame->maGeometry.nWidth-1-aEvent.mnX; 832cdf0e10cSrcweir 833cdf0e10cSrcweir if( dX != 0.0 ) 834cdf0e10cSrcweir { 835cdf0e10cSrcweir aEvent.mnDelta = static_cast<long>(floor(dX)); 836*09c47e18SHerbert Dürr aEvent.mnNotchDelta = (dX < 0) ? -1 : +1; 837cdf0e10cSrcweir if( aEvent.mnDelta == 0 ) 838cdf0e10cSrcweir aEvent.mnDelta = aEvent.mnNotchDelta; 839cdf0e10cSrcweir aEvent.mbHorz = TRUE; 840cdf0e10cSrcweir aEvent.mnScrollLines = SAL_WHEELMOUSE_EVENT_PAGESCROLL; 841cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_WHEELMOUSE, &aEvent ); 842cdf0e10cSrcweir } 843cdf0e10cSrcweir if( dY != 0.0 && AquaSalFrame::isAlive( mpFrame )) 844cdf0e10cSrcweir { 845cdf0e10cSrcweir aEvent.mnDelta = static_cast<long>(floor(dY)); 846*09c47e18SHerbert Dürr aEvent.mnNotchDelta = (dY < 0) ? -1 : +1; 847cdf0e10cSrcweir if( aEvent.mnDelta == 0 ) 848cdf0e10cSrcweir aEvent.mnDelta = aEvent.mnNotchDelta; 849cdf0e10cSrcweir aEvent.mbHorz = FALSE; 850cdf0e10cSrcweir aEvent.mnScrollLines = SAL_WHEELMOUSE_EVENT_PAGESCROLL; 851cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_WHEELMOUSE, &aEvent ); 852cdf0e10cSrcweir } 853cdf0e10cSrcweir } 854cdf0e10cSrcweir} 855cdf0e10cSrcweir 856cdf0e10cSrcweir-(void)scrollWheel: (NSEvent*)pEvent 857cdf0e10cSrcweir{ 858cdf0e10cSrcweir YIELD_GUARD; 859cdf0e10cSrcweir 860cdf0e10cSrcweir if( AquaSalFrame::isAlive( mpFrame ) ) 861cdf0e10cSrcweir { 862cdf0e10cSrcweir mpFrame->mnLastEventTime = static_cast<sal_uLong>( [pEvent timestamp] * 1000.0 ); 863cdf0e10cSrcweir mpFrame->mnLastModifierFlags = [pEvent modifierFlags]; 864cdf0e10cSrcweir 865cdf0e10cSrcweir // merge pending scroll wheel events 866*09c47e18SHerbert Dürr CGFloat dX = 0.0; 867*09c47e18SHerbert Dürr CGFloat dY = 0.0; 868cdf0e10cSrcweir for(;;) 869cdf0e10cSrcweir { 870cdf0e10cSrcweir dX += [pEvent deltaX]; 871cdf0e10cSrcweir dY += [pEvent deltaY]; 872cdf0e10cSrcweir NSEvent* pNextEvent = [NSApp nextEventMatchingMask: NSScrollWheelMask 873cdf0e10cSrcweir untilDate: nil inMode: NSDefaultRunLoopMode dequeue: YES ]; 874cdf0e10cSrcweir if( !pNextEvent ) 875cdf0e10cSrcweir break; 876cdf0e10cSrcweir pEvent = pNextEvent; 877cdf0e10cSrcweir } 878cdf0e10cSrcweir 879cdf0e10cSrcweir NSPoint aPt = [NSEvent mouseLocation]; 880cdf0e10cSrcweir mpFrame->CocoaToVCL( aPt ); 881cdf0e10cSrcweir 882cdf0e10cSrcweir SalWheelMouseEvent aEvent; 883cdf0e10cSrcweir aEvent.mnTime = mpFrame->mnLastEventTime; 884cdf0e10cSrcweir aEvent.mnX = static_cast<long>(aPt.x) - mpFrame->maGeometry.nX; 885cdf0e10cSrcweir aEvent.mnY = static_cast<long>(aPt.y) - mpFrame->maGeometry.nY; 886cdf0e10cSrcweir aEvent.mnCode = ImplGetModifierMask( mpFrame->mnLastModifierFlags ); 887cdf0e10cSrcweir aEvent.mbDeltaIsPixel = TRUE; 888cdf0e10cSrcweir 889cdf0e10cSrcweir // --- RTL --- (mirror mouse pos) 890cdf0e10cSrcweir if( Application::GetSettings().GetLayoutRTL() ) 891cdf0e10cSrcweir aEvent.mnX = mpFrame->maGeometry.nWidth-1-aEvent.mnX; 892cdf0e10cSrcweir 893cdf0e10cSrcweir if( dX != 0.0 ) 894cdf0e10cSrcweir { 895cdf0e10cSrcweir aEvent.mnDelta = static_cast<long>(floor(dX)); 896*09c47e18SHerbert Dürr aEvent.mnNotchDelta = (dX < 0) ? -1 : +1; 897cdf0e10cSrcweir if( aEvent.mnDelta == 0 ) 898cdf0e10cSrcweir aEvent.mnDelta = aEvent.mnNotchDelta; 899cdf0e10cSrcweir aEvent.mbHorz = TRUE; 900*09c47e18SHerbert Dürr aEvent.mnScrollLines = (dX > 0) ? +dX/WHEEL_EVENT_FACTOR : -dX/WHEEL_EVENT_FACTOR; 901cdf0e10cSrcweir if( aEvent.mnScrollLines == 0 ) 902cdf0e10cSrcweir aEvent.mnScrollLines = 1; 903cdf0e10cSrcweir 904cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_WHEELMOUSE, &aEvent ); 905cdf0e10cSrcweir } 906cdf0e10cSrcweir if( dY != 0.0 && AquaSalFrame::isAlive( mpFrame ) ) 907cdf0e10cSrcweir { 908cdf0e10cSrcweir aEvent.mnDelta = static_cast<long>(floor(dY)); 909*09c47e18SHerbert Dürr aEvent.mnNotchDelta = (dY < 0) ? -1 : +1; 910cdf0e10cSrcweir if( aEvent.mnDelta == 0 ) 911cdf0e10cSrcweir aEvent.mnDelta = aEvent.mnNotchDelta; 912cdf0e10cSrcweir aEvent.mbHorz = FALSE; 913*09c47e18SHerbert Dürr aEvent.mnScrollLines = (dY > 0) ? +dY/WHEEL_EVENT_FACTOR : -dY/WHEEL_EVENT_FACTOR; 914cdf0e10cSrcweir if( aEvent.mnScrollLines < 1 ) 915cdf0e10cSrcweir aEvent.mnScrollLines = 1; 916cdf0e10cSrcweir 917cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_WHEELMOUSE, &aEvent ); 918cdf0e10cSrcweir } 919cdf0e10cSrcweir } 920cdf0e10cSrcweir} 921cdf0e10cSrcweir 922cdf0e10cSrcweir 923cdf0e10cSrcweir-(void)keyDown: (NSEvent*)pEvent 924cdf0e10cSrcweir{ 925cdf0e10cSrcweir YIELD_GUARD; 926cdf0e10cSrcweir 927cdf0e10cSrcweir if( AquaSalFrame::isAlive( mpFrame ) ) 928cdf0e10cSrcweir { 929cdf0e10cSrcweir mpLastEvent = pEvent; 930cdf0e10cSrcweir mbInKeyInput = true; 931cdf0e10cSrcweir mbNeedSpecialKeyHandle = false; 932cdf0e10cSrcweir mbKeyHandled = false; 933cdf0e10cSrcweir 934cdf0e10cSrcweir mpFrame->mnLastEventTime = static_cast<sal_uLong>( [pEvent timestamp] * 1000.0 ); 935cdf0e10cSrcweir mpFrame->mnLastModifierFlags = [pEvent modifierFlags]; 936cdf0e10cSrcweir 937cdf0e10cSrcweir if( ! [self handleKeyDownException: pEvent] ) 938cdf0e10cSrcweir { 939cdf0e10cSrcweir NSArray* pArray = [NSArray arrayWithObject: pEvent]; 940cdf0e10cSrcweir [self interpretKeyEvents: pArray]; 941cdf0e10cSrcweir } 942cdf0e10cSrcweir 943cdf0e10cSrcweir mbInKeyInput = false; 944cdf0e10cSrcweir } 945cdf0e10cSrcweir} 946cdf0e10cSrcweir 947cdf0e10cSrcweir-(BOOL)handleKeyDownException:(NSEvent*)pEvent 948cdf0e10cSrcweir{ 949cdf0e10cSrcweir // check for a very special set of modified characters 950cdf0e10cSrcweir NSString* pUnmodifiedString = [pEvent charactersIgnoringModifiers]; 951cdf0e10cSrcweir 952cdf0e10cSrcweir if( pUnmodifiedString && [pUnmodifiedString length] == 1 ) 953cdf0e10cSrcweir { 954cdf0e10cSrcweir /* #i103102# key events with command and alternate don't make it through 955cdf0e10cSrcweir interpretKeyEvents (why ?). Try to dispatch them here first, 956cdf0e10cSrcweir if not successful continue normally 957cdf0e10cSrcweir */ 958cdf0e10cSrcweir if( (mpFrame->mnLastModifierFlags & (NSAlternateKeyMask | NSCommandKeyMask)) 959cdf0e10cSrcweir == (NSAlternateKeyMask | NSCommandKeyMask) ) 960cdf0e10cSrcweir { 961cdf0e10cSrcweir if( [self sendSingleCharacter: mpLastEvent] ) 962cdf0e10cSrcweir return YES; 963cdf0e10cSrcweir } 964cdf0e10cSrcweir unichar keyChar = [pUnmodifiedString characterAtIndex: 0]; 965cdf0e10cSrcweir sal_uInt16 nKeyCode = ImplMapCharCode( keyChar ); 966cdf0e10cSrcweir 967cdf0e10cSrcweir // Caution: should the table grow to more than 5 or 6 entries, 968cdf0e10cSrcweir // we must consider moving it to a kind of hash map 969cdf0e10cSrcweir const unsigned int nExceptions = sizeof( aExceptionalKeys ) / sizeof( aExceptionalKeys[0] ); 970cdf0e10cSrcweir for( unsigned int i = 0; i < nExceptions; i++ ) 971cdf0e10cSrcweir { 972cdf0e10cSrcweir if( nKeyCode == aExceptionalKeys[i].nKeyCode && 973cdf0e10cSrcweir (mpFrame->mnLastModifierFlags & aExceptionalKeys[i].nModifierMask) 974cdf0e10cSrcweir == aExceptionalKeys[i].nModifierMask ) 975cdf0e10cSrcweir { 976cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: nKeyCode character: 0]; 977cdf0e10cSrcweir 978cdf0e10cSrcweir return YES; 979cdf0e10cSrcweir } 980cdf0e10cSrcweir } 981cdf0e10cSrcweir } 982cdf0e10cSrcweir return NO; 983cdf0e10cSrcweir} 984cdf0e10cSrcweir 985cdf0e10cSrcweir-(void)flagsChanged: (NSEvent*)pEvent 986cdf0e10cSrcweir{ 987cdf0e10cSrcweir YIELD_GUARD; 988cdf0e10cSrcweir 989cdf0e10cSrcweir if( AquaSalFrame::isAlive( mpFrame ) ) 990cdf0e10cSrcweir { 991cdf0e10cSrcweir mpFrame->mnLastEventTime = static_cast<sal_uLong>( [pEvent timestamp] * 1000.0 ); 992cdf0e10cSrcweir mpFrame->mnLastModifierFlags = [pEvent modifierFlags]; 993cdf0e10cSrcweir } 994cdf0e10cSrcweir} 995cdf0e10cSrcweir 996cdf0e10cSrcweir-(void)insertText:(id)aString 997cdf0e10cSrcweir{ 998cdf0e10cSrcweir YIELD_GUARD; 999cdf0e10cSrcweir 1000cdf0e10cSrcweir if( AquaSalFrame::isAlive( mpFrame ) ) 1001cdf0e10cSrcweir { 1002cdf0e10cSrcweir NSString* pInsert = nil; 1003cdf0e10cSrcweir if( [aString isMemberOfClass: [NSAttributedString class]] ) 1004cdf0e10cSrcweir pInsert = [aString string]; 1005cdf0e10cSrcweir else 1006cdf0e10cSrcweir pInsert = aString; 1007cdf0e10cSrcweir 1008cdf0e10cSrcweir int nLen = 0; 1009cdf0e10cSrcweir if( pInsert && ( nLen = [pInsert length] ) > 0 ) 1010cdf0e10cSrcweir { 1011cdf0e10cSrcweir OUString aInsertString( GetOUString( pInsert ) ); 1012cdf0e10cSrcweir // aCharCode initializer is safe since aInsertString will at least contain '\0' 1013cdf0e10cSrcweir sal_Unicode aCharCode = *aInsertString.getStr(); 1014cdf0e10cSrcweir 1015cdf0e10cSrcweir if( nLen == 1 && 1016cdf0e10cSrcweir aCharCode < 0x80 && 1017cdf0e10cSrcweir aCharCode > 0x1f && 1018cdf0e10cSrcweir ! [self hasMarkedText ] 1019cdf0e10cSrcweir ) 1020cdf0e10cSrcweir { 1021cdf0e10cSrcweir sal_uInt16 nKeyCode = ImplMapCharCode( aCharCode ); 1022cdf0e10cSrcweir unsigned int nLastModifiers = mpFrame->mnLastModifierFlags; 1023cdf0e10cSrcweir 1024cdf0e10cSrcweir // #i99567# 1025cdf0e10cSrcweir // find out the unmodified key code 1026cdf0e10cSrcweir 1027cdf0e10cSrcweir // sanity check 1028cdf0e10cSrcweir if( mpLastEvent && ( [mpLastEvent type] == NSKeyDown || [mpLastEvent type] == NSKeyUp ) ) 1029cdf0e10cSrcweir { 1030cdf0e10cSrcweir // get unmodified string 1031cdf0e10cSrcweir NSString* pUnmodifiedString = [mpLastEvent charactersIgnoringModifiers]; 1032cdf0e10cSrcweir if( pUnmodifiedString && [pUnmodifiedString length] == 1 ) 1033cdf0e10cSrcweir { 1034cdf0e10cSrcweir // map the unmodified key code 1035cdf0e10cSrcweir unichar keyChar = [pUnmodifiedString characterAtIndex: 0]; 1036cdf0e10cSrcweir nKeyCode = ImplMapCharCode( keyChar ); 1037cdf0e10cSrcweir } 1038cdf0e10cSrcweir nLastModifiers = [mpLastEvent modifierFlags]; 1039cdf0e10cSrcweir 1040cdf0e10cSrcweir } 1041cdf0e10cSrcweir // #i99567# 1042cdf0e10cSrcweir // applications and vcl's edit fields ignore key events with ALT 1043cdf0e10cSrcweir // however we're at a place where we know text should be inserted 1044cdf0e10cSrcweir // so it seems we need to strip the Alt modifier here 1045cdf0e10cSrcweir if( (nLastModifiers & (NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)) 1046cdf0e10cSrcweir == NSAlternateKeyMask ) 1047cdf0e10cSrcweir { 1048cdf0e10cSrcweir nLastModifiers = 0; 1049cdf0e10cSrcweir } 1050cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: nKeyCode character: aCharCode modifiers: nLastModifiers]; 1051cdf0e10cSrcweir } 1052cdf0e10cSrcweir else 1053cdf0e10cSrcweir { 1054cdf0e10cSrcweir SalExtTextInputEvent aEvent; 1055cdf0e10cSrcweir aEvent.mnTime = mpFrame->mnLastEventTime; 1056cdf0e10cSrcweir aEvent.maText = aInsertString; 1057cdf0e10cSrcweir aEvent.mpTextAttr = NULL; 1058cdf0e10cSrcweir aEvent.mnCursorPos = aInsertString.getLength(); 1059cdf0e10cSrcweir aEvent.mnDeltaStart = 0; 1060cdf0e10cSrcweir aEvent.mnCursorFlags = 0; 1061cdf0e10cSrcweir aEvent.mbOnlyCursor = FALSE; 1062cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_EXTTEXTINPUT, &aEvent ); 1063cdf0e10cSrcweir if( AquaSalFrame::isAlive( mpFrame ) ) 1064cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_ENDEXTTEXTINPUT, 0 ); 1065cdf0e10cSrcweir } 1066cdf0e10cSrcweir } 1067cdf0e10cSrcweir else 1068cdf0e10cSrcweir { 1069cdf0e10cSrcweir SalExtTextInputEvent aEvent; 1070cdf0e10cSrcweir aEvent.mnTime = mpFrame->mnLastEventTime; 1071cdf0e10cSrcweir aEvent.maText = String(); 1072cdf0e10cSrcweir aEvent.mpTextAttr = NULL; 1073cdf0e10cSrcweir aEvent.mnCursorPos = 0; 1074cdf0e10cSrcweir aEvent.mnDeltaStart = 0; 1075cdf0e10cSrcweir aEvent.mnCursorFlags = 0; 1076cdf0e10cSrcweir aEvent.mbOnlyCursor = FALSE; 1077cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_EXTTEXTINPUT, &aEvent ); 1078cdf0e10cSrcweir if( AquaSalFrame::isAlive( mpFrame ) ) 1079cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_ENDEXTTEXTINPUT, 0 ); 1080cdf0e10cSrcweir 1081cdf0e10cSrcweir } 1082cdf0e10cSrcweir mbKeyHandled = true; 1083cdf0e10cSrcweir [self unmarkText]; 1084cdf0e10cSrcweir } 1085cdf0e10cSrcweir} 1086cdf0e10cSrcweir 1087cdf0e10cSrcweir-(void)insertTab: (id)aSender 1088cdf0e10cSrcweir{ 1089cdf0e10cSrcweir (void)aSender; 1090cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: KEY_TAB character: '\t' modifiers: 0]; 1091cdf0e10cSrcweir} 1092cdf0e10cSrcweir 1093cdf0e10cSrcweir-(void)insertBacktab: (id)aSender 1094cdf0e10cSrcweir{ 1095cdf0e10cSrcweir (void)aSender; 1096cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: (KEY_TAB | KEY_SHIFT) character: '\t' modifiers: 0]; 1097cdf0e10cSrcweir} 1098cdf0e10cSrcweir 1099cdf0e10cSrcweir-(void)moveLeft: (id)aSender 1100cdf0e10cSrcweir{ 1101cdf0e10cSrcweir (void)aSender; 1102cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: KEY_LEFT character: 0 modifiers: 0]; 1103cdf0e10cSrcweir} 1104cdf0e10cSrcweir 1105cdf0e10cSrcweir-(void)moveLeftAndModifySelection: (id)aSender 1106cdf0e10cSrcweir{ 1107cdf0e10cSrcweir (void)aSender; 1108cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: KEY_LEFT character: 0 modifiers: NSShiftKeyMask]; 1109cdf0e10cSrcweir} 1110cdf0e10cSrcweir 1111cdf0e10cSrcweir-(void)moveBackwardAndModifySelection: (id)aSender 1112cdf0e10cSrcweir{ 1113cdf0e10cSrcweir (void)aSender; 1114cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_BACKWARD character: 0 modifiers: 0]; 1115cdf0e10cSrcweir} 1116cdf0e10cSrcweir 1117cdf0e10cSrcweir-(void)moveRight: (id)aSender 1118cdf0e10cSrcweir{ 1119cdf0e10cSrcweir (void)aSender; 1120cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: KEY_RIGHT character: 0 modifiers: 0]; 1121cdf0e10cSrcweir} 1122cdf0e10cSrcweir 1123cdf0e10cSrcweir-(void)moveRightAndModifySelection: (id)aSender 1124cdf0e10cSrcweir{ 1125cdf0e10cSrcweir (void)aSender; 1126cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: KEY_RIGHT character: 0 modifiers: NSShiftKeyMask]; 1127cdf0e10cSrcweir} 1128cdf0e10cSrcweir 1129cdf0e10cSrcweir-(void)moveForwardAndModifySelection: (id)aSender 1130cdf0e10cSrcweir{ 1131cdf0e10cSrcweir (void)aSender; 1132cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_FORWARD character: 0 modifiers: 0]; 1133cdf0e10cSrcweir} 1134cdf0e10cSrcweir 1135cdf0e10cSrcweir-(void)moveWordLeft: (id)aSender 1136cdf0e10cSrcweir{ 1137cdf0e10cSrcweir (void)aSender; 1138cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_WORD_BACKWARD character: 0 modifiers: 0]; 1139cdf0e10cSrcweir} 1140cdf0e10cSrcweir 1141cdf0e10cSrcweir-(void)moveWordBackward: (id)aSender 1142cdf0e10cSrcweir{ 1143cdf0e10cSrcweir (void)aSender; 1144cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_WORD_BACKWARD character: 0 modifiers: 0]; 1145cdf0e10cSrcweir} 1146cdf0e10cSrcweir 1147cdf0e10cSrcweir-(void)moveWordBackwardAndModifySelection: (id)aSender 1148cdf0e10cSrcweir{ 1149cdf0e10cSrcweir (void)aSender; 1150cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_WORD_BACKWARD character: 0 modifiers: 0]; 1151cdf0e10cSrcweir} 1152cdf0e10cSrcweir 1153cdf0e10cSrcweir-(void)moveWordLeftAndModifySelection: (id)aSender 1154cdf0e10cSrcweir{ 1155cdf0e10cSrcweir (void)aSender; 1156cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_WORD_BACKWARD character: 0 modifiers: 0]; 1157cdf0e10cSrcweir} 1158cdf0e10cSrcweir 1159cdf0e10cSrcweir-(void)moveWordRight: (id)aSender 1160cdf0e10cSrcweir{ 1161cdf0e10cSrcweir (void)aSender; 1162cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_WORD_FORWARD character: 0 modifiers: 0]; 1163cdf0e10cSrcweir} 1164cdf0e10cSrcweir 1165cdf0e10cSrcweir-(void)moveWordForward: (id)aSender 1166cdf0e10cSrcweir{ 1167cdf0e10cSrcweir (void)aSender; 1168cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_WORD_FORWARD character: 0 modifiers: 0]; 1169cdf0e10cSrcweir} 1170cdf0e10cSrcweir 1171cdf0e10cSrcweir-(void)moveWordForwardAndModifySelection: (id)aSender 1172cdf0e10cSrcweir{ 1173cdf0e10cSrcweir (void)aSender; 1174cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_WORD_FORWARD character: 0 modifiers: 0]; 1175cdf0e10cSrcweir} 1176cdf0e10cSrcweir 1177cdf0e10cSrcweir-(void)moveWordRightAndModifySelection: (id)aSender 1178cdf0e10cSrcweir{ 1179cdf0e10cSrcweir (void)aSender; 1180cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_WORD_FORWARD character: 0 modifiers: 0]; 1181cdf0e10cSrcweir} 1182cdf0e10cSrcweir 1183cdf0e10cSrcweir-(void)moveToEndOfLine: (id)aSender 1184cdf0e10cSrcweir{ 1185cdf0e10cSrcweir (void)aSender; 1186cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_END_OF_LINE character: 0 modifiers: 0]; 1187cdf0e10cSrcweir} 1188cdf0e10cSrcweir 1189cdf0e10cSrcweir-(void)moveToRightEndOfLine: (id)aSender 1190cdf0e10cSrcweir{ 1191cdf0e10cSrcweir (void)aSender; 1192cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_END_OF_LINE character: 0 modifiers: 0]; 1193cdf0e10cSrcweir} 1194cdf0e10cSrcweir 1195cdf0e10cSrcweir-(void)moveToEndOfLineAndModifySelection: (id)aSender 1196cdf0e10cSrcweir{ 1197cdf0e10cSrcweir (void)aSender; 1198cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_END_OF_LINE character: 0 modifiers: 0]; 1199cdf0e10cSrcweir} 1200cdf0e10cSrcweir 1201cdf0e10cSrcweir-(void)moveToRightEndOfLineAndModifySelection: (id)aSender 1202cdf0e10cSrcweir{ 1203cdf0e10cSrcweir (void)aSender; 1204cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_END_OF_LINE character: 0 modifiers: 0]; 1205cdf0e10cSrcweir} 1206cdf0e10cSrcweir 1207cdf0e10cSrcweir-(void)moveToBeginningOfLine: (id)aSender 1208cdf0e10cSrcweir{ 1209cdf0e10cSrcweir (void)aSender; 1210cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_LINE character: 0 modifiers: 0]; 1211cdf0e10cSrcweir} 1212cdf0e10cSrcweir 1213cdf0e10cSrcweir-(void)moveToLeftEndOfLine: (id)aSender 1214cdf0e10cSrcweir{ 1215cdf0e10cSrcweir (void)aSender; 1216cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_LINE character: 0 modifiers: 0]; 1217cdf0e10cSrcweir} 1218cdf0e10cSrcweir 1219cdf0e10cSrcweir-(void)moveToBeginningOfLineAndModifySelection: (id)aSender 1220cdf0e10cSrcweir{ 1221cdf0e10cSrcweir (void)aSender; 1222cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_LINE character: 0 modifiers: 0]; 1223cdf0e10cSrcweir} 1224cdf0e10cSrcweir 1225cdf0e10cSrcweir-(void)moveToLeftEndOfLineAndModifySelection: (id)aSender 1226cdf0e10cSrcweir{ 1227cdf0e10cSrcweir (void)aSender; 1228cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_LINE character: 0 modifiers: 0]; 1229cdf0e10cSrcweir} 1230cdf0e10cSrcweir 1231cdf0e10cSrcweir-(void)moveToEndOfParagraph: (id)aSender 1232cdf0e10cSrcweir{ 1233cdf0e10cSrcweir (void)aSender; 1234cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_END_OF_PARAGRAPH character: 0 modifiers: 0]; 1235cdf0e10cSrcweir} 1236cdf0e10cSrcweir 1237cdf0e10cSrcweir-(void)moveToEndOfParagraphAndModifySelection: (id)aSender 1238cdf0e10cSrcweir{ 1239cdf0e10cSrcweir (void)aSender; 1240cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_END_OF_PARAGRAPH character: 0 modifiers: 0]; 1241cdf0e10cSrcweir} 1242cdf0e10cSrcweir 1243cdf0e10cSrcweir-(void)moveParagraphForward: (id)aSender 1244cdf0e10cSrcweir{ 1245cdf0e10cSrcweir (void)aSender; 1246cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_END_OF_PARAGRAPH character: 0 modifiers: 0]; 1247cdf0e10cSrcweir} 1248cdf0e10cSrcweir 1249cdf0e10cSrcweir-(void)moveParagraphForwardAndModifySelection: (id)aSender 1250cdf0e10cSrcweir{ 1251cdf0e10cSrcweir (void)aSender; 1252cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_END_OF_PARAGRAPH character: 0 modifiers: 0]; 1253cdf0e10cSrcweir} 1254cdf0e10cSrcweir 1255cdf0e10cSrcweir-(void)moveToBeginningOfParagraph: (id)aSender 1256cdf0e10cSrcweir{ 1257cdf0e10cSrcweir (void)aSender; 1258cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_PARAGRAPH character: 0 modifiers: 0]; 1259cdf0e10cSrcweir} 1260cdf0e10cSrcweir 1261cdf0e10cSrcweir-(void)moveParagraphBackward: (id)aSender 1262cdf0e10cSrcweir{ 1263cdf0e10cSrcweir (void)aSender; 1264cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_PARAGRAPH character: 0 modifiers: 0]; 1265cdf0e10cSrcweir} 1266cdf0e10cSrcweir 1267cdf0e10cSrcweir-(void)moveToBeginningOfParagraphAndModifySelection: (id)aSender 1268cdf0e10cSrcweir{ 1269cdf0e10cSrcweir (void)aSender; 1270cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_PARAGRAPH character: 0 modifiers: 0]; 1271cdf0e10cSrcweir} 1272cdf0e10cSrcweir 1273cdf0e10cSrcweir-(void)moveParagraphBackwardAndModifySelection: (id)aSender 1274cdf0e10cSrcweir{ 1275cdf0e10cSrcweir (void)aSender; 1276cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_PARAGRAPH character: 0 modifiers: 0]; 1277cdf0e10cSrcweir} 1278cdf0e10cSrcweir 1279cdf0e10cSrcweir-(void)moveToEndOfDocument: (id)aSender 1280cdf0e10cSrcweir{ 1281cdf0e10cSrcweir (void)aSender; 1282cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_END_OF_DOCUMENT character: 0 modifiers: 0]; 1283cdf0e10cSrcweir} 1284cdf0e10cSrcweir 1285cdf0e10cSrcweir-(void)scrollToEndOfDocument: (id)aSender 1286cdf0e10cSrcweir{ 1287cdf0e10cSrcweir (void)aSender; 1288cdf0e10cSrcweir // this is not exactly what we should do, but it makes "End" and "Shift-End" behave consistent 1289cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_END_OF_DOCUMENT character: 0 modifiers: 0]; 1290cdf0e10cSrcweir} 1291cdf0e10cSrcweir 1292cdf0e10cSrcweir-(void)moveToEndOfDocumentAndModifySelection: (id)aSender 1293cdf0e10cSrcweir{ 1294cdf0e10cSrcweir (void)aSender; 1295cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_END_OF_DOCUMENT character: 0 modifiers: 0]; 1296cdf0e10cSrcweir} 1297cdf0e10cSrcweir 1298cdf0e10cSrcweir-(void)moveToBeginningOfDocument: (id)aSender 1299cdf0e10cSrcweir{ 1300cdf0e10cSrcweir (void)aSender; 1301cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_DOCUMENT character: 0 modifiers: 0]; 1302cdf0e10cSrcweir} 1303cdf0e10cSrcweir 1304cdf0e10cSrcweir-(void)scrollToBeginningOfDocument: (id)aSender 1305cdf0e10cSrcweir{ 1306cdf0e10cSrcweir (void)aSender; 1307cdf0e10cSrcweir // this is not exactly what we should do, but it makes "Home" and "Shift-Home" behave consistent 1308cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_DOCUMENT character: 0 modifiers: 0]; 1309cdf0e10cSrcweir} 1310cdf0e10cSrcweir 1311cdf0e10cSrcweir-(void)moveToBeginningOfDocumentAndModifySelection: (id)aSender 1312cdf0e10cSrcweir{ 1313cdf0e10cSrcweir (void)aSender; 1314cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_DOCUMENT character: 0 modifiers: 0]; 1315cdf0e10cSrcweir} 1316cdf0e10cSrcweir 1317cdf0e10cSrcweir-(void)moveUp: (id)aSender 1318cdf0e10cSrcweir{ 1319cdf0e10cSrcweir (void)aSender; 1320cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: KEY_UP character: 0 modifiers: 0]; 1321cdf0e10cSrcweir} 1322cdf0e10cSrcweir 1323cdf0e10cSrcweir-(void)moveDown: (id)aSender 1324cdf0e10cSrcweir{ 1325cdf0e10cSrcweir (void)aSender; 1326cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: KEY_DOWN character: 0 modifiers: 0]; 1327cdf0e10cSrcweir} 1328cdf0e10cSrcweir 1329cdf0e10cSrcweir-(void)insertNewline: (id)aSender 1330cdf0e10cSrcweir{ 1331cdf0e10cSrcweir (void)aSender; 1332cdf0e10cSrcweir // #i91267# make enter and shift-enter work by evaluating the modifiers 1333cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: KEY_RETURN character: '\n' modifiers: mpFrame->mnLastModifierFlags]; 1334cdf0e10cSrcweir} 1335cdf0e10cSrcweir 1336cdf0e10cSrcweir-(void)deleteBackward: (id)aSender 1337cdf0e10cSrcweir{ 1338cdf0e10cSrcweir (void)aSender; 1339cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: KEY_BACKSPACE character: '\b' modifiers: 0]; 1340cdf0e10cSrcweir} 1341cdf0e10cSrcweir 1342cdf0e10cSrcweir-(void)deleteForward: (id)aSender 1343cdf0e10cSrcweir{ 1344cdf0e10cSrcweir (void)aSender; 1345cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: KEY_DELETE character: 0x7f modifiers: 0]; 1346cdf0e10cSrcweir} 1347cdf0e10cSrcweir 1348cdf0e10cSrcweir-(void)deleteBackwardByDecomposingPreviousCharacter: (id)aSender 1349cdf0e10cSrcweir{ 1350cdf0e10cSrcweir (void)aSender; 1351cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: KEY_BACKSPACE character: '\b' modifiers: 0]; 1352cdf0e10cSrcweir} 1353cdf0e10cSrcweir 1354cdf0e10cSrcweir-(void)deleteWordBackward: (id)aSender 1355cdf0e10cSrcweir{ 1356cdf0e10cSrcweir (void)aSender; 1357cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::DELETE_WORD_BACKWARD character: 0 modifiers: 0]; 1358cdf0e10cSrcweir} 1359cdf0e10cSrcweir 1360cdf0e10cSrcweir-(void)deleteWordForward: (id)aSender 1361cdf0e10cSrcweir{ 1362cdf0e10cSrcweir (void)aSender; 1363cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::DELETE_WORD_FORWARD character: 0 modifiers: 0]; 1364cdf0e10cSrcweir} 1365cdf0e10cSrcweir 1366cdf0e10cSrcweir-(void)deleteToBeginningOfLine: (id)aSender 1367cdf0e10cSrcweir{ 1368cdf0e10cSrcweir (void)aSender; 1369cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::DELETE_TO_BEGIN_OF_LINE character: 0 modifiers: 0]; 1370cdf0e10cSrcweir} 1371cdf0e10cSrcweir 1372cdf0e10cSrcweir-(void)deleteToEndOfLine: (id)aSender 1373cdf0e10cSrcweir{ 1374cdf0e10cSrcweir (void)aSender; 1375cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::DELETE_TO_END_OF_LINE character: 0 modifiers: 0]; 1376cdf0e10cSrcweir} 1377cdf0e10cSrcweir 1378cdf0e10cSrcweir-(void)deleteToBeginningOfParagraph: (id)aSender 1379cdf0e10cSrcweir{ 1380cdf0e10cSrcweir (void)aSender; 1381cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::DELETE_TO_BEGIN_OF_PARAGRAPH character: 0 modifiers: 0]; 1382cdf0e10cSrcweir} 1383cdf0e10cSrcweir 1384cdf0e10cSrcweir-(void)deleteToEndOfParagraph: (id)aSender 1385cdf0e10cSrcweir{ 1386cdf0e10cSrcweir (void)aSender; 1387cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::DELETE_TO_END_OF_PARAGRAPH character: 0 modifiers: 0]; 1388cdf0e10cSrcweir} 1389cdf0e10cSrcweir 1390cdf0e10cSrcweir-(void)insertLineBreak: (id)aSender 1391cdf0e10cSrcweir{ 1392cdf0e10cSrcweir (void)aSender; 1393cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::INSERT_LINEBREAK character: 0 modifiers: 0]; 1394cdf0e10cSrcweir} 1395cdf0e10cSrcweir 1396cdf0e10cSrcweir-(void)insertParagraphSeparator: (id)aSender 1397cdf0e10cSrcweir{ 1398cdf0e10cSrcweir (void)aSender; 1399cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::INSERT_PARAGRAPH character: 0 modifiers: 0]; 1400cdf0e10cSrcweir} 1401cdf0e10cSrcweir 1402cdf0e10cSrcweir-(void)selectWord: (id)aSender 1403cdf0e10cSrcweir{ 1404cdf0e10cSrcweir (void)aSender; 1405cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_WORD character: 0 modifiers: 0]; 1406cdf0e10cSrcweir} 1407cdf0e10cSrcweir 1408cdf0e10cSrcweir-(void)selectLine: (id)aSender 1409cdf0e10cSrcweir{ 1410cdf0e10cSrcweir (void)aSender; 1411cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_LINE character: 0 modifiers: 0]; 1412cdf0e10cSrcweir} 1413cdf0e10cSrcweir 1414cdf0e10cSrcweir-(void)selectParagraph: (id)aSender 1415cdf0e10cSrcweir{ 1416cdf0e10cSrcweir (void)aSender; 1417cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_PARAGRAPH character: 0 modifiers: 0]; 1418cdf0e10cSrcweir} 1419cdf0e10cSrcweir 1420cdf0e10cSrcweir-(void)selectAll: (id)aSender 1421cdf0e10cSrcweir{ 1422cdf0e10cSrcweir (void)aSender; 1423cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_ALL character: 0 modifiers: 0]; 1424cdf0e10cSrcweir} 1425cdf0e10cSrcweir 1426cdf0e10cSrcweir-(void)cancelOperation: (id)aSender 1427cdf0e10cSrcweir{ 1428cdf0e10cSrcweir (void)aSender; 1429cdf0e10cSrcweir [self sendKeyInputAndReleaseToFrame: KEY_ESCAPE character: 0x1b modifiers: 0]; 1430cdf0e10cSrcweir} 1431cdf0e10cSrcweir 1432cdf0e10cSrcweir-(void)noop: (id)aSender 1433cdf0e10cSrcweir{ 1434cdf0e10cSrcweir (void)aSender; 1435cdf0e10cSrcweir if( ! mbKeyHandled ) 1436cdf0e10cSrcweir { 1437cdf0e10cSrcweir if( ! [self sendSingleCharacter:mpLastEvent] ) 1438cdf0e10cSrcweir { 1439cdf0e10cSrcweir /* prevent recursion */ 1440cdf0e10cSrcweir if( mpLastEvent != mpLastSuperEvent && [NSApp respondsToSelector: @selector(sendSuperEvent:)] ) 1441cdf0e10cSrcweir { 1442cdf0e10cSrcweir id pLastSuperEvent = mpLastSuperEvent; 1443cdf0e10cSrcweir mpLastSuperEvent = mpLastEvent; 1444cdf0e10cSrcweir [NSApp performSelector:@selector(sendSuperEvent:) withObject: mpLastEvent]; 1445cdf0e10cSrcweir mpLastSuperEvent = pLastSuperEvent; 1446cdf0e10cSrcweir 1447cdf0e10cSrcweir std::map< NSEvent*, bool >::iterator it = GetSalData()->maKeyEventAnswer.find( mpLastEvent ); 1448cdf0e10cSrcweir if( it != GetSalData()->maKeyEventAnswer.end() ) 1449cdf0e10cSrcweir it->second = true; 1450cdf0e10cSrcweir } 1451cdf0e10cSrcweir } 1452cdf0e10cSrcweir } 1453cdf0e10cSrcweir} 1454cdf0e10cSrcweir 1455cdf0e10cSrcweir-(BOOL)sendKeyInputAndReleaseToFrame: (sal_uInt16)nKeyCode character: (sal_Unicode)aChar 1456cdf0e10cSrcweir{ 1457cdf0e10cSrcweir return [self sendKeyInputAndReleaseToFrame: nKeyCode character: aChar modifiers: mpFrame->mnLastModifierFlags]; 1458cdf0e10cSrcweir} 1459cdf0e10cSrcweir 1460cdf0e10cSrcweir-(BOOL)sendKeyInputAndReleaseToFrame: (sal_uInt16)nKeyCode character: (sal_Unicode)aChar modifiers: (unsigned int)nMod 1461cdf0e10cSrcweir{ 1462cdf0e10cSrcweir return [self sendKeyToFrameDirect: nKeyCode character: aChar modifiers: nMod] || 1463cdf0e10cSrcweir [self sendSingleCharacter: mpLastEvent]; 1464cdf0e10cSrcweir} 1465cdf0e10cSrcweir 1466cdf0e10cSrcweir-(BOOL)sendKeyToFrameDirect: (sal_uInt16)nKeyCode character: (sal_Unicode)aChar modifiers: (unsigned int)nMod 1467cdf0e10cSrcweir{ 1468cdf0e10cSrcweir YIELD_GUARD; 1469cdf0e10cSrcweir 1470cdf0e10cSrcweir long nRet = 0; 1471cdf0e10cSrcweir if( AquaSalFrame::isAlive( mpFrame ) ) 1472cdf0e10cSrcweir { 1473cdf0e10cSrcweir SalKeyEvent aEvent; 1474cdf0e10cSrcweir aEvent.mnTime = mpFrame->mnLastEventTime; 1475cdf0e10cSrcweir aEvent.mnCode = nKeyCode | ImplGetModifierMask( nMod ); 1476cdf0e10cSrcweir aEvent.mnCharCode = aChar; 1477cdf0e10cSrcweir aEvent.mnRepeat = FALSE; 1478cdf0e10cSrcweir nRet = mpFrame->CallCallback( SALEVENT_KEYINPUT, &aEvent ); 1479cdf0e10cSrcweir std::map< NSEvent*, bool >::iterator it = GetSalData()->maKeyEventAnswer.find( mpLastEvent ); 1480cdf0e10cSrcweir if( it != GetSalData()->maKeyEventAnswer.end() ) 1481cdf0e10cSrcweir it->second = nRet ? true : false; 1482cdf0e10cSrcweir if( AquaSalFrame::isAlive( mpFrame ) ) 1483cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_KEYUP, &aEvent ); 1484cdf0e10cSrcweir } 1485cdf0e10cSrcweir return nRet ? YES : NO; 1486cdf0e10cSrcweir} 1487cdf0e10cSrcweir 1488cdf0e10cSrcweir 1489cdf0e10cSrcweir-(BOOL)sendSingleCharacter: (NSEvent *)pEvent 1490cdf0e10cSrcweir{ 1491cdf0e10cSrcweir NSString* pUnmodifiedString = [pEvent charactersIgnoringModifiers]; 1492cdf0e10cSrcweir 1493cdf0e10cSrcweir if( pUnmodifiedString && [pUnmodifiedString length] == 1 ) 1494cdf0e10cSrcweir { 1495cdf0e10cSrcweir unichar keyChar = [pUnmodifiedString characterAtIndex: 0]; 1496cdf0e10cSrcweir sal_uInt16 nKeyCode = ImplMapCharCode( keyChar ); 1497cdf0e10cSrcweir if( nKeyCode != 0 ) 1498cdf0e10cSrcweir { 1499cdf0e10cSrcweir // don't send unicodes in the private use area 1500cdf0e10cSrcweir if( keyChar >= 0xf700 && keyChar < 0xf780 ) 1501cdf0e10cSrcweir keyChar = 0; 1502cdf0e10cSrcweir BOOL bRet = [self sendKeyToFrameDirect: nKeyCode character: keyChar modifiers: mpFrame->mnLastModifierFlags]; 1503cdf0e10cSrcweir mbInKeyInput = false; 1504cdf0e10cSrcweir 1505cdf0e10cSrcweir return bRet; 1506cdf0e10cSrcweir } 1507cdf0e10cSrcweir } 1508cdf0e10cSrcweir return NO; 1509cdf0e10cSrcweir} 1510cdf0e10cSrcweir 1511cdf0e10cSrcweir 1512cdf0e10cSrcweir// NSTextInput protocol 1513cdf0e10cSrcweir- (NSArray *)validAttributesForMarkedText 1514cdf0e10cSrcweir{ 1515cdf0e10cSrcweir return [NSArray arrayWithObjects:NSUnderlineStyleAttributeName, nil]; 1516cdf0e10cSrcweir} 1517cdf0e10cSrcweir 1518cdf0e10cSrcweir- (BOOL)hasMarkedText 1519cdf0e10cSrcweir{ 1520cdf0e10cSrcweir BOOL bHasMarkedText; 1521cdf0e10cSrcweir 1522cdf0e10cSrcweir bHasMarkedText = ( mMarkedRange.location != NSNotFound ) && 1523cdf0e10cSrcweir ( mMarkedRange.length != 0 ); 1524cdf0e10cSrcweir // hack to check keys like "Control-j" 1525cdf0e10cSrcweir if( mbInKeyInput ) 1526cdf0e10cSrcweir { 1527cdf0e10cSrcweir mbNeedSpecialKeyHandle = true; 1528cdf0e10cSrcweir } 1529cdf0e10cSrcweir 1530cdf0e10cSrcweir // FIXME: 1531cdf0e10cSrcweir // #i106901# 1532cdf0e10cSrcweir // if we come here outside of mbInKeyInput, this is likely to be because 1533cdf0e10cSrcweir // of the keyboard viewer. For unknown reasons having no marked range 1534cdf0e10cSrcweir // in this case causes a crash. So we say we have a marked range anyway 1535cdf0e10cSrcweir // This is a hack, since it is not understood what a) causes that crash 1536cdf0e10cSrcweir // and b) why we should have a marked range at this point. 1537cdf0e10cSrcweir if( ! mbInKeyInput ) 1538cdf0e10cSrcweir bHasMarkedText = YES; 1539cdf0e10cSrcweir 1540cdf0e10cSrcweir return bHasMarkedText; 1541cdf0e10cSrcweir} 1542cdf0e10cSrcweir 1543cdf0e10cSrcweir- (NSRange)markedRange 1544cdf0e10cSrcweir{ 1545cdf0e10cSrcweir // FIXME: 1546cdf0e10cSrcweir // #i106901# 1547cdf0e10cSrcweir // if we come here outside of mbInKeyInput, this is likely to be because 1548cdf0e10cSrcweir // of the keyboard viewer. For unknown reasons having no marked range 1549cdf0e10cSrcweir // in this case causes a crash. So we say we have a marked range anyway 1550cdf0e10cSrcweir // This is a hack, since it is not understood what a) causes that crash 1551cdf0e10cSrcweir // and b) why we should have a marked range at this point. 1552cdf0e10cSrcweir if( ! mbInKeyInput ) 1553cdf0e10cSrcweir return NSMakeRange( 0, 0 ); 1554cdf0e10cSrcweir 1555cdf0e10cSrcweir return [self hasMarkedText] ? mMarkedRange : NSMakeRange( NSNotFound, 0 ); 1556cdf0e10cSrcweir} 1557cdf0e10cSrcweir 1558cdf0e10cSrcweir- (NSRange)selectedRange 1559cdf0e10cSrcweir{ 1560cdf0e10cSrcweir return mSelectedRange; 1561cdf0e10cSrcweir} 1562cdf0e10cSrcweir 1563cdf0e10cSrcweir- (void)setMarkedText:(id)aString selectedRange:(NSRange)selRange 1564cdf0e10cSrcweir{ 1565cdf0e10cSrcweir if( ![aString isKindOfClass:[NSAttributedString class]] ) 1566cdf0e10cSrcweir aString = [[[NSAttributedString alloc] initWithString:aString] autorelease]; 1567cdf0e10cSrcweir NSRange rangeToReplace = [self hasMarkedText] ? [self markedRange] : [self selectedRange]; 1568cdf0e10cSrcweir if( rangeToReplace.location == NSNotFound ) 1569cdf0e10cSrcweir { 1570cdf0e10cSrcweir mMarkedRange = NSMakeRange( selRange.location, [aString length] ); 1571cdf0e10cSrcweir mSelectedRange = NSMakeRange( selRange.location, selRange.length ); 1572cdf0e10cSrcweir } 1573cdf0e10cSrcweir else 1574cdf0e10cSrcweir { 1575cdf0e10cSrcweir mMarkedRange = NSMakeRange( rangeToReplace.location, [aString length] ); 1576cdf0e10cSrcweir mSelectedRange = NSMakeRange( rangeToReplace.location + selRange.location, selRange.length ); 1577cdf0e10cSrcweir } 1578cdf0e10cSrcweir 1579cdf0e10cSrcweir int len = [aString length]; 1580cdf0e10cSrcweir SalExtTextInputEvent aInputEvent; 1581cdf0e10cSrcweir aInputEvent.mnTime = mpFrame->mnLastEventTime; 1582cdf0e10cSrcweir aInputEvent.mnDeltaStart = 0; 1583cdf0e10cSrcweir aInputEvent.mbOnlyCursor = FALSE; 1584cdf0e10cSrcweir if( len > 0 ) { 1585cdf0e10cSrcweir NSString *pString = [aString string]; 1586cdf0e10cSrcweir OUString aInsertString( GetOUString( pString ) ); 1587cdf0e10cSrcweir std::vector<sal_uInt16> aInputFlags = std::vector<sal_uInt16>( std::max( 1, len ), 0 ); 1588cdf0e10cSrcweir for ( int i = 0; i < len; i++ ) 1589cdf0e10cSrcweir { 1590cdf0e10cSrcweir unsigned int nUnderlineValue; 1591cdf0e10cSrcweir NSRange effectiveRange; 1592cdf0e10cSrcweir 1593cdf0e10cSrcweir effectiveRange = NSMakeRange(i, 1); 1594cdf0e10cSrcweir nUnderlineValue = [[aString attribute:NSUnderlineStyleAttributeName atIndex:i effectiveRange:&effectiveRange] unsignedIntValue]; 1595cdf0e10cSrcweir 1596cdf0e10cSrcweir switch (nUnderlineValue & 0xff) { 1597cdf0e10cSrcweir case NSUnderlineStyleSingle: 1598cdf0e10cSrcweir aInputFlags[i] = SAL_EXTTEXTINPUT_ATTR_UNDERLINE; 1599cdf0e10cSrcweir break; 1600cdf0e10cSrcweir case NSUnderlineStyleThick: 1601cdf0e10cSrcweir aInputFlags[i] = SAL_EXTTEXTINPUT_ATTR_UNDERLINE | SAL_EXTTEXTINPUT_ATTR_HIGHLIGHT; 1602cdf0e10cSrcweir break; 1603cdf0e10cSrcweir case NSUnderlineStyleDouble: 1604cdf0e10cSrcweir aInputFlags[i] = SAL_EXTTEXTINPUT_ATTR_BOLDUNDERLINE; 1605cdf0e10cSrcweir break; 1606cdf0e10cSrcweir default: 1607cdf0e10cSrcweir aInputFlags[i] = SAL_EXTTEXTINPUT_ATTR_HIGHLIGHT; 1608cdf0e10cSrcweir break; 1609cdf0e10cSrcweir } 1610cdf0e10cSrcweir } 1611cdf0e10cSrcweir 1612cdf0e10cSrcweir aInputEvent.maText = aInsertString; 1613cdf0e10cSrcweir aInputEvent.mnCursorPos = selRange.location; 1614cdf0e10cSrcweir aInputEvent.mpTextAttr = &aInputFlags[0]; 1615cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_EXTTEXTINPUT, (void *)&aInputEvent ); 1616cdf0e10cSrcweir } else { 1617cdf0e10cSrcweir aInputEvent.maText = String(); 1618cdf0e10cSrcweir aInputEvent.mnCursorPos = 0; 1619cdf0e10cSrcweir aInputEvent.mnCursorFlags = 0; 1620cdf0e10cSrcweir aInputEvent.mpTextAttr = 0; 1621cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_EXTTEXTINPUT, (void *)&aInputEvent ); 1622cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_ENDEXTTEXTINPUT, 0 ); 1623cdf0e10cSrcweir } 1624cdf0e10cSrcweir mbKeyHandled= true; 1625cdf0e10cSrcweir} 1626cdf0e10cSrcweir 1627cdf0e10cSrcweir- (void)unmarkText 1628cdf0e10cSrcweir{ 1629cdf0e10cSrcweir mSelectedRange = mMarkedRange = NSMakeRange(NSNotFound, 0); 1630cdf0e10cSrcweir} 1631cdf0e10cSrcweir 1632cdf0e10cSrcweir- (NSAttributedString *)attributedSubstringFromRange:(NSRange)theRange 1633cdf0e10cSrcweir{ 1634cdf0e10cSrcweir (void)theRange; 1635cdf0e10cSrcweir // FIXME 1636cdf0e10cSrcweir return nil; 1637cdf0e10cSrcweir} 1638cdf0e10cSrcweir 16392dae3561SHerbert Dürr- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint 1640cdf0e10cSrcweir{ 1641cdf0e10cSrcweir (void)thePoint; 1642cdf0e10cSrcweir // FIXME 1643cdf0e10cSrcweir return 0; 1644cdf0e10cSrcweir} 1645cdf0e10cSrcweir 1646cdf0e10cSrcweir#if defined(MAC_OS_X_VERSION_10_5) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) 1647cdf0e10cSrcweir/* build target 10.5 or greater */ 1648cdf0e10cSrcweir- (NSInteger)conversationIdentifier 1649cdf0e10cSrcweir#else 1650cdf0e10cSrcweir/* build target 10.4 */ 1651cdf0e10cSrcweir- (long)conversationIdentifier 1652cdf0e10cSrcweir#endif 1653cdf0e10cSrcweir{ 1654cdf0e10cSrcweir return (long)self; 1655cdf0e10cSrcweir} 1656cdf0e10cSrcweir 1657cdf0e10cSrcweir- (void)doCommandBySelector:(SEL)aSelector 1658cdf0e10cSrcweir{ 1659cdf0e10cSrcweir if( AquaSalFrame::isAlive( mpFrame ) ) 1660cdf0e10cSrcweir { 1661cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1662cdf0e10cSrcweir // fprintf( stderr, "SalFrameView: doCommandBySelector %s\n", (char*)aSelector ); 1663cdf0e10cSrcweir #endif 1664cdf0e10cSrcweir if( (mpFrame->mnICOptions & SAL_INPUTCONTEXT_TEXT) != 0 && 1665cdf0e10cSrcweir aSelector != NULL && [self respondsToSelector: aSelector] ) 1666cdf0e10cSrcweir { 1667cdf0e10cSrcweir [self performSelector: aSelector]; 1668cdf0e10cSrcweir } 1669cdf0e10cSrcweir else 1670cdf0e10cSrcweir { 1671cdf0e10cSrcweir [self sendSingleCharacter:mpLastEvent]; 1672cdf0e10cSrcweir } 1673cdf0e10cSrcweir } 1674cdf0e10cSrcweir 1675cdf0e10cSrcweir mbKeyHandled = true; 1676cdf0e10cSrcweir} 1677cdf0e10cSrcweir 1678cdf0e10cSrcweir-(void)clearLastEvent 1679cdf0e10cSrcweir{ 1680cdf0e10cSrcweir mpLastEvent = nil; 1681cdf0e10cSrcweir} 1682cdf0e10cSrcweir 1683cdf0e10cSrcweir- (NSRect)firstRectForCharacterRange:(NSRange)theRange 1684cdf0e10cSrcweir{ 1685cdf0e10cSrcweir (void)theRange; 1686cdf0e10cSrcweir SalExtTextInputPosEvent aPosEvent; 1687cdf0e10cSrcweir mpFrame->CallCallback( SALEVENT_EXTTEXTINPUTPOS, (void *)&aPosEvent ); 1688cdf0e10cSrcweir 1689cdf0e10cSrcweir NSRect rect; 1690cdf0e10cSrcweir 1691cdf0e10cSrcweir rect.origin.x = aPosEvent.mnX + mpFrame->maGeometry.nX; 1692cdf0e10cSrcweir rect.origin.y = aPosEvent.mnY + mpFrame->maGeometry.nY + 4; // add some space for underlines 1693cdf0e10cSrcweir rect.size.width = aPosEvent.mnWidth; 1694cdf0e10cSrcweir rect.size.height = aPosEvent.mnHeight; 1695cdf0e10cSrcweir 1696cdf0e10cSrcweir mpFrame->VCLToCocoa( rect ); 1697cdf0e10cSrcweir return rect; 1698cdf0e10cSrcweir} 1699cdf0e10cSrcweir 1700cdf0e10cSrcweir-(id)parentAttribute { 1701bde8a4bdSHerbert Dürr return mpFrame->getNSWindow(); 1702cdf0e10cSrcweir} 1703cdf0e10cSrcweir 1704cdf0e10cSrcweir-(::com::sun::star::accessibility::XAccessibleContext *)accessibleContext 1705cdf0e10cSrcweir{ 1706cdf0e10cSrcweir if ( mpReferenceWrapper == nil ) { 1707cdf0e10cSrcweir // some frames never become visible .. 1708cdf0e10cSrcweir Window *pWindow = mpFrame -> GetWindow(); 1709cdf0e10cSrcweir if ( ! pWindow ) 1710cdf0e10cSrcweir return nil; 1711cdf0e10cSrcweir 1712cdf0e10cSrcweir mpReferenceWrapper = new ReferenceWrapper; 1713cdf0e10cSrcweir mpReferenceWrapper -> rAccessibleContext = pWindow -> /*GetAccessibleChildWindow( 0 ) ->*/ GetAccessible() -> getAccessibleContext(); 1714cdf0e10cSrcweir [ AquaA11yFactory insertIntoWrapperRepository: self forAccessibleContext: mpReferenceWrapper -> rAccessibleContext ]; 1715cdf0e10cSrcweir } 1716cdf0e10cSrcweir return [ super accessibleContext ]; 1717cdf0e10cSrcweir} 1718cdf0e10cSrcweir 171997dacec1SHerbert Dürr-(NSWindow*)windowForParent 17202fb76c82SHerbert Dürr{ 172197dacec1SHerbert Dürr return mpFrame->getNSWindow(); 1722cdf0e10cSrcweir} 1723cdf0e10cSrcweir 1724cdf0e10cSrcweir-(void)registerMouseEventListener: (id)theListener 1725cdf0e10cSrcweir{ 1726cdf0e10cSrcweir mpMouseEventListener = theListener; 1727cdf0e10cSrcweir} 1728cdf0e10cSrcweir 1729cdf0e10cSrcweir-(void)unregisterMouseEventListener: (id)theListener 1730cdf0e10cSrcweir{ 1731cdf0e10cSrcweir (void)theListener; 1732cdf0e10cSrcweir mpMouseEventListener = nil; 1733cdf0e10cSrcweir} 1734cdf0e10cSrcweir 1735cdf0e10cSrcweir-(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender 1736cdf0e10cSrcweir{ 1737cdf0e10cSrcweir return [mDraggingDestinationHandler draggingEntered: sender]; 1738cdf0e10cSrcweir} 1739cdf0e10cSrcweir 1740cdf0e10cSrcweir-(NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender 1741cdf0e10cSrcweir{ 1742cdf0e10cSrcweir return [mDraggingDestinationHandler draggingUpdated: sender]; 1743cdf0e10cSrcweir} 1744cdf0e10cSrcweir 1745cdf0e10cSrcweir-(void)draggingExited:(id <NSDraggingInfo>)sender 1746cdf0e10cSrcweir{ 1747cdf0e10cSrcweir [mDraggingDestinationHandler draggingExited: sender]; 1748cdf0e10cSrcweir} 1749cdf0e10cSrcweir 1750cdf0e10cSrcweir-(BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender 1751cdf0e10cSrcweir{ 1752cdf0e10cSrcweir return [mDraggingDestinationHandler prepareForDragOperation: sender]; 1753cdf0e10cSrcweir} 1754cdf0e10cSrcweir 1755cdf0e10cSrcweir-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender 1756cdf0e10cSrcweir{ 1757cdf0e10cSrcweir return [mDraggingDestinationHandler performDragOperation: sender]; 1758cdf0e10cSrcweir} 1759cdf0e10cSrcweir 1760cdf0e10cSrcweir-(void)concludeDragOperation:(id <NSDraggingInfo>)sender 1761cdf0e10cSrcweir{ 1762cdf0e10cSrcweir [mDraggingDestinationHandler concludeDragOperation: sender]; 1763cdf0e10cSrcweir} 1764cdf0e10cSrcweir 1765cdf0e10cSrcweir-(void)registerDraggingDestinationHandler:(id)theHandler 1766cdf0e10cSrcweir{ 1767cdf0e10cSrcweir mDraggingDestinationHandler = theHandler; 1768cdf0e10cSrcweir} 1769cdf0e10cSrcweir 1770cdf0e10cSrcweir-(void)unregisterDraggingDestinationHandler:(id)theHandler 1771cdf0e10cSrcweir{ 1772cdf0e10cSrcweir (void)theHandler; 1773cdf0e10cSrcweir mDraggingDestinationHandler = nil; 1774cdf0e10cSrcweir} 1775cdf0e10cSrcweir 1776cdf0e10cSrcweir@end 1777cdf0e10cSrcweir 1778