Difference between revisions of "OOP344 20103 BorderTester"

From CDOT Wiki
Jump to: navigation, search
(Created page with '<big><syntaxhighlight lang="cpp"> #include "confw.h" #include "fwborder.h" void Move(FWBorder &Br); int main(){ bool done = false; int key = 0; iol_init(); FWBorder Cont;…')
 
Line 1: Line 1:
 
<big><syntaxhighlight lang="cpp">
 
<big><syntaxhighlight lang="cpp">
 +
// V1.0
 +
 
#include "confw.h"
 
#include "confw.h"
 
#include "fwborder.h"
 
#include "fwborder.h"

Revision as of 13:26, 8 November 2010

// V1.0

#include "confw.h"
#include "fwborder.h"
void Move(FWBorder &Br);
int main(){
  bool done = false;
  int key = 0;
  iol_init();
  FWBorder Cont;
  FWBorder B(5, 10, 50,15, true, "+-+|+-+|", &Cont);
  FWBorder C(5, 10, 20,5, true,FW_BORDER_CHARS, &B);
  B.draw();
  iol_display("Press any key...", 0, 0,-1);
  iol_getch();
  while(!done){
    C.draw(true);
    iol_display("ESC: exit, F6: Move Container, F7: Move Inner border", 0, 0,-1);
    key = iol_getch();
    switch(key){
    case ESCAPE_KEY:
      done = true;
      break;
    case F6_KEY:
      Move(B);
      break;
    case F7_KEY:
      Move(C);
      break;
    }
  }
  iol_end();
  return 0;
}

void Move(FWBorder &Br){
  bool done = false;
  int key;
  while(!done){
    Br.draw(FW_REFRESH);
    iol_display("Moving! ESC: exit", 0, 0,-1);
    key = iol_getch();
    switch(key){
    case ESCAPE_KEY:
      done = true;
      break;
    case UP_KEY:
      if(Br.row() > 0){
        Br.row(Br.row()-1);
      }
      break;
    case DOWN_KEY:
      if(Br.row() + Br.height() < Br.container()->height()){
        Br.row(Br.row()+1);
      }
      break;
    case LEFT_KEY:
      if(Br.col() > 0){
        Br.col(Br.col()-1);
      }
      break;
    case RIGHT_KEY:
      if(Br.col() + Br.width() < Br.container()->width()){
        Br.col(Br.col() + 1);
      }
      break;
    }
  }
}