Game Development Reference
In-Depth Information
public:
enum eSorting
{
Ascending,
Descending
};
listbox(std::shared_ptr<core> core, const std::shared_ptr<DirectX::SpriteFont>& font, const std::shared_ptr<DirectX::SpriteBatch>
spriteBatch)
: control(core, font, spriteBatch)
, m_scrollBar(core, font, spriteBatch)
, m_lastMouseWheelValue(0)
, m_sorting(Descending)
{}
virtual ~listbox();
virtual void Refresh();
virtual bool HandleInput(float deltaTime, const input::input_state& inputState);
virtual void InternalDraw();
protected:
eSorting m_sorting;
scrollbar m_scrollBar;
std::list<listboxitem*> m_items;
std::list<listboxitem*> m_selectedItems;
int m_lastMouseWheelValue;
};
A listbox is a control, a control that will host several items and will allow us to view a sub-
setoftheseitemsatatime.Inadditiontothelistofitems,wealsokeepalistofthoseitems
that have been selected.
void listbox::Refresh()
{
auto backRect = m_rectangle;
m_scrollBar.SetBackgroundColor( render::color::LIGHTGRAY );
m_scrollBar.SetForegroundColor( render::color::GREEN );
if ( m_items.size() > 1 )
{
backRect.Top() = m_rectangle.Top();
backRect.Height() = m_font->GetLineSpacing() * ((m_items.size()/2) );
m_scrollBar.Visible() = true;
}
else
{
m_scrollBar.Visible() = false;
}
Search WWH ::




Custom Search