// -*- c++ -*-
#ifndef _GRAPH_H
#define _GRAPH_H

#ifdef USE_XVIEW
#include <xview/xview.h>
#undef coord
#endif
#ifdef USE_XT
#include <X11/Intrinsic.h>
#endif

#include "list.h"
#include "mytypes.h"

class MsgQ;
class PixmapInfo;

class Graphics
{
public:
  virtual ~Graphics() {}

  virtual void MainLoop() = 0;

  // displays a choice box, calls f with ptr to string which was selected
  virtual void CreateChoiceFrame(char *mesg, List<charp> choices,
				 ChoiceHandlerFunc f, void *client_data) = 0;
  
  // pop up a message box, calls the f when the user clicks ok
  virtual void DispMessageBox(char *mesg, MessageHandlerFunc f, void *data) = 0;
  
  virtual class MapDisplay *CreateMapDisplay() = 0;
  virtual class MapDisplay *CreateMapDisplay(class World *W, class Player *p) = 0;
  virtual class CityDisplay *CreateCityDisplay(class City *city, class Player *owner) = 0;
  virtual class TextDisplay *CreateTextDisplay(int x, int y) = 0;

  virtual int AllocColor(char *name) = 0;
  virtual PixmapInfo *CompilePixmap(char **pixmap) = 0;
  virtual void FreePixmap(PixmapInfo *handle) = 0;
  virtual void GetPixmapInfo(PixmapInfo *handle, int &w, int &h) = 0;

  // this function starts up an event driven loop and calls the handler
  // which you specified whenever some event occurs
  // event's are either keypresses or data arriving on the socket
  virtual void StartUp() = 0; // will not return

  virtual void StartTimer(int which, unsigned long milli, HandlerFunc func, void *client_data) =0;
  virtual void StopTimer(int which) = 0;

  // add a notify handler for data available on a fd
  virtual void AddReadNotify(int fd, readNotifyFunc func, int info = 0, int q = 1) = 0;

#ifdef USE_XT
  friend void ReadNotify(XtPointer clt, int* fd_p, XtInputId* id);
#elif defined (USE_XVIEW)
  friend Notify_value ReadNotify(Notify_client client, int fd);
  friend Notify_value TimerNotify(...);
#endif

protected:
  HandlerFunc Timers[3];			  // upto three timer handlers
  ReadHandler **readHandlers;
};

#endif
