home *** CD-ROM | disk | FTP | other *** search
- /*
- ***************************************************************************
- *
- * Datei:
- * RSysGfxCtrl.c
- *
- * Inhalt:
- *
- * --- Globale Routinen ---
- *
- * UWORD ComputeX ( UWORD value );
- * UWORD ComputeY ( UWORD value );
- * void ComputeFont ( struct Screen *wndscr , UWORD width , UWORD height );
- * WORD compute ( UWORD offset , UWORD xy , int measure );
- *
- * --- Lokale Routinen ---
- *
- *
- * Bemerkungen:
- * Graphics-Routinen für die Unterstützung fontsensitiver
- * Benutzeroberflächen.
- *
- * Erstellungsdatum:
- * 25-Jun-93 Rolf Böhme
- *
- * Änderungen:
- * 25-Jun-93 Rolf Böhme Erstellung
- *
- ***************************************************************************
- */
-
- #include "RSys.h"
-
-
- /*
- * compute() berechnet die fontsensitiven Abmessungen von
- * Intuition-Objekten
- */
- WORD
- compute(UWORD offset, UWORD xy, int measure)
- {
- return (offset + ((xy * (measure * FRAC)) / FULL));
- }
-
- /*
- * computeX() berechnet einen Wert bezüglich der
- * Fontbreite
- */
- UWORD
- ComputeX(UWORD value)
- {
- return ((UWORD) (((FontX * value) + 4) / 8));
- }
-
- /*
- * computeY() berechnet einen Wert bezüglich der
- * Fonthöhe
- */
- UWORD
- ComputeY(UWORD value)
- {
- return ((UWORD) (((FontY * value) + 4) / 8));
- }
-
-
- /*
- * ComputeFont() berechnet die korrekte Breite und Höhe eines
- * Fonts. Passen Höhe und Breite eines Abschnittes, verknüpft
- * mit den Fontdaten nicht auf den angegebenen Screen, wird der
- * System-Standard-Font topaz in der Größe 8 verwendet
- */
- void
- ComputeFont(struct Screen *wndscr, UWORD width, UWORD height)
- {
- extern struct TextAttr TAttr;
-
- DPOS;
-
- if (Flags.sysfont)
- {
- Font = &Topaz80;
- FontX = 8;
- FontY = 8;
- Font->ta_YSize = 8;
- }
- else
- {
- Forbid();
- Font = &TAttr;
- Font->ta_Name = (STRPTR)GfxBase->DefaultFont->tf_Message.mn_Node.ln_Name;
- Font->ta_YSize = FontY = GfxBase->DefaultFont->tf_YSize;
- FontX = GfxBase->DefaultFont->tf_XSize;
- Permit();
- }
-
- OffX = wndscr->WBorLeft;
- OffY = wndscr->RastPort.TxHeight + wndscr->WBorTop + 1;
-
- if (width && height)
- {
- if ((ComputeX(width) + OffX + wndscr->WBorRight) > wndscr->Width) goto UseTopaz;
- if ((ComputeY(height) + OffY + wndscr->WBorBottom) > wndscr->Height) goto UseTopaz;
- }
-
- return;
-
- UseTopaz:
- ErrorHandle((char *)Font->ta_Name, FONT_ERR, SIZE_FAIL, NO_KILL);
-
- Font = &Topaz80;
- FontX = 8;
- FontY = 8;
- Font->ta_YSize = 8;
-
- Flags.sysfont = 1;
-
- return;
- }
-