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
;
807 if( !!maBitmapHC
&& ImplGetCurrentBackgroundColor( aCol
) )
810 pBitmap
= &maBitmapHC
;
811 // #99902 no col transform required
812 //if( aCol.IsBright() )
813 // nStyle |= IMAGE_DRAW_COLORTRANSFORM;
816 if( nStyle
& IMAGE_DRAW_COLORTRANSFORM
)
818 // only images support IMAGE_DRAW_COLORTRANSFORM
819 Image
aImage( maBitmap
);
822 if ( GetStyle() & WB_SCALE
)
823 pDev
->DrawImage( rPos
, rSize
, aImage
, nStyle
);
826 Point aPos
= ImplCalcPos( GetStyle(), rPos
, aImage
.GetSizePixel(), rSize
);
827 pDev
->DrawImage( aPos
, aImage
, nStyle
);
833 // Haben wir ueberhaupt eine Bitmap
834 if ( !(!(*pBitmap
)) )
836 if ( GetStyle() & WB_SCALE
)
837 pDev
->DrawBitmap( rPos
, rSize
, *pBitmap
);
840 Point aPos
= ImplCalcPos( GetStyle(), rPos
, pBitmap
->GetSizePixel(), rSize
);
841 pDev
->DrawBitmap( aPos
, *pBitmap
);
847 // -----------------------------------------------------------------------
849 void FixedBitmap::Paint( const Rectangle
& )
851 ImplDraw( this, 0, Point(), GetOutputSizePixel() );
854 // -----------------------------------------------------------------------
856 void FixedBitmap::Draw( OutputDevice
* pDev
, const Point
& rPos
, const Size
& rSize
,
859 Point aPos
= pDev
->LogicToPixel( rPos
);
860 Size aSize
= pDev
->LogicToPixel( rSize
);
861 Rectangle
aRect( aPos
, aSize
);
867 if ( !(nFlags
& WINDOW_DRAW_NOBORDER
) && (GetStyle() & WB_BORDER
) )
869 DecorationView
aDecoView( pDev
);
870 aRect
= aDecoView
.DrawFrame( aRect
, FRAME_DRAW_DOUBLEIN
);
872 pDev
->IntersectClipRegion( aRect
);
873 ImplDraw( pDev
, nFlags
, aRect
.TopLeft(), aRect
.GetSize() );
878 // -----------------------------------------------------------------------
880 void FixedBitmap::Resize()
886 // -----------------------------------------------------------------------
888 void FixedBitmap::StateChanged( StateChangedType nType
)
890 Control::StateChanged( nType
);
892 if ( (nType
== STATE_CHANGE_DATA
) ||
893 (nType
== STATE_CHANGE_UPDATEMODE
) )
895 if ( IsReallyVisible() && IsUpdateMode() )
898 else if ( nType
== STATE_CHANGE_STYLE
)
900 SetStyle( ImplInitStyle( GetStyle() ) );
901 if ( (GetPrevStyle() & FIXEDBITMAP_VIEW_STYLE
) !=
902 (GetStyle() & FIXEDBITMAP_VIEW_STYLE
) )
905 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
912 // -----------------------------------------------------------------------
914 void FixedBitmap::DataChanged( const DataChangedEvent
& rDCEvt
)
916 Control::DataChanged( rDCEvt
);
918 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
919 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
926 // -----------------------------------------------------------------------
928 void FixedBitmap::SetBitmap( const Bitmap
& rBitmap
)
931 StateChanged( STATE_CHANGE_DATA
);
934 // -----------------------------------------------------------------------
936 BOOL
FixedBitmap::SetModeBitmap( const Bitmap
& rBitmap
, BmpColorMode eMode
)
938 if( eMode
== BMP_COLOR_NORMAL
)
939 SetBitmap( rBitmap
);
940 else if( eMode
== BMP_COLOR_HIGHCONTRAST
)
942 maBitmapHC
= rBitmap
;
943 StateChanged( STATE_CHANGE_DATA
);
950 // -----------------------------------------------------------------------
952 const Bitmap
& FixedBitmap::GetModeBitmap( BmpColorMode eMode
) const
954 if( eMode
== BMP_COLOR_HIGHCONTRAST
)
960 // =======================================================================
962 void FixedImage::ImplInit( Window
* pParent
, WinBits nStyle
)
964 nStyle
= ImplInitStyle( nStyle
);
965 mbInUserDraw
= FALSE
;
966 Control::ImplInit( pParent
, nStyle
, NULL
);
970 // -----------------------------------------------------------------------
972 WinBits
FixedImage::ImplInitStyle( WinBits nStyle
)
974 if ( !(nStyle
& WB_NOGROUP
) )
979 // -----------------------------------------------------------------------
981 void FixedImage::ImplInitSettings()
983 Window
* pParent
= GetParent();
984 if ( pParent
->IsChildTransparentModeEnabled() && !IsControlBackground() )
986 EnableChildTransparentMode( TRUE
);
987 SetParentClipMode( PARENTCLIPMODE_NOCLIP
);
988 SetPaintTransparent( TRUE
);
993 EnableChildTransparentMode( FALSE
);
994 SetParentClipMode( 0 );
995 SetPaintTransparent( FALSE
);
997 if ( IsControlBackground() )
998 SetBackground( GetControlBackground() );
1000 SetBackground( pParent
->GetBackground() );
1004 // -----------------------------------------------------------------------
1006 void FixedImage::ImplLoadRes( const ResId
& rResId
)
1008 Control::ImplLoadRes( rResId
);
1010 ULONG nObjMask
= ReadLongRes();
1012 if ( RSC_FIXEDIMAGE_IMAGE
& nObjMask
)
1014 maImage
= Image( ResId( (RSHEADER_TYPE
*)GetClassRes(), *rResId
.GetResMgr() ) );
1015 IncrementRes( GetObjSizeRes( (RSHEADER_TYPE
*)GetClassRes() ) );
1019 // -----------------------------------------------------------------------
1021 FixedImage::FixedImage( Window
* pParent
, WinBits nStyle
) :
1022 Control( WINDOW_FIXEDIMAGE
)
1024 ImplInit( pParent
, nStyle
);
1027 // -----------------------------------------------------------------------
1029 FixedImage::FixedImage( Window
* pParent
, const ResId
& rResId
) :
1030 Control( WINDOW_FIXEDIMAGE
)
1032 rResId
.SetRT( RSC_FIXEDIMAGE
);
1033 WinBits nStyle
= ImplInitRes( rResId
);
1034 ImplInit( pParent
, nStyle
);
1035 ImplLoadRes( rResId
);
1037 if ( !(nStyle
& WB_HIDE
) )
1041 // -----------------------------------------------------------------------
1043 FixedImage::~FixedImage()
1047 // -----------------------------------------------------------------------
1049 void FixedImage::ImplDraw( OutputDevice
* pDev
, ULONG nDrawFlags
,
1050 const Point
& rPos
, const Size
& rSize
)
1053 if ( !(nDrawFlags
& WINDOW_DRAW_NODISABLE
) )
1056 nStyle
|= IMAGE_DRAW_DISABLE
;
1059 Image
*pImage
= &maImage
;
1061 if( !!maImageHC
&& ImplGetCurrentBackgroundColor( aCol
) )
1064 pImage
= &maImageHC
;
1065 // #99902 no col transform required
1066 //if( aCol.IsBright() )
1067 // nStyle |= IMAGE_DRAW_COLORTRANSFORM;
1070 // Haben wir ueberhaupt ein Image
1071 if ( !(!(*pImage
)) )
1073 if ( GetStyle() & WB_SCALE
)
1074 pDev
->DrawImage( rPos
, rSize
, *pImage
, nStyle
);
1077 Point aPos
= ImplCalcPos( GetStyle(), rPos
, pImage
->GetSizePixel(), rSize
);
1078 pDev
->DrawImage( aPos
, *pImage
, nStyle
);
1082 mbInUserDraw
= TRUE
;
1083 UserDrawEvent
aUDEvt( pDev
, Rectangle( rPos
, rSize
), 0, nStyle
);
1085 mbInUserDraw
= FALSE
;
1088 // -----------------------------------------------------------------------
1090 void FixedImage::Paint( const Rectangle
& )
1092 ImplDraw( this, 0, Point(), GetOutputSizePixel() );
1095 // -----------------------------------------------------------------------
1097 void FixedImage::UserDraw( const UserDrawEvent
& )
1101 // -----------------------------------------------------------------------
1103 void FixedImage::Draw( OutputDevice
* pDev
, const Point
& rPos
, const Size
& rSize
,
1106 Point aPos
= pDev
->LogicToPixel( rPos
);
1107 Size aSize
= pDev
->LogicToPixel( rSize
);
1108 Rectangle
aRect( aPos
, aSize
);
1114 if ( !(nFlags
& WINDOW_DRAW_NOBORDER
) && (GetStyle() & WB_BORDER
) )
1116 ImplDrawFrame( pDev
, aRect
);
1118 pDev
->IntersectClipRegion( aRect
);
1119 ImplDraw( pDev
, nFlags
, aRect
.TopLeft(), aRect
.GetSize() );
1124 // -----------------------------------------------------------------------
1126 void FixedImage::Resize()
1132 // -----------------------------------------------------------------------
1134 void FixedImage::StateChanged( StateChangedType nType
)
1136 Control::StateChanged( nType
);
1138 if ( (nType
== STATE_CHANGE_ENABLE
) ||
1139 (nType
== STATE_CHANGE_DATA
) ||
1140 (nType
== STATE_CHANGE_UPDATEMODE
) )
1142 if ( IsReallyVisible() && IsUpdateMode() )
1145 else if ( nType
== STATE_CHANGE_STYLE
)
1147 SetStyle( ImplInitStyle( GetStyle() ) );
1148 if ( (GetPrevStyle() & FIXEDIMAGE_VIEW_STYLE
) !=
1149 (GetStyle() & FIXEDIMAGE_VIEW_STYLE
) )
1152 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
1159 // -----------------------------------------------------------------------
1161 void FixedImage::DataChanged( const DataChangedEvent
& rDCEvt
)
1163 Control::DataChanged( rDCEvt
);
1165 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
1166 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
1173 // -----------------------------------------------------------------------
1175 void FixedImage::SetImage( const Image
& rImage
)
1177 if ( rImage
!= maImage
)
1180 StateChanged( STATE_CHANGE_DATA
);
1184 // -----------------------------------------------------------------------
1186 BOOL
FixedImage::SetModeImage( const Image
& rImage
, BmpColorMode eMode
)
1188 if( eMode
== BMP_COLOR_NORMAL
)
1190 else if( eMode
== BMP_COLOR_HIGHCONTRAST
)
1192 if( maImageHC
!= rImage
)
1195 StateChanged( STATE_CHANGE_DATA
);
1203 // -----------------------------------------------------------------------
1205 const Image
& FixedImage::GetModeImage( BmpColorMode eMode
) const
1207 if( eMode
== BMP_COLOR_HIGHCONTRAST
)
1213 // -----------------------------------------------------------------------
1215 Point
FixedImage::CalcImagePos( const Point
& rPos
,
1216 const Size
& rObjSize
, const Size
& rWinSize
)
1218 return ImplCalcPos( GetStyle(), rPos
, rObjSize
, rWinSize
);