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