1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/shl.hxx>
21 #include <vcl/builder.hxx>
22 #include <vcl/svapp.hxx>
24 #include <svx/xtable.hxx>
25 #include <svx/xpool.hxx>
26 #include <svx/dialogs.hrc>
27 #include <accessibility.hrc>
28 #include <svx/dlgctrl.hxx>
29 #include <svx/dialmgr.hxx>
30 #include <tools/poly.hxx>
31 #include <vcl/region.hxx>
32 #include <vcl/gradient.hxx>
33 #include <vcl/hatch.hxx>
34 #include <svtools/colorcfg.hxx>
35 #include <svxrectctaccessiblecontext.hxx>
36 #include <com/sun/star/lang/XUnoTunnel.hpp>
37 #include <basegfx/point/b2dpoint.hxx>
38 #include <basegfx/polygon/b2dpolygon.hxx>
39 #include <svx/svdorect.hxx>
40 #include <svx/svdmodel.hxx>
41 #include <svx/svdopath.hxx>
42 #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
43 #include <svx/sdr/contact/displayinfo.hxx>
44 #include <vcl/bmpacc.hxx>
45 #include <svx/xbtmpit.hxx>
47 #define OUTPUT_DRAWMODE_COLOR (DRAWMODE_DEFAULT)
48 #define OUTPUT_DRAWMODE_CONTRAST (DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT)
50 using namespace ::com::sun::star::uno
;
51 using namespace ::com::sun::star::lang
;
52 using namespace ::com::sun::star::accessibility
;
54 // Control for display and selection of the corner points and
55 // mid point of an object
57 Bitmap
& SvxRectCtl::GetRectBitmap( void )
65 SvxRectCtl::SvxRectCtl( Window
* pParent
, const ResId
& rResId
, RECT_POINT eRpt
,
66 sal_uInt16 nBorder
, sal_uInt16 nCircle
, CTL_STYLE eStyle
) :
68 Control( pParent
, rResId
),
71 nBorderWidth( nBorder
),
77 mbCompleteDisable(sal_False
)
79 SetMapMode( MAP_100TH_MM
);
83 SvxRectCtl::SvxRectCtl(Window
* pParent
, RECT_POINT eRpt
,
84 sal_uInt16 nBorder
, sal_uInt16 nCircle
, CTL_STYLE eStyle
)
85 : Control(pParent
, WB_BORDER
| WB_TABSTOP
)
87 , nBorderWidth(nBorder
)
93 , mbCompleteDisable(false)
95 SetMapMode(MAP_100TH_MM
);
100 extern "C" SAL_DLLPUBLIC_EXPORT Window
* SAL_CALL
makeSvxRectCtl(Window
*pParent
, VclBuilder::stringmap
&)
102 return new SvxRectCtl(pParent
);
105 // -----------------------------------------------------------------------
107 SvxRectCtl::~SvxRectCtl()
112 pAccContext
->release();
115 // -----------------------------------------------------------------------
116 void SvxRectCtl::Resize()
122 // -----------------------------------------------------------------------
124 void SvxRectCtl::Resize_Impl()
126 aSize
= GetOutputSize();
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
);
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
);
161 InitSettings( sal_True
, sal_True
);
163 // -----------------------------------------------------------------------
165 void SvxRectCtl::InitRectBitmap( void )
169 const StyleSettings
& rStyles
= Application::GetSettings().GetStyleSettings();
170 svtools::ColorConfig aColorConfig
;
172 pBitmap
= new Bitmap( SVX_RES( RID_SVXCTRL_RECTBTNS
) );
177 aColorAry1
[0] = Color( 0xC0, 0xC0, 0xC0 ); // light-gray
178 aColorAry1
[1] = Color( 0xFF, 0xFF, 0x00 ); // yellow
179 aColorAry1
[2] = Color( 0xFF, 0xFF, 0xFF ); // white
180 aColorAry1
[3] = Color( 0x80, 0x80, 0x80 ); // dark-gray
181 aColorAry1
[4] = Color( 0x00, 0x00, 0x00 ); // black
182 aColorAry1
[5] = Color( 0x00, 0xFF, 0x00 ); // green
183 aColorAry1
[6] = Color( 0x00, 0x00, 0xFF ); // blue
184 aColorAry2
[0] = rStyles
.GetDialogColor(); // background
185 aColorAry2
[1] = rStyles
.GetWindowColor();
186 aColorAry2
[2] = rStyles
.GetLightColor();
187 aColorAry2
[3] = rStyles
.GetShadowColor();
188 aColorAry2
[4] = rStyles
.GetDarkShadowColor();
189 aColorAry2
[5] = Color( aColorConfig
.GetColorValue( svtools::FONTCOLOR
).nColor
);
190 aColorAry2
[6] = rStyles
.GetDialogColor();
193 static sal_Bool bModify
= sal_False
;
194 sal_Bool
& rModify
= bModify
;
198 static sal_uInt8 r
= 0xFF;
199 static sal_uInt8 g
= 0x00;
200 static sal_uInt8 b
= 0xFF;
205 aColorAry2
[ rn
] = Color( rr
, rg
, rb
);
209 pBitmap
->Replace( aColorAry1
, aColorAry2
, 7, NULL
);
212 // -----------------------------------------------------------------------
214 void SvxRectCtl::InitSettings( sal_Bool bForeground
, sal_Bool bBackground
)
216 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
220 svtools::ColorConfig aColorConfig
;
221 Color
aTextColor( aColorConfig
.GetColorValue( svtools::FONTCOLOR
).nColor
);
223 if ( IsControlForeground() )
224 aTextColor
= GetControlForeground();
225 SetTextColor( aTextColor
);
230 if ( IsControlBackground() )
231 SetBackground( GetControlBackground() );
233 SetBackground( rStyleSettings
.GetWindowColor() );
237 pBitmap
= NULL
; // forces new creating of bitmap
242 // The clicked rectangle (3 x 3) is determined and the parent (dialog)
243 // is notified that the item was changed
244 void SvxRectCtl::MouseButtonDown( const MouseEvent
& rMEvt
)
246 // CompletelyDisabled() added to have a disabled state for SvxRectCtl
247 if(!IsCompletelyDisabled())
249 Point aPtLast
= aPtNew
;
251 aPtNew
= GetApproxLogPtFromPixPt( rMEvt
.GetPosPixel() );
253 if( aPtNew
== aPtMM
&& ( eCS
== CS_SHADOW
|| eCS
== CS_ANGLE
) )
259 Invalidate( Rectangle( aPtLast
- Point( nRadius
, nRadius
),
260 aPtLast
+ Point( nRadius
, nRadius
) ) );
261 Invalidate( Rectangle( aPtNew
- Point( nRadius
, nRadius
),
262 aPtNew
+ Point( nRadius
, nRadius
) ) );
263 eRP
= GetRPFromPoint( aPtNew
);
267 if( WINDOW_TABPAGE
== GetParent()->GetType() )
268 ( (SvxTabPage
*) GetParent() )->PointChanged( this, eRP
);
273 // -----------------------------------------------------------------------
275 void SvxRectCtl::KeyInput( const KeyEvent
& rKeyEvt
)
277 // CompletelyDisabled() added to have a disabled state for SvxRectCtl
278 if(!IsCompletelyDisabled())
280 RECT_POINT eNewRP
= eRP
;
281 bool bUseMM
= (eCS
!= CS_SHADOW
) && (eCS
!= CS_ANGLE
);
283 switch( rKeyEvt
.GetKeyCode().GetCode() )
287 if( !(m_nState
& CS_NOVERT
) )
290 case RP_LT
: eNewRP
= RP_LM
; break;
291 case RP_MT
: eNewRP
= bUseMM
? RP_MM
: RP_MB
; break;
292 case RP_RT
: eNewRP
= RP_RM
; break;
293 case RP_LM
: eNewRP
= RP_LB
; break;
294 case RP_MM
: eNewRP
= RP_MB
; break;
295 case RP_RM
: eNewRP
= RP_RB
; break;
296 default: ; //prevent warning
302 if( !(m_nState
& CS_NOVERT
) )
305 case RP_LM
: eNewRP
= RP_LT
; break;
306 case RP_MM
: eNewRP
= RP_MT
; break;
307 case RP_RM
: eNewRP
= RP_RT
; break;
308 case RP_LB
: eNewRP
= RP_LM
; break;
309 case RP_MB
: eNewRP
= bUseMM
? RP_MM
: RP_MT
; break;
310 case RP_RB
: eNewRP
= RP_RM
; break;
311 default: ; //prevent warning
317 if( !(m_nState
& CS_NOHORZ
) )
320 case RP_MT
: eNewRP
= RP_LT
; break;
321 case RP_RT
: eNewRP
= RP_MT
; break;
322 case RP_MM
: eNewRP
= RP_LM
; break;
323 case RP_RM
: eNewRP
= bUseMM
? RP_MM
: RP_LM
; break;
324 case RP_MB
: eNewRP
= RP_LB
; break;
325 case RP_RB
: eNewRP
= RP_MB
; break;
326 default: ; //prevent warning
332 if( !(m_nState
& CS_NOHORZ
) )
335 case RP_LT
: eNewRP
= RP_MT
; break;
336 case RP_MT
: eNewRP
= RP_RT
; break;
337 case RP_LM
: eNewRP
= bUseMM
? RP_MM
: RP_RM
; break;
338 case RP_MM
: eNewRP
= RP_RM
; break;
339 case RP_LB
: eNewRP
= RP_MB
; break;
340 case RP_MB
: eNewRP
= RP_RB
; break;
341 default: ; //prevent warning
346 Control::KeyInput( rKeyEvt
);
351 SetActualRP( eNewRP
);
353 if( WINDOW_TABPAGE
== GetParent()->GetType() )
354 ( (SvxTabPage
*) GetParent() )->PointChanged( this, eRP
);
361 // -----------------------------------------------------------------------
363 void SvxRectCtl::StateChanged( StateChangedType nType
)
365 if ( nType
== STATE_CHANGE_CONTROLFOREGROUND
)
366 InitSettings( sal_True
, sal_False
);
367 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
368 InitSettings( sal_False
, sal_True
);
370 Window::StateChanged( nType
);
373 // -----------------------------------------------------------------------
375 void SvxRectCtl::DataChanged( const DataChangedEvent
& rDCEvt
)
377 if ( ( rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && ( rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
378 InitSettings( sal_True
, sal_True
);
380 Window::DataChanged( rDCEvt
);
383 // the control (rectangle with 9 circles)
385 void SvxRectCtl::Paint( const Rectangle
& )
387 Point
aPtDiff( PixelToLogic( Point( 1, 1 ) ) );
389 const StyleSettings
& rStyles
= Application::GetSettings().GetStyleSettings();
391 SetLineColor( rStyles
.GetDialogColor() );
392 SetFillColor( rStyles
.GetDialogColor() );
393 DrawRect( Rectangle( Point(0,0), GetOutputSize() ) );
396 SetLineColor( rStyles
.GetLabelTextColor() );
398 SetLineColor( rStyles
.GetShadowColor() );
409 Color aOldCol
= GetLineColor();
410 SetLineColor( rStyles
.GetLightColor() );
411 DrawRect( Rectangle( aPtLT
+ aPtDiff
, aPtRB
+ aPtDiff
) );
412 SetLineColor( aOldCol
);
414 DrawRect( Rectangle( aPtLT
, aPtRB
) );
420 Color aOldCol
= GetLineColor();
421 SetLineColor( rStyles
.GetLightColor() );
422 DrawLine( aPtLM
- Point( 2 * nBorderWidth
, 0) + aPtDiff
,
423 aPtRM
+ Point( 2 * nBorderWidth
, 0 ) + aPtDiff
);
424 SetLineColor( aOldCol
);
426 DrawLine( aPtLM
- Point( 2 * nBorderWidth
, 0),
427 aPtRM
+ Point( 2 * nBorderWidth
, 0 ) );
433 Color aOldCol
= GetLineColor();
434 SetLineColor( rStyles
.GetLightColor() );
435 DrawLine( aPtLT
+ aPtDiff
, aPtRB
+ aPtDiff
);
436 DrawLine( aPtLB
+ aPtDiff
, aPtRT
+ aPtDiff
);
437 DrawLine( aPtLM
+ aPtDiff
, aPtRM
+ aPtDiff
);
438 DrawLine( aPtMT
+ aPtDiff
, aPtMB
+ aPtDiff
);
439 SetLineColor( aOldCol
);
441 DrawLine( aPtLT
, aPtRB
);
442 DrawLine( aPtLB
, aPtRT
);
443 DrawLine( aPtLM
, aPtRM
);
444 DrawLine( aPtMT
, aPtMB
);
450 SetFillColor( GetBackground().GetColor() );
452 Size
aBtnSize( 11, 11 );
453 Size
aDstBtnSize( PixelToLogic( aBtnSize
) );
454 Point
aToCenter( aDstBtnSize
.Width() >> 1, aDstBtnSize
.Height() >> 1);
455 Point
aBtnPnt1( IsEnabled()?0:22,0 );
456 Point
aBtnPnt2( 11,0 );
457 Point
aBtnPnt3( 22,0 );
459 bool bNoHorz
= (m_nState
& CS_NOHORZ
) != 0;
460 bool bNoVert
= (m_nState
& CS_NOVERT
) != 0;
462 Bitmap
& rBitmap
= GetRectBitmap();
464 // CompletelyDisabled() added to have a disabled state for SvxRectCtl
465 if(IsCompletelyDisabled())
467 DrawBitmap( aPtLT
- aToCenter
, aDstBtnSize
, aBtnPnt3
, aBtnSize
, rBitmap
);
468 DrawBitmap( aPtMT
- aToCenter
, aDstBtnSize
, aBtnPnt3
, aBtnSize
, rBitmap
);
469 DrawBitmap( aPtRT
- aToCenter
, aDstBtnSize
, aBtnPnt3
, aBtnSize
, rBitmap
);
470 DrawBitmap( aPtLM
- aToCenter
, aDstBtnSize
, aBtnPnt3
, aBtnSize
, rBitmap
);
471 if( eCS
== CS_RECT
|| eCS
== CS_LINE
)
472 DrawBitmap( aPtMM
- aToCenter
, aDstBtnSize
, aBtnPnt3
, aBtnSize
, rBitmap
);
473 DrawBitmap( aPtRM
- aToCenter
, aDstBtnSize
, aBtnPnt3
, aBtnSize
, rBitmap
);
474 DrawBitmap( aPtLB
- aToCenter
, aDstBtnSize
, aBtnPnt3
, aBtnSize
, rBitmap
);
475 DrawBitmap( aPtMB
- aToCenter
, aDstBtnSize
, aBtnPnt3
, aBtnSize
, rBitmap
);
476 DrawBitmap( aPtRB
- aToCenter
, aDstBtnSize
, aBtnPnt3
, aBtnSize
, rBitmap
);
480 DrawBitmap( aPtLT
- aToCenter
, aDstBtnSize
, (bNoHorz
|| bNoVert
)?aBtnPnt3
:aBtnPnt1
, aBtnSize
, rBitmap
);
481 DrawBitmap( aPtMT
- aToCenter
, aDstBtnSize
, bNoVert
?aBtnPnt3
:aBtnPnt1
, aBtnSize
, rBitmap
);
482 DrawBitmap( aPtRT
- aToCenter
, aDstBtnSize
, (bNoHorz
|| bNoVert
)?aBtnPnt3
:aBtnPnt1
, aBtnSize
, rBitmap
);
484 DrawBitmap( aPtLM
- aToCenter
, aDstBtnSize
, bNoHorz
?aBtnPnt3
:aBtnPnt1
, aBtnSize
, rBitmap
);
486 // Center for rectangle and line
487 if( eCS
== CS_RECT
|| eCS
== CS_LINE
)
488 DrawBitmap( aPtMM
- aToCenter
, aDstBtnSize
, aBtnPnt1
, aBtnSize
, rBitmap
);
490 DrawBitmap( aPtRM
- aToCenter
, aDstBtnSize
, bNoHorz
?aBtnPnt3
:aBtnPnt1
, aBtnSize
, rBitmap
);
492 DrawBitmap( aPtLB
- aToCenter
, aDstBtnSize
, (bNoHorz
|| bNoVert
)?aBtnPnt3
:aBtnPnt1
, aBtnSize
, rBitmap
);
493 DrawBitmap( aPtMB
- aToCenter
, aDstBtnSize
, bNoVert
?aBtnPnt3
:aBtnPnt1
, aBtnSize
, rBitmap
);
494 DrawBitmap( aPtRB
- aToCenter
, aDstBtnSize
, (bNoHorz
|| bNoVert
)?aBtnPnt3
:aBtnPnt1
, aBtnSize
, rBitmap
);
497 // draw active button, avoid center pos for angle
498 // CompletelyDisabled() added to have a disabled state for SvxRectCtl
499 if(!IsCompletelyDisabled())
501 if( IsEnabled() && (eCS
!= CS_ANGLE
|| aPtNew
!= aPtMM
) )
503 Point
aCenterPt( aPtNew
);
504 aCenterPt
-= aToCenter
;
506 DrawBitmap( aCenterPt
, aDstBtnSize
, aBtnPnt2
, aBtnSize
, rBitmap
);
511 // Convert RECT_POINT Point
513 Point
SvxRectCtl::GetPointFromRP( RECT_POINT _eRP
) const
517 case RP_LT
: return aPtLT
;
518 case RP_MT
: return aPtMT
;
519 case RP_RT
: return aPtRT
;
520 case RP_LM
: return aPtLM
;
521 case RP_MM
: return aPtMM
;
522 case RP_RM
: return aPtRM
;
523 case RP_LB
: return aPtLB
;
524 case RP_MB
: return aPtMB
;
525 case RP_RB
: return aPtRB
;
527 return( aPtMM
); // default
531 void SvxRectCtl::SetFocusRect( const Rectangle
* pRect
)
538 ShowFocus( CalculateFocusRectangle() );
541 Point
SvxRectCtl::SetActualRPWithoutInvalidate( RECT_POINT eNewRP
)
543 Point aPtLast
= aPtNew
;
544 aPtNew
= GetPointFromRP( eNewRP
);
546 if( (m_nState
& CS_NOHORZ
) != 0 )
547 aPtNew
.X() = aPtMM
.X();
549 if( (m_nState
& CS_NOVERT
) != 0 )
550 aPtNew
.Y() = aPtMM
.Y();
552 eNewRP
= GetRPFromPoint( aPtNew
);
560 void SvxRectCtl::GetFocus()
566 void SvxRectCtl::LoseFocus()
572 Point
SvxRectCtl::GetApproxLogPtFromPixPt( const Point
& rPt
) const
574 Point aPt
= PixelToLogic( rPt
);
578 if( ( m_nState
& CS_NOHORZ
) == 0 )
580 if( aPt
.X() < aSize
.Width() / 3 )
582 else if( aPt
.X() < aSize
.Width() * 2 / 3 )
590 if( ( m_nState
& CS_NOVERT
) == 0 )
592 if( aPt
.Y() < aSize
.Height() / 3 )
594 else if( aPt
.Y() < aSize
.Height() * 2 / 3 )
602 return Point( x
, y
);
606 // Converts Point in RECT_POINT
608 RECT_POINT
SvxRectCtl::GetRPFromPoint( Point aPt
) const
610 if ( aPt
== aPtLT
) return RP_LT
;
611 else if( aPt
== aPtMT
) return RP_MT
;
612 else if( aPt
== aPtRT
) return RP_RT
;
613 else if( aPt
== aPtLM
) return RP_LM
;
614 else if( aPt
== aPtRM
) return RP_RM
;
615 else if( aPt
== aPtLB
) return RP_LB
;
616 else if( aPt
== aPtMB
) return RP_MB
;
617 else if( aPt
== aPtRB
) return RP_RB
;
620 return RP_MM
; // default
623 // Resets to the original state of the control
625 void SvxRectCtl::Reset()
627 aPtNew
= GetPointFromRP( eDefRP
);
632 // Returns the currently selected RECT_POINT
634 RECT_POINT
SvxRectCtl::GetActualRP() const
639 void SvxRectCtl::SetActualRP( RECT_POINT eNewRP
)
641 Point
aPtLast( SetActualRPWithoutInvalidate( eNewRP
) );
643 Invalidate( Rectangle( aPtLast
- Point( nRadius
, nRadius
), aPtLast
+ Point( nRadius
, nRadius
) ) );
644 Invalidate( Rectangle( aPtNew
- Point( nRadius
, nRadius
), aPtNew
+ Point( nRadius
, nRadius
) ) );
646 // notify accessibility object about change
648 pAccContext
->selectChild( eNewRP
);
651 void SvxRectCtl::SetState( CTL_STATE nState
)
655 Point
aPtLast( GetPointFromRP( eRP
) );
656 Point
_aPtNew( aPtLast
);
658 if( (m_nState
& CS_NOHORZ
) != 0 )
659 _aPtNew
.X() = aPtMM
.X();
661 if( (m_nState
& CS_NOVERT
) != 0 )
662 _aPtNew
.Y() = aPtMM
.Y();
664 eRP
= GetRPFromPoint( _aPtNew
);
667 if( WINDOW_TABPAGE
== GetParent()->GetType() )
668 ( (SvxTabPage
*) GetParent() )->PointChanged( this, eRP
);
671 sal_uInt8
SvxRectCtl::GetNumOfChildren( void ) const
673 return ( eCS
== CS_ANGLE
)? 8 : 9;
676 Rectangle
SvxRectCtl::CalculateFocusRectangle( void ) const
678 Size
aDstBtnSize( PixelToLogic( Size( 15, 15 ) ) );
679 return Rectangle( aPtNew
- Point( aDstBtnSize
.Width() >> 1, aDstBtnSize
.Height() >> 1 ), aDstBtnSize
);
682 Rectangle
SvxRectCtl::CalculateFocusRectangle( RECT_POINT eRectPoint
) const
685 RECT_POINT eOldRectPoint
= GetActualRP();
687 if( eOldRectPoint
== eRectPoint
)
688 aRet
= CalculateFocusRectangle();
691 SvxRectCtl
* pThis
= const_cast< SvxRectCtl
* >( this );
693 pThis
->SetActualRPWithoutInvalidate( eRectPoint
); // no invalidation because it's only temporary!
694 aRet
= CalculateFocusRectangle();
696 pThis
->SetActualRPWithoutInvalidate( eOldRectPoint
); // no invalidation because nothing has changed!
702 Reference
< XAccessible
> SvxRectCtl::CreateAccessible()
704 Window
* pParent
= GetAccessibleParentWindow();
706 DBG_ASSERT( pParent
, "-SvxRectCtl::CreateAccessible(): No Parent!" );
708 Reference
< XAccessible
> xAccParent
= pParent
->GetAccessible();
709 if( xAccParent
.is() )
711 pAccContext
= new SvxRectCtlAccessibleContext( xAccParent
, *this );
712 pAccContext
->acquire();
714 SetActualRP( GetActualRP() );
719 return Reference
< XAccessible
>();
722 RECT_POINT
SvxRectCtl::GetApproxRPFromPixPt( const ::com::sun::star::awt::Point
& r
) const
724 return GetRPFromPoint( GetApproxLogPtFromPixPt( Point( r
.X
, r
.Y
) ) );
727 // CompletelyDisabled() added to have a disabled state for SvxRectCtl
728 void SvxRectCtl::DoCompletelyDisable(sal_Bool bNew
)
730 mbCompleteDisable
= bNew
;
734 // Control for editing bitmaps
736 SvxPixelCtl::SvxPixelCtl( Window
* pParent
, const ResId
& rResId
, sal_uInt16 nNumber
) :
737 Control ( pParent
, rResId
),
739 bPaintable ( sal_True
)
741 aRectSize
= GetOutputSize();
743 SetPixelColor( Color( COL_BLACK
) );
744 SetBackgroundColor( Color( COL_WHITE
) );
745 SetLineColor( Application::GetSettings().GetStyleSettings().GetShadowColor() );
747 nSquares
= nLines
* nLines
;
748 pPixel
= new sal_uInt16
[ nSquares
];
749 memset(pPixel
, 0, nSquares
* sizeof(sal_uInt16
));
752 // Destructor dealocating the dynamic array
754 SvxPixelCtl::~SvxPixelCtl( )
759 // Changes the foreground or Background color
761 void SvxPixelCtl::ChangePixel( sal_uInt16 nPixel
)
763 if( *( pPixel
+ nPixel
) == 0 )
764 *( pPixel
+ nPixel
) = 1; // could be extended to more colors
766 *( pPixel
+ nPixel
) = 0;
769 // The clicked rectangle is identified, to change its color
771 void SvxPixelCtl::MouseButtonDown( const MouseEvent
& rMEvt
)
773 Point aPt
= PixelToLogic( rMEvt
.GetPosPixel() );
777 nX
= (sal_uInt16
) ( aPt
.X() * nLines
/ aRectSize
.Width() );
778 nY
= (sal_uInt16
) ( aPt
.Y() * nLines
/ aRectSize
.Height() );
780 ChangePixel( nX
+ nY
* nLines
);
782 aPtTl
.X() = aRectSize
.Width() * nX
/ nLines
+ 1;
783 aPtBr
.X() = aRectSize
.Width() * (nX
+ 1) / nLines
- 1;
784 aPtTl
.Y() = aRectSize
.Height() * nY
/ nLines
+ 1;
785 aPtBr
.Y() = aRectSize
.Height() * (nY
+ 1) / nLines
- 1;
787 Invalidate( Rectangle( aPtTl
, aPtBr
) );
789 if( WINDOW_TABPAGE
== GetParent()->GetType() )
790 ( (SvxTabPage
*) GetParent() )->PointChanged( this, RP_MM
); // RectPoint is a dummy
793 // Draws the Control (Rectangle with nine circles)
795 void SvxPixelCtl::Paint( const Rectangle
& )
797 sal_uInt16 i
, j
, nTmp
;
803 Control::SetLineColor( aLineColor
);
804 for( i
= 1; i
< nLines
; i
++)
807 nTmp
= (sal_uInt16
) ( aRectSize
.Height() * i
/ nLines
);
808 DrawLine( Point( 0, nTmp
), Point( aRectSize
.Width(), nTmp
) );
810 nTmp
= (sal_uInt16
) ( aRectSize
.Width() * i
/ nLines
);
811 DrawLine( Point( nTmp
, 0 ), Point( nTmp
, aRectSize
.Height() ) );
814 //Draw Rectangles (squares)
815 Control::SetLineColor();
816 sal_uInt16 nLastPixel
= *pPixel
? 0 : 1;
818 for( i
= 0; i
< nLines
; i
++)
820 aPtTl
.Y() = aRectSize
.Height() * i
/ nLines
+ 1;
821 aPtBr
.Y() = aRectSize
.Height() * (i
+ 1) / nLines
- 1;
823 for( j
= 0; j
< nLines
; j
++)
825 aPtTl
.X() = aRectSize
.Width() * j
/ nLines
+ 1;
826 aPtBr
.X() = aRectSize
.Width() * (j
+ 1) / nLines
- 1;
828 if ( *( pPixel
+ i
* nLines
+ j
) != nLastPixel
)
830 nLastPixel
= *( pPixel
+ i
* nLines
+ j
);
831 // Change color: 0 -> Background color
832 SetFillColor( nLastPixel
? aPixelColor
: aBackgroundColor
);
834 DrawRect( Rectangle( aPtTl
, aPtBr
) );
840 SetBackground( Wallpaper( Color( COL_LIGHTGRAY
) ) );
841 Control::SetLineColor( Color( COL_LIGHTRED
) );
842 DrawLine( Point( 0, 0 ), Point( aRectSize
.Width(), aRectSize
.Height() ) );
843 DrawLine( Point( 0, aRectSize
.Height() ), Point( aRectSize
.Width(), 0 ) );
847 void SvxPixelCtl::SetXBitmap( const BitmapEx
& rBitmapEx
)
852 if(isHistorical8x8(rBitmapEx
, aBack
, aFront
))
854 Bitmap
aBitmap(rBitmapEx
.GetBitmap());
855 BitmapReadAccess
* pRead
= aBitmap
.AcquireReadAccess();
857 aBackgroundColor
= aBack
;
858 aPixelColor
= aFront
;
860 for(sal_uInt16
i(0); i
< nSquares
; i
++)
862 const BitmapColor
aColor(pRead
->GetColor(i
/8, i
%8));
874 aBitmap
.ReleaseAccess(pRead
);
878 // Resets to the original state of the control
880 void SvxPixelCtl::Reset()
883 memset(pPixel
, 0, nSquares
* sizeof(sal_uInt16
));
887 // Constructor: BitmapCtl for SvxPixelCtl
889 SvxBitmapCtl::SvxBitmapCtl( Window
* /*pParent*/, const Size
& rSize
)
894 SvxBitmapCtl::~SvxBitmapCtl()
898 // BitmapCtl: Returns the Bitmap
900 BitmapEx
SvxBitmapCtl::GetBitmapEx()
902 const Bitmap
aRetval(createHistorical8x8FromArray(pBmpArray
, aPixelColor
, aBackgroundColor
));
904 return BitmapEx(aRetval
);
907 extern "C" SAL_DLLPUBLIC_EXPORT Window
* SAL_CALL
makeColorLB(Window
*pParent
, VclBuilder::stringmap
&)
909 ColorLB
*pListBox
= new ColorLB(pParent
, WB_LEFT
|WB_DROPDOWN
|WB_VCENTER
|WB_3DLOOK
|WB_SIMPLEMODE
);
910 pListBox
->EnableAutoSize(true);
914 // Fills the Listbox with color and strings
916 void ColorLB::Fill( const XColorListRef
&pColorTab
)
918 if( !pColorTab
.is() )
921 long nCount
= pColorTab
->Count();
923 SetUpdateMode( sal_False
);
925 for( long i
= 0; i
< nCount
; i
++ )
927 pEntry
= pColorTab
->GetColor( i
);
928 InsertEntry( pEntry
->GetColor(), pEntry
->GetName() );
931 AdaptDropDownLineCountToMaximum();
932 SetUpdateMode( sal_True
);
935 /************************************************************************/
937 void ColorLB::Append( XColorEntry
* pEntry
, Bitmap
* )
939 InsertEntry( pEntry
->GetColor(), pEntry
->GetName() );
940 AdaptDropDownLineCountToMaximum();
943 /************************************************************************/
945 void ColorLB::Modify( XColorEntry
* pEntry
, sal_uInt16 nPos
, Bitmap
* )
948 InsertEntry( pEntry
->GetColor(), pEntry
->GetName(), nPos
);
951 // Fills the Listbox with color and strings
953 void FillAttrLB::Fill( const XColorListRef
&pColorTab
)
955 long nCount
= pColorTab
->Count();
957 SetUpdateMode( sal_False
);
959 for( long i
= 0; i
< nCount
; i
++ )
961 pEntry
= pColorTab
->GetColor( i
);
962 InsertEntry( pEntry
->GetColor(), pEntry
->GetName() );
965 AdaptDropDownLineCountToMaximum();
966 SetUpdateMode( sal_True
);
969 // Fills the listbox (provisional) with strings
971 HatchingLB::HatchingLB( Window
* pParent
, ResId Id
)
972 : ListBox( pParent
, Id
),
975 SetEdgeBlending(true);
978 void HatchingLB::Fill( const XHatchListRef
&pList
)
985 long nCount
= pList
->Count();
987 SetUpdateMode( sal_False
);
989 for( long i
= 0; i
< nCount
; i
++ )
991 pEntry
= pList
->GetHatch( i
);
992 const Bitmap aBitmap
= pList
->GetUiBitmap( i
);
993 if( !aBitmap
.IsEmpty() )
994 InsertEntry( pEntry
->GetName(), aBitmap
);
996 InsertEntry( pEntry
->GetName() );
999 AdaptDropDownLineCountToMaximum();
1000 SetUpdateMode( sal_True
);
1003 /************************************************************************/
1005 void HatchingLB::Append( XHatchEntry
* pEntry
, Bitmap
* pBmp
)
1008 InsertEntry( pEntry
->GetName(), *pBmp
);
1010 InsertEntry( pEntry
->GetName() );
1011 AdaptDropDownLineCountToMaximum();
1014 /************************************************************************/
1016 void HatchingLB::Modify( XHatchEntry
* pEntry
, sal_uInt16 nPos
, Bitmap
* pBmp
)
1018 RemoveEntry( nPos
);
1021 InsertEntry( pEntry
->GetName(), *pBmp
, nPos
);
1023 InsertEntry( pEntry
->GetName(), nPos
);
1026 // Fills the listbox (provisional) with strings
1028 void FillAttrLB::Fill( const XHatchListRef
&pList
)
1030 long nCount
= pList
->Count();
1031 XHatchEntry
* pEntry
;
1032 ListBox::SetUpdateMode( sal_False
);
1034 for( long i
= 0; i
< nCount
; i
++ )
1036 pEntry
= pList
->GetHatch( i
);
1037 const Bitmap aBitmap
= pList
->GetUiBitmap( i
);
1038 if( !aBitmap
.IsEmpty() )
1039 ListBox::InsertEntry( pEntry
->GetName(), aBitmap
);
1041 InsertEntry( pEntry
->GetName() );
1044 AdaptDropDownLineCountToMaximum();
1045 ListBox::SetUpdateMode( sal_True
);
1048 // Fills the listbox (provisional) with strings
1050 GradientLB::GradientLB( Window
* pParent
, ResId Id
)
1051 : ListBox( pParent
, Id
),
1054 SetEdgeBlending(true);
1057 GradientLB::GradientLB( Window
* pParent
, WinBits aWB
)
1058 : ListBox( pParent
, aWB
),
1061 SetEdgeBlending(true);
1064 extern "C" SAL_DLLPUBLIC_EXPORT Window
* SAL_CALL
makeGradientLB(Window
*pParent
, VclBuilder::stringmap
&rMap
)
1066 WinBits nWinStyle
= WB_LEFT
|WB_VCENTER
|WB_3DLOOK
|WB_SIMPLEMODE
;
1067 OString sBorder
= VclBuilder::extractCustomProperty(rMap
);
1068 if (!sBorder
.isEmpty())
1069 nWinStyle
|= WB_BORDER
;
1070 GradientLB
*pListBox
= new GradientLB(pParent
, nWinStyle
);
1071 pListBox
->EnableAutoSize(true);
1075 void GradientLB::Fill( const XGradientListRef
&pList
)
1081 XGradientEntry
* pEntry
;
1082 long nCount
= pList
->Count();
1084 SetUpdateMode( sal_False
);
1086 for( long i
= 0; i
< nCount
; i
++ )
1088 pEntry
= pList
->GetGradient( i
);
1089 const Bitmap aBitmap
= pList
->GetUiBitmap( i
);
1090 if( !aBitmap
.IsEmpty() )
1091 InsertEntry( pEntry
->GetName(), aBitmap
);
1093 InsertEntry( pEntry
->GetName() );
1096 AdaptDropDownLineCountToMaximum();
1097 SetUpdateMode( sal_True
);
1100 /************************************************************************/
1102 void GradientLB::Append( XGradientEntry
* pEntry
, Bitmap
* pBmp
)
1105 InsertEntry( pEntry
->GetName(), *pBmp
);
1107 InsertEntry( pEntry
->GetName() );
1108 AdaptDropDownLineCountToMaximum();
1111 /************************************************************************/
1113 void GradientLB::Modify( XGradientEntry
* pEntry
, sal_uInt16 nPos
, Bitmap
* pBmp
)
1115 RemoveEntry( nPos
);
1118 InsertEntry( pEntry
->GetName(), *pBmp
, nPos
);
1120 InsertEntry( pEntry
->GetName(), nPos
);
1123 /************************************************************************/
1125 void GradientLB::SelectEntryByList( const XGradientListRef
&pList
, const String
& rStr
,
1126 const XGradient
& rGradient
, sal_uInt16 nDist
)
1128 long nCount
= pList
->Count();
1129 XGradientEntry
* pEntry
;
1130 bool bFound
= false;
1134 for( i
= 0; i
< nCount
&& !bFound
; i
++ )
1136 pEntry
= pList
->GetGradient( i
);
1138 aStr
= pEntry
->GetName();
1140 if( rStr
== aStr
&& rGradient
== pEntry
->GetGradient() )
1144 SelectEntryPos( (sal_uInt16
) ( i
- 1 + nDist
) );
1147 // Fills the listbox (provisional) with strings
1149 void FillAttrLB::Fill( const XGradientListRef
&pList
)
1151 long nCount
= pList
->Count();
1152 XGradientEntry
* pEntry
;
1153 ListBox::SetUpdateMode( sal_False
);
1155 for( long i
= 0; i
< nCount
; i
++ )
1157 pEntry
= pList
->GetGradient( i
);
1158 const Bitmap aBitmap
= pList
->GetUiBitmap( i
);
1159 if( !aBitmap
.IsEmpty() )
1160 ListBox::InsertEntry( pEntry
->GetName(), aBitmap
);
1162 InsertEntry( pEntry
->GetName() );
1165 AdaptDropDownLineCountToMaximum();
1166 ListBox::SetUpdateMode( sal_True
);
1169 // BitmapLB Constructor
1171 BitmapLB::BitmapLB(Window
* pParent
, ResId Id
)
1172 : ListBox(pParent
, Id
),
1176 SetEdgeBlending(true);
1179 /************************************************************************/
1183 void formatBitmapExToSize(BitmapEx
& rBitmapEx
, const Size
& rSize
)
1185 if(!rBitmapEx
.IsEmpty() && rSize
.Width() > 0 && rSize
.Height() > 0)
1187 VirtualDevice aVirtualDevice
;
1188 aVirtualDevice
.SetOutputSizePixel(rSize
);
1190 if(rBitmapEx
.IsTransparent())
1192 const Point
aNull(0, 0);
1193 static const sal_uInt32
nLen(8);
1194 static const Color
aW(COL_WHITE
);
1195 static const Color
aG(0xef, 0xef, 0xef);
1197 aVirtualDevice
.DrawCheckered(aNull
, rSize
, nLen
, aW
, aG
);
1200 if(rBitmapEx
.GetSizePixel().Width() >= rSize
.Width() && rBitmapEx
.GetSizePixel().Height() >= rSize
.Height())
1202 rBitmapEx
.Scale(rSize
, BMP_SCALE_DEFAULT
);
1203 aVirtualDevice
.DrawBitmapEx(Point(0, 0), rBitmapEx
);
1207 const Size
aBitmapSize(rBitmapEx
.GetSizePixel());
1209 for(sal_Int32
y(0); y
< rSize
.Height(); y
+= aBitmapSize
.Height())
1211 for(sal_Int32
x(0); x
< rSize
.Width(); x
+= aBitmapSize
.Width())
1213 aVirtualDevice
.DrawBitmapEx(
1220 rBitmapEx
= aVirtualDevice
.GetBitmap(Point(0, 0), rSize
);
1223 } // end of anonymous namespace
1225 /************************************************************************/
1227 void BitmapLB::Fill( const XBitmapListRef
&pList
)
1233 XBitmapEntry
* pEntry
;
1234 const long nCount(pList
->Count());
1235 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
1236 const Size
aSize(rStyleSettings
.GetListBoxPreviewDefaultPixelSize());
1238 SetUpdateMode(false);
1240 for(long i(0); i
< nCount
; i
++)
1242 pEntry
= pList
->GetBitmap(i
);
1243 maBitmapEx
= pEntry
->GetGraphicObject().GetGraphic().GetBitmapEx();
1244 formatBitmapExToSize(maBitmapEx
, aSize
);
1245 InsertEntry(pEntry
->GetName(), maBitmapEx
);
1248 AdaptDropDownLineCountToMaximum();
1249 SetUpdateMode(true);
1252 /************************************************************************/
1254 void BitmapLB::Append(const Size
& rSize
, const XBitmapEntry
& rEntry
, BitmapEx
* pBmpEx
)
1258 maBitmapEx
= rEntry
.GetGraphicObject().GetGraphic().GetBitmapEx();
1259 formatBitmapExToSize(maBitmapEx
, rSize
);
1260 InsertEntry(rEntry
.GetName(), maBitmapEx
);
1264 InsertEntry(rEntry
.GetName());
1267 AdaptDropDownLineCountToMaximum();
1270 /************************************************************************/
1272 void BitmapLB::Modify(const Size
& rSize
, const XBitmapEntry
& rEntry
, sal_uInt16 nPos
, BitmapEx
* pBmpEx
)
1278 maBitmapEx
= rEntry
.GetGraphicObject().GetGraphic().GetBitmapEx();
1279 formatBitmapExToSize(maBitmapEx
, rSize
);
1280 InsertEntry(rEntry
.GetName(), maBitmapEx
, nPos
);
1284 InsertEntry(rEntry
.GetName());
1288 FillAttrLB::FillAttrLB(Window
* pParent
, WinBits aWB
)
1289 : ColorListBox(pParent
, aWB
)
1293 /************************************************************************/
1295 void FillAttrLB::Fill( const XBitmapListRef
&pList
)
1297 const long nCount(pList
->Count());
1298 XBitmapEntry
* pEntry
;
1299 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
1300 const Size
aSize(rStyleSettings
.GetListBoxPreviewDefaultPixelSize());
1302 ListBox::SetUpdateMode(false);
1304 for(long i(0); i
< nCount
; i
++)
1306 pEntry
= pList
->GetBitmap( i
);
1307 maBitmapEx
= pEntry
->GetGraphicObject().GetGraphic().GetBitmapEx();
1308 formatBitmapExToSize(maBitmapEx
, aSize
);
1309 ListBox::InsertEntry(pEntry
->GetName(), maBitmapEx
);
1312 AdaptDropDownLineCountToMaximum();
1313 ListBox::SetUpdateMode(true);
1316 void FillTypeLB::Fill()
1318 SetUpdateMode( sal_False
);
1320 InsertEntry( String( SVX_RES( RID_SVXSTR_INVISIBLE
) ) );
1321 InsertEntry( String( SVX_RES( RID_SVXSTR_COLOR
) ) );
1322 InsertEntry( String( SVX_RES( RID_SVXSTR_GRADIENT
) ) );
1323 InsertEntry( String( SVX_RES( RID_SVXSTR_HATCH
) ) );
1324 InsertEntry( String( SVX_RES( RID_SVXSTR_BITMAP
) ) );
1326 AdaptDropDownLineCountToMaximum();
1327 SetUpdateMode( sal_True
);
1330 LineLB::LineLB(Window
* pParent
, ResId Id
)
1331 : ListBox(pParent
, Id
),
1332 mbAddStandardFields(true)
1334 // No EdgeBlending for LineStyle/Dash SetEdgeBlending(true);
1337 LineLB::LineLB(Window
* pParent
, WinBits aWB
)
1338 : ListBox(pParent
, aWB
),
1339 mbAddStandardFields(true)
1341 // No EdgeBlending for LineStyle/Dash SetEdgeBlending(true);
1348 void LineLB::setAddStandardFields(bool bNew
)
1350 if(getAddStandardFields() != bNew
)
1352 mbAddStandardFields
= bNew
;
1356 // Fills the listbox (provisional) with strings
1358 void LineLB::Fill( const XDashListRef
&pList
)
1365 if(getAddStandardFields())
1368 InsertEntry(pList
->GetStringForUiNoLine());
1370 // entry for solid line
1371 InsertEntry(pList
->GetStringForUiSolidLine(), pList
->GetBitmapForUISolidLine());
1374 // entries for dashed lines
1376 long nCount
= pList
->Count();
1378 SetUpdateMode( sal_False
);
1380 for( long i
= 0; i
< nCount
; i
++ )
1382 pEntry
= pList
->GetDash( i
);
1383 const Bitmap aBitmap
= pList
->GetUiBitmap( i
);
1384 if( !aBitmap
.IsEmpty() )
1386 InsertEntry( pEntry
->GetName(), aBitmap
);
1389 InsertEntry( pEntry
->GetName() );
1392 AdaptDropDownLineCountToMaximum();
1393 SetUpdateMode( sal_True
);
1396 /************************************************************************/
1398 void LineLB::Append( XDashEntry
* pEntry
, const Bitmap
* pBmp
)
1401 InsertEntry( pEntry
->GetName(), *pBmp
);
1403 InsertEntry( pEntry
->GetName() );
1404 AdaptDropDownLineCountToMaximum();
1407 /************************************************************************/
1409 void LineLB::Modify( XDashEntry
* pEntry
, sal_uInt16 nPos
, const Bitmap
* pBmp
)
1411 RemoveEntry( nPos
);
1414 InsertEntry( pEntry
->GetName(), *pBmp
, nPos
);
1416 InsertEntry( pEntry
->GetName(), nPos
);
1419 // Fills the listbox (provisional) with strings
1421 LineEndLB::LineEndLB( Window
* pParent
, ResId Id
)
1422 : ListBox( pParent
, Id
)
1424 // No EdgeBlending for LineEnds SetEdgeBlending(true);
1427 LineEndLB::LineEndLB( Window
* pParent
, WinBits aWB
)
1428 : ListBox( pParent
, aWB
)
1430 // No EdgeBlending for LineEnds SetEdgeBlending(true);
1433 LineEndLB::~LineEndLB(void)
1437 void LineEndLB::Fill( const XLineEndListRef
&pList
, sal_Bool bStart
)
1442 long nCount
= pList
->Count();
1443 XLineEndEntry
* pEntry
;
1445 SetUpdateMode( sal_False
);
1447 for( long i
= 0; i
< nCount
; i
++ )
1449 pEntry
= pList
->GetLineEnd( i
);
1450 const Bitmap aBitmap
= pList
->GetUiBitmap( i
);
1451 if( !aBitmap
.IsEmpty() )
1453 Size
aBmpSize( aBitmap
.GetSizePixel() );
1454 aVD
.SetOutputSizePixel( aBmpSize
, sal_False
);
1455 aVD
.DrawBitmap( Point(), aBitmap
);
1456 InsertEntry( pEntry
->GetName(),
1457 aVD
.GetBitmap( bStart
? Point() : Point( aBmpSize
.Width() / 2, 0 ),
1458 Size( aBmpSize
.Width() / 2, aBmpSize
.Height() ) ) );
1462 InsertEntry( pEntry
->GetName() );
1465 AdaptDropDownLineCountToMaximum();
1466 SetUpdateMode( sal_True
);
1469 /************************************************************************/
1471 void LineEndLB::Append( XLineEndEntry
* pEntry
, const Bitmap
* pBmp
, sal_Bool bStart
)
1476 Size
aBmpSize( pBmp
->GetSizePixel() );
1478 aVD
.SetOutputSizePixel( aBmpSize
, sal_False
);
1479 aVD
.DrawBitmap( Point(), *pBmp
);
1480 InsertEntry( pEntry
->GetName(),
1481 aVD
.GetBitmap( bStart
? Point() : Point( aBmpSize
.Width() / 2, 0 ),
1482 Size( aBmpSize
.Width() / 2, aBmpSize
.Height() ) ) );
1485 InsertEntry( pEntry
->GetName() );
1486 AdaptDropDownLineCountToMaximum();
1489 /************************************************************************/
1491 void LineEndLB::Modify( XLineEndEntry
* pEntry
, sal_uInt16 nPos
, const Bitmap
* pBmp
, sal_Bool bStart
)
1493 RemoveEntry( nPos
);
1498 Size
aBmpSize( pBmp
->GetSizePixel() );
1500 aVD
.SetOutputSizePixel( aBmpSize
, sal_False
);
1501 aVD
.DrawBitmap( Point(), *pBmp
);
1502 InsertEntry( pEntry
->GetName(),
1503 aVD
.GetBitmap( bStart
? Point() : Point( aBmpSize
.Width() / 2, 0 ),
1504 Size( aBmpSize
.Width() / 2, aBmpSize
.Height() ) ), nPos
);
1507 InsertEntry( pEntry
->GetName(), nPos
);
1510 //////////////////////////////////////////////////////////////////////////////
1512 void SvxPreviewBase::InitSettings(bool bForeground
, bool bBackground
)
1514 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
1518 svtools::ColorConfig aColorConfig
;
1519 Color
aTextColor(aColorConfig
.GetColorValue(svtools::FONTCOLOR
).nColor
);
1521 if(IsControlForeground())
1523 aTextColor
= GetControlForeground();
1526 getBufferDevice().SetTextColor(aTextColor
);
1531 if(IsControlBackground())
1533 getBufferDevice().SetBackground(GetControlBackground());
1537 getBufferDevice().SetBackground(rStyleSettings
.GetWindowColor());
1541 // do not paint background self, it gets painted buffered
1542 SetControlBackground();
1548 SvxPreviewBase::SvxPreviewBase( Window
* pParent
, const ResId
& rResId
)
1549 : Control( pParent
, rResId
),
1550 mpModel( new SdrModel() ),
1551 mpBufferDevice( new VirtualDevice(*this) )
1553 // Draw the control's border as a flat thin black line.
1554 SetBorderStyle(WINDOW_BORDER_MONO
);
1555 SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST
: OUTPUT_DRAWMODE_COLOR
);
1556 SetMapMode(MAP_100TH_MM
);
1559 mpModel
->GetItemPool().FreezeIdRanges();
1562 SvxPreviewBase::SvxPreviewBase(Window
* pParent
)
1563 : Control(pParent
, WB_BORDER
)
1564 , mpModel(new SdrModel())
1565 , mpBufferDevice(new VirtualDevice(*this))
1567 // Draw the control's border as a flat thin black line.
1568 SetBorderStyle(WINDOW_BORDER_MONO
);
1569 SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST
: OUTPUT_DRAWMODE_COLOR
);
1570 SetMapMode(MAP_100TH_MM
);
1573 mpModel
->GetItemPool().FreezeIdRanges();
1576 SvxPreviewBase::~SvxPreviewBase()
1579 delete mpBufferDevice
;
1582 void SvxPreviewBase::LocalPrePaint()
1584 // init BufferDevice
1585 if(mpBufferDevice
->GetOutputSizePixel() != GetOutputSizePixel())
1587 mpBufferDevice
->SetDrawMode(GetDrawMode());
1588 mpBufferDevice
->SetSettings(GetSettings());
1589 mpBufferDevice
->SetAntialiasing(GetAntialiasing());
1590 mpBufferDevice
->SetOutputSizePixel(GetOutputSizePixel());
1591 mpBufferDevice
->SetMapMode(GetMapMode());
1594 mpBufferDevice
->Erase();
1597 void SvxPreviewBase::LocalPostPaint()
1599 // copy to front (in pixel mode)
1600 const bool bWasEnabledSrc(mpBufferDevice
->IsMapModeEnabled());
1601 const bool bWasEnabledDst(IsMapModeEnabled());
1602 const Point aEmptyPoint
;
1604 mpBufferDevice
->EnableMapMode(false);
1605 EnableMapMode(false);
1608 aEmptyPoint
, GetOutputSizePixel(),
1609 aEmptyPoint
, GetOutputSizePixel(),
1612 mpBufferDevice
->EnableMapMode(bWasEnabledSrc
);
1613 EnableMapMode(bWasEnabledDst
);
1616 void SvxPreviewBase::StateChanged(StateChangedType nType
)
1618 Control::StateChanged(nType
);
1620 if(STATE_CHANGE_CONTROLFOREGROUND
== nType
)
1622 InitSettings(true, false);
1624 else if(STATE_CHANGE_CONTROLBACKGROUND
== nType
)
1626 InitSettings(false, true);
1630 void SvxPreviewBase::DataChanged(const DataChangedEvent
& rDCEvt
)
1632 SetDrawMode(GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST
: OUTPUT_DRAWMODE_COLOR
);
1634 if((DATACHANGED_SETTINGS
== rDCEvt
.GetType()) && (rDCEvt
.GetFlags() & SETTINGS_STYLE
))
1636 InitSettings(true, true);
1640 Control::DataChanged(rDCEvt
);
1644 SvxXLinePreview::SvxXLinePreview( Window
* pParent
, const ResId
& rResId
)
1645 : SvxPreviewBase( pParent
, rResId
),
1650 mbWithSymbol( sal_False
)
1652 const Size
aOutputSize(GetOutputSize());
1653 InitSettings( sal_True
, sal_True
);
1655 const sal_Int32
nDistance(500L);
1656 const sal_Int32
nAvailableLength(aOutputSize
.Width() - (4 * nDistance
));
1658 // create DrawObectA
1659 const sal_Int32
aYPosA(aOutputSize
.Height() / 2);
1660 const basegfx::B2DPoint
aPointA1( nDistance
, aYPosA
);
1661 const basegfx::B2DPoint
aPointA2( aPointA1
.getX() + ((nAvailableLength
* 14) / 20), aYPosA
);
1662 basegfx::B2DPolygon aPolygonA
;
1663 aPolygonA
.append(aPointA1
);
1664 aPolygonA
.append(aPointA2
);
1665 mpLineObjA
= new SdrPathObj(OBJ_LINE
, basegfx::B2DPolyPolygon(aPolygonA
));
1666 mpLineObjA
->SetModel(&getModel());
1668 // create DrawObectB
1669 const sal_Int32
aYPosB1((aOutputSize
.Height() * 3) / 4);
1670 const sal_Int32
aYPosB2((aOutputSize
.Height() * 1) / 4);
1671 const basegfx::B2DPoint
aPointB1( aPointA2
.getX() + nDistance
, aYPosB1
);
1672 const basegfx::B2DPoint
aPointB2( aPointB1
.getX() + ((nAvailableLength
* 2) / 20), aYPosB2
);
1673 const basegfx::B2DPoint
aPointB3( aPointB2
.getX() + ((nAvailableLength
* 2) / 20), aYPosB1
);
1674 basegfx::B2DPolygon aPolygonB
;
1675 aPolygonB
.append(aPointB1
);
1676 aPolygonB
.append(aPointB2
);
1677 aPolygonB
.append(aPointB3
);
1678 mpLineObjB
= new SdrPathObj(OBJ_PLIN
, basegfx::B2DPolyPolygon(aPolygonB
));
1679 mpLineObjB
->SetModel(&getModel());
1681 // create DrawObectC
1682 const basegfx::B2DPoint
aPointC1( aPointB3
.getX() + nDistance
, aYPosB1
);
1683 const basegfx::B2DPoint
aPointC2( aPointC1
.getX() + ((nAvailableLength
* 1) / 20), aYPosB2
);
1684 const basegfx::B2DPoint
aPointC3( aPointC2
.getX() + ((nAvailableLength
* 1) / 20), aYPosB1
);
1685 basegfx::B2DPolygon aPolygonC
;
1686 aPolygonC
.append(aPointC1
);
1687 aPolygonC
.append(aPointC2
);
1688 aPolygonC
.append(aPointC3
);
1689 mpLineObjC
= new SdrPathObj(OBJ_PLIN
, basegfx::B2DPolyPolygon(aPolygonC
));
1690 mpLineObjC
->SetModel(&getModel());
1693 SvxXLinePreview::~SvxXLinePreview()
1695 SdrObject::Free( mpLineObjA
);
1696 SdrObject::Free( mpLineObjB
);
1697 SdrObject::Free( mpLineObjC
);
1700 // -----------------------------------------------------------------------
1702 void SvxXLinePreview::SetSymbol(Graphic
* p
,const Size
& s
)
1708 // -----------------------------------------------------------------------
1710 void SvxXLinePreview::ResizeSymbol(const Size
& s
)
1712 if ( s
!= maSymbolSize
)
1719 // -----------------------------------------------------------------------
1721 void SvxXLinePreview::SetLineAttributes(const SfxItemSet
& rItemSet
)
1723 // Set ItemSet at objects
1724 mpLineObjA
->SetMergedItemSet(rItemSet
);
1726 // At line joints, do not use arrows
1727 SfxItemSet
aTempSet(rItemSet
);
1728 aTempSet
.ClearItem(XATTR_LINESTART
);
1729 aTempSet
.ClearItem(XATTR_LINEEND
);
1731 mpLineObjB
->SetMergedItemSet(aTempSet
);
1732 mpLineObjC
->SetMergedItemSet(aTempSet
);
1735 // -----------------------------------------------------------------------
1737 void SvxXLinePreview::Paint( const Rectangle
& )
1741 // paint objects to buffer device
1742 sdr::contact::SdrObjectVector aObjectVector
;
1743 aObjectVector
.push_back(mpLineObjA
);
1744 aObjectVector
.push_back(mpLineObjB
);
1745 aObjectVector
.push_back(mpLineObjC
);
1747 sdr::contact::ObjectContactOfObjListPainter
aPainter(getBufferDevice(), aObjectVector
, 0);
1748 sdr::contact::DisplayInfo aDisplayInfo
;
1751 aPainter
.ProcessDisplay(aDisplayInfo
);
1753 if ( mbWithSymbol
&& mpGraphic
)
1755 const Size
aOutputSize(GetOutputSize());
1756 Point aPos
= Point( aOutputSize
.Width() / 3, aOutputSize
.Height() / 2 );
1757 aPos
.X() -= maSymbolSize
.Width() / 2;
1758 aPos
.Y() -= maSymbolSize
.Height() / 2;
1759 mpGraphic
->Draw( &getBufferDevice(), aPos
, maSymbolSize
);
1765 SvxXRectPreview::SvxXRectPreview( Window
* pParent
, const ResId
& rResId
)
1766 : SvxPreviewBase( pParent
, rResId
),
1767 mpRectangleObject(0)
1769 InitSettings(true, true);
1771 // create RectangleObject
1772 const Rectangle
aObjectSize(Point(), GetOutputSize());
1773 mpRectangleObject
= new SdrRectObj(aObjectSize
);
1774 mpRectangleObject
->SetModel(&getModel());
1777 SvxXRectPreview::SvxXRectPreview(Window
* pParent
)
1778 : SvxPreviewBase(pParent
)
1779 , mpRectangleObject(0)
1781 InitSettings(true, true);
1783 // create RectangleObject
1784 const Rectangle
aObjectSize(Point(), GetOutputSize());
1785 mpRectangleObject
= new SdrRectObj(aObjectSize
);
1786 mpRectangleObject
->SetModel(&getModel());
1789 void SvxXRectPreview::Resize()
1791 const Rectangle
aObjectSize(Point(), GetOutputSize());
1792 SdrObject
*pOrigObject
= mpRectangleObject
;
1795 mpRectangleObject
= new SdrRectObj(aObjectSize
);
1796 mpRectangleObject
->SetModel(&getModel());
1797 SetAttributes(pOrigObject
->GetMergedItemSet());
1798 SdrObject::Free(pOrigObject
);
1800 SvxPreviewBase::Resize();
1803 extern "C" SAL_DLLPUBLIC_EXPORT Window
* SAL_CALL
makeSvxXRectPreview(Window
*pParent
, VclBuilder::stringmap
&)
1805 return new SvxXRectPreview(pParent
);
1808 SvxXRectPreview::~SvxXRectPreview()
1810 SdrObject::Free(mpRectangleObject
);
1813 void SvxXRectPreview::SetAttributes(const SfxItemSet
& rItemSet
)
1815 mpRectangleObject
->SetMergedItemSet(rItemSet
, true);
1816 mpRectangleObject
->SetMergedItem(XLineStyleItem(XLINE_NONE
));
1819 void SvxXRectPreview::Paint( const Rectangle
& )
1823 sdr::contact::SdrObjectVector aObjectVector
;
1825 aObjectVector
.push_back(mpRectangleObject
);
1827 sdr::contact::ObjectContactOfObjListPainter
aPainter(getBufferDevice(), aObjectVector
, 0);
1828 sdr::contact::DisplayInfo aDisplayInfo
;
1830 aPainter
.ProcessDisplay(aDisplayInfo
);
1835 SvxXShadowPreview::SvxXShadowPreview( Window
* pParent
, const ResId
& rResId
)
1836 : SvxPreviewBase( pParent
, rResId
),
1837 mpRectangleObject(0),
1838 mpRectangleShadow(0)
1840 InitSettings(true, true);
1843 Size aSize
= GetOutputSize();
1844 aSize
.Width() = aSize
.Width() / 3;
1845 aSize
.Height() = aSize
.Height() / 3;
1847 // create RectangleObject
1848 const Rectangle
aObjectSize( Point( aSize
.Width(), aSize
.Height() ), aSize
);
1849 mpRectangleObject
= new SdrRectObj(aObjectSize
);
1850 mpRectangleObject
->SetModel(&getModel());
1852 // create ShadowObject
1853 const Rectangle
aShadowSize( Point( aSize
.Width(), aSize
.Height() ), aSize
);
1854 mpRectangleShadow
= new SdrRectObj(aShadowSize
);
1855 mpRectangleShadow
->SetModel(&getModel());
1858 SvxXShadowPreview::~SvxXShadowPreview()
1860 SdrObject::Free(mpRectangleObject
);
1861 SdrObject::Free(mpRectangleShadow
);
1864 void SvxXShadowPreview::SetRectangleAttributes(const SfxItemSet
& rItemSet
)
1866 mpRectangleObject
->SetMergedItemSet(rItemSet
, true);
1867 mpRectangleObject
->SetMergedItem(XLineStyleItem(XLINE_NONE
));
1870 void SvxXShadowPreview::SetShadowAttributes(const SfxItemSet
& rItemSet
)
1872 mpRectangleShadow
->SetMergedItemSet(rItemSet
, true);
1873 mpRectangleShadow
->SetMergedItem(XLineStyleItem(XLINE_NONE
));
1876 void SvxXShadowPreview::SetShadowPosition(const Point
& rPos
)
1878 Rectangle
aObjectPosition(mpRectangleObject
->GetSnapRect());
1879 aObjectPosition
.Move(rPos
.X(), rPos
.Y());
1880 mpRectangleShadow
->SetSnapRect(aObjectPosition
);
1883 void SvxXShadowPreview::Paint( const Rectangle
& )
1887 sdr::contact::SdrObjectVector aObjectVector
;
1889 aObjectVector
.push_back(mpRectangleShadow
);
1890 aObjectVector
.push_back(mpRectangleObject
);
1892 sdr::contact::ObjectContactOfObjListPainter
aPainter(getBufferDevice(), aObjectVector
, 0);
1893 sdr::contact::DisplayInfo aDisplayInfo
;
1895 aPainter
.ProcessDisplay(aDisplayInfo
);
1900 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */