Project Button Text - OOP344 20103
OOP344 | Weekly Schedule | Student List | Teams | Project | Student Resources
#include "confw.h"
#include "fwborder.h"
#include "fwdialog.h"
#include "fwlabel.h"
#include "fwbutton.h"
#include <stdio.h>
void Move(FWBorder &Br);
void main(){
bool done = false;
int key = 0;
int i = 100;
iol_init();
FWDialog App;
FWDialog D(&App, 5, 10, 50, 15, true, "+-+|+-+|");
FWButton Inc("Increase",9,10);
FWButton Dec("Decrease",9,30);
App<<new FWLabel("Press F10 to toggle button borders visiblity",1,1);
D.add(new FWLabel("Testing Buttons (bordered)",1, 12,30));
int mesIndx = D.add(new FWLabel(7, 24, 10));
D << Inc << Dec
<< new FWLabel("Press Escape to exit", 12, 15);
D[mesIndx].set("100");
D.draw(FW_REFRESH);
while(!done){
key = D.edit();
switch(key){
case ESCAPE_KEY:
done = true;
break;
case F10_KEY:
Inc.visible(!Inc.visible());
Dec.visible(!Dec.visible());
D[0].set(Inc.visible() ? "Testing Buttons (bordered)" : "Testing Buttons (no border)");
break;
case F6_KEY:
Move(D);
break;
case FW_BUTTON_HIT:
if(&D.curField() == &Inc){
i++;
}
else{
i--;
}
sprintf((char*)D[mesIndx].data(),"%d",i);
break;
}
}
iol_end();
}
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;
}
}
}