#ifndef TEXTFEEDER_H
#define TEXTFEEDER_H

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

#include "Button.h"
#include "FormattedText.h"
#include "../graphics/GraphicTransformation.h"

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

//Make a textbox feeder.

//Its contents can be edited on the fly, by line.
//You can feed unlimited text, the feeder will break it up by line.

//Set its dimensions upon creation.
//Give option to scroll down.
//Give option to fill: empties all text and loads next set of text.
//Make a stack of text.
//Give option to hold lines of text.

class TextFeeder: public Button{
 public:
  TextFeeder();
  ~TextFeeder();

  //set graphic
  const string & getGraphicFrame();
  void setGraphicFrame (const string &);

  //modify text.
  bool scrollToNextLine (); //scrolls text 1 line forward.
  void scrollToNextFill (); //clears current text from window and fills with new text.
  void empty (); //empties all text.
  void holdFirstLinesOfText (uint8_t); //holds the first lines of text, preventing it from being wiped or scrolled.

  //gets the iterators that contain the text that is visibly contained in the LineFeeder
  void getCurrentText(vector <FormattedText> :: iterator & fmtIterStart,
                      vector <FormattedText> :: iterator & fmtIterEnd);

  vector <FormattedText> & getFormattedText();

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

  void setGraphicTransformation (GraphicTransformation & g);
  GraphicTransformation & getGraphicTransformation ();

  //number of lines
  int getNumberOfLines ();
  void setNumberOfLines (int);

  //dirty bit
  bool getDirtyBit();
  void setDirtyBit(bool);

 private:
  vector <FormattedText> :: iterator getNextLine (vector <FormattedText> :: iterator);

  bool dirty;
  int numberOfLines;
  GraphicTransformation gt;
  string graphicFrame;
  uint8_t numHeldLines;
  vector <FormattedText> fmt;
  vector <uint8_t> colorR;
  vector <uint8_t> colorG;
  vector <uint8_t> colorB;
};
#endif
