26 #if defined (HAVE_CONFIG_H)
33 #include <QMouseEvent>
52 if (pp.bordertype_is (
"none"))
53 return QFrame::NoFrame;
54 else if (pp.bordertype_is (
"etchedin"))
55 return (QFrame::Box | QFrame::Sunken);
56 else if (pp.bordertype_is (
"etchedout"))
57 return (QFrame::Box | QFrame::Raised);
58 else if (pp.bordertype_is (
"beveledin"))
59 return (QFrame::Panel | QFrame::Sunken);
60 else if (pp.bordertype_is (
"beveledout"))
61 return (QFrame::Panel | QFrame::Raised);
63 return (QFrame::Panel | QFrame::Plain);
69 p.setColor (QPalette::Window,
71 p.setColor (QPalette::WindowText,
73 p.setColor (QPalette::Light,
75 p.setColor (QPalette::Dark,
84 if (! pp.bordertype_is (
"none"))
87 if (pp.bordertype_is (
"etchedin") || pp.bordertype_is (
"etchedout"))
95 Panel::create (octave::base_qobject& oct_qobj, octave::interpreter& interp,
96 const graphics_object& go)
105 return new Panel (oct_qobj, interp, go,
new QFrame (container));
111 Panel::Panel (octave::base_qobject& oct_qobj, octave::interpreter& interp,
112 const graphics_object& go, QFrame *frame)
113 :
Object (oct_qobj, interp, go, frame), m_container (nullptr),
114 m_title (nullptr), m_blockUpdates (false),
115 m_previous_bbox (
Matrix (1, 4, 0))
119 frame->setObjectName (
"UIPanel");
120 frame->setAutoFillBackground (
true);
121 Matrix bb = pp.get_boundingbox (
false);
126 QPalette pal = frame->palette ();
128 frame->setPalette (pal);
139 if (frame->hasMouseTracking ())
141 for (
auto *
w : frame->findChildren<
QWidget *> ())
142 w->setMouseTracking (
true);
146 if (! title.isEmpty ())
149 m_title->setAutoFillBackground (
true);
150 m_title->setContentsMargins (4, 0, 4, 0);
155 frame->installEventFilter (
this);
158 graphics_object fig (go.get_ancestor (
"figure"));
159 if (! fig.get (
"keypressfcn").isempty ())
162 if (! fig.get (
"keyreleasefcn").isempty ())
165 if (pp.is_visible ())
166 QTimer::singleShot (0, frame, &QFrame::show);
183 switch (xevent->type ())
187 octave::autolock guard (gh_mgr.graphics_lock ());
189 graphics_object go =
object ();
191 if (go.valid_object ())
196 Utils::properties<uipanel> (go);
198 if (pp.fontunits_is (
"normalized"))
200 QFrame *frame = qWidget<QFrame> ();
203 (pp, frame->height ()));
212 case QEvent::MouseButtonPress:
214 QMouseEvent *
m =
dynamic_cast<QMouseEvent *
> (xevent);
216 if (
m->button () == Qt::RightButton)
218 octave::autolock guard (gh_mgr.graphics_lock ());
220 graphics_object go =
object ();
222 if (go.valid_object ())
224 go.get_properties (),
236 switch (xevent->type ())
239 if (qWidget<QWidget> ()->isVisible ())
241 octave::autolock guard (gh_mgr.graphics_lock ());
243 graphics_object go =
object ();
245 if (go.valid_object ())
246 go.get_properties ().update_boundingbox ();
263 QFrame *frame = qWidget<QFrame> ();
269 case uipanel::properties::ID_POSITION:
271 Matrix bb = pp.get_boundingbox (
false);
285 case uipanel::properties::ID_BORDERWIDTH:
290 case uipanel::properties::ID_BACKGROUNDCOLOR:
291 case uipanel::properties::ID_FOREGROUNDCOLOR:
292 case uipanel::properties::ID_HIGHLIGHTCOLOR:
293 case uipanel::properties::ID_SHADOWCOLOR:
295 QPalette pal = frame->palette ();
298 frame->setPalette (pal);
304 case uipanel::properties::ID_TITLE:
308 if (title.isEmpty ())
318 QPalette pal = frame->palette ();
321 m_title->setAutoFillBackground (
true);
322 m_title->setContentsMargins (4, 0, 4, 0);
337 case uipanel::properties::ID_TITLEPOSITION:
341 case uipanel::properties::ID_BORDERTYPE:
346 case uipanel::properties::ID_FONTNAME:
347 case uipanel::properties::ID_FONTSIZE:
348 case uipanel::properties::ID_FONTWEIGHT:
349 case uipanel::properties::ID_FONTANGLE:
358 case uipanel::properties::ID_VISIBLE:
359 frame->setVisible (pp.is_visible ());
373 update (uipanel::properties::ID_POSITION);
385 QFrame *frame = qWidget<QFrame> ();
387 Matrix bb = pp.get_boundingbox (
true);
398 pp.update_boundingbox ();
402 QSize sz =
m_title->sizeHint ();
405 if (pp.titleposition_is (
"lefttop"))
407 else if (pp.titleposition_is (
"righttop"))
408 m_title->move (frame->width () - bw - offset - sz.width (), 0);
409 else if (pp.titleposition_is (
"leftbottom"))
410 m_title->move (bw+offset, frame->height () - sz.height ());
411 else if (pp.titleposition_is (
"rightbottom"))
412 m_title->move (frame->width () - bw - offset - sz.width (),
413 frame->height () - sz.height ());
414 else if (pp.titleposition_is (
"centertop"))
415 m_title->move (frame->width () / 2 - sz.width () / 2, 0);
416 else if (pp.titleposition_is (
"centerbottom"))
417 m_title->move (frame->width () / 2 - sz.width () / 2,
418 frame->height () - sz.height ());
OCTAVE_END_NAMESPACE(octave)
static int frameStyleFromProperties(const uipanel::properties &pp)
static int borderWidthFromProperties(const uipanel::properties &pp)
static void setupPalette(const uipanel::properties &pp, QPalette &p)
void redraw(bool sync=false)
Canvas * canvas(const graphics_handle &handle, bool create=true)
static Object * parentObject(octave::interpreter &interp, const graphics_object &go)
virtual void do_connections(const QObject *receiver, const QObject *emitter=nullptr)
graphics_object object(void) const
virtual QObject * qObject(void)
virtual Container * innerContainer(void)=0
octave::interpreter & m_interpreter
void do_connections(const QObject *receiver, const QObject *emitter=nullptr)
static Panel * create(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go)
bool eventFilter(QObject *watched, QEvent *event)
Panel(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go, QFrame *frame)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
std::function< void(void)> fcn_callback
std::function< void(interpreter &)> meth_callback
std::complex< double > w(std::complex< double > z, double relerr=0)
template QFont computeFont< uipanel >(const uipanel::properties &props, int height)
QString fromStdString(const std::string &s)
QColor fromRgb(const Matrix &rgb)
T::properties & properties(graphics_object obj)