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 // Tell the accessible object that we got the focus.
1687 ValueSetAcc
* pAcc
= ValueSetAcc::getImplementation( GetAccessible( FALSE
) );
1692 // -----------------------------------------------------------------------
1694 void ValueSet::LoseFocus()
1696 OSL_TRACE ("value set losing focus");
1697 if ( mbNoSelection
&& mnSelItemId
)
1698 ImplHideSelect( mnSelItemId
);
1701 Control::LoseFocus();
1703 // Tell the accessible object that we lost the focus.
1704 ValueSetAcc
* pAcc
= ValueSetAcc::getImplementation( GetAccessible( FALSE
) );
1709 // -----------------------------------------------------------------------
1711 void ValueSet::Resize()
1714 if ( IsReallyVisible() && IsUpdateMode() )
1719 // -----------------------------------------------------------------------
1721 void ValueSet::RequestHelp( const HelpEvent
& rHEvt
)
1723 if ( (rHEvt
.GetMode() & (HELPMODE_QUICK
| HELPMODE_BALLOON
)) == HELPMODE_QUICK
)
1725 Point aPos
= ScreenToOutputPixel( rHEvt
.GetMousePosPixel() );
1726 USHORT nItemPos
= ImplGetItem( aPos
);
1727 if ( nItemPos
!= VALUESET_ITEM_NOTFOUND
)
1729 ValueSetItem
* pItem
= ImplGetItem( nItemPos
);
1730 Rectangle aItemRect
= pItem
->maRect
;
1731 Point aPt
= OutputToScreenPixel( aItemRect
.TopLeft() );
1732 aItemRect
.Left() = aPt
.X();
1733 aItemRect
.Top() = aPt
.Y();
1734 aPt
= OutputToScreenPixel( aItemRect
.BottomRight() );
1735 aItemRect
.Right() = aPt
.X();
1736 aItemRect
.Bottom() = aPt
.Y();
1737 Help::ShowQuickHelp( this, aItemRect
, GetItemText( pItem
->mnId
) );
1742 Control::RequestHelp( rHEvt
);
1745 // -----------------------------------------------------------------------
1747 void ValueSet::StateChanged( StateChangedType nType
)
1749 Control::StateChanged( nType
);
1751 if ( nType
== STATE_CHANGE_INITSHOW
)
1756 else if ( nType
== STATE_CHANGE_UPDATEMODE
)
1758 if ( IsReallyVisible() && IsUpdateMode() )
1761 else if ( nType
== STATE_CHANGE_TEXT
)
1763 if ( mpNoneItem
&& !mbFormat
&& IsReallyVisible() && IsUpdateMode() )
1765 ImplFormatItem( mpNoneItem
);
1766 Invalidate( mpNoneItem
->maRect
);
1769 else if ( (nType
== STATE_CHANGE_ZOOM
) ||
1770 (nType
== STATE_CHANGE_CONTROLFONT
) )
1772 ImplInitSettings( TRUE
, FALSE
, FALSE
);
1775 else if ( nType
== STATE_CHANGE_CONTROLFOREGROUND
)
1777 ImplInitSettings( FALSE
, TRUE
, FALSE
);
1780 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
1782 ImplInitSettings( FALSE
, FALSE
, TRUE
);
1785 else if ( (nType
== STATE_CHANGE_STYLE
) || (nType
== STATE_CHANGE_ENABLE
) )
1788 ImplInitSettings( FALSE
, FALSE
, TRUE
);
1793 // -----------------------------------------------------------------------
1795 void ValueSet::DataChanged( const DataChangedEvent
& rDCEvt
)
1797 Control::DataChanged( rDCEvt
);
1799 if ( (rDCEvt
.GetType() == DATACHANGED_FONTS
) ||
1800 (rDCEvt
.GetType() == DATACHANGED_DISPLAY
) ||
1801 (rDCEvt
.GetType() == DATACHANGED_FONTSUBSTITUTION
) ||
1802 ((rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
1803 (rDCEvt
.GetFlags() & SETTINGS_STYLE
)) )
1806 ImplInitSettings( TRUE
, TRUE
, TRUE
);
1811 // -----------------------------------------------------------------------
1813 void ValueSet::Select()
1815 maSelectHdl
.Call( this );
1818 // -----------------------------------------------------------------------
1820 void ValueSet::DoubleClick()
1822 maDoubleClickHdl
.Call( this );
1825 // -----------------------------------------------------------------------
1827 void ValueSet::UserDraw( const UserDrawEvent
& )
1831 // -----------------------------------------------------------------------
1833 void ValueSet::InsertItem( USHORT nItemId
, const Image
& rImage
, USHORT nPos
)
1835 DBG_ASSERT( nItemId
, "ValueSet::InsertItem(): ItemId == 0" );
1836 DBG_ASSERT( GetItemPos( nItemId
) == VALUESET_ITEM_NOTFOUND
,
1837 "ValueSet::InsertItem(): ItemId already exists" );
1839 ValueSetItem
* pItem
= new ValueSetItem( *this );
1840 pItem
->mnId
= nItemId
;
1841 pItem
->meType
= VALUESETITEM_IMAGE
;
1842 pItem
->maImage
= rImage
;
1843 mpImpl
->mpItemList
->Insert( pItem
, (ULONG
)nPos
);
1846 if ( IsReallyVisible() && IsUpdateMode() )
1850 // -----------------------------------------------------------------------
1852 void ValueSet::InsertItem( USHORT nItemId
, const Color
& rColor
, USHORT nPos
)
1854 DBG_ASSERT( nItemId
, "ValueSet::InsertItem(): ItemId == 0" );
1855 DBG_ASSERT( GetItemPos( nItemId
) == VALUESET_ITEM_NOTFOUND
,
1856 "ValueSet::InsertItem(): ItemId already exists" );
1858 ValueSetItem
* pItem
= new ValueSetItem( *this );
1859 pItem
->mnId
= nItemId
;
1860 pItem
->meType
= VALUESETITEM_COLOR
;
1861 pItem
->maColor
= rColor
;
1862 mpImpl
->mpItemList
->Insert( pItem
, (ULONG
)nPos
);
1865 if ( IsReallyVisible() && IsUpdateMode() )
1869 // -----------------------------------------------------------------------
1871 void ValueSet::InsertItem( USHORT nItemId
, const Image
& rImage
,
1872 const XubString
& rText
, USHORT nPos
)
1874 DBG_ASSERT( nItemId
, "ValueSet::InsertItem(): ItemId == 0" );
1875 DBG_ASSERT( GetItemPos( nItemId
) == VALUESET_ITEM_NOTFOUND
,
1876 "ValueSet::InsertItem(): ItemId already exists" );
1878 ValueSetItem
* pItem
= new ValueSetItem( *this );
1879 pItem
->mnId
= nItemId
;
1880 pItem
->meType
= VALUESETITEM_IMAGE
;
1881 pItem
->maImage
= rImage
;
1882 pItem
->maText
= rText
;
1883 mpImpl
->mpItemList
->Insert( pItem
, (ULONG
)nPos
);
1886 if ( IsReallyVisible() && IsUpdateMode() )
1890 // -----------------------------------------------------------------------
1892 void ValueSet::InsertItem( USHORT nItemId
, const Color
& rColor
,
1893 const XubString
& rText
, USHORT nPos
)
1895 DBG_ASSERT( nItemId
, "ValueSet::InsertItem(): ItemId == 0" );
1896 DBG_ASSERT( GetItemPos( nItemId
) == VALUESET_ITEM_NOTFOUND
,
1897 "ValueSet::InsertItem(): ItemId already exists" );
1899 ValueSetItem
* pItem
= new ValueSetItem( *this );
1900 pItem
->mnId
= nItemId
;
1901 pItem
->meType
= VALUESETITEM_COLOR
;
1902 pItem
->maColor
= rColor
;
1903 pItem
->maText
= rText
;
1904 mpImpl
->mpItemList
->Insert( pItem
, (ULONG
)nPos
);
1907 if ( IsReallyVisible() && IsUpdateMode() )
1911 // -----------------------------------------------------------------------
1913 void ValueSet::InsertItem( USHORT nItemId
, USHORT nPos
)
1915 DBG_ASSERT( nItemId
, "ValueSet::InsertItem(): ItemId == 0" );
1916 DBG_ASSERT( GetItemPos( nItemId
) == VALUESET_ITEM_NOTFOUND
,
1917 "ValueSet::InsertItem(): ItemId already exists" );
1919 ValueSetItem
* pItem
= new ValueSetItem( *this );
1920 pItem
->mnId
= nItemId
;
1921 pItem
->meType
= VALUESETITEM_USERDRAW
;
1922 mpImpl
->mpItemList
->Insert( pItem
, (ULONG
)nPos
);
1925 if ( IsReallyVisible() && IsUpdateMode() )
1929 // -----------------------------------------------------------------------
1931 void ValueSet::InsertSpace( USHORT nItemId
, USHORT nPos
)
1933 DBG_ASSERT( nItemId
, "ValueSet::InsertSpace(): ItemId == 0" );
1934 DBG_ASSERT( GetItemPos( nItemId
) == VALUESET_ITEM_NOTFOUND
,
1935 "ValueSet::InsertSpace(): ItemId already exists" );
1937 ValueSetItem
* pItem
= new ValueSetItem( *this );
1938 pItem
->mnId
= nItemId
;
1939 pItem
->meType
= VALUESETITEM_SPACE
;
1940 mpImpl
->mpItemList
->Insert( pItem
, (ULONG
)nPos
);
1943 if ( IsReallyVisible() && IsUpdateMode() )
1947 // -----------------------------------------------------------------------
1949 void ValueSet::RemoveItem( USHORT nItemId
)
1951 USHORT nPos
= GetItemPos( nItemId
);
1953 if ( nPos
== VALUESET_ITEM_NOTFOUND
)
1956 delete mpImpl
->mpItemList
->Remove( nPos
);
1958 // Variablen zuruecksetzen
1959 if ( (mnHighItemId
== nItemId
) || (mnSelItemId
== nItemId
) )
1965 mbNoSelection
= TRUE
;
1969 if ( IsReallyVisible() && IsUpdateMode() )
1973 // -----------------------------------------------------------------------
1975 void ValueSet::CopyItems( const ValueSet
& rValueSet
)
1979 ValueSetItem
* pItem
= rValueSet
.mpImpl
->mpItemList
->First();
1982 ValueSetItem
* pNewItem
= new ValueSetItem( *this );
1984 pNewItem
->mnId
= pItem
->mnId
;
1985 pNewItem
->mnBits
= pItem
->mnBits
;
1986 pNewItem
->meType
= pItem
->meType
;
1987 pNewItem
->maImage
= pItem
->maImage
;
1988 pNewItem
->maColor
= pItem
->maColor
;
1989 pNewItem
->maText
= pItem
->maText
;
1990 pNewItem
->mpData
= pItem
->mpData
;
1991 pNewItem
->maRect
= pItem
->maRect
;
1992 pNewItem
->mpxAcc
= NULL
;
1994 mpImpl
->mpItemList
->Insert( pNewItem
);
1995 pItem
= rValueSet
.mpImpl
->mpItemList
->Next();
1998 // Variablen zuruecksetzen
2004 mbNoSelection
= TRUE
;
2007 if ( IsReallyVisible() && IsUpdateMode() )
2011 // -----------------------------------------------------------------------
2013 void ValueSet::Clear()
2017 // Variablen zuruecksetzen
2023 mbNoSelection
= TRUE
;
2026 if ( IsReallyVisible() && IsUpdateMode() )
2030 // -----------------------------------------------------------------------
2032 USHORT
ValueSet::GetItemCount() const
2034 return (USHORT
)mpImpl
->mpItemList
->Count();
2037 // -----------------------------------------------------------------------
2039 USHORT
ValueSet::GetItemPos( USHORT nItemId
) const
2041 ValueSetItem
* pItem
= mpImpl
->mpItemList
->First();
2044 if ( pItem
->mnId
== nItemId
)
2045 return (USHORT
)mpImpl
->mpItemList
->GetCurPos();
2046 pItem
= mpImpl
->mpItemList
->Next();
2049 return VALUESET_ITEM_NOTFOUND
;
2052 // -----------------------------------------------------------------------
2054 USHORT
ValueSet::GetItemId( USHORT nPos
) const
2056 ValueSetItem
* pItem
= mpImpl
->mpItemList
->GetObject( nPos
);
2064 // -----------------------------------------------------------------------
2066 USHORT
ValueSet::GetItemId( const Point
& rPos
) const
2068 USHORT nItemPos
= ImplGetItem( rPos
);
2069 if ( nItemPos
!= VALUESET_ITEM_NOTFOUND
)
2070 return GetItemId( nItemPos
);
2075 // -----------------------------------------------------------------------
2077 Rectangle
ValueSet::GetItemRect( USHORT nItemId
) const
2079 USHORT nPos
= GetItemPos( nItemId
);
2081 if ( nPos
!= VALUESET_ITEM_NOTFOUND
)
2082 return mpImpl
->mpItemList
->GetObject( nPos
)->maRect
;
2087 // -----------------------------------------------------------------------
2089 void ValueSet::EnableFullItemMode( BOOL bFullMode
)
2091 mbFullMode
= bFullMode
;
2094 // -----------------------------------------------------------------------
2096 void ValueSet::SetColCount( USHORT nNewCols
)
2098 if ( mnUserCols
!= nNewCols
)
2100 mnUserCols
= nNewCols
;
2102 if ( IsReallyVisible() && IsUpdateMode() )
2107 // -----------------------------------------------------------------------
2109 void ValueSet::SetLineCount( USHORT nNewLines
)
2111 if ( mnUserVisLines
!= nNewLines
)
2113 mnUserVisLines
= nNewLines
;
2115 if ( IsReallyVisible() && IsUpdateMode() )
2120 // -----------------------------------------------------------------------
2122 void ValueSet::SetItemWidth( long nNewItemWidth
)
2124 if ( mnUserItemWidth
!= nNewItemWidth
)
2126 mnUserItemWidth
= nNewItemWidth
;
2128 if ( IsReallyVisible() && IsUpdateMode() )
2133 // -----------------------------------------------------------------------
2135 void ValueSet::SetItemHeight( long nNewItemHeight
)
2137 if ( mnUserItemHeight
!= nNewItemHeight
)
2139 mnUserItemHeight
= nNewItemHeight
;
2141 if ( IsReallyVisible() && IsUpdateMode() )
2146 // -----------------------------------------------------------------------
2148 void ValueSet::SetFirstLine( USHORT nNewLine
)
2150 if ( mnFirstLine
!= nNewLine
)
2152 mnFirstLine
= nNewLine
;
2154 if ( IsReallyVisible() && IsUpdateMode() )
2159 // -----------------------------------------------------------------------
2161 void ValueSet::SelectItem( USHORT nItemId
)
2163 USHORT nItemPos
= 0;
2167 nItemPos
= GetItemPos( nItemId
);
2168 if ( nItemPos
== VALUESET_ITEM_NOTFOUND
)
2170 if ( mpImpl
->mpItemList
->GetObject( nItemPos
)->meType
== VALUESETITEM_SPACE
)
2174 if ( (mnSelItemId
!= nItemId
) || mbNoSelection
)
2176 USHORT nOldItem
= mnSelItemId
? mnSelItemId
: 1;
2177 mnSelItemId
= nItemId
;
2178 mbNoSelection
= FALSE
;
2182 if ( !mbFormat
&& IsReallyVisible() && IsUpdateMode() )
2188 // Gegebenenfalls in den sichtbaren Bereich scrollen
2189 if ( mbScroll
&& nItemId
)
2191 USHORT nNewLine
= (USHORT
)(nItemPos
/ mnCols
);
2192 if ( nNewLine
< mnFirstLine
)
2194 mnFirstLine
= nNewLine
;
2197 else if ( nNewLine
> (USHORT
)(mnFirstLine
+mnVisLines
-1) )
2199 mnFirstLine
= (USHORT
)(nNewLine
-mnVisLines
+1);
2208 // Falls sich der sichtbare Bereich geaendert hat,
2209 // alles neu ausgeben
2215 // alte Selection wegnehmen und neue ausgeben
2216 ImplHideSelect( nOldItem
);
2221 if( ImplHasAccessibleListeners() )
2223 // focus event (deselect)
2226 const USHORT nPos
= GetItemPos( nItemId
);
2228 if( nPos
!= VALUESET_ITEM_NOTFOUND
)
2230 ValueItemAcc
* pItemAcc
= ValueItemAcc::getImplementation(
2231 mpImpl
->mpItemList
->GetObject( nPos
)->GetAccessible( mpImpl
->mbIsTransientChildrenDisabled
) );
2235 ::com::sun::star::uno::Any aOldAny
, aNewAny
;
2236 if( !mpImpl
->mbIsTransientChildrenDisabled
)
2238 aOldAny
<<= ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>(
2239 static_cast< ::cppu::OWeakObject
* >( pItemAcc
));
2240 ImplFireAccessibleEvent (::com::sun::star::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED
, aOldAny
, aNewAny
);
2244 aOldAny
<<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED
;
2245 pItemAcc
->FireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED
, aOldAny
, aNewAny
);
2251 // focus event (select)
2252 const USHORT nPos
= GetItemPos( mnSelItemId
);
2254 ValueSetItem
* pItem
;
2255 if( nPos
!= VALUESET_ITEM_NOTFOUND
)
2256 pItem
= mpImpl
->mpItemList
->GetObject(nPos
);
2260 ValueItemAcc
* pItemAcc
= NULL
;
2262 pItemAcc
= ValueItemAcc::getImplementation(pItem
->GetAccessible( mpImpl
->mbIsTransientChildrenDisabled
) );
2266 ::com::sun::star::uno::Any aOldAny
, aNewAny
;
2267 if( !mpImpl
->mbIsTransientChildrenDisabled
)
2269 aNewAny
<<= ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>(
2270 static_cast< ::cppu::OWeakObject
* >( pItemAcc
));
2271 ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED
, aOldAny
, aNewAny
);
2275 aNewAny
<<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED
;
2276 pItemAcc
->FireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED
, aOldAny
, aNewAny
);
2281 ::com::sun::star::uno::Any aOldAny
, aNewAny
;
2282 ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::SELECTION_CHANGED
, aOldAny
, aNewAny
);
2287 // -----------------------------------------------------------------------
2289 void ValueSet::SetNoSelection()
2291 mbNoSelection
= TRUE
;
2292 mbHighlight
= FALSE
;
2293 mbSelection
= FALSE
;
2295 if ( IsReallyVisible() && IsUpdateMode() )
2299 // -----------------------------------------------------------------------
2301 void ValueSet::SetItemBits( USHORT nItemId
, USHORT nItemBits
)
2303 USHORT nPos
= GetItemPos( nItemId
);
2305 if ( nPos
!= VALUESET_ITEM_NOTFOUND
)
2306 mpImpl
->mpItemList
->GetObject( nPos
)->mnBits
= nItemBits
;
2309 // -----------------------------------------------------------------------
2311 USHORT
ValueSet::GetItemBits( USHORT nItemId
) const
2313 USHORT nPos
= GetItemPos( nItemId
);
2315 if ( nPos
!= VALUESET_ITEM_NOTFOUND
)
2316 return mpImpl
->mpItemList
->GetObject( nPos
)->mnBits
;
2321 // -----------------------------------------------------------------------
2323 void ValueSet::SetItemImage( USHORT nItemId
, const Image
& rImage
)
2325 USHORT nPos
= GetItemPos( nItemId
);
2327 if ( nPos
== VALUESET_ITEM_NOTFOUND
)
2330 ValueSetItem
* pItem
= mpImpl
->mpItemList
->GetObject( nPos
);
2331 pItem
->meType
= VALUESETITEM_IMAGE
;
2332 pItem
->maImage
= rImage
;
2334 if ( !mbFormat
&& IsReallyVisible() && IsUpdateMode() )
2336 ImplFormatItem( pItem
);
2337 Invalidate( pItem
->maRect
);
2343 // -----------------------------------------------------------------------
2345 Image
ValueSet::GetItemImage( USHORT nItemId
) const
2347 USHORT nPos
= GetItemPos( nItemId
);
2349 if ( nPos
!= VALUESET_ITEM_NOTFOUND
)
2350 return mpImpl
->mpItemList
->GetObject( nPos
)->maImage
;
2355 // -----------------------------------------------------------------------
2357 void ValueSet::SetItemColor( USHORT nItemId
, const Color
& rColor
)
2359 USHORT nPos
= GetItemPos( nItemId
);
2361 if ( nPos
== VALUESET_ITEM_NOTFOUND
)
2364 ValueSetItem
* pItem
= mpImpl
->mpItemList
->GetObject( nPos
);
2365 pItem
->meType
= VALUESETITEM_COLOR
;
2366 pItem
->maColor
= rColor
;
2368 if ( !mbFormat
&& IsReallyVisible() && IsUpdateMode() )
2370 ImplFormatItem( pItem
);
2371 Invalidate( pItem
->maRect
);
2377 // -----------------------------------------------------------------------
2379 Color
ValueSet::GetItemColor( USHORT nItemId
) const
2381 USHORT nPos
= GetItemPos( nItemId
);
2383 if ( nPos
!= VALUESET_ITEM_NOTFOUND
)
2384 return mpImpl
->mpItemList
->GetObject( nPos
)->maColor
;
2389 // -----------------------------------------------------------------------
2391 void ValueSet::SetItemData( USHORT nItemId
, void* pData
)
2393 USHORT nPos
= GetItemPos( nItemId
);
2395 if ( nPos
== VALUESET_ITEM_NOTFOUND
)
2398 ValueSetItem
* pItem
= mpImpl
->mpItemList
->GetObject( nPos
);
2399 pItem
->mpData
= pData
;
2401 if ( pItem
->meType
== VALUESETITEM_USERDRAW
)
2403 if ( !mbFormat
&& IsReallyVisible() && IsUpdateMode() )
2405 ImplFormatItem( pItem
);
2406 Invalidate( pItem
->maRect
);
2413 // -----------------------------------------------------------------------
2415 void* ValueSet::GetItemData( USHORT nItemId
) const
2417 USHORT nPos
= GetItemPos( nItemId
);
2419 if ( nPos
!= VALUESET_ITEM_NOTFOUND
)
2420 return mpImpl
->mpItemList
->GetObject( nPos
)->mpData
;
2425 // -----------------------------------------------------------------------
2427 void ValueSet::SetItemText( USHORT nItemId
, const XubString
& rText
)
2429 USHORT nPos
= GetItemPos( nItemId
);
2431 if ( nPos
== VALUESET_ITEM_NOTFOUND
)
2435 ValueSetItem
* pItem
= mpImpl
->mpItemList
->GetObject( nPos
);
2437 // Remember old and new name for accessibility event.
2438 ::com::sun::star::uno::Any aOldName
, aNewName
;
2439 ::rtl::OUString
sString (pItem
->maText
);
2440 aOldName
<<= sString
;
2442 aNewName
<<= sString
;
2444 pItem
->maText
= rText
;
2446 if ( !mbFormat
&& IsReallyVisible() && IsUpdateMode() )
2448 USHORT nTempId
= mnSelItemId
;
2451 nTempId
= mnHighItemId
;
2453 if ( nTempId
== nItemId
)
2454 ImplDrawItemText( pItem
->maText
);
2457 if (ImplHasAccessibleListeners())
2459 ::com::sun::star::uno::Reference
<
2460 ::com::sun::star::accessibility::XAccessible
> xAccessible (
2461 pItem
->GetAccessible( mpImpl
->mbIsTransientChildrenDisabled
) );
2462 static_cast<ValueItemAcc
*>(xAccessible
.get())->FireAccessibleEvent (
2463 ::com::sun::star::accessibility::AccessibleEventId::NAME_CHANGED
,
2464 aOldName
, aNewName
);
2468 // -----------------------------------------------------------------------
2470 XubString
ValueSet::GetItemText( USHORT nItemId
) const
2472 USHORT nPos
= GetItemPos( nItemId
);
2474 if ( nPos
!= VALUESET_ITEM_NOTFOUND
)
2475 return mpImpl
->mpItemList
->GetObject( nPos
)->maText
;
2480 // -----------------------------------------------------------------------
2482 void ValueSet::SetColor( const Color
& rColor
)
2486 if ( IsReallyVisible() && IsUpdateMode() )
2490 // -----------------------------------------------------------------------
2492 void ValueSet::SetExtraSpacing( USHORT nNewSpacing
)
2494 if ( GetStyle() & WB_ITEMBORDER
)
2496 mnSpacing
= nNewSpacing
;
2499 if ( IsReallyVisible() && IsUpdateMode() )
2504 // -----------------------------------------------------------------------
2506 void ValueSet::StartSelection()
2508 mnOldItemId
= mnSelItemId
;
2511 mnHighItemId
= mnSelItemId
;
2514 // -----------------------------------------------------------------------
2516 void ValueSet::EndSelection()
2521 EndTracking( ENDTRACK_CANCEL
);
2523 ImplHighlightItem( mnSelItemId
);
2524 mbHighlight
= FALSE
;
2526 mbSelection
= FALSE
;
2529 // -----------------------------------------------------------------------
2531 BOOL
ValueSet::StartDrag( const CommandEvent
& rCEvt
, Region
& rRegion
)
2533 if ( rCEvt
.GetCommand() != COMMAND_STARTDRAG
)
2536 // Gegebenenfalls eine vorhandene Aktion abbrechen
2539 // Testen, ob angeklickte Seite selektiert ist. Falls dies nicht
2540 // der Fall ist, setzen wir ihn als aktuellen Eintrag. Falls Drag and
2541 // Drop auch mal ueber Tastatur ausgeloest werden kann, testen wir
2542 // dies nur bei einer Mausaktion.
2544 if ( rCEvt
.IsMouseEvent() )
2545 nSelId
= GetItemId( rCEvt
.GetMousePosPixel() );
2547 nSelId
= mnSelItemId
;
2549 // Falls kein Eintrag angeklickt wurde, starten wir kein Dragging
2553 // Testen, ob Seite selektiertiert ist. Falls nicht, als aktuelle
2554 // Seite setzen und Select rufen.
2555 if ( nSelId
!= mnSelItemId
)
2557 SelectItem( nSelId
);
2570 // -----------------------------------------------------------------------
2572 Size
ValueSet::CalcWindowSizePixel( const Size
& rItemSize
, USHORT nDesireCols
,
2573 USHORT nDesireLines
)
2575 long nCalcCols
= (long)nDesireCols
;
2576 long nCalcLines
= (long)nDesireLines
;
2581 nCalcCols
= (long)mnUserCols
;
2588 nCalcLines
= mnVisLines
;
2592 if ( mnUserVisLines
)
2593 nCalcLines
= mnUserVisLines
;
2596 nCalcLines
= (long)mpImpl
->mpItemList
->Count() / nCalcCols
;
2597 if ( mpImpl
->mpItemList
->Count() % nCalcCols
)
2599 else if ( !nCalcLines
)
2605 Size
aSize( rItemSize
.Width()*nCalcCols
, rItemSize
.Height()*nCalcLines
);
2606 WinBits nStyle
= GetStyle();
2607 long nTxtHeight
= GetTextHeight();
2611 if ( nStyle
& WB_ITEMBORDER
)
2613 if ( nStyle
& WB_DOUBLEBORDER
)
2614 n
= ITEM_OFFSET_DOUBLE
;
2618 aSize
.Width() += n
*nCalcCols
;
2619 aSize
.Height() += n
*nCalcLines
;
2627 aSize
.Width() += mnSpacing
*(nCalcCols
-1);
2628 aSize
.Height() += mnSpacing
*(nCalcLines
-1);
2633 if ( nStyle
& WB_NAMEFIELD
)
2635 aSize
.Height() += nTxtHeight
+ NAME_OFFSET
;
2636 if ( !(nStyle
& WB_FLATVALUESET
) )
2637 aSize
.Height() += NAME_LINE_HEIGHT
+NAME_LINE_OFF_Y
;
2640 if ( nStyle
& WB_NONEFIELD
)
2642 aSize
.Height() += nTxtHeight
+ n
+ nSpace
;
2643 if ( nStyle
& WB_RADIOSEL
)
2644 aSize
.Height() += 8;
2647 // Evt. ScrollBar-Breite aufaddieren
2648 aSize
.Width() += GetScrollWidth();
2653 // -----------------------------------------------------------------------
2655 Size
ValueSet::CalcItemSizePixel( const Size
& rItemSize
, BOOL bOut
) const
2657 Size aSize
= rItemSize
;
2659 WinBits nStyle
= GetStyle();
2660 if ( nStyle
& WB_ITEMBORDER
)
2664 if ( nStyle
& WB_DOUBLEBORDER
)
2665 n
= ITEM_OFFSET_DOUBLE
;
2672 aSize
.Height() += n
;
2677 aSize
.Height() -= n
;
2684 // -----------------------------------------------------------------------
2686 long ValueSet::GetScrollWidth() const
2688 if ( GetStyle() & WB_VSCROLL
)
2690 ((ValueSet
*)this)->ImplInitScrollBar();
2691 return mpScrBar
->GetSizePixel().Width()+SCRBAR_OFFSET
;
2697 // -----------------------------------------------------------------------
2699 USHORT
ValueSet::ShowDropPos( const Point
& rPos
)
2703 // Gegebenenfalls scrollen
2706 // DropPosition ermitteln
2707 USHORT nPos
= ImplGetItem( rPos
, TRUE
);
2708 if ( nPos
== VALUESET_ITEM_NONEITEM
)
2710 else if ( nPos
== VALUESET_ITEM_NOTFOUND
)
2712 Size aOutSize
= GetOutputSizePixel();
2713 if ( GetStyle() & WB_NAMEFIELD
)
2714 aOutSize
.Height() = mnTextOffset
;
2715 if ( (rPos
.X() >= 0) && (rPos
.X() < aOutSize
.Width()) &&
2716 (rPos
.Y() >= 0) && (rPos
.Y() < aOutSize
.Height()) )
2717 nPos
= (USHORT
)mpImpl
->mpItemList
->Count();
2721 // Im letzten viertel, dann wird ein Item spaeter eingefuegt
2722 Rectangle aRect
= mpImpl
->mpItemList
->GetObject( nPos
)->maRect
;
2723 if ( rPos
.X() > aRect
.Left()+aRect
.GetWidth()-(aRect
.GetWidth()/4) )
2727 if ( nPos
!= mnDropPos
)
2729 ImplDrawDropPos( FALSE
);
2731 ImplDrawDropPos( TRUE
);
2737 // -----------------------------------------------------------------------
2739 void ValueSet::HideDropPos()
2743 ImplDrawDropPos( FALSE
);
2748 // -----------------------------------------------------------------------
2750 bool ValueSet::IsRTLActive (void)
2752 return Application::GetSettings().GetLayoutRTL() && IsRTLEnabled();