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

#ifndef DJ_DIALOG_H
#define DJ_DIALOG_H
#include <djWindow.h>

namespace dj {

class LabelWidget;
class TextWidget;

// Layout.
//
inline const Vec2i dialogSize() { return Vec2i(300, 100); }

// Dialog base.
//
class DialogBase : public Window {
public:
  
  DialogBase(const Str & title = Str());
  virtual ~DialogBase() = 0;
};

// Message dialog.
//
class MessageDialog : public DialogBase {
public:
  
  MessageDialog(const Str & message = Str());
  
  // Message.
  //
  void set(const Str &);
  const Str get() const;

private:

  DJ_CALLBACK(MessageDialog, closeCallback, bool)

  LabelWidget * _widget;
};

// Question dialog.
//
class QuestionDialog : public DialogBase {
public:
  
  QuestionDialog(const Str & message = Str());
  
  // Message.
  //
  void set(const Str &);
  const Str get() const;
  
  // Signals.
  //
  Signal<bool> & okSig() { return _okSig; }

private:

  DJ_CALLBACK(QuestionDialog, okCallback, bool)
  DJ_CALLBACK(QuestionDialog, closeCallback, bool)

  Signal<bool> _okSig;
  
  LabelWidget * _widget;
};

// Input dialog.
//
class InputDialog : public DialogBase {
public:
  
  InputDialog(const Str & message = Str(), const Str & value = Str());
  
  // Message.
  //
  void set(const Str &);
  const Str get() const;
  
  // Value.
  //
  void value(const Str &);
  const Str value() const;
  
  // Signals.
  //
  Signal<const Str &> & okSig() { return _okSig; }

private:

  DJ_CALLBACK(InputDialog, inputCallback, bool)
  DJ_CALLBACK(InputDialog, okCallback, bool)
  DJ_CALLBACK(InputDialog, closeCallback, bool)

  Signal<const Str &> _okSig;

  LabelWidget * _widget;
  TextWidget * _inputWidget;
};

}

#endif
