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

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

#ifndef DJ_WIDGET_H
#define DJ_WIDGET_H
#include <djLayout.h>
#include <FL/Fl_Group.H>

namespace dj {

// Widget base.
//
class WidgetBase : public LayoutItem {
public:

  WidgetBase();
  virtual ~WidgetBase() = 0;
  virtual void die() {}
  
  // Layout.
  //
  virtual void layout(Layout *);
  Layout * layout() const { return _layout; }
  virtual const Vec2i sizeHint() const;
  virtual void resize(int, int, int, int);

  // Widget.
  //
  virtual void tooltip(const Str &);
  const Str & tooltip() const { return _tooltip; }
  virtual void draw();
  
private:

  Layout * _layout;
  Str _tooltip;
};

// Widget.
//
class Widget : public Fl_Group, public WidgetBase {
public:

  Widget();
  virtual ~Widget();
  
  // Layout.
  //
  virtual const Vec2i sizeHint() const;
  virtual void resize(int, int, int, int);
  virtual int visible() const;
  int frameWidth() const;
  
  // Widget.
  //
  virtual void tooltip(const Str &);
  const Str & tooltip() const { return WidgetBase::tooltip(); }
  virtual void draw();
  virtual int handle(int);

private:

  char * _tooltipAscii;
};

}

#endif
