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