xref: /aoo41x/main/vcl/source/control/fixed.cxx (revision 9f62ea84)
1*9f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9f62ea84SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9f62ea84SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9f62ea84SAndrew Rist  * distributed with this work for additional information
6*9f62ea84SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9f62ea84SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9f62ea84SAndrew Rist  * "License"); you may not use this file except in compliance
9*9f62ea84SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9f62ea84SAndrew Rist  *
11*9f62ea84SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9f62ea84SAndrew Rist  *
13*9f62ea84SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9f62ea84SAndrew Rist  * software distributed under the License is distributed on an
15*9f62ea84SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9f62ea84SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9f62ea84SAndrew Rist  * specific language governing permissions and limitations
18*9f62ea84SAndrew Rist  * under the License.
19*9f62ea84SAndrew Rist  *
20*9f62ea84SAndrew Rist  *************************************************************/
21*9f62ea84SAndrew Rist 
22*9f62ea84SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "tools/rc.h"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "vcl/decoview.hxx"
30cdf0e10cSrcweir #include "vcl/event.hxx"
31cdf0e10cSrcweir #include "vcl/fixed.hxx"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include "controldata.hxx"
34cdf0e10cSrcweir #include "window.h"
35cdf0e10cSrcweir 
36cdf0e10cSrcweir // =======================================================================
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #define FIXEDLINE_TEXT_BORDER	 4
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #define FIXEDTEXT_VIEW_STYLE	(WB_3DLOOK |						\
41cdf0e10cSrcweir 								 WB_LEFT | WB_CENTER | WB_RIGHT |	\
42cdf0e10cSrcweir 								 WB_TOP | WB_VCENTER | WB_BOTTOM |	\
43cdf0e10cSrcweir 								 WB_WORDBREAK | WB_NOLABEL |		\
44cdf0e10cSrcweir 								 WB_INFO | WB_PATHELLIPSIS)
45cdf0e10cSrcweir #define FIXEDLINE_VIEW_STYLE	(WB_3DLOOK | WB_NOLABEL)
46cdf0e10cSrcweir #define FIXEDBITMAP_VIEW_STYLE	(WB_3DLOOK |						\
47cdf0e10cSrcweir 								 WB_LEFT | WB_CENTER | WB_RIGHT |	\
48cdf0e10cSrcweir 								 WB_TOP | WB_VCENTER | WB_BOTTOM |	\
49cdf0e10cSrcweir 								 WB_SCALE)
50cdf0e10cSrcweir #define FIXEDIMAGE_VIEW_STYLE	(WB_3DLOOK |						\
51cdf0e10cSrcweir 								 WB_LEFT | WB_CENTER | WB_RIGHT |	\
52cdf0e10cSrcweir 								 WB_TOP | WB_VCENTER | WB_BOTTOM |	\
53cdf0e10cSrcweir 								 WB_SCALE)
54cdf0e10cSrcweir 
55cdf0e10cSrcweir // =======================================================================
56cdf0e10cSrcweir 
ImplCalcPos(WinBits nStyle,const Point & rPos,const Size & rObjSize,const Size & rWinSize)57cdf0e10cSrcweir static Point ImplCalcPos( WinBits nStyle, const Point& rPos,
58cdf0e10cSrcweir 						  const Size& rObjSize, const Size& rWinSize )
59cdf0e10cSrcweir {
60cdf0e10cSrcweir 	long	nX;
61cdf0e10cSrcweir 	long	nY;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 	if ( nStyle & WB_LEFT )
64cdf0e10cSrcweir 		nX = 0;
65cdf0e10cSrcweir 	else if ( nStyle & WB_RIGHT )
66cdf0e10cSrcweir 		nX = rWinSize.Width()-rObjSize.Width();
67cdf0e10cSrcweir 	else
68cdf0e10cSrcweir 		nX = (rWinSize.Width()-rObjSize.Width())/2;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	if ( nStyle & WB_TOP )
71cdf0e10cSrcweir 		nY = 0;
72cdf0e10cSrcweir 	else if ( nStyle & WB_BOTTOM )
73cdf0e10cSrcweir 		nY = rWinSize.Height()-rObjSize.Height();
74cdf0e10cSrcweir 	else
75cdf0e10cSrcweir 		nY = (rWinSize.Height()-rObjSize.Height())/2;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	if ( nStyle & WB_TOPLEFTVISIBLE )
78cdf0e10cSrcweir 	{
79cdf0e10cSrcweir 		if ( nX < 0 )
80cdf0e10cSrcweir 			nX = 0;
81cdf0e10cSrcweir 		if ( nY < 0 )
82cdf0e10cSrcweir 			nY = 0;
83cdf0e10cSrcweir 	}
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	Point aPos( nX+rPos.X(), nY+rPos.Y() );
86cdf0e10cSrcweir 	return aPos;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir // =======================================================================
90cdf0e10cSrcweir 
ImplInit(Window * pParent,WinBits nStyle)91cdf0e10cSrcweir void FixedText::ImplInit( Window* pParent, WinBits nStyle )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir 	nStyle = ImplInitStyle( nStyle );
94cdf0e10cSrcweir 	Control::ImplInit( pParent, nStyle, NULL );
95cdf0e10cSrcweir 	ImplInitSettings( sal_True, sal_True, sal_True );
96cdf0e10cSrcweir }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir // -----------------------------------------------------------------------
99cdf0e10cSrcweir 
ImplInitStyle(WinBits nStyle)100cdf0e10cSrcweir WinBits FixedText::ImplInitStyle( WinBits nStyle )
101cdf0e10cSrcweir {
102cdf0e10cSrcweir 	if ( !(nStyle & WB_NOGROUP) )
103cdf0e10cSrcweir 		nStyle |= WB_GROUP;
104cdf0e10cSrcweir 	return nStyle;
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir // -----------------------------------------------------------------
108cdf0e10cSrcweir 
GetCanonicalFont(const StyleSettings & _rStyle) const109cdf0e10cSrcweir const Font& FixedText::GetCanonicalFont( const StyleSettings& _rStyle ) const
110cdf0e10cSrcweir {
111cdf0e10cSrcweir     return ( GetStyle() & WB_INFO ) ? _rStyle.GetInfoFont() : _rStyle.GetLabelFont();
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir // -----------------------------------------------------------------
GetCanonicalTextColor(const StyleSettings & _rStyle) const115cdf0e10cSrcweir const Color& FixedText::GetCanonicalTextColor( const StyleSettings& _rStyle ) const
116cdf0e10cSrcweir {
117cdf0e10cSrcweir     return ( GetStyle() & WB_INFO ) ? _rStyle.GetInfoTextColor() : _rStyle.GetLabelTextColor();
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir // -----------------------------------------------------------------------
121cdf0e10cSrcweir 
ImplInitSettings(sal_Bool bFont,sal_Bool bForeground,sal_Bool bBackground)122cdf0e10cSrcweir void FixedText::ImplInitSettings( sal_Bool bFont,
123cdf0e10cSrcweir 								  sal_Bool bForeground, sal_Bool bBackground )
124cdf0e10cSrcweir {
125cdf0e10cSrcweir     Control::ImplInitSettings( bFont, bForeground );
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	if ( bBackground )
128cdf0e10cSrcweir 	{
129cdf0e10cSrcweir 		Window* pParent = GetParent();
130cdf0e10cSrcweir 		if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
131cdf0e10cSrcweir 		{
132cdf0e10cSrcweir 			EnableChildTransparentMode( sal_True );
133cdf0e10cSrcweir 			SetParentClipMode( PARENTCLIPMODE_NOCLIP );
134cdf0e10cSrcweir 			SetPaintTransparent( sal_True );
135cdf0e10cSrcweir 			SetBackground();
136cdf0e10cSrcweir 		}
137cdf0e10cSrcweir 		else
138cdf0e10cSrcweir 		{
139cdf0e10cSrcweir 			EnableChildTransparentMode( sal_False );
140cdf0e10cSrcweir 			SetParentClipMode( 0 );
141cdf0e10cSrcweir 			SetPaintTransparent( sal_False );
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 			if ( IsControlBackground() )
144cdf0e10cSrcweir 				SetBackground( GetControlBackground() );
145cdf0e10cSrcweir 			else
146cdf0e10cSrcweir 				SetBackground( pParent->GetBackground() );
147cdf0e10cSrcweir 		}
148cdf0e10cSrcweir 	}
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir // -----------------------------------------------------------------------
152cdf0e10cSrcweir 
FixedText(Window * pParent,WinBits nStyle)153cdf0e10cSrcweir FixedText::FixedText( Window* pParent, WinBits nStyle ) :
154cdf0e10cSrcweir 	Control( WINDOW_FIXEDTEXT )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir 	ImplInit( pParent, nStyle );
157cdf0e10cSrcweir }
158cdf0e10cSrcweir 
159cdf0e10cSrcweir // -----------------------------------------------------------------------
160cdf0e10cSrcweir 
FixedText(Window * pParent,const ResId & rResId)161cdf0e10cSrcweir FixedText::FixedText( Window* pParent, const ResId& rResId ) :
162cdf0e10cSrcweir 	Control( WINDOW_FIXEDTEXT )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir 	rResId.SetRT( RSC_TEXT );
165cdf0e10cSrcweir 	WinBits nStyle = ImplInitRes( rResId );
166cdf0e10cSrcweir 	ImplInit( pParent, nStyle );
167cdf0e10cSrcweir 	ImplLoadRes( rResId );
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	if ( !(nStyle & WB_HIDE) )
170cdf0e10cSrcweir 		Show();
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir // -----------------------------------------------------------------------
174cdf0e10cSrcweir 
FixedText(Window * pParent,const ResId & rResId,bool bDisableAccessibleLabelForRelation)175cdf0e10cSrcweir FixedText::FixedText( Window* pParent, const ResId& rResId, bool bDisableAccessibleLabelForRelation ) :
176cdf0e10cSrcweir     Control( WINDOW_FIXEDTEXT )
177cdf0e10cSrcweir {
178cdf0e10cSrcweir     rResId.SetRT( RSC_TEXT );
179cdf0e10cSrcweir     WinBits nStyle = ImplInitRes( rResId );
180cdf0e10cSrcweir     ImplInit( pParent, nStyle );
181cdf0e10cSrcweir     ImplLoadRes( rResId );
182cdf0e10cSrcweir     if ( bDisableAccessibleLabelForRelation )
183cdf0e10cSrcweir         ImplGetWindowImpl()->mbDisableAccessibleLabelForRelation = sal_True;
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     if ( !(nStyle & WB_HIDE) )
186cdf0e10cSrcweir         Show();
187cdf0e10cSrcweir }
188cdf0e10cSrcweir 
189cdf0e10cSrcweir // -----------------------------------------------------------------------
190cdf0e10cSrcweir 
ImplGetTextStyle(WinBits nWinStyle)191cdf0e10cSrcweir sal_uInt16 FixedText::ImplGetTextStyle( WinBits nWinStyle )
192cdf0e10cSrcweir {
193cdf0e10cSrcweir 	sal_uInt16 nTextStyle = TEXT_DRAW_MNEMONIC | TEXT_DRAW_ENDELLIPSIS;
194cdf0e10cSrcweir 
195cdf0e10cSrcweir     if( ! (nWinStyle & WB_NOMULTILINE) )
196cdf0e10cSrcweir         nTextStyle |= TEXT_DRAW_MULTILINE;
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 	if ( nWinStyle & WB_RIGHT )
199cdf0e10cSrcweir 		nTextStyle |= TEXT_DRAW_RIGHT;
200cdf0e10cSrcweir 	else if ( nWinStyle & WB_CENTER )
201cdf0e10cSrcweir 		nTextStyle |= TEXT_DRAW_CENTER;
202cdf0e10cSrcweir 	else
203cdf0e10cSrcweir 		nTextStyle |= TEXT_DRAW_LEFT;
204cdf0e10cSrcweir 	if ( nWinStyle & WB_BOTTOM )
205cdf0e10cSrcweir 		nTextStyle |= TEXT_DRAW_BOTTOM;
206cdf0e10cSrcweir 	else if ( nWinStyle & WB_VCENTER )
207cdf0e10cSrcweir 		nTextStyle |= TEXT_DRAW_VCENTER;
208cdf0e10cSrcweir 	else
209cdf0e10cSrcweir 		nTextStyle |= TEXT_DRAW_TOP;
210cdf0e10cSrcweir 	if ( nWinStyle & WB_WORDBREAK )
211cdf0e10cSrcweir     {
212cdf0e10cSrcweir 		nTextStyle |= TEXT_DRAW_WORDBREAK;
213cdf0e10cSrcweir         if ( (nWinStyle & WB_HYPHENATION ) == WB_HYPHENATION )
214cdf0e10cSrcweir             nTextStyle |= TEXT_DRAW_WORDBREAK_HYPHENATION;
215cdf0e10cSrcweir     }
216cdf0e10cSrcweir 	if ( nWinStyle & WB_NOLABEL )
217cdf0e10cSrcweir 		nTextStyle &= ~TEXT_DRAW_MNEMONIC;
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 	return nTextStyle;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir 
222cdf0e10cSrcweir // -----------------------------------------------------------------------
223cdf0e10cSrcweir 
ImplDraw(OutputDevice * pDev,sal_uLong nDrawFlags,const Point & rPos,const Size & rSize,bool bFillLayout) const224cdf0e10cSrcweir void FixedText::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
225cdf0e10cSrcweir 						  const Point& rPos, const Size& rSize,
226cdf0e10cSrcweir                           bool bFillLayout
227cdf0e10cSrcweir                           ) const
228cdf0e10cSrcweir {
229cdf0e10cSrcweir 	const StyleSettings&	rStyleSettings = GetSettings().GetStyleSettings();
230cdf0e10cSrcweir 	WinBits 				nWinStyle = GetStyle();
231cdf0e10cSrcweir 	XubString				aText( GetText() );
232cdf0e10cSrcweir 	sal_uInt16					nTextStyle = FixedText::ImplGetTextStyle( nWinStyle );
233cdf0e10cSrcweir     Point                   aPos = rPos;
234cdf0e10cSrcweir 
235cdf0e10cSrcweir     if ( nWinStyle & WB_EXTRAOFFSET )
236cdf0e10cSrcweir         aPos.X() += 2;
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 	if ( nWinStyle & WB_PATHELLIPSIS )
239cdf0e10cSrcweir 	{
240cdf0e10cSrcweir 		nTextStyle &= ~(TEXT_DRAW_ENDELLIPSIS | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK);
241cdf0e10cSrcweir 		nTextStyle |= TEXT_DRAW_PATHELLIPSIS;
242cdf0e10cSrcweir 	}
243cdf0e10cSrcweir 	if ( nDrawFlags & WINDOW_DRAW_NOMNEMONIC )
244cdf0e10cSrcweir 	{
245cdf0e10cSrcweir 		if ( nTextStyle & TEXT_DRAW_MNEMONIC )
246cdf0e10cSrcweir 		{
247cdf0e10cSrcweir 			aText = GetNonMnemonicString( aText );
248cdf0e10cSrcweir 			nTextStyle &= ~TEXT_DRAW_MNEMONIC;
249cdf0e10cSrcweir 		}
250cdf0e10cSrcweir 	}
251cdf0e10cSrcweir 	if ( !(nDrawFlags & WINDOW_DRAW_NODISABLE) )
252cdf0e10cSrcweir 	{
253cdf0e10cSrcweir 		if ( !IsEnabled() )
254cdf0e10cSrcweir 			nTextStyle |= TEXT_DRAW_DISABLE;
255cdf0e10cSrcweir 	}
256cdf0e10cSrcweir 	if ( (nDrawFlags & WINDOW_DRAW_MONO) ||
257cdf0e10cSrcweir 		 (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
258cdf0e10cSrcweir 		nTextStyle |= TEXT_DRAW_MONO;
259cdf0e10cSrcweir 
260cdf0e10cSrcweir     if( bFillLayout )
261cdf0e10cSrcweir         mpControlData->mpLayoutData->m_aDisplayText = String();
262cdf0e10cSrcweir 
263cdf0e10cSrcweir     Rectangle aRect( Rectangle( aPos, rSize ) );
264cdf0e10cSrcweir     DrawControlText( *pDev, aRect, aText, nTextStyle,
265cdf0e10cSrcweir         bFillLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL,
266cdf0e10cSrcweir         bFillLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL
267cdf0e10cSrcweir     );
268cdf0e10cSrcweir }
269cdf0e10cSrcweir 
270cdf0e10cSrcweir // -----------------------------------------------------------------------
271cdf0e10cSrcweir 
Paint(const Rectangle &)272cdf0e10cSrcweir void FixedText::Paint( const Rectangle& )
273cdf0e10cSrcweir {
274cdf0e10cSrcweir 	ImplDraw( this, 0, Point(), GetOutputSizePixel() );
275cdf0e10cSrcweir }
276cdf0e10cSrcweir 
277cdf0e10cSrcweir // -----------------------------------------------------------------------
278cdf0e10cSrcweir 
Draw(OutputDevice * pDev,const Point & rPos,const Size & rSize,sal_uLong nFlags)279cdf0e10cSrcweir void FixedText::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
280cdf0e10cSrcweir 					  sal_uLong nFlags )
281cdf0e10cSrcweir {
282cdf0e10cSrcweir 	ImplInitSettings( sal_True, sal_True, sal_True );
283cdf0e10cSrcweir 
284cdf0e10cSrcweir 	Point		aPos  = pDev->LogicToPixel( rPos );
285cdf0e10cSrcweir 	Size		aSize = pDev->LogicToPixel( rSize );
286cdf0e10cSrcweir 	Font		aFont = GetDrawPixelFont( pDev );
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 	pDev->Push();
289cdf0e10cSrcweir 	pDev->SetMapMode();
290cdf0e10cSrcweir 	pDev->SetFont( aFont );
291cdf0e10cSrcweir 	if ( nFlags & WINDOW_DRAW_MONO )
292cdf0e10cSrcweir 		pDev->SetTextColor( Color( COL_BLACK ) );
293cdf0e10cSrcweir 	else
294cdf0e10cSrcweir 		pDev->SetTextColor( GetTextColor() );
295cdf0e10cSrcweir 	pDev->SetTextFillColor();
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 	sal_Bool bBorder = !(nFlags & WINDOW_DRAW_NOBORDER ) && (GetStyle() & WB_BORDER);
298cdf0e10cSrcweir 	sal_Bool bBackground = !(nFlags & WINDOW_DRAW_NOBACKGROUND) && IsControlBackground();
299cdf0e10cSrcweir 	if ( bBorder || bBackground )
300cdf0e10cSrcweir 	{
301cdf0e10cSrcweir 		Rectangle aRect( aPos, aSize );
302cdf0e10cSrcweir 		if ( bBorder )
303cdf0e10cSrcweir 		{
304cdf0e10cSrcweir             ImplDrawFrame( pDev, aRect );
305cdf0e10cSrcweir 		}
306cdf0e10cSrcweir 		if ( bBackground )
307cdf0e10cSrcweir 		{
308cdf0e10cSrcweir 			pDev->SetFillColor( GetControlBackground() );
309cdf0e10cSrcweir 			pDev->DrawRect( aRect );
310cdf0e10cSrcweir 		}
311cdf0e10cSrcweir 	}
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 	ImplDraw( pDev, nFlags, aPos, aSize );
314cdf0e10cSrcweir 	pDev->Pop();
315cdf0e10cSrcweir }
316cdf0e10cSrcweir 
317cdf0e10cSrcweir // -----------------------------------------------------------------------
318cdf0e10cSrcweir 
Resize()319cdf0e10cSrcweir void FixedText::Resize()
320cdf0e10cSrcweir {
321cdf0e10cSrcweir     Control::Resize();
322cdf0e10cSrcweir 	Invalidate();
323cdf0e10cSrcweir }
324cdf0e10cSrcweir 
325cdf0e10cSrcweir // -----------------------------------------------------------------------
326cdf0e10cSrcweir 
StateChanged(StateChangedType nType)327cdf0e10cSrcweir void FixedText::StateChanged( StateChangedType nType )
328cdf0e10cSrcweir {
329cdf0e10cSrcweir 	Control::StateChanged( nType );
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 	if ( (nType == STATE_CHANGE_ENABLE) ||
332cdf0e10cSrcweir 		 (nType == STATE_CHANGE_TEXT) ||
333cdf0e10cSrcweir 		 (nType == STATE_CHANGE_UPDATEMODE) )
334cdf0e10cSrcweir 	{
335cdf0e10cSrcweir 		if ( IsReallyVisible() && IsUpdateMode() )
336cdf0e10cSrcweir 			Invalidate();
337cdf0e10cSrcweir 	}
338cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_STYLE )
339cdf0e10cSrcweir 	{
340cdf0e10cSrcweir 		SetStyle( ImplInitStyle( GetStyle() ) );
341cdf0e10cSrcweir 		if ( (GetPrevStyle() & FIXEDTEXT_VIEW_STYLE) !=
342cdf0e10cSrcweir 			 (GetStyle() & FIXEDTEXT_VIEW_STYLE) )
343cdf0e10cSrcweir 		{
344cdf0e10cSrcweir 			ImplInitSettings( sal_True, sal_False, sal_False );
345cdf0e10cSrcweir 			Invalidate();
346cdf0e10cSrcweir 		}
347cdf0e10cSrcweir 	}
348cdf0e10cSrcweir 	else if ( (nType == STATE_CHANGE_ZOOM)	||
349cdf0e10cSrcweir 			  (nType == STATE_CHANGE_CONTROLFONT) )
350cdf0e10cSrcweir 	{
351cdf0e10cSrcweir 		ImplInitSettings( sal_True, sal_False, sal_False );
352cdf0e10cSrcweir 		Invalidate();
353cdf0e10cSrcweir 	}
354cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
355cdf0e10cSrcweir 	{
356cdf0e10cSrcweir 		ImplInitSettings( sal_False, sal_True, sal_False );
357cdf0e10cSrcweir 		Invalidate();
358cdf0e10cSrcweir 	}
359cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
360cdf0e10cSrcweir 	{
361cdf0e10cSrcweir 		ImplInitSettings( sal_False, sal_False, sal_True );
362cdf0e10cSrcweir 		Invalidate();
363cdf0e10cSrcweir 	}
364cdf0e10cSrcweir }
365cdf0e10cSrcweir 
366cdf0e10cSrcweir // -----------------------------------------------------------------------
367cdf0e10cSrcweir 
DataChanged(const DataChangedEvent & rDCEvt)368cdf0e10cSrcweir void FixedText::DataChanged( const DataChangedEvent& rDCEvt )
369cdf0e10cSrcweir {
370cdf0e10cSrcweir 	Control::DataChanged( rDCEvt );
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 	if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
373cdf0e10cSrcweir 		 (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
374cdf0e10cSrcweir 		 ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
375cdf0e10cSrcweir 		  (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
376cdf0e10cSrcweir 	{
377cdf0e10cSrcweir 		ImplInitSettings( sal_True, sal_True, sal_True );
378cdf0e10cSrcweir 		Invalidate();
379cdf0e10cSrcweir 	}
380cdf0e10cSrcweir }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir // -----------------------------------------------------------------------
383cdf0e10cSrcweir 
CalcMinimumTextSize(Control const * pControl,long nMaxWidth)384cdf0e10cSrcweir Size FixedText::CalcMinimumTextSize( Control const *pControl, long nMaxWidth )
385cdf0e10cSrcweir {
386cdf0e10cSrcweir 	sal_uInt16 nStyle = ImplGetTextStyle( pControl->GetStyle() );
387cdf0e10cSrcweir 	if ( !( pControl->GetStyle() & WB_NOLABEL ) )
388cdf0e10cSrcweir 		nStyle |= TEXT_DRAW_MNEMONIC;
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 	Size aSize = pControl->GetTextRect( Rectangle( Point(), Size( (nMaxWidth ? nMaxWidth : 0x7fffffff), 0x7fffffff ) ),
391cdf0e10cSrcweir 									   pControl->GetText(), nStyle ).GetSize();
392cdf0e10cSrcweir 
393cdf0e10cSrcweir     if ( pControl->GetStyle() & WB_EXTRAOFFSET )
394cdf0e10cSrcweir         aSize.Width() += 2;
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 	// GetTextRect verkraftet keinen leeren String:
397cdf0e10cSrcweir 	if ( aSize.Width() < 0 )
398cdf0e10cSrcweir 		aSize.Width() = 0;
399cdf0e10cSrcweir 	if ( aSize.Height() <= 0 )
400cdf0e10cSrcweir 		aSize.Height() = pControl->GetTextHeight();
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 	return aSize;
403cdf0e10cSrcweir }
404cdf0e10cSrcweir 
CalcMinimumSize(long nMaxWidth) const405cdf0e10cSrcweir Size FixedText::CalcMinimumSize( long nMaxWidth ) const
406cdf0e10cSrcweir {
407cdf0e10cSrcweir 	return CalcWindowSize( CalcMinimumTextSize ( this, nMaxWidth ) );
408cdf0e10cSrcweir }
409cdf0e10cSrcweir // -----------------------------------------------------------------------
410cdf0e10cSrcweir 
GetOptimalSize(WindowSizeType eType) const411cdf0e10cSrcweir Size FixedText::GetOptimalSize(WindowSizeType eType) const
412cdf0e10cSrcweir {
413cdf0e10cSrcweir     switch (eType) {
414cdf0e10cSrcweir     case WINDOWSIZE_MINIMUM:
415cdf0e10cSrcweir         return CalcMinimumSize();
416cdf0e10cSrcweir     default:
417cdf0e10cSrcweir         return Control::GetOptimalSize( eType );
418cdf0e10cSrcweir     }
419cdf0e10cSrcweir }
420cdf0e10cSrcweir 
421cdf0e10cSrcweir // -----------------------------------------------------------------------
422cdf0e10cSrcweir 
FillLayoutData() const423cdf0e10cSrcweir void  FixedText::FillLayoutData() const
424cdf0e10cSrcweir {
425cdf0e10cSrcweir     mpControlData->mpLayoutData = new vcl::ControlLayoutData();
426cdf0e10cSrcweir     ImplDraw( const_cast<FixedText*>(this), 0, Point(), GetOutputSizePixel(), true );
427cdf0e10cSrcweir }
428cdf0e10cSrcweir 
429cdf0e10cSrcweir // =======================================================================
430cdf0e10cSrcweir 
ImplInit(Window * pParent,WinBits nStyle)431cdf0e10cSrcweir void FixedLine::ImplInit( Window* pParent, WinBits nStyle )
432cdf0e10cSrcweir {
433cdf0e10cSrcweir 	nStyle = ImplInitStyle( nStyle );
434cdf0e10cSrcweir 	Control::ImplInit( pParent, nStyle, NULL );
435cdf0e10cSrcweir 	ImplInitSettings( sal_True, sal_True, sal_True );
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir // -----------------------------------------------------------------------
439cdf0e10cSrcweir 
ImplInitStyle(WinBits nStyle)440cdf0e10cSrcweir WinBits FixedLine::ImplInitStyle( WinBits nStyle )
441cdf0e10cSrcweir {
442cdf0e10cSrcweir 	if ( !(nStyle & WB_NOGROUP) )
443cdf0e10cSrcweir 		nStyle |= WB_GROUP;
444cdf0e10cSrcweir 	return nStyle;
445cdf0e10cSrcweir }
446cdf0e10cSrcweir 
447cdf0e10cSrcweir // -----------------------------------------------------------------
448cdf0e10cSrcweir 
GetCanonicalFont(const StyleSettings & _rStyle) const449cdf0e10cSrcweir const Font& FixedLine::GetCanonicalFont( const StyleSettings& _rStyle ) const
450cdf0e10cSrcweir {
451cdf0e10cSrcweir     return _rStyle.GetGroupFont();
452cdf0e10cSrcweir }
453cdf0e10cSrcweir 
454cdf0e10cSrcweir // -----------------------------------------------------------------
GetCanonicalTextColor(const StyleSettings & _rStyle) const455cdf0e10cSrcweir const Color& FixedLine::GetCanonicalTextColor( const StyleSettings& _rStyle ) const
456cdf0e10cSrcweir {
457cdf0e10cSrcweir     return _rStyle.GetGroupTextColor();
458cdf0e10cSrcweir }
459cdf0e10cSrcweir 
460cdf0e10cSrcweir // -----------------------------------------------------------------------
461cdf0e10cSrcweir 
ImplInitSettings(sal_Bool bFont,sal_Bool bForeground,sal_Bool bBackground)462cdf0e10cSrcweir void FixedLine::ImplInitSettings( sal_Bool bFont,
463cdf0e10cSrcweir 								  sal_Bool bForeground, sal_Bool bBackground )
464cdf0e10cSrcweir {
465cdf0e10cSrcweir     Control::ImplInitSettings( bFont, bForeground );
466cdf0e10cSrcweir 
467cdf0e10cSrcweir     if ( bBackground )
468cdf0e10cSrcweir 	{
469cdf0e10cSrcweir 		Window* pParent = GetParent();
470cdf0e10cSrcweir 		if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
471cdf0e10cSrcweir 		{
472cdf0e10cSrcweir 			EnableChildTransparentMode( sal_True );
473cdf0e10cSrcweir 			SetParentClipMode( PARENTCLIPMODE_NOCLIP );
474cdf0e10cSrcweir 			SetPaintTransparent( sal_True );
475cdf0e10cSrcweir 			SetBackground();
476cdf0e10cSrcweir 		}
477cdf0e10cSrcweir 		else
478cdf0e10cSrcweir 		{
479cdf0e10cSrcweir 			EnableChildTransparentMode( sal_False );
480cdf0e10cSrcweir 			SetParentClipMode( 0 );
481cdf0e10cSrcweir 			SetPaintTransparent( sal_False );
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 			if ( IsControlBackground() )
484cdf0e10cSrcweir 				SetBackground( GetControlBackground() );
485cdf0e10cSrcweir 			else
486cdf0e10cSrcweir 				SetBackground( pParent->GetBackground() );
487cdf0e10cSrcweir 		}
488cdf0e10cSrcweir 	}
489cdf0e10cSrcweir }
490cdf0e10cSrcweir 
491cdf0e10cSrcweir // -----------------------------------------------------------------------
492cdf0e10cSrcweir 
ImplDraw(bool bLayout)493cdf0e10cSrcweir void FixedLine::ImplDraw( bool bLayout )
494cdf0e10cSrcweir {
495cdf0e10cSrcweir 	Size					aOutSize = GetOutputSizePixel();
496cdf0e10cSrcweir 	String					aText = GetText();
497cdf0e10cSrcweir 	WinBits 				nWinStyle = GetStyle();
498cdf0e10cSrcweir     MetricVector*			pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL;
499cdf0e10cSrcweir     String*					pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL;
500cdf0e10cSrcweir 
501cdf0e10cSrcweir     DecorationView aDecoView( this );
502cdf0e10cSrcweir 	if ( !aText.Len() )
503cdf0e10cSrcweir 	{
504cdf0e10cSrcweir         if( !pVector )
505cdf0e10cSrcweir         {
506cdf0e10cSrcweir             long nX = 0;
507cdf0e10cSrcweir             long nY = 0;
508cdf0e10cSrcweir 
509cdf0e10cSrcweir             if ( nWinStyle & WB_VERT )
510cdf0e10cSrcweir             {
511cdf0e10cSrcweir                 nX = (aOutSize.Width()-1)/2;
512cdf0e10cSrcweir                 aDecoView.DrawSeparator( Point( nX, 0 ), Point( nX, aOutSize.Height()-1 ) );
513cdf0e10cSrcweir             }
514cdf0e10cSrcweir             else
515cdf0e10cSrcweir             {
516cdf0e10cSrcweir                 nY = (aOutSize.Height()-1)/2;
517cdf0e10cSrcweir                 aDecoView.DrawSeparator( Point( 0, nY ), Point( aOutSize.Width()-1, nY ), false );
518cdf0e10cSrcweir             }
519cdf0e10cSrcweir         }
520cdf0e10cSrcweir 	}
521cdf0e10cSrcweir 	else if( (nWinStyle & WB_VERT) )
522cdf0e10cSrcweir 	{
523cdf0e10cSrcweir 	    long nWidth = GetTextWidth( aText );
524cdf0e10cSrcweir 	    Push( PUSH_FONT );
525cdf0e10cSrcweir 	    Font aFont( GetFont() );
526cdf0e10cSrcweir 	    aFont.SetOrientation( 900 );
527cdf0e10cSrcweir 	    SetFont( aFont );
528cdf0e10cSrcweir 	    Point aStartPt( aOutSize.Width()/2, aOutSize.Height()-1 );
529cdf0e10cSrcweir 	    if( (nWinStyle & WB_VCENTER) )
530cdf0e10cSrcweir 	        aStartPt.Y() -= (aOutSize.Height() - nWidth)/2;
531cdf0e10cSrcweir 	    Point aTextPt( aStartPt );
532cdf0e10cSrcweir 	    aTextPt.X() -= GetTextHeight()/2;
533cdf0e10cSrcweir 	    DrawText( aTextPt, aText, 0, STRING_LEN, pVector, pDisplayText );
534cdf0e10cSrcweir 	    Pop();
535cdf0e10cSrcweir 	    if( aOutSize.Height() - aStartPt.Y() > FIXEDLINE_TEXT_BORDER )
536cdf0e10cSrcweir 	        aDecoView.DrawSeparator( Point( aStartPt.X(), aOutSize.Height()-1 ),
537cdf0e10cSrcweir 	                                 Point( aStartPt.X(), aStartPt.Y() + FIXEDLINE_TEXT_BORDER ) );
538cdf0e10cSrcweir 	    if( aStartPt.Y() - nWidth - FIXEDLINE_TEXT_BORDER > 0 )
539cdf0e10cSrcweir 	        aDecoView.DrawSeparator( Point( aStartPt.X(), aStartPt.Y() - nWidth - FIXEDLINE_TEXT_BORDER ),
540cdf0e10cSrcweir 	                                 Point( aStartPt.X(), 0 ) );
541cdf0e10cSrcweir 	}
542cdf0e10cSrcweir 	else
543cdf0e10cSrcweir 	{
544cdf0e10cSrcweir 		sal_uInt16		nStyle = TEXT_DRAW_MNEMONIC | TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER | TEXT_DRAW_ENDELLIPSIS;
545cdf0e10cSrcweir 		Rectangle	aRect( 0, 0, aOutSize.Width(), aOutSize.Height() );
546cdf0e10cSrcweir         const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
547cdf0e10cSrcweir         if( (nWinStyle & WB_CENTER) )
548cdf0e10cSrcweir             nStyle |= TEXT_DRAW_CENTER;
549cdf0e10cSrcweir 
550cdf0e10cSrcweir 		if ( !IsEnabled() )
551cdf0e10cSrcweir 			nStyle |= TEXT_DRAW_DISABLE;
552cdf0e10cSrcweir 		if ( GetStyle() & WB_NOLABEL )
553cdf0e10cSrcweir 			nStyle &= ~TEXT_DRAW_MNEMONIC;
554cdf0e10cSrcweir 		if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
555cdf0e10cSrcweir 			nStyle |= TEXT_DRAW_MONO;
556cdf0e10cSrcweir 
557cdf0e10cSrcweir         DrawControlText( *this, aRect, aText, nStyle, pVector, pDisplayText );
558cdf0e10cSrcweir 
559cdf0e10cSrcweir         if( !pVector )
560cdf0e10cSrcweir         {
561cdf0e10cSrcweir             long nTop = aRect.Top() + ((aRect.GetHeight()-1)/2);
562cdf0e10cSrcweir             aDecoView.DrawSeparator( Point( aRect.Right()+FIXEDLINE_TEXT_BORDER, nTop ), Point( aOutSize.Width()-1, nTop ), false );
563cdf0e10cSrcweir             if( aRect.Left() > FIXEDLINE_TEXT_BORDER )
564cdf0e10cSrcweir                 aDecoView.DrawSeparator( Point( 0, nTop ), Point( aRect.Left()-FIXEDLINE_TEXT_BORDER, nTop ), false );
565cdf0e10cSrcweir         }
566cdf0e10cSrcweir     }
567cdf0e10cSrcweir }
568cdf0e10cSrcweir 
569cdf0e10cSrcweir // -----------------------------------------------------------------------
570cdf0e10cSrcweir 
FixedLine(Window * pParent,WinBits nStyle)571cdf0e10cSrcweir FixedLine::FixedLine( Window* pParent, WinBits nStyle ) :
572cdf0e10cSrcweir 	Control( WINDOW_FIXEDLINE )
573cdf0e10cSrcweir {
574cdf0e10cSrcweir 	ImplInit( pParent, nStyle );
575cdf0e10cSrcweir 	SetSizePixel( Size( 2, 2 ) );
576cdf0e10cSrcweir }
577cdf0e10cSrcweir 
578cdf0e10cSrcweir // -----------------------------------------------------------------------
579cdf0e10cSrcweir 
FixedLine(Window * pParent,const ResId & rResId)580cdf0e10cSrcweir FixedLine::FixedLine( Window* pParent, const ResId& rResId ) :
581cdf0e10cSrcweir 	Control( WINDOW_FIXEDLINE )
582cdf0e10cSrcweir {
583cdf0e10cSrcweir 	rResId.SetRT( RSC_FIXEDLINE );
584cdf0e10cSrcweir 	WinBits nStyle = ImplInitRes( rResId );
585cdf0e10cSrcweir 	ImplInit( pParent, nStyle );
586cdf0e10cSrcweir 	ImplLoadRes( rResId );
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 	if ( !(nStyle & WB_HIDE) )
589cdf0e10cSrcweir 		Show();
590cdf0e10cSrcweir }
591cdf0e10cSrcweir 
592cdf0e10cSrcweir // -----------------------------------------------------------------------
593cdf0e10cSrcweir 
FillLayoutData() const594cdf0e10cSrcweir void  FixedLine::FillLayoutData() const
595cdf0e10cSrcweir {
596cdf0e10cSrcweir     mpControlData->mpLayoutData = new vcl::ControlLayoutData();
597cdf0e10cSrcweir 	const_cast<FixedLine*>(this)->ImplDraw( true );
598cdf0e10cSrcweir }
599cdf0e10cSrcweir 
600cdf0e10cSrcweir 
601cdf0e10cSrcweir // -----------------------------------------------------------------------
602cdf0e10cSrcweir 
Paint(const Rectangle &)603cdf0e10cSrcweir void FixedLine::Paint( const Rectangle& )
604cdf0e10cSrcweir {
605cdf0e10cSrcweir     ImplDraw();
606cdf0e10cSrcweir }
607cdf0e10cSrcweir 
608cdf0e10cSrcweir // -----------------------------------------------------------------------
609cdf0e10cSrcweir 
Draw(OutputDevice *,const Point &,const Size &,sal_uLong)610cdf0e10cSrcweir void FixedLine::Draw( OutputDevice*, const Point&, const Size&, sal_uLong )
611cdf0e10cSrcweir {
612cdf0e10cSrcweir }
613cdf0e10cSrcweir 
614cdf0e10cSrcweir // -----------------------------------------------------------------------
615cdf0e10cSrcweir 
Resize()616cdf0e10cSrcweir void FixedLine::Resize()
617cdf0e10cSrcweir {
618cdf0e10cSrcweir     Control::Resize();
619cdf0e10cSrcweir 	Invalidate();
620cdf0e10cSrcweir }
621cdf0e10cSrcweir 
622cdf0e10cSrcweir // -----------------------------------------------------------------------
623cdf0e10cSrcweir 
StateChanged(StateChangedType nType)624cdf0e10cSrcweir void FixedLine::StateChanged( StateChangedType nType )
625cdf0e10cSrcweir {
626cdf0e10cSrcweir 	Control::StateChanged( nType );
627cdf0e10cSrcweir 
628cdf0e10cSrcweir 	if ( (nType == STATE_CHANGE_ENABLE) ||
629cdf0e10cSrcweir 		 (nType == STATE_CHANGE_TEXT) ||
630cdf0e10cSrcweir 		 (nType == STATE_CHANGE_UPDATEMODE) )
631cdf0e10cSrcweir 	{
632cdf0e10cSrcweir 		if ( IsReallyVisible() && IsUpdateMode() )
633cdf0e10cSrcweir 			Invalidate();
634cdf0e10cSrcweir 	}
635cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_STYLE )
636cdf0e10cSrcweir 	{
637cdf0e10cSrcweir 		SetStyle( ImplInitStyle( GetStyle() ) );
638cdf0e10cSrcweir 		if ( (GetPrevStyle() & FIXEDLINE_VIEW_STYLE) !=
639cdf0e10cSrcweir 			 (GetStyle() & FIXEDLINE_VIEW_STYLE) )
640cdf0e10cSrcweir 			Invalidate();
641cdf0e10cSrcweir 	}
642cdf0e10cSrcweir 	else if ( (nType == STATE_CHANGE_ZOOM)	||
643cdf0e10cSrcweir 			  (nType == STATE_CHANGE_STYLE) ||
644cdf0e10cSrcweir 			  (nType == STATE_CHANGE_CONTROLFONT) )
645cdf0e10cSrcweir 	{
646cdf0e10cSrcweir 		ImplInitSettings( sal_True, sal_False, sal_False );
647cdf0e10cSrcweir 		Invalidate();
648cdf0e10cSrcweir 	}
649cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
650cdf0e10cSrcweir 	{
651cdf0e10cSrcweir 		ImplInitSettings( sal_False, sal_True, sal_False );
652cdf0e10cSrcweir 		Invalidate();
653cdf0e10cSrcweir 	}
654cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
655cdf0e10cSrcweir 	{
656cdf0e10cSrcweir 		ImplInitSettings( sal_False, sal_False, sal_True );
657cdf0e10cSrcweir 		Invalidate();
658cdf0e10cSrcweir 	}
659cdf0e10cSrcweir }
660cdf0e10cSrcweir 
661cdf0e10cSrcweir // -----------------------------------------------------------------------
662cdf0e10cSrcweir 
DataChanged(const DataChangedEvent & rDCEvt)663cdf0e10cSrcweir void FixedLine::DataChanged( const DataChangedEvent& rDCEvt )
664cdf0e10cSrcweir {
665cdf0e10cSrcweir 	Control::DataChanged( rDCEvt );
666cdf0e10cSrcweir 
667cdf0e10cSrcweir 	if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
668cdf0e10cSrcweir 		 (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
669cdf0e10cSrcweir 		 ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
670cdf0e10cSrcweir 		  (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
671cdf0e10cSrcweir 	{
672cdf0e10cSrcweir 		ImplInitSettings( sal_True, sal_True, sal_True );
673cdf0e10cSrcweir 		Invalidate();
674cdf0e10cSrcweir 	}
675cdf0e10cSrcweir }
676cdf0e10cSrcweir 
677cdf0e10cSrcweir // -----------------------------------------------------------------------
678cdf0e10cSrcweir 
GetOptimalSize(WindowSizeType eType) const679cdf0e10cSrcweir Size FixedLine::GetOptimalSize(WindowSizeType eType) const
680cdf0e10cSrcweir {
681cdf0e10cSrcweir     switch (eType) {
682cdf0e10cSrcweir     case WINDOWSIZE_MINIMUM:
683cdf0e10cSrcweir         return CalcWindowSize( FixedText::CalcMinimumTextSize ( this ) );
684cdf0e10cSrcweir     default:
685cdf0e10cSrcweir         return Control::GetOptimalSize( eType );
686cdf0e10cSrcweir     }
687cdf0e10cSrcweir }
688cdf0e10cSrcweir 
689cdf0e10cSrcweir // =======================================================================
690cdf0e10cSrcweir 
ImplInit(Window * pParent,WinBits nStyle)691cdf0e10cSrcweir void FixedBitmap::ImplInit( Window* pParent, WinBits nStyle )
692cdf0e10cSrcweir {
693cdf0e10cSrcweir 	nStyle = ImplInitStyle( nStyle );
694cdf0e10cSrcweir 	Control::ImplInit( pParent, nStyle, NULL );
695cdf0e10cSrcweir 	ImplInitSettings();
696cdf0e10cSrcweir }
697cdf0e10cSrcweir 
698cdf0e10cSrcweir // -----------------------------------------------------------------------
699cdf0e10cSrcweir 
ImplInitStyle(WinBits nStyle)700cdf0e10cSrcweir WinBits FixedBitmap::ImplInitStyle( WinBits nStyle )
701cdf0e10cSrcweir {
702cdf0e10cSrcweir 	if ( !(nStyle & WB_NOGROUP) )
703cdf0e10cSrcweir 		nStyle |= WB_GROUP;
704cdf0e10cSrcweir 	return nStyle;
705cdf0e10cSrcweir }
706cdf0e10cSrcweir 
707cdf0e10cSrcweir // -----------------------------------------------------------------------
708cdf0e10cSrcweir 
ImplInitSettings()709cdf0e10cSrcweir void FixedBitmap::ImplInitSettings()
710cdf0e10cSrcweir {
711cdf0e10cSrcweir 	Window* pParent = GetParent();
712cdf0e10cSrcweir 	if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
713cdf0e10cSrcweir 	{
714cdf0e10cSrcweir 		EnableChildTransparentMode( sal_True );
715cdf0e10cSrcweir 		SetParentClipMode( PARENTCLIPMODE_NOCLIP );
716cdf0e10cSrcweir 		SetPaintTransparent( sal_True );
717cdf0e10cSrcweir 		SetBackground();
718cdf0e10cSrcweir 	}
719cdf0e10cSrcweir 	else
720cdf0e10cSrcweir 	{
721cdf0e10cSrcweir 		EnableChildTransparentMode( sal_False );
722cdf0e10cSrcweir 		SetParentClipMode( 0 );
723cdf0e10cSrcweir 		SetPaintTransparent( sal_False );
724cdf0e10cSrcweir 
725cdf0e10cSrcweir 		if ( IsControlBackground() )
726cdf0e10cSrcweir 			SetBackground( GetControlBackground() );
727cdf0e10cSrcweir 		else
728cdf0e10cSrcweir 			SetBackground( pParent->GetBackground() );
729cdf0e10cSrcweir 	}
730cdf0e10cSrcweir }
731cdf0e10cSrcweir 
732cdf0e10cSrcweir // -----------------------------------------------------------------------
733cdf0e10cSrcweir 
ImplLoadRes(const ResId & rResId)734cdf0e10cSrcweir void FixedBitmap::ImplLoadRes( const ResId& rResId )
735cdf0e10cSrcweir {
736cdf0e10cSrcweir 	Control::ImplLoadRes( rResId );
737cdf0e10cSrcweir 
738cdf0e10cSrcweir 	sal_uLong nObjMask = ReadLongRes();
739cdf0e10cSrcweir 
740cdf0e10cSrcweir 	if ( RSC_FIXEDBITMAP_BITMAP & nObjMask )
741cdf0e10cSrcweir 	{
742cdf0e10cSrcweir 		maBitmap = Bitmap( ResId( (RSHEADER_TYPE*)GetClassRes(), *rResId.GetResMgr() ) );
743cdf0e10cSrcweir 		IncrementRes( GetObjSizeRes( (RSHEADER_TYPE*)GetClassRes() ) );
744cdf0e10cSrcweir 	}
745cdf0e10cSrcweir }
746cdf0e10cSrcweir 
747cdf0e10cSrcweir // -----------------------------------------------------------------------
748cdf0e10cSrcweir 
FixedBitmap(Window * pParent,WinBits nStyle)749cdf0e10cSrcweir FixedBitmap::FixedBitmap( Window* pParent, WinBits nStyle ) :
750cdf0e10cSrcweir 	Control( WINDOW_FIXEDBITMAP )
751cdf0e10cSrcweir {
752cdf0e10cSrcweir 	ImplInit( pParent, nStyle );
753cdf0e10cSrcweir }
754cdf0e10cSrcweir 
755cdf0e10cSrcweir // -----------------------------------------------------------------------
756cdf0e10cSrcweir 
FixedBitmap(Window * pParent,const ResId & rResId)757cdf0e10cSrcweir FixedBitmap::FixedBitmap( Window* pParent, const ResId& rResId ) :
758cdf0e10cSrcweir 	Control( WINDOW_FIXEDBITMAP )
759cdf0e10cSrcweir {
760cdf0e10cSrcweir 	rResId.SetRT( RSC_FIXEDBITMAP );
761cdf0e10cSrcweir 	WinBits nStyle = ImplInitRes( rResId );
762cdf0e10cSrcweir 	ImplInit( pParent, nStyle );
763cdf0e10cSrcweir 	ImplLoadRes( rResId );
764cdf0e10cSrcweir 
765cdf0e10cSrcweir 	if ( !(nStyle & WB_HIDE) )
766cdf0e10cSrcweir 		Show();
767cdf0e10cSrcweir }
768cdf0e10cSrcweir 
769cdf0e10cSrcweir // -----------------------------------------------------------------------
770cdf0e10cSrcweir 
~FixedBitmap()771cdf0e10cSrcweir FixedBitmap::~FixedBitmap()
772cdf0e10cSrcweir {
773cdf0e10cSrcweir }
774cdf0e10cSrcweir 
775cdf0e10cSrcweir // -----------------------------------------------------------------------
776cdf0e10cSrcweir 
ImplDraw(OutputDevice * pDev,sal_uLong,const Point & rPos,const Size & rSize)777cdf0e10cSrcweir void FixedBitmap::ImplDraw( OutputDevice* pDev, sal_uLong /* nDrawFlags */,
778cdf0e10cSrcweir 							const Point& rPos, const Size& rSize )
779cdf0e10cSrcweir {
780cdf0e10cSrcweir 	sal_uInt16 nStyle = 0;
781cdf0e10cSrcweir 	Bitmap* pBitmap = &maBitmap;
782cdf0e10cSrcweir 	Color aCol;
783cdf0e10cSrcweir 	if( !!maBitmapHC )
784cdf0e10cSrcweir 	{
785cdf0e10cSrcweir 		if( GetSettings().GetStyleSettings().GetHighContrastMode() )
786cdf0e10cSrcweir 			pBitmap = &maBitmapHC;
787cdf0e10cSrcweir 	}
788cdf0e10cSrcweir 
789cdf0e10cSrcweir 	if( nStyle & IMAGE_DRAW_COLORTRANSFORM )
790cdf0e10cSrcweir 	{
791cdf0e10cSrcweir 		// only images support IMAGE_DRAW_COLORTRANSFORM
792cdf0e10cSrcweir 		Image aImage( maBitmap );
793cdf0e10cSrcweir 		if ( !(!aImage) )
794cdf0e10cSrcweir 		{
795cdf0e10cSrcweir 			if ( GetStyle() & WB_SCALE )
796cdf0e10cSrcweir 				pDev->DrawImage( rPos, rSize, aImage, nStyle );
797cdf0e10cSrcweir 			else
798cdf0e10cSrcweir 			{
799cdf0e10cSrcweir 				Point aPos = ImplCalcPos( GetStyle(), rPos, aImage.GetSizePixel(), rSize );
800cdf0e10cSrcweir 				pDev->DrawImage( aPos, aImage, nStyle );
801cdf0e10cSrcweir 			}
802cdf0e10cSrcweir 		}
803cdf0e10cSrcweir 	}
804cdf0e10cSrcweir 	else
805cdf0e10cSrcweir 	{
806cdf0e10cSrcweir 		// Haben wir ueberhaupt eine Bitmap
807cdf0e10cSrcweir 		if ( !(!(*pBitmap)) )
808cdf0e10cSrcweir 		{
809cdf0e10cSrcweir 			if ( GetStyle() & WB_SCALE )
810cdf0e10cSrcweir 				pDev->DrawBitmap( rPos, rSize, *pBitmap );
811cdf0e10cSrcweir 			else
812cdf0e10cSrcweir 			{
813cdf0e10cSrcweir 				Point aPos = ImplCalcPos( GetStyle(), rPos, pBitmap->GetSizePixel(), rSize );
814cdf0e10cSrcweir 				pDev->DrawBitmap( aPos, *pBitmap );
815cdf0e10cSrcweir 			}
816cdf0e10cSrcweir 		}
817cdf0e10cSrcweir 	}
818cdf0e10cSrcweir }
819cdf0e10cSrcweir 
820cdf0e10cSrcweir // -----------------------------------------------------------------------
821cdf0e10cSrcweir 
Paint(const Rectangle &)822cdf0e10cSrcweir void FixedBitmap::Paint( const Rectangle& )
823cdf0e10cSrcweir {
824cdf0e10cSrcweir 	ImplDraw( this, 0, Point(), GetOutputSizePixel() );
825cdf0e10cSrcweir }
826cdf0e10cSrcweir 
827cdf0e10cSrcweir // -----------------------------------------------------------------------
828cdf0e10cSrcweir 
Draw(OutputDevice * pDev,const Point & rPos,const Size & rSize,sal_uLong nFlags)829cdf0e10cSrcweir void FixedBitmap::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
830cdf0e10cSrcweir 						sal_uLong nFlags )
831cdf0e10cSrcweir {
832cdf0e10cSrcweir 	Point		aPos  = pDev->LogicToPixel( rPos );
833cdf0e10cSrcweir 	Size		aSize = pDev->LogicToPixel( rSize );
834cdf0e10cSrcweir 	Rectangle	aRect( aPos, aSize );
835cdf0e10cSrcweir 
836cdf0e10cSrcweir 	pDev->Push();
837cdf0e10cSrcweir 	pDev->SetMapMode();
838cdf0e10cSrcweir 
839cdf0e10cSrcweir 	// Border
840cdf0e10cSrcweir 	if ( !(nFlags & WINDOW_DRAW_NOBORDER) && (GetStyle() & WB_BORDER) )
841cdf0e10cSrcweir 	{
842cdf0e10cSrcweir 		DecorationView aDecoView( pDev );
843cdf0e10cSrcweir 		aRect = aDecoView.DrawFrame( aRect, FRAME_DRAW_DOUBLEIN );
844cdf0e10cSrcweir 	}
845cdf0e10cSrcweir 	pDev->IntersectClipRegion( aRect );
846cdf0e10cSrcweir 	ImplDraw( pDev, nFlags, aRect.TopLeft(), aRect.GetSize() );
847cdf0e10cSrcweir 
848cdf0e10cSrcweir 	pDev->Pop();
849cdf0e10cSrcweir }
850cdf0e10cSrcweir 
851cdf0e10cSrcweir // -----------------------------------------------------------------------
852cdf0e10cSrcweir 
Resize()853cdf0e10cSrcweir void FixedBitmap::Resize()
854cdf0e10cSrcweir {
855cdf0e10cSrcweir     Control::Resize();
856cdf0e10cSrcweir 	Invalidate();
857cdf0e10cSrcweir }
858cdf0e10cSrcweir 
859cdf0e10cSrcweir // -----------------------------------------------------------------------
860cdf0e10cSrcweir 
StateChanged(StateChangedType nType)861cdf0e10cSrcweir void FixedBitmap::StateChanged( StateChangedType nType )
862cdf0e10cSrcweir {
863cdf0e10cSrcweir 	Control::StateChanged( nType );
864cdf0e10cSrcweir 
865cdf0e10cSrcweir 	if ( (nType == STATE_CHANGE_DATA) ||
866cdf0e10cSrcweir 		 (nType == STATE_CHANGE_UPDATEMODE) )
867cdf0e10cSrcweir 	{
868cdf0e10cSrcweir 		if ( IsReallyVisible() && IsUpdateMode() )
869cdf0e10cSrcweir 			Invalidate();
870cdf0e10cSrcweir 	}
871cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_STYLE )
872cdf0e10cSrcweir 	{
873cdf0e10cSrcweir 		SetStyle( ImplInitStyle( GetStyle() ) );
874cdf0e10cSrcweir 		if ( (GetPrevStyle() & FIXEDBITMAP_VIEW_STYLE) !=
875cdf0e10cSrcweir 			 (GetStyle() & FIXEDBITMAP_VIEW_STYLE) )
876cdf0e10cSrcweir 			Invalidate();
877cdf0e10cSrcweir 	}
878cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
879cdf0e10cSrcweir 	{
880cdf0e10cSrcweir 		ImplInitSettings();
881cdf0e10cSrcweir 		Invalidate();
882cdf0e10cSrcweir 	}
883cdf0e10cSrcweir }
884cdf0e10cSrcweir 
885cdf0e10cSrcweir // -----------------------------------------------------------------------
886cdf0e10cSrcweir 
DataChanged(const DataChangedEvent & rDCEvt)887cdf0e10cSrcweir void FixedBitmap::DataChanged( const DataChangedEvent& rDCEvt )
888cdf0e10cSrcweir {
889cdf0e10cSrcweir 	Control::DataChanged( rDCEvt );
890cdf0e10cSrcweir 
891cdf0e10cSrcweir 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
892cdf0e10cSrcweir 		 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
893cdf0e10cSrcweir 	{
894cdf0e10cSrcweir 		ImplInitSettings();
895cdf0e10cSrcweir 		Invalidate();
896cdf0e10cSrcweir 	}
897cdf0e10cSrcweir }
898cdf0e10cSrcweir 
899cdf0e10cSrcweir // -----------------------------------------------------------------------
900cdf0e10cSrcweir 
SetBitmap(const Bitmap & rBitmap)901cdf0e10cSrcweir void FixedBitmap::SetBitmap( const Bitmap& rBitmap )
902cdf0e10cSrcweir {
903cdf0e10cSrcweir 	maBitmap = rBitmap;
904cdf0e10cSrcweir 	StateChanged( STATE_CHANGE_DATA );
905cdf0e10cSrcweir }
906cdf0e10cSrcweir 
907cdf0e10cSrcweir // -----------------------------------------------------------------------
908cdf0e10cSrcweir 
SetModeBitmap(const Bitmap & rBitmap,BmpColorMode eMode)909cdf0e10cSrcweir sal_Bool FixedBitmap::SetModeBitmap( const Bitmap& rBitmap, BmpColorMode eMode )
910cdf0e10cSrcweir {
911cdf0e10cSrcweir     if( eMode == BMP_COLOR_NORMAL )
912cdf0e10cSrcweir         SetBitmap( rBitmap );
913cdf0e10cSrcweir     else if( eMode == BMP_COLOR_HIGHCONTRAST )
914cdf0e10cSrcweir     {
915cdf0e10cSrcweir 	    maBitmapHC = rBitmap;
916cdf0e10cSrcweir 	    StateChanged( STATE_CHANGE_DATA );
917cdf0e10cSrcweir     }
918cdf0e10cSrcweir     else
919cdf0e10cSrcweir         return sal_False;
920cdf0e10cSrcweir     return sal_True;
921cdf0e10cSrcweir }
922cdf0e10cSrcweir 
923cdf0e10cSrcweir // -----------------------------------------------------------------------
924cdf0e10cSrcweir 
GetModeBitmap(BmpColorMode eMode) const925cdf0e10cSrcweir const Bitmap& FixedBitmap::GetModeBitmap( BmpColorMode eMode) const
926cdf0e10cSrcweir {
927cdf0e10cSrcweir     if( eMode == BMP_COLOR_HIGHCONTRAST )
928cdf0e10cSrcweir         return maBitmapHC;
929cdf0e10cSrcweir     else
930cdf0e10cSrcweir         return maBitmap;
931cdf0e10cSrcweir }
932cdf0e10cSrcweir 
933cdf0e10cSrcweir // =======================================================================
934cdf0e10cSrcweir 
ImplInit(Window * pParent,WinBits nStyle)935cdf0e10cSrcweir void FixedImage::ImplInit( Window* pParent, WinBits nStyle )
936cdf0e10cSrcweir {
937cdf0e10cSrcweir 	nStyle = ImplInitStyle( nStyle );
938cdf0e10cSrcweir 	mbInUserDraw = sal_False;
939cdf0e10cSrcweir 	Control::ImplInit( pParent, nStyle, NULL );
940cdf0e10cSrcweir 	ImplInitSettings();
941cdf0e10cSrcweir }
942cdf0e10cSrcweir 
943cdf0e10cSrcweir // -----------------------------------------------------------------------
944cdf0e10cSrcweir 
ImplInitStyle(WinBits nStyle)945cdf0e10cSrcweir WinBits FixedImage::ImplInitStyle( WinBits nStyle )
946cdf0e10cSrcweir {
947cdf0e10cSrcweir 	if ( !(nStyle & WB_NOGROUP) )
948cdf0e10cSrcweir 		nStyle |= WB_GROUP;
949cdf0e10cSrcweir 	return nStyle;
950cdf0e10cSrcweir }
951cdf0e10cSrcweir 
952cdf0e10cSrcweir // -----------------------------------------------------------------------
953cdf0e10cSrcweir 
ImplInitSettings()954cdf0e10cSrcweir void FixedImage::ImplInitSettings()
955cdf0e10cSrcweir {
956cdf0e10cSrcweir 	Window* pParent = GetParent();
957cdf0e10cSrcweir 	if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
958cdf0e10cSrcweir 	{
959cdf0e10cSrcweir 		EnableChildTransparentMode( sal_True );
960cdf0e10cSrcweir 		SetParentClipMode( PARENTCLIPMODE_NOCLIP );
961cdf0e10cSrcweir 		SetPaintTransparent( sal_True );
962cdf0e10cSrcweir 		SetBackground();
963cdf0e10cSrcweir 	}
964cdf0e10cSrcweir 	else
965cdf0e10cSrcweir 	{
966cdf0e10cSrcweir 		EnableChildTransparentMode( sal_False );
967cdf0e10cSrcweir 		SetParentClipMode( 0 );
968cdf0e10cSrcweir 		SetPaintTransparent( sal_False );
969cdf0e10cSrcweir 
970cdf0e10cSrcweir 		if ( IsControlBackground() )
971cdf0e10cSrcweir 			SetBackground( GetControlBackground() );
972cdf0e10cSrcweir 		else
973cdf0e10cSrcweir 			SetBackground( pParent->GetBackground() );
974cdf0e10cSrcweir 	}
975cdf0e10cSrcweir }
976cdf0e10cSrcweir 
977cdf0e10cSrcweir // -----------------------------------------------------------------------
978cdf0e10cSrcweir 
ImplLoadRes(const ResId & rResId)979cdf0e10cSrcweir void FixedImage::ImplLoadRes( const ResId& rResId )
980cdf0e10cSrcweir {
981cdf0e10cSrcweir 	Control::ImplLoadRes( rResId );
982cdf0e10cSrcweir 
983cdf0e10cSrcweir 	sal_uLong nObjMask = ReadLongRes();
984cdf0e10cSrcweir 
985cdf0e10cSrcweir 	if ( RSC_FIXEDIMAGE_IMAGE & nObjMask )
986cdf0e10cSrcweir 	{
987cdf0e10cSrcweir 		maImage = Image( ResId( (RSHEADER_TYPE*)GetClassRes(), *rResId.GetResMgr() ) );
988cdf0e10cSrcweir 		IncrementRes( GetObjSizeRes( (RSHEADER_TYPE*)GetClassRes() ) );
989cdf0e10cSrcweir 	}
990cdf0e10cSrcweir }
991cdf0e10cSrcweir 
992cdf0e10cSrcweir // -----------------------------------------------------------------------
993cdf0e10cSrcweir 
FixedImage(Window * pParent,WinBits nStyle)994cdf0e10cSrcweir FixedImage::FixedImage( Window* pParent, WinBits nStyle ) :
995cdf0e10cSrcweir 	Control( WINDOW_FIXEDIMAGE )
996cdf0e10cSrcweir {
997cdf0e10cSrcweir 	ImplInit( pParent, nStyle );
998cdf0e10cSrcweir }
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir // -----------------------------------------------------------------------
1001cdf0e10cSrcweir 
FixedImage(Window * pParent,const ResId & rResId)1002cdf0e10cSrcweir FixedImage::FixedImage( Window* pParent, const ResId& rResId ) :
1003cdf0e10cSrcweir 	Control( WINDOW_FIXEDIMAGE )
1004cdf0e10cSrcweir {
1005cdf0e10cSrcweir 	rResId.SetRT( RSC_FIXEDIMAGE );
1006cdf0e10cSrcweir 	WinBits nStyle = ImplInitRes( rResId );
1007cdf0e10cSrcweir 	ImplInit( pParent, nStyle );
1008cdf0e10cSrcweir 	ImplLoadRes( rResId );
1009cdf0e10cSrcweir 
1010cdf0e10cSrcweir 	if ( !(nStyle & WB_HIDE) )
1011cdf0e10cSrcweir 		Show();
1012cdf0e10cSrcweir }
1013cdf0e10cSrcweir 
1014cdf0e10cSrcweir // -----------------------------------------------------------------------
1015cdf0e10cSrcweir 
~FixedImage()1016cdf0e10cSrcweir FixedImage::~FixedImage()
1017cdf0e10cSrcweir {
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir // -----------------------------------------------------------------------
1021cdf0e10cSrcweir 
ImplDraw(OutputDevice * pDev,sal_uLong nDrawFlags,const Point & rPos,const Size & rSize)1022cdf0e10cSrcweir void FixedImage::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
1023cdf0e10cSrcweir 						   const Point& rPos, const Size& rSize )
1024cdf0e10cSrcweir {
1025cdf0e10cSrcweir 	sal_uInt16 nStyle = 0;
1026cdf0e10cSrcweir 	if ( !(nDrawFlags & WINDOW_DRAW_NODISABLE) )
1027cdf0e10cSrcweir 	{
1028cdf0e10cSrcweir 		if ( !IsEnabled() )
1029cdf0e10cSrcweir 			nStyle |= IMAGE_DRAW_DISABLE;
1030cdf0e10cSrcweir 	}
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir 	Image *pImage = &maImage;
1033cdf0e10cSrcweir 	Color aCol;
1034cdf0e10cSrcweir 	if( !!maImageHC )
1035cdf0e10cSrcweir 	{
1036cdf0e10cSrcweir 		if( GetSettings().GetStyleSettings().GetHighContrastMode() )
1037cdf0e10cSrcweir 			pImage = &maImageHC;
1038cdf0e10cSrcweir 	}
1039cdf0e10cSrcweir 
1040cdf0e10cSrcweir 	// Haben wir ueberhaupt ein Image
1041cdf0e10cSrcweir 	if ( !(!(*pImage)) )
1042cdf0e10cSrcweir 	{
1043cdf0e10cSrcweir 		if ( GetStyle() & WB_SCALE )
1044cdf0e10cSrcweir 			pDev->DrawImage( rPos, rSize, *pImage, nStyle );
1045cdf0e10cSrcweir 		else
1046cdf0e10cSrcweir 		{
1047cdf0e10cSrcweir 			Point aPos = ImplCalcPos( GetStyle(), rPos, pImage->GetSizePixel(), rSize );
1048cdf0e10cSrcweir 			pDev->DrawImage( aPos, *pImage, nStyle );
1049cdf0e10cSrcweir 		}
1050cdf0e10cSrcweir 	}
1051cdf0e10cSrcweir 
1052cdf0e10cSrcweir 	mbInUserDraw = sal_True;
1053cdf0e10cSrcweir 	UserDrawEvent aUDEvt( pDev, Rectangle( rPos, rSize ), 0, nStyle );
1054cdf0e10cSrcweir 	UserDraw( aUDEvt );
1055cdf0e10cSrcweir 	mbInUserDraw = sal_False;
1056cdf0e10cSrcweir }
1057cdf0e10cSrcweir 
1058cdf0e10cSrcweir // -----------------------------------------------------------------------
1059cdf0e10cSrcweir 
Paint(const Rectangle &)1060cdf0e10cSrcweir void FixedImage::Paint( const Rectangle& )
1061cdf0e10cSrcweir {
1062cdf0e10cSrcweir 	ImplDraw( this, 0, Point(), GetOutputSizePixel() );
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir // -----------------------------------------------------------------------
1066cdf0e10cSrcweir 
GetOptimalSize(WindowSizeType) const1067cdf0e10cSrcweir Size FixedImage::GetOptimalSize( WindowSizeType ) const
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir     const Image* pImage = GetSettings().GetStyleSettings().GetHighContrastMode() ? &maImageHC : &maImage;
1070cdf0e10cSrcweir     return pImage->GetSizePixel();
1071cdf0e10cSrcweir }
1072cdf0e10cSrcweir 
1073cdf0e10cSrcweir // -----------------------------------------------------------------------
1074cdf0e10cSrcweir 
UserDraw(const UserDrawEvent &)1075cdf0e10cSrcweir void FixedImage::UserDraw( const UserDrawEvent& )
1076cdf0e10cSrcweir {
1077cdf0e10cSrcweir }
1078cdf0e10cSrcweir 
1079cdf0e10cSrcweir // -----------------------------------------------------------------------
1080cdf0e10cSrcweir 
Draw(OutputDevice * pDev,const Point & rPos,const Size & rSize,sal_uLong nFlags)1081cdf0e10cSrcweir void FixedImage::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
1082cdf0e10cSrcweir 					   sal_uLong nFlags )
1083cdf0e10cSrcweir {
1084cdf0e10cSrcweir 	Point		aPos  = pDev->LogicToPixel( rPos );
1085cdf0e10cSrcweir 	Size		aSize = pDev->LogicToPixel( rSize );
1086cdf0e10cSrcweir 	Rectangle	aRect( aPos, aSize );
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir 	pDev->Push();
1089cdf0e10cSrcweir 	pDev->SetMapMode();
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir 	// Border
1092cdf0e10cSrcweir 	if ( !(nFlags & WINDOW_DRAW_NOBORDER) && (GetStyle() & WB_BORDER) )
1093cdf0e10cSrcweir 	{
1094cdf0e10cSrcweir 		ImplDrawFrame( pDev, aRect );
1095cdf0e10cSrcweir 	}
1096cdf0e10cSrcweir 	pDev->IntersectClipRegion( aRect );
1097cdf0e10cSrcweir 	ImplDraw( pDev, nFlags, aRect.TopLeft(), aRect.GetSize() );
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir 	pDev->Pop();
1100cdf0e10cSrcweir }
1101cdf0e10cSrcweir 
1102cdf0e10cSrcweir // -----------------------------------------------------------------------
1103cdf0e10cSrcweir 
Resize()1104cdf0e10cSrcweir void FixedImage::Resize()
1105cdf0e10cSrcweir {
1106cdf0e10cSrcweir     Control::Resize();
1107cdf0e10cSrcweir 	Invalidate();
1108cdf0e10cSrcweir }
1109cdf0e10cSrcweir 
1110cdf0e10cSrcweir // -----------------------------------------------------------------------
1111cdf0e10cSrcweir 
StateChanged(StateChangedType nType)1112cdf0e10cSrcweir void FixedImage::StateChanged( StateChangedType nType )
1113cdf0e10cSrcweir {
1114cdf0e10cSrcweir 	Control::StateChanged( nType );
1115cdf0e10cSrcweir 
1116cdf0e10cSrcweir 	if ( (nType == STATE_CHANGE_ENABLE) ||
1117cdf0e10cSrcweir 		 (nType == STATE_CHANGE_DATA) ||
1118cdf0e10cSrcweir 		 (nType == STATE_CHANGE_UPDATEMODE) )
1119cdf0e10cSrcweir 	{
1120cdf0e10cSrcweir 		if ( IsReallyVisible() && IsUpdateMode() )
1121cdf0e10cSrcweir 			Invalidate();
1122cdf0e10cSrcweir 	}
1123cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_STYLE )
1124cdf0e10cSrcweir 	{
1125cdf0e10cSrcweir 		SetStyle( ImplInitStyle( GetStyle() ) );
1126cdf0e10cSrcweir 		if ( (GetPrevStyle() & FIXEDIMAGE_VIEW_STYLE) !=
1127cdf0e10cSrcweir 			 (GetStyle() & FIXEDIMAGE_VIEW_STYLE) )
1128cdf0e10cSrcweir 			Invalidate();
1129cdf0e10cSrcweir 	}
1130cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
1131cdf0e10cSrcweir 	{
1132cdf0e10cSrcweir 		ImplInitSettings();
1133cdf0e10cSrcweir 		Invalidate();
1134cdf0e10cSrcweir 	}
1135cdf0e10cSrcweir }
1136cdf0e10cSrcweir 
1137cdf0e10cSrcweir // -----------------------------------------------------------------------
1138cdf0e10cSrcweir 
DataChanged(const DataChangedEvent & rDCEvt)1139cdf0e10cSrcweir void FixedImage::DataChanged( const DataChangedEvent& rDCEvt )
1140cdf0e10cSrcweir {
1141cdf0e10cSrcweir 	Control::DataChanged( rDCEvt );
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
1144cdf0e10cSrcweir 		 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1145cdf0e10cSrcweir 	{
1146cdf0e10cSrcweir 		ImplInitSettings();
1147cdf0e10cSrcweir 		Invalidate();
1148cdf0e10cSrcweir 	}
1149cdf0e10cSrcweir }
1150cdf0e10cSrcweir 
1151cdf0e10cSrcweir // -----------------------------------------------------------------------
1152cdf0e10cSrcweir 
SetImage(const Image & rImage)1153cdf0e10cSrcweir void FixedImage::SetImage( const Image& rImage )
1154cdf0e10cSrcweir {
1155cdf0e10cSrcweir 	if ( rImage != maImage )
1156cdf0e10cSrcweir 	{
1157cdf0e10cSrcweir 		maImage = rImage;
1158cdf0e10cSrcweir 		StateChanged( STATE_CHANGE_DATA );
1159cdf0e10cSrcweir 	}
1160cdf0e10cSrcweir }
1161cdf0e10cSrcweir 
1162cdf0e10cSrcweir // -----------------------------------------------------------------------
1163cdf0e10cSrcweir 
SetModeImage(const Image & rImage,BmpColorMode eMode)1164cdf0e10cSrcweir sal_Bool FixedImage::SetModeImage( const Image& rImage, BmpColorMode eMode )
1165cdf0e10cSrcweir {
1166cdf0e10cSrcweir     if( eMode == BMP_COLOR_NORMAL )
1167cdf0e10cSrcweir         SetImage( rImage );
1168cdf0e10cSrcweir     else if( eMode == BMP_COLOR_HIGHCONTRAST )
1169cdf0e10cSrcweir     {
1170cdf0e10cSrcweir 		if( maImageHC != rImage )
1171cdf0e10cSrcweir 		{
1172cdf0e10cSrcweir 			maImageHC = rImage;
1173cdf0e10cSrcweir 			StateChanged( STATE_CHANGE_DATA );
1174cdf0e10cSrcweir 		}
1175cdf0e10cSrcweir     }
1176cdf0e10cSrcweir     else
1177cdf0e10cSrcweir         return sal_False;
1178cdf0e10cSrcweir     return sal_True;
1179cdf0e10cSrcweir }
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir // -----------------------------------------------------------------------
1182cdf0e10cSrcweir 
GetModeImage(BmpColorMode eMode) const1183cdf0e10cSrcweir const Image& FixedImage::GetModeImage( BmpColorMode eMode ) const
1184cdf0e10cSrcweir {
1185cdf0e10cSrcweir     if( eMode == BMP_COLOR_HIGHCONTRAST )
1186cdf0e10cSrcweir         return maImageHC;
1187cdf0e10cSrcweir     else
1188cdf0e10cSrcweir         return maImage;
1189cdf0e10cSrcweir }
1190cdf0e10cSrcweir 
1191cdf0e10cSrcweir // -----------------------------------------------------------------------
1192cdf0e10cSrcweir 
CalcImagePos(const Point & rPos,const Size & rObjSize,const Size & rWinSize)1193cdf0e10cSrcweir Point FixedImage::CalcImagePos( const Point& rPos,
1194cdf0e10cSrcweir 								const Size& rObjSize, const Size& rWinSize )
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir 	return ImplCalcPos( GetStyle(), rPos, rObjSize, rWinSize );
1197cdf0e10cSrcweir }
1198