+/* $Id$
+
+This file is part of libmspgltk
+Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
#include <msp/gl/matrix.h>
#include <msp/gl/transform.h>
+#include "panel.h"
#include "resources.h"
#include "widget.h"
-#include <iostream>
using namespace std;
namespace Msp {
namespace GLtk {
+Widget::Widget(const Resources &r):
+ res(r),
+ style(0),
+ state(NORMAL),
+ visible(true),
+ parent(0)
+{ }
+
+Widget::~Widget()
+{
+ if(parent)
+ parent->remove(*this);
+}
+
void Widget::set_position(int x, int y)
{
geom.x=x;
GL::pop_matrix();
}
-Widget::Widget(const Resources &r):
- res(r),
- style(0),
- state(NORMAL)
-{ }
-
-void Widget::update_style()
-{
- string sname=get_class();
- if(!style_name.empty())
- {
- sname+='-';
- sname+=style_name;
- }
- style=res.get<Style>(sname);
-}
-
void Widget::render_part(const Part &part) const
{
render_graphic(part);
GL::pop_matrix();
}
+void Widget::update_style()
+{
+ string sname=get_class();
+ if(!style_name.empty())
+ {
+ sname+='-';
+ sname+=style_name;
+ }
+ style=res.get<Style>(sname);
+}
+
+void Widget::set_parent(Panel *p)
+{
+ if(parent && p)
+ throw InvalidState("Widget is already in a Panel");
+ parent=p;
+}
+
+void Widget::set_parent(Widget &w, Panel *p)
+{
+ w.set_parent(p);
+}
+
Widget::Loader::Loader(Widget &w):
wdg(w)
add("position", &Loader::position);
add("size", &Loader::size);
add("style", &Loader::style);
+ add("visible", &Widget::visible);
}
void Widget::Loader::position(int x, int y)