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

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1992, 1993 by Borland International
  3. //   include\owl\gdiobjct.h
  4. //   Definition of abstract GDI object class and derived classes
  5. //----------------------------------------------------------------------------
  6. #if !defined(__OWL_GDIOBJEC_H)
  7. #define __OWL_GDIOBJEC_H
  8.  
  9. #if !defined(__OWL_GDIBASE_H)
  10.   #include <owl\gdibase.h>
  11. #endif
  12.  
  13. class _OWLCLASS TDC;
  14. class _BIDSCLASS TFile;
  15. class _OWLCLASS TBrush;
  16. class _OWLCLASS TBitmap;
  17. class _OWLCLASS TDib;
  18. class _OWLCLASS TPalette;
  19. class _OWLCLASS TClipboard;
  20. class _OWLCLASS TMetaFilePict;
  21.  
  22. //
  23. // GDI Orphan control - Object reference counting & orphan recovery
  24. // enabled by default unless NO_GDI_ORPHAN_CONTROL is defined.
  25. //
  26. #if !defined(NO_GDI_ORPHAN_CONTROL)
  27.   #define OBJ_REF_ADD(handle,type) TGdiObject::RefAdd((handle), (type))
  28.   #define OBJ_REF_REMOVE(handle) TGdiObject::RefRemove(handle)
  29.   #define OBJ_REF_INC(handle) TGdiObject::RefInc(handle)
  30.   #if defined(__TRACE)
  31.     #define OBJ_REF_DEC(handle, wantDelete) TGdiObject::RefDec((handle),\
  32.                                                                (wantDelete))
  33.   #else
  34.     #define OBJ_REF_DEC(handle, wantDelete) TGdiObject::RefDec((handle))
  35.   #endif
  36.   #define OBJ_REF_COUNT(handle) TGdiObject::RefCount(handle)
  37.   struct TObjInfo;
  38. #else
  39.   #define OBJ_REF_ADD(handle,type) handle
  40.   #define OBJ_REF_REMOVE(handle) handle
  41.   #define OBJ_REF_INC(handle) handle
  42.   #define OBJ_REF_DEC(handle,wantDelete) handle
  43.   #define OBJ_REF_COUNT(handle) -1
  44. #endif
  45.  
  46. //
  47. // class TGdiObject
  48. // ----- ----------
  49. //
  50. // Abstract class for Windows GDI objects. Provides base, destruction &
  51. // orphan control for true GDI objects
  52. //
  53. class _OWLCLASS TGdiObject : private TGdiBase {
  54.   public:
  55.     // virtual destructor--all GDI objects inherit this.
  56.     /*virtual*/    ~TGdiObject();
  57.  
  58.     operator    HGDIOBJ() const {return HGDIOBJ(Handle);}
  59.     int         GetObject(int count, void far* object) const;
  60.  
  61.     #if !defined(NO_GDI_ORPHAN_CONTROL)
  62.       enum TType {
  63.         None, Pen, Brush, Font, Palette, Bitmap, TextBrush
  64.       };
  65.       static TObjInfo* RefFind(HANDLE object);
  66.       static void      RefAdd(HANDLE handle, TType type);
  67.       static void      RefRemove(HANDLE handle);
  68.       static void      RefInc(HANDLE handle);
  69.       #if defined(__TRACE)
  70.         static void    RefDec(HANDLE handle, BOOL wantDelete);
  71.       #else
  72.         static void    RefDec(HANDLE handle);
  73.       #endif
  74.       static int       RefCount(HANDLE handle);
  75.     #endif
  76.  
  77.   protected:
  78.     TGdiBase::CheckValid;  // make this function available to derivatives
  79.     TGdiBase::Handle;      // and these members too
  80.     TGdiBase::ShouldDelete;
  81.  
  82.     // constructors for use by derived classes only
  83.     TGdiObject();
  84.     TGdiObject(HANDLE handle, TAutoDelete autoDelete = NoAutoDelete);
  85.  
  86.   private:
  87.     TGdiObject(const TGdiObject&); // Protect against copying of GDI objects
  88.     TGdiObject& operator =(const TGdiObject&);
  89. };
  90.  
  91. //
  92. // class TPen
  93. // ----- ----
  94. //
  95. // GDI Pen class. Can construct a pen from explicit info, or indirectly
  96. //
  97. class _OWLCLASS TPen : public TGdiObject {
  98.   public:
  99.     // Constructors
  100.     TPen(HPEN handle, TAutoDelete autoDelete = NoAutoDelete);
  101.  
  102.     TPen(TColor color, int width=1, int style=PS_SOLID);
  103.     TPen(const LOGPEN far* logPen);
  104.     TPen(const TPen&);
  105.   #if defined(__WIN32__)
  106.     TPen(DWORD penStyle, DWORD width, const TBrush& brush, DWORD styleCount,
  107.          LPDWORD style);
  108.     TPen(DWORD penStyle, DWORD width, const LOGBRUSH& logBrush,
  109.          DWORD styleCount, LPDWORD style);
  110.   #endif
  111.  
  112.     operator HPEN() const {return HPEN(HGDIOBJ(*this));}
  113.  
  114.     // Get GDI Pen Object information
  115.     BOOL        GetObject(LOGPEN far& logPen) const;
  116.  
  117.   private:
  118.     TPen& operator =(const TPen&);
  119. };
  120.  
  121. //
  122. // class TBrush
  123. // ----- ------
  124. //
  125. // GDI Brush class. Can construct a brush from explicit info, creating a 
  126. // solid, styled, or patterned brush.  Can also create a brush indirectly.
  127. //
  128. class _OWLCLASS TBrush : public TGdiObject {
  129.   public:
  130.     // Constructors
  131.     TBrush(HBRUSH handle, TAutoDelete autoDelete = NoAutoDelete);
  132.  
  133.     TBrush(TColor color);
  134.     TBrush(TColor color, int style);
  135.     TBrush(const TBitmap& pattern);
  136.     TBrush(const TDib& pattern);
  137.     TBrush(const LOGBRUSH far* logBrush);
  138.     TBrush(const TBrush& src);
  139.  
  140.     operator HBRUSH() const {return HBRUSH(HGDIOBJ(*this));}
  141.  
  142.     // Get GDI Brush Object information
  143.     BOOL        GetObject(LOGBRUSH far& logBrush) const;
  144.     BOOL        UnrealizeObject();
  145.  
  146.   private:
  147.     TBrush& operator =(const TBrush&);
  148. };
  149.  
  150. //
  151. // class TFont
  152. // ----- -----
  153. //
  154. // GDI Font class.  Can construct a font from explicit info, or indirectly.
  155. //
  156. class _OWLCLASS TFont : public TGdiObject {
  157.   public:
  158.     // Constructors
  159.     TFont(HFONT handle, TAutoDelete autoDelete = NoAutoDelete);
  160.   
  161.     // Convenient font ctor
  162.     TFont(const char far* facename=0,
  163.           int height=0, int width=0, int escapement=0, int orientation=0,
  164.           int weight=FW_NORMAL,
  165.           BYTE pitchAndFamily=DEFAULT_PITCH|FF_DONTCARE,
  166.           BYTE italic=FALSE, BYTE underline=FALSE, BYTE strikeout=FALSE,
  167.           BYTE charSet=1,  // DEFAULT_CHARSET or UNICODE_CHARSET
  168.           BYTE outputPrecision=OUT_DEFAULT_PRECIS,
  169.           BYTE clipPrecision=CLIP_DEFAULT_PRECIS,
  170.           BYTE quality=DEFAULT_QUALITY);
  171.  
  172.     // CreateFont() matching font ctor
  173.     TFont(int height, int width, int escapement=0, int orientation=0,
  174.           int weight=FW_NORMAL,
  175.           BYTE italic=FALSE, BYTE underline=FALSE, BYTE strikeout=FALSE,
  176.           BYTE charSet=1,  // DEFAULT_CHARSET or UNICODE_CHARSET
  177.           BYTE outputPrecision=OUT_DEFAULT_PRECIS,
  178.           BYTE clipPrecision=CLIP_DEFAULT_PRECIS,
  179.           BYTE quality=DEFAULT_QUALITY,
  180.           BYTE pitchAndFamily=DEFAULT_PITCH|FF_DONTCARE,
  181.           const char far* facename=0);
  182.     TFont(const LOGFONT far* logFont);
  183.     TFont(const TFont&);
  184.  
  185.     operator HFONT() const {return HFONT(HGDIOBJ(*this));}
  186.  
  187.     // Get GDI Font Object information
  188.     BOOL        GetObject(LOGFONT far& logFont) const;
  189.  
  190.   private:
  191.     TFont& operator =(const TFont&);
  192. };
  193.  
  194. //
  195. // class TPalette
  196. // ----- --------
  197. //
  198. // GDI Palette class.  Can construct a palette from explicit info, or
  199. // indirectly from various color table types that are used by DIBs.
  200. //
  201. class _OWLCLASS TPalette : public TGdiObject {
  202.   public:
  203.     // Constructors
  204.     TPalette(HPALETTE handle, TAutoDelete autoDelete = NoAutoDelete);
  205.  
  206.     TPalette(const TClipboard&);
  207.     TPalette(const TPalette& palette);          // Copy whole palette
  208.  
  209.     TPalette(const LOGPALETTE far* logPalette);
  210.     TPalette(const PALETTEENTRY far* entries, int count);
  211.     TPalette(const BITMAPINFO far* info, UINT flags=0);    //Win 3.0 DIB hdr
  212.     TPalette(const BITMAPCOREINFO far* core, UINT flags=0);//PM 1.0 DIB header
  213.     TPalette(const TDib& dib, UINT flags=0);               // DIB object
  214.  
  215.     operator HPALETTE() const {return HPALETTE(HGDIOBJ(*this));}
  216.  
  217.     // Palette functions
  218.     BOOL        ResizePalette(UINT numEntries);
  219.     void        AnimatePalette(UINT start, UINT count, const PALETTEENTRY far* entries);
  220.     UINT        SetPaletteEntries(WORD start, WORD count, const PALETTEENTRY far* entries);
  221.     UINT        SetPaletteEntry(WORD index, const PALETTEENTRY far& entry);
  222.     UINT        GetPaletteEntries(WORD start, WORD count, PALETTEENTRY far* entries) const;
  223.     UINT        GetPaletteEntry(WORD index, PALETTEENTRY far& entry) const;
  224.     UINT        GetNearestPaletteIndex(TColor color) const;
  225.     BOOL        GetObject(WORD far& numEntries) const;
  226.     WORD        GetNumEntries() const;
  227.  
  228.     // Put this palette onto the clipboard
  229.     void        ToClipboard(TClipboard& Clipboard);
  230.     BOOL        UnrealizeObject() {return ::UnrealizeObject(Handle);}
  231.  
  232.   protected:
  233.     void        Create(const BITMAPINFO far* info, UINT flags);
  234.     void        Create(const BITMAPCOREINFO far* core, UINT flags);
  235.  
  236.   private:
  237.     TPalette& operator =(const TPalette&);
  238. };
  239.  
  240. inline TClipboard& operator <<(TClipboard& clipboard, TPalette& palette)
  241.       {palette.ToClipboard(clipboard); return clipboard;}
  242.  
  243. //
  244. // class TBitmap
  245. // ----- -------
  246. //
  247. // GDI Bitmap class.  Can construct a bitmap from many sources.  This bitmap
  248. // is the lowest level object that is actually selected into a DC.
  249. //
  250. class _OWLCLASS TBitmap : public TGdiObject {
  251.   public:
  252.     // Constructors
  253.     TBitmap(HBITMAP handle, TAutoDelete autoDelete = NoAutoDelete);
  254.     TBitmap(const TClipboard& clipboard);
  255.     TBitmap(const TBitmap& bitmap);
  256.  
  257.     TBitmap(int width, int height, BYTE planes=1, BYTE bitCount=1, void far* bits=0);
  258.     TBitmap(const BITMAP far* bitmap);
  259.     TBitmap(const TDC& Dc, int width, int height, BOOL discardable = FALSE);
  260.     TBitmap(const TDC& Dc, const TDib& dib, DWORD usage=CBM_INIT);
  261.  
  262.     TBitmap(const TMetaFilePict& metaFile, TPalette& palette, const TSize& size);
  263.     TBitmap(const TDib& dib, const TPalette* palette = 0);
  264.  
  265.     TBitmap(HINSTANCE, TResId);
  266.  
  267.     operator HBITMAP() const {return HBITMAP(HGDIOBJ(*this));}
  268.  
  269.     // Get/set GDI Object information
  270.     BOOL        GetObject(BITMAP far& bitmap) const;
  271.     int         Width() const;
  272.     int         Height() const;
  273.     BYTE        Planes() const;
  274.     BYTE        BitsPixel() const;
  275.     DWORD       GetBitmapBits(DWORD count, void far* bits) const;
  276.     DWORD       SetBitmapBits(DWORD count, const void far* bits);
  277.     BOOL        GetBitmapDimension(TSize& size) const;
  278.     BOOL        SetBitmapDimension(const TSize& size, TSize far* oldSize=0);
  279.  
  280.     // Put this bitmap onto the clipboard
  281.     void  ToClipboard(TClipboard& clipboard);
  282.  
  283.   protected:
  284.     TBitmap();
  285.  
  286.     // Create a bitmap & fill in it's Handle
  287.     void Create(const TDib& dib, const TPalette& palette);
  288.     void Create(const TBitmap& src);
  289.  
  290.   private:
  291.     TBitmap& operator =(const TBitmap&);
  292. };
  293.  
  294. inline TClipboard& operator <<(TClipboard& clipboard, TBitmap& bitmap)
  295.       {bitmap.ToClipboard(clipboard); return clipboard;}
  296.  
  297. //
  298. // class TRegion
  299. // ----- -------
  300. //
  301. // GDI Region class. Can construct a region from various shapes
  302. //
  303. class _OWLCLASS TRegion : private TGdiBase {
  304.   public:
  305.     // Constructors
  306.     TRegion();
  307.     TRegion(HRGN handle, TAutoDelete autoDelete = NoAutoDelete);
  308.     TRegion(const TRegion& region);
  309.     TRegion(const TRect& rect);
  310.     enum TEllipse {Ellipse};
  311.     TRegion(const TRect& e, TEllipse);
  312.     TRegion(const TRect& rect, const TSize& corner);
  313.     TRegion(const TPoint* points, int count, int fillMode);
  314.     TRegion(const TPoint* points, const int* polyCounts, int count,
  315.             int fillMode);
  316.    ~TRegion();
  317.  
  318.     // Other initialization
  319.     void        SetRectRgn(const TRect& rect);
  320.  
  321.     // Type Conversion Operators
  322.     operator HRGN() const {return HRGN(Handle);}
  323.  
  324.     // Test and information functions/operators
  325.     BOOL        operator ==(const TRegion& other) const;
  326.     BOOL        operator !=(const TRegion& other) const;
  327.     BOOL        Contains(const TPoint& point) const;
  328.     BOOL        Touches(const TRect& rect) const;
  329.     int         GetRgnBox(TRect& box) const;
  330.     TRect       GetRgnBox() const;
  331.  
  332.     // Assignment operators
  333.     TRegion&    operator =(const TRegion& source);
  334.     TRegion&    operator +=(const TSize& delta);
  335.     TRegion&    operator -=(const TSize& delta);
  336.     TRegion&    operator -=(const TRegion& source);
  337.     TRegion&    operator &=(const TRegion& source);
  338.     TRegion&    operator &=(const TRect& source);
  339.     TRegion&    operator |=(const TRegion& source);
  340.     TRegion&    operator |=(const TRect& source);
  341.     TRegion&    operator ^=(const TRegion& source);
  342.     TRegion&    operator ^=(const TRect& source);
  343. };
  344.  
  345. //
  346. // class TIcon
  347. // ----- -----
  348. //
  349. // Pseudo-GDI object Icon class.  Can construct an icon from a resource or
  350. // explicit info.  Overloads the destructor since it is not a real GDI object.
  351. //
  352. class _OWLCLASS TIcon : private TGdiBase {
  353.   public:
  354.     // Constructors
  355.     TIcon(HICON handle, TAutoDelete autoDelete = NoAutoDelete);
  356.     TIcon(HINSTANCE, const TIcon& icon);
  357.     TIcon(HINSTANCE, TResId);
  358.     TIcon(HINSTANCE, const char far* filename, int index);
  359.     TIcon(HINSTANCE, const TSize& size, int planes, int bitsPixel, 
  360.           const void far* andBits, const void far* xorBits);
  361.   #if defined(__WIN32__)
  362.     TIcon(const void* resBits, DWORD resSize);
  363.     TIcon(const ICONINFO* iconInfo);
  364.   #endif
  365.     ~TIcon();
  366.  
  367.     operator HICON() const {return HICON(Handle);}
  368.  
  369.   #if defined(__WIN32__)
  370.     BOOL      GetIconInfo(ICONINFO* iconInfo) const;
  371.   #endif
  372.  
  373.   private:
  374.     TIcon(const TIcon&); // Protect against copying of icons
  375.     TIcon& operator =(const TIcon&);
  376. };
  377.  
  378. //
  379. // class TCursor
  380. // ----- -------
  381. //
  382. // Pseudo-GDI object Icon class.  Can construct an icon from a resource or
  383. // explicit info.  Overloads the destructor since it is not a real GDI object.
  384. //
  385. class _OWLCLASS TCursor : public TGdiObject {
  386.   public:
  387.     // Constructors
  388.     TCursor(HCURSOR handle, TAutoDelete autoDelete = NoAutoDelete);
  389.     TCursor(HINSTANCE, const TCursor& cursor);
  390.     TCursor(HINSTANCE, TResId);
  391.     TCursor(HINSTANCE, const TPoint& hotSpot,
  392.             const TSize& size, void far* andBits, void far* xorBits);
  393.   #if defined(__WIN32__)
  394.     TCursor(const void* resBits, DWORD resSize);
  395.     TCursor(const ICONINFO* iconInfo);
  396.   #endif
  397.     ~TCursor();
  398.  
  399.     operator HCURSOR() const {return HCURSOR(Handle);}
  400.  
  401.   #if defined(__WIN32__)
  402.     BOOL      GetIconInfo(ICONINFO* iconInfo) const;
  403.   #endif
  404.     
  405.   private:
  406.     TCursor(const TCursor&); // Protect against copying of cursors
  407.     TCursor& operator =(const TCursor&);
  408. };
  409.  
  410. //
  411. // class TDib
  412. // ----- ----
  413. //
  414. // Pseudo-GDI object Device Independent Bitmap (DIB) class.  DIBs really have
  415. // no Window's handle, they are just a structure containing format and palette
  416. // information and a collection of bits (pixels).  This class provides a very
  417. // convenient way to work with DIBs like any other GDI object.
  418. // The memory for the DIB is in one GlobalAlloc'd chunk so it can be passed to
  419. // the Clipboard, OLE, etc.
  420. // Overloads the destructor since it is not a real GDI object.
  421. //
  422. // This is what is really inside a .BMP file, what is in bitmap resources, and
  423. // what is put on the clipboard as a DIB.
  424. //
  425. class _OWLCLASS TDib : private TGdiBase {
  426.   public:
  427.     // Constructors and destructor
  428.     TDib(HGLOBAL handle, TAutoDelete autoDelete = NoAutoDelete);
  429.     TDib(const TClipboard& clipboard);
  430.     TDib(const TDib& dib);
  431.  
  432.     TDib(int width, int height, int nColors, WORD mode=DIB_RGB_COLORS);
  433.     TDib(HINSTANCE, TResId);
  434.     TDib(const char* name);
  435.     TDib(const TBitmap& bitmap, const TPalette* pal = 0);
  436.     ~TDib();
  437.  
  438.     // Access to the internal structures of the dib
  439.     const BITMAPINFO far*      GetInfo() const {return Info;}
  440.     BITMAPINFO far*            GetInfo() {return Info;}
  441.     const BITMAPINFOHEADER far*GetInfoHeader() const {return &Info->bmiHeader;}
  442.     BITMAPINFOHEADER far*      GetInfoHeader() {return &Info->bmiHeader;}
  443.     const TRgbQuad far*        GetColors() const {return (const TRgbQuad far*)Info->bmiColors;}
  444.     TRgbQuad far*              GetColors() {return (TRgbQuad far*)Info->bmiColors;}
  445.     const WORD far*            GetIndices() const {return (WORD*)Info->bmiColors;}
  446.     WORD far*                  GetIndices() {return (WORD*)Info->bmiColors;}
  447.     const void HUGE*           GetBits() const {return Bits;}
  448.     void HUGE*                 GetBits() {return Bits;}
  449.  
  450.     // Type convert this dib by returning pointers to internal structures
  451.     operator HANDLE() const {return Handle;}
  452.     operator const BITMAPINFO far*() const {return GetInfo();}
  453.     operator BITMAPINFO far*() {return GetInfo();}
  454.     operator const BITMAPINFOHEADER far*() const {return GetInfoHeader();}
  455.     operator BITMAPINFOHEADER far*() {return GetInfoHeader();}
  456.     operator const TRgbQuad far*() const {return GetColors();}
  457.     operator TRgbQuad far*() {return GetColors();}
  458.  
  459.     // Put this Dib onto the clipboard
  460.     void      ToClipboard(TClipboard& clipboard);
  461.  
  462.     // Get info about this Dib
  463.     BOOL      IsOK() const {return Info != 0;}
  464.     BOOL      IsPM() const {return IsCore;}
  465.     int       Width() const {return W;}
  466.     int       Height() const {return H;}
  467.     TSize     Size() const {return TSize(W,H);}
  468.     long      NumColors() const {return NumClrs;}
  469.     WORD      StartScan() const {return 0;}
  470.     WORD      NumScans() const {return WORD(H);}
  471.     WORD      Usage() const {return Mode;}
  472.  
  473.     BOOL      WriteFile(const char* filename);
  474.  
  475.     // Work with the dib in PAL or RGB mode
  476.     BOOL      ChangeModeToPal(const TPalette& pal);
  477.     BOOL      ChangeModeToRGB(const TPalette& pal);
  478.     TColor    GetColor(int entry) const;
  479.     void      SetColor(int entry, TColor color);
  480.     int       FindColor(TColor color);
  481.     int       MapColor(TColor fromColor, TColor toColor, BOOL doAll = FALSE);
  482.     WORD      GetIndex(int entry) const;
  483.     void      SetIndex(int entry, WORD index);
  484.     int       FindIndex(WORD index);
  485.     int       MapIndex(WORD fromIndex, WORD toIndex, BOOL doAll = FALSE);
  486.  
  487.     enum {
  488.       MapFace      = 0x01,  // Or these together to control colors to map
  489.       MapText      = 0x02,  // to current SysColor values 
  490.       MapShadow    = 0x04,
  491.       MapHighlight = 0x08,
  492.       MapFrame     = 0x10
  493.     };
  494.     void      MapUIColors(UINT mapColors, TColor* bkColor = 0);
  495.     
  496.   protected:
  497.     BITMAPINFO far* Info;       // Locked global alloc'd block
  498.     void HUGE*      Bits;       // Pointer into above block at bits
  499.     long            NumClrs;
  500.     int             W;
  501.     int             H;
  502.     WORD            Mode;
  503.     BOOL            IsCore : 4;       //Q 1;
  504.     BOOL            IsResHandle : 4;  //Q 1;
  505.  
  506.     void      InfoFromHandle();
  507.     BOOL      Read(TFile& file, long offBits = 0);
  508.     BOOL      LoadResource(HINSTANCE, TResId);
  509.     BOOL      LoadFile(const char* name);
  510.  
  511.   private:
  512.     TDib& operator =(const TDib&);
  513. };
  514.  
  515. inline TClipboard& operator <<(TClipboard& clipboard, TDib& dib)
  516.       {dib.ToClipboard(clipboard); return clipboard;}
  517.  
  518.  
  519.  
  520. //----------------------------------------------------------------------------
  521. //   Inlines for abstract GDI object class and derived classes.
  522. //----------------------------------------------------------------------------
  523. #if !defined(__OWL_DC_H)
  524.   #include <owl\dc.h>
  525. #endif
  526. #if !defined(__OWL_CLIPBOAR_H)
  527.   #include <owl\clipboar.h>
  528. #endif
  529.  
  530. inline int TGdiObject::GetObject(int count, void far* object) const {
  531.   #if defined(__WIN32__)
  532.     #if defined(UNICODE)
  533.       return ::GetObjectW(Handle, count, object);
  534.     #else
  535.       return ::GetObjectA(Handle, count, object);
  536.     #endif
  537.   #else
  538.     return ::GetObject(Handle, count, object);
  539.   #endif
  540. }
  541.  
  542. inline BOOL TPen::GetObject(LOGPEN far& logPen) const {
  543.   return TGdiObject::GetObject(sizeof(logPen), &logPen) != 0;
  544. }
  545.  
  546. inline BOOL TBrush::GetObject(LOGBRUSH far& logBrush) const {
  547.   return TGdiObject::GetObject(sizeof(logBrush), &logBrush) != 0;
  548. }
  549.  
  550. #if !defined(__WIN32__)
  551.   inline BOOL TBrush:: UnrealizeObject() {
  552.     return ::UnrealizeObject(Handle);
  553.  }
  554. #endif
  555.  
  556. inline BOOL TFont::GetObject(LOGFONT far& logFont) const {
  557.   return TGdiObject::GetObject(sizeof(logFont), &logFont) != 0;
  558. }
  559.  
  560.  
  561. inline BOOL TPalette::ResizePalette(UINT numEntries) {
  562.   return ::ResizePalette((HPALETTE)Handle, numEntries);
  563. }
  564.  
  565. inline void TPalette::AnimatePalette(UINT start, UINT count, const PALETTEENTRY far* entries) {
  566.   ::AnimatePalette((HPALETTE)Handle, start, count, entries);
  567. }
  568.  
  569. inline UINT TPalette::SetPaletteEntries(WORD start, WORD count, const PALETTEENTRY far* entries) {
  570.   return ::SetPaletteEntries((HPALETTE)Handle, start, count, entries);
  571. }
  572.  
  573. inline UINT TPalette::SetPaletteEntry(WORD index, const PALETTEENTRY far& entry) {
  574.   return ::SetPaletteEntries((HPALETTE)Handle, index, 1, &entry);
  575. }
  576.  
  577. inline UINT TPalette::GetPaletteEntries(WORD start, WORD count, PALETTEENTRY far* entries) const {
  578.   return ::GetPaletteEntries((HPALETTE)Handle, start, count, entries);
  579. }
  580.  
  581. inline UINT TPalette::GetPaletteEntry(WORD index, PALETTEENTRY far& entry) const {
  582.   return ::GetPaletteEntries((HPALETTE)Handle, index, 1, &entry);
  583. }
  584.  
  585. inline UINT TPalette::GetNearestPaletteIndex(TColor Color) const {
  586.   return ::GetNearestPaletteIndex((HPALETTE)Handle, Color);
  587. }
  588.  
  589. inline BOOL TPalette::GetObject(WORD far& numEntries) const {
  590.   return TGdiObject::GetObject(sizeof(numEntries), &numEntries);
  591. }
  592.  
  593. inline WORD TPalette::GetNumEntries() const {
  594.   WORD numEntries;
  595.   if (TGdiObject::GetObject(sizeof(numEntries), &numEntries))
  596.     return numEntries;
  597.   return 0;
  598. }
  599.  
  600. inline DWORD TBitmap::GetBitmapBits(DWORD count, void far* bits) const {
  601.   return ::GetBitmapBits((HBITMAP)Handle, count, bits);
  602. }
  603.  
  604. inline DWORD TBitmap::SetBitmapBits(DWORD count, const void far* bits) {
  605.   return ::SetBitmapBits((HBITMAP)Handle, count, bits);
  606. }
  607.  
  608. inline BOOL TBitmap::GetBitmapDimension(TSize& size) const {
  609.   return ::GetBitmapDimensionEx((HBITMAP)Handle, &size);
  610. }
  611.  
  612. inline BOOL TBitmap::SetBitmapDimension(const TSize& size, TSize far* oldSize) {
  613.   return ::SetBitmapDimensionEx((HBITMAP)Handle, size.cx, size.cy, oldSize);
  614. }
  615.  
  616. inline BOOL TBitmap::GetObject(BITMAP far& Bitmap) const {
  617.   return TGdiObject::GetObject(sizeof(Bitmap), &Bitmap) != 0;
  618. }
  619.  
  620.  
  621. inline void TRegion::SetRectRgn(const TRect& rect) {
  622.   ::SetRectRgn((HRGN)Handle, rect.left, rect.top, rect.right, rect.bottom);
  623. }
  624.  
  625. inline BOOL TRegion::operator ==(const TRegion& other) const {
  626.   return ::EqualRgn((HRGN)Handle, other);
  627. }
  628.  
  629. inline BOOL TRegion::operator !=(const TRegion& other) const {
  630.   return !::EqualRgn((HRGN)Handle, other);
  631. }
  632.  
  633. inline BOOL TRegion::Contains(const TPoint& point) const {
  634.   return ::PtInRegion((HRGN)Handle, point.x, point.y);
  635. }
  636.  
  637. inline BOOL TRegion::Touches(const TRect& rect) const {
  638.   return ::RectInRegion((HRGN)Handle, (TRect*)&rect); // API <const> typecast 
  639. }
  640.  
  641. inline int TRegion::GetRgnBox(TRect& box) const {
  642.   return ::GetRgnBox((HRGN)Handle, &box);
  643. }
  644.  
  645. inline TRect TRegion::GetRgnBox() const {
  646.   TRect box;
  647.   ::GetRgnBox((HRGN)Handle, &box);
  648.   return box;
  649. }
  650.  
  651. inline TRegion& TRegion::operator =(const TRegion& source) {
  652.   ::CombineRgn((HRGN)Handle, source, 0, RGN_COPY);
  653.   return *this;
  654. }
  655.  
  656. inline TRegion& TRegion::operator +=(const TSize& delta) {
  657.   ::OffsetRgn((HRGN)Handle, delta.cx, delta.cy);
  658.   return *this;
  659. }
  660.  
  661. inline TRegion& TRegion::operator -=(const TSize& delta) {
  662.   ::OffsetRgn((HRGN)Handle, -delta.cx, -delta.cy);
  663.   return *this;
  664. }
  665.  
  666. inline TRegion& TRegion::operator -=(const TRegion& source) {
  667.   ::CombineRgn((HRGN)Handle, (HRGN)Handle, source, RGN_DIFF);
  668.   return *this;
  669. }
  670.  
  671. inline TRegion& TRegion::operator &=(const TRegion& source) {
  672.   ::CombineRgn((HRGN)Handle, (HRGN)Handle, source, RGN_AND);
  673.   return *this;
  674. }
  675.  
  676. inline TRegion& TRegion::operator |=(const TRegion& source) {
  677.   ::CombineRgn((HRGN)Handle, (HRGN)Handle, source, RGN_OR);
  678.   return *this;
  679. }
  680.  
  681. inline TRegion& TRegion::operator ^=(const TRegion& source) {
  682.   ::CombineRgn((HRGN)Handle, (HRGN)Handle, source, RGN_XOR);
  683.   return *this;
  684. }
  685. #if defined(__WIN32__)
  686. inline BOOL TIcon::GetIconInfo(ICONINFO far* IconInfo) const {
  687.   return ::GetIconInfo((HICON)Handle, IconInfo);
  688. }
  689.  
  690. inline BOOL TCursor::GetIconInfo(ICONINFO far* IconInfo) const {
  691.   return ::GetIconInfo((HICON)(HCURSOR)Handle, IconInfo);
  692. }
  693. #endif
  694.  
  695.  
  696. #endif  // __OWL_GDIOBJEC_H
  697.