home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / monitors / rsys / rsyssrc.lha / RSysGfxCtrl.c < prev    next >
C/C++ Source or Header  |  1993-09-19  |  2KB  |  119 lines

  1. /*
  2. ***************************************************************************
  3. *
  4. * Datei:
  5. *      RSysGfxCtrl.c
  6. *
  7. * Inhalt:
  8. *
  9. *      --- Globale Routinen ---
  10. *
  11. *    UWORD ComputeX ( UWORD value );
  12. *    UWORD ComputeY ( UWORD value );
  13. *    void ComputeFont ( struct Screen *wndscr , UWORD width , UWORD height );
  14. *    WORD compute ( UWORD offset , UWORD xy , int measure );
  15. *
  16. *      --- Lokale  Routinen ---
  17. *
  18. *
  19. * Bemerkungen:
  20. *      Graphics-Routinen für die Unterstützung fontsensitiver
  21. *      Benutzeroberflächen.
  22. *
  23. * Erstellungsdatum:
  24. *      25-Jun-93     Rolf Böhme
  25. *
  26. * Änderungen:
  27. *      25-Jun-93     Rolf Böhme      Erstellung
  28. *
  29. ***************************************************************************
  30. */
  31.  
  32. #include "RSys.h"
  33.  
  34.  
  35. /*
  36. * compute() berechnet die fontsensitiven Abmessungen von
  37. * Intuition-Objekten
  38. */
  39. WORD
  40. compute(UWORD offset, UWORD xy, int measure)
  41. {
  42.    return (offset + ((xy * (measure * FRAC)) / FULL));
  43. }
  44.  
  45. /*
  46. * computeX() berechnet einen Wert bezüglich der
  47. * Fontbreite
  48. */
  49. UWORD
  50. ComputeX(UWORD value)
  51. {
  52.    return ((UWORD) (((FontX * value) + 4) / 8));
  53. }
  54.  
  55. /*
  56. * computeY() berechnet einen Wert bezüglich der
  57. * Fonthöhe
  58. */
  59. UWORD
  60. ComputeY(UWORD value)
  61. {
  62.    return ((UWORD) (((FontY * value) + 4) / 8));
  63. }
  64.  
  65.  
  66. /*
  67. * ComputeFont() berechnet die korrekte Breite und Höhe eines
  68. * Fonts. Passen Höhe und Breite eines Abschnittes, verknüpft
  69. * mit den Fontdaten nicht auf den angegebenen Screen, wird der
  70. * System-Standard-Font topaz in der Größe 8 verwendet
  71. */
  72. void
  73. ComputeFont(struct Screen *wndscr, UWORD width, UWORD height)
  74. {
  75.    extern struct TextAttr TAttr;
  76.  
  77.    DPOS;
  78.  
  79.    if (Flags.sysfont)
  80.    {
  81.       Font = &Topaz80;
  82.       FontX = 8;
  83.       FontY = 8;
  84.       Font->ta_YSize = 8;
  85.    }
  86.    else
  87.    {
  88.       Forbid();
  89.       Font = &TAttr;
  90.        Font->ta_Name = (STRPTR)GfxBase->DefaultFont->tf_Message.mn_Node.ln_Name;
  91.        Font->ta_YSize = FontY = GfxBase->DefaultFont->tf_YSize;
  92.        FontX = GfxBase->DefaultFont->tf_XSize;
  93.       Permit();
  94.    }
  95.  
  96.    OffX = wndscr->WBorLeft;
  97.    OffY = wndscr->RastPort.TxHeight + wndscr->WBorTop + 1;
  98.  
  99.    if (width && height)
  100.    {
  101.       if ((ComputeX(width) + OffX + wndscr->WBorRight) > wndscr->Width) goto UseTopaz;
  102.       if ((ComputeY(height) + OffY + wndscr->WBorBottom) > wndscr->Height) goto UseTopaz;
  103.    }
  104.  
  105.    return;
  106.  
  107.  UseTopaz:
  108.    ErrorHandle((char *)Font->ta_Name, FONT_ERR, SIZE_FAIL, NO_KILL);
  109.  
  110.    Font = &Topaz80;
  111.    FontX = 8;
  112.    FontY = 8;
  113.    Font->ta_YSize = 8;
  114.  
  115.    Flags.sysfont = 1;
  116.  
  117.    return;
  118. }
  119.