home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / QuickDraw / DrawLine / DrawLine.c next >
Encoding:
C/C++ Source or Header  |  1995-05-10  |  2.1 KB  |  113 lines  |  [TEXT/MMCC]

  1. /****************************************************************************/
  2. /*                                                                            */
  3. /*    Application:    DrawLine                                                */
  4. /*                                                                            */
  5. /*    Description:    This application shows how to use the QuickDraw         */
  6. /*                    pattern mode 'srcCopy' to invert the intersection        */
  7. /*                    of the two green lines.                                    */
  8. /*                                                                            */
  9. /*    Files:            DrawLine.c                                                */
  10. /*                                                                            */
  11. /*    Programmer:        Greg Henderson                                            */
  12. /*    Organization:    Apple Computer, Inc.                                    */
  13. /*    Department:        Developer Technical Support, DTS                        */
  14. /*    Language:        CodeWarrior C/C++                                        */
  15. /*    Date Created:    05-10-95                                                */
  16. /*                                                                            */
  17. /****************************************************************************/
  18.  
  19. #define KBaseResID            128
  20. #define kMoveToFront        (WindowPtr)-1L
  21.  
  22.  
  23. /*********************/
  24. /*    Functions         */
  25. /*********************/
  26.  
  27. void    ToolBoxInit( void );
  28. void    WindowInit( void );
  29. void    DrawLine( void );
  30.  
  31.  
  32. /*************** main ***************/
  33.  
  34. void    main( void )
  35.  
  36. {
  37.     ToolBoxInit();
  38.     WindowInit();
  39.     DrawLine();
  40.     
  41.     while ( !Button() );
  42.     
  43. }
  44.  
  45. /*************** ToolBoxInit ***************/
  46.  
  47. void    ToolBoxInit( void )
  48.  
  49. {
  50.     InitGraf(&qd.thePort);          /* init Quickdraw and global variables        */
  51.     InitFonts();
  52.     InitWindows();
  53.     InitMenus();
  54.     TEInit();
  55.     InitDialogs( nil );
  56.     InitCursor();
  57.     
  58. }
  59.  
  60. /*************** WindowInit ***************/
  61.  
  62. void    WindowInit( void )
  63.  
  64. {
  65.     WindowPtr    window;
  66.  
  67.     window = GetNewCWindow( KBaseResID, nil, kMoveToFront );
  68.     
  69.     if ( window == nil )
  70.     {
  71.         SysBeep ( 10 );    /* Couldn't load the WIND resource! */
  72.         ExitToShell();
  73.     }
  74.     
  75.     ShowWindow( window );
  76.     SetPort( window );
  77. }
  78.  
  79. /*************** Draw two Lines ***************/
  80.  
  81. void    DrawLine( )
  82. {
  83.     Rect        pictureRect;
  84.     WindowPtr    window;    
  85.     
  86.     window    =    FrontWindow();
  87.     pictureRect = window->portRect;
  88.     
  89.     PenNormal() ;
  90.     PenSize(5,5);
  91.  
  92.     ForeColor( blackColor );
  93.         PenMode(srcCopy);
  94.          MoveTo(  50, 47 );
  95.         LineTo( 300,231 );
  96.         
  97.          PenMode(srcXor);
  98.         MoveTo( 400, 47 );
  99.         LineTo( 200,231 ); 
  100.     
  101.     
  102.        ForeColor( greenColor );
  103.         PenMode(addMax);
  104.          MoveTo( 50, 47 );
  105.         LineTo(300,231);
  106.         
  107.         PenMode(addMax);
  108.         MoveTo( 400, 47 );
  109.         LineTo( 200,231 ); 
  110.     
  111. }
  112.  
  113.