コード例 #1
0
ファイル: ui_button.cpp プロジェクト: djdron/UnrealSpeccyP
//=============================================================================
//	eButton::Update
//-----------------------------------------------------------------------------
void eButton::Update()
{
	bool change_focus = focused != last_focused;
	eInherited::Update();
	if(changed)
	{
		changed = false;
		eRect sr = ScreenBound();
		DrawRect(sr, focused ? COLOR_FOCUSED : background);
		ePoint cen = sr.Beg() + ePoint(sr.Width() / 2, sr.Height() / 2);
		ePoint t_half((strlen(text) * FontSize().x / 2), FontSize().y / 2);
		eRect r(cen.x - t_half.x, cen.y - t_half.y, cen.x + t_half.x, cen.y + t_half.y);
		DrawText(r, text);
	}
	if(pushed != last_pushed)
	{
		last_pushed = pushed;
		if(triggered && highlight)	DrawRect(ScreenBound(), focused ? COLOR_PUSHED_FOCUSED : COLOR_PUSHED, COLOR_WHITE);
		else			DrawRect(ScreenBound(), focused ? COLOR_FOCUSED : background, COLOR_WHITE);
		Notify(pushed ? N_PUSH : N_POP);
	}
	if(change_focus && triggered && highlight)
	{
		DrawRect(ScreenBound(), focused ? COLOR_PUSHED_FOCUSED : COLOR_PUSHED, COLOR_WHITE);
	}
}
コード例 #2
0
//=============================================================================
//	eList::Update
//-----------------------------------------------------------------------------
void eList::Update()
{
	eRect sr = ScreenBound();
	if(changed)
	{
		DrawRect(sr, background);
		eRect r(sr.left, sr.top, sr.right, sr.top + FontSize().y);
		int i = page_begin;
		for(; items[i]; ++i)
		{
			if(r.bottom > sr.bottom)
				break;
			DrawText(r, items[i]);
			r.Move(ePoint(0, FontSize().y));
		}
		page_size = i - page_begin;
	}
	if((changed || (selected != last_selected)) && page_size)
	{
		eRect cursor(sr.left, 0, sr.right, 0);
		cursor.top = sr.top + (last_selected - page_begin) * FontSize().y;
		cursor.bottom = cursor.top + FontSize().y;
		DrawRect(cursor, background, 0x08ffffff);
		last_selected = selected;
		if(selected < page_begin)
		{
			page_begin = selected;
			changed = true;
			return;
		}
		if(selected >= page_begin + page_size)
		{
			page_begin = selected - page_size + 1;
			changed = true;
			return;
		}
		cursor.top = sr.top + (selected - page_begin) * FontSize().y;
		cursor.bottom = cursor.top + FontSize().y;
		DrawRect(cursor, CURSOR_COLOR, 0x08ffffff);
	}
	changed = false;
}