26 #if defined (HAVE_CONFIG_H)
32 #include <QMouseEvent>
47 QPalette p =
w->palette ();
49 if (props.style_is (
"edit")
50 || props.style_is (
"listbox"))
52 Matrix bg_color = props.get_backgroundcolor_rgb ();
55 if (bg_color(0) == bg_color(1) && bg_color(0) == bg_color(2)
56 && (
std::abs (bg_color(1) - 0.94) < .005))
59 p.setColor (QPalette::Active, QPalette::Base,
61 p.setColor (QPalette::Inactive, QPalette::Base,
63 p.setColor (QPalette::Active, QPalette::Text,
65 p.setColor (QPalette::Inactive, QPalette::Text,
68 else if (props.style_is (
"popupmenu"))
74 QString qss = QString (
":enabled { background: %1 none;\n"
76 .arg(bcol.name ()).arg (fcol.name ());
77 w->setStyleSheet(qss);
80 else if (props.style_is (
"radiobutton")
81 || props.style_is (
"checkbox"))
83 p.setColor (QPalette::Active, QPalette::Button,
85 p.setColor (QPalette::Inactive, QPalette::Button,
87 p.setColor (QPalette::Active, QPalette::WindowText,
89 p.setColor (QPalette::Inactive, QPalette::WindowText,
92 else if (props.style_is (
"pushbutton")
93 || props.style_is (
"togglebutton"))
97 QString qss = QString (
":enabled { background: %1 none;\n"
99 .arg(bcol.name ()).arg (fcol.name ());
100 w->setStyleSheet(qss);
105 p.setColor (QPalette::Active, QPalette::Window,
107 p.setColor (QPalette::Inactive, QPalette::Window,
109 p.setColor (QPalette::Active, QPalette::WindowText,
111 p.setColor (QPalette::Inactive, QPalette::WindowText,
119 octave::interpreter& interp,
120 const graphics_object& go,
QWidget *
w)
121 :
Object (oct_qobj, interp, go,
w), m_normalizedFont (false),
122 m_keyPressHandlerDefined (false)
124 qObject ()->setObjectName (
"UIControl");
136 Matrix bb = up.get_boundingbox (
false);
141 if (up.enable_is (
"inactive"))
142 w->blockSignals (
true);
144 w->setEnabled (up.enable_is (
"on"));
146 w->setVisible (up.is_visible ());
149 w->installEventFilter (
this);
160 update (uicontrol::properties::ID_POSITION);
171 case uicontrol::properties::ID_POSITION:
173 Matrix bb = up.get_boundingbox (
false);
179 case uicontrol::properties::ID_FONTNAME:
180 case uicontrol::properties::ID_FONTSIZE:
181 case uicontrol::properties::ID_FONTWEIGHT:
182 case uicontrol::properties::ID_FONTANGLE:
186 case uicontrol::properties::ID_FONTUNITS:
193 case uicontrol::properties::ID_BACKGROUNDCOLOR:
194 case uicontrol::properties::ID_FOREGROUNDCOLOR:
198 case uicontrol::properties::ID_ENABLE:
199 if (up.enable_is (
"inactive"))
201 w->blockSignals (
true);
202 w->setEnabled (
true);
206 w->blockSignals (
false);
207 w->setEnabled (up.enable_is (
"on"));
211 case uicontrol::properties::ID_TOOLTIPSTRING:
215 case base_properties::ID_VISIBLE:
216 w->setVisible (up.is_visible ());
219 case uicontrol::properties::ID_KEYPRESSFCN:
223 case uicontrol::properties::ID___FOCUS__:
224 if (up.is___focus__ ())
240 switch (xevent->type ())
245 octave::autolock guard (gh_mgr.graphics_lock ());
248 (properties<uicontrol> ()));
252 case QEvent::MouseButtonPress:
254 octave::autolock guard (gh_mgr.graphics_lock ());
256 QMouseEvent *
m =
dynamic_cast<QMouseEvent *
> (xevent);
257 graphics_object go =
object ();
259 graphics_object fig = go.get_ancestor (
"figure");
265 if (
m->button () != Qt::LeftButton || ! up.enable_is (
"on"))
273 "windowbuttondownfcn");
276 if (
m->button () == Qt::RightButton)
281 if (up.style_is (
"listbox"))
293 case QEvent::MouseMove:
294 if (qWidget<QWidget> ()->hasMouseTracking ())
296 octave::autolock guard (gh_mgr.graphics_lock ());
298 QMouseEvent *
m =
dynamic_cast<QMouseEvent *
> (xevent);
299 graphics_object go =
object ();
300 graphics_object fig = go.get_ancestor (
"figure");
307 "windowbuttonmotionfcn");
312 case QEvent::KeyPress:
315 octave::autolock guard (gh_mgr.graphics_lock ());
319 graphics_object fig =
object ().get_ancestor (
"figure");
321 emit
gh_set_event (fig.get_handle (),
"currentcharacter",
322 keyData.
getfield (
"Character"),
false);
327 case QEvent::FocusIn:
331 case QEvent::FocusOut:
339 return Object::eventFilter (watched, xevent);
static void updatePalette(const uicontrol::properties &props, QWidget *w)
bool eventFilter(QObject *watched, QEvent *e)
bool m_keyPressHandlerDefined
BaseControl(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go, QWidget *w)
void init(QWidget *w, bool callBase=false)
OCTAVE_API Matrix & fill(double val)
void gh_callback_event(const graphics_handle &h, const std::string &name)
void gh_set_event(const graphics_handle &h, const std::string &name, const octave_value &value)
graphics_object object(void) const
virtual QObject * qObject(void)
octave::interpreter & m_interpreter
void init(QObject *obj, bool callBase=false)
octave_value getfield(const std::string &key) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
std::complex< double > w(std::complex< double > z, double relerr=0)
Matrix figureCurrentPoint(const graphics_object &fig, QMouseEvent *event)
QString fromStdString(const std::string &s)
octave_scalar_map makeKeyEventStruct(QKeyEvent *event)
template QFont computeFont< uicontrol >(const uicontrol::properties &props, int height)
std::string figureSelectionType(QMouseEvent *event, bool isDoubleClick)
QColor fromRgb(const Matrix &rgb)
T::properties & properties(graphics_object obj)