Oop344 20103 Framework Dialog and Lineeditor Tester
From CDOT Wiki
OOP344 | Weekly Schedule | Student List | Teams | Project | Student Resources
#include "confw.h"
#include "fwborder.h"
#include "fwdialog.h"
#include "fwlabel.h"
#include "fwlineedit.h"
#include <stdio.h>
void Move(FWBorder &Br);
int main(){
bool done = false;
int key = 0;
int i = 0;
int insert = 1;
char str[81] = "I want to edit this thing!";
iol_init();
FWDialog App;
FWDialog D(&App, 5, 10, 50, 15, true, "+-+|+-+|");
FWLabel L("Enter some text down here:",6, 4);
App<<new FWLabel("Dialog and Line Editor Tester", 0, 0);
D.add(new FWLabel("Testing Label and Line edit",1, 12));
D << new FWLabel("Name: ", 4, 3, 45)
<< new FWLineEdit(4,9,20,40,&insert)<< L
<< new FWLineEdit(str,7,4,40,80, &insert, true);
int mesIndx = D.add(new FWLabel(10, 5, 40));
D << new FWLabel("Press ESC or F2 to exit, press F6 to Move", 2, 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:
case F2_KEY:
done = true;
break;
case F6_KEY:
Move(D);
break;
}
}
iol_clrscr();
iol_display("First Lineedit data:", 10, 1, -1);
iol_display((char*)D[2].data(), 11, 0, -1);
iol_display("Second Linedit data:", 14, 1, -1);
iol_display((char*)D[4].data(), 15, 0, -1);
iol_getch();
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;
}
}
}