Lab4

Dependencies:   SeeedStudioTFTv2 TFT_fonts mbed

Fork of Seeed_TFT_Touch_Shield by Shields

Widget.h

Committer:
uswickra
Date:
2014-09-26
Revision:
6:ebffa73d4f95
Parent:
4:ebcf8d366b91

File content as of revision 6:ebffa73d4f95:

#pragma once
#include "mbed.h"
#include "SeeedStudioTFTv2.h"
#include "ActionListener.h"
#include <vector>
//extern ActionType;

extern SeeedStudioTFTv2 TFT;
extern Serial pc;
//class ActionEvent;
//class ActionListener;
//typedef enum { CORD, STR, CORD_STR } ActionType;

class AbstractWidget:public ActionListener
{
    friend class Panel;
public:
    void redraw();

    //refresh state of this widget and all its children
    void refresh() ;

    AbstractWidget* remove_child();
    
    virtual void trigger_action(ActionType type, ActionEvent evnt, void* target);
    
    void inject_action(int x, int y);


protected:
    virtual bool addWidget(AbstractWidget *p){return true;};
    vector<AbstractWidget*> children;
    bool state_changed ;
    virtual void paint()=0;
    int back_color, border_color;
    //relative measure unit on space occupied on parent
    //width/hieght in "cell" units
    int width, height ;
    //left top corner of widget
    int x0,y0 ;
    //right bottom corner of widget
    int x1,y1 ;
    //number of cells panel is divided into
    //book keeping for child widgets
    int rows, cols ;
    double pp_row;
    double pp_col;
    bool push_children;  

    int curr_row;
    int curr_col;
    int prev_row;
    int prev_col;

};