Lab4

Dependencies:   SeeedStudioTFTv2 TFT_fonts mbed

Fork of Seeed_TFT_Touch_Shield by Shields

Committer:
uswickra
Date:
Fri Sep 26 12:40:19 2014 +0000
Revision:
4:ebcf8d366b91
Child:
6:ebffa73d4f95
Lab 4;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
uswickra 4:ebcf8d366b91 1 #include "Widget.h"
uswickra 4:ebcf8d366b91 2
uswickra 4:ebcf8d366b91 3 void AbstractWidget::redraw()
uswickra 4:ebcf8d366b91 4 {
uswickra 4:ebcf8d366b91 5 //if state has changed in this widget
uswickra 4:ebcf8d366b91 6 if(state_changed) {
uswickra 4:ebcf8d366b91 7 paint();
uswickra 4:ebcf8d366b91 8 pc.printf("starting to paint# \r\n");
uswickra 4:ebcf8d366b91 9 state_changed = false;
uswickra 4:ebcf8d366b91 10 }
uswickra 4:ebcf8d366b91 11 //redraw action for all children
uswickra 4:ebcf8d366b91 12 for(vector<AbstractWidget*>::iterator it = children.begin(); it != children.end(); it++) {
uswickra 4:ebcf8d366b91 13 AbstractWidget* w = *it;
uswickra 4:ebcf8d366b91 14 w->redraw();
uswickra 4:ebcf8d366b91 15 }
uswickra 4:ebcf8d366b91 16 }
uswickra 4:ebcf8d366b91 17
uswickra 4:ebcf8d366b91 18 void AbstractWidget::refresh()
uswickra 4:ebcf8d366b91 19 {
uswickra 4:ebcf8d366b91 20 state_changed = true;
uswickra 4:ebcf8d366b91 21 //try to re-adjust cordinates for any children of 'p'
uswickra 4:ebcf8d366b91 22 if(children.size() > 0 ) {
uswickra 4:ebcf8d366b91 23 curr_row = 0 ;
uswickra 4:ebcf8d366b91 24 curr_col = 0 ;
uswickra 4:ebcf8d366b91 25 for(vector<AbstractWidget*>::iterator it = children.begin(); it != children.end(); it++) {
uswickra 4:ebcf8d366b91 26 AbstractWidget* pnl = (*it);
uswickra 4:ebcf8d366b91 27 push_children = false ;
uswickra 4:ebcf8d366b91 28 addWidget(pnl);
uswickra 4:ebcf8d366b91 29 push_children = true ;
uswickra 4:ebcf8d366b91 30 }
uswickra 4:ebcf8d366b91 31 }
uswickra 4:ebcf8d366b91 32 //refresh action for all children
uswickra 4:ebcf8d366b91 33 for(vector<AbstractWidget*>::iterator it = children.begin(); it != children.end(); it++) {
uswickra 4:ebcf8d366b91 34 AbstractWidget* w = *it;
uswickra 4:ebcf8d366b91 35 w->refresh();
uswickra 4:ebcf8d366b91 36 }
uswickra 4:ebcf8d366b91 37 }
uswickra 4:ebcf8d366b91 38
uswickra 4:ebcf8d366b91 39 AbstractWidget* AbstractWidget::remove_child() {
uswickra 4:ebcf8d366b91 40 AbstractWidget* w = children.back();
uswickra 4:ebcf8d366b91 41 children.pop_back();
uswickra 4:ebcf8d366b91 42 //refresh state of returned widget
uswickra 4:ebcf8d366b91 43 // w->refresh();
uswickra 4:ebcf8d366b91 44 //revert to previous row/col position
uswickra 4:ebcf8d366b91 45 curr_row = prev_row;
uswickra 4:ebcf8d366b91 46 curr_col = prev_col;
uswickra 4:ebcf8d366b91 47 return w;
uswickra 4:ebcf8d366b91 48 }
uswickra 4:ebcf8d366b91 49
uswickra 4:ebcf8d366b91 50 void AbstractWidget::trigger_action(ActionType type, ActionEvent evnt){
uswickra 4:ebcf8d366b91 51 //do nothing
uswickra 4:ebcf8d366b91 52 }