Esempio n. 1
0
ListBox::ListBox( Framework &fw, Control* Owner, VScrollBar* ExternalScrollBar ) : Control( fw, Owner )
{
	if( ExternalScrollBar == nullptr )
	{
		ConfigureInternalScrollBar();
	} else {
		scroller = ExternalScrollBar;
		scroller_is_internal = false;
	}
}
Esempio n. 2
0
void ListBox::Update()
{
	Control::Update();
	if (scroller == nullptr)
	{
		ConfigureInternalScrollBar();
	}
	if (scroller)
	{
		scroller->Update();
	}
}
Esempio n. 3
0
void ListBox::OnRender()
{
	int offset = 0;
	if (scroller == nullptr)
	{
		ConfigureInternalScrollBar();
	}

	for (auto c = Controls.begin(); c != Controls.end(); c++)
	{
		auto ctrl = *c;
		if (ctrl != scroller)
		{
			switch (ListOrientation)
			{
				case Orientation::Vertical:
					ctrl->Location.x = 0;
					ctrl->Location.y = offset - scroller->GetValue();
					if (ItemSize != 0)
					{
						ctrl->Size.x = (scroller_is_internal ? scroller->Location.x : this->Size.x);
						ctrl->Size.y = ItemSize;
					}
					offset += ctrl->Size.y + ItemSpacing;
					break;
				case Orientation::Horizontal:
					ctrl->Location.x = offset - scroller->GetValue();
					ctrl->Location.y = 0;
					if (ItemSize != 0)
					{
						ctrl->Size.x = ItemSize;
						ctrl->Size.y = (scroller_is_internal ? scroller->Location.y : this->Size.y);
					}
					offset += ctrl->Size.x + ItemSpacing;
					break;
			}
		}
	}
	ResolveLocation();
	switch (ListOrientation)
	{
		case Orientation::Vertical:
			scroller->Maximum = std::max(offset - this->Size.y, scroller->Minimum);
			break;
		case Orientation::Horizontal:
			scroller->Maximum = std::max(offset - this->Size.x, scroller->Minimum);
			break;
	}
	scroller->LargeChange =
	    static_cast<int>(std::max((scroller->Maximum - scroller->Minimum + 2) / 10.0f, 4.0f));
}
Esempio n. 4
0
void ListBox::Clear()
{
	for (auto &c : Controls)
	{
		c->SetParent(nullptr);
	}
	Controls.clear();
	this->selected = nullptr;
	this->hovered = nullptr;
	if (scroller_is_internal)
	{
		ConfigureInternalScrollBar();
	}
	ResolveLocation();
}
Esempio n. 5
0
ListBox::ListBox( Framework &fw, Control* Owner ) : Control( fw, Owner )
{
	ConfigureInternalScrollBar();
}