#include "GL/TextView.h"
#include "GL/Font.h"
#include "GL/ImmediateMode.h"
BEGIN_NAMESPACE
template <typename T>
void TreeView<T>::draw()
{
drawPanel();
const int fontSize = 14;
int row = 1;
int xOff = 0;
// std::vector<std::pair<int,const std::vector<const T*> > > objectTreeStack;
std::vector<std::pair<int, std::vector<const T*> > > objectTreeStack;
// objectTreeStack.push_back(std::pair<int,const std::vector<const T*> >(0, m_root->children()));
//Object* root = m_root;
objectTreeStack.push_back(std::pair<int,std::vector<const T*> >(0, m_root->children()));
while (objectTreeStack.size())
{
int i = objectTreeStack.back().first;
//std::vector<const T*> childList = objectTreeStack.back().second;
std::vector<const T*> childList = objectTreeStack.back().second;
if ( (size_t)i == childList.size() ) {
objectTreeStack.pop_back();
xOff -= 10;
} else {
glDrawText(xOff+x+8+1, y+30+row*20, childList[i]->text(), 0xff000000, 0xffffffff, fontSize);
objectTreeStack.back().first = i + 1;
if ( childList[i]->hasChildren() ) {
//objectTreeStack.push_back(std::pair<int,const std::vector<const T*> >(0, childList[i]->children()));
objectTreeStack.push_back(std::pair<int, std::vector<const T*> >(0, childList[i]->children()));
xOff += 10;
}
row++;
}
}
}
END_NAMESPACE