26 #if defined (HAVE_CONFIG_H)
31 #include <QActionEvent>
32 #include <QApplication>
35 #include <QFileDialog>
39 #include <QMainWindow>
42 #include <QMessageBox>
46 #if defined (HAVE_QSCREEN_DEVICEPIXELRATIO)
65 #include "builtin-defun-decls.h"
94 QColor black (
"Black");
95 QColor white (
"White");
99 if (cdata(ii,jj) == 1.0)
101 else if (cdata(ii,jj) == 2.0)
106 retval.setPixel (jj, ii, tmp.rgba ());
121 :
Object (oct_qobj, interp, go, win), m_blockUpdates (false),
122 m_figureToolBar (nullptr), m_menuBar (nullptr), m_innerRect (),
123 m_outerRect (), m_previousHeight (0), m_resizable (true)
153 if (fp.toolbar_is (
"figure")
154 || (fp.toolbar_is (
"auto") && fp.menubar_is (
"figure")))
164 update (figure::properties::ID_NUMBERTITLE);
168 update (figure::properties::ID_KEYPRESSFCN);
169 update (figure::properties::ID_KEYRELEASEFCN);
172 update (figure::properties::ID_WINDOWSTYLE);
175 update (figure::properties::ID_RESIZE);
178 update (figure::properties::ID_POINTERSHAPECDATA);
181 update (figure::properties::ID_VISIBLE);
207 std::string
name = fp.get_filename ();
221 fp.set_filename (
name.toStdString ());
233 std::string mode = fp.get___mouse_mode__ ();
241 mode +=
' ' + direction;
244 if (mode ==
"rotate")
246 else if (mode ==
"zoom in")
248 else if (mode ==
"zoom out")
250 else if (mode ==
"pan")
252 else if (mode ==
"text")
265 win->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred);
266 win->setFixedSize (QSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
270 int state = win->windowState ();
271 if (
state == Qt::WindowFullScreen ||
state == Qt::WindowMaximized)
272 win->setWindowState (Qt::WindowNoState);
274 win->setGeometry (
r);
278 win->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
279 win->setFixedSize(win->size ());
297 for (
auto *qobj : qWidget<QWidget> ()->findChildren<QObject*> ())
299 if (qobj->objectName () ==
"UIPanel"
300 || qobj->objectName () ==
"UIButtonGroup"
301 || qobj->objectName () ==
"UIControl"
302 || qobj->objectName () ==
"UITable")
315 QWidget *win = qWidget<QWidget> ();
317 win->activateWindow ();
327 canvas->
print (file_cmd, term);
357 qWidget<FigureWindow> ()->removeReceiver (
this);
368 if (fp.is___printing__ ())
381 case figure::properties::ID_POSITION:
387 for (
auto *tb : win->findChildren<QToolBar*> ())
388 if (! tb->isHidden ())
389 toffset += tb->sizeHint ().height ();
392 toffset +=
m_menuBar->sizeHint ().height ();
401 case figure::properties::ID_NAME:
402 case figure::properties::ID_NUMBERTITLE:
406 case figure::properties::ID_VISIBLE:
407 if (fp.is_visible ())
409 QTimer::singleShot (0, win, SLOT (
show ()));
410 if (! fp.is___gl_window__ ())
415 fp.
set (
"__gl_window__",
"on");
422 case figure::properties::ID_RESIZE:
425 win->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred);
426 win->setFixedSize (QSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
431 win->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
432 win->setFixedSize(win->size ());
437 case figure::properties::ID_MENUBAR:
438 case figure::properties::ID_TOOLBAR:
439 if (fp.toolbar_is (
"none"))
441 else if (fp.toolbar_is (
"figure"))
447 case figure::properties::ID_KEYPRESSFCN:
448 if (fp.get_keypressfcn ().isempty ())
453 for (
auto *qobj : qWidget<QWidget> ()->findChildren<QObject*> ())
455 if (qobj->objectName () ==
"UIPanel")
461 if (fp.get_keypressfcn ().isempty ())
472 case figure::properties::ID_KEYRELEASEFCN:
473 if (fp.get_keyreleasefcn ().isempty ())
479 for (
auto *qobj : qWidget<QWidget> ()->findChildren<QObject*> ())
481 if (qobj->objectName () ==
"UIPanel")
487 if (fp.get_keypressfcn ().isempty ())
498 case figure::properties::ID_WINDOWSTYLE:
499 if (fp.windowstyle_is (
"modal"))
501 bool is_visible = win->isVisible ();
506 win->setVisible (
false);
508 win->setWindowModality (Qt::ApplicationModal);
509 win->setVisible (is_visible);
512 win->setWindowModality (Qt::NonModal);
516 case figure::properties::ID_POINTERSHAPECDATA:
519 if (fp.get_pointer () !=
"custom")
523 case figure::properties::ID_POINTER:
524 case figure::properties::ID_POINTERSHAPEHOTSPOT:
525 case figure::properties::ID___MOUSE_MODE__:
526 case figure::properties::ID___ZOOM_MODE__:
530 fp.get_pointershapehotspot ()
548 QRect
r = qWidget<QWidget> ()->geometry ();
551 r.adjust (0, 0, 0, -dy);
553 r.adjust (0, 0, 0, dy);
574 QRect
r = qWidget<QWidget> ()->geometry ();
576 r.adjust (0, dh, 0, 0);
591 .arg (pt(0), 0,
'g', 5)
592 .arg (pt(1), 0,
'g', 5));
605 return qWidget<QMainWindow> ()->menuBar ();
611 QWidget *win = qWidget<QWidget> ();
639 prop =
"outerposition";
643 r.moveTopLeft (win->pos ());
645 r.setSize (win->frameGeometry ().size ());
672 if (xevent->type () == QEvent::MouseButtonPress)
680 if (fp.get_handlevisibility () ==
"on")
681 root.
set (
"currentfigure",
682 fp.get___myhandle__ ().as_octave_value ());
691 switch (xevent->type ())
693 case QEvent::ActionAdded:
694 case QEvent::ActionChanged:
695 case QEvent::ActionRemoved:
704 switch (xevent->type ())
729 switch (xevent->type ())
735 case QEvent::ChildAdded:
736 if (
dynamic_cast<QChildEvent *
> (xevent)->child
740 update (figure::properties::ID_TOOLBAR);
746 case QEvent::ChildRemoved:
747 if (
dynamic_cast<QChildEvent *
> (xevent)->child
751 update (figure::properties::ID_TOOLBAR);
761 switch (xevent->type ())
763 case QEvent::ActionAdded:
764 case QEvent::ActionChanged:
765 case QEvent::ActionRemoved:
768 QAction *a =
dynamic_cast<QActionEvent *
> (xevent)->action ();
769 int currentHeight =
m_menuBar->sizeHint ().height ();
771 && ! a->isSeparator ())
782 switch (xevent->type ())
809 win->addToolBar (bar);
812 QSize sz = bar->sizeHint ();
813 QRect
r = win->geometry ();
815 r.adjust (0, -sz.height (), 0, 0);
819 win->addToolBarBreak ();
820 win->addToolBar (bar);
832 if ((! bar->isHidden ()) != visible)
834 QSize sz = bar->sizeHint ();
835 QRect
r = win->geometry ();
838 r.adjust (0, -sz.height (), 0, 0);
840 r.adjust (0, sz.height (), 0, 0);
844 bar->setVisible (visible);
860 #if defined (HAVE_QSCREEN_DEVICEPIXELRATIO)
861 QWindow* window = qWidget<QMainWindow> ()->windowHandle ();
862 QScreen* screen = window->screen ();
869 fp.set___device_pixel_ratio__ (screen->devicePixelRatio ());
879 #if defined (HAVE_QSCREEN_DEVICEPIXELRATIO)
885 double old_dpr = fp.get___device_pixel_ratio__ ();
886 double new_dpr = screen->devicePixelRatio ();
887 if (old_dpr != new_dpr)
889 fp.set___device_pixel_ratio__ (new_dpr);
896 octave_unused_parameter (screen);
907 w->setMouseTracking (
true);
#define DECLARE_GENERICEVENTNOTIFY_SENDER(T, B)
octave_idx_type columns(void) const
octave_idx_type numel(void) const
Number of elements in the array.
octave_idx_type rows(void) const
void print(const QString &file_cmd, const QString &term)
virtual QWidget * qWidget(void)=0
void setCursor(MouseMode mode, std::string fallback, QImage cdata, Matrix hotspot)
void clearEventMask(int m)
virtual uint8NDArray getPixels(void)
void redraw(bool sync=false)
void blockRedraw(bool block=true)
Canvas * canvas(const graphics_handle &handle, bool create=true)
void removeReceiver(GenericEventNotifyReceiver *r)
void addReceiver(GenericEventNotifyReceiver *r)
graphics_object object(void) const
virtual Container * innerContainer(void)=0
virtual void do_connections(const QObject *receiver, const QObject *emitter=nullptr)
octave::interpreter & m_interpreter
void gh_callback_event(const graphics_handle &h, const std::string &name)
static Object * fromQObject(QObject *obj)
void gh_set_event(const graphics_handle &h, const std::string &name, const octave_value &value)
virtual void set(const caseless_str &, const octave_value &)
graphics_object get_object(double val) const
int process_events(bool force=false)
octave::mutex graphics_lock(void)
void set(const caseless_str &name, const octave_value &val)
bool valid_object(void) const
Base class for Octave interfaces that use Qt.
gh_manager & get_gh_manager(void)
octave_value getfield(const std::string &key) const
std::string string_value(bool force=false) const
const QString global_menubar_style("QMenuBar {" "spacing-top: 0px;" "spacing-bottom: 0px;" "margin-top: 0px;" "margin-bottom: 0px;" "padding-top: 0px;" "padding-bottom: 0px;" "}")
std::complex< double > w(std::complex< double > z, double relerr=0)
QString fromStdString(const std::string &s)
static QRect boundingBoxToRect(const Matrix &bb)
static QImage pointer_to_qimage(const Matrix &cdata)
static uint32_t state[624]
std::function< void(octave::interpreter &)> meth_callback
std::function< void(void)> fcn_callback
octave_value::octave_value(const Array< char > &chm, char type) return retval