#ifndef CACTIVEWIN_H
#define CACTIVEWIN_H

class CActiveWin
{
  CWindow* CurrentWin;
  int Width, Height;

 public:
  CActiveWin(const std::string& caption = std::string(""),
             int width = 500, int height = 500)
    {
      glutInitWindowPosition((glutGet(GLUT_SCREEN_WIDTH) - width) >> 1,
                             (glutGet(GLUT_SCREEN_HEIGHT) - height) >> 1);
      glutInitWindowSize(width, height);
      glutCreateWindow(caption.c_str());

      CurrentWin = 0;
    }

  void operator = (CWindow* NewActive)
    {
      glutSetWindowTitle(NewActive->GetCaption().c_str());
      NewActive->init();
      Activate(NewActive->GetToActivate());
      Width = glutGet(GLUT_WINDOW_WIDTH);
      Height = glutGet(GLUT_WINDOW_HEIGHT);
      glutPostRedisplay();

      CurrentWin = NewActive;
    }

  void Activate(unsigned int Code);
  CWindow* GetCurrentWin() const { return CurrentWin; }
  int GetWidth() const { return Width; }
  void SetWidth(int w) { Width = w; }
  int GetHeight() const { return Height; }
  void SetHeight(int h) { Height = h; }
};

extern CActiveWin* g_Window;

#endif
