home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK4 / SAMPLES / CPPTUTOR / OOD / OODEMO.CP$ / OODEMO
Encoding:
Text File  |  1992-02-21  |  2.4 KB  |  82 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <new.h>
  4. #include "winmgr.h"
  5. #include "textwin.h"
  6. #include "lifewin.h"
  7.  
  8. int my_handler( size_t size )
  9. {
  10.     printf( "new failed on request for %d\n", size );
  11.     exit( -1 );
  12.     return 0;
  13. }
  14.  
  15. void main()
  16. {
  17.    Buffer buf1( 30, 40, RED_FORE | BLUE_BACK );
  18.    Buffer buf2( 10, 40, GREEN_FORE | BLACK_BACK );
  19.    Buffer buf3( 40, 15, BLACK_FORE | WHITE_BACK );
  20.    Buffer buf4( 50, 50, WHITE_FORE | BLACK_BACK );
  21.  
  22.    WinMgr winGrp;
  23.  
  24.    Event *evt;
  25.  
  26.    TextWin win1( Point( 30, 10 ), 17, 12, &buf1 );
  27.    TextWin win2( Point( 20, 5 ), 12, 12, &buf2 );
  28.    EditWin win3( Point( 40, 7 ), 12, 17, &buf3 );
  29.    LifeWin win4( Point( 45, 8 ), 22, 12, &buf4 );
  30.  
  31.    EventGenerator evtSource;
  32.  
  33.    buf1.putStr( Point( 0, 0 ),
  34.                "Whan that April with his shoures soot "
  35.                "/ the droght of March hath perced to the roote "
  36.                "/ and bathed every veyne in switch licour "
  37.                "/ of which vertu engendred is the flour "
  38.                "/ What Zephyrus eke with his sweete breeth "
  39.                "/ inspired hath in every holt and heeth "
  40.                "/ the tender croppes and the younge sonne "
  41.                "/ hath in the Ram his half course-y ronne ");
  42.  
  43.    buf2.putStr( Point( 0, 0 ),
  44.                 "Once upon a time, there was a little girl "
  45.                 "who lived in a cottage on the edge of a "
  46.                 "forest with her mother. She always wore a "
  47.                 "red hood when she went outside, so she was "
  48.                 "named Little Red Riding Hood. ");
  49.  
  50.    buf3.putStr( Point( 0, 0 ),
  51.                 "To be or not to be: that is the question "
  52.                 " whether tis nobler in the mind to suffer "
  53.                 "the slings and arrows of outrageous fortune "
  54.                 "or to take up arms against a sea of troubles "
  55.                 "and by opposing, end them. ");
  56.  
  57.    _set_new_handler( my_handler );
  58.  
  59.    win1.setTitle( "TextWin1" );
  60.    winGrp.addWindow( &win1 );
  61.  
  62.    win2.setTitle( "TextWin2" );
  63.    winGrp.addWindow( &win2 );
  64.  
  65.    win3.setTitle( "EditWin" );
  66.    winGrp.addWindow( &win3 );
  67.  
  68.    win4.setTitle( "LifeWin" );
  69.    winGrp.addWindow( &win4 );
  70.  
  71.    winGrp.repaint( Rect( 1, 1, 80, 25 ) );
  72.  
  73.    for(;;)
  74.    {
  75.       if( evt = evtSource.getNextEvent() )
  76.       {
  77.           winGrp.handleEvent( *evt );
  78.           delete evt;
  79.       }
  80.    }
  81. }
  82.