home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP Advantage / NeXTstep_Advantage.img / YourCallDemo / CallReviewer.m < prev    next >
Text File  |  1993-04-14  |  4KB  |  165 lines

  1. #import "CallReviewer.h"
  2.  
  3. @implementation CallReviewer : CallController
  4.  
  5. /* 
  6.  * Purpose: Initialize the CallReviewer
  7.  *
  8.  * Inherited from CallController, overridden by CallReviewer
  9.  * to prepare the user interface to accept input.  
  10.  */
  11.  
  12. - awakeFromNib
  13. {
  14.     [self resetReviewer];
  15.     [super awakeFromNib];
  16.     return self;
  17. }
  18.  
  19.  
  20. /*
  21.  * Purpose: Retrieve a call from the database.  
  22.  *
  23.  * Inherited from CallController, overridden by CallReviewer to
  24.  * reset the User Interface when the user retrieves a call.  
  25.  */
  26.  
  27. - retrieveCall:sender
  28. {
  29.     [self resetReviewer];
  30.     [super retrieveCall:sender];
  31.     return self;
  32. }
  33.  
  34.  
  35. /*
  36.  * Purpose: Save the information in the form to the database
  37.  *
  38.  * Inherited from CallController, overridden by CallReviewer to
  39.  * reset the User Interface when the user saves a call.  
  40.  *
  41.  */
  42.  
  43. - saveCall:sender
  44. {
  45.     if ([super saveCall:sender]) {
  46.         [self resetReviewer];
  47.         return self;
  48.     }
  49.     else return nil;
  50. }
  51.  
  52.  
  53. /*
  54.  * Purpose: Begin a new call entry
  55.  *
  56.  * Inherited from CallController, overridden by CallReviewer to
  57.  * reset the User Interface when the user clears the form.  
  58.  *   
  59.  */
  60.  
  61. - clearForm:sender;
  62. {
  63.     [self resetReviewer];
  64.     [super clearForm:sender];
  65.     return self;
  66. }
  67.  
  68.  
  69. /*
  70.  * Purpose: Display a record in the log form
  71.  *
  72.  * Accepts a CallRecord and displays its data.  Used by the
  73.  * showNextCall method to display records as the user 
  74.  * clicks the button in the Review Calls panel.  
  75.  */ 
  76.  
  77. - showCall:(CallRecord *)theRecord
  78. {
  79.     [customerForm setStringValue:[theRecord name] at:0]; // name
  80.     [customerForm setStringValue:[theRecord street] at:1]; // street
  81.     [customerForm setStringValue:[theRecord city] at:2]; // city
  82.     [customerForm setStringValue:[theRecord state] at:3]; // state
  83.     [customerForm setStringValue:[theRecord phone] at:4]; // phone
  84.     [questionText setStringValue:[theRecord question]];
  85.     [answerText setStringValue:[theRecord answer]];
  86.     [customerForm selectText:self];
  87.     return self;
  88. }
  89.  
  90. /*
  91.  * Purpose: To initialize and present the Review Calls feature
  92.  * 
  93.  * This method displays the review calls panel, resets the 
  94.  * reviewer, and displays the first call in the database.  
  95.  * It is sent to CallReviewer by the Review Calls MenuCell.
  96.  * 
  97.  */
  98.  
  99. - showFirstCall:sender
  100. {
  101.     [reviewCallsPanel makeKeyAndOrderFront:self];
  102.     [self resetReviewer];
  103.     [self showNextCall:self];
  104.     return self;
  105. }
  106.  
  107. /*
  108.  * Purpose: To display the next caller in the database
  109.  * 
  110.  * This method checks the call number being displayed.
  111.  * If zero, beeps and no call is displayed.  
  112.  * Otherwise, gets the record by number from the database
  113.  * and displays it in the form.  
  114.  * 
  115.  */
  116.  
  117. - showNextCall:sender
  118. {
  119.     const char *formName = NULL;
  120.     CallRecord *currentRecord;
  121.     BOOL successful;
  122.     
  123.     if ([callTable count] == 0) {
  124.     NXBeep();
  125.     return nil;
  126.     }
  127.  
  128.     [ofButton setTransparent:NO];
  129.     successful = [callTable nextState:&hashState
  130.         key:(const void **)&formName
  131.     value:(void **)¤tRecord];
  132.     if (successful == NO) {
  133.     NXBeep();
  134.     [self resetReviewer];
  135.     [self clearForm:self];
  136.     return nil;
  137.     }
  138.     indexOfCall++;
  139.     [callIndexField setIntValue:indexOfCall];
  140.     [totalCallsField setIntValue:[callTable count]];
  141.     [self showCall:currentRecord];
  142.     return self;
  143. }
  144.  
  145. /*
  146.  * Purpose: To reset the Review Calls feature 
  147.  * 
  148.  * This method sets the call number to zero and initializes
  149.  * Review Calls panel so that the user may begin 
  150.  * reviewing calls in the database.  
  151.  * 
  152.  */
  153.  
  154. - resetReviewer
  155. {
  156.     indexOfCall = 0;
  157.     hashState = [callTable initState];
  158.     [callIndexField setStringValue:NULL];
  159.     [totalCallsField setIntValue:[callTable count]];
  160.     [ofButton setTransparent:YES];
  161.     return self;
  162. }
  163.  
  164. @end
  165.