home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / OWLINC.PAK / DC.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  53KB  |  1,523 lines

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