1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: roadmap.cxx,v $
10 * $Revision: 1.16.56.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
33 #include <roadmap.hxx>
39 #ifndef __SGI_STL_VECTOR
44 #include <vcl/bitmap.hxx>
45 #include <tools/color.hxx>
47 #ifndef _RTL_USTRING_HXX_
48 #include <rtl/OUString.hxx>
52 #define RMENTRYPOINT_X 4
53 #define RMENTRYPOINT_Y 27
54 #define RMITEMDISTANCE_Y 6
55 #define RMINCOMPLETE -1
56 #define NREMOVERMITEM -1
58 #define INCOMPLETELABEL ::String::CreateFromAscii("...") // TODO: Cast to String
60 //.........................................................................
63 //.........................................................................
65 typedef std::vector
< ::rtl::OUString
> S_Vector
;
66 typedef std::vector
< ORoadmapHyperLabel
* > HL_Vector
;
68 //=====================================================================
70 //=====================================================================
74 // OutputDevice* m_pDev;
77 // FontChanger( OutputDevice* _pDev, const Font& _rNewFont )
80 // m_pDev->Push( PUSH_FONT );
81 // m_pDev->SetFont( _rNewFont );
91 //=====================================================================
93 //=====================================================================
100 ColorChanger( OutputDevice
* _pDev
, const Color
& _rNewLineColor
, const Color
& _rNewFillColor
)
103 m_pDev
->Push( PUSH_LINECOLOR
| PUSH_FILLCOLOR
);
104 m_pDev
->SetLineColor( _rNewLineColor
);
105 m_pDev
->SetFillColor( _rNewFillColor
);
115 //=====================================================================
117 //=====================================================================
118 class RoadmapImpl
: public RoadmapTypes
123 HL_Vector m_aRoadmapSteps
;
125 sal_Bool m_bInteractive
;
126 sal_Bool m_bComplete
;
130 m_bInteractive( sal_True
),
131 m_bComplete( sal_True
) {}
133 Size aHyperLabelPixelSize
;
134 ORoadmapHyperLabel
* InCompleteHyperLabel
;
136 void addHyperLabel( ORoadmapHyperLabel
* _rRoadmapStep
) { m_aRoadmapSteps
.push_back(_rRoadmapStep
); }
138 HL_Vector
& getHyperLabels() { return m_aRoadmapSteps
; }
139 const HL_Vector
& getHyperLabels() const { return m_aRoadmapSteps
; }
141 void insertHyperLabel( ItemIndex _Index
, ORoadmapHyperLabel
* _rRoadmapStep
) { m_aRoadmapSteps
.insert( m_aRoadmapSteps
.begin() + _Index
, _rRoadmapStep
); }
143 ItemIndex
getItemCount() const { return m_aRoadmapSteps
.size();}
145 void setCurItemID( ItemId i
) {m_iCurItemID
= i
; }
146 ItemId
getCurItemID() const { return m_iCurItemID
; }
148 void setInteractive(const sal_Bool _bInteractive
) {m_bInteractive
= _bInteractive
; }
149 sal_Bool
isInteractive() const { return m_bInteractive
; };
151 void setComplete(const sal_Bool _bComplete
) {m_bComplete
= _bComplete
; }
152 sal_Bool
isComplete() const { return m_bComplete
; };
154 void setPicture( const BitmapEx
& _rPic
) { m_aPicture
= _rPic
; }
155 const BitmapEx
& getPicture( ) const { return m_aPicture
; }
157 void setSelectHdl( const Link
& _rHdl
) { m_aSelectHdl
= _rHdl
; }
158 const Link
& getSelectHdl( ) const { return m_aSelectHdl
; }
160 void removeHyperLabel( ItemIndex _Index
)
162 if ( ( _Index
> -1 ) && ( _Index
< getItemCount() ) )
164 delete m_aRoadmapSteps
[_Index
];
165 m_aRoadmapSteps
.erase( m_aRoadmapSteps
.begin() + _Index
);
171 //=====================================================================
173 //=====================================================================
174 //---------------------------------------------------------------------
175 ORoadmap::ORoadmap( Window
* _pParent
, const ResId
& _rId
):Control( _pParent
, _rId
)
176 ,m_pImpl( new RoadmapImpl() )
181 //---------------------------------------------------------------------
182 ORoadmap::ORoadmap( Window
* _pParent
, WinBits _nWinStyle
)
183 :Control( _pParent
, _nWinStyle
)
184 , m_pImpl( new RoadmapImpl() )
190 //---------------------------------------------------------------------
191 void ORoadmap::implInit()
193 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
194 Color aTextColor
= rStyleSettings
.GetFieldTextColor();
195 Font aFont
= GetFont( );
196 aFont
.SetColor( aTextColor
);
197 aFont
.SetWeight( WEIGHT_BOLD
);
198 aFont
.SetUnderline( UNDERLINE_SINGLE
);
200 SetBackground( Wallpaper( rStyleSettings
.GetFieldColor() ) );
201 m_pImpl
->InCompleteHyperLabel
= NULL
;
202 m_pImpl
->setCurItemID(-1 );
203 m_pImpl
->setComplete( sal_True
);
205 // Roadmap control should be reachable as one unit with a Tab key
206 // the next Tab key should spring out of the control.
207 // To reach it the control itself should get focus and set it
208 // on entries. The entries themself should not be reachable with
209 // the Tab key directly. So each entry should have WB_NOTABSTOP.
211 // In other words the creator should create the control with the following
213 // SetStyle( ( GetStyle() | WB_TABSTOP ) & ~WB_DIALOGCONTROL );
215 // TODO: if somebody sets a new font from outside (OutputDevice::SetFont), we would have to react
216 // on this with calculating a new bold font.
217 // Unfortunately, the OutputDevice does not offer a notify mechanism for a changed font.
218 // So settings the font from outside is simply a forbidded scenario at the moment
221 //---------------------------------------------------------------------
222 ORoadmap::~ORoadmap( )
224 HL_Vector pLocRoadmapItems
= m_pImpl
->getHyperLabels();
225 m_pImpl
->getHyperLabels().clear();
226 for ( HL_Vector::iterator i
= pLocRoadmapItems
.begin(); i
< pLocRoadmapItems
.end(); i
++)
230 if ( ! m_pImpl
->isComplete() )
231 delete m_pImpl
->InCompleteHyperLabel
;
237 RoadmapTypes::ItemId
ORoadmap::GetCurrentRoadmapItemID() const
239 return m_pImpl
->getCurItemID();
243 void ORoadmap::InitializeHyperLabelSize()
245 Size aSize
= GetSizePixel();
246 Size aLogicSize
= PixelToLogic( aSize
, MAP_APPFONT
);
247 aLogicSize
.Height() = LABELBASEMAPHEIGHT
;
248 aLogicSize
.Width() -= (2*RMENTRYPOINT_X
);
249 m_pImpl
->aHyperLabelPixelSize
= LogicToPixel( aLogicSize
, MAP_APPFONT
);
250 EnableMapMode( sal_False
);
254 ORoadmapHyperLabel
* ORoadmap::GetPreviousHyperLabel( ItemIndex _Index
)
256 ORoadmapHyperLabel
* OldHyperLabel
= NULL
;
258 OldHyperLabel
= m_pImpl
->getHyperLabels().at( _Index
- 1 );
259 return OldHyperLabel
;
263 //---------------------------------------------------------------------
265 ORoadmapHyperLabel
* ORoadmap::InsertHyperLabel( ItemIndex _Index
, ::rtl::OUString _sLabel
, ItemId _RMID
, sal_Bool _bEnabled
)
267 if (m_pImpl
->getItemCount() == 0 )
268 InitializeHyperLabelSize();
269 ORoadmapHyperLabel
* CurHyperLabel
;
270 ORoadmapHyperLabel
* OldHyperLabel
= GetPreviousHyperLabel( _Index
);
272 if (_RMID
!= RMINCOMPLETE
)
274 CurHyperLabel
= new ORoadmapHyperLabel(this, WB_WORDBREAK
);
275 CurHyperLabel
->SetInteractive( m_pImpl
->isInteractive() );
276 m_pImpl
->insertHyperLabel(_Index
, CurHyperLabel
);
280 CurHyperLabel
= new ORoadmapHyperLabel(this);
281 CurHyperLabel
->SetInteractive( sal_False
);
283 CurHyperLabel
->SetPosition( OldHyperLabel
);
284 CurHyperLabel
->SetLabelAndSize( _Index
, _sLabel
, m_pImpl
->aHyperLabelPixelSize
);
285 CurHyperLabel
->SetClickHdl(LINK( this, ORoadmap
, ImplClickHdl
) );
286 CurHyperLabel
->SetID( _RMID
);
287 CurHyperLabel
->SetIndex( _Index
);
289 CurHyperLabel
->Enable( _bEnabled
);
290 return CurHyperLabel
;
293 //---------------------------------------------------------------------
294 void ORoadmap::SetRoadmapBitmap( const BitmapEx
& _rBmp
, sal_Bool _bInvalidate
)
296 m_pImpl
->setPicture( _rBmp
);
301 //---------------------------------------------------------------------
302 const BitmapEx
& ORoadmap::GetRoadmapBitmap( ) const
304 return m_pImpl
->getPicture( );
307 //---------------------------------------------------------------------
308 void ORoadmap::SetRoadmapInteractive( sal_Bool _bInteractive
)
310 m_pImpl
->setInteractive( _bInteractive
);
311 ORoadmapHyperLabel
* CurHyperLabel
;
312 HL_Vector pLocRoadmapItems
= m_pImpl
->getHyperLabels();
313 for ( HL_Vector::iterator i
= pLocRoadmapItems
.begin(); i
< pLocRoadmapItems
.end(); i
++)
316 CurHyperLabel
->SetInteractive( _bInteractive
);
320 //---------------------------------------------------------------------
321 sal_Bool
ORoadmap::IsRoadmapInteractive()
323 return m_pImpl
->isInteractive();
326 //---------------------------------------------------------------------
327 void ORoadmap::SetRoadmapComplete( sal_Bool _bComplete
)
329 sal_Bool OldbComplete
= m_pImpl
->isComplete();
330 m_pImpl
->setComplete( _bComplete
);
333 if ( m_pImpl
->InCompleteHyperLabel
!= NULL
)
335 if (m_pImpl
->getItemCount() > 0)
337 HL_Vector pLocRoadmapItems
= m_pImpl
->getHyperLabels();
338 pLocRoadmapItems
.pop_back();
339 delete m_pImpl
->InCompleteHyperLabel
;
341 m_pImpl
->InCompleteHyperLabel
= NULL
;
344 else if (OldbComplete
)
345 m_pImpl
->InCompleteHyperLabel
= InsertHyperLabel( m_pImpl
->getItemCount(), ::String::CreateFromAscii("..."), RMINCOMPLETE
);
348 //---------------------------------------------------------------------
349 void ORoadmap::SetRoadmapLabel(ORoadmapHyperLabel
* CurHyperLabel
, sal_Int32 _nPrefix
, String _sDescription
)
351 const xub_StrLen n_Pos
= _sDescription
.Search( String::CreateFromAscii(".") );
352 if ( n_Pos
!= STRING_NOTFOUND
)
354 const String sID
= ::String::CreateFromInt32( _nPrefix
);
355 _sDescription
.Replace(0 , n_Pos
, sID
);
357 CurHyperLabel
->SetLabelAndSize( _nPrefix
, _sDescription
, m_pImpl
->aHyperLabelPixelSize
);
360 //---------------------------------------------------------------------
361 void ORoadmap::UpdatefollowingHyperLabels( ItemIndex _Index
, sal_Int16
)
363 if ( _Index
< ( m_pImpl
->getItemCount() ) )
367 HL_Vector pLocRoadmapItems
= m_pImpl
->getHyperLabels();
368 ORoadmapHyperLabel
* CurHyperLabel
= NULL
;
369 ItemIndex n_CurPrefix
= _Index
+ 1 ;
370 for ( HL_Vector::iterator i
= pLocRoadmapItems
.begin()+ _Index
; i
< pLocRoadmapItems
.end(); i
++)
373 aPos
= CurHyperLabel
->GetLogicalPosition();
374 CurHyperLabel
->SetIndex( n_CurPrefix
- 1);
375 sLabel
= CurHyperLabel
->GetLabel();
376 SetRoadmapLabel(CurHyperLabel
, n_CurPrefix
, sLabel
);
377 ORoadmapHyperLabel
* OldHyperLabel
= GetPreviousHyperLabel( n_CurPrefix
-1);
378 CurHyperLabel
->SetPosition( OldHyperLabel
);
382 if ( ! m_pImpl
->isComplete() )
384 ORoadmapHyperLabel
* OldHyperLabel
= GetPreviousHyperLabel( m_pImpl
->getItemCount());
385 m_pImpl
->InCompleteHyperLabel
->SetPosition( OldHyperLabel
);
386 m_pImpl
->InCompleteHyperLabel
->SetLabelAndSize( m_pImpl
->getItemCount(), ::String::CreateFromAscii("..."), m_pImpl
->aHyperLabelPixelSize
);
390 //---------------------------------------------------------------------
391 void ORoadmap::ReplaceRoadmapItem( ItemIndex _Index
, ::rtl::OUString _RoadmapItem
, ItemId _RMID
, sal_Bool _bEnabled
)
393 ORoadmapHyperLabel
* CurHyperLabel
= GetByIndex( _Index
);
394 if ( CurHyperLabel
!= NULL
)
396 CurHyperLabel
->SetLabelAndSize( _Index
, _RoadmapItem
, m_pImpl
->aHyperLabelPixelSize
);
397 CurHyperLabel
->SetID( _RMID
);
398 CurHyperLabel
->Enable( _bEnabled
);
402 //---------------------------------------------------------------------
403 RoadmapTypes::ItemIndex
ORoadmap::GetItemCount() const
405 return m_pImpl
->getItemCount();
408 //---------------------------------------------------------------------
409 RoadmapTypes::ItemId
ORoadmap::GetItemID( ItemIndex _nIndex
) const
411 const ORoadmapHyperLabel
* pHyperLabel
= GetByIndex( _nIndex
);
413 return pHyperLabel
->GetID();
417 //---------------------------------------------------------------------
418 RoadmapTypes::ItemIndex
ORoadmap::GetItemIndex( ItemId _nID
) const
420 ORoadmapHyperLabel
* CurHyperLabel
;
422 HL_Vector
&LocHyperLabels
= m_pImpl
->getHyperLabels();
423 ItemIndex nResult
= 0;
424 for ( HL_Vector::iterator i
= LocHyperLabels
.begin(); i
< LocHyperLabels
.end(); i
++)
427 nLocID
= CurHyperLabel
->GetID();
428 if ( nLocID
== _nID
)
435 //---------------------------------------------------------------------
436 void ORoadmap::InsertRoadmapItem( ItemIndex _Index
, ::rtl::OUString _RoadmapItem
, ItemId _nUniqueId
, sal_Bool _bEnabled
)
438 ORoadmapHyperLabel
* CurHyperLabel
;
439 CurHyperLabel
= InsertHyperLabel(_Index
, _RoadmapItem
, _nUniqueId
, _bEnabled
);
440 // Todo: YPos is superfluous, if items are always appended
441 UpdatefollowingHyperLabels( _Index
+ 1);
444 //---------------------------------------------------------------------
445 void ORoadmap::DeleteRoadmapItem( ItemIndex _Index
)
447 if ( m_pImpl
->getItemCount() > 0 && ( _Index
> -1) && ( _Index
< m_pImpl
->getItemCount() ) )
449 m_pImpl
->removeHyperLabel( _Index
);
450 UpdatefollowingHyperLabels( _Index
, NREMOVERMITEM
);
454 //---------------------------------------------------------------------
455 sal_Bool
ORoadmap::IsRoadmapComplete( ) const
457 return m_pImpl
->isComplete();
460 //---------------------------------------------------------------------
461 sal_Bool
ORoadmap::IsRoadmapItemEnabled( ItemId _nItemId
, ItemIndex _nStartIndex
) const
463 const ORoadmapHyperLabel
* _pLabelItem
= GetByID( _nItemId
, _nStartIndex
);
464 return _pLabelItem
? _pLabelItem
->IsEnabled() : sal_False
;
467 //---------------------------------------------------------------------
468 void ORoadmap::EnableRoadmapItem( ItemId _nItemId
, sal_Bool _bEnable
, ItemIndex _nStartIndex
)
470 ORoadmapHyperLabel
* CurHyperLabel
= GetByID( _nItemId
, _nStartIndex
);
471 if ( CurHyperLabel
!= NULL
)
472 CurHyperLabel
->Enable( _bEnable
);
475 //---------------------------------------------------------------------
476 void ORoadmap::ChangeRoadmapItemLabel( ItemId _nID
, ::rtl::OUString _sLabel
, ItemIndex _nStartIndex
)
478 ORoadmapHyperLabel
* CurHyperLabel
= GetByID( _nID
, _nStartIndex
);
479 if ( CurHyperLabel
!= NULL
)
481 CurHyperLabel
->SetLabelAndSize( CurHyperLabel
->GetIndex(), _sLabel
, m_pImpl
->aHyperLabelPixelSize
);
482 HL_Vector pLocRoadmapItems
= m_pImpl
->getHyperLabels();
483 ItemIndex Index
= _nStartIndex
;
484 for ( HL_Vector::iterator i
= pLocRoadmapItems
.begin()+ Index
; i
< pLocRoadmapItems
.end(); i
++)
487 ORoadmapHyperLabel
* OldHyperLabel
= GetPreviousHyperLabel( Index
);
488 CurHyperLabel
->SetPosition( OldHyperLabel
);
494 //---------------------------------------------------------------------
496 ::rtl::OUString
ORoadmap::GetRoadmapItemLabel( ItemId _nID
, ItemIndex _nStartIndex
)
498 ORoadmapHyperLabel
* CurHyperLabel
= GetByID( _nID
, _nStartIndex
);
499 if ( CurHyperLabel
!= NULL
)
500 return CurHyperLabel
->GetLabel();
502 return ::rtl::OUString();
505 //---------------------------------------------------------------------
506 void ORoadmap::ChangeRoadmapItemID( ItemId _nID
, ItemId _NewID
, ItemIndex _nStartIndex
)
508 ORoadmapHyperLabel
* CurHyperLabel
= GetByID( _nID
, _nStartIndex
);
509 if ( CurHyperLabel
!= NULL
)
510 CurHyperLabel
->SetID( _NewID
);
513 //---------------------------------------------------------------------
514 ORoadmapHyperLabel
* ORoadmap::GetByID( ItemId _nID
, ItemIndex _nStartIndex
)
516 ORoadmapHyperLabel
* CurHyperLabel
;
518 HL_Vector
&LocHyperLabels
= m_pImpl
->getHyperLabels();
519 for ( HL_Vector::iterator i
= LocHyperLabels
.begin()+ _nStartIndex
; i
< LocHyperLabels
.end(); i
++)
522 nLocID
= CurHyperLabel
->GetID();
523 if ( nLocID
== _nID
)
524 return CurHyperLabel
;
529 //---------------------------------------------------------------------
530 const ORoadmapHyperLabel
* ORoadmap::GetByID( ItemId _nID
, ItemIndex _nStartIndex
) const
532 return const_cast< ORoadmap
* >( this )->GetByID( _nID
, _nStartIndex
);
535 //---------------------------------------------------------------------
536 ORoadmapHyperLabel
* ORoadmap::GetByIndex( ItemIndex _nItemIndex
)
538 HL_Vector
&LocHyperLabels
= m_pImpl
->getHyperLabels();
539 if ((_nItemIndex
> -1) && (_nItemIndex
< m_pImpl
->getItemCount( ) ) )
541 ORoadmapHyperLabel
* CurHyperLabel
= LocHyperLabels
.at(_nItemIndex
); // Vectors are one-based
542 return CurHyperLabel
;
547 //---------------------------------------------------------------------
548 const ORoadmapHyperLabel
* ORoadmap::GetByIndex( ItemIndex _nItemIndex
) const
550 return const_cast< ORoadmap
* >( this )->GetByIndex( _nItemIndex
);
553 //---------------------------------------------------------------------
554 RoadmapTypes::ItemId
ORoadmap::GetNextAvailableItemId( ItemIndex _nNewIndex
)
556 ORoadmapHyperLabel
* CurHyperLabel
;
558 ItemIndex searchIndex
= ++_nNewIndex
;
559 while ( searchIndex
< m_pImpl
->getItemCount() )
561 CurHyperLabel
= GetByIndex( searchIndex
);
562 if ( CurHyperLabel
->IsEnabled() )
563 return CurHyperLabel
->GetID( );
570 //---------------------------------------------------------------------
571 RoadmapTypes::ItemId
ORoadmap::GetPreviousAvailableItemId( ItemIndex _nNewIndex
)
573 ORoadmapHyperLabel
* CurHyperLabel
;
574 ItemIndex searchIndex
= --_nNewIndex
;
575 while ( searchIndex
> -1 )
577 CurHyperLabel
= GetByIndex( searchIndex
);
578 if ( CurHyperLabel
->IsEnabled() )
579 return CurHyperLabel
->GetID( );
586 //---------------------------------------------------------------------
587 void ORoadmap::DeselectOldRoadmapItems()
589 HL_Vector pLocRoadmapItems
= m_pImpl
->getHyperLabels();
590 ORoadmapHyperLabel
* CurHyperLabel
= NULL
;
591 for ( HL_Vector::iterator i
= pLocRoadmapItems
.begin(); i
< pLocRoadmapItems
.end(); i
++)
594 CurHyperLabel
->ToggleBackgroundColor( COL_TRANSPARENT
);
598 //---------------------------------------------------------------------
599 void ORoadmap::SetItemSelectHdl( const Link
& _rHdl
)
601 m_pImpl
->setSelectHdl( _rHdl
);
604 //---------------------------------------------------------------------
605 Link
ORoadmap::GetItemSelectHdl( ) const
607 return m_pImpl
->getSelectHdl();
610 //---------------------------------------------------------------------
611 void ORoadmap::Select()
613 GetItemSelectHdl().Call( this );
614 CallEventListeners( VCLEVENT_ROADMAP_ITEMSELECTED
);
617 //---------------------------------------------------------------------
618 void ORoadmap::GetFocus()
620 ORoadmapHyperLabel
* pCurHyperLabel
= GetByID( GetCurrentRoadmapItemID() );
621 if ( pCurHyperLabel
!= NULL
)
622 pCurHyperLabel
->GrabFocus();
625 //---------------------------------------------------------------------
626 sal_Bool
ORoadmap::SelectRoadmapItemByID( ItemId _nNewID
)
628 DeselectOldRoadmapItems();
629 ORoadmapHyperLabel
* CurHyperLabel
= GetByID( _nNewID
);
630 if (CurHyperLabel
!= NULL
)
632 if (CurHyperLabel
->IsEnabled())
634 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
635 CurHyperLabel
->ToggleBackgroundColor( rStyleSettings
.GetHighlightColor() ); //HighlightColor
637 CurHyperLabel
->GrabFocus();
638 m_pImpl
->setCurItemID(_nNewID
);
647 //---------------------------------------------------------------------
648 void ORoadmap::Paint( const Rectangle
& _rRect
)
650 Control::Paint( _rRect
);
654 if ( !!m_pImpl
->getPicture() )
656 Size aBitmapSize
= m_pImpl
->getPicture().GetSizePixel();
657 Size aMySize
= GetOutputSizePixel();
659 Point
aBitmapPos( aMySize
.Width() - aBitmapSize
.Width(), aMySize
.Height() - aBitmapSize
.Height() );
662 DrawBitmapEx( aBitmapPos
, m_pImpl
->getPicture() );
665 //.................................................................
670 //---------------------------------------------------------------------
671 void ORoadmap::DrawHeadline()
673 Point aTextPos
= LogicToPixel( Point( RMENTRYPOINT_X
, 8 ), MAP_APPFONT
);
675 Size
aOutputSize( GetOutputSizePixel() );
678 DrawText( Rectangle( aTextPos
, aOutputSize
), GetText(), TEXT_DRAW_LEFT
| TEXT_DRAW_TOP
| TEXT_DRAW_MULTILINE
| TEXT_DRAW_WORDBREAK
);
679 DrawTextLine( aTextPos
, aOutputSize
.Width(), STRIKEOUT_NONE
, UNDERLINE_SINGLE
, UNDERLINE_NONE
, sal_False
);
680 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
681 SetLineColor( rStyleSettings
.GetFieldTextColor());
682 SetTextColor(rStyleSettings
.GetFieldTextColor());
685 //---------------------------------------------------------------------
686 ORoadmapHyperLabel
* ORoadmap::GetByPointer(Window
* pWindow
)
688 ORoadmapHyperLabel
* CurHyperLabel
;
689 HL_Vector
&LocHyperLabels
= m_pImpl
->getHyperLabels();
690 for ( HL_Vector::iterator i
= LocHyperLabels
.begin(); i
< LocHyperLabels
.end(); i
++)
693 if ( (CurHyperLabel
->GetIDLabel() == pWindow
) || (CurHyperLabel
->GetDescriptionHyperLabel() == pWindow
) )
694 return CurHyperLabel
;
699 //---------------------------------------------------------------------
700 long ORoadmap::PreNotify( NotifyEvent
& _rNEvt
)
702 // capture KeyEvents for taskpane cycling
703 if ( _rNEvt
.GetType() == EVENT_KEYINPUT
)
705 Window
* pWindow
= _rNEvt
.GetWindow();
706 ORoadmapHyperLabel
* CurHyperLabel
= GetByPointer( pWindow
);
707 if ( CurHyperLabel
!= NULL
)
709 sal_Int16 nKeyCode
= _rNEvt
.GetKeyEvent()->GetKeyCode().GetCode();
713 { // Note: Performancewhise this is not optimal, because we search for an ID in the labels
714 // and afterwards we search again for a label with the appropriate ID ->
715 // unnecessarily we search twice!!!
716 ItemId nPrevItemID
= GetPreviousAvailableItemId( CurHyperLabel
->GetIndex() );
717 if ( nPrevItemID
!= -1 )
718 return SelectRoadmapItemByID( nPrevItemID
);
723 ItemId nNextItemID
= GetNextAvailableItemId( CurHyperLabel
->GetIndex() );
724 if ( nNextItemID
!= -1 )
725 return SelectRoadmapItemByID( nNextItemID
);
729 return SelectRoadmapItemByID( CurHyperLabel
->GetID() );
733 return Window::PreNotify( _rNEvt
);
736 //---------------------------------------------------------------------
737 IMPL_LINK(ORoadmap
, ImplClickHdl
, HyperLabel
*, _CurHyperLabel
)
739 return SelectRoadmapItemByID( _CurHyperLabel
->GetID() );
742 void ORoadmap::DataChanged( const DataChangedEvent
& rDCEvt
)
744 if ((( rDCEvt
.GetType() == DATACHANGED_SETTINGS
) ||
745 ( rDCEvt
.GetType() == DATACHANGED_DISPLAY
)) &&
746 ( rDCEvt
.GetFlags() & SETTINGS_STYLE
))
748 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
749 SetBackground( Wallpaper( rStyleSettings
.GetFieldColor() ) );
750 Color aTextColor
= rStyleSettings
.GetFieldTextColor();
751 Font aFont
= GetFont();
752 aFont
.SetColor( aTextColor
);
754 RoadmapTypes::ItemId curItemID
= GetCurrentRoadmapItemID();
755 ORoadmapHyperLabel
* pLabelItem
= GetByID( curItemID
);
756 pLabelItem
->ToggleBackgroundColor(rStyleSettings
.GetHighlightColor());
762 ORoadmapHyperLabel::ORoadmapHyperLabel( Window
* _pParent
, const ResId
& )
764 mpIDLabel
= new ORoadmapIDHyperLabel(_pParent
, WB_WORDBREAK
);
765 mpDescHyperLabel
= new HyperLabel(_pParent
, WB_NOTABSTOP
| WB_WORDBREAK
);
769 ORoadmapHyperLabel::ORoadmapHyperLabel( Window
* _pParent
, WinBits
)
771 mpIDLabel
= new ORoadmapIDHyperLabel(_pParent
, WB_WORDBREAK
);
772 mpIDLabel
->SetTextColor( mpIDLabel
->GetSettings().GetStyleSettings().GetFieldTextColor( ) );
773 mpDescHyperLabel
= new HyperLabel(_pParent
, WB_NOTABSTOP
| WB_WORDBREAK
);
776 //---------------------------------------------------------------------
777 void ORoadmapHyperLabel::GrabFocus()
779 if ( mpDescHyperLabel
)
780 mpDescHyperLabel
->GrabFocus();
784 void ORoadmapHyperLabel::SetInteractive( sal_Bool _bInteractive
)
786 if ( mpDescHyperLabel
)
787 mpDescHyperLabel
->SetInteractive(_bInteractive
);
790 void ORoadmapHyperLabel::SetID( sal_Int16 _ID
)
792 if ( mpDescHyperLabel
)
793 mpDescHyperLabel
->SetID(_ID
);
796 sal_Int16
ORoadmapHyperLabel::GetID() const
798 return mpDescHyperLabel
? mpDescHyperLabel
->GetID() : sal_Int16(-1);
801 void ORoadmapHyperLabel::SetIndex( sal_Int32 _Index
)
803 if ( mpDescHyperLabel
)
804 mpDescHyperLabel
->SetIndex(_Index
);
808 sal_Int32
ORoadmapHyperLabel::GetIndex() const
810 return mpDescHyperLabel
? mpDescHyperLabel
->GetIndex() : sal_Int32(-1);
814 void ORoadmapHyperLabel::SetLabel( ::rtl::OUString _rText
)
816 if ( mpDescHyperLabel
)
817 mpDescHyperLabel
->SetText(_rText
);
821 ::rtl::OUString
ORoadmapHyperLabel::GetLabel( )
823 return mpDescHyperLabel
? mpDescHyperLabel
->GetText() : String();
827 void ORoadmapHyperLabel::SetPosition(ORoadmapHyperLabel
* OldHyperLabel
)
829 Point aNewLogicalPoint
;
831 if (OldHyperLabel
== NULL
)
833 aNewLogicalPoint
= Point( RMENTRYPOINT_X
, RMENTRYPOINT_Y
);
834 aNewPoint
= mpIDLabel
->LogicToPixel(aNewLogicalPoint
, MAP_APPFONT
);
838 Size aOldSize
= OldHyperLabel
->GetDescriptionHyperLabel()->GetSizePixel();
839 Point aOldLogicalPoint
= OldHyperLabel
->GetLogicalPosition();
840 aNewLogicalPoint
= Point(aOldLogicalPoint
.X(), (aOldLogicalPoint
.Y() + RMITEMDISTANCE_Y
));
841 aNewPoint
= mpIDLabel
->LogicToPixel(aNewLogicalPoint
, MAP_APPFONT
);
842 aNewPoint
= Point(aNewPoint
.X(),aNewPoint
.Y() + aOldSize
.Height());
844 mpIDLabel
->SetPosPixel( aNewPoint
);
845 sal_Int32 xDescPos
= aNewPoint
.X() + mpIDLabel
->GetSizePixel().Width();
846 mpDescHyperLabel
->SetPosPixel( Point(xDescPos
, aNewPoint
.Y()) );
850 void ORoadmapHyperLabel::SetZOrder( ORoadmapHyperLabel
* pRefRoadmapHyperLabel
, USHORT nFlags
)
852 if (pRefRoadmapHyperLabel
== NULL
)
853 mpDescHyperLabel
->SetZOrder( NULL
, nFlags
); //WINDOW_ZORDER_FIRST );
855 mpDescHyperLabel
->SetZOrder( pRefRoadmapHyperLabel
->mpDescHyperLabel
, nFlags
); //, WINDOW_ZORDER_BEHIND );
859 void ORoadmapHyperLabel::Enable( BOOL _bEnable
)
861 mpIDLabel
->Enable(_bEnable
);
862 mpDescHyperLabel
->Enable(_bEnable
);
865 BOOL
ORoadmapHyperLabel::IsEnabled() const
867 return mpIDLabel
->IsEnabled();
870 // void ORoadmapHyperLabel::GrabFocus()
872 // mpDescHyperLabel->GrabFocus();
876 void ORoadmapHyperLabel::ToggleBackgroundColor( const Color
& _rGBColor
)
878 if (_rGBColor
== COL_TRANSPARENT
)
880 mpIDLabel
->SetTextColor( mpIDLabel
->GetSettings().GetStyleSettings().GetFieldTextColor( ) );
881 mpIDLabel
->SetControlBackground( COL_TRANSPARENT
);
885 mpIDLabel
->SetControlBackground( mpIDLabel
->GetSettings().GetStyleSettings().GetHighlightColor() );
886 mpIDLabel
->SetTextColor( mpIDLabel
->GetSettings().GetStyleSettings().GetHighlightTextColor( ) );
888 mpDescHyperLabel
->ToggleBackgroundColor(_rGBColor
);
892 Point
ORoadmapHyperLabel::GetLogicalPosition()
894 Point aPoint
= mpIDLabel
->GetPosPixel( );
895 Size aSize
= Size(aPoint
.X(), aPoint
.Y());
896 aSize
= mpIDLabel
->PixelToLogic( aSize
, MAP_APPFONT
);
897 aPoint
= Point(aSize
.Width(), aSize
.Height());
902 void ORoadmapHyperLabel::SetLabelAndSize( ItemIndex _RMIndex
, ::rtl::OUString _rText
, const Size
& _rNewSize
)
904 Size rIDSize
= _rNewSize
;
905 ::rtl::OUString aStr
= ::rtl::OUString::valueOf( (sal_Int32
)( _RMIndex
+ 1 ) ) + ::rtl::OUString::createFromAscii( "." );
906 rIDSize
.Width() = (sal_Int32
) mpIDLabel
->GetTextWidth( aStr
);
907 long nMaxWidth
= mpIDLabel
->GetTextWidth( ::rtl::OUString::createFromAscii("100.") );
908 rIDSize
.Width() = ::std::min( rIDSize
.getWidth(),nMaxWidth
);
909 mpIDLabel
->SetSizePixel(mpIDLabel
->LogicToPixel( rIDSize
));
910 mpIDLabel
->SetText( aStr
);
912 Size rDescSize
= _rNewSize
;
913 rDescSize
.Width() -= rIDSize
.Width();
914 sal_Int32 xDescPos
= mpIDLabel
->GetPosPixel().X() + mpIDLabel
->GetSizePixel().Width();
915 sal_Int32 yDescPos
= mpIDLabel
->GetPosPixel().Y();
916 Point aPoint
= Point(xDescPos
, yDescPos
);
917 mpDescHyperLabel
->SetPosPixel( aPoint
);
918 mpDescHyperLabel
->SetLabelAndSize(_rText
, rDescSize
);
919 mpIDLabel
->SetSizePixel( Size( mpIDLabel
->GetSizePixel().Width(), mpDescHyperLabel
->GetSizePixel().Height() ) );
922 ORoadmapHyperLabel::~ORoadmapHyperLabel( )
925 ::std::auto_ptr
<Control
> aTemp(mpIDLabel
);
929 ::std::auto_ptr
<Control
> aTemp(mpDescHyperLabel
);
930 mpDescHyperLabel
= NULL
;
935 void ORoadmapHyperLabel::SetClickHdl( const Link
& rLink
)
937 if ( mpDescHyperLabel
)
938 mpDescHyperLabel
->SetClickHdl( rLink
);
941 const Link
& ORoadmapHyperLabel::GetClickHdl( ) const
943 return mpDescHyperLabel
->GetClickHdl();
947 ORoadmapIDHyperLabel::ORoadmapIDHyperLabel( Window
* _pParent
, const ResId
& _rId
)
948 :FixedText( _pParent
, _rId
)
952 ORoadmapIDHyperLabel::ORoadmapIDHyperLabel( Window
* _pParent
, WinBits _nWinStyle
)
953 :FixedText( _pParent
, _nWinStyle
)
959 ORoadmapIDHyperLabel::~ORoadmapIDHyperLabel( )
964 void ORoadmapIDHyperLabel::DataChanged( const DataChangedEvent
& rDCEvt
)
966 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
967 FixedText::DataChanged( rDCEvt
);
968 if ((( rDCEvt
.GetType() == DATACHANGED_SETTINGS
) ||
969 ( rDCEvt
.GetType() == DATACHANGED_DISPLAY
)) &&
970 ( rDCEvt
.GetFlags() & SETTINGS_STYLE
))
972 const Color
& rGBColor
= GetControlBackground();
973 if (rGBColor
== COL_TRANSPARENT
)
974 SetTextColor( rStyleSettings
.GetFieldTextColor( ) );
977 SetControlBackground(rStyleSettings
.GetHighlightColor());
978 SetTextColor( rStyleSettings
.GetHighlightTextColor( ) );
987 //.........................................................................
989 //.........................................................................