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