update dev300-m58
[ooovba.git] / svx / source / dialog / dlgctrl.cxx
blob2d3b9d33b40a0c68d009974c9fbbc80097ebb0c1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dlgctrl.cxx,v $
10 * $Revision: 1.36 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 // include ---------------------------------------------------------------
35 #include <tools/shl.hxx>
36 #ifndef _APP_HXX //autogen
37 #include <vcl/svapp.hxx>
38 #endif
40 #include <svx/xtable.hxx>
41 #include <svx/xpool.hxx>
43 #include <svx/dialogs.hrc>
44 #include "accessibility.hrc"
45 #include <svx/dlgctrl.hxx>
46 #include <svx/dialmgr.hxx>
47 #include <tools/poly.hxx>
48 #include <vcl/region.hxx>
49 #include <vcl/gradient.hxx>
50 #include <vcl/hatch.hxx>
51 #include <svtools/colorcfg.hxx>
53 #include "svxrectctaccessiblecontext.hxx"
54 #include <com/sun/star/lang/XUnoTunnel.hpp>
55 #include <basegfx/point/b2dpoint.hxx>
56 #include <basegfx/polygon/b2dpolygon.hxx>
57 #include <svx/svdorect.hxx>
59 #include <svx/svdmodel.hxx>
60 #include <svx/svdopath.hxx>
61 #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
62 #include <svx/sdr/contact/displayinfo.hxx>
64 #define OUTPUT_DRAWMODE_COLOR (DRAWMODE_DEFAULT)
65 #define OUTPUT_DRAWMODE_CONTRAST (DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT)
67 using namespace ::com::sun::star::uno;
68 using namespace ::com::sun::star::lang;
69 using namespace ::com::sun::star::accessibility;
72 /*************************************************************************
74 |* Control zur Darstellung und Auswahl der Eckpunkte (und Mittelpunkt)
75 |* eines Objekts
77 \************************************************************************/
79 Bitmap& SvxRectCtl::GetRectBitmap( void )
81 if( !pBitmap )
82 InitRectBitmap();
84 return *pBitmap;
87 SvxRectCtl::SvxRectCtl( Window* pParent, const ResId& rResId, RECT_POINT eRpt,
88 USHORT nBorder, USHORT nCircle, CTL_STYLE eStyle ) :
90 Control( pParent, rResId ),
92 pAccContext ( NULL ),
93 nBorderWidth( nBorder ),
94 nRadius ( nCircle),
95 eDefRP ( eRpt ),
96 eCS ( eStyle ),
97 pBitmap ( NULL ),
98 m_nState ( 0 ),
99 mbCompleteDisable(sal_False)
101 SetMapMode( MAP_100TH_MM );
102 Resize_Impl();
105 // -----------------------------------------------------------------------
107 SvxRectCtl::~SvxRectCtl()
109 delete pBitmap;
111 if( pAccContext )
112 pAccContext->release();
115 // -----------------------------------------------------------------------
116 void SvxRectCtl::Resize()
118 Resize_Impl();
119 Control::Resize();
122 // -----------------------------------------------------------------------
124 void SvxRectCtl::Resize_Impl()
126 aSize = GetOutputSize();
128 switch( eCS )
130 case CS_RECT:
131 case CS_ANGLE:
132 case CS_SHADOW:
133 aPtLT = Point( 0 + nBorderWidth, 0 + nBorderWidth );
134 aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
135 aPtRT = Point( aSize.Width() - nBorderWidth, 0 + nBorderWidth );
137 aPtLM = Point( 0 + nBorderWidth, aSize.Height() / 2 );
138 aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
139 aPtRM = Point( aSize.Width() - nBorderWidth, aSize.Height() / 2 );
141 aPtLB = Point( 0 + nBorderWidth, aSize.Height() - nBorderWidth );
142 aPtMB = Point( aSize.Width() / 2, aSize.Height() - nBorderWidth );
143 aPtRB = Point( aSize.Width() - nBorderWidth, aSize.Height() - nBorderWidth );
144 break;
146 case CS_LINE:
147 aPtLT = Point( 0 + 3 * nBorderWidth, 0 + nBorderWidth );
148 aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
149 aPtRT = Point( aSize.Width() - 3 * nBorderWidth, 0 + nBorderWidth );
151 aPtLM = Point( 0 + 3 * nBorderWidth, aSize.Height() / 2 );
152 aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
153 aPtRM = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() / 2 );
155 aPtLB = Point( 0 + 3 * nBorderWidth, aSize.Height() - nBorderWidth );
156 aPtMB = Point( aSize.Width() / 2, aSize.Height() - nBorderWidth );
157 aPtRB = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() - nBorderWidth );
158 break;
160 Reset();
161 InitSettings( TRUE, TRUE );
163 // -----------------------------------------------------------------------
165 void SvxRectCtl::InitRectBitmap( void )
167 if( pBitmap )
168 delete pBitmap;
170 const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
171 svtools::ColorConfig aColorConfig;
173 pBitmap = new Bitmap( SVX_RES( RID_SVXCTRL_RECTBTNS ) );
175 // set bitmap-colors
176 Color aColorAry1[7];
177 Color aColorAry2[7];
178 aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 ); // light-gray
179 aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 ); // yellow
180 aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF ); // white
181 aColorAry1[3] = Color( 0x80, 0x80, 0x80 ); // dark-gray
182 aColorAry1[4] = Color( 0x00, 0x00, 0x00 ); // black
183 aColorAry1[5] = Color( 0x00, 0xFF, 0x00 ); // green
184 aColorAry1[6] = Color( 0x00, 0x00, 0xFF ); // blue
185 aColorAry2[0] = rStyles.GetDialogColor(); // background
186 aColorAry2[1] = rStyles.GetWindowColor();
187 aColorAry2[2] = rStyles.GetLightColor();
188 aColorAry2[3] = rStyles.GetShadowColor();
189 aColorAry2[4] = rStyles.GetDarkShadowColor();
190 aColorAry2[5] = Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
191 aColorAry2[6] = rStyles.GetDialogColor();
193 #ifdef DBG_UTIL
194 static BOOL bModify = FALSE;
195 BOOL& rModify = bModify;
196 if( rModify )
198 static int n = 0;
199 static UINT8 r = 0xFF;
200 static UINT8 g = 0x00;
201 static UINT8 b = 0xFF;
202 int& rn = n;
203 UINT8& rr = r;
204 UINT8& rg = g;
205 UINT8& rb = b;
206 aColorAry2[ rn ] = Color( rr, rg, rb );
208 #endif
210 pBitmap->Replace( aColorAry1, aColorAry2, 7, NULL );
213 // -----------------------------------------------------------------------
215 void SvxRectCtl::InitSettings( BOOL bForeground, BOOL bBackground )
217 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
219 if( bForeground )
221 svtools::ColorConfig aColorConfig;
222 Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
224 if ( IsControlForeground() )
225 aTextColor = GetControlForeground();
226 SetTextColor( aTextColor );
229 if( bBackground )
231 if ( IsControlBackground() )
232 SetBackground( GetControlBackground() );
233 else
234 SetBackground( rStyleSettings.GetWindowColor() );
237 delete pBitmap;
238 pBitmap = NULL; // forces new creating of bitmap
240 Invalidate();
243 /*************************************************************************
245 |* Das angeklickte Rechteck (3 x 3) wird ermittelt und der Parent (Dialog)
246 |* wird benachrichtigt, dass der Punkt geaendert wurde
248 \************************************************************************/
250 void SvxRectCtl::MouseButtonDown( const MouseEvent& rMEvt )
252 // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
253 if(!IsCompletelyDisabled())
255 Point aPtLast = aPtNew;
257 aPtNew = GetApproxLogPtFromPixPt( rMEvt.GetPosPixel() );
259 if( aPtNew == aPtMM && ( eCS == CS_SHADOW || eCS == CS_ANGLE ) )
261 aPtNew = aPtLast;
263 else
265 Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ),
266 aPtLast + Point( nRadius, nRadius ) ) );
267 Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ),
268 aPtNew + Point( nRadius, nRadius ) ) );
269 eRP = GetRPFromPoint( aPtNew );
271 SetActualRP( eRP );
273 if( WINDOW_TABPAGE == GetParent()->GetType() )
274 ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
279 // -----------------------------------------------------------------------
281 void SvxRectCtl::KeyInput( const KeyEvent& rKeyEvt )
283 // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
284 if(!IsCompletelyDisabled())
286 RECT_POINT eNewRP = eRP;
287 BOOL bUseMM = (eCS != CS_SHADOW) && (eCS != CS_ANGLE);
289 switch( rKeyEvt.GetKeyCode().GetCode() )
291 case KEY_DOWN:
293 if( !(m_nState & CS_NOVERT) )
294 switch( eNewRP )
296 case RP_LT: eNewRP = RP_LM; break;
297 case RP_MT: eNewRP = bUseMM ? RP_MM : RP_MB; break;
298 case RP_RT: eNewRP = RP_RM; break;
299 case RP_LM: eNewRP = RP_LB; break;
300 case RP_MM: eNewRP = RP_MB; break;
301 case RP_RM: eNewRP = RP_RB; break;
302 default: ; //prevent warning
305 break;
306 case KEY_UP:
308 if( !(m_nState & CS_NOVERT) )
309 switch( eNewRP )
311 case RP_LM: eNewRP = RP_LT; break;
312 case RP_MM: eNewRP = RP_MT; break;
313 case RP_RM: eNewRP = RP_RT; break;
314 case RP_LB: eNewRP = RP_LM; break;
315 case RP_MB: eNewRP = bUseMM ? RP_MM : RP_MT; break;
316 case RP_RB: eNewRP = RP_RM; break;
317 default: ; //prevent warning
320 break;
321 case KEY_LEFT:
323 if( !(m_nState & CS_NOHORZ) )
324 switch( eNewRP )
326 case RP_MT: eNewRP = RP_LT; break;
327 case RP_RT: eNewRP = RP_MT; break;
328 case RP_MM: eNewRP = RP_LM; break;
329 case RP_RM: eNewRP = bUseMM ? RP_MM : RP_LM; break;
330 case RP_MB: eNewRP = RP_LB; break;
331 case RP_RB: eNewRP = RP_MB; break;
332 default: ; //prevent warning
335 break;
336 case KEY_RIGHT:
338 if( !(m_nState & CS_NOHORZ) )
339 switch( eNewRP )
341 case RP_LT: eNewRP = RP_MT; break;
342 case RP_MT: eNewRP = RP_RT; break;
343 case RP_LM: eNewRP = bUseMM ? RP_MM : RP_RM; break;
344 case RP_MM: eNewRP = RP_RM; break;
345 case RP_LB: eNewRP = RP_MB; break;
346 case RP_MB: eNewRP = RP_RB; break;
347 default: ; //prevent warning
350 break;
351 default:
352 Control::KeyInput( rKeyEvt );
353 return;
355 if( eNewRP != eRP )
357 SetActualRP( eNewRP );
359 if( WINDOW_TABPAGE == GetParent()->GetType() )
360 ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
362 SetFocusRect();
367 // -----------------------------------------------------------------------
369 void SvxRectCtl::StateChanged( StateChangedType nType )
371 if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
372 InitSettings( TRUE, FALSE );
373 else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
374 InitSettings( FALSE, TRUE );
376 Window::StateChanged( nType );
379 // -----------------------------------------------------------------------
381 void SvxRectCtl::DataChanged( const DataChangedEvent& rDCEvt )
383 if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
384 InitSettings( TRUE, TRUE );
385 else
386 Window::DataChanged( rDCEvt );
389 /*************************************************************************
391 |* Zeichnet das Control (Rechteck mit 9 Kreisen)
393 \************************************************************************/
395 void SvxRectCtl::Paint( const Rectangle& )
397 Point aPtDiff( PixelToLogic( Point( 1, 1 ) ) );
399 const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
401 SetLineColor( rStyles.GetDialogColor() );
402 SetFillColor( rStyles.GetDialogColor() );
403 DrawRect( Rectangle( Point(0,0), GetOutputSize() ) );
405 if( IsEnabled() )
406 SetLineColor( rStyles.GetLabelTextColor() );
407 else
408 SetLineColor( rStyles.GetShadowColor() );
410 SetFillColor();
412 switch( eCS )
415 case CS_RECT:
416 case CS_SHADOW:
417 if( !IsEnabled() )
419 Color aOldCol = GetLineColor();
420 SetLineColor( rStyles.GetLightColor() );
421 DrawRect( Rectangle( aPtLT + aPtDiff, aPtRB + aPtDiff ) );
422 SetLineColor( aOldCol );
424 DrawRect( Rectangle( aPtLT, aPtRB ) );
425 break;
427 case CS_LINE:
428 if( !IsEnabled() )
430 Color aOldCol = GetLineColor();
431 SetLineColor( rStyles.GetLightColor() );
432 DrawLine( aPtLM - Point( 2 * nBorderWidth, 0) + aPtDiff,
433 aPtRM + Point( 2 * nBorderWidth, 0 ) + aPtDiff );
434 SetLineColor( aOldCol );
436 DrawLine( aPtLM - Point( 2 * nBorderWidth, 0),
437 aPtRM + Point( 2 * nBorderWidth, 0 ) );
438 break;
440 case CS_ANGLE:
441 if( !IsEnabled() )
443 Color aOldCol = GetLineColor();
444 SetLineColor( rStyles.GetLightColor() );
445 DrawLine( aPtLT + aPtDiff, aPtRB + aPtDiff );
446 DrawLine( aPtLB + aPtDiff, aPtRT + aPtDiff );
447 DrawLine( aPtLM + aPtDiff, aPtRM + aPtDiff );
448 DrawLine( aPtMT + aPtDiff, aPtMB + aPtDiff );
449 SetLineColor( aOldCol );
451 DrawLine( aPtLT, aPtRB );
452 DrawLine( aPtLB, aPtRT );
453 DrawLine( aPtLM, aPtRM );
454 DrawLine( aPtMT, aPtMB );
455 break;
457 default:
458 break;
460 SetFillColor( GetBackground().GetColor() );
462 Size aBtnSize( 11, 11 );
463 Size aDstBtnSize( PixelToLogic( aBtnSize ) );
464 Point aToCenter( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1);
465 Point aBtnPnt1( IsEnabled()?0:22,0 );
466 Point aBtnPnt2( 11,0 );
467 Point aBtnPnt3( 22,0 );
469 BOOL bNoHorz = (m_nState & CS_NOHORZ) != 0;
470 BOOL bNoVert = (m_nState & CS_NOVERT) != 0;
472 Bitmap& rBitmap = GetRectBitmap();
474 // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
475 if(IsCompletelyDisabled())
477 DrawBitmap( aPtLT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
478 DrawBitmap( aPtMT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
479 DrawBitmap( aPtRT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
480 DrawBitmap( aPtLM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
481 if( eCS == CS_RECT || eCS == CS_LINE )
482 DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
483 DrawBitmap( aPtRM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
484 DrawBitmap( aPtLB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
485 DrawBitmap( aPtMB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
486 DrawBitmap( aPtRB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
488 else
490 DrawBitmap( aPtLT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
491 DrawBitmap( aPtMT - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
492 DrawBitmap( aPtRT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
494 DrawBitmap( aPtLM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
496 // Mittelpunkt bei Rechteck und Linie
497 if( eCS == CS_RECT || eCS == CS_LINE )
498 DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt1, aBtnSize, rBitmap );
500 DrawBitmap( aPtRM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
502 DrawBitmap( aPtLB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
503 DrawBitmap( aPtMB - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
504 DrawBitmap( aPtRB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
507 // draw active button, avoid center pos for angle
508 // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
509 if(!IsCompletelyDisabled())
511 if( IsEnabled() && (eCS != CS_ANGLE || aPtNew != aPtMM) )
513 Point aCenterPt( aPtNew );
514 aCenterPt -= aToCenter;
516 DrawBitmap( aCenterPt, aDstBtnSize, aBtnPnt2, aBtnSize, rBitmap );
521 /*************************************************************************
523 |* Konvertiert RECT_POINT in Point
525 \************************************************************************/
527 Point SvxRectCtl::GetPointFromRP( RECT_POINT _eRP) const
529 switch( _eRP )
531 case RP_LT: return aPtLT;
532 case RP_MT: return aPtMT;
533 case RP_RT: return aPtRT;
534 case RP_LM: return aPtLM;
535 case RP_MM: return aPtMM;
536 case RP_RM: return aPtRM;
537 case RP_LB: return aPtLB;
538 case RP_MB: return aPtMB;
539 case RP_RB: return aPtRB;
541 return( aPtMM ); // default
545 void SvxRectCtl::SetFocusRect( const Rectangle* pRect )
547 HideFocus();
549 if( pRect )
550 ShowFocus( *pRect );
551 else
552 ShowFocus( CalculateFocusRectangle() );
555 Point SvxRectCtl::SetActualRPWithoutInvalidate( RECT_POINT eNewRP )
557 Point aPtLast = aPtNew;
558 aPtNew = GetPointFromRP( eNewRP );
560 if( (m_nState & CS_NOHORZ) != 0 )
561 aPtNew.X() = aPtMM.X();
563 if( (m_nState & CS_NOVERT) != 0 )
564 aPtNew.Y() = aPtMM.Y();
566 eNewRP = GetRPFromPoint( aPtNew );
568 eDefRP = eNewRP;
569 eRP = eNewRP;
571 return aPtLast;
574 void SvxRectCtl::GetFocus()
576 SetFocusRect();
580 void SvxRectCtl::LoseFocus()
582 HideFocus();
586 Point SvxRectCtl::GetApproxLogPtFromPixPt( const Point& rPt ) const
588 Point aPt = PixelToLogic( rPt );
589 long x;
590 long y;
592 if( ( m_nState & CS_NOHORZ ) == 0 )
594 if( aPt.X() < aSize.Width() / 3 )
595 x = aPtLT.X();
596 else if( aPt.X() < aSize.Width() * 2 / 3 )
597 x = aPtMM.X();
598 else
599 x = aPtRB.X();
601 else
602 x = aPtMM.X();
604 if( ( m_nState & CS_NOVERT ) == 0 )
606 if( aPt.Y() < aSize.Height() / 3 )
607 y = aPtLT.Y();
608 else if( aPt.Y() < aSize.Height() * 2 / 3 )
609 y = aPtMM.Y();
610 else
611 y = aPtRB.Y();
613 else
614 y = aPtMM.Y();
616 return Point( x, y );
620 /*************************************************************************
622 |* Konvertiert Point in RECT_POINT
624 \************************************************************************/
626 RECT_POINT SvxRectCtl::GetRPFromPoint( Point aPt ) const
628 if ( aPt == aPtLT) return RP_LT;
629 else if( aPt == aPtMT) return RP_MT;
630 else if( aPt == aPtRT) return RP_RT;
631 else if( aPt == aPtLM) return RP_LM;
632 else if( aPt == aPtRM) return RP_RM;
633 else if( aPt == aPtLB) return RP_LB;
634 else if( aPt == aPtMB) return RP_MB;
635 else if( aPt == aPtRB) return RP_RB;
637 else
638 return RP_MM; // default
641 /*************************************************************************
643 |* Bewirkt den Ursprungszustand des Controls
645 \************************************************************************/
647 void SvxRectCtl::Reset()
649 aPtNew = GetPointFromRP( eDefRP );
650 eRP = eDefRP;
651 Invalidate();
654 /*************************************************************************
656 |* Gibt den aktuell ausgewaehlten RECT_POINT zur�ck
658 \************************************************************************/
660 RECT_POINT SvxRectCtl::GetActualRP() const
662 return( eRP );
665 /*************************************************************************
667 |* Gibt den aktuell ausgewaehlten RECT_POINT zur�ck
669 \************************************************************************/
671 void SvxRectCtl::SetActualRP( RECT_POINT eNewRP )
673 Point aPtLast( SetActualRPWithoutInvalidate( eNewRP ) );
675 Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ), aPtLast + Point( nRadius, nRadius ) ) );
676 Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ), aPtNew + Point( nRadius, nRadius ) ) );
678 // notify accessibility object about change
679 if( pAccContext )
680 pAccContext->selectChild( eNewRP );
683 void SvxRectCtl::SetState( CTL_STATE nState )
685 m_nState = nState;
687 Point aPtLast( GetPointFromRP( eRP ) );
688 Point _aPtNew( aPtLast );
690 if( (m_nState & CS_NOHORZ) != 0 )
691 _aPtNew.X() = aPtMM.X();
693 if( (m_nState & CS_NOVERT) != 0 )
694 _aPtNew.Y() = aPtMM.Y();
696 eRP = GetRPFromPoint( _aPtNew );
697 Invalidate();
699 if( WINDOW_TABPAGE == GetParent()->GetType() )
700 ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
703 UINT8 SvxRectCtl::GetNumOfChilds( void ) const
705 return ( eCS == CS_ANGLE )? 8 : 9;
708 Rectangle SvxRectCtl::CalculateFocusRectangle( void ) const
710 Size aDstBtnSize( PixelToLogic( Size( 15, 15 ) ) );
711 return Rectangle( aPtNew - Point( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1 ), aDstBtnSize );
714 Rectangle SvxRectCtl::CalculateFocusRectangle( RECT_POINT eRectPoint ) const
716 Rectangle aRet;
717 RECT_POINT eOldRectPoint = GetActualRP();
719 if( eOldRectPoint == eRectPoint )
720 aRet = CalculateFocusRectangle();
721 else
723 SvxRectCtl* pThis = const_cast< SvxRectCtl* >( this );
725 pThis->SetActualRPWithoutInvalidate( eRectPoint ); // no invalidation because it's only temporary!
726 aRet = CalculateFocusRectangle();
728 pThis->SetActualRPWithoutInvalidate( eOldRectPoint ); // no invalidation because nothing has changed!
731 return aRet;
734 Reference< XAccessible > SvxRectCtl::CreateAccessible()
736 Window* pParent = GetAccessibleParentWindow();
738 DBG_ASSERT( pParent, "-SvxRectCtl::CreateAccessible(): No Parent!" );
740 Reference< XAccessible > xAccParent = pParent->GetAccessible();
741 if( xAccParent.is() )
743 pAccContext = new SvxRectCtlAccessibleContext( xAccParent, *this );
744 pAccContext->acquire();
746 SetActualRP( GetActualRP() );
748 return pAccContext;
750 else
751 return Reference< XAccessible >();
754 RECT_POINT SvxRectCtl::GetApproxRPFromPixPt( const ::com::sun::star::awt::Point& r ) const
756 return GetRPFromPoint( GetApproxLogPtFromPixPt( Point( r.X, r.Y ) ) );
759 // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
760 void SvxRectCtl::DoCompletelyDisable(sal_Bool bNew)
762 mbCompleteDisable = bNew;
763 Invalidate();
766 /*************************************************************************
768 |* Konstruktor ohne Size-Parameter
770 \************************************************************************/
772 SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId ) :
774 SvxRectCtl( pParent, rResId ),
776 aFont( Application::GetSettings().GetStyleSettings().GetAppFont() )
778 aFontSize = Size( 250, 400 );
779 Initialize();
782 /*************************************************************************
784 |* Konstruktor mit Size-Parameter
786 \************************************************************************/
788 SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId, Size _aSize ) :
790 SvxRectCtl( pParent, rResId ),
792 aFont( Application::GetSettings().GetStyleSettings().GetAppFont() )
794 aFontSize = _aSize;
795 Initialize();
798 /*************************************************************************
800 |* Initialisierung
802 \************************************************************************/
804 void SvxAngleCtl::Initialize()
806 bPositive = TRUE;
808 // aFont.SetName( "Helvetica" );
809 aFont.SetSize( aFontSize );
810 aFont.SetWeight( WEIGHT_NORMAL );
811 aFont.SetTransparent( FALSE );
813 SetFont( aFont );
816 /*************************************************************************
818 |* Zeichnet das (Mini-)Koordinatensystem
820 \************************************************************************/
822 void SvxAngleCtl::Paint( const Rectangle& )
824 SetLineColor( Color( COL_BLACK ) ); // PEN_DOT ???
825 DrawLine( aPtLT - Point( 0, 0), aPtRB + Point( 0, 0 ) );
826 DrawLine( aPtLB - Point( 0, 0), aPtRT + Point( 0, 0 ) );
828 SetLineColor( Color( COL_BLACK ) );
829 DrawLine( aPtLM - Point( 0, 0), aPtRM + Point( 0, 0 ) );
830 DrawLine( aPtMT - Point( 0, 0), aPtMB + Point( 0, 0 ) );
832 Point aDiff(aFontSize.Width() / 2, aFontSize.Height() / 2);
834 DrawText( aPtLT - aDiff, UniString::CreateFromAscii(
835 RTL_CONSTASCII_STRINGPARAM( "135" ) ) );
836 DrawText( aPtLM - aDiff, UniString::CreateFromAscii(
837 RTL_CONSTASCII_STRINGPARAM( "180" ) ) );
839 if ( bPositive )
840 DrawText( aPtLB - aDiff, UniString::CreateFromAscii(
841 RTL_CONSTASCII_STRINGPARAM( "225" ) ) );
842 else
843 DrawText( aPtLB - aDiff, UniString::CreateFromAscii(
844 RTL_CONSTASCII_STRINGPARAM( "-135" ) ) );
846 aDiff.X() = aFontSize.Width();
847 DrawText( aPtMT - aDiff, UniString::CreateFromAscii(
848 RTL_CONSTASCII_STRINGPARAM( "90" ) ) );
849 DrawText( aPtRT - aDiff, UniString::CreateFromAscii(
850 RTL_CONSTASCII_STRINGPARAM( "45" ) ) );
851 aDiff.X() = aDiff .X() * 3 / 2;
853 if ( bPositive )
854 DrawText( aPtMB - aDiff, UniString::CreateFromAscii(
855 RTL_CONSTASCII_STRINGPARAM( "270" ) ) );
856 else
857 DrawText( aPtMB - aDiff, UniString::CreateFromAscii(
858 RTL_CONSTASCII_STRINGPARAM( "-90" ) ) );
860 DrawText( aPtRM - Point( 0, aDiff.Y() ), UniString::CreateFromAscii(
861 RTL_CONSTASCII_STRINGPARAM( "0" ) ) );
862 aDiff.X() = aFontSize.Width() * 2;
864 if ( bPositive )
865 DrawText( aPtRB - aDiff, UniString::CreateFromAscii(
866 RTL_CONSTASCII_STRINGPARAM( "315" ) ) );
867 else
868 DrawText( aPtRB - aDiff, UniString::CreateFromAscii(
869 RTL_CONSTASCII_STRINGPARAM( "-45" ) ) );
872 /*************************************************************************
874 |* Control zum Editieren von Bitmaps
876 \************************************************************************/
878 SvxPixelCtl::SvxPixelCtl( Window* pParent, const ResId& rResId, USHORT nNumber ) :
879 Control ( pParent, rResId ),
880 nLines ( nNumber ),
881 bPaintable ( TRUE )
883 // SetMapMode( MAP_100TH_MM );
884 aRectSize = GetOutputSize();
886 SetPixelColor( Color( COL_BLACK ) );
887 SetBackgroundColor( Color( COL_WHITE ) );
888 SetLineColor( Application::GetSettings().GetStyleSettings().GetShadowColor() );
890 nSquares = nLines * nLines;
891 pPixel = new USHORT[ nSquares ];
892 rtl_zeroMemory(pPixel, nSquares * sizeof(USHORT));
895 /*************************************************************************
897 |* Destruktor dealociert dyn. Array
899 \************************************************************************/
901 SvxPixelCtl::~SvxPixelCtl( )
903 delete []pPixel;
906 /*************************************************************************
908 |* Wechselt die Vordergrund- ,bzw. Hintergrundfarbe
910 \************************************************************************/
912 void SvxPixelCtl::ChangePixel( USHORT nPixel )
914 if( *( pPixel + nPixel) == 0 )
915 *( pPixel + nPixel) = 1; // koennte erweitert werden auf mehrere Farben
916 else
917 *( pPixel + nPixel) = 0;
920 /*************************************************************************
922 |* Das angeklickte Rechteck wird ermittelt um die Farbe zu wechseln
924 \************************************************************************/
926 void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt )
928 Point aPt = PixelToLogic( rMEvt.GetPosPixel() );
929 Point aPtTl, aPtBr;
930 USHORT nX, nY;
932 nX = (USHORT) ( aPt.X() * nLines / aRectSize.Width() );
933 nY = (USHORT) ( aPt.Y() * nLines / aRectSize.Height() );
935 ChangePixel( nX + nY * nLines );
937 aPtTl.X() = aRectSize.Width() * nX / nLines + 1;
938 aPtBr.X() = aRectSize.Width() * (nX + 1) / nLines - 1;
939 aPtTl.Y() = aRectSize.Height() * nY / nLines + 1;
940 aPtBr.Y() = aRectSize.Height() * (nY + 1) / nLines - 1;
942 Invalidate( Rectangle( aPtTl, aPtBr ) );
944 if( WINDOW_TABPAGE == GetParent()->GetType() )
945 ( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint ist dummy
948 /*************************************************************************
950 |* Zeichnet das Control (Rechteck mit 9 Kreisen)
952 \************************************************************************/
954 void SvxPixelCtl::Paint( const Rectangle& )
956 USHORT i, j, nTmp;
957 Point aPtTl, aPtBr;
959 if( bPaintable )
961 // Linien Zeichnen
962 Control::SetLineColor( aLineColor );
963 for( i = 1; i < nLines; i++)
965 // horizontal
966 nTmp = (USHORT) ( aRectSize.Height() * i / nLines );
967 DrawLine( Point( 0, nTmp ), Point( aRectSize.Width(), nTmp ) );
968 // vertikal
969 nTmp = (USHORT) ( aRectSize.Width() * i / nLines );
970 DrawLine( Point( nTmp, 0 ), Point( nTmp, aRectSize.Height() ) );
973 // Rechtecke (Quadrate) zeichnen
974 Control::SetLineColor();
975 USHORT nLastPixel = *pPixel ? 0 : 1;
977 for( i = 0; i < nLines; i++)
979 aPtTl.Y() = aRectSize.Height() * i / nLines + 1;
980 aPtBr.Y() = aRectSize.Height() * (i + 1) / nLines - 1;
982 for( j = 0; j < nLines; j++)
984 aPtTl.X() = aRectSize.Width() * j / nLines + 1;
985 aPtBr.X() = aRectSize.Width() * (j + 1) / nLines - 1;
987 if ( *( pPixel + i * nLines + j ) != nLastPixel )
989 nLastPixel = *( pPixel + i * nLines + j );
990 // Farbe wechseln: 0 -> Hintergrundfarbe
991 SetFillColor( nLastPixel ? aPixelColor : aBackgroundColor );
993 DrawRect( Rectangle( aPtTl, aPtBr ) );
996 } // bPaintable
997 else
999 SetBackground( Wallpaper( Color( COL_LIGHTGRAY ) ) );
1000 Control::SetLineColor( Color( COL_LIGHTRED ) );
1001 DrawLine( Point( 0, 0 ), Point( aRectSize.Width(), aRectSize.Height() ) );
1002 DrawLine( Point( 0, aRectSize.Height() ), Point( aRectSize.Width(), 0 ) );
1006 /*************************************************************************
1010 \************************************************************************/
1012 void SvxPixelCtl::SetXBitmap( const XOBitmap& rXBmp )
1014 if( rXBmp.GetBitmapType() == XBITMAP_8X8 )
1016 aPixelColor = rXBmp.GetPixelColor();
1017 aBackgroundColor = rXBmp.GetBackgroundColor();
1019 USHORT* pArray = rXBmp.GetPixelArray();
1021 for( USHORT i = 0; i < nSquares; i++ )
1022 *( pPixel + i ) = *( pArray + i );
1026 /*************************************************************************
1028 |* Gibt ein bestimmtes Pixel zurueck
1030 \************************************************************************/
1032 USHORT SvxPixelCtl::GetBitmapPixel( const USHORT nPixel )
1034 return( *( pPixel + nPixel ) );
1037 /*************************************************************************
1039 |* Bewirkt den Ursprungszustand des Controls
1041 \************************************************************************/
1043 void SvxPixelCtl::Reset()
1045 // clear pixel area
1046 rtl_zeroMemory(pPixel, nSquares * sizeof(USHORT));
1047 Invalidate();
1050 /*************************************************************************
1052 |* Ctor: BitmapCtl fuer SvxPixelCtl
1054 \************************************************************************/
1056 SvxBitmapCtl::SvxBitmapCtl( Window* /*pParent*/, const Size& rSize )
1058 aSize = rSize;
1059 // aVD.SetOutputSizePixel( aSize );
1062 /*************************************************************************
1064 |* Dtor
1066 \************************************************************************/
1068 SvxBitmapCtl::~SvxBitmapCtl()
1072 /*************************************************************************
1074 |* BitmapCtl: Gibt die Bitmap zurueck
1076 \************************************************************************/
1078 XOBitmap SvxBitmapCtl::GetXBitmap()
1080 XOBitmap aXOBitmap( pBmpArray, aPixelColor, aBackgroundColor );
1082 return( aXOBitmap );
1085 /*************************************************************************
1087 |* Fuellt die Listbox mit Farben und Strings
1089 \************************************************************************/
1091 void ColorLB::Fill( const XColorTable* pColorTab )
1093 long nCount = pColorTab->Count();
1094 XColorEntry* pEntry;
1095 SetUpdateMode( FALSE );
1097 for( long i = 0; i < nCount; i++ )
1099 pEntry = pColorTab->GetColor( i );
1100 InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1102 SetUpdateMode( TRUE );
1105 /************************************************************************/
1107 void ColorLB::Append( XColorEntry* pEntry, Bitmap* )
1109 InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1112 /************************************************************************/
1114 void ColorLB::Modify( XColorEntry* pEntry, USHORT nPos, Bitmap* )
1116 RemoveEntry( nPos );
1117 InsertEntry( pEntry->GetColor(), pEntry->GetName(), nPos );
1120 /*************************************************************************
1122 |* Fuellt die Listbox mit Farben und Strings
1124 \************************************************************************/
1126 void FillAttrLB::Fill( const XColorTable* pColorTab )
1128 long nCount = pColorTab->Count();
1129 XColorEntry* pEntry;
1130 SetUpdateMode( FALSE );
1132 for( long i = 0; i < nCount; i++ )
1134 pEntry = pColorTab->GetColor( i );
1135 InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1137 SetUpdateMode( TRUE );
1140 /*************************************************************************
1142 |* Fuellt die Listbox (vorlaeufig) mit Strings
1144 \************************************************************************/
1146 HatchingLB::HatchingLB( Window* pParent, ResId Id, BOOL bUserDraw /*= TRUE*/ )
1147 : ListBox( pParent, Id ),
1148 mpList ( NULL ),
1149 mbUserDraw( bUserDraw )
1151 EnableUserDraw( mbUserDraw );
1154 HatchingLB::HatchingLB( Window* pParent, WinBits aWB, BOOL bUserDraw /*= TRUE*/ )
1155 : ListBox( pParent, aWB ),
1156 mpList ( NULL ),
1157 mbUserDraw( bUserDraw )
1159 EnableUserDraw( mbUserDraw );
1162 void HatchingLB::Fill( const XHatchList* pList )
1164 mpList = (XHatchList*)pList;
1165 XHatchEntry* pEntry;
1166 long nCount = pList->Count();
1168 SetUpdateMode( FALSE );
1170 if( mbUserDraw )
1172 for( long i = 0; i < nCount; i++ )
1173 InsertEntry( pList->GetHatch( i )->GetName() );
1175 else
1177 for( long i = 0; i < nCount; i++ )
1179 pEntry = pList->GetHatch( i );
1180 Bitmap* pBitmap = pList->GetBitmap( i );
1181 if( pBitmap )
1182 InsertEntry( pEntry->GetName(), *pBitmap );
1183 else
1184 InsertEntry( pEntry->GetName() );
1188 SetUpdateMode( TRUE );
1191 void HatchingLB::UserDraw( const UserDrawEvent& rUDEvt )
1193 if( mpList != NULL )
1195 // Draw gradient with borderrectangle
1196 const Rectangle& rDrawRect = rUDEvt.GetRect();
1197 Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 );
1199 sal_Int32 nId = rUDEvt.GetItemId();
1200 if( nId >= 0 && nId <= mpList->Count() )
1202 OutputDevice* pDevice = rUDEvt.GetDevice();
1204 ULONG nOldDrawMode = pDevice->GetDrawMode();
1205 pDevice->SetDrawMode( GetDisplayBackground().GetColor().IsDark() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
1207 XHatch& rXHatch = mpList->GetHatch( rUDEvt.GetItemId() )->GetHatch();
1208 MapMode aMode( MAP_100TH_MM );
1209 Hatch aHatch( (HatchStyle) rXHatch.GetHatchStyle(),
1210 rXHatch.GetColor(),
1211 rUDEvt.GetDevice()->LogicToPixel( Point( rXHatch.GetDistance(), 0 ), aMode ).X(),
1212 (sal_uInt16)rXHatch.GetAngle() );
1213 const Polygon aPolygon( aRect );
1214 const PolyPolygon aPolypoly( aPolygon );
1215 pDevice->DrawHatch( aPolypoly, aHatch );
1217 pDevice->SetLineColor( COL_BLACK );
1218 pDevice->SetFillColor();
1219 pDevice->DrawRect( aRect );
1221 pDevice->SetDrawMode( nOldDrawMode );
1223 // Draw name
1224 pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->GetHatch( rUDEvt.GetItemId() )->GetName() );
1229 /************************************************************************/
1231 void HatchingLB::Append( XHatchEntry* pEntry, Bitmap* pBmp )
1233 if( pBmp )
1234 InsertEntry( pEntry->GetName(), *pBmp );
1235 else
1236 InsertEntry( pEntry->GetName() );
1239 /************************************************************************/
1241 void HatchingLB::Modify( XHatchEntry* pEntry, USHORT nPos, Bitmap* pBmp )
1243 RemoveEntry( nPos );
1245 if( pBmp )
1246 InsertEntry( pEntry->GetName(), *pBmp, nPos );
1247 else
1248 InsertEntry( pEntry->GetName(), nPos );
1251 /************************************************************************/
1253 void HatchingLB::SelectEntryByList( const XHatchList* pList, const String& rStr,
1254 const XHatch& rHatch, USHORT nDist )
1256 long nCount = pList->Count();
1257 XHatchEntry* pEntry;
1258 BOOL bFound = FALSE;
1259 String aStr;
1261 long i;
1262 for( i = 0; i < nCount && !bFound; i++ )
1264 pEntry = pList->GetHatch( i );
1266 aStr = pEntry->GetName();
1268 if( rStr == aStr && rHatch == pEntry->GetHatch() )
1269 bFound = TRUE;
1271 if( bFound )
1272 SelectEntryPos( (USHORT) ( i - 1 + nDist ) );
1275 /*************************************************************************
1277 |* Fuellt die Listbox (vorlaeufig) mit Strings
1279 \************************************************************************/
1281 void FillAttrLB::Fill( const XHatchList* pList )
1283 long nCount = pList->Count();
1284 XHatchEntry* pEntry;
1285 ListBox::SetUpdateMode( FALSE );
1287 for( long i = 0; i < nCount; i++ )
1289 pEntry = pList->GetHatch( i );
1290 Bitmap* pBitmap = pList->GetBitmap( i );
1291 if( pBitmap )
1292 ListBox::InsertEntry( pEntry->GetName(), *pBitmap );
1293 else
1294 InsertEntry( pEntry->GetName() );
1296 ListBox::SetUpdateMode( TRUE );
1299 /*************************************************************************
1301 |* Fuellt die Listbox (vorlaeufig) mit Strings
1303 \************************************************************************/
1305 GradientLB::GradientLB( Window* pParent, ResId Id, BOOL bUserDraw /*= TRUE*/ )
1306 : ListBox( pParent, Id ),
1307 mpList(NULL),
1308 mbUserDraw( bUserDraw )
1310 EnableUserDraw( mbUserDraw);
1313 GradientLB::GradientLB( Window* pParent, WinBits aWB, BOOL bUserDraw /*= TRUE*/ )
1314 : ListBox( pParent, aWB ),
1315 mpList(NULL),
1316 mbUserDraw( bUserDraw )
1318 EnableUserDraw( mbUserDraw );
1321 void GradientLB::Fill( const XGradientList* pList )
1323 mpList = (XGradientList*)pList;
1324 XGradientEntry* pEntry;
1325 long nCount = pList->Count();
1327 SetUpdateMode( FALSE );
1329 if( mbUserDraw )
1331 for( long i = 0; i < nCount; i++ )
1332 InsertEntry( pList->GetGradient( i )->GetName() );
1334 else
1336 for( long i = 0; i < nCount; i++ )
1338 pEntry = pList->GetGradient( i );
1339 Bitmap* pBitmap = pList->GetBitmap( i );
1340 if( pBitmap )
1341 InsertEntry( pEntry->GetName(), *pBitmap );
1342 else
1343 InsertEntry( pEntry->GetName() );
1347 SetUpdateMode( TRUE );
1350 void GradientLB::UserDraw( const UserDrawEvent& rUDEvt )
1352 if( mpList != NULL )
1354 // Draw gradient with borderrectangle
1355 const Rectangle& rDrawRect = rUDEvt.GetRect();
1356 Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 );
1358 sal_Int32 nId = rUDEvt.GetItemId();
1359 if( nId >= 0 && nId <= mpList->Count() )
1361 OutputDevice* pDevice = rUDEvt.GetDevice();
1363 XGradient& rXGrad = mpList->GetGradient( rUDEvt.GetItemId() )->GetGradient();
1364 Gradient aGradient( (GradientStyle) rXGrad.GetGradientStyle(), rXGrad.GetStartColor(), rXGrad.GetEndColor() );
1365 aGradient.SetAngle( (USHORT)rXGrad.GetAngle() );
1366 aGradient.SetBorder( rXGrad.GetBorder() );
1367 aGradient.SetOfsX( rXGrad.GetXOffset() );
1368 aGradient.SetOfsY( rXGrad.GetYOffset() );
1369 aGradient.SetStartIntensity( rXGrad.GetStartIntens() );
1370 aGradient.SetEndIntensity( rXGrad.GetEndIntens() );
1371 aGradient.SetSteps( 255 );
1373 // #i76307# always paint the preview in LTR, because this is what the document does
1374 Window* pWin = dynamic_cast<Window*>(pDevice);
1375 if( pWin && pWin->IsRTLEnabled() && Application::GetSettings().GetLayoutRTL())
1377 long nWidth = pDevice->GetOutputSize().Width();
1379 pWin->EnableRTL( FALSE );
1381 Rectangle aMirrorRect( Point( nWidth - aRect.Left() - aRect.GetWidth(), aRect.Top() ),
1382 aRect.GetSize() );
1384 pDevice->DrawGradient( aMirrorRect, aGradient );
1386 pWin->EnableRTL( TRUE );
1388 else
1389 pDevice->DrawGradient( aRect, aGradient );
1391 pDevice->SetLineColor( COL_BLACK );
1392 pDevice->SetFillColor();
1393 pDevice->DrawRect( aRect );
1395 // Draw name
1396 pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->GetGradient( rUDEvt.GetItemId() )->GetName() );
1401 /************************************************************************/
1403 void GradientLB::Append( XGradientEntry* pEntry, Bitmap* pBmp )
1405 if( pBmp )
1406 InsertEntry( pEntry->GetName(), *pBmp );
1407 else
1408 InsertEntry( pEntry->GetName() );
1411 /************************************************************************/
1413 void GradientLB::Modify( XGradientEntry* pEntry, USHORT nPos, Bitmap* pBmp )
1415 RemoveEntry( nPos );
1417 if( pBmp )
1418 InsertEntry( pEntry->GetName(), *pBmp, nPos );
1419 else
1420 InsertEntry( pEntry->GetName(), nPos );
1423 /************************************************************************/
1425 void GradientLB::SelectEntryByList( const XGradientList* pList, const String& rStr,
1426 const XGradient& rGradient, USHORT nDist )
1428 long nCount = pList->Count();
1429 XGradientEntry* pEntry;
1430 BOOL bFound = FALSE;
1431 String aStr;
1433 long i;
1434 for( i = 0; i < nCount && !bFound; i++ )
1436 pEntry = pList->GetGradient( i );
1438 aStr = pEntry->GetName();
1440 if( rStr == aStr && rGradient == pEntry->GetGradient() )
1441 bFound = TRUE;
1443 if( bFound )
1444 SelectEntryPos( (USHORT) ( i - 1 + nDist ) );
1447 /*************************************************************************
1449 |* Fuellt die Listbox (vorlaeufig) mit Strings
1451 \************************************************************************/
1453 void FillAttrLB::Fill( const XGradientList* pList )
1455 long nCount = pList->Count();
1456 XGradientEntry* pEntry;
1457 ListBox::SetUpdateMode( FALSE );
1459 for( long i = 0; i < nCount; i++ )
1461 pEntry = pList->GetGradient( i );
1462 Bitmap* pBitmap = pList->GetBitmap( i );
1463 if( pBitmap )
1464 ListBox::InsertEntry( pEntry->GetName(), *pBitmap );
1465 else
1466 InsertEntry( pEntry->GetName() );
1468 ListBox::SetUpdateMode( TRUE );
1471 /*************************************************************************
1473 |* Konstruktor von BitmapLB
1475 \************************************************************************/
1477 BitmapLB::BitmapLB( Window* pParent, ResId Id, BOOL bUserDraw /*= TRUE*/ )
1478 : ListBox( pParent, Id ),
1479 mpList( NULL ),
1480 mbUserDraw( bUserDraw )
1482 aVD.SetOutputSizePixel( Size( 32, 16 ) );
1483 EnableUserDraw( mbUserDraw );
1486 /************************************************************************/
1488 void BitmapLB::SetVirtualDevice()
1490 if( aBitmap.GetSizePixel().Width() > 8 ||
1491 aBitmap.GetSizePixel().Height() > 8 )
1493 aVD.DrawBitmap( Point( 0, 0 ), Size( 32, 16 ), aBitmap );
1495 else
1497 aVD.DrawBitmap( Point( 0, 0 ), aBitmap );
1498 aVD.DrawBitmap( Point( 8, 0 ), aBitmap );
1499 aVD.DrawBitmap( Point( 16, 0 ), aBitmap );
1500 aVD.DrawBitmap( Point( 24, 0 ), aBitmap );
1501 aVD.DrawBitmap( Point( 0, 8 ), aBitmap );
1502 aVD.DrawBitmap( Point( 8, 8 ), aBitmap );
1503 aVD.DrawBitmap( Point( 16, 8 ), aBitmap );
1504 aVD.DrawBitmap( Point( 24, 8 ), aBitmap );
1508 /************************************************************************/
1510 void BitmapLB::Fill( const XBitmapList* pList )
1512 mpList = (XBitmapList*)pList;
1513 XBitmapEntry* pEntry;
1514 long nCount = pList->Count();
1516 SetUpdateMode( FALSE );
1518 if( mbUserDraw )
1520 for( long i = 0; i < nCount; i++ )
1521 InsertEntry( pList->GetBitmap( i )->GetName() );
1523 else
1525 for( long i = 0; i < nCount; i++ )
1527 pEntry = pList->GetBitmap( i );
1528 aBitmap = pEntry->GetXBitmap().GetBitmap();
1530 SetVirtualDevice();
1532 InsertEntry( pEntry->GetName(), aVD.GetBitmap( Point( 0, 2 ), Size( 32, 12 ) ) );
1536 SetUpdateMode( TRUE );
1539 void BitmapLB::UserDraw( const UserDrawEvent& rUDEvt )
1541 if( mpList != NULL )
1543 // Draw bitmap
1544 const Rectangle& rDrawRect = rUDEvt.GetRect();
1545 Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 );
1547 sal_Int32 nId = rUDEvt.GetItemId();
1548 if( nId >= 0 && nId <= mpList->Count() )
1550 Rectangle aClipRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nRight-1, rDrawRect.nBottom-1 );
1552 OutputDevice* pDevice = rUDEvt.GetDevice();
1553 pDevice->SetClipRegion( Region( aClipRect ) );
1555 aBitmap = mpList->GetBitmap( nId )->GetXBitmap().GetBitmap();
1557 long nPosBaseX = aRect.nLeft;
1558 long nPosBaseY = aRect.nTop;
1560 if( aBitmap.GetSizePixel().Width() > 8 ||
1561 aBitmap.GetSizePixel().Height() > 8 )
1563 pDevice->DrawBitmap( Point( nPosBaseX, nPosBaseY ), Size( 32, 16 ), aBitmap );
1565 else
1567 pDevice->DrawBitmap( Point( nPosBaseX+ 0, nPosBaseY+0 ), aBitmap );
1568 pDevice->DrawBitmap( Point( nPosBaseX+ 8, nPosBaseY+0 ), aBitmap );
1569 pDevice->DrawBitmap( Point( nPosBaseX+16, nPosBaseY+0 ), aBitmap );
1570 pDevice->DrawBitmap( Point( nPosBaseX+24, nPosBaseY+0 ), aBitmap );
1571 pDevice->DrawBitmap( Point( nPosBaseX+ 0, nPosBaseY+8 ), aBitmap );
1572 pDevice->DrawBitmap( Point( nPosBaseX+ 8, nPosBaseY+8 ), aBitmap );
1573 pDevice->DrawBitmap( Point( nPosBaseX+16, nPosBaseY+8 ), aBitmap );
1574 pDevice->DrawBitmap( Point( nPosBaseX+24, nPosBaseY+8 ), aBitmap );
1577 pDevice->SetClipRegion();
1579 // Draw name
1580 pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->GetBitmap( nId )->GetName() );
1585 /************************************************************************/
1587 void BitmapLB::Append( XBitmapEntry* pEntry, Bitmap* pBmp )
1589 if( pBmp )
1591 aBitmap = pEntry->GetXBitmap().GetBitmap();
1592 SetVirtualDevice();
1593 InsertEntry( pEntry->GetName(), aVD.GetBitmap( Point( 0, 2 ), Size( 32, 12 ) ) );
1595 else
1596 InsertEntry( pEntry->GetName() );
1599 /************************************************************************/
1601 void BitmapLB::Modify( XBitmapEntry* pEntry, USHORT nPos, Bitmap* pBmp )
1603 RemoveEntry( nPos );
1605 if( pBmp )
1607 aBitmap = pEntry->GetXBitmap().GetBitmap();
1608 SetVirtualDevice();
1610 InsertEntry( pEntry->GetName(), aVD.GetBitmap( Point( 0, 2 ), Size( 32, 12 ) ), nPos );
1612 else
1613 InsertEntry( pEntry->GetName() );
1616 /************************************************************************/
1618 void BitmapLB::SelectEntryByList( const XBitmapList* pList, const String& rStr,
1619 const Bitmap& )
1621 long nCount = pList->Count();
1622 XBitmapEntry* pEntry;
1623 BOOL bFound = FALSE;
1625 long i;
1626 for( i = 0; i < nCount && !bFound; i++ )
1628 pEntry = pList->GetBitmap( i );
1630 String aStr = pEntry->GetName();
1631 // Bitmap aBmp = pEntry->GetBitmap();
1633 if( rStr == aStr )
1635 bFound = TRUE;
1638 if( bFound )
1639 SelectEntryPos( (USHORT) ( i - 1 ) );
1642 /*************************************************************************
1644 |* Konstruktor von FillAttrLB
1646 \************************************************************************/
1648 FillAttrLB::FillAttrLB( Window* pParent, ResId Id ) :
1649 ColorListBox( pParent, Id )
1651 aVD.SetOutputSizePixel( Size( 32, 16 ) );
1654 /************************************************************************/
1656 FillAttrLB::FillAttrLB( Window* pParent, WinBits aWB ) :
1657 ColorListBox( pParent, aWB )
1659 aVD.SetOutputSizePixel( Size( 32, 16 ) );
1662 /************************************************************************/
1664 void FillAttrLB::SetVirtualDevice()
1666 if( aBitmap.GetSizePixel().Width() > 8 ||
1667 aBitmap.GetSizePixel().Height() > 8 )
1669 aVD.DrawBitmap( Point( 0, 0 ), Size( 32, 16 ), aBitmap );
1671 else
1673 aVD.DrawBitmap( Point( 0, 0 ), aBitmap );
1674 aVD.DrawBitmap( Point( 8, 0 ), aBitmap );
1675 aVD.DrawBitmap( Point( 16, 0 ), aBitmap );
1676 aVD.DrawBitmap( Point( 24, 0 ), aBitmap );
1677 aVD.DrawBitmap( Point( 0, 8 ), aBitmap );
1678 aVD.DrawBitmap( Point( 8, 8 ), aBitmap );
1679 aVD.DrawBitmap( Point( 16, 8 ), aBitmap );
1680 aVD.DrawBitmap( Point( 24, 8 ), aBitmap );
1684 /************************************************************************/
1686 void FillAttrLB::Fill( const XBitmapList* pList )
1688 long nCount = pList->Count();
1689 XBitmapEntry* pEntry;
1690 ListBox::SetUpdateMode( FALSE );
1692 for( long i = 0; i < nCount; i++ )
1694 pEntry = pList->GetBitmap( i );
1695 aBitmap = pEntry->GetXBitmap().GetBitmap();
1697 SetVirtualDevice();
1699 ListBox::InsertEntry( pEntry->GetName(), aVD.GetBitmap( Point( 0, 2 ), Size( 32, 12 ) ) );
1701 ListBox::SetUpdateMode( TRUE );
1704 /************************************************************************/
1706 void FillAttrLB::SelectEntryByList( const XBitmapList* pList, const String& rStr,
1707 const Bitmap& /*rBmp*/)
1709 long nCount = pList->Count();
1710 XBitmapEntry* pEntry;
1711 BOOL bFound = FALSE;
1713 long i;
1714 for( i = 0; i < nCount && !bFound; i++ )
1716 pEntry = pList->GetBitmap( i );
1718 String aStr = pEntry->GetName();
1719 // Bitmap aBmp = pEntry->GetBitmap();
1721 if( rStr == aStr )
1723 bFound = TRUE;
1726 if( rStr == aStr && rBmp == aBmp )
1727 bFound = TRUE; */
1729 if( bFound )
1730 SelectEntryPos( (USHORT) ( i - 1 ) );
1733 /*************************************************************************
1735 |* Fuellt die Listbox (vorlaeufig) mit Strings
1737 \************************************************************************/
1739 void FillTypeLB::Fill()
1741 SetUpdateMode( FALSE );
1742 InsertEntry( String( SVX_RES( RID_SVXSTR_INVISIBLE ) ) );
1743 InsertEntry( String( SVX_RES( RID_SVXSTR_COLOR ) ) );
1744 InsertEntry( String( SVX_RES( RID_SVXSTR_GRADIENT ) ) );
1745 InsertEntry( String( SVX_RES( RID_SVXSTR_HATCH ) ) );
1746 InsertEntry( String( SVX_RES( RID_SVXSTR_BITMAP ) ) );
1747 SetUpdateMode( TRUE );
1750 /*************************************************************************
1752 |* Fuellt die Listbox (vorlaeufig) mit Strings
1754 \************************************************************************/
1756 void LineLB::Fill( const XDashList* pList )
1758 long nCount = pList->Count();
1759 XDashEntry* pEntry;
1760 SetUpdateMode( FALSE );
1762 for( long i = 0; i < nCount; i++ )
1764 pEntry = pList->GetDash( i );
1765 Bitmap* pBitmap = const_cast<XDashList*>(pList)->CreateBitmapForUI( i );
1766 if( pBitmap )
1768 InsertEntry( pEntry->GetName(), *pBitmap );
1769 delete pBitmap;
1771 else
1772 InsertEntry( pEntry->GetName() );
1774 SetUpdateMode( TRUE );
1777 /************************************************************************/
1779 void LineLB::Append( XDashEntry* pEntry, Bitmap* pBmp )
1781 if( pBmp )
1782 InsertEntry( pEntry->GetName(), *pBmp );
1783 else
1784 InsertEntry( pEntry->GetName() );
1787 /************************************************************************/
1789 void LineLB::Modify( XDashEntry* pEntry, USHORT nPos, Bitmap* pBmp )
1791 RemoveEntry( nPos );
1793 if( pBmp )
1794 InsertEntry( pEntry->GetName(), *pBmp, nPos );
1795 else
1796 InsertEntry( pEntry->GetName(), nPos );
1799 /************************************************************************/
1801 void LineLB::SelectEntryByList( const XDashList* pList, const String& rStr,
1802 const XDash& rDash, USHORT nDist )
1804 long nCount = pList->Count();
1805 XDashEntry* pEntry;
1806 BOOL bFound = FALSE;
1807 String aStr;
1808 XDash aDash;
1810 long i;
1811 for( i = 0; i < nCount && !bFound; i++ )
1813 pEntry = pList->GetDash( i );
1815 aStr = pEntry->GetName();
1816 aDash = pEntry->GetDash();
1818 if( rStr == aStr && rDash == aDash )
1819 bFound = TRUE;
1821 if( bFound )
1822 SelectEntryPos( (USHORT) ( i - 1 + nDist ) );
1825 /*************************************************************************
1827 |* Fuellt die Listbox (vorlaeufig) mit Strings
1829 \************************************************************************/
1831 void LineEndLB::Fill( const XLineEndList* pList, BOOL bStart )
1833 long nCount = pList->Count();
1834 XLineEndEntry* pEntry;
1835 VirtualDevice aVD;
1836 SetUpdateMode( FALSE );
1838 for( long i = 0; i < nCount; i++ )
1840 pEntry = pList->GetLineEnd( i );
1841 Bitmap* pBitmap = const_cast<XLineEndList*>(pList)->CreateBitmapForUI( i );
1842 if( pBitmap )
1844 Size aBmpSize( pBitmap->GetSizePixel() );
1845 aVD.SetOutputSizePixel( aBmpSize, FALSE );
1846 aVD.DrawBitmap( Point(), *pBitmap );
1847 InsertEntry( pEntry->GetName(),
1848 aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
1849 Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) );
1851 delete pBitmap;
1853 else
1854 InsertEntry( pEntry->GetName() );
1856 SetUpdateMode( TRUE );
1859 /************************************************************************/
1861 void LineEndLB::Append( XLineEndEntry* pEntry, Bitmap* pBmp,
1862 BOOL bStart )
1864 if( pBmp )
1866 VirtualDevice aVD;
1867 Size aBmpSize( pBmp->GetSizePixel() );
1869 aVD.SetOutputSizePixel( aBmpSize, FALSE );
1870 aVD.DrawBitmap( Point(), *pBmp );
1871 InsertEntry( pEntry->GetName(),
1872 aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
1873 Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) );
1875 else
1876 InsertEntry( pEntry->GetName() );
1879 /************************************************************************/
1881 void LineEndLB::Modify( XLineEndEntry* pEntry, USHORT nPos, Bitmap* pBmp,
1882 BOOL bStart )
1884 RemoveEntry( nPos );
1886 if( pBmp )
1888 VirtualDevice aVD;
1889 Size aBmpSize( pBmp->GetSizePixel() );
1891 aVD.SetOutputSizePixel( aBmpSize, FALSE );
1892 aVD.DrawBitmap( Point(), *pBmp );
1893 InsertEntry( pEntry->GetName(),
1894 aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
1895 Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ), nPos );
1897 else
1898 InsertEntry( pEntry->GetName(), nPos );
1901 //////////////////////////////////////////////////////////////////////////////
1903 void SvxPreviewBase::InitSettings(bool bForeground, bool bBackground)
1905 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1907 if(bForeground)
1909 svtools::ColorConfig aColorConfig;
1910 Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
1912 if(IsControlForeground())
1914 aTextColor = GetControlForeground();
1917 getBufferDevice().SetTextColor(aTextColor);
1920 if(bBackground)
1922 if(IsControlBackground())
1924 getBufferDevice().SetBackground(GetControlBackground());
1926 else
1928 getBufferDevice().SetBackground(rStyleSettings.GetWindowColor());
1932 // do not paint background self, it gets painted buffered
1933 SetControlBackground();
1934 SetBackground();
1936 Invalidate();
1939 SvxPreviewBase::SvxPreviewBase( Window* pParent, const ResId& rResId )
1940 : Control( pParent, rResId ),
1941 mpModel( new SdrModel() ),
1942 mpBufferDevice( new VirtualDevice(*this) )
1944 // Draw the control's border as a flat thin black line.
1945 SetBorderStyle(WINDOW_BORDER_MONO);
1946 SetDrawMode( GetDisplayBackground().GetColor().IsDark() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
1947 SetMapMode(MAP_100TH_MM);
1949 // init model
1950 mpModel->GetItemPool().FreezeIdRanges();
1953 SvxPreviewBase::~SvxPreviewBase()
1955 delete mpModel;
1956 delete mpBufferDevice;
1959 void SvxPreviewBase::LocalPrePaint()
1961 // init BufferDevice
1962 if(mpBufferDevice->GetOutputSizePixel() != GetOutputSizePixel())
1964 mpBufferDevice->SetDrawMode(GetDrawMode());
1965 mpBufferDevice->SetSettings(GetSettings());
1966 mpBufferDevice->SetAntialiasing(GetAntialiasing());
1967 mpBufferDevice->SetOutputSizePixel(GetOutputSizePixel());
1968 mpBufferDevice->SetMapMode(GetMapMode());
1971 mpBufferDevice->Erase();
1974 void SvxPreviewBase::LocalPostPaint()
1976 // copy to front (in pixel mode)
1977 const bool bWasEnabledSrc(mpBufferDevice->IsMapModeEnabled());
1978 const bool bWasEnabledDst(IsMapModeEnabled());
1979 const Point aEmptyPoint;
1981 mpBufferDevice->EnableMapMode(false);
1982 EnableMapMode(false);
1984 DrawOutDev(
1985 aEmptyPoint, GetOutputSizePixel(),
1986 aEmptyPoint, GetOutputSizePixel(),
1987 *mpBufferDevice);
1989 mpBufferDevice->EnableMapMode(bWasEnabledSrc);
1990 EnableMapMode(bWasEnabledDst);
1993 void SvxPreviewBase::StateChanged(StateChangedType nType)
1995 Control::StateChanged(nType);
1997 if(STATE_CHANGE_CONTROLFOREGROUND == nType)
1999 InitSettings(true, false);
2001 else if(STATE_CHANGE_CONTROLBACKGROUND == nType)
2003 InitSettings(false, true);
2007 void SvxPreviewBase::DataChanged(const DataChangedEvent& rDCEvt)
2009 SetDrawMode(GetDisplayBackground().GetColor().IsDark() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR);
2011 if((DATACHANGED_SETTINGS == rDCEvt.GetType()) && (rDCEvt.GetFlags() & SETTINGS_STYLE))
2013 InitSettings(true, true);
2015 else
2017 Control::DataChanged(rDCEvt);
2021 /*************************************************************************
2023 |* SvxXLinePreview::SvxXLinePreview()
2025 *************************************************************************/
2027 SvxXLinePreview::SvxXLinePreview( Window* pParent, const ResId& rResId )
2028 : SvxPreviewBase( pParent, rResId ),
2029 mpLineObjA( 0L ),
2030 mpLineObjB( 0L ),
2031 mpLineObjC( 0L ),
2032 mpGraphic( 0L ),
2033 mbWithSymbol( sal_False )
2035 const Size aOutputSize(GetOutputSize());
2036 InitSettings( TRUE, TRUE );
2038 const sal_Int32 nDistance(500L);
2039 const sal_Int32 nAvailableLength(aOutputSize.Width() - (4 * nDistance));
2041 // create DrawObectA
2042 const sal_Int32 aYPosA(aOutputSize.Height() / 2);
2043 const basegfx::B2DPoint aPointA1( nDistance, aYPosA);
2044 const basegfx::B2DPoint aPointA2( aPointA1.getX() + ((nAvailableLength * 14) / 20), aYPosA );
2045 basegfx::B2DPolygon aPolygonA;
2046 aPolygonA.append(aPointA1);
2047 aPolygonA.append(aPointA2);
2048 mpLineObjA = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygonA));
2049 mpLineObjA->SetModel(&getModel());
2051 // create DrawObectB
2052 const sal_Int32 aYPosB1((aOutputSize.Height() * 3) / 4);
2053 const sal_Int32 aYPosB2((aOutputSize.Height() * 1) / 4);
2054 const basegfx::B2DPoint aPointB1( aPointA2.getX() + nDistance, aYPosB1);
2055 const basegfx::B2DPoint aPointB2( aPointB1.getX() + ((nAvailableLength * 2) / 20), aYPosB2 );
2056 const basegfx::B2DPoint aPointB3( aPointB2.getX() + ((nAvailableLength * 2) / 20), aYPosB1 );
2057 basegfx::B2DPolygon aPolygonB;
2058 aPolygonB.append(aPointB1);
2059 aPolygonB.append(aPointB2);
2060 aPolygonB.append(aPointB3);
2061 mpLineObjB = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonB));
2062 mpLineObjB->SetModel(&getModel());
2064 // create DrawObectC
2065 const basegfx::B2DPoint aPointC1( aPointB3.getX() + nDistance, aYPosB1);
2066 const basegfx::B2DPoint aPointC2( aPointC1.getX() + ((nAvailableLength * 1) / 20), aYPosB2 );
2067 const basegfx::B2DPoint aPointC3( aPointC2.getX() + ((nAvailableLength * 1) / 20), aYPosB1 );
2068 basegfx::B2DPolygon aPolygonC;
2069 aPolygonC.append(aPointC1);
2070 aPolygonC.append(aPointC2);
2071 aPolygonC.append(aPointC3);
2072 mpLineObjC = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonC));
2073 mpLineObjC->SetModel(&getModel());
2076 SvxXLinePreview::~SvxXLinePreview()
2078 SdrObject::Free( mpLineObjA );
2079 SdrObject::Free( mpLineObjB );
2080 SdrObject::Free( mpLineObjC );
2083 // -----------------------------------------------------------------------
2085 void SvxXLinePreview::SetSymbol(Graphic* p,const Size& s)
2087 mpGraphic = p;
2088 maSymbolSize = s;
2091 // -----------------------------------------------------------------------
2093 void SvxXLinePreview::ResizeSymbol(const Size& s)
2095 if ( s != maSymbolSize )
2097 maSymbolSize = s;
2098 Invalidate();
2102 // -----------------------------------------------------------------------
2104 void SvxXLinePreview::SetLineAttributes(const SfxItemSet& rItemSet)
2106 // Set ItemSet at objects
2107 mpLineObjA->SetMergedItemSet(rItemSet);
2109 // At line joints, do not use arrows
2110 SfxItemSet aTempSet(rItemSet);
2111 aTempSet.ClearItem(XATTR_LINESTART);
2112 aTempSet.ClearItem(XATTR_LINEEND);
2114 mpLineObjB->SetMergedItemSet(aTempSet);
2115 mpLineObjC->SetMergedItemSet(aTempSet);
2118 // -----------------------------------------------------------------------
2120 void SvxXLinePreview::Paint( const Rectangle& )
2122 LocalPrePaint();
2124 // paint objects to buffer device
2125 sdr::contact::SdrObjectVector aObjectVector;
2126 aObjectVector.push_back(mpLineObjA);
2127 aObjectVector.push_back(mpLineObjB);
2128 aObjectVector.push_back(mpLineObjC);
2130 sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
2131 sdr::contact::DisplayInfo aDisplayInfo;
2133 // do processing
2134 aPainter.ProcessDisplay(aDisplayInfo);
2136 if ( mbWithSymbol && mpGraphic )
2138 const Size aOutputSize(GetOutputSize());
2139 Point aPos = Point( aOutputSize.Width() / 3, aOutputSize.Height() / 2 );
2140 aPos.X() -= maSymbolSize.Width() / 2;
2141 aPos.Y() -= maSymbolSize.Height() / 2;
2142 mpGraphic->Draw( &getBufferDevice(), aPos, maSymbolSize );
2145 LocalPostPaint();
2148 /*************************************************************************
2150 |* SvxXRectPreview::SvxXRectPreview()
2152 *************************************************************************/
2154 SvxXRectPreview::SvxXRectPreview( Window* pParent, const ResId& rResId )
2155 : SvxPreviewBase( pParent, rResId ),
2156 mpRectangleObject(0)
2158 InitSettings(true, true);
2160 // create RectangleObject
2161 const Rectangle aObjectSize(Point(), GetOutputSize());
2162 mpRectangleObject = new SdrRectObj(aObjectSize);
2163 mpRectangleObject->SetModel(&getModel());
2166 SvxXRectPreview::~SvxXRectPreview()
2168 SdrObject::Free(mpRectangleObject);
2171 void SvxXRectPreview::SetAttributes(const SfxItemSet& rItemSet)
2173 mpRectangleObject->SetMergedItemSet(rItemSet, true);
2174 mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
2177 void SvxXRectPreview::Paint( const Rectangle& )
2179 LocalPrePaint();
2181 sdr::contact::SdrObjectVector aObjectVector;
2183 aObjectVector.push_back(mpRectangleObject);
2185 sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
2186 sdr::contact::DisplayInfo aDisplayInfo;
2188 aPainter.ProcessDisplay(aDisplayInfo);
2190 LocalPostPaint();
2193 /*************************************************************************
2195 |* SvxXShadowPreview::SvxXShadowPreview()
2197 *************************************************************************/
2199 SvxXShadowPreview::SvxXShadowPreview( Window* pParent, const ResId& rResId )
2200 : SvxPreviewBase( pParent, rResId ),
2201 mpRectangleObject(0),
2202 mpRectangleShadow(0)
2204 InitSettings(true, true);
2206 // prepare size
2207 Size aSize = GetOutputSize();
2208 aSize.Width() = aSize.Width() / 3;
2209 aSize.Height() = aSize.Height() / 3;
2211 // create RectangleObject
2212 const Rectangle aObjectSize( Point( aSize.Width(), aSize.Height() ), aSize );
2213 mpRectangleObject = new SdrRectObj(aObjectSize);
2214 mpRectangleObject->SetModel(&getModel());
2216 // create ShadowObject
2217 const Rectangle aShadowSize( Point( aSize.Width(), aSize.Height() ), aSize );
2218 mpRectangleShadow = new SdrRectObj(aShadowSize);
2219 mpRectangleShadow->SetModel(&getModel());
2222 SvxXShadowPreview::~SvxXShadowPreview()
2224 SdrObject::Free(mpRectangleObject);
2225 SdrObject::Free(mpRectangleShadow);
2228 void SvxXShadowPreview::SetRectangleAttributes(const SfxItemSet& rItemSet)
2230 mpRectangleObject->SetMergedItemSet(rItemSet, true);
2231 mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
2234 void SvxXShadowPreview::SetShadowAttributes(const SfxItemSet& rItemSet)
2236 mpRectangleShadow->SetMergedItemSet(rItemSet, true);
2237 mpRectangleShadow->SetMergedItem(XLineStyleItem(XLINE_NONE));
2240 void SvxXShadowPreview::SetShadowPosition(const Point& rPos)
2242 Rectangle aObjectPosition(mpRectangleObject->GetSnapRect());
2243 aObjectPosition.Move(rPos.X(), rPos.Y());
2244 mpRectangleShadow->SetSnapRect(aObjectPosition);
2247 void SvxXShadowPreview::Paint( const Rectangle& )
2249 LocalPrePaint();
2251 sdr::contact::SdrObjectVector aObjectVector;
2253 aObjectVector.push_back(mpRectangleShadow);
2254 aObjectVector.push_back(mpRectangleObject);
2256 sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
2257 sdr::contact::DisplayInfo aDisplayInfo;
2259 aPainter.ProcessDisplay(aDisplayInfo);
2261 LocalPostPaint();
2264 // -----------------------------------------------------------------------
2265 // eof