#ifndef _KWINDOW_H
#define _KWINDOW_H

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Output.H>		// for Fl_Input!
#include <FL/Fl_Light_Button.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Simple_Terminal.H>

#include "kbox.h"

using namespace std;

/* ----------------------------------------------------- */

const int WINDOW_WIDTH	= 1600;
const int WINDOW_HEIGHT	= 1000;
const int TAB1		= 25;
const int TAB2		= 225;
const int TAB3		= 1000;
const int TAB4		= 1200;
const int BACKTAB5	= -125;

static string IREG_LABELS[16]
{ "I0            IA","I1            IB",
  "I2            IC","I3            ID",
  "I4           SAR","I5           DAR",
  "I6            OR","I7            IR",
  "I8","I9","I10",
  "I11           ZR",
  "I12           SP","I13           FP",
  "I14           RP","I15           HP" };

static string FREG_LABELS[16]
{ "F0            FA","F1            FB",
  "F2            FC","F3            FD",
  "F4","F5","F6","F7",
  "F8","F9","F10","F11",
  "F12","F13","F14","F15" };

/* ----------------------------------------------------- */

class kwindow_type : public Fl_Window
{
public:
  Fl_Button*		step_button;
  bool			step_button_pushed;

  Fl_Button*		stop_button;
  bool			stop_button_pushed;

  Fl_Button*		run_button;
  bool			run_button_pushed;

  Fl_Button*		memory_button;
  bool			memory_button_pushed;

  Fl_Button*		stack_button;
  bool			stack_button_pushed;

  Fl_Button*		heap_button;
  bool			heap_button_pushed;

  Fl_Box*		i_registers_label;
  Fl_Box*		i_reg_names[16];
  Fl_Box*		i_reg_values[16];

  Fl_Box*		f_registers_label;
  Fl_Box*		f_reg_names[16];
  Fl_Box*		f_reg_values[16];

  Fl_Box*		pc_label;
  Fl_Box*		pc_value;

  Fl_Box*		pc_opcode;
  Fl_Box*		pc_oper1;
  Fl_Box*		pc_oper2;
  Fl_Box*		pc_oper3;

  Fl_Light_Button*	eq_flag;
  Fl_Light_Button*	gt_flag;
  Fl_Light_Button*	lt_flag;

  Fl_Simple_Terminal*	console_display;

/* ----------------------------------------------------- */

  kwindow_type (void);

/* ----------------------------------------------------- */

  void wait_for_step_button (void);

  static void cb_step (Fl_Widget* w,void* d)
  {  ((kwindow_type*)d)->do_step();  }

  void do_step (void);

/* ----------------------------------------------------- */

  void wait_for_stop_button (void);

  static void cb_stop (Fl_Widget* w,void* d)
  {  ((kwindow_type*)d)->do_stop();  };

  void do_stop (void);

/* ----------------------------------------------------- */

  void wait_for_run_button (void);

  static void cb_run (Fl_Widget* w,void* d)
  {  ((kwindow_type*)d)->do_run();  };

  void do_run (void);

/* ----------------------------------------------------- */

  void wait_for_memory_button (void);

  static void cb_memory (Fl_Widget* w,void* d)
  {  ((kwindow_type*)d)->do_memory();  };

  void do_memory (void);

/* ----------------------------------------------------- */

  void wait_for_stack_button (void);

  static void cb_stack (Fl_Widget* w,void* d)
  {  ((kwindow_type*)d)->do_stack(); };

  void do_stack (void);

/* ----------------------------------------------------- */


  void wait_for_heap_button (void);

  static void cb_heap (Fl_Widget* w,void* d)
  {  ((kwindow_type*)d)->do_heap(); };

  void do_heap (void);

/* ----------------------------------------------------- */

  void fedex (klunk,bool&);

  void refresh ();
};

/* ----------------------------------------------------- */

void popup (string prompt,char* buffer);

/* ----------------------------------------------------- */

#endif // _KWINDOW_H
