home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / jËzyki_programowania / amigae / e_v3.2a / rkrmsrc / intuition / images_text / intuitext.e < prev    next >
Text File  |  1977-12-31  |  2KB  |  65 lines

  1. -> intuitext.e - Program to show the use of an Intuition IntuiText object.
  2.  
  3. OPT OSVERSION=37  -> E-Note: silently require V37
  4.  
  5. MODULE 'exec/ports',
  6.        'exec/nodes',
  7.        'graphics/rastport',
  8.        'graphics/text',
  9.        'intuition/intuition',
  10.        'intuition/screens'
  11.  
  12. ENUM ERR_NONE, ERR_DRAW, ERR_PUB, ERR_WIN
  13.  
  14. RAISE ERR_DRAW IF GetScreenDrawInfo()=NIL,
  15.       ERR_PUB  IF LockPubScreen()=NIL,
  16.       ERR_WIN  IF OpenWindowTagList()=NIL
  17.  
  18. CONST MYTEXT_LEFT=0, MYTEXT_TOP=0
  19.  
  20. -> Main routine. Open required window and draw the images.  This routine opens
  21. -> a very simple window with no IDCMP.  See the chapters on "Windows" and
  22. -> "Input and Output Methods" for more info.  Free all resources when done.
  23. PROC main() HANDLE
  24.   DEF screen=NIL, drawinfo=NIL:PTR TO drawinfo, win=NIL:PTR TO window,
  25.       myTEXTPEN, myBACKGROUNDPEN
  26.  
  27.   screen:=LockPubScreen(NIL)
  28.  
  29.   drawinfo:=GetScreenDrawInfo(screen)
  30.  
  31.   -> Get a copy of the correct pens for the screen.  This is very important in
  32.   -> case the user or the application has the pens set in a unusual way.
  33.   myTEXTPEN:=drawinfo.pens[TEXTPEN]
  34.   myBACKGROUNDPEN:=drawinfo.pens[BACKGROUNDPEN]
  35.  
  36.   -> Open a simple window on the workbench screen for displaying a text string.
  37.   -> An application would probably never use such a window, but it is useful
  38.   -> for demonstrating graphics...
  39.   win:=OpenWindowTagList(NIL, [WA_PUBSCREEN, screen, WA_RMBTRAP, TRUE, NIL])
  40.  
  41.  
  42.   -> Draw the text string at 10, 10
  43.   PrintIText(win.rport,
  44.              [myTEXTPEN, myBACKGROUNDPEN, RP_JAM2, MYTEXT_LEFT, MYTEXT_TOP,
  45.               [drawinfo.font.mn.ln.name, drawinfo.font.ysize,
  46.                drawinfo.font.style, drawinfo.font.flags]:textattr,
  47.               'Hello, World.  ;-)', NIL]:intuitext,
  48.              10, 10)
  49.  
  50.   -> Wait a bit, then quit.
  51.   -> In a real application, this would be an event loop, like the one described
  52.   -> in the Intuition Input and Output Methods chapter.
  53.   Delay(200)
  54.  
  55. EXCEPT DO
  56.   IF win THEN CloseWindow(win)
  57.   IF drawinfo THEN FreeScreenDrawInfo(screen, drawinfo)
  58.   IF screen THEN UnlockPubScreen(NIL, screen)
  59.   SELECT exception
  60.   CASE ERR_DRAW; WriteF('Error: Failed to get DrawInfo for screen\n')
  61.   CASE ERR_PUB;  WriteF('Error: Failed to lock public screen\n')
  62.   CASE ERR_WIN;  WriteF('Error: Failed to open window\n')
  63.   ENDSELECT
  64. ENDPROC
  65.