26 #if defined (HAVE_CONFIG_H)
33 #include <QMouseEvent>
53 if (pp.bordertype_is (
"none"))
54 return QFrame::NoFrame;
55 else if (pp.bordertype_is (
"etchedin"))
56 return (QFrame::Box | QFrame::Sunken);
57 else if (pp.bordertype_is (
"etchedout"))
58 return (QFrame::Box | QFrame::Raised);
59 else if (pp.bordertype_is (
"beveledin"))
60 return (QFrame::Panel | QFrame::Sunken);
61 else if (pp.bordertype_is (
"beveledout"))
62 return (QFrame::Panel | QFrame::Raised);
64 return (QFrame::Panel | QFrame::Plain);
70 p.setColor (QPalette::Window,
72 p.setColor (QPalette::WindowText,
74 p.setColor (QPalette::Light,
76 p.setColor (QPalette::Dark,
85 if (! pp.bordertype_is (
"none"))
88 if (pp.bordertype_is (
"etchedin") || pp.bordertype_is (
"etchedout"))
106 return new Panel (oct_qobj, interp, go,
new QFrame (container));
114 :
Object (oct_qobj, interp, go, frame), m_container (nullptr),
115 m_title (nullptr), m_blockUpdates (false),
116 m_previous_bbox (
Matrix (1, 4, 0))
120 frame->setObjectName (
"UIPanel");
121 frame->setAutoFillBackground (
true);
127 QPalette pal = frame->palette ();
129 frame->setPalette (pal);
140 if (frame->hasMouseTracking ())
142 for (
auto *
w : frame->findChildren<
QWidget*> ())
143 w->setMouseTracking (
true);
147 if (! title.isEmpty ())
149 m_title =
new QLabel (title, frame);
150 m_title->setAutoFillBackground (
true);
151 m_title->setContentsMargins (4, 0, 4, 0);
156 frame->installEventFilter (
this);
166 if (pp.is_visible ())
167 QTimer::singleShot (0, frame, SLOT (
show (
void)));
184 switch (xevent->type ())
197 Utils::properties<uipanel> (go);
199 if (pp.fontunits_is (
"normalized"))
201 QFrame *frame = qWidget<QFrame> ();
204 (pp, frame->height ()));
213 case QEvent::MouseButtonPress:
215 QMouseEvent *
m =
dynamic_cast<QMouseEvent *
> (xevent);
217 if (
m->button () == Qt::RightButton)
237 switch (xevent->type ())
240 if (qWidget<QWidget> ()->isVisible ())
264 QFrame *frame = qWidget<QFrame> ();
270 case uipanel::properties::ID_POSITION:
286 case uipanel::properties::ID_BORDERWIDTH:
291 case uipanel::properties::ID_BACKGROUNDCOLOR:
292 case uipanel::properties::ID_FOREGROUNDCOLOR:
293 case uipanel::properties::ID_HIGHLIGHTCOLOR:
294 case uipanel::properties::ID_SHADOWCOLOR:
296 QPalette pal = frame->palette ();
299 frame->setPalette (pal);
305 case uipanel::properties::ID_TITLE:
309 if (title.isEmpty ())
319 QPalette pal = frame->palette ();
321 m_title =
new QLabel (title, frame);
322 m_title->setAutoFillBackground (
true);
323 m_title->setContentsMargins (4, 0, 4, 0);
338 case uipanel::properties::ID_TITLEPOSITION:
342 case uipanel::properties::ID_BORDERTYPE:
347 case uipanel::properties::ID_FONTNAME:
348 case uipanel::properties::ID_FONTSIZE:
349 case uipanel::properties::ID_FONTWEIGHT:
350 case uipanel::properties::ID_FONTANGLE:
359 case uipanel::properties::ID_VISIBLE:
360 frame->setVisible (pp.is_visible ());
374 update (uipanel::properties::ID_POSITION);
386 QFrame *frame = qWidget<QFrame> ();
403 QSize sz =
m_title->sizeHint ();
406 if (pp.titleposition_is (
"lefttop"))
408 else if (pp.titleposition_is (
"righttop"))
409 m_title->move (frame->width () - bw - offset - sz.width (), 0);
410 else if (pp.titleposition_is (
"leftbottom"))
411 m_title->move (bw+offset, frame->height () - sz.height ());
412 else if (pp.titleposition_is (
"rightbottom"))
413 m_title->move (frame->width () - bw - offset - sz.width (),
414 frame->height () - sz.height ());
415 else if (pp.titleposition_is (
"centertop"))
416 m_title->move (frame->width () / 2 - sz.width () / 2, 0);
417 else if (pp.titleposition_is (
"centerbottom"))
418 m_title->move (frame->width () / 2 - sz.width () / 2,
419 frame->height () - sz.height ());
void redraw(bool sync=false)
Canvas * canvas(const graphics_handle &handle, bool create=true)
static void executeAt(octave::interpreter &interp, const base_properties &props, const QPoint &pt)
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
static Object * parentObject(octave::interpreter &interp, const graphics_object &go)
virtual QObject * qObject(void)
void do_connections(const QObject *receiver, const QObject *emitter=nullptr)
Panel(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go, QFrame *frame)
bool eventFilter(QObject *watched, QEvent *event)
static Panel * create(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go)
virtual void update_boundingbox(void)
octave::mutex graphics_lock(void)
octave_value get(bool all=false) const
graphics_object get_ancestor(const std::string &type) const
base_properties & get_properties(void)
bool valid_object(void) const
Base class for Octave interfaces that use Qt.
gh_manager & get_gh_manager(void)
Matrix get_boundingbox(bool internal=false, const Matrix &parent_pix_size=Matrix()) const
std::complex< double > w(std::complex< double > z, double relerr=0)
QColor fromRgb(const Matrix &rgb)
template QFont computeFont< uipanel >(const uipanel::properties &props, int height)
QString fromStdString(const std::string &s)
static int frameStyleFromProperties(const uibuttongroup::properties &pp)
static void setupPalette(const uibuttongroup::properties &pp, QPalette &p)
static int borderWidthFromProperties(const uibuttongroup::properties &pp)
std::function< void(octave::interpreter &)> meth_callback
std::function< void(void)> fcn_callback