1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svtools.hxx" 30 #include <svtools/editbrowsebox.hxx> 31 32 #ifndef _SVTOOLS_EDITBROWSEBOX_HRC_ 33 #include "editbrowsebox.hrc" 34 #endif 35 36 #ifndef _APP_HXX //autogen 37 #include <vcl/svapp.hxx> 38 #endif 39 #include <tools/debug.hxx> 40 #include <vcl/window.hxx> 41 42 #ifndef _EDIT_HXX //autogen 43 #include <vcl/edit.hxx> 44 #endif 45 #include <tools/resid.hxx> 46 #include <vcl/spinfld.hxx> 47 #include <svtools/svtdata.hxx> 48 49 #ifndef _SVTOOLS_HRC 50 #include <svtools/svtools.hrc> 51 #endif 52 53 #include <algorithm> 54 #include <tools/multisel.hxx> 55 #include "editbrowseboximpl.hxx" 56 #include <com/sun/star/accessibility/AccessibleEventId.hpp> 57 #include <com/sun/star/accessibility/XAccessible.hpp> 58 #include <comphelper/types.hxx> 59 60 // ....................................................................... 61 namespace svt 62 { 63 // ....................................................................... 64 namespace 65 { 66 //.............................................................. 67 sal_Bool isHiContrast(Window* _pWindow) 68 { 69 OSL_ENSURE(_pWindow,"Window must be not null!"); 70 return _pWindow && _pWindow->GetSettings().GetStyleSettings().GetHighContrastMode(); 71 } 72 73 //.............................................................. 74 sal_uInt16 getRealGetFocusFlags( Window* _pWindow ) 75 { 76 sal_uInt16 nFlags = 0; 77 while ( _pWindow && !nFlags ) 78 { 79 nFlags = _pWindow->GetGetFocusFlags( ); 80 _pWindow = _pWindow->GetParent(); 81 } 82 return nFlags; 83 } 84 } 85 86 using namespace ::com::sun::star::uno; 87 using namespace com::sun::star::accessibility::AccessibleEventId; 88 using com::sun::star::accessibility::XAccessible; 89 //================================================================== 90 91 #define HANDLE_ID 0 92 93 //================================================================== 94 //= EditBrowserHeader 95 //================================================================== 96 //------------------------------------------------------------------------------ 97 void EditBrowserHeader::DoubleClick() 98 { 99 sal_uInt16 nColId = GetCurItemId(); 100 if (nColId) 101 { 102 sal_uInt32 nAutoWidth = ((EditBrowseBox*)GetParent())->GetAutoColumnWidth(nColId); 103 if (nAutoWidth != ((EditBrowseBox*)GetParent())->GetColumnWidth(nColId)) 104 { 105 ((EditBrowseBox*)GetParent())->SetColumnWidth(nColId, nAutoWidth); 106 ((EditBrowseBox*)GetParent())->ColumnResized(nColId); 107 } 108 } 109 } 110 111 112 //================================================================== 113 //= EditBrowseBox 114 //================================================================== 115 //------------------------------------------------------------------------------ 116 void EditBrowseBox::BrowserMouseEventPtr::Clear() 117 { 118 DELETEZ(pEvent); 119 } 120 121 //------------------------------------------------------------------------------ 122 void EditBrowseBox::BrowserMouseEventPtr::Set(const BrowserMouseEvent* pEvt, sal_Bool bIsDown) 123 { 124 if (pEvt == pEvent) 125 { 126 bDown = bIsDown; 127 return; 128 } 129 Clear(); 130 if (pEvt) 131 { 132 pEvent = new BrowserMouseEvent(pEvt->GetWindow(), 133 *pEvt, 134 pEvt->GetRow(), 135 pEvt->GetColumn(), 136 pEvt->GetColumnId(), 137 pEvt->GetRect()); 138 bDown = bIsDown; 139 } 140 } 141 142 //------------------------------------------------------------------------------ 143 DBG_NAME(EditBrowseBox); 144 void EditBrowseBox::impl_construct() 145 { 146 m_aImpl = ::std::auto_ptr<EditBrowseBoxImpl>(new EditBrowseBoxImpl()); 147 m_aImpl->m_bHiContrast = isHiContrast(&GetDataWindow()); 148 149 SetCompoundControl(sal_True); 150 SetGridLineColor( Color( COL_LIGHTGRAY ) ); 151 152 ImplInitSettings(sal_True, sal_True, sal_True); 153 154 pCheckBoxPaint = new CheckBoxControl(&GetDataWindow()); 155 pCheckBoxPaint->SetPaintTransparent( sal_True ); 156 pCheckBoxPaint->SetBackground(); 157 } 158 159 //------------------------------------------------------------------------------ 160 EditBrowseBox::EditBrowseBox(Window* pParent, const ResId& rId, sal_Int32 nBrowserFlags, BrowserMode _nMode ) 161 :BrowseBox( pParent, rId, _nMode ) 162 ,nStartEvent(0) 163 ,nEndEvent(0) 164 ,nCellModifiedEvent(0) 165 ,nPaintRow(-1) 166 ,nEditRow(-1) 167 ,nOldEditRow(-1) 168 ,nEditCol(0) 169 ,nOldEditCol(0) 170 ,bHasFocus(sal_False) 171 ,bPaintStatus(sal_True) 172 ,bActiveBeforeTracking( sal_False ) 173 ,m_nBrowserFlags(nBrowserFlags) 174 { 175 DBG_CTOR(EditBrowseBox,NULL); 176 177 impl_construct(); 178 } 179 180 //================================================================== 181 EditBrowseBox::EditBrowseBox( Window* pParent, sal_Int32 nBrowserFlags, WinBits nBits, BrowserMode _nMode ) 182 :BrowseBox( pParent, nBits, _nMode ) 183 ,nStartEvent(0) 184 ,nEndEvent(0) 185 ,nCellModifiedEvent(0) 186 ,nPaintRow(-1) 187 ,nEditRow(-1) 188 ,nOldEditRow(-1) 189 ,nEditCol(0) 190 ,nOldEditCol(0) 191 ,bHasFocus(sal_False) 192 ,bPaintStatus(sal_True) 193 ,bActiveBeforeTracking( sal_False ) 194 ,m_nBrowserFlags(nBrowserFlags) 195 ,pHeader(NULL) 196 { 197 DBG_CTOR(EditBrowseBox,NULL); 198 199 impl_construct(); 200 } 201 202 //------------------------------------------------------------------------------ 203 void EditBrowseBox::Init() 204 { 205 // spaetes Construieren, 206 } 207 208 //------------------------------------------------------------------------------ 209 EditBrowseBox::~EditBrowseBox() 210 { 211 if (nStartEvent) 212 Application::RemoveUserEvent(nStartEvent); 213 if (nEndEvent) 214 Application::RemoveUserEvent(nEndEvent); 215 if (nCellModifiedEvent) 216 Application::RemoveUserEvent(nCellModifiedEvent); 217 218 delete pCheckBoxPaint; 219 220 DBG_DTOR(EditBrowseBox,NULL); 221 } 222 223 //------------------------------------------------------------------------------ 224 void EditBrowseBox::RemoveRows() 225 { 226 BrowseBox::Clear(); 227 nOldEditRow = nEditRow = nPaintRow = -1; 228 nEditCol = nOldEditCol = 0; 229 } 230 231 //------------------------------------------------------------------------------ 232 BrowserHeader* EditBrowseBox::CreateHeaderBar(BrowseBox* pParent) 233 { 234 pHeader = imp_CreateHeaderBar(pParent); 235 if (!IsUpdateMode()) 236 pHeader->SetUpdateMode(sal_False); 237 return pHeader; 238 } 239 240 //------------------------------------------------------------------------------ 241 BrowserHeader* EditBrowseBox::imp_CreateHeaderBar(BrowseBox* pParent) 242 { 243 return new EditBrowserHeader(pParent); 244 } 245 246 //------------------------------------------------------------------------------ 247 void EditBrowseBox::LoseFocus() 248 { 249 BrowseBox::LoseFocus(); 250 DetermineFocus( 0 ); 251 } 252 253 //------------------------------------------------------------------------------ 254 void EditBrowseBox::GetFocus() 255 { 256 BrowseBox::GetFocus(); 257 258 // This should handle the case that the BrowseBox (or one of it's children) 259 // gets the focus from outside by pressing Tab 260 if (IsEditing() && Controller()->GetWindow().IsVisible()) 261 Controller()->GetWindow().GrabFocus(); 262 263 DetermineFocus( getRealGetFocusFlags( this ) ); 264 } 265 266 //------------------------------------------------------------------------------ 267 sal_Bool EditBrowseBox::SeekRow(long nRow) 268 { 269 nPaintRow = nRow; 270 return sal_True; 271 } 272 273 //------------------------------------------------------------------------------ 274 IMPL_LINK(EditBrowseBox, StartEditHdl, void*, EMPTYARG) 275 { 276 nStartEvent = 0; 277 if (IsEditing()) 278 { 279 EnableAndShow(); 280 if (!aController->GetWindow().HasFocus() && (m_pFocusWhileRequest == Application::GetFocusWindow())) 281 aController->GetWindow().GrabFocus(); 282 } 283 return 0; 284 } 285 286 //------------------------------------------------------------------------------ 287 void EditBrowseBox::PaintField( OutputDevice& rDev, const Rectangle& rRect, 288 sal_uInt16 nColumnId ) const 289 { 290 if (nColumnId == HANDLE_ID) 291 { 292 if (bPaintStatus) 293 PaintStatusCell(rDev, rRect); 294 } 295 else 296 { 297 // don't paint the current cell 298 if (&rDev == &GetDataWindow()) 299 // but only if we're painting onto our data win (which is the usual painting) 300 if (nPaintRow == nEditRow) 301 { 302 if (IsEditing() && nEditCol == nColumnId && aController->GetWindow().IsVisible()) 303 return; 304 } 305 PaintCell(rDev, rRect, nColumnId); 306 } 307 } 308 309 //------------------------------------------------------------------------------ 310 Image EditBrowseBox::GetImage(RowStatus eStatus) const 311 { 312 sal_Bool bHiContrast = isHiContrast(&GetDataWindow()); 313 if ( !m_aStatusImages.GetImageCount() || (bHiContrast != m_aImpl->m_bHiContrast) ) 314 { 315 m_aImpl->m_bHiContrast = bHiContrast; 316 const_cast<EditBrowseBox*>(this)->m_aStatusImages = ImageList(SvtResId(bHiContrast ? RID_SVTOOLS_IMAGELIST_EDITBWSEBOX_H : RID_SVTOOLS_IMAGELIST_EDITBROWSEBOX)); 317 } 318 319 Image aImage; 320 bool bNeedMirror = IsRTLEnabled(); 321 switch (eStatus) 322 { 323 case CURRENT: 324 aImage = m_aStatusImages.GetImage(IMG_EBB_CURRENT); 325 break; 326 case CURRENTNEW: 327 aImage = m_aStatusImages.GetImage(IMG_EBB_CURRENTNEW); 328 break; 329 case MODIFIED: 330 aImage = m_aStatusImages.GetImage(IMG_EBB_MODIFIED); 331 bNeedMirror = false; // the pen is not mirrored 332 break; 333 case NEW: 334 aImage = m_aStatusImages.GetImage(IMG_EBB_NEW); 335 break; 336 case DELETED: 337 aImage = m_aStatusImages.GetImage(IMG_EBB_DELETED); 338 break; 339 case PRIMARYKEY: 340 aImage = m_aStatusImages.GetImage(IMG_EBB_PRIMARYKEY); 341 break; 342 case CURRENT_PRIMARYKEY: 343 aImage = m_aStatusImages.GetImage(IMG_EBB_CURRENT_PRIMARYKEY); 344 break; 345 case FILTER: 346 aImage = m_aStatusImages.GetImage(IMG_EBB_FILTER); 347 break; 348 case HEADERFOOTER: 349 aImage = m_aStatusImages.GetImage(IMG_EBB_HEADERFOOTER); 350 break; 351 case CLEAN: 352 break; 353 } 354 if ( bNeedMirror ) 355 { 356 BitmapEx aBitmap( aImage.GetBitmapEx() ); 357 aBitmap.Mirror( BMP_MIRROR_HORZ ); 358 aImage = Image( aBitmap ); 359 } 360 return aImage; 361 } 362 363 //------------------------------------------------------------------------------ 364 void EditBrowseBox::PaintStatusCell(OutputDevice& rDev, const Rectangle& rRect) const 365 { 366 if (nPaintRow < 0) 367 return; 368 369 RowStatus eStatus = GetRowStatus( nPaintRow ); 370 sal_Int32 nBrowserFlags = GetBrowserFlags(); 371 372 if (nBrowserFlags & EBBF_NO_HANDLE_COLUMN_CONTENT) 373 return; 374 375 // draw the text of the header column 376 if (nBrowserFlags & EBBF_HANDLE_COLUMN_TEXT ) 377 { 378 rDev.DrawText( rRect, GetCellText( nPaintRow, 0 ), 379 TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER | TEXT_DRAW_CLIP ); 380 } 381 // draw an image 382 else if (eStatus != CLEAN && rDev.GetOutDevType() == OUTDEV_WINDOW) 383 { 384 Image aImage(GetImage(eStatus)); 385 // calc the image position 386 Size aImageSize(aImage.GetSizePixel()); 387 aImageSize.Width() = CalcZoom(aImageSize.Width()); 388 aImageSize.Height() = CalcZoom(aImageSize.Height()); 389 Point aPos( rRect.TopLeft() ); 390 391 if ( ( aImageSize.Width() > rRect.GetWidth() ) || ( aImageSize.Height() > rRect.GetHeight() ) ) 392 rDev.SetClipRegion(rRect); 393 394 if ( aImageSize.Width() < rRect.GetWidth() ) 395 aPos.X() += ( rRect.GetWidth() - aImageSize.Width() ) / 2; 396 397 if ( aImageSize.Height() < rRect.GetHeight() ) 398 aPos.Y() += ( rRect.GetHeight() - aImageSize.Height() ) / 2; 399 400 if ( IsZoom() ) 401 rDev.DrawImage( aPos, aImageSize, aImage, 0 ); 402 else 403 rDev.DrawImage( aPos, aImage, 0 ); 404 405 if (rDev.IsClipRegion()) 406 rDev.SetClipRegion(); 407 } 408 } 409 410 //------------------------------------------------------------------------------ 411 void EditBrowseBox::ImplStartTracking() 412 { 413 bActiveBeforeTracking = IsEditing(); 414 if ( bActiveBeforeTracking ) 415 { 416 DeactivateCell(); 417 Update(); 418 } 419 420 BrowseBox::ImplStartTracking(); 421 } 422 423 //------------------------------------------------------------------------------ 424 void EditBrowseBox::ImplTracking() 425 { 426 BrowseBox::ImplTracking(); 427 } 428 429 //------------------------------------------------------------------------------ 430 void EditBrowseBox::ImplEndTracking() 431 { 432 if ( bActiveBeforeTracking ) 433 ActivateCell(); 434 bActiveBeforeTracking = sal_False; 435 436 BrowseBox::ImplEndTracking(); 437 } 438 439 //------------------------------------------------------------------------------ 440 void EditBrowseBox::RowHeightChanged() 441 { 442 if ( IsEditing() ) 443 { 444 Rectangle aRect( GetCellRect( nEditRow, nEditCol, sal_False ) ); 445 CellControllerRef aCellController( Controller() ); 446 ResizeController( aCellController, aRect ); 447 aCellController->GetWindow().GrabFocus(); 448 } 449 450 BrowseBox::RowHeightChanged(); 451 } 452 453 //------------------------------------------------------------------------------ 454 EditBrowseBox::RowStatus EditBrowseBox::GetRowStatus(long) const 455 { 456 return CLEAN; 457 } 458 459 //------------------------------------------------------------------------------ 460 void EditBrowseBox::KeyInput( const KeyEvent& rEvt ) 461 { 462 sal_uInt16 nCode = rEvt.GetKeyCode().GetCode(); 463 sal_Bool bShift = rEvt.GetKeyCode().IsShift(); 464 sal_Bool bCtrl = rEvt.GetKeyCode().IsMod1(); 465 466 switch (nCode) 467 { 468 case KEY_RETURN: 469 if (!bCtrl && !bShift && IsTabAllowed(sal_True)) 470 { 471 Dispatch(BROWSER_CURSORRIGHT); 472 } 473 else 474 BrowseBox::KeyInput(rEvt); 475 return; 476 case KEY_TAB: 477 if (!bCtrl && !bShift) 478 { 479 if (IsTabAllowed(sal_True)) 480 Dispatch(BROWSER_CURSORRIGHT); 481 else 482 // do NOT call BrowseBox::KeyInput : this would handle the tab, but we already now 483 // that tab isn't allowed here. So give the Control class a chance 484 Control::KeyInput(rEvt); 485 return; 486 } 487 else if (!bCtrl && bShift) 488 { 489 if (IsTabAllowed(sal_False)) 490 Dispatch(BROWSER_CURSORLEFT); 491 else 492 // do NOT call BrowseBox::KeyInput : this would handle the tab, but we already now 493 // that tab isn't allowed here. So give the Control class a chance 494 Control::KeyInput(rEvt); 495 return; 496 } 497 default: 498 BrowseBox::KeyInput(rEvt); 499 } 500 } 501 502 //------------------------------------------------------------------------------ 503 void EditBrowseBox::MouseButtonDown(const BrowserMouseEvent& rEvt) 504 { 505 sal_uInt16 nColPos = GetColumnPos( rEvt.GetColumnId() ); 506 long nRow = rEvt.GetRow(); 507 508 // absorb double clicks 509 if (rEvt.GetClicks() > 1 && rEvt.GetRow() >= 0) 510 return; 511 512 // change to a new position 513 if (IsEditing() && (nColPos != nEditCol || nRow != nEditRow) && (nColPos != BROWSER_INVALIDID) && (nRow < GetRowCount())) 514 { 515 CellControllerRef aCellController(Controller()); 516 HideAndDisable(aCellController); 517 } 518 519 // we are about to leave the current cell. If there is a "this cell has been modified" notification 520 // pending (asynchronously), this may be deadly -> do it synchronously 521 // 95826 - 2002-10-14 - fs@openoffice.org 522 if ( nCellModifiedEvent ) 523 { 524 Application::RemoveUserEvent( nCellModifiedEvent ); 525 nCellModifiedEvent = 0; 526 LINK( this, EditBrowseBox, CellModifiedHdl ).Call( NULL ); 527 } 528 529 if (0 == rEvt.GetColumnId()) 530 { // it was the handle column. save the current cell content if necessary 531 // (clicking on the handle column results in selecting the current row) 532 // 23.01.2001 - 82797 - FS 533 if (IsEditing() && aController->IsModified()) 534 SaveModified(); 535 } 536 537 aMouseEvent.Set(&rEvt,sal_True); 538 BrowseBox::MouseButtonDown(rEvt); 539 aMouseEvent.Clear(); 540 541 if (0 != (m_nBrowserFlags & EBBF_ACTIVATE_ON_BUTTONDOWN)) 542 { 543 // the base class does not travel upon MouseButtonDown, but implActivateCellOnMouseEvent assumes we traveled ... 544 GoToRowColumnId( rEvt.GetRow(), rEvt.GetColumnId() ); 545 if (rEvt.GetRow() >= 0) 546 implActivateCellOnMouseEvent(rEvt, sal_False); 547 } 548 } 549 550 //------------------------------------------------------------------------------ 551 void EditBrowseBox::MouseButtonUp( const BrowserMouseEvent& rEvt ) 552 { 553 // absorb double clicks 554 if (rEvt.GetClicks() > 1 && rEvt.GetRow() >= 0) 555 return; 556 557 aMouseEvent.Set(&rEvt,sal_False); 558 BrowseBox::MouseButtonUp(rEvt); 559 aMouseEvent.Clear(); 560 561 if (0 == (m_nBrowserFlags & EBBF_ACTIVATE_ON_BUTTONDOWN)) 562 if (rEvt.GetRow() >= 0) 563 implActivateCellOnMouseEvent(rEvt, sal_True); 564 } 565 566 //------------------------------------------------------------------------------ 567 void EditBrowseBox::implActivateCellOnMouseEvent(const BrowserMouseEvent& _rEvt, sal_Bool _bUp) 568 { 569 if (!IsEditing()) 570 ActivateCell(); 571 else if (IsEditing() && !aController->GetWindow().IsEnabled()) 572 DeactivateCell(); 573 else if (IsEditing() && !aController->GetWindow().HasChildPathFocus()) 574 AsynchGetFocus(); 575 576 if (IsEditing() && aController->GetWindow().IsEnabled() && aController->WantMouseEvent()) 577 { // forwards the event to the control 578 579 // If the field has been moved previously, we have to adjust the position 580 581 aController->GetWindow().GrabFocus(); 582 583 // the position of the event relative to the controller's window 584 Point aPos = _rEvt.GetPosPixel() - _rEvt.GetRect().TopLeft(); 585 // the (child) window which should really get the event 586 Window* pRealHandler = aController->GetWindow().FindWindow(aPos); 587 if (pRealHandler) 588 // the coords relative to this real handler 589 aPos -= pRealHandler->GetPosPixel(); 590 else 591 pRealHandler = &aController->GetWindow(); 592 593 // the faked event 594 MouseEvent aEvent(aPos, _rEvt.GetClicks(), _rEvt.GetMode(), 595 _rEvt.GetButtons(), 596 _rEvt.GetModifier()); 597 598 pRealHandler->MouseButtonDown(aEvent); 599 if (_bUp) 600 pRealHandler->MouseButtonUp(aEvent); 601 602 Window *pWin = &aController->GetWindow(); 603 if (!pWin->IsTracking()) 604 { 605 for (pWin = pWin->GetWindow(WINDOW_FIRSTCHILD); 606 pWin && !pWin->IsTracking(); 607 pWin = pWin->GetWindow(WINDOW_NEXT)) 608 { 609 } 610 } 611 if (pWin && pWin->IsTracking()) 612 pWin->EndTracking(); 613 } 614 } 615 616 //------------------------------------------------------------------------------ 617 void EditBrowseBox::Dispatch( sal_uInt16 _nId ) 618 { 619 if ( _nId == BROWSER_ENHANCESELECTION ) 620 { // this is a workaround for the bug in the base class: 621 // if the row selection is to be extended (which is what BROWSER_ENHANCESELECTION tells us) 622 // then the base class does not revert any column selections, while, for doing a "simple" 623 // selection (BROWSER_SELECT), it does. In fact, it does not only revert the col selection then, 624 // but also any current row selections. 625 // This clearly tells me that the both ids are for row selection only - there this behaviour does 626 // make sense. 627 // But here, where we have column selection, too, we take care of this ourself. 628 if ( GetSelectColumnCount( ) ) 629 { 630 while ( GetSelectColumnCount( ) ) 631 SelectColumnPos( 632 sal::static_int_cast< sal_uInt16 >(FirstSelectedColumn()), 633 sal_False ); 634 Select(); 635 } 636 } 637 BrowseBox::Dispatch( _nId ); 638 } 639 640 //------------------------------------------------------------------------------ 641 long EditBrowseBox::PreNotify(NotifyEvent& rEvt) 642 { 643 switch (rEvt.GetType()) 644 { 645 case EVENT_KEYINPUT: 646 if ( (IsEditing() && Controller()->GetWindow().HasChildPathFocus()) 647 || rEvt.GetWindow() == &GetDataWindow() 648 || (!IsEditing() && HasChildPathFocus()) 649 ) 650 { 651 const KeyEvent* pKeyEvent = rEvt.GetKeyEvent(); 652 sal_uInt16 nCode = pKeyEvent->GetKeyCode().GetCode(); 653 sal_Bool bShift = pKeyEvent->GetKeyCode().IsShift(); 654 sal_Bool bCtrl = pKeyEvent->GetKeyCode().IsMod1(); 655 sal_Bool bAlt = pKeyEvent->GetKeyCode().IsMod2(); 656 sal_Bool bLocalSelect= sal_False; 657 sal_Bool bNonEditOnly = sal_False; 658 sal_uInt16 nId = BROWSER_NONE; 659 660 if (!bAlt && !bCtrl && !bShift ) 661 switch ( nCode ) 662 { 663 case KEY_DOWN: nId = BROWSER_CURSORDOWN; break; 664 case KEY_UP: nId = BROWSER_CURSORUP; break; 665 case KEY_PAGEDOWN: nId = BROWSER_CURSORPAGEDOWN; break; 666 case KEY_PAGEUP: nId = BROWSER_CURSORPAGEUP; break; 667 case KEY_HOME: nId = BROWSER_CURSORHOME; break; 668 case KEY_END: nId = BROWSER_CURSOREND; break; 669 670 case KEY_TAB: 671 // ask if traveling to the next cell is allowed 672 if (IsTabAllowed(sal_True)) 673 nId = BROWSER_CURSORRIGHT; 674 break; 675 676 case KEY_RETURN: 677 // save the cell content (if necessary) 678 if (IsEditing() && aController->IsModified() && !((EditBrowseBox *) this)->SaveModified()) 679 { 680 // maybe we're not visible ... 681 EnableAndShow(); 682 aController->GetWindow().GrabFocus(); 683 return 1; 684 } 685 // ask if traveling to the next cell is allowed 686 if (IsTabAllowed(sal_True)) 687 nId = BROWSER_CURSORRIGHT; 688 689 break; 690 case KEY_RIGHT: nId = BROWSER_CURSORRIGHT; break; 691 case KEY_LEFT: nId = BROWSER_CURSORLEFT; break; 692 case KEY_SPACE: nId = BROWSER_SELECT; bNonEditOnly = bLocalSelect = sal_True;break; 693 } 694 695 if ( !bAlt && !bCtrl && bShift ) 696 switch ( nCode ) 697 { 698 case KEY_DOWN: nId = BROWSER_SELECTDOWN; bLocalSelect = sal_True;break; 699 case KEY_UP: nId = BROWSER_SELECTUP; bLocalSelect = sal_True;break; 700 case KEY_HOME: nId = BROWSER_SELECTHOME; bLocalSelect = sal_True;break; 701 case KEY_END: nId = BROWSER_SELECTEND; bLocalSelect = sal_True;break; 702 case KEY_TAB: 703 if (IsTabAllowed(sal_False)) 704 nId = BROWSER_CURSORLEFT; 705 break; 706 } 707 708 if ( !bAlt && bCtrl && bShift ) 709 switch ( nCode ) 710 { 711 case KEY_SPACE: nId = BROWSER_SELECTCOLUMN; bLocalSelect = sal_True; break; 712 } 713 714 715 if ( !bAlt && bCtrl && !bShift ) 716 switch ( nCode ) 717 { 718 case KEY_DOWN: nId = BROWSER_SCROLLUP; break; 719 case KEY_UP: nId = BROWSER_SCROLLDOWN; break; 720 case KEY_PAGEDOWN: nId = BROWSER_CURSORENDOFFILE; break; 721 case KEY_PAGEUP: nId = BROWSER_CURSORTOPOFFILE; break; 722 case KEY_HOME: nId = BROWSER_CURSORTOPOFSCREEN; break; 723 case KEY_END: nId = BROWSER_CURSORENDOFSCREEN; break; 724 case KEY_SPACE: nId = BROWSER_ENHANCESELECTION; bLocalSelect = sal_True;break; 725 } 726 727 728 if ( ( nId != BROWSER_NONE ) 729 && ( !IsEditing() 730 || ( !bNonEditOnly 731 && aController->MoveAllowed( *pKeyEvent ) 732 ) 733 ) 734 ) 735 { 736 if (nId == BROWSER_SELECT || BROWSER_SELECTCOLUMN == nId ) 737 { 738 // save the cell content (if necessary) 739 if (IsEditing() && aController->IsModified() && !((EditBrowseBox *) this)->SaveModified()) 740 { 741 // maybe we're not visible ... 742 EnableAndShow(); 743 aController->GetWindow().GrabFocus(); 744 return 1; 745 } 746 } 747 748 Dispatch(nId); 749 750 if (bLocalSelect && (GetSelectRowCount() || GetSelection() != NULL)) 751 DeactivateCell(); 752 return 1; 753 } 754 } 755 } 756 return BrowseBox::PreNotify(rEvt); 757 } 758 759 //------------------------------------------------------------------------------ 760 sal_Bool EditBrowseBox::IsTabAllowed(sal_Bool) const 761 { 762 return sal_True; 763 } 764 765 //------------------------------------------------------------------------------ 766 long EditBrowseBox::Notify(NotifyEvent& rEvt) 767 { 768 switch (rEvt.GetType()) 769 { 770 case EVENT_GETFOCUS: 771 DetermineFocus( getRealGetFocusFlags( this ) ); 772 break; 773 774 case EVENT_LOSEFOCUS: 775 DetermineFocus( 0 ); 776 break; 777 } 778 return BrowseBox::Notify(rEvt); 779 } 780 781 //------------------------------------------------------------------------------ 782 void EditBrowseBox::StateChanged( StateChangedType nType ) 783 { 784 BrowseBox::StateChanged( nType ); 785 786 bool bNeedCellReActivation = false; 787 if ( nType == STATE_CHANGE_MIRRORING ) 788 { 789 bNeedCellReActivation = true; 790 } 791 else if ( nType == STATE_CHANGE_ZOOM ) 792 { 793 ImplInitSettings( sal_True, sal_False, sal_False ); 794 bNeedCellReActivation = true; 795 } 796 else if ( nType == STATE_CHANGE_CONTROLFONT ) 797 { 798 ImplInitSettings( sal_True, sal_False, sal_False ); 799 Invalidate(); 800 } 801 else if ( nType == STATE_CHANGE_CONTROLFOREGROUND ) 802 { 803 ImplInitSettings( sal_False, sal_True, sal_False ); 804 Invalidate(); 805 } 806 else if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) 807 { 808 ImplInitSettings( sal_False, sal_False, sal_True ); 809 Invalidate(); 810 } 811 else if (nType == STATE_CHANGE_STYLE) 812 { 813 WinBits nStyle = GetStyle(); 814 if (!(nStyle & WB_NOTABSTOP) ) 815 nStyle |= WB_TABSTOP; 816 817 SetStyle(nStyle); 818 } 819 if ( bNeedCellReActivation ) 820 { 821 if ( IsEditing() ) 822 { 823 DeactivateCell(); 824 ActivateCell(); 825 } 826 } 827 } 828 829 //------------------------------------------------------------------------------ 830 void EditBrowseBox::DataChanged( const DataChangedEvent& rDCEvt ) 831 { 832 BrowseBox::DataChanged( rDCEvt ); 833 834 if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS ) || 835 ( rDCEvt.GetType() == DATACHANGED_DISPLAY )) && 836 ( rDCEvt.GetFlags() & SETTINGS_STYLE )) 837 { 838 ImplInitSettings( sal_True, sal_True, sal_True ); 839 Invalidate(); 840 } 841 } 842 843 //------------------------------------------------------------------------------ 844 void EditBrowseBox::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ) 845 { 846 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 847 848 if (bFont) 849 { 850 Font aFont = rStyleSettings.GetFieldFont(); 851 if (IsControlFont()) 852 { 853 GetDataWindow().SetControlFont(GetControlFont()); 854 aFont.Merge(GetControlFont()); 855 } 856 else 857 GetDataWindow().SetControlFont(); 858 859 GetDataWindow().SetZoomedPointFont(aFont); 860 } 861 862 if ( bFont || bForeground ) 863 { 864 Color aTextColor = rStyleSettings.GetFieldTextColor(); 865 if (IsControlForeground()) 866 { 867 aTextColor = GetControlForeground(); 868 GetDataWindow().SetControlForeground(aTextColor); 869 } 870 else 871 GetDataWindow().SetControlForeground(); 872 873 GetDataWindow().SetTextColor( aTextColor ); 874 } 875 876 if ( bBackground ) 877 { 878 if (GetDataWindow().IsControlBackground()) 879 { 880 GetDataWindow().SetControlBackground(GetControlBackground()); 881 GetDataWindow().SetBackground(GetDataWindow().GetControlBackground()); 882 GetDataWindow().SetFillColor(GetDataWindow().GetControlBackground()); 883 } 884 else 885 { 886 GetDataWindow().SetControlBackground(); 887 GetDataWindow().SetBackground( rStyleSettings.GetFieldColor() ); 888 GetDataWindow().SetFillColor( rStyleSettings.GetFieldColor() ); 889 } 890 } 891 } 892 893 //------------------------------------------------------------------------------ 894 sal_Bool EditBrowseBox::IsCursorMoveAllowed(long nNewRow, sal_uInt16 nNewColId) const 895 { 896 sal_uInt16 nInfo = 0; 897 898 if (GetSelectColumnCount() || (aMouseEvent.Is() && aMouseEvent->GetRow() < 0)) 899 nInfo |= COLSELECT; 900 if ((GetSelection() != NULL && GetSelectRowCount()) || 901 (aMouseEvent.Is() && aMouseEvent->GetColumnId() == HANDLE_ID)) 902 nInfo |= ROWSELECT; 903 if (!nInfo && nNewRow != nEditRow) 904 nInfo |= ROWCHANGE; 905 if (!nInfo && nNewColId != nEditCol) 906 nInfo |= COLCHANGE; 907 908 if (nInfo == 0) // nothing happened 909 return sal_True; 910 911 // save the cell content 912 if (IsEditing() && aController->IsModified() && !((EditBrowseBox *) this)->SaveModified()) 913 { 914 // maybe we're not visible ... 915 EnableAndShow(); 916 aController->GetWindow().GrabFocus(); 917 return sal_False; 918 } 919 920 EditBrowseBox * pTHIS = (EditBrowseBox *) this; 921 922 // save the cell content if 923 // a) a selection is beeing made 924 // b) the row is changing 925 if (IsModified() && (nInfo & (ROWCHANGE | COLSELECT | ROWSELECT)) && 926 !pTHIS->SaveRow()) 927 { 928 if (nInfo & COLSELECT || 929 nInfo & ROWSELECT) 930 { 931 // cancel selected 932 pTHIS->SetNoSelection(); 933 } 934 935 if (IsEditing()) 936 { 937 if (!Controller()->GetWindow().IsVisible()) 938 { 939 EnableAndShow(); 940 } 941 aController->GetWindow().GrabFocus(); 942 } 943 return sal_False; 944 } 945 946 if (nNewRow != nEditRow) 947 { 948 Window& rWindow = GetDataWindow(); 949 // don't paint too much 950 // update the status immediatly if possible 951 if ((nEditRow >= 0) && (GetBrowserFlags() & EBBF_NO_HANDLE_COLUMN_CONTENT) == 0) 952 { 953 Rectangle aRect = GetFieldRectPixel(nEditRow, 0, sal_False ); 954 // status cell should be painted if and only if text is displayed 955 // note: bPaintStatus is mutable, but Solaris has problems with assigning 956 // probably because it is part of a bitfield 957 pTHIS->bPaintStatus = static_cast< sal_Bool > 958 (( GetBrowserFlags() & EBBF_HANDLE_COLUMN_TEXT ) == EBBF_HANDLE_COLUMN_TEXT ); 959 rWindow.Paint(aRect); 960 pTHIS->bPaintStatus = sal_True; 961 } 962 963 // don't paint during row change 964 rWindow.EnablePaint(sal_False); 965 966 // the last veto chance for derived classes 967 if (!pTHIS->CursorMoving(nNewRow, nNewColId)) 968 { 969 pTHIS->InvalidateStatusCell(nEditRow); 970 rWindow.EnablePaint(sal_True); 971 return sal_False; 972 } 973 else 974 { 975 rWindow.EnablePaint(sal_True); 976 return sal_True; 977 } 978 } 979 else 980 return pTHIS->CursorMoving(nNewRow, nNewColId); 981 } 982 983 //------------------------------------------------------------------------------ 984 void EditBrowseBox::ColumnMoved(sal_uInt16 nId) 985 { 986 BrowseBox::ColumnMoved(nId); 987 if (IsEditing()) 988 { 989 Rectangle aRect( GetCellRect(nEditRow, nEditCol, sal_False)); 990 CellControllerRef aControllerRef = Controller(); 991 ResizeController(aControllerRef, aRect); 992 Controller()->GetWindow().GrabFocus(); 993 } 994 } 995 996 //------------------------------------------------------------------------------ 997 sal_Bool EditBrowseBox::SaveRow() 998 { 999 return sal_True; 1000 } 1001 1002 //------------------------------------------------------------------------------ 1003 sal_Bool EditBrowseBox::CursorMoving(long, sal_uInt16) 1004 { 1005 ((EditBrowseBox *) this)->DeactivateCell(sal_False); 1006 return sal_True; 1007 } 1008 1009 //------------------------------------------------------------------------------ 1010 void EditBrowseBox::CursorMoved() 1011 { 1012 long nNewRow = GetCurRow(); 1013 if (nEditRow != nNewRow) 1014 { 1015 if ((GetBrowserFlags() & EBBF_NO_HANDLE_COLUMN_CONTENT) == 0) 1016 InvalidateStatusCell(nNewRow); 1017 nEditRow = nNewRow; 1018 } 1019 ActivateCell(); 1020 GetDataWindow().EnablePaint(sal_True); 1021 // should not be called here because the descant event is not needed here 1022 //BrowseBox::CursorMoved(); 1023 } 1024 1025 //------------------------------------------------------------------------------ 1026 void EditBrowseBox::EndScroll() 1027 { 1028 if (IsEditing()) 1029 { 1030 Rectangle aRect = GetCellRect(nEditRow, nEditCol, sal_False); 1031 ResizeController(aController,aRect); 1032 AsynchGetFocus(); 1033 } 1034 BrowseBox::EndScroll(); 1035 } 1036 1037 //------------------------------------------------------------------------------ 1038 void EditBrowseBox::ActivateCell(long nRow, sal_uInt16 nCol, sal_Bool bCellFocus) 1039 { 1040 if (IsEditing()) 1041 return; 1042 1043 nEditCol = nCol; 1044 1045 if ((GetSelectRowCount() && GetSelection() != NULL) || GetSelectColumnCount() || 1046 (aMouseEvent.Is() && (aMouseEvent.IsDown() || aMouseEvent->GetClicks() > 1))) // bei MouseDown passiert noch nichts 1047 { 1048 return; 1049 } 1050 1051 if (nEditRow >= 0 && nEditCol > HANDLE_ID) 1052 { 1053 aController = GetController(nRow, nCol); 1054 if (aController.Is()) 1055 { 1056 Rectangle aRect( GetCellRect(nEditRow, nEditCol, sal_False)); 1057 ResizeController(aController, aRect); 1058 1059 InitController(aController, nEditRow, nEditCol); 1060 1061 aController->ClearModified(); 1062 aController->SetModifyHdl(LINK(this,EditBrowseBox,ModifyHdl)); 1063 EnableAndShow(); 1064 1065 if ( isAccessibleAlive() ) 1066 implCreateActiveAccessible(); 1067 1068 // activate the cell only of the browser has the focus 1069 if ( bHasFocus && bCellFocus ) 1070 AsynchGetFocus(); 1071 } 1072 else 1073 { 1074 // no controller -> we have a new "active descendant" 1075 if ( isAccessibleAlive() && HasFocus() ) 1076 { 1077 commitTableEvent( 1078 ACTIVE_DESCENDANT_CHANGED, 1079 makeAny( CreateAccessibleCell( nRow, GetColumnPos( nCol ) ) ), 1080 Any() 1081 ); 1082 } 1083 } 1084 } 1085 } 1086 1087 //------------------------------------------------------------------------------ 1088 void EditBrowseBox::DeactivateCell(sal_Bool bUpdate) 1089 { 1090 if (IsEditing()) 1091 { 1092 if ( isAccessibleAlive() ) 1093 { 1094 commitBrowseBoxEvent( CHILD, Any(), makeAny( m_aImpl->m_xActiveCell ) ); 1095 m_aImpl->clearActiveCell(); 1096 } 1097 1098 aOldController = aController; 1099 aController.Clear(); 1100 1101 // reset the modify handler 1102 aOldController->SetModifyHdl(Link()); 1103 1104 if (bHasFocus) 1105 GrabFocus(); // ensure that we have (and keep) the focus 1106 1107 HideAndDisable(aOldController); 1108 1109 // update if requested 1110 if (bUpdate) 1111 Update(); 1112 1113 nOldEditCol = nEditCol; 1114 nOldEditRow = nEditRow; 1115 1116 // release the controller (asynchronously) 1117 if (nEndEvent) 1118 Application::RemoveUserEvent(nEndEvent); 1119 nEndEvent = Application::PostUserEvent(LINK(this,EditBrowseBox,EndEditHdl)); 1120 } 1121 } 1122 1123 //------------------------------------------------------------------------------ 1124 Rectangle EditBrowseBox::GetCellRect(long nRow, sal_uInt16 nColId, sal_Bool bRel) const 1125 { 1126 Rectangle aRect( GetFieldRectPixel(nRow, nColId, bRel)); 1127 if ((GetMode() & BROWSER_CURSOR_WO_FOCUS) == BROWSER_CURSOR_WO_FOCUS) 1128 { 1129 aRect.Top() += 1; 1130 aRect.Bottom() -= 1; 1131 } 1132 return aRect; 1133 } 1134 1135 //------------------------------------------------------------------------------ 1136 IMPL_LINK(EditBrowseBox, EndEditHdl, void*, EMPTYARG) 1137 { 1138 nEndEvent = 0; 1139 ReleaseController(aOldController, nOldEditRow, nOldEditCol); 1140 1141 aOldController = CellControllerRef(); 1142 nOldEditRow = -1; 1143 nOldEditCol = 0; 1144 1145 return 0; 1146 } 1147 1148 //------------------------------------------------------------------------------ 1149 IMPL_LINK(EditBrowseBox, ModifyHdl, void*, EMPTYARG) 1150 { 1151 if (nCellModifiedEvent) 1152 Application::RemoveUserEvent(nCellModifiedEvent); 1153 nCellModifiedEvent = Application::PostUserEvent(LINK(this,EditBrowseBox,CellModifiedHdl)); 1154 return 0; 1155 } 1156 1157 //------------------------------------------------------------------------------ 1158 IMPL_LINK(EditBrowseBox, CellModifiedHdl, void*, EMPTYARG) 1159 { 1160 nCellModifiedEvent = 0; 1161 CellModified(); 1162 return 0; 1163 } 1164 1165 //------------------------------------------------------------------------------ 1166 void EditBrowseBox::ColumnResized( sal_uInt16 ) 1167 { 1168 if (IsEditing()) 1169 { 1170 Rectangle aRect( GetCellRect(nEditRow, nEditCol, sal_False)); 1171 CellControllerRef aControllerRef = Controller(); 1172 ResizeController(aControllerRef, aRect); 1173 Controller()->GetWindow().GrabFocus(); 1174 } 1175 } 1176 1177 //------------------------------------------------------------------------------ 1178 sal_uInt16 EditBrowseBox::AppendColumn(const String& rName, sal_uInt16 nWidth, sal_uInt16 nPos, sal_uInt16 nId) 1179 { 1180 if (nId == (sal_uInt16)-1) 1181 { 1182 // look for the next free id 1183 for (nId = ColCount(); nId > 0 && GetColumnPos(nId) != BROWSER_INVALIDID; nId--) 1184 ; 1185 1186 if (!nId) 1187 { 1188 // if there is no handle column 1189 // increment the id 1190 if (!ColCount() || GetColumnId(0)) 1191 nId = ColCount() + 1; 1192 } 1193 } 1194 1195 DBG_ASSERT(nId, "EditBrowseBox::AppendColumn: invalid id!"); 1196 1197 long w = nWidth; 1198 if (!w) 1199 w = GetDefaultColumnWidth(rName); 1200 1201 InsertDataColumn(nId, rName, w, (HIB_CENTER | HIB_VCENTER | HIB_CLICKABLE), nPos); 1202 return nId; 1203 } 1204 1205 //------------------------------------------------------------------------------ 1206 void EditBrowseBox::Resize() 1207 { 1208 BrowseBox::Resize(); 1209 1210 // if the window is smaller than "title line height" + "control area", 1211 // do nothing 1212 if (GetOutputSizePixel().Height() < 1213 (GetControlArea().GetHeight() + GetDataWindow().GetPosPixel().Y())) 1214 return; 1215 1216 // the size of the control area 1217 Point aPoint(GetControlArea().TopLeft()); 1218 sal_uInt16 nX = (sal_uInt16)aPoint.X(); 1219 1220 ArrangeControls(nX, (sal_uInt16)aPoint.Y()); 1221 1222 if (!nX) 1223 nX = USHRT_MAX; 1224 ReserveControlArea((sal_uInt16)nX); 1225 } 1226 1227 //------------------------------------------------------------------------------ 1228 void EditBrowseBox::ArrangeControls(sal_uInt16&, sal_uInt16) 1229 { 1230 } 1231 1232 //------------------------------------------------------------------------------ 1233 CellController* EditBrowseBox::GetController(long, sal_uInt16) 1234 { 1235 return NULL; 1236 } 1237 1238 //----------------------------------------------------------------------------- 1239 void EditBrowseBox::ResizeController(CellControllerRef& rController, const Rectangle& rRect) 1240 { 1241 rController->GetWindow().SetPosSizePixel(rRect.TopLeft(), rRect.GetSize()); 1242 } 1243 1244 //------------------------------------------------------------------------------ 1245 void EditBrowseBox::InitController(CellControllerRef&, long, sal_uInt16) 1246 { 1247 } 1248 1249 //------------------------------------------------------------------------------ 1250 void EditBrowseBox::ReleaseController(CellControllerRef&, long, sal_uInt16) 1251 { 1252 } 1253 1254 //------------------------------------------------------------------------------ 1255 void EditBrowseBox::CellModified() 1256 { 1257 } 1258 1259 1260 //------------------------------------------------------------------------------ 1261 sal_Bool EditBrowseBox::SaveModified() 1262 { 1263 return sal_True; 1264 } 1265 1266 //------------------------------------------------------------------------------ 1267 void EditBrowseBox::DoubleClick(const BrowserMouseEvent& rEvt) 1268 { 1269 // when double clicking on the column, the optimum size will be calculated 1270 sal_uInt16 nColId = rEvt.GetColumnId(); 1271 if (nColId != HANDLE_ID) 1272 SetColumnWidth(nColId, GetAutoColumnWidth(nColId)); 1273 } 1274 1275 //------------------------------------------------------------------------------ 1276 sal_uInt32 EditBrowseBox::GetAutoColumnWidth(sal_uInt16 nColId) 1277 { 1278 sal_uInt32 nCurColWidth = GetColumnWidth(nColId); 1279 sal_uInt32 nMinColWidth = CalcZoom(20); // minimum 1280 sal_uInt32 nNewColWidth = nMinColWidth; 1281 long nMaxRows = Min(long(GetVisibleRows()), GetRowCount()); 1282 long nLastVisRow = GetTopRow() + nMaxRows - 1; 1283 1284 if (GetTopRow() <= nLastVisRow) // calc the column with using the cell contents 1285 { 1286 for (long i = GetTopRow(); i <= nLastVisRow; ++i) 1287 nNewColWidth = std::max(nNewColWidth,GetTotalCellWidth(i,nColId) + 12); 1288 1289 if (nNewColWidth == nCurColWidth) // size has not changed 1290 nNewColWidth = GetDefaultColumnWidth(GetColumnTitle(nColId)); 1291 } 1292 else 1293 nNewColWidth = GetDefaultColumnWidth(GetColumnTitle(nColId)); 1294 return nNewColWidth; 1295 } 1296 1297 //------------------------------------------------------------------------------ 1298 sal_uInt32 EditBrowseBox::GetTotalCellWidth(long, sal_uInt16) 1299 { 1300 return 0; 1301 } 1302 1303 //------------------------------------------------------------------------------ 1304 void EditBrowseBox::InvalidateHandleColumn() 1305 { 1306 Rectangle aHdlFieldRect( GetFieldRectPixel( 0, 0 )); 1307 Rectangle aInvalidRect( Point(0,0), GetOutputSizePixel() ); 1308 aInvalidRect.Right() = aHdlFieldRect.Right(); 1309 Invalidate( aInvalidRect ); 1310 } 1311 1312 //------------------------------------------------------------------------------ 1313 void EditBrowseBox::PaintTristate(OutputDevice&, const Rectangle& rRect,const TriState& eState,sal_Bool _bEnabled) const 1314 { 1315 pCheckBoxPaint->GetBox().SetState(eState); 1316 pCheckBoxPaint->SetPosSizePixel(rRect.TopLeft(), rRect.GetSize()); 1317 1318 // First update the parent, preventing that while painting this window 1319 // an update for the parent is done (because it's in the queue already) 1320 // which may lead to hiding this window immediately 1321 // #95598# comment out OJ 1322 /* if (pCheckBoxPaint->GetParent()) 1323 pCheckBoxPaint->GetParent()->Update(); 1324 */ 1325 pCheckBoxPaint->GetBox().Enable(_bEnabled); 1326 pCheckBoxPaint->Show(); 1327 pCheckBoxPaint->SetParentUpdateMode( sal_False ); 1328 pCheckBoxPaint->Update(); 1329 pCheckBoxPaint->Hide(); 1330 pCheckBoxPaint->SetParentUpdateMode( sal_True ); 1331 } 1332 1333 //------------------------------------------------------------------------------ 1334 void EditBrowseBox::AsynchGetFocus() 1335 { 1336 if (nStartEvent) 1337 Application::RemoveUserEvent(nStartEvent); 1338 1339 m_pFocusWhileRequest = Application::GetFocusWindow(); 1340 nStartEvent = Application::PostUserEvent(LINK(this,EditBrowseBox,StartEditHdl)); 1341 } 1342 1343 //------------------------------------------------------------------------------ 1344 void EditBrowseBox::SetBrowserFlags(sal_Int32 nFlags) 1345 { 1346 if (m_nBrowserFlags == nFlags) 1347 return; 1348 1349 sal_Bool RowPicturesChanges = ((m_nBrowserFlags & EBBF_NO_HANDLE_COLUMN_CONTENT) != 1350 (nFlags & EBBF_NO_HANDLE_COLUMN_CONTENT)); 1351 m_nBrowserFlags = nFlags; 1352 1353 if (RowPicturesChanges) 1354 InvalidateStatusCell(GetCurRow()); 1355 } 1356 //------------------------------------------------------------------------------ 1357 inline void EditBrowseBox::HideAndDisable(CellControllerRef& rController) 1358 { 1359 rController->suspend(); 1360 } 1361 //------------------------------------------------------------------------------ 1362 inline void EditBrowseBox::EnableAndShow() const 1363 { 1364 Controller()->resume(); 1365 } 1366 //=============================================================================== 1367 1368 DBG_NAME(CellController); 1369 //------------------------------------------------------------------------------ 1370 CellController::CellController(Control* pW) 1371 :pWindow( pW ) 1372 ,bSuspended( sal_True ) 1373 { 1374 DBG_CTOR(CellController,NULL); 1375 1376 DBG_ASSERT(pWindow, "CellController::CellController: missing the window!"); 1377 DBG_ASSERT(!pWindow->IsVisible(), "CellController::CellController: window should not be visible!"); 1378 } 1379 1380 //----------------------------------------------------------------------------- 1381 CellController::~CellController() 1382 { 1383 1384 DBG_DTOR(CellController,NULL); 1385 } 1386 1387 //----------------------------------------------------------------------------- 1388 void CellController::suspend( ) 1389 { 1390 DBG_ASSERT( bSuspended == !GetWindow().IsVisible(), "CellController::suspend: inconsistence!" ); 1391 if ( !isSuspended( ) ) 1392 { 1393 CommitModifications(); 1394 GetWindow().Hide( ); 1395 GetWindow().Disable( ); 1396 bSuspended = sal_True; 1397 } 1398 } 1399 1400 //----------------------------------------------------------------------------- 1401 void CellController::resume( ) 1402 { 1403 DBG_ASSERT( bSuspended == !GetWindow().IsVisible(), "CellController::resume: inconsistence!" ); 1404 if ( isSuspended( ) ) 1405 { 1406 GetWindow().Enable( ); 1407 GetWindow().Show( ); 1408 bSuspended = sal_False; 1409 } 1410 } 1411 1412 //----------------------------------------------------------------------------- 1413 void CellController::CommitModifications() 1414 { 1415 // nothing to do in this base class 1416 } 1417 1418 //----------------------------------------------------------------------------- 1419 sal_Bool CellController::WantMouseEvent() const 1420 { 1421 return sal_False; 1422 } 1423 1424 //----------------------------------------------------------------------------- 1425 void CellController::SetModified() 1426 { 1427 } 1428 1429 //----------------------------------------------------------------------------- 1430 sal_Bool CellController::MoveAllowed(const KeyEvent&) const 1431 { 1432 return sal_True; 1433 } 1434 // ....................................................................... 1435 } // namespace svt 1436 // ....................................................................... 1437 1438