summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-02-26 21:43:22 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-02-27 21:30:05 +0100
commit22a830a4bd7384b0a636dd8e184a506bc5fdeb0b (patch)
tree05f522dd376df38296c42d787b4997cac2fd02d3 /vcl
parentf94c5a53efb78cd7829a6ae83555a61a6e77d9fc (diff)
cast MessBox into exile
Change-Id: I2fccc06b2228c1e7fd791d049d951d3a09f0f814 Reviewed-on: https://gerrit.libreoffice.org/50432 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/window/dialog.cxx6
-rw-r--r--vcl/source/window/msgbox.cxx257
2 files changed, 1 insertions, 262 deletions
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 9665fa880e5e..75d31d1f17b4 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -69,11 +69,7 @@ static OString ImplGetDialogText( Dialog* pDialog )
pDialog->GetText(), RTL_TEXTENCODING_UTF8));
OUString sMessage;
- if (MessBox* pMessBox = dynamic_cast<MessBox*>(pDialog))
- {
- sMessage = pMessBox->GetMessText();
- }
- else if (MessageDialog* pMessDialog = dynamic_cast<MessageDialog*>(pDialog))
+ if (MessageDialog* pMessDialog = dynamic_cast<MessageDialog*>(pDialog))
{
sMessage = pMessDialog->get_primary_text();
}
diff --git a/vcl/source/window/msgbox.cxx b/vcl/source/window/msgbox.cxx
index 805eae6f8b4f..b91f3b2fb973 100644
--- a/vcl/source/window/msgbox.cxx
+++ b/vcl/source/window/msgbox.cxx
@@ -46,263 +46,6 @@ static void ImplInitMsgBoxImageList()
}
}
-void MessBox::ImplInitButtons()
-{
- ButtonDialogFlags nOKFlags = ButtonDialogFlags::OK;
- ButtonDialogFlags nCancelFlags = ButtonDialogFlags::Cancel;
- ButtonDialogFlags nRetryFlags = ButtonDialogFlags::NONE;
- ButtonDialogFlags nYesFlags = ButtonDialogFlags::NONE;
- ButtonDialogFlags nNoFlags = ButtonDialogFlags::NONE;
-
- if ( mnMessBoxStyle & MessBoxStyle::OkCancel )
- {
- if ( mnMessBoxStyle & MessBoxStyle::DefaultCancel )
- nCancelFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus;
- else // MessBoxStyle::DefaultOk
- nOKFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus;
-
- AddButton( StandardButtonType::OK, RET_OK, nOKFlags );
- AddButton( StandardButtonType::Cancel, RET_CANCEL, nCancelFlags );
- }
- else if ( mnMessBoxStyle & MessBoxStyle::YesNo )
- {
- if ( mnMessBoxStyle & MessBoxStyle::DefaultYes )
- nYesFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus;
- else // MessBoxStyle::DefaultNo
- nNoFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus;
- nNoFlags |= ButtonDialogFlags::Cancel;
-
- AddButton( StandardButtonType::Yes, RET_YES, nYesFlags );
- AddButton( StandardButtonType::No, RET_NO, nNoFlags );
- }
- else if ( mnMessBoxStyle & MessBoxStyle::YesNoCancel )
- {
- if ( mnMessBoxStyle & MessBoxStyle::DefaultYes )
- nYesFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus;
- else if ( mnMessBoxStyle & MessBoxStyle::DefaultNo )
- nNoFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus;
- else
- nCancelFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus;
-
- AddButton( StandardButtonType::Yes, RET_YES, nYesFlags );
- AddButton( StandardButtonType::No, RET_NO, nNoFlags );
- AddButton( StandardButtonType::Cancel, RET_CANCEL, nCancelFlags );
- }
- else if ( mnMessBoxStyle & MessBoxStyle::RetryCancel )
- {
- if ( mnMessBoxStyle & MessBoxStyle::DefaultCancel )
- nCancelFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus;
- else // MessBoxStyle::DefaultRetry
- nRetryFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus;
-
- AddButton( StandardButtonType::Retry, RET_RETRY, nRetryFlags );
- AddButton( StandardButtonType::Cancel, RET_CANCEL, nCancelFlags );
- }
- else if ( mnMessBoxStyle & MessBoxStyle::AbortRetryIgnore )
- {
- ButtonDialogFlags nAbortFlags = ButtonDialogFlags::NONE;
- ButtonDialogFlags nIgnoreFlags = ButtonDialogFlags::NONE;
-
- if ( mnMessBoxStyle & MessBoxStyle::DefaultCancel )
- nAbortFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus;
- else if ( mnMessBoxStyle & MessBoxStyle::DefaultRetry )
- nRetryFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus;
- else if ( mnMessBoxStyle & MessBoxStyle::DefaultIgnore )
- nIgnoreFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus;
-
- AddButton( StandardButtonType::Abort, RET_CANCEL, nAbortFlags );
- AddButton( StandardButtonType::Retry, RET_RETRY, nRetryFlags );
- AddButton( StandardButtonType::Ignore, RET_IGNORE, nIgnoreFlags );
- }
- else if ( mnMessBoxStyle & MessBoxStyle::Ok )
- {
- nOKFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus;
-
- AddButton( StandardButtonType::OK, RET_OK, nOKFlags );
- }
-}
-
-MessBox::MessBox(vcl::Window* pParent, MessBoxStyle nMessBoxStyle, WinBits nWinBits,
- const OUString& rTitle, const OUString& rMessage) :
- ButtonDialog( WindowType::MESSBOX ),
- mbHelpBtn( false ),
- mnMessBoxStyle( nMessBoxStyle ),
- maMessText( rMessage )
-{
- ImplLOKNotifier(pParent);
- ImplInit(pParent, nWinBits | WB_MOVEABLE | WB_HORZ | WB_CENTER);
- ImplInitButtons();
-
- if ( !rTitle.isEmpty() )
- SetText( rTitle );
-}
-
-MessBox::~MessBox()
-{
- disposeOnce();
-}
-
-void MessBox::dispose()
-{
- mpVCLMultiLineEdit.disposeAndClear();
- mpFixedImage.disposeAndClear();
- ButtonDialog::dispose();
-}
-
-void MessBox::ImplPosControls()
-{
- if ( !GetHelpId().isEmpty() )
- {
- if ( !mbHelpBtn )
- {
- AddButton( StandardButtonType::Help, RET_HELP, ButtonDialogFlags::Help, 3 );
- mbHelpBtn = true;
- }
- }
- else
- {
- if ( mbHelpBtn )
- {
- RemoveButton( RET_HELP );
- mbHelpBtn = false;
- }
- }
-
- TextRectInfo aTextInfo;
- tools::Rectangle aRect( 0, 0, 30000, 30000 );
- tools::Rectangle aFormatRect;
- Point aTextPos( IMPL_DIALOG_OFFSET, IMPL_DIALOG_OFFSET+IMPL_MSGBOX_OFFSET_EXTRA_Y );
- Size aImageSize;
- Size aPageSize;
- Size aMEditSize;
- long nTitleWidth;
- long nButtonSize = ImplGetButtonSize();
- long nMaxWidth = GetDesktopRectPixel().GetWidth()-8;
- long nMaxLineWidth;
- long nWidth;
- WinBits nWinStyle = WB_LEFT | WB_NOLABEL;
- DrawTextFlags nTextStyle = DrawTextFlags::MultiLine | DrawTextFlags::Top | DrawTextFlags::Left;
-
- mpVCLMultiLineEdit.disposeAndClear();
- mpFixedImage.disposeAndClear();
-
- // Clean up message text with tabs
- OUString aMessText(maMessText.replaceAll("\t", " "));
-
- //If window too small, we make dialog box be wider
- if ( mpWindowImpl->mbFrame )
- {
- nMaxWidth = 630 * GetDPIScaleFactor();
- }
- else if ( nMaxWidth < 120 )
- nMaxWidth = 120;
-
- nMaxWidth -= mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder+4;
-
- // MessagBox should be at least as wide as to see the title
- // Extra-Width for Close button, because Close button is set after this call
- nTitleWidth = CalcTitleWidth();
- nTitleWidth += mpWindowImpl->mnTopBorder;
-
- nMaxWidth -= (IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_X*2);
-
- // for an image, get its size, create a suitable control and position it
- aImageSize = maImage.GetSizePixel();
- if ( aImageSize.Width() )
- {
- aImageSize.AdjustWidth(4 );
- aImageSize.AdjustHeight(4 );
- aTextPos.AdjustX(aImageSize.Width()+IMPL_SEP_MSGBOX_IMAGE );
- mpFixedImage = VclPtr<FixedImage>::Create( this );
- mpFixedImage->SetPosSizePixel( Point( IMPL_DIALOG_OFFSET-2+IMPL_MSGBOX_OFFSET_EXTRA_X,
- IMPL_DIALOG_OFFSET-2+IMPL_MSGBOX_OFFSET_EXTRA_Y ),
- aImageSize );
- mpFixedImage->SetImage( maImage );
- mpFixedImage->Show();
- nMaxWidth -= aImageSize.Width()+IMPL_SEP_MSGBOX_IMAGE;
- }
- else
- aTextPos.AdjustX(IMPL_MSGBOX_OFFSET_EXTRA_X );
-
- // Determine maximum line length without wordbreak
- aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo );
- nMaxLineWidth = aFormatRect.GetWidth();
- nTextStyle |= DrawTextFlags::WordBreak;
-
- // Determine the width for text formatting
- if ( nMaxLineWidth > 450 )
- nWidth = 450;
- else if ( nMaxLineWidth > 300 )
- nWidth = nMaxLineWidth+5;
- else
- nWidth = 300;
-
- nWidth *= GetDPIScaleFactor();
-
- if ( nButtonSize > nWidth )
- nWidth = nButtonSize-(aTextPos.X()-IMPL_DIALOG_OFFSET);
- if ( nWidth > nMaxWidth )
- nWidth = nMaxWidth;
-
- aRect.SetRight( nWidth );
- aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo );
- if ( aTextInfo.GetMaxLineWidth() > nWidth )
- {
- nWidth = aTextInfo.GetMaxLineWidth()+8;
- aRect.SetRight( nWidth );
- aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo );
- }
-
- // get Style for VCLMultiLineEdit
- aMEditSize.setWidth( aTextInfo.GetMaxLineWidth()+1 );
- aMEditSize.setHeight( aFormatRect.GetHeight() );
- aPageSize.setWidth( aImageSize.Width() );
- if ( aMEditSize.Height() < aImageSize.Height() )
- {
- nWinStyle |= WB_VCENTER;
- aPageSize.setHeight( aImageSize.Height() );
- aMEditSize.setHeight( aImageSize.Height() );
- }
- else
- {
- nWinStyle |= WB_TOP;
- aPageSize.setHeight( aMEditSize.Height() );
- }
- if ( aImageSize.Width() )
- aPageSize.AdjustWidth(IMPL_SEP_MSGBOX_IMAGE );
- aPageSize.AdjustWidth((IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_X*2) );
- aPageSize.AdjustWidth(aMEditSize.Width()+1 );
- aPageSize.AdjustHeight((IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_Y*2) );
-
- if ( aPageSize.Width() < IMPL_MINSIZE_MSGBOX_WIDTH )
- aPageSize.setWidth( IMPL_MINSIZE_MSGBOX_WIDTH );
- if ( aPageSize.Width() < nTitleWidth )
- aPageSize.setWidth( nTitleWidth );
-
- mpVCLMultiLineEdit = VclPtr<VclMultiLineEdit>::Create( this, nWinStyle );
- mpVCLMultiLineEdit->SetText( aMessText );
- mpVCLMultiLineEdit->SetPosSizePixel( aTextPos, aMEditSize );
- mpVCLMultiLineEdit->Show();
- mpVCLMultiLineEdit->SetPaintTransparent(true);
- mpVCLMultiLineEdit->EnableCursor(false);
- SetPageSizePixel( aPageSize );
-}
-
-void MessBox::StateChanged( StateChangedType nType )
-{
- if ( nType == StateChangedType::InitShow )
- {
- ImplPosControls();
- }
- ButtonDialog::StateChanged( nType );
-}
-
-Size MessBox::GetOptimalSize() const
-{
- // FIXME: base me on the font size ?
- return Size( 250, 100 );
-}
-
Image const & GetStandardInfoBoxImage()
{
ImplInitMsgBoxImageList();