/*
Solar Conquest
Copyright (C) 2006 Greg Beaman

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#define MAX_LIST_ITEMS 28

struct ListItem
{
	char text[MAX_STRING_SIZE];
};

class CListBox : public CMenuItem
{
protected:
	ListItem List[MAX_LIST_ITEMS];

public:

	CListBox(int iid, int px, int py, int w, int h);
	virtual ~CListBox();

	void DrawItem(bool selected);
	void DrawItemText(bool selected);

	void Clear();
	void AddItem(char* text);
};

CListBox::CListBox(int iid, int px, int py, int w, int h)
{
	id = iid;

	x = px;
	y = py;
	width = w;
	height = h;
	itemType = MENU_ITEM_LISTBOX;
	strcpy(caption,"");

	nextItem = NULL;

	Clear();
};

CListBox::~CListBox()
{
}

void CListBox::DrawItem(bool selected)
{
/*	if (selected)
		SelectObject(hDC,spenBg);
	else
		SelectObject(hDC,penBg);
	if (selected)
		SelectObject(hDC,sbrushBg);
	else
		SelectObject(hDC,brushBg);

	Rectangle(hDC,x,y,x+width,y+height);
	SelectObject(hDC,penFg);
	SelectObject(hDC,brushFg);
	Rectangle(hDC,x+2,y+2,x+width-2,y+height-2);

	for (int i=0; i < MAX_LIST_ITEMS; i++)
		TextOut(hDC,x+4,(y+2)+(i*15),List[i].text,strlen(List[i].text));
*/
}

void CListBox::DrawItemText(bool selected) {}

void CListBox::Clear()
{
	for (int i=0; i < MAX_LIST_ITEMS; i++)
		strcpy(List[i].text,"");
}

void CListBox::AddItem(char* text)
{
	if (strlen(text) >= MAX_STRING_SIZE)
		return;

	for (int i=0; i < MAX_LIST_ITEMS-1; i++)
		strcpy(List[i].text,List[i+1].text);
	strcpy(List[MAX_LIST_ITEMS-1].text,text);
}