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