home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Reference_Library / lib_examples / intuitext.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-21  |  3.4 KB  |  103 lines

  1. ;/* intuitext.c - Execute me to compile me with SAS C 5.10
  2. LC -b1 -cfistq -v -y -j73 intuitext.c
  3. Blink FROM LIB:c.o,intuitext.o TO intuitext LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit
  5.  
  6. ** intuitext.c - program to show the use of an Intuition IntuiText object.
  7. */
  8. #define INTUI_V36_NAMES_ONLY
  9.  
  10. #include <exec/types.h>
  11. #include <intuition/intuition.h>
  12.  
  13. #include <clib/exec_protos.h>
  14. #include <clib/dos_protos.h>
  15. #include <clib/intuition_protos.h>
  16.  
  17. #include <stdio.h>
  18.  
  19. #ifdef LATTICE
  20. int CXBRK(void)    { return(0); }  /* Disable Lattice CTRL/C handling */
  21. int chkabort(void) { return(0); }  /* really */
  22. #endif
  23.  
  24. struct Library *IntuitionBase = NULL;
  25.  
  26. #define MYTEXT_LEFT (0)
  27. #define MYTEXT_TOP  (0)
  28.  
  29. /*
  30. ** main routine. Open required library and window and draw the images.
  31. ** This routine opens a very simple window with no IDCMP.  See the
  32. ** chapters on "Windows" and "Input and Output Methods" for more info.
  33. ** Free all resources when done.
  34. */
  35. VOID main(int argc, char **argv)
  36. {
  37. struct Screen    *screen;
  38. struct DrawInfo  *drawinfo;
  39. struct Window    *win;
  40. struct IntuiText  myIText;
  41. struct TextAttr   myTextAttr;
  42.  
  43. ULONG myTEXTPEN;
  44. ULONG myBACKGROUNDPEN;
  45.  
  46. IntuitionBase = OpenLibrary("intuition.library",37);
  47. if (IntuitionBase)
  48.     {
  49.     if (screen = LockPubScreen(NULL))
  50.         {
  51.         if (drawinfo = GetScreenDrawInfo(screen))
  52.             {
  53.             /* Get a copy of the correct pens for the screen.
  54.             ** This is very important in case the user or the
  55.             ** application has the pens set in a unusual way.
  56.             */
  57.             myTEXTPEN = drawinfo->dri_Pens[TEXTPEN];
  58.             myBACKGROUNDPEN  = drawinfo->dri_Pens[BACKGROUNDPEN];
  59.  
  60.             /* create a TextAttr that matches the specified font. */
  61.             myTextAttr.ta_Name  = drawinfo->dri_Font->tf_Message.mn_Node.ln_Name;
  62.             myTextAttr.ta_YSize = drawinfo->dri_Font->tf_YSize;
  63.             myTextAttr.ta_Style = drawinfo->dri_Font->tf_Style;
  64.             myTextAttr.ta_Flags = drawinfo->dri_Font->tf_Flags;
  65.  
  66.             /* open a simple window on the workbench screen for displaying
  67.             ** a text string.  An application would probably never use such a
  68.             ** window, but it is useful for demonstrating graphics...
  69.             */
  70.             if (win = OpenWindowTags(NULL,
  71.                                 WA_PubScreen,    screen,
  72.                                 WA_RMBTrap,      TRUE,
  73.                                 TAG_END))
  74.                 {
  75.                 myIText.FrontPen    = myTEXTPEN;
  76.                 myIText.BackPen     = myBACKGROUNDPEN;
  77.                 myIText.DrawMode    = JAM2;
  78.                 myIText.LeftEdge    = MYTEXT_LEFT;
  79.                 myIText.TopEdge     = MYTEXT_TOP;
  80.                 myIText.ITextFont   = &myTextAttr;
  81.                 myIText.IText       = "Hello, World.  ;-)";
  82.                 myIText.NextText    = NULL;
  83.  
  84.                 /* Draw the text string at 10,10 */
  85.                 PrintIText(win->RPort,&myIText,10,10);
  86.  
  87.                 /* Wait a bit, then quit.
  88.                 ** In a real application, this would be an event loop,
  89.                 ** like the one described in the Intuition Input and
  90.                 ** Output Methods chapter.
  91.                 */
  92.                 Delay(200);
  93.  
  94.                 CloseWindow(win);
  95.                 }
  96.             FreeScreenDrawInfo(screen,drawinfo);
  97.             }
  98.         UnlockPubScreen(NULL,screen);
  99.         }
  100.     CloseLibrary(IntuitionBase);
  101.     }
  102. }
  103.