home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377a.lha / libraries / graphics / text / ShowDrawModes.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-02-04  |  2.9 KB  |  76 lines

  1. /* ShowDrawModes
  2.    Example to illustrate the different DrawModes.
  3.    Insert this routine into the "wrapper" code at the end of the chapter.
  4.  
  5.    Copyright (c) 1990 Commodore-Amiga, Inc.
  6.   
  7.    This example is provided in electronic form by Commodore-Amiga, Inc. for
  8.    use with the 1.3 revisions of the Addison-Wesley Amiga reference manuals. 
  9.    The 1.3 Addison-Wesley Amiga Reference Manual series contains additional
  10.    information on the correct usage of the techniques and operating system
  11.    functions presented in this example.  The source and executable code of
  12.    this example may only be distributed in free electronic form, via bulletin
  13.    board or as part of a fully non-commercial and freely redistributable
  14.    diskette.  Both the source and executable code (including comments) must
  15.    be included, without modification, in any copy.  This example may not be
  16.    published in printed form or distributed with any commercial product.
  17.    However, the programming techniques and support routines set forth in
  18.    this example may be used in the development of original executable
  19.    software products for Commodore Amiga computers.
  20.    All other rights reserved.
  21.    This example is provided "as-is" and is subject to change; no warranties
  22.    are made.  All use is at your own risk.  No liability or responsibility
  23.    is assumed.
  24. */
  25.  
  26.  
  27. BOOL example(struct Window *window)
  28. {
  29. struct RastPort *rastPort = window->RPort;
  30. /*  x and y will be used to position the text.  d (the amount to move
  31.     down to keep subsequent lines of text from overlapping) is 1 more
  32.     than the height of the default font for this RastPort.
  33. */
  34. SHORT x = window->BorderLeft;
  35. SHORT y = window->BorderTop + rastPort->TxBaseline;
  36. SHORT d = rastPort->TxHeight + 1;
  37. static UBYTE mode, modes[] =
  38.     {
  39.     JAM1, JAM2, COMPLEMENT
  40.     };
  41. static UBYTE *modeText[] =
  42.     {
  43.     " This is JAM1 DrawMode ",
  44.     " This is JAM2 DrawMode ",
  45.     " This is COMPLEMENT DrawMode "
  46.     };
  47.  
  48. TITLE(window, "The various DrawModes");
  49.  
  50. /* Set the A pen color to one which will stand out from both the
  51.    standard foreground and background Workbench colors.
  52. */
  53. SetAPen(rastPort, COLOR3);
  54. /* The B pen color will be the standard background color. */
  55. SetBPen(rastPort, COLOR0);
  56.  
  57. /* Fill the RastPort with a color other than the standard background color. */
  58. SetRast(rastPort, COLOR1);
  59.  
  60. /* Run through the three modes.  y is incremented by d pixels for each line. */
  61. for (mode=0; mode < 3; mode++, y+=d)
  62.     {
  63.     Move(rastPort, x, y);    /* Set the starting position. */
  64.     SetDrMd(rastPort, modes[mode] );    /* Set the draw mode. */
  65.     Text(rastPort, modeText[mode], strlen(modeText[mode]));
  66.     /* cp_x (current position for x) has increased by the length of the
  67.        string (in pixels), cp_y is unchanged.  The text that is about to
  68.        be rendered will begin at this position.
  69.     */
  70.     SetDrMd(rastPort, modes[mode] | INVERSVID );    /* "or" in INVERSVID. */
  71.     Text(rastPort, " and this is it in inverse. ", 28);
  72.     }
  73. return(WAIT_FOR_CLOSE);
  74. }
  75.  
  76.