// C++ code Copyright (C) David R. Evans G4AMJ/NQ0I

//  surface class

#ifndef SURF_WINH
#define SURF_WINH

#include <canvas31.h>
#include <gf_win.h>
#include <DREstring.h>
#include <surface.h>

#include <stdio.h>
#include <iostream.h>

class windows31 : public surface
{ friend class windows_mode;

protected:
  boolean _autoupdate;
  int curx, cury;
  popup* cwp;
  popup& canvas;
  HBITMAP _hbm;
  char _print_device[32], _print_driver[9], _print_port[80];

public:
  windows31(popup* c, boolean autoupdate = true);
  virtual ~windows31(void)
    { }

  void batch_off(void)
    { update(); }

// necessary functions
  surface& operator<<(LINE&);
  surface& operator<<(dot&);
  surface& operator<<(text&);

  void moveto(const int x, const int y);
  void flush(void);
  int width(void)
    { return canvas.width(); }
  int height(void)
    { return canvas.height(); }
  void clear(void);
  virtual boolean hardcopy(void)
    { return false; }

  inline int usable_top(void)
    { return 0; }
  inline int usable_bottom(void) 
    { return cwp->Attr.H  - GetSystemMetrics(SM_CYCAPTION) - 1; }
  inline int usable_left(void)
    { return 0; }
  inline int usable_right(void)
    { return cwp->Attr.W - 1; }

  void invert(void);
  void update(void)
    { cwp->update(); }

  void print(const char* printer_name = "");
  
// set printer characteristics
  inline windows31& print_device(const char* dev)
    { strcpy(_print_device, dev); return *this; }

  inline windows31& print_driver(const char* driv)
    { strcpy(_print_driver, driv); return *this; }

  inline windows31& print_port(const char* port)
    { strcpy(_print_port, port); return *this; }
};

// the only difference between a screen and a printer in Windows is
// that the latter produces a hard copy.
class windows_printer : public windows31
{
public:
  windows_printer(popup* c, boolean autoupdate = true)
    : windows31(c, autoupdate)
    { }

  boolean hardcopy(void)
    { return true; }
};

#endif



