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