// Aseprite UI Library
// Copyright (C) 2001-2016  David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.

#ifndef UI_LISTBOX_H_INCLUDED
#define UI_LISTBOX_H_INCLUDED
#pragma once

#include "obs/signal.h"
#include "ui/widget.h"

namespace ui {

  class ListItem;

  class ListBox : public Widget {
  public:
    ListBox();

    Widget* getSelectedChild();
    int getSelectedIndex();

    void selectChild(Widget* item);
    void selectIndex(int index);

    std::size_t getItemsCount() const;

    void makeChildVisible(Widget* item);
    void centerScroll();
    void sortItems();

    obs::signal<void()> Change;
    obs::signal<void()> DoubleClickItem;

  protected:
    virtual bool onProcessMessage(Message* msg) override;
    virtual void onPaint(PaintEvent& ev) override;
    virtual void onResize(ResizeEvent& ev) override;
    virtual void onSizeHint(SizeHintEvent& ev) override;
    virtual void onChange();
    virtual void onDoubleClickItem();
  };

} // namespace ui

#endif
