summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-02-23 09:35:08 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-02-26 15:27:09 +0000
commit942f05996bc287923cdbcae12c64e57adf8ec975 (patch)
tree7005380763a9ecb93f5f27c28174633b9774abb7 /vcl/source
parentc410a3dcfeb68ba2247c0d879727afe4ca8ed3da (diff)
convert remaining ErrorBox to weld::MessageDialog
and convert remaining QueryBox to weld::MessageDialog Change-Id: Ifb4c316dee8eabf57c4940c44e29c65a2781aa6c
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/app/salvtables.cxx35
-rw-r--r--vcl/source/window/builder.cxx8
-rw-r--r--vcl/source/window/layout.cxx203
-rw-r--r--vcl/source/window/msgbox.cxx68
4 files changed, 144 insertions, 170 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index e7fad21b767e..46755b48b07c 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -263,11 +263,7 @@ public:
return m_xWidget->GetHelpId();
}
- virtual Widget* weld_parent() const override
- {
- vcl::Window* pParent = m_xWidget->GetParent();
- return pParent ? new SalInstanceWidget(pParent, false) : nullptr;
- }
+ virtual weld::Container* weld_parent() const override;
virtual ~SalInstanceWidget() override
{
@@ -296,8 +292,26 @@ public:
, m_xContainer(pContainer)
{
}
+ virtual void remove(weld::Widget* pWidget) override
+ {
+ SalInstanceWidget* pGtkWidget = dynamic_cast<SalInstanceWidget*>(pWidget);
+ assert(pGtkWidget);
+ pGtkWidget->getWidget()->SetParent(nullptr);
+ }
+ virtual void add(weld::Widget* pWidget) override
+ {
+ SalInstanceWidget* pGtkWidget = dynamic_cast<SalInstanceWidget*>(pWidget);
+ assert(pGtkWidget);
+ pGtkWidget->getWidget()->SetParent(m_xContainer);
+ }
};
+weld::Container* SalInstanceWidget::weld_parent() const
+{
+ vcl::Window* pParent = m_xWidget->GetParent();
+ return pParent ? new SalInstanceContainer(pParent, false) : nullptr;
+}
+
class SalInstanceWindow : public SalInstanceContainer, public virtual weld::Window
{
private:
@@ -437,6 +451,11 @@ public:
{
return m_xMessageDialog->get_secondary_text();
}
+
+ virtual Container* weld_message_area() override
+ {
+ return new SalInstanceContainer(m_xMessageDialog->get_message_area(), false);
+ }
};
class SalInstanceFrame : public SalInstanceContainer, public virtual weld::Frame
@@ -540,12 +559,14 @@ class SalInstanceButton : public SalInstanceContainer, public virtual weld::Butt
{
private:
VclPtr<::Button> m_xButton;
+ Link<::Button*,void> m_aOldClickHdl;
DECL_LINK(ClickHdl, ::Button*, void);
public:
SalInstanceButton(::Button* pButton, bool bTakeOwnership)
: SalInstanceContainer(pButton, bTakeOwnership)
, m_xButton(pButton)
+ , m_aOldClickHdl(pButton->GetClickHdl())
{
m_xButton->SetClickHdl(LINK(this, SalInstanceButton, ClickHdl));
}
@@ -573,7 +594,7 @@ IMPL_LINK(SalInstanceButton, ClickHdl, ::Button*, pButton, void)
//etc buttons.
if (!m_aClickHdl.IsSet())
{
- pButton->SetClickHdl(Link<::Button*,void>());
+ pButton->SetClickHdl(m_aOldClickHdl);
pButton->Click();
pButton->SetClickHdl(LINK(this, SalInstanceButton, ClickHdl));
return;
@@ -767,6 +788,8 @@ public:
m_xTreeView->InsertEntry(rText, pos);
}
+ using SalInstanceContainer::remove;
+
virtual void remove(int pos) override
{
m_xTreeView->RemoveEntry(pos);
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index c3b8e50cc8b2..02345baa3de4 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -523,6 +523,10 @@ VclBuilder::VclBuilder(vcl::Window *pParent, const OUString& sUIDir, const OUStr
}
}
+ // create message dialog message area now
+ for (auto const& elem : m_pParserState->m_aMessageDialogs)
+ elem->create_message_area();
+
//drop maps, etc. that we don't need again
m_pParserState.reset();
@@ -1314,7 +1318,9 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
WinBits nBits = WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE;
if (extractResizable(rMap))
nBits |= WB_SIZEABLE;
- xWindow = VclPtr<MessageDialog>::Create(pParent, nBits);
+ VclPtr<MessageDialog> xDialog(VclPtr<MessageDialog>::Create(pParent, nBits));
+ m_pParserState->m_aMessageDialogs.push_back(xDialog);
+ xWindow = xDialog;
xWindow->set_border_width(12);
}
else if (name == "GtkBox")
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 79f7bbc7a408..bf6918c1b426 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -2146,96 +2146,7 @@ void VclSizeGroup::set_property(const OString &rKey, const OUString &rValue)
}
}
-void MessageDialog::create_owned_areas()
-{
- set_border_width(12);
- m_pOwnedContentArea.set(VclPtr<VclVBox>::Create(this, false, 24));
- set_content_area(m_pOwnedContentArea);
- m_pOwnedContentArea->Show();
- m_pOwnedActionArea.set( VclPtr<VclHButtonBox>::Create(m_pOwnedContentArea) );
- set_action_area(m_pOwnedActionArea);
- m_pOwnedActionArea->Show();
-}
-
-MessageDialog::MessageDialog(vcl::Window* pParent, WinBits nStyle)
- : Dialog(pParent, nStyle)
- , m_eButtonsType(VclButtonsType::NONE)
- , m_eMessageType(VclMessageType::Info)
- , m_pOwnedContentArea(nullptr)
- , m_pOwnedActionArea(nullptr)
- , m_pGrid(nullptr)
- , m_pImage(nullptr)
- , m_pPrimaryMessage(nullptr)
- , m_pSecondaryMessage(nullptr)
-{
- SetType(WindowType::MESSBOX);
-}
-
-MessageDialog::MessageDialog(vcl::Window* pParent,
- const OUString &rMessage,
- VclMessageType eMessageType,
- VclButtonsType eButtonsType)
- : Dialog(pParent, WB_MOVEABLE | WB_3DLOOK | WB_CLOSEABLE)
- , m_eButtonsType(eButtonsType)
- , m_eMessageType(eMessageType)
- , m_pGrid(nullptr)
- , m_pImage(nullptr)
- , m_pPrimaryMessage(nullptr)
- , m_pSecondaryMessage(nullptr)
- , m_sPrimaryString(rMessage)
-{
- SetType(WindowType::MESSBOX);
- create_owned_areas();
-}
-
-MessageDialog::MessageDialog(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription)
- : Dialog(pParent, OStringToOUString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription, WindowType::MESSBOX)
- , m_eButtonsType(VclButtonsType::NONE)
- , m_eMessageType(VclMessageType::Info)
- , m_pOwnedContentArea(nullptr)
- , m_pOwnedActionArea(nullptr)
- , m_pGrid(nullptr)
- , m_pImage(nullptr)
- , m_pPrimaryMessage(nullptr)
- , m_pSecondaryMessage(nullptr)
-{
-}
-
-void MessageDialog::dispose()
-{
- disposeOwnedButtons();
- m_pPrimaryMessage.disposeAndClear();
- m_pSecondaryMessage.disposeAndClear();
- m_pImage.disposeAndClear();
- m_pGrid.disposeAndClear();
- m_pOwnedActionArea.disposeAndClear();
- m_pOwnedContentArea.disposeAndClear();
- Dialog::dispose();
-}
-
-MessageDialog::~MessageDialog()
-{
- disposeOnce();
-}
-
-void MessageDialog::SetMessagesWidths(vcl::Window const *pParent,
- VclMultiLineEdit *pPrimaryMessage, VclMultiLineEdit *pSecondaryMessage)
-{
- if (pSecondaryMessage)
- {
- assert(pPrimaryMessage);
- vcl::Font aFont = pParent->GetSettings().GetStyleSettings().GetLabelFont();
- aFont.SetFontSize(Size(0, aFont.GetFontSize().Height() * 1.2));
- aFont.SetWeight(WEIGHT_BOLD);
- pPrimaryMessage->SetControlFont(aFont);
- pPrimaryMessage->SetMaxTextWidth(pPrimaryMessage->approximate_char_width() * 44);
- pSecondaryMessage->SetMaxTextWidth(pSecondaryMessage->approximate_char_width() * 60);
- }
- else
- pPrimaryMessage->SetMaxTextWidth(pPrimaryMessage->approximate_char_width() * 60);
-}
-
-short MessageDialog::Execute()
+void MessageDialog::create_message_area()
{
setDeferredProperties();
@@ -2247,7 +2158,10 @@ short MessageDialog::Execute()
m_pGrid.set( VclPtr<VclGrid>::Create(pContainer) );
m_pGrid->reorderWithinParent(0);
m_pGrid->set_column_spacing(12);
- m_pGrid->set_row_spacing(GetTextHeight());
+ m_pMessageBox.set(VclPtr<VclVBox>::Create(m_pGrid));
+ m_pMessageBox->set_grid_left_attach(1);
+ m_pMessageBox->set_grid_top_attach(0);
+ m_pMessageBox->set_spacing(GetTextHeight());
m_pImage = VclPtr<FixedImage>::Create(m_pGrid, WB_CENTER | WB_VCENTER | WB_3DLOOK);
switch (m_eMessageType)
@@ -2259,10 +2173,10 @@ short MessageDialog::Execute()
m_pImage->SetImage(WarningBox::GetStandardImage());
break;
case VclMessageType::Question:
- m_pImage->SetImage(QueryBox::GetStandardImage());
+ m_pImage->SetImage(GetStandardQueryBoxImage());
break;
case VclMessageType::Error:
- m_pImage->SetImage(ErrorBox::GetStandardImage());
+ m_pImage->SetImage(GetStandardErrorBoxImage());
break;
}
m_pImage->set_grid_left_attach(0);
@@ -2274,21 +2188,17 @@ short MessageDialog::Execute()
bool bHasSecondaryText = !m_sSecondaryString.isEmpty();
- m_pPrimaryMessage = VclPtr<VclMultiLineEdit>::Create(m_pGrid, nWinStyle);
+ m_pPrimaryMessage = VclPtr<VclMultiLineEdit>::Create(m_pMessageBox, nWinStyle);
m_pPrimaryMessage->SetPaintTransparent(true);
m_pPrimaryMessage->EnableCursor(false);
- m_pPrimaryMessage->set_grid_left_attach(1);
- m_pPrimaryMessage->set_grid_top_attach(0);
m_pPrimaryMessage->set_hexpand(true);
m_pPrimaryMessage->SetText(m_sPrimaryString);
m_pPrimaryMessage->Show(!m_sPrimaryString.isEmpty());
- m_pSecondaryMessage = VclPtr<VclMultiLineEdit>::Create(m_pGrid, nWinStyle);
+ m_pSecondaryMessage = VclPtr<VclMultiLineEdit>::Create(m_pMessageBox, nWinStyle);
m_pSecondaryMessage->SetPaintTransparent(true);
m_pSecondaryMessage->EnableCursor(false);
- m_pSecondaryMessage->set_grid_left_attach(1);
- m_pSecondaryMessage->set_grid_top_attach(1);
m_pSecondaryMessage->set_hexpand(true);
m_pSecondaryMessage->SetText(m_sSecondaryString);
m_pSecondaryMessage->Show(bHasSecondaryText);
@@ -2356,9 +2266,102 @@ short MessageDialog::Execute()
}
set_default_response(nDefaultResponse);
pButtonBox->sort_native_button_order();
+ m_pMessageBox->Show();
m_pGrid->Show();
}
- return Dialog::Execute();
+}
+
+void MessageDialog::create_owned_areas()
+{
+ set_border_width(12);
+ m_pOwnedContentArea.set(VclPtr<VclVBox>::Create(this, false, 24));
+ set_content_area(m_pOwnedContentArea);
+ m_pOwnedContentArea->Show();
+ m_pOwnedActionArea.set( VclPtr<VclHButtonBox>::Create(m_pOwnedContentArea) );
+ set_action_area(m_pOwnedActionArea);
+ m_pOwnedActionArea->Show();
+}
+
+MessageDialog::MessageDialog(vcl::Window* pParent, WinBits nStyle)
+ : Dialog(pParent, nStyle)
+ , m_eButtonsType(VclButtonsType::NONE)
+ , m_eMessageType(VclMessageType::Info)
+ , m_pOwnedContentArea(nullptr)
+ , m_pOwnedActionArea(nullptr)
+ , m_pGrid(nullptr)
+ , m_pMessageBox(nullptr)
+ , m_pImage(nullptr)
+ , m_pPrimaryMessage(nullptr)
+ , m_pSecondaryMessage(nullptr)
+{
+ SetType(WindowType::MESSBOX);
+}
+
+MessageDialog::MessageDialog(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription)
+ : Dialog(pParent, OStringToOUString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription, WindowType::MESSBOX)
+ , m_eButtonsType(VclButtonsType::NONE)
+ , m_eMessageType(VclMessageType::Info)
+ , m_pOwnedContentArea(nullptr)
+ , m_pOwnedActionArea(nullptr)
+ , m_pGrid(nullptr)
+ , m_pImage(nullptr)
+ , m_pPrimaryMessage(nullptr)
+ , m_pSecondaryMessage(nullptr)
+{
+}
+
+MessageDialog::MessageDialog(vcl::Window* pParent,
+ const OUString &rMessage,
+ VclMessageType eMessageType,
+ VclButtonsType eButtonsType)
+ : Dialog(pParent, WB_MOVEABLE | WB_3DLOOK | WB_CLOSEABLE)
+ , m_eButtonsType(eButtonsType)
+ , m_eMessageType(eMessageType)
+ , m_pGrid(nullptr)
+ , m_pMessageBox(nullptr)
+ , m_pImage(nullptr)
+ , m_pPrimaryMessage(nullptr)
+ , m_pSecondaryMessage(nullptr)
+ , m_sPrimaryString(rMessage)
+{
+ SetType(WindowType::MESSBOX);
+ create_owned_areas();
+ create_message_area();
+}
+
+void MessageDialog::dispose()
+{
+ disposeOwnedButtons();
+ m_pPrimaryMessage.disposeAndClear();
+ m_pSecondaryMessage.disposeAndClear();
+ m_pImage.disposeAndClear();
+ m_pMessageBox.disposeAndClear();
+ m_pGrid.disposeAndClear();
+ m_pOwnedActionArea.disposeAndClear();
+ m_pOwnedContentArea.disposeAndClear();
+ Dialog::dispose();
+}
+
+MessageDialog::~MessageDialog()
+{
+ disposeOnce();
+}
+
+void MessageDialog::SetMessagesWidths(vcl::Window const *pParent,
+ VclMultiLineEdit *pPrimaryMessage, VclMultiLineEdit *pSecondaryMessage)
+{
+ if (pSecondaryMessage)
+ {
+ assert(pPrimaryMessage);
+ vcl::Font aFont = pParent->GetSettings().GetStyleSettings().GetLabelFont();
+ aFont.SetFontSize(Size(0, aFont.GetFontSize().Height() * 1.2));
+ aFont.SetWeight(WEIGHT_BOLD);
+ pPrimaryMessage->SetControlFont(aFont);
+ pPrimaryMessage->SetMaxTextWidth(pPrimaryMessage->approximate_char_width() * 44);
+ pSecondaryMessage->SetMaxTextWidth(pSecondaryMessage->approximate_char_width() * 60);
+ }
+ else
+ pPrimaryMessage->SetMaxTextWidth(pPrimaryMessage->approximate_char_width() * 60);
}
OUString const & MessageDialog::get_primary_text() const
diff --git a/vcl/source/window/msgbox.cxx b/vcl/source/window/msgbox.cxx
index efe8bfcfe175..52d0bfdbdf97 100644
--- a/vcl/source/window/msgbox.cxx
+++ b/vcl/source/window/msgbox.cxx
@@ -411,82 +411,24 @@ OUString WarningBox::GetStandardText()
return VclResId(SV_MSGBOX_WARNING);
}
-ErrorBox::ErrorBox( vcl::Window* pParent, const OUString& rMessage ) :
- MessBox( pParent, MessBoxStyle::Ok | MessBoxStyle::DefaultOk, 0, OUString(), rMessage )
+Image const & GetStandardErrorBoxImage()
{
- DBG_TESTSOLARMUTEX();
- // Default Text is the display title from the application
- if ( GetText().isEmpty() )
- SetText( GetStandardText() );
-
- SetImage( ErrorBox::GetStandardImage() );
-}
-
-ErrorBox::ErrorBox( vcl::Window* pParent, MessBoxStyle nStyle,
- const OUString& rMessage ) :
- ErrorBox(pParent, nStyle, 0, rMessage )
-{
-}
-
-ErrorBox::ErrorBox( vcl::Window* pParent, MessBoxStyle nStyle, WinBits nWinBits,
- const OUString& rMessage ) :
- MessBox( pParent, nStyle, nWinBits, OUString(), rMessage )
-{
- DBG_TESTSOLARMUTEX();
- // Default Text is the display title from the application
- if ( GetText().isEmpty() )
- SetText( GetStandardText() );
-
- SetImage( ErrorBox::GetStandardImage() );
-}
-
-Image ErrorBox::GetStandardImage()
-{
- try
- {
- ImplInitMsgBoxImageList();
- }
- catch (const css::uno::Exception &)
- {
- // During early bootstrap we can have no initialized
- // ucb and hence no ability to get this image, so nop.
- return Image();
- }
+ ImplInitMsgBoxImageList();
return ImplGetSVData()->maWinData.maMsgBoxImgList[0];
}
-OUString ErrorBox::GetStandardText()
+OUString GetStandardErrorBoxText()
{
return VclResId(SV_MSGBOX_ERROR);
}
-QueryBox::QueryBox( vcl::Window* pParent, MessBoxStyle nStyle, const OUString& rMessage ) :
- QueryBox( pParent, nStyle, 0, rMessage )
-{
-}
-
-QueryBox::QueryBox( vcl::Window* pParent, MessBoxStyle nStyle, WinBits nWinBits, const OUString& rMessage ) :
- MessBox( pParent, nStyle, nWinBits, OUString(), rMessage )
-{
- // Default Text is the display title from the application
- if ( GetText().isEmpty() )
- SetText( GetStandardText() );
-
- SetImage( QueryBox::GetStandardImage() );
-}
-
-void QueryBox::SetDefaultCheckBoxText()
-{
- maCheckBoxText = VclResId(SV_STDTEXT_DONTASKAGAIN);
-}
-
-Image const & QueryBox::GetStandardImage()
+Image const & GetStandardQueryBoxImage()
{
ImplInitMsgBoxImageList();
return ImplGetSVData()->maWinData.maMsgBoxImgList[1];
}
-OUString QueryBox::GetStandardText()
+OUString GetStandardQueryBoxText()
{
return VclResId(SV_MSGBOX_QUERY);
}