Added a method 'widget' to LayoutView to deliver the QWidget object for the view

This commit is contained in:
Matthias Koefferlein 2023-04-13 22:50:58 +02:00
parent c6bfb03a18
commit dc689e52d1
2 changed files with 28 additions and 2 deletions

View File

@ -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); 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) 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); 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 #endif
static std::vector<std::string> static std::vector<std::string>
@ -1158,7 +1164,12 @@ LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase ("lay", "LayoutVi
"The image is drawn synchronously with the given width and height. Drawing may take some time. " "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" "Monochrome images don't have background or annotation objects currently.\n"
"\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 #endif
gsi::method ("get_screenshot_pixels", static_cast<tl::PixelBuffer (lay::LayoutViewBase::*) ()> (&lay::LayoutViewBase::get_screenshot_pb), gsi::method ("get_screenshot_pixels", static_cast<tl::PixelBuffer (lay::LayoutViewBase::*) ()> (&lay::LayoutViewBase::get_screenshot_pb),

View File

@ -54,6 +54,11 @@
#include "tlDeferredExecution.h" #include "tlDeferredExecution.h"
#include "dbInstElement.h" #include "dbInstElement.h"
#if defined(HAVE_QT)
# include <QImage>
class QWidget;
#endif
namespace rdb { namespace rdb {
class Database; 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); 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 * @brief Hierarchy level selection setter
*/ */