pplugins/pui/container.cpp

60 lines
1.2 KiB
C++

#include <pugl/pugl.h>
#include "pui.h"
Container::~Container()
{
std::list<Widget *>::iterator it;
for (it = children.begin(); it != children.end(); ++it) {
delete *it;
}
}
void Container::OnPaint() const
{
if (this->colour.a) {
glBegin(GL_QUADS);
glColor4f(colour.r, colour.g, colour.b, colour.a);
glVertex2f( x, y);
glVertex2f( x, h + y);
glVertex2f(w + x, h + y);
glVertex2f(w + x, y);
glEnd();
}
/*
glBegin(GL_LINE_LOOP);
glColor3f(0.0, 0.0, 0.0);
glVertex2f( x, y);
glVertex2f( x, h + y);
glVertex2f(w + x, h + y);
glVertex2f(w + x, y);
// glVertex2f( x, y);
glEnd();
*/
std::list<Widget *>::const_iterator it;
for (it = children.begin(); it != children.end(); ++it) {
(*it)->OnPaint();
}
}
Widget *Container::GetWidget(int x, int y)
{
std::list<Widget *>::iterator it;
for (it = children.begin(); it != children.end(); ++it) {
if ((*it)->Hit(x, y)) return (*it)->GetWidget(x, y);
}
return NULL;
}
Widget *Container::GetWidget(uint32_t port)
{
if (this->port == port) return this;
std::list<Widget *>::iterator it;
for (it = children.begin(); it != children.end(); ++it) {
Widget *w = (*it)->GetWidget(port);
if (w) return w;
}
return NULL;
}