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