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