Richard Parker / EALCD

manager/EAHitBox.h

Committer:
richardparker
Date:
2010-03-04
Revision:
1:f04bcaea1d60
Child:
3:24fbf4dbd7e5

File content as of revision 1:f04bcaea1d60:

// Copyright 2010 Richard Parker

#ifndef MBED_EAHITBOX_H
#define MBED_EAHITBOX_H

#include "mbed.h"

#include "../widgets/EAWidget.h"

class EAHitBox;

/**
 * Class to handle detection of a hit in an area of the screen.
 * @author Richard Parker
 */
class EAHitBox
{
public:
    typedef void (*ActionFunction)(EAHitBox*, short, short) ;

    EAHitBox();
    
    ~EAHitBox();

    inline unsigned short width() const { return _width; }
    inline unsigned short height() const { return _height; }

    inline void setWidth(unsigned int w) { _width = w; }
    inline void setHeight(unsigned int h) { _height = h; }

    inline unsigned short x() const { return _x; }
    inline unsigned short y() const { return _y; }

    inline void setX(short x) { _x = x; }
    inline void setY(short y) { _y = y; }
    
    inline EAHitBox* next() const { return _next; }
    inline void setNext(EAHitBox* value) { _next = value; }
    
    bool checkContains(short x, short y);
    
    inline void setAction(EAHitBox::ActionFunction action) { _action = action; }
    
    inline EAWidget* widget() const { return _widget; }
    inline void setWidget(EAWidget* value) { _widget = value; }

private:    
    EAHitBox* _next;
    
    EAWidget* _widget;
    
    unsigned short _width;
    unsigned short _height;
    
    short _x;
    short _y;
    
    ActionFunction _action;
    
};

#endif