home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 19.ddi / OWLINC.PAK / DC.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  52.1 KB  |  1,531 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1992, 1993 by Borland International
  3. //   include\owl\dc.h
  4. //   Definition of DC classes
  5. //----------------------------------------------------------------------------
  6. #if !defined(__OWL_DC_H)
  7. #define __OWL_DC_H
  8.  
  9. #if !defined(__OWL_GDIBASE_H)
  10.   #include <owl\gdibase.h>
  11. #endif
  12. #if !defined(__PRINT_H) && !defined(__WIN32__)
  13.   #include <print.h>      // Win16 printing and some general DC APIs
  14. #endif
  15.  
  16. class _OWLCLASS TPen;
  17. class _OWLCLASS TBrush;
  18. class _OWLCLASS TFont;
  19. class _OWLCLASS TBitmap;
  20. class _OWLCLASS TPalette;
  21. class _OWLCLASS TIcon;
  22. class _OWLCLASS TDib;
  23. class _OWLCLASS TRegion;
  24. class _OWLCLASS TMetaFilePict;
  25.  
  26. #if defined(__WIN32__)
  27.   #define OLDFONTENUMPROC FONTENUMPROC
  28. #else
  29.   // Win 32 object defines for 16 bit GetCurrentObject emulation
  30.   #define OBJ_PEN             1
  31.   #define OBJ_BRUSH           2
  32.   #define OBJ_PAL             5
  33.   #define OBJ_FONT            6
  34. #endif
  35.  
  36. //
  37. // class TDC
  38. // ----- ---
  39. //
  40. // Root class for GDI DC.  This class can be instantiated, or
  41. // specialized subclasses can be used to get specific behavior.
  42. // Tracks & restores handles of first GDI objects that are replaced by
  43. // ::SelectObject()
  44. // Can be used as an interface to a borrowed handle.
  45. //
  46. class _OWLCLASS TDC : private TGdiBase {
  47.   public:
  48.     // Constructors / destructor
  49.     TDC(HDC handle);  // use an existing DC, doesn't auto delete it
  50.     virtual    ~TDC();
  51.  
  52.     // Type Conversion Operators
  53.     operator    HDC() const {return HDC(Handle);}  // Must assume const is OK
  54.  
  55.     // DC functions
  56.     BOOL         GetDCOrg(TPoint& point) const;
  57.     virtual int  SaveDC() const;
  58.     virtual BOOL RestoreDC(int savedDC = -1);
  59.     virtual int  GetDeviceCaps(int index) const;
  60.     virtual BOOL ResetDC(DEVMODE far& devMode);
  61.  
  62.     // Select GDI objects into this DC and restore them to original
  63.     void         SelectObject(const TBrush& brush);
  64.     void         SelectObject(const TPen& pen);
  65.     virtual void SelectObject(const TFont& font);
  66.     void         SelectObject(const TPalette& palette, BOOL forceBackground=FALSE);
  67.     virtual void SelectStockObject(int index);
  68.     void         RestoreBrush();
  69.     void         RestorePen();
  70.     virtual void RestoreFont();
  71.     void         RestorePalette();
  72.     #if defined(__WIN32__)
  73.       void       RestoreTextBrush();
  74.     #endif
  75.     void         RestoreObjects();
  76.     HANDLE       GetCurrentObject(UINT objectType) const;
  77.  
  78.     // Drawing tool functions
  79.     BOOL         GetBrushOrg(TPoint& point) const;
  80.     BOOL         SetBrushOrg(const TPoint& origin, TPoint far* oldOrg=0);
  81.     int          EnumObjects(UINT objectType, GOBJENUMPROC proc, LPVOID data) const;
  82.  
  83.     // Color and palette functions
  84.     TColor       GetNearestColor(TColor Color) const;
  85.     int          RealizePalette();
  86.     void         UpdateColors();
  87.     UINT         GetSystemPaletteEntries(int start, int num, 
  88.                                          PALETTEENTRY far* entries) const;
  89.     UINT         GetSystemPaletteUse() const;
  90.     int          SetSystemPaletteUse(int usage);
  91.  
  92.     // Drawing attribute functions
  93.     TColor         GetBkColor() const;
  94.     virtual TColor SetBkColor(TColor color);
  95.     int          GetBkMode() const;
  96.     int          SetBkMode(int mode);
  97.     int          GetPolyFillMode() const;
  98.     int          SetPolyFillMode(int mode);
  99.     int          GetROP2() const;
  100.     int          SetROP2(int mode);
  101.     int          GetStretchBltMode() const;
  102.     int          SetStretchBltMode(int mode);
  103.     TColor         GetTextColor() const;
  104.     virtual TColor SetTextColor(TColor color);
  105.     #if defined(__WIN32__)
  106.       BOOL       SetMiterLimit(float newLimit, float* oldLimit=0);
  107.     #endif
  108.  
  109.     // Viewport & window mapping functions
  110.     int          GetMapMode() const;
  111.     virtual int  SetMapMode(int mode);
  112.     #if defined(__WIN32__)
  113.       BOOL       SetWorldTransform(XFORM far& xform);
  114.       BOOL       ModifyWorldTransform(XFORM far& xform, DWORD mode);
  115.     #endif
  116.  
  117.     BOOL         GetViewportOrg(TPoint& point) const;
  118.     TPoint       GetViewportOrg() const;
  119.     virtual BOOL SetViewportOrg(const TPoint& origin, TPoint far* oldOrg=0);
  120.     virtual BOOL OffsetViewportOrg(const TPoint& delta, TPoint far* oldOrg=0);
  121.  
  122.     BOOL         GetViewportExt(TSize& extent) const;
  123.     TSize        GetViewportExt() const;
  124.     virtual BOOL SetViewportExt(const TSize& extent, TSize far* oldExtent=0);
  125.     virtual BOOL ScaleViewportExt(int xNum, int xDenom, int yNum, int yDenom,
  126.                                   TSize far* oldExtent=0);
  127.  
  128.     BOOL         GetWindowOrg(TPoint& point) const;
  129.     TPoint       GetWindowOrg() const;
  130.     BOOL         SetWindowOrg(const TPoint& origin, TPoint far* oldOrg=0);
  131.     BOOL         OffsetWindowOrg(const TPoint& delta, TPoint far* oldOrg=0);
  132.  
  133.     BOOL         GetWindowExt(TSize& extent) const;
  134.     TSize        GetWindowExt() const;
  135.     virtual BOOL SetWindowExt(const TSize& extent, TSize far* oldExtent=0);
  136.     virtual BOOL ScaleWindowExt(int xNum, int xDenom, int yNum, int yDenom,
  137.                                 TSize far* oldExtent=0);
  138.  
  139.     // Coordinate functions
  140.     BOOL        DPtoLP(TPoint* points, int count = 1) const;
  141.     BOOL        LPtoDP(TPoint* points, int count = 1) const;
  142.  
  143.     // Clip & Update Rect & Rgn functions
  144.     int         GetClipBox(TRect& rect) const;
  145.     TRect       GetClipBox() const;
  146.     int         ExcludeClipRect(const TRect& rect);
  147.     int         ExcludeUpdateRgn(HWND wnd);
  148.     int         IntersectClipRect(const TRect& rect);
  149.     int         OffsetClipRgn(const TPoint& delta);
  150.     int         SelectClipRgn(const TRegion& region);
  151.     BOOL        PtVisible(const TPoint& point) const;
  152.     BOOL        RectVisible(const TRect& rect) const;
  153.     BOOL        GetBoundsRect(TRect& bounds, WORD flags) const;
  154.     UINT        SetBoundsRect(TRect& bounds, UINT flags);
  155.     BOOL        GetClipRgn(TRegion& region) const;
  156.  
  157.     // MetaFile functions
  158.     int         EnumMetaFile(const TMetaFilePict& metaFile,
  159.                              MFENUMPROC callback, LPVOID data) const;
  160.     BOOL        PlayMetaFile(const TMetaFilePict& metaFile);
  161.     void        PlayMetaFileRecord(HANDLETABLE far& Handletable,
  162.                                    METARECORD far& metaRecord, int count);
  163.  
  164.     // Output functions- Current position
  165.     BOOL        GetCurrentPosition(TPoint& point) const;
  166.     BOOL        MoveTo(int x, int y);
  167.     BOOL        MoveTo(const TPoint& point);
  168.     BOOL        MoveTo(const TPoint& point, TPoint& oldPoint);
  169.  
  170.     // Output functions- Icons
  171.     BOOL        DrawIcon(int x, int y, const TIcon& icon);
  172.     BOOL        DrawIcon(const TPoint& point, const TIcon& icon);
  173.  
  174.     // Output functions- Rects
  175.     BOOL        FrameRect(int x1, int y1, int x2, int y2, const TBrush& brush);
  176.     BOOL        FrameRect(const TRect& rect, const TBrush& brush);
  177.     BOOL        FillRect(int x1, int y1, int x2, int y2, const TBrush& brush);
  178.     BOOL        FillRect(const TRect& rect, const TBrush& brush);
  179.     BOOL        InvertRect(int x1, int y1, int x2, int y2);
  180.     BOOL        InvertRect(const TRect& rect);
  181.     BOOL        DrawFocusRect(int x1, int y1, int x2, int y2);
  182.     BOOL        DrawFocusRect(const TRect& rect);
  183.  
  184.     // Filled rect using ExtTextOut, no dithered colors & uses or sets BkColor
  185.     BOOL        TextRect(int x1, int y1, int x2, int y2);
  186.     BOOL        TextRect(const TRect& rect);
  187.     BOOL        TextRect(int x1, int y1, int x2, int y2, TColor color);
  188.     BOOL        TextRect(const TRect& rect, TColor color);
  189.  
  190.     // 
  191.     void        OWLFastWindowFrame(TBrush &brush, TRect &r, int xWidth, int yWidth);
  192.     
  193.     // Output functions- Regions
  194.     BOOL        FrameRgn(const TRegion& region, const TBrush& brush, const TPoint& p);
  195.     BOOL        FillRgn(const TRegion& region, const TBrush& brush);
  196.     BOOL        InvertRgn(const TRegion& region);
  197.     BOOL        PaintRgn(const TRegion& region);
  198.  
  199.     // Output functions- Shapes
  200.     #if defined(__WIN32__)
  201.       BOOL      AngleArc(int x, int y, DWORD radius, float startAngle,
  202.                          float sweepAngle);
  203.       BOOL      AngleArc(const TPoint& center, DWORD radius, float startAngle,
  204.                          float sweepAngle);
  205.     #endif
  206.     BOOL        Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4,
  207.                     int y4);
  208.     BOOL        Arc(const TRect& r, const TPoint& start, const TPoint& end);
  209.     BOOL        Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4,
  210.                       int y4);
  211.     BOOL        Chord(const TRect& R, const TPoint& Start, const TPoint& End);
  212.     BOOL        Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4,
  213.                     int y4);
  214.     BOOL        Pie(const TRect& rect, const TPoint& start, const TPoint& end);
  215.     BOOL        Ellipse(int x1, int y1, int x2, int y2);
  216.     BOOL        Ellipse(const TPoint& p1, const TPoint& p2);
  217.     BOOL        Ellipse(const TPoint& point, const TSize& size);
  218.     BOOL        Ellipse(const TRect& rect);
  219.     BOOL        LineTo(int x, int y);
  220.     BOOL        LineTo(const TPoint& point);
  221.     BOOL        Polyline(const TPoint* points, int count);
  222.     BOOL        Polygon(const TPoint* points, int count);
  223.     BOOL        PolyPolygon(const TPoint* points, const int* PolyCounts,
  224.                             int count);
  225.     #if defined(__WIN32__)
  226.       BOOL      PolyPolyline(const TPoint* points, const int* PolyCounts,
  227.                              int count);
  228.       BOOL      PolyBezier(const TPoint* points, int count);
  229.       BOOL      PolyBezierTo(const TPoint* points, int count);
  230.       BOOL      PolyDraw(const TPoint* points, BYTE* types, int count);
  231.       BOOL      PolylineTo(const TPoint* points, int count);
  232.     #endif
  233.     BOOL        Rectangle(int x1, int y1, int x2, int y2);
  234.     BOOL        Rectangle(const TPoint& p1, const TPoint& p2);
  235.     BOOL        Rectangle(const TPoint& point, const TSize& s);
  236.     BOOL        Rectangle(const TRect& rect);
  237.     BOOL        RoundRect(int x1, int y1, int x2, int y2, int x3, int y3);
  238.     BOOL        RoundRect(const TPoint& p1, const TPoint& p2, const TPoint& rad);
  239.     BOOL        RoundRect(const TPoint& p, const TSize& s, const TPoint& rad);
  240.     BOOL        RoundRect(const TRect& rect, const TPoint& rad);
  241.  
  242.     // Output functions- bitmaps & blitting
  243.     TColor      GetPixel(int x, int y) const;
  244.     TColor      GetPixel(const TPoint& point) const;
  245.     TColor      SetPixel(int x, int y, TColor color);
  246.     TColor      SetPixel(const TPoint& p, TColor color);
  247.     BOOL        BitBlt(int dstX, int dstY, int w, int h, const TDC& srcDC,
  248.                        int srcX, int srcY, DWORD rop=SRCCOPY);
  249.     BOOL        BitBlt(const TRect& dst, const TDC& srcDC,
  250.                        const TPoint& src, DWORD rop=SRCCOPY);
  251.     BOOL        PatBlt(int x, int y, int w, int h, DWORD rop=PATCOPY);
  252.     BOOL        PatBlt(const TRect& dst, DWORD rop=PATCOPY);
  253.     BOOL        ScrollDC(int x, int y, const TRect& scroll, const TRect& clip,
  254.                          TRegion& updateRgn, TRect& updateRect);
  255.     BOOL        ScrollDC(const TPoint& delta, const TRect& scroll,
  256.                          const TRect& clip, TRegion& updateRgn,
  257.                          TRect& updateRect);
  258.     BOOL        StretchBlt(int dstX, int dstY, int dstW, int dstH,
  259.                            const TDC& srcDC, int srcX, int srcY, int srcW,
  260.                            int srcH, DWORD rop=SRCCOPY);
  261.     BOOL        StretchBlt(const TRect& dst, const TDC& srcDC,
  262.                            const TRect& src, DWORD rop=SRCCOPY);
  263.     #if defined(__WIN32__)
  264.       BOOL      MaskBlt(const TRect& dst, const TDC& srcDC,
  265.                         const TPoint& src, const TBitmap& maskBm,
  266.                         const TPoint& maskPos, DWORD rop=SRCCOPY);
  267.       BOOL      PlgBlt(const TPoint& dst, const TDC& srcDC,
  268.                        const TRect& src, const TBitmap& maskBm,
  269.                        const TPoint& maskPos, DWORD rop=SRCCOPY);
  270.     #endif
  271.     BOOL        GetDIBits(const TBitmap& bitmap, WORD startScan, WORD numScans,
  272.                           void HUGE* bits, const BITMAPINFO far& info,
  273.                           WORD usage);
  274.     BOOL        GetDIBits(const TBitmap& bitmap, TDib& dib);
  275.     BOOL        SetDIBits(TBitmap& bitmap, WORD startScan, WORD numScans,
  276.                           const void HUGE* bits, const BITMAPINFO far& Info,
  277.                           WORD usage);
  278.     BOOL        SetDIBits(TBitmap& bitmap, const TDib& dib);
  279.     BOOL        SetDIBitsToDevice(const TRect& dst, const TPoint& src,
  280.                                   WORD startScan, WORD numScans,
  281.                                   const void HUGE* bits,
  282.                                   const BITMAPINFO far& bitsInfo, WORD usage);
  283.     BOOL        SetDIBitsToDevice(const TRect& dst, const TPoint& src,
  284.                                   const TDib& dib);
  285.     BOOL        StretchDIBits(const TRect& dst, const TRect& src,
  286.                               const void HUGE* bits,
  287.                               const BITMAPINFO far& bitsInfo,
  288.                               WORD usage, DWORD rop=SRCCOPY);
  289.     BOOL        StretchDIBits(const TRect& dst, const TRect& src,
  290.                               const TDib& dib, DWORD rop=SRCCOPY);
  291.     BOOL        FloodFill(const TPoint& point, TColor color);
  292.     BOOL        ExtFloodFill(const TPoint& point, TColor color, WORD fillType);
  293.  
  294.     // Output functions- text
  295.     virtual BOOL TextOut(int x, int y, const char far* str, int count=-1);
  296.     BOOL         TextOut(const TPoint& p, const char far* str, int count=-1);
  297.     virtual BOOL ExtTextOut(int x, int y, WORD options, const TRect* r,
  298.                       const char far* str, int count, const int far* dx = 0);
  299.     BOOL         ExtTextOut(const TPoint& p, WORD options, const TRect* r,
  300.                       const char far* str, int count, const int far* dx = 0);
  301.     virtual BOOL TabbedTextOut(const TPoint& p, const char far* str, int count,
  302.                                int numPositions, const int far* positions,
  303.                                int tabOrigin, TSize& size);
  304.     BOOL         TabbedTextOut(const TPoint& p, const char far* str, int count,
  305.                                int numPositions, const int far* positions,
  306.                                int tabOrigin);
  307.     virtual BOOL DrawText(const char far* str, int count, const TRect& r,
  308.                           WORD format=0);
  309.     virtual BOOL GrayString(const TBrush& brush, GRAYSTRINGPROC outputFunc,
  310.                             const char far* str, int count, const TRect& r);
  311.  
  312.     // Text functions
  313.     BOOL        GetTextExtent(const char far* str, int stringLen, TSize& size);
  314.     TSize       GetTextExtent(const char far* str, int stringLen);
  315.     BOOL        GetTabbedTextExtent(const char far* str, int stringLen,
  316.                                     int numPositions, const int far* positions,
  317.                                     TSize& size) const;
  318.     TSize       GetTabbedTextExtent(const char far* str, int stringLen,
  319.                               int numPositions, const int far* positions) const;
  320.     UINT        GetTextAlign() const;
  321.     UINT        SetTextAlign(UINT flags);
  322.     int         GetTextCharacterExtra() const;
  323.     int         SetTextCharacterExtra(int extra);
  324.     BOOL        SetTextJustification(int breakExtra, int breakCount);
  325.     int         GetTextFace(int count, char far* facename) const;
  326.     //string&    GetTextFace(string& facename) const;
  327.     BOOL        GetTextMetrics(TEXTMETRIC far& metrics) const;
  328.     DWORD       GetGlyphOutline(UINT chr, UINT format, GLYPHMETRICS far& gm,
  329.                                 DWORD buffSize, void far* buffer,
  330.                                 const MAT2 far& mat2);
  331.     int         GetKerningPairs(int pairs, KERNINGPAIR far* krnPair);
  332.   #if defined(__WIN32__)
  333.     DWORD       GetOutlineTextMetrics(UINT data, OUTLINETEXTMETRIC far& otm);
  334.   #else
  335.     WORD        GetOutlineTextMetrics(UINT data, OUTLINETEXTMETRIC far& otm);
  336.   #endif
  337.  
  338.     // Font functions
  339.     BOOL        GetCharWidth(UINT firstChar, UINT lastChar, int* buffer);
  340.     DWORD       SetMapperFlags(DWORD flag);
  341.     BOOL        GetAspectRatioFilter(TSize& size) const;
  342.     int         EnumFonts(const char far* faceName, OLDFONTENUMPROC callback,
  343.                           LPVOID data) const;
  344.     int         EnumFontFamilies(const char far* family,
  345.                                  FONTENUMPROC proc, LPVOID data) const;
  346.     DWORD       GetFontData(DWORD table, DWORD offset, void* buffer, long data);
  347.     BOOL        GetCharABCWidths(UINT firstChar, UINT lastChar, ABC* abc);
  348.  
  349.     // Path functions
  350.     #if defined(__WIN32__)
  351.       BOOL        BeginPath();
  352.       BOOL        CloseFigure();
  353.       BOOL        EndPath();
  354.       BOOL        FlattenPath();
  355.       BOOL        WidenPath();
  356.       BOOL        FillPath();
  357.       BOOL        StrokePath();
  358.       BOOL        StrokeAndFillPath();
  359.       BOOL        SelectClipPath(int mode);
  360.       HRGN        PathToRegion();
  361.     #endif
  362.  
  363.   protected:
  364.     TGdiBase::CheckValid;       // make this function available to derivatives
  365.     TGdiBase::Handle;           // The handle of this DC
  366.     TGdiBase::ShouldDelete;     // Should object delete the Handle in dtor?
  367.  
  368.     HBRUSH      OrgBrush;       // Original objects when DC was created
  369.     HPEN        OrgPen;
  370.     HFONT       OrgFont;
  371.     HPALETTE    OrgPalette;
  372.     #if defined(__WIN32__)
  373.       HBRUSH    OrgTextBrush;
  374.     #endif
  375.  
  376.     TDC();          // For use by derived classes only
  377.     TDC(HDC handle, TAutoDelete autoDelete); //use an existing DC
  378.     void        Init();
  379.  
  380.                // Override to implement a twin DC object, like TPrintPreviewDC
  381.     virtual HDC GetAttributeHDC() const;
  382.             HDC GetHDC() const {return HDC(Handle);}
  383.  
  384.   private:
  385.     //
  386.     // hidden to prevent accidental copying or assignment
  387.     //
  388.     TDC(const TDC&);
  389.     TDC& operator =(const TDC&);
  390. };
  391.  
  392. //
  393. // class TWindowDC
  394. // ----- ---------
  395. //
  396. // A DC class that provides access to the entire area owned by a window. Is
  397. // the base for any DC class that Releases its handle when done.
  398. //
  399. class _OWLCLASS TWindowDC : public TDC {
  400.   public:
  401.     TWindowDC(HWND wnd);
  402.    ~TWindowDC();
  403.  
  404.   protected:
  405.     HWND        Wnd;
  406.     TWindowDC();  // for derived classes
  407.  
  408.   private:
  409.     TWindowDC(const TWindowDC&);
  410.     TWindowDC& operator =(const TWindowDC&);
  411. };
  412.  
  413. //
  414. // class TScreenDC
  415. // ----- ---------
  416. //
  417. // A DC class that provides direct access to the screen bitmap.  Gets a DC for
  418. // Window handle 0, which is for the whole screen w/ no clipping, etc. will
  419. // paint on top of everything.
  420. //
  421. class _OWLCLASS TScreenDC : public TWindowDC {
  422.   public:
  423.     TScreenDC();
  424.  
  425.   private:
  426.     TScreenDC(const TScreenDC&);
  427.     TScreenDC& operator =(const TScreenDC&);
  428. };
  429.  
  430. //
  431. // class TDesktopDC
  432. // ----- ----------
  433. //
  434. // A DC class that provides access to the desktop window's client area which
  435. // is the screen behind all other windows.
  436. //
  437. class _OWLCLASS TDesktopDC : public TWindowDC {
  438.   public:
  439.     TDesktopDC();
  440.  
  441.   private:
  442.     TDesktopDC(const TDesktopDC&);
  443.     TDesktopDC& operator =(const TDesktopDC&);
  444. };
  445.  
  446. //
  447. // class TClientDC
  448. // ----- ---------
  449. //
  450. // A DC class that provides access to the client area owned by a window
  451. //
  452. class _OWLCLASS TClientDC : public TWindowDC {
  453.   public:
  454.     TClientDC(HWND wnd);
  455.  
  456.   private:
  457.     TClientDC(const TClientDC&);
  458.     TClientDC& operator =(const TClientDC&);
  459. };
  460.  
  461. //
  462. // class TPaintDC
  463. // ----- --------
  464. //
  465. // A DC class that wraps begin and end paint calls for use in an WM_PAINT
  466. // response function.
  467. //
  468. class _OWLCLASS TPaintDC : public TDC {
  469.   public:
  470.     TPaintDC(HWND wnd);
  471.    ~TPaintDC();
  472.  
  473.     PAINTSTRUCT Ps;
  474.  
  475.   protected:
  476.     HWND        Wnd;
  477.  
  478.   private:
  479.     TPaintDC(const TPaintDC&);
  480.     TPaintDC& operator =(const TPaintDC&);
  481. };
  482.  
  483. //
  484. // class TMetaFileDC
  485. // ----- -----------
  486. //
  487. // A DC class that provides access to a DC with a metafile selected into it
  488. // for drawing on (into).
  489. //
  490. class _OWLCLASS TMetaFileDC : public TDC {
  491.   public:
  492.     TMetaFileDC(const char far* filename = 0);
  493.    ~TMetaFileDC();
  494.  
  495.     HMETAFILE Close();
  496.  
  497.   private:
  498.     TMetaFileDC(const TMetaFileDC&);
  499.     TMetaFileDC& operator =(const TMetaFileDC&);
  500. };
  501.  
  502. //
  503. // class TCreatedDC
  504. // ----- ----------
  505. //
  506. class _OWLCLASS TCreatedDC : public TDC {
  507.   public:
  508.     TCreatedDC(const char far* driver, const char far* device,
  509.                const char far* output, const DEVMODE far* initData=0);
  510.  
  511.     TCreatedDC(HDC handle, TAutoDelete autoDelete);  // use an existing DC
  512.    ~TCreatedDC();
  513.  
  514.   protected:
  515.     TCreatedDC();
  516.  
  517.   private:
  518.     TCreatedDC(const TCreatedDC&);
  519.     TCreatedDC& operator =(const TCreatedDC&);
  520. };
  521.  
  522. //
  523. // class TIC
  524. // ----- ---
  525. //
  526. class _OWLCLASS TIC : public TCreatedDC {
  527.   public:
  528.     TIC(const char far* driver, const char far* device,
  529.         const char far* output, const DEVMODE far* initData=0);
  530.  
  531.   private:
  532.     TIC(const TIC&);
  533.     TIC& operator =(const TIC&);
  534. };
  535.  
  536. //
  537. // class TMemoryDC
  538. // ----- ---------
  539. //
  540. // A DC class that provides access to a memory DC
  541. //
  542. class _OWLCLASS TMemoryDC : public TCreatedDC {
  543.   public:
  544.     TMemoryDC();
  545.     TMemoryDC(const TDC& DC); // Make it compatible with an existing DC
  546.     TMemoryDC(HDC handle, TAutoDelete autoDelete);  // use an existing DC
  547.    ~TMemoryDC();
  548.  
  549.     // Select GDI objects into this DC and restore them to original
  550.     void        SelectObject(const TBrush& brush) {TDC::SelectObject(brush);}
  551.     void        SelectObject(const TPen& pen) {TDC::SelectObject(pen);}
  552.     void        SelectObject(const TFont& font) {TDC::SelectObject(font);}
  553.     void        SelectObject(const TPalette& palette, BOOL forceBackground=FALSE)
  554.       {TDC::SelectObject(palette, forceBackground);}
  555.     void        SelectObject(const TBitmap& bitmap);
  556.  
  557.     void        RestoreBitmap();
  558.     void        RestoreObjects() {TDC::RestoreObjects(); RestoreBitmap();}
  559.  
  560.   protected:
  561.     HBITMAP     OrgBitmap;
  562.  
  563.   private:
  564.     TMemoryDC(const TMemoryDC&);
  565.     TMemoryDC& operator =(const TMemoryDC&);
  566. };
  567.  
  568. //
  569. // class TDibDC
  570. // ----- ------
  571. //
  572. // A DC class that provides access to DIBs using the DIB.DRV driver
  573. //
  574. class _OWLCLASS TDibDC : public TCreatedDC {
  575.   public:
  576.     TDibDC(const TDib& dib);
  577.  
  578.   private:
  579.     TDibDC(const TDibDC&);
  580.     TDibDC& operator =(const TDibDC&);
  581. };
  582.  
  583. //----------------------------------------------------------------------------
  584. // A DC class that provides access to a printer
  585. //
  586. struct TBandInfo {    // Equivalent to BANDINFOSTRUCT
  587.   BOOL  HasGraphics;
  588.   BOOL  HasText;
  589.   TRect GraphicsRect;
  590. };
  591.  
  592. class _OWLCLASS TPrintDC : public TCreatedDC {
  593.   public:
  594.     TPrintDC(HDC handle, TAutoDelete autoDelete = NoAutoDelete);
  595.     TPrintDC(const char far* driver, const char far* device,
  596.              const char far* output, const DEVMODE far* initData);
  597.  
  598.     int         Escape(int escape, int count=0, const void* inData=0,
  599.                        void* outData=0);
  600.     int         SetAbortProc(ABORTPROC proc);
  601.     int         StartDoc(const char far* docName, const char far* output);
  602.     int         StartPage();
  603.     int         BandInfo(TBandInfo& bandInfo);
  604.     int         NextBand(TRect& rect);
  605.     int         EndPage();
  606.     int         EndDoc();
  607.     int         AbortDoc();
  608.  
  609.   #if !defined(__WIN32__)
  610.     BOOL        QueryAbort(int rsvd=0);
  611.   #endif
  612.  
  613.     UINT        QueryEscSupport(int escapeNum);
  614.     int         SetCopyCount(int reqestCount, int& actualCount);
  615.  
  616.     static DWORD DeviceCapabilities(const char far* driver,
  617.                                     const char far* device,
  618.                                     const char far* port,
  619.                                     int capability, char far* output=0,
  620.                                     LPDEVMODE devmode=0);
  621.   protected:
  622.   DOCINFO     DocInfo;
  623.  
  624.   private:
  625.     TPrintDC(const TPrintDC&);
  626.     TPrintDC& operator =(const TPrintDC&);
  627. };
  628.  
  629. //----------------------------------------------------------------------------
  630. // Inlines for DC classes
  631. //----------------------------------------------------------------------------
  632.  
  633. //
  634. // Get the GDI object headers so that we have access to conversion operators,
  635. // etc.
  636. //
  637. #if !defined(__OWL_GDIOBJEC_H)
  638.   #include <owl\gdiobjec.h>
  639. #endif
  640. #if !defined(__OWL_METAFILE_H)
  641.   #include <owl\metafile.h>
  642. #endif
  643.  
  644.  
  645. inline BOOL TDC::GetDCOrg(TPoint& point) const {
  646. #if defined(__WIN32__)
  647.   return ::GetDCOrgEx(GetAttributeHDC(), &point);
  648. #else
  649.   point = ::GetDCOrg(GetAttributeHDC());
  650.   return TRUE;
  651. #endif
  652. }
  653.  
  654. inline BOOL TDC::GetBrushOrg(TPoint& point) const {
  655.   return ::GetBrushOrgEx(GetHDC(), &point);
  656. }
  657.  
  658. inline BOOL TDC::SetBrushOrg(const TPoint& org, TPoint far* oldOrg) {
  659.   #if defined(__WIN32__)
  660.     return ::SetBrushOrgEx(GetHDC(), org.x, org.y, oldOrg);
  661.     // ::UnrealizeObject(CurrentBrush); // could automate this for user
  662.   #else
  663.     if (oldOrg)
  664.       *oldOrg = ::SetBrushOrg(GetHDC(), org.x, org.y);
  665.     else
  666.       ::SetBrushOrg(GetHDC(), org.x, org.y);
  667.     // ::UnrealizeObject(CurrentBrush); // could automate this for user
  668.     return TRUE;
  669.   #endif
  670. }
  671.  
  672. inline int TDC::EnumObjects(UINT objectType, GOBJENUMPROC proc, LPVOID data) const {
  673.   return ::EnumObjects(GetHDC(), objectType, proc, (LPARAM)data);
  674. }
  675.  
  676. inline TColor TDC::GetNearestColor(TColor color) const {
  677.   return ::GetNearestColor(GetAttributeHDC(), color);
  678. }
  679.  
  680. inline int TDC::RealizePalette() {
  681.   return ::RealizePalette(GetHDC());
  682. }
  683.  
  684. inline void TDC::UpdateColors() {
  685.   ::UpdateColors(GetHDC());
  686. }
  687.  
  688. inline UINT TDC::GetSystemPaletteEntries(int start, int num, PALETTEENTRY far* entries) const {
  689.   return ::GetSystemPaletteEntries(GetHDC(), start, num, entries);
  690. }
  691.  
  692. inline UINT TDC::GetSystemPaletteUse() const {
  693.   return ::GetSystemPaletteUse(GetHDC());
  694. }
  695.  
  696. inline int TDC::SetSystemPaletteUse(int usage) {
  697.   return ::SetSystemPaletteUse(GetHDC(), usage);
  698. }
  699.  
  700. inline TColor TDC::GetBkColor() const {
  701.   return ::GetBkColor(GetAttributeHDC());
  702. }
  703.  
  704. inline int TDC::GetBkMode() const {
  705.   return ::GetBkMode(GetAttributeHDC());
  706. }
  707.  
  708. inline int TDC::SetBkMode(int mode) {
  709.   if (GetHDC() != GetAttributeHDC())
  710.     ::SetBkMode(GetHDC(), mode);
  711.   return ::SetBkMode(GetAttributeHDC(), mode);
  712. }
  713.  
  714. inline int TDC::GetPolyFillMode() const {
  715.   return ::GetPolyFillMode(GetAttributeHDC());
  716. }
  717.  
  718. inline int TDC::SetPolyFillMode(int mode) {
  719.   if (GetHDC() != GetAttributeHDC())
  720.     ::SetPolyFillMode(GetHDC(), mode);
  721.   return ::SetPolyFillMode(GetAttributeHDC(), mode);
  722. }
  723.  
  724. inline int TDC::GetROP2() const {
  725.   return ::GetROP2(GetAttributeHDC());
  726. }
  727.  
  728. inline int TDC::SetROP2(int mode) {
  729.   if (GetHDC() != GetAttributeHDC())
  730.     ::SetROP2(GetHDC(), mode);
  731.   return ::SetROP2(GetAttributeHDC(), mode);
  732. }
  733.  
  734. inline int TDC::GetStretchBltMode() const {
  735.   return ::GetStretchBltMode(GetAttributeHDC());
  736. }
  737.  
  738. inline int TDC::SetStretchBltMode(int mode) {
  739.   if (GetHDC() != GetAttributeHDC())
  740.     ::SetStretchBltMode(GetHDC(), mode);
  741.   return ::SetStretchBltMode(GetAttributeHDC(), mode);
  742. }
  743.  
  744. inline TColor TDC::GetTextColor() const {
  745.   return ::GetTextColor(GetAttributeHDC());
  746. }
  747.  
  748. #if defined(__WIN32__)
  749. inline BOOL TDC::SetMiterLimit(float newLimit, float* oldLimit) {
  750.   if (GetHDC() != GetAttributeHDC())
  751.     ::SetMiterLimit(GetHDC(), newLimit, oldLimit);
  752.   return ::SetMiterLimit(GetAttributeHDC(), newLimit, oldLimit);
  753. }
  754. #endif
  755.  
  756. inline int TDC::GetMapMode() const {
  757.   return ::GetMapMode(GetAttributeHDC());
  758. }
  759.  
  760. #if defined(__WIN32__)
  761. inline BOOL TDC::SetWorldTransform(XFORM far& xform) {
  762.   if (GetHDC() != GetAttributeHDC())
  763.     ::SetWorldTransform(GetHDC(), &xform);
  764.   return ::SetWorldTransform(GetAttributeHDC(), &xform);
  765. }
  766.  
  767. inline BOOL TDC::ModifyWorldTransform(XFORM far& xform, DWORD mode) {
  768.   if (GetHDC() != GetAttributeHDC())
  769.     ::ModifyWorldTransform(GetHDC(), &xform, mode);
  770.   return ::ModifyWorldTransform(GetAttributeHDC(), &xform, mode);
  771. }
  772. #endif
  773.  
  774. inline BOOL TDC::GetViewportOrg(TPoint& point) const {
  775.   return ::GetViewportOrgEx(GetAttributeHDC(), &point);
  776. }
  777.  
  778. inline TPoint TDC::GetViewportOrg() const {
  779.   #if defined(__WIN32__)
  780.     TPoint point;
  781.     ::GetViewportOrgEx(GetAttributeHDC(), &point);
  782.     return point;
  783.   #else
  784.     return ::GetViewportOrg(GetAttributeHDC());
  785.   #endif
  786. }
  787.  
  788. inline BOOL TDC::GetViewportExt(TSize& extent) const {
  789.   return ::GetViewportExtEx(GetAttributeHDC(), &extent);
  790. }
  791.  
  792. inline TSize TDC::GetViewportExt() const {
  793.   #if defined(__WIN32__)
  794.     TSize extent;
  795.     ::GetViewportExtEx(GetAttributeHDC(), &extent);
  796.     return extent;
  797.   #else
  798.     return ::GetViewportExt(GetAttributeHDC());
  799.   #endif
  800. }
  801.  
  802. inline BOOL TDC::GetWindowOrg(TPoint& point) const {
  803.   return ::GetWindowOrgEx(GetAttributeHDC(), &point);
  804. }
  805.  
  806. inline TPoint TDC::GetWindowOrg() const {
  807.   #if defined(__WIN32__)
  808.     TPoint point;
  809.     ::GetWindowOrgEx(GetAttributeHDC(), &point);
  810.     return point;
  811.   #else
  812.     return ::GetWindowOrg(GetAttributeHDC());
  813.   #endif
  814. }
  815.  
  816. inline BOOL TDC::GetWindowExt(TSize& extent) const {
  817.   return ::GetWindowExtEx(GetAttributeHDC(), &extent);
  818. }
  819.  
  820. inline TSize TDC::GetWindowExt() const {
  821.   #if defined(__WIN32__)
  822.     TSize extent;
  823.     ::GetWindowExtEx(GetAttributeHDC(), &extent);
  824.     return extent;
  825.   #else
  826.     return ::GetWindowExt(GetAttributeHDC());
  827.   #endif
  828. }
  829.  
  830. inline BOOL TDC::DPtoLP(TPoint* points, int count) const {
  831.   return ::DPtoLP(GetAttributeHDC(), points, count);
  832. }
  833.  
  834. //inline BOOL TDC::DPtoLP(TRect& rect) const {
  835. //  return DPtoLP(rect, 2);
  836. //}
  837.  
  838. inline BOOL TDC::LPtoDP(TPoint* points, int count) const {
  839.   return ::LPtoDP(GetHDC(), points, count);
  840. }
  841.  
  842. //inline BOOL TDC::LPtoDP(TRect& rect) const {
  843. //  return LPtoDP(rect, 2);
  844. //}
  845.  
  846. inline int TDC::GetClipBox(TRect& rect) const {
  847.   return ::GetClipBox(GetAttributeHDC(), &rect);
  848. }
  849.  
  850. inline TRect TDC::GetClipBox() const {
  851.   TRect rect;
  852.   ::GetClipBox(GetHDC(), &rect);
  853.   return rect;
  854. }
  855.  
  856. inline int TDC::ExcludeClipRect(const TRect& rect) {
  857.   return ::ExcludeClipRect(GetHDC(), rect.left, rect.top, rect.right, rect.bottom);
  858. }
  859.  
  860. inline int TDC::ExcludeUpdateRgn(HWND Wnd) {
  861.   return ::ExcludeUpdateRgn(GetHDC(), Wnd);
  862. }
  863.  
  864. inline int TDC::IntersectClipRect(const TRect& rect) {
  865.   return ::IntersectClipRect(GetHDC(), rect.left, rect.top, rect.right, rect.bottom);
  866. }
  867.  
  868. inline int TDC::OffsetClipRgn(const TPoint& delta) {
  869.   return ::OffsetClipRgn(GetHDC(), delta.x, delta.y);
  870. }
  871.  
  872. inline int TDC::SelectClipRgn(const TRegion& region) {
  873.   return ::SelectClipRgn(GetHDC(), region);
  874. }
  875.  
  876. inline BOOL TDC::PtVisible(const TPoint& point) const {
  877.   return ::PtVisible(GetHDC(), point.x, point.y);
  878. }
  879.  
  880. inline BOOL TDC::RectVisible(const TRect& rect) const {
  881.   return ::RectVisible(GetHDC(), &rect);
  882. }
  883.  
  884. inline BOOL TDC::GetBoundsRect(TRect& bounds, WORD flags) const {
  885.   return ::GetBoundsRect(GetHDC(), &bounds, flags);
  886. }
  887.  
  888. inline UINT TDC::SetBoundsRect(TRect& bounds, UINT flags) {
  889.   return ::SetBoundsRect(GetHDC(), &bounds, flags);
  890. }
  891.  
  892. #if defined(__WIN32__)
  893. inline BOOL TDC::GetClipRgn(TRegion& region) const {
  894.   return ::GetClipRgn(GetHDC(), region);
  895. }
  896. #endif
  897.  
  898. inline int TDC::EnumMetaFile(const TMetaFilePict& metafile, MFENUMPROC callback,
  899.                              LPVOID data) const {
  900.   return ::EnumMetaFile(GetHDC(), metafile, callback, (long)data);
  901. }
  902.  
  903. inline BOOL TDC::PlayMetaFile(const TMetaFilePict& metafile) {
  904.   return ::PlayMetaFile(GetHDC(), metafile);
  905. }
  906.  
  907. inline void TDC::PlayMetaFileRecord(HANDLETABLE far& handletable,
  908.                                     METARECORD far& metaRecord, int count) {
  909.   ::PlayMetaFileRecord(GetHDC(), &handletable, &metaRecord, count);
  910. }
  911.  
  912. inline BOOL TDC::GetCurrentPosition(TPoint& point) const {
  913.   return ::GetCurrentPositionEx(GetHDC(), &point);
  914. }
  915.  
  916. inline BOOL TDC::MoveTo(int x, int y) {
  917.   return ::MoveToEx(GetHDC(), x, y, 0);
  918. }
  919.  
  920. inline BOOL TDC::MoveTo(const TPoint& point) {
  921.   return ::MoveToEx(GetHDC(), point.x, point.y, 0);
  922. }
  923.  
  924. inline BOOL TDC::MoveTo(const TPoint& point, TPoint& OldPoint) {
  925.   return ::MoveToEx(GetHDC(), point.x, point.y, &OldPoint);
  926. }
  927.  
  928. inline BOOL TDC::DrawIcon(int x, int y, const TIcon& icon) {
  929.   return ::DrawIcon(GetHDC(), x, y, icon);
  930. }
  931.  
  932. inline BOOL TDC::DrawIcon(const TPoint& point, const TIcon& icon) {
  933.   return ::DrawIcon(GetHDC(), point.x, point.y, icon);
  934. }
  935.  
  936. inline BOOL TDC::FrameRect(int x1, int y1, int x2, int y2, const TBrush& brush) {
  937.   return ::FrameRect(GetHDC(), &TRect(x1, y1, x2, y2), brush);
  938. }
  939.  
  940. inline BOOL TDC::FrameRect(const TRect& rect, const TBrush& brush) {
  941.   return ::FrameRect(GetHDC(), &rect, brush);
  942. }
  943.  
  944. inline BOOL TDC::FillRect(int x1, int y1, int x2, int y2, const TBrush& brush) {
  945.   return ::FillRect(GetHDC(), &TRect(x1, y1, x2, y2), brush);
  946. }
  947.  
  948. inline BOOL TDC::FillRect(const TRect& rect, const TBrush& brush) {
  949.   return ::FillRect(GetHDC(), &rect, brush);
  950. }
  951.  
  952. //
  953. // rect must be normalized for inverRect
  954. //
  955. inline BOOL TDC::InvertRect(int x1, int y1, int x2, int y2) {
  956.   ::InvertRect(GetHDC(), &TRect(x1, y1, x2, y2));
  957.   return TRUE;
  958. }
  959.  
  960. inline BOOL TDC::InvertRect(const TRect& rect) {
  961.   ::InvertRect(GetHDC(), &rect);
  962.   return TRUE;
  963. }
  964.  
  965. inline BOOL TDC::DrawFocusRect(int x1, int y1, int x2, int y2) {
  966.   ::DrawFocusRect(GetHDC(), &TRect(x1, y1, x2, y2));
  967.   return TRUE;
  968. }
  969.  
  970. inline BOOL TDC::DrawFocusRect(const TRect& rect) {
  971.   ::DrawFocusRect(GetHDC(), &rect);
  972.   return TRUE;
  973. }
  974.  
  975. inline BOOL TDC::TextRect(int x1, int y1, int x2, int y2) {
  976.   return ::ExtTextOut(GetHDC(), 0, 0, ETO_OPAQUE, &TRect(x1, y1, x2, y2), 0, 0, 0);
  977. }
  978.  
  979. inline BOOL TDC::TextRect(const TRect& rect) {
  980.   return ::ExtTextOut(GetHDC(), 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
  981. }
  982.  
  983. inline BOOL TDC::TextRect(int x1, int y1, int x2, int y2, TColor color) {
  984.   SetBkColor(color);
  985.   return ::ExtTextOut(GetHDC(), 0, 0, ETO_OPAQUE, &TRect(x1, y1, x2, y2), 0, 0, 0);
  986. }
  987.  
  988. inline BOOL TDC::TextRect(const TRect& rect, TColor color) {
  989.   SetBkColor(color);
  990.   return ::ExtTextOut(GetHDC(), 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
  991. }
  992.  
  993. inline BOOL TDC::FrameRgn(const TRegion& region, const TBrush& brush, const TPoint& p) {
  994.   return ::FrameRgn(GetHDC(), region, brush, p.x, p.y);
  995. }
  996.  
  997. inline BOOL TDC::FillRgn(const TRegion& region, const TBrush& brush) {
  998.   return ::FillRgn(GetHDC(), region, brush);
  999. }
  1000.  
  1001. inline BOOL TDC::InvertRgn(const TRegion& region) {
  1002.   return ::InvertRgn(GetHDC(), region);
  1003. }
  1004.  
  1005. inline BOOL TDC::PaintRgn(const TRegion& region) {
  1006.   return ::PaintRgn(GetHDC(), region);
  1007. }
  1008.  
  1009. #if defined(__WIN32__)
  1010. inline BOOL TDC::AngleArc(int x, int y, DWORD radius, float startAngle, float sweepAngle) {
  1011.   return ::AngleArc(GetHDC(), x, y, radius, startAngle, sweepAngle);
  1012. }
  1013.  
  1014. inline BOOL TDC::AngleArc(const TPoint& Center, DWORD radius, float StartAngle, float SweepAngle) {
  1015.   return ::AngleArc(GetHDC(), Center.x, Center.y, radius, StartAngle, SweepAngle);
  1016. }
  1017. #endif
  1018.  
  1019. inline BOOL TDC::Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
  1020.   return ::Arc(GetHDC(), x1, y1, x2, y2, x3, y3, x4, y4);
  1021. }
  1022.  
  1023. inline BOOL TDC::Arc(const TRect& rect, const TPoint& start, const TPoint& end) {
  1024.   return ::Arc(GetHDC(), rect.left, rect.top, rect.right, rect.bottom, start.x, start.y, end.x, end.y);
  1025. }
  1026.  
  1027. inline BOOL TDC::Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
  1028.   return ::Chord(GetHDC(), x1, y1, x2, y2, x3, y3, x4, y4);
  1029. }
  1030.  
  1031. inline BOOL TDC::Chord(const TRect& rect, const TPoint& start, const TPoint& end) {
  1032.   return ::Chord(GetHDC(), rect.left, rect.top, rect.right, rect.bottom, start.x, start.y, end.x, end.y);
  1033. }
  1034.  
  1035. inline BOOL TDC::Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
  1036.   return ::Pie(GetHDC(), x1, y1, x2, y2, x3, y3, x4, y4);
  1037. }
  1038.  
  1039. inline BOOL TDC::Pie(const TRect& rect, const TPoint& start, const TPoint& end) {
  1040.   return ::Pie(GetHDC(), rect.left, rect.top, rect.right, rect.bottom, start.x, start.y, end.x, end.y);
  1041. }
  1042.  
  1043. inline BOOL TDC::Ellipse(int x1, int y1, int x2, int y2) {
  1044.   return ::Ellipse(GetHDC(), x1, y1, x2, y2);
  1045. }
  1046.  
  1047. inline BOOL TDC::Ellipse(const TPoint& p1, const TPoint& p2) {
  1048.   return ::Ellipse(GetHDC(), p1.x, p1.y, p2.x, p2.y);
  1049. }
  1050.  
  1051. inline BOOL TDC::Ellipse(const TPoint& p, const TSize& s) {
  1052.   return ::Ellipse(GetHDC(), p.x, p.y, p.x+s.cx, p.y+s.cy);
  1053. }
  1054.  
  1055. inline BOOL TDC::Ellipse(const TRect& rect) {
  1056.   return ::Ellipse(GetHDC(), rect.left, rect.top, rect.right, rect.bottom);
  1057. }
  1058.  
  1059. inline BOOL TDC::LineTo(int x, int y) {
  1060.   return ::LineTo(GetHDC(), x, y);
  1061. }
  1062.  
  1063. inline BOOL TDC::LineTo(const TPoint& point) {
  1064.   return ::LineTo(GetHDC(), point.x, point.y);
  1065. }
  1066.  
  1067. inline BOOL TDC::Polyline(const TPoint* points, int count) {
  1068.   return ::Polyline(GetHDC(), points, count);
  1069. }
  1070.  
  1071. inline BOOL TDC::Polygon(const TPoint* points, int count) {
  1072.   return ::Polygon(GetHDC(), (TPoint*)points, count);
  1073. }
  1074.  
  1075. inline BOOL TDC::PolyPolygon(const TPoint* points, const int* polyCounts, int count) {
  1076.   return ::PolyPolygon(GetHDC(), (TPoint*)points, (int*)polyCounts, count); // API typecast
  1077. }
  1078.  
  1079. #if defined(__WIN32__)
  1080. inline BOOL TDC::PolyPolyline(const TPoint* points, const int* polyCounts, int count) {
  1081.   return ::PolyPolyline(GetHDC(), (TPoint*)points, (DWORD*)polyCounts, count); // API typecast
  1082. }
  1083.  
  1084. inline BOOL TDC::PolyBezier(const TPoint* points, int count) {
  1085.   return ::PolyBezier(GetHDC(), (TPoint*)points, count);
  1086. }
  1087.  
  1088. inline BOOL TDC::PolyBezierTo(const TPoint* points, int count) {
  1089.   return ::PolyBezierTo(GetHDC(), (TPoint*)points, count);
  1090. }
  1091.  
  1092. inline BOOL TDC::PolyDraw(const TPoint* points, BYTE* types, int count) {
  1093.   return ::PolyDraw(GetHDC(), (TPoint*)points, types, count);
  1094. }
  1095.  
  1096. inline BOOL TDC::PolylineTo(const TPoint* points, int count) {   //Q or TPointList
  1097.   return ::PolylineTo(GetHDC(), (TPoint*)points, count);
  1098. }
  1099. #endif
  1100.  
  1101. inline BOOL TDC::Rectangle(int x1, int y1, int x2, int y2) {
  1102.   return ::Rectangle(GetHDC(), x1, y1, x2, y2);
  1103. }
  1104.  
  1105. inline BOOL TDC::Rectangle(const TPoint& p1, const TPoint& p2) {
  1106.   return ::Rectangle(GetHDC(), p1.x, p1.y, p2.x, p2.y);
  1107. }
  1108.  
  1109. inline BOOL TDC::Rectangle(const TPoint& p, const TSize& s) {
  1110.   return ::Rectangle(GetHDC(), p.x, p.y, p.x+s.cx, p.y+s.cy);
  1111. }
  1112.  
  1113. inline BOOL TDC::Rectangle(const TRect& rect) {
  1114.   return ::Rectangle(GetHDC(), rect.left, rect.top, rect.right, rect.bottom);
  1115. }
  1116.  
  1117. inline BOOL TDC::RoundRect(int x1, int y1, int x2, int y2, int x3, int y3) {
  1118.   return ::RoundRect(GetHDC(), x1, y1, x2, y2, x3, y3);
  1119. }
  1120.  
  1121. inline BOOL TDC::RoundRect(const TPoint& p1, const TPoint& p2, const TPoint& rad) {
  1122.   return ::RoundRect(GetHDC(), p1.x, p1.y, p2.x, p2.y, rad.x, rad.y);
  1123. }
  1124.  
  1125. inline BOOL TDC::RoundRect(const TPoint& p, const TSize& s, const TPoint& rad) {
  1126.   return ::RoundRect(GetHDC(), p.x, p.y, p.x+s.cx, p.y+s.cy, rad.x, rad.y);
  1127. }
  1128.  
  1129. inline BOOL TDC::RoundRect(const TRect& rect, const TPoint& rad) {
  1130.   return ::RoundRect(GetHDC(), rect.left, rect.top, rect.right, rect.bottom,
  1131.                      rad.x, rad.y);
  1132. }
  1133.  
  1134. inline TColor TDC::GetPixel(int x, int y) const {
  1135.   return ::GetPixel(GetHDC(), x, y);
  1136. }
  1137.  
  1138. inline TColor TDC::GetPixel(const TPoint& point) const {
  1139.   return ::GetPixel(GetHDC(), point.x, point.y);
  1140. }
  1141.  
  1142. inline TColor TDC::SetPixel(int x, int y, TColor color) {
  1143.   return ::SetPixel(GetHDC(), x, y, color);
  1144. }
  1145.  
  1146. inline TColor TDC::SetPixel(const TPoint& point, TColor color) {
  1147.   return ::SetPixel(GetHDC(), point.x, point.y, color);
  1148. }
  1149.  
  1150. inline BOOL TDC::BitBlt(int dstX, int dstY, int w, int h, const TDC& srcDC,
  1151.                        int srcX, int srcY, DWORD rop) {
  1152.   return ::BitBlt(GetHDC(), dstX, dstY, w, h, srcDC, srcX, srcY, rop);
  1153. }
  1154.  
  1155. inline BOOL TDC::BitBlt(const TRect& dst, const TDC& srcDC, const TPoint& src,
  1156.                         DWORD rop) {
  1157.   return ::BitBlt(GetHDC(), dst.left, dst.top, dst.Width(), dst.Height(),
  1158.                   srcDC, src.x, src.y, rop);
  1159. }
  1160.  
  1161. inline BOOL TDC::PatBlt(int x, int y, int w, int h, DWORD rop) {
  1162.   return ::PatBlt(GetHDC(), x, y, w, h, rop);
  1163. }
  1164.  
  1165. inline BOOL TDC::PatBlt(const TRect& dst, DWORD rop) {
  1166.   return ::PatBlt(GetHDC(), dst.left, dst.top, dst.Width(), dst.Height(), rop);
  1167. }
  1168.  
  1169. inline BOOL TDC::ScrollDC(int dx, int dy, const TRect& scroll, const TRect& clip,
  1170.                           TRegion& updateRgn, TRect& updateRect) {
  1171.   return ::ScrollDC(GetHDC(), dx, dy, &scroll, &clip, updateRgn, &updateRect);
  1172. }
  1173.  
  1174. inline BOOL TDC::ScrollDC(const TPoint& delta, const TRect& scroll, const TRect& clip,
  1175.                           TRegion& updateRgn, TRect& updateRect) {
  1176.   return ::ScrollDC(GetHDC(), delta.x, delta.y, &scroll, &clip, updateRgn, &updateRect);
  1177. }
  1178.  
  1179. inline BOOL TDC::StretchBlt(int dstX, int dstY, int dstW, int dstH,
  1180.                            const TDC& srcDC, int srcX, int srcY, int srcW,
  1181.                            int srcH, DWORD rop) {
  1182.   return ::StretchBlt(GetHDC(), dstX, dstY, dstW, dstH,
  1183.                       srcDC, srcX, srcY, srcW, srcH, rop);
  1184. }
  1185.  
  1186. inline BOOL TDC::StretchBlt(const TRect& dst, const TDC& srcDC,
  1187.                             const TRect& src, DWORD rop) {
  1188.   return ::StretchBlt(GetHDC(),
  1189.                       dst.left, dst.top, dst.Width(), dst.Height(),
  1190.                       srcDC, src.left, src.top,
  1191.                       src.Width(), src.Height(), rop);
  1192. }
  1193.  
  1194. #if defined(__WIN32__)
  1195. inline BOOL TDC::MaskBlt(const TRect& dst,
  1196.                          const TDC& srcDC, const TPoint& src,
  1197.                          const TBitmap& maskBm, const TPoint& maskPos,
  1198.                          DWORD rop) {
  1199.   return ::MaskBlt(GetHDC(), dst.left, dst.top, dst.Width(), dst.Height(),
  1200.                    srcDC, src.x, src.y, maskBm, maskPos.x, maskPos.y,
  1201.                    rop);
  1202.   return FALSE;
  1203. }
  1204.  
  1205. inline BOOL TDC::PlgBlt(const TPoint& dst,
  1206.                         const TDC& srcDC, const TRect& src,
  1207.                         const TBitmap& maskBm, const TPoint& maskPos, DWORD rop) {
  1208.   return ::PlgBlt(GetHDC(), (TPoint*)&dst,
  1209.                   srcDC, src.left, src.top, src.Width(), src.Height(),
  1210.                   maskBm, maskPos.x, maskPos.y);
  1211.   return FALSE;
  1212. }
  1213. #endif
  1214.  
  1215. inline BOOL TDC::GetDIBits(const TBitmap& bitmap, WORD startScan, WORD numScans,
  1216.                            void HUGE* bits, const BITMAPINFO far& info,
  1217.                            WORD usage) {
  1218.   return ::GetDIBits(GetHDC(), bitmap, startScan, numScans, bits,
  1219.                     (BITMAPINFO far*)&info, usage);
  1220. }
  1221.  
  1222. inline BOOL TDC::GetDIBits(const TBitmap& bitmap, TDib& dib) {
  1223.   return ::GetDIBits(GetHDC(), bitmap, dib.StartScan(), dib.NumScans(),
  1224.                      dib.GetBits(), dib.GetInfo(), dib.Usage());
  1225. }
  1226.  
  1227. inline BOOL TDC::SetDIBits(TBitmap& bitmap, WORD startScan, WORD numScans,
  1228.                            const void HUGE* bits, const BITMAPINFO far& info,
  1229.                            WORD usage) {
  1230.   return ::SetDIBits(GetHDC(), bitmap, startScan, numScans,
  1231.                      bits, (BITMAPINFO far*)&info, usage);
  1232.                      // API typecast
  1233. }
  1234.  
  1235. inline BOOL TDC::SetDIBits(TBitmap& bitmap, const TDib& dib) {
  1236.   return ::SetDIBits(GetHDC(), bitmap, dib.StartScan(), dib.NumScans(),
  1237.                      dib.GetBits(), (BITMAPINFO far*)dib.GetInfo(), dib.Usage());
  1238.                                    // API typecast
  1239. }
  1240.  
  1241. inline BOOL TDC::SetDIBitsToDevice(const TRect& dst, const TPoint& src,
  1242.                                    WORD startScan, WORD numScans,
  1243.                                    const void HUGE* bits,
  1244.                                    const BITMAPINFO far& info, WORD usage) {
  1245.   return ::SetDIBitsToDevice(
  1246.              GetHDC(), dst.left, dst.top,
  1247.              dst.Width(), dst.Height(), src.x, src.y,
  1248.              startScan, numScans,
  1249.              (void HUGE*)bits, (BITMAPINFO far*)&info, usage
  1250.          );                  // API typecast
  1251. }
  1252.  
  1253. inline BOOL TDC::SetDIBitsToDevice(const TRect& dst, const TPoint& src,
  1254.                                    const TDib& dib) {
  1255.   return ::SetDIBitsToDevice(
  1256.              GetHDC(),
  1257.              dst.left, dst.top, dst.Width(), dst.Height(),
  1258.              src.x, src.y,
  1259.              dib.StartScan(), dib.NumScans(),
  1260.              (void HUGE*)dib.GetBits(),
  1261.              (BITMAPINFO far*)dib.GetInfo(), dib.Usage()
  1262.          );                  // API typecast
  1263. }
  1264.  
  1265. inline BOOL TDC::StretchDIBits(const TRect& dst, const TRect& src,
  1266.                                const void HUGE* bits,
  1267.                                const BITMAPINFO far& info,
  1268.                                WORD usage, DWORD rop) {
  1269.   return ::StretchDIBits(
  1270.              GetHDC(), dst.left, dst.top, dst.Width(), dst.Height(),
  1271.              src.left, src.top, src.Width(), src.Height(),
  1272.              bits, (BITMAPINFO far*)&info, usage, rop
  1273.          );
  1274.          // API typecast
  1275. }
  1276.  
  1277. inline BOOL TDC::StretchDIBits(const TRect& dst, const TRect& src,
  1278.                                const TDib& dib, DWORD rop) {
  1279.   return ::StretchDIBits(
  1280.              GetHDC(),
  1281.              dst.left, dst.top, dst.Width(), dst.Height(),
  1282.              src.left, src.top, src.Width(), src.Height(),
  1283.              dib.GetBits(),
  1284.              (BITMAPINFO far*)dib.GetInfo(),
  1285.              dib.Usage(), rop
  1286.          );
  1287.                          // API typecast
  1288. }
  1289.  
  1290. inline BOOL TDC::FloodFill(const TPoint& point, TColor C) {
  1291.   return ::FloodFill(GetHDC(), point.x, point.y, C);
  1292. }
  1293.  
  1294. inline BOOL TDC::ExtFloodFill(const TPoint& point, TColor color, WORD fillType) {
  1295.   return ::ExtFloodFill(GetHDC(), point.x, point.y, color, fillType);
  1296. }
  1297.  
  1298. inline BOOL TDC::TextOut(const TPoint& p, const char far* str, int count) {
  1299.   return ::TextOut(GetHDC(), p.x, p.y, str, count>=0 ? count : strlen(str));
  1300. }
  1301.  
  1302. inline BOOL TDC::ExtTextOut(const TPoint& p, WORD options, const TRect* rect,
  1303.                          const char far* str, int count, const int far* dx) {
  1304.   return ::ExtTextOut(GetHDC(), p.x, p.y, options, rect, str, count, (int far*)dx);
  1305.   // API typecast
  1306. }
  1307.  
  1308. inline BOOL TDC::TabbedTextOut(const TPoint& p, const char far* str, int count,
  1309.                                int numPositions, const int far* positions,
  1310.                                int tabOrigin) {
  1311.   ::TabbedTextOut(GetHDC(), p.x, p.y, str, count, numPositions,
  1312.                   (int far*)positions, tabOrigin);  // API typecast
  1313.   return TRUE;
  1314. }
  1315.  
  1316. inline BOOL TDC::GetTextExtent(const char far* str, int stringLen, TSize& size) {
  1317.   return ::GetTextExtentPoint(GetAttributeHDC(), str, stringLen, &size);
  1318. }
  1319.  
  1320. inline TSize TDC::GetTextExtent(const char far* str, int stringLen) {
  1321.   #if defined(__WIN32__)
  1322.     TSize size;
  1323.     ::GetTextExtentPoint(GetAttributeHDC(), str, stringLen, &size);
  1324.     return size;
  1325.   #else
  1326.     return ::GetTextExtent(GetAttributeHDC(), str, stringLen);
  1327.   #endif
  1328. }
  1329.  
  1330. inline BOOL TDC::GetTabbedTextExtent(const char far* str, int strLen,
  1331.                                      int numPositions, const int far* positions,
  1332.                                      TSize& size) const {
  1333.   size = ::GetTabbedTextExtent(GetAttributeHDC(), str, strLen, numPositions,
  1334.                                (int far*)positions);   // API Typecast
  1335.   return TRUE;
  1336. }
  1337.  
  1338. inline TSize TDC::GetTabbedTextExtent(const char far* str, int strLen,
  1339.                                       int numPositions, 
  1340.                                       const int far* positions) const {
  1341.   return ::GetTabbedTextExtent(GetAttributeHDC(), str, strLen, numPositions,
  1342.                                (int far*)positions);   // API Typecast
  1343. }
  1344.  
  1345. inline UINT TDC::GetTextAlign() const {
  1346.   return ::GetTextAlign(GetAttributeHDC());
  1347. }
  1348.  
  1349. inline UINT TDC::SetTextAlign(UINT flags) {
  1350.   if (GetHDC() != GetAttributeHDC())
  1351.     ::SetTextAlign(GetHDC(), flags);
  1352.   return ::SetTextAlign(GetAttributeHDC(), flags);
  1353. }
  1354.  
  1355. inline int TDC::GetTextCharacterExtra() const {
  1356.   return ::GetTextCharacterExtra(GetAttributeHDC());
  1357. }
  1358.  
  1359. inline int TDC::SetTextCharacterExtra(int extra) {
  1360.   if (GetHDC() != GetAttributeHDC())
  1361.     ::SetTextCharacterExtra(GetHDC(), extra);
  1362.   return ::SetTextCharacterExtra(GetAttributeHDC(), extra);
  1363. }
  1364.  
  1365. inline BOOL TDC::SetTextJustification(int breakExtra, int breakCount) {
  1366.   return ::SetTextJustification(GetAttributeHDC(), breakExtra, breakCount);
  1367. }
  1368.  
  1369. inline int TDC::GetTextFace(int count, char far* facename) const {
  1370.   return ::GetTextFace(GetAttributeHDC(), count, facename);
  1371. }
  1372.  
  1373. inline BOOL TDC::GetTextMetrics(TEXTMETRIC far& metrics) const {
  1374.   return ::GetTextMetrics(GetAttributeHDC(), &metrics);
  1375. }
  1376.  
  1377. inline DWORD TDC::GetGlyphOutline(UINT chr, UINT format, GLYPHMETRICS far& gm,
  1378.                                   DWORD buffSize, void far* buffer,
  1379.                                   const MAT2 far& mat2) {
  1380.   return ::GetGlyphOutline(GetAttributeHDC(), chr, format, &gm, buffSize,
  1381.                            buffer, (MAT2*)&mat2);
  1382. }
  1383.  
  1384. inline int TDC::GetKerningPairs(int pairs, KERNINGPAIR far* krnPair) {
  1385.   return ::GetKerningPairs(GetAttributeHDC(), pairs, krnPair);
  1386. }
  1387.  
  1388. #if defined(__WIN32__)
  1389.   inline DWORD
  1390. #else
  1391.   inline WORD
  1392. #endif
  1393. TDC::GetOutlineTextMetrics(UINT data, OUTLINETEXTMETRIC far& otm)
  1394. {
  1395.   return ::GetOutlineTextMetrics(GetAttributeHDC(), data, &otm);
  1396. }
  1397.  
  1398. inline BOOL TDC::GetCharWidth(UINT firstChar, UINT lastChar, int* buffer) {
  1399.   return ::GetCharWidth(GetAttributeHDC(), firstChar, lastChar, buffer);
  1400. }
  1401.  
  1402. inline DWORD TDC::SetMapperFlags(DWORD flag) {
  1403.   if (GetHDC() != GetAttributeHDC())
  1404.     ::SetMapperFlags(GetHDC(), flag);
  1405.   return ::SetMapperFlags(GetAttributeHDC(), flag);
  1406. }
  1407.  
  1408. inline BOOL TDC::GetAspectRatioFilter(TSize& size) const {
  1409.   return ::GetAspectRatioFilterEx(GetAttributeHDC(), &size);
  1410. }
  1411.  
  1412. inline int TDC::EnumFonts(const char far* faceName, OLDFONTENUMPROC callback, LPVOID data) const {
  1413.   return ::EnumFonts(GetAttributeHDC(), faceName, callback, LPARAM(data));
  1414. }
  1415.  
  1416. inline BOOL TDC::GetCharABCWidths(UINT firstChar, UINT lastChar, ABC* abc) {
  1417.   return ::GetCharABCWidths(GetAttributeHDC(), firstChar, lastChar, abc);
  1418. }
  1419.  
  1420. inline int TDC::EnumFontFamilies(const char far* familyName, FONTENUMPROC callback, LPVOID data) const {
  1421.   return ::EnumFontFamilies(GetAttributeHDC(), familyName, callback, LPARAM(data));
  1422. }
  1423.  
  1424. inline DWORD TDC::GetFontData(DWORD table, DWORD offset, void* buffer, long data) {
  1425.   return ::GetFontData(GetAttributeHDC(), table, offset, buffer, data);
  1426. }
  1427.  
  1428. #if defined(__WIN32__)
  1429. inline BOOL TDC::BeginPath() {
  1430.   return ::BeginPath(GetHDC());
  1431. }
  1432.  
  1433. inline BOOL TDC::CloseFigure() {
  1434.   return ::CloseFigure(GetHDC());
  1435. }
  1436.  
  1437. inline BOOL TDC::EndPath() {
  1438.   return ::EndPath(GetHDC());
  1439. }
  1440.  
  1441. inline BOOL TDC::FlattenPath() {
  1442.   return ::FlattenPath(GetHDC());
  1443. }
  1444.  
  1445. inline BOOL TDC::WidenPath() {
  1446.   return ::WidenPath(GetHDC());
  1447. }
  1448.  
  1449. inline BOOL TDC::FillPath() {
  1450.   return ::FillPath(GetHDC());
  1451. }
  1452.  
  1453. inline BOOL TDC::StrokePath() {
  1454.   return ::StrokePath(GetHDC());
  1455. }
  1456.  
  1457. inline BOOL TDC::StrokeAndFillPath() {
  1458.   return ::StrokeAndFillPath(GetHDC());
  1459. }
  1460.  
  1461. inline BOOL TDC::SelectClipPath(int mode) {
  1462.   return ::SelectClipPath(GetHDC(), mode);
  1463. }
  1464.  
  1465. inline HRGN TDC::PathToRegion() {
  1466.   return ::PathToRegion(GetHDC());
  1467. }
  1468. #endif
  1469.  
  1470.  
  1471. inline HMETAFILE TMetaFileDC::Close() {
  1472.   HMETAFILE mf = ::CloseMetaFile(GetHDC());
  1473.   Handle = 0;
  1474.   return mf;
  1475. }
  1476.  
  1477. inline int TPrintDC::Escape(int esc, int count, const void* inData, void* outData) {
  1478.   return ::Escape(GetHDC(), esc, count, (const char far*)inData, outData);
  1479.                     // API type cast
  1480. }
  1481.  
  1482. inline int TPrintDC::SetAbortProc(ABORTPROC proc) {
  1483.   return ::SetAbortProc(GetHDC(), proc);
  1484. }
  1485.  
  1486. inline int TPrintDC::StartDoc(const char far* docName, const char far* output) {
  1487.   DocInfo.lpszDocName = (char far*)docName;
  1488.   DocInfo.lpszOutput = (char far*)output;
  1489.   return ::StartDoc(GetHDC(), &DocInfo);
  1490. }
  1491.  
  1492. inline int TPrintDC::StartPage() {  // Only call if not banding
  1493.   return ::StartPage(GetHDC());
  1494. }
  1495.  
  1496. inline int TPrintDC::BandInfo(TBandInfo& bandInfo) {
  1497.   return Escape(BANDINFO, sizeof(TBandInfo), 0, (LPSTR)&bandInfo);
  1498. }
  1499.  
  1500. inline int TPrintDC::NextBand(TRect& rect) {
  1501.   return Escape(NEXTBAND, 0, 0, (void*)&rect);
  1502. }
  1503.  
  1504. inline int TPrintDC::EndPage() {  // Only call if not banding
  1505.   return ::EndPage(GetHDC());
  1506. }
  1507.  
  1508. inline int TPrintDC::AbortDoc() {
  1509.   return ::AbortDoc(GetHDC());
  1510. }
  1511.  
  1512. inline int TPrintDC::EndDoc() {
  1513.   return ::EndDoc(GetHDC());
  1514. }
  1515.  
  1516. #if !defined(__WIN32__)
  1517. inline BOOL TPrintDC::QueryAbort(int rsvd) {
  1518.   return ::QueryAbort(GetHDC(), rsvd);
  1519. }
  1520. #endif
  1521.  
  1522. inline UINT TPrintDC::QueryEscSupport(int escapeNum) {
  1523.   return Escape(QUERYESCSUPPORT, sizeof(int), &escapeNum);
  1524. }
  1525.  
  1526. inline int TPrintDC::SetCopyCount(int reqestCopies, int& actualCopies) {
  1527.   return Escape(SETCOPYCOUNT, sizeof(int), &reqestCopies, &actualCopies);
  1528. }
  1529.  
  1530. #endif  // __OWL_DC_H
  1531.