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