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