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