Difference between revisions of "OOP344 20103 Framework Dialog and Label Tester"

From CDOT Wiki
Jump to: navigation, search
(Created page with '<big><syntaxhighlight lang="cpp"> // V1.0 #include "confw.h" #include "fwborder.h" #include "fwdialog.h" #include "fwlabel.h" #include <stdio.h> void Move(FWBorder &Br); int mai…')
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 +
{{OOP344 Index | 20103}}
 +
 
<big><syntaxhighlight lang="cpp">
 
<big><syntaxhighlight lang="cpp">
 
// V1.0
 
// V1.0
Line 13: Line 15:
 
   int i = 0;
 
   int i = 0;
 
   iol_init();
 
   iol_init();
   FWBorder App;
+
   FWDialog App;
 
   FWDialog D(&App, 5, 10, 50, 15, true, "+-+|+-+|");
 
   FWDialog D(&App, 5, 10, 50, 15, true, "+-+|+-+|");
 
   FWLabel L("A Non-dynamic Label goes here",5, 4);
 
   FWLabel L("A Non-dynamic Label goes here",5, 4);
 +
 +
  App<<new FWLabel("Dialog and Label Tester", 0, 0);
 +
 
   D.add(new FWLabel("Testing Read Only Dialog",1, 12));
 
   D.add(new FWLabel("Testing Read Only Dialog",1, 12));
 
   D << new FWLabel("Another Dyanmic label goes here, and I want to make sure it will be trimmed", 3, 3, 45) << L;
 
   D << new FWLabel("Another Dyanmic label goes here, and I want to make sure it will be trimmed", 3, 3, 45) << L;

Latest revision as of 13:00, 8 November 2010


OOP344 | Weekly Schedule | Student List | Teams | Project | Student Resources

// V1.0
#include "confw.h"
#include "fwborder.h"
#include "fwdialog.h"
#include "fwlabel.h"
#include <stdio.h>

void Move(FWBorder &Br);
int main(){
  bool done = false;
  int key = 0;
  int i = 0;
  iol_init();
  FWDialog App;
  FWDialog D(&App, 5, 10, 50, 15, true, "+-+|+-+|");
  FWLabel L("A Non-dynamic Label goes here",5, 4);

  App<<new FWLabel("Dialog and Label Tester", 0, 0);

  D.add(new FWLabel("Testing Read Only Dialog",1, 12));
  D << new FWLabel("Another Dyanmic label goes here, and I want to make sure it will be trimmed", 3, 3, 45) << L;
  int mesIndx = D.add(new FWLabel(7, 5, 40));
  D << new FWLabel("ESC to exit, F6 to Move, other to loop", 9, 3);
  D[mesIndx].set("Setting the message to see what happens");
  while(!done){
    key = D.edit(FW_REFRESH);
    i++;
    sprintf((char*)D[mesIndx].data(), "LOOP No: %d", i);    
    switch(key){
    case ESCAPE_KEY:
      done = true;
      break;
    case F6_KEY:
      Move(D);
      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;
    }
  }
}