home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / BORLAND TURBO / OWLSRC.PAK / DIBDC.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  3.9 KB  |  148 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.11  $
  6. //
  7. // Implementation of TDibDC encapsulation class, including the use of WinG when
  8. // needed.
  9. //----------------------------------------------------------------------------
  10. #include <owl/pch.h>
  11. #if !defined(OWL_DC_H)
  12. # include <owl/dc.h>
  13. #endif
  14. #if !defined(OWL_GDIOBJEC_H)
  15. # include <owl/gdiobjec.h>
  16. #endif
  17. #if !defined(OWL_WING_H) && defined(BI_PLAT_WIN16)
  18. # include <owl/wing.h>
  19. #endif
  20.  
  21. OWL_DIAGINFO;
  22. DIAG_DECLARE_GROUP(OwlGDI);        // General GDI diagnostic group
  23.  
  24. //
  25. // Construct a DC that can be used with DI Bitmaps. Under Win32 bitmaps
  26. // selected must be DIBSections, under Win16 they must be WinG bitmaps.
  27. //
  28. TDibDC::TDibDC()
  29. :
  30. #if defined(BI_PLAT_WIN16)
  31.   TMemoryDC(TWinG::IsAvailable() ? TWinG::Dll()->CreateDC() : 0, AutoDelete)
  32. #else
  33.   TMemoryDC()
  34. #endif
  35. {
  36. #if defined(BI_PLAT_WIN16)
  37.   CheckValid(TWinG::IsAvailable() ? IDS_WINGFAILURE : IDS_WINGNOTAVAILABLE);
  38. #else
  39.   CheckValid();
  40. #endif
  41. }
  42.  
  43. //
  44. // Construct a DC, same as above, then auto select the given bitmap in.
  45. //
  46. TDibDC::TDibDC(const TBitmap& bitmap)
  47. :
  48. #if defined(BI_PLAT_WIN16)
  49.   TMemoryDC(TWinG::IsAvailable() ? TWinG::Dll()->CreateDC() : 0, AutoDelete)
  50. #else
  51.   TMemoryDC()
  52. #endif
  53. {
  54.   CheckValid();
  55.   SelectObject(bitmap);
  56. }
  57.  
  58.  
  59. //
  60. // Get the color table of the currently selected bitmap.
  61. //
  62. uint
  63. TDibDC::GetDIBColorTable(uint start, uint count, RGBQUAD far* colors)
  64. {
  65. #if defined(BI_PLAT_WIN16)
  66.   if (TWinG::IsAvailable())
  67.     return TWinG::Dll()->GetDIBColorTable(GetHDC(), start, count, colors);
  68.   return 0;
  69. #else
  70.   return ::GetDIBColorTable(GetHDC(), start, count, colors);
  71. #endif
  72. }
  73.  
  74. //
  75. // Set the color table of the currently selected bitmap.
  76. //
  77. uint
  78. TDibDC::SetDIBColorTable(uint start, uint count, const RGBQUAD far* colors)
  79. {
  80. #if defined(BI_PLAT_WIN16)
  81.   if (TWinG::IsAvailable())
  82.     return TWinG::Dll()->SetDIBColorTable(GetHDC(), start, count, colors);
  83.   return 0;
  84. #else
  85.   return ::SetDIBColorTable(GetHDC(), start, count, colors);
  86. #endif
  87. }
  88.  
  89.  
  90. //
  91. // Dib Screen Update BitBlt's. A screen DC must be the destination.
  92. // BitBlts from this DIB onto the destination DC.
  93. //
  94. bool
  95. TDibDC::BitBltToScreen(TDC& dstDC, const TRect& dst, const TPoint& src) const
  96. {
  97. #if defined(BI_PLAT_WIN32)
  98.   return dstDC.BitBlt(dst, *this, src);
  99. #else
  100.   return TWinG::Dll()->BitBlt(dstDC, dst.left, dst.top, dst.Width(), dst.Height(),
  101.                             GetHDC(), src.x, src.y);
  102. #endif
  103. }
  104.  
  105. //
  106. // BitBlts from this DIB onto the destination DC.
  107. //
  108. bool
  109. TDibDC::BitBltToScreen(TDC& dstDC, int dstX, int dstY, int dstW, int dstH,
  110.                        int srcX, int srcY) const
  111. {
  112. #if defined(BI_PLAT_WIN32)
  113.   return dstDC.BitBlt(dstX, dstY, dstW, dstH, *this, srcX, srcY);
  114. #else
  115.   return TWinG::Dll()->BitBlt(dstDC, dstX, dstY, dstW, dstH, GetHDC(), srcX, srcY);
  116. #endif
  117. }
  118.  
  119. //
  120. // Stretches the DIB onto the destination DC.
  121. //
  122. bool
  123. TDibDC::StretchBltToScreen(TDC& dstDC, const TRect& dst, const TRect& src) const
  124. {
  125. #if defined(BI_PLAT_WIN32)
  126.   return dstDC.StretchBlt(dst, *this, src);
  127. #else
  128.   return TWinG::Dll()->StretchBlt(dstDC, dst.left, dst.top, dst.Width(), dst.Height(),
  129.                                 GetHDC(), src.left, src.top, src.Width(), src.Height());
  130. #endif
  131. }
  132.  
  133. //
  134. // Stretches the DIB onto the destination DC.
  135. //
  136. bool
  137. TDibDC::StretchBltToScreen(TDC& dstDC, int dstX, int dstY, int dstW, int dstH,
  138.                            int srcX, int srcY, int srcW, int srcH) const
  139. {
  140. #if defined(BI_PLAT_WIN32)
  141.   return dstDC.StretchBlt(dstX, dstY, dstW, dstH, *this, srcX, srcY, srcW, srcH);
  142. #else
  143.   return TWinG::Dll()->StretchBlt(dstDC, dstX, dstY, dstW, dstH,
  144.                                 GetHDC(), srcX, srcY, srcW, srcH);
  145. #endif
  146. }
  147.  
  148.