Exemple #1
0
BOOL WidDispatch::Destroy( HWID& hWid )
{
	std::map<HWID, Widget*>::iterator it =
		m_Handle2Object.find(hWid);
	if (it == m_Handle2Object.end())
	{
		return FALSE;
	}
	Widget* pWid = it->second;
	WFX_CONDITION(pWid != NULL);
	Widget* pParent = pWid->GetParent();
	if (pParent != NULL)
	{
		pParent->RemoveChild(pWid);
	}
	m_Handle2Object.erase(it);
	std::map<HWID, Widget*>::iterator itPaint = 
		m_h2oOrphan.find(hWid);
	if (itPaint != m_h2oOrphan.end())
	{
		m_h2oOrphan.erase(itPaint);
	}
	if (m_h2oCaptured.first == hWid)
	{
		ClearH2O(m_h2oCaptured);
	}
	m_pTimer->Destroy(pWid);
	RecycleHwid(hWid);
	return TRUE;
}
Exemple #2
0
 void Widget::AddChild(const Ptr& w) {
     if (!w) return;
     Widget* parent = w->m_parent;
     if (parent==this) return;
     if (parent) {
         parent->RemoveChild(w);
     }
     w->m_parent = this;
     m_childs.push_back(w);
 }
TEST_FIXTURE(SDL_fixture, AddAndRemove)
{
	UNITTEST_TIME_CONSTRAINT(50);

	CHECK(SDL_init_ok);
	if(SDL_init_ok)
	{
		Widget* w = new Widget();
		Widget* w2 = new Widget();
		Widget* w3 = new Widget();
		w->AddChild(w2);
		w->AddChild(w3);
		CHECK_EQUAL(2, w->GetChildren().size());
		w->RemoveChild(w2);
		CHECK_EQUAL(1, w->GetChildren().size());
		Widget::ClearRoot();
	}
}