/*------------------------------------------------------------------------------
 src/lib/djWidget/djEnumWidget.h

 Copyright (c) 2004-2006 Darby Johnston.
 All rights reserved.
 Use is subject to license terms.
------------------------------------------------------------------------------*/

#ifndef DJ_ENUM_WIDGET_H
#define DJ_ENUM_WIDGET_H
#include <djWidget.h>

class Fl_Choice;

namespace dj {

// Enumeration widget.
//
template <class T>
class EnumWidget : public Widget {
public:

  EnumWidget(const StrList & in = StrList());
  
  // Value.
  //
  void set(T);
  T get() const;
  
  // Menu.
  //
  void menuList(const StrList &);
  const StrList & menuList() const { return _menuList; }
  
  // Signals.
  //
  Signal<T> & sig() { return _sig; }
  
  // Layout.
  //
  const Vec2i sizeHint() const;
  void resize(int, int, int, int);

private:

  DJ_FL_WIDGET_CALLBACK(EnumWidget, widgetCallback)

  void widgetUpdate();

  T _value;
  StrList _menuList;

  Signal<T> _sig;

  Fl_Choice * _widget;
};

}

#include <djEnumWidget_.h>
#endif
