26 #if defined (HAVE_CONFIG_H)
30 #include <QAbstractButton>
31 #include <QButtonGroup>
35 #include <QMouseEvent>
36 #include <QRadioButton>
59 if (pp.bordertype_is (
"none"))
60 return QFrame::NoFrame;
61 else if (pp.bordertype_is (
"etchedin"))
62 return (QFrame::Box | QFrame::Sunken);
63 else if (pp.bordertype_is (
"etchedout"))
64 return (QFrame::Box | QFrame::Raised);
65 else if (pp.bordertype_is (
"beveledin"))
66 return (QFrame::Panel | QFrame::Sunken);
67 else if (pp.bordertype_is (
"beveledout"))
68 return (QFrame::Panel | QFrame::Raised);
70 return (QFrame::Panel | QFrame::Plain);
76 p.setColor (QPalette::Window,
78 p.setColor (QPalette::WindowText,
80 p.setColor (QPalette::Light,
82 p.setColor (QPalette::Dark,
91 if (! pp.bordertype_is (
"none"))
94 if (pp.bordertype_is (
"etchedin") || pp.bordertype_is (
"etchedout"))
103 octave::interpreter& interp,
const graphics_object& go)
113 QFrame *frame =
new QFrame (container);
115 new QButtonGroup (frame), frame);
123 octave::interpreter& interp,
124 const graphics_object& go,
125 QButtonGroup *buttongroup, QFrame *frame)
126 :
Object (oct_qobj, interp, go, frame), m_hiddenbutton (nullptr),
127 m_container (nullptr), m_title (nullptr), m_blockUpdates (false)
131 frame->setObjectName (
"UIButtonGroup");
132 frame->setAutoFillBackground (
true);
133 Matrix bb = pp.get_boundingbox (
false);
138 QPalette pal = frame->palette ();
140 frame->setPalette (pal);
155 if (frame->hasMouseTracking ())
157 for (
auto *
w : frame->findChildren<
QWidget *> ())
158 w->setMouseTracking (
true);
159 for (
auto *
w : buttongroup->findChildren<
QWidget *> ())
160 w->setMouseTracking (
true);
164 if (! title.isEmpty ())
167 m_title->setAutoFillBackground (
true);
168 m_title->setContentsMargins (4, 0, 4, 0);
173 frame->installEventFilter (
this);
176 if (pp.is_visible ())
178 QTimer::singleShot (0, frame, &QFrame::show);
181 QTimer::singleShot (0, buttongroup, SLOT (
show (
void)));
203 switch (xevent->type ())
207 octave::autolock guard (gh_mgr.graphics_lock ());
209 graphics_object go =
object ();
211 if (go.valid_object ())
216 Utils::properties<uibuttongroup> (go);
218 if (pp.fontunits_is (
"normalized"))
220 QFrame *frame = qWidget<QFrame> ();
223 (pp, frame->height ()));
232 case QEvent::MouseButtonPress:
234 QMouseEvent *
m =
dynamic_cast<QMouseEvent *
> (xevent);
236 if (
m->button () == Qt::RightButton)
238 octave::autolock guard (gh_mgr.graphics_lock ());
252 switch (xevent->type ())
255 if (qWidget<QWidget> ()->isVisible ())
257 octave::autolock guard (gh_mgr.graphics_lock ());
276 QFrame *frame = qWidget<QFrame> ();
282 case uibuttongroup::properties::ID_POSITION:
284 Matrix bb = pp.get_boundingbox (
false);
292 case uibuttongroup::properties::ID_BORDERWIDTH:
297 case uibuttongroup::properties::ID_BACKGROUNDCOLOR:
298 case uibuttongroup::properties::ID_FOREGROUNDCOLOR:
299 case uibuttongroup::properties::ID_HIGHLIGHTCOLOR:
300 case uibuttongroup::properties::ID_SHADOWCOLOR:
302 QPalette pal = frame->palette ();
305 frame->setPalette (pal);
311 case uibuttongroup::properties::ID_TITLE:
315 if (title.isEmpty ())
325 QPalette pal = frame->palette ();
328 m_title->setAutoFillBackground (
true);
329 m_title->setContentsMargins (4, 0, 4, 0);
344 case uibuttongroup::properties::ID_TITLEPOSITION:
348 case uibuttongroup::properties::ID_BORDERTYPE:
353 case uibuttongroup::properties::ID_FONTNAME:
354 case uibuttongroup::properties::ID_FONTSIZE:
355 case uibuttongroup::properties::ID_FONTWEIGHT:
356 case uibuttongroup::properties::ID_FONTANGLE:
365 case uibuttongroup::properties::ID_VISIBLE:
366 frame->setVisible (pp.is_visible ());
370 case uibuttongroup::properties::ID_SELECTEDOBJECT:
376 octave::autolock guard (gh_mgr.graphics_lock ());
378 graphics_object go = gh_mgr.get_object (h);
386 go.get_properties ().set (
"value", 1);
390 go.get_properties ().set (
"value", 1);
409 update (uibuttongroup::properties::ID_POSITION);
422 QFrame *frame = qWidget<QFrame> ();
424 Matrix bb = pp.get_boundingbox (
true);
435 pp.update_boundingbox ();
439 QSize sz =
m_title->sizeHint ();
442 if (pp.titleposition_is (
"lefttop"))
444 else if (pp.titleposition_is (
"righttop"))
445 m_title->move (frame->width () - bw - offset - sz.width (), 0);
446 else if (pp.titleposition_is (
"leftbottom"))
447 m_title->move (bw+offset, frame->height () - sz.height ());
448 else if (pp.titleposition_is (
"rightbottom"))
449 m_title->move (frame->width () - bw - offset - sz.width (),
450 frame->height () - sz.height ());
451 else if (pp.titleposition_is (
"centertop"))
452 m_title->move (frame->width () / 2 - sz.width () / 2, 0);
453 else if (pp.titleposition_is (
"centerbottom"))
454 m_title->move (frame->width () / 2 - sz.width () / 2,
455 frame->height () - sz.height ());
480 octave::autolock guard (gh_mgr.graphics_lock ());
486 QAbstractButton *checkedBtn =
m_buttongroup->checkedButton ();
492 newValue = checkedObj->
properties ().get___myhandle__ ();
495 if (oldValue != newValue)
508 octave::autolock guard (gh_mgr.graphics_lock ());
514 QAbstractButton *checkedBtn =
m_buttongroup->checkedButton ();
518 if (oldValue != newValue)
523 eventData.
setfield (
"Source", bp.get___myhandle__ ().as_octave_value ());
524 eventData.
setfield (
"EventName",
"SelectionChanged");
527 selectionChangedEventObject);
void redraw(bool sync=false)
Canvas * canvas(const graphics_handle &handle, bool create=true)
void gh_callback_event(const graphics_handle &h, const std::string &name)
static Object * parentObject(octave::interpreter &interp, const graphics_object &go)
static Object * fromQObject(QObject *obj)
void gh_set_event(const graphics_handle &h, const std::string &name, const octave_value &value)
base_properties & properties(void)
graphics_object object(void) const
virtual QObject * qObject(void)
virtual Container * innerContainer(void)=0
octave::interpreter & m_interpreter
octave_value as_octave_value(void) const
void setfield(const std::string &key, const octave_value &val)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
std::function< void(void)> fcn_callback
std::function< void(interpreter &)> meth_callback
octave_handle graphics_handle
std::complex< double > w(std::complex< double > z, double relerr=0)
template QFont computeFont< uibuttongroup >(const uibuttongroup::properties &props, int height)
QString fromStdString(const std::string &s)
QColor fromRgb(const Matrix &rgb)
T::properties & properties(graphics_object obj)