/* $Id$
This file is part of libmspgltk
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
+#include <msp/gl/immediate.h>
#include <msp/gl/matrix.h>
#include <msp/gl/transform.h>
#include <msp/strings/formatter.h>
visible=v;
- if(!visible && parent)
- parent->child_hidden(*this);
+ signal_visibility_changed.emit(visible);
+}
+
+void Widget::set_focus()
+{
+ if(!parent)
+ throw InvalidState("No parent");
+ if(!visible)
+ throw InvalidState("Can't set focus on invisible widget");
+
+ signal_request_focus.emit();
}
void Widget::render() const
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();
}
on_style_change();
}
-void Widget::set_parent(Panel *p)
+void Widget::set_parent(Container *p)
{
if(parent && p)
- throw InvalidState("Widget is already in a Panel");
+ throw InvalidState("Widget is already in a Container");
parent=p;
on_reparent();
}
-void Widget::set_parent(Widget &w, Panel *p)
+void Widget::set_parent(Widget &w, Container *p)
{
w.set_parent(p);
}