#ifndef TEXTCONTAINER_H
#define TEXTCONTAINER_H

#include <stdint.h>
#include "SDL.h"

#include "FormattedText.h"

#include <vector>
#include <string>
using namespace std;

//Make a textbox container.

//This will hold text and display a certain range of lines on it.

//When creating or positioning a TextContainer, you'll need to set up
//Position
//TextContainerSize
//NumberOfLinesPerPage
//FontName
//FontColor (at least 1)

//Optionally:
//Margins
//Line Spacing (recommended in 16ths)
class TextContainer{
 public:
  TextContainer();
  ~TextContainer();

  void clear();

  //position
  void setPositionX (int);
  int getPositionX ();
  void setPositionY (int);
  int getPositionY ();

  //size of the TextContainer itself.
  void setTextContainerWidth(int);
  int getTextContainerWidth();
  void setTextContainerHeight(int);
  int getTextContainerHeight();

  //margins for the text
  void setMarginTop (int);
  int getMarginTop ();
  void setMarginLeft (int);
  int getMarginLeft ();
  void setMarginBottom (int);
  int getMarginBottom ();
  void setMarginRight (int);
  int getMarginRight ();

  //line spacing: How much space to put inbetween each line
  void setLineSpacing(int);
  int getLineSpacing();

  //adding text is handled in shippingHandler, as it relies on graphical dimensions.

  //scrolling text: takes a bool argument to destroy the text. Set it to true to destroy the text you scroll offscreen.
  bool scrollDown(int numLines=1, bool destroyText=false);
  bool scrollUp(int numLines=1, bool destroyText=false);
  bool scrollDownPage(bool destroyText=false);
  bool scrollUpPage(bool destroyText=false);
  void destroyAllText();

  //returns the contents of the formatted text. Necessary for external functions to add text.
  vector <vector<FormattedText> > & getFormattedText();
  void getVisibleText (int & verticalOffset, vector <vector<FormattedText> > :: iterator & startPoint,
                       vector <vector<FormattedText> > :: iterator & endPoint);

  //add colors.
  int addFontColor (int, int, int);
  uint8_t getFontColorR (int);
  uint8_t getFontColorG (int);
  uint8_t getFontColorB (int);
  bool getFontColors (int, uint8_t & r, uint8_t & g, uint8_t & b);

  //number of lines per page
  int getNumberOfLinesPerPage ();
  void setNumberOfLinesPerPage (int);

  //Font Name
  const string & getFontName();
  void setFontName (const string &);

 private:
  vector <vector<FormattedText> > fmt;
  string fontName;
  int posX, posY;
  int marginTop, marginLeft, marginBottom, marginRight;
  int numberOfLinesPerPage;
  int width, height;
  int lineSpacing;
  int lineCursor;
  vector <uint8_t> colorR;
  vector <uint8_t> colorG;
  vector <uint8_t> colorB;
};
#endif
