home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / windows / c / wvplr1 / wavexmpl.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-25  |  4.2 KB  |  170 lines

  1. /*  Project wpdemo
  2.     Lighthouse Engineering
  3.     Copyright   1994 by Lighthouse Engineering.  All Rights Reserved.
  4.  
  5.     SUBSYSTEM:    wpdemo.exe Application
  6.     FILE:         wavexmpl.cpp
  7.     AUTHOR:       K. Scott Piel
  8.  
  9.  
  10.     OVERVIEW
  11.     ========
  12.     Source file for implementation of WaveExample (TDialog).
  13. */
  14.  
  15. #include <owl\owlpch.h>
  16. #pragma hdrstop
  17.  
  18. #include <stdio.h>
  19. #include "wpdemo.h"
  20. #include "wavexmpl.h"
  21.  
  22.  
  23. DEFINE_RESPONSE_TABLE1(WaveExample, TDialog)
  24. //{{WaveExampleRSP_TBL_BEGIN}}
  25.     EV_BN_CLICKED(IDC_SAYIT, BNClickedSayIt),
  26.     EV_BN_CLICKED(IDC_DOUBLES, BNClickedDoubles),
  27.     EV_BN_CLICKED(IDC_LONGS, BNClickedLongs),
  28. //{{WaveExampleRSP_TBL_END}}
  29. END_RESPONSE_TABLE;
  30.  
  31.  
  32. //{{WaveExample Implementation}}
  33.  
  34.  
  35. static WaveExampleXfer WaveExampleData;
  36.  
  37. WaveExample::WaveExample (TWindow* parent, TResId resId, TModule* module):
  38.     TDialog(parent, resId, module)
  39. {
  40. //{{WaveExampleXFER_USE}}
  41.     NumDecimals          = new TEdit(this, IDC_DECIMALS, 3);
  42.     EnunciateValue       = new TEdit(this, IDC_NUMBERFLD, 12);
  43.     MinusRBtn            = new TRadioButton(this, IDC_MINUS, 0);
  44.     NegativeRBtn         = new TRadioButton(this, IDC_NEGATIVE, 0);
  45.     PLusMinusRBtn        = new TRadioButton(this, IDC_PLUSMINUS, 0);
  46.     PosNegRBtn           = new TRadioButton(this, IDC_POSNEG, 0);
  47.     PlayFromResourceRBtn = new TRadioButton(this, IDC_RESOURCE, 0);
  48.     UnsignedRBtn         = new TRadioButton(this, IDC_UNSIGNED, 0);
  49.     PlayFromDiskRBtn     = new TRadioButton(this, IDC_WAVEFILE, 0);
  50.     DoublesRBtn = new TRadioButton(this, IDC_DOUBLES, 0);
  51.     LongsRBtn = new TRadioButton(this, IDC_LONGS, 0);
  52.  
  53.     SetTransferBuffer(&WaveExampleData);
  54. //{{WaveExampleXFER_USE_END}}
  55.  
  56.     // INSERT>> Your constructor code here.
  57.  
  58. }
  59.  
  60.  
  61. void WaveExample::BNClickedSayIt ()
  62. {
  63.     // INSERT>> Your code here.
  64.  
  65.     wpSigns        sign;
  66.     int            precision;
  67.     double        dvalue;
  68.     long        lvalue;
  69.     char        numstr[15];
  70.     unsigned    *resource_list;
  71.     char        **file_list;
  72.     WavePlayer    Player( _hInstance, GetApplication() );
  73.  
  74.     // what signing method are we to use?
  75.  
  76.     if(      UnsignedRBtn->GetCheck()  == BF_CHECKED )    sign = wpUNSIGNED;
  77.     else if( MinusRBtn->GetCheck()     == BF_CHECKED )    sign = wpMINUS;
  78.     else if( NegativeRBtn->GetCheck()  == BF_CHECKED )    sign = wpNEGATIVE;
  79.     else if( PLusMinusRBtn->GetCheck() == BF_CHECKED )    sign = wpPLUS;
  80.     else                                                 sign = wpPOSITIVE;
  81.  
  82.     // input a precision
  83.  
  84.     NumDecimals->GetLine( numstr, sizeof(numstr), -1 );
  85.  
  86.     if( *numstr ) precision = *numstr - '0';
  87.     else          precision = 0;
  88.  
  89.     // input the value to be stated
  90.  
  91.     EnunciateValue->GetLine( numstr, sizeof(numstr), -1 );
  92.  
  93.     if(      DoublesRBtn->GetCheck()  == BF_CHECKED ) sscanf( numstr, "%lf", &dvalue );
  94.     else if( UnsignedRBtn->GetCheck() == BF_CHECKED ) sscanf( numstr, "%lu", &lvalue );
  95.     else                                              sscanf( numstr, "%ld", &lvalue );
  96.  
  97.     // convert the number to a wave string
  98.  
  99.     if( DoublesRBtn->GetCheck() == BF_CHECKED )
  100.         resource_list = Player.CvtNumToSndStr( dvalue, precision, sign );
  101.     else
  102.         resource_list = Player.CvtNumToSndStr( lvalue, sign );
  103.  
  104.     // if playing from disk, convert resource list to file list and play it
  105.  
  106.     if( PlayFromDiskRBtn->GetCheck() == BF_CHECKED )
  107.     {
  108.         file_list = Player.CvtSndStrToFileList( resource_list );
  109.         delete resource_list;
  110.  
  111.         Player.Execute( file_list );
  112.         delete file_list;
  113.     }
  114.  
  115.     // otherwise, play the string from the resources
  116.  
  117.     else
  118.     {
  119.         Player.Execute( resource_list );
  120.         delete resource_list;
  121.     }
  122. }
  123.  
  124.  
  125. WaveExample::~WaveExample ()
  126. {
  127.     Destroy();
  128.  
  129.     // INSERT>> Your destructor code here.
  130.  
  131. }
  132.  
  133. void WaveExample::SetupWindow ()
  134. {
  135.     TDialog::SetupWindow();
  136.  
  137.     // INSERT>> Your code here.
  138.  
  139.     if( DoublesRBtn->GetCheck() != BF_CHECKED && LongsRBtn->GetCheck() != BF_CHECKED )
  140.     {
  141.         LongsRBtn->Check();
  142.         UnsignedRBtn->Check();
  143.         PlayFromResourceRBtn->Check();
  144.     }
  145.  
  146.     NumDecimals->EnableWindow( DoublesRBtn->GetCheck() == BF_CHECKED );
  147.  
  148.     WavePlayer    Player( _hInstance, GetApplication() );
  149.  
  150.     GetApplication()->PumpWaitingMessages();
  151.     Player.Execute( IDW_MESSAGE );
  152. }
  153.  
  154. void WaveExample::BNClickedDoubles ()
  155. {
  156.     // INSERT>> Your code here.
  157.  
  158.     NumDecimals->EnableWindow( TRUE );
  159. }
  160.  
  161.  
  162. void WaveExample::BNClickedLongs ()
  163. {
  164.     // INSERT>> Your code here.
  165.  
  166.     NumDecimals->EnableWindow( FALSE );
  167. }
  168.  
  169.  
  170.