21
edits
Changes
{{OOP344 Index}}
= BFrame R0.1 test main =
</big>
= OpText R0.4 31 test main (with help window) =
[[OpText Text Editor (AS2) - OOP344 20101]]
<big><pre>
#include "btext.h" #include "blabel.h" #include "bedit.h" #include "bveditbform.h" #include "bform<string.h" #include <cstring> #include <cctype> using namespace std;
bool Yes(const char* message, BForm* owner){
int key;
BForm YesNo((bio_rows()- 10)/2, (bio_cols()-40)/2, 10, 40, true);
YesNo.add(new BLabel(2, 2, 36)).add(new BLabel("(Y)es / (N)o", 4, 12));
YesNo[0].set(message);
key = YesNo.edit(0, owner);
return key == 'Y' || key == 'y';
}
void Help(BForm* owner){
BForm help((bio_rows()- 10)/2, (bio_cols()-40)/2, 10, 40, true);
help.add(new BLabel(2, 3,36))
.add(new BLabel("Escape Key: Exit the test program.", 4, 3))
.add(new BLabel("F1 Key: Open this window.", 6, 3));
switch(owner->curField()){
case 2:
help[0].set("Enter the name here!");
break;
case 4:
help[0].set("Enter the Last name here!");
break;
case 6:
help[0].set("Enter Phone number: (999)999-9999");
}
help.edit(0, owner);
}
int main() {
int insert = 1;
int key;
bool done = false;
bio_init();
BForm F(3, 5, 20, 70, true);
F.add(new BLabel("Name:", 3, 2))
.add(new BEdit(2, 10, 20, 40, &insert,true))
.add(new BLabel("Lastname:", 6, 2))
.add(new BVeditBEdit(5, 13, 20, 40, &insert,NO_VFUNC, LastNameHelp, true))
.add(new BLabel("Phone Number", 9,2))
.add(new BVeditBEdit(8, 16, 1315, 1220, &insert,ValidPhone,PhoneHelp, true)); F.add(PhHelp); F.add(LnHelp); F.add(ErrMes);
while(!done){
key = F.edit();
switch(key){
case F1_KEY:
Help(&F);
break;
case ESCAPE_KEY:
if(Yes("Do you really want to quit?", &F)){
done = true;
}
F.display(OT_CLR_AND_DSPLY_ALL);
break;
}
}
bio_end();
return 0;
}
</pre></big>