diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-04-17 16:10:24 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-04-18 16:32:55 +0200 |
commit | 228723ea962e33b472317b41f31b032421879093 (patch) | |
tree | ecf94ae37a87a8c8944fa404dbf3efb1f8511ade /vcl | |
parent | 4985446a827c53bf2f1840a279b07f065f622f0e (diff) |
weld ScOptSolverDlg
Change-Id: Ie2b43377f950cb16e143f6e9ef7081bf92277088
Reviewed-on: https://gerrit.libreoffice.org/70903
Tested-by: Jenkins
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/app/salvtables.cxx | 18 | ||||
-rw-r--r-- | vcl/source/helper/commandinfoprovider.cxx | 31 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 84 |
3 files changed, 89 insertions, 44 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 59a9ab3b527a..be45ec9bf0bc 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -1615,16 +1615,20 @@ public: { m_xButton->SetImageAlign(ImageAlign::Left); if (pDevice) - { m_xButton->SetModeImage(createImage(*pDevice)); - } else m_xButton->SetModeImage(Image()); } + virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override + { + m_xButton->SetImageAlign(ImageAlign::Left); + m_xButton->SetModeImage(Image(rImage)); + } + virtual void set_from_icon_name(const OUString& rIconName) override { - m_xButton->SetModeImage(::Image(StockImage::Yes, rIconName)); + m_xButton->SetModeImage(Image(StockImage::Yes, rIconName)); } virtual void set_label_line_wrap(bool wrap) override @@ -1881,9 +1885,15 @@ public: m_xRadioButton->SetModeImage(Image()); } + virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override + { + m_xRadioButton->SetImageAlign(ImageAlign::Center); + m_xRadioButton->SetModeImage(Image(rImage)); + } + virtual void set_from_icon_name(const OUString& rIconName) override { - m_xRadioButton->SetModeRadioImage(::Image(StockImage::Yes, rIconName)); + m_xRadioButton->SetModeRadioImage(Image(StockImage::Yes, rIconName)); } virtual void set_inconsistent(bool /*inconsistent*/) override diff --git a/vcl/source/helper/commandinfoprovider.cxx b/vcl/source/helper/commandinfoprovider.cxx index 23bd3250f888..3fd267272bfd 100644 --- a/vcl/source/helper/commandinfoprovider.cxx +++ b/vcl/source/helper/commandinfoprovider.cxx @@ -295,13 +295,12 @@ OUString GetRealCommandForCommand(const OUString& rCommandName, return GetCommandProperty("TargetURL", rCommandName, rsModuleName); } -static BitmapEx GetBitmapForCommand(const OUString& rsCommandName, - const Reference<frame::XFrame>& rxFrame, - vcl::ImageType eImageType) +Reference<graphic::XGraphic> GetXGraphicForCommand(const OUString& rsCommandName, + const Reference<frame::XFrame>& rxFrame, + vcl::ImageType eImageType) { - if (rsCommandName.isEmpty()) - return BitmapEx(); + return nullptr; sal_Int16 nImageType(ui::ImageType::COLOR_NORMAL | ui::ImageType::SIZE_DEFAULT); @@ -324,11 +323,8 @@ static BitmapEx GetBitmapForCommand(const OUString& rsCommandName, aGraphicSeq = xDocImgMgr->getImages( nImageType, aImageCmdSeq ); Reference<graphic::XGraphic> xGraphic = aGraphicSeq[0]; - const Graphic aGraphic(xGraphic); - BitmapEx aBitmap(aGraphic.GetBitmapEx()); - - if (!!aBitmap) - return aBitmap; + if (xGraphic.is()) + return xGraphic; } } catch (Exception&) @@ -348,15 +344,22 @@ static BitmapEx GetBitmapForCommand(const OUString& rsCommandName, Reference<graphic::XGraphic> xGraphic(aGraphicSeq[0]); - const Graphic aGraphic(xGraphic); - - return aGraphic.GetBitmapEx(); + return xGraphic; } catch (Exception&) { } - return BitmapEx(); + return nullptr; +} + +static BitmapEx GetBitmapForCommand(const OUString& rsCommandName, + const Reference<frame::XFrame>& rxFrame, + vcl::ImageType eImageType) +{ + const Graphic aGraphic(GetXGraphicForCommand(rsCommandName, rxFrame, eImageType)); + BitmapEx aBitmap(aGraphic.GetBitmapEx()); + return aBitmap; } Image GetImageForCommand(const OUString& rsCommandName, diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 0f09eb6e0877..e5de3dc4f2d6 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -40,6 +40,7 @@ #include <vcl/i18nhelp.hxx> #include <vcl/quickselectionengine.hxx> #include <vcl/mnemonic.hxx> +#include <vcl/pngwrite.hxx> #include <vcl/syswin.hxx> #include <vcl/weld.hxx> #include <vcl/virdev.hxx> @@ -2099,6 +2100,17 @@ GdkPixbuf* load_icon_by_name(const OUString& rIconName) namespace { + GdkPixbuf* getPixbuf(const css::uno::Reference<css::graphic::XGraphic>& rImage) + { + Image aImage(rImage); + + std::unique_ptr<SvMemoryStream> xMemStm(new SvMemoryStream); + vcl::PNGWriter aWriter(aImage.GetBitmapEx()); + aWriter.Write(*xMemStm); + + return load_icon_from_stream(*xMemStm); + } + GdkPixbuf* getPixbuf(const VirtualDevice& rDevice) { Size aSize(rDevice.GetOutputSizePixel()); @@ -4321,8 +4333,6 @@ public: } }; -#include <vcl/pngwrite.hxx> - class GtkInstanceButton : public GtkInstanceContainer, public virtual weld::Button { private: @@ -4364,9 +4374,24 @@ public: { GdkPixbuf* pixbuf = load_icon_by_name(rIconName); if (!pixbuf) - return; - gtk_button_set_image(m_pButton, gtk_image_new_from_pixbuf(pixbuf)); - g_object_unref(pixbuf); + gtk_button_set_image(m_pButton, nullptr); + else + { + gtk_button_set_image(m_pButton, gtk_image_new_from_pixbuf(pixbuf)); + g_object_unref(pixbuf); + } + } + + virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override + { + GdkPixbuf* pixbuf = getPixbuf(rImage); + if (!pixbuf) + gtk_button_set_image(m_pButton, nullptr); + else + { + gtk_button_set_image(m_pButton, gtk_image_new_from_pixbuf(pixbuf)); + g_object_unref(pixbuf); + } } virtual OUString get_label() const override @@ -4677,6 +4702,20 @@ private: return false; } + void ensure_image_widget() + { + if (!m_pImage) + { + m_pImage = GTK_IMAGE(gtk_image_new()); + GtkStyleContext *pContext = gtk_widget_get_style_context(GTK_WIDGET(m_pMenuButton)); + gint nImageSpacing(0); + gtk_style_context_get_style(pContext, "image-spacing", &nImageSpacing, nullptr); + gtk_box_pack_start(m_pBox, GTK_WIDGET(m_pImage), false, false, nImageSpacing); + gtk_box_reorder_child(m_pBox, GTK_WIDGET(m_pImage), 0); + gtk_widget_show(GTK_WIDGET(m_pImage)); + } + } + public: GtkInstanceMenuButton(GtkMenuButton* pMenuButton, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) : GtkInstanceToggleButton(GTK_TOGGLE_BUTTON(pMenuButton), pBuilder, bTakeOwnership) @@ -4720,16 +4759,7 @@ public: virtual void set_image(VirtualDevice* pDevice) override { - if (!m_pImage) - { - m_pImage = GTK_IMAGE(gtk_image_new()); - GtkStyleContext *pContext = gtk_widget_get_style_context(GTK_WIDGET(m_pMenuButton)); - gint nImageSpacing(0); - gtk_style_context_get_style(pContext, "image-spacing", &nImageSpacing, nullptr); - gtk_box_pack_start(m_pBox, GTK_WIDGET(m_pImage), false, false, nImageSpacing); - gtk_box_reorder_child(m_pBox, GTK_WIDGET(m_pImage), 0); - gtk_widget_show(GTK_WIDGET(m_pImage)); - } + ensure_image_widget(); if (pDevice) { if (gtk_check_version(3, 20, 0) == nullptr) @@ -4745,6 +4775,19 @@ public: gtk_image_set_from_surface(m_pImage, nullptr); } + virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override + { + ensure_image_widget(); + GdkPixbuf* pixbuf = getPixbuf(rImage); + if (pixbuf) + { + gtk_image_set_from_pixbuf(m_pImage, pixbuf); + g_object_unref(pixbuf); + } + else + gtk_image_set_from_surface(m_pImage, nullptr); + } + virtual void insert_item(int pos, const OUString& rId, const OUString& rStr, const OUString* pIconName, VirtualDevice* pImageSurface, bool bCheck) override { @@ -5685,17 +5728,6 @@ namespace return pixbuf; } - GdkPixbuf* getPixbuf(const css::uno::Reference<css::graphic::XGraphic>& rImage) - { - Image aImage(rImage); - - std::unique_ptr<SvMemoryStream> xMemStm(new SvMemoryStream); - vcl::PNGWriter aWriter(aImage.GetBitmapEx()); - aWriter.Write(*xMemStm); - - return load_icon_from_stream(*xMemStm); - } - void insert_row(GtkListStore* pListStore, GtkTreeIter& iter, int pos, const OUString* pId, const OUString& rText, const OUString* pIconName, const VirtualDevice* pDevice) { if (!pIconName && !pDevice) |