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"))
113 QFrame *frame =
new QFrame (container);
115 new QButtonGroup (frame), frame);
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);
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 ())
166 m_title =
new QLabel (title, frame);
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, SLOT (
show (
void)));
179 QTimer::singleShot (0, buttongroup, SLOT (
show (
void)));
200 switch (xevent->type ())
213 Utils::properties<uibuttongroup> (go);
215 if (pp.fontunits_is (
"normalized"))
217 QFrame *frame = qWidget<QFrame> ();
220 (pp, frame->height ()));
229 case QEvent::MouseButtonPress:
231 QMouseEvent *
m =
dynamic_cast<QMouseEvent *
> (xevent);
233 if (
m->button () == Qt::RightButton)
249 switch (xevent->type ())
252 if (qWidget<QWidget> ()->isVisible ())
273 QFrame *frame = qWidget<QFrame> ();
279 case uibuttongroup::properties::ID_POSITION:
289 case uibuttongroup::properties::ID_BORDERWIDTH:
294 case uibuttongroup::properties::ID_BACKGROUNDCOLOR:
295 case uibuttongroup::properties::ID_FOREGROUNDCOLOR:
296 case uibuttongroup::properties::ID_HIGHLIGHTCOLOR:
297 case uibuttongroup::properties::ID_SHADOWCOLOR:
299 QPalette pal = frame->palette ();
302 frame->setPalette (pal);
308 case uibuttongroup::properties::ID_TITLE:
312 if (title.isEmpty ())
322 QPalette pal = frame->palette ();
324 m_title =
new QLabel (title, frame);
325 m_title->setAutoFillBackground (
true);
326 m_title->setContentsMargins (4, 0, 4, 0);
341 case uibuttongroup::properties::ID_TITLEPOSITION:
345 case uibuttongroup::properties::ID_BORDERTYPE:
350 case uibuttongroup::properties::ID_FONTNAME:
351 case uibuttongroup::properties::ID_FONTSIZE:
352 case uibuttongroup::properties::ID_FONTWEIGHT:
353 case uibuttongroup::properties::ID_FONTANGLE:
362 case uibuttongroup::properties::ID_VISIBLE:
363 frame->setVisible (pp.is_visible ());
367 case uibuttongroup::properties::ID_SELECTEDOBJECT:
406 update (uibuttongroup::properties::ID_POSITION);
419 QFrame *frame = qWidget<QFrame> ();
436 QSize sz =
m_title->sizeHint ();
439 if (pp.titleposition_is (
"lefttop"))
441 else if (pp.titleposition_is (
"righttop"))
442 m_title->move (frame->width () - bw - offset - sz.width (), 0);
443 else if (pp.titleposition_is (
"leftbottom"))
444 m_title->move (bw+offset, frame->height () - sz.height ());
445 else if (pp.titleposition_is (
"rightbottom"))
446 m_title->move (frame->width () - bw - offset - sz.width (),
447 frame->height () - sz.height ());
448 else if (pp.titleposition_is (
"centertop"))
449 m_title->move (frame->width () / 2 - sz.width () / 2, 0);
450 else if (pp.titleposition_is (
"centerbottom"))
451 m_title->move (frame->width () / 2 - sz.width () / 2,
452 frame->height () - sz.height ());
467 connect (btn, SIGNAL (toggled (
bool)), SLOT (
buttonToggled (
bool)));
484 QAbstractButton *checkedBtn =
m_buttongroup->checkedButton ();
490 newValue = checkedObj->
properties ().get___myhandle__ ();
493 if (oldValue != newValue)
512 QAbstractButton *checkedBtn =
m_buttongroup->checkedButton ();
516 if (oldValue != newValue)
521 eventData.
setfield (
"Source", bp.get___myhandle__ ().as_octave_value ());
522 eventData.
setfield (
"EventName",
"SelectionChanged");
525 selectionChangedEventObject);
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
base_properties & properties(void)
virtual Container * innerContainer(void)=0
octave::interpreter & m_interpreter
static Object * parentObject(octave::interpreter &interp, const graphics_object &go)
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 QObject * qObject(void)
virtual void update_boundingbox(void)
virtual void set(const caseless_str &, const octave_value &)
graphics_object get_object(double val) const
octave::mutex graphics_lock(void)
base_properties & get_properties(void)
bool valid_object(void) const
Base class for Octave interfaces that use Qt.
gh_manager & get_gh_manager(void)
octave_value as_octave_value(void) const
void setfield(const std::string &key, const octave_value &val)
octave_handle graphics_handle
std::complex< double > w(std::complex< double > z, double relerr=0)
QColor fromRgb(const Matrix &rgb)
template QFont computeFont< uibuttongroup >(const uibuttongroup::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