home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Mobile / Chip_Mobile_2001.iso / palm / business / printcar / printcar.exe / src / PrintStatusForm.cc < prev    next >
C/C++ Source or Header  |  2000-06-06  |  2KB  |  97 lines

  1. //
  2. //  $Id: PrintStatusForm.cc,v 1.1 2000/06/06 09:30:50 sergey Exp $
  3. //
  4.  
  5. #include <Pilot.h>
  6. #include "PrintStatusForm.h"
  7. #include "Util/Assert.h"
  8.  
  9. #include "PrintCardRes.h"
  10.  
  11.  
  12. PrintStatusForm::PrintStatusForm(Word formID):
  13.     UI::Form(formID),
  14.     _packetCount(0)
  15. {}
  16.  
  17. // operations
  18.  
  19. void PrintStatusForm::create()
  20. {
  21.     UI::Form::create();
  22.  
  23.     // static "thunk" for the form' event handler
  24.     static UI::FormEventHandler<PrintStatusForm> eventHandler;
  25.     eventHandler.init(this);
  26.  
  27.     display();
  28. }
  29.  
  30. // IR callback implementation
  31.  
  32. void PrintStatusForm::connected()
  33. {
  34.     setConnectedStatus();
  35. }
  36.  
  37. void PrintStatusForm::disconnected()
  38. {
  39.     setDisconnectedStatus();
  40. }
  41.  
  42. void PrintStatusForm::dataSendReady()
  43. {
  44.     setPrintingStatus();
  45. }
  46.  
  47. void PrintStatusForm::dataReceived(const Byte*, int)
  48. {}
  49.  
  50. void PrintStatusForm::statusChanged(Status status)
  51. {
  52.     if (status == NoProgressStatus)
  53.         setNoProgressStatus();
  54.     else if (status == LineOkStatus)
  55.         setConnectedStatus();
  56. }
  57.  
  58. // implementation
  59.  
  60. void PrintStatusForm::setConnectedStatus()
  61. {
  62.     _packetCount = 0;
  63.     updateStatusLabel("Connected");
  64. }
  65.  
  66. void PrintStatusForm::setDisconnectedStatus()
  67. {
  68.     _packetCount = 0;
  69.     updateStatusLabel("Disconnected");
  70. }
  71.  
  72. void PrintStatusForm::setNoProgressStatus()
  73. {
  74.     _packetCount = 0;
  75.     updateStatusLabel("No progress");
  76. }
  77.  
  78. void PrintStatusForm::setPrintingStatus()
  79. {
  80.     if (_packetCount++ == 0)
  81.         updateStatusLabel("Printing...");
  82.  
  83.     if (_packetCount%2 == 0)
  84.         showObject(ID_PRINT_INDICATOR_BITMAP);
  85.     else
  86.         hideObject(ID_PRINT_INDICATOR_BITMAP);
  87. }
  88.  
  89. void PrintStatusForm::updateStatusLabel(const char* text)
  90. {
  91.     assert(text != 0);
  92.  
  93.     hideObject(ID_PRINT_STATUS_LABEL);
  94.     FrmCopyLabel(formPtr(), ID_PRINT_STATUS_LABEL, (Char*)text);
  95.     showObject(ID_PRINT_STATUS_LABEL);
  96. }
  97.