26#if defined (HAVE_CONFIG_H)
30#include <QAbstractButton>
31#include <QButtonGroup>
36#include <QRadioButton>
60 if (pp.bordertype_is (
"none"))
61 return QFrame::NoFrame;
62 else if (pp.bordertype_is (
"etchedin"))
63 return (QFrame::Box | QFrame::Sunken);
64 else if (pp.bordertype_is (
"etchedout"))
65 return (QFrame::Box | QFrame::Raised);
66 else if (pp.bordertype_is (
"beveledin"))
67 return (QFrame::Panel | QFrame::Sunken);
68 else if (pp.bordertype_is (
"beveledout"))
69 return (QFrame::Panel | QFrame::Raised);
71 return (QFrame::Panel | QFrame::Plain);
77 p.setColor (QPalette::Window,
79 p.setColor (QPalette::WindowText,
81 p.setColor (QPalette::Light,
83 p.setColor (QPalette::Dark,
92 if (! pp.bordertype_is (
"none"))
95 if (pp.bordertype_is (
"etchedin") || pp.bordertype_is (
"etchedout"))
104 octave::interpreter& interp,
const graphics_object& go)
114 QFrame *frame =
new QFrame (container);
116 new QButtonGroup (frame), frame);
124 octave::interpreter& interp,
125 const graphics_object& go,
126 QButtonGroup *buttongroup, QFrame *frame)
127 :
Object (oct_qobj, interp, go, frame), m_hiddenbutton (nullptr),
128 m_container (nullptr), m_title (nullptr), m_blockUpdates (false)
132 frame->setObjectName (
"UIButtonGroup");
133 frame->setAutoFillBackground (
true);
134 Matrix bb = pp.get_boundingbox (
false);
139 QPalette pal = frame->palette ();
141 frame->setPalette (pal);
156 if (frame->hasMouseTracking ())
158 for (
auto *
w : frame->findChildren<
QWidget *> ())
159 w->setMouseTracking (
true);
160 for (
auto *
w : buttongroup->findChildren<
QWidget *> ())
161 w->setMouseTracking (
true);
165 if (! title.isEmpty ())
168 m_title->setAutoFillBackground (
true);
169 m_title->setContentsMargins (4, 0, 4, 0);
174 frame->installEventFilter (
this);
177 if (pp.is_visible ())
179 QTimer::singleShot (0, frame, &QFrame::show);
182 QTimer::singleShot (0, buttongroup, SLOT (
show (
void)));
204 switch (xevent->type ())
210 graphics_object go =
object ();
212 if (go.valid_object ())
217 Utils::properties<uibuttongroup> (go);
219 if (pp.fontunits_is (
"normalized"))
221 QFrame *frame = qWidget<QFrame> ();
224 (pp, frame->height ()));
233 case QEvent::MouseButtonPress:
235 QMouseEvent *m =
dynamic_cast<QMouseEvent *
> (xevent);
237 if (m->button () == Qt::RightButton)
253 switch (xevent->type ())
256 if (qWidget<QWidget> ()->isVisible ())
277 QFrame *frame = qWidget<QFrame> ();
283 case uibuttongroup::properties::ID_POSITION:
285 Matrix bb = pp.get_boundingbox (
false);
293 case uibuttongroup::properties::ID_BORDERWIDTH:
298 case uibuttongroup::properties::ID_BACKGROUNDCOLOR:
299 case uibuttongroup::properties::ID_FOREGROUNDCOLOR:
300 case uibuttongroup::properties::ID_HIGHLIGHTCOLOR:
301 case uibuttongroup::properties::ID_SHADOWCOLOR:
303 QPalette pal = frame->palette ();
306 frame->setPalette (pal);
312 case uibuttongroup::properties::ID_TITLE:
316 if (title.isEmpty ())
326 QPalette pal = frame->palette ();
329 m_title->setAutoFillBackground (
true);
330 m_title->setContentsMargins (4, 0, 4, 0);
345 case uibuttongroup::properties::ID_TITLEPOSITION:
349 case uibuttongroup::properties::ID_BORDERTYPE:
354 case uibuttongroup::properties::ID_FONTNAME:
355 case uibuttongroup::properties::ID_FONTSIZE:
356 case uibuttongroup::properties::ID_FONTWEIGHT:
357 case uibuttongroup::properties::ID_FONTANGLE:
366 case uibuttongroup::properties::ID_VISIBLE:
367 frame->setVisible (pp.is_visible ());
371 case uibuttongroup::properties::ID_SELECTEDOBJECT:
379 graphics_object go = gh_mgr.get_object (h);
387 go.get_properties ().set (
"value", 1);
391 go.get_properties ().set (
"value", 1);
410 update (uibuttongroup::properties::ID_POSITION);
423 QFrame *frame = qWidget<QFrame> ();
425 Matrix bb = pp.get_boundingbox (
true);
436 pp.update_boundingbox ();
440 QSize sz =
m_title->sizeHint ();
443 if (pp.titleposition_is (
"lefttop"))
445 else if (pp.titleposition_is (
"righttop"))
446 m_title->move (frame->width () - bw - offset - sz.width (), 0);
447 else if (pp.titleposition_is (
"leftbottom"))
448 m_title->move (bw+offset, frame->height () - sz.height ());
449 else if (pp.titleposition_is (
"rightbottom"))
450 m_title->move (frame->width () - bw - offset - sz.width (),
451 frame->height () - sz.height ());
452 else if (pp.titleposition_is (
"centertop"))
453 m_title->move (frame->width () / 2 - sz.width () / 2, 0);
454 else if (pp.titleposition_is (
"centerbottom"))
455 m_title->move (frame->width () / 2 - sz.width () / 2,
456 frame->height () - sz.height ());
488 QAbstractButton *checkedBtn =
m_buttongroup->checkedButton ();
494 newValue = checkedObj->
properties ().get___myhandle__ ();
497 if (oldValue != newValue)
516 QAbstractButton *checkedBtn =
m_buttongroup->checkedButton ();
520 if (oldValue != newValue)
525 eventData.
setfield (
"Source", bp.get___myhandle__ ().as_octave_value ());
526 eventData.
setfield (
"EventName",
"SelectionChanged");
529 selectionChangedEventObject);
void redraw(bool sync=false)
Canvas * canvas(const graphics_handle &handle, bool create=true)
virtual Container * innerContainer(void)=0
void gh_callback_event(const graphics_handle &h, const std::string &name)
octave::interpreter & m_interpreter
static Object * fromQObject(QObject *obj)
void gh_set_event(const graphics_handle &h, const std::string &name, const octave_value &value)
virtual QObject * qObject(void)
graphics_object object(void) const
static Object * parentObject(octave::interpreter &interp, const graphics_object &go)
base_properties & properties(void)
Base class for Octave interfaces that use Qt.
octave_value as_octave_value(void) const
void setfield(const std::string &key, const octave_value &val)
OCTAVE_NAMESPACE_BEGIN typedef 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)
QColor fromRgb(const Matrix &rgb)
QString fromStdString(const std::string &s)
T::properties & properties(graphics_object obj)
template QFont computeFont< uibuttongroup >(const uibuttongroup::properties &props, int height)
static int frameStyleFromProperties(const uibuttongroup::properties &pp)
static void setupPalette(const uibuttongroup::properties &pp, QPalette &p)
static int borderWidthFromProperties(const uibuttongroup::properties &pp)