summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-02-19 16:33:35 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-02-22 22:07:38 +0100
commit6a4c464b49dbfa2801818ead1b50bc9580824d00 (patch)
tree3d6381b6b13576bc536670992b36784436486e95 /vcl/source
parentf7733528e88a6619f82b54b59e92a9bca72c0a89 (diff)
weld native message dialogs
just the straight-forward MessageDialog cases first a) remove border_width from message dialog .ui so as to take the default border width b) retain 12 as default message dialog border for vcl widget case c) remove layour_style from message dialog button boxes so as to take the default mode (a no-op for vcl widget case) d) use gtk response ids (vcl builder will converts to vcl ones) Change-Id: I7de281093a1b64f92f71ca11e7cbba42bb658154 Reviewed-on: https://gerrit.libreoffice.org/50143 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/app/salvtables.cxx8
-rw-r--r--vcl/source/app/stdtext.cxx9
-rw-r--r--vcl/source/control/edit.cxx11
-rw-r--r--vcl/source/control/fixedhyper.cxx12
-rw-r--r--vcl/source/edit/textview.cxx3
-rw-r--r--vcl/source/gdi/print3.cxx18
-rw-r--r--vcl/source/window/builder.cxx4
-rw-r--r--vcl/source/window/dialog.cxx1
-rw-r--r--vcl/source/window/layout.cxx1
9 files changed, 40 insertions, 27 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index d2bef1fe030a..77a3df7d6ed7 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -28,6 +28,7 @@
#include <salobj.hxx>
#include <salmenu.hxx>
#include <svdata.hxx>
+#include <vcl/messagedialog.hxx>
#include <vcl/builder.hxx>
#include <vcl/combobox.hxx>
#include <vcl/lstbox.hxx>
@@ -236,11 +237,16 @@ public:
return m_xWidget->get_preferred_size();
}
- virtual float approximate_char_width() const override
+ virtual float get_approximate_char_width() const override
{
return m_xWidget->approximate_char_width();
}
+ virtual int get_text_height() const override
+ {
+ return m_xWidget->GetTextHeight();
+ }
+
virtual Size get_pixel_size(const OUString& rText) const override
{
//TODO, or do I want GetTextBoundRect ?, just using width at the moment anyway
diff --git a/vcl/source/app/stdtext.cxx b/vcl/source/app/stdtext.cxx
index 2e549e539db4..dbd6a0f5b82c 100644
--- a/vcl/source/app/stdtext.cxx
+++ b/vcl/source/app/stdtext.cxx
@@ -17,18 +17,19 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <vcl/layout.hxx>
#include <vcl/stdtext.hxx>
+#include <vcl/weld.hxx>
#include <strings.hrc>
#include <svdata.hxx>
-void ShowServiceNotAvailableError(vcl::Window* pParent,
+void ShowServiceNotAvailableError(weld::Widget* pParent,
const OUString& rServiceName, bool bError)
{
OUString aText = VclResId(SV_STDTEXT_SERVICENOTAVAILABLE).replaceAll("%s", rServiceName);
- ScopedVclPtrInstance< MessageDialog > aBox( pParent, aText, bError ? VclMessageType::Error : VclMessageType::Warning );
- aBox->Execute();
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent,
+ bError ? VclMessageType::Error : VclMessageType::Warning, VclButtonsType::Ok, aText));
+ xBox->run();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 1d011da56520..c11b78ff6bf8 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -26,7 +26,7 @@
#include <vcl/virdev.hxx>
#include <vcl/menu.hxx>
#include <vcl/edit.hxx>
-#include <vcl/layout.hxx>
+#include <vcl/weld.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <vcl/uitest/uiobject.hxx>
@@ -777,10 +777,11 @@ uno::Reference < i18n::XExtendedInputSequenceChecker > const & Edit::ImplGetInpu
return mxISC;
}
-void Edit::ShowTruncationWarning( vcl::Window* pParent )
+void Edit::ShowTruncationWarning(weld::Widget* pParent)
{
- ScopedVclPtrInstance< MessageDialog > aBox(pParent, VclResId(SV_EDIT_WARNING_STR), VclMessageType::Warning);
- aBox->Execute();
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent, VclMessageType::Warning,
+ VclButtonsType::Ok, VclResId(SV_EDIT_WARNING_STR)));
+ xBox->run();
}
bool Edit::ImplTruncateToMaxLen( OUString& rStr, sal_Int32 nSelectionLen ) const
@@ -1306,7 +1307,7 @@ void Edit::ImplPaste( uno::Reference< datatransfer::clipboard::XClipboard > cons
OUString aText;
aData >>= aText;
if( ImplTruncateToMaxLen( aText, maSelection.Len() ) )
- ShowTruncationWarning( this );
+ ShowTruncationWarning(GetFrameWeld());
ReplaceSelected( aText );
}
catch( const css::uno::Exception& )
diff --git a/vcl/source/control/fixedhyper.cxx b/vcl/source/control/fixedhyper.cxx
index 4d0631b85867..49ce74bb502e 100644
--- a/vcl/source/control/fixedhyper.cxx
+++ b/vcl/source/control/fixedhyper.cxx
@@ -19,7 +19,7 @@
#include <vcl/fixedhyper.hxx>
#include <vcl/svapp.hxx>
-#include <vcl/layout.hxx>
+#include <vcl/weld.hxx>
#include <comphelper/anytostring.hxx>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/exc_hlp.hxx>
@@ -149,7 +149,7 @@ bool FixedHyperlink::set_property(const OString &rKey, const OUString &rValue)
return true;
}
-IMPL_STATIC_LINK(FixedHyperlink, HandleClick, FixedHyperlink&, rHyperlink, void)
+IMPL_LINK(FixedHyperlink, HandleClick, FixedHyperlink&, rHyperlink, void)
{
if ( rHyperlink.m_sURL.isEmpty() ) // Nothing to do, when the URL is empty
return;
@@ -165,10 +165,10 @@ IMPL_STATIC_LINK(FixedHyperlink, HandleClick, FixedHyperlink&, rHyperlink, void)
{
uno::Any exc(cppu::getCaughtException());
OUString msg(comphelper::anyToString(exc));
- const SolarMutexGuard guard;
- ScopedVclPtrInstance< MessageDialog > aErrorBox(nullptr, msg);
- aErrorBox->SetText( rHyperlink.GetText() );
- aErrorBox->Execute();
+ SolarMutexGuard g;
+ std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Error, VclButtonsType::Ok, msg));
+ xErrorBox->set_title(rHyperlink.GetText());
+ xErrorBox->run();
}
}
diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx
index 0d063ae1e091..901110ab4b8c 100644
--- a/vcl/source/edit/textview.cxx
+++ b/vcl/source/edit/textview.cxx
@@ -30,6 +30,7 @@
#include <svl/undo.hxx>
#include <vcl/cursor.hxx>
+#include <vcl/weld.hxx>
#include <vcl/window.hxx>
#include <vcl/svapp.hxx>
#include <tools/stream.hxx>
@@ -1078,7 +1079,7 @@ void TextView::Paste( css::uno::Reference< css::datatransfer::clipboard::XClipbo
mpImpl->mpTextEngine->Broadcast( TextHint( SfxHintId::TextModified ) );
if( bWasTruncated )
- Edit::ShowTruncationWarning( mpImpl->mpWindow );
+ Edit::ShowTruncationWarning(mpImpl->mpWindow->GetFrameWeld());
}
catch( const css::datatransfer::UnsupportedFlavorException& )
{
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index 938dca6dd7dc..f8a34049fb0d 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <vcl/layout.hxx>
+#include <vcl/weld.hxx>
#include <vcl/print.hxx>
#include <vcl/svapp.hxx>
#include <vcl/metaact.hxx>
@@ -305,10 +305,10 @@ bool Printer::PreparePrintJob(std::shared_ptr<PrinterController> xController,
{
if (xController->isShowDialogs())
{
- ScopedVclPtrInstance<MessageDialog> aBox(
- xController->getWindow(), "ErrorNoPrinterDialog",
- "vcl/ui/errornoprinterdialog.ui");
- aBox->Execute();
+ VclPtr<vcl::Window> xParent = xController->getWindow();
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(xParent ? xParent->GetFrameWeld() : nullptr, "vcl/ui/errornoprinterdialog.ui"));
+ std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog("ErrorNoPrinterDialog"));
+ xBox->run();
}
xController->setValue( "IsDirect",
css::uno::makeAny( false ) );
@@ -456,10 +456,10 @@ bool Printer::PreparePrintJob(std::shared_ptr<PrinterController> xController,
{
if( xController->getFilteredPageCount() == 0 )
{
- ScopedVclPtrInstance<MessageDialog> aBox(
- xController->getWindow(), "ErrorNoContentDialog",
- "vcl/ui/errornocontentdialog.ui");
- aBox->Execute();
+ VclPtr<vcl::Window> xParent = xController->getWindow();
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(xParent ? xParent->GetFrameWeld() : nullptr, "vcl/ui/errornocontentdialog.ui"));
+ std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog("ErrorNoContentDialog"));
+ xBox->run();
return false;
}
}
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index c6d345434bc6..1fac71679e85 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -43,6 +43,7 @@
#include <vcl/commandinfoprovider.hxx>
#include <svdata.hxx>
#include <bitmaps.hlst>
+#include <vcl/messagedialog.hxx>
#include <window.h>
#include <xmlreader/xmlreader.hxx>
#include <desktop/crashreport.hxx>
@@ -172,7 +173,7 @@ namespace weld
m_xSpinButton->get_range(min, max);
auto width = std::max(m_xSpinButton->get_pixel_size(format_number(min)).Width(),
m_xSpinButton->get_pixel_size(format_number(max)).Width());
- int chars = ceil(width / m_xSpinButton->approximate_char_width());
+ int chars = ceil(width / m_xSpinButton->get_approximate_char_width());
m_xSpinButton->set_width_chars(chars);
}
@@ -1314,6 +1315,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
if (extractResizable(rMap))
nBits |= WB_SIZEABLE;
xWindow = VclPtr<MessageDialog>::Create(pParent, nBits);
+ xWindow->set_border_width(12);
}
else if (name == "GtkBox")
{
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index cdad91241c35..9ba5d57da2d4 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -56,6 +56,7 @@
#include <vcl/uitest/logger.hxx>
#include <vcl/virdev.hxx>
#include <vcl/IDialogRenderable.hxx>
+#include <vcl/messagedialog.hxx>
#include <salframe.hxx>
#include <iostream>
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 0b0eb098f0c7..69c492b28e70 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -15,6 +15,7 @@
#include <vcl/msgbox.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
+#include <vcl/messagedialog.hxx>
#include <window.h>
#include <boost/multi_array.hpp>
#include <officecfg/Office/Common.hxx>