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