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