home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 11.ddi / OWLSRC.PAK / FONT.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  2.8 KB  |  81 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1992, 1993 by Borland International
  3. //   source\owl\font.cpp
  4. //   Implementation for GDI Font object
  5. //----------------------------------------------------------------------------
  6. #include <owl\owlpch.h>
  7. #include <owl\gdiobjec.h>
  8.  
  9. DIAG_DECLARE_GROUP(OwlGDI);          // General GDI diagnostic group
  10. DIAG_DECLARE_GROUP(OwlGDIOrphan);    // Oprhan control tracing group
  11.  
  12. //
  13. // Constructors
  14. //
  15. TFont::TFont(HFONT handle, TAutoDelete autoDelete)
  16.   : TGdiObject(handle, autoDelete)
  17. {
  18.   #if !defined(NO_GDI_ORPHAN_CONTROL)
  19.     if (ShouldDelete)
  20.       OBJ_REF_ADD(Handle, Font);
  21.   #endif
  22. }
  23.  
  24. TFont::TFont(const char far* facename,
  25.              int height, int width, int escapement, int orientation, 
  26.              int weight,
  27.              BYTE pitchAndFamily,
  28.              BYTE italic, BYTE underline, BYTE strikeout, BYTE charSet,
  29.              BYTE outputPrecision, BYTE clipPrecision, BYTE quality)
  30. {
  31.   Handle = ::CreateFont(height, width, escapement, orientation, weight,
  32.                         italic, underline, strikeout, charSet,
  33.                         outputPrecision, clipPrecision, quality,
  34.                         pitchAndFamily, facename);
  35.   WARNX(OwlGDI, !Handle, 0, "Cannot create TFont (" << TResId(facename) << 
  36.         " " << height << "pt)");
  37.   CheckValid();
  38.   OBJ_REF_ADD(Handle, Font);
  39. }
  40.  
  41. TFont::TFont(int height, int width, int escapement, int orientation,
  42.              int weight,
  43.              BYTE italic, BYTE underline, BYTE strikeout,
  44.              BYTE charSet,
  45.              BYTE outputPrecision,
  46.              BYTE clipPrecision,
  47.              BYTE quality,
  48.              BYTE pitchAndFamily,
  49.              const char far* facename)
  50. {
  51.   Handle = ::CreateFont(height, width, escapement, orientation, weight,
  52.                         italic, underline, strikeout, charSet,
  53.                         outputPrecision, clipPrecision, quality,
  54.                         pitchAndFamily, facename);
  55.   WARNX(OwlGDI, !Handle, 0, "Cannot create TFont (" << TResId(facename) << 
  56.         " " << height << "pt)");
  57.   CheckValid();
  58.   OBJ_REF_ADD(Handle, Font);
  59. }
  60.  
  61. TFont::TFont(const LOGFONT far* logFont)
  62. {
  63.   PRECONDITION(logFont);
  64.   Handle = ::CreateFontIndirect((LPLOGFONT)logFont);  // API typecast
  65.   WARNX(OwlGDI, !Handle, 0, "Cannot create TFont from logfont @" << 
  66.         hex << DWORD(LPVOID(logFont)));
  67.   CheckValid();
  68.   OBJ_REF_ADD(Handle, Font);
  69. }
  70.  
  71. TFont::TFont(const TFont& src)
  72. {
  73.   LOGFONT logFont;
  74.   src.GetObject(logFont);
  75.   Handle = ::CreateFontIndirect(&logFont);
  76.   WARNX(OwlGDI, !Handle, 0, "Cannot create TFont from TFont @" << 
  77.         hex << DWORD(LPVOID(&src)));
  78.   CheckValid();
  79.   OBJ_REF_ADD(Handle, Font);
  80. }
  81.