#ifndef _GRAPHICS_H_
#define _GRAPHICS_H_
#include "Shapes/Shapes.h"

#include "Arduino.h"

#include "GraphicsDefs.h"

#include <pgmspace.h>

#ifndef pgm_read_byte
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#endif
#ifndef pgm_read_word
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#endif
#ifndef pgm_read_dword
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
#endif

#if !defined(__INT_MAX__) || (__INT_MAX__ > 0xFFFF)
#define pgm_read_pointer(addr) ((void *)pgm_read_dword(addr))
#else
#define pgm_read_pointer(addr) ((void *)pgm_read_word(addr))
#endif

/**
 * @brief       Graphics class that holds basic functionalities for Inkplate
 * display
 */
class Graphics : public Shapes
{
  public:
    Graphics(int16_t w, int16_t h) : Adafruit_GFX(w, h), Shapes(w, h){};

    void setRotation(uint8_t r);
    uint8_t getRotation();

    void drawPixel(int16_t x, int16_t y, uint16_t color) override;
    void drawTextBox(int16_t x0, int16_t y0, int16_t x1, int16_t x2, const char *text, uint16_t textSize = 1,
                     const GFXfont *font = NULL, uint16_t vericalSpacing = 0, bool showBorder = false,
                     uint16_t fontSize = 8);

  private:
    void startWrite(void) override;
    void writePixel(int16_t x, int16_t y, uint16_t color) override = 0;
    void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) override;
    void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) override;
    void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) override;
    void writeLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color) override;
    void endWrite(void) override;

  protected:
};


#endif