xref: /aoo41x/main/svx/source/dialog/dlgctrl.cxx (revision 33b19716)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f6e50924SAndrew Rist  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f6e50924SAndrew Rist  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19f6e50924SAndrew Rist  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // include ---------------------------------------------------------------
28cdf0e10cSrcweir #include <tools/shl.hxx>
29cdf0e10cSrcweir #include <vcl/svapp.hxx>
30cdf0e10cSrcweir #include <svx/xtable.hxx>
31cdf0e10cSrcweir #include <svx/xpool.hxx>
32cdf0e10cSrcweir #include <svx/dialogs.hrc>
3370d3707aSArmin Le Grand #include <accessibility.hrc>
34cdf0e10cSrcweir #include <svx/dlgctrl.hxx>
35cdf0e10cSrcweir #include <svx/dialmgr.hxx>
36cdf0e10cSrcweir #include <tools/poly.hxx>
37cdf0e10cSrcweir #include <vcl/region.hxx>
38cdf0e10cSrcweir #include <vcl/gradient.hxx>
39cdf0e10cSrcweir #include <vcl/hatch.hxx>
40cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
4170d3707aSArmin Le Grand #include <svxrectctaccessiblecontext.hxx>
42cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
43cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx>
44cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
45cdf0e10cSrcweir #include <svx/svdorect.hxx>
46cdf0e10cSrcweir #include <svx/svdmodel.hxx>
47cdf0e10cSrcweir #include <svx/svdopath.hxx>
48cdf0e10cSrcweir #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
49cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx>
5070d3707aSArmin Le Grand #include <vcl/bmpacc.hxx>
5170d3707aSArmin Le Grand #include <svx/xbtmpit.hxx>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir #define OUTPUT_DRAWMODE_COLOR		(DRAWMODE_DEFAULT)
54cdf0e10cSrcweir #define OUTPUT_DRAWMODE_CONTRAST	(DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT)
55cdf0e10cSrcweir 
56cdf0e10cSrcweir using namespace ::com::sun::star::uno;
57cdf0e10cSrcweir using namespace ::com::sun::star::lang;
58cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 
61cdf0e10cSrcweir /*************************************************************************
62cdf0e10cSrcweir |*
63cdf0e10cSrcweir |*	Control zur Darstellung und Auswahl der Eckpunkte (und Mittelpunkt)
64cdf0e10cSrcweir |*	eines Objekts
65cdf0e10cSrcweir |*
66cdf0e10cSrcweir \************************************************************************/
67cdf0e10cSrcweir 
68cdf0e10cSrcweir Bitmap& SvxRectCtl::GetRectBitmap( void )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir 	if( !pBitmap )
71cdf0e10cSrcweir 		InitRectBitmap();
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	return *pBitmap;
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
76cdf0e10cSrcweir SvxRectCtl::SvxRectCtl( Window* pParent, const ResId& rResId, RECT_POINT eRpt,
77cdf0e10cSrcweir 						sal_uInt16 nBorder, sal_uInt16 nCircle, CTL_STYLE eStyle ) :
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	Control( pParent, rResId ),
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	pAccContext	( NULL ),
82cdf0e10cSrcweir     nBorderWidth( nBorder ),
83cdf0e10cSrcweir     nRadius     ( nCircle),
84cdf0e10cSrcweir     eDefRP      ( eRpt ),
85cdf0e10cSrcweir     eCS         ( eStyle ),
86cdf0e10cSrcweir 	pBitmap		( NULL ),
87cdf0e10cSrcweir     m_nState    ( 0 ),
88cdf0e10cSrcweir     mbCompleteDisable(sal_False)
89cdf0e10cSrcweir {
90cdf0e10cSrcweir 	SetMapMode( MAP_100TH_MM );
91cdf0e10cSrcweir     Resize_Impl();
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir // -----------------------------------------------------------------------
95cdf0e10cSrcweir 
96cdf0e10cSrcweir SvxRectCtl::~SvxRectCtl()
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	delete pBitmap;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	if( pAccContext )
101cdf0e10cSrcweir 		pAccContext->release();
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir // -----------------------------------------------------------------------
105cdf0e10cSrcweir void SvxRectCtl::Resize()
106cdf0e10cSrcweir {
107cdf0e10cSrcweir     Resize_Impl();
108cdf0e10cSrcweir     Control::Resize();
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir // -----------------------------------------------------------------------
112cdf0e10cSrcweir 
113cdf0e10cSrcweir void SvxRectCtl::Resize_Impl()
114cdf0e10cSrcweir {
115cdf0e10cSrcweir     aSize = GetOutputSize();
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	switch( eCS )
118cdf0e10cSrcweir 	{
119cdf0e10cSrcweir 		case CS_RECT:
120cdf0e10cSrcweir 		case CS_ANGLE:
121cdf0e10cSrcweir 		case CS_SHADOW:
122cdf0e10cSrcweir 			aPtLT = Point( 0 + nBorderWidth,  0 + nBorderWidth );
123cdf0e10cSrcweir 			aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
124cdf0e10cSrcweir 			aPtRT = Point( aSize.Width() - nBorderWidth, 0 + nBorderWidth );
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 			aPtLM = Point( 0 + nBorderWidth,  aSize.Height() / 2 );
127cdf0e10cSrcweir 			aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
128cdf0e10cSrcweir 			aPtRM = Point( aSize.Width() - nBorderWidth, aSize.Height() / 2 );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 			aPtLB = Point( 0 + nBorderWidth,	aSize.Height() - nBorderWidth );
131cdf0e10cSrcweir 			aPtMB = Point( aSize.Width() / 2,	aSize.Height() - nBorderWidth );
132cdf0e10cSrcweir 			aPtRB = Point( aSize.Width() - nBorderWidth, aSize.Height() - nBorderWidth );
133cdf0e10cSrcweir 		break;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 		case CS_LINE:
136cdf0e10cSrcweir 			aPtLT = Point( 0 + 3 * nBorderWidth,  0 + nBorderWidth );
137cdf0e10cSrcweir 			aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
138cdf0e10cSrcweir 			aPtRT = Point( aSize.Width() - 3 * nBorderWidth, 0 + nBorderWidth );
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 			aPtLM = Point( 0 + 3 * nBorderWidth,  aSize.Height() / 2 );
141cdf0e10cSrcweir 			aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
142cdf0e10cSrcweir 			aPtRM = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() / 2 );
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 			aPtLB = Point( 0 + 3 * nBorderWidth,	aSize.Height() - nBorderWidth );
145cdf0e10cSrcweir 			aPtMB = Point( aSize.Width() / 2,	aSize.Height() - nBorderWidth );
146cdf0e10cSrcweir 			aPtRB = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() - nBorderWidth );
147cdf0e10cSrcweir 		break;
148cdf0e10cSrcweir 	}
149cdf0e10cSrcweir 	Reset();
150cdf0e10cSrcweir 	InitSettings( sal_True, sal_True );
151cdf0e10cSrcweir }
152cdf0e10cSrcweir // -----------------------------------------------------------------------
153cdf0e10cSrcweir 
154cdf0e10cSrcweir void SvxRectCtl::InitRectBitmap( void )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir 	if( pBitmap )
157cdf0e10cSrcweir 		delete pBitmap;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 	const StyleSettings&	rStyles = Application::GetSettings().GetStyleSettings();
160cdf0e10cSrcweir 	svtools::ColorConfig aColorConfig;
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	pBitmap = new Bitmap( SVX_RES( RID_SVXCTRL_RECTBTNS ) );
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 	// set bitmap-colors
165cdf0e10cSrcweir 	Color	aColorAry1[7];
166cdf0e10cSrcweir 	Color	aColorAry2[7];
167cdf0e10cSrcweir 	aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 );	// light-gray
168cdf0e10cSrcweir 	aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 );	// yellow
169cdf0e10cSrcweir 	aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF );	// white
170cdf0e10cSrcweir 	aColorAry1[3] = Color( 0x80, 0x80, 0x80 );	// dark-gray
171cdf0e10cSrcweir 	aColorAry1[4] = Color( 0x00, 0x00, 0x00 );  // black
172cdf0e10cSrcweir 	aColorAry1[5] = Color( 0x00, 0xFF, 0x00 );	// green
173cdf0e10cSrcweir 	aColorAry1[6] = Color( 0x00, 0x00, 0xFF );	// blue
174cdf0e10cSrcweir 	aColorAry2[0] = rStyles.GetDialogColor();		// background
175cdf0e10cSrcweir 	aColorAry2[1] = rStyles.GetWindowColor();
176cdf0e10cSrcweir 	aColorAry2[2] = rStyles.GetLightColor();
177cdf0e10cSrcweir 	aColorAry2[3] = rStyles.GetShadowColor();
178cdf0e10cSrcweir 	aColorAry2[4] = rStyles.GetDarkShadowColor();
179cdf0e10cSrcweir 	aColorAry2[5] = Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
180cdf0e10cSrcweir 	aColorAry2[6] = rStyles.GetDialogColor();
181cdf0e10cSrcweir 
182cdf0e10cSrcweir #ifdef DBG_UTIL
183cdf0e10cSrcweir 	static sal_Bool		bModify = sal_False;
184cdf0e10cSrcweir 	sal_Bool&			rModify = bModify;
185cdf0e10cSrcweir 	if( rModify )
186cdf0e10cSrcweir 	{
187cdf0e10cSrcweir 		static int		n = 0;
188cdf0e10cSrcweir 		static sal_uInt8	r = 0xFF;
189cdf0e10cSrcweir 		static sal_uInt8	g = 0x00;
190cdf0e10cSrcweir 		static sal_uInt8	b = 0xFF;
191cdf0e10cSrcweir 		int&			rn = n;
192cdf0e10cSrcweir 		sal_uInt8&			rr = r;
193cdf0e10cSrcweir 		sal_uInt8&			rg = g;
194cdf0e10cSrcweir 		sal_uInt8&			rb = b;
195cdf0e10cSrcweir 		aColorAry2[ rn ] = Color( rr, rg, rb );
196cdf0e10cSrcweir 	}
197cdf0e10cSrcweir #endif
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 	pBitmap->Replace( aColorAry1, aColorAry2, 7, NULL );
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
202cdf0e10cSrcweir // -----------------------------------------------------------------------
203cdf0e10cSrcweir 
204cdf0e10cSrcweir void SvxRectCtl::InitSettings( sal_Bool bForeground, sal_Bool bBackground )
205cdf0e10cSrcweir {
206cdf0e10cSrcweir 	const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 	if( bForeground )
209cdf0e10cSrcweir 	{
210cdf0e10cSrcweir 		svtools::ColorConfig aColorConfig;
211cdf0e10cSrcweir 		Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 		if ( IsControlForeground() )
214cdf0e10cSrcweir 			aTextColor = GetControlForeground();
215cdf0e10cSrcweir 		SetTextColor( aTextColor );
216cdf0e10cSrcweir 	}
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 	if( bBackground )
219cdf0e10cSrcweir 	{
220cdf0e10cSrcweir 		if ( IsControlBackground() )
221cdf0e10cSrcweir 			SetBackground( GetControlBackground() );
222cdf0e10cSrcweir 		else
223cdf0e10cSrcweir 			SetBackground( rStyleSettings.GetWindowColor() );
224cdf0e10cSrcweir 	}
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 	delete pBitmap;
227cdf0e10cSrcweir 	pBitmap = NULL;		// forces new creating of bitmap
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 	Invalidate();
230cdf0e10cSrcweir }
231cdf0e10cSrcweir 
232cdf0e10cSrcweir /*************************************************************************
233cdf0e10cSrcweir |*
234cdf0e10cSrcweir |*	Das angeklickte Rechteck (3 x 3) wird ermittelt und der Parent (Dialog)
235cdf0e10cSrcweir |*	wird benachrichtigt, dass der Punkt geaendert wurde
236cdf0e10cSrcweir |*
237cdf0e10cSrcweir \************************************************************************/
238cdf0e10cSrcweir 
239cdf0e10cSrcweir void SvxRectCtl::MouseButtonDown( const MouseEvent& rMEvt )
240cdf0e10cSrcweir {
241cdf0e10cSrcweir 	// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
242cdf0e10cSrcweir 	if(!IsCompletelyDisabled())
243cdf0e10cSrcweir 	{
244cdf0e10cSrcweir 		Point aPtLast = aPtNew;
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 		aPtNew = GetApproxLogPtFromPixPt( rMEvt.GetPosPixel() );
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 		if( aPtNew == aPtMM && ( eCS == CS_SHADOW || eCS == CS_ANGLE ) )
249cdf0e10cSrcweir 		{
250cdf0e10cSrcweir 			aPtNew = aPtLast;
251cdf0e10cSrcweir 		}
252cdf0e10cSrcweir 		else
253cdf0e10cSrcweir 		{
254cdf0e10cSrcweir 			Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ),
255cdf0e10cSrcweir 								   aPtLast + Point( nRadius, nRadius ) ) );
256cdf0e10cSrcweir 			Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ),
257cdf0e10cSrcweir 								   aPtNew + Point( nRadius, nRadius ) ) );
258cdf0e10cSrcweir 			eRP = GetRPFromPoint( aPtNew );
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 			SetActualRP( eRP );
261cdf0e10cSrcweir 
262cdf0e10cSrcweir 			if( WINDOW_TABPAGE == GetParent()->GetType() )
263cdf0e10cSrcweir 				( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
264cdf0e10cSrcweir 		}
265cdf0e10cSrcweir 	}
266cdf0e10cSrcweir }
267cdf0e10cSrcweir 
268cdf0e10cSrcweir // -----------------------------------------------------------------------
269cdf0e10cSrcweir 
270cdf0e10cSrcweir void SvxRectCtl::KeyInput( const KeyEvent& rKeyEvt )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir 	// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
273cdf0e10cSrcweir 	if(!IsCompletelyDisabled())
274cdf0e10cSrcweir 	{
275cdf0e10cSrcweir 		RECT_POINT eNewRP = eRP;
276cdf0e10cSrcweir 		sal_Bool bUseMM = (eCS != CS_SHADOW) && (eCS != CS_ANGLE);
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 		switch( rKeyEvt.GetKeyCode().GetCode() )
279cdf0e10cSrcweir 		{
280cdf0e10cSrcweir 			case KEY_DOWN:
281cdf0e10cSrcweir 			{
282cdf0e10cSrcweir 				if( !(m_nState & CS_NOVERT) )
283cdf0e10cSrcweir 					switch( eNewRP )
284cdf0e10cSrcweir 					{
285cdf0e10cSrcweir 						case RP_LT: eNewRP = RP_LM; break;
286cdf0e10cSrcweir 						case RP_MT: eNewRP = bUseMM ? RP_MM : RP_MB; break;
287cdf0e10cSrcweir 						case RP_RT: eNewRP = RP_RM; break;
288cdf0e10cSrcweir 						case RP_LM: eNewRP = RP_LB; break;
289cdf0e10cSrcweir 						case RP_MM: eNewRP = RP_MB; break;
290cdf0e10cSrcweir 						case RP_RM: eNewRP = RP_RB; break;
291cdf0e10cSrcweir                         default: ; //prevent warning
292cdf0e10cSrcweir                     }
293cdf0e10cSrcweir 			}
294cdf0e10cSrcweir 			break;
295cdf0e10cSrcweir 			case KEY_UP:
296cdf0e10cSrcweir 			{
297cdf0e10cSrcweir 				if( !(m_nState & CS_NOVERT) )
298cdf0e10cSrcweir 					switch( eNewRP )
299cdf0e10cSrcweir 					{
300cdf0e10cSrcweir 						case RP_LM: eNewRP = RP_LT; break;
301cdf0e10cSrcweir 						case RP_MM: eNewRP = RP_MT; break;
302cdf0e10cSrcweir 						case RP_RM: eNewRP = RP_RT; break;
303cdf0e10cSrcweir 						case RP_LB: eNewRP = RP_LM; break;
304cdf0e10cSrcweir 						case RP_MB: eNewRP = bUseMM ? RP_MM : RP_MT; break;
305cdf0e10cSrcweir 						case RP_RB: eNewRP = RP_RM; break;
306cdf0e10cSrcweir                         default: ; //prevent warning
307cdf0e10cSrcweir                     }
308cdf0e10cSrcweir 			}
309cdf0e10cSrcweir 			break;
310cdf0e10cSrcweir 			case KEY_LEFT:
311cdf0e10cSrcweir 			{
312cdf0e10cSrcweir 				if( !(m_nState & CS_NOHORZ) )
313cdf0e10cSrcweir 					switch( eNewRP )
314cdf0e10cSrcweir 					{
315cdf0e10cSrcweir 						case RP_MT: eNewRP = RP_LT; break;
316cdf0e10cSrcweir 						case RP_RT: eNewRP = RP_MT; break;
317cdf0e10cSrcweir 						case RP_MM: eNewRP = RP_LM; break;
318cdf0e10cSrcweir 						case RP_RM: eNewRP = bUseMM ? RP_MM : RP_LM; break;
319cdf0e10cSrcweir 						case RP_MB: eNewRP = RP_LB; break;
320cdf0e10cSrcweir 						case RP_RB: eNewRP = RP_MB; break;
321cdf0e10cSrcweir                         default: ; //prevent warning
322cdf0e10cSrcweir                     }
323cdf0e10cSrcweir 			}
324cdf0e10cSrcweir 			break;
325cdf0e10cSrcweir 			case KEY_RIGHT:
326cdf0e10cSrcweir 			{
327cdf0e10cSrcweir 				if( !(m_nState & CS_NOHORZ) )
328cdf0e10cSrcweir 					switch( eNewRP )
329cdf0e10cSrcweir 					{
330cdf0e10cSrcweir 						case RP_LT: eNewRP = RP_MT; break;
331cdf0e10cSrcweir 						case RP_MT: eNewRP = RP_RT; break;
332cdf0e10cSrcweir 						case RP_LM: eNewRP = bUseMM ? RP_MM : RP_RM; break;
333cdf0e10cSrcweir 						case RP_MM: eNewRP = RP_RM; break;
334cdf0e10cSrcweir 						case RP_LB: eNewRP = RP_MB; break;
335cdf0e10cSrcweir 						case RP_MB: eNewRP = RP_RB; break;
336cdf0e10cSrcweir                         default: ; //prevent warning
337cdf0e10cSrcweir                     }
338cdf0e10cSrcweir 			}
339cdf0e10cSrcweir 			break;
340cdf0e10cSrcweir 			default:
341cdf0e10cSrcweir 				Control::KeyInput( rKeyEvt );
342cdf0e10cSrcweir 				return;
343cdf0e10cSrcweir 		}
344cdf0e10cSrcweir 		if( eNewRP != eRP )
345cdf0e10cSrcweir 		{
346cdf0e10cSrcweir 			SetActualRP( eNewRP );
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 			if( WINDOW_TABPAGE == GetParent()->GetType() )
349cdf0e10cSrcweir 				( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
350cdf0e10cSrcweir 
351cdf0e10cSrcweir 			SetFocusRect();
352cdf0e10cSrcweir 		}
353cdf0e10cSrcweir 	}
354cdf0e10cSrcweir }
355cdf0e10cSrcweir 
356cdf0e10cSrcweir // -----------------------------------------------------------------------
357cdf0e10cSrcweir 
358cdf0e10cSrcweir void SvxRectCtl::StateChanged( StateChangedType nType )
359cdf0e10cSrcweir {
360cdf0e10cSrcweir 	if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
361cdf0e10cSrcweir 		InitSettings( sal_True, sal_False );
362cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
363cdf0e10cSrcweir 		InitSettings( sal_False, sal_True );
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 	Window::StateChanged( nType );
366cdf0e10cSrcweir }
367cdf0e10cSrcweir 
368cdf0e10cSrcweir // -----------------------------------------------------------------------
369cdf0e10cSrcweir 
370cdf0e10cSrcweir void SvxRectCtl::DataChanged( const DataChangedEvent& rDCEvt )
371cdf0e10cSrcweir {
372cdf0e10cSrcweir 	if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
373cdf0e10cSrcweir 		InitSettings( sal_True, sal_True );
374cdf0e10cSrcweir 	else
375cdf0e10cSrcweir 		Window::DataChanged( rDCEvt );
376cdf0e10cSrcweir }
377cdf0e10cSrcweir 
378cdf0e10cSrcweir /*************************************************************************
379cdf0e10cSrcweir |*
380cdf0e10cSrcweir |*	Zeichnet das Control (Rechteck mit 9 Kreisen)
381cdf0e10cSrcweir |*
382cdf0e10cSrcweir \************************************************************************/
383cdf0e10cSrcweir 
384cdf0e10cSrcweir void SvxRectCtl::Paint( const Rectangle& )
385cdf0e10cSrcweir {
386cdf0e10cSrcweir 	Point	aPtDiff( PixelToLogic( Point( 1, 1 ) ) );
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 	const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 	SetLineColor( rStyles.GetDialogColor() );
391cdf0e10cSrcweir 	SetFillColor( rStyles.GetDialogColor() );
392cdf0e10cSrcweir 	DrawRect( Rectangle( Point(0,0), GetOutputSize() ) );
393cdf0e10cSrcweir 
394cdf0e10cSrcweir 	if( IsEnabled() )
395cdf0e10cSrcweir 		SetLineColor( rStyles.GetLabelTextColor() );
396cdf0e10cSrcweir 	else
397cdf0e10cSrcweir 		SetLineColor( rStyles.GetShadowColor() );
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 	SetFillColor();
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 	switch( eCS )
402cdf0e10cSrcweir 	{
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 		case CS_RECT:
405cdf0e10cSrcweir 		case CS_SHADOW:
406cdf0e10cSrcweir 			if( !IsEnabled() )
407cdf0e10cSrcweir 			{
408cdf0e10cSrcweir 				Color aOldCol = GetLineColor();
409cdf0e10cSrcweir 				SetLineColor( rStyles.GetLightColor() );
410cdf0e10cSrcweir 				DrawRect( Rectangle( aPtLT + aPtDiff, aPtRB + aPtDiff ) );
411cdf0e10cSrcweir 				SetLineColor( aOldCol );
412cdf0e10cSrcweir 			}
413cdf0e10cSrcweir 			DrawRect( Rectangle( aPtLT, aPtRB ) );
414cdf0e10cSrcweir 		break;
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 		case CS_LINE:
417cdf0e10cSrcweir 			if( !IsEnabled() )
418cdf0e10cSrcweir 			{
419cdf0e10cSrcweir 				Color aOldCol = GetLineColor();
420cdf0e10cSrcweir 				SetLineColor( rStyles.GetLightColor() );
421cdf0e10cSrcweir 				DrawLine( aPtLM - Point( 2 * nBorderWidth, 0) + aPtDiff,
422cdf0e10cSrcweir 						  aPtRM + Point( 2 * nBorderWidth, 0 ) + aPtDiff );
423cdf0e10cSrcweir 				SetLineColor( aOldCol );
424cdf0e10cSrcweir 			}
425cdf0e10cSrcweir 			DrawLine( aPtLM - Point( 2 * nBorderWidth, 0),
426cdf0e10cSrcweir 					  aPtRM + Point( 2 * nBorderWidth, 0 ) );
427cdf0e10cSrcweir 		break;
428cdf0e10cSrcweir 
429cdf0e10cSrcweir 		case CS_ANGLE:
430cdf0e10cSrcweir 			if( !IsEnabled() )
431cdf0e10cSrcweir 			{
432cdf0e10cSrcweir 				Color aOldCol = GetLineColor();
433cdf0e10cSrcweir 				SetLineColor( rStyles.GetLightColor() );
434cdf0e10cSrcweir 				DrawLine( aPtLT + aPtDiff, aPtRB + aPtDiff );
435cdf0e10cSrcweir 				DrawLine( aPtLB + aPtDiff, aPtRT + aPtDiff );
436cdf0e10cSrcweir 				DrawLine( aPtLM + aPtDiff, aPtRM + aPtDiff );
437cdf0e10cSrcweir 				DrawLine( aPtMT + aPtDiff, aPtMB + aPtDiff );
438cdf0e10cSrcweir 				SetLineColor( aOldCol );
439cdf0e10cSrcweir 			}
440cdf0e10cSrcweir 			DrawLine( aPtLT, aPtRB );
441cdf0e10cSrcweir 			DrawLine( aPtLB, aPtRT );
442cdf0e10cSrcweir 			DrawLine( aPtLM, aPtRM );
443cdf0e10cSrcweir 			DrawLine( aPtMT, aPtMB );
444cdf0e10cSrcweir 		break;
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 		default:
447cdf0e10cSrcweir 			break;
448cdf0e10cSrcweir 	}
449cdf0e10cSrcweir 	SetFillColor( GetBackground().GetColor() );
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 	Size aBtnSize( 11, 11 );
452cdf0e10cSrcweir 	Size aDstBtnSize(  PixelToLogic( aBtnSize ) );
453cdf0e10cSrcweir 	Point aToCenter( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1);
454cdf0e10cSrcweir 	Point aBtnPnt1( IsEnabled()?0:22,0 );
455cdf0e10cSrcweir 	Point aBtnPnt2( 11,0 );
456cdf0e10cSrcweir 	Point aBtnPnt3( 22,0 );
457cdf0e10cSrcweir 
458cdf0e10cSrcweir 	sal_Bool bNoHorz = (m_nState & CS_NOHORZ) != 0;
459cdf0e10cSrcweir 	sal_Bool bNoVert = (m_nState & CS_NOVERT) != 0;
460cdf0e10cSrcweir 
461cdf0e10cSrcweir 	Bitmap&			rBitmap = GetRectBitmap();
462cdf0e10cSrcweir 
463cdf0e10cSrcweir 	// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
464cdf0e10cSrcweir 	if(IsCompletelyDisabled())
465cdf0e10cSrcweir 	{
466cdf0e10cSrcweir 		DrawBitmap( aPtLT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
467cdf0e10cSrcweir 		DrawBitmap( aPtMT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
468cdf0e10cSrcweir 		DrawBitmap( aPtRT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
469cdf0e10cSrcweir 		DrawBitmap( aPtLM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
470cdf0e10cSrcweir 		if( eCS == CS_RECT || eCS == CS_LINE )
471cdf0e10cSrcweir 			DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
472cdf0e10cSrcweir 		DrawBitmap( aPtRM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
473cdf0e10cSrcweir 		DrawBitmap( aPtLB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
474cdf0e10cSrcweir 		DrawBitmap( aPtMB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
475cdf0e10cSrcweir 		DrawBitmap( aPtRB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
476cdf0e10cSrcweir 	}
477cdf0e10cSrcweir 	else
478cdf0e10cSrcweir 	{
479cdf0e10cSrcweir 		DrawBitmap( aPtLT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
480cdf0e10cSrcweir 		DrawBitmap( aPtMT - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
481cdf0e10cSrcweir 		DrawBitmap( aPtRT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 		DrawBitmap( aPtLM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 		// Mittelpunkt bei Rechteck und Linie
486cdf0e10cSrcweir 		if( eCS == CS_RECT || eCS == CS_LINE )
487cdf0e10cSrcweir 			DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt1, aBtnSize, rBitmap );
488cdf0e10cSrcweir 
489cdf0e10cSrcweir 		DrawBitmap( aPtRM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 		DrawBitmap( aPtLB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
492cdf0e10cSrcweir 		DrawBitmap( aPtMB - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
493cdf0e10cSrcweir 		DrawBitmap( aPtRB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
494cdf0e10cSrcweir 	}
495cdf0e10cSrcweir 
496cdf0e10cSrcweir 	// draw active button, avoid center pos for angle
497cdf0e10cSrcweir 	// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
498cdf0e10cSrcweir 	if(!IsCompletelyDisabled())
499cdf0e10cSrcweir 	{
500cdf0e10cSrcweir 		if( IsEnabled() && (eCS != CS_ANGLE || aPtNew != aPtMM) )
501cdf0e10cSrcweir 		{
502cdf0e10cSrcweir 			Point		aCenterPt( aPtNew );
503cdf0e10cSrcweir 			aCenterPt -= aToCenter;
504cdf0e10cSrcweir 
505cdf0e10cSrcweir 			DrawBitmap( aCenterPt, aDstBtnSize, aBtnPnt2, aBtnSize, rBitmap );
506cdf0e10cSrcweir 		}
507cdf0e10cSrcweir 	}
508cdf0e10cSrcweir }
509cdf0e10cSrcweir 
510cdf0e10cSrcweir /*************************************************************************
511cdf0e10cSrcweir |*
512cdf0e10cSrcweir |*	Konvertiert RECT_POINT in Point
513cdf0e10cSrcweir |*
514cdf0e10cSrcweir \************************************************************************/
515cdf0e10cSrcweir 
516cdf0e10cSrcweir Point SvxRectCtl::GetPointFromRP( RECT_POINT _eRP) const
517cdf0e10cSrcweir {
518cdf0e10cSrcweir     switch( _eRP )
519cdf0e10cSrcweir 	{
520cdf0e10cSrcweir 		case RP_LT: return aPtLT;
521cdf0e10cSrcweir 		case RP_MT: return aPtMT;
522cdf0e10cSrcweir 		case RP_RT: return aPtRT;
523cdf0e10cSrcweir 		case RP_LM: return aPtLM;
524cdf0e10cSrcweir 		case RP_MM: return aPtMM;
525cdf0e10cSrcweir 		case RP_RM: return aPtRM;
526cdf0e10cSrcweir 		case RP_LB: return aPtLB;
527cdf0e10cSrcweir 		case RP_MB: return aPtMB;
528cdf0e10cSrcweir 		case RP_RB: return aPtRB;
529cdf0e10cSrcweir 	}
530cdf0e10cSrcweir 	return( aPtMM ); // default
531cdf0e10cSrcweir }
532cdf0e10cSrcweir 
533cdf0e10cSrcweir 
534cdf0e10cSrcweir void SvxRectCtl::SetFocusRect( const Rectangle* pRect )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir 	HideFocus();
537cdf0e10cSrcweir 
538cdf0e10cSrcweir 	if( pRect )
539cdf0e10cSrcweir 		ShowFocus( *pRect );
540cdf0e10cSrcweir 	else
541cdf0e10cSrcweir 		ShowFocus( CalculateFocusRectangle() );
542cdf0e10cSrcweir }
543cdf0e10cSrcweir 
544cdf0e10cSrcweir Point SvxRectCtl::SetActualRPWithoutInvalidate( RECT_POINT eNewRP )
545cdf0e10cSrcweir {
546cdf0e10cSrcweir 	Point aPtLast = aPtNew;
547cdf0e10cSrcweir 	aPtNew = GetPointFromRP( eNewRP );
548cdf0e10cSrcweir 
549cdf0e10cSrcweir 	if( (m_nState & CS_NOHORZ) != 0 )
550cdf0e10cSrcweir 		aPtNew.X() = aPtMM.X();
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 	if( (m_nState & CS_NOVERT) != 0 )
553cdf0e10cSrcweir 		aPtNew.Y() = aPtMM.Y();
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 	eNewRP = GetRPFromPoint( aPtNew );
556cdf0e10cSrcweir 
557cdf0e10cSrcweir 	eDefRP = eNewRP;
558cdf0e10cSrcweir 	eRP = eNewRP;
559cdf0e10cSrcweir 
560cdf0e10cSrcweir 	return aPtLast;
561cdf0e10cSrcweir }
562cdf0e10cSrcweir 
563cdf0e10cSrcweir void SvxRectCtl::GetFocus()
564cdf0e10cSrcweir {
565cdf0e10cSrcweir 	SetFocusRect();
566cdf0e10cSrcweir }
567cdf0e10cSrcweir 
568cdf0e10cSrcweir 
569cdf0e10cSrcweir void SvxRectCtl::LoseFocus()
570cdf0e10cSrcweir {
571cdf0e10cSrcweir 	HideFocus();
572cdf0e10cSrcweir }
573cdf0e10cSrcweir 
574cdf0e10cSrcweir 
575cdf0e10cSrcweir Point SvxRectCtl::GetApproxLogPtFromPixPt( const Point& rPt ) const
576cdf0e10cSrcweir {
577cdf0e10cSrcweir 	Point	aPt = PixelToLogic( rPt );
578cdf0e10cSrcweir 	long	x;
579cdf0e10cSrcweir 	long	y;
580cdf0e10cSrcweir 
581cdf0e10cSrcweir 	if( ( m_nState & CS_NOHORZ ) == 0 )
582cdf0e10cSrcweir 	{
583cdf0e10cSrcweir 		if( aPt.X() < aSize.Width() / 3 )
584cdf0e10cSrcweir 			x = aPtLT.X();
585cdf0e10cSrcweir 		else if( aPt.X() < aSize.Width() * 2 / 3 )
586cdf0e10cSrcweir 			x = aPtMM.X();
587cdf0e10cSrcweir 		else
588cdf0e10cSrcweir 			x = aPtRB.X();
589cdf0e10cSrcweir 	}
590cdf0e10cSrcweir 	else
591cdf0e10cSrcweir 		x = aPtMM.X();
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 	if( ( m_nState & CS_NOVERT ) == 0 )
594cdf0e10cSrcweir 	{
595cdf0e10cSrcweir 		if( aPt.Y() < aSize.Height() / 3 )
596cdf0e10cSrcweir 			y = aPtLT.Y();
597cdf0e10cSrcweir 		else if( aPt.Y() < aSize.Height() * 2 / 3 )
598cdf0e10cSrcweir 			y = aPtMM.Y();
599cdf0e10cSrcweir 		else
600cdf0e10cSrcweir 			y = aPtRB.Y();
601cdf0e10cSrcweir 	}
602cdf0e10cSrcweir 	else
603cdf0e10cSrcweir 			y = aPtMM.Y();
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 	return Point( x, y );
606cdf0e10cSrcweir }
607cdf0e10cSrcweir 
608cdf0e10cSrcweir 
609cdf0e10cSrcweir /*************************************************************************
610cdf0e10cSrcweir |*
611cdf0e10cSrcweir |*	Konvertiert Point in RECT_POINT
612cdf0e10cSrcweir |*
613cdf0e10cSrcweir \************************************************************************/
614cdf0e10cSrcweir 
615cdf0e10cSrcweir RECT_POINT SvxRectCtl::GetRPFromPoint( Point aPt ) const
616cdf0e10cSrcweir {
617cdf0e10cSrcweir 	if	   ( aPt == aPtLT) return RP_LT;
618cdf0e10cSrcweir 	else if( aPt == aPtMT) return RP_MT;
619cdf0e10cSrcweir 	else if( aPt == aPtRT) return RP_RT;
620cdf0e10cSrcweir 	else if( aPt == aPtLM) return RP_LM;
621cdf0e10cSrcweir 	else if( aPt == aPtRM) return RP_RM;
622cdf0e10cSrcweir 	else if( aPt == aPtLB) return RP_LB;
623cdf0e10cSrcweir 	else if( aPt == aPtMB) return RP_MB;
624cdf0e10cSrcweir 	else if( aPt == aPtRB) return RP_RB;
625cdf0e10cSrcweir 
626cdf0e10cSrcweir 	else
627cdf0e10cSrcweir 		return RP_MM; // default
628cdf0e10cSrcweir }
629cdf0e10cSrcweir 
630cdf0e10cSrcweir /*************************************************************************
631cdf0e10cSrcweir |*
632cdf0e10cSrcweir |*	Bewirkt den Ursprungszustand des Controls
633cdf0e10cSrcweir |*
634cdf0e10cSrcweir \************************************************************************/
635cdf0e10cSrcweir 
636cdf0e10cSrcweir void SvxRectCtl::Reset()
637cdf0e10cSrcweir {
638cdf0e10cSrcweir 	aPtNew = GetPointFromRP( eDefRP );
639cdf0e10cSrcweir 	eRP = eDefRP;
640cdf0e10cSrcweir 	Invalidate();
641cdf0e10cSrcweir }
642cdf0e10cSrcweir 
643cdf0e10cSrcweir /*************************************************************************
644cdf0e10cSrcweir |*
645cdf0e10cSrcweir |*	Gibt den aktuell ausgewaehlten RECT_POINT zur�ck
646cdf0e10cSrcweir |*
647cdf0e10cSrcweir \************************************************************************/
648cdf0e10cSrcweir 
649cdf0e10cSrcweir RECT_POINT SvxRectCtl::GetActualRP() const
650cdf0e10cSrcweir {
651cdf0e10cSrcweir 	return( eRP );
652cdf0e10cSrcweir }
653cdf0e10cSrcweir 
654cdf0e10cSrcweir /*************************************************************************
655cdf0e10cSrcweir |*
656cdf0e10cSrcweir |*	Gibt den aktuell ausgewaehlten RECT_POINT zur�ck
657cdf0e10cSrcweir |*
658cdf0e10cSrcweir \************************************************************************/
659cdf0e10cSrcweir 
660cdf0e10cSrcweir void SvxRectCtl::SetActualRP( RECT_POINT eNewRP )
661cdf0e10cSrcweir {
662cdf0e10cSrcweir 	Point aPtLast( SetActualRPWithoutInvalidate( eNewRP ) );
663cdf0e10cSrcweir 
664cdf0e10cSrcweir 	Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ), aPtLast + Point( nRadius, nRadius ) ) );
665cdf0e10cSrcweir 	Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ), aPtNew + Point( nRadius, nRadius ) ) );
666cdf0e10cSrcweir 
667cdf0e10cSrcweir 	// notify accessibility object about change
668cdf0e10cSrcweir 	if( pAccContext )
669cdf0e10cSrcweir 		pAccContext->selectChild( eNewRP );
670cdf0e10cSrcweir }
671cdf0e10cSrcweir 
672cdf0e10cSrcweir void SvxRectCtl::SetState( CTL_STATE nState )
673cdf0e10cSrcweir {
674cdf0e10cSrcweir 	m_nState = nState;
675cdf0e10cSrcweir 
676cdf0e10cSrcweir 	Point aPtLast( GetPointFromRP( eRP ) );
677cdf0e10cSrcweir     Point _aPtNew( aPtLast );
678cdf0e10cSrcweir 
679cdf0e10cSrcweir 	if( (m_nState & CS_NOHORZ) != 0 )
680cdf0e10cSrcweir         _aPtNew.X() = aPtMM.X();
681cdf0e10cSrcweir 
682cdf0e10cSrcweir 	if( (m_nState & CS_NOVERT) != 0 )
683cdf0e10cSrcweir         _aPtNew.Y() = aPtMM.Y();
684cdf0e10cSrcweir 
685cdf0e10cSrcweir     eRP = GetRPFromPoint( _aPtNew );
686cdf0e10cSrcweir 	Invalidate();
687cdf0e10cSrcweir 
688cdf0e10cSrcweir 	if( WINDOW_TABPAGE == GetParent()->GetType() )
689cdf0e10cSrcweir 		( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
690cdf0e10cSrcweir }
691cdf0e10cSrcweir 
692cdf0e10cSrcweir sal_uInt8 SvxRectCtl::GetNumOfChilds( void ) const
693cdf0e10cSrcweir {
694cdf0e10cSrcweir 	return ( eCS == CS_ANGLE )? 8 : 9;
695cdf0e10cSrcweir }
696cdf0e10cSrcweir 
697cdf0e10cSrcweir Rectangle SvxRectCtl::CalculateFocusRectangle( void ) const
698cdf0e10cSrcweir {
699cdf0e10cSrcweir 	Size		aDstBtnSize( PixelToLogic( Size( 15, 15 ) ) );
700cdf0e10cSrcweir 	return Rectangle( aPtNew - Point( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1 ), aDstBtnSize );
701cdf0e10cSrcweir }
702cdf0e10cSrcweir 
703cdf0e10cSrcweir Rectangle SvxRectCtl::CalculateFocusRectangle( RECT_POINT eRectPoint ) const
704cdf0e10cSrcweir {
705cdf0e10cSrcweir 	Rectangle	aRet;
706cdf0e10cSrcweir 	RECT_POINT	eOldRectPoint = GetActualRP();
707cdf0e10cSrcweir 
708cdf0e10cSrcweir 	if( eOldRectPoint == eRectPoint )
709cdf0e10cSrcweir 		aRet = CalculateFocusRectangle();
710cdf0e10cSrcweir 	else
711cdf0e10cSrcweir 	{
712cdf0e10cSrcweir 		SvxRectCtl*	pThis = const_cast< SvxRectCtl* >( this );
713cdf0e10cSrcweir 
714cdf0e10cSrcweir 		pThis->SetActualRPWithoutInvalidate( eRectPoint );		// no invalidation because it's only temporary!
715cdf0e10cSrcweir 		aRet = CalculateFocusRectangle();
716cdf0e10cSrcweir 
717cdf0e10cSrcweir 		pThis->SetActualRPWithoutInvalidate( eOldRectPoint );	// no invalidation because nothing has changed!
718cdf0e10cSrcweir 	}
719cdf0e10cSrcweir 
720cdf0e10cSrcweir 	return aRet;
721cdf0e10cSrcweir }
722cdf0e10cSrcweir 
723cdf0e10cSrcweir Reference< XAccessible > SvxRectCtl::CreateAccessible()
724cdf0e10cSrcweir {
725cdf0e10cSrcweir 	Window*						pParent = GetAccessibleParentWindow();
726cdf0e10cSrcweir 
727cdf0e10cSrcweir 	DBG_ASSERT( pParent, "-SvxRectCtl::CreateAccessible(): No Parent!" );
728cdf0e10cSrcweir 
729cdf0e10cSrcweir 	Reference< XAccessible >	xAccParent  = pParent->GetAccessible();
730cdf0e10cSrcweir 	if( xAccParent.is() )
731cdf0e10cSrcweir 	{
732cdf0e10cSrcweir 		pAccContext = new SvxRectCtlAccessibleContext( xAccParent, *this );
733cdf0e10cSrcweir 		pAccContext->acquire();
734cdf0e10cSrcweir 
735cdf0e10cSrcweir         SetActualRP( GetActualRP() );
736cdf0e10cSrcweir 
737cdf0e10cSrcweir 		return pAccContext;
738cdf0e10cSrcweir 	}
739cdf0e10cSrcweir 	else
740cdf0e10cSrcweir 		return Reference< XAccessible >();
741cdf0e10cSrcweir }
742cdf0e10cSrcweir 
743cdf0e10cSrcweir RECT_POINT SvxRectCtl::GetApproxRPFromPixPt( const ::com::sun::star::awt::Point& r ) const
744cdf0e10cSrcweir {
745cdf0e10cSrcweir 	return GetRPFromPoint( GetApproxLogPtFromPixPt( Point( r.X, r.Y ) ) );
746cdf0e10cSrcweir }
747cdf0e10cSrcweir 
748cdf0e10cSrcweir // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
749cdf0e10cSrcweir void SvxRectCtl::DoCompletelyDisable(sal_Bool bNew)
750cdf0e10cSrcweir {
751cdf0e10cSrcweir 	mbCompleteDisable = bNew;
752cdf0e10cSrcweir 	Invalidate();
753cdf0e10cSrcweir }
754cdf0e10cSrcweir 
755cdf0e10cSrcweir /*************************************************************************
756cdf0e10cSrcweir |*
757cdf0e10cSrcweir |* Konstruktor ohne Size-Parameter
758cdf0e10cSrcweir |*
759cdf0e10cSrcweir \************************************************************************/
760cdf0e10cSrcweir 
761cdf0e10cSrcweir SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId ) :
762cdf0e10cSrcweir 
763cdf0e10cSrcweir 	SvxRectCtl( pParent, rResId ),
764cdf0e10cSrcweir 
765cdf0e10cSrcweir 	aFont( Application::GetSettings().GetStyleSettings().GetAppFont() )
766cdf0e10cSrcweir {
767cdf0e10cSrcweir 	aFontSize = Size( 250, 400 );
768cdf0e10cSrcweir 	Initialize();
769cdf0e10cSrcweir }
770cdf0e10cSrcweir 
771cdf0e10cSrcweir /*************************************************************************
772cdf0e10cSrcweir |*
773cdf0e10cSrcweir |* Konstruktor mit Size-Parameter
774cdf0e10cSrcweir |*
775cdf0e10cSrcweir \************************************************************************/
776cdf0e10cSrcweir 
777cdf0e10cSrcweir SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId, Size _aSize ) :
778cdf0e10cSrcweir 
779cdf0e10cSrcweir 	SvxRectCtl( pParent, rResId ),
780cdf0e10cSrcweir 
781cdf0e10cSrcweir 	aFont( Application::GetSettings().GetStyleSettings().GetAppFont() )
782cdf0e10cSrcweir {
783cdf0e10cSrcweir     aFontSize = _aSize;
784cdf0e10cSrcweir 	Initialize();
785cdf0e10cSrcweir }
786cdf0e10cSrcweir 
787cdf0e10cSrcweir /*************************************************************************
788cdf0e10cSrcweir |*
789cdf0e10cSrcweir |* Initialisierung
790cdf0e10cSrcweir |*
791cdf0e10cSrcweir \************************************************************************/
792cdf0e10cSrcweir 
793cdf0e10cSrcweir void SvxAngleCtl::Initialize()
794cdf0e10cSrcweir {
795cdf0e10cSrcweir 	bPositive = sal_True;
796cdf0e10cSrcweir 
797cdf0e10cSrcweir 	// aFont.SetName( "Helvetica" );
798cdf0e10cSrcweir 	aFont.SetSize( aFontSize );
799cdf0e10cSrcweir 	aFont.SetWeight( WEIGHT_NORMAL );
800cdf0e10cSrcweir 	aFont.SetTransparent( sal_False );
801cdf0e10cSrcweir 
802cdf0e10cSrcweir 	SetFont( aFont );
803cdf0e10cSrcweir }
804cdf0e10cSrcweir 
805cdf0e10cSrcweir /*************************************************************************
806cdf0e10cSrcweir |*
807cdf0e10cSrcweir |*	Zeichnet das (Mini-)Koordinatensystem
808cdf0e10cSrcweir |*
809cdf0e10cSrcweir \************************************************************************/
810cdf0e10cSrcweir 
811cdf0e10cSrcweir void SvxAngleCtl::Paint( const Rectangle& )
812cdf0e10cSrcweir {
813cdf0e10cSrcweir 	SetLineColor( Color( COL_BLACK ) ); 	// PEN_DOT ???
814cdf0e10cSrcweir 	DrawLine( aPtLT - Point( 0, 0), aPtRB + Point( 0, 0 ) );
815cdf0e10cSrcweir 	DrawLine( aPtLB - Point( 0, 0), aPtRT + Point( 0, 0 ) );
816cdf0e10cSrcweir 
817cdf0e10cSrcweir 	SetLineColor( Color( COL_BLACK ) );
818cdf0e10cSrcweir 	DrawLine( aPtLM - Point( 0, 0), aPtRM + Point( 0, 0 ) );
819cdf0e10cSrcweir 	DrawLine( aPtMT - Point( 0, 0), aPtMB + Point( 0, 0 ) );
820cdf0e10cSrcweir 
821cdf0e10cSrcweir 	Point aDiff(aFontSize.Width() / 2, aFontSize.Height() / 2);
822cdf0e10cSrcweir 
823cdf0e10cSrcweir 	DrawText( aPtLT - aDiff, UniString::CreateFromAscii(
824cdf0e10cSrcweir 		                     RTL_CONSTASCII_STRINGPARAM( "135" ) ) );
825cdf0e10cSrcweir 	DrawText( aPtLM - aDiff, UniString::CreateFromAscii(
826cdf0e10cSrcweir 		                     RTL_CONSTASCII_STRINGPARAM( "180" ) ) );
827cdf0e10cSrcweir 
828cdf0e10cSrcweir 	if ( bPositive )
829cdf0e10cSrcweir 		DrawText( aPtLB - aDiff, UniString::CreateFromAscii(
830cdf0e10cSrcweir 		                         RTL_CONSTASCII_STRINGPARAM( "225" ) ) );
831cdf0e10cSrcweir 	else
832cdf0e10cSrcweir 		DrawText( aPtLB - aDiff, UniString::CreateFromAscii(
833cdf0e10cSrcweir 		                         RTL_CONSTASCII_STRINGPARAM( "-135" ) ) );
834cdf0e10cSrcweir 
835cdf0e10cSrcweir 	aDiff.X() = aFontSize.Width();
836cdf0e10cSrcweir 	DrawText( aPtMT - aDiff, UniString::CreateFromAscii(
837cdf0e10cSrcweir 		                     RTL_CONSTASCII_STRINGPARAM( "90" ) ) );
838cdf0e10cSrcweir 	DrawText( aPtRT - aDiff, UniString::CreateFromAscii(
839cdf0e10cSrcweir 		                     RTL_CONSTASCII_STRINGPARAM( "45" ) ) );
840cdf0e10cSrcweir 	aDiff.X() = aDiff .X() * 3 / 2;
841cdf0e10cSrcweir 
842cdf0e10cSrcweir 	if ( bPositive )
843cdf0e10cSrcweir 		DrawText( aPtMB - aDiff, UniString::CreateFromAscii(
844cdf0e10cSrcweir 		                         RTL_CONSTASCII_STRINGPARAM( "270" ) ) );
845cdf0e10cSrcweir 	else
846cdf0e10cSrcweir 		DrawText( aPtMB - aDiff, UniString::CreateFromAscii(
847cdf0e10cSrcweir 		                         RTL_CONSTASCII_STRINGPARAM( "-90" ) ) );
848cdf0e10cSrcweir 
849cdf0e10cSrcweir 	DrawText( aPtRM - Point( 0, aDiff.Y() ), UniString::CreateFromAscii(
850cdf0e10cSrcweir 		                                     RTL_CONSTASCII_STRINGPARAM( "0" ) ) );
851cdf0e10cSrcweir 	aDiff.X() = aFontSize.Width() * 2;
852cdf0e10cSrcweir 
853cdf0e10cSrcweir 	if ( bPositive )
854cdf0e10cSrcweir 		DrawText( aPtRB - aDiff, UniString::CreateFromAscii(
855cdf0e10cSrcweir 		                         RTL_CONSTASCII_STRINGPARAM( "315" ) ) );
856cdf0e10cSrcweir 	else
857cdf0e10cSrcweir 		DrawText( aPtRB - aDiff, UniString::CreateFromAscii(
858cdf0e10cSrcweir 		                         RTL_CONSTASCII_STRINGPARAM( "-45" ) ) );
859cdf0e10cSrcweir }
860cdf0e10cSrcweir 
861cdf0e10cSrcweir /*************************************************************************
862cdf0e10cSrcweir |*
863cdf0e10cSrcweir |*	Control zum Editieren von Bitmaps
864cdf0e10cSrcweir |*
865cdf0e10cSrcweir \************************************************************************/
866cdf0e10cSrcweir 
867cdf0e10cSrcweir SvxPixelCtl::SvxPixelCtl( Window* pParent, const ResId& rResId, sal_uInt16 nNumber ) :
868cdf0e10cSrcweir 						Control		( pParent, rResId ),
869cdf0e10cSrcweir 						nLines		( nNumber ),
870cdf0e10cSrcweir 						bPaintable	( sal_True )
871cdf0e10cSrcweir {
872cdf0e10cSrcweir 	// SetMapMode( MAP_100TH_MM );
873cdf0e10cSrcweir 	aRectSize = GetOutputSize();
874cdf0e10cSrcweir 
875cdf0e10cSrcweir 	SetPixelColor( Color( COL_BLACK ) );
876cdf0e10cSrcweir 	SetBackgroundColor( Color( COL_WHITE ) );
877cdf0e10cSrcweir 	SetLineColor( Application::GetSettings().GetStyleSettings().GetShadowColor() );
878cdf0e10cSrcweir 
879cdf0e10cSrcweir 	nSquares = nLines * nLines;
880cdf0e10cSrcweir 	pPixel = new sal_uInt16[ nSquares ];
881cdf0e10cSrcweir 	rtl_zeroMemory(pPixel, nSquares * sizeof(sal_uInt16));
882cdf0e10cSrcweir }
883cdf0e10cSrcweir 
884cdf0e10cSrcweir /*************************************************************************
885cdf0e10cSrcweir |*
886cdf0e10cSrcweir |*	Destruktor dealociert dyn. Array
887cdf0e10cSrcweir |*
888cdf0e10cSrcweir \************************************************************************/
889cdf0e10cSrcweir 
890cdf0e10cSrcweir SvxPixelCtl::~SvxPixelCtl( )
891cdf0e10cSrcweir {
892cdf0e10cSrcweir 	delete []pPixel;
893cdf0e10cSrcweir }
894cdf0e10cSrcweir 
895cdf0e10cSrcweir /*************************************************************************
896cdf0e10cSrcweir |*
897cdf0e10cSrcweir |*	Wechselt die Vordergrund- ,bzw. Hintergrundfarbe
898cdf0e10cSrcweir |*
899cdf0e10cSrcweir \************************************************************************/
900cdf0e10cSrcweir 
901cdf0e10cSrcweir void SvxPixelCtl::ChangePixel( sal_uInt16 nPixel )
902cdf0e10cSrcweir {
903cdf0e10cSrcweir 	if( *( pPixel + nPixel) == 0 )
904cdf0e10cSrcweir 		*( pPixel + nPixel) = 1; // koennte erweitert werden auf mehrere Farben
905cdf0e10cSrcweir 	else
906cdf0e10cSrcweir 		*( pPixel + nPixel) = 0;
907cdf0e10cSrcweir }
908cdf0e10cSrcweir 
909cdf0e10cSrcweir /*************************************************************************
910cdf0e10cSrcweir |*
911cdf0e10cSrcweir |*	Das angeklickte Rechteck wird ermittelt um die Farbe zu wechseln
912cdf0e10cSrcweir |*
913cdf0e10cSrcweir \************************************************************************/
914cdf0e10cSrcweir 
915cdf0e10cSrcweir void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt )
916cdf0e10cSrcweir {
917cdf0e10cSrcweir 	Point aPt = PixelToLogic( rMEvt.GetPosPixel() );
918cdf0e10cSrcweir 	Point aPtTl, aPtBr;
919cdf0e10cSrcweir 	sal_uInt16	nX, nY;
920cdf0e10cSrcweir 
921cdf0e10cSrcweir 	nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() );
922cdf0e10cSrcweir 	nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() );
923cdf0e10cSrcweir 
924cdf0e10cSrcweir 	ChangePixel( nX + nY * nLines );
925cdf0e10cSrcweir 
926cdf0e10cSrcweir 	aPtTl.X() = aRectSize.Width() * nX / nLines + 1;
927cdf0e10cSrcweir 	aPtBr.X() = aRectSize.Width() * (nX + 1) / nLines - 1;
928cdf0e10cSrcweir 	aPtTl.Y() = aRectSize.Height() * nY / nLines + 1;
929cdf0e10cSrcweir 	aPtBr.Y() = aRectSize.Height() * (nY + 1) / nLines - 1;
930cdf0e10cSrcweir 
931cdf0e10cSrcweir 	Invalidate( Rectangle( aPtTl, aPtBr ) );
932cdf0e10cSrcweir 
933cdf0e10cSrcweir 	if( WINDOW_TABPAGE == GetParent()->GetType() )
934cdf0e10cSrcweir 		( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint ist dummy
935cdf0e10cSrcweir }
936cdf0e10cSrcweir 
937cdf0e10cSrcweir /*************************************************************************
938cdf0e10cSrcweir |*
939cdf0e10cSrcweir |*	Zeichnet das Control (Rechteck mit 9 Kreisen)
940cdf0e10cSrcweir |*
941cdf0e10cSrcweir \************************************************************************/
942cdf0e10cSrcweir 
943cdf0e10cSrcweir void SvxPixelCtl::Paint( const Rectangle& )
944cdf0e10cSrcweir {
945cdf0e10cSrcweir 	sal_uInt16	i, j, nTmp;
946cdf0e10cSrcweir 	Point	aPtTl, aPtBr;
947cdf0e10cSrcweir 
948cdf0e10cSrcweir 	if( bPaintable )
949cdf0e10cSrcweir 	{
950cdf0e10cSrcweir 		// Linien Zeichnen
951cdf0e10cSrcweir 		Control::SetLineColor( aLineColor );
952cdf0e10cSrcweir 		for( i = 1; i < nLines; i++)
953cdf0e10cSrcweir 		{
954cdf0e10cSrcweir 			// horizontal
955cdf0e10cSrcweir 			nTmp = (sal_uInt16) ( aRectSize.Height() * i / nLines );
956cdf0e10cSrcweir 			DrawLine( Point( 0, nTmp ), Point( aRectSize.Width(), nTmp ) );
957cdf0e10cSrcweir 			// vertikal
958cdf0e10cSrcweir 			nTmp = (sal_uInt16) ( aRectSize.Width() * i / nLines );
959cdf0e10cSrcweir 			DrawLine( Point( nTmp, 0 ), Point( nTmp, aRectSize.Height() ) );
960cdf0e10cSrcweir 		}
961cdf0e10cSrcweir 
962cdf0e10cSrcweir 		// Rechtecke (Quadrate) zeichnen
963cdf0e10cSrcweir 		Control::SetLineColor();
964cdf0e10cSrcweir 		sal_uInt16 nLastPixel = *pPixel ? 0 : 1;
965cdf0e10cSrcweir 
966cdf0e10cSrcweir 		for( i = 0; i < nLines; i++)
967cdf0e10cSrcweir 		{
968cdf0e10cSrcweir 			aPtTl.Y() = aRectSize.Height() * i / nLines + 1;
969cdf0e10cSrcweir 			aPtBr.Y() = aRectSize.Height() * (i + 1) / nLines - 1;
970cdf0e10cSrcweir 
971cdf0e10cSrcweir 			for( j = 0; j < nLines; j++)
972cdf0e10cSrcweir 			{
973cdf0e10cSrcweir 				aPtTl.X() = aRectSize.Width() * j / nLines + 1;
974cdf0e10cSrcweir 				aPtBr.X() = aRectSize.Width() * (j + 1) / nLines - 1;
975cdf0e10cSrcweir 
976cdf0e10cSrcweir 				if ( *( pPixel + i * nLines + j ) != nLastPixel )
977cdf0e10cSrcweir 				{
978cdf0e10cSrcweir 					nLastPixel = *( pPixel + i * nLines + j );
979cdf0e10cSrcweir 					// Farbe wechseln: 0 -> Hintergrundfarbe
980cdf0e10cSrcweir 					SetFillColor( nLastPixel ? aPixelColor : aBackgroundColor );
981cdf0e10cSrcweir 				}
982cdf0e10cSrcweir 				DrawRect( Rectangle( aPtTl, aPtBr ) );
983cdf0e10cSrcweir 			}
984cdf0e10cSrcweir 		}
985cdf0e10cSrcweir 	} // bPaintable
986cdf0e10cSrcweir 	else
987cdf0e10cSrcweir 	{
988cdf0e10cSrcweir 		SetBackground( Wallpaper( Color( COL_LIGHTGRAY ) ) );
989cdf0e10cSrcweir 		Control::SetLineColor( Color( COL_LIGHTRED ) );
990cdf0e10cSrcweir 		DrawLine( Point( 0, 0 ), Point( aRectSize.Width(), aRectSize.Height() ) );
991cdf0e10cSrcweir 		DrawLine( Point( 0, aRectSize.Height() ), Point( aRectSize.Width(), 0 ) );
992cdf0e10cSrcweir 	}
993cdf0e10cSrcweir }
994cdf0e10cSrcweir 
995cdf0e10cSrcweir /*************************************************************************
996cdf0e10cSrcweir |*
997cdf0e10cSrcweir |*
998cdf0e10cSrcweir |*
999cdf0e10cSrcweir \************************************************************************/
1000cdf0e10cSrcweir 
100170d3707aSArmin Le Grand void SvxPixelCtl::SetXBitmap( const BitmapEx& rBitmapEx )
1002cdf0e10cSrcweir {
100370d3707aSArmin Le Grand     BitmapColor aBack;
100470d3707aSArmin Le Grand     BitmapColor aFront;
1005cdf0e10cSrcweir 
100670d3707aSArmin Le Grand     if(isHistorical8x8(rBitmapEx, aBack, aFront))
100770d3707aSArmin Le Grand     {
100870d3707aSArmin Le Grand         Bitmap aBitmap(rBitmapEx.GetBitmap());
100970d3707aSArmin Le Grand         BitmapReadAccess* pRead = aBitmap.AcquireReadAccess();
1010cdf0e10cSrcweir 
101170d3707aSArmin Le Grand         aBackgroundColor = aBack;
101270d3707aSArmin Le Grand         aPixelColor = aFront;
101370d3707aSArmin Le Grand 
101470d3707aSArmin Le Grand         for(sal_uInt16 i(0); i < nSquares; i++)
101570d3707aSArmin Le Grand         {
101670d3707aSArmin Le Grand             const BitmapColor aColor(pRead->GetColor(i/8, i%8));
101770d3707aSArmin Le Grand 
101870d3707aSArmin Le Grand             if(aColor == aBack)
101970d3707aSArmin Le Grand             {
102070d3707aSArmin Le Grand                 *( pPixel + i ) = 0;
102170d3707aSArmin Le Grand             }
102270d3707aSArmin Le Grand             else
102370d3707aSArmin Le Grand             {
102470d3707aSArmin Le Grand                 *( pPixel + i ) = 1;
102570d3707aSArmin Le Grand             }
102670d3707aSArmin Le Grand         }
102770d3707aSArmin Le Grand 
102870d3707aSArmin Le Grand         aBitmap.ReleaseAccess(pRead);
102970d3707aSArmin Le Grand     }
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir /*************************************************************************
1033cdf0e10cSrcweir |*
1034cdf0e10cSrcweir |*	Gibt ein bestimmtes Pixel zurueck
1035cdf0e10cSrcweir |*
1036cdf0e10cSrcweir \************************************************************************/
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir sal_uInt16 SvxPixelCtl::GetBitmapPixel( const sal_uInt16 nPixel )
1039cdf0e10cSrcweir {
1040cdf0e10cSrcweir 	return( *( pPixel + nPixel ) );
1041cdf0e10cSrcweir }
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir /*************************************************************************
1044cdf0e10cSrcweir |*
1045cdf0e10cSrcweir |*	Bewirkt den Ursprungszustand des Controls
1046cdf0e10cSrcweir |*
1047cdf0e10cSrcweir \************************************************************************/
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir void SvxPixelCtl::Reset()
1050cdf0e10cSrcweir {
1051cdf0e10cSrcweir 	// clear pixel area
1052cdf0e10cSrcweir 	rtl_zeroMemory(pPixel, nSquares * sizeof(sal_uInt16));
1053cdf0e10cSrcweir 	Invalidate();
1054cdf0e10cSrcweir }
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir /*************************************************************************
1057cdf0e10cSrcweir |*
1058cdf0e10cSrcweir |*	Ctor: BitmapCtl fuer SvxPixelCtl
1059cdf0e10cSrcweir |*
1060cdf0e10cSrcweir \************************************************************************/
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir SvxBitmapCtl::SvxBitmapCtl( Window* /*pParent*/, const Size& rSize )
1063cdf0e10cSrcweir {
1064cdf0e10cSrcweir 	aSize = rSize;
1065cdf0e10cSrcweir 	// aVD.SetOutputSizePixel( aSize );
1066cdf0e10cSrcweir }
1067cdf0e10cSrcweir 
1068cdf0e10cSrcweir /*************************************************************************
1069cdf0e10cSrcweir |*
1070cdf0e10cSrcweir |*	Dtor
1071cdf0e10cSrcweir |*
1072cdf0e10cSrcweir \************************************************************************/
1073cdf0e10cSrcweir 
1074cdf0e10cSrcweir SvxBitmapCtl::~SvxBitmapCtl()
1075cdf0e10cSrcweir {
1076cdf0e10cSrcweir }
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir /*************************************************************************
1079cdf0e10cSrcweir |*
1080cdf0e10cSrcweir |*	BitmapCtl:	Gibt die Bitmap zurueck
1081cdf0e10cSrcweir |*
1082cdf0e10cSrcweir \************************************************************************/
1083cdf0e10cSrcweir 
108470d3707aSArmin Le Grand BitmapEx SvxBitmapCtl::GetBitmapEx()
1085cdf0e10cSrcweir {
108670d3707aSArmin Le Grand     const Bitmap aRetval(createHistorical8x8FromArray(pBmpArray, aPixelColor, aBackgroundColor));
1087cdf0e10cSrcweir 
108870d3707aSArmin Le Grand 	return BitmapEx(aRetval);
1089cdf0e10cSrcweir }
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir /*************************************************************************
1092cdf0e10cSrcweir |*
1093cdf0e10cSrcweir |*	Fuellt die Listbox mit Farben und Strings
1094cdf0e10cSrcweir |*
1095cdf0e10cSrcweir \************************************************************************/
1096cdf0e10cSrcweir 
1097c7be74b1SArmin Le Grand void ColorLB::Fill( const XColorListSharedPtr aColorTab )
1098cdf0e10cSrcweir {
1099c7be74b1SArmin Le Grand 	long nCount = aColorTab->Count();
1100cdf0e10cSrcweir 	XColorEntry* pEntry;
1101cdf0e10cSrcweir 	SetUpdateMode( sal_False );
1102cdf0e10cSrcweir 
1103cdf0e10cSrcweir 	for( long i = 0; i < nCount; i++ )
1104cdf0e10cSrcweir 	{
1105c7be74b1SArmin Le Grand         pEntry = aColorTab->GetColor( i );
1106cdf0e10cSrcweir 		InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1107cdf0e10cSrcweir 	}
1108a68b38dfSArmin Le Grand 
1109a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1110cdf0e10cSrcweir 	SetUpdateMode( sal_True );
1111cdf0e10cSrcweir }
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir /************************************************************************/
1114cdf0e10cSrcweir 
11153e407bd8SArmin Le Grand void ColorLB::Append( const XColorEntry& rEntry )
1116cdf0e10cSrcweir {
11173e407bd8SArmin Le Grand     InsertEntry( rEntry.GetColor(), rEntry.GetName() );
1118a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1119cdf0e10cSrcweir }
1120cdf0e10cSrcweir 
1121cdf0e10cSrcweir /************************************************************************/
1122cdf0e10cSrcweir 
11233e407bd8SArmin Le Grand void ColorLB::Modify( const XColorEntry& rEntry, sal_uInt16 nPos )
1124cdf0e10cSrcweir {
11253e407bd8SArmin Le Grand     RemoveEntry( nPos );
11263e407bd8SArmin Le Grand     InsertEntry( rEntry.GetColor(), rEntry.GetName(), nPos );
1127cdf0e10cSrcweir }
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir /*************************************************************************
1130cdf0e10cSrcweir |*
1131cdf0e10cSrcweir |*	Fuellt die Listbox mit Farben und Strings
1132cdf0e10cSrcweir |*
1133cdf0e10cSrcweir \************************************************************************/
1134cdf0e10cSrcweir 
1135c7be74b1SArmin Le Grand void FillAttrLB::Fill( const XColorListSharedPtr aColorTab )
1136cdf0e10cSrcweir {
1137c7be74b1SArmin Le Grand 	long nCount = aColorTab->Count();
1138cdf0e10cSrcweir 	XColorEntry* pEntry;
1139cdf0e10cSrcweir 	SetUpdateMode( sal_False );
1140cdf0e10cSrcweir 
1141cdf0e10cSrcweir 	for( long i = 0; i < nCount; i++ )
1142cdf0e10cSrcweir 	{
1143c7be74b1SArmin Le Grand         pEntry = aColorTab->GetColor( i );
1144cdf0e10cSrcweir 		InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1145cdf0e10cSrcweir 	}
1146a68b38dfSArmin Le Grand 
1147a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1148a68b38dfSArmin Le Grand     SetUpdateMode( sal_True );
1149cdf0e10cSrcweir }
1150cdf0e10cSrcweir 
1151cdf0e10cSrcweir /*************************************************************************
1152cdf0e10cSrcweir |*
1153cdf0e10cSrcweir |*	Fuellt die Listbox (vorlaeufig) mit Strings
1154cdf0e10cSrcweir |*
1155cdf0e10cSrcweir \************************************************************************/
1156cdf0e10cSrcweir 
1157a68b38dfSArmin Le Grand HatchingLB::HatchingLB( Window* pParent, ResId Id)
1158c7be74b1SArmin Le Grand : ListBox( pParent, Id )
1159cdf0e10cSrcweir {
1160a68b38dfSArmin Le Grand     SetEdgeBlending(true);
1161cdf0e10cSrcweir }
1162cdf0e10cSrcweir 
1163a68b38dfSArmin Le Grand HatchingLB::HatchingLB( Window* pParent, WinBits aWB)
1164c7be74b1SArmin Le Grand : ListBox( pParent, aWB )
1165cdf0e10cSrcweir {
1166a68b38dfSArmin Le Grand     SetEdgeBlending(true);
1167cdf0e10cSrcweir }
1168cdf0e10cSrcweir 
1169c7be74b1SArmin Le Grand void HatchingLB::Fill( const XHatchListSharedPtr aList )
1170cdf0e10cSrcweir {
1171cdf0e10cSrcweir 	XHatchEntry* pEntry;
1172c7be74b1SArmin Le Grand 	long nCount = aList.get() ? aList->Count() : 0;
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir 	SetUpdateMode( sal_False );
1175cdf0e10cSrcweir 
1176a68b38dfSArmin Le Grand 	for( long i = 0; i < nCount; i++ )
1177cdf0e10cSrcweir 	{
1178c7be74b1SArmin Le Grand         pEntry = aList->GetHatch( i );
1179c7be74b1SArmin Le Grand 		const Bitmap aBitmap = aList->GetUiBitmap( i );
1180a68b38dfSArmin Le Grand 		if( !aBitmap.IsEmpty() )
1181a68b38dfSArmin Le Grand 			InsertEntry( pEntry->GetName(), aBitmap );
1182a68b38dfSArmin Le Grand 		else
1183a68b38dfSArmin Le Grand 			InsertEntry( pEntry->GetName() );
1184cdf0e10cSrcweir 	}
1185cdf0e10cSrcweir 
1186a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1187cdf0e10cSrcweir 	SetUpdateMode( sal_True );
1188cdf0e10cSrcweir }
1189cdf0e10cSrcweir 
1190cdf0e10cSrcweir /************************************************************************/
1191cdf0e10cSrcweir 
11923e407bd8SArmin Le Grand void HatchingLB::Append( const XHatchEntry& rEntry, const Bitmap& rBitmap )
1193cdf0e10cSrcweir {
11943e407bd8SArmin Le Grand     if(!rBitmap.IsEmpty())
11953e407bd8SArmin Le Grand     {
11963e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), rBitmap );
11973e407bd8SArmin Le Grand     }
11983e407bd8SArmin Le Grand     else
11993e407bd8SArmin Le Grand     {
12003e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName() );
12013e407bd8SArmin Le Grand     }
12023e407bd8SArmin Le Grand 
1203a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1204cdf0e10cSrcweir }
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir /************************************************************************/
1207cdf0e10cSrcweir 
12083e407bd8SArmin Le Grand void HatchingLB::Modify( const XHatchEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap )
1209cdf0e10cSrcweir {
12103e407bd8SArmin Le Grand     RemoveEntry( nPos );
1211cdf0e10cSrcweir 
12123e407bd8SArmin Le Grand     if( !rBitmap.IsEmpty() )
12133e407bd8SArmin Le Grand     {
12143e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), rBitmap, nPos );
12153e407bd8SArmin Le Grand     }
12163e407bd8SArmin Le Grand     else
12173e407bd8SArmin Le Grand     {
12183e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), nPos );
12193e407bd8SArmin Le Grand     }
1220cdf0e10cSrcweir }
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir /************************************************************************/
1223cdf0e10cSrcweir 
1224c7be74b1SArmin Le Grand void HatchingLB::SelectEntryByList( const XHatchListSharedPtr aList, const String& rStr, const XHatch& rHatch, sal_uInt16 nDist )
1225cdf0e10cSrcweir {
1226c7be74b1SArmin Le Grand 	long nCount = aList.get() ? aList->Count() : 0;
1227cdf0e10cSrcweir 	XHatchEntry* pEntry;
1228cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
1229cdf0e10cSrcweir 	String aStr;
1230cdf0e10cSrcweir 
1231cdf0e10cSrcweir 	long i;
1232cdf0e10cSrcweir 	for( i = 0; i < nCount && !bFound; i++ )
1233cdf0e10cSrcweir 	{
1234c7be74b1SArmin Le Grand         pEntry = aList->GetHatch( i );
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir 		aStr = pEntry->GetName();
1237cdf0e10cSrcweir 
1238cdf0e10cSrcweir 		if( rStr == aStr && rHatch == pEntry->GetHatch() )
1239cdf0e10cSrcweir 			bFound = sal_True;
1240cdf0e10cSrcweir 	}
1241cdf0e10cSrcweir 	if( bFound )
1242cdf0e10cSrcweir 		SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) );
1243cdf0e10cSrcweir }
1244cdf0e10cSrcweir 
1245cdf0e10cSrcweir /*************************************************************************
1246cdf0e10cSrcweir |*
1247cdf0e10cSrcweir |*	Fuellt die Listbox (vorlaeufig) mit Strings
1248cdf0e10cSrcweir |*
1249cdf0e10cSrcweir \************************************************************************/
1250cdf0e10cSrcweir 
1251c7be74b1SArmin Le Grand void FillAttrLB::Fill( const XHatchListSharedPtr aList )
1252cdf0e10cSrcweir {
1253c7be74b1SArmin Le Grand 	long nCount = aList.get() ? aList->Count() : 0;
1254cdf0e10cSrcweir 	XHatchEntry* pEntry;
1255cdf0e10cSrcweir 	ListBox::SetUpdateMode( sal_False );
1256cdf0e10cSrcweir 
1257cdf0e10cSrcweir 	for( long i = 0; i < nCount; i++ )
1258cdf0e10cSrcweir 	{
1259c7be74b1SArmin Le Grand         pEntry = aList->GetHatch( i );
1260c7be74b1SArmin Le Grand 		const Bitmap aBitmap = aList->GetUiBitmap( i );
126197e8a929SArmin Le Grand 		if( !aBitmap.IsEmpty() )
126297e8a929SArmin Le Grand 			ListBox::InsertEntry( pEntry->GetName(), aBitmap );
1263cdf0e10cSrcweir 		else
1264cdf0e10cSrcweir 			InsertEntry( pEntry->GetName() );
1265cdf0e10cSrcweir 	}
1266a68b38dfSArmin Le Grand 
1267a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1268cdf0e10cSrcweir 	ListBox::SetUpdateMode( sal_True );
1269cdf0e10cSrcweir }
1270cdf0e10cSrcweir 
1271cdf0e10cSrcweir /*************************************************************************
1272cdf0e10cSrcweir |*
1273cdf0e10cSrcweir |*	Fuellt die Listbox (vorlaeufig) mit Strings
1274cdf0e10cSrcweir |*
1275cdf0e10cSrcweir \************************************************************************/
1276cdf0e10cSrcweir 
1277a68b38dfSArmin Le Grand GradientLB::GradientLB( Window* pParent, ResId Id)
1278c7be74b1SArmin Le Grand : ListBox( pParent, Id )
1279cdf0e10cSrcweir {
1280a68b38dfSArmin Le Grand     SetEdgeBlending(true);
1281cdf0e10cSrcweir }
1282cdf0e10cSrcweir 
1283a68b38dfSArmin Le Grand GradientLB::GradientLB( Window* pParent, WinBits aWB)
1284c7be74b1SArmin Le Grand : ListBox( pParent, aWB )
1285cdf0e10cSrcweir {
1286a68b38dfSArmin Le Grand     SetEdgeBlending(true);
1287cdf0e10cSrcweir }
1288cdf0e10cSrcweir 
1289c7be74b1SArmin Le Grand void GradientLB::Fill( const XGradientListSharedPtr aList )
1290cdf0e10cSrcweir {
1291cdf0e10cSrcweir 	XGradientEntry* pEntry;
1292c7be74b1SArmin Le Grand 	long nCount = aList.get() ? aList->Count() : 0;
1293cdf0e10cSrcweir 
1294cdf0e10cSrcweir 	SetUpdateMode( sal_False );
1295cdf0e10cSrcweir 
1296a68b38dfSArmin Le Grand 	for( long i = 0; i < nCount; i++ )
1297cdf0e10cSrcweir 	{
1298c7be74b1SArmin Le Grand         pEntry = aList->GetGradient( i );
1299c7be74b1SArmin Le Grand 		const Bitmap aBitmap = aList->GetUiBitmap( i );
1300a68b38dfSArmin Le Grand 		if( !aBitmap.IsEmpty() )
1301a68b38dfSArmin Le Grand 			InsertEntry( pEntry->GetName(), aBitmap );
1302a68b38dfSArmin Le Grand 		else
1303a68b38dfSArmin Le Grand 			InsertEntry( pEntry->GetName() );
1304cdf0e10cSrcweir 	}
1305cdf0e10cSrcweir 
1306a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1307cdf0e10cSrcweir 	SetUpdateMode( sal_True );
1308cdf0e10cSrcweir }
1309cdf0e10cSrcweir 
1310cdf0e10cSrcweir /************************************************************************/
1311cdf0e10cSrcweir 
13123e407bd8SArmin Le Grand void GradientLB::Append( const XGradientEntry& rEntry, const Bitmap& rBitmap )
1313cdf0e10cSrcweir {
13143e407bd8SArmin Le Grand     if(!rBitmap.IsEmpty())
13153e407bd8SArmin Le Grand     {
13163e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), rBitmap );
13173e407bd8SArmin Le Grand     }
13183e407bd8SArmin Le Grand     else
13193e407bd8SArmin Le Grand     {
13203e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName() );
13213e407bd8SArmin Le Grand     }
13223e407bd8SArmin Le Grand 
1323a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1324cdf0e10cSrcweir }
1325cdf0e10cSrcweir 
1326cdf0e10cSrcweir /************************************************************************/
1327cdf0e10cSrcweir 
13283e407bd8SArmin Le Grand void GradientLB::Modify( const XGradientEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap )
1329cdf0e10cSrcweir {
13303e407bd8SArmin Le Grand     RemoveEntry( nPos );
1331cdf0e10cSrcweir 
13323e407bd8SArmin Le Grand     if(!rBitmap.IsEmpty())
13333e407bd8SArmin Le Grand     {
13343e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), rBitmap, nPos );
13353e407bd8SArmin Le Grand     }
13363e407bd8SArmin Le Grand     else
13373e407bd8SArmin Le Grand     {
13383e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), nPos );
13393e407bd8SArmin Le Grand     }
1340cdf0e10cSrcweir }
1341cdf0e10cSrcweir 
1342cdf0e10cSrcweir /************************************************************************/
1343cdf0e10cSrcweir 
1344c7be74b1SArmin Le Grand void GradientLB::SelectEntryByList( const XGradientListSharedPtr aList, const String& rStr, const XGradient& rGradient, sal_uInt16 nDist )
1345cdf0e10cSrcweir {
1346c7be74b1SArmin Le Grand 	long nCount = aList.get() ? aList->Count() : 0;
1347cdf0e10cSrcweir 	XGradientEntry* pEntry;
1348cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
1349cdf0e10cSrcweir 	String aStr;
1350cdf0e10cSrcweir 
1351cdf0e10cSrcweir 	long i;
1352cdf0e10cSrcweir 	for( i = 0; i < nCount && !bFound; i++ )
1353cdf0e10cSrcweir 	{
1354c7be74b1SArmin Le Grand         pEntry = aList->GetGradient( i );
1355cdf0e10cSrcweir 
1356cdf0e10cSrcweir 		aStr = pEntry->GetName();
1357cdf0e10cSrcweir 
1358cdf0e10cSrcweir 		if( rStr == aStr && rGradient == pEntry->GetGradient() )
1359cdf0e10cSrcweir 			bFound = sal_True;
1360cdf0e10cSrcweir 	}
1361cdf0e10cSrcweir 	if( bFound )
1362cdf0e10cSrcweir 		SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) );
1363cdf0e10cSrcweir }
1364cdf0e10cSrcweir 
1365cdf0e10cSrcweir /*************************************************************************
1366cdf0e10cSrcweir |*
1367cdf0e10cSrcweir |*	Fuellt die Listbox (vorlaeufig) mit Strings
1368cdf0e10cSrcweir |*
1369cdf0e10cSrcweir \************************************************************************/
1370cdf0e10cSrcweir 
1371c7be74b1SArmin Le Grand void FillAttrLB::Fill( const XGradientListSharedPtr aList )
1372cdf0e10cSrcweir {
1373c7be74b1SArmin Le Grand 	long nCount = aList.get() ? aList->Count() : 0;
1374cdf0e10cSrcweir 	XGradientEntry* pEntry;
1375cdf0e10cSrcweir 	ListBox::SetUpdateMode( sal_False );
1376cdf0e10cSrcweir 
1377cdf0e10cSrcweir 	for( long i = 0; i < nCount; i++ )
1378cdf0e10cSrcweir 	{
1379c7be74b1SArmin Le Grand         pEntry = aList->GetGradient( i );
1380c7be74b1SArmin Le Grand 		const Bitmap aBitmap = aList->GetUiBitmap( i );
138197e8a929SArmin Le Grand 		if( !aBitmap.IsEmpty() )
138297e8a929SArmin Le Grand 			ListBox::InsertEntry( pEntry->GetName(), aBitmap );
1383cdf0e10cSrcweir 		else
1384cdf0e10cSrcweir 			InsertEntry( pEntry->GetName() );
1385cdf0e10cSrcweir 	}
1386a68b38dfSArmin Le Grand 
1387a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1388cdf0e10cSrcweir 	ListBox::SetUpdateMode( sal_True );
1389cdf0e10cSrcweir }
1390cdf0e10cSrcweir 
1391cdf0e10cSrcweir /*************************************************************************
1392cdf0e10cSrcweir |*
1393cdf0e10cSrcweir |*	Konstruktor von BitmapLB
1394cdf0e10cSrcweir |*
1395cdf0e10cSrcweir \************************************************************************/
1396cdf0e10cSrcweir 
1397a68b38dfSArmin Le Grand BitmapLB::BitmapLB(Window* pParent, ResId Id)
139870d3707aSArmin Le Grand :   ListBox(pParent, Id),
1399c7be74b1SArmin Le Grand     maBitmapEx()
1400cdf0e10cSrcweir {
1401a68b38dfSArmin Le Grand     SetEdgeBlending(true);
1402cdf0e10cSrcweir }
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir /************************************************************************/
1405cdf0e10cSrcweir 
1406a68b38dfSArmin Le Grand namespace
1407cdf0e10cSrcweir {
1408a68b38dfSArmin Le Grand     void formatBitmapExToSize(BitmapEx& rBitmapEx, const Size& rSize)
1409a68b38dfSArmin Le Grand     {
1410a68b38dfSArmin Le Grand         if(!rBitmapEx.IsEmpty() && rSize.Width() > 0 && rSize.Height() > 0)
1411a68b38dfSArmin Le Grand         {
1412a68b38dfSArmin Le Grand             VirtualDevice aVirtualDevice;
1413a68b38dfSArmin Le Grand             aVirtualDevice.SetOutputSizePixel(rSize);
141497e8a929SArmin Le Grand 
1415a68b38dfSArmin Le Grand             if(rBitmapEx.IsTransparent())
1416a68b38dfSArmin Le Grand             {
141735726d9dSArmin Le Grand                 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
141897e8a929SArmin Le Grand 
1419*33b19716SArmin Le Grand                 if(rStyleSettings.GetPreviewUsesCheckeredBackground())
142035726d9dSArmin Le Grand                 {
142135726d9dSArmin Le Grand                     const Point aNull(0, 0);
142235726d9dSArmin Le Grand                     static const sal_uInt32 nLen(8);
142335726d9dSArmin Le Grand                     static const Color aW(COL_WHITE);
142435726d9dSArmin Le Grand                     static const Color aG(0xef, 0xef, 0xef);
142535726d9dSArmin Le Grand 
142635726d9dSArmin Le Grand                     aVirtualDevice.DrawCheckered(aNull, rSize, nLen, aW, aG);
142735726d9dSArmin Le Grand                 }
142835726d9dSArmin Le Grand                 else
142935726d9dSArmin Le Grand                 {
143035726d9dSArmin Le Grand                     aVirtualDevice.SetBackground(rStyleSettings.GetFieldColor());
143135726d9dSArmin Le Grand                     aVirtualDevice.Erase();
143235726d9dSArmin Le Grand                 }
1433a68b38dfSArmin Le Grand             }
1434a68b38dfSArmin Le Grand 
1435a68b38dfSArmin Le Grand             if(rBitmapEx.GetSizePixel().Width() >= rSize.Width() && rBitmapEx.GetSizePixel().Height() >= rSize.Height())
143697e8a929SArmin Le Grand             {
1437a68b38dfSArmin Le Grand                 static sal_uInt32 nScaleFlag(BMP_SCALE_FASTESTINTERPOLATE);
1438a68b38dfSArmin Le Grand 
1439a68b38dfSArmin Le Grand                 rBitmapEx.Scale(rSize, nScaleFlag);
1440a68b38dfSArmin Le Grand                 aVirtualDevice.DrawBitmapEx(Point(0, 0), rBitmapEx);
144197e8a929SArmin Le Grand             }
1442a68b38dfSArmin Le Grand             else
1443a68b38dfSArmin Le Grand             {
1444a68b38dfSArmin Le Grand                 const Size aBitmapSize(rBitmapEx.GetSizePixel());
1445a68b38dfSArmin Le Grand 
1446a68b38dfSArmin Le Grand                 for(sal_Int32 y(0); y < rSize.Height(); y += aBitmapSize.Height())
1447a68b38dfSArmin Le Grand                 {
1448a68b38dfSArmin Le Grand                     for(sal_Int32 x(0); x < rSize.Width(); x += aBitmapSize.Width())
1449a68b38dfSArmin Le Grand                     {
1450a68b38dfSArmin Le Grand                         aVirtualDevice.DrawBitmapEx(
1451a68b38dfSArmin Le Grand                             Point(x, y),
1452a68b38dfSArmin Le Grand                             rBitmapEx);
1453a68b38dfSArmin Le Grand                     }
1454a68b38dfSArmin Le Grand                 }
1455a68b38dfSArmin Le Grand             }
1456a68b38dfSArmin Le Grand 
1457a68b38dfSArmin Le Grand             rBitmapEx = aVirtualDevice.GetBitmap(Point(0, 0), rSize);
145897e8a929SArmin Le Grand         }
1459a68b38dfSArmin Le Grand     }
1460a68b38dfSArmin Le Grand } // end of anonymous namespace
1461cdf0e10cSrcweir 
1462cdf0e10cSrcweir /************************************************************************/
1463cdf0e10cSrcweir 
1464c7be74b1SArmin Le Grand void BitmapLB::Fill(const XBitmapListSharedPtr aList)
1465cdf0e10cSrcweir {
1466cdf0e10cSrcweir 	XBitmapEntry* pEntry;
1467c7be74b1SArmin Le Grand 	const long nCount(aList.get() ? aList->Count() : 0);
1468a68b38dfSArmin Le Grand     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1469a68b38dfSArmin Le Grand     const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
1470cdf0e10cSrcweir 
147170d3707aSArmin Le Grand 	SetUpdateMode(false);
1472cdf0e10cSrcweir 
1473a68b38dfSArmin Le Grand 	for(long i(0); i < nCount; i++)
1474cdf0e10cSrcweir 	{
1475c7be74b1SArmin Le Grand         pEntry = aList->GetBitmap(i);
1476a68b38dfSArmin Le Grand         maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
1477a68b38dfSArmin Le Grand         formatBitmapExToSize(maBitmapEx, aSize);
1478a68b38dfSArmin Le Grand         InsertEntry(pEntry->GetName(), maBitmapEx);
1479cdf0e10cSrcweir 	}
1480cdf0e10cSrcweir 
1481a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
148270d3707aSArmin Le Grand 	SetUpdateMode(true);
1483cdf0e10cSrcweir }
1484cdf0e10cSrcweir 
1485cdf0e10cSrcweir /************************************************************************/
1486cdf0e10cSrcweir 
14873e407bd8SArmin Le Grand void BitmapLB::Append(const Size& rSize, const XBitmapEntry& rEntry)
1488cdf0e10cSrcweir {
14893e407bd8SArmin Le Grand     maBitmapEx = rEntry.GetGraphicObject().GetGraphic().GetBitmapEx();
14903e407bd8SArmin Le Grand 
14913e407bd8SArmin Le Grand     if(!maBitmapEx.IsEmpty())
14923e407bd8SArmin Le Grand     {
1493a68b38dfSArmin Le Grand         formatBitmapExToSize(maBitmapEx, rSize);
14943e407bd8SArmin Le Grand         InsertEntry(rEntry.GetName(), maBitmapEx);
14953e407bd8SArmin Le Grand     }
14963e407bd8SArmin Le Grand     else
149770d3707aSArmin Le Grand     {
14983e407bd8SArmin Le Grand         InsertEntry(rEntry.GetName());
149970d3707aSArmin Le Grand     }
1500a68b38dfSArmin Le Grand 
1501a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1502cdf0e10cSrcweir }
1503cdf0e10cSrcweir 
1504cdf0e10cSrcweir /************************************************************************/
1505cdf0e10cSrcweir 
15063e407bd8SArmin Le Grand void BitmapLB::Modify(const Size& rSize, const XBitmapEntry& rEntry, sal_uInt16 nPos)
1507cdf0e10cSrcweir {
15083e407bd8SArmin Le Grand     RemoveEntry(nPos);
15093e407bd8SArmin Le Grand     maBitmapEx = rEntry.GetGraphicObject().GetGraphic().GetBitmapEx();
1510cdf0e10cSrcweir 
15113e407bd8SArmin Le Grand     if(!maBitmapEx.IsEmpty())
15123e407bd8SArmin Le Grand     {
1513a68b38dfSArmin Le Grand         formatBitmapExToSize(maBitmapEx, rSize);
15143e407bd8SArmin Le Grand         InsertEntry(rEntry.GetName(), maBitmapEx, nPos);
15153e407bd8SArmin Le Grand     }
15163e407bd8SArmin Le Grand     else
151770d3707aSArmin Le Grand     {
15183e407bd8SArmin Le Grand         InsertEntry(rEntry.GetName());
151970d3707aSArmin Le Grand     }
1520cdf0e10cSrcweir }
1521cdf0e10cSrcweir 
1522cdf0e10cSrcweir /************************************************************************/
1523cdf0e10cSrcweir 
1524c7be74b1SArmin Le Grand void BitmapLB::SelectEntryByList(const XBitmapListSharedPtr aList, const String& rStr)
1525cdf0e10cSrcweir {
1526c7be74b1SArmin Le Grand 	const long nCount(aList.get() ? aList->Count() : 0);
1527cdf0e10cSrcweir 	XBitmapEntry* pEntry;
152870d3707aSArmin Le Grand 	bool bFound(false);
152970d3707aSArmin Le Grand     long i(0);
1530cdf0e10cSrcweir 
153170d3707aSArmin Le Grand 	for(i = 0; i < nCount && !bFound; i++)
1532cdf0e10cSrcweir 	{
1533c7be74b1SArmin Le Grand         pEntry = aList->GetBitmap(i);
153470d3707aSArmin Le Grand 		const String aStr(pEntry->GetName());
1535cdf0e10cSrcweir 
153670d3707aSArmin Le Grand 		if(rStr == aStr)
1537cdf0e10cSrcweir 		{
153870d3707aSArmin Le Grand 			bFound = true;
1539cdf0e10cSrcweir 		}
1540cdf0e10cSrcweir 	}
154170d3707aSArmin Le Grand 
154270d3707aSArmin Le Grand     if(bFound)
154370d3707aSArmin Le Grand     {
154470d3707aSArmin Le Grand 		SelectEntryPos((sal_uInt16)(i - 1));
154570d3707aSArmin Le Grand     }
1546cdf0e10cSrcweir }
1547cdf0e10cSrcweir 
1548cdf0e10cSrcweir /*************************************************************************
1549cdf0e10cSrcweir |*
1550cdf0e10cSrcweir |*	Konstruktor von FillAttrLB
1551cdf0e10cSrcweir |*
1552cdf0e10cSrcweir \************************************************************************/
1553cdf0e10cSrcweir 
155470d3707aSArmin Le Grand FillAttrLB::FillAttrLB( Window* pParent, ResId Id )
155570d3707aSArmin Le Grand :   ColorListBox(pParent, Id),
155670d3707aSArmin Le Grand     maBitmapEx()
1557cdf0e10cSrcweir {
1558cdf0e10cSrcweir }
1559cdf0e10cSrcweir 
1560cdf0e10cSrcweir /************************************************************************/
1561cdf0e10cSrcweir 
156270d3707aSArmin Le Grand FillAttrLB::FillAttrLB(Window* pParent, WinBits aWB)
156370d3707aSArmin Le Grand :   ColorListBox(pParent, aWB)
1564cdf0e10cSrcweir {
1565cdf0e10cSrcweir }
1566cdf0e10cSrcweir 
1567cdf0e10cSrcweir /************************************************************************/
1568cdf0e10cSrcweir 
1569c7be74b1SArmin Le Grand void FillAttrLB::Fill(const XBitmapListSharedPtr aList)
1570cdf0e10cSrcweir {
1571c7be74b1SArmin Le Grand 	const long nCount(aList.get() ? aList->Count() : 0);
1572cdf0e10cSrcweir 	XBitmapEntry* pEntry;
1573a68b38dfSArmin Le Grand     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1574a68b38dfSArmin Le Grand     const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
157570d3707aSArmin Le Grand 
157670d3707aSArmin Le Grand     ListBox::SetUpdateMode(false);
1577cdf0e10cSrcweir 
157870d3707aSArmin Le Grand 	for(long i(0); i < nCount; i++)
1579cdf0e10cSrcweir 	{
1580c7be74b1SArmin Le Grand         pEntry = aList->GetBitmap( i );
158170d3707aSArmin Le Grand 		maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
1582a68b38dfSArmin Le Grand         formatBitmapExToSize(maBitmapEx, aSize);
1583a68b38dfSArmin Le Grand 		ListBox::InsertEntry(pEntry->GetName(), maBitmapEx);
1584cdf0e10cSrcweir 	}
158570d3707aSArmin Le Grand 
1586a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
158770d3707aSArmin Le Grand     ListBox::SetUpdateMode(true);
1588cdf0e10cSrcweir }
1589cdf0e10cSrcweir 
1590cdf0e10cSrcweir /************************************************************************/
1591cdf0e10cSrcweir 
1592c7be74b1SArmin Le Grand void FillAttrLB::SelectEntryByList( const XBitmapListSharedPtr aList, const String& rStr)
1593cdf0e10cSrcweir {
1594c7be74b1SArmin Le Grand 	const long nCount(aList.get() ? aList->Count() : 0);
1595cdf0e10cSrcweir 	XBitmapEntry* pEntry;
159670d3707aSArmin Le Grand 	bool bFound(false);
159770d3707aSArmin Le Grand 	long i(0);
1598cdf0e10cSrcweir 
159970d3707aSArmin Le Grand     for(i = 0; i < nCount && !bFound; i++)
1600cdf0e10cSrcweir 	{
1601c7be74b1SArmin Le Grand         pEntry = aList->GetBitmap(i);
160270d3707aSArmin Le Grand 		const String aStr(pEntry->GetName());
1603cdf0e10cSrcweir 
160470d3707aSArmin Le Grand 		if(rStr == aStr)
1605cdf0e10cSrcweir 		{
160670d3707aSArmin Le Grand 			bFound = true;
1607cdf0e10cSrcweir 		}
1608cdf0e10cSrcweir 	}
160970d3707aSArmin Le Grand 
161070d3707aSArmin Le Grand     if(bFound)
161170d3707aSArmin Le Grand     {
161270d3707aSArmin Le Grand 		SelectEntryPos((sal_uInt16)(i - 1));
161370d3707aSArmin Le Grand     }
1614cdf0e10cSrcweir }
1615cdf0e10cSrcweir 
1616cdf0e10cSrcweir /*************************************************************************
1617cdf0e10cSrcweir |*
1618cdf0e10cSrcweir |*	Fuellt die Listbox (vorlaeufig) mit Strings
1619cdf0e10cSrcweir |*
1620cdf0e10cSrcweir \************************************************************************/
1621cdf0e10cSrcweir 
1622cdf0e10cSrcweir void FillTypeLB::Fill()
1623cdf0e10cSrcweir {
1624cdf0e10cSrcweir 	SetUpdateMode( sal_False );
1625a68b38dfSArmin Le Grand 
1626a68b38dfSArmin Le Grand     InsertEntry( String( SVX_RES( RID_SVXSTR_INVISIBLE ) ) );
1627cdf0e10cSrcweir 	InsertEntry( String( SVX_RES( RID_SVXSTR_COLOR ) ) );
1628cdf0e10cSrcweir 	InsertEntry( String( SVX_RES( RID_SVXSTR_GRADIENT ) ) );
1629cdf0e10cSrcweir 	InsertEntry( String( SVX_RES( RID_SVXSTR_HATCH ) ) );
1630cdf0e10cSrcweir 	InsertEntry( String( SVX_RES( RID_SVXSTR_BITMAP ) ) );
1631a68b38dfSArmin Le Grand 
1632a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1633cdf0e10cSrcweir 	SetUpdateMode( sal_True );
1634cdf0e10cSrcweir }
1635cdf0e10cSrcweir 
1636cdf0e10cSrcweir /*************************************************************************
1637cdf0e10cSrcweir |*
1638cdf0e10cSrcweir |*	Fuellt die Listbox (vorlaeufig) mit Strings
1639cdf0e10cSrcweir |*
1640cdf0e10cSrcweir \************************************************************************/
1641ed6b2054SArmin Le Grand LineLB::LineLB(Window* pParent, ResId Id)
1642ed6b2054SArmin Le Grand :   ListBox(pParent, Id),
1643ed6b2054SArmin Le Grand     mbAddStandardFields(true)
1644ed6b2054SArmin Le Grand {
1645a68b38dfSArmin Le Grand     // No EdgeBlending for LineStyle/Dash SetEdgeBlending(true);
1646ed6b2054SArmin Le Grand }
1647ed6b2054SArmin Le Grand 
1648ed6b2054SArmin Le Grand LineLB::LineLB(Window* pParent, WinBits aWB)
1649ed6b2054SArmin Le Grand :   ListBox(pParent, aWB),
1650ed6b2054SArmin Le Grand     mbAddStandardFields(true)
1651ed6b2054SArmin Le Grand {
1652a68b38dfSArmin Le Grand     // No EdgeBlending for LineStyle/Dash SetEdgeBlending(true);
1653ed6b2054SArmin Le Grand }
1654ed6b2054SArmin Le Grand 
1655ed6b2054SArmin Le Grand LineLB::~LineLB()
1656ed6b2054SArmin Le Grand {
1657ed6b2054SArmin Le Grand }
1658ed6b2054SArmin Le Grand 
1659ed6b2054SArmin Le Grand void LineLB::setAddStandardFields(bool bNew)
1660ed6b2054SArmin Le Grand {
1661ed6b2054SArmin Le Grand     if(getAddStandardFields() != bNew)
1662ed6b2054SArmin Le Grand     {
1663ed6b2054SArmin Le Grand         mbAddStandardFields = bNew;
1664ed6b2054SArmin Le Grand     }
1665ed6b2054SArmin Le Grand }
1666ed6b2054SArmin Le Grand 
1667c7be74b1SArmin Le Grand void LineLB::Fill( const XDashListSharedPtr aList )
1668cdf0e10cSrcweir {
166997e8a929SArmin Le Grand 	Clear();
167097e8a929SArmin Le Grand 
1671c7be74b1SArmin Le Grand     if(getAddStandardFields() && aList.get())
1672ed6b2054SArmin Le Grand     {
1673ed6b2054SArmin Le Grand         // entry for 'none'
1674c7be74b1SArmin Le Grand         InsertEntry(aList->GetStringForUiNoLine());
167597e8a929SArmin Le Grand 
1676ed6b2054SArmin Le Grand         // entry for solid line
1677c7be74b1SArmin Le Grand         InsertEntry(aList->GetStringForUiSolidLine(), aList->GetBitmapForUISolidLine());
1678ed6b2054SArmin Le Grand     }
167997e8a929SArmin Le Grand 
168097e8a929SArmin Le Grand     // entries for dashed lines
1681c7be74b1SArmin Le Grand 	long nCount = aList.get() ? aList->Count() : 0;
1682cdf0e10cSrcweir 	XDashEntry* pEntry;
1683cdf0e10cSrcweir 	SetUpdateMode( sal_False );
1684cdf0e10cSrcweir 
1685cdf0e10cSrcweir 	for( long i = 0; i < nCount; i++ )
1686cdf0e10cSrcweir 	{
1687c7be74b1SArmin Le Grand         pEntry = aList->GetDash( i );
1688c7be74b1SArmin Le Grand 		const Bitmap aBitmap = aList->GetUiBitmap( i );
168997e8a929SArmin Le Grand 		if( !aBitmap.IsEmpty() )
1690cdf0e10cSrcweir 		{
169197e8a929SArmin Le Grand 			InsertEntry( pEntry->GetName(), aBitmap );
169297e8a929SArmin Le Grand 			//delete pBitmap;
1693cdf0e10cSrcweir 		}
1694cdf0e10cSrcweir 		else
1695cdf0e10cSrcweir 			InsertEntry( pEntry->GetName() );
1696cdf0e10cSrcweir 	}
1697a68b38dfSArmin Le Grand 
1698a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1699cdf0e10cSrcweir 	SetUpdateMode( sal_True );
1700cdf0e10cSrcweir }
1701cdf0e10cSrcweir 
1702cdf0e10cSrcweir /************************************************************************/
1703cdf0e10cSrcweir 
17043e407bd8SArmin Le Grand void LineLB::Append( const XDashEntry& rEntry, const Bitmap& rBitmap )
1705cdf0e10cSrcweir {
17063e407bd8SArmin Le Grand     if(!rBitmap.IsEmpty())
17073e407bd8SArmin Le Grand     {
17083e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), rBitmap );
17093e407bd8SArmin Le Grand     }
17103e407bd8SArmin Le Grand     else
17113e407bd8SArmin Le Grand     {
17123e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName() );
17133e407bd8SArmin Le Grand     }
17143e407bd8SArmin Le Grand 
1715a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1716cdf0e10cSrcweir }
1717cdf0e10cSrcweir 
1718cdf0e10cSrcweir /************************************************************************/
1719cdf0e10cSrcweir 
17203e407bd8SArmin Le Grand void LineLB::Modify( const XDashEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap )
1721cdf0e10cSrcweir {
17223e407bd8SArmin Le Grand     RemoveEntry( nPos );
1723cdf0e10cSrcweir 
17243e407bd8SArmin Le Grand     if(!rBitmap.IsEmpty())
17253e407bd8SArmin Le Grand     {
17263e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), rBitmap, nPos );
17273e407bd8SArmin Le Grand     }
17283e407bd8SArmin Le Grand     else
17293e407bd8SArmin Le Grand     {
17303e407bd8SArmin Le Grand         InsertEntry( rEntry.GetName(), nPos );
17313e407bd8SArmin Le Grand     }
1732cdf0e10cSrcweir }
1733cdf0e10cSrcweir 
1734cdf0e10cSrcweir /************************************************************************/
1735cdf0e10cSrcweir 
1736c7be74b1SArmin Le Grand void LineLB::SelectEntryByList( const XDashListSharedPtr aList, const String& rStr, const XDash& rDash, sal_uInt16 nDist )
1737cdf0e10cSrcweir {
1738c7be74b1SArmin Le Grand 	long nCount = aList.get() ? aList->Count() : 0;
1739cdf0e10cSrcweir 	XDashEntry* pEntry;
1740cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
1741cdf0e10cSrcweir 	String aStr;
1742cdf0e10cSrcweir 	XDash aDash;
1743cdf0e10cSrcweir 
1744cdf0e10cSrcweir 	long i;
1745cdf0e10cSrcweir 	for( i = 0; i < nCount && !bFound; i++ )
1746cdf0e10cSrcweir 	{
1747c7be74b1SArmin Le Grand         pEntry = aList->GetDash( i );
1748cdf0e10cSrcweir 
1749cdf0e10cSrcweir 		aStr = pEntry->GetName();
1750cdf0e10cSrcweir 		aDash = pEntry->GetDash();
1751cdf0e10cSrcweir 
1752cdf0e10cSrcweir 		if( rStr == aStr && rDash == aDash )
1753cdf0e10cSrcweir 			bFound = sal_True;
1754cdf0e10cSrcweir 	}
1755cdf0e10cSrcweir 	if( bFound )
1756cdf0e10cSrcweir 		SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) );
1757cdf0e10cSrcweir }
1758cdf0e10cSrcweir 
1759cdf0e10cSrcweir /*************************************************************************
1760cdf0e10cSrcweir |*
1761cdf0e10cSrcweir |*	Fuellt die Listbox (vorlaeufig) mit Strings
1762cdf0e10cSrcweir |*
1763cdf0e10cSrcweir \************************************************************************/
1764fb2c9d94SAndre Fischer LineEndLB::LineEndLB( Window* pParent, ResId Id )
1765fb2c9d94SAndre Fischer     : ListBox( pParent, Id )
1766fb2c9d94SAndre Fischer {
1767a68b38dfSArmin Le Grand     // No EdgeBlending for LineEnds SetEdgeBlending(true);
1768fb2c9d94SAndre Fischer }
1769fb2c9d94SAndre Fischer 
1770fb2c9d94SAndre Fischer LineEndLB::LineEndLB( Window* pParent, WinBits aWB )
1771fb2c9d94SAndre Fischer     : ListBox( pParent, aWB )
1772fb2c9d94SAndre Fischer {
1773a68b38dfSArmin Le Grand     // No EdgeBlending for LineEnds SetEdgeBlending(true);
1774fb2c9d94SAndre Fischer }
1775fb2c9d94SAndre Fischer 
1776fb2c9d94SAndre Fischer LineEndLB::~LineEndLB(void)
1777fb2c9d94SAndre Fischer {
1778fb2c9d94SAndre Fischer }
1779fb2c9d94SAndre Fischer 
1780cdf0e10cSrcweir 
17813e407bd8SArmin Le Grand void LineEndLB::Fill( const XLineEndListSharedPtr aList, bool bStart )
1782cdf0e10cSrcweir {
1783c7be74b1SArmin Le Grand 	long nCount = aList.get() ? aList->Count() : 0;
1784cdf0e10cSrcweir 	XLineEndEntry* pEntry;
1785cdf0e10cSrcweir 	VirtualDevice aVD;
1786cdf0e10cSrcweir 	SetUpdateMode( sal_False );
1787cdf0e10cSrcweir 
1788cdf0e10cSrcweir 	for( long i = 0; i < nCount; i++ )
1789cdf0e10cSrcweir 	{
1790c7be74b1SArmin Le Grand         pEntry = aList->GetLineEnd( i );
1791c7be74b1SArmin Le Grand 		const Bitmap aBitmap = aList->GetUiBitmap( i );
179297e8a929SArmin Le Grand 		if( !aBitmap.IsEmpty() )
1793cdf0e10cSrcweir 		{
179497e8a929SArmin Le Grand 			Size aBmpSize( aBitmap.GetSizePixel() );
1795cdf0e10cSrcweir 			aVD.SetOutputSizePixel( aBmpSize, sal_False );
179697e8a929SArmin Le Grand 			aVD.DrawBitmap( Point(), aBitmap );
1797cdf0e10cSrcweir 			InsertEntry( pEntry->GetName(),
1798cdf0e10cSrcweir 				aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
1799cdf0e10cSrcweir 					Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) );
180097e8a929SArmin Le Grand 			//delete pBitmap;
1801cdf0e10cSrcweir 		}
1802cdf0e10cSrcweir 		else
1803cdf0e10cSrcweir 			InsertEntry( pEntry->GetName() );
1804cdf0e10cSrcweir 	}
1805a68b38dfSArmin Le Grand 
1806a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1807cdf0e10cSrcweir 	SetUpdateMode( sal_True );
1808cdf0e10cSrcweir }
1809cdf0e10cSrcweir 
1810cdf0e10cSrcweir /************************************************************************/
1811cdf0e10cSrcweir 
18123e407bd8SArmin Le Grand void LineEndLB::Append( const XLineEndEntry& rEntry, const Bitmap& rBitmap, bool bStart )
1813cdf0e10cSrcweir {
18143e407bd8SArmin Le Grand     if(!rBitmap.IsEmpty())
18153e407bd8SArmin Le Grand     {
18163e407bd8SArmin Le Grand         VirtualDevice aVD;
18173e407bd8SArmin Le Grand         const Size aBmpSize(rBitmap.GetSizePixel());
18183e407bd8SArmin Le Grand 
18193e407bd8SArmin Le Grand         aVD.SetOutputSizePixel(aBmpSize, false);
18203e407bd8SArmin Le Grand         aVD.DrawBitmap(Point(), rBitmap);
18213e407bd8SArmin Le Grand         InsertEntry(
18223e407bd8SArmin Le Grand             rEntry.GetName(),
18233e407bd8SArmin Le Grand             aVD.GetBitmap(bStart ? Point() : Point(aBmpSize.Width() / 2, 0 ), Size(aBmpSize.Width() / 2, aBmpSize.Height())));
18243e407bd8SArmin Le Grand     }
18253e407bd8SArmin Le Grand     else
18263e407bd8SArmin Le Grand     {
18273e407bd8SArmin Le Grand         InsertEntry(rEntry.GetName());
18283e407bd8SArmin Le Grand     }
18293e407bd8SArmin Le Grand 
1830a68b38dfSArmin Le Grand     AdaptDropDownLineCountToMaximum();
1831cdf0e10cSrcweir }
1832cdf0e10cSrcweir 
1833cdf0e10cSrcweir /************************************************************************/
1834cdf0e10cSrcweir 
18353e407bd8SArmin Le Grand void LineEndLB::Modify( const XLineEndEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap, bool bStart )
1836cdf0e10cSrcweir {
18373e407bd8SArmin Le Grand     RemoveEntry( nPos );
1838cdf0e10cSrcweir 
18393e407bd8SArmin Le Grand     if(!rBitmap.IsEmpty())
18403e407bd8SArmin Le Grand     {
18413e407bd8SArmin Le Grand         VirtualDevice aVD;
18423e407bd8SArmin Le Grand         const Size aBmpSize(rBitmap.GetSizePixel());
18433e407bd8SArmin Le Grand 
18443e407bd8SArmin Le Grand         aVD.SetOutputSizePixel(aBmpSize, false);
18453e407bd8SArmin Le Grand         aVD.DrawBitmap(Point(), rBitmap);
18463e407bd8SArmin Le Grand         InsertEntry(
18473e407bd8SArmin Le Grand             rEntry.GetName(),
18483e407bd8SArmin Le Grand             aVD.GetBitmap(bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ), Size( aBmpSize.Width() / 2, aBmpSize.Height())),
18493e407bd8SArmin Le Grand             nPos);
18503e407bd8SArmin Le Grand     }
18513e407bd8SArmin Le Grand     else
18523e407bd8SArmin Le Grand     {
18533e407bd8SArmin Le Grand         InsertEntry(rEntry.GetName(), nPos);
18543e407bd8SArmin Le Grand     }
1855cdf0e10cSrcweir }
1856cdf0e10cSrcweir 
1857cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1858cdf0e10cSrcweir 
1859cdf0e10cSrcweir void SvxPreviewBase::InitSettings(bool bForeground, bool bBackground)
1860cdf0e10cSrcweir {
1861cdf0e10cSrcweir 	const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1862cdf0e10cSrcweir 
1863cdf0e10cSrcweir 	if(bForeground)
1864cdf0e10cSrcweir 	{
1865cdf0e10cSrcweir 		svtools::ColorConfig aColorConfig;
1866cdf0e10cSrcweir 		Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
1867cdf0e10cSrcweir 
1868cdf0e10cSrcweir 		if(IsControlForeground())
1869cdf0e10cSrcweir         {
1870cdf0e10cSrcweir 			aTextColor = GetControlForeground();
1871cdf0e10cSrcweir         }
1872cdf0e10cSrcweir 
1873cdf0e10cSrcweir 		getBufferDevice().SetTextColor(aTextColor);
1874cdf0e10cSrcweir 	}
1875cdf0e10cSrcweir 
1876cdf0e10cSrcweir 	if(bBackground)
1877cdf0e10cSrcweir 	{
1878cdf0e10cSrcweir 		if(IsControlBackground())
1879cdf0e10cSrcweir         {
1880cdf0e10cSrcweir 			getBufferDevice().SetBackground(GetControlBackground());
1881cdf0e10cSrcweir         }
1882cdf0e10cSrcweir 		else
1883cdf0e10cSrcweir         {
1884cdf0e10cSrcweir 			getBufferDevice().SetBackground(rStyleSettings.GetWindowColor());
1885cdf0e10cSrcweir         }
1886cdf0e10cSrcweir 	}
1887cdf0e10cSrcweir 
1888cdf0e10cSrcweir     // do not paint background self, it gets painted buffered
1889cdf0e10cSrcweir 	SetControlBackground();
1890cdf0e10cSrcweir     SetBackground();
1891cdf0e10cSrcweir 
1892cdf0e10cSrcweir     Invalidate();
1893cdf0e10cSrcweir }
1894cdf0e10cSrcweir 
1895cdf0e10cSrcweir SvxPreviewBase::SvxPreviewBase( Window* pParent, const ResId& rResId )
1896cdf0e10cSrcweir :	Control( pParent, rResId ),
1897cdf0e10cSrcweir 	mpModel( new SdrModel() ),
1898cdf0e10cSrcweir     mpBufferDevice( new VirtualDevice(*this) )
1899cdf0e10cSrcweir {
1900cdf0e10cSrcweir 	//	Draw the control's border as a flat thin black line.
1901cdf0e10cSrcweir     SetBorderStyle(WINDOW_BORDER_MONO);
1902cdf0e10cSrcweir     SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
1903cdf0e10cSrcweir     SetMapMode(MAP_100TH_MM);
1904cdf0e10cSrcweir 
1905cdf0e10cSrcweir     // init model
1906cdf0e10cSrcweir 	mpModel->GetItemPool().FreezeIdRanges();
1907cdf0e10cSrcweir }
1908cdf0e10cSrcweir 
1909cdf0e10cSrcweir SvxPreviewBase::~SvxPreviewBase()
1910cdf0e10cSrcweir {
1911cdf0e10cSrcweir 	delete mpModel;
1912cdf0e10cSrcweir     delete mpBufferDevice;
1913cdf0e10cSrcweir }
1914cdf0e10cSrcweir 
1915cdf0e10cSrcweir void SvxPreviewBase::LocalPrePaint()
1916cdf0e10cSrcweir {
1917cdf0e10cSrcweir     // init BufferDevice
1918cdf0e10cSrcweir     if(mpBufferDevice->GetOutputSizePixel() != GetOutputSizePixel())
1919cdf0e10cSrcweir     {
1920cdf0e10cSrcweir         mpBufferDevice->SetDrawMode(GetDrawMode());
1921cdf0e10cSrcweir         mpBufferDevice->SetSettings(GetSettings());
1922cdf0e10cSrcweir         mpBufferDevice->SetAntialiasing(GetAntialiasing());
1923cdf0e10cSrcweir         mpBufferDevice->SetOutputSizePixel(GetOutputSizePixel());
1924cdf0e10cSrcweir 	    mpBufferDevice->SetMapMode(GetMapMode());
1925cdf0e10cSrcweir     }
1926cdf0e10cSrcweir 
1927*33b19716SArmin Le Grand     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1928*33b19716SArmin Le Grand 
1929*33b19716SArmin Le Grand     if(rStyleSettings.GetPreviewUsesCheckeredBackground())
1930*33b19716SArmin Le Grand     {
1931*33b19716SArmin Le Grand         const Point aNull(0, 0);
1932*33b19716SArmin Le Grand         static const sal_uInt32 nLen(8);
1933*33b19716SArmin Le Grand         static const Color aW(COL_WHITE);
1934*33b19716SArmin Le Grand         static const Color aG(0xef, 0xef, 0xef);
1935*33b19716SArmin Le Grand         const bool bWasEnabled(mpBufferDevice->IsMapModeEnabled());
1936*33b19716SArmin Le Grand 
1937*33b19716SArmin Le Grand         mpBufferDevice->EnableMapMode(false);
1938*33b19716SArmin Le Grand         mpBufferDevice->DrawCheckered(aNull, mpBufferDevice->GetOutputSizePixel(), nLen, aW, aG);
1939*33b19716SArmin Le Grand         mpBufferDevice->EnableMapMode(bWasEnabled);
1940*33b19716SArmin Le Grand     }
1941*33b19716SArmin Le Grand     else
1942*33b19716SArmin Le Grand     {
1943*33b19716SArmin Le Grand         mpBufferDevice->Erase();
1944*33b19716SArmin Le Grand     }
1945cdf0e10cSrcweir }
1946cdf0e10cSrcweir 
1947cdf0e10cSrcweir void SvxPreviewBase::LocalPostPaint()
1948cdf0e10cSrcweir {
1949cdf0e10cSrcweir     // copy to front (in pixel mode)
1950cdf0e10cSrcweir 	const bool bWasEnabledSrc(mpBufferDevice->IsMapModeEnabled());
1951cdf0e10cSrcweir 	const bool bWasEnabledDst(IsMapModeEnabled());
1952cdf0e10cSrcweir 	const Point aEmptyPoint;
1953cdf0e10cSrcweir 
1954cdf0e10cSrcweir     mpBufferDevice->EnableMapMode(false);
1955cdf0e10cSrcweir     EnableMapMode(false);
1956cdf0e10cSrcweir 
1957cdf0e10cSrcweir     DrawOutDev(
1958cdf0e10cSrcweir         aEmptyPoint, GetOutputSizePixel(),
1959cdf0e10cSrcweir         aEmptyPoint, GetOutputSizePixel(),
1960cdf0e10cSrcweir         *mpBufferDevice);
1961cdf0e10cSrcweir 
1962cdf0e10cSrcweir     mpBufferDevice->EnableMapMode(bWasEnabledSrc);
1963cdf0e10cSrcweir     EnableMapMode(bWasEnabledDst);
1964cdf0e10cSrcweir }
1965cdf0e10cSrcweir 
1966cdf0e10cSrcweir void SvxPreviewBase::StateChanged(StateChangedType nType)
1967cdf0e10cSrcweir {
1968cdf0e10cSrcweir 	Control::StateChanged(nType);
1969cdf0e10cSrcweir 
1970cdf0e10cSrcweir     if(STATE_CHANGE_CONTROLFOREGROUND == nType)
1971cdf0e10cSrcweir     {
1972cdf0e10cSrcweir 		InitSettings(true, false);
1973cdf0e10cSrcweir     }
1974cdf0e10cSrcweir 	else if(STATE_CHANGE_CONTROLBACKGROUND == nType)
1975cdf0e10cSrcweir     {
1976cdf0e10cSrcweir 		InitSettings(false, true);
1977cdf0e10cSrcweir     }
1978cdf0e10cSrcweir }
1979cdf0e10cSrcweir 
1980cdf0e10cSrcweir void SvxPreviewBase::DataChanged(const DataChangedEvent& rDCEvt)
1981cdf0e10cSrcweir {
1982cdf0e10cSrcweir     SetDrawMode(GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR);
1983cdf0e10cSrcweir 
1984cdf0e10cSrcweir     if((DATACHANGED_SETTINGS == rDCEvt.GetType()) && (rDCEvt.GetFlags() & SETTINGS_STYLE))
1985cdf0e10cSrcweir     {
1986cdf0e10cSrcweir 		InitSettings(true, true);
1987cdf0e10cSrcweir     }
1988cdf0e10cSrcweir 	else
1989cdf0e10cSrcweir     {
1990cdf0e10cSrcweir 		Control::DataChanged(rDCEvt);
1991cdf0e10cSrcweir     }
1992cdf0e10cSrcweir }
1993cdf0e10cSrcweir 
1994cdf0e10cSrcweir /*************************************************************************
1995cdf0e10cSrcweir |*
1996cdf0e10cSrcweir |*    SvxXLinePreview::SvxXLinePreview()
1997cdf0e10cSrcweir |*
1998cdf0e10cSrcweir *************************************************************************/
1999cdf0e10cSrcweir 
2000cdf0e10cSrcweir SvxXLinePreview::SvxXLinePreview( Window* pParent, const ResId& rResId )
2001cdf0e10cSrcweir :	SvxPreviewBase( pParent, rResId ),
2002cdf0e10cSrcweir 	mpLineObjA( 0L ),
2003cdf0e10cSrcweir 	mpLineObjB( 0L ),
2004cdf0e10cSrcweir 	mpLineObjC( 0L ),
2005cdf0e10cSrcweir 	mpGraphic( 0L ),
2006cdf0e10cSrcweir 	mbWithSymbol( sal_False )
2007cdf0e10cSrcweir {
2008cdf0e10cSrcweir 	const Size aOutputSize(GetOutputSize());
2009cdf0e10cSrcweir 	InitSettings( sal_True, sal_True );
2010cdf0e10cSrcweir 
2011cdf0e10cSrcweir 	const sal_Int32 nDistance(500L);
2012cdf0e10cSrcweir 	const sal_Int32 nAvailableLength(aOutputSize.Width() - (4 * nDistance));
2013cdf0e10cSrcweir 
2014cdf0e10cSrcweir 	// create DrawObectA
2015cdf0e10cSrcweir 	const sal_Int32 aYPosA(aOutputSize.Height() / 2);
2016cdf0e10cSrcweir 	const basegfx::B2DPoint aPointA1( nDistance,  aYPosA);
2017cdf0e10cSrcweir 	const basegfx::B2DPoint aPointA2( aPointA1.getX() + ((nAvailableLength * 14) / 20), aYPosA );
2018cdf0e10cSrcweir 	basegfx::B2DPolygon aPolygonA;
2019cdf0e10cSrcweir 	aPolygonA.append(aPointA1);
2020cdf0e10cSrcweir 	aPolygonA.append(aPointA2);
2021cdf0e10cSrcweir 	mpLineObjA = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygonA));
2022cdf0e10cSrcweir 	mpLineObjA->SetModel(&getModel());
2023cdf0e10cSrcweir 
2024cdf0e10cSrcweir 	// create DrawObectB
2025cdf0e10cSrcweir 	const sal_Int32 aYPosB1((aOutputSize.Height() * 3) / 4);
2026cdf0e10cSrcweir 	const sal_Int32 aYPosB2((aOutputSize.Height() * 1) / 4);
2027cdf0e10cSrcweir 	const basegfx::B2DPoint aPointB1( aPointA2.getX() + nDistance,  aYPosB1);
2028cdf0e10cSrcweir 	const basegfx::B2DPoint aPointB2( aPointB1.getX() + ((nAvailableLength * 2) / 20), aYPosB2 );
2029cdf0e10cSrcweir 	const basegfx::B2DPoint aPointB3( aPointB2.getX() + ((nAvailableLength * 2) / 20), aYPosB1 );
2030cdf0e10cSrcweir 	basegfx::B2DPolygon aPolygonB;
2031cdf0e10cSrcweir 	aPolygonB.append(aPointB1);
2032cdf0e10cSrcweir 	aPolygonB.append(aPointB2);
2033cdf0e10cSrcweir 	aPolygonB.append(aPointB3);
2034cdf0e10cSrcweir 	mpLineObjB = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonB));
2035cdf0e10cSrcweir 	mpLineObjB->SetModel(&getModel());
2036cdf0e10cSrcweir 
2037cdf0e10cSrcweir 	// create DrawObectC
2038cdf0e10cSrcweir 	const basegfx::B2DPoint aPointC1( aPointB3.getX() + nDistance,  aYPosB1);
2039cdf0e10cSrcweir 	const basegfx::B2DPoint aPointC2( aPointC1.getX() + ((nAvailableLength * 1) / 20), aYPosB2 );
2040cdf0e10cSrcweir 	const basegfx::B2DPoint aPointC3( aPointC2.getX() + ((nAvailableLength * 1) / 20), aYPosB1 );
2041cdf0e10cSrcweir 	basegfx::B2DPolygon aPolygonC;
2042cdf0e10cSrcweir 	aPolygonC.append(aPointC1);
2043cdf0e10cSrcweir 	aPolygonC.append(aPointC2);
2044cdf0e10cSrcweir 	aPolygonC.append(aPointC3);
2045cdf0e10cSrcweir 	mpLineObjC = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonC));
2046cdf0e10cSrcweir 	mpLineObjC->SetModel(&getModel());
2047cdf0e10cSrcweir }
2048cdf0e10cSrcweir 
2049cdf0e10cSrcweir SvxXLinePreview::~SvxXLinePreview()
2050cdf0e10cSrcweir {
2051cdf0e10cSrcweir     SdrObject::Free( mpLineObjA );
2052cdf0e10cSrcweir     SdrObject::Free( mpLineObjB );
2053cdf0e10cSrcweir     SdrObject::Free( mpLineObjC );
2054cdf0e10cSrcweir }
2055cdf0e10cSrcweir 
2056cdf0e10cSrcweir // -----------------------------------------------------------------------
2057cdf0e10cSrcweir 
2058cdf0e10cSrcweir void SvxXLinePreview::SetSymbol(Graphic* p,const Size& s)
2059cdf0e10cSrcweir {
2060cdf0e10cSrcweir 	mpGraphic = p;
2061cdf0e10cSrcweir 	maSymbolSize = s;
2062cdf0e10cSrcweir }
2063cdf0e10cSrcweir 
2064cdf0e10cSrcweir // -----------------------------------------------------------------------
2065cdf0e10cSrcweir 
2066cdf0e10cSrcweir void SvxXLinePreview::ResizeSymbol(const Size& s)
2067cdf0e10cSrcweir {
2068cdf0e10cSrcweir 	if ( s != maSymbolSize )
2069cdf0e10cSrcweir 	{
2070cdf0e10cSrcweir 		maSymbolSize = s;
2071cdf0e10cSrcweir 		Invalidate();
2072cdf0e10cSrcweir 	}
2073cdf0e10cSrcweir }
2074cdf0e10cSrcweir 
2075cdf0e10cSrcweir // -----------------------------------------------------------------------
2076cdf0e10cSrcweir 
2077cdf0e10cSrcweir void SvxXLinePreview::SetLineAttributes(const SfxItemSet& rItemSet)
2078cdf0e10cSrcweir {
2079cdf0e10cSrcweir 	// Set ItemSet at objects
2080cdf0e10cSrcweir 	mpLineObjA->SetMergedItemSet(rItemSet);
2081cdf0e10cSrcweir 
2082cdf0e10cSrcweir 	// At line joints, do not use arrows
2083cdf0e10cSrcweir 	SfxItemSet aTempSet(rItemSet);
2084cdf0e10cSrcweir 	aTempSet.ClearItem(XATTR_LINESTART);
2085cdf0e10cSrcweir 	aTempSet.ClearItem(XATTR_LINEEND);
2086cdf0e10cSrcweir 
2087cdf0e10cSrcweir 	mpLineObjB->SetMergedItemSet(aTempSet);
2088cdf0e10cSrcweir 	mpLineObjC->SetMergedItemSet(aTempSet);
2089cdf0e10cSrcweir }
2090cdf0e10cSrcweir 
2091cdf0e10cSrcweir // -----------------------------------------------------------------------
2092cdf0e10cSrcweir 
2093cdf0e10cSrcweir void SvxXLinePreview::Paint( const Rectangle& )
2094cdf0e10cSrcweir {
2095cdf0e10cSrcweir 	LocalPrePaint();
2096cdf0e10cSrcweir 
2097cdf0e10cSrcweir 	// paint objects to buffer device
2098cdf0e10cSrcweir 	sdr::contact::SdrObjectVector aObjectVector;
2099cdf0e10cSrcweir 	aObjectVector.push_back(mpLineObjA);
2100cdf0e10cSrcweir 	aObjectVector.push_back(mpLineObjB);
2101cdf0e10cSrcweir 	aObjectVector.push_back(mpLineObjC);
2102cdf0e10cSrcweir 
2103cdf0e10cSrcweir 	sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
2104cdf0e10cSrcweir 	sdr::contact::DisplayInfo aDisplayInfo;
2105cdf0e10cSrcweir 
2106cdf0e10cSrcweir 	// do processing
2107cdf0e10cSrcweir 	aPainter.ProcessDisplay(aDisplayInfo);
2108cdf0e10cSrcweir 
2109cdf0e10cSrcweir 	if ( mbWithSymbol && mpGraphic )
2110cdf0e10cSrcweir 	{
2111cdf0e10cSrcweir     	const Size aOutputSize(GetOutputSize());
2112cdf0e10cSrcweir 		Point aPos = Point( aOutputSize.Width() / 3, aOutputSize.Height() / 2 );
2113cdf0e10cSrcweir 		aPos.X() -= maSymbolSize.Width() / 2;
2114cdf0e10cSrcweir 		aPos.Y() -= maSymbolSize.Height() / 2;
2115cdf0e10cSrcweir 		mpGraphic->Draw( &getBufferDevice(), aPos, maSymbolSize );
2116cdf0e10cSrcweir 	}
2117cdf0e10cSrcweir 
2118cdf0e10cSrcweir 	LocalPostPaint();
2119cdf0e10cSrcweir }
2120cdf0e10cSrcweir 
2121cdf0e10cSrcweir /*************************************************************************
2122cdf0e10cSrcweir |*
2123cdf0e10cSrcweir |*    SvxXRectPreview::SvxXRectPreview()
2124cdf0e10cSrcweir |*
2125cdf0e10cSrcweir *************************************************************************/
2126cdf0e10cSrcweir 
2127cdf0e10cSrcweir SvxXRectPreview::SvxXRectPreview( Window* pParent, const ResId& rResId )
2128cdf0e10cSrcweir :	SvxPreviewBase( pParent, rResId ),
2129cdf0e10cSrcweir 	mpRectangleObject(0)
2130cdf0e10cSrcweir {
2131cdf0e10cSrcweir 	InitSettings(true, true);
2132cdf0e10cSrcweir 
2133cdf0e10cSrcweir 	// create RectangleObject
2134cdf0e10cSrcweir     const Rectangle aObjectSize(Point(), GetOutputSize());
2135cdf0e10cSrcweir 	mpRectangleObject = new SdrRectObj(aObjectSize);
2136cdf0e10cSrcweir 	mpRectangleObject->SetModel(&getModel());
2137cdf0e10cSrcweir }
2138cdf0e10cSrcweir 
2139cdf0e10cSrcweir SvxXRectPreview::~SvxXRectPreview()
2140cdf0e10cSrcweir {
2141cdf0e10cSrcweir     SdrObject::Free(mpRectangleObject);
2142cdf0e10cSrcweir }
2143cdf0e10cSrcweir 
2144cdf0e10cSrcweir void SvxXRectPreview::SetAttributes(const SfxItemSet& rItemSet)
2145cdf0e10cSrcweir {
2146cdf0e10cSrcweir 	mpRectangleObject->SetMergedItemSet(rItemSet, true);
2147cdf0e10cSrcweir 	mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
2148cdf0e10cSrcweir }
2149cdf0e10cSrcweir 
2150cdf0e10cSrcweir void SvxXRectPreview::Paint( const Rectangle& )
2151cdf0e10cSrcweir {
2152cdf0e10cSrcweir 	LocalPrePaint();
2153cdf0e10cSrcweir 
2154cdf0e10cSrcweir     sdr::contact::SdrObjectVector aObjectVector;
2155cdf0e10cSrcweir 
2156cdf0e10cSrcweir     aObjectVector.push_back(mpRectangleObject);
2157cdf0e10cSrcweir 
2158cdf0e10cSrcweir     sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
2159cdf0e10cSrcweir 	sdr::contact::DisplayInfo aDisplayInfo;
2160cdf0e10cSrcweir 
2161cdf0e10cSrcweir 	aPainter.ProcessDisplay(aDisplayInfo);
2162cdf0e10cSrcweir 
2163cdf0e10cSrcweir     LocalPostPaint();
2164cdf0e10cSrcweir }
2165cdf0e10cSrcweir 
2166cdf0e10cSrcweir /*************************************************************************
2167cdf0e10cSrcweir |*
2168cdf0e10cSrcweir |*    SvxXShadowPreview::SvxXShadowPreview()
2169cdf0e10cSrcweir |*
2170cdf0e10cSrcweir *************************************************************************/
2171cdf0e10cSrcweir 
2172cdf0e10cSrcweir SvxXShadowPreview::SvxXShadowPreview( Window* pParent, const ResId& rResId )
2173cdf0e10cSrcweir :	SvxPreviewBase( pParent, rResId ),
2174cdf0e10cSrcweir 	mpRectangleObject(0),
2175cdf0e10cSrcweir     mpRectangleShadow(0)
2176cdf0e10cSrcweir {
2177cdf0e10cSrcweir 	InitSettings(true, true);
2178cdf0e10cSrcweir 
2179cdf0e10cSrcweir     // prepare size
2180cdf0e10cSrcweir 	Size aSize = GetOutputSize();
2181cdf0e10cSrcweir 	aSize.Width() = aSize.Width() / 3;
2182cdf0e10cSrcweir 	aSize.Height() = aSize.Height() / 3;
2183cdf0e10cSrcweir 
2184cdf0e10cSrcweir     // create RectangleObject
2185cdf0e10cSrcweir     const Rectangle aObjectSize( Point( aSize.Width(), aSize.Height() ), aSize );
2186cdf0e10cSrcweir 	mpRectangleObject = new SdrRectObj(aObjectSize);
2187cdf0e10cSrcweir 	mpRectangleObject->SetModel(&getModel());
2188cdf0e10cSrcweir 
2189cdf0e10cSrcweir     // create ShadowObject
2190cdf0e10cSrcweir     const Rectangle aShadowSize( Point( aSize.Width(), aSize.Height() ), aSize );
2191cdf0e10cSrcweir 	mpRectangleShadow = new SdrRectObj(aShadowSize);
2192cdf0e10cSrcweir 	mpRectangleShadow->SetModel(&getModel());
2193cdf0e10cSrcweir }
2194cdf0e10cSrcweir 
2195cdf0e10cSrcweir SvxXShadowPreview::~SvxXShadowPreview()
2196cdf0e10cSrcweir {
2197cdf0e10cSrcweir     SdrObject::Free(mpRectangleObject);
2198cdf0e10cSrcweir     SdrObject::Free(mpRectangleShadow);
2199cdf0e10cSrcweir }
2200cdf0e10cSrcweir 
2201cdf0e10cSrcweir void SvxXShadowPreview::SetRectangleAttributes(const SfxItemSet& rItemSet)
2202cdf0e10cSrcweir {
2203cdf0e10cSrcweir 	mpRectangleObject->SetMergedItemSet(rItemSet, true);
2204cdf0e10cSrcweir 	mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
2205cdf0e10cSrcweir }
2206cdf0e10cSrcweir 
2207cdf0e10cSrcweir void SvxXShadowPreview::SetShadowAttributes(const SfxItemSet& rItemSet)
2208cdf0e10cSrcweir {
2209cdf0e10cSrcweir 	mpRectangleShadow->SetMergedItemSet(rItemSet, true);
2210cdf0e10cSrcweir 	mpRectangleShadow->SetMergedItem(XLineStyleItem(XLINE_NONE));
2211cdf0e10cSrcweir }
2212cdf0e10cSrcweir 
2213cdf0e10cSrcweir void SvxXShadowPreview::SetShadowPosition(const Point& rPos)
2214cdf0e10cSrcweir {
2215cdf0e10cSrcweir     Rectangle aObjectPosition(mpRectangleObject->GetSnapRect());
2216cdf0e10cSrcweir     aObjectPosition.Move(rPos.X(), rPos.Y());
2217cdf0e10cSrcweir     mpRectangleShadow->SetSnapRect(aObjectPosition);
2218cdf0e10cSrcweir }
2219cdf0e10cSrcweir 
2220cdf0e10cSrcweir void SvxXShadowPreview::Paint( const Rectangle& )
2221cdf0e10cSrcweir {
2222cdf0e10cSrcweir 	LocalPrePaint();
2223cdf0e10cSrcweir 
2224cdf0e10cSrcweir     sdr::contact::SdrObjectVector aObjectVector;
2225cdf0e10cSrcweir 
2226cdf0e10cSrcweir     aObjectVector.push_back(mpRectangleShadow);
2227cdf0e10cSrcweir 	aObjectVector.push_back(mpRectangleObject);
2228cdf0e10cSrcweir 
2229cdf0e10cSrcweir     sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
2230cdf0e10cSrcweir 	sdr::contact::DisplayInfo aDisplayInfo;
2231cdf0e10cSrcweir 
2232cdf0e10cSrcweir 	aPainter.ProcessDisplay(aDisplayInfo);
2233cdf0e10cSrcweir 
2234cdf0e10cSrcweir     LocalPostPaint();
2235cdf0e10cSrcweir }
2236cdf0e10cSrcweir 
2237cdf0e10cSrcweir // -----------------------------------------------------------------------
2238cdf0e10cSrcweir // eof
2239