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