home *** CD-ROM | disk | FTP | other *** search
/ Windoware / WINDOWARE_1_6.iso / demos / tgtp60 / tutor.com / ICONS.TXT < prev    next >
Text File  |  1991-08-16  |  4KB  |  131 lines

  1. ICONS
  2. -------------------------------------------------------------------
  3.  
  4. Icons are a special kind of image that are drawn as they are used, they
  5. are not stored as bit images.
  6.  
  7. Icons are created with the ICON Editor. The ICON editor is included
  8. with the TEGL Windows Toolkit but is not included with the Intro Paks.
  9.  
  10. PutPict(x,y: Word; Icon: Pointer; Color: Word);
  11.  
  12. PutPict is the routine that draws an icon. The x,y parameters are the
  13. screen location to draw at. Icon points to a valid icon image, there
  14. is no checking done to see if the icon is a correct image. Color is
  15. the color that BLACK in the icon will be replaced with.
  16.  
  17. PutPict is NOT viewport relative and is never clipped.
  18.  
  19.  
  20. These are all the icons in teglicon.tpu and moreicon.tpu. Note that
  21. the actual name to refer to an icon is image<iconname>.
  22.  
  23. ARROWDN        ARROWLF         ARROWRT         ARROWUP
  24. BAR            BELL            BELL2           BLANKBUT
  25. BULB           C               CANCEL          CHK7X6
  26. CHK8X10        CHK8X12         CHK8X8          CLOCK
  27. COMPUTER       CORNER          CORNER2         CORNER3
  28. CREDITS        DISK            DISK35          DISKDRV
  29. DOCUMENT       DOWN            DRAWER          FILE
  30. FIND           KEYBOARD        KEYBRD2         LAST
  31. LBUT           LEFT            MBUT            MC
  32. MONITOR        MOUSE           MOUSE2          MUSIC
  33. MUSIC2         NEXT            NOTE            NOTE2
  34. OK             PREV            PRINTER         QUESTN2
  35. R              RBUT            READ            RESIZE
  36. RIGHT          SLIDER          SLIDER2         STOPSIGN
  37. SUBMENU        SYSTEM          TIGER           TINYTEGL
  38. TRASH          UP              VS              WFDN
  39. WFUP           WFICON          WFLF            WFRT
  40. WFUD           WFBAR           WRITE           WFMDN
  41.  
  42.  
  43.  
  44. This example simply create a frame a sticks an icon on it.
  45. Note that we use the x and y coordiates from the ImageStkPtr
  46. to place the iconimage.
  47.  
  48.  
  49. BEGINFILE> icon1.pas
  50. {-- icon1.pas}
  51.  
  52. USES
  53.   teglicon, moreicon,
  54.   tgraph, fastgrph,
  55.   teglunit, teglmain;
  56.  
  57.  
  58.  
  59. VAR ifs: ImageStkPtr;
  60.  
  61. BEGIN
  62.   easytegl;
  63.   easyout;
  64.   quickframe(ifs,100,100,110,100);
  65.  
  66.   {-- use the frames x and y fields to draw the icon }
  67.   {-- in a relative position }
  68.  
  69.   putpict(ifs^.x+10,ifs^.y+10,@imageSystem,BLACK);
  70.  
  71.  
  72.   teglsupervisor;
  73. END.
  74. ENDFILE>
  75.  
  76. PictSize(VAR width,height: Word; Icon: Pointer);
  77.  
  78. This function returns the size of an icon in pixels. Icon is the
  79. icon that we are interrogating. Width and Height return the
  80. respective x and y dimentions of the icon.
  81.  
  82.  
  83. This next example shows a routine that draws an icon relative to
  84. a frame and won't write outside the frame boundaries.
  85.  
  86. BEGINFILE> icon2.pas
  87. {-- icon2.pas}
  88.  
  89. USES
  90.   teglicon, moreicon,
  91.   tgraph, fastgrph,
  92.   teglunit, teglmain;
  93.  
  94.  
  95. {-- draw an icon image relative to a frame, do not draw it if }
  96. {-- it writes outside the frame }
  97.  
  98. Procedure PutPictRel(ifs: ImageStkPtr;
  99.                      x,y: Word; Icon: Pointer; Color: Word);
  100.   VAR dx,dy : Word;
  101.       fmaxx,fmaxy : Word;
  102.   BEGIN
  103.     PictSize(dx,dy,icon);
  104.     fmaxx := ifs^.x1 - ifs^.x + 1;
  105.     fmaxy := ifs^.y1 - ifs^.y + 1;
  106.     {-- check to see the icon will fit }
  107.     if ((x + dx) > fmaxx) OR ((y + dy) > fmaxy) THEN exit;
  108.     putpict(ifs^.x+x,ifs^.y+y,icon,color);
  109.   END;
  110.  
  111.  
  112. VAR ifs: ImageStkPtr;
  113.  
  114. BEGIN
  115.   easytegl;
  116.   easyout;
  117.   quickframe(ifs,100,100,110,100);
  118.  
  119.   {-- use the frames x and y fields to draw the icon }
  120.   {-- in a relative position }
  121.  
  122.   putpictRel(ifs,10,10,@imageSystem,BLACK);
  123.  
  124.  
  125.   teglsupervisor;
  126. END.
  127. ENDFILE>
  128.  
  129. ----------------------------------------------------------------------
  130. END ICONS
  131.