home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD v1.2 / amidev_cd_12.iso / reference / amiga_mail_vol2 / iv-41 / usemyic.c < prev   
C/C++ Source or Header  |  1996-01-30  |  5KB  |  129 lines

  1. /*
  2. Copyright (c) 1991 Commodore-Amiga, Inc.
  3.  
  4. This example is provided in electronic form by Commodore-Amiga,
  5. Inc. for use with the Amiga Mail Volume II technical publication.
  6. Amiga Mail Volume II contains additional information on the correct
  7. usage of the techniques and operating system functions presented in
  8. these examples.  The source and executable code of these examples may
  9. only be distributed in free electronic form, via bulletin board or
  10. as part of a fully non-commercial and freely redistributable
  11. diskette.  Both the source and executable code (including comments)
  12. must be included, without modification, in any copy.  This example
  13. may not be published in printed form or distributed with any
  14. commercial product. However, the programming techniques and support
  15. routines set forth in these examples may be used in the development
  16. of original executable software products for Commodore Amiga
  17. computers.
  18.  
  19. All other rights reserved.
  20.  
  21. This example is provided "as-is" and is subject to change; no
  22. warranties are made.  All use is at your own risk. No liability or
  23. responsibility is assumed.
  24.  *
  25.  * Compiled with SAS/C 6.56 NMINC STRMERGE OPTSIZE OPTIMIZE OPTGLOBAL NOSTKCHK
  26.  * (must be linked with mytextlabelclass.o, classface.o and hookface.o)
  27.  *
  28.  * Written by David N. Junod
  29.  */
  30.  
  31. #include <exec/types.h>
  32. #include <exec/libraries.h>
  33. #include <intuition/intuition.h>
  34. #include <intuition/classes.h>
  35. #include <intuition/classusr.h>
  36. #include <intuition/cghooks.h>
  37. #include <intuition/gadgetclass.h>
  38. #include <intuition/imageclass.h>
  39. #include <graphics/gfx.h>
  40. #include <graphics/gfxmacros.h>
  41. #include <libraries/gadtools.h>
  42. #include <utility/tagitem.h>
  43. #include <clib/macros.h>
  44. #include <clib/exec_protos.h>
  45. #include <clib/dos_protos.h>
  46. #include <clib/intuition_protos.h>
  47. #include <clib/graphics_protos.h>
  48. #include <clib/utility_protos.h>
  49. #include <string.h>
  50.  
  51. extern struct Library *SysBase, *DOSBase;
  52. struct Library *IntuitionBase, *GfxBase, *UtilityBase;
  53.  
  54. Class          *initmyTextLabelClass(VOID);
  55. ULONG           freemyTextLabelClass(Class * cl);
  56.  
  57. VOID
  58. main(VOID)
  59. {
  60.     Class          *cl;
  61.     struct Image   *im;
  62.     struct Window  *win;
  63.     struct RastPort *rp;
  64.     UWORD           top, left, height;
  65.  
  66.     /* Make sure we're at least using Version 2.0 */
  67.     if (IntuitionBase = OpenLibrary("intuition.library", 36))
  68.     {
  69.         GfxBase = OpenLibrary("graphics.library", 36);
  70.         UtilityBase = OpenLibrary("utility.library", 36);
  71.  
  72.         /* Open a window, without system gadgets or IDCMP events */
  73.         if (win = OpenWindowTags(NULL,
  74.                                  WA_Left, 10,
  75.                                  WA_Top, 10,
  76.                                  WA_Width, 320,
  77.                                  WA_Height, 100,
  78.                                  TAG_DONE))
  79.         {
  80.             /* Cache the pointer to the RastPort */
  81.             rp = win->RPort;
  82.  
  83.             /* Cache the upper-left coordinates of the window */
  84.             top = win->BorderTop + INTERHEIGHT;
  85.             left = win->BorderRight + INTERWIDTH;
  86.  
  87.             /* Cache the height of the font */
  88.             height = rp->TxHeight + INTERHEIGHT;
  89.  
  90.             /* Initialize the custom image class. */
  91.             if (cl = initmyTextLabelClass())
  92.             {
  93.                 /* Create a new image structure, using the given string. */
  94.                 if (im = NewObject(cl, NULL,
  95.                                    IA_Data, (ULONG) "Line _1",
  96.                                    TAG_DONE))
  97.                 {
  98.                     /* Paint using the provided text string. */
  99.                     DrawImageState(rp, im, left, top,
  100.                                    IDS_NORMAL, NULL);
  101.  
  102.                     /* Replace the text string, and paint it. */
  103.                     im->ImageData = (USHORT *) "Line _2";
  104.                     DrawImageState(rp, im, left, top + height,
  105.                                    IDS_NORMAL, NULL);
  106.  
  107.                     /* Replace the text string, and paint it. */
  108.                     im->ImageData = (USHORT *) "Line _3";
  109.                     DrawImageState(rp, im, left, top + (height * 2),
  110.                                    IDS_NORMAL, NULL);
  111.  
  112.                     /* Free the image. */
  113.                     DisposeObject(im);
  114.                 }
  115.  
  116.                 /* Free the image class. */
  117.                 freemyTextLabelClass(cl);
  118.             }
  119.  
  120.             Delay(250);
  121.             CloseWindow(win);
  122.         }
  123.  
  124.         CloseLibrary(UtilityBase);
  125.         CloseLibrary(GfxBase);
  126.         CloseLibrary(IntuitionBase);
  127.     }
  128. }
  129.