26#if defined (HAVE_CONFIG_H)
48 QPalette p =
w->palette ();
50 if (props.style_is (
"edit")
51 || props.style_is (
"listbox"))
53 Matrix bg_color = props.get_backgroundcolor_rgb ();
56 if (bg_color(0) == bg_color(1) && bg_color(0) == bg_color(2)
57 && (
std::abs (bg_color(1) - 0.94) < .005))
60 p.setColor (QPalette::Active, QPalette::Base,
62 p.setColor (QPalette::Inactive, QPalette::Base,
64 p.setColor (QPalette::Active, QPalette::Text,
66 p.setColor (QPalette::Inactive, QPalette::Text,
69 else if (props.style_is (
"popupmenu"))
75 QString qss = QString (
":enabled { background: %1 none;\n"
77 .arg(bcol.name ()).arg (fcol.name ());
78 w->setStyleSheet(qss);
81 else if (props.style_is (
"radiobutton")
82 || props.style_is (
"checkbox"))
84 p.setColor (QPalette::Active, QPalette::Button,
86 p.setColor (QPalette::Inactive, QPalette::Button,
88 p.setColor (QPalette::Active, QPalette::WindowText,
90 p.setColor (QPalette::Inactive, QPalette::WindowText,
93 else if (props.style_is (
"pushbutton")
94 || props.style_is (
"togglebutton"))
98 QString qss = QString (
":enabled { background: %1 none;\n"
100 .arg(bcol.name ()).arg (fcol.name ());
101 w->setStyleSheet(qss);
106 p.setColor (QPalette::Active, QPalette::Window,
108 p.setColor (QPalette::Inactive, QPalette::Window,
110 p.setColor (QPalette::Active, QPalette::WindowText,
112 p.setColor (QPalette::Inactive, QPalette::WindowText,
120 octave::interpreter& interp,
121 const graphics_object& go,
QWidget *
w)
122 :
Object (oct_qobj, interp, go,
w), m_normalizedFont (false),
123 m_keyPressHandlerDefined (false)
125 qObject ()->setObjectName (
"UIControl");
137 Matrix bb = up.get_boundingbox (
false);
142 if (up.enable_is (
"inactive"))
143 w->blockSignals (
true);
145 w->setEnabled (up.enable_is (
"on"));
147 w->setVisible (up.is_visible ());
150 w->installEventFilter (
this);
161 update (uicontrol::properties::ID_POSITION);
172 case uicontrol::properties::ID_POSITION:
174 Matrix bb = up.get_boundingbox (
false);
180 case uicontrol::properties::ID_FONTNAME:
181 case uicontrol::properties::ID_FONTSIZE:
182 case uicontrol::properties::ID_FONTWEIGHT:
183 case uicontrol::properties::ID_FONTANGLE:
187 case uicontrol::properties::ID_FONTUNITS:
194 case uicontrol::properties::ID_BACKGROUNDCOLOR:
195 case uicontrol::properties::ID_FOREGROUNDCOLOR:
199 case uicontrol::properties::ID_ENABLE:
200 if (up.enable_is (
"inactive"))
202 w->blockSignals (
true);
203 w->setEnabled (
true);
207 w->blockSignals (
false);
208 w->setEnabled (up.enable_is (
"on"));
212 case uicontrol::properties::ID_TOOLTIPSTRING:
216 case base_properties::ID_VISIBLE:
217 w->setVisible (up.is_visible ());
220 case uicontrol::properties::ID_KEYPRESSFCN:
224 case uicontrol::properties::ID___FOCUS__:
225 if (up.is___focus__ ())
241 switch (xevent->type ())
249 (properties<uicontrol> ()));
253 case QEvent::MouseButtonPress:
257 QMouseEvent *m =
dynamic_cast<QMouseEvent *
> (xevent);
258 graphics_object go =
object ();
260 graphics_object fig = go.get_ancestor (
"figure");
266 if (m->button () != Qt::LeftButton || ! up.enable_is (
"on"))
274 "windowbuttondownfcn");
277 if (m->button () == Qt::RightButton)
282 if (up.style_is (
"listbox"))
294 case QEvent::MouseMove:
295 if (qWidget<QWidget> ()->hasMouseTracking ())
299 QMouseEvent *m =
dynamic_cast<QMouseEvent *
> (xevent);
300 graphics_object go =
object ();
301 graphics_object fig = go.get_ancestor (
"figure");
308 "windowbuttonmotionfcn");
313 case QEvent::KeyPress:
320 graphics_object fig =
object ().get_ancestor (
"figure");
322 emit
gh_set_event (fig.get_handle (),
"currentcharacter",
323 keyData.
getfield (
"Character"),
false);
328 case QEvent::FocusIn:
332 case QEvent::FocusOut:
340 return Object::eventFilter (watched, xevent);
OCTAVE_API Matrix & fill(double val)
bool eventFilter(QObject *watched, QEvent *e)
BaseControl(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go, QWidget *w)
bool m_keyPressHandlerDefined
void init(QWidget *w, bool callBase=false)
void gh_callback_event(const graphics_handle &h, const std::string &name)
octave::interpreter & m_interpreter
void gh_set_event(const graphics_handle &h, const std::string &name, const octave_value &value)
void init(QObject *obj, bool callBase=false)
virtual QObject * qObject(void)
graphics_object object(void) const
Base class for Octave interfaces that use Qt.
octave_value getfield(const std::string &key) const
std::complex< double > w(std::complex< double > z, double relerr=0)
QColor fromRgb(const Matrix &rgb)
QString fromStdString(const std::string &s)
std::string figureSelectionType(QMouseEvent *event, bool isDoubleClick)
T::properties & properties(graphics_object obj)
octave_scalar_map makeKeyEventStruct(QKeyEvent *event)
template QFont computeFont< uicontrol >(const uicontrol::properties &props, int height)
Matrix figureCurrentPoint(const graphics_object &fig, QMouseEvent *event)
static void updatePalette(const uicontrol::properties &props, QWidget *w)