home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 635.lha / MemSnap_v1.0 / wintext.c < prev    next >
C/C++ Source or Header  |  1992-03-30  |  2KB  |  77 lines

  1. /*
  2. *    wintext.h
  3. *
  4. *    Routines for font-independent window-text system, which allows
  5. *    writing of text based on character positions.
  6. *    Still being tweaked.
  7. *
  8. *    MWS 3/92.
  9. */
  10.  
  11. #include <exec/types.h>
  12. #include <graphics/gfxmacros.h>
  13. #include <intuition/intuition.h>
  14. #include <proto/graphics.h>
  15. #include <proto/intuition.h>
  16.  
  17. #include <string.h>
  18.  
  19. #include "wintext.h"
  20.  
  21. BOOL InitWinTextInfo(WINTEXTINFO *wti)    /* for Workbench screen at moment */
  22. {
  23.     struct Screen screen;
  24.     struct TextFont *tf;
  25.  
  26.     if (GetScreenData(&screen, sizeof(screen), WBENCHSCREEN, NULL))
  27.     {
  28.         if (tf = OpenFont(wti->tattr = screen.Font))    /* have a peek */
  29.         {
  30.             wti->font_x = tf->tf_XSize;
  31.             wti->font_y = tf->tf_YSize;
  32.             wti->font_baseline = tf->tf_Baseline;
  33.             wti->toffset = screen.WBorTop + tf->tf_YSize + 1;
  34.             wti->loffset = screen.WBorLeft+2;
  35.             wti->roffset = screen.WBorRight+2;
  36.             wti->boffset = screen.WBorBottom;
  37.  
  38.             CloseFont(tf);        /* should be set to rastport of window */
  39.             return TRUE;
  40.         }
  41.     }
  42.     return FALSE;
  43. }    
  44.  
  45.  
  46. void RenderWinTexts(WINTEXTINFO *info, WINTEXT *wt)
  47. {
  48.     struct RastPort *rp;
  49.  
  50.     while (wt)
  51.     {
  52.         rp = info->window->RPort;
  53.         SetAPen(rp, wt->pen);
  54.         SetDrMd(rp, wt->mode);
  55.         Move(rp, info->loffset + wt->lpos*info->font_x, 
  56.              info->toffset + wt->tpos*info->font_y + info->font_baseline);
  57.         Text(rp, wt->text, strlen(wt->text));
  58.         wt = wt->next;
  59.     }
  60. }
  61.  
  62. /****** UNUSED AT MOMENT 
  63.  
  64. void WinText(WINTEXTINFO *info, char *text,
  65.          UWORD lpos, UWORD tpos, UWORD pen, UWORD mode)
  66. {
  67.     struct RastPort *rp;
  68.  
  69.     rp = info->window->RPort;
  70.     SetAPen(rp, pen);
  71.     SetDrMd(rp, mode);
  72.     Move(rp, info->loffset + lpos*info->font_x, info->toffset + (tpos+1)*info->font_y);
  73.     Text(rp, text, strlen(text));
  74. }
  75.  
  76. ******/
  77.