Difference between revisions of "OpText Test Programs - OOP344 20101"

From CDOT Wiki
Jump to: navigation, search
(Created page with '= OpText R0.3 test main = <big><pre> #include "btext.h" #include "blabel.h" #include "bedit.h" #include "bform.h" #include <string.h> bool Yes(const char* message, BForm* ...')
 
(OpText R0.3 test main)
Line 2: Line 2:
  
 
<big><pre>
 
<big><pre>
 
+
# include "btext.h"
#include "btext.h"
+
# include "blabel.h"
 
+
# include "bedit.h"
#include "blabel.h"
+
# include "bform.h"
 
+
# include <string.h>
#include "bedit.h"
 
 
 
#include "bform.h"
 
 
 
#include <string.h>
 
 
 
 
bool Yes(const char* message, BForm* owner){
 
bool Yes(const char* message, BForm* owner){
 
 
   int key;
 
   int key;
 
 
   BForm YesNo((bio_rows()- 10)/2, (bio_cols()-40)/2, 10, 40, true);
 
   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.add(new BLabel(2, 2, 36)).add(new BLabel("(Y)es / (N)o", 4, 12));  
 
 
 
 
   YesNo[0].set(message);
 
   YesNo[0].set(message);
 
 
   key = YesNo.edit(0, owner);
 
   key = YesNo.edit(0, owner);
 
 
   return key == 'Y' || key == 'y';
 
   return key == 'Y' || key == 'y';
 
 
}
 
}
 
 
int main() {
 
int main() {
 
 
   int insert = 1;
 
   int insert = 1;
 
 
   int key;
 
   int key;
 
 
   bool done = false;
 
   bool done = false;
 
 
   bio_init();
 
   bio_init();
 
 
 
 
 
   BForm F(3, 5, 20, 70, true);
 
   BForm F(3, 5, 20, 70, true);
 
 
   F.add(new BLabel("Name:", 3, 2))
 
   F.add(new BLabel("Name:", 3, 2))
 
 
     .add(new BEdit(2, 10, 20, 40, &insert,true))
 
     .add(new BEdit(2, 10, 20, 40, &insert,true))
 
 
     .add(new BLabel("Lastname:", 6, 2))
 
     .add(new BLabel("Lastname:", 6, 2))
 
 
     .add(new BEdit(5, 13, 20, 40, &insert, true))
 
     .add(new BEdit(5, 13, 20, 40, &insert, true))
 
 
     .add(new BLabel("Phone Number", 9,2))
 
     .add(new BLabel("Phone Number", 9,2))
 
 
     .add(new BEdit(8, 16, 15, 20, &insert, true));
 
     .add(new BEdit(8, 16, 15, 20, &insert, true));
 
 
   while(!done){
 
   while(!done){
 
 
     key = F.edit();
 
     key = F.edit();
 
 
     switch(key){
 
     switch(key){
 
 
       case F1_KEY:
 
       case F1_KEY:
 
+
         // Help.edit(); to do later
         // Help.edit();
 
 
 
 
         break;
 
         break;
 
 
       case ESCAPE_KEY:
 
       case ESCAPE_KEY:
 
 
         if(Yes("Do you really want to quit?", &F)){
 
         if(Yes("Do you really want to quit?", &F)){
 
 
           done = true;
 
           done = true;
 
+
         }
         }  
 
 
 
 
         F.display(OT_CLR_AND_DSPLY_ALL);
 
         F.display(OT_CLR_AND_DSPLY_ALL);
 
 
         break;
 
         break;
 
 
     }
 
     }
 
 
   }
 
   }
 
 
   bio_end();
 
   bio_end();
 
+
   return 0;
   return 0;
 
  
 
}
 
}
  
 
</pre></big>
 
</pre></big>

Revision as of 12:20, 21 March 2010

OpText R0.3 test main

# include "btext.h"
# include "blabel.h"
# include "bedit.h"
# include "bform.h"
# include <string.h>
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';
}
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 BEdit(5, 13, 20, 40, &insert, true))
    .add(new BLabel("Phone Number", 9,2))
    .add(new BEdit(8, 16, 15, 20, &insert, true));
  while(!done){
    key = F.edit();
    switch(key){
      case F1_KEY:
        // Help.edit(); to do later
        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;

}