xref: /AOO41X/main/svtools/source/control/valueset.cxx (revision 2bfcd321e2172336182a43e6d401b533c4283ceb)
15900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35900e8ecSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45900e8ecSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55900e8ecSAndrew Rist  * distributed with this work for additional information
65900e8ecSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75900e8ecSAndrew Rist  * to you under the Apache License, Version 2.0 (the
85900e8ecSAndrew Rist  * "License"); you may not use this file except in compliance
95900e8ecSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
115900e8ecSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
135900e8ecSAndrew Rist  * Unless required by applicable law or agreed to in writing,
145900e8ecSAndrew Rist  * software distributed under the License is distributed on an
155900e8ecSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165900e8ecSAndrew Rist  * KIND, either express or implied.  See the License for the
175900e8ecSAndrew Rist  * specific language governing permissions and limitations
185900e8ecSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
205900e8ecSAndrew Rist  *************************************************************/
215900e8ecSAndrew Rist 
225900e8ecSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir #include <tools/list.hxx>
27cdf0e10cSrcweir #include <tools/debug.hxx>
28cdf0e10cSrcweir #include <vcl/decoview.hxx>
29cdf0e10cSrcweir #include <vcl/svapp.hxx>
30cdf0e10cSrcweir #ifndef _SCRBAR_HXX
31cdf0e10cSrcweir #include <vcl/scrbar.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _HELP_HXX
34cdf0e10cSrcweir #include <vcl/help.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
37cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
38cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
39cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
40cdf0e10cSrcweir #include <rtl/ustring.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #include "valueimp.hxx"
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #define _SV_VALUESET_CXX
45cdf0e10cSrcweir #include <svtools/valueset.hxx>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir // ------------
48cdf0e10cSrcweir // - ValueSet -
49cdf0e10cSrcweir // ------------
50cdf0e10cSrcweir 
51cdf0e10cSrcweir void ValueSet::ImplInit()
52cdf0e10cSrcweir {
53cdf0e10cSrcweir 	// Size aWinSize		= GetSizePixel();
54cdf0e10cSrcweir     mpImpl              = new ValueSet_Impl;
55cdf0e10cSrcweir 	mpNoneItem			= NULL;
56cdf0e10cSrcweir 	mpScrBar			= NULL;
57cdf0e10cSrcweir 	mnTextOffset		= 0;
58cdf0e10cSrcweir 	mnVisLines			= 0;
59cdf0e10cSrcweir 	mnLines 			= 0;
60cdf0e10cSrcweir 	mnUserItemWidth 	= 0;
61cdf0e10cSrcweir 	mnUserItemHeight	= 0;
62cdf0e10cSrcweir 	mnFirstLine 		= 0;
63cdf0e10cSrcweir 	mnOldItemId 		= 0;
64cdf0e10cSrcweir 	mnSelItemId 		= 0;
65cdf0e10cSrcweir 	mnHighItemId		= 0;
66cdf0e10cSrcweir 	mnDropPos			= VALUESET_ITEM_NOTFOUND;
67cdf0e10cSrcweir 	mnCols				= 0;
68cdf0e10cSrcweir 	mnCurCol			= 0;
69cdf0e10cSrcweir 	mnUserCols			= 0;
70cdf0e10cSrcweir 	mnUserVisLines		= 0;
71cdf0e10cSrcweir 	mnSpacing			= 0;
72cdf0e10cSrcweir 	mnFrameStyle		= 0;
73cdf0e10cSrcweir 	mbFormat			= sal_True;
74cdf0e10cSrcweir 	mbHighlight 		= sal_False ;
75cdf0e10cSrcweir 	mbSelection 		= sal_False;
76cdf0e10cSrcweir 	mbNoSelection		= sal_True;
77cdf0e10cSrcweir 	mbDrawSelection 	= sal_True;
78cdf0e10cSrcweir 	mbBlackSel			= sal_False;
79cdf0e10cSrcweir 	mbDoubleSel 		= sal_False;
80cdf0e10cSrcweir 	mbScroll			= sal_False;
81cdf0e10cSrcweir 	mbDropPos			= sal_False;
82cdf0e10cSrcweir 	mbFullMode			= sal_True;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     // #106446#, #106601# force mirroring of virtual device
85cdf0e10cSrcweir     maVirDev.EnableRTL( GetParent()->IsRTLEnabled() );
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	ImplInitSettings( sal_True, sal_True, sal_True );
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir // -----------------------------------------------------------------------
91cdf0e10cSrcweir 
92cdf0e10cSrcweir ValueSet::ValueSet( Window* pParent, WinBits nWinStyle, bool bDisableTransientChildren ) :
93cdf0e10cSrcweir 	Control( pParent, nWinStyle ),
94cdf0e10cSrcweir 	maVirDev( *this ),
95cdf0e10cSrcweir 	maColor( COL_TRANSPARENT )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir 	ImplInit();
98cdf0e10cSrcweir     if( mpImpl )
99cdf0e10cSrcweir         mpImpl->mbIsTransientChildrenDisabled = bDisableTransientChildren;
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir // -----------------------------------------------------------------------
103cdf0e10cSrcweir 
104cdf0e10cSrcweir ValueSet::ValueSet( Window* pParent, const ResId& rResId, bool bDisableTransientChildren ) :
105cdf0e10cSrcweir 	Control( pParent, rResId ),
106cdf0e10cSrcweir 	maVirDev( *this ),
107cdf0e10cSrcweir 	maColor( COL_TRANSPARENT )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir 	ImplInit();
110cdf0e10cSrcweir     if( mpImpl )
111cdf0e10cSrcweir         mpImpl->mbIsTransientChildrenDisabled = bDisableTransientChildren;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir // -----------------------------------------------------------------------
115cdf0e10cSrcweir 
116cdf0e10cSrcweir ValueSet::~ValueSet()
117cdf0e10cSrcweir {
118cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent>
119cdf0e10cSrcweir           xComponent (GetAccessible(sal_False), ::com::sun::star::uno::UNO_QUERY);
120cdf0e10cSrcweir     if (xComponent.is())
121cdf0e10cSrcweir         xComponent->dispose ();
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 	if ( mpScrBar )
124cdf0e10cSrcweir 		delete mpScrBar;
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	if ( mpNoneItem )
127cdf0e10cSrcweir 		delete mpNoneItem;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	ImplDeleteItems();
130cdf0e10cSrcweir     delete mpImpl;
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir // -----------------------------------------------------------------------
134cdf0e10cSrcweir 
135cdf0e10cSrcweir void ValueSet::ImplDeleteItems()
136cdf0e10cSrcweir {
137cdf0e10cSrcweir     for( ValueSetItem* pItem = mpImpl->mpItemList->First(); pItem; pItem = mpImpl->mpItemList->Next() )
138cdf0e10cSrcweir 	{
139cdf0e10cSrcweir         if( !pItem->maRect.IsEmpty() && ImplHasAccessibleListeners() )
140cdf0e10cSrcweir         {
141cdf0e10cSrcweir             ::com::sun::star::uno::Any aOldAny, aNewAny;
142cdf0e10cSrcweir 
143cdf0e10cSrcweir             aOldAny <<= pItem->GetAccessible( mpImpl->mbIsTransientChildrenDisabled );
144cdf0e10cSrcweir             ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
145cdf0e10cSrcweir         }
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 		delete pItem;
148cdf0e10cSrcweir 	}
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     mpImpl->mpItemList->Clear();
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir // -----------------------------------------------------------------------
154cdf0e10cSrcweir 
155cdf0e10cSrcweir void ValueSet::ImplInitSettings( sal_Bool bFont,
156cdf0e10cSrcweir 								 sal_Bool bForeground, sal_Bool bBackground )
157cdf0e10cSrcweir {
158cdf0e10cSrcweir 	const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 	if ( bFont )
161cdf0e10cSrcweir 	{
162cdf0e10cSrcweir 		Font aFont;
163cdf0e10cSrcweir 		aFont = rStyleSettings.GetAppFont();
164cdf0e10cSrcweir 		if ( IsControlFont() )
165cdf0e10cSrcweir 			aFont.Merge( GetControlFont() );
166cdf0e10cSrcweir 		SetZoomedPointFont( aFont );
167cdf0e10cSrcweir 	}
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	if ( bForeground || bFont )
170cdf0e10cSrcweir 	{
171cdf0e10cSrcweir 		Color aColor;
172cdf0e10cSrcweir 		if ( IsControlForeground() )
173cdf0e10cSrcweir 			aColor = GetControlForeground();
174cdf0e10cSrcweir 		else
175cdf0e10cSrcweir 			aColor = rStyleSettings.GetButtonTextColor();
176cdf0e10cSrcweir 		SetTextColor( aColor );
177cdf0e10cSrcweir 		SetTextFillColor();
178cdf0e10cSrcweir 	}
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	if ( bBackground )
181cdf0e10cSrcweir 	{
182cdf0e10cSrcweir 		Color aColor;
183cdf0e10cSrcweir 		if ( IsControlBackground() )
184cdf0e10cSrcweir 			aColor = GetControlBackground();
185cdf0e10cSrcweir         else if ( GetStyle() & WB_MENUSTYLEVALUESET )
186cdf0e10cSrcweir             aColor = rStyleSettings.GetMenuColor();
187cdf0e10cSrcweir         else if ( IsEnabled() && (GetStyle() & WB_FLATVALUESET) )
188cdf0e10cSrcweir             aColor = rStyleSettings.GetWindowColor();
189cdf0e10cSrcweir 		else
190cdf0e10cSrcweir 			aColor = rStyleSettings.GetFaceColor();
191cdf0e10cSrcweir 		SetBackground( aColor );
192cdf0e10cSrcweir 	}
193cdf0e10cSrcweir }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir // -----------------------------------------------------------------------
196cdf0e10cSrcweir 
197cdf0e10cSrcweir void ValueSet::ImplInitScrollBar()
198cdf0e10cSrcweir {
199cdf0e10cSrcweir 	if ( GetStyle() & WB_VSCROLL )
200cdf0e10cSrcweir 	{
201cdf0e10cSrcweir 		if ( !mpScrBar )
202cdf0e10cSrcweir 		{
203cdf0e10cSrcweir 			mpScrBar = new ScrollBar( this, WB_VSCROLL | WB_DRAG );
204cdf0e10cSrcweir 			mpScrBar->SetScrollHdl( LINK( this, ValueSet, ImplScrollHdl ) );
205cdf0e10cSrcweir 		}
206cdf0e10cSrcweir 		else
207cdf0e10cSrcweir 		{
208cdf0e10cSrcweir 			// Wegen Einstellungsaenderungen passen wir hier die Breite an
209cdf0e10cSrcweir 			long nScrBarWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
210cdf0e10cSrcweir 			mpScrBar->SetPosSizePixel( 0, 0, nScrBarWidth, 0, WINDOW_POSSIZE_WIDTH );
211cdf0e10cSrcweir 		}
212cdf0e10cSrcweir 	}
213cdf0e10cSrcweir }
214cdf0e10cSrcweir 
215cdf0e10cSrcweir // -----------------------------------------------------------------------
216cdf0e10cSrcweir 
217cdf0e10cSrcweir void ValueSet::ImplFormatItem( ValueSetItem* pItem )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir 	if ( pItem->meType == VALUESETITEM_SPACE )
220cdf0e10cSrcweir 		return;
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 	Rectangle aRect = pItem->maRect;
223cdf0e10cSrcweir 	WinBits nStyle = GetStyle();
224cdf0e10cSrcweir 	if ( nStyle & WB_ITEMBORDER )
225cdf0e10cSrcweir 	{
226cdf0e10cSrcweir 		aRect.Left()++;
227cdf0e10cSrcweir 		aRect.Top()++;
228cdf0e10cSrcweir 		aRect.Right()--;
229cdf0e10cSrcweir 		aRect.Bottom()--;
230cdf0e10cSrcweir 		if ( nStyle & WB_FLATVALUESET )
231cdf0e10cSrcweir 		{
232cdf0e10cSrcweir 			if ( nStyle  & WB_DOUBLEBORDER )
233cdf0e10cSrcweir 			{
234cdf0e10cSrcweir 				aRect.Left()	+= 2;
235cdf0e10cSrcweir 				aRect.Top() 	+= 2;
236cdf0e10cSrcweir 				aRect.Right()	-= 2;
237cdf0e10cSrcweir 				aRect.Bottom()	-= 2;
238cdf0e10cSrcweir 			}
239cdf0e10cSrcweir 			else
240cdf0e10cSrcweir 			{
241cdf0e10cSrcweir 				aRect.Left()++;
242cdf0e10cSrcweir 				aRect.Top()++;
243cdf0e10cSrcweir 				aRect.Right()--;
244cdf0e10cSrcweir 				aRect.Bottom()--;
245cdf0e10cSrcweir 			}
246cdf0e10cSrcweir 		}
247cdf0e10cSrcweir 		else
248cdf0e10cSrcweir 		{
249cdf0e10cSrcweir 			DecorationView aView( &maVirDev );
250cdf0e10cSrcweir 			aRect = aView.DrawFrame( aRect, mnFrameStyle );
251cdf0e10cSrcweir 		}
252cdf0e10cSrcweir 	}
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 	if ( pItem == mpNoneItem )
255cdf0e10cSrcweir 		pItem->maText = GetText();
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 	if ( (aRect.GetHeight() > 0) && (aRect.GetWidth() > 0) )
258cdf0e10cSrcweir 	{
259cdf0e10cSrcweir 		if ( pItem == mpNoneItem )
260cdf0e10cSrcweir 		{
261cdf0e10cSrcweir 			const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
262cdf0e10cSrcweir 			maVirDev.SetFont( GetFont() );
263cdf0e10cSrcweir 			maVirDev.SetTextColor( ( nStyle & WB_MENUSTYLEVALUESET ) ? rStyleSettings.GetMenuTextColor() : rStyleSettings.GetWindowTextColor() );
264cdf0e10cSrcweir 			maVirDev.SetTextFillColor();
265cdf0e10cSrcweir 			maVirDev.SetFillColor( ( nStyle & WB_MENUSTYLEVALUESET ) ? rStyleSettings.GetMenuColor() : rStyleSettings.GetWindowColor() );
266cdf0e10cSrcweir 			maVirDev.DrawRect( aRect );
267cdf0e10cSrcweir 			Point	aTxtPos( aRect.Left()+2, aRect.Top() );
268cdf0e10cSrcweir 			long	nTxtWidth = GetTextWidth( pItem->maText );
269cdf0e10cSrcweir 			if ( nStyle & WB_RADIOSEL )
270cdf0e10cSrcweir 			{
271cdf0e10cSrcweir 				aTxtPos.X() += 4;
272cdf0e10cSrcweir 				aTxtPos.Y() += 4;
273cdf0e10cSrcweir 			}
274cdf0e10cSrcweir 			if ( (aTxtPos.X()+nTxtWidth) > aRect.Right() )
275cdf0e10cSrcweir 			{
276cdf0e10cSrcweir 				maVirDev.SetClipRegion( Region( aRect ) );
277cdf0e10cSrcweir 				maVirDev.DrawText( aTxtPos, pItem->maText );
278cdf0e10cSrcweir 				maVirDev.SetClipRegion();
279cdf0e10cSrcweir 			}
280cdf0e10cSrcweir 			else
281cdf0e10cSrcweir 				maVirDev.DrawText( aTxtPos, pItem->maText );
282cdf0e10cSrcweir 		}
283cdf0e10cSrcweir 		else if ( pItem->meType == VALUESETITEM_COLOR )
284cdf0e10cSrcweir 		{
285cdf0e10cSrcweir 			maVirDev.SetFillColor( pItem->maColor );
286cdf0e10cSrcweir 			maVirDev.DrawRect( aRect );
287cdf0e10cSrcweir 		}
288cdf0e10cSrcweir 		else
289cdf0e10cSrcweir 		{
290cdf0e10cSrcweir 			const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
291cdf0e10cSrcweir 			if ( IsColor() )
292cdf0e10cSrcweir 				maVirDev.SetFillColor( maColor );
293cdf0e10cSrcweir             else if ( nStyle & WB_MENUSTYLEVALUESET )
294cdf0e10cSrcweir                 maVirDev.SetFillColor( rStyleSettings.GetMenuColor() );
295cdf0e10cSrcweir             else if ( IsEnabled() )
296cdf0e10cSrcweir                 maVirDev.SetFillColor( rStyleSettings.GetWindowColor() );
297cdf0e10cSrcweir             else
298cdf0e10cSrcweir                 maVirDev.SetFillColor( rStyleSettings.GetFaceColor() );
299cdf0e10cSrcweir 			maVirDev.DrawRect( aRect );
300cdf0e10cSrcweir 
301cdf0e10cSrcweir 			if ( pItem->meType == VALUESETITEM_USERDRAW )
302cdf0e10cSrcweir 			{
303cdf0e10cSrcweir 				UserDrawEvent aUDEvt( &maVirDev, aRect, pItem->mnId );
304cdf0e10cSrcweir 				UserDraw( aUDEvt );
305cdf0e10cSrcweir 			}
306cdf0e10cSrcweir 			else
307cdf0e10cSrcweir 			{
308cdf0e10cSrcweir 				Size	aImageSize = pItem->maImage.GetSizePixel();
309cdf0e10cSrcweir 				Size	aRectSize = aRect.GetSize();
310cdf0e10cSrcweir 				Point	aPos( aRect.Left(), aRect.Top() );
311cdf0e10cSrcweir 				aPos.X() += (aRectSize.Width()-aImageSize.Width())/2;
312cdf0e10cSrcweir 				aPos.Y() += (aRectSize.Height()-aImageSize.Height())/2;
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 			    sal_uInt16  nImageStyle  = 0;
315cdf0e10cSrcweir                 if( !IsEnabled() )
316cdf0e10cSrcweir 					nImageStyle  |= IMAGE_DRAW_DISABLE;
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 				if ( (aImageSize.Width()  > aRectSize.Width()) ||
319cdf0e10cSrcweir 					 (aImageSize.Height() > aRectSize.Height()) )
320cdf0e10cSrcweir 				{
321cdf0e10cSrcweir 					maVirDev.SetClipRegion( Region( aRect ) );
322cdf0e10cSrcweir 					maVirDev.DrawImage( aPos, pItem->maImage, nImageStyle);
323cdf0e10cSrcweir 					maVirDev.SetClipRegion();
324cdf0e10cSrcweir 				}
325cdf0e10cSrcweir 				else
326cdf0e10cSrcweir 					maVirDev.DrawImage( aPos, pItem->maImage, nImageStyle );
327cdf0e10cSrcweir 			}
328cdf0e10cSrcweir 		}
329cdf0e10cSrcweir 	}
330cdf0e10cSrcweir }
331cdf0e10cSrcweir 
332cdf0e10cSrcweir // -----------------------------------------------------------------------
333cdf0e10cSrcweir 
334cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ValueSet::CreateAccessible()
335cdf0e10cSrcweir {
336cdf0e10cSrcweir     return new ValueSetAcc( this, mpImpl->mbIsTransientChildrenDisabled );
337cdf0e10cSrcweir }
338cdf0e10cSrcweir 
339cdf0e10cSrcweir // -----------------------------------------------------------------------
340cdf0e10cSrcweir 
341cdf0e10cSrcweir void ValueSet::Format()
342cdf0e10cSrcweir {
343cdf0e10cSrcweir 	Size		aWinSize = GetOutputSizePixel();
344cdf0e10cSrcweir     sal_uLong       nItemCount = mpImpl->mpItemList->Count();
345cdf0e10cSrcweir 	WinBits 	nStyle = GetStyle();
346cdf0e10cSrcweir 	long		nTxtHeight = GetTextHeight();
347cdf0e10cSrcweir 	long		nOff;
348cdf0e10cSrcweir 	long		nSpace;
349cdf0e10cSrcweir 	long		nNoneHeight;
350cdf0e10cSrcweir 	long		nNoneSpace;
351cdf0e10cSrcweir 	ScrollBar*	pDelScrBar = NULL;
352cdf0e10cSrcweir 
353cdf0e10cSrcweir 	// Scrolling beruecksichtigen
354cdf0e10cSrcweir 	if ( nStyle & WB_VSCROLL )
355cdf0e10cSrcweir 		ImplInitScrollBar();
356cdf0e10cSrcweir 	else
357cdf0e10cSrcweir 	{
358cdf0e10cSrcweir 		if ( mpScrBar )
359cdf0e10cSrcweir 		{
360cdf0e10cSrcweir 			// ScrollBar erst spaeter zerstoeren, damit keine rekursiven
361cdf0e10cSrcweir 			// Aufrufe entstehen koennen
362cdf0e10cSrcweir 			pDelScrBar = mpScrBar;
363cdf0e10cSrcweir 			mpScrBar = NULL;
364cdf0e10cSrcweir 		}
365cdf0e10cSrcweir 	}
366cdf0e10cSrcweir 
367cdf0e10cSrcweir 	// Item-Offset berechnen
368cdf0e10cSrcweir 	if ( nStyle & WB_ITEMBORDER )
369cdf0e10cSrcweir 	{
370cdf0e10cSrcweir 		if ( nStyle & WB_DOUBLEBORDER )
371cdf0e10cSrcweir 			nOff = ITEM_OFFSET_DOUBLE;
372cdf0e10cSrcweir 		else
373cdf0e10cSrcweir 			nOff = ITEM_OFFSET;
374cdf0e10cSrcweir 	}
375cdf0e10cSrcweir 	else
376cdf0e10cSrcweir 		nOff = 0;
377cdf0e10cSrcweir 	nSpace = mnSpacing;
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 	// Groesse beruecksichtigen, wenn NameField vorhanden
380cdf0e10cSrcweir 	if ( nStyle & WB_NAMEFIELD )
381cdf0e10cSrcweir 	{
382cdf0e10cSrcweir 		mnTextOffset = aWinSize.Height()-nTxtHeight-NAME_OFFSET;
383cdf0e10cSrcweir 		aWinSize.Height() -= nTxtHeight+NAME_OFFSET;
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 		if ( !(nStyle & WB_FLATVALUESET) )
386cdf0e10cSrcweir 		{
387cdf0e10cSrcweir 			mnTextOffset -= NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
388cdf0e10cSrcweir 			aWinSize.Height() -= NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
389cdf0e10cSrcweir 		}
390cdf0e10cSrcweir 	}
391cdf0e10cSrcweir 	else
392cdf0e10cSrcweir 		mnTextOffset = 0;
393cdf0e10cSrcweir 
394cdf0e10cSrcweir 	// Offset und Groesse beruecksichtigen, wenn NoneField vorhanden
395cdf0e10cSrcweir 	if ( nStyle & WB_NONEFIELD )
396cdf0e10cSrcweir 	{
397cdf0e10cSrcweir 		nNoneHeight = nTxtHeight+nOff;
398cdf0e10cSrcweir 		nNoneSpace = nSpace;
399cdf0e10cSrcweir 		if ( nStyle & WB_RADIOSEL )
400cdf0e10cSrcweir 			nNoneHeight += 8;
401cdf0e10cSrcweir 	}
402cdf0e10cSrcweir 	else
403cdf0e10cSrcweir 	{
404cdf0e10cSrcweir 		nNoneHeight = 0;
405cdf0e10cSrcweir 		nNoneSpace = 0;
406cdf0e10cSrcweir 
407cdf0e10cSrcweir 		if ( mpNoneItem )
408cdf0e10cSrcweir 		{
409cdf0e10cSrcweir 			delete mpNoneItem;
410cdf0e10cSrcweir 			mpNoneItem = NULL;
411cdf0e10cSrcweir 		}
412cdf0e10cSrcweir 	}
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 	// Breite vom ScrollBar berechnen
415cdf0e10cSrcweir 	long nScrBarWidth = 0;
416cdf0e10cSrcweir 	if ( mpScrBar )
417cdf0e10cSrcweir 		nScrBarWidth = mpScrBar->GetSizePixel().Width()+SCRBAR_OFFSET;
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 	// Spaltenanzahl berechnen
420cdf0e10cSrcweir 	if ( !mnUserCols )
421cdf0e10cSrcweir 	{
422cdf0e10cSrcweir 		if ( mnUserItemWidth )
423cdf0e10cSrcweir 		{
424cdf0e10cSrcweir 			mnCols = (sal_uInt16)((aWinSize.Width()-nScrBarWidth+nSpace) / (mnUserItemWidth+nSpace));
425cdf0e10cSrcweir 			if ( !mnCols )
426cdf0e10cSrcweir 				mnCols = 1;
427cdf0e10cSrcweir 		}
428cdf0e10cSrcweir 		else
429cdf0e10cSrcweir 			mnCols = 1;
430cdf0e10cSrcweir 	}
431cdf0e10cSrcweir 	else
432cdf0e10cSrcweir 		mnCols = mnUserCols;
433cdf0e10cSrcweir 
434cdf0e10cSrcweir 	// Zeilenanzahl berechnen
435cdf0e10cSrcweir 	mbScroll = sal_False;
436cdf0e10cSrcweir     mnLines = (long)mpImpl->mpItemList->Count() / mnCols;
437cdf0e10cSrcweir     if ( mpImpl->mpItemList->Count() % mnCols )
438cdf0e10cSrcweir 		mnLines++;
439cdf0e10cSrcweir 	else if ( !mnLines )
440cdf0e10cSrcweir 		mnLines = 1;
441cdf0e10cSrcweir 
442cdf0e10cSrcweir 	long nCalcHeight = aWinSize.Height()-nNoneHeight;
443cdf0e10cSrcweir 	if ( mnUserVisLines )
444cdf0e10cSrcweir 		mnVisLines = mnUserVisLines;
445cdf0e10cSrcweir 	else if ( mnUserItemHeight )
446cdf0e10cSrcweir 	{
447cdf0e10cSrcweir 		mnVisLines = (nCalcHeight-nNoneSpace+nSpace) / (mnUserItemHeight+nSpace);
448cdf0e10cSrcweir 		if ( !mnVisLines )
449cdf0e10cSrcweir 			mnVisLines = 1;
450cdf0e10cSrcweir 	}
451cdf0e10cSrcweir 	else
452cdf0e10cSrcweir 		mnVisLines = mnLines;
453cdf0e10cSrcweir 	if ( mnLines > mnVisLines )
454cdf0e10cSrcweir 		mbScroll = sal_True;
455cdf0e10cSrcweir 	if ( mnLines <= mnVisLines )
456cdf0e10cSrcweir 		mnFirstLine = 0;
457cdf0e10cSrcweir 	else
458cdf0e10cSrcweir 	{
459cdf0e10cSrcweir 		if ( mnFirstLine > (sal_uInt16)(mnLines-mnVisLines) )
460cdf0e10cSrcweir 			mnFirstLine = (sal_uInt16)(mnLines-mnVisLines);
461cdf0e10cSrcweir 	}
462cdf0e10cSrcweir 
463cdf0e10cSrcweir 	// Itemgroessen berechnen
464cdf0e10cSrcweir 	long nColSpace	= (mnCols-1)*nSpace;
465cdf0e10cSrcweir 	long nLineSpace = ((mnVisLines-1)*nSpace)+nNoneSpace;
466cdf0e10cSrcweir 	long nItemWidth;
467cdf0e10cSrcweir 	long nItemHeight;
468cdf0e10cSrcweir 	if ( mnUserItemWidth && !mnUserCols )
469cdf0e10cSrcweir 	{
470cdf0e10cSrcweir 		nItemWidth = mnUserItemWidth;
471cdf0e10cSrcweir 		if ( nItemWidth > aWinSize.Width()-nScrBarWidth-nColSpace )
472cdf0e10cSrcweir 			nItemWidth = aWinSize.Width()-nScrBarWidth-nColSpace;
473cdf0e10cSrcweir 	}
474cdf0e10cSrcweir 	else
475cdf0e10cSrcweir 		nItemWidth = (aWinSize.Width()-nScrBarWidth-nColSpace) / mnCols;
476cdf0e10cSrcweir 	if ( mnUserItemHeight && !mnUserVisLines )
477cdf0e10cSrcweir 	{
478cdf0e10cSrcweir 		nItemHeight = mnUserItemHeight;
479cdf0e10cSrcweir 		if ( nItemHeight > nCalcHeight-nNoneSpace )
480cdf0e10cSrcweir 			nItemHeight = nCalcHeight-nNoneSpace;
481cdf0e10cSrcweir 	}
482cdf0e10cSrcweir 	else
483cdf0e10cSrcweir 	{
484cdf0e10cSrcweir 		nCalcHeight -= nLineSpace;
485cdf0e10cSrcweir 		nItemHeight = nCalcHeight / mnVisLines;
486cdf0e10cSrcweir 	}
487cdf0e10cSrcweir 
488cdf0e10cSrcweir 	// Init VirDev
489cdf0e10cSrcweir 	maVirDev.SetSettings( GetSettings() );
490cdf0e10cSrcweir 	maVirDev.SetBackground( GetBackground() );
491cdf0e10cSrcweir 	maVirDev.SetOutputSizePixel( aWinSize, sal_True );
492cdf0e10cSrcweir 
493cdf0e10cSrcweir 	// Bei zu kleinen Items machen wir nichts
494cdf0e10cSrcweir 	long nMinHeight = 2;
495cdf0e10cSrcweir 	if ( nStyle & WB_ITEMBORDER )
496cdf0e10cSrcweir 		nMinHeight = 4;
497cdf0e10cSrcweir 	if ( (nItemWidth <= 0) || (nItemHeight <= nMinHeight) || !nItemCount )
498cdf0e10cSrcweir 	{
499cdf0e10cSrcweir 		if ( nStyle & WB_NONEFIELD )
500cdf0e10cSrcweir 		{
501cdf0e10cSrcweir 			if ( mpNoneItem )
502cdf0e10cSrcweir 			{
503cdf0e10cSrcweir 				mpNoneItem->maRect.SetEmpty();
504cdf0e10cSrcweir 				mpNoneItem->maText = GetText();
505cdf0e10cSrcweir 			}
506cdf0e10cSrcweir 		}
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 		for ( sal_uLong i = 0; i < nItemCount; i++ )
509cdf0e10cSrcweir 		{
510cdf0e10cSrcweir             ValueSetItem* pItem = mpImpl->mpItemList->GetObject( i );
511cdf0e10cSrcweir 			pItem->maRect.SetEmpty();
512cdf0e10cSrcweir 		}
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 		if ( mpScrBar )
515cdf0e10cSrcweir 			mpScrBar->Hide();
516cdf0e10cSrcweir 	}
517cdf0e10cSrcweir 	else
518cdf0e10cSrcweir 	{
519cdf0e10cSrcweir 		// Frame-Style ermitteln
520cdf0e10cSrcweir 		if ( nStyle & WB_DOUBLEBORDER )
521cdf0e10cSrcweir 			mnFrameStyle = FRAME_DRAW_DOUBLEIN;
522cdf0e10cSrcweir 		else
523cdf0e10cSrcweir 			mnFrameStyle = FRAME_DRAW_IN;
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 		// Selektionsfarben und -breiten ermitteln
526cdf0e10cSrcweir 		// Gegebenenfalls die Farben anpassen, damit man die Selektion besser
527cdf0e10cSrcweir 		// erkennen kann
528cdf0e10cSrcweir 		const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
529cdf0e10cSrcweir 		Color aHighColor( rStyleSettings.GetHighlightColor() );
530cdf0e10cSrcweir 		if ( ((aHighColor.GetRed() > 0x80) || (aHighColor.GetGreen() > 0x80) ||
531cdf0e10cSrcweir 			  (aHighColor.GetBlue() > 0x80)) ||
532cdf0e10cSrcweir 			 ((aHighColor.GetRed() == 0x80) && (aHighColor.GetGreen() == 0x80) &&
533cdf0e10cSrcweir 			  (aHighColor.GetBlue() == 0x80)) )
534cdf0e10cSrcweir 			mbBlackSel = sal_True;
535cdf0e10cSrcweir 		else
536cdf0e10cSrcweir 			mbBlackSel = sal_False;
537cdf0e10cSrcweir 
538cdf0e10cSrcweir 		// Wenn die Items groesser sind, dann die Selektion doppelt so breit
539cdf0e10cSrcweir 		// zeichnen
540cdf0e10cSrcweir 		if ( (nStyle & WB_DOUBLEBORDER) &&
541cdf0e10cSrcweir 			 ((nItemWidth >= 25) && (nItemHeight >= 20)) )
542cdf0e10cSrcweir 			mbDoubleSel = sal_True;
543cdf0e10cSrcweir 		else
544cdf0e10cSrcweir 			mbDoubleSel = sal_False;
545cdf0e10cSrcweir 
546cdf0e10cSrcweir 		// Calculate offsets
547cdf0e10cSrcweir 		long nStartX;
548cdf0e10cSrcweir 		long nStartY;
549cdf0e10cSrcweir 		if ( mbFullMode )
550cdf0e10cSrcweir 		{
551cdf0e10cSrcweir 			long nAllItemWidth = (nItemWidth*mnCols)+nColSpace;
552cdf0e10cSrcweir 			long nAllItemHeight = (nItemHeight*mnVisLines)+nNoneHeight+nLineSpace;
553cdf0e10cSrcweir 			nStartX = (aWinSize.Width()-nScrBarWidth-nAllItemWidth)/2;
554cdf0e10cSrcweir 			nStartY = (aWinSize.Height()-nAllItemHeight)/2;
555cdf0e10cSrcweir 		}
556cdf0e10cSrcweir 		else
557cdf0e10cSrcweir 		{
558cdf0e10cSrcweir 			nStartX = 0;
559cdf0e10cSrcweir 			nStartY = 0;
560cdf0e10cSrcweir 		}
561cdf0e10cSrcweir 
562cdf0e10cSrcweir 		// Items berechnen und zeichnen
563cdf0e10cSrcweir 		maVirDev.SetLineColor();
564cdf0e10cSrcweir 		long x = nStartX;
565cdf0e10cSrcweir 		long y = nStartY;
566cdf0e10cSrcweir 
567cdf0e10cSrcweir 		// NoSelection-Field erzeugen und anzeigen
568cdf0e10cSrcweir 		if ( nStyle & WB_NONEFIELD )
569cdf0e10cSrcweir 		{
570cdf0e10cSrcweir 			if ( !mpNoneItem )
571cdf0e10cSrcweir 				mpNoneItem = new ValueSetItem( *this );
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 			mpNoneItem->mnId			= 0;
574cdf0e10cSrcweir 			mpNoneItem->meType			= VALUESETITEM_NONE;
575cdf0e10cSrcweir 			mpNoneItem->maRect.Left()	= x;
576cdf0e10cSrcweir 			mpNoneItem->maRect.Top()	= y;
577cdf0e10cSrcweir 			mpNoneItem->maRect.Right()	= mpNoneItem->maRect.Left()+aWinSize.Width()-x-1;
578cdf0e10cSrcweir 			mpNoneItem->maRect.Bottom() = y+nNoneHeight-1;
579cdf0e10cSrcweir 
580cdf0e10cSrcweir 			ImplFormatItem( mpNoneItem );
581cdf0e10cSrcweir 
582cdf0e10cSrcweir 			y += nNoneHeight+nNoneSpace;
583cdf0e10cSrcweir 		}
584cdf0e10cSrcweir 
585cdf0e10cSrcweir 		// draw items
586cdf0e10cSrcweir 		sal_uLong nFirstItem = mnFirstLine * mnCols;
587cdf0e10cSrcweir 		sal_uLong nLastItem = nFirstItem + (mnVisLines * mnCols);
588cdf0e10cSrcweir 
589cdf0e10cSrcweir         if ( !mbFullMode )
590cdf0e10cSrcweir 		{
591cdf0e10cSrcweir 			// If want also draw parts of items in the last line,
592cdf0e10cSrcweir 			// then we add one more line if parts of these line are
593cdf0e10cSrcweir 			// visible
594cdf0e10cSrcweir 			if ( y+(mnVisLines*(nItemHeight+nSpace)) < aWinSize.Height() )
595cdf0e10cSrcweir 				nLastItem += mnCols;
596cdf0e10cSrcweir 		}
597cdf0e10cSrcweir 		for ( sal_uLong i = 0; i < nItemCount; i++ )
598cdf0e10cSrcweir 		{
599cdf0e10cSrcweir             ValueSetItem*   pItem = mpImpl->mpItemList->GetObject( i );
600cdf0e10cSrcweir 
601cdf0e10cSrcweir 			if ( (i >= nFirstItem) && (i < nLastItem) )
602cdf0e10cSrcweir 			{
603cdf0e10cSrcweir                 const sal_Bool bWasEmpty = pItem->maRect.IsEmpty();
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 				pItem->maRect.Left()	= x;
606cdf0e10cSrcweir 				pItem->maRect.Top() 	= y;
607cdf0e10cSrcweir 				pItem->maRect.Right()	= pItem->maRect.Left()+nItemWidth-1;
608cdf0e10cSrcweir 				pItem->maRect.Bottom()	= pItem->maRect.Top()+nItemHeight-1;
609cdf0e10cSrcweir 
610cdf0e10cSrcweir                 if( bWasEmpty && ImplHasAccessibleListeners() )
611cdf0e10cSrcweir                 {
612cdf0e10cSrcweir                     ::com::sun::star::uno::Any aOldAny, aNewAny;
613cdf0e10cSrcweir 
614cdf0e10cSrcweir                     aNewAny <<= pItem->GetAccessible( mpImpl->mbIsTransientChildrenDisabled );
615cdf0e10cSrcweir                     ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
616cdf0e10cSrcweir                 }
617cdf0e10cSrcweir 
618cdf0e10cSrcweir 				ImplFormatItem( pItem );
619cdf0e10cSrcweir 
620cdf0e10cSrcweir 				if ( !((i+1) % mnCols) )
621cdf0e10cSrcweir 				{
622cdf0e10cSrcweir 					x = nStartX;
623cdf0e10cSrcweir 					y += nItemHeight+nSpace;
624cdf0e10cSrcweir 				}
625cdf0e10cSrcweir 				else
626cdf0e10cSrcweir 					x += nItemWidth+nSpace;
627cdf0e10cSrcweir 			}
628cdf0e10cSrcweir 			else
629cdf0e10cSrcweir             {
630cdf0e10cSrcweir                 if( !pItem->maRect.IsEmpty() && ImplHasAccessibleListeners() )
631cdf0e10cSrcweir                 {
632cdf0e10cSrcweir                     ::com::sun::star::uno::Any aOldAny, aNewAny;
633cdf0e10cSrcweir 
634cdf0e10cSrcweir                     aOldAny <<= pItem->GetAccessible( mpImpl->mbIsTransientChildrenDisabled );
635cdf0e10cSrcweir                     ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
636cdf0e10cSrcweir                 }
637cdf0e10cSrcweir 
638cdf0e10cSrcweir                 pItem->maRect.SetEmpty();
639cdf0e10cSrcweir             }
640cdf0e10cSrcweir 		}
641cdf0e10cSrcweir 
642cdf0e10cSrcweir 		// ScrollBar anordnen, Werte setzen und anzeigen
643cdf0e10cSrcweir 		if ( mpScrBar )
644cdf0e10cSrcweir 		{
645cdf0e10cSrcweir 			Point	aPos( aWinSize.Width()-nScrBarWidth+SCRBAR_OFFSET, 0 );
646cdf0e10cSrcweir 			Size	aSize( nScrBarWidth-SCRBAR_OFFSET, aWinSize.Height() );
647cdf0e10cSrcweir 			// If a none field is visible, then we center the scrollbar
648cdf0e10cSrcweir 			if ( nStyle & WB_NONEFIELD )
649cdf0e10cSrcweir 			{
650cdf0e10cSrcweir 				aPos.Y() = nStartY+nNoneHeight+1;
651cdf0e10cSrcweir 				aSize.Height() = ((nItemHeight+nSpace)*mnVisLines)-2-nSpace;
652cdf0e10cSrcweir 			}
653cdf0e10cSrcweir 			mpScrBar->SetPosSizePixel( aPos, aSize );
654cdf0e10cSrcweir 			mpScrBar->SetRangeMax( mnLines );
655cdf0e10cSrcweir 			mpScrBar->SetVisibleSize( mnVisLines );
656cdf0e10cSrcweir 			mpScrBar->SetThumbPos( (long)mnFirstLine );
657cdf0e10cSrcweir 			long nPageSize = mnVisLines;
658cdf0e10cSrcweir 			if ( nPageSize < 1 )
659cdf0e10cSrcweir 				nPageSize = 1;
660cdf0e10cSrcweir 			mpScrBar->SetPageSize( nPageSize );
661cdf0e10cSrcweir 			mpScrBar->Show();
662cdf0e10cSrcweir 		}
663cdf0e10cSrcweir 	}
664cdf0e10cSrcweir 
665cdf0e10cSrcweir 	// Jetzt haben wir formatiert und warten auf das naechste
666cdf0e10cSrcweir 	mbFormat = sal_False;
667cdf0e10cSrcweir 
668cdf0e10cSrcweir 	// ScrollBar loeschen
669cdf0e10cSrcweir 	if ( pDelScrBar )
670cdf0e10cSrcweir 		delete pDelScrBar;
671cdf0e10cSrcweir }
672cdf0e10cSrcweir 
673cdf0e10cSrcweir // -----------------------------------------------------------------------
674cdf0e10cSrcweir 
675cdf0e10cSrcweir void ValueSet::ImplDrawItemText( const XubString& rText )
676cdf0e10cSrcweir {
677cdf0e10cSrcweir 	if ( !(GetStyle() & WB_NAMEFIELD) )
678cdf0e10cSrcweir 		return;
679cdf0e10cSrcweir 
680cdf0e10cSrcweir 	Size	aWinSize = GetOutputSizePixel();
681cdf0e10cSrcweir 	long	nTxtWidth = GetTextWidth( rText );
682cdf0e10cSrcweir 	long	nTxtOffset = mnTextOffset;
683cdf0e10cSrcweir 
684cdf0e10cSrcweir 	// Rechteck loeschen und Text ausgeben
685cdf0e10cSrcweir 	if ( GetStyle() & WB_FLATVALUESET )
686cdf0e10cSrcweir 	{
687cdf0e10cSrcweir 		const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
688cdf0e10cSrcweir 		SetLineColor();
689cdf0e10cSrcweir 		SetFillColor( rStyleSettings.GetFaceColor() );
690cdf0e10cSrcweir 		DrawRect( Rectangle( Point( 0, nTxtOffset ), Point( aWinSize.Width(), aWinSize.Height() ) ) );
691cdf0e10cSrcweir 		SetTextColor( rStyleSettings.GetButtonTextColor() );
692cdf0e10cSrcweir 	}
693cdf0e10cSrcweir 	else
694cdf0e10cSrcweir 	{
695cdf0e10cSrcweir 		nTxtOffset += NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
696cdf0e10cSrcweir 		Erase( Rectangle( Point( 0, nTxtOffset ), Point( aWinSize.Width(), aWinSize.Height() ) ) );
697cdf0e10cSrcweir 	}
698cdf0e10cSrcweir 	DrawText( Point( (aWinSize.Width()-nTxtWidth) / 2, nTxtOffset+(NAME_OFFSET/2) ), rText );
699cdf0e10cSrcweir }
700cdf0e10cSrcweir 
701cdf0e10cSrcweir // -----------------------------------------------------------------------
702cdf0e10cSrcweir 
703cdf0e10cSrcweir void ValueSet::ImplDrawSelect()
704cdf0e10cSrcweir {
705cdf0e10cSrcweir 	if ( !IsReallyVisible() )
706cdf0e10cSrcweir 		return;
707cdf0e10cSrcweir 
708cdf0e10cSrcweir 	sal_Bool bFocus = HasFocus();
709cdf0e10cSrcweir 	sal_Bool bDrawSel;
710cdf0e10cSrcweir 
711cdf0e10cSrcweir 	if ( (mbNoSelection && !mbHighlight) || (!mbDrawSelection && mbHighlight) )
712cdf0e10cSrcweir 		bDrawSel = sal_False;
713cdf0e10cSrcweir 	else
714cdf0e10cSrcweir 		bDrawSel = sal_True;
715cdf0e10cSrcweir 
716cdf0e10cSrcweir 	if ( !bFocus &&
717cdf0e10cSrcweir 		 ((mbNoSelection && !mbHighlight) || (!mbDrawSelection && mbHighlight)) )
718cdf0e10cSrcweir 	{
719cdf0e10cSrcweir 		XubString aEmptyStr;
720cdf0e10cSrcweir 		ImplDrawItemText( aEmptyStr );
721cdf0e10cSrcweir 		return;
722cdf0e10cSrcweir 	}
723cdf0e10cSrcweir 
724cdf0e10cSrcweir 	sal_uInt16 nItemId = mnSelItemId;
725cdf0e10cSrcweir 
726cdf0e10cSrcweir 	for( int stage = 0; stage < 2; stage++ )
727cdf0e10cSrcweir 	{
728cdf0e10cSrcweir 		if( stage == 1 )
729cdf0e10cSrcweir 		{
730cdf0e10cSrcweir 			if ( mbHighlight )
731cdf0e10cSrcweir 				nItemId = mnHighItemId;
732cdf0e10cSrcweir 			else
733cdf0e10cSrcweir 				break;
734cdf0e10cSrcweir 		}
735cdf0e10cSrcweir 
736cdf0e10cSrcweir 		ValueSetItem* pItem;
737cdf0e10cSrcweir 		if ( nItemId )
738cdf0e10cSrcweir             pItem = mpImpl->mpItemList->GetObject( GetItemPos( nItemId ) );
739cdf0e10cSrcweir 		else
740cdf0e10cSrcweir 		{
741cdf0e10cSrcweir 			if ( mpNoneItem )
742cdf0e10cSrcweir 				pItem = mpNoneItem;
743cdf0e10cSrcweir 			else
744cdf0e10cSrcweir 			{
745cdf0e10cSrcweir 				pItem = ImplGetFirstItem();
746cdf0e10cSrcweir 				if ( !bFocus || !pItem )
747cdf0e10cSrcweir 					continue;
748cdf0e10cSrcweir 			}
749cdf0e10cSrcweir 		}
750cdf0e10cSrcweir 
751cdf0e10cSrcweir 		if ( pItem->maRect.IsEmpty() )
752cdf0e10cSrcweir 			continue;
753cdf0e10cSrcweir 
754cdf0e10cSrcweir 		// Selection malen
755cdf0e10cSrcweir 		const StyleSettings&	rStyleSettings = GetSettings().GetStyleSettings();
756cdf0e10cSrcweir 		Rectangle				aRect = pItem->maRect;
757cdf0e10cSrcweir 		Control::SetFillColor();
758cdf0e10cSrcweir 
759cdf0e10cSrcweir 		Color aDoubleColor( rStyleSettings.GetHighlightColor() );
760cdf0e10cSrcweir 		Color aSingleColor( rStyleSettings.GetHighlightTextColor() );
761cdf0e10cSrcweir 		if( ! mbDoubleSel )
762cdf0e10cSrcweir 		{
763cdf0e10cSrcweir 			/*
764cdf0e10cSrcweir 			*  #99777# contrast enhancement for thin mode
765cdf0e10cSrcweir 			*/
766cdf0e10cSrcweir 			const Wallpaper& rWall = GetDisplayBackground();
767cdf0e10cSrcweir 			if( ! rWall.IsBitmap() && ! rWall.IsGradient() )
768cdf0e10cSrcweir 			{
769cdf0e10cSrcweir 				const Color& rBack = rWall.GetColor();
770cdf0e10cSrcweir 				if( rBack.IsDark() && ! aDoubleColor.IsBright() )
771cdf0e10cSrcweir 				{
772cdf0e10cSrcweir 					aDoubleColor = Color( COL_WHITE );
773cdf0e10cSrcweir 					aSingleColor = Color( COL_BLACK );
774cdf0e10cSrcweir 				}
775cdf0e10cSrcweir 				else if( rBack.IsBright() && ! aDoubleColor.IsDark() )
776cdf0e10cSrcweir 				{
777cdf0e10cSrcweir 					aDoubleColor = Color( COL_BLACK );
778cdf0e10cSrcweir 					aSingleColor = Color( COL_WHITE );
779cdf0e10cSrcweir 				}
780cdf0e10cSrcweir 			}
781cdf0e10cSrcweir 		}
782cdf0e10cSrcweir 
783cdf0e10cSrcweir 		// Selectionsausgabe festlegen
784cdf0e10cSrcweir 		WinBits nStyle = GetStyle();
785cdf0e10cSrcweir 		if ( nStyle & WB_MENUSTYLEVALUESET )
786cdf0e10cSrcweir 		{
787cdf0e10cSrcweir 			if ( bFocus )
788cdf0e10cSrcweir 				ShowFocus( aRect );
789cdf0e10cSrcweir 
790cdf0e10cSrcweir 			if ( bDrawSel )
791cdf0e10cSrcweir 			{
792cdf0e10cSrcweir 				if ( mbBlackSel )
793cdf0e10cSrcweir 					SetLineColor( Color( COL_BLACK ) );
794cdf0e10cSrcweir 				else
795cdf0e10cSrcweir 					SetLineColor( aDoubleColor );
796cdf0e10cSrcweir 				DrawRect( aRect );
797cdf0e10cSrcweir 			}
798cdf0e10cSrcweir 		}
799cdf0e10cSrcweir 		else if ( nStyle & WB_RADIOSEL )
800cdf0e10cSrcweir 		{
801cdf0e10cSrcweir 			aRect.Left()	+= 3;
802cdf0e10cSrcweir 			aRect.Top() 	+= 3;
803cdf0e10cSrcweir 			aRect.Right()	-= 3;
804cdf0e10cSrcweir 			aRect.Bottom()	-= 3;
805cdf0e10cSrcweir 			if ( nStyle & WB_DOUBLEBORDER )
806cdf0e10cSrcweir 			{
807cdf0e10cSrcweir 				aRect.Left()++;
808cdf0e10cSrcweir 				aRect.Top()++;
809cdf0e10cSrcweir 				aRect.Right()--;
810cdf0e10cSrcweir 				aRect.Bottom()--;
811cdf0e10cSrcweir 			}
812cdf0e10cSrcweir 
813cdf0e10cSrcweir 			if ( bFocus )
814cdf0e10cSrcweir 				ShowFocus( aRect );
815cdf0e10cSrcweir 
816cdf0e10cSrcweir 			aRect.Left()++;
817cdf0e10cSrcweir 			aRect.Top()++;
818cdf0e10cSrcweir 			aRect.Right()--;
819cdf0e10cSrcweir 			aRect.Bottom()--;
820cdf0e10cSrcweir 
821cdf0e10cSrcweir 			if ( bDrawSel )
822cdf0e10cSrcweir 			{
823cdf0e10cSrcweir 				SetLineColor( aDoubleColor );
824cdf0e10cSrcweir 				aRect.Left()++;
825cdf0e10cSrcweir 				aRect.Top()++;
826cdf0e10cSrcweir 				aRect.Right()--;
827cdf0e10cSrcweir 				aRect.Bottom()--;
828cdf0e10cSrcweir 				DrawRect( aRect );
829cdf0e10cSrcweir 				aRect.Left()++;
830cdf0e10cSrcweir 				aRect.Top()++;
831cdf0e10cSrcweir 				aRect.Right()--;
832cdf0e10cSrcweir 				aRect.Bottom()--;
833cdf0e10cSrcweir 				DrawRect( aRect );
834cdf0e10cSrcweir 			}
835cdf0e10cSrcweir 		}
836cdf0e10cSrcweir 		else
837cdf0e10cSrcweir 		{
838cdf0e10cSrcweir 			if ( bDrawSel )
839cdf0e10cSrcweir 			{
840cdf0e10cSrcweir 				if ( mbBlackSel )
841cdf0e10cSrcweir 					SetLineColor( Color( COL_BLACK ) );
842cdf0e10cSrcweir 				else
843cdf0e10cSrcweir 					SetLineColor( aDoubleColor );
844cdf0e10cSrcweir 				DrawRect( aRect );
845cdf0e10cSrcweir 			}
846cdf0e10cSrcweir 			if ( mbDoubleSel )
847cdf0e10cSrcweir 			{
848cdf0e10cSrcweir 				aRect.Left()++;
849cdf0e10cSrcweir 				aRect.Top()++;
850cdf0e10cSrcweir 				aRect.Right()--;
851cdf0e10cSrcweir 				aRect.Bottom()--;
852cdf0e10cSrcweir 				if ( bDrawSel )
853cdf0e10cSrcweir 					DrawRect( aRect );
854cdf0e10cSrcweir 			}
855cdf0e10cSrcweir 			aRect.Left()++;
856cdf0e10cSrcweir 			aRect.Top()++;
857cdf0e10cSrcweir 			aRect.Right()--;
858cdf0e10cSrcweir 			aRect.Bottom()--;
859cdf0e10cSrcweir 			Rectangle aRect2 = aRect;
860cdf0e10cSrcweir 			aRect.Left()++;
861cdf0e10cSrcweir 			aRect.Top()++;
862cdf0e10cSrcweir 			aRect.Right()--;
863cdf0e10cSrcweir 			aRect.Bottom()--;
864cdf0e10cSrcweir 			if ( bDrawSel )
865cdf0e10cSrcweir 				DrawRect( aRect );
866cdf0e10cSrcweir 			if ( mbDoubleSel )
867cdf0e10cSrcweir 			{
868cdf0e10cSrcweir 				aRect.Left()++;
869cdf0e10cSrcweir 				aRect.Top()++;
870cdf0e10cSrcweir 				aRect.Right()--;
871cdf0e10cSrcweir 				aRect.Bottom()--;
872cdf0e10cSrcweir 				if ( bDrawSel )
873cdf0e10cSrcweir 					DrawRect( aRect );
874cdf0e10cSrcweir 			}
875cdf0e10cSrcweir 
876cdf0e10cSrcweir 			if ( bDrawSel )
877cdf0e10cSrcweir 			{
878cdf0e10cSrcweir 				if ( mbBlackSel )
879cdf0e10cSrcweir 					SetLineColor( Color( COL_WHITE ) );
880cdf0e10cSrcweir 				else
881cdf0e10cSrcweir 					SetLineColor( aSingleColor );
882cdf0e10cSrcweir 			}
883cdf0e10cSrcweir 			else
884cdf0e10cSrcweir 				SetLineColor( Color( COL_LIGHTGRAY ) );
885cdf0e10cSrcweir 			DrawRect( aRect2 );
886cdf0e10cSrcweir 
887cdf0e10cSrcweir 			if ( bFocus )
888cdf0e10cSrcweir 				ShowFocus( aRect2 );
889cdf0e10cSrcweir 		}
890cdf0e10cSrcweir 
891cdf0e10cSrcweir 		ImplDrawItemText( pItem->maText );
892cdf0e10cSrcweir 	}
893cdf0e10cSrcweir }
894cdf0e10cSrcweir 
895cdf0e10cSrcweir // -----------------------------------------------------------------------
896cdf0e10cSrcweir 
897cdf0e10cSrcweir void ValueSet::ImplHideSelect( sal_uInt16 nItemId )
898cdf0e10cSrcweir {
899cdf0e10cSrcweir 	Rectangle aRect;
900cdf0e10cSrcweir 
901cdf0e10cSrcweir     sal_uInt16 nItemPos = GetItemPos( nItemId );
902cdf0e10cSrcweir 	if ( nItemPos != sal::static_int_cast<sal_uInt16>(LIST_ENTRY_NOTFOUND) )
903cdf0e10cSrcweir         aRect = mpImpl->mpItemList->GetObject( nItemPos )->maRect;
904cdf0e10cSrcweir 	else
905cdf0e10cSrcweir 	{
906cdf0e10cSrcweir 		if ( mpNoneItem )
907cdf0e10cSrcweir 			aRect = mpNoneItem->maRect;
908cdf0e10cSrcweir 	}
909cdf0e10cSrcweir 
910cdf0e10cSrcweir 	if ( !aRect.IsEmpty() )
911cdf0e10cSrcweir 	{
912cdf0e10cSrcweir 		HideFocus();
913cdf0e10cSrcweir 		Point aPos	= aRect.TopLeft();
914cdf0e10cSrcweir 		Size  aSize = aRect.GetSize();
915cdf0e10cSrcweir 		DrawOutDev( aPos, aSize, aPos, aSize, maVirDev );
916cdf0e10cSrcweir 	}
917cdf0e10cSrcweir }
918cdf0e10cSrcweir 
919cdf0e10cSrcweir // -----------------------------------------------------------------------
920cdf0e10cSrcweir 
921cdf0e10cSrcweir void ValueSet::ImplHighlightItem( sal_uInt16 nItemId, sal_Bool bIsSelection )
922cdf0e10cSrcweir {
923cdf0e10cSrcweir 	if ( mnHighItemId != nItemId )
924cdf0e10cSrcweir 	{
925cdf0e10cSrcweir 		// Alten merken, um vorherige Selektion zu entfernen
926cdf0e10cSrcweir 		sal_uInt16 nOldItem = mnHighItemId;
927cdf0e10cSrcweir 		mnHighItemId = nItemId;
928cdf0e10cSrcweir 
929cdf0e10cSrcweir 		// Wenn keiner selektiert ist, dann Selektion nicht malen
930cdf0e10cSrcweir 		if ( !bIsSelection && mbNoSelection )
931cdf0e10cSrcweir 			mbDrawSelection = sal_False;
932cdf0e10cSrcweir 
933cdf0e10cSrcweir 		// Neu ausgeben und alte Selection wegnehmen
934cdf0e10cSrcweir 		ImplHideSelect( nOldItem );
935cdf0e10cSrcweir 		ImplDrawSelect();
936cdf0e10cSrcweir 		mbDrawSelection = sal_True;
937cdf0e10cSrcweir 	}
938cdf0e10cSrcweir }
939cdf0e10cSrcweir 
940cdf0e10cSrcweir // -----------------------------------------------------------------------
941cdf0e10cSrcweir 
942cdf0e10cSrcweir void ValueSet::ImplDrawDropPos( sal_Bool bShow )
943cdf0e10cSrcweir {
944cdf0e10cSrcweir     if ( (mnDropPos != VALUESET_ITEM_NOTFOUND) && mpImpl->mpItemList->Count() )
945cdf0e10cSrcweir 	{
946cdf0e10cSrcweir 		sal_uInt16	nItemPos = mnDropPos;
947cdf0e10cSrcweir 		sal_uInt16	nItemId1;
948cdf0e10cSrcweir 		sal_uInt16	nItemId2 = 0;
949cdf0e10cSrcweir 		sal_Bool	bRight;
950cdf0e10cSrcweir         if ( nItemPos >= mpImpl->mpItemList->Count() )
951cdf0e10cSrcweir 		{
952cdf0e10cSrcweir             nItemPos = (sal_uInt16)(mpImpl->mpItemList->Count()-1);
953cdf0e10cSrcweir 			bRight = sal_True;
954cdf0e10cSrcweir 		}
955cdf0e10cSrcweir 		else
956cdf0e10cSrcweir 			bRight = sal_False;
957cdf0e10cSrcweir 
958cdf0e10cSrcweir 		nItemId1 = GetItemId( nItemPos );
959cdf0e10cSrcweir 		if ( (nItemId1 != mnSelItemId) && (nItemId1 != mnHighItemId) )
960cdf0e10cSrcweir 			nItemId1 = 0;
961cdf0e10cSrcweir         Rectangle aRect2 = mpImpl->mpItemList->GetObject( nItemPos )->maRect;
962cdf0e10cSrcweir 		Rectangle aRect1;
963cdf0e10cSrcweir 		if ( bRight )
964cdf0e10cSrcweir 		{
965cdf0e10cSrcweir 			aRect1 = aRect2;
966cdf0e10cSrcweir 			aRect2.SetEmpty();
967cdf0e10cSrcweir 		}
968cdf0e10cSrcweir 		else if ( nItemPos > 0 )
969cdf0e10cSrcweir 		{
970cdf0e10cSrcweir             aRect1 = mpImpl->mpItemList->GetObject( nItemPos-1 )->maRect;
971cdf0e10cSrcweir 			nItemId2 = GetItemId( nItemPos-1 );
972cdf0e10cSrcweir 			if ( (nItemId2 != mnSelItemId) && (nItemId2 != mnHighItemId) )
973cdf0e10cSrcweir 				nItemId2 = 0;
974cdf0e10cSrcweir 		}
975cdf0e10cSrcweir 
976cdf0e10cSrcweir 		// Items ueberhaupt sichtbar (nur Erstes/Letztes)
977cdf0e10cSrcweir 		if ( !aRect1.IsEmpty() || !aRect2.IsEmpty() )
978cdf0e10cSrcweir 		{
979cdf0e10cSrcweir 			if ( nItemId1 )
980cdf0e10cSrcweir 				ImplHideSelect( nItemId1 );
981cdf0e10cSrcweir 			if ( nItemId2 )
982cdf0e10cSrcweir 				ImplHideSelect( nItemId2 );
983cdf0e10cSrcweir 
984cdf0e10cSrcweir 			if ( bShow )
985cdf0e10cSrcweir 			{
986cdf0e10cSrcweir 				const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
987cdf0e10cSrcweir 				long	nX;
988cdf0e10cSrcweir 				long	nY;
989cdf0e10cSrcweir 				SetLineColor( rStyleSettings.GetButtonTextColor() );
990cdf0e10cSrcweir 				if ( !aRect1.IsEmpty() )
991cdf0e10cSrcweir 				{
992cdf0e10cSrcweir 					Point aPos = aRect1.RightCenter();
993cdf0e10cSrcweir 					nX = aPos.X()-2;
994cdf0e10cSrcweir 					nY = aPos.Y();
995cdf0e10cSrcweir 					for ( sal_uInt16 i = 0; i < 4; i++ )
996cdf0e10cSrcweir 						DrawLine( Point( nX-i, nY-i ), Point( nX-i, nY+i ) );
997cdf0e10cSrcweir 				}
998cdf0e10cSrcweir 				if ( !aRect2.IsEmpty() )
999cdf0e10cSrcweir 				{
1000cdf0e10cSrcweir 					Point aPos = aRect2.LeftCenter();
1001cdf0e10cSrcweir 					nX = aPos.X()+2;
1002cdf0e10cSrcweir 					nY = aPos.Y();
1003cdf0e10cSrcweir 					for ( sal_uInt16 i = 0; i < 4; i++ )
1004cdf0e10cSrcweir 						DrawLine( Point( nX+i, nY-i ), Point( nX+i, nY+i ) );
1005cdf0e10cSrcweir 				}
1006cdf0e10cSrcweir 			}
1007cdf0e10cSrcweir 			else
1008cdf0e10cSrcweir 			{
1009cdf0e10cSrcweir 				if ( !aRect1.IsEmpty() )
1010cdf0e10cSrcweir 				{
1011cdf0e10cSrcweir 					Point aPos	= aRect1.TopLeft();
1012cdf0e10cSrcweir 					Size  aSize = aRect1.GetSize();
1013cdf0e10cSrcweir 					DrawOutDev( aPos, aSize, aPos, aSize, maVirDev );
1014cdf0e10cSrcweir 				}
1015cdf0e10cSrcweir 				if ( !aRect2.IsEmpty() )
1016cdf0e10cSrcweir 				{
1017cdf0e10cSrcweir 					Point aPos	= aRect2.TopLeft();
1018cdf0e10cSrcweir 					Size  aSize = aRect2.GetSize();
1019cdf0e10cSrcweir 					DrawOutDev( aPos, aSize, aPos, aSize, maVirDev );
1020cdf0e10cSrcweir 				}
1021cdf0e10cSrcweir 			}
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir 			if ( nItemId1 || nItemId2 )
1024cdf0e10cSrcweir 				ImplDrawSelect();
1025cdf0e10cSrcweir 		}
1026cdf0e10cSrcweir 	}
1027cdf0e10cSrcweir }
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir // -----------------------------------------------------------------------
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir void ValueSet::ImplDraw()
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir 	if ( mbFormat )
1034cdf0e10cSrcweir 		Format();
1035cdf0e10cSrcweir 
1036cdf0e10cSrcweir 	HideFocus();
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir 	Point	aDefPos;
1039cdf0e10cSrcweir 	Size	aSize = maVirDev.GetOutputSizePixel();
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir 	if ( mpScrBar && mpScrBar->IsVisible() )
1042cdf0e10cSrcweir 	{
1043cdf0e10cSrcweir 		Point	aScrPos = mpScrBar->GetPosPixel();
1044cdf0e10cSrcweir 		Size	aScrSize = mpScrBar->GetSizePixel();
1045cdf0e10cSrcweir 		Point	aTempPos( 0, aScrPos.Y() );
1046cdf0e10cSrcweir 		Size	aTempSize( aSize.Width(), aScrPos.Y() );
1047cdf0e10cSrcweir 
1048cdf0e10cSrcweir 		DrawOutDev( aDefPos, aTempSize, aDefPos, aTempSize, maVirDev );
1049cdf0e10cSrcweir 		aTempSize.Width()	= aScrPos.X()-1;
1050cdf0e10cSrcweir 		aTempSize.Height()	= aScrSize.Height();
1051cdf0e10cSrcweir 		DrawOutDev( aTempPos, aTempSize, aTempPos, aTempSize, maVirDev );
1052cdf0e10cSrcweir 		aTempPos.Y()		= aScrPos.Y()+aScrSize.Height();
1053cdf0e10cSrcweir 		aTempSize.Width()	= aSize.Width();
1054cdf0e10cSrcweir 		aTempSize.Height()	= aSize.Height()-aTempPos.Y();
1055cdf0e10cSrcweir 		DrawOutDev( aTempPos, aTempSize, aTempPos, aTempSize, maVirDev );
1056cdf0e10cSrcweir 	}
1057cdf0e10cSrcweir 	else
1058cdf0e10cSrcweir 		DrawOutDev( aDefPos, aSize, aDefPos, aSize, maVirDev );
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir 	// Trennlinie zum Namefield zeichnen
1061cdf0e10cSrcweir 	if ( GetStyle() & WB_NAMEFIELD )
1062cdf0e10cSrcweir 	{
1063cdf0e10cSrcweir 		if ( !(GetStyle() & WB_FLATVALUESET) )
1064cdf0e10cSrcweir 		{
1065cdf0e10cSrcweir 			const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1066cdf0e10cSrcweir 			Size aWinSize = GetOutputSizePixel();
1067cdf0e10cSrcweir 			Point aPos1( NAME_LINE_OFF_X, mnTextOffset+NAME_LINE_OFF_Y );
1068cdf0e10cSrcweir 			Point aPos2( aWinSize.Width()-(NAME_LINE_OFF_X*2), mnTextOffset+NAME_LINE_OFF_Y );
1069cdf0e10cSrcweir 			if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
1070cdf0e10cSrcweir 			{
1071cdf0e10cSrcweir 				SetLineColor( rStyleSettings.GetShadowColor() );
1072cdf0e10cSrcweir 				DrawLine( aPos1, aPos2 );
1073cdf0e10cSrcweir 				aPos1.Y()++;
1074cdf0e10cSrcweir 				aPos2.Y()++;
1075cdf0e10cSrcweir 				SetLineColor( rStyleSettings.GetLightColor() );
1076cdf0e10cSrcweir 			}
1077cdf0e10cSrcweir 			else
1078cdf0e10cSrcweir 				SetLineColor( rStyleSettings.GetWindowTextColor() );
1079cdf0e10cSrcweir 			DrawLine( aPos1, aPos2 );
1080cdf0e10cSrcweir 		}
1081cdf0e10cSrcweir 	}
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir 	ImplDrawSelect();
1084cdf0e10cSrcweir }
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir // -----------------------------------------------------------------------
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir sal_Bool ValueSet::ImplScroll( const Point& rPos )
1089cdf0e10cSrcweir {
1090cdf0e10cSrcweir 	Size aOutSize = GetOutputSizePixel();
1091cdf0e10cSrcweir 	long nScrBarWidth;
1092cdf0e10cSrcweir 
1093cdf0e10cSrcweir 	if ( mpScrBar )
1094cdf0e10cSrcweir 		nScrBarWidth = mpScrBar->GetSizePixel().Width();
1095cdf0e10cSrcweir 	else
1096cdf0e10cSrcweir 		nScrBarWidth = 0;
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir 	if ( !mbScroll || (rPos.X() < 0) || (rPos.X() > aOutSize.Width()-nScrBarWidth) )
1099cdf0e10cSrcweir 		return sal_False;
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir 	long			 nScrollOffset;
1102cdf0e10cSrcweir 	sal_uInt16			 nOldLine = mnFirstLine;
1103cdf0e10cSrcweir     const Rectangle& rTopRect = mpImpl->mpItemList->GetObject( mnFirstLine*mnCols )->maRect;
1104cdf0e10cSrcweir 	if ( rTopRect.GetHeight() <= 16 )
1105cdf0e10cSrcweir 		nScrollOffset = VALUESET_SCROLL_OFFSET/2;
1106cdf0e10cSrcweir 	else
1107cdf0e10cSrcweir 		nScrollOffset = VALUESET_SCROLL_OFFSET;
1108cdf0e10cSrcweir 	if ( (mnFirstLine > 0) && (rPos.Y() >= 0) )
1109cdf0e10cSrcweir 	{
1110cdf0e10cSrcweir 		long nTopPos = rTopRect.Top();
1111cdf0e10cSrcweir 		if ( (rPos.Y() >= nTopPos) && (rPos.Y() <= nTopPos+nScrollOffset) )
1112cdf0e10cSrcweir 			mnFirstLine--;
1113cdf0e10cSrcweir 	}
1114cdf0e10cSrcweir 	if ( (mnFirstLine == nOldLine) &&
1115cdf0e10cSrcweir 		 (mnFirstLine < (sal_uInt16)(mnLines-mnVisLines)) && (rPos.Y() < aOutSize.Height()) )
1116cdf0e10cSrcweir 	{
1117cdf0e10cSrcweir         long nBottomPos = mpImpl->mpItemList->GetObject( (mnFirstLine+mnVisLines-1)*mnCols )->maRect.Bottom();
1118cdf0e10cSrcweir 		if ( (rPos.Y() >= nBottomPos-nScrollOffset) && (rPos.Y() <= nBottomPos) )
1119cdf0e10cSrcweir 			mnFirstLine++;
1120cdf0e10cSrcweir 	}
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir 	if ( mnFirstLine != nOldLine )
1123cdf0e10cSrcweir 	{
1124cdf0e10cSrcweir 		mbFormat = sal_True;
1125cdf0e10cSrcweir 		ImplDraw();
1126cdf0e10cSrcweir 		return sal_True;
1127cdf0e10cSrcweir 	}
1128cdf0e10cSrcweir 	else
1129cdf0e10cSrcweir 		return sal_False;
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir 
1132cdf0e10cSrcweir // -----------------------------------------------------------------------
1133cdf0e10cSrcweir 
1134cdf0e10cSrcweir sal_uInt16 ValueSet::ImplGetItem( const Point& rPos, sal_Bool bMove ) const
1135cdf0e10cSrcweir {
1136cdf0e10cSrcweir 	if ( mpNoneItem )
1137cdf0e10cSrcweir 	{
1138cdf0e10cSrcweir 		if ( mpNoneItem->maRect.IsInside( rPos ) )
1139cdf0e10cSrcweir 			return VALUESET_ITEM_NONEITEM;
1140cdf0e10cSrcweir 	}
1141cdf0e10cSrcweir 
1142cdf0e10cSrcweir 	Point	  aDefPos;
1143cdf0e10cSrcweir 	Rectangle aWinRect( aDefPos, maVirDev.GetOutputSizePixel() );
1144cdf0e10cSrcweir 
1145cdf0e10cSrcweir     sal_uLong nItemCount = mpImpl->mpItemList->Count();
1146cdf0e10cSrcweir 	for ( sal_uLong i = 0; i < nItemCount; i++ )
1147cdf0e10cSrcweir 	{
1148cdf0e10cSrcweir         ValueSetItem* pItem = mpImpl->mpItemList->GetObject( i );
1149cdf0e10cSrcweir 		if ( pItem->maRect.IsInside( rPos ) )
1150cdf0e10cSrcweir 		{
1151cdf0e10cSrcweir 			if ( aWinRect.IsInside( rPos ) )
1152cdf0e10cSrcweir 				return (sal_uInt16)i;
1153cdf0e10cSrcweir 			else
1154cdf0e10cSrcweir 				return VALUESET_ITEM_NOTFOUND;
1155cdf0e10cSrcweir 		}
1156cdf0e10cSrcweir 	}
1157cdf0e10cSrcweir 
1158cdf0e10cSrcweir 	// Wenn Spacing gesetzt ist, wird der vorher selektierte
1159cdf0e10cSrcweir 	// Eintrag zurueckgegeben, wenn die Maus noch nicht das Fenster
1160cdf0e10cSrcweir 	// verlassen hat
1161cdf0e10cSrcweir 	if ( bMove && mnSpacing && mnHighItemId )
1162cdf0e10cSrcweir 	{
1163cdf0e10cSrcweir 		if ( aWinRect.IsInside( rPos ) )
1164cdf0e10cSrcweir 			return GetItemPos( mnHighItemId );
1165cdf0e10cSrcweir 	}
1166cdf0e10cSrcweir 
1167cdf0e10cSrcweir 	return VALUESET_ITEM_NOTFOUND;
1168cdf0e10cSrcweir }
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir // -----------------------------------------------------------------------
1171cdf0e10cSrcweir 
1172cdf0e10cSrcweir ValueSetItem* ValueSet::ImplGetItem( sal_uInt16 nPos )
1173cdf0e10cSrcweir {
1174cdf0e10cSrcweir 	if ( nPos == VALUESET_ITEM_NONEITEM )
1175cdf0e10cSrcweir 		return mpNoneItem;
1176cdf0e10cSrcweir 	else
1177cdf0e10cSrcweir         return mpImpl->mpItemList->GetObject( nPos );
1178cdf0e10cSrcweir }
1179cdf0e10cSrcweir 
1180cdf0e10cSrcweir // -----------------------------------------------------------------------
1181cdf0e10cSrcweir 
1182cdf0e10cSrcweir ValueSetItem* ValueSet::ImplGetFirstItem()
1183cdf0e10cSrcweir {
1184cdf0e10cSrcweir     sal_uInt16 nItemCount = (sal_uInt16)mpImpl->mpItemList->Count();
1185cdf0e10cSrcweir 	sal_uInt16 i = 0;
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir 	while ( i < nItemCount )
1188cdf0e10cSrcweir 	{
1189cdf0e10cSrcweir         ValueSetItem* pItem = mpImpl->mpItemList->GetObject( i );
1190cdf0e10cSrcweir 		if ( pItem->meType != VALUESETITEM_SPACE )
1191cdf0e10cSrcweir 			return pItem;
1192cdf0e10cSrcweir 		i++;
1193cdf0e10cSrcweir 	}
1194cdf0e10cSrcweir 
1195cdf0e10cSrcweir 	return NULL;
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir 
1198cdf0e10cSrcweir // -----------------------------------------------------------------------
1199cdf0e10cSrcweir 
1200cdf0e10cSrcweir sal_uInt16 ValueSet::ImplGetVisibleItemCount() const
1201cdf0e10cSrcweir {
1202cdf0e10cSrcweir     sal_uInt16 nRet = 0;
1203cdf0e10cSrcweir 
1204cdf0e10cSrcweir     for( sal_Int32 n = 0, nItemCount = mpImpl->mpItemList->Count(); n < nItemCount; n++  )
1205cdf0e10cSrcweir     {
1206cdf0e10cSrcweir         ValueSetItem* pItem = mpImpl->mpItemList->GetObject( n );
1207cdf0e10cSrcweir 
1208*2bfcd321SSteve Yin 		//IAccessible2 implementation - also count empty rectangles as visible...
1209*2bfcd321SSteve Yin         // if( pItem->meType != VALUESETITEM_SPACE && !pItem->maRect.IsEmpty() )
1210*2bfcd321SSteve Yin 		if( pItem->meType != VALUESETITEM_SPACE )
1211cdf0e10cSrcweir             nRet++;
1212cdf0e10cSrcweir     }
1213cdf0e10cSrcweir 
1214cdf0e10cSrcweir     return nRet;
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir 
1217cdf0e10cSrcweir // -----------------------------------------------------------------------
1218cdf0e10cSrcweir 
1219cdf0e10cSrcweir ValueSetItem* ValueSet::ImplGetVisibleItem( sal_uInt16 nVisiblePos )
1220cdf0e10cSrcweir {
1221cdf0e10cSrcweir     ValueSetItem*   pRet = NULL;
1222cdf0e10cSrcweir     sal_uInt16          nFoundPos = 0;
1223cdf0e10cSrcweir 
1224cdf0e10cSrcweir     for( sal_Int32 n = 0, nItemCount = mpImpl->mpItemList->Count(); ( n < nItemCount ) && !pRet; n++  )
1225cdf0e10cSrcweir     {
1226cdf0e10cSrcweir         ValueSetItem* pItem = mpImpl->mpItemList->GetObject( n );
1227cdf0e10cSrcweir 
1228cdf0e10cSrcweir         if( ( pItem->meType != VALUESETITEM_SPACE ) && !pItem->maRect.IsEmpty() && ( nVisiblePos == nFoundPos++ ) )
1229cdf0e10cSrcweir             pRet = pItem;
1230cdf0e10cSrcweir     }
1231cdf0e10cSrcweir 
1232cdf0e10cSrcweir     return pRet;
1233cdf0e10cSrcweir }
1234cdf0e10cSrcweir 
1235cdf0e10cSrcweir // -----------------------------------------------------------------------
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir void ValueSet::ImplFireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue )
1238cdf0e10cSrcweir {
1239cdf0e10cSrcweir     ValueSetAcc* pAcc = ValueSetAcc::getImplementation( GetAccessible( sal_False ) );
1240cdf0e10cSrcweir 
1241cdf0e10cSrcweir     if( pAcc )
1242cdf0e10cSrcweir         pAcc->FireAccessibleEvent( nEventId, rOldValue, rNewValue );
1243cdf0e10cSrcweir }
1244cdf0e10cSrcweir 
1245cdf0e10cSrcweir // -----------------------------------------------------------------------
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir sal_Bool ValueSet::ImplHasAccessibleListeners()
1248cdf0e10cSrcweir {
1249cdf0e10cSrcweir     ValueSetAcc* pAcc = ValueSetAcc::getImplementation( GetAccessible( sal_False ) );
1250cdf0e10cSrcweir     return( pAcc && pAcc->HasAccessibleListeners() );
1251cdf0e10cSrcweir }
1252cdf0e10cSrcweir 
1253cdf0e10cSrcweir // -----------------------------------------------------------------------
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir IMPL_LINK( ValueSet,ImplScrollHdl, ScrollBar*, pScrollBar )
1256cdf0e10cSrcweir {
1257cdf0e10cSrcweir 	sal_uInt16 nNewFirstLine = (sal_uInt16)pScrollBar->GetThumbPos();
1258cdf0e10cSrcweir 	if ( nNewFirstLine != mnFirstLine )
1259cdf0e10cSrcweir 	{
1260cdf0e10cSrcweir 		mnFirstLine = nNewFirstLine;
1261cdf0e10cSrcweir 		mbFormat = sal_True;
1262cdf0e10cSrcweir 		ImplDraw();
1263cdf0e10cSrcweir 	}
1264cdf0e10cSrcweir 	return 0;
1265cdf0e10cSrcweir }
1266cdf0e10cSrcweir 
1267cdf0e10cSrcweir // -----------------------------------------------------------------------
1268cdf0e10cSrcweir 
1269cdf0e10cSrcweir IMPL_LINK( ValueSet,ImplTimerHdl, Timer*, EMPTYARG )
1270cdf0e10cSrcweir {
1271cdf0e10cSrcweir 	ImplTracking( GetPointerPosPixel(), sal_True );
1272cdf0e10cSrcweir 	return 0;
1273cdf0e10cSrcweir }
1274cdf0e10cSrcweir 
1275cdf0e10cSrcweir // -----------------------------------------------------------------------
1276cdf0e10cSrcweir 
1277cdf0e10cSrcweir void ValueSet::ImplTracking( const Point& rPos, sal_Bool bRepeat )
1278cdf0e10cSrcweir {
1279cdf0e10cSrcweir 	if ( bRepeat || mbSelection )
1280cdf0e10cSrcweir 	{
1281cdf0e10cSrcweir 		if ( ImplScroll( rPos ) )
1282cdf0e10cSrcweir 		{
1283cdf0e10cSrcweir 			if ( mbSelection )
1284cdf0e10cSrcweir 			{
1285cdf0e10cSrcweir 				maTimer.SetTimeoutHdl( LINK( this, ValueSet, ImplTimerHdl ) );
1286cdf0e10cSrcweir 				maTimer.SetTimeout( GetSettings().GetMouseSettings().GetScrollRepeat() );
1287cdf0e10cSrcweir 				maTimer.Start();
1288cdf0e10cSrcweir 			}
1289cdf0e10cSrcweir 		}
1290cdf0e10cSrcweir 	}
1291cdf0e10cSrcweir 
1292cdf0e10cSrcweir 	ValueSetItem* pItem = ImplGetItem( ImplGetItem( rPos ) );
1293cdf0e10cSrcweir 	if ( pItem && (pItem->meType != VALUESETITEM_SPACE) )
1294cdf0e10cSrcweir 	{
1295cdf0e10cSrcweir 		if( GetStyle() & WB_MENUSTYLEVALUESET )
1296cdf0e10cSrcweir 			mbHighlight = sal_True;
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir 		ImplHighlightItem( pItem->mnId );
1299cdf0e10cSrcweir 	}
1300cdf0e10cSrcweir 	else
1301cdf0e10cSrcweir 	{
1302cdf0e10cSrcweir 		if( GetStyle() & WB_MENUSTYLEVALUESET )
1303cdf0e10cSrcweir 			mbHighlight = sal_True;
1304cdf0e10cSrcweir 
1305cdf0e10cSrcweir 		ImplHighlightItem( mnSelItemId, sal_False );
1306cdf0e10cSrcweir 	}
1307cdf0e10cSrcweir }
1308cdf0e10cSrcweir 
1309cdf0e10cSrcweir // -----------------------------------------------------------------------
1310cdf0e10cSrcweir 
1311cdf0e10cSrcweir void ValueSet::ImplEndTracking( const Point& rPos, sal_Bool bCancel )
1312cdf0e10cSrcweir {
1313cdf0e10cSrcweir 	ValueSetItem* pItem;
1314cdf0e10cSrcweir 
1315cdf0e10cSrcweir 	// Bei Abbruch, den alten Status wieder herstellen
1316cdf0e10cSrcweir 	if ( bCancel )
1317cdf0e10cSrcweir 		pItem = NULL;
1318cdf0e10cSrcweir 	else
1319cdf0e10cSrcweir 		pItem = ImplGetItem( ImplGetItem( rPos ) );
1320cdf0e10cSrcweir 
1321cdf0e10cSrcweir 	if ( pItem && (pItem->meType != VALUESETITEM_SPACE) )
1322cdf0e10cSrcweir 	{
1323cdf0e10cSrcweir 		SelectItem( pItem->mnId );
1324cdf0e10cSrcweir 		if ( !mbSelection && !(GetStyle() & WB_NOPOINTERFOCUS) )
1325cdf0e10cSrcweir 			GrabFocus();
1326cdf0e10cSrcweir 		mbHighlight = sal_False;
1327cdf0e10cSrcweir 		mbSelection = sal_False;
1328cdf0e10cSrcweir 		Select();
1329cdf0e10cSrcweir 	}
1330cdf0e10cSrcweir 	else
1331cdf0e10cSrcweir 	{
1332cdf0e10cSrcweir 		ImplHighlightItem( mnSelItemId, sal_False );
1333cdf0e10cSrcweir 		mbHighlight = sal_False;
1334cdf0e10cSrcweir 		mbSelection = sal_False;
1335cdf0e10cSrcweir 	}
1336cdf0e10cSrcweir }
1337cdf0e10cSrcweir 
1338cdf0e10cSrcweir // -----------------------------------------------------------------------
1339cdf0e10cSrcweir 
1340cdf0e10cSrcweir void ValueSet::MouseButtonDown( const MouseEvent& rMEvt )
1341cdf0e10cSrcweir {
1342cdf0e10cSrcweir 	if ( rMEvt.IsLeft() )
1343cdf0e10cSrcweir 	{
1344cdf0e10cSrcweir 		ValueSetItem* pItem = ImplGetItem( ImplGetItem( rMEvt.GetPosPixel() ) );
1345cdf0e10cSrcweir 		if ( mbSelection )
1346cdf0e10cSrcweir 		{
1347cdf0e10cSrcweir 			mbHighlight = sal_True;
1348cdf0e10cSrcweir 			if ( pItem && (pItem->meType != VALUESETITEM_SPACE) )
1349cdf0e10cSrcweir 			{
1350cdf0e10cSrcweir 				mnOldItemId  = mnSelItemId;
1351cdf0e10cSrcweir 				mnHighItemId = mnSelItemId;
1352cdf0e10cSrcweir 				ImplHighlightItem( pItem->mnId );
1353cdf0e10cSrcweir 			}
1354cdf0e10cSrcweir 
1355cdf0e10cSrcweir 			return;
1356cdf0e10cSrcweir 		}
1357cdf0e10cSrcweir 		else
1358cdf0e10cSrcweir 		{
1359cdf0e10cSrcweir 			if ( pItem && (pItem->meType != VALUESETITEM_SPACE) && !rMEvt.IsMod2() )
1360cdf0e10cSrcweir 			{
1361cdf0e10cSrcweir 				if ( (pItem->mnBits & VIB_NODOUBLECLICK) || (rMEvt.GetClicks() == 1) )
1362cdf0e10cSrcweir 				{
1363cdf0e10cSrcweir 					mnOldItemId  = mnSelItemId;
1364cdf0e10cSrcweir 					mbHighlight  = sal_True;
1365cdf0e10cSrcweir 					mnHighItemId = mnSelItemId;
1366cdf0e10cSrcweir 					ImplHighlightItem( pItem->mnId );
1367cdf0e10cSrcweir 					StartTracking( STARTTRACK_SCROLLREPEAT );
1368cdf0e10cSrcweir 				}
1369cdf0e10cSrcweir 				else if ( rMEvt.GetClicks() == 2 )
1370cdf0e10cSrcweir 					DoubleClick();
1371cdf0e10cSrcweir 
1372cdf0e10cSrcweir 				return;
1373cdf0e10cSrcweir 			}
1374cdf0e10cSrcweir 		}
1375cdf0e10cSrcweir 	}
1376cdf0e10cSrcweir 
1377cdf0e10cSrcweir 	Control::MouseButtonDown( rMEvt );
1378cdf0e10cSrcweir }
1379cdf0e10cSrcweir 
1380cdf0e10cSrcweir // -----------------------------------------------------------------------
1381cdf0e10cSrcweir 
1382cdf0e10cSrcweir void ValueSet::MouseButtonUp( const MouseEvent& rMEvt )
1383cdf0e10cSrcweir {
1384cdf0e10cSrcweir 	// Wegen SelectionMode
1385cdf0e10cSrcweir 	if ( rMEvt.IsLeft() && mbSelection )
1386cdf0e10cSrcweir 		ImplEndTracking( rMEvt.GetPosPixel(), sal_False );
1387cdf0e10cSrcweir 	else
1388cdf0e10cSrcweir 		Control::MouseButtonUp( rMEvt );
1389cdf0e10cSrcweir }
1390cdf0e10cSrcweir 
1391cdf0e10cSrcweir // -----------------------------------------------------------------------
1392cdf0e10cSrcweir 
1393cdf0e10cSrcweir void ValueSet::MouseMove( const MouseEvent& rMEvt )
1394cdf0e10cSrcweir {
1395cdf0e10cSrcweir 	// Wegen SelectionMode
1396cdf0e10cSrcweir 	if ( mbSelection || (GetStyle() & WB_MENUSTYLEVALUESET) )
1397cdf0e10cSrcweir 		ImplTracking( rMEvt.GetPosPixel(), sal_False );
1398cdf0e10cSrcweir 	Control::MouseMove( rMEvt );
1399cdf0e10cSrcweir }
1400cdf0e10cSrcweir 
1401cdf0e10cSrcweir // -----------------------------------------------------------------------
1402cdf0e10cSrcweir 
1403cdf0e10cSrcweir void ValueSet::Tracking( const TrackingEvent& rTEvt )
1404cdf0e10cSrcweir {
1405cdf0e10cSrcweir 	Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
1406cdf0e10cSrcweir 
1407cdf0e10cSrcweir 	if ( rTEvt.IsTrackingEnded() )
1408cdf0e10cSrcweir 		ImplEndTracking( aMousePos, rTEvt.IsTrackingCanceled() );
1409cdf0e10cSrcweir 	else
1410cdf0e10cSrcweir 		ImplTracking( aMousePos, rTEvt.IsTrackingRepeat() );
1411cdf0e10cSrcweir }
1412cdf0e10cSrcweir 
1413cdf0e10cSrcweir // -----------------------------------------------------------------------
1414cdf0e10cSrcweir 
1415cdf0e10cSrcweir void ValueSet::KeyInput( const KeyEvent& rKEvt )
1416cdf0e10cSrcweir {
1417cdf0e10cSrcweir     sal_uInt16 nLastItem = (sal_uInt16)mpImpl->mpItemList->Count();
1418cdf0e10cSrcweir 	sal_uInt16 nItemPos = VALUESET_ITEM_NOTFOUND;
1419cdf0e10cSrcweir 	sal_uInt16 nCurPos = VALUESET_ITEM_NONEITEM;
1420cdf0e10cSrcweir 	sal_uInt16 nCalcPos;
1421cdf0e10cSrcweir 
1422cdf0e10cSrcweir 	if ( !nLastItem || !ImplGetFirstItem() )
1423cdf0e10cSrcweir 	{
1424cdf0e10cSrcweir 		Control::KeyInput( rKEvt );
1425cdf0e10cSrcweir 		return;
1426cdf0e10cSrcweir 	}
1427cdf0e10cSrcweir 	else
1428cdf0e10cSrcweir 		nLastItem--;
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir 	if ( mnSelItemId )
1431cdf0e10cSrcweir 		nCurPos = GetItemPos( mnSelItemId );
1432cdf0e10cSrcweir 	nCalcPos = nCurPos;
1433cdf0e10cSrcweir 
1434cdf0e10cSrcweir     //switch off selection mode if key travelling is used
1435cdf0e10cSrcweir     sal_Bool bDefault = sal_False;
1436cdf0e10cSrcweir     switch ( rKEvt.GetKeyCode().GetCode() )
1437cdf0e10cSrcweir 	{
1438cdf0e10cSrcweir 		case KEY_HOME:
1439cdf0e10cSrcweir 			if ( mpNoneItem )
1440cdf0e10cSrcweir 				nItemPos = VALUESET_ITEM_NONEITEM;
1441cdf0e10cSrcweir 			else
1442cdf0e10cSrcweir 			{
1443cdf0e10cSrcweir 				nItemPos = 0;
1444cdf0e10cSrcweir 				while ( ImplGetItem( nItemPos )->meType == VALUESETITEM_SPACE )
1445cdf0e10cSrcweir 					nItemPos++;
1446cdf0e10cSrcweir 			}
1447cdf0e10cSrcweir 			break;
1448cdf0e10cSrcweir 
1449cdf0e10cSrcweir 		case KEY_END:
1450cdf0e10cSrcweir 			nItemPos = nLastItem;
1451cdf0e10cSrcweir 			while ( ImplGetItem( nItemPos )->meType == VALUESETITEM_SPACE )
1452cdf0e10cSrcweir 			{
1453cdf0e10cSrcweir 				if ( nItemPos == 0 )
1454cdf0e10cSrcweir 					nItemPos = VALUESET_ITEM_NONEITEM;
1455cdf0e10cSrcweir 				else
1456cdf0e10cSrcweir 					nItemPos--;
1457cdf0e10cSrcweir 			}
1458cdf0e10cSrcweir 			break;
1459cdf0e10cSrcweir 
1460cdf0e10cSrcweir 		case KEY_LEFT:
1461cdf0e10cSrcweir 		case KEY_RIGHT:
1462cdf0e10cSrcweir             if ( rKEvt.GetKeyCode().GetCode()==KEY_LEFT )
1463cdf0e10cSrcweir             {
1464cdf0e10cSrcweir                 do
1465cdf0e10cSrcweir                 {
1466cdf0e10cSrcweir                     if ( nCalcPos == VALUESET_ITEM_NONEITEM )
1467cdf0e10cSrcweir                         nItemPos = nLastItem;
1468cdf0e10cSrcweir                     else if ( !nCalcPos )
1469cdf0e10cSrcweir                     {
1470cdf0e10cSrcweir                         if ( mpNoneItem )
1471cdf0e10cSrcweir                             nItemPos = VALUESET_ITEM_NONEITEM;
1472cdf0e10cSrcweir                         else
1473cdf0e10cSrcweir                             nItemPos = nLastItem;
1474cdf0e10cSrcweir                     }
1475cdf0e10cSrcweir                     else
1476cdf0e10cSrcweir                         nItemPos = nCalcPos-1;
1477cdf0e10cSrcweir                     nCalcPos = nItemPos;
1478cdf0e10cSrcweir                 }
1479cdf0e10cSrcweir                 while ( ImplGetItem( nItemPos )->meType == VALUESETITEM_SPACE );
1480cdf0e10cSrcweir             }
1481cdf0e10cSrcweir             else
1482cdf0e10cSrcweir             {
1483cdf0e10cSrcweir                 do
1484cdf0e10cSrcweir                 {
1485cdf0e10cSrcweir                     if ( nCalcPos == VALUESET_ITEM_NONEITEM )
1486cdf0e10cSrcweir                         nItemPos = 0;
1487cdf0e10cSrcweir                     else if ( nCalcPos == nLastItem )
1488cdf0e10cSrcweir                     {
1489cdf0e10cSrcweir                         if ( mpNoneItem )
1490cdf0e10cSrcweir                             nItemPos = VALUESET_ITEM_NONEITEM;
1491cdf0e10cSrcweir                         else
1492cdf0e10cSrcweir                             nItemPos = 0;
1493cdf0e10cSrcweir                     }
1494cdf0e10cSrcweir                     else
1495cdf0e10cSrcweir                         nItemPos = nCalcPos+1;
1496cdf0e10cSrcweir                     nCalcPos = nItemPos;
1497cdf0e10cSrcweir                 }
1498cdf0e10cSrcweir                 while ( ImplGetItem( nItemPos )->meType == VALUESETITEM_SPACE );
1499cdf0e10cSrcweir             }
1500cdf0e10cSrcweir             break;
1501cdf0e10cSrcweir 
1502cdf0e10cSrcweir 		case KEY_UP:
1503cdf0e10cSrcweir 		case KEY_PAGEUP:
1504cdf0e10cSrcweir         {
1505cdf0e10cSrcweir             if( rKEvt.GetKeyCode().GetCode() != KEY_PAGEUP ||
1506cdf0e10cSrcweir                 ( !rKEvt.GetKeyCode().IsShift() && !rKEvt.GetKeyCode().IsMod1() && !rKEvt.GetKeyCode().IsMod2() ) )
1507cdf0e10cSrcweir             {
1508cdf0e10cSrcweir                 const long nLineCount = ( ( KEY_UP == rKEvt.GetKeyCode().GetCode() ) ? 1 : mnVisLines );
1509cdf0e10cSrcweir 			    do
1510cdf0e10cSrcweir 			    {
1511cdf0e10cSrcweir 				    if ( nCalcPos == VALUESET_ITEM_NONEITEM )
1512cdf0e10cSrcweir 				    {
1513cdf0e10cSrcweir 					    if ( nLastItem+1 <= mnCols )
1514cdf0e10cSrcweir 						    nItemPos = mnCurCol;
1515cdf0e10cSrcweir 					    else
1516cdf0e10cSrcweir 					    {
1517cdf0e10cSrcweir 						    nItemPos = ((((nLastItem+1)/mnCols)-1)*mnCols)+(mnCurCol%mnCols);
1518cdf0e10cSrcweir 						    if ( nItemPos+mnCols <= nLastItem )
1519cdf0e10cSrcweir 							    nItemPos = nItemPos + mnCols;
1520cdf0e10cSrcweir 					    }
1521cdf0e10cSrcweir 				    }
1522cdf0e10cSrcweir 				    else if ( nCalcPos >= ( nLineCount * mnCols ) )
1523cdf0e10cSrcweir 					    nItemPos = sal::static_int_cast< sal_uInt16 >(
1524cdf0e10cSrcweir                             nCalcPos - ( nLineCount * mnCols ));
1525cdf0e10cSrcweir 				    else
1526cdf0e10cSrcweir 				    {
1527cdf0e10cSrcweir 						if ( mpNoneItem )
1528cdf0e10cSrcweir 						{
1529cdf0e10cSrcweir 							mnCurCol  = nCalcPos%mnCols;
1530cdf0e10cSrcweir 							nItemPos = VALUESET_ITEM_NONEITEM;
1531cdf0e10cSrcweir 						}
1532cdf0e10cSrcweir 						else
1533cdf0e10cSrcweir 						{
1534cdf0e10cSrcweir 							if ( nLastItem+1 <= mnCols )
1535cdf0e10cSrcweir 								nItemPos = nCalcPos;
1536cdf0e10cSrcweir 							else
1537cdf0e10cSrcweir 							{
1538cdf0e10cSrcweir 								nItemPos = ((((nLastItem+1)/mnCols)-1)*mnCols)+(nCalcPos%mnCols);
1539cdf0e10cSrcweir 								if ( nItemPos+mnCols <= nLastItem )
1540cdf0e10cSrcweir 									nItemPos = nItemPos + mnCols;
1541cdf0e10cSrcweir 							}
1542cdf0e10cSrcweir 						}
1543cdf0e10cSrcweir 				    }
1544cdf0e10cSrcweir 				    nCalcPos = nItemPos;
1545cdf0e10cSrcweir 			    }
1546cdf0e10cSrcweir 			    while ( ImplGetItem( nItemPos )->meType == VALUESETITEM_SPACE );
1547cdf0e10cSrcweir             }
1548cdf0e10cSrcweir             else
1549cdf0e10cSrcweir     			Control::KeyInput( rKEvt );
1550cdf0e10cSrcweir         }
1551cdf0e10cSrcweir 		break;
1552cdf0e10cSrcweir 
1553cdf0e10cSrcweir 		case KEY_DOWN:
1554cdf0e10cSrcweir 		case KEY_PAGEDOWN:
1555cdf0e10cSrcweir         {
1556cdf0e10cSrcweir             if( rKEvt.GetKeyCode().GetCode() != KEY_PAGEDOWN ||
1557cdf0e10cSrcweir                 ( !rKEvt.GetKeyCode().IsShift() && !rKEvt.GetKeyCode().IsMod1() && !rKEvt.GetKeyCode().IsMod2() ) )
1558cdf0e10cSrcweir             {
1559cdf0e10cSrcweir                 const long nLineCount = ( ( KEY_DOWN == rKEvt.GetKeyCode().GetCode() ) ? 1 : mnVisLines );
1560cdf0e10cSrcweir                 do
1561cdf0e10cSrcweir 			    {
1562cdf0e10cSrcweir 				    if ( nCalcPos == VALUESET_ITEM_NONEITEM )
1563cdf0e10cSrcweir 					    nItemPos = mnCurCol;
1564cdf0e10cSrcweir 				    else if ( nCalcPos + ( nLineCount * mnCols ) <= nLastItem )
1565cdf0e10cSrcweir 					    nItemPos = sal::static_int_cast< sal_uInt16 >(
1566cdf0e10cSrcweir                             nCalcPos + ( nLineCount * mnCols ));
1567cdf0e10cSrcweir 				    else
1568cdf0e10cSrcweir 				    {
1569cdf0e10cSrcweir #if 0
1570cdf0e10cSrcweir 						if( (KEY_DOWN == rKEvt.GetKeyCode().GetCode() ) && (GetStyle() & WB_MENUSTYLEVALUESET) )
1571cdf0e10cSrcweir 						{
1572cdf0e10cSrcweir 							Window* pParent = GetParent();
1573cdf0e10cSrcweir 							pParent->GrabFocus();
1574cdf0e10cSrcweir 							pParent->KeyInput( rKEvt );
1575cdf0e10cSrcweir 							break;
1576cdf0e10cSrcweir 						}
1577cdf0e10cSrcweir 						else
1578cdf0e10cSrcweir #endif
1579cdf0e10cSrcweir 						{
1580cdf0e10cSrcweir 							if ( mpNoneItem )
1581cdf0e10cSrcweir 							{
1582cdf0e10cSrcweir 								mnCurCol  = nCalcPos%mnCols;
1583cdf0e10cSrcweir 								nItemPos = VALUESET_ITEM_NONEITEM;
1584cdf0e10cSrcweir 							}
1585cdf0e10cSrcweir 							else
1586cdf0e10cSrcweir 								nItemPos = nCalcPos%mnCols;
1587cdf0e10cSrcweir 						}
1588cdf0e10cSrcweir 				    }
1589cdf0e10cSrcweir 				    nCalcPos = nItemPos;
1590cdf0e10cSrcweir 			    }
1591cdf0e10cSrcweir 			    while ( ImplGetItem( nItemPos )->meType == VALUESETITEM_SPACE );
1592cdf0e10cSrcweir             }
1593cdf0e10cSrcweir             else
1594cdf0e10cSrcweir     			Control::KeyInput( rKEvt );
1595cdf0e10cSrcweir 
1596cdf0e10cSrcweir         }
1597cdf0e10cSrcweir         break;
1598cdf0e10cSrcweir         case KEY_RETURN:
1599cdf0e10cSrcweir             //enable default handling of KEY_RETURN in dialogs
1600cdf0e10cSrcweir 			if(0 != (GetStyle()&WB_NO_DIRECTSELECT))
1601cdf0e10cSrcweir             {
1602cdf0e10cSrcweir                 Select();
1603cdf0e10cSrcweir                 break;
1604cdf0e10cSrcweir             }
1605cdf0e10cSrcweir             //no break;
1606cdf0e10cSrcweir 		default:
1607cdf0e10cSrcweir 			Control::KeyInput( rKEvt );
1608cdf0e10cSrcweir             bDefault = sal_True;
1609cdf0e10cSrcweir 			break;
1610cdf0e10cSrcweir 	}
1611cdf0e10cSrcweir     if(!bDefault)
1612cdf0e10cSrcweir         EndSelection();
1613cdf0e10cSrcweir     if ( nItemPos != VALUESET_ITEM_NOTFOUND )
1614cdf0e10cSrcweir 	{
1615cdf0e10cSrcweir 		sal_uInt16 nItemId;
1616cdf0e10cSrcweir 		if ( nItemPos != VALUESET_ITEM_NONEITEM )
1617cdf0e10cSrcweir 			nItemId = GetItemId( nItemPos );
1618cdf0e10cSrcweir 		else
1619cdf0e10cSrcweir 			nItemId = 0;
1620cdf0e10cSrcweir 
1621cdf0e10cSrcweir 		if ( nItemId != mnSelItemId )
1622cdf0e10cSrcweir 		{
1623cdf0e10cSrcweir 			SelectItem( nItemId );
1624cdf0e10cSrcweir 			//select only if WB_NO_DIRECTSELECT is not set
1625cdf0e10cSrcweir 			if(0 == (GetStyle()&WB_NO_DIRECTSELECT))
1626cdf0e10cSrcweir 				Select();
1627cdf0e10cSrcweir 		}
1628cdf0e10cSrcweir 	}
1629cdf0e10cSrcweir }
1630cdf0e10cSrcweir 
1631cdf0e10cSrcweir // -----------------------------------------------------------------------
1632cdf0e10cSrcweir 
1633cdf0e10cSrcweir void ValueSet::Command( const CommandEvent& rCEvt )
1634cdf0e10cSrcweir {
1635cdf0e10cSrcweir 	if ( (rCEvt.GetCommand() == COMMAND_WHEEL) ||
1636cdf0e10cSrcweir 		 (rCEvt.GetCommand() == COMMAND_STARTAUTOSCROLL) ||
1637cdf0e10cSrcweir 		 (rCEvt.GetCommand() == COMMAND_AUTOSCROLL) )
1638cdf0e10cSrcweir 	{
1639cdf0e10cSrcweir 		if ( HandleScrollCommand( rCEvt, NULL, mpScrBar ) )
1640cdf0e10cSrcweir 			return;
1641cdf0e10cSrcweir 	}
1642cdf0e10cSrcweir 
1643cdf0e10cSrcweir 	Control::Command( rCEvt );
1644cdf0e10cSrcweir }
1645cdf0e10cSrcweir 
1646cdf0e10cSrcweir // -----------------------------------------------------------------------
1647cdf0e10cSrcweir 
1648cdf0e10cSrcweir void ValueSet::Paint( const Rectangle& )
1649cdf0e10cSrcweir {
1650cdf0e10cSrcweir 	if ( GetStyle() & WB_FLATVALUESET )
1651cdf0e10cSrcweir 	{
1652cdf0e10cSrcweir 		const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1653cdf0e10cSrcweir 		SetLineColor();
1654cdf0e10cSrcweir 		SetFillColor( rStyleSettings.GetFaceColor() );
1655cdf0e10cSrcweir 		long nOffY = maVirDev.GetOutputSizePixel().Height();
1656cdf0e10cSrcweir 		Size aWinSize = GetOutputSizePixel();
1657cdf0e10cSrcweir 		DrawRect( Rectangle( Point( 0, nOffY ), Point( aWinSize.Width(), aWinSize.Height() ) ) );
1658cdf0e10cSrcweir 	}
1659cdf0e10cSrcweir 
1660cdf0e10cSrcweir 	ImplDraw();
1661cdf0e10cSrcweir }
1662cdf0e10cSrcweir 
1663cdf0e10cSrcweir // -----------------------------------------------------------------------
1664cdf0e10cSrcweir 
1665cdf0e10cSrcweir void ValueSet::GetFocus()
1666cdf0e10cSrcweir {
1667cdf0e10cSrcweir     OSL_TRACE ("value set getting focus");
1668cdf0e10cSrcweir 	ImplDrawSelect();
1669cdf0e10cSrcweir 	Control::GetFocus();
1670cdf0e10cSrcweir 
1671cdf0e10cSrcweir     // Tell the accessible object that we got the focus.
1672cdf0e10cSrcweir     ValueSetAcc* pAcc = ValueSetAcc::getImplementation( GetAccessible( sal_False ) );
1673cdf0e10cSrcweir     if( pAcc )
1674cdf0e10cSrcweir         pAcc->GetFocus();
1675cdf0e10cSrcweir }
1676cdf0e10cSrcweir 
1677cdf0e10cSrcweir // -----------------------------------------------------------------------
1678cdf0e10cSrcweir 
1679cdf0e10cSrcweir void ValueSet::LoseFocus()
1680cdf0e10cSrcweir {
1681cdf0e10cSrcweir     OSL_TRACE ("value set losing focus");
1682cdf0e10cSrcweir 	if ( mbNoSelection && mnSelItemId )
1683cdf0e10cSrcweir 		ImplHideSelect( mnSelItemId );
1684cdf0e10cSrcweir 	else
1685cdf0e10cSrcweir 		HideFocus();
1686cdf0e10cSrcweir 	Control::LoseFocus();
1687cdf0e10cSrcweir 
1688cdf0e10cSrcweir     // Tell the accessible object that we lost the focus.
1689cdf0e10cSrcweir     ValueSetAcc* pAcc = ValueSetAcc::getImplementation( GetAccessible( sal_False ) );
1690cdf0e10cSrcweir     if( pAcc )
1691cdf0e10cSrcweir         pAcc->LoseFocus();
1692cdf0e10cSrcweir }
1693cdf0e10cSrcweir 
1694cdf0e10cSrcweir // -----------------------------------------------------------------------
1695cdf0e10cSrcweir 
1696cdf0e10cSrcweir void ValueSet::Resize()
1697cdf0e10cSrcweir {
1698cdf0e10cSrcweir 	mbFormat = sal_True;
1699cdf0e10cSrcweir 	if ( IsReallyVisible() && IsUpdateMode() )
1700cdf0e10cSrcweir 		Invalidate();
1701cdf0e10cSrcweir 	Control::Resize();
1702cdf0e10cSrcweir }
1703cdf0e10cSrcweir 
1704cdf0e10cSrcweir // -----------------------------------------------------------------------
1705cdf0e10cSrcweir 
1706cdf0e10cSrcweir void ValueSet::RequestHelp( const HelpEvent& rHEvt )
1707cdf0e10cSrcweir {
1708cdf0e10cSrcweir 	if ( (rHEvt.GetMode() & (HELPMODE_QUICK | HELPMODE_BALLOON)) == HELPMODE_QUICK )
1709cdf0e10cSrcweir 	{
1710cdf0e10cSrcweir 		Point aPos = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
1711cdf0e10cSrcweir 		sal_uInt16 nItemPos = ImplGetItem( aPos );
1712cdf0e10cSrcweir 		if ( nItemPos != VALUESET_ITEM_NOTFOUND )
1713cdf0e10cSrcweir 		{
1714cdf0e10cSrcweir 			ValueSetItem* pItem = ImplGetItem( nItemPos );
1715cdf0e10cSrcweir 			Rectangle aItemRect = pItem->maRect;
1716cdf0e10cSrcweir 			Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
1717cdf0e10cSrcweir 			aItemRect.Left()   = aPt.X();
1718cdf0e10cSrcweir 			aItemRect.Top()    = aPt.Y();
1719cdf0e10cSrcweir 			aPt = OutputToScreenPixel( aItemRect.BottomRight() );
1720cdf0e10cSrcweir 			aItemRect.Right()  = aPt.X();
1721cdf0e10cSrcweir 			aItemRect.Bottom() = aPt.Y();
1722cdf0e10cSrcweir 			Help::ShowQuickHelp( this, aItemRect, GetItemText( pItem->mnId ) );
1723cdf0e10cSrcweir 			return;
1724cdf0e10cSrcweir 		}
1725cdf0e10cSrcweir 	}
1726cdf0e10cSrcweir 
1727cdf0e10cSrcweir 	Control::RequestHelp( rHEvt );
1728cdf0e10cSrcweir }
1729cdf0e10cSrcweir 
1730cdf0e10cSrcweir // -----------------------------------------------------------------------
1731cdf0e10cSrcweir 
1732cdf0e10cSrcweir void ValueSet::StateChanged( StateChangedType nType )
1733cdf0e10cSrcweir {
1734cdf0e10cSrcweir 	Control::StateChanged( nType );
1735cdf0e10cSrcweir 
1736cdf0e10cSrcweir 	if ( nType == STATE_CHANGE_INITSHOW )
1737cdf0e10cSrcweir 	{
1738cdf0e10cSrcweir 		if ( mbFormat )
1739cdf0e10cSrcweir 			Format();
1740cdf0e10cSrcweir 	}
1741cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_UPDATEMODE )
1742cdf0e10cSrcweir 	{
1743cdf0e10cSrcweir 		if ( IsReallyVisible() && IsUpdateMode() )
1744cdf0e10cSrcweir 			Invalidate();
1745cdf0e10cSrcweir 	}
1746cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_TEXT )
1747cdf0e10cSrcweir 	{
1748cdf0e10cSrcweir 		if ( mpNoneItem && !mbFormat && IsReallyVisible() && IsUpdateMode() )
1749cdf0e10cSrcweir 		{
1750cdf0e10cSrcweir 			ImplFormatItem( mpNoneItem );
1751cdf0e10cSrcweir 			Invalidate( mpNoneItem->maRect );
1752cdf0e10cSrcweir 		}
1753cdf0e10cSrcweir 	}
1754cdf0e10cSrcweir 	else if ( (nType == STATE_CHANGE_ZOOM) ||
1755cdf0e10cSrcweir 			  (nType == STATE_CHANGE_CONTROLFONT) )
1756cdf0e10cSrcweir 	{
1757cdf0e10cSrcweir 		ImplInitSettings( sal_True, sal_False, sal_False );
1758cdf0e10cSrcweir 		Invalidate();
1759cdf0e10cSrcweir 	}
1760cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
1761cdf0e10cSrcweir 	{
1762cdf0e10cSrcweir 		ImplInitSettings( sal_False, sal_True, sal_False );
1763cdf0e10cSrcweir 		Invalidate();
1764cdf0e10cSrcweir 	}
1765cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
1766cdf0e10cSrcweir 	{
1767cdf0e10cSrcweir 		ImplInitSettings( sal_False, sal_False, sal_True );
1768cdf0e10cSrcweir 		Invalidate();
1769cdf0e10cSrcweir 	}
1770cdf0e10cSrcweir     else if ( (nType == STATE_CHANGE_STYLE) || (nType == STATE_CHANGE_ENABLE) )
1771cdf0e10cSrcweir 	{
1772cdf0e10cSrcweir 		mbFormat = sal_True;
1773cdf0e10cSrcweir 		ImplInitSettings( sal_False, sal_False, sal_True );
1774cdf0e10cSrcweir 		Invalidate();
1775cdf0e10cSrcweir 	}
1776cdf0e10cSrcweir }
1777cdf0e10cSrcweir 
1778cdf0e10cSrcweir // -----------------------------------------------------------------------
1779cdf0e10cSrcweir 
1780cdf0e10cSrcweir void ValueSet::DataChanged( const DataChangedEvent& rDCEvt )
1781cdf0e10cSrcweir {
1782cdf0e10cSrcweir 	Control::DataChanged( rDCEvt );
1783cdf0e10cSrcweir 
1784cdf0e10cSrcweir 	if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
1785cdf0e10cSrcweir 		 (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
1786cdf0e10cSrcweir 		 (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
1787cdf0e10cSrcweir 		 ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
1788cdf0e10cSrcweir 		  (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
1789cdf0e10cSrcweir 	{
1790cdf0e10cSrcweir 		mbFormat = sal_True;
1791cdf0e10cSrcweir 		ImplInitSettings( sal_True, sal_True, sal_True );
1792cdf0e10cSrcweir 		Invalidate();
1793cdf0e10cSrcweir 	}
1794cdf0e10cSrcweir }
1795cdf0e10cSrcweir 
1796cdf0e10cSrcweir // -----------------------------------------------------------------------
1797cdf0e10cSrcweir 
1798cdf0e10cSrcweir void ValueSet::Select()
1799cdf0e10cSrcweir {
1800cdf0e10cSrcweir 	maSelectHdl.Call( this );
1801cdf0e10cSrcweir }
1802cdf0e10cSrcweir 
1803cdf0e10cSrcweir // -----------------------------------------------------------------------
1804cdf0e10cSrcweir 
1805cdf0e10cSrcweir void ValueSet::DoubleClick()
1806cdf0e10cSrcweir {
1807cdf0e10cSrcweir 	maDoubleClickHdl.Call( this );
1808cdf0e10cSrcweir }
1809cdf0e10cSrcweir 
1810cdf0e10cSrcweir // -----------------------------------------------------------------------
1811cdf0e10cSrcweir 
1812cdf0e10cSrcweir void ValueSet::UserDraw( const UserDrawEvent& )
1813cdf0e10cSrcweir {
1814cdf0e10cSrcweir }
1815cdf0e10cSrcweir 
1816cdf0e10cSrcweir // -----------------------------------------------------------------------
1817cdf0e10cSrcweir 
1818cdf0e10cSrcweir void ValueSet::InsertItem( sal_uInt16 nItemId, const Image& rImage, sal_uInt16 nPos )
1819cdf0e10cSrcweir {
1820cdf0e10cSrcweir 	DBG_ASSERT( nItemId, "ValueSet::InsertItem(): ItemId == 0" );
1821cdf0e10cSrcweir 	DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
1822cdf0e10cSrcweir 				"ValueSet::InsertItem(): ItemId already exists" );
1823cdf0e10cSrcweir 
1824cdf0e10cSrcweir 	ValueSetItem* pItem = new ValueSetItem( *this );
1825cdf0e10cSrcweir 	pItem->mnId 	= nItemId;
1826cdf0e10cSrcweir 	pItem->meType	= VALUESETITEM_IMAGE;
1827cdf0e10cSrcweir 	pItem->maImage	= rImage;
1828cdf0e10cSrcweir     mpImpl->mpItemList->Insert( pItem, (sal_uLong)nPos );
1829cdf0e10cSrcweir 
1830cdf0e10cSrcweir 	mbFormat = sal_True;
1831cdf0e10cSrcweir 	if ( IsReallyVisible() && IsUpdateMode() )
1832cdf0e10cSrcweir 		Invalidate();
1833cdf0e10cSrcweir }
1834cdf0e10cSrcweir 
1835cdf0e10cSrcweir // -----------------------------------------------------------------------
1836cdf0e10cSrcweir 
1837cdf0e10cSrcweir void ValueSet::InsertItem( sal_uInt16 nItemId, const Color& rColor, sal_uInt16 nPos )
1838cdf0e10cSrcweir {
1839cdf0e10cSrcweir 	DBG_ASSERT( nItemId, "ValueSet::InsertItem(): ItemId == 0" );
1840cdf0e10cSrcweir 	DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
1841cdf0e10cSrcweir 				"ValueSet::InsertItem(): ItemId already exists" );
1842cdf0e10cSrcweir 
1843cdf0e10cSrcweir 	ValueSetItem* pItem = new ValueSetItem( *this );
1844cdf0e10cSrcweir 	pItem->mnId 	= nItemId;
1845cdf0e10cSrcweir 	pItem->meType	= VALUESETITEM_COLOR;
1846cdf0e10cSrcweir 	pItem->maColor	= rColor;
1847cdf0e10cSrcweir     mpImpl->mpItemList->Insert( pItem, (sal_uLong)nPos );
1848cdf0e10cSrcweir 
1849cdf0e10cSrcweir 	mbFormat = sal_True;
1850cdf0e10cSrcweir 	if ( IsReallyVisible() && IsUpdateMode() )
1851cdf0e10cSrcweir 		Invalidate();
1852cdf0e10cSrcweir }
1853cdf0e10cSrcweir 
1854cdf0e10cSrcweir // -----------------------------------------------------------------------
1855cdf0e10cSrcweir 
1856cdf0e10cSrcweir void ValueSet::InsertItem( sal_uInt16 nItemId, const Image& rImage,
1857cdf0e10cSrcweir 						   const XubString& rText, sal_uInt16 nPos )
1858cdf0e10cSrcweir {
1859cdf0e10cSrcweir 	DBG_ASSERT( nItemId, "ValueSet::InsertItem(): ItemId == 0" );
1860cdf0e10cSrcweir 	DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
1861cdf0e10cSrcweir 				"ValueSet::InsertItem(): ItemId already exists" );
1862cdf0e10cSrcweir 
1863cdf0e10cSrcweir 	ValueSetItem* pItem = new ValueSetItem( *this );
1864cdf0e10cSrcweir 	pItem->mnId 	= nItemId;
1865cdf0e10cSrcweir 	pItem->meType	= VALUESETITEM_IMAGE;
1866cdf0e10cSrcweir 	pItem->maImage	= rImage;
1867cdf0e10cSrcweir 	pItem->maText	= rText;
1868cdf0e10cSrcweir     mpImpl->mpItemList->Insert( pItem, (sal_uLong)nPos );
1869cdf0e10cSrcweir 
1870cdf0e10cSrcweir 	mbFormat = sal_True;
1871cdf0e10cSrcweir 	if ( IsReallyVisible() && IsUpdateMode() )
1872cdf0e10cSrcweir 		Invalidate();
1873cdf0e10cSrcweir }
1874cdf0e10cSrcweir 
1875cdf0e10cSrcweir // -----------------------------------------------------------------------
1876cdf0e10cSrcweir 
1877cdf0e10cSrcweir void ValueSet::InsertItem( sal_uInt16 nItemId, const Color& rColor,
1878cdf0e10cSrcweir 						   const XubString& rText, sal_uInt16 nPos )
1879cdf0e10cSrcweir {
1880cdf0e10cSrcweir 	DBG_ASSERT( nItemId, "ValueSet::InsertItem(): ItemId == 0" );
1881cdf0e10cSrcweir 	DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
1882cdf0e10cSrcweir 				"ValueSet::InsertItem(): ItemId already exists" );
1883cdf0e10cSrcweir 
1884cdf0e10cSrcweir 	ValueSetItem* pItem = new ValueSetItem( *this );
1885cdf0e10cSrcweir 	pItem->mnId 	= nItemId;
1886cdf0e10cSrcweir 	pItem->meType	= VALUESETITEM_COLOR;
1887cdf0e10cSrcweir 	pItem->maColor	= rColor;
1888cdf0e10cSrcweir 	pItem->maText	= rText;
1889cdf0e10cSrcweir     mpImpl->mpItemList->Insert( pItem, (sal_uLong)nPos );
1890cdf0e10cSrcweir 
1891cdf0e10cSrcweir 	mbFormat = sal_True;
1892cdf0e10cSrcweir 	if ( IsReallyVisible() && IsUpdateMode() )
1893cdf0e10cSrcweir 		Invalidate();
1894cdf0e10cSrcweir }
1895cdf0e10cSrcweir 
1896*2bfcd321SSteve Yin //IAccessibility2 Implementation 2009-----
1897*2bfcd321SSteve Yin //method to set accessible when the style is user draw.
1898*2bfcd321SSteve Yin void ValueSet::InsertItem( sal_uInt16 nItemId, const XubString& rText, sal_uInt16 nPos	)
1899*2bfcd321SSteve Yin {
1900*2bfcd321SSteve Yin 	DBG_ASSERT( nItemId, "ValueSet::InsertItem(): ItemId == 0" );
1901*2bfcd321SSteve Yin 	DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
1902*2bfcd321SSteve Yin 				"ValueSet::InsertItem(): ItemId already exists" );
1903*2bfcd321SSteve Yin 	ValueSetItem* pItem = new ValueSetItem( *this );
1904*2bfcd321SSteve Yin 	pItem->mnId 	= nItemId;
1905*2bfcd321SSteve Yin 	pItem->meType	= VALUESETITEM_USERDRAW;
1906*2bfcd321SSteve Yin 	pItem->maText	= rText;
1907*2bfcd321SSteve Yin 	mpImpl->mpItemList->Insert( pItem, (sal_uLong)nPos );
1908*2bfcd321SSteve Yin 	mbFormat = sal_True;
1909*2bfcd321SSteve Yin 	if ( IsReallyVisible() && IsUpdateMode() )
1910*2bfcd321SSteve Yin 		Invalidate();
1911*2bfcd321SSteve Yin }
1912*2bfcd321SSteve Yin //-----IAccessibility2 Implementation 2009
1913*2bfcd321SSteve Yin 
1914cdf0e10cSrcweir // -----------------------------------------------------------------------
1915cdf0e10cSrcweir 
1916cdf0e10cSrcweir void ValueSet::InsertItem( sal_uInt16 nItemId, sal_uInt16 nPos )
1917cdf0e10cSrcweir {
1918cdf0e10cSrcweir 	DBG_ASSERT( nItemId, "ValueSet::InsertItem(): ItemId == 0" );
1919cdf0e10cSrcweir 	DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
1920cdf0e10cSrcweir 				"ValueSet::InsertItem(): ItemId already exists" );
1921cdf0e10cSrcweir 
1922cdf0e10cSrcweir 	ValueSetItem* pItem = new ValueSetItem( *this );
1923cdf0e10cSrcweir 	pItem->mnId 	= nItemId;
1924cdf0e10cSrcweir 	pItem->meType	= VALUESETITEM_USERDRAW;
1925cdf0e10cSrcweir     mpImpl->mpItemList->Insert( pItem, (sal_uLong)nPos );
1926cdf0e10cSrcweir 
1927cdf0e10cSrcweir 	mbFormat = sal_True;
1928cdf0e10cSrcweir 	if ( IsReallyVisible() && IsUpdateMode() )
1929cdf0e10cSrcweir 		Invalidate();
1930cdf0e10cSrcweir }
1931cdf0e10cSrcweir 
1932cdf0e10cSrcweir // -----------------------------------------------------------------------
1933cdf0e10cSrcweir 
1934cdf0e10cSrcweir void ValueSet::InsertSpace( sal_uInt16 nItemId, sal_uInt16 nPos )
1935cdf0e10cSrcweir {
1936cdf0e10cSrcweir 	DBG_ASSERT( nItemId, "ValueSet::InsertSpace(): ItemId == 0" );
1937cdf0e10cSrcweir 	DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
1938cdf0e10cSrcweir 				"ValueSet::InsertSpace(): ItemId already exists" );
1939cdf0e10cSrcweir 
1940cdf0e10cSrcweir 	ValueSetItem* pItem = new ValueSetItem( *this );
1941cdf0e10cSrcweir 	pItem->mnId 	= nItemId;
1942cdf0e10cSrcweir 	pItem->meType	= VALUESETITEM_SPACE;
1943cdf0e10cSrcweir     mpImpl->mpItemList->Insert( pItem, (sal_uLong)nPos );
1944cdf0e10cSrcweir 
1945cdf0e10cSrcweir 	mbFormat = sal_True;
1946cdf0e10cSrcweir 	if ( IsReallyVisible() && IsUpdateMode() )
1947cdf0e10cSrcweir 		Invalidate();
1948cdf0e10cSrcweir }
1949cdf0e10cSrcweir 
1950cdf0e10cSrcweir // -----------------------------------------------------------------------
1951cdf0e10cSrcweir 
1952cdf0e10cSrcweir void ValueSet::RemoveItem( sal_uInt16 nItemId )
1953cdf0e10cSrcweir {
1954cdf0e10cSrcweir 	sal_uInt16 nPos = GetItemPos( nItemId );
1955cdf0e10cSrcweir 
1956cdf0e10cSrcweir 	if ( nPos == VALUESET_ITEM_NOTFOUND )
1957cdf0e10cSrcweir 		return;
1958cdf0e10cSrcweir 
1959cdf0e10cSrcweir     delete mpImpl->mpItemList->Remove( nPos );
1960cdf0e10cSrcweir 
1961cdf0e10cSrcweir 	// Variablen zuruecksetzen
1962cdf0e10cSrcweir 	if ( (mnHighItemId == nItemId) || (mnSelItemId == nItemId) )
1963cdf0e10cSrcweir 	{
1964cdf0e10cSrcweir 		mnCurCol		= 0;
1965cdf0e10cSrcweir 		mnOldItemId 	= 0;
1966cdf0e10cSrcweir 		mnHighItemId	= 0;
1967cdf0e10cSrcweir 		mnSelItemId 	= 0;
1968cdf0e10cSrcweir 		mbNoSelection	= sal_True;
1969cdf0e10cSrcweir 	}
1970cdf0e10cSrcweir 
1971cdf0e10cSrcweir 	mbFormat = sal_True;
1972cdf0e10cSrcweir 	if ( IsReallyVisible() && IsUpdateMode() )
1973cdf0e10cSrcweir 		Invalidate();
1974cdf0e10cSrcweir }
1975cdf0e10cSrcweir 
1976cdf0e10cSrcweir // -----------------------------------------------------------------------
1977cdf0e10cSrcweir 
1978cdf0e10cSrcweir void ValueSet::CopyItems( const ValueSet& rValueSet )
1979cdf0e10cSrcweir {
1980cdf0e10cSrcweir     ImplDeleteItems();
1981cdf0e10cSrcweir 
1982cdf0e10cSrcweir     ValueSetItem* pItem = rValueSet.mpImpl->mpItemList->First();
1983cdf0e10cSrcweir 	while ( pItem )
1984cdf0e10cSrcweir 	{
1985cdf0e10cSrcweir         ValueSetItem* pNewItem = new ValueSetItem( *this );
1986cdf0e10cSrcweir 
1987cdf0e10cSrcweir         pNewItem->mnId = pItem->mnId;
1988cdf0e10cSrcweir         pNewItem->mnBits = pItem->mnBits;
1989cdf0e10cSrcweir         pNewItem->meType = pItem->meType;
1990cdf0e10cSrcweir         pNewItem->maImage = pItem->maImage;
1991cdf0e10cSrcweir         pNewItem->maColor = pItem->maColor;
1992cdf0e10cSrcweir         pNewItem->maText = pItem->maText;
1993cdf0e10cSrcweir         pNewItem->mpData = pItem->mpData;
1994cdf0e10cSrcweir         pNewItem->maRect = pItem->maRect;
1995cdf0e10cSrcweir         pNewItem->mpxAcc = NULL;
1996cdf0e10cSrcweir 
1997cdf0e10cSrcweir         mpImpl->mpItemList->Insert( pNewItem );
1998cdf0e10cSrcweir         pItem = rValueSet.mpImpl->mpItemList->Next();
1999cdf0e10cSrcweir 	}
2000cdf0e10cSrcweir 
2001cdf0e10cSrcweir 	// Variablen zuruecksetzen
2002cdf0e10cSrcweir 	mnFirstLine 	= 0;
2003cdf0e10cSrcweir 	mnCurCol		= 0;
2004cdf0e10cSrcweir 	mnOldItemId 	= 0;
2005cdf0e10cSrcweir 	mnHighItemId	= 0;
2006cdf0e10cSrcweir 	mnSelItemId 	= 0;
2007cdf0e10cSrcweir 	mbNoSelection	= sal_True;
2008cdf0e10cSrcweir 
2009cdf0e10cSrcweir 	mbFormat = sal_True;
2010cdf0e10cSrcweir 	if ( IsReallyVisible() && IsUpdateMode() )
2011cdf0e10cSrcweir 		Invalidate();
2012cdf0e10cSrcweir }
2013cdf0e10cSrcweir 
2014cdf0e10cSrcweir // -----------------------------------------------------------------------
2015cdf0e10cSrcweir 
2016cdf0e10cSrcweir void ValueSet::Clear()
2017cdf0e10cSrcweir {
2018cdf0e10cSrcweir     ImplDeleteItems();
2019cdf0e10cSrcweir 
2020cdf0e10cSrcweir 	// Variablen zuruecksetzen
2021cdf0e10cSrcweir 	mnFirstLine 	= 0;
2022cdf0e10cSrcweir 	mnCurCol		= 0;
2023cdf0e10cSrcweir 	mnOldItemId 	= 0;
2024cdf0e10cSrcweir 	mnHighItemId	= 0;
2025cdf0e10cSrcweir 	mnSelItemId 	= 0;
2026cdf0e10cSrcweir 	mbNoSelection	= sal_True;
2027cdf0e10cSrcweir 
2028cdf0e10cSrcweir 	mbFormat = sal_True;
2029cdf0e10cSrcweir 	if ( IsReallyVisible() && IsUpdateMode() )
2030cdf0e10cSrcweir 		Invalidate();
2031cdf0e10cSrcweir }
2032cdf0e10cSrcweir 
2033cdf0e10cSrcweir // -----------------------------------------------------------------------
2034cdf0e10cSrcweir 
2035cdf0e10cSrcweir sal_uInt16 ValueSet::GetItemCount() const
2036cdf0e10cSrcweir {
2037cdf0e10cSrcweir     return (sal_uInt16)mpImpl->mpItemList->Count();
2038cdf0e10cSrcweir }
2039cdf0e10cSrcweir 
2040cdf0e10cSrcweir // -----------------------------------------------------------------------
2041cdf0e10cSrcweir 
2042cdf0e10cSrcweir sal_uInt16 ValueSet::GetItemPos( sal_uInt16 nItemId ) const
2043cdf0e10cSrcweir {
2044cdf0e10cSrcweir     ValueSetItem* pItem = mpImpl->mpItemList->First();
2045cdf0e10cSrcweir 	while ( pItem )
2046cdf0e10cSrcweir 	{
2047cdf0e10cSrcweir 		if ( pItem->mnId == nItemId )
2048cdf0e10cSrcweir             return (sal_uInt16)mpImpl->mpItemList->GetCurPos();
2049cdf0e10cSrcweir         pItem = mpImpl->mpItemList->Next();
2050cdf0e10cSrcweir 	}
2051cdf0e10cSrcweir 
2052cdf0e10cSrcweir 	return VALUESET_ITEM_NOTFOUND;
2053cdf0e10cSrcweir }
2054cdf0e10cSrcweir 
2055cdf0e10cSrcweir // -----------------------------------------------------------------------
2056cdf0e10cSrcweir 
2057cdf0e10cSrcweir sal_uInt16 ValueSet::GetItemId( sal_uInt16 nPos ) const
2058cdf0e10cSrcweir {
2059cdf0e10cSrcweir     ValueSetItem* pItem = mpImpl->mpItemList->GetObject( nPos );
2060cdf0e10cSrcweir 
2061cdf0e10cSrcweir 	if ( pItem )
2062cdf0e10cSrcweir 		return pItem->mnId;
2063cdf0e10cSrcweir 	else
2064cdf0e10cSrcweir 		return 0;
2065cdf0e10cSrcweir }
2066cdf0e10cSrcweir 
2067cdf0e10cSrcweir // -----------------------------------------------------------------------
2068cdf0e10cSrcweir 
2069cdf0e10cSrcweir sal_uInt16 ValueSet::GetItemId( const Point& rPos ) const
2070cdf0e10cSrcweir {
2071cdf0e10cSrcweir 	sal_uInt16 nItemPos = ImplGetItem( rPos );
2072cdf0e10cSrcweir 	if ( nItemPos != VALUESET_ITEM_NOTFOUND )
2073cdf0e10cSrcweir 		return GetItemId( nItemPos );
2074cdf0e10cSrcweir 
2075cdf0e10cSrcweir 	return 0;
2076cdf0e10cSrcweir }
2077cdf0e10cSrcweir 
2078cdf0e10cSrcweir // -----------------------------------------------------------------------
2079cdf0e10cSrcweir 
2080cdf0e10cSrcweir Rectangle ValueSet::GetItemRect( sal_uInt16 nItemId ) const
2081cdf0e10cSrcweir {
2082cdf0e10cSrcweir 	sal_uInt16 nPos = GetItemPos( nItemId );
2083cdf0e10cSrcweir 
2084cdf0e10cSrcweir 	if ( nPos != VALUESET_ITEM_NOTFOUND )
2085cdf0e10cSrcweir         return mpImpl->mpItemList->GetObject( nPos )->maRect;
2086cdf0e10cSrcweir 	else
2087cdf0e10cSrcweir 		return Rectangle();
2088cdf0e10cSrcweir }
2089cdf0e10cSrcweir 
2090cdf0e10cSrcweir // -----------------------------------------------------------------------
2091cdf0e10cSrcweir 
2092cdf0e10cSrcweir void ValueSet::EnableFullItemMode( sal_Bool bFullMode )
2093cdf0e10cSrcweir {
2094cdf0e10cSrcweir 	mbFullMode = bFullMode;
2095cdf0e10cSrcweir }
2096cdf0e10cSrcweir 
2097cdf0e10cSrcweir // -----------------------------------------------------------------------
2098cdf0e10cSrcweir 
2099cdf0e10cSrcweir void ValueSet::SetColCount( sal_uInt16 nNewCols )
2100cdf0e10cSrcweir {
2101cdf0e10cSrcweir 	if ( mnUserCols != nNewCols )
2102cdf0e10cSrcweir 	{
2103cdf0e10cSrcweir 		mnUserCols = nNewCols;
2104cdf0e10cSrcweir 		mbFormat = sal_True;
2105cdf0e10cSrcweir 		if ( IsReallyVisible() && IsUpdateMode() )
2106cdf0e10cSrcweir 			Invalidate();
2107cdf0e10cSrcweir 	}
2108cdf0e10cSrcweir }
2109cdf0e10cSrcweir 
2110cdf0e10cSrcweir // -----------------------------------------------------------------------
2111cdf0e10cSrcweir 
2112cdf0e10cSrcweir void ValueSet::SetLineCount( sal_uInt16 nNewLines )
2113cdf0e10cSrcweir {
2114cdf0e10cSrcweir 	if ( mnUserVisLines != nNewLines )
2115cdf0e10cSrcweir 	{
2116cdf0e10cSrcweir 		mnUserVisLines = nNewLines;
2117cdf0e10cSrcweir 		mbFormat = sal_True;
2118cdf0e10cSrcweir 		if ( IsReallyVisible() && IsUpdateMode() )
2119cdf0e10cSrcweir 			Invalidate();
2120cdf0e10cSrcweir 	}
2121cdf0e10cSrcweir }
2122cdf0e10cSrcweir 
2123cdf0e10cSrcweir // -----------------------------------------------------------------------
2124cdf0e10cSrcweir 
2125cdf0e10cSrcweir void ValueSet::SetItemWidth( long nNewItemWidth )
2126cdf0e10cSrcweir {
2127cdf0e10cSrcweir 	if ( mnUserItemWidth != nNewItemWidth )
2128cdf0e10cSrcweir 	{
2129cdf0e10cSrcweir 		mnUserItemWidth = nNewItemWidth;
2130cdf0e10cSrcweir 		mbFormat = sal_True;
2131cdf0e10cSrcweir 		if ( IsReallyVisible() && IsUpdateMode() )
2132cdf0e10cSrcweir 			Invalidate();
2133cdf0e10cSrcweir 	}
2134cdf0e10cSrcweir }
2135cdf0e10cSrcweir 
2136cdf0e10cSrcweir // -----------------------------------------------------------------------
2137cdf0e10cSrcweir 
2138cdf0e10cSrcweir void ValueSet::SetItemHeight( long nNewItemHeight )
2139cdf0e10cSrcweir {
2140cdf0e10cSrcweir 	if ( mnUserItemHeight != nNewItemHeight )
2141cdf0e10cSrcweir 	{
2142cdf0e10cSrcweir 		mnUserItemHeight = nNewItemHeight;
2143cdf0e10cSrcweir 		mbFormat = sal_True;
2144cdf0e10cSrcweir 		if ( IsReallyVisible() && IsUpdateMode() )
2145cdf0e10cSrcweir 			Invalidate();
2146cdf0e10cSrcweir 	}
2147cdf0e10cSrcweir }
2148cdf0e10cSrcweir 
2149cdf0e10cSrcweir // -----------------------------------------------------------------------
2150cdf0e10cSrcweir 
2151cdf0e10cSrcweir void ValueSet::SetFirstLine( sal_uInt16 nNewLine )
2152cdf0e10cSrcweir {
2153cdf0e10cSrcweir 	if ( mnFirstLine != nNewLine )
2154cdf0e10cSrcweir 	{
2155cdf0e10cSrcweir 		mnFirstLine = nNewLine;
2156cdf0e10cSrcweir 		mbFormat = sal_True;
2157cdf0e10cSrcweir 		if ( IsReallyVisible() && IsUpdateMode() )
2158cdf0e10cSrcweir 			Invalidate();
2159cdf0e10cSrcweir 	}
2160cdf0e10cSrcweir }
2161cdf0e10cSrcweir 
2162cdf0e10cSrcweir // -----------------------------------------------------------------------
2163cdf0e10cSrcweir 
2164cdf0e10cSrcweir void ValueSet::SelectItem( sal_uInt16 nItemId )
2165cdf0e10cSrcweir {
2166cdf0e10cSrcweir 	sal_uInt16 nItemPos = 0;
2167cdf0e10cSrcweir 
2168cdf0e10cSrcweir 	if ( nItemId )
2169cdf0e10cSrcweir 	{
2170cdf0e10cSrcweir 		nItemPos = GetItemPos( nItemId );
2171cdf0e10cSrcweir 		if ( nItemPos == VALUESET_ITEM_NOTFOUND )
2172cdf0e10cSrcweir 			return;
2173cdf0e10cSrcweir         if ( mpImpl->mpItemList->GetObject( nItemPos )->meType == VALUESETITEM_SPACE )
2174cdf0e10cSrcweir 			return;
2175cdf0e10cSrcweir 	}
2176cdf0e10cSrcweir 
2177cdf0e10cSrcweir 	if ( (mnSelItemId != nItemId) || mbNoSelection )
2178cdf0e10cSrcweir 	{
2179cdf0e10cSrcweir         sal_uInt16 nOldItem = mnSelItemId ? mnSelItemId : 1;
2180cdf0e10cSrcweir 		mnSelItemId = nItemId;
2181cdf0e10cSrcweir 		mbNoSelection = sal_False;
2182cdf0e10cSrcweir 
2183cdf0e10cSrcweir 		sal_Bool bNewOut;
2184cdf0e10cSrcweir 		sal_Bool bNewLine;
2185cdf0e10cSrcweir 		if ( !mbFormat && IsReallyVisible() && IsUpdateMode() )
2186cdf0e10cSrcweir 			bNewOut = sal_True;
2187cdf0e10cSrcweir 		else
2188cdf0e10cSrcweir 			bNewOut = sal_False;
2189cdf0e10cSrcweir 		bNewLine = sal_False;
2190cdf0e10cSrcweir 
2191cdf0e10cSrcweir 		// Gegebenenfalls in den sichtbaren Bereich scrollen
2192cdf0e10cSrcweir 		if ( mbScroll && nItemId )
2193cdf0e10cSrcweir 		{
2194cdf0e10cSrcweir 			sal_uInt16 nNewLine = (sal_uInt16)(nItemPos / mnCols);
2195cdf0e10cSrcweir 			if ( nNewLine < mnFirstLine )
2196cdf0e10cSrcweir 			{
2197cdf0e10cSrcweir 				mnFirstLine = nNewLine;
2198cdf0e10cSrcweir 				bNewLine = sal_True;
2199cdf0e10cSrcweir 			}
2200cdf0e10cSrcweir 			else if ( nNewLine > (sal_uInt16)(mnFirstLine+mnVisLines-1) )
2201cdf0e10cSrcweir 			{
2202cdf0e10cSrcweir 				mnFirstLine = (sal_uInt16)(nNewLine-mnVisLines+1);
2203cdf0e10cSrcweir 				bNewLine = sal_True;
2204cdf0e10cSrcweir 			}
2205cdf0e10cSrcweir 		}
2206cdf0e10cSrcweir 
2207cdf0e10cSrcweir 		if ( bNewOut )
2208cdf0e10cSrcweir 		{
2209cdf0e10cSrcweir 			if ( bNewLine )
2210cdf0e10cSrcweir 			{
2211cdf0e10cSrcweir 				// Falls sich der sichtbare Bereich geaendert hat,
2212cdf0e10cSrcweir 				// alles neu ausgeben
2213cdf0e10cSrcweir 				mbFormat = sal_True;
2214cdf0e10cSrcweir 				ImplDraw();
2215cdf0e10cSrcweir 			}
2216cdf0e10cSrcweir 			else
2217cdf0e10cSrcweir 			{
2218cdf0e10cSrcweir 				// alte Selection wegnehmen und neue ausgeben
2219cdf0e10cSrcweir 				ImplHideSelect( nOldItem );
2220cdf0e10cSrcweir 				ImplDrawSelect();
2221cdf0e10cSrcweir 			}
2222cdf0e10cSrcweir 		}
2223cdf0e10cSrcweir 
2224cdf0e10cSrcweir         if( ImplHasAccessibleListeners() )
2225cdf0e10cSrcweir         {
2226cdf0e10cSrcweir             // focus event (deselect)
2227cdf0e10cSrcweir             if( nOldItem )
2228cdf0e10cSrcweir             {
2229cdf0e10cSrcweir 	            const sal_uInt16 nPos = GetItemPos( nItemId );
2230cdf0e10cSrcweir 
2231cdf0e10cSrcweir 	            if( nPos != VALUESET_ITEM_NOTFOUND )
2232cdf0e10cSrcweir                 {
2233cdf0e10cSrcweir                     ValueItemAcc* pItemAcc = ValueItemAcc::getImplementation(
2234cdf0e10cSrcweir                         mpImpl->mpItemList->GetObject( nPos )->GetAccessible( mpImpl->mbIsTransientChildrenDisabled ) );
2235cdf0e10cSrcweir 
2236cdf0e10cSrcweir                     if( pItemAcc )
2237cdf0e10cSrcweir                     {
2238cdf0e10cSrcweir                         ::com::sun::star::uno::Any aOldAny, aNewAny;
2239cdf0e10cSrcweir                         if( !mpImpl->mbIsTransientChildrenDisabled)
2240cdf0e10cSrcweir                         {
2241cdf0e10cSrcweir                             aOldAny <<= ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(
2242cdf0e10cSrcweir                                 static_cast< ::cppu::OWeakObject* >( pItemAcc ));
2243cdf0e10cSrcweir                             ImplFireAccessibleEvent (::com::sun::star::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny );
2244cdf0e10cSrcweir                         }
2245cdf0e10cSrcweir                         else
2246cdf0e10cSrcweir                         {
2247cdf0e10cSrcweir                             aOldAny <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED;
2248cdf0e10cSrcweir                             pItemAcc->FireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED, aOldAny, aNewAny );
2249cdf0e10cSrcweir                         }
2250cdf0e10cSrcweir                     }
2251cdf0e10cSrcweir                 }
2252cdf0e10cSrcweir             }
2253cdf0e10cSrcweir 
2254cdf0e10cSrcweir             // focus event (select)
2255cdf0e10cSrcweir             const sal_uInt16 nPos = GetItemPos( mnSelItemId );
2256cdf0e10cSrcweir 
2257cdf0e10cSrcweir             ValueSetItem* pItem;
2258cdf0e10cSrcweir             if( nPos != VALUESET_ITEM_NOTFOUND )
2259cdf0e10cSrcweir                 pItem = mpImpl->mpItemList->GetObject(nPos);
2260cdf0e10cSrcweir             else
2261cdf0e10cSrcweir                 pItem = mpNoneItem;
2262cdf0e10cSrcweir 
2263cdf0e10cSrcweir             ValueItemAcc* pItemAcc = NULL;
2264cdf0e10cSrcweir             if (pItem != NULL)
2265cdf0e10cSrcweir                 pItemAcc = ValueItemAcc::getImplementation(pItem->GetAccessible( mpImpl->mbIsTransientChildrenDisabled ) );
2266cdf0e10cSrcweir 
2267cdf0e10cSrcweir             if( pItemAcc )
2268cdf0e10cSrcweir             {
2269cdf0e10cSrcweir                 ::com::sun::star::uno::Any aOldAny, aNewAny;
2270cdf0e10cSrcweir                 if( !mpImpl->mbIsTransientChildrenDisabled)
2271cdf0e10cSrcweir                 {
2272cdf0e10cSrcweir                     aNewAny <<= ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(
2273cdf0e10cSrcweir                         static_cast< ::cppu::OWeakObject* >( pItemAcc ));
2274cdf0e10cSrcweir                     ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny );
2275cdf0e10cSrcweir                 }
2276cdf0e10cSrcweir                 else
2277cdf0e10cSrcweir                 {
2278cdf0e10cSrcweir                     aNewAny <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED;
2279cdf0e10cSrcweir                     pItemAcc->FireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED, aOldAny, aNewAny );
2280cdf0e10cSrcweir                 }
2281cdf0e10cSrcweir             }
2282cdf0e10cSrcweir 
2283cdf0e10cSrcweir             // selection event
2284cdf0e10cSrcweir             ::com::sun::star::uno::Any aOldAny, aNewAny;
2285cdf0e10cSrcweir             ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::SELECTION_CHANGED, aOldAny, aNewAny );
2286cdf0e10cSrcweir         }
2287cdf0e10cSrcweir 		mpImpl->maHighlightHdl.Call(this);
2288cdf0e10cSrcweir 	}
2289cdf0e10cSrcweir }
2290cdf0e10cSrcweir 
2291cdf0e10cSrcweir // -----------------------------------------------------------------------
2292cdf0e10cSrcweir 
2293cdf0e10cSrcweir void ValueSet::SetNoSelection()
2294cdf0e10cSrcweir {
2295cdf0e10cSrcweir 	mbNoSelection	= sal_True;
2296cdf0e10cSrcweir 	mbHighlight 	= sal_False;
2297cdf0e10cSrcweir 	mbSelection 	= sal_False;
2298cdf0e10cSrcweir 
2299cdf0e10cSrcweir 	if ( IsReallyVisible() && IsUpdateMode() )
2300cdf0e10cSrcweir 		ImplDraw();
2301cdf0e10cSrcweir }
2302cdf0e10cSrcweir 
2303cdf0e10cSrcweir // -----------------------------------------------------------------------
2304cdf0e10cSrcweir 
2305cdf0e10cSrcweir void ValueSet::SetItemBits( sal_uInt16 nItemId, sal_uInt16 nItemBits )
2306cdf0e10cSrcweir {
2307cdf0e10cSrcweir 	sal_uInt16 nPos = GetItemPos( nItemId );
2308cdf0e10cSrcweir 
2309cdf0e10cSrcweir 	if ( nPos != VALUESET_ITEM_NOTFOUND )
2310cdf0e10cSrcweir         mpImpl->mpItemList->GetObject( nPos )->mnBits = nItemBits;
2311cdf0e10cSrcweir }
2312cdf0e10cSrcweir 
2313cdf0e10cSrcweir // -----------------------------------------------------------------------
2314cdf0e10cSrcweir 
2315cdf0e10cSrcweir sal_uInt16 ValueSet::GetItemBits( sal_uInt16 nItemId ) const
2316cdf0e10cSrcweir {
2317cdf0e10cSrcweir 	sal_uInt16 nPos = GetItemPos( nItemId );
2318cdf0e10cSrcweir 
2319cdf0e10cSrcweir 	if ( nPos != VALUESET_ITEM_NOTFOUND )
2320cdf0e10cSrcweir         return mpImpl->mpItemList->GetObject( nPos )->mnBits;
2321cdf0e10cSrcweir 	else
2322cdf0e10cSrcweir 		return 0;
2323cdf0e10cSrcweir }
2324cdf0e10cSrcweir 
2325cdf0e10cSrcweir // -----------------------------------------------------------------------
2326cdf0e10cSrcweir 
2327cdf0e10cSrcweir void ValueSet::SetItemImage( sal_uInt16 nItemId, const Image& rImage )
2328cdf0e10cSrcweir {
2329cdf0e10cSrcweir 	sal_uInt16 nPos = GetItemPos( nItemId );
2330cdf0e10cSrcweir 
2331cdf0e10cSrcweir 	if ( nPos == VALUESET_ITEM_NOTFOUND )
2332cdf0e10cSrcweir 		return;
2333cdf0e10cSrcweir 
2334cdf0e10cSrcweir     ValueSetItem* pItem = mpImpl->mpItemList->GetObject( nPos );
2335cdf0e10cSrcweir 	pItem->meType  = VALUESETITEM_IMAGE;
2336cdf0e10cSrcweir 	pItem->maImage = rImage;
2337cdf0e10cSrcweir 
2338cdf0e10cSrcweir 	if ( !mbFormat && IsReallyVisible() && IsUpdateMode() )
2339cdf0e10cSrcweir 	{
2340cdf0e10cSrcweir 		ImplFormatItem( pItem );
2341cdf0e10cSrcweir 		Invalidate( pItem->maRect );
2342cdf0e10cSrcweir 	}
2343cdf0e10cSrcweir 	else
2344cdf0e10cSrcweir 		mbFormat = sal_True;
2345cdf0e10cSrcweir }
2346cdf0e10cSrcweir 
2347cdf0e10cSrcweir // -----------------------------------------------------------------------
2348cdf0e10cSrcweir 
2349cdf0e10cSrcweir Image ValueSet::GetItemImage( sal_uInt16 nItemId ) const
2350cdf0e10cSrcweir {
2351cdf0e10cSrcweir 	sal_uInt16 nPos = GetItemPos( nItemId );
2352cdf0e10cSrcweir 
2353cdf0e10cSrcweir 	if ( nPos != VALUESET_ITEM_NOTFOUND )
2354cdf0e10cSrcweir         return mpImpl->mpItemList->GetObject( nPos )->maImage;
2355cdf0e10cSrcweir 	else
2356cdf0e10cSrcweir 		return Image();
2357cdf0e10cSrcweir }
2358cdf0e10cSrcweir 
2359cdf0e10cSrcweir // -----------------------------------------------------------------------
2360cdf0e10cSrcweir 
2361cdf0e10cSrcweir void ValueSet::SetItemColor( sal_uInt16 nItemId, const Color& rColor )
2362cdf0e10cSrcweir {
2363cdf0e10cSrcweir 	sal_uInt16 nPos = GetItemPos( nItemId );
2364cdf0e10cSrcweir 
2365cdf0e10cSrcweir 	if ( nPos == VALUESET_ITEM_NOTFOUND )
2366cdf0e10cSrcweir 		return;
2367cdf0e10cSrcweir 
2368cdf0e10cSrcweir     ValueSetItem* pItem = mpImpl->mpItemList->GetObject( nPos );
2369cdf0e10cSrcweir 	pItem->meType  = VALUESETITEM_COLOR;
2370cdf0e10cSrcweir 	pItem->maColor = rColor;
2371cdf0e10cSrcweir 
2372cdf0e10cSrcweir 	if ( !mbFormat && IsReallyVisible() && IsUpdateMode() )
2373cdf0e10cSrcweir 	{
2374cdf0e10cSrcweir 		ImplFormatItem( pItem );
2375cdf0e10cSrcweir 		Invalidate( pItem->maRect );
2376cdf0e10cSrcweir 	}
2377cdf0e10cSrcweir 	else
2378cdf0e10cSrcweir 		mbFormat = sal_True;
2379cdf0e10cSrcweir }
2380cdf0e10cSrcweir 
2381cdf0e10cSrcweir // -----------------------------------------------------------------------
2382cdf0e10cSrcweir 
2383cdf0e10cSrcweir Color ValueSet::GetItemColor( sal_uInt16 nItemId ) const
2384cdf0e10cSrcweir {
2385cdf0e10cSrcweir 	sal_uInt16 nPos = GetItemPos( nItemId );
2386cdf0e10cSrcweir 
2387cdf0e10cSrcweir 	if ( nPos != VALUESET_ITEM_NOTFOUND )
2388cdf0e10cSrcweir         return mpImpl->mpItemList->GetObject( nPos )->maColor;
2389cdf0e10cSrcweir 	else
2390cdf0e10cSrcweir 		return Color();
2391cdf0e10cSrcweir }
2392cdf0e10cSrcweir 
2393cdf0e10cSrcweir // -----------------------------------------------------------------------
2394cdf0e10cSrcweir 
2395cdf0e10cSrcweir void ValueSet::SetItemData( sal_uInt16 nItemId, void* pData )
2396cdf0e10cSrcweir {
2397cdf0e10cSrcweir 	sal_uInt16 nPos = GetItemPos( nItemId );
2398cdf0e10cSrcweir 
2399cdf0e10cSrcweir 	if ( nPos == VALUESET_ITEM_NOTFOUND )
2400cdf0e10cSrcweir 		return;
2401cdf0e10cSrcweir 
2402cdf0e10cSrcweir     ValueSetItem* pItem = mpImpl->mpItemList->GetObject( nPos );
2403cdf0e10cSrcweir 	pItem->mpData = pData;
2404cdf0e10cSrcweir 
2405cdf0e10cSrcweir 	if ( pItem->meType == VALUESETITEM_USERDRAW )
2406cdf0e10cSrcweir 	{
2407cdf0e10cSrcweir 		if ( !mbFormat && IsReallyVisible() && IsUpdateMode() )
2408cdf0e10cSrcweir 		{
2409cdf0e10cSrcweir 			ImplFormatItem( pItem );
2410cdf0e10cSrcweir 			Invalidate( pItem->maRect );
2411cdf0e10cSrcweir 		}
2412cdf0e10cSrcweir 		else
2413cdf0e10cSrcweir 			mbFormat = sal_True;
2414cdf0e10cSrcweir 	}
2415cdf0e10cSrcweir }
2416cdf0e10cSrcweir 
2417cdf0e10cSrcweir // -----------------------------------------------------------------------
2418cdf0e10cSrcweir 
2419cdf0e10cSrcweir void* ValueSet::GetItemData( sal_uInt16 nItemId ) const
2420cdf0e10cSrcweir {
2421cdf0e10cSrcweir 	sal_uInt16 nPos = GetItemPos( nItemId );
2422cdf0e10cSrcweir 
2423cdf0e10cSrcweir 	if ( nPos != VALUESET_ITEM_NOTFOUND )
2424cdf0e10cSrcweir         return mpImpl->mpItemList->GetObject( nPos )->mpData;
2425cdf0e10cSrcweir 	else
2426cdf0e10cSrcweir 		return NULL;
2427cdf0e10cSrcweir }
2428cdf0e10cSrcweir 
2429cdf0e10cSrcweir // -----------------------------------------------------------------------
2430cdf0e10cSrcweir 
2431cdf0e10cSrcweir void ValueSet::SetItemText( sal_uInt16 nItemId, const XubString& rText )
2432cdf0e10cSrcweir {
2433cdf0e10cSrcweir 	sal_uInt16 nPos = GetItemPos( nItemId );
2434cdf0e10cSrcweir 
2435cdf0e10cSrcweir 	if ( nPos == VALUESET_ITEM_NOTFOUND )
2436cdf0e10cSrcweir 		return;
2437cdf0e10cSrcweir 
2438cdf0e10cSrcweir 
2439cdf0e10cSrcweir     ValueSetItem* pItem = mpImpl->mpItemList->GetObject( nPos );
2440cdf0e10cSrcweir 
2441cdf0e10cSrcweir     // Remember old and new name for accessibility event.
2442cdf0e10cSrcweir     ::com::sun::star::uno::Any aOldName, aNewName;
2443cdf0e10cSrcweir     ::rtl::OUString sString (pItem->maText);
2444cdf0e10cSrcweir     aOldName <<= sString;
2445cdf0e10cSrcweir     sString = rText;
2446cdf0e10cSrcweir     aNewName <<= sString;
2447cdf0e10cSrcweir 
2448cdf0e10cSrcweir 	pItem->maText = rText;
2449cdf0e10cSrcweir 
2450cdf0e10cSrcweir 	if ( !mbFormat && IsReallyVisible() && IsUpdateMode() )
2451cdf0e10cSrcweir 	{
2452cdf0e10cSrcweir 		sal_uInt16 nTempId = mnSelItemId;
2453cdf0e10cSrcweir 
2454cdf0e10cSrcweir 		if ( mbHighlight )
2455cdf0e10cSrcweir 			nTempId = mnHighItemId;
2456cdf0e10cSrcweir 
2457cdf0e10cSrcweir 		if ( nTempId == nItemId )
2458cdf0e10cSrcweir 			ImplDrawItemText( pItem->maText );
2459cdf0e10cSrcweir 	}
2460cdf0e10cSrcweir 
2461cdf0e10cSrcweir     if (ImplHasAccessibleListeners())
2462cdf0e10cSrcweir     {
2463cdf0e10cSrcweir         ::com::sun::star::uno::Reference<
2464cdf0e10cSrcweir               ::com::sun::star::accessibility::XAccessible> xAccessible (
2465cdf0e10cSrcweir                   pItem->GetAccessible( mpImpl->mbIsTransientChildrenDisabled ) );
2466cdf0e10cSrcweir         static_cast<ValueItemAcc*>(xAccessible.get())->FireAccessibleEvent (
2467cdf0e10cSrcweir             ::com::sun::star::accessibility::AccessibleEventId::NAME_CHANGED,
2468cdf0e10cSrcweir             aOldName, aNewName);
2469cdf0e10cSrcweir     }
2470cdf0e10cSrcweir }
2471cdf0e10cSrcweir 
2472cdf0e10cSrcweir // -----------------------------------------------------------------------
2473cdf0e10cSrcweir 
2474cdf0e10cSrcweir XubString ValueSet::GetItemText( sal_uInt16 nItemId ) const
2475cdf0e10cSrcweir {
2476cdf0e10cSrcweir 	sal_uInt16 nPos = GetItemPos( nItemId );
2477cdf0e10cSrcweir 
2478cdf0e10cSrcweir 	if ( nPos != VALUESET_ITEM_NOTFOUND )
2479cdf0e10cSrcweir         return mpImpl->mpItemList->GetObject( nPos )->maText;
2480cdf0e10cSrcweir 	else
2481cdf0e10cSrcweir 		return XubString();
2482cdf0e10cSrcweir }
2483cdf0e10cSrcweir 
2484cdf0e10cSrcweir // -----------------------------------------------------------------------
2485cdf0e10cSrcweir 
2486cdf0e10cSrcweir void ValueSet::SetColor( const Color& rColor )
2487cdf0e10cSrcweir {
2488cdf0e10cSrcweir 	maColor 	= rColor;
2489cdf0e10cSrcweir 	mbFormat	= sal_True;
2490cdf0e10cSrcweir 	if ( IsReallyVisible() && IsUpdateMode() )
2491cdf0e10cSrcweir 		ImplDraw();
2492cdf0e10cSrcweir }
2493cdf0e10cSrcweir 
2494cdf0e10cSrcweir // -----------------------------------------------------------------------
2495cdf0e10cSrcweir 
2496cdf0e10cSrcweir void ValueSet::SetExtraSpacing( sal_uInt16 nNewSpacing )
2497cdf0e10cSrcweir {
2498cdf0e10cSrcweir 	if ( GetStyle() & WB_ITEMBORDER )
2499cdf0e10cSrcweir 	{
2500cdf0e10cSrcweir 		mnSpacing = nNewSpacing;
2501cdf0e10cSrcweir 
2502cdf0e10cSrcweir 		mbFormat = sal_True;
2503cdf0e10cSrcweir 		if ( IsReallyVisible() && IsUpdateMode() )
2504cdf0e10cSrcweir 			Invalidate();
2505cdf0e10cSrcweir 	}
2506cdf0e10cSrcweir }
2507cdf0e10cSrcweir 
2508cdf0e10cSrcweir // -----------------------------------------------------------------------
2509cdf0e10cSrcweir 
2510cdf0e10cSrcweir void ValueSet::StartSelection()
2511cdf0e10cSrcweir {
2512cdf0e10cSrcweir 	mnOldItemId 	= mnSelItemId;
2513cdf0e10cSrcweir 	mbHighlight 	= sal_True;
2514cdf0e10cSrcweir 	mbSelection 	= sal_True;
2515cdf0e10cSrcweir 	mnHighItemId	= mnSelItemId;
2516cdf0e10cSrcweir }
2517cdf0e10cSrcweir 
2518cdf0e10cSrcweir // -----------------------------------------------------------------------
2519cdf0e10cSrcweir 
2520cdf0e10cSrcweir void ValueSet::EndSelection()
2521cdf0e10cSrcweir {
2522cdf0e10cSrcweir 	if ( mbHighlight )
2523cdf0e10cSrcweir 	{
2524cdf0e10cSrcweir 		if ( IsTracking() )
2525cdf0e10cSrcweir 			EndTracking( ENDTRACK_CANCEL );
2526cdf0e10cSrcweir 
2527cdf0e10cSrcweir 		ImplHighlightItem( mnSelItemId );
2528cdf0e10cSrcweir 		mbHighlight = sal_False;
2529cdf0e10cSrcweir 	}
2530cdf0e10cSrcweir 	mbSelection = sal_False;
2531cdf0e10cSrcweir }
2532cdf0e10cSrcweir 
2533cdf0e10cSrcweir // -----------------------------------------------------------------------
2534cdf0e10cSrcweir 
2535cdf0e10cSrcweir sal_Bool ValueSet::StartDrag( const CommandEvent& rCEvt, Region& rRegion )
2536cdf0e10cSrcweir {
2537cdf0e10cSrcweir 	if ( rCEvt.GetCommand() != COMMAND_STARTDRAG )
2538cdf0e10cSrcweir 		return sal_False;
2539cdf0e10cSrcweir 
2540cdf0e10cSrcweir 	// Gegebenenfalls eine vorhandene Aktion abbrechen
2541cdf0e10cSrcweir 	EndSelection();
2542cdf0e10cSrcweir 
2543cdf0e10cSrcweir 	// Testen, ob angeklickte Seite selektiert ist. Falls dies nicht
2544cdf0e10cSrcweir 	// der Fall ist, setzen wir ihn als aktuellen Eintrag. Falls Drag and
2545cdf0e10cSrcweir 	// Drop auch mal ueber Tastatur ausgeloest werden kann, testen wir
2546cdf0e10cSrcweir 	// dies nur bei einer Mausaktion.
2547cdf0e10cSrcweir 	sal_uInt16 nSelId;
2548cdf0e10cSrcweir 	if ( rCEvt.IsMouseEvent() )
2549cdf0e10cSrcweir 		nSelId = GetItemId( rCEvt.GetMousePosPixel() );
2550cdf0e10cSrcweir 	else
2551cdf0e10cSrcweir 		nSelId = mnSelItemId;
2552cdf0e10cSrcweir 
2553cdf0e10cSrcweir 	// Falls kein Eintrag angeklickt wurde, starten wir kein Dragging
2554cdf0e10cSrcweir 	if ( !nSelId )
2555cdf0e10cSrcweir 		return sal_False;
2556cdf0e10cSrcweir 
2557cdf0e10cSrcweir 	// Testen, ob Seite selektiertiert ist. Falls nicht, als aktuelle
2558cdf0e10cSrcweir 	// Seite setzen und Select rufen.
2559cdf0e10cSrcweir 	if ( nSelId != mnSelItemId )
2560cdf0e10cSrcweir 	{
2561cdf0e10cSrcweir 		SelectItem( nSelId );
2562cdf0e10cSrcweir 		Update();
2563cdf0e10cSrcweir 		Select();
2564cdf0e10cSrcweir 	}
2565cdf0e10cSrcweir 
2566cdf0e10cSrcweir 	Region aRegion;
2567cdf0e10cSrcweir 
2568cdf0e10cSrcweir 	// Region zuweisen
2569cdf0e10cSrcweir 	rRegion = aRegion;
2570cdf0e10cSrcweir 
2571cdf0e10cSrcweir 	return sal_True;
2572cdf0e10cSrcweir }
2573cdf0e10cSrcweir 
2574cdf0e10cSrcweir // -----------------------------------------------------------------------
2575cdf0e10cSrcweir 
2576cdf0e10cSrcweir Size ValueSet::CalcWindowSizePixel( const Size& rItemSize, sal_uInt16 nDesireCols,
2577cdf0e10cSrcweir 									sal_uInt16 nDesireLines )
2578cdf0e10cSrcweir {
2579cdf0e10cSrcweir 	long nCalcCols = (long)nDesireCols;
2580cdf0e10cSrcweir 	long nCalcLines = (long)nDesireLines;
2581cdf0e10cSrcweir 
2582cdf0e10cSrcweir 	if ( !nCalcCols )
2583cdf0e10cSrcweir 	{
2584cdf0e10cSrcweir 		if ( mnUserCols )
2585cdf0e10cSrcweir 			nCalcCols = (long)mnUserCols;
2586cdf0e10cSrcweir 		else
2587cdf0e10cSrcweir 			nCalcCols = 1;
2588cdf0e10cSrcweir 	}
2589cdf0e10cSrcweir 
2590cdf0e10cSrcweir 	if ( !nCalcLines )
2591cdf0e10cSrcweir 	{
2592cdf0e10cSrcweir 		nCalcLines = mnVisLines;
2593cdf0e10cSrcweir 
2594cdf0e10cSrcweir 		if ( mbFormat )
2595cdf0e10cSrcweir 		{
2596cdf0e10cSrcweir 			if ( mnUserVisLines )
2597cdf0e10cSrcweir 				nCalcLines = mnUserVisLines;
2598cdf0e10cSrcweir 			else
2599cdf0e10cSrcweir 			{
2600cdf0e10cSrcweir                 nCalcLines = (long)mpImpl->mpItemList->Count() / nCalcCols;
2601cdf0e10cSrcweir                 if ( mpImpl->mpItemList->Count() % nCalcCols )
2602cdf0e10cSrcweir 					nCalcLines++;
2603cdf0e10cSrcweir 				else if ( !nCalcLines )
2604cdf0e10cSrcweir 					nCalcLines = 1;
2605cdf0e10cSrcweir 			}
2606cdf0e10cSrcweir 		}
2607cdf0e10cSrcweir 	}
2608cdf0e10cSrcweir 
2609cdf0e10cSrcweir 	Size		aSize( rItemSize.Width()*nCalcCols, rItemSize.Height()*nCalcLines );
2610cdf0e10cSrcweir 	WinBits 	nStyle = GetStyle();
2611cdf0e10cSrcweir 	long		nTxtHeight = GetTextHeight();
2612cdf0e10cSrcweir 	long		nSpace;
2613cdf0e10cSrcweir 	long		n;
2614cdf0e10cSrcweir 
2615cdf0e10cSrcweir 	if ( nStyle & WB_ITEMBORDER )
2616cdf0e10cSrcweir 	{
2617cdf0e10cSrcweir 		if ( nStyle & WB_DOUBLEBORDER )
2618cdf0e10cSrcweir 			n = ITEM_OFFSET_DOUBLE;
2619cdf0e10cSrcweir 		else
2620cdf0e10cSrcweir 			n = ITEM_OFFSET;
2621cdf0e10cSrcweir 
2622cdf0e10cSrcweir 		aSize.Width()  += n*nCalcCols;
2623cdf0e10cSrcweir 		aSize.Height() += n*nCalcLines;
2624cdf0e10cSrcweir 	}
2625cdf0e10cSrcweir 	else
2626cdf0e10cSrcweir 		n = 0;
2627cdf0e10cSrcweir 
2628cdf0e10cSrcweir 	if ( mnSpacing )
2629cdf0e10cSrcweir 	{
2630cdf0e10cSrcweir 		nSpace = mnSpacing;
2631cdf0e10cSrcweir 		aSize.Width()  += mnSpacing*(nCalcCols-1);
2632cdf0e10cSrcweir 		aSize.Height() += mnSpacing*(nCalcLines-1);
2633cdf0e10cSrcweir 	}
2634cdf0e10cSrcweir 	else
2635cdf0e10cSrcweir 		nSpace = 0;
2636cdf0e10cSrcweir 
2637cdf0e10cSrcweir 	if ( nStyle & WB_NAMEFIELD )
2638cdf0e10cSrcweir 	{
2639cdf0e10cSrcweir 		aSize.Height() += nTxtHeight + NAME_OFFSET;
2640cdf0e10cSrcweir 		if ( !(nStyle & WB_FLATVALUESET) )
2641cdf0e10cSrcweir 			aSize.Height() += NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
2642cdf0e10cSrcweir 	}
2643cdf0e10cSrcweir 
2644cdf0e10cSrcweir 	if ( nStyle & WB_NONEFIELD )
2645cdf0e10cSrcweir 	{
2646cdf0e10cSrcweir 		aSize.Height() += nTxtHeight + n + nSpace;
2647cdf0e10cSrcweir 		if ( nStyle & WB_RADIOSEL )
2648cdf0e10cSrcweir 			aSize.Height() += 8;
2649cdf0e10cSrcweir 	}
2650cdf0e10cSrcweir 
2651cdf0e10cSrcweir 	// Evt. ScrollBar-Breite aufaddieren
2652cdf0e10cSrcweir 	aSize.Width() += GetScrollWidth();
2653cdf0e10cSrcweir 
2654cdf0e10cSrcweir 	return aSize;
2655cdf0e10cSrcweir }
2656cdf0e10cSrcweir 
2657cdf0e10cSrcweir // -----------------------------------------------------------------------
2658cdf0e10cSrcweir 
2659cdf0e10cSrcweir Size ValueSet::CalcItemSizePixel( const Size& rItemSize, sal_Bool bOut ) const
2660cdf0e10cSrcweir {
2661cdf0e10cSrcweir 	Size aSize = rItemSize;
2662cdf0e10cSrcweir 
2663cdf0e10cSrcweir 	WinBits nStyle = GetStyle();
2664cdf0e10cSrcweir 	if ( nStyle & WB_ITEMBORDER )
2665cdf0e10cSrcweir 	{
2666cdf0e10cSrcweir 		long n;
2667cdf0e10cSrcweir 
2668cdf0e10cSrcweir 		if ( nStyle & WB_DOUBLEBORDER )
2669cdf0e10cSrcweir 			n = ITEM_OFFSET_DOUBLE;
2670cdf0e10cSrcweir 		else
2671cdf0e10cSrcweir 			n = ITEM_OFFSET;
2672cdf0e10cSrcweir 
2673cdf0e10cSrcweir 		if ( bOut )
2674cdf0e10cSrcweir 		{
2675cdf0e10cSrcweir 			aSize.Width()  += n;
2676cdf0e10cSrcweir 			aSize.Height() += n;
2677cdf0e10cSrcweir 		}
2678cdf0e10cSrcweir 		else
2679cdf0e10cSrcweir 		{
2680cdf0e10cSrcweir 			aSize.Width()  -= n;
2681cdf0e10cSrcweir 			aSize.Height() -= n;
2682cdf0e10cSrcweir 		}
2683cdf0e10cSrcweir 	}
2684cdf0e10cSrcweir 
2685cdf0e10cSrcweir 	return aSize;
2686cdf0e10cSrcweir }
2687cdf0e10cSrcweir 
2688cdf0e10cSrcweir // -----------------------------------------------------------------------
2689cdf0e10cSrcweir 
2690cdf0e10cSrcweir long ValueSet::GetScrollWidth() const
2691cdf0e10cSrcweir {
2692cdf0e10cSrcweir 	if ( GetStyle() & WB_VSCROLL )
2693cdf0e10cSrcweir 	{
2694cdf0e10cSrcweir 		((ValueSet*)this)->ImplInitScrollBar();
2695cdf0e10cSrcweir 		return mpScrBar->GetSizePixel().Width()+SCRBAR_OFFSET;
2696cdf0e10cSrcweir 	}
2697cdf0e10cSrcweir 	else
2698cdf0e10cSrcweir 		return 0;
2699cdf0e10cSrcweir }
2700cdf0e10cSrcweir 
2701cdf0e10cSrcweir // -----------------------------------------------------------------------
2702cdf0e10cSrcweir 
2703cdf0e10cSrcweir sal_uInt16 ValueSet::ShowDropPos( const Point& rPos )
2704cdf0e10cSrcweir {
2705cdf0e10cSrcweir 	mbDropPos = sal_True;
2706cdf0e10cSrcweir 
2707cdf0e10cSrcweir 	// Gegebenenfalls scrollen
2708cdf0e10cSrcweir 	ImplScroll( rPos );
2709cdf0e10cSrcweir 
2710cdf0e10cSrcweir 	// DropPosition ermitteln
2711cdf0e10cSrcweir 	sal_uInt16 nPos = ImplGetItem( rPos, sal_True );
2712cdf0e10cSrcweir 	if ( nPos == VALUESET_ITEM_NONEITEM )
2713cdf0e10cSrcweir 		nPos = 0;
2714cdf0e10cSrcweir 	else if ( nPos == VALUESET_ITEM_NOTFOUND )
2715cdf0e10cSrcweir 	{
2716cdf0e10cSrcweir 		Size aOutSize = GetOutputSizePixel();
2717cdf0e10cSrcweir 		if ( GetStyle() & WB_NAMEFIELD )
2718cdf0e10cSrcweir 			aOutSize.Height() = mnTextOffset;
2719cdf0e10cSrcweir 		if ( (rPos.X() >= 0) && (rPos.X() < aOutSize.Width()) &&
2720cdf0e10cSrcweir 			 (rPos.Y() >= 0) && (rPos.Y() < aOutSize.Height()) )
2721cdf0e10cSrcweir             nPos = (sal_uInt16)mpImpl->mpItemList->Count();
2722cdf0e10cSrcweir 	}
2723cdf0e10cSrcweir 	else
2724cdf0e10cSrcweir 	{
2725cdf0e10cSrcweir 		// Im letzten viertel, dann wird ein Item spaeter eingefuegt
2726cdf0e10cSrcweir         Rectangle aRect = mpImpl->mpItemList->GetObject( nPos )->maRect;
2727cdf0e10cSrcweir 		if ( rPos.X() > aRect.Left()+aRect.GetWidth()-(aRect.GetWidth()/4) )
2728cdf0e10cSrcweir 			nPos++;
2729cdf0e10cSrcweir 	}
2730cdf0e10cSrcweir 
2731cdf0e10cSrcweir 	if ( nPos != mnDropPos )
2732cdf0e10cSrcweir 	{
2733cdf0e10cSrcweir 		ImplDrawDropPos( sal_False );
2734cdf0e10cSrcweir 		mnDropPos = nPos;
2735cdf0e10cSrcweir 		ImplDrawDropPos( sal_True );
2736cdf0e10cSrcweir 	}
2737cdf0e10cSrcweir 
2738cdf0e10cSrcweir 	return mnDropPos;
2739cdf0e10cSrcweir }
2740cdf0e10cSrcweir 
2741cdf0e10cSrcweir // -----------------------------------------------------------------------
2742cdf0e10cSrcweir 
2743cdf0e10cSrcweir void ValueSet::HideDropPos()
2744cdf0e10cSrcweir {
2745cdf0e10cSrcweir 	if ( mbDropPos )
2746cdf0e10cSrcweir 	{
2747cdf0e10cSrcweir 		ImplDrawDropPos( sal_False );
2748cdf0e10cSrcweir 		mbDropPos = sal_False;
2749cdf0e10cSrcweir 	}
2750cdf0e10cSrcweir }
2751cdf0e10cSrcweir 
2752cdf0e10cSrcweir // -----------------------------------------------------------------------
2753cdf0e10cSrcweir 
2754cdf0e10cSrcweir bool ValueSet::IsRTLActive (void)
2755cdf0e10cSrcweir {
2756cdf0e10cSrcweir     return Application::GetSettings().GetLayoutRTL() && IsRTLEnabled();
2757cdf0e10cSrcweir }
2758cdf0e10cSrcweir 
2759cdf0e10cSrcweir // -----------------------------------------------------------------------
2760cdf0e10cSrcweir 
2761cdf0e10cSrcweir void ValueSet::SetHighlightHdl( const Link& rLink )
2762cdf0e10cSrcweir {
2763cdf0e10cSrcweir 	mpImpl->maHighlightHdl = rLink;
2764cdf0e10cSrcweir }
2765cdf0e10cSrcweir 
2766cdf0e10cSrcweir // -----------------------------------------------------------------------
2767cdf0e10cSrcweir 
2768cdf0e10cSrcweir const Link& ValueSet::GetHighlightHdl() const
2769cdf0e10cSrcweir {
2770cdf0e10cSrcweir 	return mpImpl->maHighlightHdl;
2771cdf0e10cSrcweir }
2772cdf0e10cSrcweir 
2773cdf0e10cSrcweir // -----------------------------------------------------------------------
2774cdf0e10cSrcweir 
2775*2bfcd321SSteve Yin //IAccessibility2 Implementation 2009-----
2776*2bfcd321SSteve Yin //For sending out the focused event on the first focused item when this valueset is first focused.
2777*2bfcd321SSteve Yin // MT: Focus notifications changed in DEV300 meanwhile, so this is not used for now.
2778*2bfcd321SSteve Yin // Just keeping it here for reference, in case something in out implementation doesn't work as expected...
2779*2bfcd321SSteve Yin /*
2780*2bfcd321SSteve Yin void ValueSet::SetFocusedItem(sal_Bool bFocused)
2781*2bfcd321SSteve Yin {
2782*2bfcd321SSteve Yin 	if( ImplHasAccessibleListeners() )
2783*2bfcd321SSteve Yin 	{
2784*2bfcd321SSteve Yin         // selection event
2785*2bfcd321SSteve Yin         ::com::sun::star::uno::Any aSelOldAny, aSelNewAny;
2786*2bfcd321SSteve Yin 		if ( mnSelItemId >= 0)
2787*2bfcd321SSteve Yin 		{
2788*2bfcd321SSteve Yin 			// focus event (select)
2789*2bfcd321SSteve Yin 		    sal_uInt16 nPos = GetItemPos( mnSelItemId );
2790*2bfcd321SSteve Yin 
2791*2bfcd321SSteve Yin 			ValueSetItem* pItem;
2792*2bfcd321SSteve Yin 			if ((GetStyle() & WB_NONEFIELD) != 0
2793*2bfcd321SSteve Yin 				&& nPos == VALUESET_ITEM_NOTFOUND
2794*2bfcd321SSteve Yin 				&& mnSelItemId == 0)
2795*2bfcd321SSteve Yin 			{
2796*2bfcd321SSteve Yin 				// When present the first item is the then allways visible none field.
2797*2bfcd321SSteve Yin 				pItem = ImplGetItem (VALUESET_ITEM_NONEITEM);
2798*2bfcd321SSteve Yin 			}
2799*2bfcd321SSteve Yin 			else
2800*2bfcd321SSteve Yin 			{
2801*2bfcd321SSteve Yin 				if (nPos == VALUESET_ITEM_NOTFOUND)
2802*2bfcd321SSteve Yin 					nPos = 0;
2803*2bfcd321SSteve Yin 				pItem = mpImpl->mpItemList->GetObject(nPos);
2804*2bfcd321SSteve Yin 			}
2805*2bfcd321SSteve Yin 			ValueItemAcc* pItemAcc = NULL;
2806*2bfcd321SSteve Yin 			if (pItem != NULL)
2807*2bfcd321SSteve Yin 				pItemAcc = ValueItemAcc::getImplementation(pItem->GetAccessible(mpImpl->mbIsTransientChildrenDisabled) );
2808*2bfcd321SSteve Yin 			if( pItemAcc )
2809*2bfcd321SSteve Yin 			{
2810*2bfcd321SSteve Yin 				if (bFocused)
2811*2bfcd321SSteve Yin 					aSelNewAny <<= pItem->GetAccessible(mpImpl->mbIsTransientChildrenDisabled);
2812*2bfcd321SSteve Yin 				else
2813*2bfcd321SSteve Yin 					aSelOldAny <<= pItem->GetAccessible(mpImpl->mbIsTransientChildrenDisabled);
2814*2bfcd321SSteve Yin 			}
2815*2bfcd321SSteve Yin 			ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aSelOldAny, aSelNewAny );
2816*2bfcd321SSteve Yin 			if (pItemAcc && bFocused)
2817*2bfcd321SSteve Yin 			{
2818*2bfcd321SSteve Yin 				pItemAcc->FireAccessibleEvent(
2819*2bfcd321SSteve Yin 					::com::sun::star::accessibility::AccessibleEventId::SELECTION_CHANGED,
2820*2bfcd321SSteve Yin 					::com::sun::star::uno::Any(),::com::sun::star::uno::Any());
2821*2bfcd321SSteve Yin 			}
2822*2bfcd321SSteve Yin 		}
2823*2bfcd321SSteve Yin 	}
2824*2bfcd321SSteve Yin }
2825*2bfcd321SSteve Yin */
2826*2bfcd321SSteve Yin //end
2827*2bfcd321SSteve Yin //-----IAccessibility2 Implementation 2009
2828*2bfcd321SSteve Yin 
2829