1*9f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*9f62ea84SAndrew Rist * distributed with this work for additional information
6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance
9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at
10*9f62ea84SAndrew Rist *
11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*9f62ea84SAndrew Rist *
13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an
15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the
17*9f62ea84SAndrew Rist * specific language governing permissions and limitations
18*9f62ea84SAndrew Rist * under the License.
19*9f62ea84SAndrew Rist *
20*9f62ea84SAndrew Rist *************************************************************/
21*9f62ea84SAndrew Rist
22*9f62ea84SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "vcl/outdev.hxx"
28cdf0e10cSrcweir #include "vcl/window.hxx"
29cdf0e10cSrcweir #include "vcl/salnativewidgets.hxx"
30cdf0e10cSrcweir #include "vcl/pdfextoutdevdata.hxx"
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include "salgdi.hxx"
33cdf0e10cSrcweir
34cdf0e10cSrcweir // -----------------------------------------------------------------------
35cdf0e10cSrcweir
lcl_enableNativeWidget(const OutputDevice & i_rDevice)36cdf0e10cSrcweir static bool lcl_enableNativeWidget( const OutputDevice& i_rDevice )
37cdf0e10cSrcweir {
38cdf0e10cSrcweir const OutDevType eType( i_rDevice.GetOutDevType() );
39cdf0e10cSrcweir switch ( eType )
40cdf0e10cSrcweir {
41cdf0e10cSrcweir
42cdf0e10cSrcweir case OUTDEV_WINDOW:
43cdf0e10cSrcweir return dynamic_cast< const Window* >( &i_rDevice )->IsNativeWidgetEnabled();
44cdf0e10cSrcweir
45cdf0e10cSrcweir case OUTDEV_VIRDEV:
46cdf0e10cSrcweir {
47cdf0e10cSrcweir const ::vcl::ExtOutDevData* pOutDevData( i_rDevice.GetExtOutDevData() );
48cdf0e10cSrcweir const ::vcl::PDFExtOutDevData* pPDFData( dynamic_cast< const ::vcl::PDFExtOutDevData* >( pOutDevData ) );
49cdf0e10cSrcweir if ( pPDFData != NULL )
50cdf0e10cSrcweir return false;
51cdf0e10cSrcweir return true;
52cdf0e10cSrcweir }
53cdf0e10cSrcweir
54cdf0e10cSrcweir default:
55cdf0e10cSrcweir return false;
56cdf0e10cSrcweir }
57cdf0e10cSrcweir }
58cdf0e10cSrcweir
~ImplControlValue()59cdf0e10cSrcweir ImplControlValue::~ImplControlValue()
60cdf0e10cSrcweir {
61cdf0e10cSrcweir }
62cdf0e10cSrcweir
~ScrollbarValue()63cdf0e10cSrcweir ScrollbarValue::~ScrollbarValue()
64cdf0e10cSrcweir {
65cdf0e10cSrcweir }
66cdf0e10cSrcweir
~SliderValue()67cdf0e10cSrcweir SliderValue::~SliderValue()
68cdf0e10cSrcweir {
69cdf0e10cSrcweir }
70cdf0e10cSrcweir
~TabitemValue()71cdf0e10cSrcweir TabitemValue::~TabitemValue()
72cdf0e10cSrcweir {
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
~SpinbuttonValue()75cdf0e10cSrcweir SpinbuttonValue::~SpinbuttonValue()
76cdf0e10cSrcweir {
77cdf0e10cSrcweir }
78cdf0e10cSrcweir
~ToolbarValue()79cdf0e10cSrcweir ToolbarValue::~ToolbarValue()
80cdf0e10cSrcweir {
81cdf0e10cSrcweir }
82cdf0e10cSrcweir
~MenubarValue()83cdf0e10cSrcweir MenubarValue::~MenubarValue()
84cdf0e10cSrcweir {
85cdf0e10cSrcweir }
86cdf0e10cSrcweir
~MenupopupValue()87cdf0e10cSrcweir MenupopupValue::~MenupopupValue()
88cdf0e10cSrcweir {
89cdf0e10cSrcweir }
90cdf0e10cSrcweir
~PushButtonValue()91cdf0e10cSrcweir PushButtonValue::~PushButtonValue()
92cdf0e10cSrcweir {
93cdf0e10cSrcweir }
94cdf0e10cSrcweir
95cdf0e10cSrcweir // -----------------------------------------------------------------------
96cdf0e10cSrcweir // These functions are mainly passthrough functions that allow access to
97cdf0e10cSrcweir // the SalFrame behind a Window object for native widget rendering purposes.
98cdf0e10cSrcweir // -----------------------------------------------------------------------
99cdf0e10cSrcweir
100cdf0e10cSrcweir // -----------------------------------------------------------------------
101cdf0e10cSrcweir
IsNativeControlSupported(ControlType nType,ControlPart nPart)102cdf0e10cSrcweir sal_Bool OutputDevice::IsNativeControlSupported( ControlType nType, ControlPart nPart )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir if( !lcl_enableNativeWidget( *this ) )
105cdf0e10cSrcweir return sal_False;
106cdf0e10cSrcweir
107cdf0e10cSrcweir if ( !mpGraphics )
108cdf0e10cSrcweir if ( !ImplGetGraphics() )
109cdf0e10cSrcweir return sal_False;
110cdf0e10cSrcweir
111cdf0e10cSrcweir return( mpGraphics->IsNativeControlSupported(nType, nPart) );
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
114cdf0e10cSrcweir
115cdf0e10cSrcweir // -----------------------------------------------------------------------
116cdf0e10cSrcweir
HitTestNativeControl(ControlType nType,ControlPart nPart,const Rectangle & rControlRegion,const Point & aPos,sal_Bool & rIsInside)117cdf0e10cSrcweir sal_Bool OutputDevice::HitTestNativeControl( ControlType nType,
118cdf0e10cSrcweir ControlPart nPart,
119cdf0e10cSrcweir const Rectangle& rControlRegion,
120cdf0e10cSrcweir const Point& aPos,
121cdf0e10cSrcweir sal_Bool& rIsInside )
122cdf0e10cSrcweir {
123cdf0e10cSrcweir if( !lcl_enableNativeWidget( *this ) )
124cdf0e10cSrcweir return sal_False;
125cdf0e10cSrcweir
126cdf0e10cSrcweir if ( !mpGraphics )
127cdf0e10cSrcweir if ( !ImplGetGraphics() )
128cdf0e10cSrcweir return sal_False;
129cdf0e10cSrcweir
130cdf0e10cSrcweir Point aWinOffs( mnOutOffX, mnOutOffY );
131cdf0e10cSrcweir Rectangle screenRegion( rControlRegion );
132cdf0e10cSrcweir screenRegion.Move( aWinOffs.X(), aWinOffs.Y());
133cdf0e10cSrcweir
134cdf0e10cSrcweir return( mpGraphics->HitTestNativeControl(nType, nPart, screenRegion, Point( aPos.X() + mnOutOffX, aPos.Y() + mnOutOffY ),
135cdf0e10cSrcweir rIsInside, this ) );
136cdf0e10cSrcweir }
137cdf0e10cSrcweir
138cdf0e10cSrcweir // -----------------------------------------------------------------------
139cdf0e10cSrcweir
lcl_transformControlValue(const ImplControlValue & rVal,OutputDevice & rDev)140cdf0e10cSrcweir static boost::shared_ptr< ImplControlValue > lcl_transformControlValue( const ImplControlValue& rVal, OutputDevice& rDev )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir boost::shared_ptr< ImplControlValue > aResult;
143cdf0e10cSrcweir switch( rVal.getType() )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir case CTRL_SLIDER:
146cdf0e10cSrcweir {
147cdf0e10cSrcweir const SliderValue* pSlVal = static_cast<const SliderValue*>(&rVal);
148cdf0e10cSrcweir SliderValue* pNew = new SliderValue( *pSlVal );
149cdf0e10cSrcweir aResult.reset( pNew );
150cdf0e10cSrcweir pNew->maThumbRect = rDev.ImplLogicToDevicePixel( pSlVal->maThumbRect );
151cdf0e10cSrcweir }
152cdf0e10cSrcweir break;
153cdf0e10cSrcweir case CTRL_SCROLLBAR:
154cdf0e10cSrcweir {
155cdf0e10cSrcweir const ScrollbarValue* pScVal = static_cast<const ScrollbarValue*>(&rVal);
156cdf0e10cSrcweir ScrollbarValue* pNew = new ScrollbarValue( *pScVal );
157cdf0e10cSrcweir aResult.reset( pNew );
158cdf0e10cSrcweir pNew->maThumbRect = rDev.ImplLogicToDevicePixel( pScVal->maThumbRect );
159cdf0e10cSrcweir pNew->maButton1Rect = rDev.ImplLogicToDevicePixel( pScVal->maButton1Rect );
160cdf0e10cSrcweir pNew->maButton2Rect = rDev.ImplLogicToDevicePixel( pScVal->maButton2Rect );
161cdf0e10cSrcweir }
162cdf0e10cSrcweir break;
163cdf0e10cSrcweir case CTRL_SPINBUTTONS:
164cdf0e10cSrcweir {
165cdf0e10cSrcweir const SpinbuttonValue* pSpVal = static_cast<const SpinbuttonValue*>(&rVal);
166cdf0e10cSrcweir SpinbuttonValue* pNew = new SpinbuttonValue( *pSpVal );
167cdf0e10cSrcweir aResult.reset( pNew );
168cdf0e10cSrcweir pNew->maUpperRect = rDev.ImplLogicToDevicePixel( pSpVal->maUpperRect );
169cdf0e10cSrcweir pNew->maLowerRect = rDev.ImplLogicToDevicePixel( pSpVal->maLowerRect );
170cdf0e10cSrcweir }
171cdf0e10cSrcweir break;
172cdf0e10cSrcweir case CTRL_TOOLBAR:
173cdf0e10cSrcweir {
174cdf0e10cSrcweir const ToolbarValue* pTVal = static_cast<const ToolbarValue*>(&rVal);
175cdf0e10cSrcweir ToolbarValue* pNew = new ToolbarValue( *pTVal );
176cdf0e10cSrcweir aResult.reset( pNew );
177cdf0e10cSrcweir pNew->maGripRect = rDev.ImplLogicToDevicePixel( pTVal->maGripRect );
178cdf0e10cSrcweir }
179cdf0e10cSrcweir break;
180cdf0e10cSrcweir case CTRL_TAB_ITEM:
181cdf0e10cSrcweir {
182cdf0e10cSrcweir const TabitemValue* pTIVal = static_cast<const TabitemValue*>(&rVal);
183cdf0e10cSrcweir TabitemValue* pNew = new TabitemValue( *pTIVal );
184cdf0e10cSrcweir aResult.reset( pNew );
185cdf0e10cSrcweir }
186cdf0e10cSrcweir break;
187cdf0e10cSrcweir case CTRL_MENUBAR:
188cdf0e10cSrcweir {
189cdf0e10cSrcweir const MenubarValue* pMVal = static_cast<const MenubarValue*>(&rVal);
190cdf0e10cSrcweir MenubarValue* pNew = new MenubarValue( *pMVal );
191cdf0e10cSrcweir aResult.reset( pNew );
192cdf0e10cSrcweir }
193cdf0e10cSrcweir break;
194cdf0e10cSrcweir case CTRL_PUSHBUTTON:
195cdf0e10cSrcweir {
196cdf0e10cSrcweir const PushButtonValue* pBVal = static_cast<const PushButtonValue*>(&rVal);
197cdf0e10cSrcweir PushButtonValue* pNew = new PushButtonValue( *pBVal );
198cdf0e10cSrcweir aResult.reset( pNew );
199cdf0e10cSrcweir }
200cdf0e10cSrcweir break;
201cdf0e10cSrcweir case CTRL_GENERIC:
202cdf0e10cSrcweir aResult.reset( new ImplControlValue( rVal ) );
203cdf0e10cSrcweir break;
204cdf0e10cSrcweir case CTRL_MENU_POPUP:
205cdf0e10cSrcweir {
206cdf0e10cSrcweir const MenupopupValue* pMVal = static_cast<const MenupopupValue*>(&rVal);
207cdf0e10cSrcweir MenupopupValue* pNew = new MenupopupValue( *pMVal );
208cdf0e10cSrcweir pNew->maItemRect = rDev.ImplLogicToDevicePixel( pMVal->maItemRect );
209cdf0e10cSrcweir aResult.reset( pNew );
210cdf0e10cSrcweir }
211cdf0e10cSrcweir break;
212cdf0e10cSrcweir default:
213cdf0e10cSrcweir OSL_ENSURE( 0, "unknown ImplControlValue type !" );
214cdf0e10cSrcweir break;
215cdf0e10cSrcweir }
216cdf0e10cSrcweir return aResult;
217cdf0e10cSrcweir }
218cdf0e10cSrcweir
DrawNativeControl(ControlType nType,ControlPart nPart,const Rectangle & rControlRegion,ControlState nState,const ImplControlValue & aValue,::rtl::OUString aCaption)219cdf0e10cSrcweir sal_Bool OutputDevice::DrawNativeControl( ControlType nType,
220cdf0e10cSrcweir ControlPart nPart,
221cdf0e10cSrcweir const Rectangle& rControlRegion,
222cdf0e10cSrcweir ControlState nState,
223cdf0e10cSrcweir const ImplControlValue& aValue,
224cdf0e10cSrcweir ::rtl::OUString aCaption )
225cdf0e10cSrcweir {
226cdf0e10cSrcweir if( !lcl_enableNativeWidget( *this ) )
227cdf0e10cSrcweir return sal_False;
228cdf0e10cSrcweir
229cdf0e10cSrcweir // make sure the current clip region is initialized correctly
230cdf0e10cSrcweir if ( !mpGraphics )
231cdf0e10cSrcweir if ( !ImplGetGraphics() )
232cdf0e10cSrcweir return sal_False;
233cdf0e10cSrcweir
234cdf0e10cSrcweir if ( mbInitClipRegion )
235cdf0e10cSrcweir ImplInitClipRegion();
236cdf0e10cSrcweir if ( mbOutputClipped )
237cdf0e10cSrcweir return sal_True;
238cdf0e10cSrcweir
239cdf0e10cSrcweir if ( mbInitLineColor )
240cdf0e10cSrcweir ImplInitLineColor();
241cdf0e10cSrcweir if ( mbInitFillColor )
242cdf0e10cSrcweir ImplInitFillColor();
243cdf0e10cSrcweir
244cdf0e10cSrcweir // Convert the coordinates from relative to Window-absolute, so we draw
245cdf0e10cSrcweir // in the correct place in platform code
246cdf0e10cSrcweir boost::shared_ptr< ImplControlValue > aScreenCtrlValue( lcl_transformControlValue( aValue, *this ) );
247cdf0e10cSrcweir Rectangle screenRegion( ImplLogicToDevicePixel( rControlRegion ) );
248cdf0e10cSrcweir
249cdf0e10cSrcweir Region aTestRegion( GetActiveClipRegion() );
250cdf0e10cSrcweir aTestRegion.Intersect( rControlRegion );
251cdf0e10cSrcweir if( aTestRegion == rControlRegion )
252cdf0e10cSrcweir nState |= CTRL_CACHING_ALLOWED; // control is not clipped, caching allowed
253cdf0e10cSrcweir
254cdf0e10cSrcweir sal_Bool bRet = mpGraphics->DrawNativeControl(nType, nPart, screenRegion, nState, *aScreenCtrlValue, aCaption, this );
255cdf0e10cSrcweir
256cdf0e10cSrcweir return bRet;
257cdf0e10cSrcweir }
258cdf0e10cSrcweir
259cdf0e10cSrcweir
260cdf0e10cSrcweir // -----------------------------------------------------------------------
261cdf0e10cSrcweir
DrawNativeControlText(ControlType nType,ControlPart nPart,const Rectangle & rControlRegion,ControlState nState,const ImplControlValue & aValue,::rtl::OUString aCaption)262cdf0e10cSrcweir sal_Bool OutputDevice::DrawNativeControlText(ControlType nType,
263cdf0e10cSrcweir ControlPart nPart,
264cdf0e10cSrcweir const Rectangle& rControlRegion,
265cdf0e10cSrcweir ControlState nState,
266cdf0e10cSrcweir const ImplControlValue& aValue,
267cdf0e10cSrcweir ::rtl::OUString aCaption )
268cdf0e10cSrcweir {
269cdf0e10cSrcweir if( !lcl_enableNativeWidget( *this ) )
270cdf0e10cSrcweir return sal_False;
271cdf0e10cSrcweir
272cdf0e10cSrcweir // make sure the current clip region is initialized correctly
273cdf0e10cSrcweir if ( !mpGraphics )
274cdf0e10cSrcweir if ( !ImplGetGraphics() )
275cdf0e10cSrcweir return false;
276cdf0e10cSrcweir
277cdf0e10cSrcweir if ( mbInitClipRegion )
278cdf0e10cSrcweir ImplInitClipRegion();
279cdf0e10cSrcweir if ( mbOutputClipped )
280cdf0e10cSrcweir return true;
281cdf0e10cSrcweir
282cdf0e10cSrcweir if ( mbInitLineColor )
283cdf0e10cSrcweir ImplInitLineColor();
284cdf0e10cSrcweir if ( mbInitFillColor )
285cdf0e10cSrcweir ImplInitFillColor();
286cdf0e10cSrcweir
287cdf0e10cSrcweir // Convert the coordinates from relative to Window-absolute, so we draw
288cdf0e10cSrcweir // in the correct place in platform code
289cdf0e10cSrcweir boost::shared_ptr< ImplControlValue > aScreenCtrlValue( lcl_transformControlValue( aValue, *this ) );
290cdf0e10cSrcweir Rectangle screenRegion( ImplLogicToDevicePixel( rControlRegion ) );
291cdf0e10cSrcweir
292cdf0e10cSrcweir sal_Bool bRet = mpGraphics->DrawNativeControlText(nType, nPart, screenRegion, nState, *aScreenCtrlValue, aCaption, this );
293cdf0e10cSrcweir
294cdf0e10cSrcweir return bRet;
295cdf0e10cSrcweir }
296cdf0e10cSrcweir
297cdf0e10cSrcweir
298cdf0e10cSrcweir // -----------------------------------------------------------------------
299cdf0e10cSrcweir
GetNativeControlRegion(ControlType nType,ControlPart nPart,const Rectangle & rControlRegion,ControlState nState,const ImplControlValue & aValue,::rtl::OUString aCaption,Rectangle & rNativeBoundingRegion,Rectangle & rNativeContentRegion)300cdf0e10cSrcweir sal_Bool OutputDevice::GetNativeControlRegion( ControlType nType,
301cdf0e10cSrcweir ControlPart nPart,
302cdf0e10cSrcweir const Rectangle& rControlRegion,
303cdf0e10cSrcweir ControlState nState,
304cdf0e10cSrcweir const ImplControlValue& aValue,
305cdf0e10cSrcweir ::rtl::OUString aCaption,
306cdf0e10cSrcweir Rectangle &rNativeBoundingRegion,
307cdf0e10cSrcweir Rectangle &rNativeContentRegion )
308cdf0e10cSrcweir {
309cdf0e10cSrcweir if( !lcl_enableNativeWidget( *this ) )
310cdf0e10cSrcweir return sal_False;
311cdf0e10cSrcweir
312cdf0e10cSrcweir if ( !mpGraphics )
313cdf0e10cSrcweir if ( !ImplGetGraphics() )
314cdf0e10cSrcweir return sal_False;
315cdf0e10cSrcweir
316cdf0e10cSrcweir // Convert the coordinates from relative to Window-absolute, so we draw
317cdf0e10cSrcweir // in the correct place in platform code
318cdf0e10cSrcweir boost::shared_ptr< ImplControlValue > aScreenCtrlValue( lcl_transformControlValue( aValue, *this ) );
319cdf0e10cSrcweir Rectangle screenRegion( ImplLogicToDevicePixel( rControlRegion ) );
320cdf0e10cSrcweir
321cdf0e10cSrcweir sal_Bool bRet = mpGraphics->GetNativeControlRegion(nType, nPart, screenRegion, nState, *aScreenCtrlValue,
322cdf0e10cSrcweir aCaption, rNativeBoundingRegion,
323cdf0e10cSrcweir rNativeContentRegion, this );
324cdf0e10cSrcweir if( bRet )
325cdf0e10cSrcweir {
326cdf0e10cSrcweir // transform back native regions
327cdf0e10cSrcweir rNativeBoundingRegion = ImplDevicePixelToLogic( rNativeBoundingRegion );
328cdf0e10cSrcweir rNativeContentRegion = ImplDevicePixelToLogic( rNativeContentRegion );
329cdf0e10cSrcweir }
330cdf0e10cSrcweir
331cdf0e10cSrcweir return bRet;
332cdf0e10cSrcweir }
333cdf0e10cSrcweir
334cdf0e10cSrcweir
335