xref: /trunk/main/svtools/source/contnr/svlbitm.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svtools.hxx"
30 
31 
32 #include <svtools/svlbox.hxx>
33 #include <svtools/svlbitm.hxx>
34 #include <vcl/svapp.hxx>
35 #ifndef _SV_BUTTON_HXX
36 #include <vcl/button.hxx>
37 #endif
38 #include <vcl/decoview.hxx>
39 #include <vcl/sound.hxx>
40 #include <vcl/salnativewidgets.hxx>
41 
42 #define TABOFFS_NOT_VALID -2000000
43 
44 struct SvLBoxButtonData_Impl
45 {
46     SvLBoxEntry*    pEntry;
47     sal_Bool            bDefaultImages;
48     sal_Bool            bShowRadioButton;
49 
50     SvLBoxButtonData_Impl() : pEntry( NULL ), bDefaultImages( sal_False ), bShowRadioButton( sal_False ) {}
51 };
52 
53 
54 DBG_NAME(SvLBoxButtonData)
55 
56 void SvLBoxButtonData::InitData( sal_Bool bImagesFromDefault, bool _bRadioBtn, const Control* pCtrl )
57 {
58     pImpl = new SvLBoxButtonData_Impl;
59 
60     bDataOk = sal_False;
61     eState = SV_BUTTON_UNCHECKED;
62     pImpl->bDefaultImages = bImagesFromDefault;
63     pImpl->bShowRadioButton = ( _bRadioBtn != false );
64 
65     if ( bImagesFromDefault )
66         SetDefaultImages( pCtrl );
67 }
68 
69 SvLBoxButtonData::SvLBoxButtonData( const Control* pControlForSettings )
70 {
71     DBG_CTOR(SvLBoxButtonData,0);
72 
73     InitData( sal_True, false, pControlForSettings );
74 }
75 
76 SvLBoxButtonData::SvLBoxButtonData( const Control* pControlForSettings, bool _bRadioBtn )
77 {
78     DBG_CTOR(SvLBoxButtonData,0);
79 
80     InitData( sal_True, _bRadioBtn, pControlForSettings );
81 }
82 
83 SvLBoxButtonData::SvLBoxButtonData()
84 {
85     DBG_CTOR(SvLBoxButtonData,0);
86 
87     InitData( sal_False, false );
88 }
89 
90 SvLBoxButtonData::~SvLBoxButtonData()
91 {
92     DBG_DTOR(SvLBoxButtonData,0);
93 
94     delete pImpl;
95 #ifdef DBG_UTIL
96     pImpl = NULL;
97 #endif
98 }
99 
100 void SvLBoxButtonData::CallLink()
101 {
102     DBG_CHKTHIS(SvLBoxButtonData,0);
103     aLink.Call( this );
104 }
105 
106 sal_uInt16 SvLBoxButtonData::GetIndex( sal_uInt16 nItemState )
107 {
108     DBG_CHKTHIS(SvLBoxButtonData,0);
109     nItemState &= 0x000F;
110     sal_uInt16 nIdx;
111     switch( nItemState )
112     {
113         case SV_ITEMSTATE_UNCHECKED:
114                 nIdx = SV_BMP_UNCHECKED; break;
115         case SV_ITEMSTATE_CHECKED:
116                 nIdx = SV_BMP_CHECKED; break;
117         case SV_ITEMSTATE_TRISTATE:
118                 nIdx = SV_BMP_TRISTATE; break;
119         case SV_ITEMSTATE_UNCHECKED | SV_ITEMSTATE_HILIGHTED:
120                 nIdx = SV_BMP_HIUNCHECKED; break;
121         case SV_ITEMSTATE_CHECKED | SV_ITEMSTATE_HILIGHTED:
122                 nIdx = SV_BMP_HICHECKED; break;
123         case SV_ITEMSTATE_TRISTATE | SV_ITEMSTATE_HILIGHTED:
124                 nIdx = SV_BMP_HITRISTATE; break;
125         default:
126                 nIdx = SV_BMP_UNCHECKED;
127     }
128     return nIdx;
129 }
130 
131 void SvLBoxButtonData::SetWidthAndHeight()
132 {
133     DBG_CHKTHIS(SvLBoxButtonData,0);
134     Size aSize = aBmps[0].GetSizePixel();
135     nWidth = aSize.Width();
136     nHeight = aSize.Height();
137     bDataOk = sal_True;
138 }
139 
140 
141 void SvLBoxButtonData::StoreButtonState( SvLBoxEntry* pActEntry, sal_uInt16 nItemFlags )
142 {
143     DBG_CHKTHIS(SvLBoxButtonData,0);
144     pImpl->pEntry = pActEntry;
145     eState = ConvertToButtonState( nItemFlags );
146 }
147 
148 SvButtonState SvLBoxButtonData::ConvertToButtonState( sal_uInt16 nItemFlags ) const
149 {
150     DBG_CHKTHIS(SvLBoxButtonData,0);
151     nItemFlags &= (SV_ITEMSTATE_UNCHECKED |
152                    SV_ITEMSTATE_CHECKED |
153                    SV_ITEMSTATE_TRISTATE);
154     switch( nItemFlags )
155     {
156         case SV_ITEMSTATE_UNCHECKED:
157             return SV_BUTTON_UNCHECKED;
158 
159         case SV_ITEMSTATE_CHECKED:
160             return SV_BUTTON_CHECKED;
161 
162         case SV_ITEMSTATE_TRISTATE:
163             return SV_BUTTON_TRISTATE;
164         default:
165             return SV_BUTTON_UNCHECKED;
166     }
167 }
168 
169 SvLBoxEntry* SvLBoxButtonData::GetActEntry() const
170 {
171     DBG_ASSERT( pImpl, "-SvLBoxButtonData::GetActEntry(): don't use me that way!" );
172     return pImpl->pEntry;
173 }
174 
175 void SvLBoxButtonData::SetDefaultImages( const Control* pCtrl )
176 {
177     const AllSettings& rSettings = pCtrl? pCtrl->GetSettings() : Application::GetSettings();
178 
179     if ( pImpl->bShowRadioButton )
180     {
181         aBmps[ SV_BMP_UNCHECKED ]   = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_DEFAULT );
182         aBmps[ SV_BMP_CHECKED ]     = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_CHECKED );
183         aBmps[ SV_BMP_HICHECKED ]   = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_CHECKED | BUTTON_DRAW_PRESSED );
184         aBmps[ SV_BMP_HIUNCHECKED ] = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_DEFAULT | BUTTON_DRAW_PRESSED );
185         aBmps[ SV_BMP_TRISTATE ]    = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_DONTKNOW );
186         aBmps[ SV_BMP_HITRISTATE ]  = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_DONTKNOW | BUTTON_DRAW_PRESSED );
187     }
188     else
189     {
190         aBmps[ SV_BMP_UNCHECKED ]   = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DEFAULT );
191         aBmps[ SV_BMP_CHECKED ]     = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_CHECKED );
192         aBmps[ SV_BMP_HICHECKED ]   = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_CHECKED | BUTTON_DRAW_PRESSED );
193         aBmps[ SV_BMP_HIUNCHECKED ] = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DEFAULT | BUTTON_DRAW_PRESSED );
194         aBmps[ SV_BMP_TRISTATE ]    = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DONTKNOW );
195         aBmps[ SV_BMP_HITRISTATE ]  = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DONTKNOW | BUTTON_DRAW_PRESSED );
196     }
197 }
198 
199 sal_Bool SvLBoxButtonData::HasDefaultImages( void ) const
200 {
201     return pImpl->bDefaultImages;
202 }
203 
204 sal_Bool SvLBoxButtonData::IsRadio() {
205     return pImpl->bShowRadioButton;
206 }
207 
208 // ***************************************************************
209 // class SvLBoxString
210 // ***************************************************************
211 
212 DBG_NAME(SvLBoxString);
213 
214 SvLBoxString::SvLBoxString( SvLBoxEntry* pEntry,sal_uInt16 nFlags,const XubString& rStr) :
215         SvLBoxItem( pEntry, nFlags )
216 {
217     DBG_CTOR(SvLBoxString,0);
218     SetText( pEntry, rStr );
219 }
220 
221 SvLBoxString::SvLBoxString() : SvLBoxItem()
222 {
223     DBG_CTOR(SvLBoxString,0);
224 }
225 
226 SvLBoxString::~SvLBoxString()
227 {
228     DBG_DTOR(SvLBoxString,0);
229 }
230 
231 sal_uInt16 SvLBoxString::IsA()
232 {
233     DBG_CHKTHIS(SvLBoxString,0);
234     return SV_ITEM_ID_LBOXSTRING;
235 }
236 
237 void SvLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 /* nFlags */,
238     SvLBoxEntry* _pEntry)
239 {
240     DBG_CHKTHIS(SvLBoxString,0);
241     if ( _pEntry )
242     {
243         sal_uInt16 nStyle = rDev.IsEnabled() ? 0 : TEXT_DRAW_DISABLE;
244         if ( rDev.IsEntryMnemonicsEnabled() )
245             nStyle |= TEXT_DRAW_MNEMONIC;
246         rDev.DrawText( Rectangle(rPos,GetSize(&rDev,_pEntry)),aStr,nStyle);
247     }
248     else
249         rDev.DrawText( rPos, aStr);
250 
251 }
252 
253 SvLBoxItem* SvLBoxString::Create() const
254 {
255     DBG_CHKTHIS(SvLBoxString,0);
256     return new SvLBoxString;
257 }
258 
259 void SvLBoxString::Clone( SvLBoxItem* pSource )
260 {
261     DBG_CHKTHIS(SvLBoxString,0);
262     aStr = ((SvLBoxString*)pSource)->aStr;
263 }
264 
265 void SvLBoxString::SetText( SvLBoxEntry*, const XubString& rStr )
266 {
267     DBG_CHKTHIS(SvLBoxString,0);
268     aStr = rStr;
269 }
270 
271 void SvLBoxString::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry,
272     SvViewDataItem* pViewData)
273 {
274     DBG_CHKTHIS(SvLBoxString,0);
275     if( !pViewData )
276         pViewData = pView->GetViewDataItem( pEntry, this );
277     pViewData->aSize = Size(pView->GetTextWidth( aStr ), pView->GetTextHeight());
278 }
279 
280 // ***************************************************************
281 // class SvLBoxBmp
282 // ***************************************************************
283 
284 DBG_NAME(SvLBoxBmp);
285 
286 SvLBoxBmp::SvLBoxBmp( SvLBoxEntry* pEntry, sal_uInt16 nFlags, Image aBitmap ) :
287     SvLBoxItem( pEntry, nFlags )
288 {
289     DBG_CTOR(SvLBoxBmp,0);
290     SetBitmap( pEntry, aBitmap);
291 }
292 
293 SvLBoxBmp::SvLBoxBmp() : SvLBoxItem()
294 {
295     DBG_CTOR(SvLBoxBmp,0);
296 }
297 
298 SvLBoxBmp::~SvLBoxBmp()
299 {
300     DBG_DTOR(SvLBoxBmp,0);
301 }
302 
303 sal_uInt16 SvLBoxBmp::IsA()
304 {
305     DBG_CHKTHIS(SvLBoxBmp,0);
306     return SV_ITEM_ID_LBOXBMP;
307 }
308 
309 void SvLBoxBmp::SetBitmap( SvLBoxEntry*, Image aBitmap)
310 {
311     DBG_CHKTHIS(SvLBoxBmp,0);
312     aBmp = aBitmap;
313 }
314 
315 void SvLBoxBmp::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry,
316     SvViewDataItem* pViewData)
317 {
318     DBG_CHKTHIS(SvLBoxBmp,0);
319     if( !pViewData )
320         pViewData = pView->GetViewDataItem( pEntry, this );
321     pViewData->aSize = aBmp.GetSizePixel();
322 }
323 
324 void SvLBoxBmp::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 /* nFlags */,
325                         SvLBoxEntry* )
326 {
327     DBG_CHKTHIS(SvLBoxBmp,0);
328     sal_uInt16 nStyle = rDev.IsEnabled() ? 0 : IMAGE_DRAW_DISABLE;
329     rDev.DrawImage( rPos, aBmp ,nStyle);
330 }
331 
332 SvLBoxItem* SvLBoxBmp::Create() const
333 {
334     DBG_CHKTHIS(SvLBoxBmp,0);
335     return new SvLBoxBmp;
336 }
337 
338 void SvLBoxBmp::Clone( SvLBoxItem* pSource )
339 {
340     DBG_CHKTHIS(SvLBoxBmp,0);
341     aBmp = ((SvLBoxBmp*)pSource)->aBmp;
342 }
343 
344 // ***************************************************************
345 // class SvLBoxButton
346 // ***************************************************************
347 
348 DBG_NAME(SvLBoxButton);
349 
350 SvLBoxButton::SvLBoxButton( SvLBoxEntry* pEntry, SvLBoxButtonKind eTheKind,
351                             sal_uInt16 nFlags, SvLBoxButtonData* pBData )
352     : SvLBoxItem( pEntry, nFlags )
353 {
354     DBG_CTOR(SvLBoxButton,0);
355     eKind = eTheKind;
356     nBaseOffs = 0;
357     nItemFlags = 0;
358     SetStateUnchecked();
359     pData = pBData;
360 }
361 
362 SvLBoxButton::SvLBoxButton() : SvLBoxItem()
363 {
364     DBG_CTOR(SvLBoxButton,0);
365     eKind = SvLBoxButtonKind_enabledCheckbox;
366     nItemFlags = 0;
367     SetStateUnchecked();
368 }
369 
370 SvLBoxButton::~SvLBoxButton()
371 {
372     DBG_DTOR(SvLBoxButton,0);
373 }
374 
375 sal_uInt16 SvLBoxButton::IsA()
376 {
377     DBG_CHKTHIS(SvLBoxButton,0);
378     return SV_ITEM_ID_LBOXBUTTON;
379 }
380 
381 void SvLBoxButton::Check(SvLBox*, SvLBoxEntry*, sal_Bool bOn)
382 {
383     DBG_CHKTHIS(SvLBoxButton,0);
384     if ( bOn != IsStateChecked() )
385     {
386         if ( bOn )
387             SetStateChecked();
388         else
389             SetStateUnchecked();
390     }
391 }
392 
393 sal_Bool SvLBoxButton::ClickHdl( SvLBox*, SvLBoxEntry* pEntry )
394 {
395     DBG_CHKTHIS(SvLBoxButton,0);
396     if ( CheckModification() )
397     {
398         if ( IsStateChecked() )
399             SetStateUnchecked();
400         else
401             SetStateChecked();
402         pData->StoreButtonState( pEntry, nItemFlags );
403         pData->CallLink();
404     }
405     return sal_False;
406 }
407 
408 void SvLBoxButton::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 /* nFlags */,
409                             SvLBoxEntry* /*pEntry*/ )
410 {
411     DBG_CHKTHIS(SvLBoxButton,0);
412     sal_uInt16 nIndex = eKind == SvLBoxButtonKind_staticImage
413         ? SV_BMP_STATICIMAGE : pData->GetIndex( nItemFlags );
414     sal_uInt16 nStyle = eKind != SvLBoxButtonKind_disabledCheckbox &&
415         rDev.IsEnabled() ? 0 : IMAGE_DRAW_DISABLE;
416 
417 ///
418 //Native drawing
419 ///
420     sal_Bool bNativeOK = sal_False;
421     ControlType eCtrlType = (pData->IsRadio())? CTRL_RADIOBUTTON : CTRL_CHECKBOX;
422     if ( nIndex != SV_BMP_STATICIMAGE && rDev.IsNativeControlSupported( eCtrlType, PART_ENTIRE_CONTROL) )
423     {
424         Size aSize(pData->Width(), pData->Height());
425         ImplAdjustBoxSize( aSize, eCtrlType, &rDev );
426         ImplControlValue    aControlValue;
427         Rectangle           aCtrlRegion( rPos, aSize );
428         ControlState        nState = 0;
429 
430         //states CTRL_STATE_DEFAULT, CTRL_STATE_PRESSED and CTRL_STATE_ROLLOVER are not implemented
431         if ( IsStateHilighted() )                   nState |= CTRL_STATE_FOCUSED;
432         if ( nStyle != IMAGE_DRAW_DISABLE )         nState |= CTRL_STATE_ENABLED;
433 
434         if ( IsStateChecked() )
435             aControlValue.setTristateVal( BUTTONVALUE_ON );
436         else if ( IsStateUnchecked() )
437             aControlValue.setTristateVal( BUTTONVALUE_OFF );
438         else if ( IsStateTristate() )
439             aControlValue.setTristateVal( BUTTONVALUE_MIXED );
440 
441         bNativeOK = rDev.DrawNativeControl( eCtrlType, PART_ENTIRE_CONTROL,
442                                 aCtrlRegion, nState, aControlValue, rtl::OUString() );
443     }
444 
445     if( !bNativeOK)
446         rDev.DrawImage( rPos, pData->aBmps[nIndex + nBaseOffs] ,nStyle);
447 }
448 
449 SvLBoxItem* SvLBoxButton::Create() const
450 {
451     DBG_CHKTHIS(SvLBoxButton,0);
452     return new SvLBoxButton;
453 }
454 
455 void SvLBoxButton::Clone( SvLBoxItem* pSource )
456 {
457     DBG_CHKTHIS(SvLBoxButton,0);
458     pData = ((SvLBoxButton*)pSource)->pData;
459 }
460 
461 void SvLBoxButton::ImplAdjustBoxSize( Size& io_rSize, ControlType i_eType, Window* i_pParent )
462 {
463     if ( i_pParent->IsNativeControlSupported( i_eType, PART_ENTIRE_CONTROL) )
464     {
465         ImplControlValue    aControlValue;
466         Rectangle           aCtrlRegion( Point( 0, 0 ), io_rSize );
467         ControlState        nState = CTRL_STATE_ENABLED;
468 
469         aControlValue.setTristateVal( BUTTONVALUE_ON );
470 
471         Rectangle aNativeBounds, aNativeContent;
472         bool bNativeOK = i_pParent->GetNativeControlRegion( i_eType,
473                                                             PART_ENTIRE_CONTROL,
474                                                             aCtrlRegion,
475                                                             nState,
476                                                             aControlValue,
477                                                             rtl::OUString(),
478                                                             aNativeBounds,
479                                                             aNativeContent );
480         if( bNativeOK )
481         {
482             Size aContentSize( aNativeContent.GetSize() );
483             // leave a little space around the box image (looks better
484             if( aContentSize.Height() + 2 > io_rSize.Height() )
485                 io_rSize.Height() = aContentSize.Height() + 2;
486         }
487     }
488 }
489 
490 void SvLBoxButton::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry,
491     SvViewDataItem* pViewData )
492 {
493     DBG_CHKTHIS(SvLBoxButton,0);
494     if( !pViewData )
495         pViewData = pView->GetViewDataItem( pEntry, this );
496     Size aSize( pData->Width(), pData->Height() );
497 
498     ControlType eCtrlType = (pData->IsRadio())? CTRL_RADIOBUTTON : CTRL_CHECKBOX;
499     if ( eKind != SvLBoxButtonKind_staticImage && pView )
500         ImplAdjustBoxSize( aSize, eCtrlType, pView );
501     pViewData->aSize = aSize;
502 }
503 
504 bool SvLBoxButton::CheckModification() const
505 {
506     if( eKind == SvLBoxButtonKind_disabledCheckbox )
507         Sound::Beep();
508     return eKind == SvLBoxButtonKind_enabledCheckbox;
509 }
510 
511 // ***************************************************************
512 // class SvLBoxContextBmp
513 // ***************************************************************
514 
515 struct SvLBoxContextBmp_Impl
516 {
517     Image       m_aImage1;
518     Image       m_aImage2;
519 
520     Image       m_aImage1_hc;
521     Image       m_aImage2_hc;
522 
523     sal_uInt16      m_nB2IndicatorFlags;
524 };
525 
526 // ***************************************************************
527 DBG_NAME(SvLBoxContextBmp)
528 
529 SvLBoxContextBmp::SvLBoxContextBmp( SvLBoxEntry* pEntry, sal_uInt16 nItemFlags,
530     Image aBmp1, Image aBmp2, sal_uInt16 nEntryFlags )
531     :SvLBoxItem( pEntry, nItemFlags )
532     ,m_pImpl( new SvLBoxContextBmp_Impl )
533 {
534     DBG_CTOR(SvLBoxContextBmp,0);
535 
536     m_pImpl->m_nB2IndicatorFlags = nEntryFlags;
537     SetModeImages( aBmp1, aBmp2 );
538 }
539 
540 SvLBoxContextBmp::SvLBoxContextBmp()
541     :SvLBoxItem( )
542     ,m_pImpl( new SvLBoxContextBmp_Impl )
543 {
544     m_pImpl->m_nB2IndicatorFlags = 0;
545     DBG_CTOR(SvLBoxContextBmp,0);
546 }
547 
548 SvLBoxContextBmp::~SvLBoxContextBmp()
549 {
550     delete m_pImpl;
551     DBG_DTOR(SvLBoxContextBmp,0);
552 }
553 
554 sal_uInt16 SvLBoxContextBmp::IsA()
555 {
556     DBG_CHKTHIS(SvLBoxContextBmp,0);
557     return SV_ITEM_ID_LBOXCONTEXTBMP;
558 }
559 
560 sal_Bool SvLBoxContextBmp::SetModeImages( const Image& _rBitmap1, const Image& _rBitmap2, BmpColorMode _eMode )
561 {
562     DBG_CHKTHIS(SvLBoxContextBmp,0);
563 
564     sal_Bool bSuccess = sal_True;
565     switch ( _eMode )
566     {
567         case BMP_COLOR_NORMAL:
568             m_pImpl->m_aImage1 = _rBitmap1;
569             m_pImpl->m_aImage2 = _rBitmap2;
570             break;
571 
572         case BMP_COLOR_HIGHCONTRAST:
573             m_pImpl->m_aImage1_hc = _rBitmap1;
574             m_pImpl->m_aImage2_hc = _rBitmap2;
575             break;
576 
577         default:
578             DBG_ERROR( "SvLBoxContextBmp::SetModeImages: unexpected mode!");
579             bSuccess = sal_False;
580             break;
581     }
582     return bSuccess;
583 }
584 
585 Image& SvLBoxContextBmp::implGetImageStore( sal_Bool _bFirst, BmpColorMode _eMode )
586 {
587     DBG_CHKTHIS(SvLBoxContextBmp,0);
588 
589     switch ( _eMode )
590     {
591         case BMP_COLOR_NORMAL:
592             return _bFirst ? m_pImpl->m_aImage1 : m_pImpl->m_aImage2;
593 
594         case BMP_COLOR_HIGHCONTRAST:
595             return _bFirst ? m_pImpl->m_aImage1_hc : m_pImpl->m_aImage2_hc;
596 
597         default:
598             DBG_ERROR( "SvLBoxContextBmp::implGetImageStore: unexpected mode!");
599     }
600 
601     // OJ: #i27071# wrong mode so we just return the normal images
602     return _bFirst ? m_pImpl->m_aImage1 : m_pImpl->m_aImage2;
603 }
604 
605 void SvLBoxContextBmp::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry,
606     SvViewDataItem* pViewData)
607 {
608     DBG_CHKTHIS(SvLBoxContextBmp,0);
609     if( !pViewData )
610         pViewData = pView->GetViewDataItem( pEntry, this );
611     pViewData->aSize = m_pImpl->m_aImage1.GetSizePixel();
612 }
613 
614 void SvLBoxContextBmp::Paint( const Point& _rPos, SvLBox& _rDev,
615     sal_uInt16 _nViewDataEntryFlags, SvLBoxEntry* _pEntry )
616 {
617     DBG_CHKTHIS(SvLBoxContextBmp,0);
618 
619     // determine the image set
620     BmpColorMode eMode( BMP_COLOR_NORMAL );
621     if ( !!m_pImpl->m_aImage1_hc )
622     {   // we really have HC images
623         if ( _rDev.GetSettings().GetStyleSettings().GetHighContrastMode() )
624             eMode = BMP_COLOR_HIGHCONTRAST;
625     }
626 
627     // get the image
628     const Image& rImage = implGetImageStore( 0 == ( _nViewDataEntryFlags & m_pImpl->m_nB2IndicatorFlags ), eMode );
629 
630     sal_Bool _bSemiTransparent = _pEntry && ( 0 != ( SV_ENTRYFLAG_SEMITRANSPARENT  & _pEntry->GetFlags( ) ) );
631     // draw
632     sal_uInt16 nStyle = _rDev.IsEnabled() ? 0 : IMAGE_DRAW_DISABLE;
633     if ( _bSemiTransparent )
634         nStyle |= IMAGE_DRAW_SEMITRANSPARENT;
635     _rDev.DrawImage( _rPos, rImage, nStyle);
636 }
637 
638 SvLBoxItem* SvLBoxContextBmp::Create() const
639 {
640     DBG_CHKTHIS(SvLBoxContextBmp,0);
641     return new SvLBoxContextBmp;
642 }
643 
644 void SvLBoxContextBmp::Clone( SvLBoxItem* pSource )
645 {
646     DBG_CHKTHIS(SvLBoxContextBmp,0);
647     m_pImpl->m_aImage1 = static_cast< SvLBoxContextBmp* >( pSource )->m_pImpl->m_aImage1;
648     m_pImpl->m_aImage2 = static_cast< SvLBoxContextBmp* >( pSource )->m_pImpl->m_aImage2;
649     m_pImpl->m_nB2IndicatorFlags = static_cast< SvLBoxContextBmp* >( pSource )->m_pImpl->m_nB2IndicatorFlags;
650 }
651 
652