home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / c / actlib11 / tvtools / inkey.cpp < prev    next >
C/C++ Source or Header  |  1993-01-19  |  1KB  |  62 lines

  1. /*  Copyright (C) 1993   Marc Stern  (internet: stern@mble.philips.be)  */
  2.  
  3. #define Uses_TStreamable
  4. #define Uses_MsgBox
  5. #define Uses_TInputKey
  6. #include "tvtools.h"
  7. __link( RInputLine )
  8.  
  9.  
  10. #include <string.h>
  11. #include <stdio.h>
  12. #include <values.h>
  13. #include <stdlib.h>
  14. #include <strstream.h>
  15.  
  16.  
  17. // TInputKey
  18.  
  19. const char *const TInputKey::name = "TInputKey";
  20.  
  21. TStreamable *TInputKey::build()
  22. {
  23.   return new TInputKey( streamableInit );
  24. }
  25.  
  26. TInputKey::TInputKey( const TRect& bounds, int aMaxLen )
  27.           :TInputLine( bounds, aMaxLen )
  28. {
  29. }
  30.  
  31. TInputKey::TInputKey( int x, int y, int aMaxLen )
  32.           :TInput1Line( x, y, aMaxLen )
  33. {
  34. }
  35.  
  36. TStreamableClass RInputKey( TInputKey::name,
  37.                             TInputKey::build,
  38.                             __DELTA(TInputKey)
  39.                           );
  40.  
  41.  
  42. Boolean TInputKey::valid( ushort command )
  43. {
  44.   switch( command )
  45.         {
  46.           case cmQuit :
  47.           case cmClose:
  48.           case cmOK   : if ( ! *data )
  49.                            {
  50.                              select();
  51.                              messageBox( "\03This field cannot be empty.",
  52.                                          mfError | mfOKButton
  53.                                        );
  54.                              return False;
  55.                            }
  56.                         break;
  57.         }
  58.  
  59.   return TInputLine::valid(command);
  60. }
  61.  
  62.