From dc689e52d12ed25038bc1d54dfa4fb2613545e1c Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 13 Apr 2023 22:50:58 +0200 Subject: [PATCH] Added a method 'widget' to LayoutView to deliver the QWidget object for the view --- src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc | 15 +++++++++++++-- src/laybasic/laybasic/layLayoutViewBase.h | 15 +++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc index 54478e7ef..43b8af32b 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc @@ -335,11 +335,17 @@ static void save_image_with_options (lay::LayoutViewBase *view, const std::strin view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, tl::Color (), tl::Color (), tl::Color (), target_box, monochrome); } -#if defined(HAVE_QTBINDINGS) +#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) static QImage get_image_with_options (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) { return view->get_image_with_options (width, height, linewidth, oversampling, resolution, tl::Color (), tl::Color (), tl::Color (), target_box, monochrome); } + +static QWidget *widget (lay::LayoutViewBase *view) +{ + return view->widget (); +} + #endif static std::vector @@ -1158,7 +1164,12 @@ LAYBASIC_PUBLIC Class decl_LayoutViewBase ("lay", "LayoutVi "The image is drawn synchronously with the given width and height. Drawing may take some time. " "Monochrome images don't have background or annotation objects currently.\n" "\n" - "This method has been introduced in 0.23.10.\n" + "This method has been introduced in version 0.23.10.\n" + ) + + gsi::method_ext ("widget", &widget, + "@brief Gets the QWidget object of the view\n" + "\n" + "This method has been introduced in version 0.28.7.\n" ) + #endif gsi::method ("get_screenshot_pixels", static_cast (&lay::LayoutViewBase::get_screenshot_pb), diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index 0263a208a..0f8281458 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -54,6 +54,11 @@ #include "tlDeferredExecution.h" #include "dbInstElement.h" +#if defined(HAVE_QT) +# include +class QWidget; +#endif + namespace rdb { class Database; } @@ -980,6 +985,16 @@ public: */ tl::BitmapBuffer get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box); +#if defined(HAVE_QT) + /** + * @brief Gets the widget object that view is embedded in + */ + virtual QWidget *widget () + { + return 0; + } +#endif + /** * @brief Hierarchy level selection setter */