Library release of Simon Ford's GraphicsDisplay Display Library Base Class.

Dependents:   ese_project_copy ese_project_share Test_ColorMemLCD rIoTwear_LCD ... more

GraphicsDisplay.h

Committer:
frankvnk
Date:
2015-01-23
Revision:
1:1cb0fcbce1bf
Parent:
0:282710e02ef4

File content as of revision 1:1cb0fcbce1bf:

/* mbed GraphicsDisplay Display Library Base Class
 * Copyright (c) 2007-2009 sford
 * Released under the MIT License: http://mbed.org/license/mit
 *
 * A library for providing a common base class for Graphics displays
 * To port a new display, derive from this class and implement
 * the constructor (setup the display), pixel (put a pixel
 * at a location), width and height functions. Everything else
 * (locate, printf, putc, cls, window, putp, fill, blit, blitbit) 
 * will come for free. You can also provide a specialised implementation
 * of window and putp to speed up the results
 */

#ifndef MBED_GRAPHICSDISPLAY_H
#define MBED_GRAPHICSDISPLAY_H

#include "TextDisplay.h"

/** A common base class for Graphics displays
*/
class GraphicsDisplay : public TextDisplay {

public:         
          
    /** Create a GraphicsDisplay interface
    * @param name The name used by the parent class to access the interface
    */
    GraphicsDisplay(const char* name);
     
    // functions needing implementation in derived implementation class
    // ----------------------------------------------------------------
    /** Draw a pixel in the specified color.
    * @note this method must be supported in the derived class.
    * @param x is the horizontal offset to this pixel.
    * @param y is the vertical offset to this pixel.
    * @param colour defines the color for the pixel.
    */
    virtual void pixel(int x, int y, int colour) = 0;

    /** get the screen width in pixels
    * @note this method must be supported in the derived class.
    * @returns screen width in pixels.
    */
    virtual int width() = 0;

    /** get the screen height in pixels
    * @note this method must be supported in the derived class.
    * @returns screen height in pixels.
    */
    virtual int height() = 0;
        
    // functions that come for free, but can be overwritten
    // ----------------------------------------------------
    /** Set the window, which controls where items are written to the screen.
    * When something hits the window width, it wraps back to the left side
    * and down a row. If the initial write is outside the window, it will
    * be captured into the window when it crosses a boundary.
    * @param x is the left edge in pixels.
    * @param y is the top edge in pixels.
    * @param w is the window width in pixels.
    * @param h is the window height in pixels.
    * @note this method may be overridden in a derived class.
    */
    virtual void window(int x, int y, int w, int h);

    /** Put a single pixel at the current pixel location
    * and update the pixel location based on window settings.
    * @param colour is the pixel colour.
    * @note this method may be overridden in a derived class.
    */
    virtual void putp(int colour);
    
    /** clear the entire screen
    */
    virtual void cls();

    /** Fill a region using a single colour.
    * @param x is the left-edge of the region.
    * @param y is the top-edge of the region.
    * @param w specifies the width of the region.
    * @param h specifies the height of the region.
    * @param colour is the fill colour.
    * @note this method may be overridden in a derived class.
    */
    virtual void fill(int x, int y, int w, int h, int colour);

    /** Fill a region using an array.
    * @param x is the left-edge of the region.
    * @param y is the top-edge of the region.
    * @param w specifies the width of the region.
    * @param h specifies the height of the region.
    * @param colour is a pointer to the array with size = w * h.
    * @note this method may be overridden in a derived class.
    */
    virtual void blit(int x, int y, int w, int h, const int *colour);    

    /** Fill a region using a font array.
    * @param x is the left-edge of the region.
    * @param y is the top-edge of the region.
    * @param w specifies the width of the region.
    * @param h specifies the height of the region.
    * @param colour is a pointer to the font array.
    * @note this method may be overridden in a derived class.
    */
    virtual void blitbit(int x, int y, int w, int h, const char* colour);
    
    /** Print one character at the specified row, column.
    * @param column is the horizontal character position.
    * @param row is the vertical character position.
    * @param value is the character to print.
    * @note this method may be overridden in a derived class.
    */
    virtual void character(int column, int row, int value);

    /** Get the number of columns based on the currently active font.
    * @returns number of columns.
    * @note this method may be overridden in a derived class.
    */
    virtual int columns();

    /** Get the number of rows based on the currently active font.
    * @returns number of rows.
    * @note this method may be overridden in a derived class.
    */
    virtual int rows();
    
protected:

    // pixel location
    short _x;
    short _y;
    
    // window location
    short _x1;
    short _x2;
    short _y1;
    short _y2;

};

#endif