home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / mmremote / mmremote.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  49.2 KB  |  1,183 lines

  1. /******************************************************************************
  2. * .FILE:         mmremote.cpp                                                 *
  3. *                                                                             *
  4. * .DESCRIPTION:  Multimedia Remote-Control Sample:     Class Implementation   *
  5. *                                                                             *
  6. * .CLASSES:      KeyPad                                                       *
  7. *                MainWindow                                                   *
  8. *                MainHandler                                                  *
  9. *                MainObserver                                                 *
  10. *                                                                             *
  11. * .COPYRIGHT:                                                                 *
  12. *    Licensed Material - Program-Property of IBM                              *
  13. *    (C) Copyright IBM Corp. 1992, 1995 - All Rights Reserved                 *
  14. *                                                                             *
  15. * .DISCLAIMER:                                                                *
  16. *   The following [enclosed] code is sample code created by IBM               *
  17. *   Corporation.  This sample code is not part of any standard IBM product    *
  18. *   and is provided to you solely for the purpose of assisting you in the     *
  19. *   development of your applications.  The code is provided 'AS IS',          *
  20. *   without warranty of any kind.  IBM shall not be liable for any damages    *
  21. *   arising out of your use of the sample code, even if they have been        *
  22. *   advised of the possibility of such damages.                               *
  23. *                                                                             *
  24. * .NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE          *
  25. *                                                                             *
  26. ******************************************************************************/
  27. #ifndef _IBASE_                         //Make sure ibase.hpp is included
  28.   #include <ibase.hpp>                  //  since that is where IC_<environ>
  29. #endif                                  //  is defined.
  30. #include <iapp.hpp>
  31. #include <ifont.hpp>
  32. #include <immttime.hpp>
  33. #include <inotifev.hpp>
  34. #include <imsgbox.hpp>
  35. #include <icoordsy.hpp>
  36. #include "mmremote.hpp"
  37.  
  38. //*************************************************************************
  39. // main  - Application entry point                                        *
  40. //*************************************************************************
  41.  
  42. int main()
  43. {
  44.   ICoordinateSystem::setApplicationOrientation(
  45.           ICoordinateSystem::originLowerLeft );
  46.   MainWindow  mainWindow(WINDOWID);
  47.   IApplication::current().run();
  48.   return 0;
  49. }
  50.  
  51. //******************************************************************************
  52. // KeyPad::KeyPad                                                              *
  53. //   Defines the keypad 0-9 for entering tracks for the CD player or special   *
  54. //   functions for the video player.                                           *
  55. //******************************************************************************
  56.  
  57. KeyPad::KeyPad(unsigned long windowid,
  58.                IWindow*          parent,
  59.                IWindow*          owner)
  60.       : IMultiCellCanvas(windowid,parent,owner),
  61.         one             (ONEID   ,this  ,owner),
  62.         two             (TWOID   ,this  ,owner),
  63.         three           (THREEID ,this  ,owner),
  64.         four            (FOURID  ,this  ,owner),
  65.         five            (FIVEID  ,this  ,owner),
  66.         six             (SIXID   ,this  ,owner),
  67.         seven           (SEVENID ,this  ,owner),
  68.         eight           (EIGHTID ,this  ,owner),
  69.         nine            (NINEID  ,this  ,owner),
  70.         zero            (ZEROID  ,this  ,owner)
  71. {
  72.    IResourceLibrary reslib;
  73.    one.setText  (reslib.loadString(STR_ONE));
  74.    two.setText  (reslib.loadString(STR_TWO));
  75.    three.setText(reslib.loadString(STR_THREE));
  76.    four.setText (reslib.loadString(STR_FOUR));
  77.    five.setText (reslib.loadString(STR_FIVE));
  78.    six.setText  (reslib.loadString(STR_SIX));
  79.    seven.setText(reslib.loadString(STR_SEVEN));
  80.    eight.setText(reslib.loadString(STR_EIGHT));
  81.    nine.setText (reslib.loadString(STR_NINE));
  82.    zero.setText (reslib.loadString(STR_ZERO));
  83.  
  84. //*****************************************************************************
  85. //  Lay out the keypad multicell canvas - 3 columns, 4 rows, no margins       *
  86. //*****************************************************************************
  87.  
  88.    addToCell(&one,           1, 1, 1, 1);
  89.    addToCell(&two,           2, 1, 1, 1);
  90.    addToCell(&three,         3, 1, 1, 1);
  91.    addToCell(&four,          1, 2, 1, 1);
  92.    addToCell(&five,          2, 2, 1, 1);
  93.    addToCell(&six,           3, 2, 1, 1);
  94.    addToCell(&seven,         1, 3, 1, 1);
  95.    addToCell(&eight,         2, 3, 1, 1);
  96.    addToCell(&nine,          3, 3, 1, 1);
  97.    addToCell(&zero,          2, 4, 1, 1);
  98. }
  99. //*******************************************************************************
  100. // MainWindow::~MainWindow                                                      *
  101. //   Destruct the remote control main window                                    *
  102. //                                                                              *
  103. //*******************************************************************************
  104.  
  105. MainWindow::~MainWindow()
  106. {
  107.    if (cdPlayer)
  108.       delete cdPlayer;
  109.    if (digPlayer)
  110.       delete digPlayer;
  111.    if (midPlayer)
  112.       delete midPlayer;
  113.    if (wavPlayer)
  114.       delete wavPlayer;
  115.    if (handler)
  116.       delete handler;
  117.    if (observer)
  118.       delete observer;
  119. }
  120.  
  121. //*******************************************************************************
  122. // MainWindow::MainWindow                                                       *
  123. //   Construct the remote control main window                                   *
  124. //                                                                              *
  125. //*******************************************************************************
  126.  
  127. MainWindow::MainWindow( unsigned long windowId)
  128.           : IFrameWindow(windowId),
  129.             title(this),
  130.             newTrackDigit1(0),
  131.             newTrackDigit2(0),
  132.             flyText(FLYTEXTID, this),
  133.             flyHelpHandler(&flyText, 100, 5),
  134.  
  135.  
  136. //*****************************************************************************
  137. // remoteCanvas is the main canvas.  devices, controls, volkey, volume, and   *
  138. // pad are canvases it contains                                               *
  139. //*****************************************************************************
  140.  
  141.             remoteCanvas(REMOTECANVASID ,this,this),
  142.             devices     (DEVID   ,&remoteCanvas,this),
  143.             controls    (CTLID   ,&remoteCanvas,this),
  144.             volkey      (VKID    ,&remoteCanvas,this),
  145.             volume      (VOLUMEID,&volkey,this),
  146.             pad         (PADID   ,&volkey,this),
  147.  
  148. //*****************************************************************************
  149. //  These are the control buttons for the remote control                      *
  150. //*****************************************************************************
  151.  
  152.             powerbtn        (POWERID ,&remoteCanvas,this,IRectangle(),
  153.                             IWindow::visible | IAnimatedButton::animateWhenLatched),
  154.             volupbtn        (VOLUPID ,&volume,this,IRectangle(),
  155.                             IControl::group |
  156.                             IWindow::visible | IAnimatedButton::animateWhenLatched),
  157.             voldnbtn        (VOLDNID ,&volume,this,IRectangle(),
  158.                             IWindow::visible | IAnimatedButton::animateWhenLatched),
  159.             playbtn         (PLAYID  ,&controls,this,IRectangle(),
  160.                             ICustomButton::latchable |
  161.                             ICustomButton::autoLatch |
  162.                             IControl::group |
  163.                             IWindow::visible | IAnimatedButton::animateWhenLatched),
  164.             stopbtn         (STOPID  ,&controls,this,IRectangle(),
  165.                             IWindow::visible | IAnimatedButton::animateWhenLatched),
  166.             rewbtn          (REWID   ,&controls,this,IRectangle(),
  167.                             IWindow::visible | IAnimatedButton::animateWhenLatched),
  168.             ffbtn           (FFID    ,&controls,this,IRectangle(),
  169.                             IWindow::visible | IAnimatedButton::animateWhenLatched),
  170.             pausebtn        (PAUSEID ,&controls,this,IRectangle(),
  171.                             ICustomButton::latchable |
  172.                             ICustomButton::autoLatch |
  173.                             IWindow::visible | IAnimatedButton::animateWhenLatched),
  174.             stepOrTrackFBtn (STEPTRACKFID ,&controls,this,IRectangle(),
  175.                             IWindow::visible | IAnimatedButton::animateWhenLatched),
  176.             stepOrTrackBBtn (STEPTRACKBID ,&controls,this,IRectangle(),
  177.                             IWindow::visible | IAnimatedButton::animateWhenLatched),
  178.  
  179. //*****************************************************************************
  180. //  These are the device selection buttons for video, midi, CD, and wave      *
  181. //  players                                                                   *
  182. //*****************************************************************************
  183.  
  184.             videobtn        (VIDEOID ,&devices,this,IRectangle(),
  185.                             IControl::group |
  186.                             ICustomButton::autoLatch |
  187.                             IWindow::visible | IAnimatedButton::animateWhenLatched),
  188.             midibtn         (MIDIID  ,&devices,this,IRectangle(),
  189.                             ICustomButton::autoLatch |
  190.                             IWindow::visible | IAnimatedButton::animateWhenLatched),
  191.             cdbtn           (CDID    ,&devices,this,IRectangle(),
  192.                             ICustomButton::autoLatch |
  193.                             IWindow::visible | IAnimatedButton::animateWhenLatched),
  194.             wavebtn         (WAVEID  ,&devices,this,IRectangle(),
  195.                             ICustomButton::autoLatch |
  196.                             IWindow::visible | IAnimatedButton::animateWhenLatched),
  197.  
  198. //*****************************************************************************
  199. //  This is the status line for the playing device                            *
  200. //*****************************************************************************
  201.  
  202.             readout     (READOUTID, &remoteCanvas,this),
  203.  
  204. //*****************************************************************************
  205. //  Set the pointers for the devices to be zero.                              *
  206. //*****************************************************************************
  207.             player   (0),
  208.             cdPlayer (0),
  209.             digPlayer(0),
  210.             midPlayer(0),
  211.             wavPlayer(0),
  212.             handler  (0),
  213.  
  214. //*****************************************************************************
  215. //  Initialize the observer to this window.                                   *
  216. //*****************************************************************************
  217.             observer ( new MainObserver( *this ) )
  218.  
  219. //*****************************************************************************
  220. //  Open the CD player.  If not ready, post message and allow retry or cancel.*
  221. //  Then point the player to the default device - CD and set the device ID.   *
  222. //*****************************************************************************
  223.  
  224. {
  225.    IResourceLibrary reslib;
  226.    title.setTitleText(WINDOWID);
  227.    try
  228.    {
  229.       //***********************************************************************
  230.       //  Construct the CD player. The default arguments cause the audio CD   *
  231.       //  device to be opened so we don't need to make an additional open()   *
  232.       //  call later.  Also, it uses the system profile for storing and       *
  233.       //  retrieving information(track titles, disc titles, playback order of *
  234.       //  the tracks).  If we get an error opening the audio CD device then   *
  235.       //  the remote will not control the audio cd player.                    *
  236.       //***********************************************************************
  237.       cdPlayer = new IMMAudioCD();
  238.       while (!cdPlayer->isMediaPresent())
  239.       {
  240.          IMessageBox::Response response = IMessageBox::cancel;
  241.          IMessageBox msgBox(this);
  242.          response = msgBox.show(reslib.loadString(STR_NOAUDCD),
  243.                      IMessageBox::retryCancelButton  |
  244.                      IMessageBox::errorIcon          |
  245.                      IMessageBox::moveable );
  246.          if (response == IMessageBox::cancel)
  247.          {
  248.             msgBox.show(reslib.loadString(STR_CDDIS),
  249.                         IMessageBox::okButton  |
  250.                         IMessageBox::errorIcon |
  251.                         IMessageBox::moveable );
  252.             cdbtn.disable();
  253.             delete cdPlayer;
  254.             cdPlayer = 0;
  255.             break;
  256.          }
  257.       }
  258.    }
  259.    catch (IException& exc)
  260.    {
  261.       IMessageBox msgBox(this);
  262.       msgBox.show(reslib.loadString(STR_NOCD),
  263.                   IMessageBox::okButton  |
  264.                   IMessageBox::errorIcon |
  265.                   IMessageBox::moveable );
  266.       cdbtn.disable();
  267.    }
  268.  
  269.    if (cdPlayer)
  270.    {
  271.       player = cdPlayer;
  272.       playerDevice = CDID;
  273.       cdPlayer->enableNotification() ;
  274.       try
  275.       {
  276.          //********************************************************************
  277.          //  Allow CD sound to be played without a connector cable            *
  278.          //********************************************************************
  279.          cdPlayer->enableConnector(IMMDevice::cdStream);
  280.       }
  281.       catch (IException& exc)
  282.       {
  283.          IMessageBox msgBox(this);
  284.          msgBox.show(reslib.loadString(STR_NOTRANS),
  285.                      IMessageBox::okButton  |
  286.                      IMessageBox::errorIcon |
  287.                      IMessageBox::moveable );
  288.       }
  289.    } /* endif */
  290.  
  291.    try
  292.    {
  293.       wavPlayer = new IMMWaveAudio();
  294.       if (wavPlayer)
  295.       {
  296.          player       = wavPlayer;
  297.          playerDevice = WAVEID;
  298.          wavPlayer->enableNotification();
  299.       } /* endif */
  300.    }
  301.    catch (IException& exc)
  302.    {
  303.       IMessageBox msgBox(this);
  304.       msgBox.show(reslib.loadString(STR_NOWAVE),
  305.                   IMessageBox::okButton  |
  306.                   IMessageBox::errorIcon |
  307.                   IMessageBox::moveable );
  308.       wavebtn.disable();
  309.    }
  310.    try
  311.    {
  312.       digPlayer = new IMMDigitalVideo();
  313.       if (digPlayer)
  314.       {
  315.          player       = digPlayer;
  316.          playerDevice = VIDEOID;
  317.          digPlayer->enableNotification();
  318.       } /* endif */
  319.    }
  320.    catch (IException& exc)
  321.    {
  322.       IMessageBox msgBox(this);
  323.       msgBox.show(reslib.loadString(STR_NOVID),
  324.                   IMessageBox::okButton  |
  325.                   IMessageBox::errorIcon |
  326.                   IMessageBox::moveable );
  327.       videobtn.disable();
  328.    }
  329.    try
  330.    {
  331.       midPlayer = new IMMSequencer();
  332.       if (midPlayer)
  333.       {
  334.          player       = midPlayer;
  335.          playerDevice = MIDIID;
  336.          midPlayer->enableNotification();
  337.       } /* endif */
  338.    }
  339.    catch (IException& exc)
  340.    {
  341.       IMessageBox msgBox(this);
  342.       msgBox.show(reslib.loadString(STR_NOMIDI),
  343.                   IMessageBox::okButton  |
  344.                   IMessageBox::errorIcon |
  345.                   IMessageBox::moveable );
  346.       midibtn.disable();
  347.    }
  348.  
  349. //*****************************************************************************
  350. //  Put the bitmaps on the buttons                                            *
  351. //*****************************************************************************
  352.  
  353.    powerbtn.setBitmaps(BMPPOWER,1);
  354.    volupbtn.setBitmaps(IAnimatedButton::volumeUp);
  355.    voldnbtn.setBitmaps(IAnimatedButton::volumeDown);
  356.    rewbtn.setBitmaps  (IAnimatedButton::rewind);
  357.    ffbtn.setBitmaps   (IAnimatedButton::fastForward);
  358.    pausebtn.setBitmaps(IAnimatedButton::pause);
  359.    stopbtn.setBitmaps (IAnimatedButton::stop);
  360.    playbtn.setBitmaps (IAnimatedButton::play);
  361.    stepOrTrackBBtn.setBitmaps(IAnimatedButton::trackReverse);
  362.    stepOrTrackFBtn.setBitmaps(IAnimatedButton::trackAdvance);
  363.    videobtn.setBitmaps(BMPVIDEO,1);
  364.    midibtn.setBitmaps (BMPMIDI ,1);
  365.    cdbtn.setBitmaps   (BMPCD   ,1);
  366.    wavebtn.setBitmaps (BMPWAVE ,1);
  367.  
  368. //*****************************************************************************
  369. //  Set the text for each of the buttons.  The \n causes the following word   *
  370. //  to be on a new line                                                       *
  371. //*****************************************************************************
  372.  
  373.    powerbtn.setText(reslib.loadString(STR_POWER));
  374.    volupbtn.setText(reslib.loadString(STR_VOLUMEUP));
  375.    voldnbtn.setText(reslib.loadString(STR_VOLUMEDOWN));
  376.    videobtn.setText(reslib.loadString(STR_VIDEO));
  377.    midibtn.setText (reslib.loadString(STR_MIDI));
  378.    cdbtn.setText   (reslib.loadString(STR_CD));
  379.    wavebtn.setText (reslib.loadString(STR_WAVE));
  380. //*****************************************************************************
  381. //  Build the main canvas.  Columns 1 and 3 and rows 1 and 11 are margins     *
  382. //*****************************************************************************
  383.  
  384.    remoteCanvas.addToCell(&powerbtn,      2, 2, 1, 1);
  385.    remoteCanvas.addToCell(&devices,       2, 4, 1, 1);
  386.    remoteCanvas.addToCell(&volkey,        2, 6, 1, 1);
  387.    remoteCanvas.addToCell(&controls,      2, 8, 1, 1);
  388.    remoteCanvas.addToCell(&readout,       2, 10, 1,1);
  389.    remoteCanvas.setColumnWidth(1, MARGIN, true);
  390.    remoteCanvas.setColumnWidth(3, MARGIN, true);
  391.    remoteCanvas.setRowHeight  (1, MARGIN, true);
  392.    remoteCanvas.setRowHeight  (11, MARGIN, true);
  393.  
  394. //*****************************************************************************
  395. //  Calculate size for control buttons to keep them all the same.             *
  396. //*****************************************************************************
  397.  
  398.    ISize bigbtn;
  399.    bigbtn = bigbtn.maximum(playbtn.minimumSize());
  400.    bigbtn = bigbtn.maximum(stopbtn.minimumSize());
  401.    bigbtn = bigbtn.maximum(rewbtn.minimumSize());
  402.    bigbtn = bigbtn.maximum(ffbtn.minimumSize());
  403.    bigbtn = bigbtn.maximum(pausebtn.minimumSize());
  404.    bigbtn = bigbtn.maximum(stepOrTrackBBtn.minimumSize());
  405.    bigbtn = bigbtn.maximum(stepOrTrackFBtn.minimumSize());
  406.    if (bigbtn.width() > bigbtn.height())
  407.       bigbtn.setHeight(bigbtn.width());
  408.    else bigbtn.setWidth(bigbtn.height());
  409.    playbtn.setMinimumSize( bigbtn );
  410.    stopbtn.setMinimumSize( bigbtn );
  411.    rewbtn.setMinimumSize( bigbtn );
  412.    ffbtn.setMinimumSize( bigbtn );
  413.    pausebtn.setMinimumSize( bigbtn );
  414.    stepOrTrackBBtn.setMinimumSize( bigbtn );
  415.    stepOrTrackFBtn.setMinimumSize( bigbtn );
  416.  
  417. //*****************************************************************************
  418. //  Build the controls canvas.  Columns 1 and 5 and rows 1 and 5 are margins  *
  419. //*****************************************************************************
  420.  
  421.    controls.addToCell(&playbtn,         3, 2, 1, 1);
  422.    controls.addToCell(&stopbtn,         3, 3, 1, 1);
  423.    controls.addToCell(&rewbtn,          2, 2, 1, 1);
  424.    controls.addToCell(&ffbtn,           4, 2, 1, 1);
  425.    controls.addToCell(&pausebtn,        3, 4, 1, 1);
  426.    controls.addToCell(&stepOrTrackBBtn, 2, 3, 1, 1);
  427.    controls.addToCell(&stepOrTrackFBtn, 4, 3, 1, 1);
  428.    controls.setColumnWidth(1, MARGIN, true);
  429.    controls.setColumnWidth(5, MARGIN, true);
  430.    controls.setRowHeight  (1, MARGIN, true);
  431.    controls.setRowHeight  (5, MARGIN, true);
  432.  
  433. //*****************************************************************************
  434. //  Calculate size for device buttons to keep them all the same.              *
  435. //*****************************************************************************
  436.  
  437.    ISize biggest;
  438.    biggest = biggest.maximum(videobtn.minimumSize());
  439.    biggest = biggest.maximum(midibtn.minimumSize());
  440.    biggest = biggest.maximum(cdbtn.minimumSize());
  441.    biggest = biggest.maximum(wavebtn.minimumSize());
  442.    videobtn.setMinimumSize( biggest );
  443.    midibtn.setMinimumSize( biggest );
  444.    cdbtn.setMinimumSize( biggest );
  445.    wavebtn.setMinimumSize( biggest );
  446.  
  447. //*****************************************************************************
  448. //  Build the devices canvas.  Columns 2, 4, and 6 are separators             *
  449. //*****************************************************************************
  450.  
  451.    devices.addToCell(&videobtn,     1, 1, 1, 1);
  452.    devices.addToCell(&midibtn,      3, 1, 1, 1);
  453.    devices.addToCell(&cdbtn,        5, 1, 1, 1);
  454.    devices.addToCell(&wavebtn,      7, 1, 1, 1);
  455.    devices.setColumnWidth( 1, IMultiCellCanvas::defaultCell().width(), true);
  456.    devices.setColumnWidth( 2, MARGIN);
  457.    devices.setColumnWidth( 3, IMultiCellCanvas::defaultCell().width(), true);
  458.    devices.setColumnWidth( 4, MARGIN);
  459.    devices.setColumnWidth( 5, IMultiCellCanvas::defaultCell().width(), true);
  460.    devices.setColumnWidth( 6, MARGIN);
  461.    devices.setColumnWidth( 7, IMultiCellCanvas::defaultCell().width(), true);
  462.  
  463. //*****************************************************************************
  464. //  Build the canvas containing the volume buttons                            *
  465. //*****************************************************************************
  466.  
  467.    volume.addToCell(&volupbtn,      1, 1, 1, 1);
  468.    volume.addToCell(&voldnbtn,      1, 2, 1, 1);
  469.  
  470. //*****************************************************************************
  471. //  Build the canvas containing the keypad and volume buttons canvases        *
  472. //*****************************************************************************
  473.  
  474.    volkey.addToCell(&pad,           1, 1, 1, 1);
  475.    volkey.addToCell(&volume,        3, 1, 1, 1);
  476.    volkey.setColumnWidth( 2, MARGIN, true);
  477.  
  478. //*****************************************************************************
  479. //  Set the background color for all canvases to black                        *
  480. //*****************************************************************************
  481.  
  482.    remoteCanvas.setBackgroundColor(IColor(IColor::black));
  483.    pad.setBackgroundColor(IColor(IColor::black));
  484.    devices.setBackgroundColor(IColor(IColor::black));
  485.    controls.setBackgroundColor(IColor(IColor::black));
  486.    volume.setBackgroundColor(IColor(IColor::black));
  487.    volkey.setBackgroundColor(IColor(IColor::black));
  488.  
  489. //*****************************************************************************
  490. //  Set up the readout for the player status line                             *
  491. //*****************************************************************************
  492.  
  493.    readout.setForegroundColor(IColor(0,160,0));
  494.    readout.setBackgroundColor(IColor(IColor::black));
  495.    readout.setText(IString(reslib.loadString(STR_TRACK)) + IString(newTrackDigit1) +
  496.                    IString(newTrackDigit2) + IString(reslib.loadString(STR_PAD)) +
  497.                    IString(reslib.loadString(STR_TIME_00)));
  498.    ISize charSize = readout.characterSize();
  499.    readout.setMinimumSize(ISize( charSize.width()*30, charSize.height()));
  500.  
  501. //*****************************************************************************
  502. // Have the command handler handle events for this window                     *
  503. //*****************************************************************************
  504.  
  505.    handler  = new MainHandler();
  506.    handler->handleEventsFor(this);
  507.  
  508.    if (cdPlayer)
  509.    {
  510.       cdPlayer->setVolume (50);
  511.       observer->handleNotificationsFor(*cdPlayer);
  512.    }
  513.    if (wavPlayer)
  514.    {
  515.       observer->handleNotificationsFor(*wavPlayer);
  516.    }
  517.    if (digPlayer)
  518.    {
  519.       observer->handleNotificationsFor(*digPlayer);
  520.    }
  521.    if (midPlayer)
  522.    {
  523.       observer->handleNotificationsFor(*midPlayer);
  524.    }
  525.  
  526. //*****************************************************************************
  527. //  Latch the button for the default device.  Until play is                   *
  528. //  pressed, disable the stop and pause buttons. By doing this latching after *
  529. //  the command handler is added, we can let the command handler do all of the*
  530. //  setup(enable, disable, and latch) for the buttons.                        *
  531. //*****************************************************************************
  532.  
  533.    switch (playerDevice)
  534.    {
  535.      case VIDEOID:
  536.           videobtn.click();
  537.           videobtn.latch();
  538.           break;
  539.      case MIDIID:
  540.           midibtn.click();
  541.           midibtn.latch();
  542.           break;
  543.      case CDID:
  544.           cdbtn.click();
  545.           cdbtn.latch();
  546.           break;
  547.      case WAVEID:
  548.           wavebtn.click();
  549.           wavebtn.latch();
  550.           break;
  551.      default:
  552.           remoteCanvas.disable();
  553.           break;
  554.    } /* endswitch */
  555.  
  556.  
  557. //*****************************************************************************
  558. //  Set up the fly over help handler                                          *
  559. //*****************************************************************************
  560.  
  561.    flyHelpHandler.handleEventsFor(this);
  562.  
  563. //*****************************************************************************
  564. //  Size the window to it's minimum size, give it focus and show it           *
  565. //*****************************************************************************
  566.  
  567.    setIcon(WINDOWID);
  568.    setClient(&remoteCanvas);
  569.    ISize size = remoteCanvas.minimumSize();
  570.    moveSizeToClient(IRectangle(MARGIN*3,
  571.                                MARGIN*3,
  572.                                MARGIN*3+size.width(),
  573.                                MARGIN*3+size.height()));
  574.    setFocus();
  575.    show();
  576. }
  577.  
  578. //*****************************************************************************
  579. //  newDigit routine manages digital input for CD player.                     *
  580. //*****************************************************************************
  581.  
  582. MainWindow& MainWindow::newDigit(int digit)
  583. {
  584.   IResourceLibrary reslib;
  585.   if (newTrackDigit2 ==-1)
  586.   {
  587.      newTrackDigit2 = digit;
  588.      readout.setText(IString(reslib.loadString(STR_TRACK)) + IString(newTrackDigit1) +
  589.                      IString(newTrackDigit2) + IString(reslib.loadString(STR_PAD)) +
  590.                      IString(reslib.loadString(STR_TIME_00)));
  591.      if (newTrackDigit1*10 + newTrackDigit2 > cdPlayer->numberOfTracks())
  592.      {
  593.         IMessageBox msgBox(this);
  594.         msgBox.show(IString(newTrackDigit1*10+newTrackDigit2) +
  595.                     IString(reslib.loadString(STR_INVALID_TRACK)) + IString(cdPlayer->numberOfTracks()) + IString(reslib.loadString(STR_TRACKS)),
  596.                     IMessageBox::okButton  |
  597.                     IMessageBox::errorIcon |
  598.                     IMessageBox::moveable );
  599.      } else
  600.      {
  601.         cdPlayer->goToEntry(newTrackDigit1*10 + newTrackDigit2);
  602.      } /* endif */
  603.   }
  604.   else
  605.   {
  606.     newTrackDigit1 = digit;
  607.     newTrackDigit2 = -1;
  608.     readout.setText(IString(reslib.loadString(STR_TRACK)) + IString(newTrackDigit1) +
  609.                     IString(reslib.loadString(STR_PAD)) + IString(reslib.loadString(STR_TIME_00)));
  610.   }
  611.   return *this;
  612. }
  613.  
  614. //*******************************************************************************
  615. // MainHandler::MainHandler                                                      *
  616. //                                                                              *
  617. // Constructs the handler.                                                      *
  618. //*******************************************************************************
  619. MainHandler::MainHandler()
  620.            : MainHandler::Inherited()
  621. {}
  622.  
  623. //*******************************************************************************
  624. // MainHandler::command                                                          *
  625. //                                                                              *
  626. // Does the processing for the button presses.                                  *
  627. //*******************************************************************************
  628.  
  629. IBase::Boolean MainHandler::command( ICommandEvent& event )
  630. {
  631.   IResourceLibrary reslib;
  632.   Boolean rv = false;
  633.   MainWindow* panel = (MainWindow*) (event.window());
  634.   switch ( event.commandId() )
  635.   {
  636.  
  637. //*****************************************************************************
  638. //  The power button is used to start a new device.  It loads the file to be  *
  639. //  played and sets up the device and buttons                                 *
  640. //*****************************************************************************
  641.   case POWERID:
  642.        {
  643.           IFileDialog::Settings fdSettings;
  644.           fdSettings.setTitle(STR_LOAD_DEVICE);
  645.           switch (panel->playerDevice)
  646.           {
  647. //*****************************************************************************
  648. //  Load a video file, using the file dialog.  Enable the control buttons     *
  649. //  and keypad, and set the status line text.  Start position tracking for    *
  650. //  timer.                                                                    *
  651. //*****************************************************************************
  652.  
  653.              case VIDEOID:
  654.                   {
  655.                   fdSettings.setFileName(reslib.loadString(STR_AVI));
  656.                   IFileDialog fd(panel->desktopWindow(),panel,fdSettings);
  657.                   if (fd.pressedOK())
  658.                   {
  659.                      panel->digPlayer->loadOnThread(fd.fileName());
  660.                      panel->digPlayer->startPositionTracking(IMMTime(3000));
  661.                      panel->digPlayer->setVolume(50);
  662.                      panel->stepOrTrackBBtn.enable();
  663.                      panel->stepOrTrackFBtn.enable();
  664.                      panel->readout.setText(IString(reslib.loadString(STR_TIME_00)));
  665.                      if (!panel->playbtn.isEnabled())
  666.                      {
  667.                         panel->playbtn.enable();
  668.                         panel->stopbtn.enable();
  669.                         panel->rewbtn.enable();
  670.                         panel->ffbtn.enable();
  671.                         panel->pausebtn.enable();
  672.                         panel->pad.enable();
  673.                      }
  674.                   }
  675.                   }
  676.                   break;
  677.  
  678. //*****************************************************************************
  679. //  Load a midi file, using the file dialog.  Enable the control buttons      *
  680. //  and set the status line text.  Start position tracking for timer.         *
  681. //*****************************************************************************
  682.  
  683.              case MIDIID:
  684.                   {
  685.                   fdSettings.setFileName(reslib.loadString(STR_MID_EXT));
  686.                   IFileDialog fd(panel->desktopWindow(),panel,fdSettings);
  687.                   if (fd.pressedOK())
  688.                   {
  689.                      panel->midPlayer->loadOnThread(fd.fileName());
  690.                      panel->midPlayer->startPositionTracking(IMMTime(3000));
  691.                      panel->midPlayer->setVolume(50);
  692.                      panel->readout.setText(IString(reslib.loadString(STR_TIME_00)));
  693.                      if (!panel->playbtn.isEnabled())
  694.                      {
  695.                         panel->playbtn.enable();
  696.                         panel->stopbtn.enable();
  697.                         panel->rewbtn.enable();
  698.                         panel->ffbtn.enable();
  699.                         panel->pausebtn.enable();
  700.                      }
  701.                   }
  702.                   }
  703.                   break;
  704.  
  705. //*****************************************************************************
  706. //  Load a wave file using the file dialog. Enable the control buttons and    *
  707. //  set the status line text.  Start position tracking for timer.             *
  708. //*****************************************************************************
  709.  
  710.              case WAVEID:
  711.                   {
  712.                   fdSettings.setFileName(reslib.loadString(STR_WAV_EXT));
  713.                   IFileDialog fd(panel->desktopWindow(),panel,fdSettings);
  714.                   if (fd.pressedOK())
  715.                   {
  716.                      panel->wavPlayer->loadOnThread(fd.fileName());
  717.                      panel->wavPlayer->startPositionTracking(IMMTime(3000));
  718.                      panel->wavPlayer->setVolume(50);
  719.                      panel->readout.setText(IString(reslib.loadString(STR_TIME_00)));
  720.                      if (!panel->playbtn.isEnabled())
  721.                      {
  722.                         panel->playbtn.enable();
  723.                         panel->stopbtn.enable();
  724.                         panel->rewbtn.enable();
  725.                         panel->ffbtn.enable();
  726.                         panel->pausebtn.enable();
  727.                      }
  728.                   }
  729.                   }
  730.                   break;
  731.           }
  732.           panel->powerbtn.setText(reslib.loadString(STR_POWER));
  733.           rv=true;
  734.        }
  735.        break;
  736.  
  737. //*****************************************************************************
  738. //  If CD button is pressed, set up the bitmaps on the buttons and the        *
  739. //  status line.                                                              *
  740. //*****************************************************************************
  741.  
  742.   case CDID:
  743.        panel->player->stop();
  744.        panel->pausebtn.unlatch();
  745.        panel->playbtn.unlatch();
  746.        panel->stopbtn.disable();
  747.        panel->pausebtn.disable();
  748.        panel->player=panel->cdPlayer;
  749.        if (panel->playerDevice!=CDID)
  750.        {
  751.          panel->player->setVolume(50);
  752.          panel->stepOrTrackBBtn.setBitmaps(IAnimatedButton::trackReverse);
  753.          panel->stepOrTrackFBtn.setBitmaps(IAnimatedButton::trackAdvance);
  754.          panel->stepOrTrackBBtn.enable();
  755.          panel->stepOrTrackFBtn.enable();
  756.          panel->readout.setText(IString(reslib.loadString(STR_TRACK)) + IString(panel->newTrackDigit1) +
  757.                    IString(panel->newTrackDigit2) + IString(reslib.loadString(STR_PAD)) +
  758.                    IString(reslib.loadString(STR_TIME_00)));
  759.          panel->flyHelpHandler.setFlyTextStringTableOffset(0);
  760.        }
  761.        panel->playerDevice=CDID;
  762.        if (!panel->playbtn.isEnabled())
  763.        {
  764.           panel->playbtn.enable();
  765.           panel->stopbtn.enable();
  766.           panel->rewbtn.enable();
  767.           panel->ffbtn.enable();
  768.           panel->pausebtn.enable();
  769.        }
  770.        panel->pad.enable();
  771.        rv=true;
  772.        break;
  773.  
  774. //*****************************************************************************
  775. // If video is pressed, disable the buttons until a file is loaded            *
  776. //*****************************************************************************
  777.  
  778.   case VIDEOID:
  779.        panel->player->stop();
  780.        panel->player=panel->digPlayer;
  781.        if (panel->playerDevice!=VIDEOID)
  782.        {
  783.           panel->stepOrTrackBBtn.setBitmaps(IAnimatedButton::stepBackward);
  784.           panel->stepOrTrackFBtn.setBitmaps(IAnimatedButton::stepForward );
  785.           panel->flyHelpHandler.setFlyTextStringTableOffset(VIDEO);
  786.        }
  787.        if (panel->playbtn.isLatched())
  788.           panel->playbtn.unlatch();
  789.        panel->playerDevice=VIDEOID;
  790.        panel->pausebtn.unlatch();
  791.        panel->playbtn.disable();
  792.        panel->stopbtn.disable();
  793.        panel->rewbtn.disable();
  794.        panel->ffbtn.disable();
  795.        panel->pausebtn.disable();
  796.        panel->stepOrTrackBBtn.disable();
  797.        panel->stepOrTrackFBtn.disable();
  798.        panel->pad.disable();
  799.        panel->powerbtn.setText(reslib.loadString(STR_LOAD_FILE) );
  800.        rv=true;
  801.        break;
  802.  
  803. //*****************************************************************************
  804. //  If midi device is selected, disable buttons until a file is loaded        *
  805. //*****************************************************************************
  806.  
  807.   case MIDIID:
  808.        panel->player->stop();
  809.        panel->player=panel->midPlayer;
  810.        panel->playerDevice=MIDIID;
  811.        if (panel->playbtn.isLatched())
  812.           panel->playbtn.unlatch();
  813.        panel->stepOrTrackBBtn.disable();
  814.        panel->stepOrTrackFBtn.disable();
  815.        panel->playbtn.disable();
  816.        panel->stopbtn.disable();
  817.        panel->rewbtn.disable();
  818.        panel->ffbtn.disable();
  819.        panel->pausebtn.unlatch();
  820.        panel->pausebtn.disable();
  821.        panel->pad.disable();
  822.        panel->powerbtn.setText(reslib.loadString(STR_LOAD_FILE) );
  823.        panel->flyHelpHandler.setFlyTextStringTableOffset(MIDI);
  824.        rv=true;
  825.        break;
  826. //*****************************************************************************
  827. //  If wave device is selected, disable buttons until a file is loaded        *
  828. //*****************************************************************************
  829.  
  830.   case WAVEID:
  831.        panel->player->stop();
  832.        panel->player=panel->wavPlayer;
  833.        panel->playerDevice=WAVEID;
  834.        if (panel->playbtn.isLatched())
  835.           panel->playbtn.unlatch();
  836.        panel->stepOrTrackBBtn.disable();
  837.        panel->stepOrTrackFBtn.disable();
  838.        panel->playbtn.disable();
  839.        panel->stopbtn.disable();
  840.        panel->rewbtn.disable();
  841.        panel->ffbtn.disable();
  842.        panel->pausebtn.unlatch();
  843.        panel->pausebtn.disable();
  844.        panel->pad.disable();
  845.        panel->powerbtn.setText(reslib.loadString(STR_LOAD_FILE));
  846.        panel->flyHelpHandler.setFlyTextStringTableOffset(WAVE);
  847.        rv=true;
  848.        break;
  849.  
  850. //*****************************************************************************
  851. // Step backward button.  For CD, back up to previous track                   *
  852. //*****************************************************************************
  853.  
  854.   case STEPTRACKBID:
  855.        if (panel->playerDevice==CDID)
  856.           panel->cdPlayer->trackBackward();
  857.        else
  858.        {
  859.           IMMTime::Format format = panel->player->timeFormat();
  860.           panel->player->setTimeFormat(IMMTime::mmTime);
  861.           if (panel->player->position())
  862.           {
  863.              panel->player->setTimeFormat(format);
  864.              panel->player->stepFrame(1,false);
  865.           }
  866.           else
  867.              panel->player->setTimeFormat(format);
  868.        }
  869.        break;
  870.  
  871. //*****************************************************************************
  872. //  Step forward button.  For CD, advance to next track                       *
  873. //*****************************************************************************
  874.  
  875.   case STEPTRACKFID:
  876.        if (panel->playerDevice==CDID)
  877.           panel->cdPlayer->trackForward();
  878.        else
  879.        {
  880.           IMMTime::Format format = panel->player->timeFormat();
  881.           panel->player->setTimeFormat(IMMTime::mmTime);
  882.           if (panel->player->position() < panel->player->length())
  883.           {
  884.              panel->player->setTimeFormat(format);
  885.              panel->player->stepFrame();
  886.           }
  887.           else
  888.              panel->player->setTimeFormat(format);
  889.        }
  890.        break;
  891.  
  892. //*****************************************************************************
  893. // If play is pressed, first check to see if already playing.  If not, enable *
  894. // pause and stop buttons and play.  If it is, relatch the play button        *
  895. //*****************************************************************************
  896.  
  897.   case PLAYID:
  898.        if (panel->player->mode() != IMMDevice::playing)
  899.        {
  900.           panel->stopbtn.enable();
  901.           panel->pausebtn.enable();
  902.           panel->pausebtn.unlatch();
  903.           panel->player->play();
  904.           panel->playHours=0;
  905.           panel->playMins=0;
  906.           panel->playSecs=0;
  907.         }
  908.        else panel->playbtn.latch();
  909.        rv=true;
  910.        break;
  911.  
  912. //*****************************************************************************
  913. //  If Stop is pressed, stop the player and reset to the beginning.  Disable  *
  914. //  stop and pause buttons                                                    *
  915. //*****************************************************************************
  916.  
  917.   case STOPID:
  918.        panel->player->stop();
  919.        panel->player->seekToStart();
  920.        panel->pausebtn.unlatch();
  921.        panel->playbtn.unlatch();
  922.        panel->stopbtn.disable();
  923.        panel->pausebtn.disable();
  924.        rv=true;
  925.        break;
  926.  
  927. //*****************************************************************************
  928. //  For rewind, reset to beginning of file, unlatch the play button and       *
  929. //  diable stop and pause                                                     *
  930. //*****************************************************************************
  931.  
  932.   case REWID:
  933.        if (panel->playerDevice == CDID) {
  934.           panel->cdPlayer->startScanningBackward() ;
  935.           panel->stopbtn.enable();
  936.        }
  937.        else {
  938.           panel->player->seekToStart();
  939.           panel->playbtn.unlatch();
  940.           panel->pausebtn.unlatch();
  941.           panel->stopbtn.disable();
  942.           panel->pausebtn.disable();
  943.        }
  944.        rv=true;
  945.        break;
  946.  
  947. //*****************************************************************************
  948. //  For fast forward, advance to end of file                                  *
  949. //*****************************************************************************
  950.  
  951.   case FFID:
  952.        if (panel->playerDevice == CDID) {
  953.           panel->cdPlayer->startScanningForward() ;
  954.           panel->stopbtn.enable();
  955.        }
  956.        else {
  957.           panel->player->seekToEnd();
  958.           panel->pausebtn.unlatch();
  959.           panel->playbtn.unlatch();
  960.           panel->stopbtn.disable();
  961.           panel->pausebtn.disable();
  962.        }
  963.        rv=true;
  964.        break;
  965.  
  966. //*****************************************************************************
  967. //  If pause, check pause state.  If paused, resume play, otherwise pause     *
  968. //*****************************************************************************
  969.  
  970.     case PAUSEID:
  971.        if ( panel->player->mode() != IMMDevice::playing )
  972.        {
  973.           panel->player->play();
  974.           panel->playbtn.latch();
  975.        }
  976.        else
  977.          panel->player->pause();
  978.  
  979.        rv=true;
  980.        break;
  981.  
  982. //*****************************************************************************
  983. //  Turn down volume 5%                                                       *
  984. //*****************************************************************************
  985.  
  986.   case VOLDNID:
  987.        panel->player->setVolume(panel->player->volume()-5);
  988.        rv=true;
  989.        break;
  990.  
  991. //*****************************************************************************
  992. //  Turn up volume 5%                                                         *
  993. //*****************************************************************************
  994.  
  995.   case VOLUPID:
  996.        panel->player->setVolume(panel->player->volume()+5);
  997.        rv=true;
  998.        break;
  999.  
  1000. //*****************************************************************************
  1001. // For one on keypad, enter digit 1 for CD, or play slow motion for video     *
  1002. //*****************************************************************************
  1003.  
  1004.   case ONEID:
  1005.        switch (panel->playerDevice){
  1006.        case CDID:
  1007.           panel->newDigit(1);
  1008.           rv=true;
  1009.           break;
  1010.        case VIDEOID:
  1011.           panel->digPlayer->playSlow();
  1012.           rv=true;
  1013.           break;
  1014.        }
  1015.        break;
  1016.  
  1017. //*****************************************************************************
  1018. //  For two on keypad, enter digit 2 for CD, or play fast speed for video     *
  1019. //*****************************************************************************
  1020.  
  1021.   case TWOID:
  1022.        switch (panel->playerDevice) {
  1023.        case CDID:
  1024.           panel->newDigit(2);
  1025.           rv=true;
  1026.           break;
  1027.        case VIDEOID:
  1028.           panel->digPlayer->playFast();
  1029.           rv=true;
  1030.           break;
  1031.        }
  1032.        break;
  1033.  
  1034. //*****************************************************************************
  1035. //  For three on keypad, enter digit 3 for CD, play in scan mode for video    *
  1036. //*****************************************************************************
  1037.  
  1038.   case THREEID:
  1039.        switch (panel->playerDevice){
  1040.        case CDID:
  1041.           panel->newDigit(3);
  1042.           rv=true;
  1043.           break;
  1044.        case VIDEOID:
  1045.           panel->digPlayer->playScan();
  1046.           rv=true;
  1047.           break;
  1048.        }
  1049.        break;
  1050.  
  1051. //*****************************************************************************
  1052. //  For digits 4-9, enter digit for CD track                                  *
  1053. //*****************************************************************************
  1054.  
  1055.   case FOURID:
  1056.        if (panel->playerDevice==CDID)
  1057.           panel->newDigit(4);
  1058.        rv=true;
  1059.        break;
  1060.   case FIVEID:
  1061.        if (panel->playerDevice==CDID)
  1062.           panel->newDigit(5);
  1063.        rv=true;
  1064.        break;
  1065.   case SIXID:
  1066.        if (panel->playerDevice==CDID)
  1067.           panel->newDigit(6);
  1068.        rv=true;
  1069.        break;
  1070.   case SEVENID:
  1071.        if (panel->playerDevice==CDID)
  1072.           panel->newDigit(7);
  1073.        rv=true;
  1074.        break;
  1075.   case EIGHTID:
  1076.        if (panel->playerDevice==CDID)
  1077.           panel->newDigit(8);
  1078.        rv=true;
  1079.        break;
  1080.   case NINEID:
  1081.        if (panel->playerDevice==CDID)
  1082.           panel->newDigit(9);
  1083.        rv=true;
  1084.        break;
  1085.  
  1086. //*****************************************************************************
  1087. //  For zero on keypad, enter 0 for CD, or resume normal play for video       *
  1088. //*****************************************************************************
  1089.  
  1090.   case ZEROID:
  1091.        switch (panel->playerDevice) {
  1092.        case CDID:
  1093.           if (panel->playerDevice==CDID && !(panel->newTrackDigit1==0 && panel->newTrackDigit2==-1))
  1094.           panel->newDigit(0);
  1095.           rv=true;
  1096.           break;
  1097.        case VIDEOID:
  1098.           panel->digPlayer->play();
  1099.           rv=true;
  1100.           break;
  1101.        }
  1102.        break;
  1103.   }
  1104.   return rv;
  1105. }
  1106.  
  1107. //*******************************************************************************
  1108. // MainObserver::MainObserver                                                     *
  1109. //                                                                              *
  1110. // Constructs the observer.                                                     *
  1111. //*******************************************************************************
  1112. MainObserver::MainObserver(MainWindow& mainPanel)
  1113.             : MainObserver::Inherited(),
  1114.               panel(mainPanel)
  1115. {}
  1116.  
  1117. //*****************************************************************************
  1118. //  Set up observer to track time and update status line for CD player        *
  1119. //*****************************************************************************
  1120.  
  1121. MainObserver& MainObserver::dispatchNotificationEvent(const INotificationEvent& event)
  1122. {
  1123.    IResourceLibrary reslib;
  1124.    if (event.notificationId() == IMMAudioCD::positionTimerId)
  1125.    {
  1126.       IMMTrackMinSecFrameTime* time = (IMMTrackMinSecFrameTime*)(event.eventData().asUnsignedLong());
  1127.       panel.readout.setText(IString(reslib.loadString(STR_TRACK)) +
  1128.                       IString(time->track()).rightJustify(2,'0') +
  1129.                       IString(reslib.loadString(STR_PAD)) +
  1130.                       IString(time->hours()).rightJustify(2,'0') +
  1131.                       IString(reslib.loadString(STR_COLON)) +
  1132.                       IString(time->minutes()).rightJustify(2,'0') +
  1133.                       IString(reslib.loadString(STR_COLON)) +
  1134.                       IString(time->seconds()).rightJustify(2,'0'));
  1135.    }
  1136.    else if (event.notificationId() == IMMAudioCD::trackStartedId)
  1137.    {
  1138.       IMMTrackMinSecFrameTime* time = (IMMTrackMinSecFrameTime*)(event.eventData().asUnsignedLong());
  1139.       panel.readout.setText(IString(reslib.loadString(STR_TRACK)) +
  1140.                       IString(time->track()).rightJustify(2,'0') +
  1141.                       IString(reslib.loadString(STR_PAD)) +
  1142.                       IString(time->hours()).rightJustify(2,'0') +
  1143.                       IString(reslib.loadString(STR_COLON)) +
  1144.                       IString(time->minutes()).rightJustify(2,'0') +
  1145.                       IString(reslib.loadString(STR_COLON)) +
  1146.                       IString(time->seconds()).rightJustify(2,'0'));
  1147.       if ((panel.cdPlayer->mode()==IMMDevice::playing) &&
  1148.           !(panel.playbtn.isLatched()))
  1149.          panel.playbtn.latch();
  1150.    } /* endif */
  1151.    else if (event.notificationId() == IMMDevice::positionChangeId)
  1152.    {
  1153.       IMMPositionChangeEvent* positionEvent = (IMMPositionChangeEvent*)(event.eventData().asUnsignedLong());
  1154.       IMMTime time(positionEvent->position());
  1155.  
  1156.       if ((panel.player)->deviceId() == (positionEvent->device())->deviceId() )
  1157.       {
  1158.          panel.readout.setText(
  1159.                          IString(time.hours()).rightJustify(2,'0') +
  1160.                          IString(reslib.loadString(STR_COLON)) +
  1161.                          IString(time.minutes()).rightJustify(2,'0') +
  1162.                          IString(reslib.loadString(STR_COLON)) +
  1163.                          IString(time.seconds()).rightJustify(2,'0'));
  1164.       }
  1165.  
  1166.    }
  1167.    else if (event.notificationId() == IMMDevice::commandNotifyId)
  1168.    {
  1169.       IMMNotifyEvent* notifyEvent = (IMMNotifyEvent*)(event.eventData().asUnsignedLong());
  1170.       if (notifyEvent->command() == IMMNotifyEvent::play)
  1171.       {
  1172.          panel.playbtn.unlatch();
  1173.          if (panel.playerDevice == CDID &&
  1174.              panel.cdPlayer->mode() == IMMDevice::playing)
  1175.          {
  1176.             panel.playbtn.latch();
  1177.          }
  1178.       }
  1179.    }
  1180.  
  1181.    return *this;
  1182. }
  1183.