26 #if defined (HAVE_CONFIG_H)
32 #include <QMouseEvent>
48 QPalette p =
w->palette ();
50 if (props.style_is (
"edit")
51 || props.style_is (
"listbox"))
53 p.setColor (QPalette::Base,
55 p.setColor (QPalette::Text,
58 else if (props.style_is (
"popupmenu"))
63 QString qss = QString (
"background: %1 none;\n"
65 .arg(bcol.name ()).arg (fcol.name ());
66 w->setStyleSheet(qss);
69 else if (props.style_is (
"radiobutton")
70 || props.style_is (
"checkbox"))
72 p.setColor (QPalette::Button,
74 p.setColor (QPalette::WindowText,
77 else if (props.style_is (
"pushbutton")
78 || props.style_is (
"togglebutton"))
82 QString qss = QString (
"background: %1 none;\n"
84 .arg(bcol.name ()).arg (fcol.name ());
85 w->setStyleSheet(qss);
90 p.setColor (QPalette::Window,
92 p.setColor (QPalette::WindowText,
102 :
Object (oct_qobj, interp, go,
w), m_normalizedFont (false),
103 m_keyPressHandlerDefined (false)
105 qObject ()->setObjectName (
"UIControl");
122 w->setEnabled (up.enable_is (
"on"));
124 w->setVisible (up.is_visible ());
127 w->installEventFilter (
this);
138 update (uicontrol::properties::ID_POSITION);
149 case uicontrol::properties::ID_POSITION:
157 case uicontrol::properties::ID_FONTNAME:
158 case uicontrol::properties::ID_FONTSIZE:
159 case uicontrol::properties::ID_FONTWEIGHT:
160 case uicontrol::properties::ID_FONTANGLE:
164 case uicontrol::properties::ID_FONTUNITS:
171 case uicontrol::properties::ID_BACKGROUNDCOLOR:
172 case uicontrol::properties::ID_FOREGROUNDCOLOR:
176 case uicontrol::properties::ID_ENABLE:
177 w->setEnabled (up.enable_is (
"on"));
180 case uicontrol::properties::ID_TOOLTIPSTRING:
184 case base_properties::ID_VISIBLE:
185 w->setVisible (up.is_visible ());
188 case uicontrol::properties::ID_KEYPRESSFCN:
192 case uicontrol::properties::ID___FOCUS__:
193 if (up.is___focus__ ())
209 switch (xevent->type ())
217 (properties<uicontrol> ()));
221 case QEvent::MouseButtonPress:
225 QMouseEvent *
m =
dynamic_cast<QMouseEvent *
> (xevent);
234 if (
m->button () != Qt::LeftButton || ! up.enable_is (
"on"))
242 "windowbuttondownfcn");
245 if (
m->button () == Qt::RightButton)
250 if (up.style_is (
"listbox"))
262 case QEvent::MouseMove:
263 if (qWidget<QWidget> ()->hasMouseTracking ())
267 QMouseEvent *
m =
dynamic_cast<QMouseEvent *
> (xevent);
276 "windowbuttonmotionfcn");
281 case QEvent::KeyPress:
291 keyData.
getfield (
"Character"),
false);
296 case QEvent::FocusIn:
300 case QEvent::FocusOut:
308 return Object::eventFilter (watched, xevent);
BaseControl(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go, QWidget *w)
void init(QWidget *w, bool callBase=false)
bool eventFilter(QObject *watched, QEvent *e)
bool m_keyPressHandlerDefined
static void executeAt(octave::interpreter &interp, const base_properties &props, const QPoint &pt)
graphics_object object(void) const
octave::interpreter & m_interpreter
void gh_callback_event(const graphics_handle &h, const std::string &name)
void init(QObject *obj, bool callBase=false)
void gh_set_event(const graphics_handle &h, const std::string &name, const octave_value &value)
virtual QObject * qObject(void)
octave::mutex graphics_lock(void)
graphics_object get_ancestor(const std::string &type) const
graphics_handle get_handle(void) const
Base class for Octave interfaces that use Qt.
gh_manager & get_gh_manager(void)
octave_value getfield(const std::string &key) const
Matrix get_boundingbox(bool internal=false, const Matrix &parent_pix_size=Matrix()) const
std::complex< double > w(std::complex< double > z, double relerr=0)
QColor fromRgb(const Matrix &rgb)
template QFont computeFont< uicontrol >(const uicontrol::properties &props, int height)
std::string figureSelectionType(QMouseEvent *event, bool isDoubleClick)
octave_scalar_map makeKeyEventStruct(QKeyEvent *event)
Matrix figureCurrentPoint(const graphics_object &fig, QMouseEvent *event)
QString fromStdString(const std::string &s)
static void updatePalette(const uicontrol::properties &props, QWidget *w)