home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tv20os2.zip / demos / TVEDIT2.CPP < prev    next >
C/C++ Source or Header  |  1992-06-11  |  3KB  |  110 lines

  1. /*----------------------------------------------------------*/
  2. /*                                                          */
  3. /*   Turbo Vision 1.0                                       */
  4. /*   Copyright (c) 1991 by Borland International            */
  5. /*                                                          */
  6. /*   Turbo Vision TVEDIT source file                        */
  7. /*----------------------------------------------------------*/
  8.  
  9. #define Uses_TDialog
  10. #define Uses_TDeskTop
  11. #define Uses_TProgram
  12. #define Uses_TApplication
  13. #define Uses_TObject
  14. #define Uses_TInputLine
  15. #define Uses_TLabel
  16. #define Uses_THistory
  17. #define Uses_TRect
  18. #define Uses_TCheckBoxes
  19. #define Uses_TButton
  20. #define Uses_TButton
  21. #define Uses_MsgBox
  22. #define Uses_TSItem
  23. #define Uses_TEditor
  24.  
  25. #include <tv.h>
  26.  
  27. #include "tvedit.h"
  28.  
  29. #include <stdlib.h>
  30. #include <stdarg.h>
  31. #include <strstrea.h>
  32. #include <iomanip.h>
  33.  
  34. ushort execDialog( TDialog *d, void *data )
  35. {
  36.     TView *p = TProgram::application->validView( d );
  37.     if( p == 0 )
  38.         return cmCancel;
  39.     else
  40.         {
  41.         if( data != 0 )
  42.             p->setData( data );
  43.         ushort result = TProgram::deskTop->execView( p );
  44.         if( result != cmCancel && data != 0 )
  45.             p->getData( data );
  46.         TObject::destroy( p );
  47.         return result;
  48.         }
  49. }
  50.  
  51. TDialog *createFindDialog()
  52. {
  53.     TDialog *d = new TDialog( TRect( 0, 0, 38, 12 ), "Find" );
  54.  
  55.     d->options |= ofCentered;
  56.  
  57.     TInputLine *control = new TInputLine( TRect( 3, 3, 32, 4 ), 80 );
  58.     d->insert( control );
  59.     d->insert(
  60.         new TLabel( TRect( 2, 2, 15, 3 ), "~T~ext to find", control ) );
  61.     d->insert(
  62.         new THistory( TRect( 32, 3, 35, 4 ), control, 10 ) );
  63.  
  64.     d->insert( new TCheckBoxes( TRect( 3, 5, 35, 7 ),
  65.         new TSItem( "~C~ase sensitive",
  66.         new TSItem( "~W~hole words only", 0 ))));
  67.  
  68.     d->insert(
  69.         new TButton( TRect( 14, 9, 24, 11 ), "O~K~", cmOK, bfDefault ) );
  70.     d->insert(
  71.         new TButton( TRect( 26, 9, 36, 11 ), "Cancel", cmCancel, bfNormal ) );
  72.  
  73.     d->selectNext( False );
  74.     return d;
  75. }
  76.  
  77. TDialog *createReplaceDialog()
  78. {
  79.     TDialog *d = new TDialog( TRect( 0, 0, 40, 16 ), "Replace" );
  80.  
  81.     d->options |= ofCentered;
  82.  
  83.     TInputLine *control = new TInputLine( TRect( 3, 3, 34, 4 ), 80 );
  84.     d->insert( control );
  85.     d->insert(
  86.         new TLabel( TRect( 2, 2, 15, 3 ), "~T~ext to find", control ) );
  87.     d->insert( new THistory( TRect( 34, 3, 37, 4 ), control, 10 ) );
  88.  
  89.     control = new TInputLine( TRect( 3, 6, 34, 7 ), 80 );
  90.     d->insert( control );
  91.     d->insert( new TLabel( TRect( 2, 5, 12, 6 ), "~N~ew text", control ) );
  92.     d->insert( new THistory( TRect( 34, 6, 37, 7 ), control, 11 ) );
  93.  
  94.     d->insert( new TCheckBoxes( TRect( 3, 8, 37, 12 ),
  95.         new TSItem("~C~ase sensitive",
  96.         new TSItem("~W~hole words only",
  97.         new TSItem("~P~rompt on replace",
  98.         new TSItem("~R~eplace all", 0 ))))));
  99.  
  100.     d->insert(
  101.         new TButton( TRect( 17, 13, 27, 15 ), "O~K~", cmOK, bfDefault ) );
  102.     d->insert( new TButton( TRect( 28, 13, 38, 15 ),
  103.                             "Cancel", cmCancel, bfNormal ) );
  104.  
  105.     d->selectNext( False );
  106.  
  107.     return d;
  108. }
  109.  
  110.