///////////////////////////////////////////////////
//
//	Contour-tree based isosurfaces
//	version 3.0
//	copyright Hamish Carr
//	February, 2001
//
//	------------------------
//	GLUTStaticText.cpp
//	------------------------
//	
//	A pane that holds a single piece of static text
//
//	Notes:
//	------
//
//
//	Change log:
//	-----------
//	Date:		Changes:
//	-----		--------
//	02/07/01		Initial version
//
///////////////////////////////////////////////////	

#include "GLUTStaticText.h"													//	the header
#include "GLUTString.h"														//	and the font utilities
#include <string.h>															//	C string handling
#include <stdlib.h>															//	C memory handling, &c.
#include <ctype.h>															//	C character utilities
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <stdio.h>

GLUTStaticText::GLUTStaticText(GLUTPane *Parent, const char *text)
	: GLUTPane(text, Parent, StringLength(text) + 2*STATIC_TEXT_BOUNDARY, StringHeight(text) + 2*STATIC_TEXT_BOUNDARY, false, false)
																		//	call pane constructor
	{ // GLUTStaticText()
	theText = (char *) malloc(strlen(text) + 1);									//	allocate memory for a copy of it	
	strcpy(theText, text);													//	copy the string
	} // GLUTStaticText()

GLUTStaticText::~GLUTStaticText()												//	destructor
	{ // ~GLUTStaticText()
	free(theText);															//	get rid of the string
	} // ~GLUTStaticText()

void GLUTStaticText::Display()												//	displays the text
	{ // Display()
	GLfloat textColour[3] = { 0.0, 0.0, 0.0 };									//	we want to draw in black
	glDisable(GL_LIGHTING);													//	turn off lighting
	glDisable(GL_DEPTH_TEST);												//	turn off depth test

	glColor3fv(textColour);													//	switch to the desired text colour

	glMatrixMode(GL_PROJECTION);												//	set the projection matrix
	glLoadIdentity();														//	revert to identity matrix
	glOrtho(0, WindowWidth(), 0, WindowHeight(), -1.0, 1.0);									//	set projection to match viewport
	glViewport(0,0, WindowWidth(), WindowHeight());

	glRasterPos2i(left + STATIC_TEXT_BOUNDARY, bottom + STATIC_TEXT_BOUNDARY + 5);						//	set the raster position
	PrintString(theText);													//	and print the string

	} // Display()
		
void GLUTStaticText::PrintType()												//	prints text string for type
	{ // PrintType()
	printf("GLUTStaticText");
	} // PrintType()	
	
