X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fwidget.cpp;h=48b647b71850b464bf8da56f102170d64bc8cf6e;hb=aba0416fb73e17d068b30ff163c2fedcb0254da2;hp=0128367c2b32a6a6c54ae458b3d3a994b38cdf2e;hpb=48fd4db84c4d0b43305d85f74de99eb4fef04fd6;p=libs%2Fgltk.git diff --git a/source/widget.cpp b/source/widget.cpp index 0128367..48b647b 100644 --- a/source/widget.cpp +++ b/source/widget.cpp @@ -5,6 +5,7 @@ Copyright © 2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ +#include #include #include #include @@ -68,6 +69,16 @@ void Widget::set_visible(bool v) 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) @@ -108,13 +119,33 @@ void Widget::render_text(const Part &part, const string &text) 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(); } +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();