diff -x CVS -urN ooo_SRC680_m187_src.orig/canvas/source/java/aqua/WindowAdapter.java ooo_SRC680_m187_src.aquavcl01/canvas/source/java/aqua/WindowAdapter.java --- ooo_SRC680_m187_src.orig/canvas/source/java/aqua/WindowAdapter.java 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/canvas/source/java/aqua/WindowAdapter.java 2006-01-31 01:07:05.000000000 +0100 @@ -0,0 +1,175 @@ +// UNO +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.uno.AnyConverter; +import com.sun.star.lang.XInitialization; +import com.sun.star.lib.uno.helper.WeakBase; + +// OOo AWT +import com.sun.star.awt.*; + +// system-dependent stuff +import sun.awt.*; + +//Apple specifics +import apple.awt.*; + + +public class WindowAdapter +// defacto implementing the interface, but not deriving from it, since +// we're no real XInterface here +// implements com.sun.star.awt.XWindow +{ + public java.awt.Frame frame; + private boolean fullscreen; + + public WindowAdapter( int windowHandle, + boolean _fullscreen ) + { + fullscreen = false; + + if( _fullscreen ) + { + // create a normal Java frame, and set it into fullscreen mode + frame = new javax.swing.JFrame( "Presentation" ); + frame.setUndecorated( true ); + frame.setVisible( true ); + + java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); + if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) + { + CanvasUtils.printLog( "WindowAdapter(Aqua): entering fullscreen mode" ); + graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame ); + fullscreen = true; + } + else + { + CanvasUtils.printLog( "WindowAdapter(Aqua): fullscreen not supported" ); + } + + graphics.dispose(); + } + else + { + // we're initialized with the operating system window handle + // as the parameter. We then generate a dummy Java frame with + // that window as the parent, to fake a root window for the + // Java implementation. + + // now, we're getting slightly system dependent here. + String os = (String) System.getProperty("os.name"); + + // create the embedded frame + if( os.startsWith("Mac OS X") ) + frame = new apple.awt.CEmbeddedFrame( windowHandle ); + else + throw new com.sun.star.uno.RuntimeException(); + + +// frame = new javax.swing.JFrame( "Test window" ); + +// // resize it according to the given bounds +// frame.setBounds( boundRect ); +// frame.setVisible( true ); + } + } + + //---------------------------------------------------------------------------------- + + public void dispose() + { + if( fullscreen ) + { + java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); + if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) + { + CanvasUtils.printLog( "WindowAdapter(Aqua): leaving fullscreen mode" ); + graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null ); + } + graphics.dispose(); + } + + if( frame != null ) + frame.dispose(); + } + + //---------------------------------------------------------------------------------- + + // + // XWindow interface + // ================= + // + public void setPosSize( int X, int Y, int Width, int Height, short Flags ) + { + frame.setBounds( new java.awt.Rectangle( X, Y, Width, Height ) ); + } + + public com.sun.star.awt.Rectangle getPosSize( ) + { + java.awt.Rectangle bounds = frame.getBounds(); + + return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height ); + } + + public void setVisible( boolean visible ) + { + frame.setVisible( visible ); + } + + public void setEnable( boolean enable ) + { + frame.setEnabled( enable ); + } + + public void setFocus() + { + } + + public void addWindowListener( XWindowListener xListener ) + { + } + + public void removeWindowListener( XWindowListener xListener ) + { + } + + public void addFocusListener( XFocusListener xListener ) + { + } + + public void removeFocusListener( XFocusListener xListener ) + { + } + + public void addKeyListener( XKeyListener xListener ) + { + } + + public void removeKeyListener( XKeyListener xListener ) + { + } + + public void addMouseListener( XMouseListener xListener ) + { + } + + public void removeMouseListener( XMouseListener xListener ) + { + } + + public void addMouseMotionListener( XMouseMotionListener xListener ) + { + } + + public void removeMouseMotionListener( XMouseMotionListener xListener ) + { + } + + public void addPaintListener( XPaintListener xListener ) + { + } + + public void removePaintListener( XPaintListener xListener ) + { + } +} diff -x CVS -urN ooo_SRC680_m187_src.orig/canvas/source/java/makefile.mk ooo_SRC680_m187_src.aquavcl01/canvas/source/java/makefile.mk --- ooo_SRC680_m187_src.orig/canvas/source/java/makefile.mk 2006-08-14 18:14:56.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/canvas/source/java/makefile.mk 2006-08-22 00:09:13.000000000 +0200 @@ -68,15 +68,19 @@ BezierPolyPolygon.java \ SpriteRunner.java -.IF "$(GUIBASE)"!="unx" +.IF "$(GUIBASE)"=="unx" -JAVAFILES += win/WindowAdapter.java +JAVAFILES += x11/WindowAdapter.java -.ELSE # "$(GUIBASE)"!="unx" +.ELIF "$(GUIBASE)"=="aqua" -JAVAFILES += x11/WindowAdapter.java +JAVAFILES += aqua/WindowAdapter.java + +.ELSE + +JAVAFILES += win/WindowAdapter.java -.ENDIF # "$(GUIBASE)"!="unx" +.ENDIF # "$(GUIBASE)"=="unx" JARFILES = jurt.jar unoil.jar ridl.jar juh.jar java_uno.jar #JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) diff -x CVS -urN ooo_SRC680_m187_src.orig/dtrans/source/aqua/dtransaqua.xml ooo_SRC680_m187_src.aquavcl01/dtrans/source/aqua/dtransaqua.xml --- ooo_SRC680_m187_src.orig/dtrans/source/aqua/dtransaqua.xml 2003-03-25 15:05:32.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/dtrans/source/aqua/dtransaqua.xml 2005-11-27 11:12:33.000000000 +0100 @@ -1,55 +1,48 @@ - - - - - - Tino Rachui - - com.sun.star.comp.datatransfer.clipboard - - - The win32 implementation of the datatransfer service. - - - sysdtrans - - com.sun.star.loader.SharedLibrary - - c++ - - - - com.sun.star.datatransfer.clipboard.SystemClipboard - - ... - - cppuhelper - cppu - sal - - cppuhelper - cppu2 - sal2 - - com.sun.star.datatransfer.clipboard.XClipboardEx - com.sun.star.datatransfer.XTransferable - com.sun.star.datatransfer.XTransferableEx - com.sun.star.datatransfer.clipboard.XClipboardOwner - com.sun.star.datatransfer.clipboard.XClipboardListener - com.sun.star.datatransfer.clipboard.XClipboardNotifier - com.sun.star.datatransfer.XTransferDataAccess - com.sun.star.lang.XComponent - com.sun.star.lang.XMultiServiceFactory - com.sun.star.lang.XSingleServiceFactory - com.sun.star.lang.XServiceInfo - com.sun.star.lang.XTypeProvider - com.sun.star.lang.IllegalArgumentException - com.sun.star.uno.TypeClass - com.sun.star.uno.XWeak - com.sun.star.uno.XAggregation - com.sun.star.registry.XRegistryKey - com.sun.star.container.XSet - - - + + + + dtransaqua + + Tino Rachui + com.sun.star.comp.datatransfer.aqua + + The aqua implementation of the datatransfer service. + + com.sun.star.loader.SharedLibrary + c++ + + com.sun.star.datatransfer.clipboard.SystemClipboard + ... + com.sun.star.datatransfer.clipboard.XClipboardEx + com.sun.star.datatransfer.XTransferable + com.sun.star.datatransfer.clipboard.RenderingCapabilities + com.sun.star.datatransfer.clipboard.XClipboardOwner + com.sun.star.datatransfer.clipboard.XClipboardListener + com.sun.star.datatransfer.clipboard.XClipboardNotifier + com.sun.star.datatransfer.dnd.XDropTargetDropContext + com.sun.star.datatransfer.dnd.XDropTargetDragContext + com.sun.star.datatransfer.dnd.XDropTarget + com.sun.star.datatransfer.dnd.DNDConstants + com.sun.star.datatransfer.dnd.XDragSource + com.sun.star.datatransfer.dnd.XDragSourceContext + com.sun.star.awt.XDisplayConnection + com.sun.star.lang.DisposedException + com.sun.star.lang.IllegalArgumentException + com.sun.star.lang.XComponent + com.sun.star.lang.XMultiServiceFactory + com.sun.star.lang.XSingleServiceFactory + com.sun.star.lang.XServiceInfo + com.sun.star.lang.XTypeProvider + com.sun.star.uno.TypeClass + com.sun.star.uno.XWeak + com.sun.star.uno.XAggregation + com.sun.star.registry.XRegistryKey + com.sun.star.container.XSet + + cppuhelper + cppu + sal + cppuhelper + cppu2 + sal2 + diff -x CVS -urN ooo_SRC680_m187_src.orig/dtrans/source/aqua/makefile.mk ooo_SRC680_m187_src.aquavcl01/dtrans/source/aqua/makefile.mk --- ooo_SRC680_m187_src.orig/dtrans/source/aqua/makefile.mk 2006-05-24 16:32:51.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/dtrans/source/aqua/makefile.mk 2006-08-07 20:28:22.000000000 +0200 @@ -93,9 +93,7 @@ # --- Targets ------------------------------------------------------ ALL : ALLTAR -# hjs - do *not* call deliver out of makefiles -# +deliver.pl - +regcomp -register -r $(BIN)$/$(COMP1TYPELIST).rdb -c $(SHL1TARGET) + +cd $(LB) && regcomp -register -r ../bin/$(COMP1TYPELIST).rdb -c $(SHL1TARGET) .INCLUDE : target.mk diff -x CVS -urN ooo_SRC680_m187_src.orig/extensions/prj/build.lst ooo_SRC680_m187_src.aquavcl01/extensions/prj/build.lst --- ooo_SRC680_m187_src.orig/extensions/prj/build.lst 2006-08-10 17:45:19.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/extensions/prj/build.lst 2006-08-22 00:20:47.000000000 +0200 @@ -11,10 +11,11 @@ ex extensions\source\resource nmake - all ex_resrc NULL ex extensions\source\installation nmake - w ex_inst NULL ex extensions\source\installation\office\protchk nmake - all ex_pchk NULL +ex extensions\source\plugin\aqua nmake - u ex_plaqua ex_plbase NULL ex extensions\source\plugin\base nmake - all ex_plbase NULL ex extensions\source\plugin\win nmake - w ex_plwin ex_plbase NULL ex extensions\source\plugin\unx nmake - u ex_plunx NULL -ex extensions\source\plugin\util nmake - all ex_plutil ex_plbase ex_plunx.u ex_plwin.w NULL +ex extensions\source\plugin\util nmake - all ex_plutil ex_plbase ex_plunx.u ex_plwin.w ex_plaqua.u NULL ex extensions\source\scanner nmake - all ex_scan ex_resrc NULL ex extensions\source\svg nmake - all ex_svg ex_scan NULL ex extensions\source\packer nmake - all ex_pck NULL diff -x CVS -urN ooo_SRC680_m187_src.orig/extensions/source/plugin/aqua/macmgr.cxx ooo_SRC680_m187_src.aquavcl01/extensions/source/plugin/aqua/macmgr.cxx --- ooo_SRC680_m187_src.orig/extensions/source/plugin/aqua/macmgr.cxx 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/extensions/source/plugin/aqua/macmgr.cxx 2006-08-25 14:26:41.000000000 +0200 @@ -0,0 +1,273 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * 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 + * + ************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace rtl; +using namespace std; +using namespace com::sun::star::uno; +using namespace com::sun::star::plugin; + +// Unix specific implementation +static bool CheckPlugin( const ByteString& rPath, list< PluginDescription* >& rDescriptions ) +{ +#if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "Trying plugin %s ... ", rPath.GetBuffer() ); +#endif + + xub_StrLen nPos = rPath.SearchBackward( '/' ); + if( nPos == STRING_NOTFOUND ) + { +#if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "no absolute path to plugin\n" ); +#endif + return false; + } + + ByteString aBaseName = rPath.Copy( nPos+1 ); + if( aBaseName.Equals( "libnullplugin.so" ) ) + { +#if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "don't like %s\n", aBaseName.GetBuffer() ); +#endif + return false; + } + + struct stat aStat; + if( stat( rPath.GetBuffer(), &aStat ) || ! S_ISREG( aStat.st_mode ) ) + { +#if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "%s is not a regular file\n", rPath.GetBuffer() ); +#endif + return false; + } + + + rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); + + ByteString aCommand( "pluginapp.bin \"" ); + aCommand.Append( rPath ); + aCommand.Append( '"' ); + + FILE* pResult = popen( aCommand.GetBuffer(), "r" ); + int nDescriptions = 0; + if( pResult ) + { + OStringBuffer aMIME; + char buf[256]; + while( fgets( buf, sizeof( buf ), pResult ) ) + { + for( int i = 0; i < sizeof(buf) && buf[i]; ++i ) + { + if( buf[i] == '\n' ) + buf[i] = ';'; + } + aMIME.append( buf ); + } + pclose( pResult ); + + if( aMIME.getLength() > 0 ) + { + OString aLine = aMIME.makeStringAndClear(); + + sal_Int32 nIndex = 0; + while( nIndex != -1 ) + { + OString aType = aLine.getToken( 0, ';', nIndex ); + + sal_Int32 nTypeIndex = 0; + OString aMimetype = aType.getToken( 0, ':', nTypeIndex ); + OString aExtLine = aType.getToken( 0, ':', nTypeIndex ); + if( nTypeIndex < 0 ) // ensure at least three tokens + continue; + OString aDesc = aType.getToken( 0, ':', nTypeIndex ); + + // create extension list string + sal_Int32 nExtIndex = 0; + OStringBuffer aExtension; + while( nExtIndex != -1 ) + { + OString aExt = aExtLine.getToken( 0, ',', nExtIndex); + if( aExt.indexOf( "*." ) != 0 ) + aExtension.append( "*." ); + aExtension.append( aExt ); + if( nExtIndex != -1 ) + aExtension.append( ';' ); + } + + PluginDescription* pNew = new PluginDescription; + // set plugin name (path to library) + pNew->PluginName = OStringToOUString( rPath, aEncoding ); + // set mimetype + pNew->Mimetype = OStringToOUString( aMimetype, aEncoding ); + // set extension line + pNew->Extension = OStringToOUString( aExtension.makeStringAndClear(), aEncoding ); + // set description + pNew->Description= OStringToOUString( aDesc, aEncoding ); + rDescriptions.push_back( pNew ); +#if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "Mimetype: %s\nExtension: %s\n" + "Description: %s\n", + OUStringToOString( pNew->Mimetype, aEncoding ).getStr(), + OUStringToOString( pNew->Extension, aEncoding ).getStr(), + OUStringToOString( pNew->Description, aEncoding ).getStr() + ); +#endif + } + } +#if OSL_DEBUG_LEVEL > 1 + else + fprintf( stderr, "result of \"%s\" contains no mimtype\n", + aCommand.GetBuffer() ); +#endif + } +#if OSL_DEBUG_LEVEL > 1 + else + fprintf( stderr, "command \"%s\" failed\n", aCommand.GetBuffer() ); +#endif + return nDescriptions > 0; +} + +Sequence XPluginManager_Impl::getPluginDescriptions() throw() +{ + static Sequence aDescriptions; + static BOOL bHavePlugins = FALSE; + if( ! bHavePlugins ) + { + rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); + list aPlugins; + int i; + + // unix: search for plugins in /usr/lib/netscape/plugins, + // ~/.netscape/plugins und NPX_PLUGIN_PATH + // additionally: search in PluginsPath + static const char* pHome = getenv( "HOME" ); + static const char* pNPXPluginPath = getenv( "NPX_PLUGIN_PATH" ); + + ByteString aSearchPath( "/usr/lib/netscape/plugins" ); + if( pHome ) + { + aSearchPath.Append( ':' ); + aSearchPath.Append( pHome ); + aSearchPath += "/.netscape/plugins"; + } + if( pNPXPluginPath ) + { + aSearchPath.Append( ':' ); + aSearchPath += pNPXPluginPath; + } + + const Sequence< ::rtl::OUString >& rPaths( PluginManager::getAdditionalSearchPaths() ); + for( i = 0; i < rPaths.getLength(); i++ ) + { + aSearchPath += ":"; + aSearchPath += ByteString( String( rPaths.getConstArray()[i] ), aEncoding ); + } + + + long aBuffer[ sizeof( struct dirent ) + _PC_NAME_MAX +1 ]; + int nPaths = aSearchPath.GetTokenCount( ':' ); + for( i = 0; i < nPaths; i++ ) + { + ByteString aPath( aSearchPath.GetToken( i, ':' ) ); + if( aPath.Len() ) + { + DIR* pDIR = opendir( aPath.GetBuffer() ); + struct dirent* pDirEnt = NULL; + while( pDIR && ! readdir_r( pDIR, (struct dirent*)aBuffer, &pDirEnt ) && pDirEnt ) + { + char* pBaseName = ((struct dirent*)aBuffer)->d_name; + if( pBaseName[0] != '.' || + pBaseName[1] != '.' || + pBaseName[2] != 0 ) + { + ByteString aFileName( aPath ); + aFileName += "/"; + aFileName += pBaseName; + CheckPlugin( aFileName, aPlugins ); + } + } + if( pDIR ) + closedir( pDIR ); + } + } + + // try ~/.mozilla/pluginreg.dat + ByteString aMozPluginreg( pHome ); + aMozPluginreg.Append( "/.mozilla/pluginreg.dat" ); + FILE* fp = fopen( aMozPluginreg.GetBuffer(), "r" ); + if( fp ) + { +#if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "parsing %s\n", aMozPluginreg.GetBuffer() ); +#endif + char aLine[1024]; + while( fgets( aLine, sizeof( aLine ), fp ) ) + { + int nLineLen = strlen( aLine ); + int nDotPos; + for( nDotPos = nLineLen-1; nDotPos > 0 && aLine[nDotPos] != ':'; nDotPos-- ) + ; + if( aLine[0] == '/' && aLine[nDotPos] == ':' && aLine[nDotPos+1] == '$' ) + CheckPlugin( ByteString( aLine, nDotPos ), aPlugins ); + } + fclose( fp ); + } + + // create return value + aDescriptions = Sequence( aPlugins.size() ); +#if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "found %d plugins\n", aPlugins.size() ); +#endif + list::iterator iter; + for( iter = aPlugins.begin(), i=0; iter != aPlugins.end(); ++iter ,i++ ) + { + aDescriptions.getArray()[ i ] = **iter; + delete *iter; + } + aPlugins.clear(); + bHavePlugins = TRUE; + } + return aDescriptions; +} + diff -x CVS -urN ooo_SRC680_m187_src.orig/extensions/source/plugin/aqua/makefile.mk ooo_SRC680_m187_src.aquavcl01/extensions/source/plugin/aqua/makefile.mk --- ooo_SRC680_m187_src.orig/extensions/source/plugin/aqua/makefile.mk 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/extensions/source/plugin/aqua/makefile.mk 2006-09-22 10:14:12.000000000 +0200 @@ -0,0 +1,79 @@ +#************************************************************************* +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile$ +# +# $Revision$ +# +# last change: $Author$ $Date$ +# +# 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 +# +#************************************************************************* +PRJ=..$/..$/.. + +PRJNAME=extensions +TARGET=plaqua +#ENABLE_EXCEPTIONS=TRUE +#TARGETTYPE=CUI + +.INCLUDE : ..$/util$/makefile.pmk + +.IF "$(GUIBASE)"!="aqua" || "$(WITH_MOZILLA)"=="NO" + +dummy: + @echo "Nothing to build for GUIBASE $(GUIBASE)." + +.ELSE + +# --- Files -------------------------------------------------------- + +INCPRE+=-I$(SOLARINCDIR)$/mozilla$/plugin +.IF "$(SOLAR_JAVA)" != "" +INCPRE+=-I$(SOLARINCDIR)$/mozilla$/java +INCPRE+=-I$(SOLARINCDIR)$/mozilla$/nspr +INCPRE+=-I$(SOLARINCDIR)$/npsdk +CDEFS+=-DOJI +.ENDIF + +SLOFILES=\ + $(SLO)$/macmgr.obj \ + $(SLO)$/sysplug.obj + +#APP1TARGET=pluginapp.bin +#APP1OBJS=$(OBJFILES) +#APP1STDLIBS=\ +# $(TOOLSLIB) \ +# $(VOSLIB) \ +# $(SALLIB) + +#APP1DEF= $(MISC)$/$(TARGET).def + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + +.ENDIF # $(GUIBASE)==aqua diff -x CVS -urN ooo_SRC680_m187_src.orig/extensions/source/plugin/aqua/sysplug.cxx ooo_SRC680_m187_src.aquavcl01/extensions/source/plugin/aqua/sysplug.cxx --- ooo_SRC680_m187_src.orig/extensions/source/plugin/aqua/sysplug.cxx 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/extensions/source/plugin/aqua/sysplug.cxx 2006-08-25 14:26:41.000000000 +0200 @@ -0,0 +1,220 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * 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 + * + ************************************************************************/ +#include + +#include +#include +#include +#include + +#include + +int MacPluginComm::nConnCounter = 0; + +MacPluginComm::MacPluginComm( + const String& mimetype, + const String& library, + WindowRef aParent, + int nDescriptor1, + int nDescriptor2 + ) : +PluginComm( ::rtl::OUStringToOString( library, osl_getThreadTextEncoding() ) )/*, +PluginConnector( nDescriptor2 )*/ +{ + //char pDesc[32]; +// char pWindow[32]; +// sprintf( pWindow, "%d", aParent ); +// sprintf( pDesc, "%d", nDescriptor1 ); +// ByteString aLib( library, osl_getThreadTextEncoding() ); +// +// char* pArgs[5]; +// pArgs[0] = "pluginapp.bin"; +// pArgs[1] = pDesc; +// pArgs[2] = const_cast(aLib.GetBuffer()); +// pArgs[3] = pWindow; +// pArgs[4] = NULL; +// +//#if OSL_DEBUG_LEVEL > 1 +// m_nCommPID = 10; +// fprintf( stderr, "Try to launch: %s %s %s %s, descriptors are %d, %d\n", pArgs[0], pArgs[1], pArgs[2], pArgs[3], nDescriptor1, nDescriptor2 ); +//#endif +// +// if( ! ( m_nCommPID = fork() ) ) +// { +// execvp( pArgs[0], pArgs ); +// fprintf( stderr, "Error: could not exec %s\n", pArgs[0] ); +// _exit(255); +// } +// +// if( m_nCommPID != -1 ) +// { +// // wait for pluginapp.bin to start up +// if( ! WaitForMessage( 5000 ) ) +// { +// fprintf( stderr, "Timeout on command: %s %s %s %s\n", pArgs[0], pArgs[1], pArgs[2], pArgs[3] ); +// invalidate(); +// } +// else +// { +// MediatorMessage* pMessage = GetNextMessage( TRUE ); +// Respond( pMessage->m_nID, +// "init ack",8, +// NULL ); +// delete pMessage; +// NPP_Initialize(); +// } +// } +} + +MacPluginComm::~MacPluginComm() +{ + NPP_Shutdown(); + if( m_nCommPID != -1 && m_nCommPID != 0 ) + { + int status = 16777216; + pid_t nExit = waitpid( m_nCommPID, &status, WUNTRACED ); +#if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "child %d (plugin app child %d) exited with status %d\n", nExit, m_nCommPID, WEXITSTATUS(status) ); +#endif + } +} + +NPError MacPluginComm::NPP_Destroy( NPP instance, + NPSavedData** save ) +{ + return 0; +} + +NPError MacPluginComm::NPP_DestroyStream( NPP instance, + NPStream* stream, + NPError reason ) +{ + return 0; +} + +jref MacPluginComm::NPP_GetJavaClass() +{ + return 0; +} + +NPError MacPluginComm::NPP_Initialize() +{ + return 0; +} + +NPError MacPluginComm::NPP_New( NPMIMEType pluginType, + NPP instance, + uint16 mode, + int16 argc, + char* argn[], + char* argv[], + NPSavedData *saved ) +{ + return 0; +} + +NPError MacPluginComm::NPP_NewStream( NPP instance, + NPMIMEType type, + NPStream* stream, + NPBool seekable, + uint16* stype ) +{ + return 0; +} + +void MacPluginComm::NPP_Print( NPP instance, + NPPrint* platformPrint ) +{ + +} + +NPError MacPluginComm::NPP_SetWindow( NPP instance, + NPWindow* window ) +{ + return 0; +} + +void MacPluginComm::NPP_Shutdown() +{ + +} + +void MacPluginComm::NPP_StreamAsFile( NPP instance, + NPStream* stream, + const char* fname ) +{ + +} + +void MacPluginComm::NPP_URLNotify( NPP instance, + const char* url, + NPReason reason, + void* notifyData ) +{ + +} + +int32 MacPluginComm::NPP_Write( NPP instance, + NPStream* stream, + int32 offset, + int32 len, + void* buffer ) +{ + return 0; +} + +int32 MacPluginComm::NPP_WriteReady( NPP instance, + NPStream* stream ) +{ + return 0; +} + +char* MacPluginComm::NPP_GetMIMEDescription() +{ + return ""; +} + +NPError MacPluginComm::NPP_GetValue( NPP instance, NPPVariable variable, void* value ) +{ + return 0; +} + +NPError MacPluginComm::NPP_SetValue( NPP instance, + NPNVariable variable, + void *value) +{ + return 0; +} + diff -x CVS -urN ooo_SRC680_m187_src.orig/extensions/source/plugin/base/xplugin.cxx ooo_SRC680_m187_src.aquavcl01/extensions/source/plugin/base/xplugin.cxx --- ooo_SRC680_m187_src.orig/extensions/source/plugin/base/xplugin.cxx 2006-09-16 15:09:27.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/extensions/source/plugin/base/xplugin.cxx 2006-10-14 01:02:52.000000000 +0200 @@ -61,6 +61,11 @@ #ifdef UNX #include #include +#ifdef QUARTZ +#include +#include +#include +#endif //QUARTZ #endif #if OSL_DEBUG_LEVEL > 1 @@ -526,7 +531,7 @@ } } const SystemEnvData* pEnvData = getSysChildSysData(); -#ifdef UNX +#if defined( UNX ) && !(defined(QUARTZ)) XSync( (Display*)pEnvData->pDisplay, False ); #endif if( ! getPluginComm() ) @@ -538,12 +543,21 @@ PluginComm* pComm = NULL; int sv[2]; if( !socketpair( AF_UNIX, SOCK_STREAM, 0, sv ) ) +#ifdef QUARTZ + pComm = new MacPluginComm( m_aDescription.Mimetype, + m_aDescription.PluginName, + (WindowRef)pEnvData->aWindow, + sv[0], + sv[1] + ); +#else pComm = new UnxPluginComm( m_aDescription.Mimetype, m_aDescription.PluginName, (XLIB_Window)pEnvData->aWindow, sv[0], sv[1] ); +#endif //QUARTZ #elif (defined WNT || defined OS2) PluginComm* pComm = new PluginComm_Impl( m_aDescription.Mimetype, m_aDescription.PluginName, @@ -565,13 +579,17 @@ (char**)(m_nArgs ? m_pArgv : NULL), NULL ); -#ifdef UNX +#if defined( UNX ) && !defined(QUARTZ) XSync( (Display*)pEnvData->pDisplay, False ); #endif #ifdef UNX m_aNPWindow.window = (void*)pEnvData->aWindow; +#if !defined(QUARTZ) m_aNPWindow.ws_info = NULL; #else + m_aNPWindow.type = NPWindowTypeWindow; +#endif //QUARTZ +#else m_aNPWindow.window = (void*)pEnvData->hWnd; #endif com::sun::star::awt::Rectangle aPosSize = getPosSize(); diff -x CVS -urN ooo_SRC680_m187_src.orig/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx ooo_SRC680_m187_src.aquavcl01/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx --- ooo_SRC680_m187_src.orig/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx 2006-09-22 10:18:40.000000000 +0200 @@ -0,0 +1,104 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * 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 + * + ************************************************************************/ +#ifndef __PLUGIN_INC_MACPLUG_HXX +#define __PLUGIN_INC_MACPLUG_HXX + +#include + +#include +#include +#include + +#include +#include +#include + +#include +#define GENERATINGCFM 0 +#include + +#include +//#include +//#include +//#include +#include + +//================================================================================================== +class MacPluginComm : public PluginComm +{ +private: + static int nConnCounter; + + pid_t m_nCommPID; +public: + MacPluginComm( const String& mimetype, + const String& library, + WindowRef aParent, + int nDescriptor1, + int nDescriptor2 + ); + virtual ~MacPluginComm(); + + virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ); + virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, + NPError reason ); + virtual jref NPP_GetJavaClass(); + virtual NPError NPP_Initialize(); + virtual NPError NPP_New( NPMIMEType pluginType, NPP instance, + uint16 mode, int16 argc, + char* argn[], char* argv[], NPSavedData *saved ); + virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, + NPStream* stream, + NPBool seekable, uint16* stype ); + virtual void NPP_Print( NPP instance, NPPrint* platformPrint ); + virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ); + virtual void NPP_Shutdown(); + virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, + const char* fname ); + virtual void NPP_URLNotify( NPP instance, const char* url, NPReason reason, + void* notifyData ); + virtual int32 NPP_Write( NPP instance, NPStream* stream, int32 offset, + int32 len, void* buffer ); + virtual int32 NPP_WriteReady( NPP instance, NPStream* stream ); + virtual char* NPP_GetMIMEDescription(); + virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void* value ); + virtual NPError NPP_SetValue( NPP instance, NPNVariable variable, + void *value); +}; + + +#endif + + diff -x CVS -urN ooo_SRC680_m187_src.orig/extensions/source/plugin/inc/plugin/impl.hxx ooo_SRC680_m187_src.aquavcl01/extensions/source/plugin/inc/plugin/impl.hxx --- ooo_SRC680_m187_src.orig/extensions/source/plugin/inc/plugin/impl.hxx 2005-09-08 21:52:49.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/extensions/source/plugin/inc/plugin/impl.hxx 2006-01-31 01:36:16.000000000 +0100 @@ -140,9 +140,13 @@ #include #endif -#ifdef UNX +#if defined(UNX) +#if defined(QUARTZ) +#include +#else #include #endif +#endif #include #include diff -x CVS -urN ooo_SRC680_m187_src.orig/extensions/source/plugin/unx/makefile.mk ooo_SRC680_m187_src.aquavcl01/extensions/source/plugin/unx/makefile.mk --- ooo_SRC680_m187_src.orig/extensions/source/plugin/unx/makefile.mk 2006-06-19 12:45:51.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/extensions/source/plugin/unx/makefile.mk 2006-07-19 11:00:12.000000000 +0200 @@ -40,6 +40,12 @@ .INCLUDE : ..$/util$/makefile.pmk +.IF "$(GUIBASE)"=="aqua" +dummy: + @echo "Nothing to build for GUIBASE aqua." + +.ELSE + # --- Files -------------------------------------------------------- INCPRE+=-I$(SOLARINCDIR)$/mozilla$/plugin @@ -84,6 +90,8 @@ .ENDIF # $(WITH_MOZILLA) != "NO" +.ENDIF # $(GUIBASE)==aqua + # --- Targets ------------------------------------------------------ .INCLUDE : target.mk diff -x CVS -urN ooo_SRC680_m187_src.orig/extensions/source/plugin/util/makefile.mk ooo_SRC680_m187_src.aquavcl01/extensions/source/plugin/util/makefile.mk --- ooo_SRC680_m187_src.orig/extensions/source/plugin/util/makefile.mk 2006-03-08 15:16:55.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/extensions/source/plugin/util/makefile.mk 2006-09-22 10:14:13.000000000 +0200 @@ -52,7 +52,13 @@ $(SHL1LINKLIB) .IF "$(GUI)" == "UNX" +.IF "$(GUIBASE)"=="aqua" +.IF "$(WITH_MOZILLA)"=="YES" +SHL1LINKLIB = $(SLB)$/plaqua.lib +.ENDIF +.ELSE SHL1LINKLIB = $(SLB)$/plunx.lib +.ENDIF # $(GUIBASE)==aqua .IF "$(OS)" == "SOLARIS" SHL1OWNLIBS = -lsocket .ENDIF # SOLARIS @@ -94,7 +100,7 @@ $(CPPULIB) \ $(SALLIB) -.IF "$(OS)"=="MACOSX" +.IF "$(OS)"=="MACOSX" && "$(GUIBASE)"=="unx" SHL1STDLIBS+= -lX11 .ENDIF diff -x CVS -urN ooo_SRC680_m187_src.orig/padmin/source/makefile.mk ooo_SRC680_m187_src.aquavcl01/padmin/source/makefile.mk --- ooo_SRC680_m187_src.orig/padmin/source/makefile.mk 2005-09-08 18:25:28.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/padmin/source/makefile.mk 2006-01-31 01:48:58.000000000 +0100 @@ -33,6 +33,13 @@ # #************************************************************************* +.IF "$(GUIBASE)"=="aqua" + +dummy: + @echo "Nothing to build for GUIBASE aqua." + +.ELSE + PRJ=.. PRJNAME=padmin TARGET=padmin @@ -111,3 +118,5 @@ .INCLUDE : target.mk +.ENDIF #aqua + diff -x CVS -urN ooo_SRC680_m187_src.orig/psprint/source/fontmanager/makefile.mk ooo_SRC680_m187_src.aquavcl01/psprint/source/fontmanager/makefile.mk --- ooo_SRC680_m187_src.orig/psprint/source/fontmanager/makefile.mk 2005-09-08 18:37:39.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/psprint/source/fontmanager/makefile.mk 2006-08-16 22:09:09.000000000 +0200 @@ -51,6 +51,13 @@ # --- Files -------------------------------------------------------- +.IF "$(GUIBASE)"=="aqua" + +dummy: + @echo "Nothing to build for GUIBASE $(GUIBASE)" + +.ELSE # "$(GUIBASE)"=="aqua" + SLOFILES=\ $(SLO)$/fontmanager.obj \ $(SLO)$/fontcache.obj \ @@ -61,6 +68,8 @@ NOOPTFILES=$(SLO)$/fontmanager.obj .ENDIF +.ENDIF + # --- Targets ------------------------------------------------------ .INCLUDE : target.mk diff -x CVS -urN ooo_SRC680_m187_src.orig/scp2/source/ooo/file_library_ooo.scp ooo_SRC680_m187_src.aquavcl01/scp2/source/ooo/file_library_ooo.scp --- ooo_SRC680_m187_src.orig/scp2/source/ooo/file_library_ooo.scp 2006-10-06 12:40:39.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/scp2/source/ooo/file_library_ooo.scp 2006-10-14 02:19:11.000000000 +0200 @@ -1568,7 +1568,7 @@ #endif End -#ifdef UNX +#if defined(UNX) && !defined(QUARTZ) File gid_File_Lib_Psp Name = LIBNAME(psp); TXT_FILE_BODY; @@ -1900,7 +1900,7 @@ STD_LIB_FILE_PATCH( gid_File_Lib_So, so ) STD_UNO_LIB_FILE_PATCH( gid_File_Lib_Sot, sot ) -#ifdef UNX +#if defined(UNX) && !defined(QUARTZ) File gid_File_Lib_Spa Name = LIBNAME(spa); @@ -2032,7 +2032,11 @@ RegistryID = gid_Starregistry_Services_Rdb; Dir = gid_Dir_Program; #ifdef UNX - Name = STRING(CONCAT4(libdtransX11,SUPD,DLLPOSTFIX,UNXSUFFIX)); + #ifdef QUARTZ + Name = STRING(CONCAT4(libdtransaqua,SUPD,DLLPOSTFIX,UNXSUFFIX)); + #else + Name = STRING(CONCAT4(libdtransX11,SUPD,DLLPOSTFIX,UNXSUFFIX)); + #endif #else Name = "sysdtrans.dll"; #endif diff -x CVS -urN ooo_SRC680_m187_src.orig/scp2/source/ooo/file_ooo.scp ooo_SRC680_m187_src.aquavcl01/scp2/source/ooo/file_ooo.scp --- ooo_SRC680_m187_src.orig/scp2/source/ooo/file_ooo.scp 2006-10-06 12:40:54.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/scp2/source/ooo/file_ooo.scp 2006-10-14 02:19:18.000000000 +0200 @@ -286,7 +286,7 @@ #endif -#if !defined(WITHOUT_MOZILLA) && defined(UNX) +#if !defined(WITHOUT_MOZILLA) && defined(UNX) && !defined(QUARTZ) File gid_File_Bin_Pluginapp BIN_FILE_BODY; @@ -395,7 +395,7 @@ #endif End -#ifdef UNX +#if defined(UNX) && !defined(QUARTZ) File gid_File_Bin_Spadmin_Bin BIN_FILE_BODY; diff -x CVS -urN ooo_SRC680_m187_src.orig/scp2/source/ooo/file_resource_ooo.scp ooo_SRC680_m187_src.aquavcl01/scp2/source/ooo/file_resource_ooo.scp --- ooo_SRC680_m187_src.orig/scp2/source/ooo/file_resource_ooo.scp 2006-08-04 12:09:57.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/scp2/source/ooo/file_resource_ooo.scp 2006-08-16 14:40:31.000000000 +0200 @@ -122,7 +122,7 @@ STD_RES_FILE_PATCH( gid_File_Res_Sfx, sfx ) -#ifdef UNX +#if defined(UNX) && !defined(QUARTZ) STD_RES_FILE_PATCH( gid_File_Res_Spa, spa ) diff -x CVS -urN ooo_SRC680_m187_src.orig/scp2/source/ooo/shortcut_ooo.scp ooo_SRC680_m187_src.aquavcl01/scp2/source/ooo/shortcut_ooo.scp --- ooo_SRC680_m187_src.orig/scp2/source/ooo/shortcut_ooo.scp 2005-09-09 03:42:03.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/scp2/source/ooo/shortcut_ooo.scp 2006-01-31 01:57:23.000000000 +0100 @@ -397,7 +397,7 @@ #endif -#ifdef UNX +#if defined(UNX) && !defined(QUARTZ) Shortcut gid_Shortcut_Spadmin_Program FileID = gid_File_Bin_Soffice; diff -x CVS -urN ooo_SRC680_m187_src.orig/sj2/source/jscpp/sjapplet_impl.cxx ooo_SRC680_m187_src.aquavcl01/sj2/source/jscpp/sjapplet_impl.cxx --- ooo_SRC680_m187_src.orig/sj2/source/jscpp/sjapplet_impl.cxx 2006-06-19 12:38:55.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/sj2/source/jscpp/sjapplet_impl.cxx 2006-07-19 10:12:23.000000000 +0200 @@ -55,7 +55,7 @@ #include #include -#ifdef UNX +#if defined(UNX) && !defined(QUARTZ) #define Time xlib_time #define Window xlib_window #define Font xlib_font @@ -128,7 +128,9 @@ // ensure that all operations for the window contained in pEnvData // have been processed by the Xserver since java will access that // window by a separate connection to the Xserver +#if !defined(QUARTZ) XSync( (Display*)pEnvData->pDisplay, False); +#endif try { //java < 1.5 jclass jcToolkit = pEnv->FindClass("java/awt/Toolkit"); testJavaException(pEnv); diff -x CVS -urN ooo_SRC680_m187_src.orig/solenv/inc/postmac.h ooo_SRC680_m187_src.aquavcl01/solenv/inc/postmac.h --- ooo_SRC680_m187_src.orig/solenv/inc/postmac.h 2005-09-08 11:36:31.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/solenv/inc/postmac.h 2006-02-21 19:15:36.000000000 +0100 @@ -50,7 +50,7 @@ #undef LSize #undef ModalDialog #undef SetCursor -#undef ShowWindow +//#undef ShowWindow #undef StringPtr #undef DirInfo #undef BOOL diff -x CVS -urN ooo_SRC680_m187_src.orig/solenv/inc/premac.h ooo_SRC680_m187_src.aquavcl01/solenv/inc/premac.h --- ooo_SRC680_m187_src.orig/solenv/inc/premac.h 2005-09-08 11:37:32.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/solenv/inc/premac.h 2006-02-21 19:15:36.000000000 +0100 @@ -50,7 +50,7 @@ #define LSize MacOSLSize #define ModalDialog MacOSModalDialog #define SetCursor MacOSSetCursor -#define ShowWindow MacOSShowWindow +//#define ShowWindow MacOSShowWindow #define StringPtr MacOSStringPtr #define DirInfo MacOSDirInfo #define BOOL MacOSBOOL diff -x CVS -urN ooo_SRC680_m187_src.orig/solenv/inc/rules.mk ooo_SRC680_m187_src.aquavcl01/solenv/inc/rules.mk --- ooo_SRC680_m187_src.orig/solenv/inc/rules.mk 2006-10-05 18:20:20.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/solenv/inc/rules.mk 2006-10-14 01:29:43.000000000 +0200 @@ -298,6 +298,63 @@ # dependencies c / c++ +# Objective-C++ files +$(OBJ)$/%.obj : %.mm + @echo ------------------------------ + @echo Making: $@ +.IF "$(OS)"=="MACOSX" +.IF "$(TEST)"!="" + $(objc) $(CFLAGS) $(CFLAGSCC) $(OBJCXXFLAGS) $(CFLAGSOBJ) $(CDEFS) $(CDEFSOBJ) -E $(CFLAGSAPPEND) $(CFLAGSOUTOBJ) $(OBJ)$/$*.o $*.mm +.ELSE + @$(RM) $@ $(@:s/.obj/.o/) + $(objc) $(CFLAGS) $(CFLAGSCC) $(OBJCXXFLAGS) $(CFLAGSOBJ) $(CDEFS) $(CDEFSOBJ) $(CFLAGSAPPEND) $(CFLAGSOUTOBJ) $(OBJ)$/$*.o $*.mm + +if ( -e $(@:s/.obj/.o/)) $(TOUCH) $@ +.ENDIF +.ELSE "$(OS)"=="MACOSX" + @echo "No recipe for compiling Objective-C++ files is available for this platform" +.ENDIF "$(OS)"=="MACOSX" + +# Objective-C++ files +$(OBJ)$/%.obj : $(MISC)$/%.mm + @echo ------------------------------ + @echo Making: $@ +.IF "$(OS)"=="MACOSX" + @$(RM) $@ $(@:s/.obj/.o/) + $(objc) $(CFLAGS) $(CFLAGSCC) $(OBJCXXFLAGS) $(CFLAGSOBJ) $(CDEFS) $(CDEFSOBJ) $(CFLAGSAPPEND) $(CFLAGSOUTOBJ) $(OBJ)$/$*.o $(MISC)$/$*.mm + +if ( -e $(@:s/.obj/.o/)) $(TOUCH) $@ +.ELSE "$(OS)"=="MACOSX" + @echo "No recipe for compiling Objective-C++ files is available for this platform" +.ENDIF "$(OS)"=="MACOSX" + +# Objective-C++ files +$(SLO)$/%.obj : $(MISC)$/%.mm + @echo ------------------------------ + @echo Making: $@ +.IF "$(OS)"=="MACOSX" + @$(RM) $@ $(@:s/.obj/.o/) + $(objc) $(CFLAGS) $(CFLAGSCC) $(OBJCXXFLAGS) $(CFLAGSSLO) $(CDEFS) $(CDEFSSLO) $(CFLAGSAPPEND) $(CFLAGSOUTOBJ) $(SLO)$/$*.o $(MISC)$/$*.mm + +if ( -e $(@:s/.obj/.o/)) $(TOUCH) $@ +.ELSE "$(OS)"=="MACOSX" + @echo "No recipe for compiling Objective-C++ files is available for this platform" +.ENDIF "$(OS)"=="MACOSX" + +# Objective-C++ files +$(SLO)$/%.obj : %.mm + @echo ------------------------------ + @echo Making: $@ +.IF "$(OS)"=="MACOSX" + @$(RM) $@ $(@:s/.obj/.o/) + $(objc) $(CFLAGS) $(CFLAGSCC) $(OBJCXXFLAGS) $(CFLAGSSLO) $(CDEFS) $(CDEFSSLO) $(CDEFSMT) $(CFLAGSAPPEND) $(CFLAGSOUTOBJ) $(SLO)$/$*.o $*.mm + +if ( -e $(@:s/.obj/.o/)) $(TOUCH) $@ +.ELSE "$(OS)"=="MACOSX" + @echo "No recipe for compiling Objective-C++ files is available for this platform" +.ENDIF "$(OS)"=="MACOSX" + +# dependencies c / c++ +.IF "$(verbose)"=="" +noout=>& $(NULLDEV) +.ENDIF + $(MISC)$/s_%.dpcc : %.c @+-$(RM) $@ >& $(NULLDEV) @$(MAKEDEPEND) -f - -p$(SLO) $(MKDEPFLAGS) $(CDEFS) $(CDEFSSLO) $(CDEFSMT) $< > $@ @@ -450,6 +507,60 @@ @echo LAZY_DEPS=were_used_to_generate >> $@ .ENDIF # "$(LAZY_DEPS)"=="" +# dependencies objective-c++ + +$(MISC)$/s_%.dpcc : %.mm + @echo ------------------------------ $(noout) + @echo Making: $@ $(noout) + @+-$(RM) $@ >& $(NULLDEV) + @$(MAKEDEPEND) -f - -p$(SLO)$/ $(MKDEPFLAGS) $(CDEFS) $(CDEFSSLO) $(CDEFSMT) $< > $@ +.IF "$(LAZY_DEPS)"=="" + @+echo $@ : $(SLO)$/$(<:b).obj >> $@ +.ELSE # "$(LAZY_DEPS)"=="" + @+echo LAZY_DEPS=were_used_to_generate >> $@ +.ENDIF # "$(LAZY_DEPS)"=="" + +$(MISC)$/o_%.dpcc : %.mm + @echo ------------------------------ $(noout) + @echo Making: $@ $(noout) + @+-$(RM) $@ >& $(NULLDEV) + @$(MAKEDEPEND) -f - -p$(OBJ)$/ $(MKDEPFLAGS) $(CDEFS) $(CDEFSOBJ) $(CDEFSMT) $< > $@ +.IF "$(LAZY_DEPS)"=="" + @+echo $@ : $(OBJ)$/$(<:b).obj >> $@ +.ELSE # "$(LAZY_DEPS)"=="" + @+echo LAZY_DEPS=were_used_to_generate >> $@ +.ENDIF # "$(LAZY_DEPS)"=="" + +$(MISC)$/s_%.dpcc : $(MISC)$/%.mm + @echo ------------------------------ $(noout) + @echo Making: $@ $(noout) + @+-$(RM) $@ >& $(NULLDEV) +.IF "$(GUI)"=="UNX" + @$(MAKEDEPEND) -f - -p$(SLO)$/ $(MKDEPFLAGS) $(CDEFS) $(CDEFSSLO) $(CDEFSMT) $< | sed s\#$(MISC)$/\#\# > $@ +.ELSE # "$(GUI)"=="UNX" + @$(MAKEDEPEND) -f - -p$(SLO)$/ $(MKDEPFLAGS) $(CDEFS) $(CDEFSSLO) $(CDEFSMT) $< | $(SED) s/$(MISC:s/\/\\/)\\// > $@ +.ENDIF # "$(GUI)"=="UNX" +.IF "$(LAZY_DEPS)"=="" + @+echo $@ : $(SLO)$/$(<:b).obj >> $@ +.ELSE # "$(LAZY_DEPS)"=="" + @+echo LAZY_DEPS=were_used_to_generate >> $@ +.ENDIF # "$(LAZY_DEPS)"=="" + +$(MISC)$/o_%.dpcc : $(MISC)$/%.mm + @echo ------------------------------ $(noout) + @echo Making: $@ $(noout) + @+-$(RM) $@ >& $(NULLDEV) +.IF "$(GUI)"=="UNX" + @$(MAKEDEPEND) -f - -p$(OBJ)$/ $(MKDEPFLAGS) $(CDEFS) $(CDEFSOBJ) $(CDEFSMT) $< | sed s\#$(MISC)$/\#\# > $@ +.ELSE # "$(GUI)"=="UNX" + @$(MAKEDEPEND) -f - -p$(OBJ)$/ $(MKDEPFLAGS) $(CDEFS) $(CDEFSOBJ) $(CDEFSMT) $< | $(SED) s/$(MISC:s/\/\\/)\\// > $@ +.ENDIF # "$(GUI)"=="UNX" +.IF "$(LAZY_DEPS)"=="" + @echo $@ : $(OBJ)$/$(<:b).obj >> $@ +.ELSE # "$(LAZY_DEPS)"=="" + @echo LAZY_DEPS=were_used_to_generate >> $@ +.ENDIF # "$(LAZY_DEPS)"=="" + # dependency dummy for *.s files $(MISC)$/s_%.dpcc : %.s diff -x CVS -urN ooo_SRC680_m187_src.orig/solenv/inc/unxmacx.mk ooo_SRC680_m187_src.aquavcl01/solenv/inc/unxmacx.mk --- ooo_SRC680_m187_src.orig/solenv/inc/unxmacx.mk 2006-07-06 00:04:13.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/solenv/inc/unxmacx.mk 2006-07-19 10:10:41.000000000 +0200 @@ -97,7 +97,9 @@ CFLAGSCC=-pipe -fsigned-char -malign-natural $(ARCH_FLAGS) # Normal Objective C compilation flags -OBJCFLAGS=-no-precomp +#OBJCFLAGS=-no-precomp +OBJCFLAGS=-fobjc-exceptions +OBJCXXFLAGS=-x objective-c++ -fobjc-exceptions # Comp Flags for files that need exceptions enabled (C and C++) CFLAGSEXCEPTIONS=-fexceptions -fno-enforce-eh-specs @@ -200,10 +202,16 @@ STDSLOCUI= STDLIBGUIST=-lm -STDLIBCUIST=-lX11 -lpthread CPPRUNTIME -lm +.IF "$(GUIBASE)" == "aqua" + STDLIBCUIST=-lpthread CPPRUNTIME -lm + STDLIBCUIMT=CPPRUNTIME -lm + STDSHLGUIMT=-lpthread CPPRUNTIME -lm +.ELSE + STDLIBCUIST=-lX11 -lpthread CPPRUNTIME -lm + STDLIBCUIMT=-lX11 CPPRUNTIME -lm + STDSHLGUIMT=-lX11 -lXext -lpthread CPPRUNTIME -lm +.ENDIF STDLIBGUIMT=-lpthread CPPRUNTIME -lm -STDLIBCUIMT=-lX11 CPPRUNTIME -lm -STDSHLGUIMT=-lX11 -lXext -lpthread CPPRUNTIME -lm STDSHLCUIMT=-lpthread CPPRUNTIME -lm LIBMGR=ar diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/inc/aquavclevents.hxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/aquavclevents.hxx --- ooo_SRC680_m187_src.orig/vcl/aqua/inc/aquavclevents.hxx 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/aquavclevents.hxx 2006-09-04 10:31:58.000000000 +0200 @@ -0,0 +1,51 @@ +#ifndef INCLUDED_AQUAVCLEVENTS_HXX +#define INCLUDED_AQUAVCLEVENTS_HXX + +#include +#include +#include + +/* Definition of custom OpenOffice.org events. + + Avoid conflict with Apple defined event class and type + definitions by using uppercase letters. Lowercase + letter definitions are reserved for Apple! + */ +enum { + cOOoSalUserEventClass = 'OOUE' +}; + +enum { + cOOoSalEventUser = 'UEVT', + cOOoSalEventTimer = 'EVTT', + cOOoSalEventData = 'EVTD', + cOOoSalEventParamTypePtr = 'EPPT' +}; + +/* Definition of all necessary EventTypeSpec's */ + +const EventTypeSpec cWindowBoundsChangedEvent = { kEventClassWindow, kEventWindowBoundsChanged }; +const EventTypeSpec cWindowCloseEvent = { kEventClassWindow, kEventWindowClose }; +const EventTypeSpec cOOoSalUserEvent = { cOOoSalUserEventClass, cOOoSalEventUser }; +const EventTypeSpec cOOoSalTimerEvent = { cOOoSalUserEventClass, cOOoSalEventTimer }; +const EventTypeSpec cWindowActivatedEvent = { kEventClassWindow, kEventWindowActivated }; +const EventTypeSpec cWindowPaintEvent = { kEventClassWindow, kEventWindowPaint }; +const EventTypeSpec cWindowDrawContentEvent = { kEventClassWindow, kEventWindowDrawContent }; +const EventTypeSpec cMouseUpDownEvent[] = { { kEventClassMouse, kEventMouseDown }, { kEventClassMouse, kEventMouseUp } }; +const EventTypeSpec cMouseWheelMovedEvent = { kEventClassMouse, kEventMouseWheelMoved }; +const EventTypeSpec cWindowResizeStarted = { kEventClassWindow, kEventWindowResizeStarted }; +const EventTypeSpec cWindowResizeCompleted = { kEventClassWindow, kEventWindowResizeCompleted }; + +/* Events for native menus */ +const EventTypeSpec cCommandProcessEvent = { kEventClassCommand, kEventCommandProcess }; +const EventTypeSpec cMenuPopulateEvent = { kEventClassMenu, kEventMenuPopulate }; +const EventTypeSpec cMenuClosedEvent = { kEventClassMenu, kEventMenuClosed }; +const EventTypeSpec cMenuTargetItemEvent = { kEventClassMenu, kEventMenuTargetItem }; + +/* Events for keyboard */ +const EventTypeSpec cKeyboardRawKeyEvents[] = { { kEventClassKeyboard, kEventRawKeyDown}, + { kEventClassKeyboard, kEventRawKeyUp}, + { kEventClassKeyboard, kEventRawKeyRepeat}, + { kEventClassKeyboard, kEventRawKeyModifiersChanged} }; + +#endif // INCLUDED_AQUAVCLEVENTS_HXX diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/inc/aquavcltypes.h ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/aquavcltypes.h --- ooo_SRC680_m187_src.orig/vcl/aqua/inc/aquavcltypes.h 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/aquavcltypes.h 2006-08-23 07:15:19.000000000 +0200 @@ -0,0 +1,16 @@ +#ifndef _AQUAVCLTYPES_H +#define _AQUAVCLTYPES_H + +#include +#include +#include + +typedef WindowRef CarbonWindowRef; +typedef ControlRef CarbonViewRef; + +// Constants for menu property back pointers passing +#define APP_PROPERTY_CREATOR 'OOo2' +#define APP_PROPERTY_TAG_MENU_POINTER 'mptr' +#define APP_PROPERTY_TAG_MENU_ITEM_POINTER 'iptr' + +#endif _AQUAVCLTYPES_H diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/inc/salbmp.h ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salbmp.h --- ooo_SRC680_m187_src.orig/vcl/aqua/inc/salbmp.h 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salbmp.h 2006-08-25 19:28:29.000000000 +0200 @@ -0,0 +1,155 @@ +/************************************************************************* +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile$ +* +* $Revision$ +* +* last change: $Author$ $Date$ +* +* 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 +* +************************************************************************/ + +#ifndef _SV_SALBMP_H +#define _SV_SALBMP_H + +#ifndef _GEN_HXX +#include +#endif + +#ifndef _SV_SV_H +#include +#endif + +#ifndef _SV_SALBTYPE_HXX +#include +#endif + +#ifndef _SV_SALDATA_HXX +#include +#endif + +#ifndef _SV_SALINST_HXX +#include +#endif + +#ifndef _SV_SALCONST_H +#include +#endif + +#ifndef _SV_SALVD_HXX +#include +#endif + +#ifndef _SV_SALCOLORUTILS_HXX +#include +#endif + +#ifndef _SV_SALPIXMAPUTILS_HXX +#include +#endif + +#ifndef _SV_SALRECTANGLEUTILS_HXX +#include +#endif + +#ifndef _SV_SALBMP_HXX +#include +#endif + +#ifndef _SV_SALGDI_H +#include +#endif + +#ifndef INCLUDED_BASEBMP_BITMAPDEVICE_HXX +#include +#endif + +// -------------- +// - SalBitmap - +// -------------- + +struct BitmapBuffer; +class BitmapColor; +class BitmapPalette; +class AquaSalVirtualDevice; +class AquaSalGraphics; + +class AquaSalBitmap : public SalBitmap +{ +public: + CGContextRef mxGraphicContext; + BitmapPalette maPalette; + basebmp::RawMemorySharedArray maUserBuffer; + basebmp::RawMemorySharedArray maContextBuffer; + sal_uInt16 mnBits; + sal_uInt32 mnWidth; + sal_uInt32 mnHeight; + sal_uInt32 mnBytesPerRow; + +public: + AquaSalBitmap(); + ~AquaSalBitmap(); + +public: + + // SalBitmap methods + bool Create( const Size& rSize, USHORT nBitCount, const BitmapPalette& rPal ); + bool Create( const SalBitmap& rSalBmp ); + bool Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics ); + bool Create( const SalBitmap& rSalBmp, USHORT nNewBitCount ); + + void Destroy(); + + Size GetSize() const; + USHORT GetBitCount() const; + + BitmapBuffer *AcquireBuffer( bool bReadOnly ); + void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ); + + bool GetSystemData( BitmapSystemData& rData ); + + // quartz helper + bool CreateContext(); + void DestroyContext(); + bool AllocateUserData(); + + void ConvertBitmapData( sal_uInt32 nWidth, sal_uInt32 nHeight, + sal_uInt16 nDestBits, sal_uInt32 nDestBytesPerRow, const BitmapPalette& rDestPalette, sal_uInt8* pDestData, + sal_uInt16 nSrcBits, sal_uInt32 nSrcBytesPerRow, const BitmapPalette& rSrcPalette, sal_uInt8* pSrcData ); + + bool Create( CGContextRef xContext, int nX, int nY, int nWidth, int nHeight ); + bool Create( sal_uInt32 nWidth, sal_uInt32 nHeight, sal_uInt16 nBits, sal_uInt32 nBytesPerRow, sal_uInt8* pBuffer, sal_uInt32 nX, sal_uInt32 nY, sal_uInt32 nDX, sal_uInt32 nDY ); + bool Create( CGImageRef& xImage ); + + CGImageRef CreateWithMask( const AquaSalBitmap& rMask, sal_uInt32 nX, sal_uInt32 nY, sal_uInt32 nDX, sal_uInt32 nDY ); + CGImageRef CreateColorMask( int nX, int nY, int nWidth, int nHeight, SalColor nMaskColor ) const; + CGImageRef CreateMask( int nX, int nY, int nWidth, int nHeight ) const; + CGImageRef CreateCroppedImage( int nX, int nY, int nWidth, int nHeight ); + static CGImageRef CreateCroppedImage( CGContextRef xContext, int nX, int nY, int nWidth, int nHeight ); +}; + +#endif // _SV_SALBMP_HXX diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/inc/saldata.hxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/saldata.hxx --- ooo_SRC680_m187_src.orig/vcl/aqua/inc/saldata.hxx 2005-09-09 12:33:28.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/saldata.hxx 2006-03-19 22:37:06.000000000 +0100 @@ -37,43 +37,30 @@ #define _SV_SALDATA_HXX #ifndef _SV_SV_H - #include +#include #endif -#ifdef __cplusplus - - #ifndef _SV_SVDATA_HXX - #include - #endif - -#endif // __cplusplus - -#ifndef _SV_SALWTYPE_HXX - #include +#ifndef _SV_SVDATA_HXX +#include #endif -#ifndef _SV_VCLWINDOW_H - #include +#ifndef _SV_SALWTYPE_HXX +#include #endif -#ifdef __cplusplus - - class SalInstance; - class SalObject; - class SalFrame; - class SalVirtualDevice; - class SalPrinter; - - class FontList; - -#else // __cplusplus - - #define SalInstance void - #define SalVirtualDevice void - #define SalPrinter void - #define FontList void +class SalInstance; +class SalObject; +class SalFrame; +class SalVirtualDevice; +class SalPrinter; + +class FontList; + +// ------------------ +// - Some constants - +// ------------------ -#endif // __cplusplus +#define SAL_CLIPRECT_COUNT 16 // ----------- // - SalData - @@ -90,24 +77,14 @@ FontList *mpFontList; // Mac OS font list }; -#ifdef __cplusplus - - inline void SetSalData( SalData* pData ) { ImplGetSVData()->mpSalData = (void*)pData; } - - inline SalData *GetSalData() { return (SalData*)ImplGetSVData()->mpSalData; } - inline SalData *GetAppSalData() { return (SalData*)ImplGetAppSVData()->mpSalData; } - -#else // __cplusplus - - // C wrapper functions around SetSalData, GetSalData, and GetAppSalData - - void SalSetSalData( struct SalData* pData ); - - struct SalData *SalGetSalData(); - struct SalData *SalGetAppSalData(); - - BOOL SalGetAppQuit(); - -#endif // __cplusplus +inline void SetSalData( SalData* pData ) { ImplGetSVData()->mpSalData = (void*)pData; } +inline SalData *GetSalData() { return (SalData*)ImplGetSVData()->mpSalData; } +inline SalData *GetAppSalData() { return (SalData*)ImplGetAppSVData()->mpSalData; } + +// --- Prototypes --- + +BOOL ImplSalYieldMutexTryToAcquire(); +void ImplSalYieldMutexAcquire(); +void ImplSalYieldMutexRelease(); #endif // _SV_SALDATA_HXX diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/inc/salframe.h ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salframe.h --- ooo_SRC680_m187_src.orig/vcl/aqua/inc/salframe.h 2005-09-09 12:33:56.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salframe.h 2006-10-14 15:27:19.000000000 +0200 @@ -36,32 +36,162 @@ #ifndef _SV_SALFRAME_H #define _SV_SALFRAME_H +#include + +#include + #ifndef _SV_SV_H #include #endif -#ifndef _SV_VCLWINDOW_H -#include -#endif #ifndef _SV_SYSDATA_HXX #include #endif +#include +#include +#include +#include + +class AquaSalGraphics; +class AquaSalFrame; +class AquaSalTimer; +class AquaSalInstance; + +typedef struct SalFrame::SalPointerState SalPointerState; + // ---------------- -// - SalFrameData - +// - AquaSalFrame - // ---------------- -struct SalFrameData +class AquaSalFrame : public SalFrame { - VCLWINDOW mhWnd; // Window handle - SalGraphics* mpGraphics; // current frame graphics - SalFrame* mpNextFrame; // pointer to next frame - SalFrame* mpParent; // pointer to parent frame +public: + CarbonWindowRef mrWindow; // Window handle + AquaSalGraphics* mpGraphics; // current frame graphics + AquaSalFrame* mpNextFrame; // pointer to next frame + AquaSalFrame* mpParent; // pointer to parent frame void* mpInst; // instance handle for callback SALFRAMEPROC mpProc; // callback proc long mnWidth; // client width in pixels long mnHeight; // client height in pixels - BOOL mbGraphics; // is Graphics used? -}; + int mnMinWidth; // min. client width in pixeln + int mnMinHeight; // min. client height in pixeln + int mnMaxWidth; // max. client width in pixeln + int mnMaxHeight; // max. client height in pixeln + Rect maFullScreenRect; // old window size when in FullScreen + WindowAttributes maFullScreenAttr; // old window attributes when in FullScreen + BOOL mbGraphics; // is Graphics used? + BOOL mbFullScreen; // is Window in FullScreen? + AquaSalInstance* mpSalInstance; + +public: + AquaSalFrame(); + + /** Constructor + + Creates a system window and connects this frame with it. + + @throws std::runtime_error in case window creation fails + */ + AquaSalFrame(SalFrame* pParent, ULONG salFrameStyle, AquaSalInstance* pSalInstance); + + virtual ~AquaSalFrame(); + + virtual SalGraphics* GetGraphics(); + virtual void ReleaseGraphics( SalGraphics* pGraphics ); + virtual BOOL PostEvent( void* pData ); + BOOL PostTimerEvent( AquaSalTimer *pTimer ); + virtual void SetTitle( const XubString& rTitle ); + virtual void SetIcon( USHORT nIcon ); + virtual void SetMenu( SalMenu* pSalMenu ); + virtual void DrawMenuBar(); + virtual void Show( BOOL bVisible, BOOL bNoActivate = FALSE ); + virtual void Enable( BOOL bEnable ); + virtual void SetMinClientSize( long nWidth, long nHeight ); + virtual void SetMaxClientSize( long nWidth, long nHeight ); + virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight, USHORT nFlags ); + virtual void GetClientSize( long& rWidth, long& rHeight ); + virtual void GetWorkArea( Rectangle& rRect ); + virtual SalFrame* GetParent() const; + virtual void SetWindowState( const SalFrameState* pState ); + virtual BOOL GetWindowState( SalFrameState* pState ); + virtual void ShowFullScreen( BOOL bFullScreen, sal_Int32 nDisplay ); + virtual void StartPresentation( BOOL bStart ); + virtual void SetAlwaysOnTop( BOOL bOnTop ); + virtual void ToTop( USHORT nFlags ); + virtual void SetPointer( PointerStyle ePointerStyle ); + virtual void CaptureMouse( BOOL bMouse ); + virtual void SetPointerPos( long nX, long nY ); + virtual void Flush(); + virtual void Sync(); + virtual void SetInputContext( SalInputContext* pContext ); + virtual void EndExtTextInput( USHORT nFlags ); + virtual String GetKeyName( USHORT nKeyCode ); + virtual String GetSymbolKeyName( const XubString& rFontName, USHORT nKeyCode ); + virtual BOOL MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, KeyCode& rKeyCode ); + virtual LanguageType GetInputLanguage(); + virtual SalBitmap* SnapShot(); + virtual void UpdateSettings( AllSettings& rSettings ); + virtual void Beep( SoundType eSoundType ); + virtual const SystemEnvData* GetSystemData() const; + virtual SalPointerState GetPointerState(); + virtual void SetParent( SalFrame* pNewParent ); + virtual bool SetPluginParent( SystemParentData* pNewParent ); + virtual void SetExtendedFrameStyle( SalExtStyle ); + virtual void SetBackgroundBitmap( SalBitmap* ); + + virtual void SetClientSize( long nWidth, long nHeight ); + void UpdateFrameGeometry(); + + private: // methods + + /** Create a new system window. + The newly create window will be associated whith this frame. + + @param pParent + the parent of the window may be NULL + + @param nSalFrameStyle + the style of the new window + + @throws std::runtime_error in case window creation fails + */ + void CreateNewSystemWindow(CarbonWindowRef pParent, ULONG nSalFrameStyle); + + void InsertThisIntoFrameList(); + void RemoveThisFromFrameList(); + BOOL ImplPostUserEvent( UInt32 eventKind, void *pData ); + + /** Install a window event handler + + The window event handler and the corresponding Universal Procedure Pointer (UPP) pointer + need to be save during destruction of the frame instance we have to unregister all installed + event handlers and dispose the UPP. + + @param upp + a universal procedure pointer + + @param nEvents + number of events to register + + @param eventSpec + the event specification + + @return the status of the registration see Carbon Event Manager reference for details + */ + OSStatus InstallAndRegisterEventHandler(EventHandlerUPP upp, size_t nEvents, const EventTypeSpec* eventSpec); + void DeinstallAndUnregisterAllEventHandler(); + + private: // data + + typedef std::pair SysWindowEventHandlerData_t; + typedef std::vector SysWindowEventHandlerDataContainer_t; + SysWindowEventHandlerDataContainer_t mSysWindowEventHandlerDataContainer; + + // Menu associated with this SalFrame + SalMenu *mpMenu; +}; + #endif // _SV_SALFRAME_H diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/inc/salgdi.h ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salgdi.h --- ooo_SRC680_m187_src.orig/vcl/aqua/inc/salgdi.h 2005-09-09 12:34:10.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salgdi.h 2006-08-19 22:50:34.000000000 +0200 @@ -41,78 +41,327 @@ #include #ifndef _SV_SV_H - #include +#include #endif -#ifndef _SV_VCLWINDOW_H - #include +#ifndef _SV_OUTFONT_HXX +#include #endif -// ------------------- -// - Structures - -// ------------------- - -struct SalGraphicsData -{ - // NSView and NSWindow - - VCLVIEW mhDC; // VCLVIEW - - // QuickDraw graph port, offscreen graphic world, and graphic device handle - - CGrafPtr mpCGrafPort; // QD color graphics port - GWorldPtr mpGWorld; // QD offscreen GWorld - GDHandle mhGDevice; // QD GDevice - - // Graph port pixels, state and flags - - BOOL mbGWorldPixelsLocked; // GWorld pixels locked? - BOOL mbGWorldPixelsCopy; // GWorld pixels was a copy of the original? - BOOL mbGWorldPixelsNew; // GWorld pixels is brand new? - GWorldFlags mnGWorldFlags; // GWorld pixels status flags - PixMapHandle mhGWorldPixMap; // GWorld pixels - - // Clip region - - BOOL mbClipRgnChanged; // Did the clip region change? - RgnHandle mhClipRgn; // Clip Region Handle - - // Font attributes +#ifndef _SV_SALGDI_HXX +#include +#endif - short mnFontID; // Mac FontFamilyId - short mnFontSize; // Mac Font Size - RGBColor maFontColor; // Text Color - Style mnFontStyle; // Mac Font Style +#ifndef _AQUAVCLTYPES_H +#include +#endif - // Pen attributes and status +#include +//#include +class AquaSalBitmap; - BOOL mbPenTransparent; // Is pen transparent? - SInt32 mnPenMode; // Pen Mode - RGBColor maPenColor; // Pen Color +// mac specific physically available font face +class ImplMacFontData : public ImplFontData +{ +public: + rtl_TextEncoding meScript; + FontFamily meFamily; + FontType meType; + AquaSalSystem mpSysData; + ATSUFontID mnFontID; + + +public: + ImplMacFontData( const ImplDevFontAttributes&, + int nFontHeight, int macCharSet, + int nPitchAndFamily ); + ~ImplMacFontData(); + + virtual ImplFontData* Clone() const; + virtual ImplFontEntry* CreateFontInstance( ImplFontSelectData& ) const; + // void UpdateFromHDC( HDC ); + + bool HasChar( sal_uInt32 cChar ) const; + +// int GetCharSet() const { return meWinCharSet; } +// int GetPitchAndFamily() const { return mnPitchAndFamily; } +// bool IsGlyphApiDisabled() const { return mbDisableGlyphApi; } +// bool SupportsKorean() const { return mbHasKoreanRange; } +// bool SupportsCJK() const { return mbHasCJKSupport; } +// bool AliasSymbolsHigh() const { return mbAliasSymbolsHigh; } +// bool AliasSymbolsLow() const { return mbAliasSymbolsLow; } + + ImplFontCharMap* GetImplFontCharMap(); + +private: +// bool mbDisableGlyphApi; +// bool mbHasKoreanRange; +// bool mbHasCJKSupport; +// +// ImplFontCharMap* mpUnicodeMap; +// +// // TODO: get rid of the members below needed to work with the Win9x non-unicode API +// int* mpFontCharSets; // all Charsets for the current font (used on W98 for kerning) +// int mnFontCharSetCount; // Number of Charsets of the current font; 0 - if not queried +// int meWinCharSet; +// int mnPitchAndFamily; +// bool mbAliasSymbolsHigh; +// bool mbAliasSymbolsLow; + +private: +// void ReadCmapTable( HDC ); +// void ReadOs2Table( HDC ); + +#ifdef GNG_VERT_HACK +// void ReadGsubTable( HDC ) const; + + typedef std::hash_set IntHashSet; + mutable IntHashSet maGsubTable; + mutable bool mbGsubRead; +public: +// bool HasGSUBstitutions( HDC ) const; +// bool IsGSUBstituted( sal_Unicode ) const; +#endif // GNG_VERT_HACK +}; - // Port's pen attributes - SInt32 mnPortPenMode; // Port's pen mode - MacOSPoint maPortPenSize; // Port's pen size; - MacOSPoint maPortPenLocation; // Port's pen location - PixPatHandle mhPortPenPattern; // Port's pen pattern +// ------------------- +// - AquaSalGraphics - +// ------------------- - // Brush attributes and status +class AquaSalGraphics : public SalGraphics +{ + friend class ATSLayout; +protected: + CarbonViewRef mrView; // VCLVIEW + + CGContextRef mrBitmapContext; // bitmap graphics context (either from a virtual device(mrBitmapContext==mrContext) or an offscreen copy of mrContext + CGContextRef mrContext; // graphics context for Quartz 2D + CarbonWindowRef mrWindow; // Window if this is a Window graphics + + CGMutablePathRef mrClippingPath; // path representing current clip region + CGRect* mpStdClippingRect; // array for collecting clipping rectangles + CGRect* mpClippingRect; // used if more clipping rects are used than mpStdClippingRect can handle + CGRect* mpNextClippingRect; // points to next free slot in clipping rect array + long mnClippingRectCount; // number of clipping rects in current region + + // Drawing colors + CGColorSpaceRef mrRGBColorSpace; // the RGB color space + float mpLineColor[4]; // pen color RGBA + float mpFillColor[4]; // brush color RGBA + + ATSUStyle maATSUStyle; // style object which carries all font attributes + long mnATSUIRotation; // text rotation + + SInt32 mnPenMode; // Pen Mode + + // Graphics types + bool mbPrinter; // is this a printer graphics + bool mbVirDev; // is this a virtual device graphics + bool mbWindow; // is this a window graphics + bool mbScreen; // is this graphics screen compatible + + sal_Int32 mnGraphics; // guards BeginGraphics and EndGraphics from multiple calls + +/* + sal_uInt32 mnUpdateGraphicsEvent; + DECL_LINK( UpdateGraphics, void* ); +*/ + +private: + /** returns the display id this window is mostly visible on */ + CGDirectDisplayID GetWindowDisplayID() const; +public: + AquaSalGraphics(); + virtual ~AquaSalGraphics(); + + bool IsPenTransparent() const { return (mpLineColor[3] == 0.0); } + bool IsBrushTransparent() const { return (mpFillColor[3] == 0.0); } + + void SetWindowGraphics( CarbonViewRef rView, CarbonWindowRef rWindow, bool bScreenCompatible ); + void SetPrinterGraphics( CarbonViewRef rView, bool bScreenCompatible ); + void SetVirDevGraphics( CGContextRef xContext, bool bSCreenCompatible ); + + bool IsWindowGraphics() const { return mbWindow; } + bool IsPrinterGraphics() const { return mbPrinter; } + bool IsVirDevGraphics() const { return mbVirDev; } + bool IsScreenCompatible() const { return mbScreen; } + + void ImplDrawPixel( long nX, long nY, float pColor[] ); // helper to draw single pixels + + bool isOffscreenCopy() const; +protected: + // set up and release graphics context, required for any drawing opration + // the view will be be flipped like the HIView coordinate system + // i.e. (0,0) is top left and the y-axis points to the bottom + bool BeginGraphics(); + bool EndGraphics(); + void InitContextForPainting( CGContextRef xContext ); + + virtual BOOL unionClipRegion( long nX, long nY, long nWidth, long nHeight ); + // draw --> LineColor and FillColor and RasterOp and ClipRegion + virtual void drawPixel( long nX, long nY ); + virtual void drawPixel( long nX, long nY, SalColor nSalColor ); + virtual void drawLine( long nX1, long nY1, long nX2, long nY2 ); + virtual void drawRect( long nX, long nY, long nWidth, long nHeight ); + virtual void drawPolyLine( ULONG nPoints, const SalPoint* pPtAry ); + virtual void drawPolygon( ULONG nPoints, const SalPoint* pPtAry ); + virtual void drawPolyPolygon( ULONG nPoly, const ULONG* pPoints, PCONSTSALPOINT* pPtAry ); + virtual sal_Bool drawPolyLineBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ); + virtual sal_Bool drawPolygonBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ); + virtual sal_Bool drawPolyPolygonBezier( ULONG nPoly, const ULONG* pPoints, const SalPoint* const* pPtAry, const BYTE* const* pFlgAry ); + + // CopyArea --> No RasterOp, but ClipRegion + virtual void copyArea( long nDestX, long nDestY, long nSrcX, long nSrcY, long nSrcWidth, + long nSrcHeight, USHORT nFlags ); + + // CopyBits and DrawBitmap --> RasterOp and ClipRegion + // CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics + virtual void copyBits( const SalTwoRect* pPosAry, SalGraphics* pSrcGraphics ); + virtual void drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap ); + virtual void drawBitmap( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap, + SalColor nTransparentColor ); + virtual void drawBitmap( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap, + const SalBitmap& rTransparentBitmap ); + virtual void drawMask( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap, + SalColor nMaskColor ); + + virtual SalBitmap* getBitmap( long nX, long nY, long nWidth, long nHeight ); + virtual SalColor getPixel( long nX, long nY ); + + // invert --> ClipRegion (only Windows or VirDevs) + virtual void invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags); + virtual void invert( ULONG nPoints, const SalPoint* pPtAry, SalInvert nFlags ); + + virtual BOOL drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, ULONG nSize ); + + // native widget rendering methods that require mirroring + virtual BOOL hitTestNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, + const Point& aPos, SalControlHandle& rControlHandle, BOOL& rIsInside ); + virtual BOOL drawNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, + ControlState nState, const ImplControlValue& aValue, SalControlHandle& rControlHandle, + const rtl::OUString& aCaption ); + virtual BOOL drawNativeControlText( ControlType nType, ControlPart nPart, const Region& rControlRegion, + ControlState nState, const ImplControlValue& aValue, + SalControlHandle& rControlHandle, const rtl::OUString& aCaption ); + virtual BOOL getNativeControlRegion( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, + const ImplControlValue& aValue, SalControlHandle& rControlHandle, const rtl::OUString& aCaption, + Region &rNativeBoundingRegion, Region &rNativeContentRegion ); + +public: + // public SalGraphics methods, the interface to teh independent vcl part + + // get device resolution + virtual void GetResolution( long& rDPIX, long& rDPIY ); + // get resolution for fonts (an implementations specific adjustment, + // ideally would be the same as the Resolution) + virtual void GetScreenFontResolution( long& rDPIX, long& rDPIY ); + // get the depth of the device + virtual USHORT GetBitCount(); + // get the width of the device + virtual long GetGraphicsWidth() const; + + // set the clip region to empty + virtual void ResetClipRegion(); + // begin setting the clip region, add rectangles to the + // region with the UnionClipRegion call + virtual void BeginSetClipRegion( ULONG nCount ); + // all rectangles were added and the clip region should be set now + virtual void EndSetClipRegion(); + + // set the line color to transparent (= don't draw lines) + virtual void SetLineColor(); + // set the line color to a specific color + virtual void SetLineColor( SalColor nSalColor ); + // set the fill color to transparent (= don't fill) + virtual void SetFillColor(); + // set the fill color to a specific color, shapes will be + // filled accordingly + virtual void SetFillColor( SalColor nSalColor ); + // enable/disable XOR drawing + virtual void SetXORMode( BOOL bSet ); + // set line color for raster operations + virtual void SetROPLineColor( SalROPColor nROPColor ); + // set fill color for raster operations + virtual void SetROPFillColor( SalROPColor nROPColor ); + // set the text color to a specific color + virtual void SetTextColor( SalColor nSalColor ); + // set the font + virtual USHORT SetFont( ImplFontSelectData*, int nFallbackLevel ); + // get the current font's etrics + virtual void GetFontMetric( ImplFontMetricData* ); + // get kernign pairs of the current font + // return only PairCount if (pKernPairs == NULL) + virtual ULONG GetKernPairs( ULONG nPairs, ImplKernPairData* pKernPairs ); + // get the repertoire of the current font + virtual ImplFontCharMap* GetImplFontCharMap() const; + // graphics must fill supplied font list + virtual void GetDevFontList( ImplDevFontList* ); + // graphics should call ImplAddDevFontSubstitute on supplied + // OutputDevice for all its device specific preferred font substitutions + virtual void GetDevFontSubstList( OutputDevice* ); + virtual bool AddTempDevFont( ImplDevFontList*, const String& rFileURL, const String& rFontName ); + // CreateFontSubset: a method to get a subset of glyhps of a font + // inside a new valid font file + // returns TRUE if creation of subset was successfull + // parameters: rToFile: contains a osl file URL to write the subset to + // pFont: describes from which font to create a subset + // pGlyphIDs: the glyph ids to be extracted + // pEncoding: the character code corresponding to each glyph + // pWidths: the advance widths of the correspoding glyphs (in PS font units) + // nGlyphs: the number of glyphs + // rInfo: additional outgoing information + // implementation note: encoding 0 with glyph id 0 should be added implicitly + // as "undefined character" + virtual BOOL CreateFontSubset( const rtl::OUString& rToFile, + ImplFontData* pFont, + long* pGlyphIDs, + sal_uInt8* pEncoding, + sal_Int32* pWidths, + int nGlyphs, + FontSubsetInfo& rInfo // out parameter + ); + + // GetFontEncodingVector: a method to get the encoding map Unicode + // to font encoded character; this is only used for type1 fonts and + // may return NULL in case of unknown encoding vector + // if ppNonEncoded is set and non encoded characters (that is type1 + // glyphs with only a name) exist it is set to the corresponding + // map for non encoded glyphs; the encoding vector contains -1 + // as encoding for these cases + virtual const std::map< sal_Unicode, sal_Int32 >* GetFontEncodingVector( ImplFontData* pFont, const std::map< sal_Unicode, rtl::OString >** ppNonEncoded ); + + // GetEmbedFontData: gets the font data for a font marked + // embeddable by GetDevFontList or NULL in case of error + // parameters: pFont: describes the font in question + // pWidths: the widths of all glyphs from char code 0 to 255 + // pWidths MUST support at least 256 members; + // rInfo: additional outgoing information + // pDataLen: out parameter, contains the byte length of the returned buffer + virtual const void* GetEmbedFontData( ImplFontData* pFont, + const sal_Unicode* pUnicodes, + sal_Int32* pWidths, + FontSubsetInfo& rInfo, + long* pDataLen ); + // frees the font data again + virtual void FreeEmbedFontData( const void* pData, long nDataLen ); - BOOL mbBrushTransparent; // Is brush transparent? - RGBColor maBrushColor; // Brush Color + virtual BOOL GetGlyphBoundRect( long nIndex, Rectangle& ); + virtual BOOL GetGlyphOutline( long nIndex, basegfx::B2DPolyPolygon& ); - // Miscellaneous status flags + virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ); + virtual void DrawServerFontLayout( const ServerFontLayout& ); - BOOL mbPrinter; // Is a printer available? - BOOL mbVirDev; // Is a virtual device available? - BOOL mbWindow; // Is a window availble? - BOOL mbScreen; // Is this screen compatiable? - OSStatus mnOSStatus; // The current MacOS error + // Query the platform layer for control support + virtual BOOL IsNativeControlSupported( ControlType nType, ControlPart nPart ); }; -typedef struct SalGraphicsData SalGraphicsData; -typedef SalGraphicsData *SalGraphicsDataPtr; -typedef SalGraphicsDataPtr *SalGraphicsDataHandle; +inline bool AquaSalGraphics::isOffscreenCopy() const +{ + return mrBitmapContext && (mrBitmapContext != mrContext); +} #endif // _SV_SALGDI_H diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/inc/salinst.h ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salinst.h --- ooo_SRC680_m187_src.orig/vcl/aqua/inc/salinst.h 2005-09-09 12:34:41.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salinst.h 2006-07-19 12:21:11.000000000 +0200 @@ -46,9 +46,12 @@ #include #endif -#ifndef _SV_VCLWINDOW_H -#include -#endif +#include +#include +#include +#include +#include +#include #ifdef __cplusplus @@ -82,12 +85,99 @@ // - SalInstanceData - // ------------------- -struct SalInstanceData +//struct SalInstanceData +//{ +//public: +//}; + +// ------------------ +// - AquaSalInstance - +// ------------------ + +class AquaSalInstance : public SalInstance { public: void* mpFilterInst; void* mpFilterCallback; SalYieldMutex* mpSalYieldMutex; // Sal-Yield-Mutex +public: + AquaSalInstance(); + virtual ~AquaSalInstance(); + + virtual SalSystem* CreateSystem(); + virtual void DestroySystem(SalSystem*); + virtual SalFrame* CreateChildFrame( SystemParentData* pParent, ULONG nStyle ); + virtual SalFrame* CreateFrame( SalFrame* pParent, ULONG nStyle ); + virtual void DestroyFrame( SalFrame* pFrame ); + virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData ); + virtual void DestroyObject( SalObject* pObject ); + virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, + long nDX, long nDY, + USHORT nBitCount, const SystemGraphicsData *pData ); + virtual void DestroyVirtualDevice( SalVirtualDevice* pDevice ); + + virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, + ImplJobSetup* pSetupData ); + virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ); + virtual SalPrinter* CreatePrinter( SalInfoPrinter* pInfoPrinter ); + virtual void DestroyPrinter( SalPrinter* pPrinter ); + virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ); + virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ); + virtual void DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ); + virtual String GetDefaultPrinter(); + virtual SalSound* CreateSalSound(); + virtual SalTimer* CreateSalTimer(); + virtual SalOpenGL* CreateSalOpenGL( SalGraphics* pGraphics ); + virtual SalI18NImeStatus* CreateI18NImeStatus(); + virtual SalSystem* CreateSalSystem(); + virtual SalBitmap* CreateSalBitmap(); + virtual vos::IMutex* GetYieldMutex(); + virtual ULONG ReleaseYieldMutex(); + virtual void AcquireYieldMutex( ULONG nCount ); + virtual void Yield( bool bWait, bool bHandleAllCurrentEvents ); + virtual bool AnyInput( USHORT nType ); + virtual SalMenu* CreateMenu( BOOL bMenuBar ); + virtual void DestroyMenu( SalMenu* ); + virtual SalMenuItem* CreateMenuItem( const SalItemParams* pItemData ); + virtual void DestroyMenuItem( SalMenuItem* ); + virtual SalSession* CreateSalSession(); + virtual void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ); + virtual void SetEventCallback( void* pInstance, bool(*pCallback)(void*,void*,int) ); + virtual void SetErrorEventCallback( void* pInstance, bool(*pCallback)(void*,void*,int) ); + + static void TimerEventHandler(EventLoopTimerRef inTimer, void* pData); + + public: + /* During window resizing the standard event handler does + not dispatch VCL timer messages which (for some strange + reasons) trigger VCL painting. So when live resizing of + windows is enabled the window content will not be painted + at all especially when the user doesn't move the mouse + anymore but still holds the left mouse button pressed on + the resize area. + So to get timer messages delivered nevertheless we setup + a message loop timer. Events fired by this timer will also + be delivered during window resizing. + */ + void StartForceDispatchingPaintEvents(); + void StopForceDispatchingPaintEvents(); + EventLoopTimerRef mEventLoopTimerRef; + bool mbForceDispatchPaintEvents; + + friend class AquaSalFrame; }; +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + + // Invokes [VCLApplication run] + void VCLApplication_Run( BOOL bWait ); + +#ifdef __cplusplus +} +#endif // __cplusplus + + + #endif // _SV_SALINST_H diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/inc/salmenu.h ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salmenu.h --- ooo_SRC680_m187_src.orig/vcl/aqua/inc/salmenu.h 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salmenu.h 2006-08-20 18:02:02.000000000 +0200 @@ -0,0 +1,99 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * 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 + * + ************************************************************************/ + +#ifndef _SV_SALMENU_H +#define _SV_SALMENU_H + +#include +#include +#include + +#ifndef _SV_SV_H +#include +#endif +#ifndef _SV_BITMAP_HXX +#include +#endif + +#ifndef _SV_SALMENU_HXX +#include +#endif + + +class AquaSalMenu : public SalMenu +{ +public: + AquaSalMenu() {} + virtual ~AquaSalMenu(); + + virtual BOOL VisibleMenuBar(); // must return TRUE to actually DISPLAY native menu bars + // otherwise only menu messages are processed (eg, OLE on Windows) + + virtual void InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos ); + virtual void RemoveItem( unsigned nPos ); + virtual void SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos ); + virtual void SetFrame( const SalFrame* pFrame ); + virtual void CheckItem( unsigned nPos, BOOL bCheck ); + virtual void EnableItem( unsigned nPos, BOOL bEnable ); + virtual void SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const XubString& rText ); + virtual void SetItemImage( unsigned nPos, SalMenuItem* pSalMenuItem, const Image& rImage); + virtual void SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const KeyCode& rKeyCode, const XubString& rKeyName ); + virtual void GetSystemMenuData( SystemMenuData* pData ); + + XubString mText; // Title of this menu + MenuRef mrMenuRef; // The Carbon reference to this menu + BOOL mbMenuBar; // TRUE - Menubar, FALSE - Menu +}; + +class AquaSalMenuItem : public SalMenuItem +{ +public: + AquaSalMenuItem() {} + virtual ~AquaSalMenuItem(); + + USHORT mnId; // Item ID + Menu *mpMenu; // Menu into which this MenuItem is inserted + SalMenu *mpSubMenu; // Sub menu of this item (if defined) + XubString mText; // Title of this menu item + MenuRef mrParentMenuRef; // The menu in which this menu item is inserted + + MenuItemIndex mnMenuItemIndex; // The menu index of this menu item in mpMenu + // It is 1 based, so the first menu + // item's MenuItemIndex in the menu has value 1 + + MenuItemAttributes maMenuAttributes; +}; + +#endif // _SV_SALMENU_H diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/inc/salobj.h ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salobj.h --- ooo_SRC680_m187_src.orig/vcl/aqua/inc/salobj.h 2005-09-09 12:35:10.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salobj.h 2005-11-27 10:48:16.000000000 +0100 @@ -44,16 +44,57 @@ #include #endif +#include + +class AquaSalFrame; +class AquaSalObject; + + // ----------------- // - SalObjectData - // ----------------- struct SalObjectData { - SalFrame* mpFrame; // parent frame - SalObject* mpNextObject; // pointer to next object +}; + +class AquaSalObject : public SalObject +{ +public: + AquaSalFrame* mpFrame; // parent frame + AquaSalObject* mpNextObject; // pointer to next object void* mpInst; // instance handle for callback SALOBJECTPROC mpProc; // callback proc + + +// HWND mhWnd; // Window handle +// HWND mhWndChild; // Child Window handle +// HWND mhLastFocusWnd; // Child-Window, welches als letztes den Focus hatte +// SystemChildData maSysData; // SystemEnvData +// RGNDATA* mpClipRgnData; // ClipRegion-Data +// RGNDATA* mpStdClipRgnData; // Cache Standard-ClipRegion-Data +// RECT* mpNextClipRect; // Naechstes ClipRegion-Rect +// BOOL mbFirstClipRect; // Flag for first cliprect to insert +// WinSalObject* mpNextObject; // pointer to next object + + + AquaSalObject(); + virtual ~AquaSalObject(); + + virtual void ResetClipRegion(); + virtual USHORT GetClipRegionType(); + virtual void BeginSetClipRegion( ULONG nRects ); + virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight ); + virtual void EndSetClipRegion(); + virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight ); + virtual void Show( BOOL bVisible ); + virtual void Enable( BOOL nEnable ); + virtual void GrabFocus(); + virtual void SetBackground(); + virtual void SetBackground( SalColor nSalColor ); + virtual const SystemEnvData* GetSystemData() const; + + virtual void SetCallback( void* pInst, SALOBJECTPROC pProc ); }; #endif // _SV_SALOBJ_H diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/inc/salogl.h ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salogl.h --- ooo_SRC680_m187_src.orig/vcl/aqua/inc/salogl.h 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salogl.h 2006-07-19 12:19:48.000000000 +0200 @@ -0,0 +1,118 @@ +/************************************************************************* +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile$ +* +* $Revision$ +* +* last change: $Author$ $Date$ +* +* 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 +* +************************************************************************/ + +#ifndef _SV_SALOGL_H +#define _SV_SALOGL_H + +//#if defined EXPLICITLY_INCLUDE_GLX_H +//#include +//#define GL_H +//#include +//#include +//#else +//typedef void* GLXContext; +//typedef XID GLXDrawable; +//// needed GLX_ constants +//#define GLX_USE_GL 1 +//#define GLX_DOUBLEBUFFER 5 +//#endif + +#ifndef _SV_SALOGL_HXX +#include +#endif + +#ifndef _OSL_MODULE_H +#include +#endif + +// ------------- +// - SalOpenGL - +// ------------- + +class SalGraphics; + +class AquaSalOpenGL : public SalOpenGL +{ +private: + static CarbonViewRef mhOGLLastDC; + static ULONG mnOGLState; + + // static oslModule mpGLLib; +// static GLXContext maGLXContext; +// static ULONG mnOGLState; +// static Display* mpDisplay; +// static XVisualInfo* mpVisualInfo; +// static BOOL mbHaveGLVisual; +// +// static BOOL ImplInit(); +// +// static GLXContext (*pCreateContext)( Display *, XVisualInfo *, GLXContext, Bool ); +// static void (*pDestroyContext)( Display *, GLXContext ); +// static GLXContext (*pGetCurrentContext)( ); +// static Bool (*pMakeCurrent)( Display *, GLXDrawable, GLXContext ); +// static void (*pSwapBuffers)( Display*, GLXDrawable ); +// static int (*pGetConfig)( Display*, XVisualInfo*, int, int* ); +// static void (*pFlush)(); +// +// Drawable maDrawable; +// +// static void* resolveSymbol( const char* pSym ); +public: + + AquaSalOpenGL( SalGraphics* pGraphics ); + ~AquaSalOpenGL(); + +// static void Release(); +// static void ReleaseLib(); +// static void MakeVisualWeights( +// Display *pDisplay, +// XVisualInfo* pInfos, +// int* pWeights, +// int nVisuals +// ); + + // overload all pure virtual methods + virtual bool IsValid(); + virtual oglFunction GetOGLFnc( const char * ); + virtual void OGLEntry( SalGraphics* pGraphics ); + virtual void OGLExit( SalGraphics* pGraphics ); + virtual void StartScene( SalGraphics* pGraphics ); + virtual void StopScene(); + virtual BOOL Create(); + virtual void Release(); + +}; + +#endif // _SV_SALOGL_H diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/inc/salogl.hxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salogl.hxx --- ooo_SRC680_m187_src.orig/vcl/aqua/inc/salogl.hxx 2005-09-09 12:35:24.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salogl.hxx 2006-02-27 22:33:53.000000000 +0100 @@ -69,7 +69,7 @@ class SalOpenGL { private: - static VCLVIEW mhOGLLastDC; + static CarbonViewRef mhOGLLastDC; static ULONG mnOGLState; public: diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/inc/salprn.h ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salprn.h --- ooo_SRC680_m187_src.orig/vcl/aqua/inc/salprn.h 2005-09-09 12:36:03.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salprn.h 2006-02-27 22:33:54.000000000 +0100 @@ -40,6 +40,9 @@ #include #endif +#ifndef _AQUAVCLTYPES_H +#include +#endif class SalGraphics; class SalInfoPrinter; @@ -84,7 +87,7 @@ ByteString maDriverNameA; // printer driver name ByteString maDeviceNameA; // printer device name ByteString maPortNameA; // printer port name - VCLVIEW mhDC; // printer hdc + CarbonViewRef mhDC; // printer hdc BOOL mbGraphics; // is Graphics used BOOL mbAnsi; }; @@ -99,4 +102,78 @@ SalInfoPrinter* mpInfoPrinter; // pointer to the compatible InfoPrinter }; +// --------------------- +// - AquaSalInfoPrinter - +// --------------------- + +class AquaSalGraphics; + +class AquaSalInfoPrinter : public SalInfoPrinter +{ +public: + AquaSalGraphics* mpGraphics; // current Printer graphics + XubString maDriverName; // printer driver name + XubString maDeviceName; // printer device name + XubString maPortName; // printer port name + ByteString maDriverNameA; // printer driver name + ByteString maDeviceNameA; // printer device name + ByteString maPortNameA; // printer port name +// HDC mhDC; // printer hdc + BOOL mbGraphics; // is Graphics used + BOOL mbAnsi; + +public: + AquaSalInfoPrinter(); + virtual ~AquaSalInfoPrinter(); + + virtual SalGraphics* GetGraphics(); + virtual void ReleaseGraphics( SalGraphics* pGraphics ); + virtual BOOL Setup( SalFrame* pFrame, ImplJobSetup* pSetupData ); + virtual BOOL SetPrinterData( ImplJobSetup* pSetupData ); + virtual BOOL SetData( ULONG nFlags, ImplJobSetup* pSetupData ); + virtual void GetPageInfo( const ImplJobSetup* pSetupData, + long& rOutWidth, long& rOutHeight, + long& rPageOffX, long& rPageOffY, + long& rPageWidth, long& rPageHeight ); + virtual ULONG GetCapabilities( const ImplJobSetup* pSetupData, USHORT nType ); + virtual ULONG GetPaperBinCount( const ImplJobSetup* pSetupData ); + virtual String GetPaperBinName( const ImplJobSetup* pSetupData, ULONG nPaperBin ); + virtual void InitPaperFormats( const ImplJobSetup* pSetupData ); + virtual int GetLandscapeAngle( const ImplJobSetup* pSetupData ); + virtual DuplexMode GetDuplexMode( const ImplJobSetup* pSetupData ); +}; + +// ----------------- +// - AquaSalPrinter - +// ----------------- + +class AquaSalPrinter : public SalPrinter +{ +public: + AquaSalGraphics* mpGraphics; // current Printer graphics + AquaSalInfoPrinter* mpInfoPrinter; // pointer to the compatible InfoPrinter + AquaSalPrinter* mpNextPrinter; // next printing printer +// HDC mhDC; // printer hdc + ULONG mnError; // Error Code + ULONG mnCopies; // Kopien + BOOL mbCollate; // Sortierte Kopien + BOOL mbAbort; // Job Aborted + +public: + AquaSalPrinter(); + virtual ~AquaSalPrinter(); + + virtual BOOL StartJob( const XubString* pFileName, + const XubString& rJobName, + const XubString& rAppName, + ULONG nCopies, BOOL bCollate, + ImplJobSetup* pSetupData ); + virtual BOOL EndJob(); + virtual BOOL AbortJob(); + virtual SalGraphics* StartPage( ImplJobSetup* pSetupData, BOOL bNewJobData ); + virtual BOOL EndPage(); + virtual ULONG GetErrorCode(); +}; + + #endif // _SV_SALPRN_H diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/inc/salsound.h ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salsound.h --- ooo_SRC680_m187_src.orig/vcl/aqua/inc/salsound.h 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salsound.h 2005-11-27 10:48:19.000000000 +0100 @@ -0,0 +1,109 @@ +/************************************************************************* +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile$ +* +* $Revision$ +* +* last change: $Author$ $Date$ +* +* 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 +* +************************************************************************/ + +#ifndef _SV_SALSOUND_H +#define _SV_SALSOUND_H + +//#ifndef _SV_WINCOMP_HXX +//#include +//#endif + +#ifndef _GEN_HXX +#include +#endif +#ifndef _STRING_HXX +#include +#endif + +#ifndef _SV_SV_H +#include +#endif + +#include + +#ifndef _SV_SALFRAME_HXX +#include +#endif +#ifndef _SV_SALSTYPE_HXX +#include +#endif +#ifndef _SV_SALSOUND_HXX +#include +#endif + +// ------------ +// - SalSound - +// ------------ + +class AquaSalSound : public SalSound +{ +private: +// static oslModule mhMCILib; + static ULONG mnSoundState; + SALSOUNDPROC mpProc; +// static void* mpMCIFnc; +// ULONG mnStartTime; +// ULONG mnPlayLen; +// HWND mhSoundWnd; +// UINT mnDeviceId; + bool mbLoop; + bool mbPaused; + +public: + void ImplSetError( int nMciErr ); + void ImplNotify( SoundNotification eNotification, ULONG nError ); + +public: + AquaSalSound(); + virtual ~AquaSalSound(); + + virtual bool IsValid(); + virtual bool Init( const String& rSoundName, + ULONG& rSoundLen ); + virtual void Play( ULONG nStartTime, ULONG nPlayTime, bool bLoop ); + virtual void Stop(); + virtual void Pause(); + virtual void Continue(); + virtual bool IsLoopMode() const; + virtual bool IsPlaying() const; + virtual bool IsPaused() const; + + + bool ImplCreate(); + void ImplDestroy(); + static void Release(); +}; + +#endif // _SV_SALSOUND_H diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/inc/salsys.h ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salsys.h --- ooo_SRC680_m187_src.orig/vcl/aqua/inc/salsys.h 2005-09-09 12:36:47.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salsys.h 2006-10-14 15:27:41.000000000 +0200 @@ -40,13 +40,41 @@ #include #endif +#include + +#include // ----------------- // - SalSystemData - // ----------------- -struct SalSystemData +//struct SalSystemData +//{ +//}; + +class VCL_DLLPUBLIC AquaSalSystem : public SalSystem { +public: + AquaSalSystem() {} + virtual ~AquaSalSystem(); + + // get info about the display + virtual unsigned int GetDisplayScreenCount(); + virtual bool IsMultiDisplay(); + virtual unsigned int GetDefaultDisplayNumber(); + virtual Rectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ); + virtual Rectangle GetDisplayWorkAreaPosSizePixel( unsigned int nScreen ); + + // overload pure virtual methods + virtual int ShowNativeDialog( const String& rTitle, + const String& rMessage, + const std::list< String >& rButtons, + int nDefButton ); + virtual int ShowNativeMessageBox( const String& rTitle, + const String& rMessage, + int nButtonCombination, + int nDefaultButton); }; + #endif // _SV_SALSYS_H diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/inc/saltimer.h ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/saltimer.h --- ooo_SRC680_m187_src.orig/vcl/aqua/inc/saltimer.h 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/saltimer.h 2006-03-02 01:31:02.000000000 +0100 @@ -0,0 +1,68 @@ +/************************************************************************* +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile$ +* +* $Revision$ +* +* last change: $Author$ $Date$ +* +* 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 +* +************************************************************************/ + +#ifndef _SV_SALTIMER_H +#define _SV_SALTIMER_H + +#include +#include +#include + +#ifndef _SV_SALTIMER_HXX +#include +#endif + +class AquaSalTimer : public SalTimer +{ +private: + TMTask mTask; // the timer task + BOOL mbInstalled; // timer task is in queue + long mMS; // current timer interval in msec + BOOL InstallTask(); // installs timer task and returns status + +public: + AquaSalTimer(); + virtual ~AquaSalTimer(); + + // overload all pure virtual methods + void Start( ULONG nMS ); + void Stop(); + + // restarts active tasks using the current timeout + // optional with different timeout (when nMS is != 0) + void ReStart( ULONG nMS = 0 ); +}; + +#endif diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/inc/salvd.h ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salvd.h --- ooo_SRC680_m187_src.orig/vcl/aqua/inc/salvd.h 2005-09-09 12:37:00.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/inc/salvd.h 2006-08-14 23:07:01.000000000 +0200 @@ -56,6 +56,9 @@ #include #endif +#include +#include + #if PRAGMA_ONCE #pragma once #endif @@ -70,11 +73,6 @@ struct SalVirDevData { - SalGraphics *mpGraphics; // current VirDev graphics - USHORT mnBitCount; // GWorld pixel depth - long mnWidth; // GWorld width - long mnHeight; // GWorld height - BOOL mbGraphics; // is Graphics used? }; typedef struct SalVirDevData SalVirDevData; @@ -83,6 +81,31 @@ // ======================================================================= +class AquaSalGraphics; + +// ----------------- +// - SalVirDevData - +// ----------------- + +class AquaSalVirtualDevice : public SalVirtualDevice +{ +private: + bool mbGraphicsUsed; + CGContextRef mxContext; + AquaSalGraphics* mpGraphics; + + void Destroy(); + +public: + AquaSalVirtualDevice( AquaSalGraphics* pGraphic, long nDX, long nDY, USHORT nBitCount, const SystemGraphicsData *pData ); + virtual ~AquaSalVirtualDevice(); + + virtual SalGraphics* GetGraphics(); + virtual void ReleaseGraphics( SalGraphics* pGraphics ); + virtual BOOL SetSize( long nNewDX, long nNewDY ); + virtual void GetSize( long& rWidth, long& rHeight ); +}; + // ======================================================================= #endif // _SV_SALVD_H diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/app/makefile.mk ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/app/makefile.mk --- ooo_SRC680_m187_src.orig/vcl/aqua/source/app/makefile.mk 2005-09-09 12:38:32.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/app/makefile.mk 2006-03-08 22:35:07.000000000 +0100 @@ -38,6 +38,7 @@ PRJNAME=vcl TARGET=salapp .INCLUDE : $(PRJ)$/util$/makefile.pmk +ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- @@ -55,19 +56,16 @@ .ELSE # "$(GUIBASE)"!="aqua" -OBJFILES= $(OBJ)$/salmain.obj \ - $(OBJ)$/VCLApplication.obj \ - $(OBJ)$/VCLAutoreleasePool.obj +#CFLAGS+=-x objective-c++ + +OBJFILES= $(OBJ)$/salmain.obj SLOFILES= $(SLO)$/salinst.obj \ $(SLO)$/saldata.obj \ $(SLO)$/saltimer.obj \ $(SLO)$/salsound.obj \ $(SLO)$/salsys.obj \ - $(SLO)$/salmain.obj \ - $(SLO)$/VCLApplication.obj \ - $(SLO)$/VCLAutoreleasePool.obj \ - $(SLO)$/VCLEvent.obj + $(SLO)$/salmain.obj EXCEPTIONSFILES=$(SLO)$/salmain.obj \ $(OBJ)$/salmain.obj diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/app/salinst.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/app/salinst.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/app/salinst.cxx 2006-09-17 13:42:16.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/app/salinst.cxx 2006-10-13 23:54:14.000000000 +0200 @@ -44,32 +44,49 @@ #ifndef _SV_SALINST_HXX #include #endif -#ifndef _SV_SALFRAME_HXX -#include +#ifndef _SV_SALINST_H +#include +#endif +#ifndef _SV_SALFRAME_H +#include #endif #ifndef _SV_SALOBJ_HXX #include #endif +#include +#ifndef _SV_SALOBJ_H +#include +#endif #ifndef _SV_SALSYS_HXX #include #endif +#ifndef _SV_SALSYS_H +#include +#endif #ifndef _SV_SALVD_HXX #include #endif +#ifndef _SV_SALVD_H +#include +#endif #ifndef _SV_DIALOG_HXX #include #endif -#ifndef _SV_VCLAPPLICATION_H -#include -#endif -#ifndef _SV_VCLAUTORELEASEPOOL_H -#include -#endif #ifndef _FSYS_HXX #include #endif +#ifndef _SV_SALIMESTATUS_HXX +#include +#endif -static VCLAUTORELEASEPOOL hMainAutoreleasePool = NULL; +#include +#include + +#include + +#include + +using namespace std; // ======================================================================= @@ -94,6 +111,14 @@ // ----------------------------------------------------------------------- +const ::rtl::OUString& SalGetDesktopEnvironment() +{ + static OUString aDesktopEnvironment(RTL_CONSTASCII_USTRINGPARAM( "MacOSX" )); + return aDesktopEnvironment; +} + +// ----------------------------------------------------------------------- + void DeInitSalData() { SalData *pSalData = GetSalData(); @@ -111,80 +136,59 @@ void InitSalMain() { - // [ed] 5/14/02 We need to use _NSGetEnviron() here and can't use the straight - // environ. This is due to two-level-namespaces not enjoying having funky - // global hack symbols lying around. -#ifdef QUARTZ - char **environ; - char *stackNULL=NULL; - if(_NSGetEnviron()) - environ=*_NSGetEnviron(); - else - environ=&stackNULL; -#else - extern char **environ; -#endif - - char **pEnviron; - - // Get full executable path. We cna't use __progname as that only holds - // the name of the executable and not the path. The full executable path - // is listed after the first NULL in *environ. - pEnviron = environ; - while ( *pEnviron++ ) - ; - - // Need to include the absolute path for this executable in the PATH - // and STAR_RESOURCEPATH environment variables so that the resource manager - // can find resource files and in the DYLD_LIBRARY_PATH environment - // variable so that the dynamic library loader can find shared libraries - ByteString aPath( getenv( "PATH" ) ); - ByteString aResPath( getenv( "STAR_RESOURCEPATH" ) ); - ByteString aLibPath( getenv( "DYLD_LIBRARY_PATH" ) ); - ByteString aCmdPath( *pEnviron ); - ByteString aTmpPath; - // Get absolute path of command's directory - if ( aCmdPath.Len() ) { - DirEntry aCmdDirEntry( aCmdPath ); - aCmdDirEntry.ToAbs(); - aCmdPath = ByteString( aCmdDirEntry.GetPath().GetFull(), RTL_TEXTENCODING_ASCII_US ); - } - // Assign to PATH environment variable - if ( aCmdPath.Len() ) - { - aTmpPath = ByteString( "PATH=" ); - aTmpPath += aCmdPath; - if ( aPath.Len() ) - aTmpPath += ByteString( DirEntry::GetSearchDelimiter(), RTL_TEXTENCODING_ASCII_US ); - aTmpPath += aPath; - putenv( aTmpPath.GetBuffer() ); - } - // Assign to STAR_RESOURCEPATH environment variable - if ( aCmdPath.Len() ) - { - aTmpPath = ByteString( "STAR_RESOURCEPATH=" ); - aTmpPath += aCmdPath; - if ( aResPath.Len() ) - aTmpPath += ByteString( DirEntry::GetSearchDelimiter(), RTL_TEXTENCODING_ASCII_US ); - aTmpPath += aResPath; - putenv( aTmpPath.GetBuffer() ); - } - // Assign to DYLD_LIBRARY_PATH environment variable - if ( aCmdPath.Len() ) - { - aTmpPath = ByteString( "DYLD_LIBRARY_PATH=" ); - aTmpPath += aCmdPath; - if ( aLibPath.Len() ) - aTmpPath += ByteString( DirEntry::GetSearchDelimiter(), RTL_TEXTENCODING_ASCII_US ); - aTmpPath += aLibPath; - putenv( aTmpPath.GetBuffer() ); - } - - // Setup up autorelease pool for Objective-C objects - hMainAutoreleasePool = VCLAutoreleasePool_Init(); - - // Initialize application's connection to the window server - VCLApplication_SharedApplication(); + rtl_uString *urlWorkDir = NULL; + rtl_uString *sysWorkDir = NULL; + + oslProcessError err1 = osl_getProcessWorkingDir(&urlWorkDir); + + if (err1 == osl_Process_E_None) + { + oslFileError err2 = osl_getSystemPathFromFileURL(urlWorkDir, &sysWorkDir); + if (err2 == osl_File_E_None) + { + ByteString aPath( getenv( "PATH" ) ); + ByteString aResPath( getenv( "STAR_RESOURCEPATH" ) ); + ByteString aLibPath( getenv( "DYLD_LIBRARY_PATH" ) ); + ByteString aCmdPath( OUStringToOString(OUString(sysWorkDir), RTL_TEXTENCODING_UTF8).getStr() ); + ByteString aTmpPath; + // Get absolute path of command's directory + if ( aCmdPath.Len() ) { + DirEntry aCmdDirEntry( aCmdPath ); + aCmdDirEntry.ToAbs(); + aCmdPath = ByteString( aCmdDirEntry.GetPath().GetFull(), RTL_TEXTENCODING_ASCII_US ); + } + // Assign to PATH environment variable + if ( aCmdPath.Len() ) + { + aTmpPath = ByteString( "PATH=" ); + aTmpPath += aCmdPath; + if ( aPath.Len() ) + aTmpPath += ByteString( DirEntry::GetSearchDelimiter(), RTL_TEXTENCODING_ASCII_US ); + aTmpPath += aPath; + putenv( (char*)aTmpPath.GetBuffer() ); + } + // Assign to STAR_RESOURCEPATH environment variable + if ( aCmdPath.Len() ) + { + aTmpPath = ByteString( "STAR_RESOURCEPATH=" ); + aTmpPath += aCmdPath; + if ( aResPath.Len() ) + aTmpPath += ByteString( DirEntry::GetSearchDelimiter(), RTL_TEXTENCODING_ASCII_US ); + aTmpPath += aResPath; + putenv( (char*)aTmpPath.GetBuffer() ); + } + // Assign to DYLD_LIBRARY_PATH environment variable + if ( aCmdPath.Len() ) + { + aTmpPath = ByteString( "DYLD_LIBRARY_PATH=" ); + aTmpPath += aCmdPath; + if ( aLibPath.Len() ) + aTmpPath += ByteString( DirEntry::GetSearchDelimiter(), RTL_TEXTENCODING_ASCII_US ); + aTmpPath += aLibPath; + putenv( (char*)aTmpPath.GetBuffer() ); + } + } + } } // ----------------------------------------------------------------------- @@ -192,7 +196,7 @@ void DeInitSalMain() { // Release autorelease pool - VCLAutoreleasePool_Release( hMainAutoreleasePool ); + //VCLAutoreleasePool_Release( hMainAutoreleasePool ); } @@ -201,8 +205,8 @@ void SetFilterCallback( void* pCallback, void* pInst ) { SalData *pSalData = GetSalData(); - pSalData->mpFirstInstance->maInstData.mpFilterCallback = pCallback; - pSalData->mpFirstInstance->maInstData.mpFilterInst = pInst; + //[fheckl]pSalData->mpFirstInstance->mpFilterCallback = pCallback; + //[fheckl]pSalData->mpFirstInstance->mpFilterInst = pInst; } // ======================================================================= @@ -237,23 +241,56 @@ { mnThreadId = NAMESPACE_VOS(OThread)::getCurrentIdentifier(); mnCount++; - return True; + return sal_True; } else - return False; + return sal_False; +} + +// ----------------------------------------------------------------------- + +// some convenience functions regarding the yield mutex, aka solar mutex + +BOOL ImplSalYieldMutexTryToAcquire() +{ + AquaSalInstance* pInst = (AquaSalInstance*) GetSalData()->mpFirstInstance; + if ( pInst ) + return pInst->mpSalYieldMutex->tryToAcquire(); + else + return FALSE; +} + +void ImplSalYieldMutexAcquire() +{ + AquaSalInstance* pInst = (AquaSalInstance*) GetSalData()->mpFirstInstance; + if ( pInst ) + pInst->mpSalYieldMutex->acquire(); +} + +void ImplSalYieldMutexRelease() +{ + AquaSalInstance* pInst = (AquaSalInstance*) GetSalData()->mpFirstInstance; + if ( pInst ) + { + //GdiFlush(); + pInst->mpSalYieldMutex->release(); + } } // ======================================================================= SalInstance* CreateSalInstance() { - SalData* pSalData = GetSalData(); - SalInstance* pInst = new SalInstance; + SalData* pSalData = GetSalData(); + AquaSalInstance* pInst = new AquaSalInstance; + + EventLoopTimerUPP eventLoopTimer = NewEventLoopTimerUPP(AquaSalInstance::TimerEventHandler); + OSStatus rc = InstallEventLoopTimer(GetMainEventLoop(), 1, 0, eventLoopTimer, pInst, &pInst->mEventLoopTimerRef); + + // init instance (only one instance in this version !!!) + pSalData->mpFirstInstance = pInst; - // init instance (only one instance in this version !!!) - pSalData->mpFirstInstance = pInst; - - return pInst; + return pInst; } // ----------------------------------------------------------------------- @@ -265,34 +302,66 @@ // ----------------------------------------------------------------------- -SalInstance::SalInstance() +AquaSalInstance::AquaSalInstance() { - maInstData.mpFilterCallback = NULL; - maInstData.mpFilterInst = NULL; - maInstData.mpSalYieldMutex = new SalYieldMutex; - maInstData.mpSalYieldMutex->acquire(); + mpFilterCallback = NULL; + mpFilterInst = NULL; + mpSalYieldMutex = new SalYieldMutex; + mEventLoopTimerRef = NULL; + mbForceDispatchPaintEvents = false; + mpSalYieldMutex->acquire(); } // ----------------------------------------------------------------------- -SalInstance::~SalInstance() +AquaSalInstance::~AquaSalInstance() { - maInstData.mpSalYieldMutex->release(); - delete maInstData.mpSalYieldMutex; + mpSalYieldMutex->release(); + delete mpSalYieldMutex; } // ----------------------------------------------------------------------- -vos::IMutex* SalInstance::GetYieldMutex() +void AquaSalInstance::TimerEventHandler(EventLoopTimerRef inTimer, void* pData) { - return maInstData.mpSalYieldMutex; + AquaSalInstance* pInst = reinterpret_cast(pData); + + if (pInst->mbForceDispatchPaintEvents) + { + ULONG nCount = 0; + + // Release all locks so that we don't deadlock when we pull pending + // events from the event queue + nCount = pInst->ReleaseYieldMutex(); + + EventRef theEvent; + EventTargetRef theTarget = GetEventDispatcherTarget(); + + if (ReceiveNextEvent(1, &cOOoSalTimerEvent, 0, true, &theEvent) == noErr) + { + SendEventToEventTarget(theEvent, theTarget); + ReleaseEvent(theEvent); + } + + // Reset all locks + pInst->AcquireYieldMutex(nCount); + + SetEventLoopTimerNextFireTime(inTimer, 1); // restart timer + } } // ----------------------------------------------------------------------- -ULONG SalInstance::ReleaseYieldMutex() +vos::IMutex* AquaSalInstance::GetYieldMutex() { - SalYieldMutex* pYieldMutex = maInstData.mpSalYieldMutex; + return mpSalYieldMutex; +} + +// ----------------------------------------------------------------------- + +ULONG AquaSalInstance::ReleaseYieldMutex() +{ + SalYieldMutex* pYieldMutex = mpSalYieldMutex; if ( pYieldMutex->GetThreadId() == NAMESPACE_VOS(OThread)::getCurrentIdentifier() ) { @@ -312,9 +381,9 @@ // ----------------------------------------------------------------------- -void SalInstance::AcquireYieldMutex( ULONG nCount ) +void AquaSalInstance::AcquireYieldMutex( ULONG nCount ) { - SalYieldMutex* pYieldMutex = maInstData.mpSalYieldMutex; + SalYieldMutex* pYieldMutex = mpSalYieldMutex; while ( nCount ) { pYieldMutex->acquire(); @@ -324,67 +393,89 @@ // ----------------------------------------------------------------------- -void SalInstance::Yield( BOOL bWait ) +void AquaSalInstance::StartForceDispatchingPaintEvents() +{ + SetEventLoopTimerNextFireTime(mEventLoopTimerRef, 1); + mbForceDispatchPaintEvents = true; +} + +void AquaSalInstance::StopForceDispatchingPaintEvents() +{ + mbForceDispatchPaintEvents = false; +} + +void AquaSalInstance::Yield( bool bWait, bool bHandleAllCurrentEvents ) { - ULONG nCount = 0; + ULONG nCount = 0; - // Release all locks so that we don't deadlock when we pull pending - // events from the event queue - nCount = ReleaseYieldMutex(); + // Release all locks so that we don't deadlock when we pull pending + // events from the event queue + nCount = ReleaseYieldMutex(); - // Pull pending events from the event queue and dispatch them. - VCLApplication_Run( bWait ); + EventRef theEvent; + EventTargetRef theTarget = GetEventDispatcherTarget(); + EventTimeout timeout = bWait ? kEventDurationForever : 0; + + if (ReceiveNextEvent(0, NULL, timeout, true, &theEvent) == noErr) + { + //ImplSalYieldMutexAcquire(); + SendEventToEventTarget(theEvent, theTarget); + //ImplSalYieldMutexRelease(); + ReleaseEvent(theEvent); + } // Reset all locks - AcquireYieldMutex( nCount ); + AcquireYieldMutex( nCount ); } // ----------------------------------------------------------------------- -BOOL SalInstance::AnyInput( USHORT nType ) +bool AquaSalInstance::AnyInput( USHORT nType ) { return FALSE; } // ----------------------------------------------------------------------- -SalFrame* SalInstance::CreateChildFrame( SystemParentData* pSystemParentData, ULONG nSalFrameStyle ) +SalFrame* AquaSalInstance::CreateChildFrame( SystemParentData* pSystemParentData, ULONG nSalFrameStyle ) { return NULL; } // ----------------------------------------------------------------------- -SalFrame* SalInstance::CreateFrame( SalFrame* pParent, ULONG nSalFrameStyle ) +SalFrame* AquaSalInstance::CreateFrame( SalFrame* pParent, ULONG nSalFrameStyle ) { - SalFrame *pFrame = new SalFrame; - - pFrame->maFrameData.mpParent = pParent; + SalFrame* pFrame = NULL; - // Create the native window - pFrame->maFrameData.mhWnd = VCLWindow_New( nSalFrameStyle, NULL, - pFrame, &(pFrame->maFrameData) ); - - return pFrame; + try + { + pFrame = new AquaSalFrame(pParent, nSalFrameStyle, this); + } + catch(runtime_error&) + { + // frame creation failed + } + return pFrame; } // ----------------------------------------------------------------------- -void SalInstance::DestroyFrame( SalFrame* pFrame ) +void AquaSalInstance::DestroyFrame( SalFrame* pFrame ) { delete pFrame; } // ----------------------------------------------------------------------- -SalObject* SalInstance::CreateObject( SalFrame* pParent ) +SalObject* AquaSalInstance::CreateObject( SalFrame* pParent, SystemWindowData* pWindowData ) { - SalObject *pObject = NULL; + AquaSalObject *pObject = NULL; if ( pParent ) { - pObject = new SalObject; - pObject->maObjectData.mpFrame = pParent; + pObject = new AquaSalObject(); + pObject->mpFrame = (AquaSalFrame*)pParent; } return pObject; @@ -392,116 +483,164 @@ // ----------------------------------------------------------------------- -void SalInstance::DestroyObject( SalObject* pObject ) +void AquaSalInstance::DestroyObject( SalObject* pObject ) { delete ( pObject ); } // ----------------------------------------------------------------------- -SalVirtualDevice* SalInstance::CreateVirtualDevice( SalGraphics* pGraphics, - long nDX, long nDY, USHORT nBitCount ) +SalPrinter* AquaSalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter ) { - SalVirtualDevice *pVirDev = new SalVirtualDevice; + return NULL; +} - // Cache values for when SalVirtualDevice::GetGraphics() is invoked - pVirDev->maVirDevData.mnBitCount = nBitCount; - pVirDev->maVirDevData.mnWidth = nDX; - pVirDev->maVirDevData.mnHeight = nDY; +// ----------------------------------------------------------------------- - return pVirDev; +void AquaSalInstance::DestroyPrinter( SalPrinter* pPrinter ) +{ } // ----------------------------------------------------------------------- -void SalInstance::DestroyVirtualDevice( SalVirtualDevice* pDevice ) +void AquaSalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList ) { - delete pDevice; } // ----------------------------------------------------------------------- -SalPrinter* SalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter ) +void AquaSalInstance::GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) +{ +} + +// ----------------------------------------------------------------------- + +void AquaSalInstance::DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ) +{ +} + +// ----------------------------------------------------------------------- + +XubString AquaSalInstance::GetDefaultPrinter() +{ + return XubString(); +} + +// ----------------------------------------------------------------------- + +SalInfoPrinter* AquaSalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, + ImplJobSetup* pSetupData ) { return NULL; } // ----------------------------------------------------------------------- -void SalInstance::DestroyPrinter( SalPrinter* pPrinter ) +void AquaSalInstance::DestroyInfoPrinter( SalInfoPrinter* pPrinter ) { } // ----------------------------------------------------------------------- -void SalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList ) +SalSystem* AquaSalInstance::CreateSystem() { + return new AquaSalSystem(); } // ----------------------------------------------------------------------- -void SalInstance::GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) +void AquaSalInstance::DestroySystem( SalSystem* pSystem ) { + delete pSystem; } // ----------------------------------------------------------------------- -void SalInstance::DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ) +void AquaSalInstance::SetEventCallback( void* pInstance, bool(*pCallback)(void*,void*,int) ) { } // ----------------------------------------------------------------------- -XubString SalInstance::GetDefaultPrinter() +void AquaSalInstance::SetErrorEventCallback( void* pInstance, bool(*pCallback)(void*,void*,int) ) { - return XubString(); } // ----------------------------------------------------------------------- -SalInfoPrinter* SalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, - ImplJobSetup* pSetupData ) +void* AquaSalInstance::GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ) { - return NULL; + rReturnedBytes = 1; + rReturnedType = AsciiCString; + return (void*)""; } // ----------------------------------------------------------------------- -void SalInstance::DestroyInfoPrinter( SalInfoPrinter* pPrinter ) +SalSound* AquaSalInstance::CreateSalSound() { + return new AquaSalSound(); } // ----------------------------------------------------------------------- -SalSystem* SalInstance::CreateSystem() +SalTimer* AquaSalInstance::CreateSalTimer() { - return new SalSystem(); + return new AquaSalTimer(); } // ----------------------------------------------------------------------- -void SalInstance::DestroySystem( SalSystem* pSystem ) +SalOpenGL* AquaSalInstance::CreateSalOpenGL( SalGraphics* pGraphics ) { - delete pSystem; + return new AquaSalOpenGL( pGraphics ); } // ----------------------------------------------------------------------- -void SalInstance::SetEventCallback( void* pInstance, bool(*pCallback)(void*,void*,int) ) +SalSystem* AquaSalInstance::CreateSalSystem() { + return new AquaSalSystem(); } // ----------------------------------------------------------------------- -void SalInstance::SetErrorEventCallback( void* pInstance, bool(*pCallback)(void*,void*,int) ) +SalBitmap* AquaSalInstance::CreateSalBitmap() { + return new AquaSalBitmap(); } // ----------------------------------------------------------------------- -void* SalInstance::GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ) +SalSession* AquaSalInstance::CreateSalSession() { - rReturnedBytes = 1; - rReturnedType = AsciiCString; - return ""; + return NULL; } + +// ----------------------------------------------------------------------- + +class MacImeStatus : public SalI18NImeStatus +{ +public: + MacImeStatus() {} + virtual ~MacImeStatus() {} + + // asks whether there is a status window available + // to toggle into menubar + virtual bool canToggle() { return false; } + virtual void toggle() {} +}; + +// ----------------------------------------------------------------------- + +SalI18NImeStatus* AquaSalInstance::CreateI18NImeStatus() +{ + return new MacImeStatus(); +} + +////////////////////////////////////////////////////////////// +void VCLApplication_Run( BOOL bWait ) +{ + RunApplicationEventLoop(); +} + diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/app/salmain.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/app/salmain.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/app/salmain.cxx 2006-09-17 13:42:29.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/app/salmain.cxx 2006-10-14 15:27:58.000000000 +0200 @@ -36,10 +36,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" +#include + #include #ifndef _SAL_MAIN_H_ -#include "sal/main.h" +#include #endif #ifndef _SV_SALINST_HXX diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/app/salsound.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/app/salsound.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/app/salsound.cxx 2006-09-17 13:42:43.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/app/salsound.cxx 2006-10-14 15:28:13.000000000 +0200 @@ -36,19 +36,19 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#ifndef _SV_SALSOUND_HXX -#include +#ifndef _SV_SALSOUND_H +#include #endif // ======================================================================== // Initialize static data members -ULONG SalSound::mnSoundState = SOUND_STATE_UNLOADED; +ULONG AquaSalSound::mnSoundState = SOUND_STATE_UNLOADED; // ======================================================================== -SalSound::SalSound() : +AquaSalSound::AquaSalSound() : mpProc ( NULL ), mbLoop ( FALSE ), mbPaused ( FALSE ) @@ -57,52 +57,85 @@ // ------------------------------------------------------------------------ -SalSound::~SalSound() +AquaSalSound::~AquaSalSound() { Stop(); } // ------------------------------------------------------------------------ -BOOL SalSound::Create() -{ - return FALSE; -} +//BOOL AquaSalSound::Create() +//{ +// return FALSE; +//} // ------------------------------------------------------------------------ -void SalSound::Release() +void AquaSalSound::Release() { } // ------------------------------------------------------------------------ -BOOL SalSound::Init( SalFrame* pFrame, const XubString& rSoundName, ULONG& rSoundLen ) +bool AquaSalSound::Init( /*SalFrame* pFrame,*/ const String& rSoundName, ULONG& rSoundLen ) { return FALSE; } // ------------------------------------------------------------------------ -BOOL SalSound::Init( SalFrame* pFrame, const BYTE* pSound, ULONG nDataLen, ULONG& rSoundLen ) +//BOOL AquaSalSound::Init( SalFrame* pFrame, const BYTE* pSound, ULONG nDataLen, ULONG& rSoundLen ) +//{ +// return FALSE; +//} + +// ------------------------------------------------------------------------ + +void AquaSalSound::Play( ULONG nStartTime, ULONG nPlayLen, bool bLoop ) { - return FALSE; } // ------------------------------------------------------------------------ -void SalSound::Play( ULONG nStartTime, ULONG nPlayLen, BOOL bLoop ) +void AquaSalSound::Stop() { } // ------------------------------------------------------------------------ -void SalSound::Stop() +void AquaSalSound::Pause() { } -// ------------------------------------------------------------------------ -void SalSound::Pause() + + + + + + + +bool AquaSalSound::IsValid() +{ + return false; +} + +void AquaSalSound::Continue() +{ + +} + +bool AquaSalSound::IsLoopMode() const +{ + return false; +} + +bool AquaSalSound::IsPlaying() const +{ + return false; +} + +bool AquaSalSound::IsPaused() const { + return false; } diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/app/salsys.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/app/salsys.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/app/salsys.cxx 2006-09-17 13:42:57.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/app/salsys.cxx 2006-10-14 15:28:40.000000000 +0200 @@ -39,33 +39,90 @@ #ifndef _SV_SALSYS_HXX #include #endif +#ifndef _SV_SALSYS_H +#include +#endif +#include +#include +#include // ======================================================================= -SalSystem::SalSystem() +//AquaSalSystem::AquaSalSystem() +//{ +//} + +// ----------------------------------------------------------------------- + +AquaSalSystem::~AquaSalSystem() { } // ----------------------------------------------------------------------- -SalSystem::~SalSystem() +//bool AquaSalSystem::StartProcess( SalFrame* pFrame, +// const XubString& rFileName, +// const XubString& rParam, +// const XubString& rWorkDir ) +//{ +// return FALSE; +//} + +// ----------------------------------------------------------------------- + +//BOOL AquaSalSystem::AddRecentDoc( SalFrame*, const XubString& rFileName ) +//{ +// return FALSE; +//} + +unsigned int AquaSalSystem::GetDisplayScreenCount() { +/* + CGDirectDisplayID displays[64]; // 64 displays are enough for everyone + CGDisplayCount displayCount; + if( noErr == CGGetActiveDisplayList( 64, displays, &displayCount ) ) + return displayCount; +*/ + return 1; } -// ----------------------------------------------------------------------- +bool AquaSalSystem::IsMultiDisplay() +{ + /* FIXME: add support for multiple displays. */ + return false; +} -BOOL SalSystem::StartProcess( SalFrame* pFrame, - const XubString& rFileName, - const XubString& rParam, - const XubString& rWorkDir ) +unsigned int AquaSalSystem::GetDefaultDisplayNumber() { - return FALSE; + return 0; } -// ----------------------------------------------------------------------- +Rectangle AquaSalSystem::GetDisplayScreenPosSizePixel( unsigned int nScreen ) +{ + CGRect aRect( CGDisplayBounds ( CGMainDisplayID() ) ); + Rectangle aRet( aRect.origin.x, aRect.origin.y, aRect.origin.x + aRect.size.width, aRect.origin.y + aRect.size.height ); + fprintf(stderr,"AquaSalSystem::GetDisplayScreenPosSizePixel(%d) (%d,%d,%d,%d)\n", nScreen, aRet.nLeft, aRet.nTop, aRet.nRight, aRet.nBottom ); + return aRet; +} + +Rectangle AquaSalSystem::GetDisplayWorkAreaPosSizePixel( unsigned int nScreen ) +{ + return Rectangle(); +} + +int AquaSalSystem::ShowNativeDialog( const String& rTitle, + const String& rMessage, + const std::list< String >& rButtons, + int nDefButton ) +{ + return 0; +} -BOOL SalSystem::AddRecentDoc( SalFrame*, const XubString& rFileName ) +int AquaSalSystem::ShowNativeMessageBox( const String& rTitle, + const String& rMessage, + int nButtonCombination, + int nDefaultButton) { - return FALSE; + return 0; } diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/app/saltimer.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/app/saltimer.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/app/saltimer.cxx 2006-09-17 13:43:11.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/app/saltimer.cxx 2006-10-14 15:28:53.000000000 +0200 @@ -36,34 +36,122 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#ifndef _SV_SALTIMER_HXX -#include +#ifndef _SV_SALTIMER_H +#include #endif #ifndef _SV_SALDATA_HXX #include #endif -#ifndef _SV_VCLEVENT_H -#include +#ifndef _SV_SALFRAME_H +#include #endif // ======================================================================= -void SalTimer::Start( ULONG nMS ) + +#define USEMAINTHREAD 1 + +void AquaSalTimerProc ( TMTaskPtr tmTaskPtr ) { - VCLEvent_StartPeriodicEvents( nMS ); -} + ImplSVData* pSVData = ImplGetSVData(); + + AquaSalTimer *pSalTimer = (AquaSalTimer*) pSVData->mpSalTimer; + if( pSalTimer ) + { +#ifdef USEMAINTHREAD + // send event to main thread + SalData* pSalData = GetSalData(); + AquaSalFrame *pFrame = dynamic_cast(pSalData->mpFirstFrame); + + if( pFrame ) + pFrame->PostTimerEvent( pSalTimer ); + // fire again using current timeout as this is a single shot timer + pSalTimer->ReStart(); +#else + // call back directly from timer thread + if( ImplSalYieldMutexTryToAcquire() ) + { + pSalTimer->CallCallback(); + ImplSalYieldMutexRelease(); + + // fire again using current timeout as this is a single shot timer + pSalTimer->ReStart(); + } + else + { + // could not acquire solar mutex, so + // fire again with a short delay (10ms) + //fprintf(stderr, "TIMER: solar mutex not free\n"); + pSalTimer->ReStart( 10 ); + } + +#endif + } +} // ----------------------------------------------------------------------- -void SalTimer::Stop() +AquaSalTimer::AquaSalTimer( ) { - VCLEvent_StopPeriodicEvents(); + mbInstalled = FALSE; + mMS = 0; + mTask.tmAddr = NewTimerUPP( AquaSalTimerProc ); +} + +AquaSalTimer::~AquaSalTimer() +{ + if( mbInstalled ) + RemoveTimeTask( (QElemPtr) &mTask ); + DisposeTimerUPP( mTask.tmAddr ); } // ----------------------------------------------------------------------- -void SalTimer::SetCallback( SALTIMERPROC pProc ) +void AquaSalTimer::Start( ULONG nMS ) { - SalData* pSalData = GetSalData(); - pSalData->mpTimerProc = pProc; + // cancel current timer + if( mbInstalled ) + RemoveTimeTask( (QElemPtr) &mTask ); + + // store new timeout + mMS = nMS; + + // install the timer task + mbInstalled = InstallTask(); + + // fire + if( mbInstalled ) + PrimeTimeTask( (QElemPtr) &mTask, mMS ); } + +void AquaSalTimer::ReStart( ULONG nMS ) +{ + if( mbInstalled ) + // use current timeout if nMS == 0 + PrimeTimeTask( (QElemPtr) &mTask, nMS ? nMS : mMS ); +} + +void AquaSalTimer::Stop() +{ + if( mbInstalled ) + { + RemoveTimeTask( (QElemPtr) &mTask ); + mbInstalled = FALSE; + } +} + +BOOL AquaSalTimer::InstallTask() +{ + // install the timer task + mTask.tmWakeUp = 0; + mTask.tmCount = 0; + if( InstallTimeTask( (QElemPtr) &mTask ) == noErr ) + return TRUE; + else + { + fprintf(stderr, "Could not install timer task!\n"); + return FALSE; + } +} + +// ----------------------------------------------------------------------- diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/makefile.mk ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/makefile.mk --- ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/makefile.mk 2005-09-09 12:40:51.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/makefile.mk 2006-08-21 17:21:41.000000000 +0200 @@ -60,10 +60,11 @@ $(SLO)$/salcolorutils.obj \ $(SLO)$/salpixmaputils.obj \ $(SLO)$/salgdiutils.obj \ + $(SLO)$/salnativewidgets.obj \ $(SLO)$/salatsuifontutils.obj \ + $(SLO)$/salatslayout.obj \ $(SLO)$/salfontutils.obj \ $(SLO)$/salgdi.obj \ - $(SLO)$/VCLGraphics.obj \ $(SLO)$/salvd.obj \ $(SLO)$/salprn.obj \ $(SLO)$/salbmp.obj \ diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salatslayout.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salatslayout.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salatslayout.cxx 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salatslayout.cxx 2006-08-29 13:34:21.000000000 +0200 @@ -0,0 +1,618 @@ +/************************************************************************* +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile$ +* +* $Revision$ +* +* last change: $Author$ $Date$ +* +* 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 +* +************************************************************************/ + +#ifndef _SV_SALGDI_HXX +#include +#endif +#ifndef _SV_SALDATA_HXX +#include +#endif +#ifndef _SV_SALGDI_H +#include +#endif +//#ifndef _SV_SALGDIUTILS_HXX +//#include +//#endif + +#ifndef _SV_SALLAYOUT_HXX +#include +#endif + +#include +#include +#include +#include + +inline int Float32ToInt( Float32 f ) { return (int)(f+0.5); } + +// ======================================================================= + +class ATSLayout : public SalLayout +{ +public: + ATSLayout( AquaSalGraphics *pGraphics ); + ~ATSLayout(); + + virtual bool LayoutText( ImplLayoutArgs& ); + virtual void AdjustLayout( ImplLayoutArgs& ); + virtual void DrawText( SalGraphics& ) const; + + virtual int GetNextGlyphs( int nLen, long* pGlyphs, Point& rPos, int&, + long* pGlyphAdvances, int* pCharIndexes ) const; + + virtual long GetTextWidth() const; + virtual long FillDXArray( long* pDXArray ) const; + virtual int GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const; + virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const; + virtual bool GetGlyphOutlines( SalGraphics&, PolyPolyVector& ) const; + virtual bool GetBoundRect( SalGraphics&, Rectangle& ) const; + + // for glyph+font+script fallback + virtual void InitFont(); + virtual void MoveGlyph( int nStart, long nNewXPos ); + virtual void DropGlyph( int nStart ); + virtual void Simplify( bool bIsBase ); + +private: + AquaSalGraphics * mpGraphics; + ATSUTextLayout maATSULayout; + UniCharArrayOffset mnTextOfs; + UniCharCount mnTextLen; + int mnBaseAdv; + +private: + bool InitGIA() const; + mutable ATSUGlyphInfoArray * mpGIA; +}; + +// ======================================================================= + +ATSLayout::ATSLayout( AquaSalGraphics *pGraphics ) +: mpGraphics( pGraphics ), + maATSULayout( NULL ), + mnTextOfs( 0 ), + mnTextLen( 0 ), + mnBaseAdv( 0 ), + mpGIA( NULL ) +{ +} + +// ----------------------------------------------------------------------- + +ATSLayout::~ATSLayout() +{ + if ( maATSULayout ) + ATSUDisposeTextLayout( maATSULayout ); +} + +// ----------------------------------------------------------------------- + +bool ATSLayout::LayoutText( ImplLayoutArgs& rArgs ) +{ + if( maATSULayout ) + ATSUDisposeTextLayout( maATSULayout ); + + // At some point we actually need to do layout... +//#if 0 // why doesn't ATSUCreateTextLayoutWithTextPtr always fails with mnTextOfs!=0 ??? +#if 1 + mnTextOfs = rArgs.mnMinCharPos; + mnTextLen = rArgs.mnEndCharPos - rArgs.mnMinCharPos; + + UniCharCount nRunLength = kATSUToTextEnd; + OSStatus theErr = ATSUCreateTextLayoutWithTextPtr( rArgs.mpStr, + mnTextOfs, mnTextLen, rArgs.mnLength, 1, &nRunLength, + &mpGraphics->maATSUStyle, &maATSULayout ); +#else // workaround for problem above => expect small problems in complex text + mnTextOfs = 0; + mnTextLen = rArgs.mnEndCharPos - rArgs.mnMinCharPos; + + UniCharCount nRunLength = kATSUToTextEnd; + OSStatus theErr = ATSUCreateTextLayoutWithTextPtr( rArgs.mpStr + rArgs.mnMinCharPos, + mnTextOfs, mnTextLen, rArgs.mnLength-rArgs.mnMinCharPos, 1, &nRunLength, + &mpGraphics->maATSUStyle, &maATSULayout ); +#endif + if( theErr != noErr ) + { + fprintf( stderr, "ATSLayout::LayoutText() : " + "Unable to create ATSUI text layout! " + "nTextOfs=%d, nTextLen=%d, nParaLen=%d => err = %d\n", + mnTextOfs, mnTextLen, rArgs.mnLength, theErr ); + return false; + } + + return true; +} + +// ----------------------------------------------------------------------- + +void ATSLayout::AdjustLayout( ImplLayoutArgs& rArgs ) +{ + int nPixelWidth = rArgs.mnLayoutWidth; + if( !nPixelWidth && rArgs.mpDXArray ) { + // for now we are only interested in the layout width + // TODO: account for individual logical widths + nPixelWidth = rArgs.mpDXArray[ mnTextLen - 1 ]; + } + // return early if there is nothing to do + if( !nPixelWidth ) + return; + + ATSUAttributeTag nTags[2]; + ATSUAttributeValuePtr nVals[2]; + ByteCount nBytes[2]; + + Fixed nFixedWidth = Long2Fix( nPixelWidth ); + Fixed nFixedOne = Long2Fix( 1 ); + nTags[0] = kATSULineWidthTag; + nBytes[0] = sizeof( Fixed ); + nVals[0] = &nFixedWidth; + nTags[1] = kATSULineJustificationFactorTag; + nBytes[1] = sizeof( Fixed ); + nVals[1] = &nFixedOne; + ATSUSetLayoutControls( maATSULayout, 2, nTags, nBytes, nVals ); +} + +// ----------------------------------------------------------------------- + +void ATSLayout::DrawText( SalGraphics& rGraphics ) const +{ + if( mnTextLen <= 0 ) + return; + + Point aPos = GetDrawPosition( Point(mnBaseAdv, 0) ); + if ( mpGraphics->BeginGraphics() ) + { + ATSUAttributeTag cgTag = kATSUCGContextTag; + ByteCount cgSize = sizeof( CGContextRef ); + ATSUAttributeValuePtr cgValPtr = &(mpGraphics->mrContext); + Rect windowBounds; + + // the flipped view leads to flipped glyphs as well + // so apply another transformation that flips back and adjust y-pos accordingly + GetWindowPortBounds( mpGraphics->mrWindow, &windowBounds ); + long height = windowBounds.bottom - windowBounds.top; + CGContextTranslateCTM ( mpGraphics->mrContext, 0, height ); + CGContextScaleCTM ( mpGraphics->mrContext, 1.0, -1.0 ); + aPos.Y() = height - aPos.Y(); + + if( mpGraphics->mnATSUIRotation != 0 ) + { + Fixed theAngle = Long2Fix( mpGraphics->mnATSUIRotation ); + ATSUAttributeTag theTag = kATSULineRotationTag; + ByteCount valSize = sizeof( Fixed ); + ATSUAttributeValuePtr valPtr = &theAngle; + OSStatus theErr; + + theErr = ATSUSetLayoutControls( maATSULayout, 1, &theTag, &valSize, &valPtr ); + if( theErr != noErr ) + fprintf( stderr, "ATSLayout::DrawText(0x%X) : Unable to set layout font rotation\n", this ); + } + + // Tell ATSUI to use CoreGraphics + ATSUSetLayoutControls( maATSULayout, 1, &cgTag, &cgSize, &cgValPtr ); + + // Draw the text + if( ATSUDrawText( maATSULayout, mnTextOfs, mnTextLen, + Long2Fix(aPos.X()), Long2Fix(aPos.Y())) != noErr ) + { + fprintf( stderr, "ATSLayout::DrawText(0x%X) : ATSUDrawText failed!\n", this ); + } + + mpGraphics->EndGraphics(); + } +} + +// ----------------------------------------------------------------------- + +int ATSLayout::GetNextGlyphs( int nLen, long* pGlyphs, Point& rPos, int& nStart, + long* pGlyphAdvances, int* pCharIndexes ) const +{ + if( !InitGIA() ) + return 0; + + if( nStart < 0 ) // first glyph requested? + nStart = 0; + if( nStart >= mpGIA->numGlyphs ) // no glyph left? + return 0; + + const ATSUGlyphInfo* pG = mpGIA->glyphs + nStart; + rPos.X() = pG->screenX; + rPos.Y() = Float32ToInt( pG->deltaY ); + + int nCount = 0; + for(; ++nCount <= nLen; ++pG ) + { + *(pGlyphs++) = pG->glyphID; + if( pCharIndexes ) + *(pCharIndexes++) = pG->charIndex; + if( pGlyphAdvances ) + *(pGlyphAdvances++) = 0; // TODO + // TODO: break early if unexpected position + break; // nCount=1 because we don't know the glyph width + } + + nStart += nCount; + return nCount; +} + +// ----------------------------------------------------------------------- + +// get typographic bounds of the text +long ATSLayout::GetTextWidth() const +{ + ItemCount nBoundsCount = 0; + ATSTrapezoid aTrapez; + ATSUGetGlyphBounds( maATSULayout, 0, 0, mnTextOfs, mnTextLen, kATSUseDeviceOrigins, 1, &aTrapez, &nBoundsCount ); + if( nBoundsCount != 1 ) + return 0; + + long nWidth = Fix2Long( aTrapez.lowerRight.x - aTrapez.lowerLeft.x ); + return ( nWidth ); +} + +// ----------------------------------------------------------------------- + +long ATSLayout::FillDXArray( long* pDXArray ) const +{ + long nWidth = GetTextWidth(); + + if ( (NULL != pDXArray) && (mnTextLen > 0) ) + { + // for now we split the whole width to fake the virtual charwidths + // TODO: calculate the virtual character widths exactly + for( int i = 0; i < mnTextLen; i++ ) + pDXArray[ i ] = ((i+1) * nWidth) / mnTextLen; + } + + return( nWidth ); +} + +// ----------------------------------------------------------------------- + +int ATSLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const +{ + // TODO: accout for nCharExtra + ATSUTextMeasurement nATSUMaxWidth = Long2Fix( nMaxWidth / nFactor ); + + // TODO: massage ATSUBreakLine to like inword breaks: + // we prefer BreakInWord instead of ATSUBreakLine trying to be smart + // and moving the soft break inbetween words, as the ATSUI API says + UniCharArrayOffset nBreakPos = mnTextOfs; + OSStatus nStatus = ATSUBreakLine( maATSULayout, mnTextOfs, + nATSUMaxWidth, false, &nBreakPos ); + if( (nStatus != noErr) && (nStatus != kATSULineBreakInWord) ) + { + fprintf(stderr,"ATSUBreakLine => %d\n", nStatus); + return( STRING_LEN ); + } + + return( nBreakPos ); +} + +// ----------------------------------------------------------------------- + +void ATSLayout::GetCaretPositions( int nMaxIndex, long* pCaretXArray ) const +{ + // prepare caret array + int n; + for( n = 0; n < nMaxIndex; ++n ) + pCaretXArray[n] = -1; + + if( !InitGIA() ) + return; + + // use glyph index array to fill the caret positions + const ATSUGlyphInfo* pG = mpGIA->glyphs; + for( int i = 0; i < mpGIA->numGlyphs; ++i ) + { + n = 2 * pG->charIndex; + if( n > nMaxIndex + 1 ) + continue; + // TODO: recognize and deal with RTL glyphs + // is it one the pG->layputFlags? + bool bRTL = false; + // TODO: pCaretXArray[ n+0 ] = ???; + pCaretXArray[ n+1 ] = pG->caretX; + } + + long nXPos = 0; + for( n = 0; n < nMaxIndex; ++n ) + { + if( pCaretXArray[n] >= 0 ) + nXPos = pCaretXArray[n]; + else + pCaretXArray[n] = nXPos; + } +} + +// ----------------------------------------------------------------------- + +// get ink bounds of the text +bool ATSLayout::GetBoundRect( SalGraphics&, Rectangle& rVCLRect ) const +{ + Rect aMacRect; + ATSUMeasureTextImage( maATSULayout, + mnTextOfs, mnTextLen, 0, 0, &aMacRect ); + rVCLRect.Left() = aMacRect.left; + rVCLRect.Top() = aMacRect.top; + rVCLRect.Right() = aMacRect.right; + rVCLRect.Bottom() = aMacRect.bottom; + return true; +} + +// ----------------------------------------------------------------------- + +// initialize glyph index array +bool ATSLayout::InitGIA() const +{ + if( mpGIA ) + return true; + + // TODO: is there a good way to predict the maximum glyph count? + ByteCount nBufSize = sizeof(ATSUGlyphInfoArray); + nBufSize += 3*(mnTextLen+16) * sizeof(ATSUGlyphInfo); + char* pBuffer = new char[ nBufSize ]; + + OSStatus theErr = ATSUGetGlyphInfo( maATSULayout, + mnTextOfs, mnTextLen, &nBufSize, mpGIA ); + if( theErr == noErr ) + mpGIA = reinterpret_cast( pBuffer ); + else + { + fprintf( stderr, "ATSUGetGlyphInfo => err=%d\n", theErr); + delete[] pBuffer; + } + + return (mpGIA != NULL); +} + +// ======================================================================= + +#if 0 +// helper class to convert ATSUI outlines to VCL PolyPolygons +class PolyArgs +{ +public: + PolyArgs(); + ~PolyArgs(); + + void Init( PolyPolygon* pPolyPoly, long nXOffset, long nYOffset ); + void AddPoint( const Float32Point&, PolyFlags ); + void ClosePolygon(); + +private: + PolyPolygon* mpPolyPoly; + long mnXOffset, mnYOffset; + + Point* mpPointAry; + BYTE* mpFlagAry; + USHORT mnMaxPoints; + + USHORT mnPointCount; + USHORT mnPolyCount; + bool mbHasOffline; +}; + +// ----------------------------------------------------------------------- + +PolyArgs::PolyArgs() +: mpPolyPoly(NULL), + mnPointCount(0), + mnPolyCount(0), + mbHasOffline(false) +{ + mnMaxPoints = 256; + mpPointAry = new Point[ mnMaxPoints ]; + mpFlagAry = new BYTE [ mnMaxPoints ]; +} + +// ----------------------------------------------------------------------- + +PolyArgs::~PolyArgs() +{ + delete[] mpFlagAry; + delete[] mpPointAry; +} + +// ----------------------------------------------------------------------- + +void PolyArgs::Init( PolyPolygon* pPolyPoly, long nXOffset, long nYOffset ) +{ + mnXOffset = nXOffset; + mnYOffset = nYOffset; + mpPolyPoly = pPolyPoly; + + mpPolyPoly->Clear(); + mnPointCount = 0; + mnPolyCount = 0; +} + +// ----------------------------------------------------------------------- + +void PolyArgs::AddPoint( const Float32Point& rPoint, PolyFlags eFlags ) +{ + if( mnPointCount >= mnMaxPoints ) + { + // resize if needed (TODO: use STL?) + mnMaxPoints *= 4; + Point* mpNewPoints = new Point[ mnMaxPoints ]; + BYTE* mpNewFlags = new BYTE[ mnMaxPoints ]; + for( int i = 0; i < mnPointCount; ++i ) + { + mpNewPoints[ i ] = mpPointAry[ i ]; + mpNewFlags[ i ] = mpFlagAry[ i ]; + } + delete[] mpFlagAry; + delete[] mpPointAry; + mpPointAry = mpNewPoints; + mpFlagAry = mpNewFlags; + } + + // convert to pixels and add startpoint offset + int nXPos = Float32ToInt( rPoint.x ); + int nYPos = Float32ToInt( rPoint.y ); + mpPointAry[ mnPointCount ] = Point( nXPos + mnXOffset, nYPos + mnYOffset ); + // set point flags + mpFlagAry[ mnPointCount++ ]= eFlags; + mbHasOffline |= (eFlags != POLY_NORMAL); +} + +// ----------------------------------------------------------------------- + +void PolyArgs::ClosePolygon() +{ + if( !mnPolyCount++ ) + return; + + // append finished polygon + Polygon aPoly( mnPointCount, mpPointAry, (mbHasOffline ? mpFlagAry : NULL) ); + mpPolyPoly->Insert( aPoly ); + + // prepare for new polygon + mnPointCount = 0; + mbHasOffline = false; +} +#endif +// ======================================================================= +#if 0 +// helper functions for ATSLayout::GetGlyphOutlines() +OSStatus MyATSCubicMoveToCallback( const Float32Point *pt1, + void* pData ) +{ + PolyArgs& rA = *reinterpret_cast(pData); + // MoveTo implies a new polygon => finish old polygon first + rA.ClosePolygon(); + rA.AddPoint( *pt1, POLY_NORMAL ); +} + +OSStatus MyATSCubicLineToCallback( const Float32Point* pt1, + void* pData ) +{ + PolyArgs& rA = *reinterpret_cast(pData); + rA.AddPoint( *pt1, POLY_NORMAL ); +} + +OSStatus MyATSCubicCurveToCallback( const Float32Point* pt1, + const Float32Point* pt2, const Float32Point* pt3, void* pData ) +{ + PolyArgs& rA = *reinterpret_cast(pData); + rA.AddPoint( *pt1, POLY_CONTROL ); + rA.AddPoint( *pt2, POLY_CONTROL ); + rA.AddPoint( *pt3, POLY_NORMAL ); +} + +OSStatus MyATSCubicClosePathCallback ( + void *pData ) +{ + PolyArgs& rA = *reinterpret_cast(pData); + rA.ClosePolygon(); +} +#endif +// ----------------------------------------------------------------------- + +bool ATSLayout::GetGlyphOutlines( SalGraphics&, PolyPolyVector& rPPV ) const +{ + return false; + /* + rPPV.clear(); + + if( !InitGIA() ) + return false; + + rPPV.resize( mpGIA->numGlyphs ); + PolyArgs aPolyArgs; + const ATSUGlyphInfo* pG = mpGIA->glyphs; + for( int i = 0; i < mpGIA->numGlyphs; ++i, ++pG ) + { + // convert glyphid at glyphpos to outline + GlyphID nGlyphId = pG->glyphID; + long nDeltaY = Float32ToInt( pG->deltaY ); + aPolyArgs.Init( &rPPV[i], pG->screenX, nDeltaY ); + OSStatus nStatus, nCBStatus; + nStatus = ATSUGlyphGetCubicPaths( + mpGraphics->maATSUStyle, nGlyphId, + MyATSCubicMoveToCallback, MyATSCubicLineToCallback, + MyATSCubicCurveToCallback, MyATSCubicClosePathCallback, + &aPolyArgs, &nCBStatus ); + + if( (nStatus != noErr) && (nCBStatus != noErr) ) + { + fprintf( stderr,"ATSUCallback = %d,%d\n", nStatus, nCBStatus ); + rPPV.resize( i ); + break; + } + } + + return true; + */ +} + +// ----------------------------------------------------------------------- + +void ATSLayout::InitFont() +{ + // TODO to allow glyph fallback +} + +// ----------------------------------------------------------------------- + +void ATSLayout::MoveGlyph( int nStart, long nNewXPos ) +{ + // TODO to allow glyph fallback +} + +// ----------------------------------------------------------------------- + +void ATSLayout::DropGlyph( int nStart ) +{ + // TODO to allow glyph fallback +} + +// ----------------------------------------------------------------------- + +void ATSLayout::Simplify( bool bIsBase ) +{ + // TODO to allow glyph fallback +} + +// ======================================================================= + +SalLayout* AquaSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel ) +{ + ATSLayout* pATSLayout = new ATSLayout( this ); + return( pATSLayout ); +} + +// ======================================================================= diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salatsuifontutils.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salatsuifontutils.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salatsuifontutils.cxx 2006-09-17 13:43:25.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salatsuifontutils.cxx 2006-10-13 23:55:01.000000000 +0200 @@ -152,9 +152,9 @@ ByteCount nFontFamilyNameLength = 0; FontNamesPtr pFontFamilyNames = NULL; FontNameCode nFontFamilyNameCode = kFontFamilyName; - FontLanguageCode nFontFamilyLanguageCode = kFontNoLanguage; - FontPlatformCode nFontFamilyPlatformCode = kFontNoPlatform; - FontScriptCode nFontFamilyScriptCode = kFontNoScript; + FontLanguageCode nFontFamilyLanguageCode = kFontNoLanguageCode; + FontPlatformCode nFontFamilyPlatformCode = kFontNoPlatformCode; + FontScriptCode nFontFamilyScriptCode = kFontNoScriptCode; ItemCount nFontFamilyIndex = 0; OSStatus nStatus = noErr; MacOSPtr pFontFamilyName = NULL; @@ -1056,9 +1056,9 @@ { FontNameEncodingRecord aBestFontNameEncoding; FontNameCode *pFontNameCode = NULL; - FontPlatformCode nFontNamePlatformCode = kFontNoPlatform; - FontScriptCode nFontNameScriptCode = kFontNoScript; - FontLanguageCode nFontNameLanguageCode = kFontNoLanguage; + FontPlatformCode nFontNamePlatformCode = kFontNoPlatformCode; + FontScriptCode nFontNameScriptCode = kFontNoScriptCode; + FontLanguageCode nFontNameLanguageCode = kFontNoLanguageCode; ItemCount nBestFontIndex = ULONG_MAX; ItemCount nNextFontIndex = 0; ItemCount nFontNamesCount = 0; diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salbmp.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salbmp.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salbmp.cxx 2006-09-17 13:43:39.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salbmp.cxx 2006-10-14 15:26:33.000000000 +0200 @@ -36,456 +36,734 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#ifndef _SV_SALBMP_HXX - #include +#ifndef _TOOLS_COLOR_HXX +#include #endif +#ifndef _SV_SALBMP_H +#include "salbmp.h" +#endif + +#ifndef _SV_SALBTYPE_HXX +#include "salbtype.hxx" +#endif + +#include "salinst.h" + // ======================================================================= +static bool isValidBitCount( sal_uInt16 nBitCount ) +{ + return (nBitCount == 1) || (nBitCount == 4) || (nBitCount == 8) || (nBitCount == 16) || (nBitCount == 24) || (nBitCount == 32); +} + // ======================================================================= -SalBitmap::SalBitmap() : - mpVirDev( 0 ), - mnBitCount( 0 ) +AquaSalBitmap::AquaSalBitmap() +: mxGraphicContext( 0 ) +, mnBits(0) +, mnWidth(0) +, mnHeight(0) +, mnBytesPerRow(0) { } // ------------------------------------------------------------------ -SalBitmap::~SalBitmap() +AquaSalBitmap::~AquaSalBitmap() { Destroy(); } // ------------------------------------------------------------------ -BOOL SalBitmap::Create( const Size& rSize, - USHORT nBitCount, - const BitmapPalette& rBitmapPalette - ) +bool AquaSalBitmap::Create( CGContextRef xContext, int nX, int nY, int nWidth, int nHeight ) +{ + return Create( CGBitmapContextGetWidth( xContext ), CGBitmapContextGetHeight( xContext ), + CGBitmapContextGetBitsPerPixel( xContext ), CGBitmapContextGetBytesPerRow( xContext ), + static_cast< sal_uInt8* >( CGBitmapContextGetData( xContext ) ), + nX, nY, nWidth, nHeight ); +} + +/** creates an AquaSalBitmap from a rectangle inside a memory bitmap (only 16 und 32 bit supported!) + NOTE: This code flips the data upside down so sources must come from AQUA directly +*/ +bool AquaSalBitmap::Create( sal_uInt32 nWidth, sal_uInt32 nHeight, sal_uInt16 nBits, sal_uInt32 nBytesPerRow, sal_uInt8* pBuffer, sal_uInt32 nX, sal_uInt32 nY, sal_uInt32 nDX, sal_uInt32 nDY ) { - ImplSVData *pSVData = ImplGetSVData(); - BOOL bSalBitmapCreated = FALSE; + if( (nBits != 16) && (nBits != 32) || !nWidth || !nHeight ) + return false; - if ( pSVData != NULL ) + mnBits = nBits; + mnWidth = nDX; + mnHeight = nDY; + + if( AllocateUserData() ) { - const long nHeight = rSize.Height(); - const long nWidth = rSize.Width(); - - Destroy(); + sal_uInt8* pDest = maUserBuffer.get(); + + sal_uInt8* pSource = pBuffer; + if( nX ) + pSource += nX << (( nBits == 32 ) ? 2 : 1); - if ( ( nHeight > 0 ) && ( nWidth > 0 ) ) + nY = nHeight - nY - nDY; + pSource += nBytesPerRow * nY; + + sal_uInt32 y = nDY; + while( y-- ) { - // Create a SalVirtualDevice - - mpVirDev - = pSVData->mpDefInst->CreateVirtualDevice( NULL, - nWidth, - nHeight, - nBitCount - ); + memcpy( pDest, pSource, mnBytesPerRow ); + pDest += mnBytesPerRow; + pSource += nBytesPerRow; + } + return true; + } + return false; +} + +// ------------------------------------------------------------------ + +bool AquaSalBitmap::Create( CGImageRef& xImage ) +{ + mnBits = CGImageGetBitsPerPixel( xImage ); + if( (mnBits == 16) || (mnBits == 32) ) + { + mnWidth = CGImageGetWidth( xImage ); + mnHeight = CGImageGetHeight( xImage ); - if ( mpVirDev != NULL ) + if( AllocateUserData() ) + { + CreateContext(); + if( mxGraphicContext ) { - // Get the SalGraphics which contains the - // GWorld we will draw to - - SalGraphics *pGraphics = GetGraphics(); + CGContextDrawImage(mxGraphicContext, CGRectMake( 0, 0, mnWidth, mnHeight ), xImage); + return true; + } + } + } + return false; +} - if ( pGraphics != NULL ) - { - const CGrafPtr pCGraf = pGraphics->maGraphicsData.mpCGrafPort; - - if ( pCGraf != NULL ) - { - mhPixMap = GetCGrafPortPixMap( rSize, - nBitCount, - rBitmapPalette, - pCGraf - ); - - if ( ( mhPixMap != NULL ) && ( *mhPixMap != NULL ) ) - { - mnBitCount = GetPixDepth( mhPixMap); - mnSize = rSize; - - bSalBitmapCreated = TRUE; - } // if - - // Release the SalGraphics so that others can get a - // handle to it in future GetGraphics() calls - } // if - - ReleaseGraphics( pGraphics ); - } // if - } // if - } // if - } // if +// ------------------------------------------------------------------ - return bSalBitmapCreated; -} // SalBitmap::Create +bool AquaSalBitmap::Create( const Size& rSize, USHORT nBits, const BitmapPalette& rBitmapPalette ) +{ + if( !isValidBitCount( nBits ) ) + return false; + maPalette = rBitmapPalette; + mnBits = nBits; + mnWidth = rSize.Width(); + mnHeight = rSize.Height(); + return AllocateUserData(); +} // ------------------------------------------------------------------ -BOOL SalBitmap::Create( const SalBitmap& rSalBmp ) +bool AquaSalBitmap::Create( const SalBitmap& rSalBmp ) { return Create( rSalBmp, rSalBmp.GetBitCount() ); -} // SalBitmap::Create +} + +// ------------------------------------------------------------------ + +bool AquaSalBitmap::Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics ) +{ + return Create( rSalBmp, pGraphics ? pGraphics->GetBitCount() : rSalBmp.GetBitCount() ); +} // ------------------------------------------------------------------ -BOOL SalBitmap::Create( const SalBitmap& rSalBmp, - SalGraphics* pGraphics - ) +bool AquaSalBitmap::Create( const SalBitmap& rSalBmp, USHORT nNewBitCount ) { - USHORT nSalBmpBitCount = 0; - BOOL bSalBitmapCreated = FALSE; + const AquaSalBitmap& rSourceBitmap = static_cast(rSalBmp); - if ( pGraphics != NULL ) + if( isValidBitCount( nNewBitCount ) && rSourceBitmap.maUserBuffer.get() ) { - const CGrafPtr pCGraf = pGraphics->maGraphicsData.mpCGrafPort; - - if ( pCGraf != NULL ) + mnBits = nNewBitCount; + mnWidth = rSourceBitmap.mnWidth; + mnHeight = rSourceBitmap.mnHeight; + maPalette = rSourceBitmap.maPalette; + + if( AllocateUserData() ) { - mhPixMap = GetCGrafPortPixMap( rSalBmp.GetSize(), - rSalBmp.GetBitCount(), - BitmapPalette(), - pCGraf - ); - - if ( ( mhPixMap != NULL ) && ( *mhPixMap != NULL ) ) - { - nSalBmpBitCount = GetPixDepth( mhPixMap ); - } // if - } // if - } // if - - if ( nSalBmpBitCount == 0 ) + ConvertBitmapData( mnWidth, mnHeight, mnBits, mnBytesPerRow, maPalette, maUserBuffer.get(), rSourceBitmap.mnBits, rSourceBitmap.mnBytesPerRow, rSourceBitmap.maPalette, rSourceBitmap.maUserBuffer.get() ); + return true; + } + } + return false; +} + +// ------------------------------------------------------------------ + +void AquaSalBitmap::Destroy() +{ + DestroyContext(); + maUserBuffer.reset(); +} + +// ------------------------------------------------------------------ + +void AquaSalBitmap::DestroyContext() +{ + if( mxGraphicContext ) { - nSalBmpBitCount = rSalBmp.GetBitCount(); - } // if - - bSalBitmapCreated = Create( rSalBmp, nSalBmpBitCount ); + CFRelease( mxGraphicContext ); + mxGraphicContext = 0; + maContextBuffer.reset(); + } +} + +// ------------------------------------------------------------------ + +bool AquaSalBitmap::CreateContext() +{ + DestroyContext(); + + sal_uInt8* pContextBuffer = 0; + size_t bitsPerComponent = (mnBits == 16) ? 5 : 8; + sal_uInt32 nContextBytesPerRow = mnBytesPerRow; + if( (mnBits == 16) || (mnBits ==32) ) + { + // simple, no conversion needed + maContextBuffer = maUserBuffer; + } + else + { + // convert user data to 32 bit + nContextBytesPerRow = mnWidth << 2; + maContextBuffer.reset( new sal_uInt8[ mnHeight * nContextBytesPerRow ] ); + + ConvertBitmapData( mnWidth, mnHeight, + 32, nContextBytesPerRow, maPalette, maContextBuffer.get(), + mnBits, mnBytesPerRow, maPalette, maUserBuffer.get() ); + } + + CGColorSpaceRef xColorSpace( CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB) ); + mxGraphicContext = CGBitmapContextCreate( maContextBuffer.get(), mnWidth, mnHeight, bitsPerComponent, nContextBytesPerRow, xColorSpace, kCGImageAlphaNoneSkipFirst ); + CFRelease( xColorSpace ); + + if( mxGraphicContext ) + { + CGContextTranslateCTM (mxGraphicContext, 0, mnHeight); + CGContextScaleCTM (mxGraphicContext, 1.0, -1.0); + } + else + { + maContextBuffer.reset(); + } - return bSalBitmapCreated; -} // SalBitmap::Create + return mxGraphicContext != NULL; +} // ------------------------------------------------------------------ -BOOL SalBitmap::Create( const SalBitmap& rSalBmp, USHORT nNewBitCount ) +bool AquaSalBitmap::AllocateUserData() { - BOOL bSalBitmapCreated = FALSE; + Destroy(); - if ( Create( rSalBmp.mnSize, nNewBitCount, BitmapPalette() ) ) + if( mnWidth && mnHeight ) { - // Copy pixels from rSalBmp.mpVirDev to mpVirDev - - SalGraphics *pDstGraphics = GetGraphics(); + mnBytesPerRow = 0; - if ( pDstGraphics != NULL ) + switch( mnBits ) { - SalGraphics *pSrcGraphics = rSalBmp.GetGraphics(); + case 1: mnBytesPerRow = (mnWidth + 7) >> 3; break; + case 4: mnBytesPerRow = (mnWidth + 1) >> 1; break; + case 8: mnBytesPerRow = mnWidth; break; + case 16: mnBytesPerRow = mnWidth << 1; break; + case 24: mnBytesPerRow = (mnWidth << 1) + mnWidth; break; + case 32: mnBytesPerRow = mnWidth << 2; break; + default: + DBG_ERROR("vcl::AquaSalBitmap::AllocateUserData(), illegal bitcount!"); + } + } + + if( mnBytesPerRow ) + maUserBuffer.reset( new sal_uInt8[mnBytesPerRow * mnHeight] ); + + return maUserBuffer.get() != 0; +} - if ( ( pSrcGraphics != NULL ) - && ( pSrcGraphics->maGraphicsData.mpCGrafPort != NULL ) - ) - { - SalTwoRect aTwoRect; +// ------------------------------------------------------------------ - // Get size of graphics to copy from - - GetTwoRectFromSalBmp( rSalBmp, &aTwoRect ); - - // Copy bits from source graphics - - pDstGraphics->CopyBits( &aTwoRect, pSrcGraphics ); +class ImplPixelFormat +{ +protected: + sal_uInt8* pData; +public: + static ImplPixelFormat* GetFormat( sal_uInt16 nBits, const BitmapPalette& rPalette ); + + virtual void StartLine( sal_uInt8* pLine ) { pData = pLine; } + virtual void SkipPixel( sal_uInt32 nPixel ) = 0; + virtual ColorData ReadPixel() = 0; + virtual void WritePixel( ColorData nColor ) = 0; +}; - rSalBmp.ReleaseGraphics( pSrcGraphics ); +class ImplPixelFormat32 : public ImplPixelFormat +{ +public: + virtual void SkipPixel( sal_uInt32 nPixel ) + { + pData += nPixel << 2; + } + virtual ColorData ReadPixel() + { + pData++; + return RGB_COLORDATA( *pData++, *pData++, *pData++ ); + } + virtual void WritePixel( ColorData nColor ) + { + *pData++ = 0; + *pData++ = COLORDATA_RED( nColor ); + *pData++ = COLORDATA_GREEN( nColor ); + *pData++ = COLORDATA_BLUE( nColor ); + } +}; - bSalBitmapCreated = TRUE; - } // if +class ImplPixelFormat24 : public ImplPixelFormat +{ +public: + virtual void SkipPixel( sal_uInt32 nPixel ) + { + pData += (nPixel << 1) + nPixel; + } + virtual ColorData ReadPixel() + { + const ColorData c = RGB_COLORDATA( pData[2], pData[1], pData[0] ); + pData += 3; + return c; + } + virtual void WritePixel( ColorData nColor ) + { + *pData++ = COLORDATA_BLUE( nColor ); + *pData++ = COLORDATA_GREEN( nColor ); + *pData++ = COLORDATA_RED( nColor ); + } +}; - ReleaseGraphics( pDstGraphics ); - } // if - } // if +class ImplPixelFormat16 : public ImplPixelFormat +{ +protected: + sal_uInt16* pData16; +public: + + virtual void StartLine( sal_uInt8* pLine ) + { + pData16 = (sal_uInt16*)pLine; + } + virtual void SkipPixel( sal_uInt32 nPixel ) + { + pData += nPixel; + } + virtual ColorData ReadPixel() + { + const ColorData c = RGB_COLORDATA( (*pData & 0x7c00) >> 7, (*pData & 0x03e0) >> 2 , (*pData & 0x001f) << 3 ); + pData++; + return c; + } + virtual void WritePixel( ColorData nColor ) + { + *pData++ = ((COLORDATA_RED( nColor ) & 0xf8 ) << 7 ) || + ((COLORDATA_GREEN( nColor ) & 0xf8 ) << 2 ) || + ((COLORDATA_BLUE( nColor ) & 0xf8 ) >> 3 ); + } +}; - return bSalBitmapCreated; -} // SalBitmap::Create +class ImplPixelFormat8 : public ImplPixelFormat +{ +private: + const BitmapPalette& mrPalette; -// ------------------------------------------------------------------ +public: + ImplPixelFormat8( const BitmapPalette& rPalette ) + : mrPalette( rPalette ) + { + } + virtual void SkipPixel( sal_uInt32 nPixel ) + { + pData += nPixel; + } + virtual ColorData ReadPixel() + { + return mrPalette[ *pData++ ].operator Color().GetColor(); + } + virtual void WritePixel( ColorData nColor ) + { + const BitmapColor aColor( COLORDATA_RED( nColor ), COLORDATA_GREEN( nColor ), COLORDATA_BLUE( nColor ) ); + *pData++ = static_cast< sal_uInt8 >( mrPalette.GetBestIndex( aColor ) ); + } +}; -void SalBitmap::Destroy() +class ImplPixelFormat4 : public ImplPixelFormat { - ImplSVData *pSVData = ImplGetSVData(); - - if ( pSVData != NULL ) +private: + const BitmapPalette& mrPalette; + sal_uInt32 mnX; + sal_uInt32 mnShift; + +public: + ImplPixelFormat4( const BitmapPalette& rPalette ) + : mrPalette( rPalette ) { - if ( mpVirDev != NULL ) - { - pSVData->mpDefInst->DestroyVirtualDevice( mpVirDev ); - } // if - - mhPixMap = NULL; - mnSize = Size(); - mnBitCount = 0; - } // if -} // SalBitmap::Destroy + } + virtual void SkipPixel( sal_uInt32 nPixel ) + { + mnX += nPixel; + if( (nPixel & 1) ) + mnShift ^= 4; + } + virtual void StartLine( sal_uInt8* pLine ) + { + pData = pLine; + mnX = 0; + mnShift = 4; + } + virtual ColorData ReadPixel() + { + const BitmapColor& rColor = mrPalette[( pData[mnX >> 1] >> mnShift) & 0x0f]; + mnX++; + mnShift ^= 4; + return rColor.operator Color().GetColor(); + } + virtual void WritePixel( ColorData nColor ) + { + const BitmapColor aColor( COLORDATA_RED( nColor ), COLORDATA_GREEN( nColor ), COLORDATA_BLUE( nColor ) ); + pData[mnX>>1] &= (0xf0 >> mnShift); + pData[mnX>>1] |= (static_cast< sal_uInt8 >( mrPalette.GetBestIndex( aColor ) ) & 0x0f); + mnX++; + mnShift ^= 4; + } +}; -// ------------------------------------------------------------------ +class ImplPixelFormat1 : public ImplPixelFormat +{ +private: + const BitmapPalette& mrPalette; + sal_uInt32 mnX; + +public: + ImplPixelFormat1( const BitmapPalette& rPalette ) + : mrPalette( rPalette ) + { + } + virtual void SkipPixel( sal_uInt32 nPixel ) + { + mnX += nPixel; + } + virtual void StartLine( sal_uInt8* pLine ) + { + pData = pLine; + mnX = 0; + } + virtual ColorData ReadPixel() + { + const BitmapColor& rColor = mrPalette[ (pData[mnX >> 3 ] >> ( 7 - ( mnX & 7 ) )) & 1]; + mnX++; + return rColor.operator Color().GetColor(); + } + virtual void WritePixel( ColorData nColor ) + { + const BitmapColor aColor( COLORDATA_RED( nColor ), COLORDATA_GREEN( nColor ), COLORDATA_BLUE( nColor ) ); + if( mrPalette.GetBestIndex( aColor ) & 1 ) + pData[ mnX >> 3 ] |= 1 << ( 7 - ( mnX & 7 ) ); + else + pData[ mnX >> 3 ] &= ~( 1 << ( 7 - ( mnX & 7 ) ) ); + mnX++; + } +}; -BitmapBuffer* SalBitmap::AcquireBuffer( BOOL bReadOnly ) +ImplPixelFormat* ImplPixelFormat::GetFormat( sal_uInt16 nBits, const BitmapPalette& rPalette ) { - BitmapBuffer *pBuffer = NULL; + switch( nBits ) + { + case 1: return new ImplPixelFormat1( rPalette ); + case 4: return new ImplPixelFormat4( rPalette ); + case 8: return new ImplPixelFormat8( rPalette ); + case 16: return new ImplPixelFormat16; + case 24: return new ImplPixelFormat24; + case 32: return new ImplPixelFormat32; + } - if ( mpVirDev != NULL ) + return 0; +} + +void AquaSalBitmap::ConvertBitmapData( sal_uInt32 nWidth, sal_uInt32 nHeight, + sal_uInt16 nDestBits, sal_uInt32 nDestBytesPerRow, const BitmapPalette& rDestPalette, sal_uInt8* pDestData, + sal_uInt16 nSrcBits, sal_uInt32 nSrcBytesPerRow, const BitmapPalette& rSrcPalette, sal_uInt8* pSrcData ) + +{ + if( (nDestBytesPerRow == nSrcBytesPerRow) && (nDestBits == nSrcBits) && ((nSrcBits != 8) || (rDestPalette.operator==( rSrcPalette ))) ) { - pBuffer = new BitmapBuffer(); + // simple case, same format, so just copy + memcpy( pDestData, pSrcData, nHeight * nDestBytesPerRow ); + } + else + { + // TODO: this implementation is for clarety, not for speed - if ( ( pBuffer != NULL ) - && ( mhPixMap != NULL ) - && ( *mhPixMap != NULL ) - ) + ImplPixelFormat* pD = ImplPixelFormat::GetFormat( nDestBits, rDestPalette ); + ImplPixelFormat* pS = ImplPixelFormat::GetFormat( nSrcBits, rSrcPalette ); + + if( pD && pS ) { - GWorldFlags nPixMapFlags = noErr; - - nPixMapFlags = GetPixelsState( mhPixMap ); - - if ( nPixMapFlags == noErr ) + sal_uInt32 nY = nHeight; + while( nY-- ) { - if ( LockPixels( mhPixMap ) ) - { - SetBitmapBufferColorFormat( mhPixMap, pBuffer ); + pD->StartLine( pDestData ); + pS->StartLine( pSrcData ); - if ( BMP_SCANLINE_FORMAT( pBuffer->mnFormat ) ) - { - pBuffer->mnWidth = mpVirDev->maVirDevData.mnWidth; - pBuffer->mnHeight = mpVirDev->maVirDevData.mnHeight; - pBuffer->mnScanlineSize = GetPixRowBytes( mhPixMap ); - pBuffer->mpBits = (BYTE *)GetPixBaseAddr( mhPixMap ); - pBuffer->mnBitCount = GetPixDepth( mhPixMap); - - // If the pixel depth is <= 8, we need to map QD's - // internal color table to the platform independent - // BitmapPalette color table - - if ( pBuffer->mnBitCount <= kEightBitColor ) - { - CTabHandle hCTab = (**mhPixMap).pmTable; - - if ( ( hCTab != NULL ) && ( *hCTab != NULL ) ) - { - SInt8 nCTabFlags = noErr; - - nCTabFlags = HGetState( (Handle)hCTab ); - - if ( nCTabFlags == noErr ) - { - USHORT nCTabSize = 0; - USHORT nCTabIndex = 0; - BitmapPalette &rBitmapPalette = pBuffer->maPalette; - - HLock( (Handle)hCTab ); - - // Map each color in the QuickDraw color - // table to a BitmapColor - - nCTabSize = (**hCTab).ctSize + 1; - - rBitmapPalette.SetEntryCount( nCTabSize ); - - for ( nCTabIndex = 0; - nCTabIndex < nCTabSize; - nCTabIndex++ - ) - { - BitmapColor &rBitmapColor = rBitmapPalette[nCTabIndex]; - const RGBColor aRGBColor = (**hCTab).ctTable[nCTabIndex].rgb; - - RGBColor2BitmapColor( &aRGBColor, rBitmapColor ); - } // for - - HSetState( (Handle)hCTab, nCTabFlags ); - } // if - } // if - } // if - } // if - else - { - delete pBuffer; - - pBuffer = NULL; - } // else - - SetPixelsState( mhPixMap, nPixMapFlags ); - } // if - } // if - } // if - } // if + sal_uInt32 nX = nWidth; + while( nX-- ) + pD->WritePixel( pS->ReadPixel() ); + + pSrcData += nSrcBytesPerRow; + pDestData += nDestBytesPerRow; + } + } + delete pS; + delete pD; + } +} + +// ------------------------------------------------------------------ + +Size AquaSalBitmap::GetSize() const +{ + return Size( mnWidth, mnHeight ); +} + +// ------------------------------------------------------------------ + +USHORT AquaSalBitmap::GetBitCount() const +{ + return mnBits; +} + +// ------------------------------------------------------------------ + +BitmapBuffer* AquaSalBitmap::AcquireBuffer( bool bReadOnly ) +{ + BitmapBuffer* pBuffer = new BitmapBuffer; + pBuffer->mnWidth = mnWidth; + pBuffer->mnHeight = mnHeight; + pBuffer->maPalette = maPalette; + pBuffer->mnScanlineSize = mnBytesPerRow; + pBuffer->mpBits = maUserBuffer.get(); + pBuffer->mnBitCount = mnBits; + switch( mnBits ) + { + case 1: pBuffer->mnFormat = BMP_FORMAT_1BIT_MSB_PAL; break; + case 4: pBuffer->mnFormat = BMP_FORMAT_4BIT_MSN_PAL; break; + case 8: pBuffer->mnFormat = BMP_FORMAT_8BIT_PAL; break; + case 16: pBuffer->mnFormat = BMP_FORMAT_16BIT_TC_MSB_MASK; + pBuffer->maColorMask = ColorMask( k16BitRedColorMask, k16BitGreenColorMask, k16BitBlueColorMask ); + break; + case 24: pBuffer->mnFormat = BMP_FORMAT_24BIT_TC_BGR; break; + case 32: pBuffer->mnFormat = BMP_FORMAT_32BIT_TC_ARGB; + pBuffer->maColorMask = ColorMask( k32BitRedColorMask, k32BitGreenColorMask, k32BitBlueColorMask ); + break; + } return pBuffer; -} // SalBitmap::AcquireBuffer +} // ------------------------------------------------------------------ -void SalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BOOL bReadOnly ) +void AquaSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ) { - if ( mpVirDev != NULL ) +// fprintf(stderr,"AquaSalBitmap::ReleaseBuffer(%lx)\n", this); + + // invalidate graphic context if we have different data + if( !bReadOnly ) { - // Get the SalGraphics which contains the GWorld - // we used as the buffer + maPalette = pBuffer->maPalette; + if( mxGraphicContext ) + DestroyContext(); + } + + delete pBuffer; +} + +// ------------------------------------------------------------------ + +CGImageRef AquaSalBitmap::CreateCroppedImage( int nX, int nY, int nWidth, int nHeight ) +{ + CGImageRef xImage = 0; + + if( !mxGraphicContext ) + CreateContext(); - SalGraphics *pGraphics = GetGraphics(); + if( mxGraphicContext ) + xImage = CreateCroppedImage( mxGraphicContext, nX, nY, nWidth, nHeight ); + + return xImage; +} - if ( ( pGraphics != NULL ) - && ( pGraphics->maGraphicsData.mpCGrafPort != NULL ) - ) +// ------------------------------------------------------------------ + +/*static*/ CGImageRef AquaSalBitmap::CreateCroppedImage( CGContextRef xContext, int nX, int nY, int nWidth, int nHeight ) +{ + CGImageRef xImage = 0; + if( xContext ) + { + xImage = CGBitmapContextCreateImage( xContext ); + if( nX || nY || (CGImageGetWidth(xImage) != nWidth) || (CGImageGetHeight(xImage) != nHeight) ) { - // Release the SalGraphics so that others can get a - // handle to it in future calls to GetGraphics() - - ReleaseGraphics( pGraphics ); - - pGraphics = NULL; - } // if - } // if - - if ( pBuffer != NULL ) + CGImageRef myTempImage = CGImageCreateWithImageInRect( xImage, CGRectMake( nX, nY, nWidth, nHeight ) ); + CGImageRelease( xImage ); + xImage = myTempImage; + } + } + return xImage; +} + +// ------------------------------------------------------------------ + +/** TODO: Optimize me, merge the bitmap and alpha mask ourself +*/ +CGImageRef AquaSalBitmap::CreateWithMask( const AquaSalBitmap& rMask, sal_uInt32 nX, sal_uInt32 nY, sal_uInt32 nDX, sal_uInt32 nDY ) +{ + fprintf(stderr,"source: (%d,%d,%u) mask: (%d,%d,%u)\n", mnWidth, mnHeight, mnBits, rMask.mnWidth, rMask.mnHeight, rMask.mnBits ); + + CGImageRef xMaskedImage = 0; + + CGImageRef xImage( CreateCroppedImage( nX, nY, nDX, nDY ) ); + if( xImage ) { - if ( !bReadOnly ) + CGImageRef xMask = rMask.CreateMask( nX, nY, nDX, nDY ); + if( xMask ) { - if ( ( mhPixMap != NULL ) && (*mhPixMap != NULL ) ) - { - GWorldFlags nPixMapFlags = noErr; - - nPixMapFlags = GetPixelsState( mhPixMap ); + xMaskedImage = CGImageCreateWithMask( xImage, xMask ); + CFRelease( xMask ); + } + CFRelease( xImage ); + } + return xMaskedImage; +} + +// ------------------------------------------------------------------ + +/** creates an image from the given rectangle, replacing all black pixels with nMaskColor and make all other full transparent */ +CGImageRef AquaSalBitmap::CreateColorMask( int nX, int nY, int nWidth, int nHeight, SalColor nMaskColor ) const +{ + CGImageRef xMask = 0; + if( maUserBuffer.get() && ((nX + nWidth) <= mnWidth) && ((nY + nHeight) <= mnHeight) ) + { + const sal_uInt32 nDestBytesPerRow = nWidth << 2; + sal_uInt32* pMaskBuffer = static_cast( malloc( nHeight * nDestBytesPerRow ) ); + sal_uInt32* pDest = pMaskBuffer; + + ImplPixelFormat* pSourcePixels = ImplPixelFormat::GetFormat( mnBits, maPalette ); + + if( pMaskBuffer && pSourcePixels ) + { + sal_uInt32 nColor; + reinterpret_cast(&nColor)[0] = 0xff; + reinterpret_cast(&nColor)[1] = SALCOLOR_RED( nMaskColor ); + reinterpret_cast(&nColor)[2] = SALCOLOR_GREEN( nMaskColor ); + reinterpret_cast(&nColor)[3] = SALCOLOR_BLUE( nMaskColor ); + + sal_uInt8* pSource = maUserBuffer.get(); + if( nY ) + pSource += nY * mnBytesPerRow; - if ( nPixMapFlags == noErr ) + sal_uInt32 y = nHeight; + while( y-- ) + { + pSourcePixels->StartLine( pSource ); + pSourcePixels->SkipPixel(nX); + sal_uInt32 x = nWidth; + while( x-- ) { - if ( LockPixels( mhPixMap ) ) - { - if ( !!pBuffer->maPalette ) - { - CTabHandle hCTab = (**mhPixMap).pmTable; - - if ( ( hCTab != NULL ) && ( *hCTab != NULL ) ) - { - SInt8 nCTabFlags = noErr; - - nCTabFlags = HGetState( (Handle)hCTab ); - - if ( nCTabFlags == noErr ) - { - const BitmapPalette &rBitmapPalette = pBuffer->maPalette; - short nCTabSize = 0; - short nCTabMinSize = 0; - short nCTabIndex; - - HLock( (Handle)hCTab ); - - nCTabSize = (**hCTab).ctSize + 1; - nCTabMinSize = GetMinColorCount( nCTabSize, rBitmapPalette ); - - for( nCTabIndex = 0; - nCTabIndex < nCTabMinSize; - nCTabIndex++ - ) - { - const BitmapColor &rBitmapPaletteColor = rBitmapPalette[nCTabIndex]; - - (**hCTab).ctTable[nCTabIndex].value = nCTabIndex; - - (**hCTab).ctTable[nCTabIndex].rgb - = BitmapColor2RGBColor( rBitmapPaletteColor ); - } // for - - CTabChanged( hCTab ); - - HSetState( (Handle)hCTab, nCTabFlags ); - } // if - } // if - } // if - else - { - GDPtr pGDevice = NULL; - - pGDevice = *GetGDevice(); - - if ( pGDevice != NULL ) - { - PixMapPtr pPixMap = *pGDevice->gdPMap; - - if ( pPixMap != NULL ) - { - CTabPtr pCTable = *pPixMap->pmTable; - - if ( pCTable != NULL ) - { - ITabPtr pITable = *pGDevice->gdITable; - - if ( pITable != NULL ) - { - // Is the inverse color table up-to-date? - - if ( pITable->iTabSeed != pCTable->ctSeed ) - { - // Update our inverse color table - - MakeITable( pPixMap->pmTable, - pGDevice->gdITable, - pGDevice->gdResPref - ); - - pGDevice = *GetGDevice(); - pCTable = *pPixMap->pmTable; - } // if - } // if - - (**mhPixMap).pmTable = pPixMap->pmTable; - } // if - else - { - (**mhPixMap).pmTable = NULL; - } // else - } // if - } // if - } // else - - SetPixelsState( mhPixMap, nPixMapFlags ); - } // if - } //if - } // if - } // if - - delete pBuffer; - - pBuffer = NULL; - } // if -} // SalBitmap::ReleaseBuffer + *pDest++ = ( pSourcePixels->ReadPixel() == 0 ) ? nColor : 0; + } + pSource += mnBytesPerRow; + } + + CGColorSpaceRef xColorSpace( CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB) ); + CGDataProviderRef xDataProvider( CGDataProviderCreateWithData(NULL, pMaskBuffer, nHeight * nDestBytesPerRow, NULL) ); + xMask = CGImageCreate(nWidth, nHeight, 8, 32, nDestBytesPerRow, xColorSpace, kCGImageAlphaPremultipliedFirst, xDataProvider, NULL, true, kCGRenderingIntentDefault); + CFRelease(xDataProvider); + CFRelease(xColorSpace); + } + + if( pMaskBuffer ) + free(pMaskBuffer); + delete pSourcePixels; + } + return xMask; +} // ------------------------------------------------------------------ -SalGraphics* SalBitmap::GetGraphics() +CGImageRef AquaSalBitmap::CreateMask( int nX, int nY, int nWidth, int nHeight ) const { - if ( mpVirDev != NULL ) - { - return mpVirDev->GetGraphics(); - } // if - else + CGImageRef xMask = 0; + if( (maUserBuffer.get()) && ((nX + nWidth) <= mnWidth) && ((nY + nHeight) <= mnHeight) ) { - return NULL; - } // else -} // SalBitmap::GetGraphics + if( mnBits == 1 ) + { + CGDataProviderRef xDataProvider( CGDataProviderCreateWithData(NULL, maUserBuffer.get(), nHeight * mnBytesPerRow, NULL) ); + xMask = CGImageMaskCreate(nWidth, nHeight, 1, 1, mnBytesPerRow, xDataProvider, NULL, true ); + CFRelease(xDataProvider); + } + else + { + basebmp::RawMemorySharedArray aMaskBuffer( new sal_uInt8[ nWidth * nHeight ] ); + sal_uInt8* pDest = aMaskBuffer.get(); + if( pDest ) + { + sal_uInt8* pSource = maUserBuffer.get(); + if( nY ) + pSource += nY * mnBytesPerRow; -// ------------------------------------------------------------------ + if( mnBits == 8 ) + { + if( nX ) + pSource += nX; -void SalBitmap::ReleaseGraphics( SalGraphics* pGraphics ) -{ - if ( mpVirDev != NULL ) - { - mpVirDev->ReleaseGraphics( pGraphics ); - } // if -} // SalBitmap::ReleaseGraphics + // simple convert alpha + sal_uInt32 y = nHeight; + while( y-- ) + { + sal_uInt8* pSourceLine = pSource; + sal_uInt32 x = nWidth; + while( x-- ) + *pDest++ = 0xff - *pSource++; + pSource += mnBytesPerRow; + } + } + else + { + ImplPixelFormat* pSourcePixels = ImplPixelFormat::GetFormat( mnBits, maPalette ); + if( pSourcePixels ) + { + sal_uInt32 y = nHeight; + while( y-- ) + { + pSourcePixels->StartLine(pSource); + pSourcePixels->SkipPixel(nX); + sal_uInt32 x = nWidth; + while( x-- ) + *pDest++ = (pSourcePixels->ReadPixel() == 0) ? 0x00 : 0xff; + + pSource += mnBytesPerRow; + } + delete pSourcePixels; + } + } + + CGDataProviderRef xDataProvider( CGDataProviderCreateWithData(NULL, aMaskBuffer.get(), nHeight * nWidth, NULL) ); + xMask = CGImageMaskCreate(nWidth, nHeight, 8, 8, nWidth, xDataProvider, NULL, true ); + CFRelease(xDataProvider); + } + } + } + return xMask; +} // ======================================================================= -// ======================================================================= +bool AquaSalBitmap::GetSystemData( BitmapSystemData& rData ) +{ + return false; +} diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salcolorutils.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salcolorutils.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salcolorutils.cxx 2006-09-17 13:43:53.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salcolorutils.cxx 2006-10-13 23:55:16.000000000 +0200 @@ -39,6 +39,7 @@ #ifndef _SV_SALCOLORUTILS_HXX #include #endif +#include // ======================================================================= @@ -957,7 +958,7 @@ switch ( nPixMapCmpSize ) { case ( kPixMapCmpSizeFiveBits ): - rBuffer->mnFormat |= BMP_FORMAT_16BIT_TC_MASK; + rBuffer->mnFormat |= BMP_FORMAT_16BIT_TC_MSB_MASK; rBuffer->maColorMask = ColorMask( k16BitRedColorMask, k16BitGreenColorMask, k16BitBlueColorMask @@ -978,5 +979,18 @@ // ======================================================================= +SalColor GetSalColor( const float* pQuartzColor ) +{ + return MAKE_SALCOLOR( sal_uInt8( pQuartzColor[0] * 255.0), sal_uInt8( pQuartzColor[1] * 255.0 ), sal_uInt8( pQuartzColor[2] * 255.0 ) ); +} + +void SetSalColor( const SalColor& rColor, float* pQuartzColor ) +{ + pQuartzColor[0] = (float) SALCOLOR_RED(rColor) / 255.0; + pQuartzColor[1] = (float) SALCOLOR_GREEN(rColor) / 255.0; + pQuartzColor[2] = (float) SALCOLOR_BLUE(rColor) / 255.0; + pQuartzColor[3] = 1.0; +} + // ======================================================================= diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salfontutils.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salfontutils.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salfontutils.cxx 2006-09-17 13:44:07.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salfontutils.cxx 2006-10-13 23:55:23.000000000 +0200 @@ -48,164 +48,320 @@ #include #endif +#include + // ======================================================================= // ======================================================================= -static rtl_Script GetRTLScriptFromFontScriptCode( const FontNameEncodingPtr pFontNameEncoding ) +static rtl_TextEncoding GetRTLScriptFromFontScriptCode( const FontNameEncodingPtr pFontNameEncoding ) { FontScriptCode nFontScriptCode = pFontNameEncoding->mnFontScriptCode; FontPlatformCode nFontPlatformCode = pFontNameEncoding->mnFontPlatformCode; - rtl_Script nFontRTLScript = SCRIPT_DONTKNOW; + rtl_TextEncoding nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; if ( nFontPlatformCode == kFontUnicodePlatform ) { - nFontRTLScript = SCRIPT_UNICODE; + nFontRTLScript = RTL_TEXTENCODING_UNICODE; } // if else { switch( nFontScriptCode ) { case kFontRomanScript: - nFontRTLScript = SCRIPT_LATIN; + nFontRTLScript = RTL_TEXTENCODING_APPLE_ROMAN; break; case kFontJapaneseScript: - nFontRTLScript = SCRIPT_JAPANESE; + nFontRTLScript = RTL_TEXTENCODING_APPLE_JAPANESE; break; case kFontTraditionalChineseScript: - nFontRTLScript = SCRIPT_CHINESE_TRADITIONAL; + nFontRTLScript = RTL_TEXTENCODING_APPLE_CHINTRAD; break; case kFontKoreanScript: - nFontRTLScript = SCRIPT_KOREAN; + nFontRTLScript = RTL_TEXTENCODING_APPLE_KOREAN; break; case kFontArabicScript: - nFontRTLScript = SCRIPT_ARABIC; + nFontRTLScript = RTL_TEXTENCODING_APPLE_ARABIC; break; case kFontHebrewScript: - nFontRTLScript = SCRIPT_HEBREW; + nFontRTLScript = RTL_TEXTENCODING_APPLE_HEBREW; break; case kFontGreekScript: - nFontRTLScript = SCRIPT_GREEK; + nFontRTLScript = RTL_TEXTENCODING_APPLE_GREEK; break; case kFontCyrillicScript: - nFontRTLScript = SCRIPT_CYRILLIC; + nFontRTLScript = RTL_TEXTENCODING_APPLE_CYRILLIC; break; case kFontRSymbolScript: - nFontRTLScript = SCRIPT_SYMBOL; + nFontRTLScript = RTL_TEXTENCODING_SYMBOL; break; case kFontDevanagariScript: - nFontRTLScript = SCRIPT_DEVANAGARI; + nFontRTLScript = RTL_TEXTENCODING_APPLE_DEVANAGARI; break; case kFontGurmukhiScript: - nFontRTLScript = SCRIPT_GURMUKHI; + nFontRTLScript = RTL_TEXTENCODING_APPLE_GURMUKHI; break; case kFontGujaratiScript: - nFontRTLScript = SCRIPT_GUJARATI; + nFontRTLScript = RTL_TEXTENCODING_APPLE_GUJARATI; break; case kFontOriyaScript: - nFontRTLScript = SCRIPT_ORIYA; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontBengaliScript: - nFontRTLScript = SCRIPT_BENGALI; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontTamilScript: - nFontRTLScript = SCRIPT_TAMIL; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontTeluguScript: - nFontRTLScript = SCRIPT_TELUGU; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontKannadaScript: - nFontRTLScript = SCRIPT_KANNADA; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontMalayalamScript: - nFontRTLScript = SCRIPT_MALAYALAM; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontSinhaleseScript: - nFontRTLScript = SCRIPT_DONTKNOW; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontBurmeseScript: - nFontRTLScript = SCRIPT_DONTKNOW; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontKhmerScript: - nFontRTLScript = SCRIPT_DONTKNOW; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontThaiScript: - nFontRTLScript = SCRIPT_THAI; + nFontRTLScript = RTL_TEXTENCODING_APPLE_THAI; break; case kFontLaotianScript: - nFontRTLScript = SCRIPT_LAO; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontGeorgianScript: - nFontRTLScript = SCRIPT_GEORGIEN; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontArmenianScript: - nFontRTLScript = SCRIPT_ARMENIAN; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontSimpleChineseScript: - nFontRTLScript = SCRIPT_CHINESE_SIMPLIFIED; + nFontRTLScript = RTL_TEXTENCODING_APPLE_CHINSIMP; break; case kFontTibetanScript: - nFontRTLScript = SCRIPT_DONTKNOW; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontMongolianScript: - nFontRTLScript = SCRIPT_DONTKNOW; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontGeezScript: - nFontRTLScript = SCRIPT_DONTKNOW; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontEastEuropeanRomanScript: - nFontRTLScript = SCRIPT_EASTEUROPE; + nFontRTLScript = RTL_TEXTENCODING_APPLE_CENTEURO; break; case kFontVietnameseScript: - nFontRTLScript = SCRIPT_VIETNAMESE; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontExtendedArabicScript: - nFontRTLScript = SCRIPT_DONTKNOW; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; case kFontUninterpretedScript: - nFontRTLScript = SCRIPT_DONTKNOW; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; default: - nFontRTLScript = SCRIPT_DONTKNOW; + nFontRTLScript = RTL_TEXTENCODING_DONTKNOW; break; } // switch } // else return nFontRTLScript; } // GetRTLScriptFromFontScriptCode +//static rtl_Script GetRTLScriptFromFontScriptCode( const FontNameEncodingPtr pFontNameEncoding ) +//{ +// FontScriptCode nFontScriptCode = pFontNameEncoding->mnFontScriptCode; +// FontPlatformCode nFontPlatformCode = pFontNameEncoding->mnFontPlatformCode; +// rtl_Script nFontRTLScript = SCRIPT_DONTKNOW; +// +// if ( nFontPlatformCode == kFontUnicodePlatform ) +// { +// nFontRTLScript = SCRIPT_UNICODE; +// } // if +// else +// { +// switch( nFontScriptCode ) +// { +// case kFontRomanScript: +// nFontRTLScript = SCRIPT_LATIN; +// break; +// +// case kFontJapaneseScript: +// nFontRTLScript = SCRIPT_JAPANESE; +// break; +// +// case kFontTraditionalChineseScript: +// nFontRTLScript = SCRIPT_CHINESE_TRADITIONAL; +// break; +// +// case kFontKoreanScript: +// nFontRTLScript = SCRIPT_KOREAN; +// break; +// +// case kFontArabicScript: +// nFontRTLScript = SCRIPT_ARABIC; +// break; +// +// case kFontHebrewScript: +// nFontRTLScript = SCRIPT_HEBREW; +// break; +// +// case kFontGreekScript: +// nFontRTLScript = SCRIPT_GREEK; +// break; +// +// case kFontCyrillicScript: +// nFontRTLScript = SCRIPT_CYRILLIC; +// break; +// +// case kFontRSymbolScript: +// nFontRTLScript = SCRIPT_SYMBOL; +// break; +// +// case kFontDevanagariScript: +// nFontRTLScript = SCRIPT_DEVANAGARI; +// break; +// +// case kFontGurmukhiScript: +// nFontRTLScript = SCRIPT_GURMUKHI; +// break; +// +// case kFontGujaratiScript: +// nFontRTLScript = SCRIPT_GUJARATI; +// break; +// +// case kFontOriyaScript: +// nFontRTLScript = SCRIPT_ORIYA; +// break; +// +// case kFontBengaliScript: +// nFontRTLScript = SCRIPT_BENGALI; +// break; +// +// case kFontTamilScript: +// nFontRTLScript = SCRIPT_TAMIL; +// break; +// +// case kFontTeluguScript: +// nFontRTLScript = SCRIPT_TELUGU; +// break; +// +// case kFontKannadaScript: +// nFontRTLScript = SCRIPT_KANNADA; +// break; +// +// case kFontMalayalamScript: +// nFontRTLScript = SCRIPT_MALAYALAM; +// break; +// +// case kFontSinhaleseScript: +// nFontRTLScript = SCRIPT_DONTKNOW; +// break; +// +// case kFontBurmeseScript: +// nFontRTLScript = SCRIPT_DONTKNOW; +// break; +// +// case kFontKhmerScript: +// nFontRTLScript = SCRIPT_DONTKNOW; +// break; +// +// case kFontThaiScript: +// nFontRTLScript = SCRIPT_THAI; +// break; +// +// case kFontLaotianScript: +// nFontRTLScript = SCRIPT_LAO; +// break; +// +// case kFontGeorgianScript: +// nFontRTLScript = SCRIPT_GEORGIEN; +// break; +// +// case kFontArmenianScript: +// nFontRTLScript = SCRIPT_ARMENIAN; +// break; +// +// case kFontSimpleChineseScript: +// nFontRTLScript = SCRIPT_CHINESE_SIMPLIFIED; +// break; +// +// case kFontTibetanScript: +// nFontRTLScript = SCRIPT_DONTKNOW; +// break; +// +// case kFontMongolianScript: +// nFontRTLScript = SCRIPT_DONTKNOW; +// break; +// +// case kFontGeezScript: +// nFontRTLScript = SCRIPT_DONTKNOW; +// break; +// +// case kFontEastEuropeanRomanScript: +// nFontRTLScript = SCRIPT_EASTEUROPE; +// break; +// +// case kFontVietnameseScript: +// nFontRTLScript = SCRIPT_VIETNAMESE; +// break; +// +// case kFontExtendedArabicScript: +// nFontRTLScript = SCRIPT_DONTKNOW; +// break; +// +// case kFontUninterpretedScript: +// nFontRTLScript = SCRIPT_DONTKNOW; +// break; +// +// default: +// nFontRTLScript = SCRIPT_DONTKNOW; +// break; +// } // switch +// } // else +// +// return nFontRTLScript; +//} // GetRTLScriptFromFontScriptCode // ----------------------------------------------------------------------- @@ -309,18 +465,19 @@ if ( hFontList != NULL ) { short nItem = 1; - ImplFontData *pData = NULL; - ImplFontData *pCompare = NULL; + ImplDevFontAttributes pAttributes; + ImplMacFontData *pData = NULL; + ImplMacFontData *pCompare = NULL; ULONG nInsertPos = 0; char pFontFamilyName[kFontFamilyNameLength]; char pFontStyleName[kFontStyleNameLength]; - for ( nItem = 1; - nItem <= nFontListLength; + for ( nItem = 0; + nItem < nFontListLength; nItem++ ) { - pData = new ImplFontData; + pData = new ImplMacFontData(pAttributes,0,0,0); memset( pFontFamilyName, 0, kFontFamilyNameMemSize ); memset( pFontStyleName, 0, kFontStyleNameMemSize ); @@ -356,11 +513,15 @@ pData->meWeight = GetFontWeightFromFontNamesRecord( hFontList[ nItem ] ); - pData->mpSysData = NULL; // System-Data (only GSL) - pData->mnWidth = 0; // Font width in pixels - pData->mnHeight = 0; // Font height in pixels + // ATSUFontID + pData->mnFontID = hFontList[ nItem ]->mnFontID; + + //pData->mpSysData = (AquaSalSystem*)NULL; // System-Data (only GSL) +// pData->mnWidth = 0; // Font width in pixels +// pData->mnHeight = 0; // Font height in pixels +// pData->SetBitmapSize(0,0); pData->meFamily = FAMILY_DONTKNOW; // Font family - pData->meCharSet = 0; // Font character set +// pData->meCharSet = 0; // Font character set pData->mePitch = PITCH_DONTKNOW; // Font pitch pData->meWidthType = WIDTH_NORMAL; // Font weight type pData->meWeight = WEIGHT_NORMAL; // Font weight @@ -370,11 +531,11 @@ pData->mbDevice = TRUE; // Device font pData->mnQuality = 0; // Font quality - nInsertPos = nItem - 1; + nInsertPos = nItem /*- 1*/; while ( nInsertPos ) { - pCompare = pList->GetObject( nInsertPos - 1 ); + pCompare = (ImplMacFontData*)pList->GetObject( nInsertPos - 1 ); if ( pCompare->maName > pData->maName ) { diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salgdi.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salgdi.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salgdi.cxx 2006-09-17 13:44:22.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salgdi.cxx 2006-10-13 23:55:30.000000000 +0200 @@ -37,648 +37,494 @@ #include "precompiled_vcl.hxx" #ifndef _SV_SALCONST_H - #include +#include #endif #ifndef _SV_SALGDI_H - #include +#include #endif #ifndef _SV_SALBMP_HXX - #include +#include #endif -#ifndef _SV_VCLGRAPHICS_H - #include +#ifndef _SV_SALBMP_H +#include #endif #ifndef _SV_SALCOLORUTILS_HXX - #include +#include #endif #ifndef _SV_SALFONTUTILS_HXX - #include -#endif - -#ifndef _SV_SALGDIUTILS_HXX - #include +#include #endif #ifndef _SV_SALRECTANGLEUTILS_HXX - #include +#include #endif -// ======================================================================= +#include +#include + +typedef unsigned char Boolean; // copied from MacTypes.h, should be properly included // ======================================================================= -SalGraphics::SalGraphics() +ImplMacFontData::ImplMacFontData(const ImplDevFontAttributes& rDFA, + int nFontHeight=0, int macCharSet=0, + int nPitchAndFamily=0) : +ImplFontData(rDFA,0) { - // QuickDraw graph port, offscreen graphic world, and graphic device handle - - InitQD( &maGraphicsData ); - - // GWorld attributes - - InitGWorld( &maGraphicsData ); - - // Regions within a current port - - InitRegions( &maGraphicsData ); + +} - // Font attributes - - InitFont( &maGraphicsData ); +ImplMacFontData::~ImplMacFontData() +{ + +} - // Pen attributes and status - - InitPen( &maGraphicsData ); +ImplFontData* ImplMacFontData::Clone() const +{ + ImplFontData* pClone = new ImplMacFontData( *this ); + return pClone; +} - // Brush attributes and status - - InitBrush( &maGraphicsData ); +ImplFontEntry* ImplMacFontData::CreateFontInstance( ImplFontSelectData& rFSD ) const +{ + ImplFontEntry* pEntry = new ImplFontEntry( rFSD ); + return pEntry; +} - // Miscellaneous status flags - - InitStatusFlags( &maGraphicsData ); +// ======================================================================= -} // SalGraphics Class Constructor +AquaSalGraphics::AquaSalGraphics() +{ + mrView = NULL; + mrWindow = NULL; + mrContext = NULL; + mrBitmapContext = NULL; + + mrRGBColorSpace = CGColorSpaceCreateDeviceRGB(); + + mrClippingPath = NULL; + mpStdClippingRect = NULL; + mpClippingRect = NULL; + mpNextClippingRect = NULL; + mnClippingRectCount = 0; + + // init colors + for(int i=0; i<3; i++) + { + mpFillColor[i] = 0.0; // white + mpLineColor[i] = 1.0; // black + } + mpFillColor[3] = mpLineColor[3] = 1.0; // opaque colors + + // create the style object for font attributes + ATSUCreateStyle( &maATSUStyle ); + mnATSUIRotation = 0; + + mnPenMode = patCopy; + + mbPrinter = false; + mbVirDev = false; + mbWindow = false; + mbScreen = false; + +// mnUpdateGraphicsEvent = 0; + mnGraphics = 0; +} // ----------------------------------------------------------------------- -SalGraphics::~SalGraphics() +AquaSalGraphics::~AquaSalGraphics() { - // Release memory taken up by clip region, off-screen - // graph world, and colour graph port - - if ( ( ( maGraphicsData.mbGWorldPixelsCopy == TRUE ) - || ( maGraphicsData.mbGWorldPixelsNew == TRUE ) - ) - && ( maGraphicsData.mhGWorldPixMap != NULL ) - ) - { - DisposePixMap( maGraphicsData.mhGWorldPixMap ); - - maGraphicsData.mhGWorldPixMap = NULL; - } // if + DBG_ASSERT( mnGraphics == 0, "vcl::AquaSalGraphics::~AquaSalGraphics(), BeginGraphics and EndGraphics calls do not match!" ); - if ( maGraphicsData.mhClipRgn != NULL ) +/* + if( mnUpdateGraphicsEvent ) { - DisposeRgn( maGraphicsData.mhClipRgn ); - - maGraphicsData.mhClipRgn = NULL; - } // if - - if ( maGraphicsData.mpGWorld != NULL ) - { - DisposeGWorld( maGraphicsData.mpGWorld ); - - maGraphicsData.mpGWorld = NULL; - } // if - - if ( maGraphicsData.mpCGrafPort != NULL ) - { - DisposeGWorld( maGraphicsData.mpCGrafPort ); - - maGraphicsData.mpCGrafPort = NULL; - } // if - - // Initialize the rest of the fields to zero - - memset( &maGraphicsData, 0, sizeof(SalGraphicsData) ); -} // SalGraphics Class Destructor - -// ======================================================================= + Application::RemoveUserEvent( mnUpdateGraphicsEvent ); + } +*/ + CGColorSpaceRelease( mrRGBColorSpace ); + CGPathRelease( mrClippingPath ); + ATSUDisposeStyle( maATSUStyle ); + delete [] mpStdClippingRect; + + if( mrBitmapContext && (mrBitmapContext != mrContext) ) + { + // destroy backbuffer bitmap context that we created ourselfs + void * pBuffer = CGBitmapContextGetData(mrBitmapContext); + CFRelease( mrBitmapContext ); + mrBitmapContext = 0; + if( pBuffer ) + free( pBuffer ); + } +} // ======================================================================= -void SalGraphics::GetResolution( long& rDPIX, - long& rDPIY - ) +void AquaSalGraphics::GetResolution( long& rDPIX, long& rDPIY ) { - long nHRes = 0; - long nVRes = 0; + CGDirectDisplayID display = GetWindowDisplayID(); - maGraphicsData.mnOSStatus = GetGDeviceResolution( &nHRes, &nVRes ); + // Returns the width and height of a display in millimeters. + CGSize aSize = CGDisplayScreenSize ( display ); - if ( maGraphicsData.mnOSStatus == noErr ) - { - rDPIX = nHRes; - rDPIY = nVRes; - } // if -} // SalGraphics::GetResolution - -// ----------------------------------------------------------------------- - -void SalGraphics::GetScreenFontResolution( long& rDPIX, - long& rDPIY - ) -{ - long nHRes = 0; - long nVRes = 0; - - maGraphicsData.mnOSStatus = GetGDeviceResolution( &nHRes, &nVRes ); - - if ( maGraphicsData.mnOSStatus == noErr ) - { - rDPIX = nHRes; - rDPIY = nVRes; - } // if -} // SalGraphics::GetScreenFontResolution + rDPIX = static_cast(((double)CGDisplayPixelsWide( display ) * 25.4) / aSize.width ); + rDPIY = static_cast(((double)CGDisplayPixelsHigh( display ) * 25.4) / aSize.height ); +} // ----------------------------------------------------------------------- -USHORT SalGraphics::GetBitCount() +void AquaSalGraphics::GetScreenFontResolution( long& rDPIX, long& rDPIY ) { - unsigned short nBitDepth = 0; - - maGraphicsData.mnOSStatus = GetGDeviceBitDepth( &nBitDepth ); - - return nBitDepth; -} // SalGraphics::GetBitCount + // TODO: Is this correct? + GetResolution( rDPIX, rDPIY ); +} // ----------------------------------------------------------------------- -void SalGraphics::ResetClipRegion() +USHORT AquaSalGraphics::GetBitCount() { - if ( !maGraphicsData.mbWindow ) + if ( mrWindow ) { - if ( maGraphicsData.mhClipRgn != NULL ) - { - DisposeRgn( maGraphicsData.mhClipRgn ); - - maGraphicsData.mhClipRgn = NULL; - } // if - } // if + return static_cast( CGDisplayBitsPerPixel( GetWindowDisplayID() ) ); + } + else if( mrBitmapContext ) + { + return static_cast( CGBitmapContextGetBitsPerPixel(mrBitmapContext) ); + } else { - Rect aClipRect; - short nLeft = 0; - short nTop = 0; - short nRight = 0; - short nBottom = 0; - - if ( maGraphicsData.mhClipRgn == NULL ) - { - maGraphicsData.mhClipRgn = NewRgn(); - } // if - - GetPortBounds( maGraphicsData.mpCGrafPort, &aClipRect); - - nRight = aClipRect.right - aClipRect.left; - nBottom = aClipRect.bottom - aClipRect.top; - - MacSetRectRgn ( maGraphicsData.mhClipRgn, - nLeft, - nTop, - nRight, - nBottom - ); - } // else - - maGraphicsData.mbClipRgnChanged = TRUE; -} // SalGraphics::ResetClipRegion + return 32; + } +} // ----------------------------------------------------------------------- -void SalGraphics::BeginSetClipRegion( ULONG nRectCount ) +void AquaSalGraphics::ResetClipRegion() { - if ( maGraphicsData.mhClipRgn != NULL ) - { - DisposeRgn( maGraphicsData.mhClipRgn ); - - maGraphicsData.mhClipRgn = NULL; - } // if -} // SalGraphics::BeginSetClipRegion + // release old path and indicate no clipping + CGPathRelease( mrClippingPath ); + mrClippingPath = NULL; +} // ----------------------------------------------------------------------- -BOOL SalGraphics::UnionClipRegion( long nX, - long nY, - long nWidth, - long nHeight - ) -{ - RgnHandle hClipRegion = NULL; - BOOL bClipRegionsJoined = FALSE; - - hClipRegion = NewRgn(); +void AquaSalGraphics::BeginSetClipRegion( ULONG nRectCount ) +{ + // release old path + if( mrClippingPath ) + { + CGPathRelease( mrClippingPath ); + mrClippingPath = NULL; + } + + // allocate rect array or use existing + if( nRectCount < SAL_CLIPRECT_COUNT ) + { + if( !mpStdClippingRect ) + mpStdClippingRect = new CGRect[SAL_CLIPRECT_COUNT]; + mpClippingRect = mpStdClippingRect; + } + else + mpClippingRect = new CGRect[nRectCount]; + + // initialize index and count + mpNextClippingRect = mpClippingRect; + mnClippingRectCount = nRectCount; +} - if ( hClipRegion != NULL ) - { - short nLeft = nX; - short nTop = nY; - short nRight = nX+nWidth; - short nBottom = nY+nHeight; - - MacSetRectRgn ( hClipRegion, - nLeft, - nTop, - nRight, - nBottom - ); +// ----------------------------------------------------------------------- - if ( maGraphicsData.mhClipRgn != NULL ) - { - MacUnionRgn ( maGraphicsData.mhClipRgn, - hClipRegion, - maGraphicsData.mhClipRgn - ); - - maGraphicsData.mnOSStatus = QDErr(); - - DisposeRgn( hClipRegion ); - } // if - else - { - maGraphicsData.mhClipRgn = hClipRegion; - } // else +BOOL AquaSalGraphics::unionClipRegion( long nX, long nY, long nWidth, long nHeight ) +{ + if( nWidth && nHeight ) + { + *mpNextClippingRect++ = CGRectMake (nX, nY, nWidth, nHeight); + } + else + { + // do not add useless clipping rects but correct the count + mnClippingRectCount--; + } - if ( maGraphicsData.mnOSStatus == noErr ) - { - bClipRegionsJoined = TRUE; - } // if - } // if - - return bClipRegionsJoined; -} // SalGraphics::UnionClipRegion + return TRUE; +} // ----------------------------------------------------------------------- -void SalGraphics::EndSetClipRegion() +void AquaSalGraphics::EndSetClipRegion() { - maGraphicsData.mbClipRgnChanged = TRUE; - - if ( maGraphicsData.mhClipRgn == NULL ) - { - ResetClipRegion(); - } -} // SalGraphics::EndSetClipRegion + if( mnClippingRectCount ) + { + mrClippingPath = CGPathCreateMutable(); + if( mnClippingRectCount == 1 ) + CGPathAddRect( mrClippingPath, NULL, *mpClippingRect ); + else + CGPathAddRects( mrClippingPath, NULL, mpClippingRect, mnClippingRectCount ); + mnClippingRectCount = 0; + } + if ( mpClippingRect != mpStdClippingRect ) + { + delete [] mpClippingRect; + mpClippingRect = NULL; + } +} // ----------------------------------------------------------------------- -void SalGraphics::SetLineColor() +void AquaSalGraphics::SetLineColor() { - maGraphicsData.mbPenTransparent = TRUE; -} // SalGraphics::SetLineColor + mpLineColor[3] = 0.0; // set alpha component to 0 +} // ----------------------------------------------------------------------- -void SalGraphics::SetLineColor( SalColor nSalColor ) +void AquaSalGraphics::SetLineColor( SalColor nSalColor ) { - maGraphicsData.mbPenTransparent = FALSE; - maGraphicsData.maPenColor = SALColor2RGBColor( nSalColor ); -} // SalGraphics::SetLineColor + mpLineColor[0] = (float) SALCOLOR_RED(nSalColor) / 255.0; + mpLineColor[1] = (float) SALCOLOR_GREEN(nSalColor) / 255.0; + mpLineColor[2] = (float) SALCOLOR_BLUE(nSalColor) / 255.0; + mpLineColor[3] = 1.0; // opaque +} // ----------------------------------------------------------------------- -void SalGraphics::SetFillColor() +void AquaSalGraphics::SetFillColor() { - maGraphicsData.mbBrushTransparent = TRUE; -} // SalGraphics::SetFillColor + mpFillColor[3] = 0.0; // set alpha component to 0 +} // ----------------------------------------------------------------------- -void SalGraphics::SetFillColor( SalColor nSalColor ) +void AquaSalGraphics::SetFillColor( SalColor nSalColor ) { - RGBColor aRGBColor; - - aRGBColor = SALColor2RGBColor( nSalColor ); - - maGraphicsData.maBrushColor = aRGBColor; - maGraphicsData.mbBrushTransparent = FALSE; -} // SalGraphics::SetFillColor + mpFillColor[0] = (float) SALCOLOR_RED(nSalColor) / 255.0; + mpFillColor[1] = (float) SALCOLOR_GREEN(nSalColor) / 255.0; + mpFillColor[2] = (float) SALCOLOR_BLUE(nSalColor) / 255.0; + mpFillColor[3] = 1.0; // opaque +} // ----------------------------------------------------------------------- -void SalGraphics::SetXORMode( BOOL bSet ) +void AquaSalGraphics::SetXORMode( BOOL bSet ) { - if ( bSet == TRUE ) - { - maGraphicsData.mnPenMode = patXor; - } // if - else - { - maGraphicsData.mnPenMode = patCopy; - } // else -} // SalGraphics::SetXORMode +} // ----------------------------------------------------------------------- -void SalGraphics::SetROPLineColor( SalROPColor nROPColor ) +void AquaSalGraphics::SetROPLineColor( SalROPColor nROPColor ) { - SalColor nSalColor = GetROPSalColor( nROPColor ); - - SetLineColor( nSalColor ); -} // SalGraphics::SetROPLineColor +} // ----------------------------------------------------------------------- -void SalGraphics::SetROPFillColor( SalROPColor nROPColor ) +void AquaSalGraphics::SetROPFillColor( SalROPColor nROPColor ) { - SalColor nSalColor = GetROPSalColor( nROPColor ); - - SetFillColor( nSalColor ); -} // SalGraphics::SetROPFillColor +} // ----------------------------------------------------------------------- -void SalGraphics::DrawPixel( long nX, - long nY - ) +void AquaSalGraphics::ImplDrawPixel( long nX, long nY, float pColor[] ) { - if ( BeginGraphics( &maGraphicsData ) ) + // save fill color and replace it with the desired color + float oldFillColor[4]; + memcpy( (void*) oldFillColor, (void*) mpFillColor, sizeof( oldFillColor ) ); + memcpy( (void*) mpFillColor, (void*) pColor, sizeof( mpFillColor ) ); + + if ( BeginGraphics() ) { - RGBColor aPixelRGBColor = maGraphicsData.maPenColor; + // draw 1x1 rect, there is no pixel drawing in Quartz + CGContextFillRect (mrContext, CGRectMake (nX, nY, 1, 1)); - SetCPixel( nX, nY, &aPixelRGBColor ); + if( isOffscreenCopy() ) + CGContextFillRect (mrBitmapContext, CGRectMake (nX, nY, 1, 1)); + EndGraphics(); + } + + // restore fill color + memcpy( (void*) mpFillColor, (void*) oldFillColor, sizeof( mpFillColor ) ); + +} - EndGraphics( &maGraphicsData ); - } // if -} // SalGraphics::DrawPixel +void AquaSalGraphics::drawPixel( long nX, long nY ) +{ + // draw pixel with current line color + ImplDrawPixel( nX, nY, mpLineColor ); +} + +void AquaSalGraphics::drawPixel( long nX, long nY, SalColor nSalColor ) +{ + // draw pixel with specified color + float pColor[] = + { + (float) SALCOLOR_RED(nSalColor) / 255.0, + (float) SALCOLOR_GREEN(nSalColor) / 255.0, + (float) SALCOLOR_BLUE(nSalColor) / 255.0, + 1.0 // opaque + }; + + ImplDrawPixel(nX, nY, pColor); +} // ----------------------------------------------------------------------- -void SalGraphics::DrawPixel( long nX, - long nY, - SalColor nSalColor - ) +static void implDrawLine( CGContextRef& xContext, long nX1, long nY1, long nX2, long nY2 ) +{ + CGContextBeginPath( xContext ); + CGContextMoveToPoint( xContext, nX1, nY1 ); + CGContextAddLineToPoint( xContext, nX2, nY2 ); + CGContextDrawPath( xContext, kCGPathStroke ); +} + +void AquaSalGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 ) { - if ( BeginGraphics( &maGraphicsData ) ) + if ( BeginGraphics() ) { - RGBColor aPixelRGBColor; - - aPixelRGBColor = SALColor2RGBColor( nSalColor ); - - SetCPixel( nX, nY, &aPixelRGBColor ); - - EndGraphics( &maGraphicsData ); - } // if -} // SalGraphics::DrawPixel + implDrawLine( mrContext, nX1, nY1, nX2, nY2 ); + if( isOffscreenCopy() ) + implDrawLine( mrBitmapContext, nX1, nY1, nX2, nY2 ); + EndGraphics(); + } +} // ----------------------------------------------------------------------- -void SalGraphics::DrawLine( long nX1, - long nY1, - long nX2, - long nY2 - ) +static void implDrawRect( CGContextRef& xContext, long nX, long nY, long nWidth, long nHeight, bool bFilled ) { - if ( BeginGraphics( &maGraphicsData ) ) - { - MoveTo( nX1, nY1 ); - - if ( maGraphicsData.mbPenTransparent == TRUE ) - { - SetBlackForeColor(); - } // if - else - { - RGBColor aPenColor = maGraphicsData.maPenColor; - - RGBForeColor( &aPenColor ); - } // else - - MacLineTo( nX2, nY2 ); - - EndGraphics( &maGraphicsData ); - } // if -} // SalGraphics::DrawLine - -// ----------------------------------------------------------------------- + if( bFilled ) + CGContextStrokeRect(xContext, CGRectMake (nX, nY, nWidth, nHeight)); + else + CGContextFillRect(xContext, CGRectMake (nX, nY, nWidth, nHeight)); +} -void SalGraphics::DrawRect( long nX, - long nY, - long nWidth, - long nHeight - ) +void AquaSalGraphics::drawRect( long nX, long nY, long nWidth, long nHeight ) { - if ( BeginGraphics( &maGraphicsData ) ) + if ( BeginGraphics() ) { - long nEndX = 0; - long nEndY = 0; - RGBColor aBrushColor = maGraphicsData.maBrushColor; - Rect aRect; - - // [ed] 12/1/01 Parameter checks. Limit all of the parameters to fit within - // the current port bounds - - Rect portBounds; - GetPortBounds(maGraphicsData.mpCGrafPort, &portBounds); - - if(nX < portBounds.left) - nX=portBounds.left; - - if(nY < portBounds.top) - nY=portBounds.top; - - if((nHeight > (portBounds.bottom-portBounds.top)-(nY-portBounds.top)) || (nHeight < 0)) - nHeight=portBounds.bottom-portBounds.top-(nY-portBounds.top)-1; - - if((nWidth > (portBounds.right-portBounds.left-(nX-portBounds.left))) || (nHeight < 0)) - nWidth=portBounds.right-portBounds.left-(nX-portBounds.left)-1; + const bool bFilled = IsBrushTransparent(); - // Compute the second set of (nX,nY) coordinates - - nEndX = nX + nWidth; - nEndY = nY + nHeight; - - RGBForeColor( &aBrushColor ); - - MoveTo( nX, nY ); - - MacSetRect( &aRect, nX, nY, nEndX, nEndY ); - - if ( maGraphicsData.mbBrushTransparent == TRUE ) - { - MacFrameRect( &aRect ); - } // if - else - { - PaintRect( &aRect ); - } // else - - EndGraphics( &maGraphicsData ); - } // if -} // SalGraphics::DrawRect + implDrawRect( mrContext, nX, nY, nWidth, nHeight, bFilled ); + if( isOffscreenCopy() ) + implDrawRect( mrBitmapContext, nX, nY, nWidth, nHeight, bFilled ); + EndGraphics(); + } +} // ----------------------------------------------------------------------- -void SalGraphics::DrawPolyLine( ULONG nPoints, - const SalPoint *pPtAry - ) +static void implDrawPolyLine( CGContextRef& xContext, ULONG nPoints, const SalPoint *pPtAry ) { - if ( ( nPoints > 1 ) && ( pPtAry != NULL ) ) - { - if ( BeginGraphics( &maGraphicsData ) ) - { - long nPolyEdges = 0; - PolyHandle hPolygon = NULL; - - SetBlackForeColor(); - - // Construct a polygon - - hPolygon = OpenPoly(); - - if ( hPolygon != NULL ) - { - MoveTo( pPtAry[0].mnX, pPtAry[0].mnY ); - - for ( nPolyEdges = 1; - nPolyEdges < nPoints; - nPolyEdges++ - ) - { - MacLineTo( pPtAry[nPolyEdges].mnX, - pPtAry[nPolyEdges].mnY - ); - } // for - - MacLineTo( pPtAry[0].mnX, - pPtAry[0].mnY - ); - } // if - - ClosePoly(); - - // Did a QD error occur whilst constructing a polygon? - - maGraphicsData.mnOSStatus = QDErr(); - - if ( ( maGraphicsData.mnOSStatus == noErr ) - && ( hPolygon != NULL ) - ) - { - FramePoly( hPolygon ); - - KillPoly( hPolygon ); - } // if - - EndGraphics( &maGraphicsData ); - } // if - } // if -} // SalGraphics::DrawPolyLine - -// ----------------------------------------------------------------------- + CGContextBeginPath( xContext ); + CGContextMoveToPoint( xContext, pPtAry->mnX, pPtAry->mnY ); + pPtAry++; + for( ULONG nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ ) + CGContextAddLineToPoint( xContext, pPtAry->mnX, pPtAry->mnY ); + CGContextDrawPath( xContext, kCGPathStroke ); +} -void SalGraphics::DrawPolygon( ULONG nPoints, - const SalPoint *pPtAry - ) +void AquaSalGraphics::drawPolyLine( ULONG nPoints, const SalPoint *pPtAry ) { - if ( ( nPoints > 1 ) && ( pPtAry != NULL ) ) + if( (nPoints > 1) && BeginGraphics() ) { - if ( BeginGraphics( &maGraphicsData ) ) - { - long nPolyEdges = 0; - PolyHandle hPolygon = NULL; - RGBColor aPolyColor = maGraphicsData.maBrushColor; - - RGBForeColor( &aPolyColor ); - - // Construct a polygon - - hPolygon = OpenPoly(); - - if ( hPolygon != NULL ) - { - MoveTo( pPtAry[0].mnX, pPtAry[0].mnY ); + implDrawPolyLine( mrContext, nPoints, pPtAry ); + if( isOffscreenCopy() ) + implDrawPolyLine( mrBitmapContext, nPoints, pPtAry ); + EndGraphics(); + } +} - for ( nPolyEdges = 1; - nPolyEdges < nPoints; - nPolyEdges++ - ) - { - MacLineTo( pPtAry[nPolyEdges].mnX, - pPtAry[nPolyEdges].mnY - ); - } // for - - MacLineTo( pPtAry[0].mnX, - pPtAry[0].mnY - ); - } // if +// ----------------------------------------------------------------------- - ClosePoly(); +static void ImplDrawPolygone( CGContextRef& xContext, ULONG nPoints, const SalPoint *pPtAry, float* pFillColor, float* pLineColor ) +{ + CGContextBeginPath( xContext ); + CGContextMoveToPoint( xContext, pPtAry->mnX, pPtAry->mnY ); + pPtAry++; + for( ULONG nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ ) + CGContextAddLineToPoint( xContext, pPtAry->mnX, pPtAry->mnY ); - // Did a QD error occur whilst constructing a polygon? + if( pFillColor[3] > 0.0 ) + { + CGContextClosePath(xContext); + CGContextDrawPath( xContext, kCGPathEOFill ); + } - maGraphicsData.mnOSStatus = QDErr(); - - if ( ( maGraphicsData.mnOSStatus == noErr ) - && ( hPolygon != NULL ) - ) - { - PaintPoly( hPolygon ); + if( pLineColor[3] > 0.0 ) + CGContextDrawPath( xContext, kCGPathStroke ); +} - KillPoly( hPolygon ); - } // if - - EndGraphics( &maGraphicsData ); - } // if - } // if -} // SalGraphics::DrawPolygon +void AquaSalGraphics::drawPolygon( ULONG nPoints, const SalPoint *pPtAry ) +{ + if( (nPoints > 1) && BeginGraphics() ) + { + ImplDrawPolygone( mrContext, nPoints, pPtAry, mpFillColor, mpLineColor ); + if( isOffscreenCopy() ) + ImplDrawPolygone( mrBitmapContext, nPoints, pPtAry, mpFillColor, mpLineColor ); + EndGraphics(); + } +} // ----------------------------------------------------------------------- -void SalGraphics::DrawPolyPolygon( ULONG nPoly, - const ULONG *pPoints, - PCONSTSALPOINT *ppPtAry - ) +static void ImplDrawPolyPolygone( CGContextRef& xContext, ULONG nPolyCount, const ULONG *pPoints, PCONSTSALPOINT *ppPtAry ) { - if ( ( nPoly > 1 ) && ( ppPtAry != NULL ) && ( ppPtAry != NULL ) ) + CGContextBeginPath( xContext ); + for( ULONG nPoly = 0; nPoly < nPolyCount; nPoly++ ) { - if ( BeginGraphics( &maGraphicsData ) ) + const ULONG nPoints = pPoints[nPoly]; + if( nPoints > 1 ) { - RgnHandle hPolyRgn = NULL; - RGBColor aPolyColor = maGraphicsData.maBrushColor; - OSStatus nOSStatus = noErr; - - RGBForeColor( &aPolyColor ); - - // Construct a polygon region - - hPolyRgn = GetPolygonRgn( nPoly, - pPoints, - ppPtAry, - &nOSStatus - ); - - if ( ( hPolyRgn != NULL ) && ( nOSStatus == noErr ) ) - { - MacPaintRgn( hPolyRgn ); - - DisposeRgn( hPolyRgn ); - - nOSStatus = QDErr(); + const SalPoint *pPtAry = ppPtAry[nPoly]; + CGContextBeginPath( xContext ); + CGContextMoveToPoint( xContext, pPtAry->mnX, pPtAry->mnY ); + pPtAry++; + for( ULONG nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ ) + CGContextAddLineToPoint( xContext, pPtAry->mnX, pPtAry->mnY ); + CGContextClosePath(xContext); + } + } + CGContextDrawPath( xContext, kCGPathEOFill ); +} - hPolyRgn = NULL; - } // if - - maGraphicsData.mnOSStatus = nOSStatus; +void AquaSalGraphics::drawPolyPolygon( ULONG nPolyCount, const ULONG *pPoints, PCONSTSALPOINT *ppPtAry ) +{ + if( nPolyCount && ( mpFillColor[3] > 0.0 ) && BeginGraphics() ) + { + ImplDrawPolyPolygone( mrContext, nPolyCount, pPoints, ppPtAry ); + if( isOffscreenCopy() ) + ImplDrawPolyPolygone( mrBitmapContext, nPolyCount, pPoints, ppPtAry ); + EndGraphics(); + } - EndGraphics( &maGraphicsData ); - } // if - } // if -} // SalGraphics::DrawPolyPolygon + if( mpLineColor[3] > 0.0 ) + { + for( ULONG nPoly = 0; nPoly < nPolyCount; nPoly++ ) + drawPolyLine( pPoints[nPoly], ppPtAry[nPoly] ); + } +} // ----------------------------------------------------------------------- -sal_Bool SalGraphics::DrawPolyLineBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ) +sal_Bool AquaSalGraphics::drawPolyLineBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ) { return sal_False; } // ----------------------------------------------------------------------- -sal_Bool SalGraphics::DrawPolygonBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ) +sal_Bool AquaSalGraphics::drawPolygonBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ) { return sal_False; } // ----------------------------------------------------------------------- -sal_Bool SalGraphics::DrawPolyPolygonBezier( ULONG nPoly, const ULONG* pPoints, +sal_Bool AquaSalGraphics::drawPolyPolygonBezier( ULONG nPoly, const ULONG* pPoints, const SalPoint* const* pPtAry, const BYTE* const* pFlgAry ) { return sal_False; @@ -686,776 +532,474 @@ // ----------------------------------------------------------------------- -void SalGraphics::CopyBits( const SalTwoRect *pPosAry, - SalGraphics *pSrcGraphics - ) +void AquaSalGraphics::copyBits( const SalTwoRect *pPosAry, SalGraphics *pSrcGraphics ) { - if ( ( pPosAry != NULL ) && ( pSrcGraphics != NULL ) ) - { - if ( BeginGraphics( &maGraphicsData ) ) - { - const BitMap *pDstBitMap = GetPortBitMapForCopyBits( maGraphicsData.mpCGrafPort ); - - if ( pDstBitMap != NULL ) - { - Rect aSrcRect; - Rect aDstRect; - Rect aPortBoundsRect; - RgnHandle hMaskRgn = NULL; // Mask Region for QD CopyBits - short nCopyMode = 0; - - SalTwoRect2QDSrcRect( pPosAry, &aSrcRect ); - - SalTwoRect2QDDstRect( pPosAry, &aDstRect ); - - GetPortBounds( pSrcGraphics->maGraphicsData.mpCGrafPort, &aPortBoundsRect ); + if( !pSrcGraphics ) + pSrcGraphics = this; - CheckRectBounds( &aPortBoundsRect, &aSrcRect, &aDstRect ); - - nCopyMode = SelectCopyMode( &maGraphicsData ); - - // Now we can call QD CopyBits to copy the bits from source rectangle - // to the destination rectangle - - if ( LockGraphics( pSrcGraphics ) ) - { - const BitMap *pSrcBitMap - = GetPortBitMapForCopyBits( pSrcGraphics->maGraphicsData.mpCGrafPort ); - - if ( pSrcBitMap != NULL ) - { - ::CopyBits ( pSrcBitMap, - pDstBitMap, - &aSrcRect, - &aDstRect, - nCopyMode, - hMaskRgn - ); - } // if - - UnlockGraphics( pSrcGraphics ); - } // if - else - { - ::CopyBits ( pDstBitMap, - pDstBitMap, - &aSrcRect, - &aDstRect, - nCopyMode, - hMaskRgn - ); - } // else - } // if - - EndGraphics( &maGraphicsData ); - } // if - } // if -} // SalGraphics::CopyBits + SalBitmap* pBitmap = static_cast(pSrcGraphics)->getBitmap( pPosAry->mnSrcX, pPosAry->mnSrcY, pPosAry->mnSrcWidth, pPosAry->mnSrcHeight ); + if( pBitmap ) + { + SalTwoRect aPosAry( *pPosAry ); + aPosAry.mnSrcX = 0; + aPosAry.mnSrcY = 0; + drawBitmap( &aPosAry, *pBitmap ); + delete pBitmap; + } +} // ----------------------------------------------------------------------- -void SalGraphics::CopyArea( long nDstX, - long nDstY, - long nSrcX, - long nSrcY, - long nSrcWidth, - long nSrcHeight, - USHORT nFlags - ) +void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY, long nSrcWidth, long nSrcHeight, USHORT nFlags ) { - if ( BeginGraphics( &maGraphicsData ) ) + SalBitmap* pBitmap = getBitmap( nSrcX, nSrcY, nSrcWidth, nSrcHeight ); + if( pBitmap ) { - const BitMap *pDstBitMap = GetPortBitMapForCopyBits( maGraphicsData.mpCGrafPort ); - - if ( pDstBitMap != NULL ) - { - short nCopyMode = 0; - long nDstWidth = nSrcWidth; - long nDstHeight = nSrcHeight; - RgnHandle hMaskRgn = NULL; // Mask Region for QD CopyBits - Rect aSrcRect; - Rect aDstRect; - Rect aPortBoundsRect; - - GetQDRect( nSrcX, nSrcY, nSrcWidth, nSrcHeight, &aSrcRect ); - - GetQDRect( nDstX, nDstY, nDstWidth, nDstHeight, &aDstRect ); - - GetPortBounds( maGraphicsData.mpCGrafPort, &aPortBoundsRect ); - - CheckRectBounds( &aPortBoundsRect, &aSrcRect, &aDstRect ); - - nCopyMode = SelectCopyMode( &maGraphicsData ); - - // Now we can call QD CopyBits to copy the bits from source rectangle - // to the destination rectangle - - ::CopyBits ( pDstBitMap, - pDstBitMap, - &aSrcRect, - &aDstRect, - nCopyMode, - hMaskRgn - ); - } // if - - EndGraphics( &maGraphicsData ); - } // if -} // SalGraphics::CopyArea + SalTwoRect aPosAry; + aPosAry.mnSrcX = 0; + aPosAry.mnSrcY = 0; + aPosAry.mnSrcWidth = nSrcWidth; + aPosAry.mnSrcHeight = nSrcHeight; + aPosAry.mnDestX = nDstX; + aPosAry.mnDestY = nDstY; + aPosAry.mnDestWidth = nSrcWidth; + aPosAry.mnDestHeight = nSrcHeight; + drawBitmap( &aPosAry, *pBitmap ); + delete pBitmap; + } +} // ----------------------------------------------------------------------- -void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, - const SalBitmap& rSalBitmap - ) +void AquaSalGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap ) { - if ( pPosAry != NULL ) + const AquaSalBitmap& rBitmap = static_cast(rSalBitmap); + if ( BeginGraphics() ) { - if ( BeginGraphics( &maGraphicsData ) ) - { - SalGraphics *pSrcGraphics = rSalBitmap.GetGraphics(); - - if ( LockGraphics( pSrcGraphics ) ) - { - const BitMap *pDstBitMap = GetPortBitMapForCopyBits( maGraphicsData.mpCGrafPort ); - - if ( pDstBitMap != NULL ) - { - const BitMap *pSrcBitMap - = GetPortBitMapForCopyBits( pSrcGraphics->maGraphicsData.mpCGrafPort ); - - if ( pSrcBitMap != NULL ) - { - Rect aSrcRect; - Rect aDstRect; - Rect aPortBoundsRect; - RgnHandle hMaskRgn = NULL; // Mask Region for QD CopyBits - short nCopyMode = 0; - - SalTwoRect2QDSrcRect( pPosAry, &aSrcRect ); - - SalTwoRect2QDDstRect( pPosAry, &aDstRect ); - - GetPortBounds( pSrcGraphics->maGraphicsData.mpCGrafPort, &aPortBoundsRect ); - - CheckRectBounds( &aPortBoundsRect, &aSrcRect, &aDstRect ); - - nCopyMode = SelectCopyMode( &maGraphicsData ); - - // Now we can call QD CopyBits to copy the bits from source rectangle - // to the destination rectangle - - ::CopyBits ( pSrcBitMap, - pDstBitMap, - &aSrcRect, - &aDstRect, - nCopyMode, - hMaskRgn - ); - } // if - } // if - - UnlockGraphics( pSrcGraphics ); + CGImageRef xImage = const_cast< AquaSalBitmap& >( rBitmap ).CreateCroppedImage( (int)pPosAry->mnSrcX, (int)pPosAry->mnSrcY, (int)pPosAry->mnSrcWidth, (int)pPosAry->mnSrcHeight ); - rSalBitmap.ReleaseGraphics( pSrcGraphics ); - } // if + CGContextDrawImage(mrContext, CGRectMake ((int)pPosAry->mnDestX, (int)pPosAry->mnDestY, (int)pPosAry->mnDestWidth, (int)pPosAry->mnDestHeight), xImage); + if( isOffscreenCopy() ) + CGContextDrawImage(mrBitmapContext, CGRectMake ((int)pPosAry->mnDestX, (int)pPosAry->mnDestY, (int)pPosAry->mnDestWidth, (int)pPosAry->mnDestHeight), xImage); - EndGraphics( &maGraphicsData ); - } // if - } // if -} // SalGraphics::DrawBitmap + CGImageRelease(xImage); + EndGraphics(); + } +} // ----------------------------------------------------------------------- -void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, - const SalBitmap& rSalBitmap, - SalColor nTransparentColor - ) +void AquaSalGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap,SalColor nTransparentColor ) { - if ( pPosAry != NULL ) - { - if ( BeginGraphics( &maGraphicsData ) ) - { - SalGraphics *pSrcGraphics = rSalBitmap.GetGraphics(); - - if ( LockGraphics( pSrcGraphics ) ) - { - const BitMap *pDstBitMap = GetPortBitMapForCopyBits( maGraphicsData.mpCGrafPort ); - - if ( pDstBitMap != NULL ) - { - const BitMap *pSrcBitMap - = GetPortBitMapForCopyBits( pSrcGraphics->maGraphicsData.mpCGrafPort ); - - if ( pSrcBitMap != NULL ) - { - Rect aSrcRect; - Rect aDstRect; - Rect aPortBoundsRect; - RGBColor aBackColor; - RgnHandle hMaskRgn = NULL; // Mask Region for QD CopyBits - short nCopyMode = transparent; - - SalTwoRect2QDSrcRect( pPosAry, &aSrcRect ); - - SalTwoRect2QDDstRect( pPosAry, &aDstRect ); - - GetPortBounds( pSrcGraphics->maGraphicsData.mpCGrafPort, &aPortBoundsRect ); - - CheckRectBounds( &aPortBoundsRect, &aSrcRect, &aDstRect ); - - aBackColor = SALColor2RGBColor( nTransparentColor ); - - RGBBackColor( &aBackColor ); - - // Now we can call QD CopyBits to copy the bits from - // source rectangle to the destination rectangle - - ::CopyBits ( pSrcBitMap, - pDstBitMap, - &aSrcRect, - &aDstRect, - nCopyMode, - hMaskRgn - ); - } // if - } // if + fprintf( stderr, "<> AquaSalGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap,SalColor nTransparentColor ) not yet implemented!\n" ); + drawBitmap( pPosAry, rSalBitmap ); +} - UnlockGraphics( pSrcGraphics ); - - rSalBitmap.ReleaseGraphics( pSrcGraphics ); - } // if +// ----------------------------------------------------------------------- - EndGraphics( &maGraphicsData ); - } // if - } // if -} // SalGraphics::DrawBitmap +void AquaSalGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap, const SalBitmap& rTransparentBitmap ) +{ + AquaSalBitmap& rBitmap = const_cast< AquaSalBitmap& >( static_cast(rSalBitmap) ); + const AquaSalBitmap& rMask = static_cast(rTransparentBitmap); + if ( BeginGraphics() ) + { + CGImageRef xMaskedImage( rBitmap.CreateWithMask( rMask, pPosAry->mnSrcX, pPosAry->mnSrcY, pPosAry->mnSrcWidth, pPosAry->mnSrcHeight ) ); + if( xMaskedImage ) + { + CGContextDrawImage(mrContext, CGRectMake (pPosAry->mnDestX, pPosAry->mnDestY, pPosAry->mnDestWidth, pPosAry->mnDestHeight), xMaskedImage); + if( isOffscreenCopy() ) + CGContextDrawImage(mrBitmapContext, CGRectMake (pPosAry->mnDestX, pPosAry->mnDestY, pPosAry->mnDestWidth, pPosAry->mnDestHeight), xMaskedImage); + CGImageRelease(xMaskedImage); + } + EndGraphics(); + } +} // ----------------------------------------------------------------------- -void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, - const SalBitmap& rSalBitmap, - const SalBitmap& rTransparentBitmap - ) +void AquaSalGraphics::drawMask( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap, SalColor nMaskColor ) { - if ( pPosAry != NULL ) + const AquaSalBitmap& rBitmap = static_cast(rSalBitmap); + + if ( BeginGraphics() ) { - if ( BeginGraphics( &maGraphicsData ) ) + CGImageRef xImage = rBitmap.CreateColorMask( pPosAry->mnSrcX, pPosAry->mnSrcY, pPosAry->mnSrcWidth, pPosAry->mnSrcHeight, nMaskColor ); + if( xImage ) { - SalGraphics *pSrcGraphics = rSalBitmap.GetGraphics(); - - if ( LockGraphics( pSrcGraphics ) ) - { - SalGraphics *pMskGraphics = rTransparentBitmap.GetGraphics(); - - if ( LockGraphics( pMskGraphics ) ) - { - const BitMap *pDstBitMap = GetPortBitMapForCopyBits( maGraphicsData.mpCGrafPort ); - - if ( pDstBitMap != NULL ) - { - const BitMap *pSrcBitMap - = GetPortBitMapForCopyBits( pSrcGraphics->maGraphicsData.mpCGrafPort ); - - if ( pSrcBitMap != NULL ) - { - const BitMap *pMskBitMap - = GetPortBitMapForCopyBits( pSrcGraphics->maGraphicsData.mpCGrafPort ); - - if ( pMskBitMap != NULL ) - { - Rect aSrcRect; - Rect aDstRect; - Rect aPortBoundsRect; - RgnHandle hMaskRgn = NULL; // Mask Region for QD CopyBits - short nCopyMode = 0; - - SalTwoRect2QDSrcRect( pPosAry, &aSrcRect ); - - SalTwoRect2QDDstRect( pPosAry, &aDstRect ); - - GetPortBounds( pSrcGraphics->maGraphicsData.mpCGrafPort, - &aPortBoundsRect - ); - - CheckRectBounds( &aPortBoundsRect, &aSrcRect, &aDstRect ); - - nCopyMode = SelectCopyMode( &maGraphicsData ); - - // Now we can call QD CopyDeepMask to copy the bits from - // source rectangle to the destination rectangle using the - // the mask bits - - ::CopyDeepMask( pSrcBitMap, - pMskBitMap, - pDstBitMap, - &aSrcRect, - &aSrcRect, - &aDstRect, - nCopyMode, - hMaskRgn - ); - } // if - } // if - } // if - - UnlockGraphics( pMskGraphics ); - - rSalBitmap.ReleaseGraphics( pMskGraphics ); - } // if - - UnlockGraphics( pSrcGraphics ); - - rSalBitmap.ReleaseGraphics( pSrcGraphics ); - } // if - - EndGraphics( &maGraphicsData ); - } // if - } //if -} // SalGraphics::DrawBitmap + CGContextDrawImage(mrContext, CGRectMake (pPosAry->mnDestX, pPosAry->mnDestY, pPosAry->mnDestWidth, pPosAry->mnDestHeight), xImage); + if( isOffscreenCopy() ) + CGContextDrawImage(mrBitmapContext, CGRectMake (pPosAry->mnDestX, pPosAry->mnDestY, pPosAry->mnDestWidth, pPosAry->mnDestHeight), xImage); + CGImageRelease(xImage); + } + EndGraphics(); + } +} // ----------------------------------------------------------------------- -void SalGraphics::DrawMask( const SalTwoRect* pPosAry, - const SalBitmap& rSalBitmap, - SalColor nMaskColor - ) +SalBitmap* AquaSalGraphics::getBitmap( long nX, long nY, long nDX, long nDY ) { - if ( pPosAry != NULL ) + AquaSalBitmap* pBitmap = 0; + if( mrBitmapContext ) { - if ( BeginGraphics( &maGraphicsData ) ) + pBitmap = new AquaSalBitmap; + if( !pBitmap->Create( mrBitmapContext, nX, nY, nDX, nDY ) ) { - SalGraphics *pSrcGraphics = rSalBitmap.GetGraphics(); - - if ( LockGraphics( pSrcGraphics ) ) - { - const BitMap *pDstBitMap - = GetPortBitMapForCopyBits( maGraphicsData.mpCGrafPort ); - - if ( pDstBitMap != NULL ) - { - const BitMap *pSrcBitMap - = GetPortBitMapForCopyBits( pSrcGraphics->maGraphicsData.mpCGrafPort ); - - if ( pSrcBitMap != NULL ) - { - Rect aSrcRect; - Rect aDstRect; - Rect aPortBoundsRect; - RGBColor aMaskBackColor; - RgnHandle hMaskRgn = NULL; // Mask Region for QD CopyBits - short nCopyMode = 0; - - SalTwoRect2QDSrcRect( pPosAry, &aSrcRect ); - - SalTwoRect2QDDstRect( pPosAry, &aDstRect ); - - GetPortBounds( pSrcGraphics->maGraphicsData.mpCGrafPort, &aPortBoundsRect ); + delete pBitmap; + pBitmap = 0; + } + } - CheckRectBounds( &aPortBoundsRect, &aSrcRect, &aDstRect ); - - aMaskBackColor = SALColor2RGBColor( nMaskColor ); - - RGBBackColor( &aMaskBackColor ); - - nCopyMode = SelectCopyMode( &maGraphicsData ); - - // Now we can call QD CopyDeepMask to copy the bits from - // source rectangle to the destination rectangle using the - // the mask bits - - ::CopyDeepMask( pSrcBitMap, - pSrcBitMap, - pDstBitMap, - &aSrcRect, - &aSrcRect, - &aDstRect, - nCopyMode, - hMaskRgn - ); - } // if - } // if - - UnlockGraphics( pSrcGraphics ); - - rSalBitmap.ReleaseGraphics( pSrcGraphics ); - } // if - - EndGraphics( &maGraphicsData ); - } // if - } // if -} // SalGraphics::DrawMask - -// ----------------------------------------------------------------------- - -SalBitmap* SalGraphics::GetBitmap( long nX, - long nY, - long nDX, - long nDY - ) -{ - fprintf( stderr, - "<> SalGraphics::GetBitmap not yet implemented!\n" - ); - - return NULL; -} // SalGraphics::GetBitmap + if( !pBitmap ) + fprintf(stderr, "<> AquaSalGraphics::getBitmap() failed!\n" ); + return pBitmap; +} // ----------------------------------------------------------------------- -SalColor SalGraphics::GetPixel( long nX, - long nY - ) +SalColor AquaSalGraphics::getPixel( long nX, long nY ) { - RGBColor aRGBColor; SalColor nSalColor = 0; - short aHorizontalCoor = (short)nX; - short aVerticalCoor = (short)nY; - - GetCPixel( aHorizontalCoor, aVerticalCoor, &aRGBColor ); - - nSalColor = RGBColor2SALColor ( &aRGBColor ); - return nSalColor; -} // SalGraphics::GetPixel +} // ----------------------------------------------------------------------- -void SalGraphics::Invert( long nX, - long nY, - long nWidth, - long nHeight, - SalInvert nFlags - ) +void AquaSalGraphics::invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags ) { - // Implementation not yet complete - - if ( BeginGraphics( &maGraphicsData ) ) - { - short left = (short)nX; - short top = (short)nY; - short right = (short)nX + (short)nWidth; - short bottom = (short)nY + (short)nHeight; - Rect aRect; - - MacSetRect( &aRect, left, top, right, bottom ); - - ::MacInvertRect( &aRect ); - - EndGraphics( &maGraphicsData ); - } // if -} // SalGraphics::Invert + fprintf(stderr,"<<>> AquaSalGraphics::invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags ), not implemented!\n"); +} // ----------------------------------------------------------------------- -void SalGraphics::Invert( ULONG nPoints, - const SalPoint* pPtAry, - SalInvert nSalFlags - ) +void AquaSalGraphics::invert( ULONG nPoints, const SalPoint* pPtAry, SalInvert nSalFlags ) { - // Implementation not yet complete - - if ( ( pPtAry != NULL ) && ( nPoints > 1 ) ) - { - if ( BeginGraphics( &maGraphicsData ) ) - { - unsigned long nPolyEdges = nPoints; - unsigned long nPolyEdgeIndex = 0; - short nX = 0; - short nY = 0; - short nPenMode = patXor; - RgnHandle hPolyRgn = NULL; - CGrafPtr pCGrafPort = maGraphicsData.mpCGrafPort; - Pattern aPenPatGray; - - hPolyRgn = NewRgn (); - - if ( hPolyRgn != NULL ) - { - GetQDGlobalsGray( &aPenPatGray ); - - PenPat( &aPenPatGray ); - - SetPortPenMode( pCGrafPort, nPenMode ); - - // Begin region construction - - OpenRgn(); - - // Begin polygon regin construction - - MoveTo( pPtAry[0].mnX, pPtAry[0].mnY ); - - for ( nPolyEdgeIndex = 1; - nPolyEdgeIndex < nPolyEdges; - nPolyEdgeIndex++ - ) - { - MacLineTo( pPtAry[nPolyEdgeIndex].mnX, - pPtAry[nPolyEdgeIndex].mnY - ); - } // for - - MacLineTo( pPtAry[0].mnX, pPtAry[0].mnY ); - - // End polygon region construction - - CloseRgn( hPolyRgn ); - - // End region construction - - maGraphicsData.mnOSStatus = QDErr(); - - if ( maGraphicsData.mnOSStatus == noErr ) - { - MacInvertRgn( hPolyRgn ); - - DisposeRgn( hPolyRgn ); - - hPolyRgn = NULL; - } // if - } // if - - EndGraphics( &maGraphicsData ); - } // if - } // if -} // SalGraphics::Invert + fprintf(stderr,"<<>> AquaSalGraphics::invert( ULONG nPoints, const SalPoint* pPtAry, SalInvert nSalFlags ), not implemented!\n"); +} // ----------------------------------------------------------------------- -BOOL SalGraphics::DrawEPS( long nX, - long nY, - long nWidth, - long nHeight, - void* pPtr, - ULONG nSize - ) +BOOL AquaSalGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, ULONG nSize ) { - fprintf( stderr, - "<> SalGraphics::DrawEPS not yet implemented!\n" - ); + fprintf( stderr, "<> SalGraphics::DrawEPS not yet implemented!\n" ); return FALSE; -} // SalGraphics::DrawEPS - -// ----------------------------------------------------------------------- - -void SalGraphics::SetTextColor( SalColor nSalColor ) -{ - maGraphicsData.maFontColor = SALColor2RGBColor( nSalColor ); -} // SalGraphics::SetTextColor - -// ----------------------------------------------------------------------- - -USHORT SalGraphics::SetFont( ImplFontSelectData* pFont ) -{ - fprintf( stderr, - "<> SalGraphics::SetFont not yet implemented!\n" - ); - - return 0; -} // SalGraphics::SetFont +} // ----------------------------------------------------------------------- -long SalGraphics::GetCharWidth( sal_Unicode nChar1, - sal_Unicode nChar2, - long* pWidthAry - ) +void AquaSalGraphics::SetTextColor( SalColor nSalColor ) { - // Stub code - - sal_Unicode nCharCount = nChar2 - nChar1 + 1; - sal_Unicode i = 0; - - // Put a stub width in the pWidthAry that is passed to this method for - // both of the two Unicode characters and all characters between them. - // The width of nChar1 is put in element 0 of pWidthAry and the width - // of nChar2 is put in element nChar2 - nChar1 of pWidthAry - - for ( i = 0 ; i < nCharCount ; i++ ) - { - pWidthAry[i] = 10; - } // for - - fprintf( stderr, - "<> SalGraphics::GetCharWidth not yet implemented!\n" - ); - - return 1; -} // SalGraphics::GetCharWidth + RGBColor color; + color.red = (unsigned short) SALCOLOR_RED(nSalColor) * 65535.0 / 255.0; + color.green = (unsigned short) SALCOLOR_GREEN(nSalColor) * 65535.0 / 255.0; + color.blue = (unsigned short) SALCOLOR_BLUE(nSalColor) * 65535.0 / 255.0; + + ATSUAttributeTag aTag = kATSUColorTag; + ByteCount aValueSize = sizeof( color ); + ATSUAttributeValuePtr aValue = &color; + + OSStatus err = ATSUSetAttributes( maATSUStyle, 1, &aTag, &aValueSize, &aValue ); + if( err != noErr ) + { + fprintf( stderr, "AquaSalGraphics::SetTextColor() : Could not set font attributes!\n"); + } +} // ----------------------------------------------------------------------- -void SalGraphics::GetFontMetric( ImplFontMetricData* pMetric ) -{ - // Stub Code - - pMetric->mnAscent = 10; - pMetric->mnDescent = 10; - - fprintf( stderr, - "<> SalGraphics::GetFontMetric not yet implemented!\n" - ); -} // SalGraphics::GetFontMetric +void AquaSalGraphics::GetFontMetric( ImplFontMetricData* pMetric ) +{ + OSStatus err; + + ATSUFontID fontId; + Fixed ptSize; + + err = ATSUGetAttribute( maATSUStyle, kATSUFontTag, sizeof(ATSUFontID), &fontId, 0 ); + if( err == noErr ) + err = ATSUGetAttribute( maATSUStyle, kATSUSizeTag, sizeof(Fixed), &ptSize, 0); + + if( err != noErr ) + { + fprintf(stderr, "AquaSalGraphics::GetFontMetric() : could not get font attributes\n"); + return; + } + + long dpiX, dpiY; + GetResolution( dpiX, dpiY ); + + double fontSize = Fix2X( ptSize ); + ATSFontRef rFont = FMGetATSFontRefFromFont( fontId ); + + ATSFontMetrics aMetrics; + err = ATSFontGetHorizontalMetrics ( rFont, kATSOptionFlagsDefault, &aMetrics ); + + if( err == noErr ) + { + double f = (double) dpiY / 72.0; + pMetric->mnAscent = (aMetrics.ascent * fontSize * f); + pMetric->mnDescent = -(aMetrics.descent * fontSize * f); + pMetric->mnExtLeading = (aMetrics.leading * fontSize * f); + pMetric->mnIntLeading = 0; + pMetric->mnWidth = (aMetrics.avgAdvanceWidth * fontSize * f); + +// fprintf(stderr, "Metrics: ascent: %d descent: %d\n", pMetric->mnAscent, pMetric->mnDescent); + } + else + fprintf(stderr, "AquaSalGraphics::GetFontMetric() : could not get font metrics\n"); +} // ----------------------------------------------------------------------- -ULONG SalGraphics::GetKernPairs( ULONG nPairs, - ImplKernPairData* pKernPairs - ) +ULONG AquaSalGraphics::GetKernPairs( ULONG nPairs, ImplKernPairData* pKernPairs ) { fprintf( stderr, "<> SalGraphics::GetKernPairs not yet implemented!\n" ); return 0; -} // SalGraphics::GetKernPairs - -// ----------------------------------------------------------------------- - -ULONG SalGraphics::GetFontCodeRanges( sal_uInt32* pCodePairs ) const -{ - // TODO: try to get the necessary info from Aqua - return 0; -} // SalGraphics::GetFontCodeRanges +} // ----------------------------------------------------------------------- -void SalGraphics::GetDevFontList( ImplDevFontList *pList ) +void AquaSalGraphics::GetDevFontList( ImplDevFontList *pList ) { - if ( pList != NULL ) + if ( pList != NULL ) { SalData *pSalData = GetSalData(); if ( pSalData != NULL ) { FontList *pMacFontList = NULL; - ImplFontData *pDevFontData = NULL; - ImplFontData *pSysFontData = NULL; - - if ( pSalData->mpFontList != NULL ) + ImplMacFontData *pDevFontData = NULL; + ImplMacFontData *pSysFontData = NULL; + + if ( pSalData->mpFontList == NULL ) { pSalData->mpFontList = GetMacFontList(); - + pMacFontList = pSalData->mpFontList; - pSysFontData = pMacFontList->First(); - + pSysFontData = (ImplMacFontData*)pMacFontList->First(); + while ( pSysFontData != NULL ) { - pDevFontData = new ImplFontData; - - pDevFontData->mpSysData = pSysFontData; + ImplDevFontAttributes pAttributes; + pDevFontData = new ImplMacFontData(pAttributes,0,0,0); + + // pDevFontData->mpSysData = pSysFontData; + pDevFontData->mnFontID = pSysFontData->mnFontID; pDevFontData->maName = pSysFontData->maName; pDevFontData->maStyleName = pSysFontData->maStyleName; - pDevFontData->mnWidth = pSysFontData->mnWidth; - pDevFontData->mnHeight = pSysFontData->mnHeight; + // pDevFontData->mnWidth = pSysFontData->mnWidth; + // pDevFontData->mnHeight = pSysFontData->mnHeight; pDevFontData->meFamily = pSysFontData->meFamily; - pDevFontData->meCharSet = pSysFontData->meCharSet; + // pDevFontData->meCharSet = pSysFontData->meCharSet; pDevFontData->meScript = pSysFontData->meScript; pDevFontData->mePitch = pSysFontData->mePitch; pDevFontData->meWidthType = pSysFontData->meWidthType; pDevFontData->meWeight = pSysFontData->meWeight; pDevFontData->meItalic = pSysFontData->meItalic; pDevFontData->meType = pSysFontData->meType; - pDevFontData->mnVerticalOrientation = pSysFontData->mnVerticalOrientation; + // pDevFontData->mnVerticalOrientation = pSysFontData->mnVerticalOrientation; pDevFontData->mbOrientation = pSysFontData->mbOrientation; pDevFontData->mbDevice = pSysFontData->mbDevice; pDevFontData->mnQuality = pSysFontData->mnQuality; - + pList->Add( pDevFontData ); + + pSysFontData = (ImplMacFontData*)pMacFontList->Next(); + } + } + } + } +} + +// ----------------------------------------------------------------------- + +bool AquaSalGraphics::AddTempDevFont( ImplDevFontList*, const String& rFileURL, const String& rFontName ) +{ + return sal_False; +} + +// ----------------------------------------------------------------------- + +BOOL AquaSalGraphics::GetGlyphOutline( long nIndex, basegfx::B2DPolyPolygon& ) +{ + return sal_False; +} + +// ----------------------------------------------------------------------- - pSysFontData = pMacFontList->Next(); - } // while - } // if - } // if - } // if -} // SalGraphics::GetDevFontList +BOOL AquaSalGraphics::CreateFontSubset( const rtl::OUString& rToFile, + ImplFontData* pFont, + long* pGlyphIDs, + sal_uInt8* pEncoding, + sal_Int32* pWidths, + int nGlyphs, + FontSubsetInfo& rInfo // out parameter + ) +{ + return sal_False; +} // ----------------------------------------------------------------------- -void SalGraphics::DrawText( long nX, - long nY, - const xub_Unicode *pStr, - xub_StrLen nLen - ) +const void* AquaSalGraphics::GetEmbedFontData( ImplFontData* pFont, + const sal_Unicode* pUnicodes, + sal_Int32* pWidths, + FontSubsetInfo& rInfo, + long* pDataLen ) { - // The implementation is not yet complete + return NULL; +} - if ( ( pStr != NULL ) && ( nLen > 0 ) ) +// ----------------------------------------------------------------------- + +long AquaSalGraphics::GetGraphicsWidth() const +{ + if( mrWindow ) + { + Rect windowBounds; + GetWindowPortBounds ( mrWindow, &windowBounds); + return windowBounds.right - windowBounds.left; + } + else if( mrBitmapContext ) { - if ( BeginGraphics( &maGraphicsData ) ) - { - ByteString aByteString( pStr, - nLen, - gsl_getSystemTextEncoding() - ); + return CGBitmapContextGetWidth( mrContext ); + } + else + return 0; +} - const char *pTextBuffer = aByteString.GetBuffer(); +// ----------------------------------------------------------------------- - if ( pTextBuffer != NULL ) - { - short nFirstByte = 0; - short nByteCount = nLen; - const RGBColor aFontForeColor = maGraphicsData.maFontColor; - - RGBForeColor( &aFontForeColor ); - - MoveTo( nX, nY ); - - ::MacDrawText( pTextBuffer, nFirstByte, nByteCount ); - } // if - - EndGraphics( &maGraphicsData ); - } // if - } // if -} // SalGraphics::DrawText +void AquaSalGraphics::FreeEmbedFontData( const void* pData, long nDataLen ) +{ + +} // ----------------------------------------------------------------------- -void SalGraphics::DrawTextArray( long nX, - long nY, - const xub_Unicode* pStr, - xub_StrLen nLen, - const long* pDXAry - ) +BOOL AquaSalGraphics::GetGlyphBoundRect( long nIndex, Rectangle& ) { - fprintf( stderr, - "<> SalGraphics::DrawTextArray not yet implemented!\n" - ); -} // SalGraphics::DrawTextArray + return sal_False; +} // ----------------------------------------------------------------------- -BOOL SalGraphics::GetGlyphBoundRect( xub_Unicode cChar, - long* pX, - long* pY, - long* pWidth, - long* pHeight - ) +void AquaSalGraphics::GetDevFontSubstList( OutputDevice* ) { - fprintf( stderr, - "<> SalGraphics::GetGlyphBoundRect not yet implemented!\n" - ); + +} - return FALSE; -} // SalGraphics::GetGlyphBoundRect +// ----------------------------------------------------------------------- + +void AquaSalGraphics::DrawServerFontLayout( const ServerFontLayout& ) +{ + +} // ----------------------------------------------------------------------- -ULONG SalGraphics::GetGlyphOutline( xub_Unicode cChar, - USHORT** ppPolySizes, - SalPoint** ppPoints, - BYTE** ppFlags - ) +const std::map< sal_Unicode, sal_Int32 >* AquaSalGraphics::GetFontEncodingVector( ImplFontData* pFont, + const std::map< sal_Unicode, + rtl::OString >** ppNonEncoded ) { - fprintf( stderr, - "<> SalGraphics::GetGlyphOutline not yet implemented!\n" - ); + return NULL; +} - return 0; -} // SalGraphics::GetGlyphOutline +// ----------------------------------------------------------------------- -// ======================================================================= +USHORT AquaSalGraphics::SetFont( ImplFontSelectData* pFont, int nFallbackLevel ) +{ -// ======================================================================= + if( !pFont ) + { + // TODO: deselect existing font, release resources +// fprintf( stderr, "AquaSalGraphics::SetFont() : DEFAULT Font!\n"); + return 0; + } + + // store fontid and attributes, will be used in LayoutText + ImplMacFontData *pMacFont = static_cast( pFont->mpFontData ); + if( pMacFont ) + { + // Set Style Attributes (i.e. font parameters) + // convert pixel to point + long dpiX, dpiY; + GetResolution( dpiX, dpiY ); + Fixed fSize = FloatToFixed( ((double) pFont->mnHeight * 72.0) / (double) dpiY ); + Boolean bBold = (pFont->GetWeight() == WEIGHT_BOLD) ? TRUE : FALSE; + Boolean bItalic = (pFont->GetSlant() == ITALIC_NORMAL) ? TRUE : FALSE; + + ATSUAttributeTag aTag[] = + { + kATSUFontTag, + kATSUSizeTag, + kATSUQDBoldfaceTag, + kATSUQDItalicTag + }; + + ByteCount aValueSize[] = + { + sizeof(pMacFont->mnFontID), + sizeof(fSize), + sizeof(bBold), + sizeof(bItalic) + }; + + ATSUAttributeValuePtr aValue[] = + { + &pMacFont->mnFontID, // the original font id + &fSize, // the requested attributes + &bBold, + &bItalic + }; + + OSStatus err = ATSUSetAttributes( maATSUStyle, + sizeof(aTag) / sizeof(ATSUAttributeTag), + aTag, aValueSize, aValue ); + if( err != noErr ) + { + fprintf( stderr, "AquaSalGraphics::SetFont() : Could not set font attributes!\n"); + } + + mnATSUIRotation = (long) (pFont->mnOrientation / 10.0); + + UniString aName; + if ( pFont->mpFontData ) + aName = pFont->mpFontData->maName; + else + aName = pFont->maName.GetToken( 0 ); +/* + fprintf(stderr, "SetFont: %s Weight: %s, Slant: %s, Height: %d, Orientation: %d id: %d\n", + ::rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), + bBold ? "bold" : "normal", + bItalic ? "italic" : "normal", + pFont->mnHeight, + pFont->mnOrientation, + pMacFont->mnFontID); +*/ } + else + return 0; + + return 0; +} + +// ----------------------------------------------------------------------- + +ImplFontCharMap* AquaSalGraphics::GetImplFontCharMap() const +{ + return NULL; +} + +// ----------------------------------------------------------------------- + +/** returns the display id this window is mostly visible on */ +CGDirectDisplayID AquaSalGraphics::GetWindowDisplayID() const +{ + // TODO: Find the correct display! + return CGMainDisplayID(); +} + +// ----------------------------------------------------------------------- diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salgdiutils.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salgdiutils.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salgdiutils.cxx 2006-09-17 13:44:35.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salgdiutils.cxx 2006-10-14 15:26:55.000000000 +0200 @@ -36,551 +36,192 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#ifndef _SV_SALGDIUTILS_HXX - #include +#ifndef _SV_SALGDI_H +#include #endif -// ======================================================================= +#include -// ======================================================================= +// ---------------------------------------------------------------------- -short SelectCopyMode ( const SalGraphicsDataPtr pSalGraphicsData ) +void AquaSalGraphics::SetWindowGraphics( CarbonViewRef rView, CarbonWindowRef rWindow, bool bScreenCompatible ) { - short nCopyMode = 0; + mrView = rView; + mrWindow = rWindow; + mbScreen = bScreenCompatible; + + mbWindow = true; + mbPrinter = false; + mbVirDev = false; +} - if ( pSalGraphicsData->mnPenMode == patCopy ) - { - nCopyMode = srcCopy; - } // if - else - { - nCopyMode = srcXor; - } // else - - return nCopyMode; -} // SelectCopyMode - -// ======================================================================= - -// ======================================================================= - -RgnHandle GetPolygonRgn ( const unsigned long nPolyCount, - const unsigned long *pPoints, - PCONSTSALPOINT *ppPtAry, - OSStatus *rQDStatus - ) +void AquaSalGraphics::SetPrinterGraphics( CarbonViewRef rView, bool bScreenCompatible ) { - RgnHandle hSrcRgnA = NULL; - - hSrcRgnA = NewRgn(); - - if ( hSrcRgnA != NULL ) - { - RgnHandle hSrcRgnB = NULL; - - hSrcRgnB = NewRgn(); - - if ( hSrcRgnB != NULL ) - { - unsigned short nPolyEdgeIndex = 0; - unsigned short nPolyIndex = 0; - unsigned short nPolyEdges = 0; - - for ( nPolyIndex = 0; - nPolyIndex < nPolyCount; - nPolyIndex++ - ) - { - const SalPoint *pPtAry = ppPtAry[nPolyIndex]; - - nPolyEdges = pPoints[nPolyIndex]; - - // Begin region construction - - OpenRgn(); - - // Begin polygon construction - - MoveTo( pPtAry[0].mnX, pPtAry[0].mnY ); + mrView = rView; + mbScreen = bScreenCompatible; - for ( nPolyEdgeIndex = 1; - nPolyEdgeIndex < nPolyEdges; - nPolyEdgeIndex++ - ) - { - MacLineTo( pPtAry[nPolyEdgeIndex].mnX, - pPtAry[nPolyEdgeIndex].mnY - ); - } // for - - MacLineTo( pPtAry[0].mnX, pPtAry[0].mnY ); - - // End polygon construction - - CloseRgn( hSrcRgnB ); - - // End region construction - - *rQDStatus = QDErr(); + mbWindow = false; + mbPrinter = true; + mbVirDev = false; +} - if ( *rQDStatus == noErr ) - { - if ( nPolyIndex == 0 ) - { - MacCopyRgn( hSrcRgnB, hSrcRgnA ); - } // if - else - { - MacXorRgn( hSrcRgnA, hSrcRgnB, hSrcRgnA ); - } // else - } // if - } // for - - DisposeRgn( hSrcRgnB ); - - *rQDStatus = QDErr(); - - if ( *rQDStatus != noErr ) - { - DisposeRgn( hSrcRgnA ); - - hSrcRgnA = NULL; - } - - hSrcRgnB = NULL; - } // if - } // if - - return hSrcRgnA; -} // GetPolygonRgn - -// ======================================================================= - -// ======================================================================= - -OSStatus GetGDeviceBitDepth ( unsigned short *rGDeviceBitDepth ) +void AquaSalGraphics::SetVirDevGraphics( CGContextRef xContext, bool bScreenCompatible ) { - GDPtr pGDevice = NULL; - OSStatus nOSStatus = noErr; - - pGDevice = *GetGDevice ( ); - - nOSStatus = QDErr(); - - if ( ( pGDevice != NULL ) && ( nOSStatus == noErr ) ) - { - *rGDeviceBitDepth = GetPixDepth( pGDevice->gdPMap ); - } // if - - return nOSStatus; -} // GetGDeviceBitDepth - -// ----------------------------------------------------------------------- - -OSStatus GetGDeviceResolution ( long *rGDeviceHRes, - long *rGDeviceVRes - ) -{ - GDPtr pGDevice = NULL; - OSStatus nOSStatus = noErr; - - pGDevice = *GetGDevice ( ); + mrView = 0; + mbScreen = bScreenCompatible; - nOSStatus = QDErr(); + mbWindow = false; + mbPrinter = false; + mbVirDev = true; - if ( ( pGDevice != NULL ) && ( nOSStatus == noErr ) ) - { - long nGDeviceTop = pGDevice->gdRect.top; - long nGDeviceLeft = pGDevice->gdRect.left; - long nGDeviceBottom = pGDevice->gdRect.bottom; - long nGDeviceRight = pGDevice->gdRect.right; - - // From the current GDevice get its horizontal resolution - - *rGDeviceHRes = abs( nGDeviceRight - nGDeviceLeft ); - - // From the current GDevice get its vertical resolution + mrContext = xContext; + mrBitmapContext = xContext; +} - *rGDeviceVRes = abs( nGDeviceBottom - nGDeviceTop ); - } // if +// ---------------------------------------------------------------------- - return nOSStatus; -} // GetGDeviceResolution - -// ======================================================================= - -// ======================================================================= - -BOOL LockGraphics ( SalGraphics *rSalGraphics ) +void AquaSalGraphics::InitContextForPainting( CGContextRef xContext ) { - BOOL bCGrafPortLocked = FALSE; - - // [ed] 12/16/01 Don't lock QDView grafports. - - if ( ( rSalGraphics != NULL ) - && ( rSalGraphics->maGraphicsData.mpCGrafPort != NULL ) - && ( rSalGraphics->maGraphicsData.mbWindow != TRUE) - ) + // set up clipping area + if( mrClippingPath ) { - rSalGraphics->maGraphicsData.mnOSStatus - = LockPortBits( rSalGraphics->maGraphicsData.mpCGrafPort ); - - if ( rSalGraphics->maGraphicsData.mnOSStatus == noErr ) - { - rSalGraphics->maGraphicsData.mhGWorldPixMap - = GetPortPixMap( rSalGraphics->maGraphicsData.mpCGrafPort ); + CGContextBeginPath( xContext ); // discard any existing path + CGContextAddPath( xContext, mrClippingPath ); // set the current path to the clipping path + CGContextClip( xContext ); // use it for clipping + } - rSalGraphics->maGraphicsData.mnOSStatus = QDErr(); - - bCGrafPortLocked = TRUE; - } // if - } // if + // set RGB colorspace and line and fill colors + CGContextSetFillColorSpace( xContext, mrRGBColorSpace ); + CGContextSetFillColor( xContext, mpFillColor ); + CGContextSetStrokeColorSpace( xContext, mrRGBColorSpace ); + CGContextSetStrokeColor( xContext, mpLineColor ); +} - return bCGrafPortLocked; -} // LockGraphics - -// ----------------------------------------------------------------------- +// ---------------------------------------------------------------------- -BOOL UnlockGraphics ( SalGraphics *rSalGraphics ) +bool AquaSalGraphics::BeginGraphics () { - BOOL bCGrafPortUnlocked = FALSE; - - if ( ( rSalGraphics->maGraphicsData.mpCGrafPort != NULL ) - && ( rSalGraphics->maGraphicsData.mnOSStatus == noErr ) - ) - { - rSalGraphics->maGraphicsData.mnOSStatus - = UnlockPortBits( rSalGraphics->maGraphicsData.mpCGrafPort ); - - bCGrafPortUnlocked = TRUE; - } // if - - return bCGrafPortUnlocked; -} // UnlockGraphics - -// ======================================================================= - -// ======================================================================= - -BOOL BeginGraphics ( SalGraphicsDataPtr rSalGraphicsData ) -{ - BOOL bStartGraphics = FALSE; - - // Previous to entering this function, was there a QD error? - - if ( rSalGraphicsData->mnOSStatus == noErr ) + if( mnGraphics++ == 0 ) { - // Get the graph port and lock focus on it - - if ( rSalGraphicsData->mbWindow == TRUE ) - { - rSalGraphicsData->mpCGrafPort - = VCLGraphics_LockFocusCGrafPort( rSalGraphicsData->mhDC ); - } // if - - // [ed] 12/3/01 Check to make sure we've got a valid graph port - - if(rSalGraphicsData->mpCGrafPort && !IsValidPort(rSalGraphicsData->mpCGrafPort)) + if( mrWindow != NULL && mrContext == 0) { - fprintf(stderr, "Invalid port in BeginGraphics()\n"); - } - - if ( ( rSalGraphicsData->mpCGrafPort != NULL ) && IsValidPort(rSalGraphicsData->mpCGrafPort)) - { - // Get the port's pen attributes - - GetPortPenPixPat( rSalGraphicsData->mpCGrafPort, - rSalGraphicsData->mhPortPenPattern - ); - - GetPortPenSize( rSalGraphicsData->mpCGrafPort, - &(rSalGraphicsData->maPortPenSize) - ); - - GetPortPenLocation( rSalGraphicsData->mpCGrafPort, - &(rSalGraphicsData->maPortPenLocation) - ); - - rSalGraphicsData->mnPortPenMode - = GetPortPenMode( rSalGraphicsData->mpCGrafPort ); - - // Set the port pen mode to its new value - - SetPortPenMode( rSalGraphicsData->mpCGrafPort, - rSalGraphicsData->mnPenMode - ); - - // Set to the current offscreen world for Mac OS X - // only as everything is written to GWorld here - - SetGWorld( rSalGraphicsData->mpCGrafPort, NULL ); - - // Was there a QD error when we set the GWorld? - - rSalGraphicsData->mnOSStatus = QDErr(); - - if ( rSalGraphicsData->mnOSStatus == noErr ) + Rect windowBounds; + GetWindowPortBounds ( mrWindow, &windowBounds); + const int nWidth = windowBounds.right - windowBounds.left; + const int nHeight = windowBounds.bottom - windowBounds.top; + + if( mrBitmapContext ) { - // Get the PixMap associated with this particular CGrafPort - - rSalGraphicsData->mhGWorldPixMap - = GetPortPixMap( rSalGraphicsData->mpCGrafPort ); - - rSalGraphicsData->mnOSStatus = QDErr(); - - if ( ( rSalGraphicsData->mnOSStatus == noErr ) - && ( rSalGraphicsData->mhGWorldPixMap != NULL ) - ) + // check if window size changed and we need to create a new bitmap context + if( (CGBitmapContextGetWidth(mrBitmapContext) != nWidth) || (CGBitmapContextGetHeight(mrBitmapContext) != nHeight) ) { - // Get the current PixMap state, i.e., - // is it the memory associated with this - // PixMap is marked to be moved? - - rSalGraphicsData->mnGWorldFlags - = GetPixelsState( rSalGraphicsData->mhGWorldPixMap ); + void* pBuffer = CGBitmapContextGetData(mrBitmapContext); + CFRelease( mrBitmapContext ); + mrBitmapContext = 0; + free( pBuffer ); + } + } + + if( !mrBitmapContext ) + { + void* pData = malloc( nWidth * 4 * nHeight ); + if (pData ) + { + mrBitmapContext = CGBitmapContextCreate( pData, nWidth, nHeight, 8, nWidth * 4, mrRGBColorSpace, kCGImageAlphaNoneSkipFirst ); - if ( rSalGraphicsData->mnGWorldFlags == noErr ) - { - // if the PixMap is a relocatable block, - // then mark it as locked. - - // [ed] 12/16/01 Don't lock pixels of QDViews - - if ( !rSalGraphicsData->mbWindow && - LockPixels( rSalGraphicsData->mhGWorldPixMap ) ) - { - rSalGraphicsData->mbGWorldPixelsLocked = TRUE; - } // if - else - { - rSalGraphicsData->mbGWorldPixelsLocked = FALSE; - } // else - - // Set background color to white on this GWorld - - SetWhiteBackColor(); - - // Set foreground color to black on this GWorld - - SetBlackForeColor(); - - // If we get here then we may safely start drawing - // to our GWorld - - bStartGraphics = TRUE; - - // Now begin to set the clip region - - if ( ( rSalGraphicsData->mbClipRgnChanged == TRUE ) - && ( rSalGraphicsData->mhClipRgn != NULL ) - ) - { - // Set to the clip region - - SetClip( rSalGraphicsData->mhClipRgn ); - - // Was there an error after setting the clip region? - - rSalGraphicsData->mnOSStatus = QDErr(); - - // Set the new status flag for our port - - rSalGraphicsData->mbClipRgnChanged = FALSE; - } // if - } // if - else + if( !mrBitmapContext ) { - // [ed] 12/13/01 GWord graphics error flags set - - fprintf(stderr, "GWorld graphics flags indicate error in BeginGraphics()\n"); + free( pData ); } - } // if - else - { - // [ed] 12/13/01 GWorld graphics has no PixMap handle - - fprintf(stderr, "Valid GWorld, but no pixmap in BeginGraphics()\n"); } - } // if - else - { - // [ed] 12/13/01 Error checking - - fprintf(stderr, "QuickDraw error in BeginGraphics()\n"); } - } // if - } // if - - return bStartGraphics; -} // BeginGraphics - -// ----------------------------------------------------------------------- - -BOOL EndGraphics ( SalGraphicsDataPtr rSalGraphicsData ) -{ - BOOL bEndGraphics = FALSE; - - // Previous to entering this function, was there a QD error? - - if ( rSalGraphicsData->mnOSStatus == noErr ) - { - // Unlock our CGrafPort - - if ( ( rSalGraphicsData->mhGWorldPixMap != NULL ) - && ( rSalGraphicsData->mnGWorldFlags == noErr ) - && ( rSalGraphicsData->mbGWorldPixelsLocked ) - ) - { - // Set pixel state to its original state - // thus unlocking the PixMap - - SetPixelsState( rSalGraphicsData->mhGWorldPixMap, - rSalGraphicsData->mnGWorldFlags - ); - - rSalGraphicsData->mnOSStatus = QDErr(); - rSalGraphicsData->mbGWorldPixelsLocked = FALSE; - } // if - - // Reset the port's pen to its original attributes - /* + SetPortWindowPort (mrWindow); + if( noErr == QDBeginCGContext (GetWindowPort (mrWindow), &mrContext)) + { + if( mrBitmapContext ) + { + CGContextSaveGState( mrBitmapContext ); + InitContextForPainting( mrBitmapContext ); + } - [ed] 12/19/01 Apparently the pen pattern handle we retrieved - in BeginGraphics() is invalid by this point on OS 10.1. - By not attempting to revert the pen pattern, we can avoid - seg faulting the next time we draw into the port. - - +++ Is it necessary to reset the pen pattern? - - SetPortPenPixPat( rSalGraphicsData->mpCGrafPort, - rSalGraphicsData->mhPortPenPattern - ); - */ + CGContextTranslateCTM (mrContext, 0, nHeight); + CGContextScaleCTM (mrContext, 1.0, -1.0); - SetPortPenSize( rSalGraphicsData->mpCGrafPort, - rSalGraphicsData->maPortPenSize - ); - - SetPortPenMode( rSalGraphicsData->mpCGrafPort, - rSalGraphicsData->mnPortPenMode - ); - - // When we get here then the QD port must have changed(?) - // [ed] 12/19/01 This will commit the changes to reset the pen size - // and pen mode. - - PortChanged( rSalGraphicsData->mpCGrafPort ); - - // [ed] 6/1/02 Always flush the buffer, regardless of whether we're in - // a debug or non-debug build. - - // [ed] 12/19/01 Flush the QuickDraw buffer immediately. This helps - // with VCL debugging. - - if(QDIsPortBuffered(rSalGraphicsData->mpCGrafPort)) - QDFlushPortBuffer( rSalGraphicsData->mpCGrafPort, NULL ); - - // Unlock focus on the current NSView - - if ( rSalGraphicsData->mbWindow == TRUE ) + InitContextForPainting( mrContext ); + } + } + else if( mbVirDev ) { - VCLGraphics_UnLockFocusCGrafPort( rSalGraphicsData->mhDC ); - } // if - - // Was there an error after flushing the QuickDraw buffer - - rSalGraphicsData->mnOSStatus = QDErr(); - - // Set the new status flag for clip region - - rSalGraphicsData->mbClipRgnChanged = FALSE; - - // If we get here then we have safely written to our GWorld - - bEndGraphics = TRUE; - } // if - - return bEndGraphics; -} // EndGraphics - -// ======================================================================= - -// ======================================================================= - -void InitBrush ( SalGraphicsDataPtr rSalGraphicsData ) -{ - rSalGraphicsData->mbBrushTransparent = FALSE; - rSalGraphicsData->maBrushColor = GetBlackColor(); -} // InitBrush - -// ----------------------------------------------------------------------- - -void InitFont ( SalGraphicsDataPtr rSalGraphicsData ) -{ - rSalGraphicsData->maFontColor = GetBlackColor(); - rSalGraphicsData->mnFontID = kFontIDGeneva; - rSalGraphicsData->mnFontSize = 10; - rSalGraphicsData->mnFontStyle = normal; -} // InitFont - -// ----------------------------------------------------------------------- + CGContextSaveGState( mrBitmapContext ); + InitContextForPainting( mrBitmapContext ); + } + } -void InitGWorld ( SalGraphicsDataPtr rSalGraphicsData ) -{ - rSalGraphicsData->mbGWorldPixelsLocked = FALSE; - rSalGraphicsData->mbGWorldPixelsCopy = FALSE; - rSalGraphicsData->mbGWorldPixelsNew = FALSE; - rSalGraphicsData->mnGWorldFlags = noErr; - rSalGraphicsData->mhGWorldPixMap = NULL; -} // InitGWorld + if( mrContext ) + { + return true; + } + else + { + fprintf(stderr,"<<>> AquaSalGraphics::BeginGraphics() FAILED!!!!\n" ); + return false; + } +} // ----------------------------------------------------------------------- -void InitPen ( SalGraphicsDataPtr rSalGraphicsData ) +bool AquaSalGraphics::EndGraphics () { - long nMacOSPointSize = sizeof(MacOSPoint); - - rSalGraphicsData->maPenColor = GetBlackColor(); - rSalGraphicsData->mnPenMode = patCopy; - rSalGraphicsData->mbPenTransparent = FALSE; - - rSalGraphicsData->mnPortPenMode = patCopy; - rSalGraphicsData->mhPortPenPattern = NULL; - - memset( &(rSalGraphicsData->maPortPenSize), 0, nMacOSPointSize ); - memset( &(rSalGraphicsData->maPortPenLocation), 0, nMacOSPointSize ); -} // InitPen + if( (mnGraphics > 0) && (--mnGraphics == 0) ) + { + if( mrContext != NULL && mrWindow != NULL ) + { +/* TODO: Optimize this so we synchronize only on user event? + if( !mnUpdateGraphicsEvent ) + mnUpdateGraphicsEvent = Application::PostUserEvent( LINK( this, AquaSalGraphics, UpdateGraphics), 0 ); +*/ + CGContextSynchronize(mrContext); + QDEndCGContext (GetWindowPort(mrWindow), &mrContext); + mrContext = 0; + + if( mrBitmapContext ) + CGContextRestoreGState( mrBitmapContext ); + } + else if( mbVirDev ) + { + if( mrBitmapContext ) + CGContextRestoreGState( mrBitmapContext ); + } + } + return true; +} // ----------------------------------------------------------------------- -void InitQD ( SalGraphicsDataPtr rSalGraphicsData ) +/* +IMPL_LINK( AquaSalGraphics, UpdateGraphics, void*, EMPTYARG ) { - rSalGraphicsData->mhDC = NULL; - rSalGraphicsData->mpCGrafPort = NULL; - rSalGraphicsData->mpGWorld = NULL; -} // InitQD - -// ----------------------------------------------------------------------- + mnUpdateGraphicsEvent = 0; -void InitRegions ( SalGraphicsDataPtr rSalGraphicsData ) -{ - rSalGraphicsData->mhClipRgn = NULL; - rSalGraphicsData->mbClipRgnChanged = FALSE; -} // InitRegions + if( mrContext != NULL && mrWindow != NULL ) + { + SetPortWindowPort (mrWindow); + if( noErr == QDBeginCGContext (GetWindowPort (mrWindow), &mrWindowContext)) + { + Rect windowBounds; + GetWindowPortBounds ( mrWindow, &windowBounds); + CGImageRef xImage = CGBitmapContextCreateImage( mrContext ); + CGContextDrawImage(mrWindowContext, CGRectMake (windowBounds.left, windowBounds.top, windowBounds.right - windowBounds.left, windowBounds.bottom - windowBounds.top ), xImage); + CGImageRelease(xImage); + CGContextSynchronize(mrWindowContext); + QDEndCGContext (GetWindowPort(mrWindow), &mrWindowContext); + mrWindowContext = 0; + } + } + return 0; +} +*/ // ----------------------------------------------------------------------- -void InitStatusFlags ( SalGraphicsDataPtr rSalGraphicsData ) -{ - rSalGraphicsData->mbPrinter = FALSE; - rSalGraphicsData->mbVirDev = FALSE; - rSalGraphicsData->mbWindow = FALSE; - rSalGraphicsData->mbScreen = FALSE; - rSalGraphicsData->mnOSStatus = noErr; -} // InitStatusFlags - -// ======================================================================= - -// ======================================================================= - diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salmathutils.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salmathutils.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salmathutils.cxx 2006-09-17 13:44:50.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salmathutils.cxx 2006-10-13 23:55:43.000000000 +0200 @@ -40,6 +40,8 @@ #include #endif +#include + // ======================================================================= // ======================================================================= diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salnativewidgets.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salnativewidgets.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salnativewidgets.cxx 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salnativewidgets.cxx 2006-10-15 11:54:19.000000000 +0200 @@ -0,0 +1,634 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * 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 + * + ************************************************************************/ + +#ifndef _SV_SALCONST_H +#include +#endif + +#ifndef _SV_SALGDI_H +#include +#endif + +using ::rtl::OUString; + +/* + * IsNativeControlSupported() + * -------------------------- + * Returns TRUE if the platform supports native + * drawing of the control defined by nPart. + * + */ +BOOL AquaSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nPart ) +{ + bool bOk = FALSE; + + // Enable/disable experimental native controls code? + // + // To enable, set the environment variable AQUA_NATIVE_CONTROLS to TRUE + + static const char *pExperimental = getenv ("AQUA_NATIVE_CONTROLS"); + + if ( !pExperimental || strcasecmp(pExperimental, "TRUE") ) + return FALSE; + // End of experimental code enable/disable part + + switch( nType ) + { + case CTRL_PUSHBUTTON: + case CTRL_RADIOBUTTON: + case CTRL_CHECKBOX: + { + if( nPart == PART_ENTIRE_CONTROL ) + return true; + } + break; + case CTRL_SCROLLBAR: + { + if( nPart == PART_DRAW_BACKGROUND_HORZ || + nPart == PART_DRAW_BACKGROUND_VERT || + nPart == PART_ENTIRE_CONTROL || + nPart == HAS_THREE_BUTTONS ) + return true; + } + break; + case CTRL_EDITBOX: // ** TO DO ** + { + if( nPart == PART_ENTIRE_CONTROL || + nPart == HAS_BACKGROUND_TEXTURE ) + return false; + } + break; + case CTRL_MULTILINE_EDITBOX: // ** TO DO ** + { + if( nPart == PART_ENTIRE_CONTROL || + nPart == HAS_BACKGROUND_TEXTURE ) + return false; + } + break; + case CTRL_SPINBOX: // ** TO DO ** + { + if( nPart == PART_ENTIRE_CONTROL || + nPart == PART_ALL_BUTTONS || + nPart == HAS_BACKGROUND_TEXTURE ) + return false; + } + break; + case CTRL_SPINBUTTONS: // ** TO DO ** + { + if( nPart == PART_ENTIRE_CONTROL || + nPart == PART_ALL_BUTTONS ) + return false; + } + break; + case CTRL_COMBOBOX: // ** TO DO ** + { + if( nPart == PART_ENTIRE_CONTROL || + nPart == HAS_BACKGROUND_TEXTURE ) + return false; + } + break; + case CTRL_LISTBOX: // ** TO DO ** + { + if( nPart == PART_ENTIRE_CONTROL //|| + // nPart == PART_WINDOW || + // nPart == HAS_BACKGROUND_TEXTURE + ) + return true; + } + break; + case CTRL_TAB_ITEM: + case CTRL_TAB_PANE: + case CTRL_TAB_BODY: + case CTRL_FIXEDBORDER: // ** TO DO + CHECK IF NEEDED ** + { + if( nPart == PART_ENTIRE_CONTROL || + nPart == PART_TABS_DRAW_RTL ) + return false; + } + break; + case CTRL_TOOLBAR: // ** TO DO + CHECK IF NEEDED ** + { + if( nPart == PART_ENTIRE_CONTROL || + nPart == PART_DRAW_BACKGROUND_HORZ || + nPart == PART_DRAW_BACKGROUND_VERT || + nPart == PART_THUMB_HORZ || + nPart == PART_THUMB_VERT || + nPart == PART_BUTTON ) + return false; + } + break; + case CTRL_MENUBAR: // ** TO DO + CHECK IF NEEDED ** + { + if( nPart == PART_ENTIRE_CONTROL ) + return false; + } + break; + case CTRL_TOOLTIP: // ** TO DO + CHECK IF NEEDED ** + { + if( nPart == PART_ENTIRE_CONTROL ) + return false; + } + break; + case CTRL_MENU_POPUP: // ** TO DO + CHECK IF NEEDED ** + { + if( nPart == PART_ENTIRE_CONTROL || + nPart == PART_MENU_ITEM || + nPart == PART_MENU_ITEM_CHECK_MARK || + nPart == PART_MENU_ITEM_RADIO_MARK ) + return false; + } + break; + } + + return bOk; +} + +/* + * HitTestNativeControl() + * + * If the return value is TRUE, bIsInside contains information whether + * aPos was or was not inside the native widget specified by the + * nType/nPart combination. + */ +BOOL AquaSalGraphics::hitTestNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, + const Point& rPos, SalControlHandle& rControlHandle, BOOL& rIsInside ) +{ + + if ( nType == CTRL_SCROLLBAR ) + { + + // outside by default + rIsInside = FALSE; + + // make position relative to rControlRegion + + // [ericb] rControlRegion.GetBoundRect() returns the rectangle where native control (the scrollbar is located + // rPos : the structure containing the cursor position + // aPos = relative position of current cursor + + Point aPos = rPos - rControlRegion.GetBoundRect().TopLeft(); + Rectangle ControlRect = rControlRegion.GetBoundRect(); + + // will print the values where the scrollbar is drawn. When Horizontal scrollbar is drawn. + + fprintf(stderr, "ControlRect.x = %f \n ", static_cast(ControlRect.Left())); + fprintf(stderr, "ControlRect.y = %f \n ", static_cast(ControlRect.Top())); + fprintf(stderr, "ControlRect.width = %f \n", static_cast(ControlRect.Right()) - static_cast(ControlRect.Left())); + fprintf(stderr, "ControlRect.height = %f \n", static_cast(ControlRect.Bottom()) - static_cast(ControlRect.Top())); + + float Width = static_cast(ControlRect.Right()) - static_cast(ControlRect.Left()); + float Height = static_cast(ControlRect.Bottom()) - static_cast(ControlRect.Top()); + + + fprintf(stderr, "Width = %f \n", Width); + fprintf(stderr, "Height = %f \n", Height); + + // depending on nPart, we have to test different regions + + switch ( nPart ) + { + case PART_BUTTON_LEFT: + + if ( aPos.getX() > (Width-40) && aPos.getX() < (Width-20) ) + { + fprintf(stderr, "button left \n"); + rIsInside = TRUE; + } + break; + + case PART_BUTTON_RIGHT: + if ( aPos.getX() > (Width-20) && aPos.getX() < Width ) + { + fprintf(stderr, "button right \n"); + rIsInside = TRUE; + } + break; + + case PART_BUTTON_UP: + if ( aPos.getY() > (Height-40) && aPos.getY() < (Height-20) ) + { + fprintf(stderr, "button up \n"); + rIsInside = TRUE; + } + break; + + case PART_BUTTON_DOWN: + if ( aPos.getY() > (Height-20) && aPos.getY() < (Height) ) + { + fprintf(stderr, "button down \n"); + rIsInside = TRUE; + } + break; + + default: rIsInside = FALSE; + break; + } + + return TRUE; + } // CTRL_SCROLLBAR + + return FALSE; +} + +/* + kThemeStateInactive = 0, + kThemeStateActive = 1, + kThemeStatePressed = 2, + kThemeStateRollover = 6, + kThemeStateUnavailable = 7, + kThemeStateUnavailableInactive = 8 + kThemeStatePressedUp = 2, + kThemeStatePressedDown = 3 + +#define CTRL_STATE_ENABLED 0x0001 +#define CTRL_STATE_FOCUSED 0x0002 +#define CTRL_STATE_PRESSED 0x0004 +#define CTRL_STATE_ROLLOVER 0x0008 +#define CTRL_STATE_HIDDEN 0x0010 +#define CTRL_STATE_DEFAULT 0x0020 +#define CTRL_STATE_SELECTED 0x0040 +#define CTRL_CACHING_ALLOWED 0x8000 // set when the control is completely visible (i.e. not clipped) +*/ +static ThemeDrawState getState( ControlState nState ) +{ + if( (nState & CTRL_STATE_ENABLED) == 0 ) + { + if( (nState & CTRL_STATE_HIDDEN) == 0 ) + { + return kThemeStateInactive; + } + else + { + return kThemeStateUnavailableInactive; + } + } + + if( (nState & CTRL_STATE_HIDDEN) != 0 ) + { + return kThemeStateUnavailable; + } + + if( (nState & CTRL_STATE_PRESSED) != 0 ) + return kThemeStatePressed; + + if( (nState & CTRL_STATE_ROLLOVER) != 0 ) + return kThemeStateRollover; + + return kThemeStateActive; +} + +/* + * DrawNativeControl() + * + * Draws the requested control described by nPart/nState. + * + * rControlRegion: The bounding region of the complete control in VCL frame coordinates. + * aValue: An optional value (tristate/numerical/string) + * rControlHandle: Carries platform dependent data and is maintained by the WinSalGraphics implementation. + * aCaption: A caption or title string (like button text etc) + */ +BOOL AquaSalGraphics::drawNativeControl( ControlType nType, + ControlPart nPart, + const Region& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + SalControlHandle& rControlHandle, + const rtl::OUString& aCaption ) +{ + BOOL bOk = FALSE; + + Rectangle buttonRect = rControlRegion.GetBoundRect(); + + HIRect rc; + rc.origin.x = static_cast(buttonRect.Left()); + rc.origin.y = static_cast(buttonRect.Top()); + rc.size.width = static_cast(buttonRect.Right()) - + static_cast(buttonRect.Left()); + rc.size.height = static_cast(buttonRect.Bottom()) - + static_cast(buttonRect.Top()); + + /** Scrollbar parts code equivalent ** + PART_BUTTON_UP 101 + PART_BUTTON_DOWN 102 + PART_THUMB_VERT 211 + PART_TRACK_VERT_UPPER 201 + PART_TRACK_VERT_LOWER 203 + + PART_DRAW_BACKGROUND_HORZ 1000 + PART_DRAW_BACKGROUND_VERT 1001 + **/ + + switch( nType ) + { + case CTRL_PUSHBUTTON: + case CTRL_RADIOBUTTON: + case CTRL_CHECKBOX: + { + HIThemeButtonDrawInfo aInfo; + switch( nType ) + { + case CTRL_RADIOBUTTON: aInfo.kind = kThemeRadioButton; + break; + case CTRL_CHECKBOX: aInfo.kind = kThemeCheckBox; + break; + case CTRL_LISTBOX: + { + switch( nPart ) + case PART_ENTIRE_CONTROL: aInfo.kind = kThemePopupButton; + break; + } + break; + case CTRL_PUSHBUTTON: + { + if( rc.size.width == rc.size.height ) + { + aInfo.kind = kThemeBevelButton; + break; + } + else if( rc.size.width >= 20 && + rc.size.height >= 20 ) + { + float difference = ((rc.size.height - 20) / 2); + aInfo.kind = kThemePushButton; + rc.size.height = 20; + rc.origin.y += difference + 1; + break; + } + } + } + + aInfo.state = getState( nState ); + switch( aValue.getTristateVal() ) + { + case BUTTONVALUE_ON: aInfo.value = kThemeButtonOn; + break; + case BUTTONVALUE_OFF: aInfo.value = kThemeButtonOff; + break; + case BUTTONVALUE_MIXED: + case BUTTONVALUE_DONTKNOW: + default: aInfo.value = kThemeButtonMixed; + break; + } + + aInfo.adornment = (( nState & CTRL_STATE_DEFAULT ) != 0) ? + kThemeAdornmentDefault : + kThemeAdornmentNone; + if( (nState & CTRL_STATE_FOCUSED) != 0 ) + aInfo.adornment |= kThemeAdornmentFocus; + if( BeginGraphics() ) + { + HIThemeDrawButton( &rc, &aInfo, mrContext, + kHIThemeOrientationNormal, NULL ); + EndGraphics(); + return true; + } + else + return false; + } + break; + case CTRL_SCROLLBAR: + { + printf("Part in scrollbar: %d\n", nPart); + ScrollbarValue* pScrollbarVal = (ScrollbarValue *)(aValue.getOptionalVal()); + + if( nPart == PART_DRAW_BACKGROUND_VERT || + nPart == PART_DRAW_BACKGROUND_HORZ ) + { + HIThemeTrackDrawInfo aTrackDraw; + aTrackDraw.version = 0; + aTrackDraw.kind = kThemeMediumScrollBar; + aTrackDraw.bounds = rc; + aTrackDraw.min = pScrollbarVal->mnMin; + aTrackDraw.max = pScrollbarVal->mnMax - pScrollbarVal->mnVisibleSize; + aTrackDraw.value = pScrollbarVal->mnCur; + aTrackDraw.reserved = 0; + aTrackDraw.attributes = kThemeTrackShowThumb; + if( nPart == PART_DRAW_BACKGROUND_HORZ ) + aTrackDraw.attributes |= kThemeTrackHorizontal; + aTrackDraw.enableState = kThemeTrackActive; + + ScrollBarTrackInfo aScrollInfo; + aScrollInfo.viewsize = pScrollbarVal->mnVisibleSize; + aScrollInfo.pressState = 0; + + if ( pScrollbarVal->mnButton1State & CTRL_STATE_ENABLED ) + { + if ( pScrollbarVal->mnButton1State & CTRL_STATE_PRESSED ) + aScrollInfo.pressState = kThemeTopOutsideArrowPressed; + } + + if ( pScrollbarVal->mnButton2State & CTRL_STATE_ENABLED ) + { + if ( pScrollbarVal->mnButton2State & CTRL_STATE_PRESSED ) + aScrollInfo.pressState = kThemeBottomOutsideArrowPressed; + } + + if ( pScrollbarVal->mnThumbState & CTRL_STATE_ENABLED ) + { + if ( pScrollbarVal->mnThumbState & CTRL_STATE_PRESSED ) + aScrollInfo.pressState = kThemeThumbPressed; + } + + aTrackDraw.trackInfo.scrollbar = aScrollInfo; + + if ( BeginGraphics() ) + { + HIThemeDrawTrack( &aTrackDraw, NULL, mrContext, kHIThemeOrientationNormal ); + EndGraphics(); + return true; + } + else + return false; + } + } + } + return bOk; +} + +/* + * DrawNativeControlText() + * + * OPTIONAL. Draws the requested text for the control described by nPart/nState. + * Used if text not drawn by DrawNativeControl(). + * + * rControlRegion: The bounding region of the complete control in VCL frame coordinates. + * aValue: An optional value (tristate/numerical/string) + * rControlHandle: Carries platform dependent data and is maintained by the WinSalGraphics implementation. + * aCaption: A caption or title string (like button text etc) + */ +BOOL AquaSalGraphics::drawNativeControlText( ControlType nType, ControlPart nPart, const Region& rControlRegion, + ControlState nState, const ImplControlValue& aValue, + SalControlHandle& rControlHandle, const rtl::OUString& aCaption ) +{ + printf("In text\n"); + return( TRUE ); +} + + +/* + * GetNativeControlRegion() + * + * If the return value is TRUE, rNativeBoundingRegion + * contains the true bounding region covered by the control + * including any adornment, while rNativeContentRegion contains the area + * within the control that can be safely drawn into without drawing over + * the borders of the control. + * + * rControlRegion: The bounding region of the control in VCL frame coordinates. + * aValue: An optional value (tristate/numerical/string) + * rControlHandle: Carries platform dependent data and is maintained by the WinSalGraphics implementation. + * aCaption: A caption or title string (like button text etc) + */ +BOOL AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, + const ImplControlValue& aValue, SalControlHandle& rControlHandle, const rtl::OUString& aCaption, + Region &rNativeBoundingRegion, Region &rNativeContentRegion ) + +{ + BOOL toReturn = FALSE; + + if ( nType == CTRL_SCROLLBAR && nPart == PART_BUTTON_UP ) + { + printf("Part: %d\n", nPart); + Rectangle buttonRect = rControlRegion.GetBoundRect(); + /* + HIRect hirc; + hirc.origin.x = static_cast(buttonRect.Left()); + hirc.origin.y = static_cast(buttonRect.Top()); + hirc.size.width = static_cast(buttonRect.Right()+1) - static_cast(buttonRect.Left()); + hirc.size.height = static_cast(buttonRect.Bottom()+1) - static_cast(buttonRect.Top()); + printf("Width: %f, height: %f\n", hirc.size.width, hirc.size.height); + */ + printf("Coor of Rectangle: %d, %d, %d, %d\n", buttonRect.Left(), buttonRect.Top(), buttonRect.Right(), buttonRect.Bottom()); + + Rectangle rect = Rectangle( 122, 189, 137, 364 ); + + rNativeBoundingRegion = rect; + rNativeContentRegion = rNativeBoundingRegion; + + toReturn = TRUE; + +/* HIThemeTrackDrawInfo aTrackDraw; + aTrackDraw.version = 0; + aTrackDraw.kind = kThemeMediumScrollBar; + aTrackDraw.bounds = hirc; + aTrackDraw.reserved = 0; + aTrackDraw.attributes = kThemeTrackShowThumb; + if( nPart == PART_DRAW_BACKGROUND_HORZ ) + aTrackDraw.attributes |= kThemeTrackHorizontal; + aTrackDraw.enableState = kThemeTrackActive; + + ThemeScrollBarArrowStyle aArrowStyle; + GetThemeScrollBarArrowStyle( &aArrowStyle );*/ + /* + if( aArrowStyle == kThemeScrollBarArrowsLowerRight ) + { + printf("In arrowStyle together\n"); + HIRect arrowRect; + HIThemeGetTrackPartBounds( &aTrackDraw, kControlUpButtonPart, &arrowRect ); + + Rectangle newRectangle = Rectangle( static_cast(arrowRect.origin.x), + static_cast(arrowRect.origin.y), + 16,//static_cast(arrowRect.origin.x + arrowRect.size.width), + 16);//static_cast(arrowRect.origin.y + arrowRect.size.height)); + + printf("BUTTON UP HIRECT\n"); + printf("x: %f, y: %f, width: %f, height: %f\n", arrowRect.origin.x, + arrowRect.origin.y, arrowRect.size.width, arrowRect.size.height); + + printf("BUTTON VCL\n"); + printf("x: %d, y: %d, width: %d, height: %d\n", newRectangle.Left(), + newRectangle.Top(), newRectangle.Right()+1-newRectangle.Left(), + newRectangle.Bottom()+1 - newRectangle.Top()); + + rNativeBoundingRegion = newRectangle; + rNativeContentRegion = newRectangle; + toReturn = TRUE; + }*/ + // Rectangle newRectangle = Rectangle( 300, 300, 100, 100); + // rNativeBoundingRegion = newRectangle; + // rNativeContentRegion = newRectangle; + // toReturn = TRUE; + } + printf("To return: %d\n", toReturn); + return toReturn; +} + + /* + BOOL bRet = FALSE; + + HDC hDC = GetDC( mhWnd ); + if( nType == CTRL_TOOLBAR ) + { + if( nPart == PART_THUMB_HORZ || nPart == PART_THUMB_VERT ) + { + / * + // the vertical gripper is not supported in most themes and it makes no + // sense to only support horizontal gripper + + HTHEME hTheme = getThemeHandle( mhWnd, L"Rebar"); + if( hTheme ) + { + Rectangle aRect( ImplGetThemeRect( hTheme, hDC, nPart == PART_THUMB_HORZ ? RP_GRIPPERVERT : RP_GRIPPER, + 0, rControlRegion.GetBoundRect() ) ); + if( nPart == PART_THUMB_HORZ && !aRect.IsEmpty() ) + { + Rectangle aVertRect( 0, 0, aRect.getHeight(), aRect.getWidth() ); + rNativeContentRegion = aVertRect; + } + else + rNativeContentRegion = aRect; + rNativeBoundingRegion = rNativeContentRegion; + if( !rNativeContentRegion.IsEmpty() ) + bRet = TRUE; + } + * / + } + if( nPart == PART_BUTTON ) + { + HTHEME hTheme = getThemeHandle( mhWnd, L"Toolbar"); + if( hTheme ) + { + Rectangle aRect( ImplGetThemeRect( hTheme, hDC, TP_SPLITBUTTONDROPDOWN, + TS_HOT, rControlRegion.GetBoundRect() ) ); + rNativeContentRegion = aRect; + rNativeBoundingRegion = rNativeContentRegion; + if( !rNativeContentRegion.IsEmpty() ) + bRet = TRUE; + } + } + } + ReleaseDC( mhWnd, hDC ); + return( bRet ); + */ diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salogl.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salogl.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salogl.cxx 2006-09-17 13:45:02.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salogl.cxx 2006-10-13 23:55:50.000000000 +0200 @@ -39,57 +39,85 @@ #ifndef _SV_SALGDI_HXX #include #endif +#ifndef _SV_SALGDI_H +#include +#endif #ifndef _SV_SALOGL_HXX #include #endif +#ifndef _SV_SALOGL_H +#include +#endif // ======================================================================== // Initialize static data members -VCLVIEW SalOpenGL::mhOGLLastDC = 0; -ULONG SalOpenGL::mnOGLState = OGL_STATE_UNLOADED; +CarbonViewRef AquaSalOpenGL::mhOGLLastDC = 0; +ULONG AquaSalOpenGL::mnOGLState = OGL_STATE_UNLOADED; // ======================================================================== -SalOpenGL::SalOpenGL( SalGraphics* pGraphics ) +AquaSalOpenGL::AquaSalOpenGL( SalGraphics* pGraphics ) { } // ------------------------------------------------------------------------ -SalOpenGL::~SalOpenGL() +AquaSalOpenGL::~AquaSalOpenGL() { } // ------------------------------------------------------------------------ -BOOL SalOpenGL::Create() +BOOL AquaSalOpenGL::Create() { return FALSE; } // ------------------------------------------------------------------------ -void SalOpenGL::Release() +void AquaSalOpenGL::Release() { } // ------------------------------------------------------------------------ -void *SalOpenGL::GetOGLFnc( const char* pFncName ) +oglFunction AquaSalOpenGL::GetOGLFnc( const char* pFncName ) { return NULL; } // ------------------------------------------------------------------------ -void SalOpenGL::OGLEntry( SalGraphics* pGraphics ) +void AquaSalOpenGL::OGLEntry( SalGraphics* pGraphics ) { } // ------------------------------------------------------------------------ -void SalOpenGL::OGLExit( SalGraphics* pGraphics ) +void AquaSalOpenGL::OGLExit( SalGraphics* pGraphics ) +{ +} + + + + + + + + +void AquaSalOpenGL::StartScene( SalGraphics* pGraphics ) +{ + +} + +bool AquaSalOpenGL::IsValid() +{ + +} + +void AquaSalOpenGL::StopScene() { + } diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salprn.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salprn.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salprn.cxx 2006-09-17 13:45:29.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salprn.cxx 2006-10-13 23:56:07.000000000 +0200 @@ -45,78 +45,81 @@ #ifndef _SV_SALPRN_HXX #include #endif +#ifndef _SV_SALPRN_H +#include +#endif // ======================================================================= -SalInfoPrinter::SalInfoPrinter() +AquaSalInfoPrinter::AquaSalInfoPrinter() { } // ----------------------------------------------------------------------- -SalInfoPrinter::~SalInfoPrinter() +AquaSalInfoPrinter::~AquaSalInfoPrinter() { } // ----------------------------------------------------------------------- -SalGraphics* SalInfoPrinter::GetGraphics() +SalGraphics* AquaSalInfoPrinter::GetGraphics() { return NULL; } // ----------------------------------------------------------------------- -void SalInfoPrinter::ReleaseGraphics( SalGraphics* ) +void AquaSalInfoPrinter::ReleaseGraphics( SalGraphics* ) { } // ----------------------------------------------------------------------- -BOOL SalInfoPrinter::Setup( SalFrame* pFrame, ImplJobSetup* pSetupData ) +BOOL AquaSalInfoPrinter::Setup( SalFrame* pFrame, ImplJobSetup* pSetupData ) { return FALSE; } // ----------------------------------------------------------------------- -BOOL SalInfoPrinter::SetPrinterData( ImplJobSetup* pSetupData ) +BOOL AquaSalInfoPrinter::SetPrinterData( ImplJobSetup* pSetupData ) { return FALSE; } // ----------------------------------------------------------------------- -BOOL SalInfoPrinter::SetData( ULONG nFlags, ImplJobSetup* pSetupData ) +BOOL AquaSalInfoPrinter::SetData( ULONG nFlags, ImplJobSetup* pSetupData ) { return FALSE; } // ----------------------------------------------------------------------- -ULONG SalInfoPrinter::GetPaperBinCount( const ImplJobSetup* pSetupData ) +ULONG AquaSalInfoPrinter::GetPaperBinCount( const ImplJobSetup* pSetupData ) { return 0; } // ----------------------------------------------------------------------- -XubString SalInfoPrinter::GetPaperBinName( const ImplJobSetup* pSetupData, ULONG nPaperBin ) +XubString AquaSalInfoPrinter::GetPaperBinName( const ImplJobSetup* pSetupData, ULONG nPaperBin ) { return XubString(); } // ----------------------------------------------------------------------- -ULONG SalInfoPrinter::GetCapabilities( const ImplJobSetup* pSetupData, USHORT nType ) +ULONG AquaSalInfoPrinter::GetCapabilities( const ImplJobSetup* pSetupData, USHORT nType ) { return 0; } // ----------------------------------------------------------------------- -void SalInfoPrinter::GetPageInfo( const ImplJobSetup*, +void AquaSalInfoPrinter::GetPageInfo( const ImplJobSetup*, long& rOutWidth, long& rOutHeight, long& rPageOffX, long& rPageOffY, long& rPageWidth, long& rPageHeight ) @@ -125,19 +128,19 @@ // ======================================================================= -SalPrinter::SalPrinter() +AquaSalPrinter::AquaSalPrinter() { } // ----------------------------------------------------------------------- -SalPrinter::~SalPrinter() +AquaSalPrinter::~AquaSalPrinter() { } // ----------------------------------------------------------------------- -BOOL SalPrinter::StartJob( const XubString* pFileName, +BOOL AquaSalPrinter::StartJob( const XubString* pFileName, const XubString& rJobName, const XubString&, ULONG nCopies, BOOL bCollate, @@ -148,35 +151,54 @@ // ----------------------------------------------------------------------- -BOOL SalPrinter::EndJob() +BOOL AquaSalPrinter::EndJob() { return TRUE; } // ----------------------------------------------------------------------- -BOOL SalPrinter::AbortJob() +BOOL AquaSalPrinter::AbortJob() { return TRUE; } // ----------------------------------------------------------------------- -SalGraphics* SalPrinter::StartPage( ImplJobSetup* pSetupData, BOOL bNewJobData ) +SalGraphics* AquaSalPrinter::StartPage( ImplJobSetup* pSetupData, BOOL bNewJobData ) { return NULL; } // ----------------------------------------------------------------------- -BOOL SalPrinter::EndPage() +BOOL AquaSalPrinter::EndPage() { return TRUE; } // ----------------------------------------------------------------------- -ULONG SalPrinter::GetErrorCode() +ULONG AquaSalPrinter::GetErrorCode() { return 0; } + +//////////////////////////// +////// IMPLEMENT US ///// +//////////////////////////// + +DuplexMode AquaSalInfoPrinter::GetDuplexMode( const ImplJobSetup* pSetupData ) +{ + return DUPLEX_UNKNOWN; +} + +void AquaSalInfoPrinter::InitPaperFormats( const ImplJobSetup* pSetupData ) +{ + +} + +int AquaSalInfoPrinter::GetLandscapeAngle( const ImplJobSetup* pSetupData ) +{ + return 0; +} \ No newline at end of file diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salvd.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salvd.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/gdi/salvd.cxx 2006-09-17 13:46:05.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/gdi/salvd.cxx 2006-10-13 23:56:25.000000000 +0200 @@ -37,230 +37,135 @@ #include "precompiled_vcl.hxx" #ifndef _SV_SALVD_HXX - #include +#include +#endif +#ifndef _SV_SALVD_H +#include +#endif +#ifndef _SV_SALINST_H +#include #endif -// ======================================================================= - -// ======================================================================= +// ----------------------------------------------------------------------- -static BOOL InitVirtualDeviceGWorld ( SalVirDevDataPtr rSalVirDevData ) +SalVirtualDevice* AquaSalInstance::CreateVirtualDevice( SalGraphics* pGraphics, + long nDX, long nDY, USHORT nBitCount, const SystemGraphicsData *pData ) { - BOOL bVirtualDeviceGWorldInited = FALSE; - - if ( ( rSalVirDevData != NULL ) - && ( rSalVirDevData->mpGraphics != NULL ) - ) - { - Rect aBoundsRect; - short nRectLeft = 0; - short nRectTop = 0; - short nRectRight = rSalVirDevData->mnWidth; - short nRectBottom = rSalVirDevData->mnHeight; - short nPixelDepth = rSalVirDevData->mnBitCount; - GWorldPtr pGWorld = NULL; - CTabHandle hCTable = NULL; - GDHandle hGDevice = NULL; - GWorldFlags nFlags = 0; // [ed] 12/1/01 Allow offscreen gworlds - OSStatus nOSStatus = noErr; - - // Set the dimensions of the GWorldPtr - - MacSetRect( &aBoundsRect, nRectLeft, nRectTop, nRectRight, nRectBottom ); - - // Create the offscreen graphics context - - nOSStatus = NewGWorld( &pGWorld, - nPixelDepth, - &aBoundsRect, - hCTable, - hGDevice, - nFlags - ); - - // If NewGWorld failed, try again with different flags + return new AquaSalVirtualDevice( static_cast< AquaSalGraphics* >( pGraphics ), nDX, nDY, nBitCount, pData ); +} - if ( nOSStatus != noErr ) - { - nFlags = noErr; - - nOSStatus = NewGWorld( &pGWorld, - nPixelDepth, - &aBoundsRect, - hCTable, - hGDevice, - nFlags - ); - } // if - - if ( ( nOSStatus == noErr ) - && ( pGWorld != NULL ) - ) - { - // Lock the virtual GWorld's port bits - - rSalVirDevData->mpGraphics->maGraphicsData.mnOSStatus - = LockPortBits( pGWorld ); - - if ( rSalVirDevData->mpGraphics->maGraphicsData.mnOSStatus == noErr ) - { - // Initialize the virtual graph port - - rSalVirDevData->mpGraphics->maGraphicsData.mpCGrafPort - = pGWorld; - - rSalVirDevData->mpGraphics->maGraphicsData.mpGWorld - = pGWorld; - - // Initialize virtual port's GWorld attributes - - rSalVirDevData->mpGraphics->maGraphicsData.mhGWorldPixMap - = GetGWorldPixMap( pGWorld ); - - // Unlock virtual GWorld's port bits - - UnlockPortBits( pGWorld ); - } // if - - // Initialize virtual port's GWorld attributes - - rSalVirDevData->mpGraphics->maGraphicsData.mbGWorldPixelsLocked = FALSE; - rSalVirDevData->mpGraphics->maGraphicsData.mbGWorldPixelsCopy = FALSE; - rSalVirDevData->mpGraphics->maGraphicsData.mbGWorldPixelsNew = FALSE; - rSalVirDevData->mpGraphics->maGraphicsData.mnGWorldFlags = noErr; - - // Initialize the virtual port's brush attributes - - rSalVirDevData->mpGraphics->maGraphicsData.mbBrushTransparent = FALSE; - rSalVirDevData->mpGraphics->maGraphicsData.maBrushColor = GetBlackColor( ); - - // Initialize the virtual port's font attributes - - rSalVirDevData->mpGraphics->maGraphicsData.maFontColor = GetBlackColor( ); - rSalVirDevData->mpGraphics->maGraphicsData.mnFontID = kFontIDGeneva; - rSalVirDevData->mpGraphics->maGraphicsData.mnFontSize = 10; - rSalVirDevData->mpGraphics->maGraphicsData.mnFontStyle = normal; - - // Initialize virtual port's clip regions - - rSalVirDevData->mpGraphics->maGraphicsData.mhClipRgn = NULL; - rSalVirDevData->mpGraphics->maGraphicsData.mbClipRgnChanged = FALSE; - - // Initilaize virtual port's status flags - - rSalVirDevData->mpGraphics->maGraphicsData.mbPrinter = FALSE; - rSalVirDevData->mpGraphics->maGraphicsData.mbVirDev = TRUE; - rSalVirDevData->mpGraphics->maGraphicsData.mbWindow = FALSE; - rSalVirDevData->mpGraphics->maGraphicsData.mbScreen = TRUE; - - bVirtualDeviceGWorldInited = TRUE; - } // if - } // if - - return bVirtualDeviceGWorldInited; -} //InitVirtualDeviceGWorld +// ----------------------------------------------------------------------- -// ======================================================================= +void AquaSalInstance::DestroyVirtualDevice( SalVirtualDevice* pDevice ) +{ + delete pDevice; +} // ======================================================================= -SalVirtualDevice::SalVirtualDevice() +AquaSalVirtualDevice::AquaSalVirtualDevice( AquaSalGraphics* pGraphic, long nDX, long nDY, USHORT nBitCount, const SystemGraphicsData *pData ) +: mbGraphicsUsed( false ) +, mxContext( 0 ) { - maVirDevData.mpGraphics = NULL; - maVirDevData.mnBitCount = 0; - maVirDevData.mnWidth = 0; - maVirDevData.mnHeight = 0; - maVirDevData.mbGraphics = FALSE; -} // Constructor + mpGraphics = new AquaSalGraphics(); + + if( nDX && nDY ) + SetSize( nDX, nDY ); +} // ----------------------------------------------------------------------- -SalVirtualDevice::~SalVirtualDevice() +AquaSalVirtualDevice::~AquaSalVirtualDevice() { - if ( maVirDevData.mpGraphics != NULL ) + if( mpGraphics ) { - // Delete exisiting clip regions, offscreen graphic world, - // and its associated colour graph port - - delete maVirDevData.mpGraphics; - } // if -} // Destructor + mpGraphics->SetVirDevGraphics( 0, true ); + delete mpGraphics; + mpGraphics = 0; + } + Destroy(); +} // ----------------------------------------------------------------------- -SalGraphics* SalVirtualDevice::GetGraphics() +void AquaSalVirtualDevice::Destroy() { - if ( maVirDevData.mbGraphics ) - { - return NULL; - } // if - - if ( !maVirDevData.mpGraphics ) + if( mxContext ) { - maVirDevData.mpGraphics = new SalGraphics; - - maVirDevData.mbGraphics = InitVirtualDeviceGWorld( &maVirDevData ); - - if ( !maVirDevData.mbGraphics ) - { - delete maVirDevData.mpGraphics; - maVirDevData.mpGraphics = NULL; - } // if - } // if + if( mpGraphics ) + mpGraphics->SetVirDevGraphics( 0, true ); + void* pBuffer = CGBitmapContextGetData(mxContext); + CFRelease( mxContext ); + mxContext = 0; + if( pBuffer ) + free( pBuffer ); + } +} +// ----------------------------------------------------------------------- - return maVirDevData.mpGraphics; -} // SalVirtualDevice::GetGraphics +SalGraphics* AquaSalVirtualDevice::GetGraphics() +{ + if( mbGraphicsUsed || !mpGraphics ) + return 0; + + mbGraphicsUsed = true; + return mpGraphics; +} // ----------------------------------------------------------------------- -void SalVirtualDevice::ReleaseGraphics( SalGraphics *pGraphics ) +void AquaSalVirtualDevice::ReleaseGraphics( SalGraphics *pGraphics ) { - maVirDevData.mbGraphics = FALSE; -} // SalVirtualDevice::ReleaseGraphics + mbGraphicsUsed = false; +} // ----------------------------------------------------------------------- -BOOL SalVirtualDevice::SetSize( long nDX, long nDY ) +BOOL AquaSalVirtualDevice::SetSize( long nDX, long nDY ) { - BOOL bSizeSet = FALSE; + if( mxContext && ( nDX == CGBitmapContextGetWidth( mxContext ) ) && ( nDY == CGBitmapContextGetHeight( mxContext ) ) ) + return true; // bummer - // If we have already created a graphics context, dispose of it, - // by deleting exisiting clip regions, offscreen graphic worlds, - // and its associated colour graph port - - if ( ( ( maVirDevData.mpGraphics->maGraphicsData.mbGWorldPixelsCopy == TRUE ) - || ( maVirDevData.mpGraphics->maGraphicsData.mbGWorldPixelsNew == TRUE ) - ) - && ( maVirDevData.mpGraphics->maGraphicsData.mhGWorldPixMap != NULL ) - ) - { - DisposePixMap( maVirDevData.mpGraphics->maGraphicsData.mhGWorldPixMap ); - } // if + Destroy(); - if ( maVirDevData.mpGraphics->maGraphicsData.mhClipRgn != NULL ) + void* pData = malloc( nDX * 4 * nDY ); + if (pData ) { - DisposeRgn( maVirDevData.mpGraphics->maGraphicsData.mhClipRgn ); - } // if + CGColorSpaceRef xColorSpace( CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB) ); + mxContext = CGBitmapContextCreate( pData, nDX, nDY, 8, nDX * 4, xColorSpace, kCGImageAlphaNoneSkipFirst ); + CFRelease( xColorSpace ); - if ( maVirDevData.mpGraphics->maGraphicsData.mpCGrafPort != NULL ) + if( mxContext ) + { + if( mpGraphics ) + mpGraphics->SetVirDevGraphics( mxContext, true ); + } + else + { + free (pData); + DBG_ERROR( "vcl::AquaSalVirtualDevice::SetSize(), could not create Bitmap Context" ); + } + } + else { - DisposeGWorld( maVirDevData.mpGraphics->maGraphicsData.mpCGrafPort ); - - maVirDevData.mpGraphics->maGraphicsData.mpGWorld = NULL; - maVirDevData.mpGraphics->maGraphicsData.mpCGrafPort = NULL; - } // if - - // Create the offscreen graphics context + DBG_ERROR( "vcl::AquaSalVirtualDevice::SetSize(), could not allocate bitmap data" ); + } - maVirDevData.mnWidth = nDX; - maVirDevData.mnHeight = nDY; + return mxContext != 0; +} - bSizeSet = InitVirtualDeviceGWorld( &maVirDevData ); - - return bSizeSet; -} // SalVirtualDevice::SetSize - -// ======================================================================= - -// ======================================================================= +// ----------------------------------------------------------------------- +void AquaSalVirtualDevice::GetSize( long& rWidth, long& rHeight ) +{ + if( mxContext ) + { + rWidth = CGBitmapContextGetWidth( mxContext ); + rHeight = CGBitmapContextGetHeight( mxContext ); + } + else + { + rWidth = 0; + rHeight = 0; + } +} diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/window/makefile.mk ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/window/makefile.mk --- ooo_SRC680_m187_src.orig/vcl/aqua/source/window/makefile.mk 2005-09-09 12:45:06.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/window/makefile.mk 2006-08-07 20:52:43.000000000 +0200 @@ -59,9 +59,8 @@ SLOFILES= \ $(SLO)/salframe.obj \ - $(SLO)/salobj.obj \ - $(SLO)/VCLView.obj \ - $(SLO)/VCLWindow.obj + $(SLO)/salmenu.obj \ + $(SLO)/salobj.obj .ENDIF # "$(GUIBASE)"!="aqua" diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/window/salframe.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/window/salframe.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/window/salframe.cxx 2006-10-06 11:56:27.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/window/salframe.cxx 2006-10-14 15:26:17.000000000 +0200 @@ -44,319 +44,1656 @@ #ifndef _SV_SALGDI_HXX #include #endif -#ifndef _SV_SALFRAME_HXX -#include +#ifndef _SV_SALGDI_H +#include #endif -#ifndef _SV_VCLWINDOW_H -#include +#ifndef _SV_SALFRAME_H +#include #endif -#ifndef _SV_VCLGRAPHICS_H -#include +#ifndef _SV_SALMENU_H +#include #endif +#ifndef _SV_SALTIMER_H +#include +#endif +#ifndef _SV_SALINST_H +#include +#endif +#ifndef _SV_SALWTYPE_HXX +#include +#endif + +#include + +#include +#include + +using namespace std; // ======================================================================= static long ImplSalFrameCallbackDummy( void*, SalFrame*, USHORT, const void* ) { + fprintf(stderr, ">*>_> %s\n",__func__); return 0; } -// ======================================================================= +static void ImplSalCalcFullScreenSize( const AquaSalFrame* pFrame, Rect* pSize ) +{ + /** FIXME ** + * Implement multiple displays here. That's why a pointer + * to frame is passed. But pointer not currently used. + **/ + CGDirectDisplayID mainDisplayID = CGMainDisplayID(); + printf("Display ID %d\n", mainDisplayID); + + CGRect rect; + rect = CGDisplayBounds( mainDisplayID ); + printf( "Screen resolution: %fx%f\n", rect.size.width, rect.size.height ); + + // Stores current resolution in pSize. + // Rect made out of ints -> cast required -> CGRect made out of floats. + pSize->top = 0; + pSize->left = 0; + pSize->bottom = static_cast(rect.size.height); + pSize->right = static_cast(rect.size.width); +} -SalFrame::SalFrame() -{ - SalData* pSalData = GetSalData(); +// ======================================================================= - maFrameData.mhWnd = NULL; - maFrameData.mpGraphics = NULL; - maFrameData.mpInst = NULL; - maFrameData.mpProc = ImplSalFrameCallbackDummy; - maFrameData.mnWidth = 0; - maFrameData.mnHeight = 0; - maFrameData.mbGraphics = FALSE; +AquaSalFrame::AquaSalFrame() : + mpMenu(NULL), + mrWindow(NULL), + mpGraphics(NULL), + mpParent(NULL), + mpInst(NULL), + mpProc(ImplSalFrameCallbackDummy), + mnWidth(0), + mnHeight(0), + mnMinWidth(0), + mnMinHeight(0), + mnMaxWidth(0), + mnMaxHeight(0), + mbGraphics(FALSE) +{ + fprintf(stderr, ">*>_> %s\n",__func__); + InsertThisIntoFrameList(); +} + +AquaSalFrame::AquaSalFrame(SalFrame* pParent, ULONG salFrameStyle, AquaSalInstance* pSalInstance) : + mpMenu(NULL), + mpGraphics(NULL), + mpParent(NULL), + mpInst(NULL), + mpProc(ImplSalFrameCallbackDummy), + mnWidth(0), + mnHeight(0), + mnMinWidth(0), + mnMinHeight(0), + mnMaxWidth(0), + mnMaxHeight(0), + mbGraphics(FALSE), + mpSalInstance(pSalInstance) +{ + InsertThisIntoFrameList(); + mpParent = dynamic_cast(pParent); + BOOST_ASSERT((pParent && pFrame->mpParent) || (pParent == NULL) && "Parent frame is no AquaSalFrame!"); + CreateNewSystemWindow(mpParent ? mpParent->mrWindow : NULL, salFrameStyle); +} - // insert frame in framelist - maFrameData.mpNextFrame = pSalData->mpFirstFrame; +void AquaSalFrame::InsertThisIntoFrameList() +{ + SalData* pSalData = GetSalData(); + mpNextFrame = dynamic_cast(pSalData->mpFirstFrame); pSalData->mpFirstFrame = this; } -// ----------------------------------------------------------------------- - -SalFrame::~SalFrame() +void AquaSalFrame::RemoveThisFromFrameList() { SalData* pSalData = GetSalData(); - if ( maFrameData.mpGraphics ) - delete maFrameData.mpGraphics; - - if ( maFrameData.mhWnd ) - VCLWindow_Release( maFrameData.mhWnd ); - - // remove frame from framelist - if ( this == pSalData->mpFirstFrame ) - pSalData->mpFirstFrame = maFrameData.mpNextFrame; + if (this == pSalData->mpFirstFrame) + pSalData->mpFirstFrame = mpNextFrame; else { - SalFrame* pTempFrame = pSalData->mpFirstFrame; - while ( pTempFrame->maFrameData.mpNextFrame != this ) - pTempFrame = pTempFrame->maFrameData.mpNextFrame; + AquaSalFrame* pTempFrame = (AquaSalFrame*)pSalData->mpFirstFrame; + while (pTempFrame->mpNextFrame != this) + pTempFrame = (AquaSalFrame*)pTempFrame->mpNextFrame; - pTempFrame->maFrameData.mpNextFrame = maFrameData.mpNextFrame; + pTempFrame->mpNextFrame = mpNextFrame; } } // ----------------------------------------------------------------------- -SalGraphics* SalFrame::GetGraphics() +AquaSalFrame::~AquaSalFrame() +{ + fprintf(stderr, ">*>_> %s\n",__func__); + + if ( mpGraphics ) + delete mpGraphics; + + if (mrWindow) + { + HideWindow(mrWindow); + DeinstallAndUnregisterAllEventHandler(); + ReleaseWindow(mrWindow); + } + + RemoveThisFromFrameList(); +} + +// ----------------------------------------------------------------------- + +SalGraphics* AquaSalFrame::GetGraphics() { - if ( maFrameData.mbGraphics ) + if ( mbGraphics ) return NULL; - if ( !maFrameData.mpGraphics ) + if ( !mpGraphics ) { - VCLVIEW hView = NULL; - SalFrame *pFrame = this; + CarbonViewRef hView = NULL; + AquaSalFrame *pFrame = this; // Search for the parent SalFrame that has a native window and // use that window to get an NSView - while ( !pFrame->maFrameData.mhWnd ) { - pFrame = pFrame->maFrameData.mpParent; + + while ( !pFrame->mrWindow ) { + pFrame = (AquaSalFrame*)pFrame->mpParent; if ( !pFrame ) break; } - hView = VCLWindow_ContentView( pFrame->maFrameData.mhWnd ); - - if ( hView ) + + // create root control if it does not exist + // however, this is currently not used + OSErr err = GetRootControl( pFrame->mrWindow, &hView ); + if( err == errNoRootControl ) + err = CreateRootControl( pFrame->mrWindow, &hView ); + + if( err == noErr ) { - maFrameData.mpGraphics = new SalGraphics; - maFrameData.mpGraphics->maGraphicsData.mhDC = hView; - maFrameData.mpGraphics->maGraphicsData.mbPrinter = FALSE; - maFrameData.mpGraphics->maGraphicsData.mbVirDev = FALSE; - maFrameData.mpGraphics->maGraphicsData.mbWindow = TRUE; - maFrameData.mpGraphics->maGraphicsData.mbScreen = TRUE; + mpGraphics = new AquaSalGraphics; + mpGraphics->SetWindowGraphics( hView, mrWindow, true ); + mbGraphics = TRUE; } + else + fprintf(stderr, "could not get graphics (get/create root control returned %d)\n", err); } - maFrameData.mbGraphics = TRUE; - - return maFrameData.mpGraphics; + return mpGraphics; } // ----------------------------------------------------------------------- -void SalFrame::ReleaseGraphics( SalGraphics *pGraphics ) +void AquaSalFrame::ReleaseGraphics( SalGraphics *pGraphics ) { - maFrameData.mbGraphics = FALSE; + fprintf(stderr, ">*>_> %s\n",__func__); + mbGraphics = FALSE; } // ----------------------------------------------------------------------- -BOOL SalFrame::PostEvent( void *pData ) +BOOL AquaSalFrame::ImplPostUserEvent( UInt32 eventKind, void *pData ) { - VCLWINDOW hWindow = NULL; - SalFrame *pFrame = this; - + //fprintf(stderr, "implpost user event\n"); + // Search for the parent SalFrame that has a native window and // use that window to post the event to - while ( !pFrame->maFrameData.mhWnd ) { - pFrame = pFrame->maFrameData.mpParent; - if ( !pFrame ) + AquaSalFrame *pFrame = this; + while (!pFrame->mrWindow) + { + pFrame = pFrame->mpParent; + if (!pFrame) break; } - return VCLWindow_PostEvent( pFrame->maFrameData.mhWnd, pData ); + + bool bret = false; + + if (pFrame) + { + EventRef eventRef; + if (CreateEvent(NULL, cOOoSalUserEventClass, eventKind, 0, kEventAttributeNone, &eventRef) == noErr) + { + EventTargetRef eventTargetRef = GetWindowEventTarget(pFrame->mrWindow); + if (SetEventParameter(eventRef, kEventParamPostTarget, typeEventTargetRef, sizeof(EventTargetRef), &eventTargetRef) == noErr && + SetEventParameter(eventRef, cOOoSalEventData, cOOoSalEventParamTypePtr, sizeof(pData), &pData) == noErr && + PostEventToQueue(GetMainEventQueue(), eventRef, kEventPriorityStandard) == noErr) + { + bret = true; + } + ReleaseEvent(eventRef); + } + } + return bret; } -// ----------------------------------------------------------------------- +BOOL AquaSalFrame::PostEvent( void *pData ) +{ + fprintf(stderr, ">*>_> %s\n",__func__); + return ImplPostUserEvent( cOOoSalEventUser, pData ); +} -void SalFrame::SetTitle( const XubString& rTitle ) +BOOL AquaSalFrame::PostTimerEvent( AquaSalTimer *pTimer ) { - ByteString aByteTitle( rTitle, gsl_getSystemTextEncoding() ); - char *pTitle = (char *)aByteTitle.GetBuffer(); + //fprintf(stderr, ">*>_> %s\n",__func__); + return ImplPostUserEvent( cOOoSalEventTimer, (void*) pTimer ); +} - if ( maFrameData.mhWnd ) - VCLWindow_SetTitle( maFrameData.mhWnd, pTitle ); +// ----------------------------------------------------------------------- +void AquaSalFrame::SetTitle(const XubString& rTitle) +{ + BOOST_ASSERT(mrWindow && "Precondition violated, no window associated with frame"); + ByteString aByteTitle(rTitle, gsl_getSystemTextEncoding()); + char *pTitle = (char *)aByteTitle.GetBuffer(); + CFStringRef pString = CFStringCreateWithCString(kCFAllocatorDefault,pTitle,kCFStringEncodingUTF8); + SetWindowTitleWithCFString(mrWindow, pString); + CFRelease(pString); } // ----------------------------------------------------------------------- -void SalFrame::SetIcon( USHORT nIcon ) +void AquaSalFrame::SetIcon( USHORT nIcon ) { + fprintf(stderr, ">*>_> %s\n",__func__); } // ----------------------------------------------------------------------- -void SalFrame::Show( BOOL bVisible ) +void AquaSalFrame::Show(BOOL bVisible, BOOL bNoActivate) { - if ( bVisible ) - { - if ( maFrameData.mhWnd ) - VCLWindow_Show( maFrameData.mhWnd ); - } // if - else - { - if ( maFrameData.mhWnd ) - { - VCLWindow_Close( maFrameData.mhWnd ); - if ( maFrameData.mpParent ) - maFrameData.mpParent->Show( TRUE ); - } - } // else -} // SalFrame::Show + BOOST_ASSERT(mrWindow && "Precondition violation - no window associated with frame yet"); + + if(bVisible) + { + ShowWindow(mrWindow); + if(!bNoActivate) + SelectWindow(mrWindow); //ActivateWindow(mrWindow, true); + + // FIXME: create empty menu bar for SalFrame without menu yet! + if (!mpMenu) + mpMenu = mpSalInstance->CreateMenu(TRUE); + + if (mpMenu) + { + AquaSalMenu *pAquaSalMenu = (AquaSalMenu *) mpMenu; + SetRootMenu(pAquaSalMenu->mrMenuRef); + } + } + else + HideWindow(mrWindow); +} // ----------------------------------------------------------------------- -void SalFrame::Enable( BOOL bEnable ) +void AquaSalFrame::Enable( BOOL bEnable ) { + fprintf(stderr, ">*>_> %s\n",__func__); } // ----------------------------------------------------------------------- -void SalFrame::SetMinClientSize( long nWidth, long nHeight ) +void AquaSalFrame::SetMinClientSize( long nWidth, long nHeight ) { + fprintf(stderr, ">*>_> %s\n",__func__); + mnMinWidth = nWidth; + mnMinHeight = nHeight; } // ----------------------------------------------------------------------- -void SalFrame::SetClientSize( long nWidth, long nHeight ) +void AquaSalFrame::SetClientSize( long nWidth, long nHeight ) { - maFrameData.mnWidth = nWidth; - maFrameData.mnHeight = nHeight; + fprintf(stderr, ">*>_> %s\n",__func__); + mnWidth = nWidth; + mnHeight = nHeight; // If this is a native window, resize it - if ( maFrameData.mhWnd ) - VCLWindow_SetSize( maFrameData.mhWnd, nWidth, nHeight ); + if ( mrWindow ) + { + Rect bounds; + GetWindowBounds( mrWindow, kWindowContentRgn, &bounds ); + bounds.right = bounds.left + nWidth; + bounds.bottom = bounds.top + nHeight; + SetWindowBounds( mrWindow, kWindowContentRgn, &bounds ); + } } // ----------------------------------------------------------------------- -void SalFrame::GetClientSize( long& rWidth, long& rHeight ) +void AquaSalFrame::GetClientSize( long& rWidth, long& rHeight ) { - rWidth = maFrameData.mnWidth; - rHeight = maFrameData.mnHeight; + fprintf(stderr, ">*>_> %s\n",__func__); + rWidth = mnWidth; + rHeight = mnHeight; } // ----------------------------------------------------------------------- -void SalFrame::SetWindowState( const SalFrameState* pState ) +void AquaSalFrame::SetWindowState( const SalFrameState* pState ) { + fprintf(stderr, ">*>_> %s\n",__func__); } // ----------------------------------------------------------------------- -BOOL SalFrame::GetWindowState( SalFrameState* pState ) +BOOL AquaSalFrame::GetWindowState( SalFrameState* pState ) { + fprintf(stderr, ">*>_> %s\n",__func__); return FALSE; } // ----------------------------------------------------------------------- -void SalFrame::ShowFullScreen( BOOL /* bFullScreen */, sal_Int32 /* nDisplay */ ) +void AquaSalFrame::ShowFullScreen( BOOL bFullScreen, sal_Int32 /* nDisplay */ ) { + fprintf(stderr, ">*>_> %s\n",__func__); + + if( mbFullScreen == bFullScreen ) + return; + + mbFullScreen = bFullScreen; + AquaSalFrame* pFrame = this; + if( bFullScreen ) + { + Rect newBounds; + ImplSalCalcFullScreenSize( pFrame, &newBounds ); // Get new bounds + GetWindowAttributes( mrWindow, &maFullScreenAttr ); // Save attributes + ChangeWindowAttributes( mrWindow, kWindowNoAttributes, maFullScreenAttr ); + GetWindowBounds( mrWindow, kWindowContentRgn, &maFullScreenRect ); + SetWindowBounds( mrWindow, kWindowContentRgn, &newBounds ); + SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar ); + // -> Shows menubar when we move the mouse over it. + } + else + { + SetWindowBounds( mrWindow, kWindowContentRgn, &maFullScreenRect ); + ChangeWindowAttributes( mrWindow, maFullScreenAttr, kWindowNoAttributes ); + SetSystemUIMode( kUIModeNormal, nil ); + } } // ----------------------------------------------------------------------- -void SalFrame::StartPresentation( BOOL bStart ) +void AquaSalFrame::StartPresentation( BOOL bStart ) { + fprintf(stderr, ">*>_> %s\n",__func__); } // ----------------------------------------------------------------------- -void SalFrame::SetAlwaysOnTop( BOOL bOnTop ) +void AquaSalFrame::SetAlwaysOnTop( BOOL bOnTop ) { + fprintf(stderr, ">*>_> %s\n",__func__); } // ----------------------------------------------------------------------- -void SalFrame::ToTop( USHORT nFlags ) +void AquaSalFrame::ToTop(USHORT nFlags) { - if ( maFrameData.mhWnd ) - VCLWindow_Show( maFrameData.mhWnd ); + BOOST_ASSERT(mrWindow && "Precondition violation - no window associated with frame yet"); + Show(true, false); } // ----------------------------------------------------------------------- -void SalFrame::SetPointer( PointerStyle ePointerStyle ) +void AquaSalFrame::SetPointer( PointerStyle ePointerStyle ) { + fprintf(stderr, ">*>_> %s\n",__func__); } // ----------------------------------------------------------------------- -void SalFrame::CaptureMouse( BOOL bCapture ) +void AquaSalFrame::CaptureMouse( BOOL bCapture ) { + fprintf(stderr, ">*>_> %s\n",__func__); } // ----------------------------------------------------------------------- -void SalFrame::SetPointerPos( long nX, long nY ) +void AquaSalFrame::SetPointerPos( long nX, long nY ) { + fprintf(stderr, ">*>_> %s\n",__func__); } // ----------------------------------------------------------------------- -void SalFrame::Flush() +void AquaSalFrame::Flush() { + fprintf(stderr, ">*>_> %s\n",__func__); } // ----------------------------------------------------------------------- -void SalFrame::Sync() +void AquaSalFrame::Sync() { + fprintf(stderr, ">*>_> %s\n",__func__); } // ----------------------------------------------------------------------- -void SalFrame::SetInputContext( SalInputContext* pContext ) +void AquaSalFrame::SetInputContext( SalInputContext* pContext ) { + fprintf(stderr, ">*>_> %s\n",__func__); } // ----------------------------------------------------------------------- -void SalFrame::EndExtTextInput( USHORT nFlags ) +void AquaSalFrame::EndExtTextInput( USHORT nFlags ) { + fprintf(stderr, ">*>_> %s\n",__func__); } // ----------------------------------------------------------------------- -XubString SalFrame::GetKeyName( USHORT nKeyCode ) +XubString AquaSalFrame::GetKeyName( USHORT nKeyCode ) { + fprintf(stderr, ">*>_> %s\n",__func__); return XubString(); } // ----------------------------------------------------------------------- -XubString SalFrame::GetSymbolKeyName( const XubString&, USHORT nKeyCode ) +XubString AquaSalFrame::GetSymbolKeyName( const XubString&, USHORT nKeyCode ) { + fprintf(stderr, ">*>_> %s\n",__func__); return GetKeyName( nKeyCode ); } // ----------------------------------------------------------------------- -void SalFrame::UpdateSettings( AllSettings& rSettings ) +void AquaSalFrame::UpdateSettings( AllSettings& rSettings ) { + StyleSettings aStyleSettings = rSettings.GetStyleSettings(); + + // Query Fonts + Font aMenuFont = aStyleSettings.GetMenuFont(); + Font aTitleFont = aStyleSettings.GetTitleFont(); + Font aFloatTitleFont = aStyleSettings.GetFloatTitleFont(); + Font aHelpFont = aStyleSettings.GetHelpFont(); + Font aAppFont = aStyleSettings.GetAppFont(); + Font aIconFont = aStyleSettings.GetIconFont(); + + // TODO: read correct facename and size from system + aMenuFont.SetSize( Size(0, 13) ); + aAppFont.SetSize( Size(0, 13) ); + + aStyleSettings.SetMenuFont( aMenuFont ); + aStyleSettings.SetTitleFont( aTitleFont ); + aStyleSettings.SetFloatTitleFont( aFloatTitleFont ); + aStyleSettings.SetHelpFont( aHelpFont ); + aStyleSettings.SetIconFont( aIconFont ); + aStyleSettings.SetAppFont( aAppFont ); + aStyleSettings.SetGroupFont( aAppFont ); + aStyleSettings.SetLabelFont( aAppFont ); + aStyleSettings.SetRadioCheckFont( aAppFont ); + aStyleSettings.SetPushButtonFont( aAppFont ); + aStyleSettings.SetFieldFont( aAppFont ); + aStyleSettings.SetInfoFont( aAppFont ); + aStyleSettings.SetToolFont( aAppFont ); + + rSettings.SetStyleSettings( aStyleSettings ); } // ----------------------------------------------------------------------- -const SystemEnvData* SalFrame::GetSystemData() const +const SystemEnvData* AquaSalFrame::GetSystemData() const { + fprintf(stderr, ">*>_> %s\n",__func__); return NULL; } // ----------------------------------------------------------------------- -void SalFrame::Beep( SoundType eSoundType ) +void AquaSalFrame::Beep( SoundType eSoundType ) { - VCLWindow_Beep(); + SysBeep(1); } // ----------------------------------------------------------------------- -void SalFrame::SetCallback( void* pInst, SALFRAMEPROC pProc ) +void AquaSalFrame::SetPosSize(long nX, long nY, long nWidth, long nHeight, USHORT nFlags) { - maFrameData.mpInst = pInst; - if ( pProc ) - maFrameData.mpProc = pProc; - else - maFrameData.mpProc = ImplSalFrameCallbackDummy; + /* + fprintf(stderr, "SetPosSize: nX: %d nY: %d nWidth: %d nHeight: %d, set_x: %s, set_y: %s, set_width: %s, set_height: %s\n", + nX, nY, nWidth, nHeight, + (nFlags&SAL_FRAME_POSSIZE_X) ? "yes" : "no", + (nFlags&SAL_FRAME_POSSIZE_Y) ? "yes" : "no", + (nFlags&SAL_FRAME_POSSIZE_WIDTH) ? "yes" : "no", + (nFlags&SAL_FRAME_POSSIZE_HEIGHT) ? "yes" : "no" ); + + fprintf(stderr, "maGeometry: left: %d top: %d right: %d bottom: %d\n", + maGeometry.nLeftDecoration, maGeometry.nTopDecoration, + maGeometry.nRightDecoration, maGeometry.nBottomDecoration ); + */ + USHORT nEvent = 0; + + if (IsWindowCollapsed(mrWindow)) + CollapseWindow(mrWindow, false); // expand the window + + if (nFlags & (SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y)) + nEvent = SALEVENT_MOVE; + + if (nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT)) + nEvent = (nEvent == SALEVENT_MOVE) ? SALEVENT_MOVERESIZE : SALEVENT_RESIZE; + + Rect currentWindowRect; + GetWindowBounds(mrWindow, kWindowStructureRgn, ¤tWindowRect); + + Rect currentContentRect; + GetWindowBounds(mrWindow, kWindowContentRgn, ¤tContentRect); + + // position is always relative to parent frame + Rect parentContentRect; + if( mpParent ) + GetWindowBounds(mpParent->mrWindow, kWindowContentRgn, &parentContentRect); + else + // use screen if no parent + GetAvailableWindowPositioningBounds(GetMainDevice(), &parentContentRect); + + // use old window pos if no new pos requested + if (!(nFlags & SAL_FRAME_POSSIZE_X)) + nX = currentWindowRect.left; + else + nX += parentContentRect.left; + + if (!(nFlags & SAL_FRAME_POSSIZE_Y)) + nY = currentWindowRect.top; + else + nY += parentContentRect.top; + + // use old window width if no new width requested + if (!(nFlags & SAL_FRAME_POSSIZE_WIDTH)) + nWidth = currentContentRect.right - currentContentRect.left; + + // always add the decoration as nWidth concerns only the content rect + nWidth += maGeometry.nLeftDecoration + maGeometry.nRightDecoration; + + // use old window height if no new height requested + if (!(nFlags & SAL_FRAME_POSSIZE_HEIGHT)) + nHeight = currentContentRect.bottom - currentContentRect.top; + + // always add the decoration as nHeight concerns only the content rect + nHeight += maGeometry.nTopDecoration + maGeometry.nBottomDecoration; + + Rect newWindowRect; + SetRect(&newWindowRect, nX, nY, nX + nWidth, nY + nHeight); + + /* + fprintf(stderr, "SetPosSize: Old rect (x: %d, y: %d, w: %d, h: %d)\n", + currentWindowRect.left, currentWindowRect.top, currentWindowRect.right - currentWindowRect.left, currentWindowRect.bottom - currentWindowRect.top); + fprintf(stderr, "SetPosSize: New rect (x: %d, y: %d, w: %d, h: %d)\n", nX, nY, nWidth, nHeight); + */ + SetWindowBounds(mrWindow, kWindowStructureRgn, &newWindowRect); + + UpdateFrameGeometry(); + + if (nEvent) + CallCallback(nEvent, NULL); +} + +void AquaSalFrame::DrawMenuBar() +{ + fprintf(stderr, ">*>_> %s\n",__func__); + + if (mpMenu) + { + AquaSalMenu *pAquaSalMenu = (AquaSalMenu *) mpMenu; + SetRootMenu(pAquaSalMenu->mrMenuRef); + } +} + +void AquaSalFrame::GetWorkArea( Rectangle& rRect ) +{ + Rect aRect; + GetAvailableWindowPositioningBounds(GetMainDevice(), &aRect); + + rRect.nTop = aRect.top; + rRect.nLeft = aRect.left; + rRect.nRight = aRect.right; + rRect.nBottom = aRect.bottom; +} + +SalPointerState AquaSalFrame::GetPointerState() +{ + fprintf(stderr, ">*>_> %s\n",__func__); + //TODO: implement + SalPointerState state; + return state; +} + +bool AquaSalFrame::SetPluginParent( SystemParentData* pNewParent ) +{ + fprintf(stderr, ">*>_> %s\n",__func__); + //TODO: implement + return sal_False; +} + +BOOL AquaSalFrame::MapUnicodeToKeyCode( sal_Unicode , LanguageType , KeyCode& ) +{ + fprintf(stderr, ">*>_> %s\n",__func__); + // not supported yet + return FALSE; +} + +LanguageType AquaSalFrame::GetInputLanguage() +{ + fprintf(stderr, ">*>_> %s\n",__func__); + //TODO: implement + return LANGUAGE_DONTKNOW; +} + +void AquaSalFrame::SetMaxClientSize( long nWidth, long nHeight ) +{ + fprintf(stderr, ">*>_> %s\n",__func__); + mnMaxWidth = nWidth; + mnMaxHeight = nHeight; +} + +void AquaSalFrame::SetMenu( SalMenu* pSalMenu ) +{ + fprintf(stderr, ">*>_> %s\n",__func__); + + mpMenu = pSalMenu; +} + +void AquaSalFrame::SetExtendedFrameStyle( SalExtStyle nStyle ) +{ + fprintf(stderr, ">*>_> %s\n",__func__); + //TODO: implement +} + +void AquaSalFrame::SetBackgroundBitmap( SalBitmap* ) +{ + fprintf(stderr, ">*>_> %s\n",__func__); + //TODO: implement +} + +SalBitmap* AquaSalFrame::SnapShot() +{ + fprintf(stderr, ">*>_> %s\n",__func__); + //TODO: implement + return NULL; +} + +SalFrame* AquaSalFrame::GetParent() const +{ + fprintf(stderr, ">*>_> %s\n",__func__); + //TODO: implement + return mpParent; +} + +void AquaSalFrame::SetParent( SalFrame* pNewParent ) +{ + fprintf(stderr, ">*>_> %s\n",__func__); + //TODO: implement + mpParent = (AquaSalFrame*)pNewParent; +} + +void DbgPrintFrameGeometry(Rect fullWndRect, Rect cntRect, Rect titleBarRect, SalFrameGeometry salGeo) +{ + fprintf(stderr, "=======================================\n"); + fprintf(stderr, "Full window rect (l: %d, t: %d, b: %d, r: %d)\n", fullWndRect.left, fullWndRect.top, fullWndRect.bottom, fullWndRect.right); + fprintf(stderr, "Content rect (l: %d, t: %d, b: %d, r: %d)\n", cntRect.left, cntRect.top, cntRect.bottom, cntRect.right); + fprintf(stderr, "Title bar rect (l: %d, t: %d, b: %d, r: %d)\n", titleBarRect.left, titleBarRect.top, titleBarRect.bottom, titleBarRect.right); + fprintf(stderr, "nX: %d, nY: %d, nWidth: %d, nHeight: %d, LeftDeco %d, RightDeco %d, TopDeco %d, BottomDeco %d\n", salGeo.nX, salGeo.nY, salGeo.nWidth, salGeo.nHeight, salGeo.nLeftDecoration, salGeo.nRightDecoration, salGeo.nTopDecoration, salGeo.nBottomDecoration); + fprintf(stderr, "=======================================\n"); +} + +void AquaSalFrame::UpdateFrameGeometry() +{ + memset(&maGeometry, 0, sizeof(SalFrameGeometry)); + + if (IsWindowCollapsed(mrWindow)) + return; + + Rect fullWindowRect; + GetWindowBounds(mrWindow, kWindowStructureRgn, &fullWindowRect); + + Rect contentRect; + GetWindowBounds(mrWindow, kWindowContentRgn, &contentRect); + + maGeometry.nX = contentRect.left; + maGeometry.nY = contentRect.top; + + maGeometry.nLeftDecoration = contentRect.left - fullWindowRect.left; + maGeometry.nRightDecoration = fullWindowRect.right - contentRect.right; + + maGeometry.nTopDecoration = contentRect.top - fullWindowRect.top; + maGeometry.nBottomDecoration = fullWindowRect.bottom - contentRect.bottom; + + Rect titleBarRect; + GetWindowBounds(mrWindow, kWindowTitleBarRgn, &titleBarRect); + + int width = fullWindowRect.right - fullWindowRect.left - maGeometry.nRightDecoration - maGeometry.nLeftDecoration; + int height = fullWindowRect.bottom - fullWindowRect.top - maGeometry.nBottomDecoration - maGeometry.nTopDecoration; + + maGeometry.nWidth = width < 0 ? 0 : width; + maGeometry.nHeight = height < 0 ? 0 : height; + + //DbgPrintFrameGeometry(fullWindowRect, contentRect, titleBarRect, maGeometry); +} + +OSStatus HandleCommandProcessEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData) +{ + + ImplSalYieldMutexAcquire(); + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + + OSStatus result = eventNotHandledErr; + HICommand commandStruct; + + GetEventParameter (inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &commandStruct); + + // If the CommandProcess event is from menu, print its MenuRef and MenuItemIndex + if ( commandStruct.attributes & kHICommandFromMenu ) { + + // handling Quit from Application menu! + if (commandStruct.commandID == kHICommandQuit) + fprintf(stderr, "Quit from application menu received!\n"); + + SalMenuItem *pSalMenuItem; + + OSStatus err; + err = GetMenuItemProperty (commandStruct.menu.menuRef, commandStruct.menu.menuItemIndex, + APP_PROPERTY_CREATOR, APP_PROPERTY_TAG_MENU_ITEM_POINTER, + sizeof(pSalMenuItem), NULL, &pSalMenuItem); + + // Only use pSalMenuItem value if the menu item property was found! + if ( (err == noErr) && pSalMenuItem) + { + // Posting native menu event... + SalMenuEvent aMenuEvt; + aMenuEvt.mnId = ((AquaSalMenuItem *)pSalMenuItem)->mnId; + aMenuEvt.mpMenu = ((AquaSalMenuItem *)pSalMenuItem)->mpMenu; + pSalFrame->CallCallback(SALEVENT_MENUCOMMAND, &aMenuEvt); + + result = noErr; + } + } + + ImplSalYieldMutexRelease(); + + return result; +} + +OSStatus HandleMenuPopulateEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData) +{ + + ImplSalYieldMutexAcquire(); + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + + MenuRef pMenuRef; + + GetEventParameter (inEvent, kEventParamDirectObject, typeMenuRef, NULL, sizeof(typeMenuRef), NULL, &pMenuRef); + + SalMenu *pSalMenu; + OSStatus err; + + err = GetMenuItemProperty (pMenuRef, 0, + APP_PROPERTY_CREATOR, APP_PROPERTY_TAG_MENU_POINTER, + sizeof(pSalMenu), NULL, &pSalMenu); + + if ( (err == noErr) && pSalMenu) + { + + // To send native menu event, we need its VCL *Menu + // So we query first item in the menu for it. + + SalMenuItem *pSalMenuItem; + OSStatus err; + + err = GetMenuItemProperty (pMenuRef, 1, + APP_PROPERTY_CREATOR, APP_PROPERTY_TAG_MENU_ITEM_POINTER, + sizeof(pSalMenuItem), NULL, &pSalMenuItem); + + if ( (err == noErr) && pSalMenuItem) + { + // Posting native menu event... + SalMenuEvent aMenuEvt; + aMenuEvt.mpMenu = ((AquaSalMenuItem *) pSalMenuItem)->mpMenu; + + // FIXME: looks like it crashes when some menus are activated... + pSalFrame->CallCallback(SALEVENT_MENUACTIVATE, &aMenuEvt); + pSalFrame->CallCallback(SALEVENT_MENUDEACTIVATE, &aMenuEvt); + } + } + + ImplSalYieldMutexRelease(); + + return noErr; +} + +OSStatus HandleMenuClosedEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData) +{ + + ImplSalYieldMutexAcquire(); + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + + MenuRef pMenuRef; + + GetEventParameter (inEvent, kEventParamDirectObject, typeMenuRef, NULL, sizeof(typeMenuRef), NULL, &pMenuRef); + + SalMenu *pSalMenu; + OSStatus err; + + err = GetMenuItemProperty (pMenuRef, 0, + APP_PROPERTY_CREATOR, APP_PROPERTY_TAG_MENU_POINTER, + sizeof(pSalMenu), NULL, &pSalMenu); + + if ( (err == noErr) && pSalMenu) + { + // Posting native menu event... + SalMenuEvent aMenuEvt; + aMenuEvt.mpMenu = pSalMenu; + // FIXME: This does not propagate to the application yet. WHY? + // pSalFrame->CallCallback(SALEVENT_MENUDEACTIVATE, &aMenuEvt); + } + + ImplSalYieldMutexRelease(); + + return noErr; +} + +OSStatus HandleMenuTargetItemEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData) +{ + + ImplSalYieldMutexAcquire(); + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + OSStatus result = eventNotHandledErr; + + MenuRef pMenuRef; + MenuItemIndex mnMenuItemIndex; + + GetEventParameter (inEvent, kEventParamDirectObject, typeMenuRef, NULL, sizeof(typeMenuRef), NULL, &pMenuRef); + GetEventParameter (inEvent, kEventParamMenuItemIndex, typeMenuItemIndex, NULL, sizeof(typeMenuItemIndex), NULL, &mnMenuItemIndex); + + // kEventMenuTargetItem is sent also for top-level items. Ignore + // them (MenuItemIndex == 0 for them). Or should we send + // MENUACTIVATE events for them? + if (mnMenuItemIndex != 0) + { + SalMenuItem *pSalMenuItem; + OSStatus err; + + err = GetMenuItemProperty (pMenuRef, mnMenuItemIndex, + APP_PROPERTY_CREATOR, APP_PROPERTY_TAG_MENU_ITEM_POINTER, + sizeof(pSalMenuItem), NULL, &pSalMenuItem); + + // We also receive kEventMenuTargetItem events for + // non-application menus (Apple menu or Application menu). But + // they do not have SalMenuItem attached with them. + if ( (err == noErr) && pSalMenuItem) + { + // Posting native menu event... + SalMenuEvent aMenuEvt; + aMenuEvt.mnId = ((AquaSalMenuItem *)pSalMenuItem)->mnId; + aMenuEvt.mpMenu = ((AquaSalMenuItem *)pSalMenuItem)->mpMenu; + pSalFrame->CallCallback(SALEVENT_MENUHIGHLIGHT, &aMenuEvt); + + result = noErr; + } + } + + ImplSalYieldMutexRelease(); + + return result; +} + +OSStatus HandleWindowCloseEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData) +{ + BOOST_ASSERT(GetEventClass(inEvent) == kEventClassWindow && GetEventKind(inEvent) == kEventWindowClose && "Only WindowClose event expected"); + + ImplSalYieldMutexAcquire(); + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + + pSalFrame->CallCallback(SALEVENT_CLOSE, 0); + ImplSalYieldMutexRelease(); + return noErr; +} + +OSStatus HandleWindowBoundsChangedEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void* inUserData) +{ + fprintf(stdout, "Bounds changed event\n"); + + BOOST_ASSERT(GetEventClass(inEvent) == kEventClassWindow && GetEventKind(inEvent) == kEventWindowBoundsChanged && "Only WindowBoundsChanged event expected"); + + //fprintf(stderr, "received resize event\n"); + + // HACK: + // during live resize our own event loop will not be active so private timer events + // that were posted into the event queue will not be handled + // it seems that all event scheduling takes place in the standard + // event handlers in this case + // calling SalInstance::Yield() will allow to dispatch events from the queue and repaints will + // occur during live resize + SalData* pSalData = GetSalData(); + pSalData->mpFirstInstance->Yield( false, false /* FIXME: bAllEvents */ ); + + ImplSalYieldMutexAcquire(); + + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + + pSalFrame->UpdateFrameGeometry(); + + // compose sal resize event + Rect windowBounds; + GetEventParameter(inEvent, kEventParamCurrentBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &windowBounds); + + long windowWidth = windowBounds.right - windowBounds.left; + long windowHeight = windowBounds.bottom - windowBounds.top; + + // Get the size of the window's content area + if (windowWidth != pSalFrame->mnWidth || windowHeight != pSalFrame->mnHeight) + { + // Cache the new size + pSalFrame->mnWidth = windowWidth; + pSalFrame->mnHeight = windowHeight; + + + pSalFrame->CallCallback( SALEVENT_RESIZE, NULL); + } + + ImplSalYieldMutexRelease(); + + return noErr; +} + +OSStatus HandleOOoSalUserEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void* inUserData) +{ + BOOST_ASSERT(GetEventClass(inEvent) == cOOoSalUserEventClass && "Only SalUserEvents expected"); + + //fprintf(stderr, "received user event\n"); + + ImplSalYieldMutexAcquire(); + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + void* pData = NULL; + + GetEventParameter(inEvent, cOOoSalEventData, cOOoSalEventParamTypePtr, NULL, sizeof(pData), NULL, &pData); + + pSalFrame->CallCallback(SALEVENT_USEREVENT, pData); + + ImplSalYieldMutexRelease(); + + return noErr; +} +OSStatus HandleOOoSalTimerEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void* inUserData) +{ + BOOST_ASSERT(GetEventClass(inEvent) == cOOoSalUserEventClass && "Only SalUserEvents expected"); + + //fprintf(stderr, "received timer event\n"); + + ImplSalYieldMutexAcquire(); + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + void* pData = NULL; + + GetEventParameter(inEvent, cOOoSalEventData, cOOoSalEventParamTypePtr, NULL, sizeof(pData), NULL, &pData); + + AquaSalTimer *pTimer = reinterpret_cast(pData); + pTimer->CallCallback(); + + ImplSalYieldMutexRelease(); + + return noErr; +} + +OSStatus HandleWindowActivatedEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void* inUserData) +{ + ImplSalYieldMutexAcquire(); + + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + pSalFrame->DrawMenuBar(); + + ImplSalYieldMutexRelease(); + + return noErr; +} + +OSStatus HandleWindowPaintEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void* inUserData) +{ + fprintf(stderr, "received full paint event\n"); + ImplSalYieldMutexAcquire(); + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + + Rect contentBounds; + GetWindowBounds( pSalFrame->mrWindow, kWindowContentRgn, &contentBounds ); + + SalPaintEvent aPaintEvt; + aPaintEvt.mnBoundX = 0; + aPaintEvt.mnBoundY = 0; + aPaintEvt.mnBoundWidth = contentBounds.right - contentBounds.left; + aPaintEvt.mnBoundHeight = contentBounds.bottom - contentBounds.top; + + fprintf(stderr, "Full paint event: (%d, %d, %d, %d)\n", + aPaintEvt.mnBoundX, aPaintEvt.mnBoundY, + aPaintEvt.mnBoundWidth, aPaintEvt.mnBoundHeight); + + pSalFrame->CallCallback(SALEVENT_PAINT, &aPaintEvt); + ImplSalYieldMutexRelease(); + + return noErr; +} + +OSStatus HandleWindowDrawContentEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void* inUserData) +{ + //fprintf(stderr, "received draw content event\n"); + ImplSalYieldMutexAcquire(); + + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + + RgnHandle rgn = NewRgn(); + Rect portBounds; + GetPortVisibleRegion(GetWindowPort(pSalFrame->mrWindow), rgn); + GetRegionBounds( rgn, &portBounds ); + DisposeRgn( rgn ); + + SalPaintEvent aPaintEvt; + aPaintEvt.mnBoundX = portBounds.left; + aPaintEvt.mnBoundY = portBounds.top; + aPaintEvt.mnBoundWidth = portBounds.right - portBounds.left; + aPaintEvt.mnBoundHeight = portBounds.bottom - portBounds.top; + + fprintf(stderr, "Paint event: (%d, %d, %d, %d)\n", + aPaintEvt.mnBoundX, aPaintEvt.mnBoundY, + aPaintEvt.mnBoundWidth, aPaintEvt.mnBoundHeight); + + pSalFrame->CallCallback(SALEVENT_PAINT, &aPaintEvt); + ImplSalYieldMutexRelease(); + + return noErr; +} + +OSStatus HandleWindowResizeStarted(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData) +{ + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + pSalFrame->mpSalInstance->StartForceDispatchingPaintEvents(); + return noErr; +} + +OSStatus HandleWindowResizeCompleted(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData) +{ + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + pSalFrame->mpSalInstance->StopForceDispatchingPaintEvents(); + return noErr; +} + +OSStatus HandleMouseUpDownEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void* inUserData) +{ + BOOST_ASSERT(GetEventClass(inEvent) == kEventClassMouse && (GetEventKind(inEvent) == kEventMouseDown || GetEventKind(inEvent) == kEventMouseUp) && "Mouse up or mouse down events expected"); + + ImplSalYieldMutexAcquire(); + + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + + // use window bounds to convert from screen to window coordinates + Rect bounds; + GetWindowBounds( pSalFrame->mrWindow, kWindowContentRgn, &bounds ); + + // get mouse coordinates in screen space + MacOSPoint aPt; + GetEventParameter(inEvent, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(aPt), NULL, &aPt); + + SalMouseEvent aMouseEvt; + aMouseEvt.mnX = aPt.h - bounds.left; + aMouseEvt.mnY = aPt.v - bounds.top; + + aMouseEvt.mnCode = 0; + aMouseEvt.mnTime = static_cast(GetEventTime(inEvent) * 1000); + + // Which modifier keys pressed? + // + // Please note: + // The system automatically preserves the state of the modifier keys during + // mouse down for the corresponding MouseUp event + UInt32 modifierKeys; + GetEventParameter(inEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(modifierKeys), NULL, &modifierKeys); + + if (modifierKeys & shiftKey) + aMouseEvt.mnCode |= KEY_SHIFT; + if (modifierKeys & controlKey) + aMouseEvt.mnCode |= KEY_MOD1; + if (modifierKeys & optionKey) + aMouseEvt.mnCode |= KEY_MOD2; + + // Which mouse button pressed? + EventMouseButton aButtonEvt; + GetEventParameter(inEvent, kEventParamMouseButton, typeMouseButton, NULL, sizeof(aButtonEvt), NULL, &aButtonEvt); + + switch (aButtonEvt) + { + case kEventMouseButtonPrimary: + aMouseEvt.mnButton = MOUSE_LEFT; + aMouseEvt.mnCode |= MOUSE_LEFT; + break; + + case kEventMouseButtonSecondary: + aMouseEvt.mnButton = MOUSE_MIDDLE; + aMouseEvt.mnCode |= MOUSE_MIDDLE; + break; + + case kEventMouseButtonTertiary: + aMouseEvt.mnButton = MOUSE_RIGHT; + aMouseEvt.mnCode |= MOUSE_RIGHT; + break; + } + + pSalFrame->CallCallback(GetEventKind(inEvent) == kEventMouseDown ? + SALEVENT_MOUSEBUTTONDOWN : SALEVENT_MOUSEBUTTONUP, + &aMouseEvt); + ImplSalYieldMutexRelease(); + + // Note: we have to return eventNotHandledErr otherwise + // the window will not be activated and stay in the background + return eventNotHandledErr; +} + +OSStatus HandleMouseWheelMovedEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void* inUserData) +{ + BOOST_ASSERT(GetEventClass(inEvent) == kEventClassMouse && GetEventKind(inEvent) == kEventMouseWheelMoved && "Mouse wheel moved event expected"); + + fprintf(stderr, "PJ: WheelMoved event received.\n"); + + ImplSalYieldMutexAcquire(); + + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + + // use window bounds to convert from screen to window coordinates + Rect bounds; + GetWindowBounds( pSalFrame->mrWindow, kWindowContentRgn, &bounds ); + + // get mouse coordinates in screen space + MacOSPoint aPt; + GetEventParameter(inEvent, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(aPt), NULL, &aPt); + + SalWheelMouseEvent aWheelEvt; + aWheelEvt.mnX = aPt.h - bounds.left; + aWheelEvt.mnY = aPt.v - bounds.top; + + aWheelEvt.mnCode = 0; + aWheelEvt.mnTime = static_cast(GetEventTime(inEvent) * 1000); + + // Which modifier keys pressed? + UInt32 modifierKeys; + GetEventParameter(inEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(modifierKeys), NULL, &modifierKeys); + + if (modifierKeys & shiftKey) + aWheelEvt.mnCode |= KEY_SHIFT; + if (modifierKeys & controlKey) + aWheelEvt.mnCode |= KEY_MOD1; + if (modifierKeys & optionKey) + aWheelEvt.mnCode |= KEY_MOD2; + + EventMouseWheelAxis wheelAxis; // kEventMouseWheelAxisX or kEventMouseWheelAxisY + SInt32 wheelDelta; + GetEventParameter(inEvent, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(wheelAxis), NULL, &wheelAxis); + + if ( wheelAxis == kEventMouseWheelAxisX ) + aWheelEvt.mbHorz = TRUE; + else + aWheelEvt.mbHorz = FALSE; + + GetEventParameter(inEvent, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(wheelDelta), NULL, &wheelDelta); + + static ULONG nLines = 0; + if( ! nLines ) + { + char* pEnv = getenv( "SAL_WHEELLINES" ); + nLines = pEnv ? atoi( pEnv ) : 3; + if( nLines > 10 ) + nLines = SAL_WHEELMOUSE_EVENT_PAGESCROLL; + } + + aWheelEvt.mnScrollLines=nLines; + + // FIXME: This all is a bit suspect ;-) + aWheelEvt.mnDelta = wheelDelta; + aWheelEvt.mnNotchDelta = (wheelDelta>0) ? 1 : -1; + + fprintf(stderr, "PJ: ... %d, %d - %d, %d\n", aWheelEvt.mnX, aWheelEvt.mnY, + wheelAxis, aWheelEvt.mnDelta); + + pSalFrame->CallCallback(SALEVENT_WHEELMOUSE, &aWheelEvt); + + ImplSalYieldMutexRelease(); + + return noErr; +} + +void DbgPrintModifiers (UInt32 keyModifiers) { + + fprintf (stderr, "...... keyModifiers: "); + if (keyModifiers & cmdKey) + fprintf (stderr, "cmdKey, "); + if (keyModifiers & shiftKey) + fprintf (stderr, "shiftKey, "); + if (keyModifiers & alphaLock) + fprintf (stderr, "alphaLock (CapsLock), "); + if (keyModifiers & optionKey) + fprintf (stderr, "optionKey, "); + if (keyModifiers & controlKey) + fprintf (stderr, "controlKey, "); + if (keyModifiers & kEventKeyModifierNumLockMask) + fprintf (stderr, "NumLock key, "); + if (keyModifiers & kEventKeyModifierFnMask) + fprintf (stderr, "Fn key, "); + fprintf (stderr, "\n"); +} + +// Table for translation of system key code to sal keycodes +#define KEY_TAB_SIZE 131 + +static USHORT aImplTranslateKeyTab[KEY_TAB_SIZE] = +{ + // sal key code constant + KEY_A, /* 0 */ + KEY_S, + KEY_D, + KEY_F, + KEY_H, + KEY_G, + KEY_Z, + KEY_X, + KEY_C, + KEY_V, + 0, /* 10 */ + KEY_B, + KEY_Q, + KEY_W, + KEY_E, + KEY_R, + KEY_Y, + KEY_T, + KEY_1, + KEY_2, + KEY_3, /* 20 */ + KEY_4, + KEY_6, + KEY_5, + 0, + KEY_9, + KEY_7, + 0, + KEY_8, + KEY_0, + 0, /* 30 */ + KEY_O, + KEY_U, + 0, + KEY_I, + KEY_P, + KEY_RETURN, + KEY_L, + KEY_J, + 0, + KEY_K, /* 40 */ + 0, + 0, + 0, + 0, + KEY_N, + KEY_M, + 0, + KEY_TAB, + KEY_SPACE, + 0, /* 50 */ + KEY_BACKSPACE, + 0, + KEY_ESCAPE, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 60 */ + 0, + 0, + 0, + 0, + KEY_DECIMAL, /* ? Dot in numpad */ + 0, + 0, + 0, + 0, + 0, /* 70 */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 80 */ + 0, + KEY_0, + KEY_1, + KEY_2, + KEY_3, + KEY_4, + KEY_5, + KEY_6, + KEY_7, + 0, /* 90 */ + KEY_8, + KEY_9, + 0, + 0, + 0, + KEY_F5, + KEY_F6, + KEY_F7, + KEY_F3, + KEY_F8, /* 100 */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 110 */ + 0, + 0, + 0, + KEY_INSERT, + KEY_HOME, + KEY_PAGEUP, + KEY_DELETE, + KEY_F3, + KEY_END, + KEY_F2, /* 120 */ + KEY_PAGEDOWN, + KEY_F1, + KEY_LEFT, + KEY_RIGHT, + KEY_DOWN, /* 125 */ + KEY_UP, /* 126 */ + 0, + 0, + 0, + 0 /* 130 */ +}; + +OSStatus HandleKeyboardEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData) +{ + static ULONG nRepeatCount = 0; + UInt32 keyModifiers; + USHORT nModCode = 0; + + ImplSalYieldMutexAcquire(); + + AquaSalFrame* pSalFrame = reinterpret_cast(inUserData); + + fprintf(stderr, ">>>> HandleKeyboardEvent\n"); + + UInt32 eventKind = GetEventKind(inEvent); + + switch (eventKind) { + case kEventRawKeyUp: + case kEventRawKeyDown: + case kEventRawKeyRepeat: + + if (eventKind == kEventRawKeyDown) + fprintf(stderr, " ... kEventRawKeyDown\n"); + else if (eventKind == kEventRawKeyUp) + fprintf(stderr, " ... kEventRawKeyUp\n"); + else if (eventKind == kEventRawKeyRepeat) + fprintf(stderr, " ... kEventRawKeyRepeat\n"); + + UInt32 keyCode, keyboardType; + char keyChar; + + GetEventParameter (inEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(keyCode), NULL, &keyCode); + fprintf(stderr, " ...... keyCode = %d (%x)\n", keyCode, keyCode); + + GetEventParameter (inEvent, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(keyChar), NULL, &keyChar); + fprintf(stderr, " ...... keyChar = %c (%x)\n", keyChar, keyChar); + + GetEventParameter (inEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(keyModifiers), NULL, &keyModifiers); + fprintf(stderr, " ...... keyModifiers = %d (%x)\n", keyModifiers, keyModifiers); + + DbgPrintModifiers(keyModifiers); + + GetEventParameter (inEvent, kEventParamKeyboardType, typeUInt32, NULL, sizeof(keyboardType), NULL, &keyboardType); + fprintf(stderr, " ...... keyboardType = %d (%x)\n", keyboardType, keyboardType); + + SalKeyEvent aKeyEvt; + + if ( (keyChar >= '0') && (keyChar <= '9') ) + aKeyEvt.mnCode = sal::static_int_cast(KEYGROUP_NUM + keyChar - '0'); + else if ( (keyChar >= 'A') && (keyChar <= 'Z') ) + aKeyEvt.mnCode = sal::static_int_cast(KEYGROUP_ALPHA + keyChar - 'A'); + else if ( (keyChar >= 'a') && (keyChar <= 'z') ) + aKeyEvt.mnCode = sal::static_int_cast(KEYGROUP_ALPHA + keyChar - 'a'); + else if ( keyChar == 0x0d ) // RETURN + aKeyEvt.mnCode = KEY_RETURN; + else if ( keyChar == 0x1b ) // ESCAPE + aKeyEvt.mnCode = KEY_ESCAPE; + else if ( keyChar == 0x09 ) // TAB + aKeyEvt.mnCode = KEY_TAB; + else if ( keyChar == 0x20 ) // SPACE + aKeyEvt.mnCode = KEY_SPACE; + else + aKeyEvt.mnCode = aImplTranslateKeyTab[keyCode]; + + aKeyEvt.mnCharCode = keyChar; + + // Set modifiers + // FIXME: how to map them? shift, option, control and command! + if (keyModifiers & shiftKey) + nModCode |= KEY_SHIFT; + if (keyModifiers & controlKey) + nModCode |= KEY_MOD1; + if (keyModifiers & optionKey) + nModCode |= KEY_MOD2; + + aKeyEvt.mnCode |= nModCode; + aKeyEvt.mnTime = static_cast(GetEventTime(inEvent) * 1000); + + if (eventKind == kEventRawKeyRepeat) + aKeyEvt.mnRepeat = nRepeatCount++; + else + // Not repeat event -> reset repeat counter + nRepeatCount = 0; + + if (eventKind == kEventRawKeyDown || eventKind == kEventRawKeyRepeat) + pSalFrame->CallCallback( SALEVENT_KEYINPUT, &aKeyEvt ); + if (eventKind == kEventRawKeyUp) + pSalFrame->CallCallback( SALEVENT_KEYUP, &aKeyEvt ); + + break; + + case kEventRawKeyModifiersChanged: + fprintf(stderr, " ... kEventRawKeyModifiersChanged\n"); + + GetEventParameter (inEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(keyModifiers), NULL, &keyModifiers); + fprintf(stderr, " ...... keyModifiers = %d (%x)\n", keyModifiers, keyModifiers); + + DbgPrintModifiers(keyModifiers); + + // FIXME: send KEYMODCHANGE event... + + break; + + default: + fprintf(stderr, " ... UNKNOWN!!!\n"); + } + + ImplSalYieldMutexRelease(); + + fprintf(stderr, "<<<< HandleKeyboardEvent\n"); + + return noErr; +} + +OSStatus GetOptimalWindowSize(Rect* rect); + +void DbgWhichSalFrameStyle(ULONG style) +{ + fprintf(stderr, "==============================\n"); + + if (style & SAL_FRAME_STYLE_DEFAULT) + fprintf(stderr, "SAL_FRAME_STYLE_DEFAULT\n"); + if (style & SAL_FRAME_STYLE_MOVEABLE) + fprintf(stderr, "SAL_FRAME_STYLE_MOVEABLE\n"); + if (style & SAL_FRAME_STYLE_SIZEABLE) + fprintf(stderr, "SAL_FRAME_STYLE_SIZEABLE\n"); + if (style & SAL_FRAME_STYLE_CLOSEABLE) + fprintf(stderr, "SAL_FRAME_STYLE_CLOSEABLE\n"); + if (style & SAL_FRAME_STYLE_NOSHADOW) + fprintf(stderr, "SAL_FRAME_STYLE_NOSHADOW\n"); + if (style & SAL_FRAME_STYLE_TOOLTIP) + fprintf(stderr, "SAL_FRAME_STYLE_TOOLTIP\n"); + if (style & SAL_FRAME_STYLE_OWNERDRAWDECORATION) + fprintf(stderr, "SAL_FRAME_STYLE_OWNERDRAWDECORATION\n"); + if (style & SAL_FRAME_STYLE_DIALOG) + fprintf(stderr, "SAL_FRAME_STYLE_DIALOG\n"); + if (style & SAL_FRAME_STYLE_CHILD) + fprintf(stderr, "SAL_FRAME_STYLE_CHILD\n"); + if (style & SAL_FRAME_STYLE_FLOAT) + fprintf(stderr, "SAL_FRAME_STYLE_FLOAT\n"); + if (style & SAL_FRAME_STYLE_TOOLWINDOW) + fprintf(stderr, "SAL_FRAME_STYLE_TOOLWINDOW\n"); + if (style & SAL_FRAME_STYLE_INTRO) + fprintf(stderr, "SAL_FRAME_STYLE_INTRO\n"); + + fprintf(stderr, "==============================\n"); +} + +void AquaSalFrame::CreateNewSystemWindow(CarbonWindowRef pParent, ULONG nSalFrameStyle) +{ + DbgWhichSalFrameStyle(nSalFrameStyle); + + // in order to receive windowupdate events we must not use compositing (kWindowCompositingAttribute)! + + // initialize with useful defaults + unsigned int nWindowAttributes = kWindowStandardHandlerAttribute; + WindowClass windowClass = kDocumentWindowClass; + + if (nSalFrameStyle & SAL_FRAME_STYLE_CHILD) + { + BOOST_ASSERT(false && "Not yet implemented! How to handle child windows on Mac OS X?"); + } + else // none-child windows + { + if (nSalFrameStyle & SAL_FRAME_STYLE_DEFAULT) + nWindowAttributes |= kWindowStandardDocumentAttributes; + + if( nSalFrameStyle & SAL_FRAME_STYLE_FLOAT ) + windowClass = kFloatingWindowClass; + if (nSalFrameStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) + windowClass = kToolbarWindowClass; + if (nSalFrameStyle & SAL_FRAME_STYLE_TOOLTIP) + windowClass = kHelpWindowClass; + + // check moveable, sizeable, closeable + if( !(nSalFrameStyle & SAL_FRAME_STYLE_MOVEABLE) ) // window without decoration + //nWindowAttributes |= kWindowNoTitleBarAttribute; // requires Mac OS X 10.4, may be choose another windows class like toolbar window + windowClass = kToolbarWindowClass; + else + { + // close box requires a titlebar + if( nSalFrameStyle & SAL_FRAME_STYLE_CLOSEABLE ) + nWindowAttributes |= kWindowCloseBoxAttribute; + else + nWindowAttributes &= ~kWindowCloseBoxAttribute; + } + + if( nSalFrameStyle & SAL_FRAME_STYLE_SIZEABLE ) + { + nWindowAttributes |= (kWindowResizableAttribute | kWindowLiveResizeAttribute); + if( (nSalFrameStyle & SAL_FRAME_STYLE_MOVEABLE) && (windowClass == kDocumentWindowClass)) + nWindowAttributes |= (kWindowCollapseBoxAttribute | kWindowFullZoomAttribute); // requires titlebar (moveable) and not allowed for floating windows + } + else + nWindowAttributes &= ~(kWindowResizableAttribute | kWindowLiveResizeAttribute | kWindowCollapseBoxAttribute | kWindowFullZoomAttribute); + } + + Rect aContentRect; + GetOptimalWindowSize(&aContentRect); + + // Directly connect the frame with the window in contrast to Win32 where frame and + // window will be connected in the WM_CREATE message handler + OSStatus rc = CreateNewWindow(windowClass, nWindowAttributes, &aContentRect, &mrWindow); + + if (rc != noErr) + throw runtime_error("System window creation failed"); + + UpdateFrameGeometry(); + + // Cache the size of the content area of the window + mnHeight = aContentRect.bottom - aContentRect.top; + mnWidth = aContentRect.right - aContentRect.left; + + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleWindowCloseEvent), 1, &cWindowCloseEvent); + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleWindowBoundsChangedEvent), 1, &cWindowBoundsChangedEvent); + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleOOoSalUserEvent), 1, &cOOoSalUserEvent); + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleOOoSalTimerEvent), 1, &cOOoSalTimerEvent); + + // do not register for paint events as this would result in no draw content events during resize anymore + // draw content events, however, are more effective as they do not require a full window repaint + //InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleWindowPaintEvent), 1, &windowPaintEvent); + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleWindowDrawContentEvent), 1, &cWindowDrawContentEvent); + + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleWindowActivatedEvent), 1, &cWindowActivatedEvent); + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleMouseUpDownEvent), GetEventTypeCount(cMouseUpDownEvent), cMouseUpDownEvent); + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleMouseWheelMovedEvent), 1, &cMouseWheelMovedEvent); + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleWindowResizeStarted), 1, &cWindowResizeStarted); + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleWindowResizeCompleted), 1, &cWindowResizeCompleted); + + /* Menu event handlers */ + + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleCommandProcessEvent), 1, &cCommandProcessEvent); + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleMenuPopulateEvent), 1, &cMenuPopulateEvent); + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleMenuClosedEvent), 1, &cMenuClosedEvent); + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleMenuTargetItemEvent), 1, &cMenuTargetItemEvent); + + /* Keyboard event handlers*/ + + InstallAndRegisterEventHandler(NewEventHandlerUPP(HandleKeyboardEvent), GetEventTypeCount(cKeyboardRawKeyEvents), cKeyboardRawKeyEvents); + +} + +OSStatus AquaSalFrame::InstallAndRegisterEventHandler(EventHandlerUPP upp, size_t nEvents, const EventTypeSpec* eventSpec) +{ + EventHandlerRef evtHandler; + OSStatus rc = InstallWindowEventHandler(mrWindow, upp, nEvents, eventSpec, this, &evtHandler); + + if (rc == noErr) + mSysWindowEventHandlerDataContainer.push_back(make_pair(upp, evtHandler)); + + return rc; +} + +void AquaSalFrame::DeinstallAndUnregisterAllEventHandler() +{ + SysWindowEventHandlerDataContainer_t::iterator iter = mSysWindowEventHandlerDataContainer.begin(); + SysWindowEventHandlerDataContainer_t::iterator iter_end = mSysWindowEventHandlerDataContainer.end(); + for (/*NOP*/; iter != iter_end; ++iter) + { + DisposeEventHandlerUPP((*iter).first); + RemoveEventHandler((*iter).second); + } + mSysWindowEventHandlerDataContainer.clear(); +} + +OSStatus GetOptimalWindowSize(Rect* rect) +{ + OSStatus err = noErr; + GDHandle hDisplay; + + BOOST_ASSERT(rect != NULL && "Precondition violated"); + + /* + for (hDisplay = DMGetFirstScreenDevice(TRUE); hDisplay != 0; hDisplay = DMGetNextScreenDevice(hDisplay, TRUE)){} + err = GetAvailableWindowPositioningBounds(hDisplay,rect); + */ + rect->top = 100; + rect->left = 100; + rect->bottom = 500; + rect->right = 500; + return err; } diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/window/salmenu.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/window/salmenu.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/window/salmenu.cxx 1970-01-01 01:00:00.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/window/salmenu.cxx 2006-08-26 17:21:56.000000000 +0200 @@ -0,0 +1,255 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * 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 + * + ************************************************************************/ + +#ifndef _SV_SALDATA_HXX +#include +#endif +#ifndef _SV_SALINST_H +#include +#endif +#ifndef _SV_SALMENU_H +#include +#endif + +#define XUBSTRINGTOCFSTRING(string) \ + CFStringCreateWithCString(NULL, \ + ByteString( (string), RTL_TEXTENCODING_UTF8).GetBuffer(), \ + kCFStringEncodingUTF8); + +// ======================================================================= + +SalMenu* AquaSalInstance::CreateMenu( BOOL bMenuBar ) +{ + AquaSalMenu *pAquaSalMenu = new AquaSalMenu(); + static MenuID inMenuID=0; + + pAquaSalMenu->mbMenuBar = bMenuBar; + + CreateNewMenu (inMenuID++, 0, &pAquaSalMenu->mrMenuRef); + + /* Associate the pointer to this SalMenu with the menu */ + SetMenuItemProperty (pAquaSalMenu->mrMenuRef, 0, + APP_PROPERTY_CREATOR, APP_PROPERTY_TAG_MENU_POINTER, + sizeof(pAquaSalMenu), &pAquaSalMenu); + + return pAquaSalMenu; +} + +void AquaSalInstance::DestroyMenu( SalMenu* pSalMenu ) +{ + delete pSalMenu; +} + +SalMenuItem* AquaSalInstance::CreateMenuItem( const SalItemParams* pItemData ) +{ + if( !pItemData ) + return NULL; + + AquaSalMenuItem *pSalMenuItem = new AquaSalMenuItem(); + + pSalMenuItem->maMenuAttributes = 0; + pSalMenuItem->mpSubMenu = NULL; + pSalMenuItem->mnId = pItemData->nId; + pSalMenuItem->mText = pItemData->aText; + + // Delete mnemonics + pSalMenuItem->mText.EraseAllChars( '~' ); + + pSalMenuItem->mpMenu = pItemData->pMenu; + + if (pItemData->eType == MENUITEM_SEPARATOR) + pSalMenuItem->maMenuAttributes |= kMenuItemAttrSeparator; + + return pSalMenuItem; +} + +void AquaSalInstance::DestroyMenuItem( SalMenuItem* pSalMenuItem ) +{ + delete pSalMenuItem; +} + + +// ======================================================================= + + +/* + * AquaSalMenu + */ + +AquaSalMenu::~AquaSalMenu() +{ + if (this->mrMenuRef) + { + DisposeMenu(this->mrMenuRef); + } +} + +BOOL AquaSalMenu::VisibleMenuBar() +{ + // Enable/disable experimental native menus code? + // + // To enable, set the environment variable AQUA_NATIVE_MENUS to TRUE + + static const char *pExperimental = getenv ("AQUA_NATIVE_MENUS"); + + if ( !pExperimental || strcasecmp(pExperimental, "TRUE") ) + return FALSE; + + // End of experimental code enable/disable part + + return TRUE; +} + +void AquaSalMenu::SetFrame( const SalFrame *pFrame ) +{ + fprintf(stderr, ">*>_> %s\n",__func__); +} + +void AquaSalMenu::InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos ) +{ + AquaSalMenuItem *pAquaSalMenuItem = (AquaSalMenuItem *) pSalMenuItem; + + // save MenuRef of the menu for future reference + pAquaSalMenuItem->mrParentMenuRef = mrMenuRef; + + if (mbMenuBar) + AppendMenuItemTextWithCFString( mrMenuRef, NULL, pAquaSalMenuItem->maMenuAttributes, 0, &pAquaSalMenuItem->mnMenuItemIndex); + else + { + CFStringRef menuText = XUBSTRINGTOCFSTRING(pAquaSalMenuItem->mText); + + AppendMenuItemTextWithCFString( mrMenuRef, menuText, pAquaSalMenuItem->maMenuAttributes, 0, &pAquaSalMenuItem->mnMenuItemIndex); + CFRelease(menuText); + } + + /* Associate the pointer to this SalMenuItem with the menu item */ + SetMenuItemProperty (mrMenuRef, pAquaSalMenuItem->mnMenuItemIndex, + APP_PROPERTY_CREATOR, APP_PROPERTY_TAG_MENU_ITEM_POINTER, + sizeof(pSalMenuItem), &pSalMenuItem); +} + +void AquaSalMenu::RemoveItem( unsigned nPos ) +{ + MenuRef menu = this->mrMenuRef; + + if (menu) + // nPos is 0 based, MenuItemIndex is 1 based + DeleteMenuItem (menu, nPos+1); +} + +void AquaSalMenu::SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos ) +{ + AquaSalMenuItem *pAquaSalMenuItem = (AquaSalMenuItem *) pSalMenuItem; + + AquaSalMenu *subAquaSalMenu = (AquaSalMenu *) pSubMenu; + + // FIXME: in svtools - workben - svdem, pSubMenu is NULL! + if (subAquaSalMenu) + { + CFStringRef menuText = XUBSTRINGTOCFSTRING(pAquaSalMenuItem->mText); + + pAquaSalMenuItem->mpSubMenu = pSubMenu; + SetMenuTitleWithCFString(subAquaSalMenu->mrMenuRef, menuText); + CFRelease(menuText); + SetMenuItemHierarchicalMenu (mrMenuRef, pAquaSalMenuItem->mnMenuItemIndex, subAquaSalMenu->mrMenuRef); + } +} + +void AquaSalMenu::CheckItem( unsigned nPos, BOOL bCheck ) +{ + // nPos is 0 based, MenuItemIndex is 1 based + CheckMenuItem(this->mrMenuRef, nPos+1, bCheck); +} + +void AquaSalMenu::EnableItem( unsigned nPos, BOOL bEnable ) +{ + // nPos is 0 based, MenuItemIndex is 1 based + if (bEnable) + EnableMenuItem(this->mrMenuRef, nPos+1); + else + DisableMenuItem(this->mrMenuRef, nPos+1); +} + +void AquaSalMenu::SetItemImage( unsigned nPos, SalMenuItem* pSalMenuItem, const Image& rImage ) +{ + fprintf(stderr, ">*>_> %s\n",__func__); +} + +void AquaSalMenu::SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const XubString& rText ) +{ + if (!pSalMenuItem) + return; + + AquaSalMenuItem *pAquaSalMenuItem = (AquaSalMenuItem *) pSalMenuItem; + + pAquaSalMenuItem->mText = rText; + + // Delete mnemonics + pAquaSalMenuItem->mText.EraseAllChars( '~' ); + + CFStringRef menuText = XUBSTRINGTOCFSTRING(pAquaSalMenuItem->mText); + + SetMenuItemTextWithCFString( mrMenuRef, pAquaSalMenuItem->mnMenuItemIndex, menuText); + + // if the menu item has a submenu, change its title as well + if (pAquaSalMenuItem->mpSubMenu) + { + AquaSalMenu *subMenu = (AquaSalMenu *) pAquaSalMenuItem->mpSubMenu; + SetMenuTitleWithCFString(subMenu->mrMenuRef, menuText); + } + CFRelease(menuText); +} + +void AquaSalMenu::SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const KeyCode& rKeyCode, const XubString& rKeyName ) +{ + fprintf(stderr, ">*>_> %s\n",__func__); +} + +void AquaSalMenu::GetSystemMenuData( SystemMenuData* pData ) +{ + fprintf(stderr, ">*>_> %s\n",__func__); +} + +// ======================================================================= + +/* + * SalMenuItem + */ + +AquaSalMenuItem::~AquaSalMenuItem() +{ +} + +// ------------------------------------------------------------------- diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/aqua/source/window/salobj.cxx ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/window/salobj.cxx --- ooo_SRC680_m187_src.orig/vcl/aqua/source/window/salobj.cxx 2006-09-17 13:46:32.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/aqua/source/window/salobj.cxx 2006-10-13 23:56:48.000000000 +0200 @@ -41,8 +41,8 @@ #ifndef _SV_SALDATA_HXX #include #endif -#ifndef _SV_SALOBJ_HXX -#include +#ifndef _SV_SALOBJ_H +#include #endif // ======================================================================= @@ -54,118 +54,118 @@ // ======================================================================= -SalObject::SalObject() +AquaSalObject::AquaSalObject() { SalData* pSalData = GetSalData(); - maObjectData.mpFrame = NULL; - maObjectData.mpInst = NULL; - maObjectData.mpProc = ImplSalObjectCallbackDummy; + mpFrame = NULL; + mpInst = NULL; + mpProc = ImplSalObjectCallbackDummy; // Insert object in objectlist - maObjectData.mpNextObject = pSalData->mpFirstObject; + mpNextObject = (AquaSalObject*)pSalData->mpFirstObject; pSalData->mpFirstObject = this; } // ----------------------------------------------------------------------- -SalObject::~SalObject() +AquaSalObject::~AquaSalObject() { SalData* pSalData = GetSalData(); // remove frame from framelist if ( this == pSalData->mpFirstObject ) - pSalData->mpFirstObject = maObjectData.mpNextObject; + pSalData->mpFirstObject = mpNextObject; else { - SalObject* pTempObject = pSalData->mpFirstObject; - while ( pTempObject->maObjectData.mpNextObject != this ) - pTempObject = pTempObject->maObjectData.mpNextObject; - pTempObject->maObjectData.mpNextObject = maObjectData.mpNextObject; + AquaSalObject* pTempObject = (AquaSalObject*)pSalData->mpFirstObject; + while ( pTempObject->mpNextObject != this ) + pTempObject = pTempObject->mpNextObject; + pTempObject->mpNextObject = mpNextObject; } } // ----------------------------------------------------------------------- -void SalObject::ResetClipRegion() +void AquaSalObject::ResetClipRegion() { } // ----------------------------------------------------------------------- -USHORT SalObject::GetClipRegionType() +USHORT AquaSalObject::GetClipRegionType() { return SAL_OBJECT_CLIP_INCLUDERECTS; } // ----------------------------------------------------------------------- -void SalObject::BeginSetClipRegion( ULONG nRectCount ) +void AquaSalObject::BeginSetClipRegion( ULONG nRectCount ) { } // ----------------------------------------------------------------------- -void SalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) +void AquaSalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) { } // ----------------------------------------------------------------------- -void SalObject::EndSetClipRegion() +void AquaSalObject::EndSetClipRegion() { } // ----------------------------------------------------------------------- -void SalObject::SetPosSize( long nX, long nY, long nWidth, long nHeight ) +void AquaSalObject::SetPosSize( long nX, long nY, long nWidth, long nHeight ) { } // ----------------------------------------------------------------------- -void SalObject::Show( BOOL bVisible ) +void AquaSalObject::Show( BOOL bVisible ) { } // ----------------------------------------------------------------------- -void SalObject::Enable( BOOL bEnable ) +void AquaSalObject::Enable( BOOL bEnable ) { } // ----------------------------------------------------------------------- -void SalObject::GrabFocus() +void AquaSalObject::GrabFocus() { } // ----------------------------------------------------------------------- -void SalObject::SetBackground() +void AquaSalObject::SetBackground() { } // ----------------------------------------------------------------------- -void SalObject::SetBackground( SalColor nSalColor ) +void AquaSalObject::SetBackground( SalColor nSalColor ) { } // ----------------------------------------------------------------------- -const SystemEnvData* SalObject::GetSystemData() const +const SystemEnvData* AquaSalObject::GetSystemData() const { return NULL; } // ----------------------------------------------------------------------- -void SalObject::SetCallback( void* pInst, SALOBJECTPROC pProc ) +void AquaSalObject::SetCallback( void* pInst, SALOBJECTPROC pProc ) { - maObjectData.mpInst = pInst; + mpInst = pInst; if ( pProc ) - maObjectData.mpProc = pProc; + mpProc = pProc; else - maObjectData.mpProc = ImplSalObjectCallbackDummy; + mpProc = ImplSalObjectCallbackDummy; } diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/inc/sysdata.hxx ooo_SRC680_m187_src.aquavcl01/vcl/inc/sysdata.hxx --- ooo_SRC680_m187_src.orig/vcl/inc/sysdata.hxx 2006-02-28 11:46:12.000000000 +0100 +++ ooo_SRC680_m187_src.aquavcl01/vcl/inc/sysdata.hxx 2006-08-14 23:46:43.000000000 +0200 @@ -93,11 +93,17 @@ // - SystemGraphicsData - // -------------------- +#if defined( QUARTZ ) + struct CGContext; +#endif + struct SystemGraphicsData { unsigned long nSize; // size in bytes of this structure #if defined( WNT ) HDC hDC; // handle to a device context +#elif defined( QUARTZ ) + CGContext* mpContext; // QUARTZ graphic context #elif defined( UNX ) long hDrawable; // a drawable void* pRenderFormat; // render format for drawable diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/prj/build.lst ooo_SRC680_m187_src.aquavcl01/vcl/prj/build.lst --- ooo_SRC680_m187_src.orig/vcl/prj/build.lst 2006-10-06 12:31:10.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/prj/build.lst 2006-10-14 14:31:02.000000000 +0200 @@ -1,4 +1,4 @@ -vc vcl : BOOST:boost NAS:nas FREETYPE:freetype psprint rsc sot ucbhelper unotools icu i18npool unoil ridljar X11_EXTENSIONS:x11_extensions offuh basegfx SNDFILE:sndfile PORTAUDIO:portaudio transex3 SO:officenames NULL +vc vcl : BOOST:boost NAS:nas FREETYPE:freetype psprint rsc sot ucbhelper unotools icu i18npool unoil ridljar X11_EXTENSIONS:x11_extensions offuh basegfx SNDFILE:sndfile PORTAUDIO:portaudio transex3 SO:officenames basebmp NULL vc vcl usr1 - all vc_mkout NULL vc vcl\source\glyphs nmake - all vc_glyphs NULL vc vcl\source\app nmake - all vc_app NULL @@ -29,5 +29,5 @@ vc vcl\mac\source\gdi nmake - m vc__gdim NULL vc vcl\mac\source\window nmake - m vc__winm NULL vc vcl\mac\source\src nmake - m vc__srcm NULL -vc vcl\util nmake - all vc_util vc__plug.u vc__appa.u vc__appm.m vc__appu.u vc__appw.w vc__gdim.m vc__gdiu.u vc__gdiw.w vc__srcm.m vc__srcw.w vc__wina.u vc__winm.m vc__winu.u vc__winw.w vc__du.u vc__gtka.u vc__gtky.u vc__gtkw.u vc__gtkg.u vc__kde.u vc_app vc_ctrl vc_gdi vc_hlp vc_src vc_win vc_glyphs vc_components NULL +vc vcl\util nmake - all vc_util vc__plug.u vc__appa.u vc__appm.m vc__appu.u vc__appw.w vc__gdia.u vc__gdim.m vc__gdiu.u vc__gdiw.w vc__srcm.m vc__srcw.w vc__wina.u vc__winm.m vc__winu.u vc__winw.w vc__du.u vc__gtka.u vc__gtky.u vc__gtkw.u vc__gtkg.u vc__kde.u vc_app vc_ctrl vc_gdi vc_hlp vc_src vc_win vc_glyphs vc_components NULL vc vcl\workben nmake - all vc_wrkb vc_util NULL diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/source/app/settings.cxx ooo_SRC680_m187_src.aquavcl01/vcl/source/app/settings.cxx --- ooo_SRC680_m187_src.orig/vcl/source/app/settings.cxx 2006-09-17 13:48:56.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/source/app/settings.cxx 2006-10-14 00:00:04.000000000 +0200 @@ -79,8 +79,10 @@ #endif #ifdef UNX +#if !defined(QUARTZ) #include #include +#endif #include #include #endif diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/source/app/svmainhook.cxx ooo_SRC680_m187_src.aquavcl01/vcl/source/app/svmainhook.cxx --- ooo_SRC680_m187_src.orig/vcl/source/app/svmainhook.cxx 2006-09-17 13:50:19.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/source/app/svmainhook.cxx 2006-10-14 00:01:04.000000000 +0200 @@ -40,11 +40,48 @@ #include #endif -#ifndef MACOSX +#if not defined(MACOSX) || defined(QUARTZ) // only Mac OS X / X11 needs this trick, the Aqua version has its own native event loop -BOOL ImplSVMainHook( BOOL * ) +#include +//#include +#include +#include + +#include + +extern BOOL ImplSVMain(); + +static BOOL* gpbInit = 0; + +static pascal void MainRunLoopForThreadedApps( EventLoopTimerRef inTimer, void *inUserData ) { - return FALSE; // indicate that ImplSVMainHook is not implemented + fprintf(stderr,">>>> MainRunLoopForThreadedApps()\n"); + + BOOL bRet = ImplSVMain(); + if( gpbInit ) + *gpbInit = bRet; + + QuitApplicationEventLoop(); + + fprintf(stderr,"<<<< MainRunLoopForThreadedApps()\n"); +} + +BOOL ImplSVMainHook( BOOL * pbInit ) +{ + fprintf(stderr,">>>> ImplSVMainHook()\n"); + + gpbInit = pbInit; + + EventLoopTimerRef aMainRunLoopTimerRef; + (void) InstallEventLoopTimer( GetCurrentEventLoop(), 0, 0, NewEventLoopTimerUPP( MainRunLoopForThreadedApps ), NULL, &aMainRunLoopTimerRef ); + + // We really only call RunApplicationEventLoop() to install the default CarbonEvent handlers. Once the timer installed above + // fires, we remain in the MainRunLoopForThreadedApps() routine which is designed to yield to other cooperative threads. + RunApplicationEventLoop(); + + fprintf(stderr,"<<<<< ImplSVMainHook()\n"); + + return TRUE; // indicate that ImplSVMainHook is implemented } #else diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/util/makefile.mk ooo_SRC680_m187_src.aquavcl01/vcl/util/makefile.mk --- ooo_SRC680_m187_src.orig/vcl/util/makefile.mk 2006-10-06 12:07:49.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/util/makefile.mk 2006-10-14 00:43:43.000000000 +0200 @@ -151,7 +151,7 @@ $(SLB)$/components.lib -.IF "$(GUI)" == "UNX" +.IF "$(GUI)" == "UNX" && "$(GUIBASE)"!="aqua" LIB1FILES+=$(SLB)$/salplug.lib .ELSE LIB1FILES+= \ @@ -232,10 +232,12 @@ .ENDIF .IF "$(GUIBASE)"=="aqua" -SHL1STDLIBS += -framework Cocoa +SHL1STDLIBS += -framework Cocoa -framework Carbon -framework AppKit .ENDIF +.IF "$(GUIBASE)"!="aqua" SHL1STDLIBS += -lX11 +.ENDIF .IF "$(OS)"=="MACOSX" SHL1STDLIBS += -framework Foundation -framework CoreFoundation @@ -260,7 +262,6 @@ # libs for generic plugin SHL2STDLIBS=\ $(VCLLIB)\ - -lpsp$(VERSION)$(DLLPOSTFIX)\ $(SOTLIB) \ $(UNOTOOLSLIB) \ $(TOOLSLIB) \ @@ -271,11 +272,17 @@ $(VOSLIB) \ $(SALLIB) +.IF "$(GUIBASE)"!="aqua" +SHL2STDLIBS+=-lpsp$(VERSION)$(DLLPOSTFIX) +.ENDIF + # prepare linking of Xinerama .IF "$(USE_XINERAMA)" != "NO" .IF "$(OS)"=="MACOSX" +.IF "$(GUIBASE)"!="aqua" XINERAMALIBS=-lXinerama +.ENDIF #aqua .ELSE .IF "$(OS)" != "SOLARIS" || "$(USE_XINERAMA_VERSION)" == "Xorg" .IF "$(XINERAMA_LINK)" == "dynamic" @@ -295,11 +302,15 @@ .IF "$(ENABLE_PASF)" != "" +SHL2STDLIBS += -lsndfile -lportaudio .IF "$(OS)"=="MACOSX" SHL2STDLIBS += -framework CoreAudio -framework AudioToolbox -.ENDIF -SHL2STDLIBS += -lsndfile -lportaudio -.ENDIF # ENABLE_PASF +.ENDIF # "$(OS)"=="MACOSX" +.ENDIF # "$(ENABLE_PASF)"!="" + +.IF "$(GUIBASE)"=="aqua" +SHL2STDLIBS += -framework Cocoa -framework Carbon +.ENDIF # aqua .IF "$(ENABLE_NAS)" != "" SHL2STDLIBS += -laudio @@ -325,8 +336,10 @@ # dummy plugin LIB3TARGET=$(SLB)$/idummy_plug_ +.IF "$(GUIBASE)"!="aqua" LIB3FILES= \ $(SLB)$/dapp.lib +.ENDIF SHL3TARGET=vclplug_dummy$(UPD)$(DLLPOSTFIX) SHL3IMPLIB=idummy_plug_ SHL3LIBS=$(LIB3TARGET) @@ -335,7 +348,6 @@ # libs for dummy plugin SHL3STDLIBS=\ $(VCLLIB)\ - -lpsp$(VERSION)$(DLLPOSTFIX)\ $(SOTLIB) \ $(UNOTOOLSLIB) \ $(TOOLSLIB) \ @@ -346,6 +358,10 @@ $(VOSLIB) \ $(SALLIB) +.IF "$(GUIBASE)"!="aqua" +SHL3STDLIBS += -lpsp$(VERSION)$(DLLPOSTFIX) +.ENDIF + # gtk plugin .IF "$(ENABLE_GTK)" != "" PKGCONFIG_MODULES=gtk+-2.0 gthread-2.0 diff -x CVS -urN ooo_SRC680_m187_src.orig/vcl/workben/svdem.cxx ooo_SRC680_m187_src.aquavcl01/vcl/workben/svdem.cxx --- ooo_SRC680_m187_src.orig/vcl/workben/svdem.cxx 2006-09-17 14:48:02.000000000 +0200 +++ ooo_SRC680_m187_src.aquavcl01/vcl/workben/svdem.cxx 2006-10-14 00:48:15.000000000 +0200 @@ -43,11 +43,16 @@ #include #include #include +#include +#include #include #include #include +#include +#include + using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; // ----------------------------------------------------------------------- @@ -91,10 +96,22 @@ void Main() { + /* + IntroWindow splash; + splash.Show(); + sleep(5); + splash.Hide(); + */ + MyWin aMainWin( NULL, WB_APP | WB_STDWORK ); aMainWin.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "VCL - Workbench" ) ) ); aMainWin.Show(); + /* + InfoBox ib(NULL, String((sal_Char*)"Test", sizeof("Test"))); + ib.Execute(); + */ + Application::Execute(); } @@ -116,14 +133,16 @@ void MyWin::MouseButtonDown( const MouseEvent& rMEvt ) { - WorkWindow::MouseButtonDown( rMEvt ); + Rectangle aRect(0,0,4,4); + aRect.SetPos( rMEvt.GetPosPixel() ); + SetFillColor(Color(COL_RED)); + DrawRect( aRect ); } // ----------------------------------------------------------------------- void MyWin::MouseButtonUp( const MouseEvent& rMEvt ) { - WorkWindow::MouseButtonUp( rMEvt ); } // ----------------------------------------------------------------------- @@ -144,7 +163,21 @@ void MyWin::Paint( const Rectangle& rRect ) { - WorkWindow::Paint( rRect ); + fprintf(stderr, "MyWin::Paint(%d,%d,%d,%d)\n", rRect.getX(), rRect.getY(), rRect.getWidth(), rRect.getHeight()); + + Size aSz(GetSizePixel()); + Point aPt; + Rectangle r(aPt, aSz); + + SetFillColor(Color(COL_BLUE)); + SetLineColor(Color(COL_YELLOW)); + + DrawRect( r ); + int i; + for(int i=0; i