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 : #include <svtools/treelistbox.hxx>
21 : #include <svtools/svlbitm.hxx>
22 : #include "svtools/treelistentry.hxx"
23 : #include "svtools/viewdataentry.hxx"
24 : #include <vcl/svapp.hxx>
25 : #include <vcl/button.hxx>
26 : #include <vcl/decoview.hxx>
27 : #include <vcl/salnativewidgets.hxx>
28 :
29 : struct SvLBoxButtonData_Impl
30 : {
31 : SvTreeListEntry* pEntry;
32 : sal_Bool bDefaultImages;
33 : sal_Bool bShowRadioButton;
34 :
35 0 : SvLBoxButtonData_Impl() : pEntry( NULL ), bDefaultImages( sal_False ), bShowRadioButton( sal_False ) {}
36 : };
37 :
38 :
39 : DBG_NAME(SvLBoxButtonData)
40 :
41 0 : void SvLBoxButtonData::InitData( sal_Bool bImagesFromDefault, bool _bRadioBtn, const Control* pCtrl )
42 : {
43 0 : pImpl = new SvLBoxButtonData_Impl;
44 :
45 0 : bDataOk = sal_False;
46 0 : eState = SV_BUTTON_UNCHECKED;
47 0 : pImpl->bDefaultImages = bImagesFromDefault;
48 0 : pImpl->bShowRadioButton = ( _bRadioBtn != false );
49 :
50 0 : if ( bImagesFromDefault )
51 0 : SetDefaultImages( pCtrl );
52 0 : }
53 :
54 0 : SvLBoxButtonData::SvLBoxButtonData( const Control* pControlForSettings )
55 : {
56 : DBG_CTOR(SvLBoxButtonData,0);
57 :
58 0 : InitData( sal_True, false, pControlForSettings );
59 0 : }
60 :
61 0 : SvLBoxButtonData::SvLBoxButtonData( const Control* pControlForSettings, bool _bRadioBtn )
62 : {
63 : DBG_CTOR(SvLBoxButtonData,0);
64 :
65 0 : InitData( sal_True, _bRadioBtn, pControlForSettings );
66 0 : }
67 :
68 0 : SvLBoxButtonData::~SvLBoxButtonData()
69 : {
70 : DBG_DTOR(SvLBoxButtonData,0);
71 :
72 0 : delete pImpl;
73 : #ifdef DBG_UTIL
74 : pImpl = NULL;
75 : #endif
76 0 : }
77 :
78 0 : void SvLBoxButtonData::CallLink()
79 : {
80 : DBG_CHKTHIS(SvLBoxButtonData,0);
81 0 : aLink.Call( this );
82 0 : }
83 :
84 0 : sal_uInt16 SvLBoxButtonData::GetIndex( sal_uInt16 nItemState )
85 : {
86 : DBG_CHKTHIS(SvLBoxButtonData,0);
87 0 : nItemState &= 0x000F;
88 : sal_uInt16 nIdx;
89 0 : switch( nItemState )
90 : {
91 : case SV_ITEMSTATE_UNCHECKED:
92 0 : nIdx = SV_BMP_UNCHECKED; break;
93 : case SV_ITEMSTATE_CHECKED:
94 0 : nIdx = SV_BMP_CHECKED; break;
95 : case SV_ITEMSTATE_TRISTATE:
96 0 : nIdx = SV_BMP_TRISTATE; break;
97 : case SV_ITEMSTATE_UNCHECKED | SV_ITEMSTATE_HILIGHTED:
98 0 : nIdx = SV_BMP_HIUNCHECKED; break;
99 : case SV_ITEMSTATE_CHECKED | SV_ITEMSTATE_HILIGHTED:
100 0 : nIdx = SV_BMP_HICHECKED; break;
101 : case SV_ITEMSTATE_TRISTATE | SV_ITEMSTATE_HILIGHTED:
102 0 : nIdx = SV_BMP_HITRISTATE; break;
103 : default:
104 0 : nIdx = SV_BMP_UNCHECKED;
105 : }
106 0 : return nIdx;
107 : }
108 :
109 0 : void SvLBoxButtonData::SetWidthAndHeight()
110 : {
111 : DBG_CHKTHIS(SvLBoxButtonData,0);
112 0 : Size aSize = aBmps[0].GetSizePixel();
113 0 : nWidth = aSize.Width();
114 0 : nHeight = aSize.Height();
115 0 : bDataOk = sal_True;
116 0 : }
117 :
118 :
119 0 : void SvLBoxButtonData::StoreButtonState( SvTreeListEntry* pActEntry, sal_uInt16 nItemFlags )
120 : {
121 : DBG_CHKTHIS(SvLBoxButtonData,0);
122 0 : pImpl->pEntry = pActEntry;
123 0 : eState = ConvertToButtonState( nItemFlags );
124 0 : }
125 :
126 0 : SvButtonState SvLBoxButtonData::ConvertToButtonState( sal_uInt16 nItemFlags ) const
127 : {
128 : DBG_CHKTHIS(SvLBoxButtonData,0);
129 : nItemFlags &= (SV_ITEMSTATE_UNCHECKED |
130 : SV_ITEMSTATE_CHECKED |
131 0 : SV_ITEMSTATE_TRISTATE);
132 0 : switch( nItemFlags )
133 : {
134 : case SV_ITEMSTATE_UNCHECKED:
135 0 : return SV_BUTTON_UNCHECKED;
136 :
137 : case SV_ITEMSTATE_CHECKED:
138 0 : return SV_BUTTON_CHECKED;
139 :
140 : case SV_ITEMSTATE_TRISTATE:
141 0 : return SV_BUTTON_TRISTATE;
142 : default:
143 0 : return SV_BUTTON_UNCHECKED;
144 : }
145 : }
146 :
147 0 : SvTreeListEntry* SvLBoxButtonData::GetActEntry() const
148 : {
149 : DBG_ASSERT( pImpl, "-SvLBoxButtonData::GetActEntry(): don't use me that way!" );
150 0 : return pImpl->pEntry;
151 : }
152 :
153 0 : void SvLBoxButtonData::SetDefaultImages( const Control* pCtrl )
154 : {
155 0 : const AllSettings& rSettings = pCtrl? pCtrl->GetSettings() : Application::GetSettings();
156 :
157 0 : if ( pImpl->bShowRadioButton )
158 : {
159 0 : aBmps[ SV_BMP_UNCHECKED ] = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_DEFAULT );
160 0 : aBmps[ SV_BMP_CHECKED ] = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_CHECKED );
161 0 : aBmps[ SV_BMP_HICHECKED ] = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_CHECKED | BUTTON_DRAW_PRESSED );
162 0 : aBmps[ SV_BMP_HIUNCHECKED ] = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_DEFAULT | BUTTON_DRAW_PRESSED );
163 0 : aBmps[ SV_BMP_TRISTATE ] = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_DONTKNOW );
164 0 : aBmps[ SV_BMP_HITRISTATE ] = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_DONTKNOW | BUTTON_DRAW_PRESSED );
165 : }
166 : else
167 : {
168 0 : aBmps[ SV_BMP_UNCHECKED ] = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DEFAULT );
169 0 : aBmps[ SV_BMP_CHECKED ] = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_CHECKED );
170 0 : aBmps[ SV_BMP_HICHECKED ] = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_CHECKED | BUTTON_DRAW_PRESSED );
171 0 : aBmps[ SV_BMP_HIUNCHECKED ] = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DEFAULT | BUTTON_DRAW_PRESSED );
172 0 : aBmps[ SV_BMP_TRISTATE ] = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DONTKNOW );
173 0 : aBmps[ SV_BMP_HITRISTATE ] = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DONTKNOW | BUTTON_DRAW_PRESSED );
174 : }
175 0 : }
176 :
177 0 : sal_Bool SvLBoxButtonData::HasDefaultImages( void ) const
178 : {
179 0 : return pImpl->bDefaultImages;
180 : }
181 :
182 0 : sal_Bool SvLBoxButtonData::IsRadio() {
183 0 : return pImpl->bShowRadioButton;
184 : }
185 :
186 : // ***************************************************************
187 : // class SvLBoxString
188 : // ***************************************************************
189 :
190 : DBG_NAME(SvLBoxString);
191 :
192 21682 : SvLBoxString::SvLBoxString(SvTreeListEntry* pEntry, sal_uInt16 nFlags, const OUString& rStr)
193 21682 : : SvLBoxItem(pEntry, nFlags)
194 : {
195 : DBG_CTOR(SvLBoxString,0);
196 21682 : SetText(rStr);
197 21682 : }
198 :
199 0 : SvLBoxString::SvLBoxString() : SvLBoxItem()
200 : {
201 : DBG_CTOR(SvLBoxString,0);
202 0 : }
203 :
204 43360 : SvLBoxString::~SvLBoxString()
205 : {
206 : DBG_DTOR(SvLBoxString,0);
207 43360 : }
208 :
209 111011 : sal_uInt16 SvLBoxString::GetType() const
210 : {
211 : DBG_CHKTHIS(SvLBoxString,0);
212 111011 : return SV_ITEM_ID_LBOXSTRING;
213 : }
214 :
215 2159 : void SvLBoxString::Paint(
216 : const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* /*pView*/,
217 : const SvTreeListEntry* pEntry)
218 : {
219 : DBG_CHKTHIS(SvLBoxString,0);
220 2159 : if (pEntry)
221 : {
222 2159 : sal_uInt16 nStyle = rDev.IsEnabled() ? 0 : TEXT_DRAW_DISABLE;
223 2159 : if ( rDev.IsEntryMnemonicsEnabled() )
224 0 : nStyle |= TEXT_DRAW_MNEMONIC;
225 2159 : rDev.DrawText(Rectangle(rPos, GetSize(&rDev, pEntry)), maText, nStyle);
226 : }
227 : else
228 0 : rDev.DrawText(rPos, maText);
229 :
230 2159 : }
231 :
232 0 : SvLBoxItem* SvLBoxString::Create() const
233 : {
234 : DBG_CHKTHIS(SvLBoxString,0);
235 0 : return new SvLBoxString;
236 : }
237 :
238 0 : void SvLBoxString::Clone( SvLBoxItem* pSource )
239 : {
240 : DBG_CHKTHIS(SvLBoxString,0);
241 0 : maText = ((SvLBoxString*)pSource)->maText;
242 0 : }
243 :
244 21717 : void SvLBoxString::InitViewData(
245 : SvTreeListBox* pView, SvTreeListEntry* pEntry, SvViewDataItem* pViewData)
246 : {
247 : DBG_CHKTHIS(SvLBoxString,0);
248 21717 : if( !pViewData )
249 39 : pViewData = pView->GetViewDataItem( pEntry, this );
250 21717 : pViewData->maSize = Size(pView->GetTextWidth(maText), pView->GetTextHeight());
251 21717 : }
252 :
253 : // ***************************************************************
254 : // class SvLBoxBmp
255 : // ***************************************************************
256 :
257 : DBG_NAME(SvLBoxBmp);
258 :
259 0 : SvLBoxBmp::SvLBoxBmp() : SvLBoxItem()
260 : {
261 : DBG_CTOR(SvLBoxBmp,0);
262 0 : }
263 :
264 0 : SvLBoxBmp::~SvLBoxBmp()
265 : {
266 : DBG_DTOR(SvLBoxBmp,0);
267 0 : }
268 :
269 0 : sal_uInt16 SvLBoxBmp::GetType() const
270 : {
271 : DBG_CHKTHIS(SvLBoxBmp,0);
272 0 : return SV_ITEM_ID_LBOXBMP;
273 : }
274 :
275 0 : void SvLBoxBmp::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry,
276 : SvViewDataItem* pViewData)
277 : {
278 : DBG_CHKTHIS(SvLBoxBmp,0);
279 0 : if( !pViewData )
280 0 : pViewData = pView->GetViewDataItem( pEntry, this );
281 0 : pViewData->maSize = aBmp.GetSizePixel();
282 0 : }
283 :
284 0 : void SvLBoxBmp::Paint(
285 : const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* /*pView*/,
286 : const SvTreeListEntry* /*pEntry*/)
287 : {
288 : DBG_CHKTHIS(SvLBoxBmp,0);
289 0 : sal_uInt16 nStyle = rDev.IsEnabled() ? 0 : IMAGE_DRAW_DISABLE;
290 0 : rDev.DrawImage( rPos, aBmp ,nStyle);
291 0 : }
292 :
293 0 : SvLBoxItem* SvLBoxBmp::Create() const
294 : {
295 : DBG_CHKTHIS(SvLBoxBmp,0);
296 0 : return new SvLBoxBmp;
297 : }
298 :
299 0 : void SvLBoxBmp::Clone( SvLBoxItem* pSource )
300 : {
301 : DBG_CHKTHIS(SvLBoxBmp,0);
302 0 : aBmp = ((SvLBoxBmp*)pSource)->aBmp;
303 0 : }
304 :
305 : // ***************************************************************
306 : // class SvLBoxButton
307 : // ***************************************************************
308 :
309 : DBG_NAME(SvLBoxButton);
310 :
311 0 : SvLBoxButton::SvLBoxButton( SvTreeListEntry* pEntry, SvLBoxButtonKind eTheKind,
312 : sal_uInt16 nFlags, SvLBoxButtonData* pBData )
313 0 : : SvLBoxItem( pEntry, nFlags )
314 : {
315 : DBG_CTOR(SvLBoxButton,0);
316 0 : eKind = eTheKind;
317 0 : nBaseOffs = 0;
318 0 : nItemFlags = 0;
319 0 : SetStateUnchecked();
320 0 : pData = pBData;
321 0 : isVis = true;
322 0 : }
323 :
324 0 : SvLBoxButton::SvLBoxButton() : SvLBoxItem()
325 : {
326 : DBG_CTOR(SvLBoxButton,0);
327 0 : eKind = SvLBoxButtonKind_enabledCheckbox;
328 0 : nItemFlags = 0;
329 0 : SetStateUnchecked();
330 0 : }
331 :
332 0 : SvLBoxButton::~SvLBoxButton()
333 : {
334 : DBG_DTOR(SvLBoxButton,0);
335 0 : }
336 :
337 0 : sal_uInt16 SvLBoxButton::GetType() const
338 : {
339 : DBG_CHKTHIS(SvLBoxButton,0);
340 0 : return SV_ITEM_ID_LBOXBUTTON;
341 : }
342 :
343 0 : sal_Bool SvLBoxButton::ClickHdl( SvTreeListBox*, SvTreeListEntry* pEntry )
344 : {
345 : DBG_CHKTHIS(SvLBoxButton,0);
346 0 : if ( CheckModification() )
347 : {
348 0 : if ( IsStateChecked() )
349 0 : SetStateUnchecked();
350 : else
351 0 : SetStateChecked();
352 0 : pData->StoreButtonState( pEntry, nItemFlags );
353 0 : pData->CallLink();
354 : }
355 0 : return sal_False;
356 : }
357 :
358 0 : void SvLBoxButton::Paint(
359 : const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* /*pView*/,
360 : const SvTreeListEntry* /*pEntry*/)
361 : {
362 : DBG_CHKTHIS(SvLBoxButton,0);
363 0 : sal_uInt16 nIndex = eKind == SvLBoxButtonKind_staticImage
364 0 : ? SV_BMP_STATICIMAGE : pData->GetIndex( nItemFlags );
365 0 : sal_uInt16 nStyle = eKind != SvLBoxButtonKind_disabledCheckbox &&
366 0 : rDev.IsEnabled() ? 0 : IMAGE_DRAW_DISABLE;
367 :
368 : ///
369 : //Native drawing
370 : ///
371 0 : sal_Bool bNativeOK = sal_False;
372 0 : ControlType eCtrlType = (pData->IsRadio())? CTRL_RADIOBUTTON : CTRL_CHECKBOX;
373 0 : if ( nIndex != SV_BMP_STATICIMAGE && rDev.IsNativeControlSupported( eCtrlType, PART_ENTIRE_CONTROL) )
374 :
375 : {
376 0 : Size aSize(pData->Width(), pData->Height());
377 0 : ImplAdjustBoxSize( aSize, eCtrlType, &rDev );
378 0 : ImplControlValue aControlValue;
379 0 : Rectangle aCtrlRegion( rPos, aSize );
380 0 : ControlState nState = 0;
381 :
382 : //states CTRL_STATE_DEFAULT, CTRL_STATE_PRESSED and CTRL_STATE_ROLLOVER are not implemented
383 0 : if ( IsStateHilighted() ) nState |= CTRL_STATE_FOCUSED;
384 0 : if ( nStyle != IMAGE_DRAW_DISABLE ) nState |= CTRL_STATE_ENABLED;
385 :
386 0 : if ( IsStateChecked() )
387 0 : aControlValue.setTristateVal( BUTTONVALUE_ON );
388 0 : else if ( IsStateUnchecked() )
389 0 : aControlValue.setTristateVal( BUTTONVALUE_OFF );
390 0 : else if ( IsStateTristate() )
391 0 : aControlValue.setTristateVal( BUTTONVALUE_MIXED );
392 :
393 0 : if( isVis)
394 : bNativeOK = rDev.DrawNativeControl( eCtrlType, PART_ENTIRE_CONTROL,
395 0 : aCtrlRegion, nState, aControlValue, OUString() );
396 : }
397 :
398 0 : if( !bNativeOK && isVis )
399 0 : rDev.DrawImage( rPos, pData->aBmps[nIndex + nBaseOffs] ,nStyle);
400 0 : }
401 :
402 0 : SvLBoxItem* SvLBoxButton::Create() const
403 : {
404 : DBG_CHKTHIS(SvLBoxButton,0);
405 0 : return new SvLBoxButton;
406 : }
407 :
408 0 : void SvLBoxButton::Clone( SvLBoxItem* pSource )
409 : {
410 : DBG_CHKTHIS(SvLBoxButton,0);
411 0 : pData = ((SvLBoxButton*)pSource)->pData;
412 0 : }
413 :
414 0 : void SvLBoxButton::ImplAdjustBoxSize( Size& io_rSize, ControlType i_eType, Window* i_pParent )
415 : {
416 0 : if ( i_pParent->IsNativeControlSupported( i_eType, PART_ENTIRE_CONTROL) )
417 : {
418 0 : ImplControlValue aControlValue;
419 0 : Rectangle aCtrlRegion( Point( 0, 0 ), io_rSize );
420 0 : ControlState nState = CTRL_STATE_ENABLED;
421 :
422 0 : aControlValue.setTristateVal( BUTTONVALUE_ON );
423 :
424 0 : Rectangle aNativeBounds, aNativeContent;
425 : bool bNativeOK = i_pParent->GetNativeControlRegion( i_eType,
426 : PART_ENTIRE_CONTROL,
427 : aCtrlRegion,
428 : nState,
429 : aControlValue,
430 : OUString(),
431 : aNativeBounds,
432 0 : aNativeContent );
433 0 : if( bNativeOK )
434 : {
435 0 : Size aContentSize( aNativeContent.GetSize() );
436 : // leave a little space around the box image (looks better)
437 0 : if( aContentSize.Height() + 2 > io_rSize.Height() )
438 0 : io_rSize.Height() = aContentSize.Height() + 2;
439 0 : if( aContentSize.Width() + 2 > io_rSize.Width() )
440 0 : io_rSize.Width() = aContentSize.Width() + 2;
441 0 : }
442 : }
443 0 : }
444 :
445 0 : void SvLBoxButton::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry,
446 : SvViewDataItem* pViewData )
447 : {
448 : DBG_CHKTHIS(SvLBoxButton,0);
449 0 : if( !pViewData )
450 0 : pViewData = pView->GetViewDataItem( pEntry, this );
451 0 : Size aSize( pData->Width(), pData->Height() );
452 :
453 0 : ControlType eCtrlType = (pData->IsRadio())? CTRL_RADIOBUTTON : CTRL_CHECKBOX;
454 0 : if ( eKind != SvLBoxButtonKind_staticImage && pView )
455 0 : ImplAdjustBoxSize( aSize, eCtrlType, pView );
456 0 : pViewData->maSize = aSize;
457 0 : }
458 :
459 0 : bool SvLBoxButton::CheckModification() const
460 : {
461 0 : return eKind == SvLBoxButtonKind_enabledCheckbox;
462 : }
463 :
464 0 : void SvLBoxButton::SetStateInvisible()
465 : {
466 0 : isVis = false;
467 0 : }
468 :
469 : // ***************************************************************
470 : // class SvLBoxContextBmp
471 : // ***************************************************************
472 :
473 43356 : struct SvLBoxContextBmp_Impl
474 : {
475 : Image m_aImage1;
476 : Image m_aImage2;
477 :
478 : bool m_bExpanded;
479 : };
480 :
481 : // ***************************************************************
482 : DBG_NAME(SvLBoxContextBmp)
483 :
484 21678 : SvLBoxContextBmp::SvLBoxContextBmp(
485 : SvTreeListEntry* pEntry, sal_uInt16 nItemFlags, Image aBmp1, Image aBmp2,
486 : bool bExpanded)
487 : :SvLBoxItem( pEntry, nItemFlags )
488 21678 : ,m_pImpl( new SvLBoxContextBmp_Impl )
489 : {
490 : DBG_CTOR(SvLBoxContextBmp,0);
491 :
492 21678 : m_pImpl->m_bExpanded = bExpanded;
493 21678 : SetModeImages( aBmp1, aBmp2 );
494 21678 : }
495 :
496 0 : SvLBoxContextBmp::SvLBoxContextBmp()
497 : :SvLBoxItem( )
498 0 : ,m_pImpl( new SvLBoxContextBmp_Impl )
499 : {
500 0 : m_pImpl->m_bExpanded = false;
501 : DBG_CTOR(SvLBoxContextBmp,0);
502 0 : }
503 :
504 65034 : SvLBoxContextBmp::~SvLBoxContextBmp()
505 : {
506 21678 : delete m_pImpl;
507 : DBG_DTOR(SvLBoxContextBmp,0);
508 43356 : }
509 :
510 134900 : sal_uInt16 SvLBoxContextBmp::GetType() const
511 : {
512 : DBG_CHKTHIS(SvLBoxContextBmp,0);
513 134900 : return SV_ITEM_ID_LBOXCONTEXTBMP;
514 : }
515 :
516 21678 : sal_Bool SvLBoxContextBmp::SetModeImages( const Image& _rBitmap1, const Image& _rBitmap2 )
517 : {
518 : DBG_CHKTHIS(SvLBoxContextBmp,0);
519 :
520 21678 : sal_Bool bSuccess = sal_True;
521 21678 : m_pImpl->m_aImage1 = _rBitmap1;
522 21678 : m_pImpl->m_aImage2 = _rBitmap2;
523 21678 : return bSuccess;
524 : }
525 :
526 45533 : Image& SvLBoxContextBmp::implGetImageStore( sal_Bool _bFirst )
527 : {
528 : DBG_CHKTHIS(SvLBoxContextBmp,0);
529 :
530 : // OJ: #i27071# wrong mode so we just return the normal images
531 45533 : return _bFirst ? m_pImpl->m_aImage1 : m_pImpl->m_aImage2;
532 : }
533 :
534 21717 : void SvLBoxContextBmp::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry,
535 : SvViewDataItem* pViewData)
536 : {
537 : DBG_CHKTHIS(SvLBoxContextBmp,0);
538 21717 : if( !pViewData )
539 39 : pViewData = pView->GetViewDataItem( pEntry, this );
540 21717 : pViewData->maSize = m_pImpl->m_aImage1.GetSizePixel();
541 21717 : }
542 :
543 2167 : void SvLBoxContextBmp::Paint(
544 : const Point& _rPos, SvTreeListBox& _rDev,
545 : const SvViewDataEntry* pView, const SvTreeListEntry* pEntry)
546 : {
547 : DBG_CHKTHIS(SvLBoxContextBmp,0);
548 :
549 : // get the image.
550 2167 : const Image& rImage = implGetImageStore(pView->IsExpanded() != m_pImpl->m_bExpanded);
551 :
552 2167 : sal_Bool _bSemiTransparent = pEntry && ( 0 != ( SV_ENTRYFLAG_SEMITRANSPARENT & pEntry->GetFlags( ) ) );
553 : // draw
554 2167 : sal_uInt16 nStyle = _rDev.IsEnabled() ? 0 : IMAGE_DRAW_DISABLE;
555 2167 : if ( _bSemiTransparent )
556 0 : nStyle |= IMAGE_DRAW_SEMITRANSPARENT;
557 2167 : _rDev.DrawImage( _rPos, rImage, nStyle);
558 2167 : }
559 :
560 0 : SvLBoxItem* SvLBoxContextBmp::Create() const
561 : {
562 : DBG_CHKTHIS(SvLBoxContextBmp,0);
563 0 : return new SvLBoxContextBmp;
564 : }
565 :
566 0 : void SvLBoxContextBmp::Clone( SvLBoxItem* pSource )
567 : {
568 : DBG_CHKTHIS(SvLBoxContextBmp,0);
569 0 : m_pImpl->m_aImage1 = static_cast< SvLBoxContextBmp* >( pSource )->m_pImpl->m_aImage1;
570 0 : m_pImpl->m_aImage2 = static_cast< SvLBoxContextBmp* >( pSource )->m_pImpl->m_aImage2;
571 0 : m_pImpl->m_bExpanded = static_cast<SvLBoxContextBmp*>(pSource)->m_pImpl->m_bExpanded;
572 0 : }
573 :
574 0 : long SvLBoxButtonData::Width()
575 : {
576 0 : if ( !bDataOk )
577 0 : SetWidthAndHeight();
578 0 : return nWidth;
579 : }
580 :
581 0 : long SvLBoxButtonData::Height()
582 : {
583 0 : if ( !bDataOk )
584 0 : SetWidthAndHeight();
585 0 : return nHeight;
586 465 : }
587 :
588 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|