1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 #include "aqua/saldata.hxx"
24 #include "aqua/salobj.h"
25 #include "aqua/salframe.h"
27 // =======================================================================
29 AquaSalObject::AquaSalObject( AquaSalFrame
* pFrame
) :
41 maSysData
.nSize
= sizeof( maSysData
);
42 maSysData
.pView
= NULL
;
44 NSRect aInitFrame
= { { 0, 0 }, { 20, 20 } };
45 mpClipView
= [[NSClipView alloc
] initWithFrame
: aInitFrame
];
48 [mpFrame
->getView() addSubview
: mpClipView
];
49 [mpClipView setHidden
: YES
];
51 maSysData
.pView
= [[NSView alloc
] initWithFrame
: aInitFrame
];
55 [mpClipView setDocumentView
: maSysData
.pView
];
59 // -----------------------------------------------------------------------
61 AquaSalObject::~AquaSalObject()
65 NSView
*pView
= maSysData
.pView
;
66 [pView removeFromSuperview
];
71 [mpClipView removeFromSuperview
];
77 sadly there seems to be no way to impose clipping on a child view,
78 especially a QTMovieView which seems to ignore the current context
79 completely. Also there is no real way to shape a window; on Aqua a
80 similar effect to non-rectangular windows is achieved by using a
81 non-opaque window and not painting where one wants the background
84 With respect to SalObject this leaves us to having an NSClipView
85 containing the child view. Even a QTMovieView respects the boundaries of
86 that, which gives us a clip "region" consisting of one rectangle.
87 This is gives us an 80% solution only, though.
90 // -----------------------------------------------------------------------
92 void AquaSalObject::ResetClipRegion()
98 // -----------------------------------------------------------------------
100 sal_uInt16
AquaSalObject::GetClipRegionType()
102 return SAL_OBJECT_CLIP_INCLUDERECTS
;
105 // -----------------------------------------------------------------------
107 void AquaSalObject::BeginSetClipRegion( sal_uLong
)
112 // -----------------------------------------------------------------------
114 void AquaSalObject::UnionClipRegion( long nX
, long nY
, long nWidth
, long nHeight
)
120 mnClipWidth
+= mnClipX
- nX
;
123 if( nX
+ nWidth
> mnClipX
+ mnClipWidth
)
124 mnClipWidth
= nX
+ nWidth
- mnClipX
;
127 mnClipHeight
+= mnClipY
- nY
;
130 if( nY
+ nHeight
> mnClipY
+ mnClipHeight
)
131 mnClipHeight
= nY
+ nHeight
- mnClipY
;
137 mnClipWidth
= nWidth
;
138 mnClipHeight
= nHeight
;
143 // -----------------------------------------------------------------------
145 void AquaSalObject::EndSetClipRegion()
150 // -----------------------------------------------------------------------
152 void AquaSalObject::SetPosSize( long nX
, long nY
, long nWidth
, long nHeight
)
161 // -----------------------------------------------------------------------
163 void AquaSalObject::setClippedPosSize()
165 NSRect aViewRect
= { { 0, 0 }, { static_cast<CGFloat
>(mnWidth
), static_cast<CGFloat
>(mnHeight
) } };
166 if( maSysData
.pView
)
168 NSView
*pView
= maSysData
.pView
;
169 [pView setFrame
: aViewRect
];
172 NSRect aClipViewRect
= { { static_cast<CGFloat
>(mnX
), static_cast<CGFloat
>(mnY
) }, { static_cast<CGFloat
>(mnWidth
), static_cast<CGFloat
>(mnHeight
) } };
173 NSPoint aClipPt
= { 0, 0 };
176 aClipViewRect
.origin
.x
+= mnClipX
;
177 aClipViewRect
.origin
.y
+= mnClipY
;
178 aClipViewRect
.size
.width
= mnClipWidth
;
179 aClipViewRect
.size
.height
= mnClipHeight
;
182 aClipPt
.y
= mnHeight
- mnClipHeight
;
185 mpFrame
->VCLToCocoa( aClipViewRect
, false );
186 [mpClipView setFrame
: aClipViewRect
];
188 [mpClipView scrollToPoint
: aClipPt
];
191 // -----------------------------------------------------------------------
193 void AquaSalObject::Show( sal_Bool bVisible
)
196 [mpClipView setHidden
: (bVisible
? NO
: YES
)];
199 // -----------------------------------------------------------------------
201 const SystemEnvData
* AquaSalObject::GetSystemData() const
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */