home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / TGE131.ZIP / INCLUDE / FIXFONT.H next >
C/C++ Source or Header  |  1994-03-05  |  3KB  |  100 lines

  1. /*****************************************************************************
  2. *       The Graphics Engine version 1.31                                     *
  3. *                                                                            *
  4. *       The Graphics Engine code and documentation are                       *
  5. *       Copyright (c) 1993-1994 by Matthew Hildebrand; all rights reserved.  *
  6. *                                                                            *
  7. *       Unauthorised usage or modification of any or all of The Graphics     *
  8. *       Engine is strictly prohibited.                                       *
  9. *****************************************************************************/
  10.  
  11. #if !defined(FONTdotH)
  12. #define FONTdotH
  13.  
  14.  
  15.  
  16. //*****
  17. //***** Bitmapped font services class
  18. //*****
  19.  
  20. class FixedFont
  21. {
  22.   unsigned charWide, charDeep;        // character cell dimensions
  23.   unsigned realCharWide;        // real character width (before adjustment)
  24.   unsigned char fgColour, bgColour;    // font colours (0=invisible)
  25.   void far *rawData;            // raw character data here
  26.   void far *image;            // buffer for putImageInv()
  27.   unsigned charSize;            // character image size in bytes
  28. public:
  29.   FixedFont(char *filename, unsigned char fg=1, unsigned char bg=0);
  30.   ~FixedFont();
  31.   inline int status(void);        // return status code (0=ERROR)
  32.   unsigned width(char *str);            // string width in pixels
  33.   inline unsigned width(char ch);       // character width in pixels
  34.   inline unsigned maxWidth(void);       // max character width in pixels
  35.   inline unsigned height(char *str);    // string depth in pixels
  36.   inline unsigned height(char ch);      // character depth in pixels
  37.   inline unsigned maxHeight(void);      // max character height in pixels
  38.   void put(int x, int y, char *str);    // write a string
  39.   void put(int x, int y, char ch);    // write a single character
  40.   inline void foreground(unsigned c);    // set foreground colour
  41.   inline void background(unsigned c);    // set background colour
  42.   inline unsigned foreground(void);    // get foreground colour
  43.   inline unsigned background(void);    // get background colour
  44. };
  45.  
  46.  
  47. inline int FixedFont::status(void)
  48. {
  49.   return (rawData==NULL ? 0 : 1);
  50. }
  51.  
  52. inline unsigned FixedFont::width(char)
  53. {
  54.   return (realCharWide);
  55. }
  56.  
  57. inline unsigned FixedFont::maxWidth(void)
  58. {
  59.   return (realCharWide);
  60. }
  61.  
  62. inline unsigned FixedFont::height(char *)
  63. {
  64.   return (charDeep);
  65. }
  66.  
  67. inline unsigned FixedFont::height(char)
  68. {
  69.   return (charDeep);
  70. }
  71.  
  72. inline unsigned FixedFont::maxHeight(void)
  73. {
  74.   return (charDeep);
  75. }
  76.  
  77. inline void FixedFont::foreground(unsigned colour)
  78. {
  79.   fgColour = colour;
  80. }
  81.  
  82. inline void FixedFont::background(unsigned colour)
  83. {
  84.   bgColour = colour;
  85. }
  86.  
  87. inline unsigned FixedFont::foreground(void)
  88. {
  89.   return (fgColour);
  90. }
  91.  
  92. inline unsigned FixedFont::background(void)
  93. {
  94.   return (bgColour);
  95. }
  96.  
  97.  
  98.  
  99. #endif
  100.