1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: valueset.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
33 #include <tools/list.hxx>
34 #include <tools/debug.hxx>
35 #include <vcl/decoview.hxx>
36 #include <vcl/svapp.hxx>
38 #include <vcl/scrbar.hxx>
41 #include <vcl/help.hxx>
43 #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
44 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
45 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
46 #include <com/sun/star/lang/XComponent.hpp>
47 #include <rtl/ustring.hxx>
49 #include "valueimp.hxx"
51 #define _SV_VALUESET_CXX
52 #include <svtools/valueset.hxx>
58 void ValueSet::ImplInit()
60 // Size aWinSize = GetSizePixel();
61 mpImpl
= new ValueSet_Impl
;
73 mnDropPos
= VALUESET_ITEM_NOTFOUND
;
84 mbDrawSelection
= TRUE
;
91 // #106446#, #106601# force mirroring of virtual device
92 maVirDev
.EnableRTL( GetParent()->IsRTLEnabled() );
94 ImplInitSettings( TRUE
, TRUE
, TRUE
);
97 // -----------------------------------------------------------------------
99 ValueSet::ValueSet( Window
* pParent
, WinBits nWinStyle
, bool bDisableTransientChildren
) :
100 Control( pParent
, nWinStyle
),
102 maColor( COL_TRANSPARENT
)
106 mpImpl
->mbIsTransientChildrenDisabled
= bDisableTransientChildren
;
109 // -----------------------------------------------------------------------
111 ValueSet::ValueSet( Window
* pParent
, const ResId
& rResId
, bool bDisableTransientChildren
) :
112 Control( pParent
, rResId
),
114 maColor( COL_TRANSPARENT
)
118 mpImpl
->mbIsTransientChildrenDisabled
= bDisableTransientChildren
;
121 // -----------------------------------------------------------------------
123 ValueSet::~ValueSet()
125 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
>
126 xComponent (GetAccessible(FALSE
), ::com::sun::star::uno::UNO_QUERY
);
128 xComponent
->dispose ();
140 // -----------------------------------------------------------------------
142 void ValueSet::ImplDeleteItems()
144 for( ValueSetItem
* pItem
= mpImpl
->mpItemList
->First(); pItem
; pItem
= mpImpl
->mpItemList
->Next() )
146 if( !pItem
->maRect
.IsEmpty() && ImplHasAccessibleListeners() )
148 ::com::sun::star::uno::Any aOldAny
, aNewAny
;
150 aOldAny
<<= pItem
->GetAccessible( mpImpl
->mbIsTransientChildrenDisabled
);
151 ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD
, aOldAny
, aNewAny
);
157 mpImpl
->mpItemList
->Clear();
160 // -----------------------------------------------------------------------
162 void ValueSet::ImplInitSettings( BOOL bFont
,
163 BOOL bForeground
, BOOL bBackground
)
165 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
170 aFont
= rStyleSettings
.GetAppFont();
171 if ( IsControlFont() )
172 aFont
.Merge( GetControlFont() );
173 SetZoomedPointFont( aFont
);
176 if ( bForeground
|| bFont
)
179 if ( IsControlForeground() )
180 aColor
= GetControlForeground();
182 aColor
= rStyleSettings
.GetButtonTextColor();
183 SetTextColor( aColor
);
190 if ( IsControlBackground() )
191 aColor
= GetControlBackground();
192 else if ( GetStyle() & WB_MENUSTYLEVALUESET
)
193 aColor
= rStyleSettings
.GetMenuColor();
194 else if ( IsEnabled() && (GetStyle() & WB_FLATVALUESET
) )
195 aColor
= rStyleSettings
.GetWindowColor();
197 aColor
= rStyleSettings
.GetFaceColor();
198 SetBackground( aColor
);
202 // -----------------------------------------------------------------------
204 void ValueSet::ImplInitScrollBar()
206 if ( GetStyle() & WB_VSCROLL
)
210 mpScrBar
= new ScrollBar( this, WB_VSCROLL
| WB_DRAG
);
211 mpScrBar
->SetScrollHdl( LINK( this, ValueSet
, ImplScrollHdl
) );
215 // Wegen Einstellungsaenderungen passen wir hier die Breite an
216 long nScrBarWidth
= GetSettings().GetStyleSettings().GetScrollBarSize();
217 mpScrBar
->SetPosSizePixel( 0, 0, nScrBarWidth
, 0, WINDOW_POSSIZE_WIDTH
);
222 // -----------------------------------------------------------------------
224 void ValueSet::ImplFormatItem( ValueSetItem
* pItem
)
226 if ( pItem
->meType
== VALUESETITEM_SPACE
)
229 Rectangle aRect
= pItem
->maRect
;
230 WinBits nStyle
= GetStyle();
231 if ( nStyle
& WB_ITEMBORDER
)
237 if ( nStyle
& WB_FLATVALUESET
)
239 if ( nStyle
& WB_DOUBLEBORDER
)
256 DecorationView
aView( &maVirDev
);
257 aRect
= aView
.DrawFrame( aRect
, mnFrameStyle
);
261 if ( pItem
== mpNoneItem
)
262 pItem
->maText
= GetText();
264 if ( (aRect
.GetHeight() > 0) && (aRect
.GetWidth() > 0) )
266 if ( pItem
== mpNoneItem
)
268 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
269 maVirDev
.SetFont( GetFont() );
270 maVirDev
.SetTextColor( ( nStyle
& WB_MENUSTYLEVALUESET
) ? rStyleSettings
.GetMenuTextColor() : rStyleSettings
.GetWindowTextColor() );
271 maVirDev
.SetTextFillColor();
272 maVirDev
.SetFillColor( ( nStyle
& WB_MENUSTYLEVALUESET
) ? rStyleSettings
.GetMenuColor() : rStyleSettings
.GetWindowColor() );
273 maVirDev
.DrawRect( aRect
);
274 Point
aTxtPos( aRect
.Left()+2, aRect
.Top() );
275 long nTxtWidth
= GetTextWidth( pItem
->maText
);
276 if ( nStyle
& WB_RADIOSEL
)
281 if ( (aTxtPos
.X()+nTxtWidth
) > aRect
.Right() )
283 maVirDev
.SetClipRegion( Region( aRect
) );
284 maVirDev
.DrawText( aTxtPos
, pItem
->maText
);
285 maVirDev
.SetClipRegion();
288 maVirDev
.DrawText( aTxtPos
, pItem
->maText
);
290 else if ( pItem
->meType
== VALUESETITEM_COLOR
)
292 maVirDev
.SetFillColor( pItem
->maColor
);
293 maVirDev
.DrawRect( aRect
);
297 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
299 maVirDev
.SetFillColor( maColor
);
300 else if ( nStyle
& WB_MENUSTYLEVALUESET
)
301 maVirDev
.SetFillColor( rStyleSettings
.GetMenuColor() );
302 else if ( IsEnabled() )
303 maVirDev
.SetFillColor( rStyleSettings
.GetWindowColor() );
305 maVirDev
.SetFillColor( rStyleSettings
.GetFaceColor() );
306 maVirDev
.DrawRect( aRect
);
308 if ( pItem
->meType
== VALUESETITEM_USERDRAW
)
310 UserDrawEvent
aUDEvt( &maVirDev
, aRect
, pItem
->mnId
);
315 Size aImageSize
= pItem
->maImage
.GetSizePixel();
316 Size aRectSize
= aRect
.GetSize();
317 Point
aPos( aRect
.Left(), aRect
.Top() );
318 aPos
.X() += (aRectSize
.Width()-aImageSize
.Width())/2;
319 aPos
.Y() += (aRectSize
.Height()-aImageSize
.Height())/2;
321 USHORT nImageStyle
= 0;
323 nImageStyle
|= IMAGE_DRAW_DISABLE
;
325 if ( (aImageSize
.Width() > aRectSize
.Width()) ||
326 (aImageSize
.Height() > aRectSize
.Height()) )
328 maVirDev
.SetClipRegion( Region( aRect
) );
329 maVirDev
.DrawImage( aPos
, pItem
->maImage
, nImageStyle
);
330 maVirDev
.SetClipRegion();
333 maVirDev
.DrawImage( aPos
, pItem
->maImage
, nImageStyle
);
339 // -----------------------------------------------------------------------
341 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> ValueSet::CreateAccessible()
343 return new ValueSetAcc( this, mpImpl
->mbIsTransientChildrenDisabled
);
346 // -----------------------------------------------------------------------
348 void ValueSet::Format()
350 Size aWinSize
= GetOutputSizePixel();
351 ULONG nItemCount
= mpImpl
->mpItemList
->Count();
352 WinBits nStyle
= GetStyle();
353 long nTxtHeight
= GetTextHeight();
358 ScrollBar
* pDelScrBar
= NULL
;
360 // Scrolling beruecksichtigen
361 if ( nStyle
& WB_VSCROLL
)
367 // ScrollBar erst spaeter zerstoeren, damit keine rekursiven
368 // Aufrufe entstehen koennen
369 pDelScrBar
= mpScrBar
;
374 // Item-Offset berechnen
375 if ( nStyle
& WB_ITEMBORDER
)
377 if ( nStyle
& WB_DOUBLEBORDER
)
378 nOff
= ITEM_OFFSET_DOUBLE
;
386 // Groesse beruecksichtigen, wenn NameField vorhanden
387 if ( nStyle
& WB_NAMEFIELD
)
389 mnTextOffset
= aWinSize
.Height()-nTxtHeight
-NAME_OFFSET
;
390 aWinSize
.Height() -= nTxtHeight
+NAME_OFFSET
;
392 if ( !(nStyle
& WB_FLATVALUESET
) )
394 mnTextOffset
-= NAME_LINE_HEIGHT
+NAME_LINE_OFF_Y
;
395 aWinSize
.Height() -= NAME_LINE_HEIGHT
+NAME_LINE_OFF_Y
;
401 // Offset und Groesse beruecksichtigen, wenn NoneField vorhanden
402 if ( nStyle
& WB_NONEFIELD
)
404 nNoneHeight
= nTxtHeight
+nOff
;
406 if ( nStyle
& WB_RADIOSEL
)
421 // Breite vom ScrollBar berechnen
422 long nScrBarWidth
= 0;
424 nScrBarWidth
= mpScrBar
->GetSizePixel().Width()+SCRBAR_OFFSET
;
426 // Spaltenanzahl berechnen
429 if ( mnUserItemWidth
)
431 mnCols
= (USHORT
)((aWinSize
.Width()-nScrBarWidth
+nSpace
) / (mnUserItemWidth
+nSpace
));
441 // Zeilenanzahl berechnen
443 mnLines
= (long)mpImpl
->mpItemList
->Count() / mnCols
;
444 if ( mpImpl
->mpItemList
->Count() % mnCols
)
449 long nCalcHeight
= aWinSize
.Height()-nNoneHeight
;
450 if ( mnUserVisLines
)
451 mnVisLines
= mnUserVisLines
;
452 else if ( mnUserItemHeight
)
454 mnVisLines
= (nCalcHeight
-nNoneSpace
+nSpace
) / (mnUserItemHeight
+nSpace
);
459 mnVisLines
= mnLines
;
460 if ( mnLines
> mnVisLines
)
462 if ( mnLines
<= mnVisLines
)
466 if ( mnFirstLine
> (USHORT
)(mnLines
-mnVisLines
) )
467 mnFirstLine
= (USHORT
)(mnLines
-mnVisLines
);
470 // Itemgroessen berechnen
471 long nColSpace
= (mnCols
-1)*nSpace
;
472 long nLineSpace
= ((mnVisLines
-1)*nSpace
)+nNoneSpace
;
475 if ( mnUserItemWidth
&& !mnUserCols
)
477 nItemWidth
= mnUserItemWidth
;
478 if ( nItemWidth
> aWinSize
.Width()-nScrBarWidth
-nColSpace
)
479 nItemWidth
= aWinSize
.Width()-nScrBarWidth
-nColSpace
;
482 nItemWidth
= (aWinSize
.Width()-nScrBarWidth
-nColSpace
) / mnCols
;
483 if ( mnUserItemHeight
&& !mnUserVisLines
)
485 nItemHeight
= mnUserItemHeight
;
486 if ( nItemHeight
> nCalcHeight
-nNoneSpace
)
487 nItemHeight
= nCalcHeight
-nNoneSpace
;
491 nCalcHeight
-= nLineSpace
;
492 nItemHeight
= nCalcHeight
/ mnVisLines
;
496 maVirDev
.SetSettings( GetSettings() );
497 maVirDev
.SetBackground( GetBackground() );
498 maVirDev
.SetOutputSizePixel( aWinSize
, TRUE
);
500 // Bei zu kleinen Items machen wir nichts
502 if ( nStyle
& WB_ITEMBORDER
)
504 if ( (nItemWidth
<= 0) || (nItemHeight
<= nMinHeight
) || !nItemCount
)
506 if ( nStyle
& WB_NONEFIELD
)
510 mpNoneItem
->maRect
.SetEmpty();
511 mpNoneItem
->maText
= GetText();
515 for ( ULONG i
= 0; i
< nItemCount
; i
++ )
517 ValueSetItem
* pItem
= mpImpl
->mpItemList
->GetObject( i
);
518 pItem
->maRect
.SetEmpty();
526 // Frame-Style ermitteln
527 if ( nStyle
& WB_DOUBLEBORDER
)
528 mnFrameStyle
= FRAME_DRAW_DOUBLEIN
;
530 mnFrameStyle
= FRAME_DRAW_IN
;
532 // Selektionsfarben und -breiten ermitteln
533 // Gegebenenfalls die Farben anpassen, damit man die Selektion besser
535 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
536 Color
aHighColor( rStyleSettings
.GetHighlightColor() );
537 if ( ((aHighColor
.GetRed() > 0x80) || (aHighColor
.GetGreen() > 0x80) ||
538 (aHighColor
.GetBlue() > 0x80)) ||
539 ((aHighColor
.GetRed() == 0x80) && (aHighColor
.GetGreen() == 0x80) &&
540 (aHighColor
.GetBlue() == 0x80)) )
545 // Wenn die Items groesser sind, dann die Selektion doppelt so breit
547 if ( (nStyle
& WB_DOUBLEBORDER
) &&
548 ((nItemWidth
>= 25) && (nItemHeight
>= 20)) )
558 long nAllItemWidth
= (nItemWidth
*mnCols
)+nColSpace
;
559 long nAllItemHeight
= (nItemHeight
*mnVisLines
)+nNoneHeight
+nLineSpace
;
560 nStartX
= (aWinSize
.Width()-nScrBarWidth
-nAllItemWidth
)/2;
561 nStartY
= (aWinSize
.Height()-nAllItemHeight
)/2;
569 // Items berechnen und zeichnen
570 maVirDev
.SetLineColor();
574 // NoSelection-Field erzeugen und anzeigen
575 if ( nStyle
& WB_NONEFIELD
)
578 mpNoneItem
= new ValueSetItem( *this );
580 mpNoneItem
->mnId
= 0;
581 mpNoneItem
->meType
= VALUESETITEM_NONE
;
582 mpNoneItem
->maRect
.Left() = x
;
583 mpNoneItem
->maRect
.Top() = y
;
584 mpNoneItem
->maRect
.Right() = mpNoneItem
->maRect
.Left()+aWinSize
.Width()-x
-1;
585 mpNoneItem
->maRect
.Bottom() = y
+nNoneHeight
-1;
587 ImplFormatItem( mpNoneItem
);
589 y
+= nNoneHeight
+nNoneSpace
;
593 ULONG nFirstItem
= mnFirstLine
* mnCols
;
594 ULONG nLastItem
= nFirstItem
+ (mnVisLines
* mnCols
);
598 // If want also draw parts of items in the last line,
599 // then we add one more line if parts of these line are
601 if ( y
+(mnVisLines
*(nItemHeight
+nSpace
)) < aWinSize
.Height() )
604 for ( ULONG i
= 0; i
< nItemCount
; i
++ )
606 ValueSetItem
* pItem
= mpImpl
->mpItemList
->GetObject( i
);
608 if ( (i
>= nFirstItem
) && (i
< nLastItem
) )
610 const BOOL bWasEmpty
= pItem
->maRect
.IsEmpty();
612 pItem
->maRect
.Left() = x
;
613 pItem
->maRect
.Top() = y
;
614 pItem
->maRect
.Right() = pItem
->maRect
.Left()+nItemWidth
-1;
615 pItem
->maRect
.Bottom() = pItem
->maRect
.Top()+nItemHeight
-1;
617 if( bWasEmpty
&& ImplHasAccessibleListeners() )
619 ::com::sun::star::uno::Any aOldAny
, aNewAny
;
621 aNewAny
<<= pItem
->GetAccessible( mpImpl
->mbIsTransientChildrenDisabled
);
622 ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD
, aOldAny
, aNewAny
);
625 ImplFormatItem( pItem
);
627 if ( !((i
+1) % mnCols
) )
630 y
+= nItemHeight
+nSpace
;
633 x
+= nItemWidth
+nSpace
;
637 if( !pItem
->maRect
.IsEmpty() && ImplHasAccessibleListeners() )
639 ::com::sun::star::uno::Any aOldAny
, aNewAny
;
641 aOldAny
<<= pItem
->GetAccessible( mpImpl
->mbIsTransientChildrenDisabled
);
642 ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD
, aOldAny
, aNewAny
);
645 pItem
->maRect
.SetEmpty();
649 // ScrollBar anordnen, Werte setzen und anzeigen
652 Point
aPos( aWinSize
.Width()-nScrBarWidth
+SCRBAR_OFFSET
, 0 );
653 Size
aSize( nScrBarWidth
-SCRBAR_OFFSET
, aWinSize
.Height() );
654 // If a none field is visible, then we center the scrollbar
655 if ( nStyle
& WB_NONEFIELD
)
657 aPos
.Y() = nStartY
+nNoneHeight
+1;
658 aSize
.Height() = ((nItemHeight
+nSpace
)*mnVisLines
)-2-nSpace
;
660 mpScrBar
->SetPosSizePixel( aPos
, aSize
);
661 mpScrBar
->SetRangeMax( mnLines
);
662 mpScrBar
->SetVisibleSize( mnVisLines
);
663 mpScrBar
->SetThumbPos( (long)mnFirstLine
);
664 long nPageSize
= mnVisLines
;
667 mpScrBar
->SetPageSize( nPageSize
);
672 // Jetzt haben wir formatiert und warten auf das naechste
675 // ScrollBar loeschen
680 // -----------------------------------------------------------------------
682 void ValueSet::ImplDrawItemText( const XubString
& rText
)
684 if ( !(GetStyle() & WB_NAMEFIELD
) )
687 Size aWinSize
= GetOutputSizePixel();
688 long nTxtWidth
= GetTextWidth( rText
);
689 long nTxtOffset
= mnTextOffset
;
691 // Rechteck loeschen und Text ausgeben
692 if ( GetStyle() & WB_FLATVALUESET
)
694 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
696 SetFillColor( rStyleSettings
.GetFaceColor() );
697 DrawRect( Rectangle( Point( 0, nTxtOffset
), Point( aWinSize
.Width(), aWinSize
.Height() ) ) );
698 SetTextColor( rStyleSettings
.GetButtonTextColor() );
702 nTxtOffset
+= NAME_LINE_HEIGHT
+NAME_LINE_OFF_Y
;
703 Erase( Rectangle( Point( 0, nTxtOffset
), Point( aWinSize
.Width(), aWinSize
.Height() ) ) );
705 DrawText( Point( (aWinSize
.Width()-nTxtWidth
) / 2, nTxtOffset
+(NAME_OFFSET
/2) ), rText
);
708 // -----------------------------------------------------------------------
710 void ValueSet::ImplDrawSelect()
712 if ( !IsReallyVisible() )
715 BOOL bFocus
= HasFocus();
718 if ( (mbNoSelection
&& !mbHighlight
) || (!mbDrawSelection
&& mbHighlight
) )
724 ((mbNoSelection
&& !mbHighlight
) || (!mbDrawSelection
&& mbHighlight
)) )
727 ImplDrawItemText( aEmptyStr
);
731 USHORT nItemId
= mnSelItemId
;
733 for( int stage
= 0; stage
< 2; stage
++ )
738 nItemId
= mnHighItemId
;
745 pItem
= mpImpl
->mpItemList
->GetObject( GetItemPos( nItemId
) );
752 pItem
= ImplGetFirstItem();
753 if ( !bFocus
|| !pItem
)
758 if ( pItem
->maRect
.IsEmpty() )
762 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
763 Rectangle aRect
= pItem
->maRect
;
764 Control::SetFillColor();
766 Color
aDoubleColor( rStyleSettings
.GetHighlightColor() );
767 Color
aSingleColor( rStyleSettings
.GetHighlightTextColor() );
771 * #99777# contrast enhancement for thin mode
773 const Wallpaper
& rWall
= GetDisplayBackground();
774 if( ! rWall
.IsBitmap() && ! rWall
.IsGradient() )
776 const Color
& rBack
= rWall
.GetColor();
777 if( rBack
.IsDark() && ! aDoubleColor
.IsBright() )
779 aDoubleColor
= Color( COL_WHITE
);
780 aSingleColor
= Color( COL_BLACK
);
782 else if( rBack
.IsBright() && ! aDoubleColor
.IsDark() )
784 aDoubleColor
= Color( COL_BLACK
);
785 aSingleColor
= Color( COL_WHITE
);
790 // Selectionsausgabe festlegen
791 WinBits nStyle
= GetStyle();
792 if ( nStyle
& WB_MENUSTYLEVALUESET
)
800 SetLineColor( Color( COL_BLACK
) );
802 SetLineColor( aDoubleColor
);
806 else if ( nStyle
& WB_RADIOSEL
)
812 if ( nStyle
& WB_DOUBLEBORDER
)
830 SetLineColor( aDoubleColor
);
848 SetLineColor( Color( COL_BLACK
) );
850 SetLineColor( aDoubleColor
);
866 Rectangle aRect2
= aRect
;
886 SetLineColor( Color( COL_WHITE
) );
888 SetLineColor( aSingleColor
);
891 SetLineColor( Color( COL_LIGHTGRAY
) );
898 ImplDrawItemText( pItem
->maText
);
902 // -----------------------------------------------------------------------
904 void ValueSet::ImplHideSelect( USHORT nItemId
)
908 USHORT nItemPos
= GetItemPos( nItemId
);
909 if ( nItemPos
!= sal::static_int_cast
<USHORT
>(LIST_ENTRY_NOTFOUND
) )
910 aRect
= mpImpl
->mpItemList
->GetObject( nItemPos
)->maRect
;
914 aRect
= mpNoneItem
->maRect
;
917 if ( !aRect
.IsEmpty() )
920 Point aPos
= aRect
.TopLeft();
921 Size aSize
= aRect
.GetSize();
922 DrawOutDev( aPos
, aSize
, aPos
, aSize
, maVirDev
);
926 // -----------------------------------------------------------------------
928 void ValueSet::ImplHighlightItem( USHORT nItemId
, BOOL bIsSelection
)
930 if ( mnHighItemId
!= nItemId
)
932 // Alten merken, um vorherige Selektion zu entfernen
933 USHORT nOldItem
= mnHighItemId
;
934 mnHighItemId
= nItemId
;
936 // Wenn keiner selektiert ist, dann Selektion nicht malen
937 if ( !bIsSelection
&& mbNoSelection
)
938 mbDrawSelection
= FALSE
;
940 // Neu ausgeben und alte Selection wegnehmen
941 ImplHideSelect( nOldItem
);
943 mbDrawSelection
= TRUE
;
947 // -----------------------------------------------------------------------
949 void ValueSet::ImplDrawDropPos( BOOL bShow
)
951 if ( (mnDropPos
!= VALUESET_ITEM_NOTFOUND
) && mpImpl
->mpItemList
->Count() )
953 USHORT nItemPos
= mnDropPos
;
957 if ( nItemPos
>= mpImpl
->mpItemList
->Count() )
959 nItemPos
= (USHORT
)(mpImpl
->mpItemList
->Count()-1);
965 nItemId1
= GetItemId( nItemPos
);
966 if ( (nItemId1
!= mnSelItemId
) && (nItemId1
!= mnHighItemId
) )
968 Rectangle aRect2
= mpImpl
->mpItemList
->GetObject( nItemPos
)->maRect
;
975 else if ( nItemPos
> 0 )
977 aRect1
= mpImpl
->mpItemList
->GetObject( nItemPos
-1 )->maRect
;
978 nItemId2
= GetItemId( nItemPos
-1 );
979 if ( (nItemId2
!= mnSelItemId
) && (nItemId2
!= mnHighItemId
) )
983 // Items ueberhaupt sichtbar (nur Erstes/Letztes)
984 if ( !aRect1
.IsEmpty() || !aRect2
.IsEmpty() )
987 ImplHideSelect( nItemId1
);
989 ImplHideSelect( nItemId2
);
993 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
996 SetLineColor( rStyleSettings
.GetButtonTextColor() );
997 if ( !aRect1
.IsEmpty() )
999 Point aPos
= aRect1
.RightCenter();
1002 for ( USHORT i
= 0; i
< 4; i
++ )
1003 DrawLine( Point( nX
-i
, nY
-i
), Point( nX
-i
, nY
+i
) );
1005 if ( !aRect2
.IsEmpty() )
1007 Point aPos
= aRect2
.LeftCenter();
1010 for ( USHORT i
= 0; i
< 4; i
++ )
1011 DrawLine( Point( nX
+i
, nY
-i
), Point( nX
+i
, nY
+i
) );
1016 if ( !aRect1
.IsEmpty() )
1018 Point aPos
= aRect1
.TopLeft();
1019 Size aSize
= aRect1
.GetSize();
1020 DrawOutDev( aPos
, aSize
, aPos
, aSize
, maVirDev
);
1022 if ( !aRect2
.IsEmpty() )
1024 Point aPos
= aRect2
.TopLeft();
1025 Size aSize
= aRect2
.GetSize();
1026 DrawOutDev( aPos
, aSize
, aPos
, aSize
, maVirDev
);
1030 if ( nItemId1
|| nItemId2
)
1036 // -----------------------------------------------------------------------
1038 void ValueSet::ImplDraw()
1046 Size aSize
= maVirDev
.GetOutputSizePixel();
1048 if ( mpScrBar
&& mpScrBar
->IsVisible() )
1050 Point aScrPos
= mpScrBar
->GetPosPixel();
1051 Size aScrSize
= mpScrBar
->GetSizePixel();
1052 Point
aTempPos( 0, aScrPos
.Y() );
1053 Size
aTempSize( aSize
.Width(), aScrPos
.Y() );
1055 DrawOutDev( aDefPos
, aTempSize
, aDefPos
, aTempSize
, maVirDev
);
1056 aTempSize
.Width() = aScrPos
.X()-1;
1057 aTempSize
.Height() = aScrSize
.Height();
1058 DrawOutDev( aTempPos
, aTempSize
, aTempPos
, aTempSize
, maVirDev
);
1059 aTempPos
.Y() = aScrPos
.Y()+aScrSize
.Height();
1060 aTempSize
.Width() = aSize
.Width();
1061 aTempSize
.Height() = aSize
.Height()-aTempPos
.Y();
1062 DrawOutDev( aTempPos
, aTempSize
, aTempPos
, aTempSize
, maVirDev
);
1065 DrawOutDev( aDefPos
, aSize
, aDefPos
, aSize
, maVirDev
);
1067 // Trennlinie zum Namefield zeichnen
1068 if ( GetStyle() & WB_NAMEFIELD
)
1070 if ( !(GetStyle() & WB_FLATVALUESET
) )
1072 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
1073 Size aWinSize
= GetOutputSizePixel();
1074 Point
aPos1( NAME_LINE_OFF_X
, mnTextOffset
+NAME_LINE_OFF_Y
);
1075 Point
aPos2( aWinSize
.Width()-(NAME_LINE_OFF_X
*2), mnTextOffset
+NAME_LINE_OFF_Y
);
1076 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
1078 SetLineColor( rStyleSettings
.GetShadowColor() );
1079 DrawLine( aPos1
, aPos2
);
1082 SetLineColor( rStyleSettings
.GetLightColor() );
1085 SetLineColor( rStyleSettings
.GetWindowTextColor() );
1086 DrawLine( aPos1
, aPos2
);
1093 // -----------------------------------------------------------------------
1095 BOOL
ValueSet::ImplScroll( const Point
& rPos
)
1097 Size aOutSize
= GetOutputSizePixel();
1101 nScrBarWidth
= mpScrBar
->GetSizePixel().Width();
1105 if ( !mbScroll
|| (rPos
.X() < 0) || (rPos
.X() > aOutSize
.Width()-nScrBarWidth
) )
1109 USHORT nOldLine
= mnFirstLine
;
1110 const Rectangle
& rTopRect
= mpImpl
->mpItemList
->GetObject( mnFirstLine
*mnCols
)->maRect
;
1111 if ( rTopRect
.GetHeight() <= 16 )
1112 nScrollOffset
= VALUESET_SCROLL_OFFSET
/2;
1114 nScrollOffset
= VALUESET_SCROLL_OFFSET
;
1115 if ( (mnFirstLine
> 0) && (rPos
.Y() >= 0) )
1117 long nTopPos
= rTopRect
.Top();
1118 if ( (rPos
.Y() >= nTopPos
) && (rPos
.Y() <= nTopPos
+nScrollOffset
) )
1121 if ( (mnFirstLine
== nOldLine
) &&
1122 (mnFirstLine
< (USHORT
)(mnLines
-mnVisLines
)) && (rPos
.Y() < aOutSize
.Height()) )
1124 long nBottomPos
= mpImpl
->mpItemList
->GetObject( (mnFirstLine
+mnVisLines
-1)*mnCols
)->maRect
.Bottom();
1125 if ( (rPos
.Y() >= nBottomPos
-nScrollOffset
) && (rPos
.Y() <= nBottomPos
) )
1129 if ( mnFirstLine
!= nOldLine
)
1139 // -----------------------------------------------------------------------
1141 USHORT
ValueSet::ImplGetItem( const Point
& rPos
, BOOL bMove
) const
1145 if ( mpNoneItem
->maRect
.IsInside( rPos
) )
1146 return VALUESET_ITEM_NONEITEM
;
1150 Rectangle
aWinRect( aDefPos
, maVirDev
.GetOutputSizePixel() );
1152 ULONG nItemCount
= mpImpl
->mpItemList
->Count();
1153 for ( ULONG i
= 0; i
< nItemCount
; i
++ )
1155 ValueSetItem
* pItem
= mpImpl
->mpItemList
->GetObject( i
);
1156 if ( pItem
->maRect
.IsInside( rPos
) )
1158 if ( aWinRect
.IsInside( rPos
) )
1161 return VALUESET_ITEM_NOTFOUND
;
1165 // Wenn Spacing gesetzt ist, wird der vorher selektierte
1166 // Eintrag zurueckgegeben, wenn die Maus noch nicht das Fenster
1168 if ( bMove
&& mnSpacing
&& mnHighItemId
)
1170 if ( aWinRect
.IsInside( rPos
) )
1171 return GetItemPos( mnHighItemId
);
1174 return VALUESET_ITEM_NOTFOUND
;
1177 // -----------------------------------------------------------------------
1179 ValueSetItem
* ValueSet::ImplGetItem( USHORT nPos
)
1181 if ( nPos
== VALUESET_ITEM_NONEITEM
)
1184 return mpImpl
->mpItemList
->GetObject( nPos
);
1187 // -----------------------------------------------------------------------
1189 ValueSetItem
* ValueSet::ImplGetFirstItem()
1191 USHORT nItemCount
= (USHORT
)mpImpl
->mpItemList
->Count();
1194 while ( i
< nItemCount
)
1196 ValueSetItem
* pItem
= mpImpl
->mpItemList
->GetObject( i
);
1197 if ( pItem
->meType
!= VALUESETITEM_SPACE
)
1205 // -----------------------------------------------------------------------
1207 USHORT
ValueSet::ImplGetVisibleItemCount() const
1211 for( sal_Int32 n
= 0, nItemCount
= mpImpl
->mpItemList
->Count(); n
< nItemCount
; n
++ )
1213 ValueSetItem
* pItem
= mpImpl
->mpItemList
->GetObject( n
);
1215 if( pItem
->meType
!= VALUESETITEM_SPACE
&& !pItem
->maRect
.IsEmpty() )
1222 // -----------------------------------------------------------------------
1224 ValueSetItem
* ValueSet::ImplGetVisibleItem( USHORT nVisiblePos
)
1226 ValueSetItem
* pRet
= NULL
;
1227 USHORT nFoundPos
= 0;
1229 for( sal_Int32 n
= 0, nItemCount
= mpImpl
->mpItemList
->Count(); ( n
< nItemCount
) && !pRet
; n
++ )
1231 ValueSetItem
* pItem
= mpImpl
->mpItemList
->GetObject( n
);
1233 if( ( pItem
->meType
!= VALUESETITEM_SPACE
) && !pItem
->maRect
.IsEmpty() && ( nVisiblePos
== nFoundPos
++ ) )
1240 // -----------------------------------------------------------------------
1242 void ValueSet::ImplFireAccessibleEvent( short nEventId
, const ::com::sun::star::uno::Any
& rOldValue
, const ::com::sun::star::uno::Any
& rNewValue
)
1244 ValueSetAcc
* pAcc
= ValueSetAcc::getImplementation( GetAccessible( FALSE
) );
1247 pAcc
->FireAccessibleEvent( nEventId
, rOldValue
, rNewValue
);
1250 // -----------------------------------------------------------------------
1252 BOOL
ValueSet::ImplHasAccessibleListeners()
1254 ValueSetAcc
* pAcc
= ValueSetAcc::getImplementation( GetAccessible( FALSE
) );
1255 return( pAcc
&& pAcc
->HasAccessibleListeners() );
1258 // -----------------------------------------------------------------------
1260 IMPL_LINK( ValueSet
,ImplScrollHdl
, ScrollBar
*, pScrollBar
)
1262 USHORT nNewFirstLine
= (USHORT
)pScrollBar
->GetThumbPos();
1263 if ( nNewFirstLine
!= mnFirstLine
)
1265 mnFirstLine
= nNewFirstLine
;
1272 // -----------------------------------------------------------------------
1274 IMPL_LINK( ValueSet
,ImplTimerHdl
, Timer
*, EMPTYARG
)
1276 ImplTracking( GetPointerPosPixel(), TRUE
);
1280 // -----------------------------------------------------------------------
1282 void ValueSet::ImplTracking( const Point
& rPos
, BOOL bRepeat
)
1284 if ( bRepeat
|| mbSelection
)
1286 if ( ImplScroll( rPos
) )
1290 maTimer
.SetTimeoutHdl( LINK( this, ValueSet
, ImplTimerHdl
) );
1291 maTimer
.SetTimeout( GetSettings().GetMouseSettings().GetScrollRepeat() );
1297 ValueSetItem
* pItem
= ImplGetItem( ImplGetItem( rPos
) );
1298 if ( pItem
&& (pItem
->meType
!= VALUESETITEM_SPACE
) )
1300 if( GetStyle() & WB_MENUSTYLEVALUESET
)
1303 ImplHighlightItem( pItem
->mnId
);
1307 if( GetStyle() & WB_MENUSTYLEVALUESET
)
1310 ImplHighlightItem( mnSelItemId
, FALSE
);
1314 // -----------------------------------------------------------------------
1316 void ValueSet::ImplEndTracking( const Point
& rPos
, BOOL bCancel
)
1318 ValueSetItem
* pItem
;
1320 // Bei Abbruch, den alten Status wieder herstellen
1324 pItem
= ImplGetItem( ImplGetItem( rPos
) );
1326 if ( pItem
&& (pItem
->meType
!= VALUESETITEM_SPACE
) )
1328 SelectItem( pItem
->mnId
);
1329 if ( !mbSelection
&& !(GetStyle() & WB_NOPOINTERFOCUS
) )
1331 mbHighlight
= FALSE
;
1332 mbSelection
= FALSE
;
1337 ImplHighlightItem( mnSelItemId
, FALSE
);
1338 mbHighlight
= FALSE
;
1339 mbSelection
= FALSE
;
1343 // -----------------------------------------------------------------------
1345 void ValueSet::MouseButtonDown( const MouseEvent
& rMEvt
)
1347 if ( rMEvt
.IsLeft() )
1349 ValueSetItem
* pItem
= ImplGetItem( ImplGetItem( rMEvt
.GetPosPixel() ) );
1353 if ( pItem
&& (pItem
->meType
!= VALUESETITEM_SPACE
) )
1355 mnOldItemId
= mnSelItemId
;
1356 mnHighItemId
= mnSelItemId
;
1357 ImplHighlightItem( pItem
->mnId
);
1364 if ( pItem
&& (pItem
->meType
!= VALUESETITEM_SPACE
) && !rMEvt
.IsMod2() )
1366 if ( (pItem
->mnBits
& VIB_NODOUBLECLICK
) || (rMEvt
.GetClicks() == 1) )
1368 mnOldItemId
= mnSelItemId
;
1370 mnHighItemId
= mnSelItemId
;
1371 ImplHighlightItem( pItem
->mnId
);
1372 StartTracking( STARTTRACK_SCROLLREPEAT
);
1374 else if ( rMEvt
.GetClicks() == 2 )
1382 Control::MouseButtonDown( rMEvt
);
1385 // -----------------------------------------------------------------------
1387 void ValueSet::MouseButtonUp( const MouseEvent
& rMEvt
)
1389 // Wegen SelectionMode
1390 if ( rMEvt
.IsLeft() && mbSelection
)
1391 ImplEndTracking( rMEvt
.GetPosPixel(), FALSE
);
1393 Control::MouseButtonUp( rMEvt
);
1396 // -----------------------------------------------------------------------
1398 void ValueSet::MouseMove( const MouseEvent
& rMEvt
)
1400 // Wegen SelectionMode
1401 if ( mbSelection
|| (GetStyle() & WB_MENUSTYLEVALUESET
) )
1402 ImplTracking( rMEvt
.GetPosPixel(), FALSE
);
1403 Control::MouseMove( rMEvt
);
1406 // -----------------------------------------------------------------------
1408 void ValueSet::Tracking( const TrackingEvent
& rTEvt
)
1410 Point aMousePos
= rTEvt
.GetMouseEvent().GetPosPixel();
1412 if ( rTEvt
.IsTrackingEnded() )
1413 ImplEndTracking( aMousePos
, rTEvt
.IsTrackingCanceled() );
1415 ImplTracking( aMousePos
, rTEvt
.IsTrackingRepeat() );
1418 // -----------------------------------------------------------------------
1420 void ValueSet::KeyInput( const KeyEvent
& rKEvt
)
1422 USHORT nLastItem
= (USHORT
)mpImpl
->mpItemList
->Count();
1423 USHORT nItemPos
= VALUESET_ITEM_NOTFOUND
;
1427 if ( !nLastItem
|| !ImplGetFirstItem() )
1429 Control::KeyInput( rKEvt
);
1436 nCurPos
= GetItemPos( mnSelItemId
);
1438 nCurPos
= VALUESET_ITEM_NONEITEM
;
1441 //switch off selection mode if key travelling is used
1442 BOOL bDefault
= FALSE
;
1443 switch ( rKEvt
.GetKeyCode().GetCode() )
1447 nItemPos
= VALUESET_ITEM_NONEITEM
;
1451 while ( ImplGetItem( nItemPos
)->meType
== VALUESETITEM_SPACE
)
1457 nItemPos
= nLastItem
;
1458 while ( ImplGetItem( nItemPos
)->meType
== VALUESETITEM_SPACE
)
1460 if ( nItemPos
== 0 )
1461 nItemPos
= VALUESET_ITEM_NONEITEM
;
1469 if ( rKEvt
.GetKeyCode().GetCode()==KEY_LEFT
)
1473 if ( nCalcPos
== VALUESET_ITEM_NONEITEM
)
1474 nItemPos
= nLastItem
;
1475 else if ( !nCalcPos
)
1478 nItemPos
= VALUESET_ITEM_NONEITEM
;
1480 nItemPos
= nLastItem
;
1483 nItemPos
= nCalcPos
-1;
1484 nCalcPos
= nItemPos
;
1486 while ( ImplGetItem( nItemPos
)->meType
== VALUESETITEM_SPACE
);
1492 if ( nCalcPos
== VALUESET_ITEM_NONEITEM
)
1494 else if ( nCalcPos
== nLastItem
)
1497 nItemPos
= VALUESET_ITEM_NONEITEM
;
1502 nItemPos
= nCalcPos
+1;
1503 nCalcPos
= nItemPos
;
1505 while ( ImplGetItem( nItemPos
)->meType
== VALUESETITEM_SPACE
);
1512 if( rKEvt
.GetKeyCode().GetCode() != KEY_PAGEUP
||
1513 ( !rKEvt
.GetKeyCode().IsShift() && !rKEvt
.GetKeyCode().IsMod1() && !rKEvt
.GetKeyCode().IsMod2() ) )
1515 const long nLineCount
= ( ( KEY_UP
== rKEvt
.GetKeyCode().GetCode() ) ? 1 : mnVisLines
);
1518 if ( nCalcPos
== VALUESET_ITEM_NONEITEM
)
1520 if ( nLastItem
+1 <= mnCols
)
1521 nItemPos
= mnCurCol
;
1524 nItemPos
= ((((nLastItem
+1)/mnCols
)-1)*mnCols
)+(mnCurCol
%mnCols
);
1525 if ( nItemPos
+mnCols
<= nLastItem
)
1526 nItemPos
= nItemPos
+ mnCols
;
1529 else if ( nCalcPos
>= ( nLineCount
* mnCols
) )
1530 nItemPos
= sal::static_int_cast
< USHORT
>(
1531 nCalcPos
- ( nLineCount
* mnCols
));
1534 if( (KEY_UP
== rKEvt
.GetKeyCode().GetCode() ) && (GetStyle() & WB_MENUSTYLEVALUESET
) )
1536 Window
* pParent
= GetParent();
1537 pParent
->GrabFocus();
1538 pParent
->KeyInput( rKEvt
);
1545 mnCurCol
= nCalcPos
%mnCols
;
1546 nItemPos
= VALUESET_ITEM_NONEITEM
;
1550 if ( nLastItem
+1 <= mnCols
)
1551 nItemPos
= nCalcPos
;
1554 nItemPos
= ((((nLastItem
+1)/mnCols
)-1)*mnCols
)+(nCalcPos
%mnCols
);
1555 if ( nItemPos
+mnCols
<= nLastItem
)
1556 nItemPos
= nItemPos
+ mnCols
;
1561 nCalcPos
= nItemPos
;
1563 while ( ImplGetItem( nItemPos
)->meType
== VALUESETITEM_SPACE
);
1566 Control::KeyInput( rKEvt
);
1573 if( rKEvt
.GetKeyCode().GetCode() != KEY_PAGEDOWN
||
1574 ( !rKEvt
.GetKeyCode().IsShift() && !rKEvt
.GetKeyCode().IsMod1() && !rKEvt
.GetKeyCode().IsMod2() ) )
1576 const long nLineCount
= ( ( KEY_DOWN
== rKEvt
.GetKeyCode().GetCode() ) ? 1 : mnVisLines
);
1579 if ( nCalcPos
== VALUESET_ITEM_NONEITEM
)
1580 nItemPos
= mnCurCol
;
1581 else if ( nCalcPos
+ ( nLineCount
* mnCols
) <= nLastItem
)
1582 nItemPos
= sal::static_int_cast
< USHORT
>(
1583 nCalcPos
+ ( nLineCount
* mnCols
));
1586 if( (KEY_DOWN
== rKEvt
.GetKeyCode().GetCode() ) && (GetStyle() & WB_MENUSTYLEVALUESET
) )
1588 Window
* pParent
= GetParent();
1589 pParent
->GrabFocus();
1590 pParent
->KeyInput( rKEvt
);
1597 mnCurCol
= nCalcPos
%mnCols
;
1598 nItemPos
= VALUESET_ITEM_NONEITEM
;
1601 nItemPos
= nCalcPos
%mnCols
;
1604 nCalcPos
= nItemPos
;
1606 while ( ImplGetItem( nItemPos
)->meType
== VALUESETITEM_SPACE
);
1609 Control::KeyInput( rKEvt
);
1614 //enable default handling of KEY_RETURN in dialogs
1615 if(0 != (GetStyle()&WB_NO_DIRECTSELECT
))
1622 Control::KeyInput( rKEvt
);
1629 if ( nItemPos
!= VALUESET_ITEM_NOTFOUND
)
1632 if ( nItemPos
!= VALUESET_ITEM_NONEITEM
)
1633 nItemId
= GetItemId( nItemPos
);
1636 if ( nItemId
!= mnSelItemId
)
1638 SelectItem( nItemId
);
1639 //select only if WB_NO_DIRECTSELECT is not set
1640 if(0 == (GetStyle()&WB_NO_DIRECTSELECT
))
1646 // -----------------------------------------------------------------------
1648 void ValueSet::Command( const CommandEvent
& rCEvt
)
1650 if ( (rCEvt
.GetCommand() == COMMAND_WHEEL
) ||
1651 (rCEvt
.GetCommand() == COMMAND_STARTAUTOSCROLL
) ||
1652 (rCEvt
.GetCommand() == COMMAND_AUTOSCROLL
) )
1654 if ( HandleScrollCommand( rCEvt
, NULL
, mpScrBar
) )
1658 Control::Command( rCEvt
);
1661 // -----------------------------------------------------------------------
1663 void ValueSet::Paint( const Rectangle
& )
1665 if ( GetStyle() & WB_FLATVALUESET
)
1667 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
1669 SetFillColor( rStyleSettings
.GetFaceColor() );
1670 long nOffY
= maVirDev
.GetOutputSizePixel().Height();
1671 Size aWinSize
= GetOutputSizePixel();
1672 DrawRect( Rectangle( Point( 0, nOffY
), Point( aWinSize
.Width(), aWinSize
.Height() ) ) );
1678 // -----------------------------------------------------------------------
1680 void ValueSet::GetFocus()
1682 OSL_TRACE ("value set getting focus");
1684 Control::GetFocus();
1686 // Send accessibility event.
1687 ::com::sun::star::uno::Any aOldState
, aNewState
;
1688 aNewState
<<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED
;
1689 ImplFireAccessibleEvent (
1690 ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED
,
1691 aOldState
, aNewState
);
1695 // -----------------------------------------------------------------------
1697 void ValueSet::LoseFocus()
1699 OSL_TRACE ("value set losing focus");
1700 if ( mbNoSelection
&& mnSelItemId
)
1701 ImplHideSelect( mnSelItemId
);
1704 Control::LoseFocus();
1706 // Send accessibility event.
1707 ::com::sun::star::uno::Any aOldState
, aNewState
;
1708 aOldState
<<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED
;
1709 ImplFireAccessibleEvent (
1710 ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED
,
1711 aOldState
, aNewState
);
1714 // -----------------------------------------------------------------------
1716 void ValueSet::Resize()
1719 if ( IsReallyVisible() && IsUpdateMode() )
1724 // -----------------------------------------------------------------------
1726 void ValueSet::RequestHelp( const HelpEvent
& rHEvt
)
1728 if ( (rHEvt
.GetMode() & (HELPMODE_QUICK
| HELPMODE_BALLOON
)) == HELPMODE_QUICK
)
1730 Point aPos
= ScreenToOutputPixel( rHEvt
.GetMousePosPixel() );
1731 USHORT nItemPos
= ImplGetItem( aPos
);
1732 if ( nItemPos
!= VALUESET_ITEM_NOTFOUND
)
1734 ValueSetItem
* pItem
= ImplGetItem( nItemPos
);
1735 Rectangle aItemRect
= pItem
->maRect
;
1736 Point aPt
= OutputToScreenPixel( aItemRect
.TopLeft() );
1737 aItemRect
.Left() = aPt
.X();
1738 aItemRect
.Top() = aPt
.Y();
1739 aPt
= OutputToScreenPixel( aItemRect
.BottomRight() );
1740 aItemRect
.Right() = aPt
.X();
1741 aItemRect
.Bottom() = aPt
.Y();
1742 Help::ShowQuickHelp( this, aItemRect
, GetItemText( pItem
->mnId
) );
1747 Control::RequestHelp( rHEvt
);
1750 // -----------------------------------------------------------------------
1752 void ValueSet::StateChanged( StateChangedType nType
)
1754 Control::StateChanged( nType
);
1756 if ( nType
== STATE_CHANGE_INITSHOW
)
1761 else if ( nType
== STATE_CHANGE_UPDATEMODE
)
1763 if ( IsReallyVisible() && IsUpdateMode() )
1766 else if ( nType
== STATE_CHANGE_TEXT
)
1768 if ( mpNoneItem
&& !mbFormat
&& IsReallyVisible() && IsUpdateMode() )
1770 ImplFormatItem( mpNoneItem
);
1771 Invalidate( mpNoneItem
->maRect
);
1774 else if ( (nType
== STATE_CHANGE_ZOOM
) ||
1775 (nType
== STATE_CHANGE_CONTROLFONT
) )
1777 ImplInitSettings( TRUE
, FALSE
, FALSE
);
1780 else if ( nType
== STATE_CHANGE_CONTROLFOREGROUND
)
1782 ImplInitSettings( FALSE
, TRUE
, FALSE
);
1785 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
1787 ImplInitSettings( FALSE
, FALSE
, TRUE
);
1790 else if ( (nType
== STATE_CHANGE_STYLE
) || (nType
== STATE_CHANGE_ENABLE
) )
1793 ImplInitSettings( FALSE
, FALSE
, TRUE
);
1798 // -----------------------------------------------------------------------
1800 void ValueSet::DataChanged( const DataChangedEvent
& rDCEvt
)
1802 Control::DataChanged( rDCEvt
);
1804 if ( (rDCEvt
.GetType() == DATACHANGED_FONTS
) ||
1805 (rDCEvt
.GetType() == DATACHANGED_DISPLAY
) ||
1806 (rDCEvt
.GetType() == DATACHANGED_FONTSUBSTITUTION
) ||
1807 ((rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
1808 (rDCEvt
.GetFlags() & SETTINGS_STYLE
)) )
1811 ImplInitSettings( TRUE
, TRUE
, TRUE
);
1816 // -----------------------------------------------------------------------
1818 void ValueSet::Select()
1820 maSelectHdl
.Call( this );
1823 // -----------------------------------------------------------------------
1825 void ValueSet::DoubleClick()
1827 maDoubleClickHdl
.Call( this );
1830 // -----------------------------------------------------------------------
1832 void ValueSet::UserDraw( const UserDrawEvent
& )
1836 // -----------------------------------------------------------------------
1838 void ValueSet::InsertItem( USHORT nItemId
, const Image
& rImage
, USHORT nPos
)
1840 DBG_ASSERT( nItemId
, "ValueSet::InsertItem(): ItemId == 0" );
1841 DBG_ASSERT( GetItemPos( nItemId
) == VALUESET_ITEM_NOTFOUND
,
1842 "ValueSet::InsertItem(): ItemId already exists" );
1844 ValueSetItem
* pItem
= new ValueSetItem( *this );
1845 pItem
->mnId
= nItemId
;
1846 pItem
->meType
= VALUESETITEM_IMAGE
;
1847 pItem
->maImage
= rImage
;
1848 mpImpl
->mpItemList
->Insert( pItem
, (ULONG
)nPos
);
1851 if ( IsReallyVisible() && IsUpdateMode() )
1855 // -----------------------------------------------------------------------
1857 void ValueSet::InsertItem( USHORT nItemId
, const Color
& rColor
, USHORT nPos
)
1859 DBG_ASSERT( nItemId
, "ValueSet::InsertItem(): ItemId == 0" );
1860 DBG_ASSERT( GetItemPos( nItemId
) == VALUESET_ITEM_NOTFOUND
,
1861 "ValueSet::InsertItem(): ItemId already exists" );
1863 ValueSetItem
* pItem
= new ValueSetItem( *this );
1864 pItem
->mnId
= nItemId
;
1865 pItem
->meType
= VALUESETITEM_COLOR
;
1866 pItem
->maColor
= rColor
;
1867 mpImpl
->mpItemList
->Insert( pItem
, (ULONG
)nPos
);
1870 if ( IsReallyVisible() && IsUpdateMode() )
1874 // -----------------------------------------------------------------------
1876 void ValueSet::InsertItem( USHORT nItemId
, const Image
& rImage
,
1877 const XubString
& rText
, USHORT nPos
)
1879 DBG_ASSERT( nItemId
, "ValueSet::InsertItem(): ItemId == 0" );
1880 DBG_ASSERT( GetItemPos( nItemId
) == VALUESET_ITEM_NOTFOUND
,
1881 "ValueSet::InsertItem(): ItemId already exists" );
1883 ValueSetItem
* pItem
= new ValueSetItem( *this );
1884 pItem
->mnId
= nItemId
;
1885 pItem
->meType
= VALUESETITEM_IMAGE
;
1886 pItem
->maImage
= rImage
;
1887 pItem
->maText
= rText
;
1888 mpImpl
->mpItemList
->Insert( pItem
, (ULONG
)nPos
);
1891 if ( IsReallyVisible() && IsUpdateMode() )
1895 // -----------------------------------------------------------------------
1897 void ValueSet::InsertItem( USHORT nItemId
, const Color
& rColor
,
1898 const XubString
& rText
, USHORT nPos
)
1900 DBG_ASSERT( nItemId
, "ValueSet::InsertItem(): ItemId == 0" );
1901 DBG_ASSERT( GetItemPos( nItemId
) == VALUESET_ITEM_NOTFOUND
,
1902 "ValueSet::InsertItem(): ItemId already exists" );
1904 ValueSetItem
* pItem
= new ValueSetItem( *this );
1905 pItem
->mnId
= nItemId
;
1906 pItem
->meType
= VALUESETITEM_COLOR
;
1907 pItem
->maColor
= rColor
;
1908 pItem
->maText
= rText
;
1909 mpImpl
->mpItemList
->Insert( pItem
, (ULONG
)nPos
);
1912 if ( IsReallyVisible() && IsUpdateMode() )
1916 // -----------------------------------------------------------------------
1918 void ValueSet::InsertItem( USHORT nItemId
, USHORT nPos
)
1920 DBG_ASSERT( nItemId
, "ValueSet::InsertItem(): ItemId == 0" );
1921 DBG_ASSERT( GetItemPos( nItemId
) == VALUESET_ITEM_NOTFOUND
,
1922 "ValueSet::InsertItem(): ItemId already exists" );
1924 ValueSetItem
* pItem
= new ValueSetItem( *this );
1925 pItem
->mnId
= nItemId
;
1926 pItem
->meType
= VALUESETITEM_USERDRAW
;
1927 mpImpl
->mpItemList
->Insert( pItem
, (ULONG
)nPos
);
1930 if ( IsReallyVisible() && IsUpdateMode() )
1934 // -----------------------------------------------------------------------
1936 void ValueSet::InsertSpace( USHORT nItemId
, USHORT nPos
)
1938 DBG_ASSERT( nItemId
, "ValueSet::InsertSpace(): ItemId == 0" );
1939 DBG_ASSERT( GetItemPos( nItemId
) == VALUESET_ITEM_NOTFOUND
,
1940 "ValueSet::InsertSpace(): ItemId already exists" );
1942 ValueSetItem
* pItem
= new ValueSetItem( *this );
1943 pItem
->mnId
= nItemId
;
1944 pItem
->meType
= VALUESETITEM_SPACE
;
1945 mpImpl
->mpItemList
->Insert( pItem
, (ULONG
)nPos
);
1948 if ( IsReallyVisible() && IsUpdateMode() )
1952 // -----------------------------------------------------------------------
1954 void ValueSet::RemoveItem( USHORT nItemId
)
1956 USHORT nPos
= GetItemPos( nItemId
);
1958 if ( nPos
== VALUESET_ITEM_NOTFOUND
)
1961 delete mpImpl
->mpItemList
->Remove( nPos
);
1963 // Variablen zuruecksetzen
1964 if ( (mnHighItemId
== nItemId
) || (mnSelItemId
== nItemId
) )
1970 mbNoSelection
= TRUE
;
1974 if ( IsReallyVisible() && IsUpdateMode() )
1978 // -----------------------------------------------------------------------
1980 void ValueSet::CopyItems( const ValueSet
& rValueSet
)
1984 ValueSetItem
* pItem
= rValueSet
.mpImpl
->mpItemList
->First();
1987 ValueSetItem
* pNewItem
= new ValueSetItem( *this );
1989 pNewItem
->mnId
= pItem
->mnId
;
1990 pNewItem
->mnBits
= pItem
->mnBits
;
1991 pNewItem
->meType
= pItem
->meType
;
1992 pNewItem
->maImage
= pItem
->maImage
;
1993 pNewItem
->maColor
= pItem
->maColor
;
1994 pNewItem
->maText
= pItem
->maText
;
1995 pNewItem
->mpData
= pItem
->mpData
;
1996 pNewItem
->maRect
= pItem
->maRect
;
1997 pNewItem
->mpxAcc
= NULL
;
1999 mpImpl
->mpItemList
->Insert( pNewItem
);
2000 pItem
= rValueSet
.mpImpl
->mpItemList
->Next();
2003 // Variablen zuruecksetzen
2009 mbNoSelection
= TRUE
;
2012 if ( IsReallyVisible() && IsUpdateMode() )
2016 // -----------------------------------------------------------------------
2018 void ValueSet::Clear()
2022 // Variablen zuruecksetzen
2028 mbNoSelection
= TRUE
;
2031 if ( IsReallyVisible() && IsUpdateMode() )
2035 // -----------------------------------------------------------------------
2037 USHORT
ValueSet::GetItemCount() const
2039 return (USHORT
)mpImpl
->mpItemList
->Count();
2042 // -----------------------------------------------------------------------
2044 USHORT
ValueSet::GetItemPos( USHORT nItemId
) const
2046 ValueSetItem
* pItem
= mpImpl
->mpItemList
->First();
2049 if ( pItem
->mnId
== nItemId
)
2050 return (USHORT
)mpImpl
->mpItemList
->GetCurPos();
2051 pItem
= mpImpl
->mpItemList
->Next();
2054 return VALUESET_ITEM_NOTFOUND
;
2057 // -----------------------------------------------------------------------
2059 USHORT
ValueSet::GetItemId( USHORT nPos
) const
2061 ValueSetItem
* pItem
= mpImpl
->mpItemList
->GetObject( nPos
);
2069 // -----------------------------------------------------------------------
2071 USHORT
ValueSet::GetItemId( const Point
& rPos
) const
2073 USHORT nItemPos
= ImplGetItem( rPos
);
2074 if ( nItemPos
!= VALUESET_ITEM_NOTFOUND
)
2075 return GetItemId( nItemPos
);
2080 // -----------------------------------------------------------------------
2082 Rectangle
ValueSet::GetItemRect( USHORT nItemId
) const
2084 USHORT nPos
= GetItemPos( nItemId
);
2086 if ( nPos
!= VALUESET_ITEM_NOTFOUND
)
2087 return mpImpl
->mpItemList
->GetObject( nPos
)->maRect
;
2092 // -----------------------------------------------------------------------
2094 void ValueSet::EnableFullItemMode( BOOL bFullMode
)
2096 mbFullMode
= bFullMode
;
2099 // -----------------------------------------------------------------------
2101 void ValueSet::SetColCount( USHORT nNewCols
)
2103 if ( mnUserCols
!= nNewCols
)
2105 mnUserCols
= nNewCols
;
2107 if ( IsReallyVisible() && IsUpdateMode() )
2112 // -----------------------------------------------------------------------
2114 void ValueSet::SetLineCount( USHORT nNewLines
)
2116 if ( mnUserVisLines
!= nNewLines
)
2118 mnUserVisLines
= nNewLines
;
2120 if ( IsReallyVisible() && IsUpdateMode() )
2125 // -----------------------------------------------------------------------
2127 void ValueSet::SetItemWidth( long nNewItemWidth
)
2129 if ( mnUserItemWidth
!= nNewItemWidth
)
2131 mnUserItemWidth
= nNewItemWidth
;
2133 if ( IsReallyVisible() && IsUpdateMode() )
2138 // -----------------------------------------------------------------------
2140 void ValueSet::SetItemHeight( long nNewItemHeight
)
2142 if ( mnUserItemHeight
!= nNewItemHeight
)
2144 mnUserItemHeight
= nNewItemHeight
;
2146 if ( IsReallyVisible() && IsUpdateMode() )
2151 // -----------------------------------------------------------------------
2153 void ValueSet::SetFirstLine( USHORT nNewLine
)
2155 if ( mnFirstLine
!= nNewLine
)
2157 mnFirstLine
= nNewLine
;
2159 if ( IsReallyVisible() && IsUpdateMode() )
2164 // -----------------------------------------------------------------------
2166 void ValueSet::SelectItem( USHORT nItemId
)
2168 USHORT nItemPos
= 0;
2172 nItemPos
= GetItemPos( nItemId
);
2173 if ( nItemPos
== VALUESET_ITEM_NOTFOUND
)
2175 if ( mpImpl
->mpItemList
->GetObject( nItemPos
)->meType
== VALUESETITEM_SPACE
)
2179 if ( (mnSelItemId
!= nItemId
) || mbNoSelection
)
2181 USHORT nOldItem
= mnSelItemId
? mnSelItemId
: 1;
2182 mnSelItemId
= nItemId
;
2183 mbNoSelection
= FALSE
;
2187 if ( !mbFormat
&& IsReallyVisible() && IsUpdateMode() )
2193 // Gegebenenfalls in den sichtbaren Bereich scrollen
2194 if ( mbScroll
&& nItemId
)
2196 USHORT nNewLine
= (USHORT
)(nItemPos
/ mnCols
);
2197 if ( nNewLine
< mnFirstLine
)
2199 mnFirstLine
= nNewLine
;
2202 else if ( nNewLine
> (USHORT
)(mnFirstLine
+mnVisLines
-1) )
2204 mnFirstLine
= (USHORT
)(nNewLine
-mnVisLines
+1);
2213 // Falls sich der sichtbare Bereich geaendert hat,
2214 // alles neu ausgeben
2220 // alte Selection wegnehmen und neue ausgeben
2221 ImplHideSelect( nOldItem
);
2226 if( ImplHasAccessibleListeners() )
2228 // focus event (deselect)
2231 const USHORT nPos
= GetItemPos( nItemId
);
2233 if( nPos
!= VALUESET_ITEM_NOTFOUND
)
2235 ValueItemAcc
* pItemAcc
= ValueItemAcc::getImplementation(
2236 mpImpl
->mpItemList
->GetObject( nPos
)->GetAccessible( mpImpl
->mbIsTransientChildrenDisabled
) );
2240 ::com::sun::star::uno::Any aOldAny
, aNewAny
;
2241 if( !mpImpl
->mbIsTransientChildrenDisabled
)
2243 aOldAny
<<= ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>(
2244 static_cast< ::cppu::OWeakObject
* >( pItemAcc
));
2245 ImplFireAccessibleEvent (::com::sun::star::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED
, aOldAny
, aNewAny
);
2249 aOldAny
<<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED
;
2250 pItemAcc
->FireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED
, aOldAny
, aNewAny
);
2256 // focus event (select)
2257 const USHORT nPos
= GetItemPos( mnSelItemId
);
2259 ValueSetItem
* pItem
;
2260 if( nPos
!= VALUESET_ITEM_NOTFOUND
)
2261 pItem
= mpImpl
->mpItemList
->GetObject(nPos
);
2265 ValueItemAcc
* pItemAcc
= NULL
;
2267 pItemAcc
= ValueItemAcc::getImplementation(pItem
->GetAccessible( mpImpl
->mbIsTransientChildrenDisabled
) );
2271 ::com::sun::star::uno::Any aOldAny
, aNewAny
;
2272 if( !mpImpl
->mbIsTransientChildrenDisabled
)
2274 aNewAny
<<= ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>(
2275 static_cast< ::cppu::OWeakObject
* >( pItemAcc
));
2276 ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED
, aOldAny
, aNewAny
);
2280 aNewAny
<<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED
;
2281 pItemAcc
->FireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED
, aOldAny
, aNewAny
);
2286 ::com::sun::star::uno::Any aOldAny
, aNewAny
;
2287 ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::SELECTION_CHANGED
, aOldAny
, aNewAny
);
2292 // -----------------------------------------------------------------------
2294 void ValueSet::SetNoSelection()
2296 mbNoSelection
= TRUE
;
2297 mbHighlight
= FALSE
;
2298 mbSelection
= FALSE
;
2300 if ( IsReallyVisible() && IsUpdateMode() )
2304 // -----------------------------------------------------------------------
2306 void ValueSet::SetItemBits( USHORT nItemId
, USHORT nItemBits
)
2308 USHORT nPos
= GetItemPos( nItemId
);
2310 if ( nPos
!= VALUESET_ITEM_NOTFOUND
)
2311 mpImpl
->mpItemList
->GetObject( nPos
)->mnBits
= nItemBits
;
2314 // -----------------------------------------------------------------------
2316 USHORT
ValueSet::GetItemBits( USHORT nItemId
) const
2318 USHORT nPos
= GetItemPos( nItemId
);
2320 if ( nPos
!= VALUESET_ITEM_NOTFOUND
)
2321 return mpImpl
->mpItemList
->GetObject( nPos
)->mnBits
;
2326 // -----------------------------------------------------------------------
2328 void ValueSet::SetItemImage( USHORT nItemId
, const Image
& rImage
)
2330 USHORT nPos
= GetItemPos( nItemId
);
2332 if ( nPos
== VALUESET_ITEM_NOTFOUND
)
2335 ValueSetItem
* pItem
= mpImpl
->mpItemList
->GetObject( nPos
);
2336 pItem
->meType
= VALUESETITEM_IMAGE
;
2337 pItem
->maImage
= rImage
;
2339 if ( !mbFormat
&& IsReallyVisible() && IsUpdateMode() )
2341 ImplFormatItem( pItem
);
2342 Invalidate( pItem
->maRect
);
2348 // -----------------------------------------------------------------------
2350 Image
ValueSet::GetItemImage( USHORT nItemId
) const
2352 USHORT nPos
= GetItemPos( nItemId
);
2354 if ( nPos
!= VALUESET_ITEM_NOTFOUND
)
2355 return mpImpl
->mpItemList
->GetObject( nPos
)->maImage
;
2360 // -----------------------------------------------------------------------
2362 void ValueSet::SetItemColor( USHORT nItemId
, const Color
& rColor
)
2364 USHORT nPos
= GetItemPos( nItemId
);
2366 if ( nPos
== VALUESET_ITEM_NOTFOUND
)
2369 ValueSetItem
* pItem
= mpImpl
->mpItemList
->GetObject( nPos
);
2370 pItem
->meType
= VALUESETITEM_COLOR
;
2371 pItem
->maColor
= rColor
;
2373 if ( !mbFormat
&& IsReallyVisible() && IsUpdateMode() )
2375 ImplFormatItem( pItem
);
2376 Invalidate( pItem
->maRect
);
2382 // -----------------------------------------------------------------------
2384 Color
ValueSet::GetItemColor( USHORT nItemId
) const
2386 USHORT nPos
= GetItemPos( nItemId
);
2388 if ( nPos
!= VALUESET_ITEM_NOTFOUND
)
2389 return mpImpl
->mpItemList
->GetObject( nPos
)->maColor
;
2394 // -----------------------------------------------------------------------
2396 void ValueSet::SetItemData( USHORT nItemId
, void* pData
)
2398 USHORT nPos
= GetItemPos( nItemId
);
2400 if ( nPos
== VALUESET_ITEM_NOTFOUND
)
2403 ValueSetItem
* pItem
= mpImpl
->mpItemList
->GetObject( nPos
);
2404 pItem
->mpData
= pData
;
2406 if ( pItem
->meType
== VALUESETITEM_USERDRAW
)
2408 if ( !mbFormat
&& IsReallyVisible() && IsUpdateMode() )
2410 ImplFormatItem( pItem
);
2411 Invalidate( pItem
->maRect
);
2418 // -----------------------------------------------------------------------
2420 void* ValueSet::GetItemData( USHORT nItemId
) const
2422 USHORT nPos
= GetItemPos( nItemId
);
2424 if ( nPos
!= VALUESET_ITEM_NOTFOUND
)
2425 return mpImpl
->mpItemList
->GetObject( nPos
)->mpData
;
2430 // -----------------------------------------------------------------------
2432 void ValueSet::SetItemText( USHORT nItemId
, const XubString
& rText
)
2434 USHORT nPos
= GetItemPos( nItemId
);
2436 if ( nPos
== VALUESET_ITEM_NOTFOUND
)
2440 ValueSetItem
* pItem
= mpImpl
->mpItemList
->GetObject( nPos
);
2442 // Remember old and new name for accessibility event.
2443 ::com::sun::star::uno::Any aOldName
, aNewName
;
2444 ::rtl::OUString
sString (pItem
->maText
);
2445 aOldName
<<= sString
;
2447 aNewName
<<= sString
;
2449 pItem
->maText
= rText
;
2451 if ( !mbFormat
&& IsReallyVisible() && IsUpdateMode() )
2453 USHORT nTempId
= mnSelItemId
;
2456 nTempId
= mnHighItemId
;
2458 if ( nTempId
== nItemId
)
2459 ImplDrawItemText( pItem
->maText
);
2462 if (ImplHasAccessibleListeners())
2464 ::com::sun::star::uno::Reference
<
2465 ::com::sun::star::accessibility::XAccessible
> xAccessible (
2466 pItem
->GetAccessible( mpImpl
->mbIsTransientChildrenDisabled
) );
2467 static_cast<ValueItemAcc
*>(xAccessible
.get())->FireAccessibleEvent (
2468 ::com::sun::star::accessibility::AccessibleEventId::NAME_CHANGED
,
2469 aOldName
, aNewName
);
2473 // -----------------------------------------------------------------------
2475 XubString
ValueSet::GetItemText( USHORT nItemId
) const
2477 USHORT nPos
= GetItemPos( nItemId
);
2479 if ( nPos
!= VALUESET_ITEM_NOTFOUND
)
2480 return mpImpl
->mpItemList
->GetObject( nPos
)->maText
;
2485 // -----------------------------------------------------------------------
2487 void ValueSet::SetColor( const Color
& rColor
)
2491 if ( IsReallyVisible() && IsUpdateMode() )
2495 // -----------------------------------------------------------------------
2497 void ValueSet::SetExtraSpacing( USHORT nNewSpacing
)
2499 if ( GetStyle() & WB_ITEMBORDER
)
2501 mnSpacing
= nNewSpacing
;
2504 if ( IsReallyVisible() && IsUpdateMode() )
2509 // -----------------------------------------------------------------------
2511 void ValueSet::StartSelection()
2513 mnOldItemId
= mnSelItemId
;
2516 mnHighItemId
= mnSelItemId
;
2519 // -----------------------------------------------------------------------
2521 void ValueSet::EndSelection()
2526 EndTracking( ENDTRACK_CANCEL
);
2528 ImplHighlightItem( mnSelItemId
);
2529 mbHighlight
= FALSE
;
2531 mbSelection
= FALSE
;
2534 // -----------------------------------------------------------------------
2536 BOOL
ValueSet::StartDrag( const CommandEvent
& rCEvt
, Region
& rRegion
)
2538 if ( rCEvt
.GetCommand() != COMMAND_STARTDRAG
)
2541 // Gegebenenfalls eine vorhandene Aktion abbrechen
2544 // Testen, ob angeklickte Seite selektiert ist. Falls dies nicht
2545 // der Fall ist, setzen wir ihn als aktuellen Eintrag. Falls Drag and
2546 // Drop auch mal ueber Tastatur ausgeloest werden kann, testen wir
2547 // dies nur bei einer Mausaktion.
2549 if ( rCEvt
.IsMouseEvent() )
2550 nSelId
= GetItemId( rCEvt
.GetMousePosPixel() );
2552 nSelId
= mnSelItemId
;
2554 // Falls kein Eintrag angeklickt wurde, starten wir kein Dragging
2558 // Testen, ob Seite selektiertiert ist. Falls nicht, als aktuelle
2559 // Seite setzen und Select rufen.
2560 if ( nSelId
!= mnSelItemId
)
2562 SelectItem( nSelId
);
2575 // -----------------------------------------------------------------------
2577 Size
ValueSet::CalcWindowSizePixel( const Size
& rItemSize
, USHORT nDesireCols
,
2578 USHORT nDesireLines
)
2580 long nCalcCols
= (long)nDesireCols
;
2581 long nCalcLines
= (long)nDesireLines
;
2586 nCalcCols
= (long)mnUserCols
;
2593 nCalcLines
= mnVisLines
;
2597 if ( mnUserVisLines
)
2598 nCalcLines
= mnUserVisLines
;
2601 nCalcLines
= (long)mpImpl
->mpItemList
->Count() / nCalcCols
;
2602 if ( mpImpl
->mpItemList
->Count() % nCalcCols
)
2604 else if ( !nCalcLines
)
2610 Size
aSize( rItemSize
.Width()*nCalcCols
, rItemSize
.Height()*nCalcLines
);
2611 WinBits nStyle
= GetStyle();
2612 long nTxtHeight
= GetTextHeight();
2616 if ( nStyle
& WB_ITEMBORDER
)
2618 if ( nStyle
& WB_DOUBLEBORDER
)
2619 n
= ITEM_OFFSET_DOUBLE
;
2623 aSize
.Width() += n
*nCalcCols
;
2624 aSize
.Height() += n
*nCalcLines
;
2632 aSize
.Width() += mnSpacing
*(nCalcCols
-1);
2633 aSize
.Height() += mnSpacing
*(nCalcLines
-1);
2638 if ( nStyle
& WB_NAMEFIELD
)
2640 aSize
.Height() += nTxtHeight
+ NAME_OFFSET
;
2641 if ( !(nStyle
& WB_FLATVALUESET
) )
2642 aSize
.Height() += NAME_LINE_HEIGHT
+NAME_LINE_OFF_Y
;
2645 if ( nStyle
& WB_NONEFIELD
)
2647 aSize
.Height() += nTxtHeight
+ n
+ nSpace
;
2648 if ( nStyle
& WB_RADIOSEL
)
2649 aSize
.Height() += 8;
2652 // Evt. ScrollBar-Breite aufaddieren
2653 aSize
.Width() += GetScrollWidth();
2658 // -----------------------------------------------------------------------
2660 Size
ValueSet::CalcItemSizePixel( const Size
& rItemSize
, BOOL bOut
) const
2662 Size aSize
= rItemSize
;
2664 WinBits nStyle
= GetStyle();
2665 if ( nStyle
& WB_ITEMBORDER
)
2669 if ( nStyle
& WB_DOUBLEBORDER
)
2670 n
= ITEM_OFFSET_DOUBLE
;
2677 aSize
.Height() += n
;
2682 aSize
.Height() -= n
;
2689 // -----------------------------------------------------------------------
2691 long ValueSet::GetScrollWidth() const
2693 if ( GetStyle() & WB_VSCROLL
)
2695 ((ValueSet
*)this)->ImplInitScrollBar();
2696 return mpScrBar
->GetSizePixel().Width()+SCRBAR_OFFSET
;
2702 // -----------------------------------------------------------------------
2704 USHORT
ValueSet::ShowDropPos( const Point
& rPos
)
2708 // Gegebenenfalls scrollen
2711 // DropPosition ermitteln
2712 USHORT nPos
= ImplGetItem( rPos
, TRUE
);
2713 if ( nPos
== VALUESET_ITEM_NONEITEM
)
2715 else if ( nPos
== VALUESET_ITEM_NOTFOUND
)
2717 Size aOutSize
= GetOutputSizePixel();
2718 if ( GetStyle() & WB_NAMEFIELD
)
2719 aOutSize
.Height() = mnTextOffset
;
2720 if ( (rPos
.X() >= 0) && (rPos
.X() < aOutSize
.Width()) &&
2721 (rPos
.Y() >= 0) && (rPos
.Y() < aOutSize
.Height()) )
2722 nPos
= (USHORT
)mpImpl
->mpItemList
->Count();
2726 // Im letzten viertel, dann wird ein Item spaeter eingefuegt
2727 Rectangle aRect
= mpImpl
->mpItemList
->GetObject( nPos
)->maRect
;
2728 if ( rPos
.X() > aRect
.Left()+aRect
.GetWidth()-(aRect
.GetWidth()/4) )
2732 if ( nPos
!= mnDropPos
)
2734 ImplDrawDropPos( FALSE
);
2736 ImplDrawDropPos( TRUE
);
2742 // -----------------------------------------------------------------------
2744 void ValueSet::HideDropPos()
2748 ImplDrawDropPos( FALSE
);
2753 // -----------------------------------------------------------------------
2755 bool ValueSet::IsRTLActive (void)
2757 return Application::GetSettings().GetLayoutRTL() && IsRTLEnabled();