diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2007-12-07 10:49:42 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2007-12-07 10:49:42 +0000 |
commit | a71e4993301e45d0028d770963f1872c2c6a2dfc (patch) | |
tree | d09957a8020dd35526879d0b0ae7e357c2183f7e /vcl/aqua/source/window/salobj.cxx | |
parent | 6b217619c8577f2167cd83ae8df63bbd59acfbe0 (diff) |
INTEGRATION: CWS macosxquicktime01 (1.12.10); FILE MERGED
2007/11/01 10:33:21 pl 1.12.10.4: #i82621# change AquaSalObject to NSClipView implementation
2007/10/30 14:45:48 pl 1.12.10.3: #i82621# implement at least one clip rectangle on AquaSalObject
2007/10/25 16:21:48 msicotte 1.12.10.2: #i82621# reverse Yes and No for AquaSalObject::Show [ QTMovieView setHidden: ] is opposite
2007/10/15 11:11:26 pl 1.12.10.1: #i82621# initial implementation of SalObject for MacOSX aqua
Diffstat (limited to 'vcl/aqua/source/window/salobj.cxx')
-rw-r--r-- | vcl/aqua/source/window/salobj.cxx | 161 |
1 files changed, 121 insertions, 40 deletions
diff --git a/vcl/aqua/source/window/salobj.cxx b/vcl/aqua/source/window/salobj.cxx index 880ee4514423..5fefcc3c3237 100644 --- a/vcl/aqua/source/window/salobj.cxx +++ b/vcl/aqua/source/window/salobj.cxx @@ -4,9 +4,9 @@ * * $RCSfile: salobj.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: kz $ $Date: 2007-10-09 15:17:19 $ + * last change: $Author: vg $ $Date: 2007-12-07 11:49:42 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -40,51 +40,81 @@ #include "saldata.hxx" #include "salobj.h" +#include "salframe.h" -// ======================================================================= - -static long ImplSalObjectCallbackDummy( void*, SalObject*, USHORT, const void* ) -{ - return 0; -} +// get QTMovieView +#include "premac.h" +#include <QTKit/QTMovieView.h> +#include "postmac.h" // ======================================================================= -AquaSalObject::AquaSalObject() -{ - SalData* pSalData = GetSalData(); - - mpFrame = NULL; - mpInst = NULL; - mpProc = ImplSalObjectCallbackDummy; - - // Insert object in objectlist - mpNextObject = (AquaSalObject*)pSalData->mpFirstObject; - pSalData->mpFirstObject = this; +AquaSalObject::AquaSalObject( AquaSalFrame* pFrame ) : + mpFrame( pFrame ), + mnClipX( -1 ), + mnClipY( -1 ), + mnClipWidth( -1 ), + mnClipHeight( -1 ), + mbClip( false ), + mnX( 0 ), + mnY( 0 ), + mnWidth( 20 ), + mnHeight( 20 ) +{ + maSysData.nSize = sizeof( maSysData ); + maSysData.pView = NULL; + + NSRect aInitFrame = { { 0, 0 }, { 20, 20 } }; + mpClipView = [[NSClipView alloc] initWithFrame: aInitFrame ]; + if( mpClipView ) + { + [mpFrame->getView() addSubview: mpClipView]; + [mpClipView setHidden: YES]; + } + maSysData.pView = [[QTMovieView alloc] initWithFrame: aInitFrame]; + if( maSysData.pView ) + { + if( mpClipView ) + [mpClipView setDocumentView: maSysData.pView]; + } } // ----------------------------------------------------------------------- AquaSalObject::~AquaSalObject() { - SalData* pSalData = GetSalData(); - - // remove frame from framelist - if ( this == pSalData->mpFirstObject ) - pSalData->mpFirstObject = mpNextObject; - else + if( maSysData.pView ) + { + [maSysData.pView removeFromSuperview]; + [maSysData.pView release]; + } + if( mpClipView ) { - AquaSalObject* pTempObject = (AquaSalObject*)pSalData->mpFirstObject; - while ( pTempObject->mpNextObject != this ) - pTempObject = pTempObject->mpNextObject; - pTempObject->mpNextObject = mpNextObject; + [mpClipView removeFromSuperview]; + [mpClipView release]; } } +/* + sadly there seems to be no way to impose clipping on a child view, + especially a QTMovieView which seems to ignore the current context + completely. Also there is no real way to shape a window; on Aqua a + similar effect to non-rectangular windows is achieved by using a + non-opaque window and not painting where one wants the background + to shine through. + + With respect to SalObject this leaves us to having an NSClipView + containing the child view. Even a QTMovieView respects the boundaries of + that, which gives us a clip "region" consisting of one rectangle. + This is gives us an 80% solution only, though. +*/ + // ----------------------------------------------------------------------- void AquaSalObject::ResetClipRegion() { + mbClip = false; + setClippedPosSize(); } // ----------------------------------------------------------------------- @@ -98,30 +128,91 @@ USHORT AquaSalObject::GetClipRegionType() void AquaSalObject::BeginSetClipRegion( ULONG nRectCount ) { + mbClip = false; } // ----------------------------------------------------------------------- void AquaSalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) { + if( mbClip ) + { + if( nX < mnClipX ) + { + mnClipWidth += mnClipX - nX; + mnClipX = nX; + } + if( nX + nWidth > mnClipX + mnClipWidth ) + mnClipWidth = nX + nWidth - mnClipX; + if( nY < mnClipY ) + { + mnClipHeight += mnClipY - nY; + mnClipY = nY; + } + if( nY + nHeight > mnClipY + mnClipHeight ) + mnClipHeight = nY + nHeight - mnClipY; + } + else + { + mnClipX = nX; + mnClipY = nY; + mnClipWidth = nWidth; + mnClipHeight = nHeight; + mbClip = true; + } } // ----------------------------------------------------------------------- void AquaSalObject::EndSetClipRegion() { + setClippedPosSize(); } // ----------------------------------------------------------------------- void AquaSalObject::SetPosSize( long nX, long nY, long nWidth, long nHeight ) { + mnX = nX; + mnY = nY; + mnWidth = nWidth; + mnHeight = nHeight; + setClippedPosSize(); +} + +// ----------------------------------------------------------------------- + +void AquaSalObject::setClippedPosSize() +{ + NSRect aViewRect = { { 0, 0 }, { mnWidth, mnHeight } }; + if( maSysData.pView ) + [maSysData.pView setFrame: aViewRect]; + + NSRect aClipViewRect = { { mnX, mnY }, { mnWidth, mnHeight } }; + NSPoint aClipPt = { 0, 0 }; + if( mbClip ) + { + aClipViewRect.origin.x += mnClipX; + aClipViewRect.origin.y += mnClipY; + aClipViewRect.size.width = mnClipWidth; + aClipViewRect.size.height = mnClipHeight; + aClipPt.x = mnClipX; + if( mnClipY == 0 ) + aClipPt.y = mnHeight - mnClipHeight;; + } + + mpFrame->VCLToCocoa( aClipViewRect, false ); + [mpClipView setFrame: aClipViewRect]; + + [mpClipView scrollToPoint: aClipPt]; } // ----------------------------------------------------------------------- void AquaSalObject::Show( BOOL bVisible ) { + if( mpClipView ) + [mpClipView setHidden: (bVisible ? NO : YES)]; } // ----------------------------------------------------------------------- @@ -152,16 +243,6 @@ void AquaSalObject::SetBackground( SalColor nSalColor ) const SystemEnvData* AquaSalObject::GetSystemData() const { - return NULL; + return &maSysData; } -// ----------------------------------------------------------------------- - -void AquaSalObject::SetCallback( void* pInst, SALOBJECTPROC pProc ) -{ - mpInst = pInst; - if ( pProc ) - mpProc = pProc; - else - mpProc = ImplSalObjectCallbackDummy; -} |