Example #1
0
void Gauge::Draw()
{
	const Point activeOffset(GetActiveOffset());
	const Point activeArea(GetActiveArea());

	Context *c = GetContext();
	const Skin &s = c->GetSkin();

	s.DrawGaugeBackground(activeOffset, activeArea);

	if (m_value > 0.0f) {
		s.DrawGaugeMask(activeOffset, activeArea);

		const Point size(activeArea.x * m_value, activeArea.y);

		switch (m_style) {
			case NORMAL:
				s.DrawGaugeFillNormal(activeOffset, size);
				break;
			case WARNING:
				s.DrawGaugeFillWarning(activeOffset, size);
				break;
			case CRITICAL:
				s.DrawGaugeFillCritical(activeOffset, size);
				break;
		}
	}
}
Example #2
0
List *List::AddOption(const std::string &text)
{
	m_options.push_back(text);

	Context *c = GetContext();

	VBox *vbox = static_cast<VBox*>(m_container->GetInnerWidget());

	int index = m_optionBackgrounds.size();

	ColorBackground *background = c->ColorBackground(Color(0,0,0, m_selected == index ? c->GetSkin().AlphaSelect_ub() : c->GetSkin().AlphaNormal_ub()));
	vbox->PackEnd(background->SetInnerWidget(c->Label(text)));

	background->onMouseOver.connect(sigc::bind(sigc::mem_fun(this, &List::HandleOptionMouseOver), index));
	background->onMouseOut.connect(sigc::bind(sigc::mem_fun(this, &List::HandleOptionMouseOut), index));
	background->onClick.connect(sigc::bind(sigc::mem_fun(this, &List::HandleOptionClick), index));

	m_optionBackgrounds.push_back(background);

	GetContext()->RequestLayout();

	return this;
}