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

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

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

class Fl_Input;
class Fl_Output;

namespace dj {

// Text input widget.
//
class TextWidget : public Widget {
public:

  TextWidget(const Str & = Str());
  
  // Value.
  //
  void set(const Str &);
  const Str & get() const { return _value; }
  
  // Signals.
  //
  Signal<const Str &> & sig() { return _sig; }
  Signal<bool> & actionSig() { return _actionSig; }
  
  // Layout.
  //
  const Vec2i sizeHint() const;
  void resize(int, int, int, int);
  
  // Widget.
  //
  int handle(int);

private:

  void widgetUpdate();

  Str _value;

  Signal<const Str &> _sig;
  Signal<bool> _actionSig;

  Fl_Input * _widget;
};

// Text output widget.
//
class TextDisplayWidget : public Widget {
public:

  TextDisplayWidget(const Str & = Str());
  
  // Value.
  //
  void set(const Str &);
  const Str & get() const { return _value; }
  
  // Layout.
  //
  const Vec2i sizeHint() const;
  void resize(int, int, int, int);

protected:

  Fl_Output * widget() { return _widget; }

private:

  void widgetUpdate();

  Str _value;

  Fl_Output * _widget;
};

}

#endif
