home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / owlsrc.pak / FONT.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-24  |  2.8 KB  |  83 lines

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