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