1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <vcl/event.hxx>
23 #include <vcl/toolkit/roadmap.hxx>
24 #include <vcl/settings.hxx>
25 #include <hyperlabel.hxx>
26 #include <tools/color.hxx>
27 #include <rtl/ustring.hxx>
29 constexpr long LABELBASEMAPHEIGHT
= 8;
30 constexpr long ROADMAP_INDENT_X
= 4;
31 constexpr long ROADMAP_INDENT_Y
= 27;
32 constexpr long ROADMAP_ITEM_DISTANCE_Y
= 6;
37 typedef std::vector
< RoadmapItem
* > HL_Vector
;
41 class IDLabel
: public FixedText
44 IDLabel( vcl::Window
* _pParent
, WinBits _nWinStyle
);
45 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
46 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
49 class RoadmapItem
: public RoadmapTypes
53 VclPtr
<HyperLabel
> mpDescription
;
54 const Size m_aItemPlayground
;
57 RoadmapItem( ORoadmap
& _rParent
, const Size
& _rItemPlayground
);
60 void SetID( sal_Int16 ID
);
61 sal_Int16
GetID() const;
63 void SetIndex( ItemIndex Index
);
64 ItemIndex
GetIndex() const;
66 void Update( ItemIndex RMIndex
, const OUString
& _rText
);
68 void SetPosition( RoadmapItem
const * OldHyperLabel
);
70 void ToggleBackgroundColor( const Color
& _rGBColor
);
71 void SetInteractive( bool _bInteractive
);
73 void SetClickHdl( const Link
<HyperLabel
*,void>& rLink
);
74 void Enable( bool bEnable
);
75 bool IsEnabled() const;
78 bool Contains( const vcl::Window
* _pWindow
) const;
81 void ImplUpdateIndex( const ItemIndex _nIndex
);
82 void ImplUpdatePosSize();
87 class RoadmapImpl
: public RoadmapTypes
90 const ORoadmap
& m_rAntiImpl
;
91 Link
<LinkParamNone
*,void> m_aSelectHdl
;
93 HL_Vector m_aRoadmapSteps
;
95 bool m_bInteractive
: 1;
97 Size m_aItemSizePixel
;
99 bool m_bPaintInitialized
: 1;
102 explicit RoadmapImpl(const ORoadmap
& rAntiImpl
)
103 : m_rAntiImpl(rAntiImpl
)
105 , m_bInteractive(true)
107 , m_bPaintInitialized(false)
108 , InCompleteHyperLabel(nullptr)
111 RoadmapItem
* InCompleteHyperLabel
;
113 HL_Vector
& getHyperLabels()
115 return m_aRoadmapSteps
;
118 void insertHyperLabel(ItemIndex Index
, RoadmapItem
* _rRoadmapStep
)
120 m_aRoadmapSteps
.insert(m_aRoadmapSteps
.begin() + Index
, _rRoadmapStep
);
123 ItemIndex
getItemCount() const
125 return m_aRoadmapSteps
.size();
128 void setCurItemID(ItemId i
)
132 ItemId
getCurItemID() const
137 void setInteractive(const bool _bInteractive
)
139 m_bInteractive
= _bInteractive
;
141 bool isInteractive() const
143 return m_bInteractive
;
146 void setComplete(const bool _bComplete
)
148 m_bComplete
= _bComplete
;
150 bool isComplete() const
155 void setPicture(const BitmapEx
& _rPic
)
159 const BitmapEx
& getPicture() const
164 void setSelectHdl(const Link
<LinkParamNone
*,void>& _rHdl
)
166 m_aSelectHdl
= _rHdl
;
168 const Link
<LinkParamNone
*,void>& getSelectHdl() const
174 const Size
& getItemSize() const
176 return m_aItemSizePixel
;
179 void removeHyperLabel(ItemIndex Index
)
181 if ((Index
> -1) && (Index
< getItemCount()))
183 delete m_aRoadmapSteps
[Index
];
184 m_aRoadmapSteps
.erase(m_aRoadmapSteps
.begin() + Index
);
189 void RoadmapImpl::initItemSize()
191 Size
aLabelSize( m_rAntiImpl
.GetOutputSizePixel() );
192 aLabelSize
.setHeight( m_rAntiImpl
.LogicToPixel(Size(0, LABELBASEMAPHEIGHT
), MapMode(MapUnit::MapAppFont
)).Height() );
193 aLabelSize
.AdjustWidth( -(m_rAntiImpl
.LogicToPixel(Size(2 * ROADMAP_INDENT_X
, 0), MapMode(MapUnit::MapAppFont
)).Width()) );
194 m_aItemSizePixel
= aLabelSize
;
199 ORoadmap::ORoadmap(vcl::Window
* _pParent
, WinBits _nWinStyle
)
200 : Control(_pParent
, _nWinStyle
)
201 , m_pImpl(new RoadmapImpl(*this))
205 void ORoadmap::implInit(vcl::RenderContext
& rRenderContext
)
207 m_pImpl
->InCompleteHyperLabel
= nullptr;
208 m_pImpl
->setCurItemID(-1);
209 m_pImpl
->setComplete(true);
210 m_pImpl
->m_bPaintInitialized
= true;
212 // Roadmap control should be reachable as one unit with a Tab key
213 // the next Tab key should spring out of the control.
214 // To reach it the control itself should get focus and set it
215 // on entries. The entries themself should not be reachable with
216 // the Tab key directly. So each entry should have WB_NOTABSTOP.
218 // In other words the creator should create the control with the following
220 // SetStyle( ( GetStyle() | WB_TABSTOP ) & ~WB_DIALOGCONTROL );
222 // TODO: if somebody sets a new font from outside (OutputDevice::SetFont), we would have to react
223 // on this with calculating a new bold font.
224 // Unfortunately, the OutputDevice does not offer a notify mechanism for a changed font.
225 // So settings the font from outside is simply a forbidden scenario at the moment
226 rRenderContext
.EnableMapMode(false);
229 ORoadmap::~ORoadmap()
234 void ORoadmap::dispose()
236 HL_Vector aItemsCopy
= m_pImpl
->getHyperLabels();
237 m_pImpl
->getHyperLabels().clear();
238 for (auto const& itemCopy
: aItemsCopy
)
242 if ( ! m_pImpl
->isComplete() )
243 delete m_pImpl
->InCompleteHyperLabel
;
248 RoadmapTypes::ItemId
ORoadmap::GetCurrentRoadmapItemID() const
250 return m_pImpl
->getCurItemID();
253 RoadmapItem
* ORoadmap::GetPreviousHyperLabel(ItemIndex Index
)
255 RoadmapItem
* pOldItem
= nullptr;
257 pOldItem
= m_pImpl
->getHyperLabels().at( Index
- 1 );
261 RoadmapItem
* ORoadmap::InsertHyperLabel(ItemIndex Index
, const OUString
& _sLabel
, ItemId RMID
, bool _bEnabled
, bool _bIncomplete
)
263 if (m_pImpl
->getItemCount() == 0)
264 m_pImpl
->initItemSize();
266 RoadmapItem
* pItem
= nullptr;
267 RoadmapItem
* pOldItem
= GetPreviousHyperLabel( Index
);
269 pItem
= new RoadmapItem( *this, m_pImpl
->getItemSize() );
272 pItem
->SetInteractive( false );
276 pItem
->SetInteractive( m_pImpl
->isInteractive() );
277 m_pImpl
->insertHyperLabel( Index
, pItem
);
279 pItem
->SetPosition( pOldItem
);
280 pItem
->Update( Index
, _sLabel
);
281 pItem
->SetClickHdl(LINK( this, ORoadmap
, ImplClickHdl
) );
282 pItem
->SetID( RMID
);
283 pItem
->SetIndex( Index
);
285 pItem
->Enable( _bEnabled
);
289 void ORoadmap::SetRoadmapBitmap(const BitmapEx
& _rBmp
)
291 m_pImpl
->setPicture( _rBmp
);
295 void ORoadmap::SetRoadmapInteractive(bool _bInteractive
)
297 m_pImpl
->setInteractive( _bInteractive
);
299 const HL_Vector
& rItems
= m_pImpl
->getHyperLabels();
300 for (auto const& item
: rItems
)
302 item
->SetInteractive( _bInteractive
);
306 bool ORoadmap::IsRoadmapInteractive() const
308 return m_pImpl
->isInteractive();
311 void ORoadmap::SetRoadmapComplete(bool _bComplete
)
313 bool bWasComplete
= m_pImpl
->isComplete();
314 m_pImpl
->setComplete( _bComplete
);
317 if (m_pImpl
->InCompleteHyperLabel
!= nullptr)
319 delete m_pImpl
->InCompleteHyperLabel
;
320 m_pImpl
->InCompleteHyperLabel
= nullptr;
323 else if (bWasComplete
)
324 m_pImpl
->InCompleteHyperLabel
= InsertHyperLabel(m_pImpl
->getItemCount(), "...", -1, true/*bEnabled*/, true/*bIncomplete*/ );
327 void ORoadmap::UpdatefollowingHyperLabels(ItemIndex _nIndex
)
329 const HL_Vector
& rItems
= m_pImpl
->getHyperLabels();
330 if ( _nIndex
< static_cast<ItemIndex
>(rItems
.size()) )
332 for ( HL_Vector::const_iterator i
= rItems
.begin() + _nIndex
;
337 RoadmapItem
* pItem
= *i
;
339 pItem
->SetIndex( _nIndex
);
340 pItem
->SetPosition( GetPreviousHyperLabel( _nIndex
) );
344 if ( ! m_pImpl
->isComplete() )
346 RoadmapItem
* pOldItem
= GetPreviousHyperLabel( m_pImpl
->getItemCount() );
347 m_pImpl
->InCompleteHyperLabel
->SetPosition( pOldItem
);
348 m_pImpl
->InCompleteHyperLabel
->Update( m_pImpl
->getItemCount(), "..." );
352 void ORoadmap::ReplaceRoadmapItem(ItemIndex Index
, const OUString
& roadmapItem
, ItemId RMID
, bool _bEnabled
)
354 RoadmapItem
* pItem
= GetByIndex( Index
);
355 if ( pItem
!= nullptr )
357 pItem
->Update( Index
, roadmapItem
);
358 pItem
->SetID( RMID
);
359 pItem
->Enable( _bEnabled
);
363 RoadmapTypes::ItemIndex
ORoadmap::GetItemCount() const
365 return m_pImpl
->getItemCount();
368 RoadmapTypes::ItemId
ORoadmap::GetItemID(ItemIndex _nIndex
) const
370 const RoadmapItem
* pHyperLabel
= GetByIndex( _nIndex
);
372 return pHyperLabel
->GetID();
376 void ORoadmap::InsertRoadmapItem(ItemIndex Index
, const OUString
& RoadmapItem
, ItemId _nUniqueId
, bool _bEnabled
)
378 InsertHyperLabel( Index
, RoadmapItem
, _nUniqueId
, _bEnabled
, false/*bIncomplete*/ );
379 // TODO YPos is superfluous, if items are always appended
380 UpdatefollowingHyperLabels( Index
+ 1 );
383 void ORoadmap::DeleteRoadmapItem(ItemIndex Index
)
385 if ( m_pImpl
->getItemCount() > 0 && ( Index
> -1) && ( Index
< m_pImpl
->getItemCount() ) )
387 m_pImpl
->removeHyperLabel( Index
);
388 UpdatefollowingHyperLabels( Index
);
392 bool ORoadmap::IsRoadmapComplete() const
394 return m_pImpl
->isComplete();
397 void ORoadmap::EnableRoadmapItem( ItemId _nItemId
, bool _bEnable
)
399 RoadmapItem
* pItem
= GetByID( _nItemId
);
400 if ( pItem
!= nullptr )
401 pItem
->Enable( _bEnable
);
404 void ORoadmap::ChangeRoadmapItemLabel( ItemId _nID
, const OUString
& _sLabel
)
406 RoadmapItem
* pItem
= GetByID( _nID
);
407 if ( pItem
== nullptr )
410 pItem
->Update( pItem
->GetIndex(), _sLabel
);
412 const HL_Vector
& rItems
= m_pImpl
->getHyperLabels();
414 for (auto const& item
: rItems
)
416 item
->SetPosition( GetPreviousHyperLabel(nPos
) );
421 void ORoadmap::ChangeRoadmapItemID(ItemId _nID
, ItemId NewID
)
423 RoadmapItem
* pItem
= GetByID( _nID
);
424 if ( pItem
!= nullptr )
425 pItem
->SetID( NewID
);
428 RoadmapItem
* ORoadmap::GetByID(ItemId _nID
)
431 const HL_Vector
& rItems
= m_pImpl
->getHyperLabels();
432 for (auto const& item
: rItems
)
434 nLocID
= item
->GetID();
435 if ( nLocID
== _nID
)
441 const RoadmapItem
* ORoadmap::GetByID(ItemId _nID
) const
443 return const_cast< ORoadmap
* >( this )->GetByID( _nID
);
446 RoadmapItem
* ORoadmap::GetByIndex(ItemIndex _nItemIndex
)
448 const HL_Vector
& rItems
= m_pImpl
->getHyperLabels();
449 if ( ( _nItemIndex
> -1 ) && ( _nItemIndex
< static_cast<ItemIndex
>(rItems
.size()) ) )
451 return rItems
.at( _nItemIndex
);
456 const RoadmapItem
* ORoadmap::GetByIndex(ItemIndex _nItemIndex
) const
458 return const_cast< ORoadmap
* >( this )->GetByIndex( _nItemIndex
);
461 RoadmapTypes::ItemId
ORoadmap::GetNextAvailableItemId(ItemIndex _nNewIndex
)
463 ItemIndex searchIndex
= ++_nNewIndex
;
464 while ( searchIndex
< m_pImpl
->getItemCount() )
466 RoadmapItem
* pItem
= GetByIndex( searchIndex
);
467 if ( pItem
->IsEnabled() )
468 return pItem
->GetID( );
475 RoadmapTypes::ItemId
ORoadmap::GetPreviousAvailableItemId(ItemIndex _nNewIndex
)
477 ItemIndex searchIndex
= --_nNewIndex
;
478 while ( searchIndex
> -1 )
480 RoadmapItem
* pItem
= GetByIndex( searchIndex
);
481 if ( pItem
->IsEnabled() )
482 return pItem
->GetID( );
489 void ORoadmap::DeselectOldRoadmapItems()
491 const HL_Vector
& rItems
= m_pImpl
->getHyperLabels();
492 for (auto const& item
: rItems
)
494 item
->ToggleBackgroundColor( COL_TRANSPARENT
);
498 void ORoadmap::SetItemSelectHdl(const Link
<LinkParamNone
*,void>& _rHdl
)
500 m_pImpl
->setSelectHdl(_rHdl
);
503 Link
<LinkParamNone
*,void> const & ORoadmap::GetItemSelectHdl() const
505 return m_pImpl
->getSelectHdl();
508 void ORoadmap::Select()
510 GetItemSelectHdl().Call( nullptr );
511 CallEventListeners( VclEventId::RoadmapItemSelected
);
514 void ORoadmap::GetFocus()
516 RoadmapItem
* pCurHyperLabel
= GetByID( GetCurrentRoadmapItemID() );
517 if ( pCurHyperLabel
!= nullptr )
518 pCurHyperLabel
->GrabFocus();
521 bool ORoadmap::SelectRoadmapItemByID( ItemId _nNewID
)
523 DeselectOldRoadmapItems();
524 RoadmapItem
* pItem
= GetByID( _nNewID
);
525 if ( pItem
!= nullptr )
527 if ( pItem
->IsEnabled() )
529 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
530 pItem
->ToggleBackgroundColor( rStyleSettings
.GetHighlightColor() ); //HighlightColor
533 m_pImpl
->setCurItemID(_nNewID
);
542 void ORoadmap::Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& _rRect
)
544 if (!m_pImpl
->m_bPaintInitialized
)
545 implInit(rRenderContext
);
546 Control::Paint(rRenderContext
, _rRect
);
549 if (!!m_pImpl
->getPicture())
551 Size aBitmapSize
= m_pImpl
->getPicture().GetSizePixel();
552 Size
aMySize(GetOutputSizePixel());
554 Point
aBitmapPos(aMySize
.Width() - aBitmapSize
.Width(), aMySize
.Height() - aBitmapSize
.Height());
557 rRenderContext
.DrawBitmapEx( aBitmapPos
, m_pImpl
->getPicture() );
561 DrawHeadline(rRenderContext
);
564 void ORoadmap::DrawHeadline(vcl::RenderContext
& rRenderContext
)
566 Point aTextPos
= LogicToPixel(Point(ROADMAP_INDENT_X
, 8), MapMode(MapUnit::MapAppFont
));
568 Size
aOutputSize(GetOutputSizePixel());
571 rRenderContext
.DrawText(tools::Rectangle(aTextPos
, aOutputSize
), GetText(),
572 DrawTextFlags::Left
| DrawTextFlags::Top
| DrawTextFlags::MultiLine
| DrawTextFlags::WordBreak
);
573 rRenderContext
.DrawTextLine(aTextPos
, aOutputSize
.Width(), STRIKEOUT_NONE
, LINESTYLE_SINGLE
, LINESTYLE_NONE
);
574 const StyleSettings
& rStyleSettings
= rRenderContext
.GetSettings().GetStyleSettings();
575 rRenderContext
.SetLineColor(rStyleSettings
.GetFieldTextColor());
576 rRenderContext
.SetTextColor(rStyleSettings
.GetFieldTextColor());
579 RoadmapItem
* ORoadmap::GetByPointer(vcl::Window
const * pWindow
)
581 const HL_Vector
& rItems
= m_pImpl
->getHyperLabels();
582 for (auto const& item
: rItems
)
584 if ( item
->Contains( pWindow
) )
590 bool ORoadmap::PreNotify(NotifyEvent
& _rNEvt
)
592 // capture KeyEvents for taskpane cycling
593 if ( _rNEvt
.GetType() == MouseNotifyEvent::KEYINPUT
)
595 vcl::Window
* pWindow
= _rNEvt
.GetWindow();
596 RoadmapItem
* pItem
= GetByPointer( pWindow
);
597 if ( pItem
!= nullptr )
599 sal_Int16 nKeyCode
= _rNEvt
.GetKeyEvent()->GetKeyCode().GetCode();
603 { // Note: Performance wise this is not optimal, because we search for an ID in the labels
604 // and afterwards we search again for a label with the appropriate ID ->
605 // unnecessarily we search twice!!!
606 ItemId nPrevItemID
= GetPreviousAvailableItemId( pItem
->GetIndex() );
607 if ( nPrevItemID
!= -1 )
608 return SelectRoadmapItemByID( nPrevItemID
);
613 ItemId nNextItemID
= GetNextAvailableItemId( pItem
->GetIndex() );
614 if ( nNextItemID
!= -1 )
615 return SelectRoadmapItemByID( nNextItemID
);
619 return SelectRoadmapItemByID( pItem
->GetID() );
623 return Window::PreNotify( _rNEvt
);
626 IMPL_LINK(ORoadmap
, ImplClickHdl
, HyperLabel
*, CurHyperLabel
, void)
628 SelectRoadmapItemByID( CurHyperLabel
->GetID() );
631 void ORoadmap::DataChanged(const DataChangedEvent
& rDCEvt
)
633 if (!((( rDCEvt
.GetType() == DataChangedEventType::SETTINGS
) ||
634 ( rDCEvt
.GetType() == DataChangedEventType::DISPLAY
)) &&
635 ( rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
)))
638 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
639 SetBackground( Wallpaper( rStyleSettings
.GetFieldColor() ) );
640 Color aTextColor
= rStyleSettings
.GetFieldTextColor();
641 vcl::Font aFont
= GetFont();
642 aFont
.SetColor( aTextColor
);
644 RoadmapTypes::ItemId curItemID
= GetCurrentRoadmapItemID();
645 RoadmapItem
* pLabelItem
= GetByID( curItemID
);
646 if (pLabelItem
!= nullptr)
648 pLabelItem
->ToggleBackgroundColor(rStyleSettings
.GetHighlightColor());
653 void ORoadmap::ApplySettings(vcl::RenderContext
& rRenderContext
)
655 const StyleSettings
& rStyleSettings
= rRenderContext
.GetSettings().GetStyleSettings();
656 Color aTextColor
= rStyleSettings
.GetFieldTextColor();
657 vcl::Font aFont
= rRenderContext
.GetFont();
658 aFont
.SetColor(aTextColor
);
659 aFont
.SetWeight(WEIGHT_BOLD
);
660 aFont
.SetUnderline(LINESTYLE_SINGLE
);
661 rRenderContext
.SetFont(aFont
);
662 rRenderContext
.SetBackground(rStyleSettings
.GetFieldColor());
665 RoadmapItem::RoadmapItem(ORoadmap
& _rParent
, const Size
& _rItemPlayground
)
666 : m_aItemPlayground(_rItemPlayground
)
668 mpID
= VclPtr
<IDLabel
>::Create( &_rParent
, WB_WORDBREAK
);
670 mpDescription
= VclPtr
<HyperLabel
>::Create( &_rParent
, WB_NOTABSTOP
| WB_WORDBREAK
);
671 mpDescription
->Show();
674 RoadmapItem::~RoadmapItem()
676 mpID
.disposeAndClear();
677 mpDescription
.disposeAndClear();
680 bool RoadmapItem::Contains(const vcl::Window
* _pWindow
) const
682 return ( mpID
== _pWindow
) || ( mpDescription
== _pWindow
);
685 void RoadmapItem::GrabFocus()
688 mpDescription
->GrabFocus();
691 void RoadmapItem::SetInteractive(bool _bInteractive
)
694 mpDescription
->SetInteractive(_bInteractive
);
697 void RoadmapItem::SetID(sal_Int16 ID
)
700 mpDescription
->SetID(ID
);
703 sal_Int16
RoadmapItem::GetID() const
705 return mpDescription
? mpDescription
->GetID() : sal_Int16(-1);
708 void RoadmapItem::ImplUpdateIndex(const ItemIndex _nIndex
)
710 mpDescription
->SetIndex( _nIndex
);
712 OUString aIDText
= OUString::number( _nIndex
+ 1 ) + ".";
713 mpID
->SetText( aIDText
);
715 // update the geometry of both controls
719 void RoadmapItem::SetIndex(ItemIndex Index
)
721 ImplUpdateIndex(Index
);
724 RoadmapTypes::ItemIndex
RoadmapItem::GetIndex() const
726 return mpDescription
? mpDescription
->GetIndex() : ItemIndex(-1);
729 void RoadmapItem::SetPosition(RoadmapItem
const * _pOldItem
)
732 if ( _pOldItem
== nullptr )
734 aIDPos
= mpID
->LogicToPixel(Point(ROADMAP_INDENT_X
, ROADMAP_INDENT_Y
), MapMode(MapUnit::MapAppFont
));
738 Size aOldSize
= _pOldItem
->mpDescription
->GetSizePixel();
740 aIDPos
= _pOldItem
->mpID
->GetPosPixel();
741 aIDPos
.AdjustY(aOldSize
.Height() );
742 aIDPos
.AdjustY(mpID
->GetParent()->LogicToPixel( Size( 0, ROADMAP_ITEM_DISTANCE_Y
) ).Height() );
744 mpID
->SetPosPixel( aIDPos
);
746 sal_Int32 nDescPos
= aIDPos
.X() + mpID
->GetSizePixel().Width();
747 mpDescription
->SetPosPixel( Point( nDescPos
, aIDPos
.Y() ) );
750 void RoadmapItem::Enable(bool _bEnable
)
752 mpID
->Enable(_bEnable
);
753 mpDescription
->Enable(_bEnable
);
756 bool RoadmapItem::IsEnabled() const
758 return mpID
->IsEnabled();
761 void RoadmapItem::ToggleBackgroundColor(const Color
& _rGBColor
)
763 if (_rGBColor
== COL_TRANSPARENT
)
764 mpID
->SetControlBackground();
766 mpID
->SetControlBackground( mpID
->GetSettings().GetStyleSettings().GetHighlightColor() );
767 mpDescription
->ToggleBackgroundColor(_rGBColor
);
770 void RoadmapItem::ImplUpdatePosSize()
773 long nIDWidth
= mpID
->GetTextWidth( mpID
->GetText() );
774 long nMaxIDWidth
= mpID
->GetTextWidth( "100." );
775 nIDWidth
= ::std::min( nIDWidth
, nMaxIDWidth
);
777 // check how many space the description would need
778 Size aDescriptionSize
= mpDescription
->CalcMinimumSize( m_aItemPlayground
.Width() - nIDWidth
);
780 // position and size both controls
781 Size
aIDSize( nIDWidth
, aDescriptionSize
.Height() );
782 mpID
->SetSizePixel( aIDSize
);
784 Point aIDPos
= mpID
->GetPosPixel();
785 mpDescription
->SetPosPixel( Point( aIDPos
.X() + nIDWidth
, aIDPos
.Y() ) );
786 mpDescription
->SetSizePixel( aDescriptionSize
);
789 void RoadmapItem::Update(ItemIndex RMIndex
, const OUString
& _rText
)
791 // update description label
792 mpDescription
->SetLabel( _rText
);
794 // update the index in both controls, which triggers updating the geometry of both
795 ImplUpdateIndex( RMIndex
);
798 void RoadmapItem::SetClickHdl(const Link
<HyperLabel
*,void>& rLink
)
801 mpDescription
->SetClickHdl( rLink
);
804 IDLabel::IDLabel(vcl::Window
* _pParent
, WinBits _nWinStyle
)
805 : FixedText(_pParent
, _nWinStyle
)
809 void IDLabel::ApplySettings(vcl::RenderContext
& rRenderContext
)
811 FixedText::ApplySettings(rRenderContext
);
813 const StyleSettings
& rStyleSettings
= rRenderContext
.GetSettings().GetStyleSettings();
814 if (GetControlBackground() == COL_TRANSPARENT
)
815 rRenderContext
.SetTextColor(rStyleSettings
.GetFieldTextColor());
817 rRenderContext
.SetTextColor(rStyleSettings
.GetHighlightTextColor());
820 void IDLabel::DataChanged(const DataChangedEvent
& rDCEvt
)
822 FixedText::DataChanged( rDCEvt
);
824 if ((( rDCEvt
.GetType() == DataChangedEventType::SETTINGS
) ||
825 ( rDCEvt
.GetType() == DataChangedEventType::DISPLAY
)) &&
826 ( rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
))
828 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
829 if (GetControlBackground() != COL_TRANSPARENT
)
830 SetControlBackground(rStyleSettings
.GetHighlightColor());
837 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */