Distributed under the LGPL
*/
+#include <msp/gl/immediate.h>
#include <msp/gl/matrix.h>
#include <msp/gl/transform.h>
#include <msp/strings/formatter.h>
parent->child_hidden(*this);
}
+void Widget::set_focus()
+{
+ if(!parent)
+ throw InvalidState("No parent");
+ if(!visible)
+ throw InvalidState("Can't set focus on invisible widget");
+
+ parent->grab_focus(*this);
+}
+
void Widget::render() const
{
if(!style)
GL::scale_uniform(font_size);
const GL::Color &color=style->get_font_color();
- glColor3f(color.r, color.g, color.b);
- font->draw_string(text);
- glColor3f(1, 1, 1);
+ GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2));
+ imm.color(color.r, color.g, color.b);
+ font->draw_string(text, imm);
GL::pop_matrix();
}
+void Widget::pointer_enter()
+{
+ state|=HOVER;
+}
+
+void Widget::pointer_leave()
+{
+ state&=~HOVER;
+}
+
+void Widget::focus_in()
+{
+ state|=FOCUS;
+}
+
+void Widget::focus_out()
+{
+ state&=~FOCUS;
+}
+
void Widget::update_style()
{
string sname=get_class();