#ifndef _GL_FORMS_
#define _GL_FORMS_


#include "forms.h"
#include "glcanvas.H"

// --- All global variables associated with a form
// --- Absolutely necessary if we want to open several forms in the same time
template <class FD_NAME> 
class XForms {
public:
  // !!! The array must not disappear in memory before the end !!!
  XForms(FD_NAME* (*cf)(), const int& ngc, DisplayGLCanvas **dispClas)
    { create_form_NAME = cf; numGLcan = ngc;
      GLcan = new GLCan[ngc]; displayClas = dispClas; }

  // Init + handling of mouse and buttons (for first $numGLcanvas$ GL canvases)
  void initFormsInteraction(char *title="MIT Graphics Group"); 
  
  // set up picking functions
  // void setPickingFunctions( int (*select[])(float*, float*, int ) );
  
  // dive into mainLoop
  void mainLoopInteraction(); 
  
  // Access to protected members 
  inline FD_NAME* getFormStruct() { return Xform; } 
  inline FL_FORM* getTheForm()    { return TheForm; } 
  inline void render(const int& n) { GLcan[n].render(); }
  inline void posReset(const int& n) { GLcan[n].posReset(); }
  
protected:
  int                numGLcan;          // number of canvases in the form
  GLCan*             GLcan;             // array of GLCan classes
  DisplayGLCanvas  **displayClas;     // array of display functions for GL canvases
  FD_NAME*      Xform;                 // info about the form, returned after creation
  FD_NAME*      (*create_form_NAME)(); // the create_form function from XFORMS
  FL_FORM*      TheForm;               // equivalent to FL_FORM *NAME in FD_NAME struct
};
//--- end of XForms<> class def



#endif




