home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-02-21 | 2.9 KB | 120 lines | [TEXT/Rich] |
- // **************************************
- // * C Translation by Richard Bannister *
- // * *
- // * Titan Software *
- // * 76 Stillorgan Wood *
- // * Stillorgan, Co. Dublin *
- // * Republic of Ireland *
- // * *
- // * titan@indigo.ie *
- // * http://aoife.indigo.ie/~titan/ *
- // **************************************
-
- // A procedure for creating a face from a string. It uses the font, size
- and color from the current port.
-
- #include "SAT.h"
-
- #ifndef THINKC
- #define thePort qd.thePort
- #endif
-
- pascal FacePtr FaceFromText (Str255 myString, short shadow);
-
- pascal FacePtr FaceFromText (Str255 myString, short shadow)
- {
- FacePtr theTextFace;
- Rect r;
- short height, width;
-
- FontInfo info;
- short txFont;
- Style txFace;
- short txSize;
- RGBColor txColor;
- long txColor2;
- SATPort savePort;
-
- SATGetPort(&savePort);
-
- // Get font, etc, from the current port.
-
- GetFontInfo(&info);
-
- width = StringWidth(myString) + shadow;
- height = info.ascent + info.descent + shadow;
-
- txFont = thePort->txFont;
- txSize = thePort->txSize;
- txFace = thePort->txFace;
-
- if (gSAT.colorFlag)
- GetForeColor(&txColor);
- else
- txColor2 = thePort->fgColor;
-
- // Create the face
-
- SetRect(&r, 0, 0, width, height);
- theTextFace = SATNewFace(&r);
-
- SATSetPortFace(theTextFace);
-
- // Set up the face-port with the parameters we got above
-
- TextFont(txFont);
- TextSize(txSize);
- TextFace(txFace);
-
- if (gSAT.colorFlag)
- RGBForeColor(&txColor);
- else
- ForeColor(txColor2);
-
- EraseRect(&theTextFace->iconMask.bounds);
-
- // Draw Shadow, if any
-
- if (shadow != 0)
- {
- MoveTo(shadow, info.ascent + shadow);
- ForeColor(blackColor);
- DrawString(myString);
- }
-
- // Draw Text
-
- if (gSAT.colorFlag)
- RGBForeColor(&txColor);
- else
- ForeColor(txColor2);
-
- MoveTo(0, info.ascent);
- DrawString(myString);
-
- // Set the forecolor to black before leaving!
- ForeColor(blackColor);
-
- // Draw Mask
-
- SATSetPortMask(theTextFace);
- TextFont(txFont);
- TextSize(txSize);
- TextFace(txFace);
- EraseRect(&theTextFace->iconMask.bounds);
- MoveTo(0, info.ascent);
- DrawString(myString);
- if (shadow != 0)
- {
- MoveTo(shadow, info.ascent + shadow);
- DrawString(myString);
- }
-
- // Set the port back
-
- SATSetPort(&savePort);
- SATChangedFace(theTextFace);
-
- return theTextFace;
- }
-