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_vcl.hxx" 30 31 #include <tools/rc.h> 32 33 #include <svids.hrc> 34 #include <svdata.hxx> 35 #include <brdwin.hxx> 36 #include <window.h> 37 38 #include <vcl/metric.hxx> 39 #include <vcl/svapp.hxx> 40 #include <vcl/wrkwin.hxx> 41 #include <vcl/fixed.hxx> 42 #include <vcl/sound.hxx> 43 #include <vcl/msgbox.hxx> 44 #include <vcl/button.hxx> 45 #include <vcl/mnemonic.hxx> 46 47 48 49 // ======================================================================= 50 51 static void ImplInitMsgBoxImageList() 52 { 53 ImplSVData* pSVData = ImplGetSVData(); 54 if ( !pSVData->maWinData.mpMsgBoxImgList ) 55 { 56 ResMgr* pResMgr = ImplGetResMgr(); 57 pSVData->maWinData.mpMsgBoxImgList = new ImageList(4); 58 pSVData->maWinData.mpMsgBoxHCImgList = new ImageList(4); 59 if( pResMgr ) 60 { 61 Color aNonAlphaMask( 0xC0, 0xC0, 0xC0 ); 62 pSVData->maWinData.mpMsgBoxImgList->InsertFromHorizontalBitmap 63 ( ResId( SV_RESID_BITMAP_MSGBOX, *pResMgr ), 4, &aNonAlphaMask ); 64 pSVData->maWinData.mpMsgBoxHCImgList->InsertFromHorizontalBitmap 65 ( ResId( SV_RESID_BITMAP_MSGBOX_HC, *pResMgr ), 4, &aNonAlphaMask ); 66 } 67 } 68 } 69 70 // ======================================================================= 71 72 void MessBox::ImplInitMessBoxData() 73 { 74 mpFixedText = NULL; 75 mpFixedImage = NULL; 76 mnSoundType = 0; 77 mbHelpBtn = sal_False; 78 mbSound = sal_True; 79 mpCheckBox = NULL; 80 mbCheck = sal_False; 81 } 82 83 // ----------------------------------------------------------------------- 84 85 void MessBox::ImplInitButtons() 86 { 87 WinBits nStyle = GetStyle(); 88 sal_uInt16 nOKFlags = BUTTONDIALOG_OKBUTTON; 89 sal_uInt16 nCancelFlags = BUTTONDIALOG_CANCELBUTTON; 90 sal_uInt16 nRetryFlags = 0; 91 sal_uInt16 nYesFlags = 0; 92 sal_uInt16 nNoFlags = 0; 93 94 if ( nStyle & WB_OK_CANCEL ) 95 { 96 if ( nStyle & WB_DEF_CANCEL ) 97 nCancelFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON; 98 else // WB_DEF_OK 99 nOKFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON; 100 101 AddButton( BUTTON_OK, BUTTONID_OK, nOKFlags ); 102 AddButton( BUTTON_CANCEL, BUTTONID_CANCEL, nCancelFlags ); 103 } 104 else if ( nStyle & WB_YES_NO ) 105 { 106 if ( nStyle & WB_DEF_YES ) 107 nYesFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON; 108 else // WB_DEF_NO 109 nNoFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON; 110 nNoFlags |= BUTTONDIALOG_CANCELBUTTON; 111 112 AddButton( BUTTON_YES, BUTTONID_YES, nYesFlags ); 113 AddButton( BUTTON_NO, BUTTONID_NO, nNoFlags ); 114 } 115 else if ( nStyle & WB_YES_NO_CANCEL ) 116 { 117 if ( nStyle & WB_DEF_YES ) 118 nYesFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON; 119 else if ( nStyle & WB_DEF_NO ) 120 nNoFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON; 121 else 122 nCancelFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON; 123 124 AddButton( BUTTON_YES, BUTTONID_YES, nYesFlags ); 125 AddButton( BUTTON_NO, BUTTONID_NO, nNoFlags ); 126 AddButton( BUTTON_CANCEL, BUTTONID_CANCEL, nCancelFlags ); 127 } 128 else if ( nStyle & WB_RETRY_CANCEL ) 129 { 130 if ( nStyle & WB_DEF_CANCEL ) 131 nCancelFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON; 132 else // WB_DEF_RETRY 133 nRetryFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON; 134 135 AddButton( BUTTON_RETRY, BUTTONID_RETRY, nRetryFlags ); 136 AddButton( BUTTON_CANCEL, BUTTONID_CANCEL, nCancelFlags ); 137 } 138 else if ( nStyle & WB_ABORT_RETRY_IGNORE ) 139 { 140 sal_uInt16 nAbortFlags = 0; 141 sal_uInt16 nIgnoreFlags = 0; 142 143 if ( nStyle & WB_DEF_CANCEL ) 144 nAbortFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON; 145 else if ( nStyle & WB_DEF_RETRY ) 146 nRetryFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON; 147 else if ( nStyle & WB_DEF_IGNORE ) 148 nIgnoreFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON; 149 150 AddButton( BUTTON_ABORT, BUTTONID_CANCEL, nAbortFlags ); 151 AddButton( BUTTON_RETRY, BUTTONID_RETRY, nRetryFlags ); 152 AddButton( BUTTON_IGNORE, BUTTONID_IGNORE, nIgnoreFlags ); 153 } 154 else if ( nStyle & WB_OK ) 155 { 156 nOKFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON; 157 158 AddButton( BUTTON_OK, BUTTONID_OK, nOKFlags ); 159 } 160 } 161 162 // ----------------------------------------------------------------------- 163 164 MessBox::MessBox( WindowType ) : 165 ButtonDialog( WINDOW_MESSBOX ) 166 { 167 ImplInitMessBoxData(); 168 } 169 170 // ----------------------------------------------------------------------- 171 172 MessBox::MessBox( Window* pParent, WinBits nStyle, 173 const XubString& rTitle, const XubString& rMessage ) : 174 ButtonDialog( WINDOW_MESSBOX ), 175 maMessText( rMessage ) 176 { 177 ImplInitMessBoxData(); 178 ImplInit( pParent, nStyle | WB_MOVEABLE | WB_HORZ | WB_CENTER ); 179 ImplInitButtons(); 180 181 if ( rTitle.Len() ) 182 SetText( rTitle ); 183 } 184 185 // ----------------------------------------------------------------------- 186 187 MessBox::MessBox( Window* pParent, const ResId& rResId ) : 188 ButtonDialog( WINDOW_MESSBOX ) 189 { 190 ImplInitMessBoxData(); 191 192 GetRes( rResId.SetRT( RSC_MESSBOX ) ); 193 sal_uInt16 nHiButtons = ReadShortRes(); 194 sal_uInt16 nLoButtons = ReadShortRes(); 195 sal_uInt16 nHiDefButton = ReadShortRes(); 196 sal_uInt16 nLoDefButton = ReadShortRes(); 197 rtl::OString aHelpId( ReadByteStringRes() ); 198 /* sal_uInt16 bSysModal = */ ReadShortRes(); 199 SetHelpId( aHelpId ); 200 WinBits nBits = (((sal_uLong)nHiButtons << 16) + nLoButtons) | 201 (((sal_uLong)nHiDefButton << 16) + nLoDefButton); 202 ImplInit( pParent, nBits | WB_MOVEABLE | WB_HORZ | WB_CENTER ); 203 204 ImplLoadRes( rResId ); 205 ImplInitButtons(); 206 } 207 208 // ----------------------------------------------------------------------- 209 210 void MessBox::ImplLoadRes( const ResId& ) 211 { 212 SetText( ReadStringRes() ); 213 SetMessText( ReadStringRes() ); 214 SetHelpText( ReadStringRes() ); 215 } 216 217 // ----------------------------------------------------------------------- 218 219 MessBox::~MessBox() 220 { 221 if ( mpFixedText ) 222 delete mpFixedText; 223 if ( mpFixedImage ) 224 delete mpFixedImage; 225 if ( mpCheckBox ) 226 delete mpCheckBox; 227 } 228 229 // ----------------------------------------------------------------------- 230 231 void MessBox::ImplPosControls() 232 { 233 if ( GetHelpId().getLength() ) 234 { 235 if ( !mbHelpBtn ) 236 { 237 AddButton( BUTTON_HELP, BUTTONID_HELP, BUTTONDIALOG_HELPBUTTON, 3 ); 238 mbHelpBtn = sal_True; 239 } 240 } 241 else 242 { 243 if ( mbHelpBtn ) 244 { 245 RemoveButton( BUTTONID_HELP ); 246 mbHelpBtn = sal_False; 247 } 248 } 249 250 XubString aMessText( maMessText ); 251 TextRectInfo aTextInfo; 252 Rectangle aRect( 0, 0, 30000, 30000 ); 253 Rectangle aFormatRect; 254 Point aTextPos( IMPL_DIALOG_OFFSET, IMPL_DIALOG_OFFSET+IMPL_MSGBOX_OFFSET_EXTRA_Y ); 255 Size aImageSize; 256 Size aPageSize; 257 Size aFixedSize; 258 long nTitleWidth; 259 long nButtonSize = ImplGetButtonSize(); 260 long nMaxWidth = GetDesktopRectPixel().GetWidth()-8; 261 long nMaxLineWidth; 262 long nWidth; 263 WinBits nWinStyle = WB_LEFT | WB_WORDBREAK | WB_NOLABEL | WB_INFO; 264 sal_uInt16 nTextStyle = TEXT_DRAW_MULTILINE | TEXT_DRAW_TOP | TEXT_DRAW_LEFT; 265 266 if ( mpFixedText ) 267 delete mpFixedText; 268 if ( mpFixedImage ) 269 { 270 delete mpFixedImage; 271 mpFixedImage = NULL; 272 } 273 if ( mpCheckBox ) 274 { 275 mbCheck = mpCheckBox->IsChecked(); 276 delete mpCheckBox; 277 mpCheckBox = NULL; 278 } 279 280 281 // Message-Text um Tabs bereinigen 282 XubString aTabStr( RTL_CONSTASCII_USTRINGPARAM( " " ) ); 283 sal_uInt16 nIndex = 0; 284 while ( nIndex != STRING_NOTFOUND ) 285 nIndex = aMessText.SearchAndReplace( '\t', aTabStr, nIndex ); 286 287 // Wenn Fenster zu schmall, machen wir Dialog auch breiter 288 if ( mpWindowImpl->mbFrame ) 289 nMaxWidth = 630; 290 else if ( nMaxWidth < 120 ) 291 nMaxWidth = 120; 292 293 nMaxWidth -= mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder+4; 294 295 // MessageBox sollte min. so breit sein, das auch Title sichtbar ist 296 // Extra-Width for Closer, because Closer is set after this call 297 nTitleWidth = CalcTitleWidth(); 298 nTitleWidth += mpWindowImpl->mnTopBorder; 299 300 nMaxWidth -= (IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_X*2); 301 302 // Wenn wir ein Image haben, dann deren Groesse ermitteln und das 303 // entsprechende Control anlegen und positionieren 304 aImageSize = maImage.GetSizePixel(); 305 if ( aImageSize.Width() ) 306 { 307 aImageSize.Width() += 4; 308 aImageSize.Height() += 4; 309 aTextPos.X() += aImageSize.Width()+IMPL_SEP_MSGBOX_IMAGE; 310 mpFixedImage = new FixedImage( this ); 311 mpFixedImage->SetPosSizePixel( Point( IMPL_DIALOG_OFFSET-2+IMPL_MSGBOX_OFFSET_EXTRA_X, 312 IMPL_DIALOG_OFFSET-2+IMPL_MSGBOX_OFFSET_EXTRA_Y ), 313 aImageSize ); 314 mpFixedImage->SetImage( maImage ); 315 // forward the HC image 316 if( !!maImageHC ) 317 mpFixedImage->SetModeImage( maImageHC, BMP_COLOR_HIGHCONTRAST ); 318 mpFixedImage->Show(); 319 nMaxWidth -= aImageSize.Width()+IMPL_SEP_MSGBOX_IMAGE; 320 } 321 else 322 aTextPos.X() += IMPL_MSGBOX_OFFSET_EXTRA_X; 323 324 // Maximale Zeilenlaenge ohne Wordbreak ermitteln 325 aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo ); 326 nMaxLineWidth = aFormatRect.GetWidth(); 327 nTextStyle |= TEXT_DRAW_WORDBREAK; 328 329 // Breite fuer Textformatierung ermitteln 330 if ( nMaxLineWidth > 450 ) 331 nWidth = 450; 332 else if ( nMaxLineWidth > 300 ) 333 nWidth = nMaxLineWidth+5; 334 else 335 nWidth = 300; 336 if ( nButtonSize > nWidth ) 337 nWidth = nButtonSize-(aTextPos.X()-IMPL_DIALOG_OFFSET); 338 if ( nWidth > nMaxWidth ) 339 nWidth = nMaxWidth; 340 341 aRect.Right() = nWidth; 342 aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo ); 343 if ( aTextInfo.GetMaxLineWidth() > nWidth ) 344 { 345 nWidth = aTextInfo.GetMaxLineWidth()+8; 346 aRect.Right() = nWidth; 347 aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo ); 348 } 349 350 // Style fuer FixedText ermitteln 351 aPageSize.Width() = aImageSize.Width(); 352 aFixedSize.Width() = aTextInfo.GetMaxLineWidth()+1; 353 aFixedSize.Height() = aFormatRect.GetHeight(); 354 if ( aFixedSize.Height() < aImageSize.Height() ) 355 { 356 nWinStyle |= WB_VCENTER; 357 aPageSize.Height() = aImageSize.Height(); 358 aFixedSize.Height() = aImageSize.Height(); 359 } 360 else 361 { 362 nWinStyle |= WB_TOP; 363 aPageSize.Height() = aFixedSize.Height(); 364 } 365 if ( aImageSize.Width() ) 366 aPageSize.Width() += IMPL_SEP_MSGBOX_IMAGE; 367 aPageSize.Width() += (IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_X*2); 368 aPageSize.Width() += aFixedSize.Width()+1; 369 aPageSize.Height() += (IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_Y*2); 370 371 if ( aPageSize.Width() < IMPL_MINSIZE_MSGBOX_WIDTH ) 372 aPageSize.Width() = IMPL_MINSIZE_MSGBOX_WIDTH; 373 if ( aPageSize.Width() < nTitleWidth ) 374 aPageSize.Width() = nTitleWidth; 375 376 if ( maCheckBoxText.Len() ) 377 { 378 Size aMinCheckboxSize ( aFixedSize ); 379 if ( aPageSize.Width() < IMPL_MINSIZE_MSGBOX_WIDTH+80 ) 380 { 381 aPageSize.Width() = IMPL_MINSIZE_MSGBOX_WIDTH+80; 382 aMinCheckboxSize.Width() += 80; 383 } 384 385 // #104492# auto mnemonics for CJK strings may increase the length, so measure the 386 // checkbox length including a temporary mnemonic, the correct auto mnemonic will be 387 // generated later in the dialog (see init_show) 388 389 String aMnemonicString( maCheckBoxText ); 390 if( GetSettings().GetStyleSettings().GetAutoMnemonic() ) 391 { 392 if( aMnemonicString == GetNonMnemonicString( maCheckBoxText ) ) 393 { 394 // no mnemonic found -> create one 395 MnemonicGenerator aMnemonicGenerator; 396 aMnemonicGenerator.CreateMnemonic( aMnemonicString ); 397 } 398 } 399 400 mpCheckBox = new CheckBox( this ); 401 mpCheckBox->Check( mbCheck ); 402 mpCheckBox->SetText( aMnemonicString ); 403 mpCheckBox->SetStyle( mpCheckBox->GetStyle() | WB_WORDBREAK ); 404 mpCheckBox->SetHelpId( GetHelpId() ); // DR: Check box and dialog have same HID 405 406 // align checkbox with message text 407 Size aSize = mpCheckBox->CalcMinimumSize( aMinCheckboxSize.Width() ); 408 409 // now set the original non-mnemonic string 410 mpCheckBox->SetText( maCheckBoxText ); 411 412 Point aPos( aTextPos ); 413 aPos.Y() += aFixedSize.Height() + (IMPL_DIALOG_OFFSET)+(IMPL_MSGBOX_OFFSET_EXTRA_Y*2); 414 415 // increase messagebox 416 aPageSize.Height() += aSize.Height() + (IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_Y*2); 417 418 mpCheckBox->SetPosSizePixel( aPos, aSize ); 419 mpCheckBox->Show(); 420 } 421 422 mpFixedText = new FixedText( this, nWinStyle ); 423 if( mpFixedText->GetStyle() & WB_EXTRAOFFSET ) // TODO: use CalcMinimumSize() instead 424 aFixedSize.Width() += 2; 425 mpFixedText->SetPosSizePixel( aTextPos, aFixedSize ); 426 mpFixedText->SetText( aMessText ); 427 mpFixedText->Show(); 428 SetPageSizePixel( aPageSize ); 429 } 430 431 // ----------------------------------------------------------------------- 432 433 void MessBox::StateChanged( StateChangedType nType ) 434 { 435 if ( nType == STATE_CHANGE_INITSHOW ) 436 { 437 ImplPosControls(); 438 if ( mbSound && mnSoundType ) 439 Sound::Beep( (SoundType)(mnSoundType-1), this ); 440 } 441 ButtonDialog::StateChanged( nType ); 442 } 443 444 // ----------------------------------------------------------------------- 445 446 sal_Bool MessBox::GetCheckBoxState() const 447 { 448 return mpCheckBox ? mpCheckBox->IsChecked() : mbCheck; 449 } 450 451 // ----------------------------------------------------------------------- 452 453 void MessBox::SetCheckBoxState( sal_Bool bCheck ) 454 { 455 if( mpCheckBox ) mpCheckBox->Check( bCheck ); 456 mbCheck = bCheck; 457 } 458 459 // ----------------------------------------------------------------------- 460 461 void MessBox::SetDefaultCheckBoxText() 462 { 463 ResMgr* pResMgr = ImplGetResMgr(); 464 if( pResMgr ) 465 maCheckBoxText = XubString( ResId( SV_STDTEXT_DONTHINTAGAIN, *pResMgr ) ); 466 } 467 468 // ----------------------------------------------------------------------- 469 470 sal_Bool MessBox::SetModeImage( const Image& rImage, BmpColorMode eMode ) 471 { 472 if( eMode == BMP_COLOR_NORMAL ) 473 SetImage( rImage ); 474 else if( eMode == BMP_COLOR_HIGHCONTRAST ) 475 maImageHC = rImage; 476 else 477 return sal_False; 478 return sal_True; 479 } 480 481 // ----------------------------------------------------------------------- 482 483 const Image& MessBox::GetModeImage( BmpColorMode eMode ) const 484 { 485 if( eMode == BMP_COLOR_HIGHCONTRAST ) 486 return maImageHC; 487 else 488 return maImage; 489 } 490 491 // ----------------------------------------------------------------------- 492 493 void InfoBox::ImplInitInfoBoxData() 494 { 495 // Default Text is the display title from the application 496 if ( !GetText().Len() ) 497 SetText( Application::GetDisplayName() ); 498 499 SetImage( GetSettings().GetStyleSettings().GetHighContrastMode() ? 500 InfoBox::GetStandardImageHC() : InfoBox::GetStandardImage() ); 501 mnSoundType = ((sal_uInt16)SOUND_INFO)+1; 502 } 503 504 // ----------------------------------------------------------------------- 505 506 InfoBox::InfoBox( Window* pParent, const XubString& rMessage ) : 507 MessBox( pParent, WB_OK | WB_DEF_OK, ImplGetSVEmptyStr(), rMessage ) 508 { 509 ImplInitInfoBoxData(); 510 } 511 512 // ----------------------------------------------------------------------- 513 514 InfoBox::InfoBox( Window* pParent, const ResId & rResId ) : 515 MessBox( pParent, rResId.SetRT( RSC_INFOBOX ) ) 516 { 517 ImplInitInfoBoxData(); 518 } 519 520 // ----------------------------------------------------------------------- 521 522 Image InfoBox::GetStandardImage() 523 { 524 ImplInitMsgBoxImageList(); 525 return ImplGetSVData()->maWinData.mpMsgBoxImgList->GetImage( 4 ); 526 } 527 528 // ----------------------------------------------------------------------- 529 530 Image InfoBox::GetStandardImageHC() 531 { 532 ImplInitMsgBoxImageList(); 533 return ImplGetSVData()->maWinData.mpMsgBoxHCImgList->GetImage( 4 ); 534 } 535 536 // ----------------------------------------------------------------------- 537 538 void WarningBox::ImplInitWarningBoxData() 539 { 540 // Default Text is the display title from the application 541 if ( !GetText().Len() ) 542 SetText( Application::GetDisplayName() ); 543 544 SetImage( WarningBox::GetStandardImage() ); 545 mnSoundType = ((sal_uInt16)SOUND_WARNING)+1; 546 } 547 548 // ----------------------------------------------------------------------- 549 550 WarningBox::WarningBox( Window* pParent, WinBits nStyle, 551 const XubString& rMessage ) : 552 MessBox( pParent, nStyle, ImplGetSVEmptyStr(), rMessage ) 553 { 554 ImplInitWarningBoxData(); 555 } 556 557 // ----------------------------------------------------------------------- 558 559 WarningBox::WarningBox( Window* pParent, const ResId& rResId ) : 560 MessBox( pParent, rResId.SetRT( RSC_WARNINGBOX ) ) 561 { 562 ImplInitWarningBoxData(); 563 } 564 565 // ----------------------------------------------------------------------- 566 567 void WarningBox::SetDefaultCheckBoxText() 568 { 569 ResMgr* pResMgr = ImplGetResMgr(); 570 if( pResMgr ) 571 maCheckBoxText = XubString( ResId( SV_STDTEXT_DONTWARNAGAIN, *pResMgr ) ); 572 } 573 574 // ----------------------------------------------------------------------- 575 576 Image WarningBox::GetStandardImage() 577 { 578 ImplInitMsgBoxImageList(); 579 return ImplGetSVData()->maWinData.mpMsgBoxImgList->GetImage( 3 ); 580 } 581 582 // ----------------------------------------------------------------------- 583 584 void ErrorBox::ImplInitErrorBoxData() 585 { 586 // Default Text is the display title from the application 587 if ( !GetText().Len() ) 588 SetText( Application::GetDisplayName() ); 589 590 SetImage( GetSettings().GetStyleSettings().GetHighContrastMode() ? 591 ErrorBox::GetStandardImageHC() : ErrorBox::GetStandardImage() ); 592 mnSoundType = ((sal_uInt16)SOUND_ERROR)+1; 593 } 594 595 // ----------------------------------------------------------------------- 596 597 ErrorBox::ErrorBox( Window* pParent, WinBits nStyle, 598 const XubString& rMessage ) : 599 MessBox( pParent, nStyle, ImplGetSVEmptyStr(), rMessage ) 600 { 601 ImplInitErrorBoxData(); 602 } 603 604 // ----------------------------------------------------------------------- 605 606 ErrorBox::ErrorBox( Window* pParent, const ResId& rResId ) : 607 MessBox( pParent, rResId.SetRT( RSC_ERRORBOX ) ) 608 { 609 ImplInitErrorBoxData(); 610 } 611 612 // ----------------------------------------------------------------------- 613 614 Image ErrorBox::GetStandardImage() 615 { 616 ImplInitMsgBoxImageList(); 617 return ImplGetSVData()->maWinData.mpMsgBoxImgList->GetImage( 1 ); 618 } 619 620 // ----------------------------------------------------------------------- 621 622 Image ErrorBox::GetStandardImageHC() 623 { 624 ImplInitMsgBoxImageList(); 625 return ImplGetSVData()->maWinData.mpMsgBoxHCImgList->GetImage( 1 ); 626 } 627 628 // ----------------------------------------------------------------------- 629 630 void QueryBox::ImplInitQueryBoxData() 631 { 632 // Default Text is the display title from the application 633 if ( !GetText().Len() ) 634 SetText( Application::GetDisplayName() ); 635 636 SetImage( GetSettings().GetStyleSettings().GetHighContrastMode() ? 637 QueryBox::GetStandardImageHC() : QueryBox::GetStandardImage() ); 638 mnSoundType = ((sal_uInt16)SOUND_QUERY)+1; 639 } 640 641 // ----------------------------------------------------------------------- 642 643 QueryBox::QueryBox( Window* pParent, WinBits nStyle, const XubString& rMessage ) : 644 MessBox( pParent, nStyle, ImplGetSVEmptyStr(), rMessage ) 645 { 646 ImplInitQueryBoxData(); 647 } 648 649 // ----------------------------------------------------------------------- 650 651 QueryBox::QueryBox( Window* pParent, const ResId& rResId ) : 652 MessBox( pParent, rResId.SetRT( RSC_QUERYBOX ) ) 653 { 654 ImplInitQueryBoxData(); 655 } 656 657 // ----------------------------------------------------------------------- 658 659 void QueryBox::SetDefaultCheckBoxText() 660 { 661 ResMgr* pResMgr = ImplGetResMgr(); 662 if( pResMgr ) 663 maCheckBoxText = XubString( ResId( SV_STDTEXT_DONTASKAGAIN, *pResMgr ) ); 664 } 665 666 // ----------------------------------------------------------------------- 667 668 Image QueryBox::GetStandardImage() 669 { 670 ImplInitMsgBoxImageList(); 671 return ImplGetSVData()->maWinData.mpMsgBoxImgList->GetImage( 2 ); 672 } 673 674 // ----------------------------------------------------------------------- 675 676 Image QueryBox::GetStandardImageHC() 677 { 678 ImplInitMsgBoxImageList(); 679 return ImplGetSVData()->maWinData.mpMsgBoxHCImgList->GetImage( 2 ); 680 } 681 682 // ----------------------------------------------------------------------- 683 684 Size MessBox::GetOptimalSize(WindowSizeType eType) const 685 { 686 switch( eType ) { 687 case WINDOWSIZE_MINIMUM: 688 // FIXME: base me on the font size ? 689 return Size( 250, 100 ); 690 default: 691 return Window::GetOptimalSize( eType ); 692 } 693 } 694