xref: /AOO41X/main/svtools/source/control/roadmap.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svtools.hxx"
30*cdf0e10cSrcweir #include <svtools/roadmap.hxx>
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #ifndef _STRING_HXX
33*cdf0e10cSrcweir #define _STRING_HXX
34*cdf0e10cSrcweir #endif
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include <vector>
37*cdf0e10cSrcweir #include <algorithm>
38*cdf0e10cSrcweir #include <vcl/bitmap.hxx>
39*cdf0e10cSrcweir #include <tools/color.hxx>
40*cdf0e10cSrcweir #include <memory>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #define ROADMAP_INDENT_X        4
43*cdf0e10cSrcweir #define ROADMAP_INDENT_Y        27
44*cdf0e10cSrcweir #define ROADMAP_ITEM_DISTANCE_Y 6
45*cdf0e10cSrcweir #define RMINCOMPLETE        -1
46*cdf0e10cSrcweir #define NADDITEM            1
47*cdf0e10cSrcweir #define INCOMPLETELABEL     ::String::CreateFromAscii("...")        // TODO: Cast to String
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir //.........................................................................
50*cdf0e10cSrcweir namespace svt
51*cdf0e10cSrcweir {
52*cdf0e10cSrcweir //.........................................................................
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir     typedef std::vector< ::rtl::OUString > S_Vector;
55*cdf0e10cSrcweir     typedef std::vector< RoadmapItem* > HL_Vector;
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir 	//=====================================================================
58*cdf0e10cSrcweir 	//= ColorChanger
59*cdf0e10cSrcweir 	//=====================================================================
60*cdf0e10cSrcweir 	class IDLabel :  public FixedText
61*cdf0e10cSrcweir 	{
62*cdf0e10cSrcweir 	public:
63*cdf0e10cSrcweir 		IDLabel( Window* _pParent, WinBits _nWinStyle = 0 );
64*cdf0e10cSrcweir 		~IDLabel( );
65*cdf0e10cSrcweir 		virtual void	DataChanged( const DataChangedEvent& rDCEvt );
66*cdf0e10cSrcweir 	};
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 	//=====================================================================
69*cdf0e10cSrcweir 	//= ColorChanger
70*cdf0e10cSrcweir 	//=====================================================================
71*cdf0e10cSrcweir 	class ColorChanger
72*cdf0e10cSrcweir 	{
73*cdf0e10cSrcweir 	protected:
74*cdf0e10cSrcweir 		OutputDevice*	m_pDev;
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	public:
77*cdf0e10cSrcweir 		ColorChanger( OutputDevice* _pDev, const Color& _rNewLineColor, const Color& _rNewFillColor )
78*cdf0e10cSrcweir 			:m_pDev( _pDev )
79*cdf0e10cSrcweir 		{
80*cdf0e10cSrcweir 			m_pDev->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
81*cdf0e10cSrcweir 			m_pDev->SetLineColor( _rNewLineColor );
82*cdf0e10cSrcweir 			m_pDev->SetFillColor( _rNewFillColor );
83*cdf0e10cSrcweir 		}
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 		~ColorChanger()
86*cdf0e10cSrcweir 		{
87*cdf0e10cSrcweir 			m_pDev->Pop();
88*cdf0e10cSrcweir 		}
89*cdf0e10cSrcweir 	};
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 	//=====================================================================
92*cdf0e10cSrcweir 	//= RoadmapItem
93*cdf0e10cSrcweir 	//=====================================================================
94*cdf0e10cSrcweir 	class RoadmapItem : public RoadmapTypes
95*cdf0e10cSrcweir 	{
96*cdf0e10cSrcweir 	private:
97*cdf0e10cSrcweir 		IDLabel*                mpID;
98*cdf0e10cSrcweir 		HyperLabel*             mpDescription;
99*cdf0e10cSrcweir         const Size              m_aItemPlayground;
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 	public:
102*cdf0e10cSrcweir 		RoadmapItem( ORoadmap& _rParent, const Size& _rItemPlayground );
103*cdf0e10cSrcweir 		~RoadmapItem( );
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir         void					SetID( sal_Int16 _ID );
106*cdf0e10cSrcweir         sal_Int16				GetID() const;
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir         void					SetIndex( ItemIndex _Index );
109*cdf0e10cSrcweir         ItemIndex               GetIndex() const;
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir         void					SetLabel( const ::rtl::OUString& _rText );
112*cdf0e10cSrcweir         ::rtl::OUString			GetLabel( );
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 		void					Update( ItemIndex _RMIndex, const ::rtl::OUString& _rText );
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir         void					SetPosition( RoadmapItem* OldHyperLabel );
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 		void					ToggleBackgroundColor( const Color& _rGBColor );
119*cdf0e10cSrcweir         void					SetInteractive( sal_Bool _bInteractive );
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir         void					SetClickHdl( const Link& rLink );
122*cdf0e10cSrcweir         const Link&				GetClickHdl() const;
123*cdf0e10cSrcweir 		void					SetZOrder( RoadmapItem* pRefRoadmapHyperLabel, sal_uInt16 nFlags );
124*cdf0e10cSrcweir 		void					Enable( sal_Bool bEnable = sal_True);
125*cdf0e10cSrcweir 		sal_Bool					IsEnabled() const;
126*cdf0e10cSrcweir 		void					GrabFocus();
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir         bool                    Contains( const Window* _pWindow ) const;
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 		HyperLabel*				GetDescriptionHyperLabel() const { return mpDescription; }
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir     private:
133*cdf0e10cSrcweir         void                    ImplUpdateIndex( const ItemIndex _nIndex );
134*cdf0e10cSrcweir         void                    ImplUpdatePosSize();
135*cdf0e10cSrcweir 	};
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 	//=====================================================================
138*cdf0e10cSrcweir 	//= RoadmapImpl
139*cdf0e10cSrcweir 	//=====================================================================
140*cdf0e10cSrcweir     class RoadmapImpl : public RoadmapTypes
141*cdf0e10cSrcweir 	{
142*cdf0e10cSrcweir 	protected:
143*cdf0e10cSrcweir         const ORoadmap&     m_rAntiImpl;
144*cdf0e10cSrcweir         Link                m_aSelectHdl;
145*cdf0e10cSrcweir 		BitmapEx	        m_aPicture;
146*cdf0e10cSrcweir         HL_Vector           m_aRoadmapSteps;
147*cdf0e10cSrcweir         ItemId              m_iCurItemID;
148*cdf0e10cSrcweir         sal_Bool            m_bInteractive;
149*cdf0e10cSrcweir         sal_Bool            m_bComplete;
150*cdf0e10cSrcweir         Size                m_aItemSizePixel;
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 	public:
153*cdf0e10cSrcweir         RoadmapImpl( const ORoadmap& _rAntiImpl )
154*cdf0e10cSrcweir             :m_rAntiImpl( _rAntiImpl )
155*cdf0e10cSrcweir             ,m_iCurItemID( -1 )
156*cdf0e10cSrcweir             ,m_bInteractive( sal_True )
157*cdf0e10cSrcweir             ,m_bComplete( sal_True )
158*cdf0e10cSrcweir         {
159*cdf0e10cSrcweir         }
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir         RoadmapItem* InCompleteHyperLabel;
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir         void			    addHyperLabel( RoadmapItem*  _rRoadmapStep ) { m_aRoadmapSteps.push_back(_rRoadmapStep); }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir         HL_Vector&	        getHyperLabels() { return m_aRoadmapSteps; }
166*cdf0e10cSrcweir 		const HL_Vector&	getHyperLabels() const { return m_aRoadmapSteps; }
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir         void                insertHyperLabel( ItemIndex _Index, RoadmapItem* _rRoadmapStep ) { m_aRoadmapSteps.insert( m_aRoadmapSteps.begin() + _Index, _rRoadmapStep ); }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir         ItemIndex           getItemCount() const { return m_aRoadmapSteps.size();}
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir         void                setCurItemID( ItemId i ) {m_iCurItemID = i; }
173*cdf0e10cSrcweir         ItemId              getCurItemID() const { return m_iCurItemID; }
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir         void                setInteractive(const sal_Bool _bInteractive) {m_bInteractive = _bInteractive; }
176*cdf0e10cSrcweir         sal_Bool            isInteractive() const { return m_bInteractive; };
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir         void                setComplete(const sal_Bool _bComplete) {m_bComplete = _bComplete; }
179*cdf0e10cSrcweir         sal_Bool            isComplete() const { return m_bComplete; };
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir 		void			    setPicture( const BitmapEx& _rPic ) { m_aPicture = _rPic; }
182*cdf0e10cSrcweir 		const BitmapEx&	    getPicture( ) const { return m_aPicture; }
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir         void			    setSelectHdl( const Link& _rHdl ) { m_aSelectHdl = _rHdl; }
185*cdf0e10cSrcweir 		const Link&	        getSelectHdl( ) const { return m_aSelectHdl; }
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir         void                initItemSize();
188*cdf0e10cSrcweir         const Size&         getItemSize() const { return m_aItemSizePixel; }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir         void removeHyperLabel( ItemIndex _Index )
191*cdf0e10cSrcweir         {
192*cdf0e10cSrcweir             if ( ( _Index > -1 ) && ( _Index < getItemCount() ) )
193*cdf0e10cSrcweir             {
194*cdf0e10cSrcweir                 delete m_aRoadmapSteps[_Index];
195*cdf0e10cSrcweir                 m_aRoadmapSteps.erase( m_aRoadmapSteps.begin() + _Index);
196*cdf0e10cSrcweir             }
197*cdf0e10cSrcweir         }
198*cdf0e10cSrcweir 	};
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 	//=====================================================================
202*cdf0e10cSrcweir 	//= Roadmap
203*cdf0e10cSrcweir 	//=====================================================================
204*cdf0e10cSrcweir 	//---------------------------------------------------------------------
205*cdf0e10cSrcweir     void RoadmapImpl::initItemSize()
206*cdf0e10cSrcweir     {
207*cdf0e10cSrcweir         Size aLabelSize( m_rAntiImpl.GetOutputSizePixel() );
208*cdf0e10cSrcweir         aLabelSize.Height() = m_rAntiImpl.LogicToPixel( Size( 0, LABELBASEMAPHEIGHT ), MAP_APPFONT ).Height();
209*cdf0e10cSrcweir         aLabelSize.Width() -= m_rAntiImpl.LogicToPixel( Size( 2 * ROADMAP_INDENT_X, 0 ), MAP_APPFONT ).Width();
210*cdf0e10cSrcweir         m_aItemSizePixel = aLabelSize;
211*cdf0e10cSrcweir     }
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir 	//=====================================================================
214*cdf0e10cSrcweir 	//= Roadmap
215*cdf0e10cSrcweir 	//=====================================================================
216*cdf0e10cSrcweir 	//---------------------------------------------------------------------
217*cdf0e10cSrcweir 	ORoadmap::ORoadmap( Window* _pParent, const ResId& _rId )
218*cdf0e10cSrcweir         :Control( _pParent, _rId )
219*cdf0e10cSrcweir 		,m_pImpl( new RoadmapImpl( *this ) )
220*cdf0e10cSrcweir 	{
221*cdf0e10cSrcweir 		implInit();
222*cdf0e10cSrcweir 	}
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir 	//---------------------------------------------------------------------
225*cdf0e10cSrcweir 	ORoadmap::ORoadmap( Window* _pParent, WinBits _nWinStyle )
226*cdf0e10cSrcweir 		:Control( _pParent, _nWinStyle )
227*cdf0e10cSrcweir 		,m_pImpl( new RoadmapImpl( *this ) )
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir     {
230*cdf0e10cSrcweir         implInit();
231*cdf0e10cSrcweir 	}
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 	//---------------------------------------------------------------------
234*cdf0e10cSrcweir 	void ORoadmap::implInit()
235*cdf0e10cSrcweir 	{
236*cdf0e10cSrcweir 		const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
237*cdf0e10cSrcweir 		Color aTextColor = rStyleSettings.GetFieldTextColor();
238*cdf0e10cSrcweir         Font aFont = GetFont( );
239*cdf0e10cSrcweir 		aFont.SetColor( aTextColor );
240*cdf0e10cSrcweir 		aFont.SetWeight( WEIGHT_BOLD );
241*cdf0e10cSrcweir         aFont.SetUnderline( UNDERLINE_SINGLE );
242*cdf0e10cSrcweir 		SetFont( aFont );
243*cdf0e10cSrcweir 		SetBackground( Wallpaper( rStyleSettings.GetFieldColor() ) );
244*cdf0e10cSrcweir         m_pImpl->InCompleteHyperLabel = NULL;
245*cdf0e10cSrcweir         m_pImpl->setCurItemID(-1 );
246*cdf0e10cSrcweir         m_pImpl->setComplete( sal_True );
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir         // Roadmap control should be reachable as one unit with a Tab key
249*cdf0e10cSrcweir         // the next Tab key should spring out of the control.
250*cdf0e10cSrcweir         // To reach it the control itself should get focus and set it
251*cdf0e10cSrcweir         // on entries. The entries themself should not be reachable with
252*cdf0e10cSrcweir         // the Tab key directly. So each entry should have WB_NOTABSTOP.
253*cdf0e10cSrcweir         //
254*cdf0e10cSrcweir         // In other words the creator should create the control with the following
255*cdf0e10cSrcweir         // flags:
256*cdf0e10cSrcweir         // SetStyle( ( GetStyle() | WB_TABSTOP ) & ~WB_DIALOGCONTROL );
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir // TODO: if somebody sets a new font from outside (OutputDevice::SetFont), we would have to react
259*cdf0e10cSrcweir // on this with calculating a new bold font.
260*cdf0e10cSrcweir // Unfortunately, the OutputDevice does not offer a notify mechanism for a changed font.
261*cdf0e10cSrcweir // So settings the font from outside is simply a forbidded scenario at the moment
262*cdf0e10cSrcweir         EnableMapMode( sal_False );
263*cdf0e10cSrcweir 	}
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir 	//---------------------------------------------------------------------
266*cdf0e10cSrcweir 	ORoadmap::~ORoadmap( )
267*cdf0e10cSrcweir 	{
268*cdf0e10cSrcweir         HL_Vector aItemsCopy = m_pImpl->getHyperLabels();
269*cdf0e10cSrcweir         m_pImpl->getHyperLabels().clear();
270*cdf0e10cSrcweir         for ( HL_Vector::iterator i = aItemsCopy.begin(); i< aItemsCopy.end(); ++i )
271*cdf0e10cSrcweir         {
272*cdf0e10cSrcweir             delete *i;
273*cdf0e10cSrcweir         }
274*cdf0e10cSrcweir         if ( ! m_pImpl->isComplete() )
275*cdf0e10cSrcweir             delete m_pImpl->InCompleteHyperLabel;
276*cdf0e10cSrcweir 		delete m_pImpl;
277*cdf0e10cSrcweir         m_pImpl = NULL;
278*cdf0e10cSrcweir     }
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir     RoadmapTypes::ItemId ORoadmap::GetCurrentRoadmapItemID() const
282*cdf0e10cSrcweir     {
283*cdf0e10cSrcweir         return m_pImpl->getCurItemID();
284*cdf0e10cSrcweir     }
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir 	RoadmapItem* ORoadmap::GetPreviousHyperLabel( ItemIndex _Index)
288*cdf0e10cSrcweir 	{
289*cdf0e10cSrcweir 		RoadmapItem* pOldItem = NULL;
290*cdf0e10cSrcweir 		if ( _Index > 0 )
291*cdf0e10cSrcweir 			pOldItem = m_pImpl->getHyperLabels().at( _Index - 1 );
292*cdf0e10cSrcweir 		return pOldItem;
293*cdf0e10cSrcweir 	}
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir    	//---------------------------------------------------------------------
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir     RoadmapItem* ORoadmap::InsertHyperLabel( ItemIndex _Index, const ::rtl::OUString& _sLabel, ItemId _RMID, sal_Bool _bEnabled)
299*cdf0e10cSrcweir     {
300*cdf0e10cSrcweir         if ( m_pImpl->getItemCount() == 0 )
301*cdf0e10cSrcweir             m_pImpl->initItemSize();
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir         RoadmapItem* pItem = NULL;
304*cdf0e10cSrcweir         RoadmapItem* pOldItem = GetPreviousHyperLabel( _Index );
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir         pItem = new RoadmapItem( *this, m_pImpl->getItemSize() );
307*cdf0e10cSrcweir         if ( _RMID != RMINCOMPLETE )
308*cdf0e10cSrcweir         {
309*cdf0e10cSrcweir             pItem->SetInteractive( m_pImpl->isInteractive() );
310*cdf0e10cSrcweir             m_pImpl->insertHyperLabel( _Index, pItem );
311*cdf0e10cSrcweir         }
312*cdf0e10cSrcweir         else
313*cdf0e10cSrcweir         {
314*cdf0e10cSrcweir             pItem->SetInteractive( sal_False );
315*cdf0e10cSrcweir 		}
316*cdf0e10cSrcweir         pItem->SetPosition( pOldItem );
317*cdf0e10cSrcweir         pItem->Update( _Index, _sLabel );
318*cdf0e10cSrcweir         pItem->SetClickHdl(LINK( this, ORoadmap, ImplClickHdl ) );
319*cdf0e10cSrcweir         pItem->SetID( _RMID );
320*cdf0e10cSrcweir         pItem->SetIndex( _Index );
321*cdf0e10cSrcweir         if (!_bEnabled)
322*cdf0e10cSrcweir             pItem->Enable( _bEnabled );
323*cdf0e10cSrcweir         return pItem;
324*cdf0e10cSrcweir     }
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir 	//---------------------------------------------------------------------
327*cdf0e10cSrcweir 	void ORoadmap::SetRoadmapBitmap( const BitmapEx& _rBmp, sal_Bool _bInvalidate )
328*cdf0e10cSrcweir 	{
329*cdf0e10cSrcweir 		m_pImpl->setPicture( _rBmp );
330*cdf0e10cSrcweir 		if ( _bInvalidate )
331*cdf0e10cSrcweir 			Invalidate( );
332*cdf0e10cSrcweir 	}
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir 	//---------------------------------------------------------------------
335*cdf0e10cSrcweir 	const BitmapEx& ORoadmap::GetRoadmapBitmap( ) const
336*cdf0e10cSrcweir 	{
337*cdf0e10cSrcweir 		return m_pImpl->getPicture( );
338*cdf0e10cSrcweir 	}
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir 	//---------------------------------------------------------------------
341*cdf0e10cSrcweir     void ORoadmap::SetRoadmapInteractive( sal_Bool _bInteractive )
342*cdf0e10cSrcweir     {
343*cdf0e10cSrcweir         m_pImpl->setInteractive( _bInteractive );
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir         const HL_Vector& rItems = m_pImpl->getHyperLabels();
346*cdf0e10cSrcweir         for (   HL_Vector::const_iterator i = rItems.begin();
347*cdf0e10cSrcweir                 i < rItems.end();
348*cdf0e10cSrcweir                 ++i
349*cdf0e10cSrcweir             )
350*cdf0e10cSrcweir         {
351*cdf0e10cSrcweir             (*i)->SetInteractive( _bInteractive );
352*cdf0e10cSrcweir         }
353*cdf0e10cSrcweir     }
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir 	//---------------------------------------------------------------------
356*cdf0e10cSrcweir     sal_Bool ORoadmap::IsRoadmapInteractive()
357*cdf0e10cSrcweir     {
358*cdf0e10cSrcweir         return m_pImpl->isInteractive();
359*cdf0e10cSrcweir     }
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir 	//---------------------------------------------------------------------
362*cdf0e10cSrcweir     void ORoadmap::SetRoadmapComplete( sal_Bool _bComplete )
363*cdf0e10cSrcweir     {
364*cdf0e10cSrcweir         sal_Bool bWasComplete = m_pImpl->isComplete();
365*cdf0e10cSrcweir         m_pImpl->setComplete( _bComplete );
366*cdf0e10cSrcweir         if ( _bComplete )
367*cdf0e10cSrcweir         {
368*cdf0e10cSrcweir             if ( m_pImpl->InCompleteHyperLabel != NULL)
369*cdf0e10cSrcweir             {
370*cdf0e10cSrcweir                 delete m_pImpl->InCompleteHyperLabel;
371*cdf0e10cSrcweir                 m_pImpl->InCompleteHyperLabel = NULL;
372*cdf0e10cSrcweir             }
373*cdf0e10cSrcweir         }
374*cdf0e10cSrcweir         else if ( bWasComplete )
375*cdf0e10cSrcweir             m_pImpl->InCompleteHyperLabel = InsertHyperLabel( m_pImpl->getItemCount(), ::String::CreateFromAscii( "..." ), RMINCOMPLETE );
376*cdf0e10cSrcweir     }
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir 	//---------------------------------------------------------------------
379*cdf0e10cSrcweir     void ORoadmap::UpdatefollowingHyperLabels( ItemIndex _nIndex )
380*cdf0e10cSrcweir     {
381*cdf0e10cSrcweir         const HL_Vector& rItems = m_pImpl->getHyperLabels();
382*cdf0e10cSrcweir         if ( _nIndex < (ItemIndex)rItems.size() )
383*cdf0e10cSrcweir         {
384*cdf0e10cSrcweir             RoadmapItem* pItem = NULL;
385*cdf0e10cSrcweir             for (   HL_Vector::const_iterator i = rItems.begin() + _nIndex;
386*cdf0e10cSrcweir                     i< rItems.end();
387*cdf0e10cSrcweir                     ++i, ++_nIndex
388*cdf0e10cSrcweir                 )
389*cdf0e10cSrcweir             {
390*cdf0e10cSrcweir                 pItem = *i;
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir                 pItem->SetIndex( _nIndex );
393*cdf0e10cSrcweir                 pItem->SetPosition( GetPreviousHyperLabel( _nIndex ) );
394*cdf0e10cSrcweir             }
395*cdf0e10cSrcweir         }
396*cdf0e10cSrcweir         if ( ! m_pImpl->isComplete() )
397*cdf0e10cSrcweir         {
398*cdf0e10cSrcweir 	        RoadmapItem* pOldItem = GetPreviousHyperLabel( m_pImpl->getItemCount() );
399*cdf0e10cSrcweir             m_pImpl->InCompleteHyperLabel->SetPosition( pOldItem );
400*cdf0e10cSrcweir             m_pImpl->InCompleteHyperLabel->Update( m_pImpl->getItemCount(), ::String::CreateFromAscii("...") );
401*cdf0e10cSrcweir         }
402*cdf0e10cSrcweir     }
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir 	//---------------------------------------------------------------------
405*cdf0e10cSrcweir     void ORoadmap::ReplaceRoadmapItem( ItemIndex _Index, const ::rtl::OUString& _RoadmapItem, ItemId _RMID, sal_Bool _bEnabled )
406*cdf0e10cSrcweir     {
407*cdf0e10cSrcweir         RoadmapItem* pItem = GetByIndex( _Index);
408*cdf0e10cSrcweir         if ( pItem != NULL )
409*cdf0e10cSrcweir         {
410*cdf0e10cSrcweir             pItem->Update( _Index,  _RoadmapItem );
411*cdf0e10cSrcweir             pItem->SetID( _RMID );
412*cdf0e10cSrcweir             pItem->Enable( _bEnabled );
413*cdf0e10cSrcweir         }
414*cdf0e10cSrcweir     }
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir 	//---------------------------------------------------------------------
417*cdf0e10cSrcweir     RoadmapTypes::ItemIndex ORoadmap::GetItemCount() const
418*cdf0e10cSrcweir     {
419*cdf0e10cSrcweir         return m_pImpl->getItemCount();
420*cdf0e10cSrcweir     }
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir 	//---------------------------------------------------------------------
423*cdf0e10cSrcweir     RoadmapTypes::ItemId ORoadmap::GetItemID( ItemIndex _nIndex ) const
424*cdf0e10cSrcweir     {
425*cdf0e10cSrcweir         const RoadmapItem* pHyperLabel = GetByIndex( _nIndex );
426*cdf0e10cSrcweir         if ( pHyperLabel )
427*cdf0e10cSrcweir             return pHyperLabel->GetID();
428*cdf0e10cSrcweir         return -1;
429*cdf0e10cSrcweir     }
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir 	//---------------------------------------------------------------------
432*cdf0e10cSrcweir     RoadmapTypes::ItemIndex ORoadmap::GetItemIndex( ItemId _nID ) const
433*cdf0e10cSrcweir     {
434*cdf0e10cSrcweir         ItemId nLocID = 0;
435*cdf0e10cSrcweir         const HL_Vector& rItems = m_pImpl->getHyperLabels();
436*cdf0e10cSrcweir         for (   HL_Vector::const_iterator i = rItems.begin();
437*cdf0e10cSrcweir                 i < rItems.end();
438*cdf0e10cSrcweir                 ++i
439*cdf0e10cSrcweir             )
440*cdf0e10cSrcweir         {
441*cdf0e10cSrcweir             nLocID = (*i)->GetID();
442*cdf0e10cSrcweir             if ( nLocID == _nID )
443*cdf0e10cSrcweir                 return ItemIndex( i - rItems.begin() );
444*cdf0e10cSrcweir         }
445*cdf0e10cSrcweir         return -1;
446*cdf0e10cSrcweir     }
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir 	//---------------------------------------------------------------------
449*cdf0e10cSrcweir     void ORoadmap::InsertRoadmapItem( ItemIndex _Index, const ::rtl::OUString& _RoadmapItem, ItemId _nUniqueId, sal_Bool _bEnabled )
450*cdf0e10cSrcweir     {
451*cdf0e10cSrcweir         InsertHyperLabel( _Index, _RoadmapItem, _nUniqueId, _bEnabled );
452*cdf0e10cSrcweir             // Todo: YPos is superfluous, if items are always appended
453*cdf0e10cSrcweir         UpdatefollowingHyperLabels( _Index + 1 );
454*cdf0e10cSrcweir     }
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir 	//---------------------------------------------------------------------
457*cdf0e10cSrcweir     void ORoadmap::DeleteRoadmapItem( ItemIndex _Index )
458*cdf0e10cSrcweir     {
459*cdf0e10cSrcweir         if ( m_pImpl->getItemCount() > 0 && ( _Index > -1)  &&  ( _Index < m_pImpl->getItemCount() ) )
460*cdf0e10cSrcweir         {
461*cdf0e10cSrcweir             m_pImpl->removeHyperLabel( _Index );
462*cdf0e10cSrcweir             UpdatefollowingHyperLabels( _Index );
463*cdf0e10cSrcweir         }
464*cdf0e10cSrcweir     }
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir 	//---------------------------------------------------------------------
467*cdf0e10cSrcweir     sal_Bool ORoadmap::IsRoadmapComplete( ) const
468*cdf0e10cSrcweir     {
469*cdf0e10cSrcweir         return m_pImpl->isComplete();
470*cdf0e10cSrcweir     }
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir 	//---------------------------------------------------------------------
473*cdf0e10cSrcweir     sal_Bool ORoadmap::IsRoadmapItemEnabled( ItemId _nItemId, ItemIndex _nStartIndex  ) const
474*cdf0e10cSrcweir     {
475*cdf0e10cSrcweir         const RoadmapItem* _pLabelItem = GetByID( _nItemId, _nStartIndex  );
476*cdf0e10cSrcweir         return _pLabelItem ? _pLabelItem->IsEnabled() : sal_False;
477*cdf0e10cSrcweir     }
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir 	//---------------------------------------------------------------------
480*cdf0e10cSrcweir     void ORoadmap::EnableRoadmapItem( ItemId _nItemId, sal_Bool _bEnable, ItemIndex _nStartIndex )
481*cdf0e10cSrcweir     {
482*cdf0e10cSrcweir         RoadmapItem* pItem = GetByID( _nItemId, _nStartIndex );
483*cdf0e10cSrcweir         if ( pItem != NULL )
484*cdf0e10cSrcweir             pItem->Enable( _bEnable );
485*cdf0e10cSrcweir     }
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir 	//---------------------------------------------------------------------
488*cdf0e10cSrcweir     void ORoadmap::ChangeRoadmapItemLabel( ItemId _nID, const ::rtl::OUString& _sLabel, ItemIndex _nStartIndex )
489*cdf0e10cSrcweir     {
490*cdf0e10cSrcweir         RoadmapItem* pItem = GetByID( _nID, _nStartIndex );
491*cdf0e10cSrcweir         if ( pItem != NULL )
492*cdf0e10cSrcweir 		{
493*cdf0e10cSrcweir             pItem->Update( pItem->GetIndex(), _sLabel );
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir             const HL_Vector& rItems = m_pImpl->getHyperLabels();
496*cdf0e10cSrcweir 			for (   HL_Vector::const_iterator i = rItems.begin() + _nStartIndex;
497*cdf0e10cSrcweir                     i < rItems.end();
498*cdf0e10cSrcweir                     ++i
499*cdf0e10cSrcweir                 )
500*cdf0e10cSrcweir 			{
501*cdf0e10cSrcweir 				(*i)->SetPosition( GetPreviousHyperLabel( i - rItems.begin() ) );
502*cdf0e10cSrcweir 			}
503*cdf0e10cSrcweir 		}
504*cdf0e10cSrcweir     }
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir 	//---------------------------------------------------------------------
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir     ::rtl::OUString ORoadmap::GetRoadmapItemLabel( ItemId _nID, ItemIndex _nStartIndex )
509*cdf0e10cSrcweir     {
510*cdf0e10cSrcweir         RoadmapItem* pItem = GetByID( _nID, _nStartIndex );
511*cdf0e10cSrcweir         if ( pItem != NULL )
512*cdf0e10cSrcweir             return pItem->GetLabel();
513*cdf0e10cSrcweir         else
514*cdf0e10cSrcweir             return ::rtl::OUString();
515*cdf0e10cSrcweir     }
516*cdf0e10cSrcweir 
517*cdf0e10cSrcweir 	//---------------------------------------------------------------------
518*cdf0e10cSrcweir     void ORoadmap::ChangeRoadmapItemID( ItemId _nID, ItemId _NewID, ItemIndex _nStartIndex )
519*cdf0e10cSrcweir     {
520*cdf0e10cSrcweir         RoadmapItem* pItem = GetByID( _nID, _nStartIndex );
521*cdf0e10cSrcweir         if ( pItem != NULL )
522*cdf0e10cSrcweir             pItem->SetID( _NewID );
523*cdf0e10cSrcweir     }
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir 	//---------------------------------------------------------------------
526*cdf0e10cSrcweir     RoadmapItem* ORoadmap::GetByID( ItemId _nID, ItemIndex _nStartIndex)
527*cdf0e10cSrcweir     {
528*cdf0e10cSrcweir         ItemId nLocID = 0;
529*cdf0e10cSrcweir         const HL_Vector& rItems = m_pImpl->getHyperLabels();
530*cdf0e10cSrcweir         for (   HL_Vector::const_iterator i = rItems.begin() + _nStartIndex;
531*cdf0e10cSrcweir                 i < rItems.end();
532*cdf0e10cSrcweir                 ++i
533*cdf0e10cSrcweir             )
534*cdf0e10cSrcweir         {
535*cdf0e10cSrcweir             nLocID = (*i)->GetID();
536*cdf0e10cSrcweir             if ( nLocID == _nID )
537*cdf0e10cSrcweir                 return *i;
538*cdf0e10cSrcweir         }
539*cdf0e10cSrcweir         return NULL;
540*cdf0e10cSrcweir     }
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir 	//---------------------------------------------------------------------
543*cdf0e10cSrcweir     const RoadmapItem* ORoadmap::GetByID( ItemId _nID, ItemIndex _nStartIndex  ) const
544*cdf0e10cSrcweir     {
545*cdf0e10cSrcweir         return const_cast< ORoadmap* >( this )->GetByID( _nID, _nStartIndex );
546*cdf0e10cSrcweir     }
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir 	//---------------------------------------------------------------------
549*cdf0e10cSrcweir     RoadmapItem* ORoadmap::GetByIndex( ItemIndex _nItemIndex)
550*cdf0e10cSrcweir     {
551*cdf0e10cSrcweir         const HL_Vector& rItems = m_pImpl->getHyperLabels();
552*cdf0e10cSrcweir         if ( ( _nItemIndex > -1 ) && ( _nItemIndex < (ItemIndex)rItems.size() ) )
553*cdf0e10cSrcweir         {
554*cdf0e10cSrcweir             return rItems.at( _nItemIndex );
555*cdf0e10cSrcweir         }
556*cdf0e10cSrcweir         return NULL;
557*cdf0e10cSrcweir     }
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir     //---------------------------------------------------------------------
560*cdf0e10cSrcweir     const RoadmapItem* ORoadmap::GetByIndex( ItemIndex _nItemIndex ) const
561*cdf0e10cSrcweir     {
562*cdf0e10cSrcweir         return const_cast< ORoadmap* >( this )->GetByIndex( _nItemIndex );
563*cdf0e10cSrcweir     }
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir 	//---------------------------------------------------------------------
566*cdf0e10cSrcweir     RoadmapTypes::ItemId ORoadmap::GetNextAvailableItemId( ItemIndex _nNewIndex )
567*cdf0e10cSrcweir     {
568*cdf0e10cSrcweir         RoadmapItem* pItem = NULL;
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir         ItemIndex searchIndex = ++_nNewIndex;
571*cdf0e10cSrcweir         while ( searchIndex < m_pImpl->getItemCount() )
572*cdf0e10cSrcweir         {
573*cdf0e10cSrcweir             pItem = GetByIndex( searchIndex );
574*cdf0e10cSrcweir             if ( pItem->IsEnabled() )
575*cdf0e10cSrcweir                 return pItem->GetID( );
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir             ++searchIndex;
578*cdf0e10cSrcweir         }
579*cdf0e10cSrcweir         return -1;
580*cdf0e10cSrcweir     }
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir 	//---------------------------------------------------------------------
583*cdf0e10cSrcweir     RoadmapTypes::ItemId ORoadmap::GetPreviousAvailableItemId( ItemIndex _nNewIndex )
584*cdf0e10cSrcweir     {
585*cdf0e10cSrcweir         RoadmapItem* pItem = NULL;
586*cdf0e10cSrcweir         ItemIndex searchIndex = --_nNewIndex;
587*cdf0e10cSrcweir         while ( searchIndex > -1 )
588*cdf0e10cSrcweir         {
589*cdf0e10cSrcweir             pItem = GetByIndex( searchIndex );
590*cdf0e10cSrcweir             if ( pItem->IsEnabled() )
591*cdf0e10cSrcweir                 return pItem->GetID( );
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir             searchIndex--;
594*cdf0e10cSrcweir         }
595*cdf0e10cSrcweir         return -1;
596*cdf0e10cSrcweir     }
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir 	//---------------------------------------------------------------------
599*cdf0e10cSrcweir     void ORoadmap::DeselectOldRoadmapItems()
600*cdf0e10cSrcweir     {
601*cdf0e10cSrcweir         const HL_Vector& rItems = m_pImpl->getHyperLabels();
602*cdf0e10cSrcweir         for (   HL_Vector::const_iterator i = rItems.begin();
603*cdf0e10cSrcweir                 i < rItems.end();
604*cdf0e10cSrcweir                 ++i
605*cdf0e10cSrcweir             )
606*cdf0e10cSrcweir         {
607*cdf0e10cSrcweir             (*i)->ToggleBackgroundColor( COL_TRANSPARENT );
608*cdf0e10cSrcweir         }
609*cdf0e10cSrcweir     }
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir 	//---------------------------------------------------------------------
612*cdf0e10cSrcweir     void ORoadmap::SetItemSelectHdl( const Link& _rHdl )
613*cdf0e10cSrcweir     {
614*cdf0e10cSrcweir         m_pImpl->setSelectHdl( _rHdl );
615*cdf0e10cSrcweir     }
616*cdf0e10cSrcweir 
617*cdf0e10cSrcweir 	//---------------------------------------------------------------------
618*cdf0e10cSrcweir     Link ORoadmap::GetItemSelectHdl( ) const
619*cdf0e10cSrcweir     {
620*cdf0e10cSrcweir         return m_pImpl->getSelectHdl();
621*cdf0e10cSrcweir     }
622*cdf0e10cSrcweir 
623*cdf0e10cSrcweir 	//---------------------------------------------------------------------
624*cdf0e10cSrcweir     void ORoadmap::Select()
625*cdf0e10cSrcweir     {
626*cdf0e10cSrcweir         GetItemSelectHdl().Call( this );
627*cdf0e10cSrcweir         CallEventListeners( VCLEVENT_ROADMAP_ITEMSELECTED );
628*cdf0e10cSrcweir     }
629*cdf0e10cSrcweir 
630*cdf0e10cSrcweir     //---------------------------------------------------------------------
631*cdf0e10cSrcweir     void ORoadmap::GetFocus()
632*cdf0e10cSrcweir 	{
633*cdf0e10cSrcweir         RoadmapItem* pCurHyperLabel = GetByID( GetCurrentRoadmapItemID() );
634*cdf0e10cSrcweir         if ( pCurHyperLabel != NULL )
635*cdf0e10cSrcweir 		    pCurHyperLabel->GrabFocus();
636*cdf0e10cSrcweir 	}
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir 	//---------------------------------------------------------------------
639*cdf0e10cSrcweir     sal_Bool ORoadmap::SelectRoadmapItemByID( ItemId _nNewID )
640*cdf0e10cSrcweir     {
641*cdf0e10cSrcweir         DeselectOldRoadmapItems();
642*cdf0e10cSrcweir         RoadmapItem* pItem = GetByID( _nNewID );
643*cdf0e10cSrcweir         if ( pItem != NULL )
644*cdf0e10cSrcweir         {
645*cdf0e10cSrcweir             if ( pItem->IsEnabled() )
646*cdf0e10cSrcweir             {
647*cdf0e10cSrcweir 				const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
648*cdf0e10cSrcweir                 pItem->ToggleBackgroundColor( rStyleSettings.GetHighlightColor() ); //HighlightColor
649*cdf0e10cSrcweir 
650*cdf0e10cSrcweir 				pItem->GrabFocus();
651*cdf0e10cSrcweir                 m_pImpl->setCurItemID(_nNewID);
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir                 Select();
654*cdf0e10cSrcweir                 return sal_True;
655*cdf0e10cSrcweir             }
656*cdf0e10cSrcweir         }
657*cdf0e10cSrcweir         return sal_False;
658*cdf0e10cSrcweir     }
659*cdf0e10cSrcweir 
660*cdf0e10cSrcweir 	//---------------------------------------------------------------------
661*cdf0e10cSrcweir 	void ORoadmap::Paint( const Rectangle& _rRect )
662*cdf0e10cSrcweir 	{
663*cdf0e10cSrcweir 		Control::Paint( _rRect );
664*cdf0e10cSrcweir 
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir 		// draw the bitmap
667*cdf0e10cSrcweir 		if ( !!m_pImpl->getPicture() )
668*cdf0e10cSrcweir 		{
669*cdf0e10cSrcweir 			Size aBitmapSize = m_pImpl->getPicture().GetSizePixel();
670*cdf0e10cSrcweir 			Size aMySize = GetOutputSizePixel();
671*cdf0e10cSrcweir 
672*cdf0e10cSrcweir 			Point aBitmapPos( aMySize.Width() - aBitmapSize.Width(),  aMySize.Height() - aBitmapSize.Height() );
673*cdf0e10cSrcweir 
674*cdf0e10cSrcweir 			// draw it
675*cdf0e10cSrcweir 			DrawBitmapEx( aBitmapPos, m_pImpl->getPicture() );
676*cdf0e10cSrcweir 		}
677*cdf0e10cSrcweir 
678*cdf0e10cSrcweir         //.................................................................
679*cdf0e10cSrcweir 		// draw the headline
680*cdf0e10cSrcweir         DrawHeadline();
681*cdf0e10cSrcweir 	}
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir 	//---------------------------------------------------------------------
684*cdf0e10cSrcweir     void ORoadmap::DrawHeadline()
685*cdf0e10cSrcweir 	{
686*cdf0e10cSrcweir 		Point aTextPos = LogicToPixel( Point( ROADMAP_INDENT_X, 8 ), MAP_APPFONT );
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir 		Size aOutputSize( GetOutputSizePixel() );
689*cdf0e10cSrcweir 
690*cdf0e10cSrcweir 		// draw it
691*cdf0e10cSrcweir 		DrawText( Rectangle( aTextPos, aOutputSize ), GetText(), TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
692*cdf0e10cSrcweir         DrawTextLine( aTextPos, aOutputSize.Width(), STRIKEOUT_NONE, UNDERLINE_SINGLE, UNDERLINE_NONE, sal_False );
693*cdf0e10cSrcweir 		const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
694*cdf0e10cSrcweir         SetLineColor( rStyleSettings.GetFieldTextColor());
695*cdf0e10cSrcweir 		SetTextColor(rStyleSettings.GetFieldTextColor());
696*cdf0e10cSrcweir 	}
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir 	//---------------------------------------------------------------------
699*cdf0e10cSrcweir     RoadmapItem* ORoadmap::GetByPointer(Window* pWindow)
700*cdf0e10cSrcweir     {
701*cdf0e10cSrcweir         const HL_Vector& rItems = m_pImpl->getHyperLabels();
702*cdf0e10cSrcweir         for (   HL_Vector::const_iterator i = rItems.begin();
703*cdf0e10cSrcweir                 i < rItems.end();
704*cdf0e10cSrcweir                 ++i
705*cdf0e10cSrcweir             )
706*cdf0e10cSrcweir         {
707*cdf0e10cSrcweir 			if ( (*i)->Contains( pWindow ) )
708*cdf0e10cSrcweir                 return *i;
709*cdf0e10cSrcweir         }
710*cdf0e10cSrcweir         return NULL;
711*cdf0e10cSrcweir     }
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir 	//---------------------------------------------------------------------
714*cdf0e10cSrcweir     long ORoadmap::PreNotify( NotifyEvent& _rNEvt )
715*cdf0e10cSrcweir     {
716*cdf0e10cSrcweir         // capture KeyEvents for taskpane cycling
717*cdf0e10cSrcweir         if ( _rNEvt.GetType() == EVENT_KEYINPUT )
718*cdf0e10cSrcweir         {
719*cdf0e10cSrcweir             Window* pWindow = _rNEvt.GetWindow();
720*cdf0e10cSrcweir             RoadmapItem* pItem = GetByPointer( pWindow );
721*cdf0e10cSrcweir             if ( pItem != NULL )
722*cdf0e10cSrcweir             {
723*cdf0e10cSrcweir                 sal_Int16 nKeyCode = _rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
724*cdf0e10cSrcweir 		        switch( nKeyCode )
725*cdf0e10cSrcweir 		        {
726*cdf0e10cSrcweir 			        case KEY_UP:
727*cdf0e10cSrcweir                         {   // Note: Performancewise this is not optimal, because we search for an ID in the labels
728*cdf0e10cSrcweir                             //       and afterwards we search again for a label with the appropriate ID ->
729*cdf0e10cSrcweir                             //       unnecessarily we search twice!!!
730*cdf0e10cSrcweir                             ItemId nPrevItemID = GetPreviousAvailableItemId( pItem->GetIndex() );
731*cdf0e10cSrcweir                             if ( nPrevItemID != -1 )
732*cdf0e10cSrcweir                                 return SelectRoadmapItemByID( nPrevItemID );
733*cdf0e10cSrcweir                         }
734*cdf0e10cSrcweir                         break;
735*cdf0e10cSrcweir 			        case KEY_DOWN:
736*cdf0e10cSrcweir                         {
737*cdf0e10cSrcweir                             ItemId nNextItemID = GetNextAvailableItemId( pItem->GetIndex() );
738*cdf0e10cSrcweir                             if ( nNextItemID != -1 )
739*cdf0e10cSrcweir                                 return SelectRoadmapItemByID( nNextItemID );
740*cdf0e10cSrcweir                         }
741*cdf0e10cSrcweir                         break;
742*cdf0e10cSrcweir                     case KEY_SPACE:
743*cdf0e10cSrcweir                         return SelectRoadmapItemByID( pItem->GetID() );
744*cdf0e10cSrcweir                 }
745*cdf0e10cSrcweir             }
746*cdf0e10cSrcweir         }
747*cdf0e10cSrcweir         return Window::PreNotify( _rNEvt );
748*cdf0e10cSrcweir     }
749*cdf0e10cSrcweir 
750*cdf0e10cSrcweir 	//---------------------------------------------------------------------
751*cdf0e10cSrcweir   	IMPL_LINK(ORoadmap, ImplClickHdl, HyperLabel*, _CurHyperLabel)
752*cdf0e10cSrcweir 	{
753*cdf0e10cSrcweir        return SelectRoadmapItemByID( _CurHyperLabel->GetID() );
754*cdf0e10cSrcweir     }
755*cdf0e10cSrcweir 
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir 
758*cdf0e10cSrcweir     //---------------------------------------------------------------------
759*cdf0e10cSrcweir 	void ORoadmap::DataChanged( const DataChangedEvent& rDCEvt )
760*cdf0e10cSrcweir 	{
761*cdf0e10cSrcweir 		if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS	)	||
762*cdf0e10cSrcweir 			( rDCEvt.GetType() == DATACHANGED_DISPLAY	))	&&
763*cdf0e10cSrcweir 			( rDCEvt.GetFlags() & SETTINGS_STYLE		))
764*cdf0e10cSrcweir 		{
765*cdf0e10cSrcweir 			const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
766*cdf0e10cSrcweir 			SetBackground( Wallpaper( rStyleSettings.GetFieldColor() ) );
767*cdf0e10cSrcweir 			Color aTextColor = rStyleSettings.GetFieldTextColor();
768*cdf0e10cSrcweir 			Font aFont = GetFont();
769*cdf0e10cSrcweir 			aFont.SetColor( aTextColor );
770*cdf0e10cSrcweir 			SetFont( aFont );
771*cdf0e10cSrcweir 			RoadmapTypes::ItemId curItemID = GetCurrentRoadmapItemID();
772*cdf0e10cSrcweir 			RoadmapItem* pLabelItem = GetByID( curItemID );
773*cdf0e10cSrcweir 			pLabelItem->ToggleBackgroundColor(rStyleSettings.GetHighlightColor());
774*cdf0e10cSrcweir 			Invalidate();
775*cdf0e10cSrcweir 		}
776*cdf0e10cSrcweir 	}
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir 
779*cdf0e10cSrcweir     //---------------------------------------------------------------------
780*cdf0e10cSrcweir     RoadmapItem::RoadmapItem( ORoadmap& _rParent, const Size& _rItemPlayground )
781*cdf0e10cSrcweir         :m_aItemPlayground( _rItemPlayground )
782*cdf0e10cSrcweir 	{
783*cdf0e10cSrcweir 		mpID = new IDLabel( &_rParent, WB_WORDBREAK );
784*cdf0e10cSrcweir 		mpID->SetTextColor( mpID->GetSettings().GetStyleSettings().GetFieldTextColor( ) );
785*cdf0e10cSrcweir         mpID->Show();
786*cdf0e10cSrcweir 		mpDescription = new HyperLabel( &_rParent, WB_NOTABSTOP | WB_WORDBREAK );
787*cdf0e10cSrcweir         mpDescription->Show();
788*cdf0e10cSrcweir 	}
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir     //---------------------------------------------------------------------
791*cdf0e10cSrcweir     bool RoadmapItem::Contains( const Window* _pWindow ) const
792*cdf0e10cSrcweir     {
793*cdf0e10cSrcweir         return ( mpID == _pWindow ) || ( mpDescription == _pWindow );
794*cdf0e10cSrcweir     }
795*cdf0e10cSrcweir 
796*cdf0e10cSrcweir     //---------------------------------------------------------------------
797*cdf0e10cSrcweir     void RoadmapItem::GrabFocus()
798*cdf0e10cSrcweir 	{
799*cdf0e10cSrcweir         if ( mpDescription )
800*cdf0e10cSrcweir             mpDescription->GrabFocus();
801*cdf0e10cSrcweir 	}
802*cdf0e10cSrcweir 
803*cdf0e10cSrcweir     //---------------------------------------------------------------------
804*cdf0e10cSrcweir 	void RoadmapItem::SetInteractive( sal_Bool _bInteractive )
805*cdf0e10cSrcweir 	{
806*cdf0e10cSrcweir         if ( mpDescription )
807*cdf0e10cSrcweir 		mpDescription->SetInteractive(_bInteractive);
808*cdf0e10cSrcweir 	}
809*cdf0e10cSrcweir 
810*cdf0e10cSrcweir     //---------------------------------------------------------------------
811*cdf0e10cSrcweir 	void RoadmapItem::SetID( sal_Int16 _ID )
812*cdf0e10cSrcweir 	{
813*cdf0e10cSrcweir         if ( mpDescription )
814*cdf0e10cSrcweir 		    mpDescription->SetID(_ID);
815*cdf0e10cSrcweir 	}
816*cdf0e10cSrcweir 
817*cdf0e10cSrcweir     //---------------------------------------------------------------------
818*cdf0e10cSrcweir 	sal_Int16 RoadmapItem::GetID() const
819*cdf0e10cSrcweir 	{
820*cdf0e10cSrcweir         return mpDescription ? mpDescription->GetID() : sal_Int16(-1);
821*cdf0e10cSrcweir 	}
822*cdf0e10cSrcweir 
823*cdf0e10cSrcweir     //---------------------------------------------------------------------
824*cdf0e10cSrcweir     void RoadmapItem::ImplUpdateIndex( const ItemIndex _nIndex )
825*cdf0e10cSrcweir     {
826*cdf0e10cSrcweir         if ( mpDescription )
827*cdf0e10cSrcweir 		    mpDescription->SetIndex( _nIndex );
828*cdf0e10cSrcweir 
829*cdf0e10cSrcweir         if ( mpID )
830*cdf0e10cSrcweir         {
831*cdf0e10cSrcweir             ::rtl::OUString aIDText = ::rtl::OUString::valueOf( (sal_Int32)( _nIndex + 1 ) ) +  ::rtl::OUString::createFromAscii( "." );
832*cdf0e10cSrcweir  		    mpID->SetText( aIDText );
833*cdf0e10cSrcweir         }
834*cdf0e10cSrcweir 
835*cdf0e10cSrcweir         // update the geometry of both controls
836*cdf0e10cSrcweir         ImplUpdatePosSize();
837*cdf0e10cSrcweir     }
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir     //---------------------------------------------------------------------
840*cdf0e10cSrcweir 	void RoadmapItem::SetIndex( ItemIndex _Index )
841*cdf0e10cSrcweir 	{
842*cdf0e10cSrcweir         ImplUpdateIndex( _Index );
843*cdf0e10cSrcweir 	}
844*cdf0e10cSrcweir 
845*cdf0e10cSrcweir     //---------------------------------------------------------------------
846*cdf0e10cSrcweir     RoadmapTypes::ItemIndex RoadmapItem::GetIndex() const
847*cdf0e10cSrcweir 	{
848*cdf0e10cSrcweir         return mpDescription ? mpDescription->GetIndex() : ItemIndex(-1);
849*cdf0e10cSrcweir 	}
850*cdf0e10cSrcweir 
851*cdf0e10cSrcweir     //---------------------------------------------------------------------
852*cdf0e10cSrcweir 	void RoadmapItem::SetLabel( const ::rtl::OUString& _rText )
853*cdf0e10cSrcweir 	{
854*cdf0e10cSrcweir         if ( mpDescription )
855*cdf0e10cSrcweir 		    mpDescription->SetText(_rText);
856*cdf0e10cSrcweir 	}
857*cdf0e10cSrcweir 
858*cdf0e10cSrcweir     //---------------------------------------------------------------------
859*cdf0e10cSrcweir 	::rtl::OUString RoadmapItem::GetLabel( )
860*cdf0e10cSrcweir 	{
861*cdf0e10cSrcweir         return mpDescription ? mpDescription->GetText() : String();
862*cdf0e10cSrcweir 	}
863*cdf0e10cSrcweir 
864*cdf0e10cSrcweir     //---------------------------------------------------------------------
865*cdf0e10cSrcweir 	void RoadmapItem::SetPosition( RoadmapItem* _pOldItem )
866*cdf0e10cSrcweir 	{
867*cdf0e10cSrcweir 		Point aIDPos;
868*cdf0e10cSrcweir 		if ( _pOldItem == NULL )
869*cdf0e10cSrcweir 		{
870*cdf0e10cSrcweir 			aIDPos = mpID->LogicToPixel( Point( ROADMAP_INDENT_X, ROADMAP_INDENT_Y ), MAP_APPFONT );
871*cdf0e10cSrcweir 		}
872*cdf0e10cSrcweir 		else
873*cdf0e10cSrcweir 		{
874*cdf0e10cSrcweir 			Size aOldSize = _pOldItem->GetDescriptionHyperLabel()->GetSizePixel();
875*cdf0e10cSrcweir 
876*cdf0e10cSrcweir             aIDPos = _pOldItem->mpID->GetPosPixel();
877*cdf0e10cSrcweir             aIDPos.Y() += aOldSize.Height();
878*cdf0e10cSrcweir             aIDPos.Y() += mpID->GetParent()->LogicToPixel( Size( 0, ROADMAP_ITEM_DISTANCE_Y ) ).Height();
879*cdf0e10cSrcweir 		}
880*cdf0e10cSrcweir 		mpID->SetPosPixel( aIDPos );
881*cdf0e10cSrcweir 
882*cdf0e10cSrcweir 		sal_Int32 nDescPos = aIDPos.X() + mpID->GetSizePixel().Width();
883*cdf0e10cSrcweir 		mpDescription->SetPosPixel( Point( nDescPos, aIDPos.Y() ) );
884*cdf0e10cSrcweir 	}
885*cdf0e10cSrcweir 
886*cdf0e10cSrcweir     //---------------------------------------------------------------------
887*cdf0e10cSrcweir 	void RoadmapItem::SetZOrder( RoadmapItem* pRefRoadmapHyperLabel, sal_uInt16 nFlags )
888*cdf0e10cSrcweir 	{
889*cdf0e10cSrcweir 		if (pRefRoadmapHyperLabel == NULL)
890*cdf0e10cSrcweir 			mpDescription->SetZOrder( NULL, nFlags); //WINDOW_ZORDER_FIRST );
891*cdf0e10cSrcweir 		else
892*cdf0e10cSrcweir 			mpDescription->SetZOrder( pRefRoadmapHyperLabel->mpDescription, nFlags); //, WINDOW_ZORDER_BEHIND );
893*cdf0e10cSrcweir 	}
894*cdf0e10cSrcweir 
895*cdf0e10cSrcweir     //---------------------------------------------------------------------
896*cdf0e10cSrcweir 	void RoadmapItem::Enable( sal_Bool _bEnable)
897*cdf0e10cSrcweir 	{
898*cdf0e10cSrcweir 		mpID->Enable(_bEnable);
899*cdf0e10cSrcweir 		mpDescription->Enable(_bEnable);
900*cdf0e10cSrcweir 	}
901*cdf0e10cSrcweir 
902*cdf0e10cSrcweir     //---------------------------------------------------------------------
903*cdf0e10cSrcweir 	sal_Bool RoadmapItem::IsEnabled() const
904*cdf0e10cSrcweir 	{
905*cdf0e10cSrcweir 		return mpID->IsEnabled();
906*cdf0e10cSrcweir 	}
907*cdf0e10cSrcweir 
908*cdf0e10cSrcweir     //---------------------------------------------------------------------
909*cdf0e10cSrcweir 	void RoadmapItem::ToggleBackgroundColor( const Color& _rGBColor )
910*cdf0e10cSrcweir 	{
911*cdf0e10cSrcweir 		if (_rGBColor == COL_TRANSPARENT)
912*cdf0e10cSrcweir 		{
913*cdf0e10cSrcweir 			mpID->SetTextColor( mpID->GetSettings().GetStyleSettings().GetFieldTextColor( ) );
914*cdf0e10cSrcweir 			mpID->SetControlBackground( COL_TRANSPARENT );
915*cdf0e10cSrcweir 		}
916*cdf0e10cSrcweir 		else
917*cdf0e10cSrcweir 		{
918*cdf0e10cSrcweir 			mpID->SetControlBackground( mpID->GetSettings().GetStyleSettings().GetHighlightColor() );
919*cdf0e10cSrcweir 			mpID->SetTextColor( mpID->GetSettings().GetStyleSettings().GetHighlightTextColor( ) );
920*cdf0e10cSrcweir 		}
921*cdf0e10cSrcweir 		mpDescription->ToggleBackgroundColor(_rGBColor);
922*cdf0e10cSrcweir 	}
923*cdf0e10cSrcweir 
924*cdf0e10cSrcweir     //---------------------------------------------------------------------
925*cdf0e10cSrcweir     void RoadmapItem::ImplUpdatePosSize()
926*cdf0e10cSrcweir     {
927*cdf0e10cSrcweir         // calculate widths
928*cdf0e10cSrcweir         long nIDWidth = mpID->GetTextWidth( mpID->GetText() );
929*cdf0e10cSrcweir 		long nMaxIDWidth = mpID->GetTextWidth( ::rtl::OUString::createFromAscii( "100." ) );
930*cdf0e10cSrcweir 		nIDWidth = ::std::min( nIDWidth, nMaxIDWidth );
931*cdf0e10cSrcweir 
932*cdf0e10cSrcweir         // check how many space the description would need
933*cdf0e10cSrcweir         Size aDescriptionSize = mpDescription->CalcMinimumSize( m_aItemPlayground.Width() - nIDWidth );
934*cdf0e10cSrcweir 
935*cdf0e10cSrcweir         // position and size both controls
936*cdf0e10cSrcweir         Size aIDSize( nIDWidth, aDescriptionSize.Height() );
937*cdf0e10cSrcweir  		mpID->SetSizePixel( aIDSize );
938*cdf0e10cSrcweir 
939*cdf0e10cSrcweir         Point aIDPos = mpID->GetPosPixel();
940*cdf0e10cSrcweir         mpDescription->SetPosPixel( Point( aIDPos.X() + nIDWidth, aIDPos.Y() ) );
941*cdf0e10cSrcweir         mpDescription->SetSizePixel( aDescriptionSize );
942*cdf0e10cSrcweir     }
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir     //---------------------------------------------------------------------
945*cdf0e10cSrcweir 	void RoadmapItem::Update( ItemIndex _RMIndex, const ::rtl::OUString& _rText )
946*cdf0e10cSrcweir 	{
947*cdf0e10cSrcweir         // update description label
948*cdf0e10cSrcweir         mpDescription->SetLabel( _rText );
949*cdf0e10cSrcweir 
950*cdf0e10cSrcweir         // update the index in both controls, which triggers updating the geometry of both
951*cdf0e10cSrcweir         ImplUpdateIndex( _RMIndex );
952*cdf0e10cSrcweir 	}
953*cdf0e10cSrcweir 
954*cdf0e10cSrcweir     //---------------------------------------------------------------------
955*cdf0e10cSrcweir 	RoadmapItem::~RoadmapItem( )
956*cdf0e10cSrcweir 	{
957*cdf0e10cSrcweir         {
958*cdf0e10cSrcweir             ::std::auto_ptr<Control> aTemp(mpID);
959*cdf0e10cSrcweir 		    mpID = NULL;
960*cdf0e10cSrcweir         }
961*cdf0e10cSrcweir         {
962*cdf0e10cSrcweir             ::std::auto_ptr<Control> aTemp(mpDescription);
963*cdf0e10cSrcweir 		    mpDescription = NULL;
964*cdf0e10cSrcweir         }
965*cdf0e10cSrcweir 	}
966*cdf0e10cSrcweir 
967*cdf0e10cSrcweir     //---------------------------------------------------------------------
968*cdf0e10cSrcweir 	void RoadmapItem::SetClickHdl( const Link& rLink )
969*cdf0e10cSrcweir 	{
970*cdf0e10cSrcweir         if ( mpDescription )
971*cdf0e10cSrcweir 		    mpDescription->SetClickHdl( rLink);
972*cdf0e10cSrcweir 	}
973*cdf0e10cSrcweir 
974*cdf0e10cSrcweir     //---------------------------------------------------------------------
975*cdf0e10cSrcweir 	const Link& RoadmapItem::GetClickHdl( ) const
976*cdf0e10cSrcweir 	{
977*cdf0e10cSrcweir 		return mpDescription->GetClickHdl();
978*cdf0e10cSrcweir 	}
979*cdf0e10cSrcweir 
980*cdf0e10cSrcweir 	//---------------------------------------------------------------------
981*cdf0e10cSrcweir     IDLabel::IDLabel( Window* _pParent, WinBits _nWinStyle )
982*cdf0e10cSrcweir 		:FixedText( _pParent, _nWinStyle )
983*cdf0e10cSrcweir 	{
984*cdf0e10cSrcweir 
985*cdf0e10cSrcweir 	}
986*cdf0e10cSrcweir 
987*cdf0e10cSrcweir 	//---------------------------------------------------------------------
988*cdf0e10cSrcweir 	IDLabel::~IDLabel( )
989*cdf0e10cSrcweir 	{
990*cdf0e10cSrcweir 	}
991*cdf0e10cSrcweir 
992*cdf0e10cSrcweir 	//---------------------------------------------------------------------
993*cdf0e10cSrcweir 	void IDLabel::DataChanged( const DataChangedEvent& rDCEvt )
994*cdf0e10cSrcweir 	{
995*cdf0e10cSrcweir 		const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
996*cdf0e10cSrcweir 		FixedText::DataChanged( rDCEvt );
997*cdf0e10cSrcweir 		if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS	)	||
998*cdf0e10cSrcweir 			( rDCEvt.GetType() == DATACHANGED_DISPLAY	))	&&
999*cdf0e10cSrcweir 			( rDCEvt.GetFlags() & SETTINGS_STYLE		))
1000*cdf0e10cSrcweir 		{
1001*cdf0e10cSrcweir 			const Color& rGBColor = GetControlBackground();
1002*cdf0e10cSrcweir 			if (rGBColor == COL_TRANSPARENT)
1003*cdf0e10cSrcweir 				SetTextColor( rStyleSettings.GetFieldTextColor( ) );
1004*cdf0e10cSrcweir 			else
1005*cdf0e10cSrcweir 			{
1006*cdf0e10cSrcweir 				SetControlBackground(rStyleSettings.GetHighlightColor());
1007*cdf0e10cSrcweir 				SetTextColor( rStyleSettings.GetHighlightTextColor( ) );
1008*cdf0e10cSrcweir 			}
1009*cdf0e10cSrcweir 			Invalidate();
1010*cdf0e10cSrcweir 		}
1011*cdf0e10cSrcweir 	}
1012*cdf0e10cSrcweir 
1013*cdf0e10cSrcweir 
1014*cdf0e10cSrcweir 
1015*cdf0e10cSrcweir 
1016*cdf0e10cSrcweir //.........................................................................
1017*cdf0e10cSrcweir }	// namespace svt
1018*cdf0e10cSrcweir //.........................................................................
1019