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