#ifndef MAZEDISP03_H
#define MAZEDISP03_H

#include <buttonpanel02.h>
#include <cellD2.h>
#include <gobj.h>
#include <graphicsImmediateDeferredSwitch.h>
#include <mazegameD2state01.h>
#include <point.h>
#include <zprmouse.h>

class mazedisp03;

/*!
\brief Iterate over mazematrixD2 as a matrix drawing
 each cell.

Interprets mazematrixD2 as a m by n matrix,
 iterating over each cell and drawing it.
*/
class mazedisp03 : public gobj

{
public:

  /** Contains all the graphics. */
  graphicsImmediateDeferredSwitch gx;

  /** Index into gx for static geometry. */
  uint staticgraphicsindex;

  /** Maze game. */
  mazegameD2state01 & mg;

  /** Square cell side length. */ 
  double dx;
  /** Display the cells id. */
  bool displaycellid;
  /** Instead of drawing the walls, draw the paths. */
  bool pipes;
  /** Color of pipes. */
  point3<double> pipecolor;
  /** Display the walls. */
  bool walls;
  /** Color of cell walls. */
  point3<double> wallcolor;
  /** Initial translation of maze. */
  point2<double> origin;
  /** Background color. */
  point3<double> backgroundcolor;
  /** Size of start and finish spheres. */
  double endpointratio;
  /** Start and finish sphere color. */
  point3<double> endpointcolor;
  /** Current position and path color. */
  point3<double> currentposcolor;

  /** Default maze draw. */
  mazedisp03( mazegameD2state01 & mg_);
  /** Cleanup. */
  ~mazedisp03();

  /** Draws to the global graphics stream. */
  void draw();

  /** Build the static geometry and add dynamic geometry. */
  void construct();

  /** Geometry which does not change. */
  void staticgraphics();

  /** Processes mouse event. */
  void mouseevent();
  /** Functional object calling mouse(zpr&) */
  fnobj0Tfn<mazedisp03,void> mousecallback;
  zprmouse* zm;
  /** Movement buttons. */
  buttonpanel02* bp02;
  
  /** Draw cell. */
  void celldraw
  ( 
    cellD2<uint> const & x,
    point2<double> const & p
  );

  /** Draw cell with path istead of walls. */
  void celldraw2
  ( 
    cellD2<uint> const & x,
    point2<double> const & p
  );

  /** Default settings for game01. */
  void game01default();

  /** This class's command line settings. */
  stringc settings() const;

  /** Get the midpoint of the cell given the cells id. */
  point2<double> const cellmidpoint(uintc id) const;

  void currentposdraw();

  void f01();

};


#endif


