LibreOffice Module vcl (master) 1
roadmap.cxx
Go to the documentation of this file.
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 <vector>
21#include <algorithm>
22#include <o3tl/safeint.hxx>
23#include <vcl/event.hxx>
25#include <vcl/settings.hxx>
26#include <vcl/vclevent.hxx>
27#include <hyperlabel.hxx>
28#include <tools/color.hxx>
29#include <rtl/ustring.hxx>
30
35
36namespace vcl
37{
38
39typedef std::vector< RoadmapItem* > HL_Vector;
40
41//= ColorChanger
42
43namespace {
44
45class IDLabel : public FixedText
46{
47public:
48 IDLabel( vcl::Window* _pParent, WinBits _nWinStyle );
49 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
50 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
51};
52
53}
54
56{
57private:
61
62public:
63 RoadmapItem( ORoadmap& _rParent, const Size& _rItemPlayground );
65
66 void SetID( sal_Int16 ID );
67 sal_Int16 GetID() const;
68
69 void SetIndex( ItemIndex Index );
70 ItemIndex GetIndex() const;
71
72 void Update( ItemIndex RMIndex, const OUString& _rText );
73
74 void SetPosition( RoadmapItem const * OldHyperLabel );
75
76 void ToggleBackgroundColor( const Color& _rGBColor );
77 void SetInteractive( bool _bInteractive );
78
79 void SetClickHdl( const Link<HyperLabel*,void>& rLink );
80 void Enable( bool bEnable );
81 bool IsEnabled() const;
82 void GrabFocus();
83
84 bool Contains( const vcl::Window* _pWindow ) const;
85
86private:
87 void ImplUpdateIndex( const ItemIndex _nIndex );
88 void ImplUpdatePosSize();
89};
90
91//= RoadmapImpl
92
94{
95protected:
96 const ORoadmap& m_rAntiImpl;
102 bool m_bComplete : 1;
104public:
106
107public:
108 explicit RoadmapImpl(const ORoadmap& rAntiImpl)
109 : m_rAntiImpl(rAntiImpl)
110 , m_iCurItemID(-1)
111 , m_bInteractive(true)
112 , m_bComplete(true)
113 , m_bPaintInitialized(false)
114 , InCompleteHyperLabel(nullptr)
115 {}
116
118
120 {
121 return m_aRoadmapSteps;
122 }
123
125 {
126 m_aRoadmapSteps.insert(m_aRoadmapSteps.begin() + Index, _rRoadmapStep);
127 }
128
130 {
131 return m_aRoadmapSteps.size();
132 }
133
135 {
136 m_iCurItemID = i;
137 }
139 {
140 return m_iCurItemID;
141 }
142
143 void setInteractive(const bool _bInteractive)
144 {
145 m_bInteractive = _bInteractive;
146 }
147 bool isInteractive() const
148 {
149 return m_bInteractive;
150 }
151
152 void setComplete(const bool _bComplete)
153 {
154 m_bComplete = _bComplete;
155 }
156 bool isComplete() const
157 {
158 return m_bComplete;
159 }
160
161 void setPicture(const BitmapEx& _rPic)
162 {
163 m_aPicture = _rPic;
164 }
165 const BitmapEx& getPicture() const
166 {
167 return m_aPicture;
168 }
169
171 {
172 m_aSelectHdl = _rHdl;
173 }
175 {
176 return m_aSelectHdl;
177 }
178
179 void initItemSize();
180 const Size& getItemSize() const
181 {
182 return m_aItemSizePixel;
183 }
184
186 {
187 if ((Index > -1) && (Index < getItemCount()))
188 {
189 delete m_aRoadmapSteps[Index];
190 m_aRoadmapSteps.erase(m_aRoadmapSteps.begin() + Index);
191 }
192 }
193};
194
196{
197 Size aLabelSize( m_rAntiImpl.GetOutputSizePixel() );
198 aLabelSize.setHeight( m_rAntiImpl.LogicToPixel(Size(0, LABELBASEMAPHEIGHT), MapMode(MapUnit::MapAppFont)).Height() );
199 aLabelSize.AdjustWidth( -(m_rAntiImpl.LogicToPixel(Size(2 * ROADMAP_INDENT_X, 0), MapMode(MapUnit::MapAppFont)).Width()) );
200 m_aItemSizePixel = aLabelSize;
201}
202
203//= Roadmap
204
205ORoadmap::ORoadmap(vcl::Window* _pParent, WinBits _nWinStyle)
206 : Control(_pParent, _nWinStyle)
207 , m_pImpl(new RoadmapImpl(*this))
208{
209}
210
211void ORoadmap::implInit(vcl::RenderContext& rRenderContext)
212{
213 delete m_pImpl->InCompleteHyperLabel;
214 m_pImpl->InCompleteHyperLabel = nullptr;
215 m_pImpl->setCurItemID(-1);
216 m_pImpl->setComplete(true);
217 m_pImpl->m_bPaintInitialized = true;
218
219 // Roadmap control should be reachable as one unit with a Tab key
220 // the next Tab key should spring out of the control.
221 // To reach it the control itself should get focus and set it
222 // on entries. The entries themself should not be reachable with
223 // the Tab key directly. So each entry should have WB_NOTABSTOP.
224
225 // In other words the creator should create the control with the following
226 // flags:
227 // SetStyle( ( GetStyle() | WB_TABSTOP ) & ~WB_DIALOGCONTROL );
228
229// TODO: if somebody sets a new font from outside (OutputDevice::SetFont), we would have to react
230// on this with calculating a new bold font.
231// Unfortunately, the OutputDevice does not offer a notify mechanism for a changed font.
232// So settings the font from outside is simply a forbidden scenario at the moment
233 rRenderContext.EnableMapMode(false);
234}
235
236ORoadmap::~ORoadmap()
237{
238 disposeOnce();
239}
240
241void ORoadmap::dispose()
242{
243 HL_Vector aItemsCopy = m_pImpl->getHyperLabels();
244 m_pImpl->getHyperLabels().clear();
245 for (auto const& itemCopy : aItemsCopy)
246 {
247 delete itemCopy;
248 }
249 if ( ! m_pImpl->isComplete() )
250 delete m_pImpl->InCompleteHyperLabel;
251 m_pImpl.reset();
253}
254
255RoadmapTypes::ItemId ORoadmap::GetCurrentRoadmapItemID() const
256{
257 return m_pImpl->getCurItemID();
258}
259
260RoadmapItem* ORoadmap::GetPreviousHyperLabel(ItemIndex Index)
261{
262 RoadmapItem* pOldItem = nullptr;
263 if ( Index > 0 )
264 pOldItem = m_pImpl->getHyperLabels().at( Index - 1 );
265 return pOldItem;
266}
267
268RoadmapItem* ORoadmap::InsertHyperLabel(ItemIndex Index, const OUString& _sLabel, ItemId RMID, bool _bEnabled, bool _bIncomplete)
269{
270 if (m_pImpl->getItemCount() == 0)
271 m_pImpl->initItemSize();
272
273 RoadmapItem* pItem = nullptr;
274 RoadmapItem* pOldItem = GetPreviousHyperLabel( Index );
275
276 pItem = new RoadmapItem( *this, m_pImpl->getItemSize() );
277 if ( _bIncomplete )
278 {
279 pItem->SetInteractive( false );
280 }
281 else
282 {
283 pItem->SetInteractive( m_pImpl->isInteractive() );
284 m_pImpl->insertHyperLabel( Index, pItem );
285 }
286 pItem->SetPosition( pOldItem );
287 pItem->Update( Index, _sLabel );
288 pItem->SetClickHdl(LINK( this, ORoadmap, ImplClickHdl ) );
289 pItem->SetID( RMID );
290 pItem->SetIndex( Index );
291 if (!_bEnabled)
292 pItem->Enable( _bEnabled );
293 return pItem;
294}
295
296void ORoadmap::SetRoadmapBitmap(const BitmapEx& _rBmp)
297{
298 m_pImpl->setPicture( _rBmp );
299 Invalidate( );
300}
301
302void ORoadmap::SetRoadmapInteractive(bool _bInteractive)
303{
304 m_pImpl->setInteractive( _bInteractive );
305
306 const HL_Vector& rItems = m_pImpl->getHyperLabels();
307 for (auto const& item : rItems)
308 {
309 item->SetInteractive( _bInteractive );
310 }
311}
312
313bool ORoadmap::IsRoadmapInteractive() const
314{
315 return m_pImpl->isInteractive();
316}
317
318void ORoadmap::SetRoadmapComplete(bool _bComplete)
319{
320 bool bWasComplete = m_pImpl->isComplete();
321 m_pImpl->setComplete( _bComplete );
322 if (_bComplete)
323 {
324 if (m_pImpl->InCompleteHyperLabel != nullptr)
325 {
326 delete m_pImpl->InCompleteHyperLabel;
327 m_pImpl->InCompleteHyperLabel = nullptr;
328 }
329 }
330 else if (bWasComplete)
331 m_pImpl->InCompleteHyperLabel = InsertHyperLabel(m_pImpl->getItemCount(), "...", -1, true/*bEnabled*/, true/*bIncomplete*/ );
332}
333
334void ORoadmap::UpdatefollowingHyperLabels(ItemIndex _nIndex)
335{
336 const HL_Vector& rItems = m_pImpl->getHyperLabels();
337 if ( _nIndex < static_cast<ItemIndex>(rItems.size()) )
338 {
339 for ( HL_Vector::const_iterator i = rItems.begin() + _nIndex;
340 i != rItems.end();
341 ++i, ++_nIndex
342 )
343 {
344 RoadmapItem* pItem = *i;
345
346 pItem->SetIndex( _nIndex );
347 pItem->SetPosition( GetPreviousHyperLabel( _nIndex ) );
348 }
349
350 }
351 if ( ! m_pImpl->isComplete() )
352 {
353 RoadmapItem* pOldItem = GetPreviousHyperLabel( m_pImpl->getItemCount() );
354 m_pImpl->InCompleteHyperLabel->SetPosition( pOldItem );
355 m_pImpl->InCompleteHyperLabel->Update( m_pImpl->getItemCount(), "..." );
356 }
357}
358
359void ORoadmap::ReplaceRoadmapItem(ItemIndex Index, const OUString& roadmapItem, ItemId RMID, bool _bEnabled)
360{
361 RoadmapItem* pItem = GetByIndex( Index);
362 if ( pItem != nullptr )
363 {
364 pItem->Update( Index, roadmapItem );
365 pItem->SetID( RMID );
366 pItem->Enable( _bEnabled );
367 }
368}
369
370RoadmapTypes::ItemIndex ORoadmap::GetItemCount() const
371{
372 return m_pImpl->getItemCount();
373}
374
375RoadmapTypes::ItemId ORoadmap::GetItemID(ItemIndex _nIndex) const
376{
377 const RoadmapItem* pHyperLabel = GetByIndex( _nIndex );
378 if ( pHyperLabel )
379 return pHyperLabel->GetID();
380 return -1;
381}
382
383void ORoadmap::InsertRoadmapItem(ItemIndex Index, const OUString& RoadmapItem, ItemId _nUniqueId, bool _bEnabled)
384{
385 InsertHyperLabel( Index, RoadmapItem, _nUniqueId, _bEnabled, false/*bIncomplete*/ );
386 // TODO YPos is superfluous, if items are always appended
387 UpdatefollowingHyperLabels( Index + 1 );
388}
389
390void ORoadmap::DeleteRoadmapItem(ItemIndex Index)
391{
392 if ( m_pImpl->getItemCount() > 0 && ( Index > -1) && ( Index < m_pImpl->getItemCount() ) )
393 {
394 m_pImpl->removeHyperLabel( Index );
395 UpdatefollowingHyperLabels( Index );
396 }
397}
398
399bool ORoadmap::IsRoadmapComplete() const
400{
401 return m_pImpl->isComplete();
402}
403
404void ORoadmap::EnableRoadmapItem( ItemId _nItemId, bool _bEnable )
405{
406 RoadmapItem* pItem = GetByID( _nItemId );
407 if ( pItem != nullptr )
408 pItem->Enable( _bEnable );
409}
410
411void ORoadmap::ChangeRoadmapItemLabel( ItemId _nID, const OUString& _sLabel )
412{
413 RoadmapItem* pItem = GetByID( _nID );
414 if ( pItem == nullptr )
415 return;
416
417 pItem->Update( pItem->GetIndex(), _sLabel );
418
419 const HL_Vector& rItems = m_pImpl->getHyperLabels();
420 size_t nPos = 0;
421 for (auto const& item : rItems)
422 {
423 item->SetPosition( GetPreviousHyperLabel(nPos) );
424 ++nPos;
425 }
426}
427
428void ORoadmap::ChangeRoadmapItemID(ItemId _nID, ItemId NewID)
429{
430 RoadmapItem* pItem = GetByID( _nID );
431 if ( pItem != nullptr )
432 pItem->SetID( NewID );
433}
434
435RoadmapItem* ORoadmap::GetByID(ItemId _nID)
436{
437 ItemId nLocID = 0;
438 const HL_Vector& rItems = m_pImpl->getHyperLabels();
439 for (auto const& item : rItems)
440 {
441 nLocID = item->GetID();
442 if ( nLocID == _nID )
443 return item;
444 }
445 return nullptr;
446}
447
448const RoadmapItem* ORoadmap::GetByID(ItemId _nID) const
449{
450 return const_cast< ORoadmap* >( this )->GetByID( _nID );
451}
452
453RoadmapItem* ORoadmap::GetByIndex(ItemIndex _nItemIndex)
454{
455 const HL_Vector& rItems = m_pImpl->getHyperLabels();
456 if ( ( _nItemIndex > -1 ) && ( o3tl::make_unsigned(_nItemIndex) < rItems.size() ) )
457 {
458 return rItems.at( _nItemIndex );
459 }
460 return nullptr;
461}
462
463const RoadmapItem* ORoadmap::GetByIndex(ItemIndex _nItemIndex) const
464{
465 return const_cast< ORoadmap* >( this )->GetByIndex( _nItemIndex );
466}
467
468RoadmapTypes::ItemId ORoadmap::GetNextAvailableItemId(ItemIndex _nNewIndex)
469{
470 ItemIndex searchIndex = ++_nNewIndex;
471 while ( searchIndex < m_pImpl->getItemCount() )
472 {
473 RoadmapItem* pItem = GetByIndex( searchIndex );
474 if ( pItem->IsEnabled() )
475 return pItem->GetID( );
476
477 ++searchIndex;
478 }
479 return -1;
480}
481
482RoadmapTypes::ItemId ORoadmap::GetPreviousAvailableItemId(ItemIndex _nNewIndex)
483{
484 ItemIndex searchIndex = --_nNewIndex;
485 while ( searchIndex > -1 )
486 {
487 RoadmapItem* pItem = GetByIndex( searchIndex );
488 if ( pItem->IsEnabled() )
489 return pItem->GetID( );
490
491 searchIndex--;
492 }
493 return -1;
494}
495
496void ORoadmap::DeselectOldRoadmapItems()
497{
498 const HL_Vector& rItems = m_pImpl->getHyperLabels();
499 for (auto const& item : rItems)
500 {
501 item->ToggleBackgroundColor( COL_TRANSPARENT );
502 }
503}
504
505void ORoadmap::SetItemSelectHdl(const Link<LinkParamNone*,void>& _rHdl)
506{
507 m_pImpl->setSelectHdl(_rHdl);
508}
509
510Link<LinkParamNone*,void> const & ORoadmap::GetItemSelectHdl() const
511{
512 return m_pImpl->getSelectHdl();
513}
514
515void ORoadmap::Select()
516{
517 GetItemSelectHdl().Call( nullptr );
518 CallEventListeners( VclEventId::RoadmapItemSelected );
519}
520
521void ORoadmap::GetFocus()
522{
523 RoadmapItem* pCurHyperLabel = GetByID( GetCurrentRoadmapItemID() );
524 if ( pCurHyperLabel != nullptr )
525 pCurHyperLabel->GrabFocus();
526}
527
528bool ORoadmap::SelectRoadmapItemByID(ItemId _nNewID, bool bGrabFocus)
529{
530 DeselectOldRoadmapItems();
531 RoadmapItem* pItem = GetByID( _nNewID );
532 if ( pItem != nullptr )
533 {
534 if ( pItem->IsEnabled() )
535 {
536 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
537 pItem->ToggleBackgroundColor( rStyleSettings.GetHighlightColor() ); //HighlightColor
538
539 if (bGrabFocus)
540 pItem->GrabFocus();
541 m_pImpl->setCurItemID(_nNewID);
542
543 Select();
544 return true;
545 }
546 }
547 return false;
548}
549
550void ORoadmap::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& _rRect)
551{
552 if (!m_pImpl->m_bPaintInitialized)
553 implInit(rRenderContext);
554 Control::Paint(rRenderContext, _rRect);
555
556 // draw the bitmap
557 if (!m_pImpl->getPicture().IsEmpty())
558 {
559 Size aBitmapSize = m_pImpl->getPicture().GetSizePixel();
560 Size aMySize(GetOutputSizePixel());
561
562 Point aBitmapPos(aMySize.Width() - aBitmapSize.Width(), aMySize.Height() - aBitmapSize.Height());
563
564 // draw it
565 rRenderContext.DrawBitmapEx( aBitmapPos, m_pImpl->getPicture() );
566 }
567
568 // draw the headline
569 DrawHeadline(rRenderContext);
570}
571
572void ORoadmap::DrawHeadline(vcl::RenderContext& rRenderContext)
573{
574 Point aTextPos = OutputDevice::LogicToLogic(Point(ROADMAP_INDENT_X, 8), GetMapMode(), MapMode(MapUnit::MapAppFont));
575
576 Size aOutputSize(rRenderContext.GetOutputSize());
577
578 // draw it
579 rRenderContext.DrawText(tools::Rectangle(aTextPos, aOutputSize), GetText(),
581 rRenderContext.DrawTextLine(aTextPos, aOutputSize.Width(), STRIKEOUT_NONE, LINESTYLE_SINGLE, LINESTYLE_NONE);
582 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
583 rRenderContext.SetLineColor(rStyleSettings.GetFieldTextColor());
584 rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor());
585}
586
587RoadmapItem* ORoadmap::GetByPointer(vcl::Window const * pWindow)
588{
589 const HL_Vector& rItems = m_pImpl->getHyperLabels();
590 for (auto const& item : rItems)
591 {
592 if ( item->Contains( pWindow ) )
593 return item;
594 }
595 return nullptr;
596}
597
598bool ORoadmap::PreNotify(NotifyEvent& _rNEvt)
599{
600 // capture KeyEvents for taskpane cycling
601 if ( _rNEvt.GetType() == NotifyEventType::KEYINPUT )
602 {
603 vcl::Window* pWindow = _rNEvt.GetWindow();
604 RoadmapItem* pItem = GetByPointer( pWindow );
605 if ( pItem != nullptr )
606 {
607 sal_Int16 nKeyCode = _rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
608 switch( nKeyCode )
609 {
610 case KEY_UP:
611 { // Note: Performance wise this is not optimal, because we search for an ID in the labels
612 // and afterwards we search again for a label with the appropriate ID ->
613 // unnecessarily we search twice!!!
614 ItemId nPrevItemID = GetPreviousAvailableItemId( pItem->GetIndex() );
615 if ( nPrevItemID != -1 )
616 return SelectRoadmapItemByID( nPrevItemID );
617 }
618 break;
619 case KEY_DOWN:
620 {
621 ItemId nNextItemID = GetNextAvailableItemId( pItem->GetIndex() );
622 if ( nNextItemID != -1 )
623 return SelectRoadmapItemByID( nNextItemID );
624 }
625 break;
626 case KEY_SPACE:
627 return SelectRoadmapItemByID( pItem->GetID() );
628 }
629 }
630 }
631 return Window::PreNotify( _rNEvt );
632}
633
634IMPL_LINK(ORoadmap, ImplClickHdl, HyperLabel*, CurHyperLabel, void)
635{
636 SelectRoadmapItemByID( CurHyperLabel->GetID() );
637}
638
639void ORoadmap::DataChanged(const DataChangedEvent& rDCEvt)
640{
641 if (!((( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) ||
642 ( rDCEvt.GetType() == DataChangedEventType::DISPLAY )) &&
643 ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE )))
644 return;
645
646 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
647 SetBackground( Wallpaper( rStyleSettings.GetFieldColor() ) );
648 Color aTextColor = rStyleSettings.GetFieldTextColor();
649 vcl::Font aFont = GetFont();
650 aFont.SetColor( aTextColor );
651 SetFont( aFont );
652 RoadmapTypes::ItemId curItemID = GetCurrentRoadmapItemID();
653 RoadmapItem* pLabelItem = GetByID( curItemID );
654 if (pLabelItem != nullptr)
655 {
656 pLabelItem->ToggleBackgroundColor(rStyleSettings.GetHighlightColor());
657 }
658 Invalidate();
659}
660
661void ORoadmap::ApplySettings(vcl::RenderContext& rRenderContext)
662{
663 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
664 Color aTextColor = rStyleSettings.GetFieldTextColor();
665 vcl::Font aFont = rRenderContext.GetFont();
666 aFont.SetColor(aTextColor);
667 aFont.SetWeight(WEIGHT_BOLD);
668 aFont.SetUnderline(LINESTYLE_SINGLE);
669 rRenderContext.SetFont(aFont);
670 rRenderContext.SetBackground(rStyleSettings.GetFieldColor());
671}
672
673RoadmapItem::RoadmapItem(ORoadmap& _rParent, const Size& _rItemPlayground)
674 : m_aItemPlayground(_rItemPlayground)
675{
677 mpID->Show();
679 mpDescription->Show();
680}
681
683{
685 mpDescription.disposeAndClear();
686}
687
688bool RoadmapItem::Contains(const vcl::Window* _pWindow) const
689{
690 return ( mpID == _pWindow ) || ( mpDescription == _pWindow );
691}
692
694{
695 if ( mpDescription )
696 mpDescription->GrabFocus();
697}
698
699void RoadmapItem::SetInteractive(bool _bInteractive)
700{
701 if ( mpDescription )
702 mpDescription->SetInteractive(_bInteractive);
703}
704
705void RoadmapItem::SetID(sal_Int16 ID)
706{
707 if ( mpDescription )
708 mpDescription->SetID(ID);
709}
710
711sal_Int16 RoadmapItem::GetID() const
712{
713 return mpDescription ? mpDescription->GetID() : sal_Int16(-1);
714}
715
717{
718 mpDescription->SetIndex( _nIndex );
719
720 OUString aIDText = OUString::number( _nIndex + 1 ) + ".";
721 mpID->SetText( aIDText );
722
723 // update the geometry of both controls
725}
726
728{
730}
731
733{
734 return mpDescription ? mpDescription->GetIndex() : ItemIndex(-1);
735}
736
738{
739 Point aIDPos;
740 if ( _pOldItem == nullptr )
741 {
742 aIDPos = mpID->LogicToPixel(Point(ROADMAP_INDENT_X, ROADMAP_INDENT_Y), MapMode(MapUnit::MapAppFont));
743 }
744 else
745 {
746 Size aOldSize = _pOldItem->mpDescription->GetSizePixel();
747
748 aIDPos = _pOldItem->mpID->GetPosPixel();
749 aIDPos.AdjustY(aOldSize.Height() );
750 aIDPos.AdjustY(mpID->GetParent()->LogicToPixel( Size( 0, ROADMAP_ITEM_DISTANCE_Y ) ).Height() );
751 }
752 mpID->SetPosPixel( aIDPos );
753
754 sal_Int32 nDescPos = aIDPos.X() + mpID->GetSizePixel().Width();
755 mpDescription->SetPosPixel( Point( nDescPos, aIDPos.Y() ) );
756}
757
758void RoadmapItem::Enable(bool _bEnable)
759{
760 mpID->Enable(_bEnable);
761 mpDescription->Enable(_bEnable);
762}
763
765{
766 return mpID->IsEnabled();
767}
768
770{
771 if (_rGBColor == COL_TRANSPARENT)
772 mpID->SetControlBackground();
773 else
774 mpID->SetControlBackground( mpID->GetSettings().GetStyleSettings().GetHighlightColor() );
775 mpDescription->ToggleBackgroundColor(_rGBColor);
776}
777
779{
780 // calculate widths
781 tools::Long nIDWidth = mpID->GetTextWidth( mpID->GetText() );
782 tools::Long nMaxIDWidth = mpID->GetTextWidth( "100." );
783 nIDWidth = ::std::min( nIDWidth, nMaxIDWidth );
784
785 // check how many space the description would need
786 Size aDescriptionSize = mpDescription->CalcMinimumSize( m_aItemPlayground.Width() - nIDWidth );
787
788 // position and size both controls
789 Size aIDSize( nIDWidth, aDescriptionSize.Height() );
790 mpID->SetSizePixel( aIDSize );
791
792 Point aIDPos = mpID->GetPosPixel();
793 mpDescription->SetPosPixel( Point( aIDPos.X() + nIDWidth, aIDPos.Y() ) );
794 mpDescription->SetSizePixel( aDescriptionSize );
795}
796
797void RoadmapItem::Update(ItemIndex RMIndex, const OUString& _rText)
798{
799 // update description label
800 mpDescription->SetLabel( _rText );
801
802 // update the index in both controls, which triggers updating the geometry of both
803 ImplUpdateIndex( RMIndex );
804}
805
807{
808 if ( mpDescription )
809 mpDescription->SetClickHdl( rLink);
810}
811
812IDLabel::IDLabel(vcl::Window* _pParent, WinBits _nWinStyle)
813 : FixedText(_pParent, _nWinStyle)
814{
815}
816
817void IDLabel::ApplySettings(vcl::RenderContext& rRenderContext)
818{
819 FixedText::ApplySettings(rRenderContext);
820
821 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
822 if (GetControlBackground() == COL_TRANSPARENT)
823 rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor());
824 else
825 rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor());
826}
827
828void IDLabel::DataChanged(const DataChangedEvent& rDCEvt)
829{
830 FixedText::DataChanged( rDCEvt );
831
832 if ((( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) ||
833 ( rDCEvt.GetType() == DataChangedEventType::DISPLAY )) &&
834 ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ))
835 {
836 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
837 if (GetControlBackground() != COL_TRANSPARENT)
838 SetControlBackground(rStyleSettings.GetHighlightColor());
839 Invalidate();
840 }
841}
842
843} // namespace vcl
844
845/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOIndex Index
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
const StyleSettings & GetStyleSettings() const
Definition: ctrl.hxx:80
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: ctrl.cxx:61
DataChangedEventType GetType() const
Definition: event.hxx:362
AllSettingsFlags GetFlags() const
Definition: event.hxx:363
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: fixed.cxx:166
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: fixed.cxx:284
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:57
const KeyEvent * GetKeyEvent() const
Definition: event.hxx:316
vcl::Window * GetWindow() const
Definition: event.hxx:309
NotifyEventType GetType() const
Definition: event.hxx:308
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
Size GetOutputSize() const
Definition: outdev.hxx:327
void EnableMapMode(bool bEnable=true)
Definition: map.cxx:589
const vcl::Font & GetFont() const
Definition: outdev.hxx:529
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
Definition: bitmapex.cxx:33
void SetFont(const vcl::Font &rNewFont)
Definition: outdev/font.cxx:56
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
Definition: map.cxx:1580
void SetLineColor()
Definition: line.cxx:37
void SetTextColor(const Color &rColor)
Definition: text.cxx:716
void DrawTextLine(const Point &rPos, tools::Long nWidth, FontStrikeout eStrikeout, FontLineStyle eUnderline, FontLineStyle eOverline, bool bUnderlineAbove=false)
Definition: textline.cxx:944
void SetBackground()
Definition: background.cxx:27
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
Definition: text.cxx:797
const AllSettings & GetSettings() const
Definition: outdev.hxx:288
constexpr tools::Long Y() const
tools::Long AdjustY(tools::Long nVertMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
const Color & GetFieldTextColor() const
const Color & GetFieldColor() const
const Color & GetHighlightColor() const
const Color & GetHighlightTextColor() const
void disposeAndClear()
Definition: vclptr.hxx:200
static VclPtr< reference_type > Create(Arg &&... arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
void SetColor(const Color &)
Definition: font/font.cxx:107
void SetWeight(FontWeight)
Definition: font/font.cxx:236
void SetUnderline(FontLineStyle)
Definition: font/font.cxx:266
sal_uInt16 GetCode() const
Definition: keycod.hxx:49
const Link< LinkParamNone *, void > & getSelectHdl() const
Definition: roadmap.cxx:174
const Size & getItemSize() const
Definition: roadmap.cxx:180
Size m_aItemSizePixel
Definition: roadmap.cxx:103
void setComplete(const bool _bComplete)
Definition: roadmap.cxx:152
Link< LinkParamNone *, void > m_aSelectHdl
Definition: roadmap.cxx:97
bool isInteractive() const
Definition: roadmap.cxx:147
BitmapEx m_aPicture
Definition: roadmap.cxx:98
void setCurItemID(ItemId i)
Definition: roadmap.cxx:134
const BitmapEx & getPicture() const
Definition: roadmap.cxx:165
void insertHyperLabel(ItemIndex Index, RoadmapItem *_rRoadmapStep)
Definition: roadmap.cxx:124
void setInteractive(const bool _bInteractive)
Definition: roadmap.cxx:143
RoadmapItem * InCompleteHyperLabel
Definition: roadmap.cxx:117
ItemIndex getItemCount() const
Definition: roadmap.cxx:129
RoadmapImpl(const ORoadmap &rAntiImpl)
Definition: roadmap.cxx:108
void initItemSize()
Definition: roadmap.cxx:195
bool isComplete() const
Definition: roadmap.cxx:156
void setSelectHdl(const Link< LinkParamNone *, void > &_rHdl)
Definition: roadmap.cxx:170
void setPicture(const BitmapEx &_rPic)
Definition: roadmap.cxx:161
const ORoadmap & m_rAntiImpl
Definition: roadmap.cxx:96
ItemId getCurItemID() const
Definition: roadmap.cxx:138
HL_Vector & getHyperLabels()
Definition: roadmap.cxx:119
ItemId m_iCurItemID
Definition: roadmap.cxx:100
bool m_bPaintInitialized
Definition: roadmap.cxx:105
HL_Vector m_aRoadmapSteps
Definition: roadmap.cxx:99
void removeHyperLabel(ItemIndex Index)
Definition: roadmap.cxx:185
void Update(ItemIndex RMIndex, const OUString &_rText)
Definition: roadmap.cxx:797
RoadmapItem(ORoadmap &_rParent, const Size &_rItemPlayground)
Definition: roadmap.cxx:673
void ToggleBackgroundColor(const Color &_rGBColor)
Definition: roadmap.cxx:769
void SetPosition(RoadmapItem const *OldHyperLabel)
Definition: roadmap.cxx:737
void SetClickHdl(const Link< HyperLabel *, void > &rLink)
Definition: roadmap.cxx:806
bool IsEnabled() const
Definition: roadmap.cxx:764
ItemIndex GetIndex() const
Definition: roadmap.cxx:732
VclPtr< HyperLabel > mpDescription
Definition: roadmap.cxx:59
void GrabFocus()
Definition: roadmap.cxx:693
void SetInteractive(bool _bInteractive)
Definition: roadmap.cxx:699
void ImplUpdateIndex(const ItemIndex _nIndex)
Definition: roadmap.cxx:716
sal_Int16 GetID() const
Definition: roadmap.cxx:711
void ImplUpdatePosSize()
Definition: roadmap.cxx:778
VclPtr< IDLabel > mpID
Definition: roadmap.cxx:58
bool Contains(const vcl::Window *_pWindow) const
Definition: roadmap.cxx:688
void SetID(sal_Int16 ID)
Definition: roadmap.cxx:705
void SetIndex(ItemIndex Index)
Definition: roadmap.cxx:727
const Size m_aItemPlayground
Definition: roadmap.cxx:60
void Enable(bool bEnable)
Definition: roadmap.cxx:758
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: paint.cxx:1020
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:52
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr sal_uInt16 KEY_UP
Definition: keycodes.hxx:111
constexpr sal_uInt16 KEY_DOWN
Definition: keycodes.hxx:110
constexpr sal_uInt16 KEY_SPACE
Definition: keycodes.hxx:123
sal_uInt16 nPos
int i
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
long Long
vcl::Font GetFont(vcl::Font const &rFont, DrawModeFlags nDrawMode, StyleSettings const &rStyleSettings)
Definition: drawmode.cxx:171
IMPL_LINK(ORoadmap, ImplClickHdl, HyperLabel *, CurHyperLabel, void)
Definition: roadmap.cxx:634
std::vector< RoadmapItem * > HL_Vector
Definition: roadmap.cxx:39
constexpr tools::Long ROADMAP_ITEM_DISTANCE_Y
Definition: roadmap.cxx:34
constexpr tools::Long ROADMAP_INDENT_X
Definition: roadmap.cxx:32
constexpr tools::Long LABELBASEMAPHEIGHT
Definition: roadmap.cxx:31
constexpr tools::Long ROADMAP_INDENT_Y
Definition: roadmap.cxx:33
sal_Int32 ItemIndex
Definition: roadmap.hxx:41
sal_Int16 ItemId
Definition: roadmap.hxx:40
@ RoadmapItemSelected
sal_Int64 WinBits
Definition: wintypes.hxx:109
WinBits const WB_NOTABSTOP
Definition: wintypes.hxx:141
WinBits const WB_WORDBREAK
Definition: wintypes.hxx:156