1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fixed.cxx,v $
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_vcl.hxx"
33 #include <vcl/decoview.hxx>
34 #include <vcl/event.hxx>
35 #include <vcl/fixed.hxx>
36 #include <vcl/controllayout.hxx>
37 #include <vcl/window.h>
41 // =======================================================================
43 #define FIXEDLINE_TEXT_BORDER 4
45 #define FIXEDTEXT_VIEW_STYLE (WB_3DLOOK | \
46 WB_LEFT | WB_CENTER | WB_RIGHT | \
47 WB_TOP | WB_VCENTER | WB_BOTTOM | \
48 WB_WORDBREAK | WB_NOLABEL | \
49 WB_INFO | WB_PATHELLIPSIS)
50 #define FIXEDLINE_VIEW_STYLE (WB_3DLOOK | WB_NOLABEL)
51 #define FIXEDBITMAP_VIEW_STYLE (WB_3DLOOK | \
52 WB_LEFT | WB_CENTER | WB_RIGHT | \
53 WB_TOP | WB_VCENTER | WB_BOTTOM | \
55 #define FIXEDIMAGE_VIEW_STYLE (WB_3DLOOK | \
56 WB_LEFT | WB_CENTER | WB_RIGHT | \
57 WB_TOP | WB_VCENTER | WB_BOTTOM | \
60 // =======================================================================
62 static Point
ImplCalcPos( WinBits nStyle
, const Point
& rPos
,
63 const Size
& rObjSize
, const Size
& rWinSize
)
68 if ( nStyle
& WB_LEFT
)
70 else if ( nStyle
& WB_RIGHT
)
71 nX
= rWinSize
.Width()-rObjSize
.Width();
73 nX
= (rWinSize
.Width()-rObjSize
.Width())/2;
75 if ( nStyle
& WB_TOP
)
77 else if ( nStyle
& WB_BOTTOM
)
78 nY
= rWinSize
.Height()-rObjSize
.Height();
80 nY
= (rWinSize
.Height()-rObjSize
.Height())/2;
82 if ( nStyle
& WB_TOPLEFTVISIBLE
)
90 Point
aPos( nX
+rPos
.X(), nY
+rPos
.Y() );
94 // =======================================================================
96 void FixedText::ImplInit( Window
* pParent
, WinBits nStyle
)
98 nStyle
= ImplInitStyle( nStyle
);
99 Control::ImplInit( pParent
, nStyle
, NULL
);
100 ImplInitSettings( TRUE
, TRUE
, TRUE
);
103 // -----------------------------------------------------------------------
105 WinBits
FixedText::ImplInitStyle( WinBits nStyle
)
107 if ( !(nStyle
& WB_NOGROUP
) )
112 // -----------------------------------------------------------------------
114 void FixedText::ImplInitSettings( BOOL bFont
,
115 BOOL bForeground
, BOOL bBackground
)
117 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
122 if ( GetStyle() & WB_INFO
)
123 aFont
= rStyleSettings
.GetInfoFont();
125 aFont
= rStyleSettings
.GetLabelFont();
126 if ( IsControlFont() )
127 aFont
.Merge( GetControlFont() );
128 SetZoomedPointFont( aFont
);
131 if ( bForeground
|| bFont
)
134 if ( IsControlForeground() )
135 aColor
= GetControlForeground();
138 if ( GetStyle() & WB_INFO
)
139 aColor
= rStyleSettings
.GetInfoTextColor();
141 aColor
= rStyleSettings
.GetLabelTextColor();
143 SetTextColor( aColor
);
149 Window
* pParent
= GetParent();
150 if ( pParent
->IsChildTransparentModeEnabled() && !IsControlBackground() )
152 EnableChildTransparentMode( TRUE
);
153 SetParentClipMode( PARENTCLIPMODE_NOCLIP
);
154 SetPaintTransparent( TRUE
);
159 EnableChildTransparentMode( FALSE
);
160 SetParentClipMode( 0 );
161 SetPaintTransparent( FALSE
);
163 if ( IsControlBackground() )
164 SetBackground( GetControlBackground() );
166 SetBackground( pParent
->GetBackground() );
171 // -----------------------------------------------------------------------
173 FixedText::FixedText( Window
* pParent
, WinBits nStyle
) :
174 Control( WINDOW_FIXEDTEXT
)
176 ImplInit( pParent
, nStyle
);
179 // -----------------------------------------------------------------------
181 FixedText::FixedText( Window
* pParent
, const ResId
& rResId
) :
182 Control( WINDOW_FIXEDTEXT
)
184 rResId
.SetRT( RSC_TEXT
);
185 WinBits nStyle
= ImplInitRes( rResId
);
186 ImplInit( pParent
, nStyle
);
187 ImplLoadRes( rResId
);
189 if ( !(nStyle
& WB_HIDE
) )
193 // -----------------------------------------------------------------------
195 FixedText::FixedText( Window
* pParent
, const ResId
& rResId
, bool bDisableAccessibleLabelForRelation
) :
196 Control( WINDOW_FIXEDTEXT
)
198 rResId
.SetRT( RSC_TEXT
);
199 WinBits nStyle
= ImplInitRes( rResId
);
200 ImplInit( pParent
, nStyle
);
201 ImplLoadRes( rResId
);
202 if ( bDisableAccessibleLabelForRelation
)
203 ImplGetWindowImpl()->mbDisableAccessibleLabelForRelation
= TRUE
;
205 if ( !(nStyle
& WB_HIDE
) )
209 // -----------------------------------------------------------------------
211 USHORT
FixedText::ImplGetTextStyle( WinBits nWinStyle
)
213 USHORT nTextStyle
= TEXT_DRAW_MNEMONIC
| TEXT_DRAW_ENDELLIPSIS
;
215 if( ! (nWinStyle
& WB_NOMULTILINE
) )
216 nTextStyle
|= TEXT_DRAW_MULTILINE
;
218 if ( nWinStyle
& WB_RIGHT
)
219 nTextStyle
|= TEXT_DRAW_RIGHT
;
220 else if ( nWinStyle
& WB_CENTER
)
221 nTextStyle
|= TEXT_DRAW_CENTER
;
223 nTextStyle
|= TEXT_DRAW_LEFT
;
224 if ( nWinStyle
& WB_BOTTOM
)
225 nTextStyle
|= TEXT_DRAW_BOTTOM
;
226 else if ( nWinStyle
& WB_VCENTER
)
227 nTextStyle
|= TEXT_DRAW_VCENTER
;
229 nTextStyle
|= TEXT_DRAW_TOP
;
230 if ( nWinStyle
& WB_WORDBREAK
)
232 nTextStyle
|= TEXT_DRAW_WORDBREAK
;
233 if ( (nWinStyle
& WB_HYPHENATION
) == WB_HYPHENATION
)
234 nTextStyle
|= TEXT_DRAW_WORDBREAK_HYPHENATION
;
236 if ( nWinStyle
& WB_NOLABEL
)
237 nTextStyle
&= ~TEXT_DRAW_MNEMONIC
;
242 // -----------------------------------------------------------------------
244 void FixedText::ImplDraw( OutputDevice
* pDev
, ULONG nDrawFlags
,
245 const Point
& rPos
, const Size
& rSize
,
249 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
250 WinBits nWinStyle
= GetStyle();
251 XubString
aText( GetText() );
252 USHORT nTextStyle
= FixedText::ImplGetTextStyle( nWinStyle
);
255 if ( nWinStyle
& WB_EXTRAOFFSET
)
258 if ( nWinStyle
& WB_PATHELLIPSIS
)
260 nTextStyle
&= ~(TEXT_DRAW_ENDELLIPSIS
| TEXT_DRAW_MULTILINE
| TEXT_DRAW_WORDBREAK
);
261 nTextStyle
|= TEXT_DRAW_PATHELLIPSIS
;
263 if ( nDrawFlags
& WINDOW_DRAW_NOMNEMONIC
)
265 if ( nTextStyle
& TEXT_DRAW_MNEMONIC
)
267 aText
= GetNonMnemonicString( aText
);
268 nTextStyle
&= ~TEXT_DRAW_MNEMONIC
;
271 if ( !(nDrawFlags
& WINDOW_DRAW_NODISABLE
) )
274 nTextStyle
|= TEXT_DRAW_DISABLE
;
276 if ( (nDrawFlags
& WINDOW_DRAW_MONO
) ||
277 (rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
278 nTextStyle
|= TEXT_DRAW_MONO
;
282 mpLayoutData
->m_aDisplayText
= String();
283 pDev
->DrawText( Rectangle( aPos
, rSize
),
286 &mpLayoutData
->m_aUnicodeBoundRects
,
287 &mpLayoutData
->m_aDisplayText
291 pDev
->DrawText( Rectangle( aPos
, rSize
), aText
, nTextStyle
);
294 // -----------------------------------------------------------------------
296 void FixedText::Paint( const Rectangle
& )
298 ImplDraw( this, 0, Point(), GetOutputSizePixel() );
301 // -----------------------------------------------------------------------
303 void FixedText::Draw( OutputDevice
* pDev
, const Point
& rPos
, const Size
& rSize
,
306 ImplInitSettings( TRUE
, TRUE
, TRUE
);
308 Point aPos
= pDev
->LogicToPixel( rPos
);
309 Size aSize
= pDev
->LogicToPixel( rSize
);
310 Font aFont
= GetDrawPixelFont( pDev
);
314 pDev
->SetFont( aFont
);
315 if ( nFlags
& WINDOW_DRAW_MONO
)
316 pDev
->SetTextColor( Color( COL_BLACK
) );
318 pDev
->SetTextColor( GetTextColor() );
319 pDev
->SetTextFillColor();
321 BOOL bBorder
= !(nFlags
& WINDOW_DRAW_NOBORDER
) && (GetStyle() & WB_BORDER
);
322 BOOL bBackground
= !(nFlags
& WINDOW_DRAW_NOBACKGROUND
) && IsControlBackground();
323 if ( bBorder
|| bBackground
)
325 Rectangle
aRect( aPos
, aSize
);
328 ImplDrawFrame( pDev
, aRect
);
332 pDev
->SetFillColor( GetControlBackground() );
333 pDev
->DrawRect( aRect
);
337 ImplDraw( pDev
, nFlags
, aPos
, aSize
);
341 // -----------------------------------------------------------------------
343 void FixedText::Resize()
349 // -----------------------------------------------------------------------
351 void FixedText::StateChanged( StateChangedType nType
)
353 Control::StateChanged( nType
);
355 if ( (nType
== STATE_CHANGE_ENABLE
) ||
356 (nType
== STATE_CHANGE_TEXT
) ||
357 (nType
== STATE_CHANGE_UPDATEMODE
) )
359 if ( IsReallyVisible() && IsUpdateMode() )
362 else if ( nType
== STATE_CHANGE_STYLE
)
364 SetStyle( ImplInitStyle( GetStyle() ) );
365 if ( (GetPrevStyle() & FIXEDTEXT_VIEW_STYLE
) !=
366 (GetStyle() & FIXEDTEXT_VIEW_STYLE
) )
368 ImplInitSettings( TRUE
, FALSE
, FALSE
);
372 else if ( (nType
== STATE_CHANGE_ZOOM
) ||
373 (nType
== STATE_CHANGE_CONTROLFONT
) )
375 ImplInitSettings( TRUE
, FALSE
, FALSE
);
378 else if ( nType
== STATE_CHANGE_CONTROLFOREGROUND
)
380 ImplInitSettings( FALSE
, TRUE
, FALSE
);
383 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
385 ImplInitSettings( FALSE
, FALSE
, TRUE
);
390 // -----------------------------------------------------------------------
392 void FixedText::DataChanged( const DataChangedEvent
& rDCEvt
)
394 Control::DataChanged( rDCEvt
);
396 if ( (rDCEvt
.GetType() == DATACHANGED_FONTS
) ||
397 (rDCEvt
.GetType() == DATACHANGED_FONTSUBSTITUTION
) ||
398 ((rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
399 (rDCEvt
.GetFlags() & SETTINGS_STYLE
)) )
401 ImplInitSettings( TRUE
, TRUE
, TRUE
);
406 // -----------------------------------------------------------------------
408 Size
FixedText::CalcMinimumTextSize( Control
const *pControl
, long nMaxWidth
)
410 USHORT nStyle
= ImplGetTextStyle( pControl
->GetStyle() );
411 if ( !( pControl
->GetStyle() & WB_NOLABEL
) )
412 nStyle
|= TEXT_DRAW_MNEMONIC
;
414 Size aSize
= pControl
->GetTextRect( Rectangle( Point(), Size( (nMaxWidth
? nMaxWidth
: 0x7fffffff), 0x7fffffff ) ),
415 pControl
->GetText(), nStyle
).GetSize();
417 if ( pControl
->GetStyle() & WB_EXTRAOFFSET
)
420 // GetTextRect verkraftet keinen leeren String:
421 if ( aSize
.Width() < 0 )
423 if ( aSize
.Height() <= 0 )
424 aSize
.Height() = pControl
->GetTextHeight();
429 Size
FixedText::CalcMinimumSize( long nMaxWidth
) const
431 return CalcWindowSize( CalcMinimumTextSize ( this, nMaxWidth
) );
433 // -----------------------------------------------------------------------
435 Size
FixedText::GetOptimalSize(WindowSizeType eType
) const
438 case WINDOWSIZE_MINIMUM
:
439 return CalcMinimumSize();
441 return Control::GetOptimalSize( eType
);
445 // -----------------------------------------------------------------------
447 void FixedText::FillLayoutData() const
449 mpLayoutData
= new vcl::ControlLayoutData();
450 ImplDraw( const_cast<FixedText
*>(this), 0, Point(), GetOutputSizePixel(), true );
453 // =======================================================================
455 void FixedLine::ImplInit( Window
* pParent
, WinBits nStyle
)
457 nStyle
= ImplInitStyle( nStyle
);
458 Control::ImplInit( pParent
, nStyle
, NULL
);
459 ImplInitSettings( TRUE
, TRUE
, TRUE
);
462 // -----------------------------------------------------------------------
464 WinBits
FixedLine::ImplInitStyle( WinBits nStyle
)
466 if ( !(nStyle
& WB_NOGROUP
) )
471 // -----------------------------------------------------------------------
473 void FixedLine::ImplInitSettings( BOOL bFont
,
474 BOOL bForeground
, BOOL bBackground
)
476 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
480 Font aFont
= rStyleSettings
.GetGroupFont();
481 if ( IsControlFont() )
482 aFont
.Merge( GetControlFont() );
483 SetZoomedPointFont( aFont
);
486 if ( bForeground
|| bFont
)
489 if ( IsControlForeground() )
490 aColor
= GetControlForeground();
492 aColor
= rStyleSettings
.GetGroupTextColor();
493 SetTextColor( aColor
);
499 Window
* pParent
= GetParent();
500 if ( pParent
->IsChildTransparentModeEnabled() && !IsControlBackground() )
502 EnableChildTransparentMode( TRUE
);
503 SetParentClipMode( PARENTCLIPMODE_NOCLIP
);
504 SetPaintTransparent( TRUE
);
509 EnableChildTransparentMode( FALSE
);
510 SetParentClipMode( 0 );
511 SetPaintTransparent( FALSE
);
513 if ( IsControlBackground() )
514 SetBackground( GetControlBackground() );
516 SetBackground( pParent
->GetBackground() );
521 // -----------------------------------------------------------------------
523 void FixedLine::ImplDraw( bool bLayout
)
525 Size aOutSize
= GetOutputSizePixel();
526 String aText
= GetText();
527 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
528 WinBits nWinStyle
= GetStyle();
529 MetricVector
* pVector
= bLayout
? &mpLayoutData
->m_aUnicodeBoundRects
: NULL
;
530 String
* pDisplayText
= bLayout
? &mpLayoutData
->m_aDisplayText
: NULL
;
532 if ( rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
)
533 SetLineColor( Color( COL_BLACK
) );
535 SetLineColor( rStyleSettings
.GetShadowColor() );
537 if ( !aText
.Len() || (nWinStyle
& WB_VERT
) )
544 if ( nWinStyle
& WB_VERT
)
546 nX
= (aOutSize
.Width()-1)/2;
547 DrawLine( Point( nX
, 0 ), Point( nX
, aOutSize
.Height()-1 ) );
551 nY
= (aOutSize
.Height()-1)/2;
552 DrawLine( Point( 0, nY
), Point( aOutSize
.Width()-1, nY
) );
555 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
557 SetLineColor( rStyleSettings
.GetLightColor() );
558 if ( nWinStyle
& WB_VERT
)
559 DrawLine( Point( nX
+1, 0 ), Point( nX
+1, aOutSize
.Height()-1 ) );
561 DrawLine( Point( 0, nY
+1 ), Point( aOutSize
.Width()-1, nY
+1 ) );
567 USHORT nStyle
= TEXT_DRAW_MNEMONIC
| TEXT_DRAW_LEFT
| TEXT_DRAW_VCENTER
| TEXT_DRAW_ENDELLIPSIS
;
568 Rectangle
aRect( 0, 0, aOutSize
.Width(), aOutSize
.Height() );
571 nStyle
|= TEXT_DRAW_DISABLE
;
572 if ( GetStyle() & WB_NOLABEL
)
573 nStyle
&= ~TEXT_DRAW_MNEMONIC
;
574 if ( rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
)
575 nStyle
|= TEXT_DRAW_MONO
;
577 aRect
= GetTextRect( aRect
, aText
, nStyle
);
578 DrawText( aRect
, aText
, nStyle
, pVector
, pDisplayText
);
582 long nTop
= aRect
.Top() + ((aRect
.GetHeight()-1)/2);
583 DrawLine( Point( aRect
.Right()+FIXEDLINE_TEXT_BORDER
, nTop
), Point( aOutSize
.Width()-1, nTop
) );
584 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
586 SetLineColor( rStyleSettings
.GetLightColor() );
587 DrawLine( Point( aRect
.Right()+FIXEDLINE_TEXT_BORDER
, nTop
+1 ), Point( aOutSize
.Width()-1, nTop
+1 ) );
593 // -----------------------------------------------------------------------
595 FixedLine::FixedLine( Window
* pParent
, WinBits nStyle
) :
596 Control( WINDOW_FIXEDLINE
)
598 ImplInit( pParent
, nStyle
);
599 SetSizePixel( Size( 2, 2 ) );
602 // -----------------------------------------------------------------------
604 FixedLine::FixedLine( Window
* pParent
, const ResId
& rResId
) :
605 Control( WINDOW_FIXEDLINE
)
607 rResId
.SetRT( RSC_FIXEDLINE
);
608 WinBits nStyle
= ImplInitRes( rResId
);
609 ImplInit( pParent
, nStyle
);
610 ImplLoadRes( rResId
);
612 if ( !(nStyle
& WB_HIDE
) )
616 // -----------------------------------------------------------------------
618 void FixedLine::FillLayoutData() const
620 mpLayoutData
= new vcl::ControlLayoutData();
621 const_cast<FixedLine
*>(this)->ImplDraw( true );
625 // -----------------------------------------------------------------------
627 void FixedLine::Paint( const Rectangle
& )
632 // -----------------------------------------------------------------------
634 void FixedLine::Draw( OutputDevice
*, const Point
&, const Size
&, ULONG
)
638 // -----------------------------------------------------------------------
640 void FixedLine::Resize()
646 // -----------------------------------------------------------------------
648 void FixedLine::StateChanged( StateChangedType nType
)
650 Control::StateChanged( nType
);
652 if ( (nType
== STATE_CHANGE_ENABLE
) ||
653 (nType
== STATE_CHANGE_TEXT
) ||
654 (nType
== STATE_CHANGE_UPDATEMODE
) )
656 if ( IsReallyVisible() && IsUpdateMode() )
659 else if ( nType
== STATE_CHANGE_STYLE
)
661 SetStyle( ImplInitStyle( GetStyle() ) );
662 if ( (GetPrevStyle() & FIXEDLINE_VIEW_STYLE
) !=
663 (GetStyle() & FIXEDLINE_VIEW_STYLE
) )
666 else if ( (nType
== STATE_CHANGE_ZOOM
) ||
667 (nType
== STATE_CHANGE_STYLE
) ||
668 (nType
== STATE_CHANGE_CONTROLFONT
) )
670 ImplInitSettings( TRUE
, FALSE
, FALSE
);
673 else if ( nType
== STATE_CHANGE_CONTROLFOREGROUND
)
675 ImplInitSettings( FALSE
, TRUE
, FALSE
);
678 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
680 ImplInitSettings( FALSE
, FALSE
, TRUE
);
685 // -----------------------------------------------------------------------
687 void FixedLine::DataChanged( const DataChangedEvent
& rDCEvt
)
689 Control::DataChanged( rDCEvt
);
691 if ( (rDCEvt
.GetType() == DATACHANGED_FONTS
) ||
692 (rDCEvt
.GetType() == DATACHANGED_FONTSUBSTITUTION
) ||
693 ((rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
694 (rDCEvt
.GetFlags() & SETTINGS_STYLE
)) )
696 ImplInitSettings( TRUE
, TRUE
, TRUE
);
701 // -----------------------------------------------------------------------
703 Size
FixedLine::GetOptimalSize(WindowSizeType eType
) const
706 case WINDOWSIZE_MINIMUM
:
707 return CalcWindowSize( FixedText::CalcMinimumTextSize ( this ) );
709 return Control::GetOptimalSize( eType
);
713 // =======================================================================
715 void FixedBitmap::ImplInit( Window
* pParent
, WinBits nStyle
)
717 nStyle
= ImplInitStyle( nStyle
);
718 Control::ImplInit( pParent
, nStyle
, NULL
);
722 // -----------------------------------------------------------------------
724 WinBits
FixedBitmap::ImplInitStyle( WinBits nStyle
)
726 if ( !(nStyle
& WB_NOGROUP
) )
731 // -----------------------------------------------------------------------
733 void FixedBitmap::ImplInitSettings()
735 Window
* pParent
= GetParent();
736 if ( pParent
->IsChildTransparentModeEnabled() && !IsControlBackground() )
738 EnableChildTransparentMode( TRUE
);
739 SetParentClipMode( PARENTCLIPMODE_NOCLIP
);
740 SetPaintTransparent( TRUE
);
745 EnableChildTransparentMode( FALSE
);
746 SetParentClipMode( 0 );
747 SetPaintTransparent( FALSE
);
749 if ( IsControlBackground() )
750 SetBackground( GetControlBackground() );
752 SetBackground( pParent
->GetBackground() );
756 // -----------------------------------------------------------------------
758 void FixedBitmap::ImplLoadRes( const ResId
& rResId
)
760 Control::ImplLoadRes( rResId
);
762 ULONG nObjMask
= ReadLongRes();
764 if ( RSC_FIXEDBITMAP_BITMAP
& nObjMask
)
766 maBitmap
= Bitmap( ResId( (RSHEADER_TYPE
*)GetClassRes(), *rResId
.GetResMgr() ) );
767 IncrementRes( GetObjSizeRes( (RSHEADER_TYPE
*)GetClassRes() ) );
771 // -----------------------------------------------------------------------
773 FixedBitmap::FixedBitmap( Window
* pParent
, WinBits nStyle
) :
774 Control( WINDOW_FIXEDBITMAP
)
776 ImplInit( pParent
, nStyle
);
779 // -----------------------------------------------------------------------
781 FixedBitmap::FixedBitmap( Window
* pParent
, const ResId
& rResId
) :
782 Control( WINDOW_FIXEDBITMAP
)
784 rResId
.SetRT( RSC_FIXEDBITMAP
);
785 WinBits nStyle
= ImplInitRes( rResId
);
786 ImplInit( pParent
, nStyle
);
787 ImplLoadRes( rResId
);
789 if ( !(nStyle
& WB_HIDE
) )
793 // -----------------------------------------------------------------------
795 FixedBitmap::~FixedBitmap()
799 // -----------------------------------------------------------------------
801 void FixedBitmap::ImplDraw( OutputDevice
* pDev
, ULONG
/* nDrawFlags */,
802 const Point
& rPos
, const Size
& rSize
)
805 Bitmap
* pBitmap
= &maBitmap
;
809 if( GetSettings().GetStyleSettings().GetHighContrastMode() )
810 pBitmap
= &maBitmapHC
;
813 if( nStyle
& IMAGE_DRAW_COLORTRANSFORM
)
815 // only images support IMAGE_DRAW_COLORTRANSFORM
816 Image
aImage( maBitmap
);
819 if ( GetStyle() & WB_SCALE
)
820 pDev
->DrawImage( rPos
, rSize
, aImage
, nStyle
);
823 Point aPos
= ImplCalcPos( GetStyle(), rPos
, aImage
.GetSizePixel(), rSize
);
824 pDev
->DrawImage( aPos
, aImage
, nStyle
);
830 // Haben wir ueberhaupt eine Bitmap
831 if ( !(!(*pBitmap
)) )
833 if ( GetStyle() & WB_SCALE
)
834 pDev
->DrawBitmap( rPos
, rSize
, *pBitmap
);
837 Point aPos
= ImplCalcPos( GetStyle(), rPos
, pBitmap
->GetSizePixel(), rSize
);
838 pDev
->DrawBitmap( aPos
, *pBitmap
);
844 // -----------------------------------------------------------------------
846 void FixedBitmap::Paint( const Rectangle
& )
848 ImplDraw( this, 0, Point(), GetOutputSizePixel() );
851 // -----------------------------------------------------------------------
853 void FixedBitmap::Draw( OutputDevice
* pDev
, const Point
& rPos
, const Size
& rSize
,
856 Point aPos
= pDev
->LogicToPixel( rPos
);
857 Size aSize
= pDev
->LogicToPixel( rSize
);
858 Rectangle
aRect( aPos
, aSize
);
864 if ( !(nFlags
& WINDOW_DRAW_NOBORDER
) && (GetStyle() & WB_BORDER
) )
866 DecorationView
aDecoView( pDev
);
867 aRect
= aDecoView
.DrawFrame( aRect
, FRAME_DRAW_DOUBLEIN
);
869 pDev
->IntersectClipRegion( aRect
);
870 ImplDraw( pDev
, nFlags
, aRect
.TopLeft(), aRect
.GetSize() );
875 // -----------------------------------------------------------------------
877 void FixedBitmap::Resize()
883 // -----------------------------------------------------------------------
885 void FixedBitmap::StateChanged( StateChangedType nType
)
887 Control::StateChanged( nType
);
889 if ( (nType
== STATE_CHANGE_DATA
) ||
890 (nType
== STATE_CHANGE_UPDATEMODE
) )
892 if ( IsReallyVisible() && IsUpdateMode() )
895 else if ( nType
== STATE_CHANGE_STYLE
)
897 SetStyle( ImplInitStyle( GetStyle() ) );
898 if ( (GetPrevStyle() & FIXEDBITMAP_VIEW_STYLE
) !=
899 (GetStyle() & FIXEDBITMAP_VIEW_STYLE
) )
902 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
909 // -----------------------------------------------------------------------
911 void FixedBitmap::DataChanged( const DataChangedEvent
& rDCEvt
)
913 Control::DataChanged( rDCEvt
);
915 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
916 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
923 // -----------------------------------------------------------------------
925 void FixedBitmap::SetBitmap( const Bitmap
& rBitmap
)
928 StateChanged( STATE_CHANGE_DATA
);
931 // -----------------------------------------------------------------------
933 BOOL
FixedBitmap::SetModeBitmap( const Bitmap
& rBitmap
, BmpColorMode eMode
)
935 if( eMode
== BMP_COLOR_NORMAL
)
936 SetBitmap( rBitmap
);
937 else if( eMode
== BMP_COLOR_HIGHCONTRAST
)
939 maBitmapHC
= rBitmap
;
940 StateChanged( STATE_CHANGE_DATA
);
947 // -----------------------------------------------------------------------
949 const Bitmap
& FixedBitmap::GetModeBitmap( BmpColorMode eMode
) const
951 if( eMode
== BMP_COLOR_HIGHCONTRAST
)
957 // =======================================================================
959 void FixedImage::ImplInit( Window
* pParent
, WinBits nStyle
)
961 nStyle
= ImplInitStyle( nStyle
);
962 mbInUserDraw
= FALSE
;
963 Control::ImplInit( pParent
, nStyle
, NULL
);
967 // -----------------------------------------------------------------------
969 WinBits
FixedImage::ImplInitStyle( WinBits nStyle
)
971 if ( !(nStyle
& WB_NOGROUP
) )
976 // -----------------------------------------------------------------------
978 void FixedImage::ImplInitSettings()
980 Window
* pParent
= GetParent();
981 if ( pParent
->IsChildTransparentModeEnabled() && !IsControlBackground() )
983 EnableChildTransparentMode( TRUE
);
984 SetParentClipMode( PARENTCLIPMODE_NOCLIP
);
985 SetPaintTransparent( TRUE
);
990 EnableChildTransparentMode( FALSE
);
991 SetParentClipMode( 0 );
992 SetPaintTransparent( FALSE
);
994 if ( IsControlBackground() )
995 SetBackground( GetControlBackground() );
997 SetBackground( pParent
->GetBackground() );
1001 // -----------------------------------------------------------------------
1003 void FixedImage::ImplLoadRes( const ResId
& rResId
)
1005 Control::ImplLoadRes( rResId
);
1007 ULONG nObjMask
= ReadLongRes();
1009 if ( RSC_FIXEDIMAGE_IMAGE
& nObjMask
)
1011 maImage
= Image( ResId( (RSHEADER_TYPE
*)GetClassRes(), *rResId
.GetResMgr() ) );
1012 IncrementRes( GetObjSizeRes( (RSHEADER_TYPE
*)GetClassRes() ) );
1016 // -----------------------------------------------------------------------
1018 FixedImage::FixedImage( Window
* pParent
, WinBits nStyle
) :
1019 Control( WINDOW_FIXEDIMAGE
)
1021 ImplInit( pParent
, nStyle
);
1024 // -----------------------------------------------------------------------
1026 FixedImage::FixedImage( Window
* pParent
, const ResId
& rResId
) :
1027 Control( WINDOW_FIXEDIMAGE
)
1029 rResId
.SetRT( RSC_FIXEDIMAGE
);
1030 WinBits nStyle
= ImplInitRes( rResId
);
1031 ImplInit( pParent
, nStyle
);
1032 ImplLoadRes( rResId
);
1034 if ( !(nStyle
& WB_HIDE
) )
1038 // -----------------------------------------------------------------------
1040 FixedImage::~FixedImage()
1044 // -----------------------------------------------------------------------
1046 void FixedImage::ImplDraw( OutputDevice
* pDev
, ULONG nDrawFlags
,
1047 const Point
& rPos
, const Size
& rSize
)
1050 if ( !(nDrawFlags
& WINDOW_DRAW_NODISABLE
) )
1053 nStyle
|= IMAGE_DRAW_DISABLE
;
1056 Image
*pImage
= &maImage
;
1060 if( GetSettings().GetStyleSettings().GetHighContrastMode() )
1061 pImage
= &maImageHC
;
1064 // Haben wir ueberhaupt ein Image
1065 if ( !(!(*pImage
)) )
1067 if ( GetStyle() & WB_SCALE
)
1068 pDev
->DrawImage( rPos
, rSize
, *pImage
, nStyle
);
1071 Point aPos
= ImplCalcPos( GetStyle(), rPos
, pImage
->GetSizePixel(), rSize
);
1072 pDev
->DrawImage( aPos
, *pImage
, nStyle
);
1076 mbInUserDraw
= TRUE
;
1077 UserDrawEvent
aUDEvt( pDev
, Rectangle( rPos
, rSize
), 0, nStyle
);
1079 mbInUserDraw
= FALSE
;
1082 // -----------------------------------------------------------------------
1084 void FixedImage::Paint( const Rectangle
& )
1086 ImplDraw( this, 0, Point(), GetOutputSizePixel() );
1089 // -----------------------------------------------------------------------
1091 void FixedImage::UserDraw( const UserDrawEvent
& )
1095 // -----------------------------------------------------------------------
1097 void FixedImage::Draw( OutputDevice
* pDev
, const Point
& rPos
, const Size
& rSize
,
1100 Point aPos
= pDev
->LogicToPixel( rPos
);
1101 Size aSize
= pDev
->LogicToPixel( rSize
);
1102 Rectangle
aRect( aPos
, aSize
);
1108 if ( !(nFlags
& WINDOW_DRAW_NOBORDER
) && (GetStyle() & WB_BORDER
) )
1110 ImplDrawFrame( pDev
, aRect
);
1112 pDev
->IntersectClipRegion( aRect
);
1113 ImplDraw( pDev
, nFlags
, aRect
.TopLeft(), aRect
.GetSize() );
1118 // -----------------------------------------------------------------------
1120 void FixedImage::Resize()
1126 // -----------------------------------------------------------------------
1128 void FixedImage::StateChanged( StateChangedType nType
)
1130 Control::StateChanged( nType
);
1132 if ( (nType
== STATE_CHANGE_ENABLE
) ||
1133 (nType
== STATE_CHANGE_DATA
) ||
1134 (nType
== STATE_CHANGE_UPDATEMODE
) )
1136 if ( IsReallyVisible() && IsUpdateMode() )
1139 else if ( nType
== STATE_CHANGE_STYLE
)
1141 SetStyle( ImplInitStyle( GetStyle() ) );
1142 if ( (GetPrevStyle() & FIXEDIMAGE_VIEW_STYLE
) !=
1143 (GetStyle() & FIXEDIMAGE_VIEW_STYLE
) )
1146 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
1153 // -----------------------------------------------------------------------
1155 void FixedImage::DataChanged( const DataChangedEvent
& rDCEvt
)
1157 Control::DataChanged( rDCEvt
);
1159 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
1160 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
1167 // -----------------------------------------------------------------------
1169 void FixedImage::SetImage( const Image
& rImage
)
1171 if ( rImage
!= maImage
)
1174 StateChanged( STATE_CHANGE_DATA
);
1178 // -----------------------------------------------------------------------
1180 BOOL
FixedImage::SetModeImage( const Image
& rImage
, BmpColorMode eMode
)
1182 if( eMode
== BMP_COLOR_NORMAL
)
1184 else if( eMode
== BMP_COLOR_HIGHCONTRAST
)
1186 if( maImageHC
!= rImage
)
1189 StateChanged( STATE_CHANGE_DATA
);
1197 // -----------------------------------------------------------------------
1199 const Image
& FixedImage::GetModeImage( BmpColorMode eMode
) const
1201 if( eMode
== BMP_COLOR_HIGHCONTRAST
)
1207 // -----------------------------------------------------------------------
1209 Point
FixedImage::CalcImagePos( const Point
& rPos
,
1210 const Size
& rObjSize
, const Size
& rWinSize
)
1212 return ImplCalcPos( GetStyle(), rPos
, rObjSize
, rWinSize
);