19f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
39f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
49f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file
59f62ea84SAndrew Rist * distributed with this work for additional information
69f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file
79f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the
89f62ea84SAndrew Rist * "License"); you may not use this file except in compliance
99f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
119f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
139f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing,
149f62ea84SAndrew Rist * software distributed under the License is distributed on an
159f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169f62ea84SAndrew Rist * KIND, either express or implied. See the License for the
179f62ea84SAndrew Rist * specific language governing permissions and limitations
189f62ea84SAndrew Rist * under the License.
19cdf0e10cSrcweir *
209f62ea84SAndrew Rist *************************************************************/
219f62ea84SAndrew Rist
229f62ea84SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <string.h>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include "aqua/saldata.hxx"
30cdf0e10cSrcweir #include "aqua/salobj.h"
31cdf0e10cSrcweir #include "aqua/salframe.h"
32cdf0e10cSrcweir
33cdf0e10cSrcweir // =======================================================================
34cdf0e10cSrcweir
AquaSalObject(AquaSalFrame * pFrame)35cdf0e10cSrcweir AquaSalObject::AquaSalObject( AquaSalFrame* pFrame ) :
36cdf0e10cSrcweir mpFrame( pFrame ),
37cdf0e10cSrcweir mnClipX( -1 ),
38cdf0e10cSrcweir mnClipY( -1 ),
39cdf0e10cSrcweir mnClipWidth( -1 ),
40cdf0e10cSrcweir mnClipHeight( -1 ),
41cdf0e10cSrcweir mbClip( false ),
42cdf0e10cSrcweir mnX( 0 ),
43cdf0e10cSrcweir mnY( 0 ),
44cdf0e10cSrcweir mnWidth( 20 ),
45cdf0e10cSrcweir mnHeight( 20 )
46cdf0e10cSrcweir {
47cdf0e10cSrcweir maSysData.nSize = sizeof( maSysData );
48bde8a4bdSHerbert Dürr maSysData.mpNSView = NULL;
49cdf0e10cSrcweir
50*01367266SHerbert Dürr NSRect aInitFrame = { NSZeroPoint, { 20, 20 } };
51cdf0e10cSrcweir mpClipView = [[NSClipView alloc] initWithFrame: aInitFrame ];
52cdf0e10cSrcweir if( mpClipView )
53cdf0e10cSrcweir {
54bde8a4bdSHerbert Dürr [mpFrame->getNSView() addSubview: mpClipView];
55cdf0e10cSrcweir [mpClipView setHidden: YES];
56cdf0e10cSrcweir }
57bde8a4bdSHerbert Dürr maSysData.mpNSView = [[NSView alloc] initWithFrame: aInitFrame];
58bde8a4bdSHerbert Dürr if( maSysData.mpNSView )
59cdf0e10cSrcweir {
60cdf0e10cSrcweir if( mpClipView )
61bde8a4bdSHerbert Dürr [mpClipView setDocumentView: maSysData.mpNSView];
62cdf0e10cSrcweir }
63cdf0e10cSrcweir }
64cdf0e10cSrcweir
65cdf0e10cSrcweir // -----------------------------------------------------------------------
66cdf0e10cSrcweir
~AquaSalObject()67cdf0e10cSrcweir AquaSalObject::~AquaSalObject()
68cdf0e10cSrcweir {
69bde8a4bdSHerbert Dürr if( maSysData.mpNSView )
70cdf0e10cSrcweir {
71bde8a4bdSHerbert Dürr NSView *pView = maSysData.mpNSView;
72cdf0e10cSrcweir [pView removeFromSuperview];
73cdf0e10cSrcweir [pView release];
74cdf0e10cSrcweir }
75cdf0e10cSrcweir if( mpClipView )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir [mpClipView removeFromSuperview];
78cdf0e10cSrcweir [mpClipView release];
79cdf0e10cSrcweir }
80cdf0e10cSrcweir }
81cdf0e10cSrcweir
82cdf0e10cSrcweir /*
83cdf0e10cSrcweir sadly there seems to be no way to impose clipping on a child view,
84cdf0e10cSrcweir especially a QTMovieView which seems to ignore the current context
85cdf0e10cSrcweir completely. Also there is no real way to shape a window; on Aqua a
86cdf0e10cSrcweir similar effect to non-rectangular windows is achieved by using a
87cdf0e10cSrcweir non-opaque window and not painting where one wants the background
88cdf0e10cSrcweir to shine through.
89cdf0e10cSrcweir
90cdf0e10cSrcweir With respect to SalObject this leaves us to having an NSClipView
91cdf0e10cSrcweir containing the child view. Even a QTMovieView respects the boundaries of
92cdf0e10cSrcweir that, which gives us a clip "region" consisting of one rectangle.
93cdf0e10cSrcweir This is gives us an 80% solution only, though.
94cdf0e10cSrcweir */
95cdf0e10cSrcweir
96cdf0e10cSrcweir // -----------------------------------------------------------------------
97cdf0e10cSrcweir
ResetClipRegion()98cdf0e10cSrcweir void AquaSalObject::ResetClipRegion()
99cdf0e10cSrcweir {
100cdf0e10cSrcweir mbClip = false;
101cdf0e10cSrcweir setClippedPosSize();
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
104cdf0e10cSrcweir // -----------------------------------------------------------------------
105cdf0e10cSrcweir
GetClipRegionType()106cdf0e10cSrcweir sal_uInt16 AquaSalObject::GetClipRegionType()
107cdf0e10cSrcweir {
108cdf0e10cSrcweir return SAL_OBJECT_CLIP_INCLUDERECTS;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
111cdf0e10cSrcweir // -----------------------------------------------------------------------
112cdf0e10cSrcweir
BeginSetClipRegion(sal_uLong)113cdf0e10cSrcweir void AquaSalObject::BeginSetClipRegion( sal_uLong )
114cdf0e10cSrcweir {
115cdf0e10cSrcweir mbClip = false;
116cdf0e10cSrcweir }
117cdf0e10cSrcweir
118cdf0e10cSrcweir // -----------------------------------------------------------------------
119cdf0e10cSrcweir
UnionClipRegion(long nX,long nY,long nWidth,long nHeight)120cdf0e10cSrcweir void AquaSalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir if( mbClip )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir if( nX < mnClipX )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir mnClipWidth += mnClipX - nX;
127cdf0e10cSrcweir mnClipX = nX;
128cdf0e10cSrcweir }
129cdf0e10cSrcweir if( nX + nWidth > mnClipX + mnClipWidth )
130cdf0e10cSrcweir mnClipWidth = nX + nWidth - mnClipX;
131cdf0e10cSrcweir if( nY < mnClipY )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir mnClipHeight += mnClipY - nY;
134cdf0e10cSrcweir mnClipY = nY;
135cdf0e10cSrcweir }
136cdf0e10cSrcweir if( nY + nHeight > mnClipY + mnClipHeight )
137cdf0e10cSrcweir mnClipHeight = nY + nHeight - mnClipY;
138cdf0e10cSrcweir }
139cdf0e10cSrcweir else
140cdf0e10cSrcweir {
141cdf0e10cSrcweir mnClipX = nX;
142cdf0e10cSrcweir mnClipY = nY;
143cdf0e10cSrcweir mnClipWidth = nWidth;
144cdf0e10cSrcweir mnClipHeight = nHeight;
145cdf0e10cSrcweir mbClip = true;
146cdf0e10cSrcweir }
147cdf0e10cSrcweir }
148cdf0e10cSrcweir
149cdf0e10cSrcweir // -----------------------------------------------------------------------
150cdf0e10cSrcweir
EndSetClipRegion()151cdf0e10cSrcweir void AquaSalObject::EndSetClipRegion()
152cdf0e10cSrcweir {
153cdf0e10cSrcweir setClippedPosSize();
154cdf0e10cSrcweir }
155cdf0e10cSrcweir
156cdf0e10cSrcweir // -----------------------------------------------------------------------
157cdf0e10cSrcweir
SetPosSize(long nX,long nY,long nWidth,long nHeight)158cdf0e10cSrcweir void AquaSalObject::SetPosSize( long nX, long nY, long nWidth, long nHeight )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir mnX = nX;
161cdf0e10cSrcweir mnY = nY;
162cdf0e10cSrcweir mnWidth = nWidth;
163cdf0e10cSrcweir mnHeight = nHeight;
164cdf0e10cSrcweir setClippedPosSize();
165cdf0e10cSrcweir }
166cdf0e10cSrcweir
167cdf0e10cSrcweir // -----------------------------------------------------------------------
168cdf0e10cSrcweir
setClippedPosSize()169cdf0e10cSrcweir void AquaSalObject::setClippedPosSize()
170cdf0e10cSrcweir {
171*01367266SHerbert Dürr NSRect aViewRect = { NSZeroPoint, NSMakeSize( mnWidth, mnHeight) };
172bde8a4bdSHerbert Dürr if( maSysData.mpNSView )
173cdf0e10cSrcweir {
174bde8a4bdSHerbert Dürr NSView* pNSView = maSysData.mpNSView;
175bde8a4bdSHerbert Dürr [pNSView setFrame: aViewRect];
176cdf0e10cSrcweir }
177cdf0e10cSrcweir
178cd426cceSHerbert Dürr NSRect aClipViewRect = NSMakeRect( mnX, mnY, mnWidth, mnHeight);
179*01367266SHerbert Dürr NSPoint aClipPt = NSZeroPoint;
180cdf0e10cSrcweir if( mbClip )
181cdf0e10cSrcweir {
182cdf0e10cSrcweir aClipViewRect.origin.x += mnClipX;
183cdf0e10cSrcweir aClipViewRect.origin.y += mnClipY;
184cdf0e10cSrcweir aClipViewRect.size.width = mnClipWidth;
185cdf0e10cSrcweir aClipViewRect.size.height = mnClipHeight;
186cdf0e10cSrcweir aClipPt.x = mnClipX;
187cdf0e10cSrcweir if( mnClipY == 0 )
188cdf0e10cSrcweir aClipPt.y = mnHeight - mnClipHeight;;
189cdf0e10cSrcweir }
190cdf0e10cSrcweir
191cdf0e10cSrcweir mpFrame->VCLToCocoa( aClipViewRect, false );
192cdf0e10cSrcweir [mpClipView setFrame: aClipViewRect];
193cdf0e10cSrcweir
194cdf0e10cSrcweir [mpClipView scrollToPoint: aClipPt];
195cdf0e10cSrcweir }
196cdf0e10cSrcweir
197cdf0e10cSrcweir // -----------------------------------------------------------------------
198cdf0e10cSrcweir
Show(sal_Bool bVisible)199cdf0e10cSrcweir void AquaSalObject::Show( sal_Bool bVisible )
200cdf0e10cSrcweir {
201cdf0e10cSrcweir if( mpClipView )
202cdf0e10cSrcweir [mpClipView setHidden: (bVisible ? NO : YES)];
203cdf0e10cSrcweir }
204cdf0e10cSrcweir
205cdf0e10cSrcweir // -----------------------------------------------------------------------
206cdf0e10cSrcweir
Enable(sal_Bool)207cdf0e10cSrcweir void AquaSalObject::Enable( sal_Bool )
208cdf0e10cSrcweir {
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211cdf0e10cSrcweir // -----------------------------------------------------------------------
212cdf0e10cSrcweir
GrabFocus()213cdf0e10cSrcweir void AquaSalObject::GrabFocus()
214cdf0e10cSrcweir {
215cdf0e10cSrcweir }
216cdf0e10cSrcweir
217cdf0e10cSrcweir // -----------------------------------------------------------------------
218cdf0e10cSrcweir
SetBackground()219cdf0e10cSrcweir void AquaSalObject::SetBackground()
220cdf0e10cSrcweir {
221cdf0e10cSrcweir }
222cdf0e10cSrcweir
223cdf0e10cSrcweir // -----------------------------------------------------------------------
224cdf0e10cSrcweir
SetBackground(SalColor)225cdf0e10cSrcweir void AquaSalObject::SetBackground( SalColor )
226cdf0e10cSrcweir {
227cdf0e10cSrcweir }
228cdf0e10cSrcweir
229cdf0e10cSrcweir // -----------------------------------------------------------------------
230cdf0e10cSrcweir
GetSystemData() const231cdf0e10cSrcweir const SystemEnvData* AquaSalObject::GetSystemData() const
232cdf0e10cSrcweir {
233cdf0e10cSrcweir return &maSysData;
234cdf0e10cSrcweir }
235cdf0e10cSrcweir
236cdf0e10cSrcweir // -----------------------------------------------------------------------
237cdf0e10cSrcweir
InterceptChildWindowKeyDown(sal_Bool)238cdf0e10cSrcweir void AquaSalObject::InterceptChildWindowKeyDown( sal_Bool /*bIntercept*/ )
239cdf0e10cSrcweir {
240cdf0e10cSrcweir }
241cdf0e10cSrcweir
242