summaryrefslogtreecommitdiff
path: root/vcl/aqua/source/app/vclnsapp.mm
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2008-01-14 15:16:30 +0000
committerIvo Hinkelmann <ihi@openoffice.org>2008-01-14 15:16:30 +0000
commit71b813ee3e529b38523c2bedb91a4eecb8598dfa (patch)
tree9c8760d9e0cadef7240c8dceaa796bf20eba9e05 /vcl/aqua/source/app/vclnsapp.mm
parent315f4b2dfb9057bfc579d967e2e0eb61b7437fd5 (diff)
INTEGRATION: CWS aquavcl04 (1.1.2); FILE ADDED
2007/12/06 12:55:02 pl 1.1.2.5: #i84306# react on display changes 2007/10/31 18:54:47 pl 1.1.2.4: clean up some copy and paste garbage 2007/10/31 18:51:23 pl 1.1.2.3: #i83176# detect system colors changing 2007/10/16 13:10:08 pl 1.1.2.2: #i82266# send mouse and wheel events to correct frame 2007/10/15 13:24:25 pl 1.1.2.1: #i82627# move objective c++ implementations to own (.mm) files
Diffstat (limited to 'vcl/aqua/source/app/vclnsapp.mm')
-rwxr-xr-xvcl/aqua/source/app/vclnsapp.mm194
1 files changed, 194 insertions, 0 deletions
diff --git a/vcl/aqua/source/app/vclnsapp.mm b/vcl/aqua/source/app/vclnsapp.mm
new file mode 100755
index 000000000000..f6655804a02b
--- /dev/null
+++ b/vcl/aqua/source/app/vclnsapp.mm
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclnsapp.mm,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: ihi $ $Date: 2008-01-14 16:16:30 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+ // MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_vcl.hxx"
+
+#include "vclnsapp.h"
+#include "salinst.h"
+#include "saldata.hxx"
+#include "salframe.h"
+#include "salframeview.h"
+
+#include "vcl/window.hxx"
+#include "vcl/svapp.hxx"
+
+#include "rtl/ustrbuf.hxx"
+
+
+@implementation CocoaThreadEnabler
+-(void)enableCocoaThreads:(id)param
+{
+ // do nothing, this is just to start an NSThread and therefore put
+ // Cocoa into multithread mode
+}
+@end
+
+@implementation VCL_NSApplication
+-(void)sendEvent:(NSEvent*)pEvent
+{
+ NSEventType eType = [pEvent type];
+ if( eType == NSApplicationDefined )
+ GetSalData()->mpFirstInstance->handleAppDefinedEvent( pEvent );
+ else if( eType == NSKeyDown && ([pEvent modifierFlags] & NSCommandKeyMask) != 0 )
+ {
+ NSWindow* pKeyWin = [NSApp keyWindow];
+ if( pKeyWin && [pKeyWin isKindOfClass: [SalFrameWindow class]] )
+ {
+ AquaSalFrame* pFrame = [(SalFrameWindow*)pKeyWin getSalFrame];
+ if( pFrame->mpParent && pFrame->mpParent->GetWindow()->IsInModalMode() )
+ {
+ // dispatch to view directly to avoid the key event being consumed by the menubar
+ [[pKeyWin contentView] keyDown: pEvent];
+ return;
+ }
+ }
+
+ }
+ else if( eType == NSScrollWheel )
+ {
+ // FIMXE: this is necessary on MacOS 10.4 only
+ // how do I find out the OS version ?
+
+ NSWindow* pWin = [pEvent window];
+ // on Tiger wheel events do not reach non key windows
+ // which probably should be considered a bug
+ if( [pWin isKindOfClass: [SalFrameWindow class]] && [pWin canBecomeKeyWindow] == NO )
+ {
+ [[pWin contentView] scrollWheel: pEvent];
+ return;
+ }
+ }
+ [super sendEvent: pEvent];
+}
+
+-(NSMenu*)applicationDockMenu:(NSApplication *)sender
+{
+ return AquaSalInstance::GetDynamicDockMenu();
+}
+-(MacOSBOOL)application: (NSApplication*)app openFile: (NSString*)pFile
+{
+ const rtl::OUString aFile( GetOUString( pFile ) );
+ const ApplicationEvent* pAppEvent = new ApplicationEvent( String(), ApplicationAddress(),
+ APPEVENT_OPEN_STRING, aFile );
+ AquaSalInstance::aAppEventList.push_back( pAppEvent );
+ return YES;
+}
+
+-(void)application: (NSApplication*) app openFiles: (NSArray*)files
+{
+ rtl::OUStringBuffer aFileList( 256 );
+
+ NSEnumerator* it = [files objectEnumerator];
+ NSString* pFile = nil;
+
+ while( (pFile = [it nextObject]) != nil )
+ {
+ if( aFileList.getLength() > 0 )
+ aFileList.append( sal_Unicode( APPEVENT_PARAM_DELIMITER ) );
+ aFileList.append( GetOUString( pFile ) );
+ }
+ // we have no back channel here, we have to assume success, in which case
+ // replyToOpenOrPrint does not need to be called according to documentation
+ // [app replyToOpenOrPrint: NSApplicationDelegateReplySuccess];
+ const ApplicationEvent* pAppEvent = new ApplicationEvent( String(), ApplicationAddress(),
+ APPEVENT_OPEN_STRING, aFileList.makeStringAndClear() );
+ AquaSalInstance::aAppEventList.push_back( pAppEvent );
+}
+
+-(MacOSBOOL)application: (NSApplication*)app printFile: (NSString*)pFile
+{
+ const rtl::OUString aFile( GetOUString( pFile ) );
+ const ApplicationEvent* pAppEvent = new ApplicationEvent( String(), ApplicationAddress(),
+ APPEVENT_PRINT_STRING, aFile );
+ AquaSalInstance::aAppEventList.push_back( pAppEvent );
+ return YES;
+}
+-(NSApplicationPrintReply)application: (NSApplication *) app printFiles:(NSArray *)files withSettings: (NSDictionary *)printSettings showPrintPanels:(MacOSBOOL)bShowPrintPanels
+{
+ // currently ignores print settings an bShowPrintPanels
+ rtl::OUStringBuffer aFileList( 256 );
+
+ NSEnumerator* it = [files objectEnumerator];
+ NSString* pFile = nil;
+
+ while( (pFile = [it nextObject]) != nil )
+ {
+ if( aFileList.getLength() > 0 )
+ aFileList.append( sal_Unicode( APPEVENT_PARAM_DELIMITER ) );
+ aFileList.append( GetOUString( pFile ) );
+ }
+ const ApplicationEvent* pAppEvent = new ApplicationEvent( String(), ApplicationAddress(),
+ APPEVENT_PRINT_STRING, aFileList.makeStringAndClear() );
+ AquaSalInstance::aAppEventList.push_back( pAppEvent );
+ // we have no back channel here, we have to assume success
+ // correct handling would be NSPrintingReplyLater and then send [app replyToOpenOrPrint]
+ return NSPrintingSuccess;
+}
+
+-(NSApplicationTerminateReply)applicationShouldTerminate: (NSApplication *) app
+{
+ const SalData* pSalData = GetSalData();
+ if( !pSalData->maFrames.empty() )
+ {
+ // we forward the signal; alas we have no answer
+ // we cancel the request; OOo will decide whether is shuts down or not
+ pSalData->maFrames.front()->CallCallback( SALEVENT_SHUTDOWN, NULL );
+ return NSTerminateCancel;
+ }
+ else
+ // no frame left to talk to -> we really should terminate
+ return NSTerminateNow;
+}
+
+-(void)systemColorsChanged: (NSNotification*) pNotification
+{
+ const SalData* pSalData = GetSalData();
+ if( !pSalData->maFrames.empty() )
+ pSalData->maFrames.front()->CallCallback( SALEVENT_SETTINGSCHANGED, NULL );
+}
+
+-(void)screenParametersChanged: (NSNotification*) pNotification
+{
+ SalData* pSalData = GetSalData();
+ std::list< AquaSalFrame* >::iterator it;
+ for( it = pSalData->maFrames.begin(); it != pSalData->maFrames.end(); ++it )
+ {
+ (*it)->screenParametersChanged();
+ }
+}
+
+@end
+