#pragma once

#include <Utils/Collection.h>
#include <Widgets/Listbox.h>

void NullString(resource::Image * const &, std::string &str) { str=""; }

class ImageList : public widgets::Listbox<resource::Image*, NullString> {
public:

	ImageList() : itemsize(68,68) {
		SetBlueprint(widgets::WR.Listboxes.Picture);
		ItemHeight=68;
		organizer.SetDistance(2);
	}

	void SetItemsize(utils::Size size) {
		itemsize=size;
		ItemHeight=size.Height;
		org();
	}
	
	void SetItemsize(int W, int H) {
		SetItemsize(utils::Size(W,H));
	}
	
	using Listbox::Resize;
    virtual void Resize (utils::Size Size) {
		Listbox::Resize(Size);
		org();
    }

protected:
	utils::Size itemsize;
	
	virtual void itemadded(ItemType &item) {
		item.Icon=item.Value;
	}
	
	void org() {
		int w=panel.GetUsableWidth();
		int cols=(int)std::floor((float)w/itemsize.Width);
		this->setColumns(cols);
	}
};

