#ifndef __CONTROLS_H
#define __CONTROLS_H

#ifndef __STRINGS_H
#include <strings.h>
#endif

WINDOW xvt_create_checkbox(
  short left, short top, short right, short bottom,
  const char* caption,
  WINDOW parent,
  long flags,
  long app_data,
  int id
  );

  WINDOW xvt_create_radiobutton(
    short left, short top, short right, short bottom,
    const char* caption,
    WINDOW parent,
    long flags,
    long app_data,
    int id
    );

    WINDOW xvt_create_pushbutton(
      short left, short top, short right, short bottom,
      const char* caption,
      WINDOW parent,
      long flags,
      long app_data,
      int id
      );

      WINDOW xvt_create_text(
        short left, short top, short right, short bottom,
        const char* caption,
        WINDOW parent,
        long flags,
        long app_data,
        int id
        );

        WINDOW xvt_create_groupbox(
          short left, short top, short right, short bottom,
          const char* caption,
          WINDOW parent,
          long flags,
          long app_data,
          int id
          );

          void free_controls_bmp();

          ///////////////////////////////////////////////////////////
          // Custom control
          ///////////////////////////////////////////////////////////

          class TControl
{
  WINDOW _win;
  short _id;
  TString _caption;
  COLOR _color, _backcolor;

  bool _disabled : 1;
  bool _checked  : 1;
  bool _focused  : 1;
  bool _multiple : 1;

protected:
  static long XVT_CALLCONV1 handler(WINDOW win, EVENT* ep);

  void create(short left, short top, short right, short bottom,
              const char* caption,
              WINDOW parent, long flags, long app_data, short id);

  virtual void update() const pure;
  virtual void mouse_down(PNT) {};
  virtual void mouse_up() {};
  virtual WIN_TYPE type() const { return W_NO_BORDER; }

public:
  static TControl* WINDOW2TControl(WINDOW win);
  virtual ~TControl();

  WINDOW win() const { return _win; }
  short id() const { return _id; }
  const char* caption() const { return _caption; }
  void set_caption(const char* c);
  
  COLOR color() const { return _color; }
  void set_color(COLOR c) { _color = c; }
  
  COLOR back_color() const { return _backcolor; }
  void set_back_color(COLOR c) { _backcolor = c; }

  bool checked() const { return _checked; }
  virtual void check(bool on);

  bool disabled() const { return _disabled; }
  void enable(bool on);

  bool focused() const { return _focused; }
  void focus(bool on) { _focused = on; }

  bool multiple() const { return _multiple; }
};

#endif