next up previous contents
Next: HashView Up: PuBGo+ Draft Hackers Previous: Iterating for all

GoGui

Sorry but it's to boring to write too much about this. Graphical functionality is provided by a Graphic virtual base class. A machine dependent Graphic is plugged into the GoGui which provides a goboard a streamable text window, GO specific pointing device and key hit menu facilities. It has been kept as minimal as possible to ease porting.

#ifndef _Windows
int main()
     
     // create a graphic to plug into the interface
#ifdef __TURBOC__
     Graphic *graphic=new BorlandGraphic();
#elif defined __WATCOMC__
     Graphic *graphic=new WatcomGraphic();
#else
     Graphic *graphic=new GraphicsX11();
#endif
     
#else
int OWLGoMain(Graphic *graphic)  // Windows entry point 
{

#endif

    // Create generic interface.
    GoGui *gui=new GoGui(graphic);

It is worth pausing for a few seconds because the GoGui is provides us with an example of a BoardView. To get the LowBoard to display what it is doing (someone might be interested?) we register a DisplayView with the board controller. The DisplayView decouples the BoardView from the GoGui.

A DisplayView is derived from the abstract BoardView,

class DisplayView : public BoardView
{
  public:
    DisplayView(GoGuiBase *gui);
    ~DisplayView();
    
    void  move(const GameMove &mv);
    void  takeBack(const GameMove &mv);
    
private:
    GoGuiBase *_gui;
};

This is then registered with the LowBoard using it's controller

 
 LowBoard *board=LowBoard::the();            
 DisplayView *dispView=new DisplayView(gui);
 board->boardController()->addView(dispView);

You can also remove a view should you want

 board->boardController()->removeView(dispView);



P J Leonard
Tue Oct 1 15:25:19 BST 1996