Exemplo n.º 1
0
void CLuaGroup::AddLuaWidget(CLuaWidget *w)
{
    if (m_bInitEnable)
    {
        m_bInitEnable = false;
        Enable(true);
    }
    
    // Update each widget's max size, this is necessary before adding new widget because they
    // may request too much width
    const TWidgetList &list = GetWidgetList();
    const int size = SafeConvert<int>(list.size()) + 1; // +1 because new widget is not added yet
    const int maxwidgetsw = NNCurses::GetMaxWidth() - 6;
    const int maxwidth = (maxwidgetsw - (LuaWidgetSpacing() * (size-1))) / size;
    for (TWidgetList::const_iterator it=list.begin(); it!=list.end(); it++)
    {
        CLuaWidget *luaw = dynamic_cast<CLuaWidget *>(*it);
        if (luaw)
            luaw->SetMaxWidth(maxwidth);
    }

    CBox *box = new CBox(VERTICAL, false);
    box->StartPack(w, true, false, 0, 0);
    w->SetMaxWidth(maxwidth);

    StartPack(box, true, true, 0, 0);
}
Exemplo n.º 2
0
		// --------------------------------------------------------------------------------
		Widget::Widget()
		: m_bVisible(true)
		, IFocusable()
		{
			GetWidgetList()->push_back(this);
		}