home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1996 November / VPR9611B.ISO / vabasic / ntclnt.exe / DISK8 / data.8 / datab / INCLUDE / CPLACE.HH < prev    next >
Text File  |  1996-07-29  |  6KB  |  177 lines

  1. //-------------------------------------------------------------
  2. // $Source: /rcs/crcs/utils/intel/cplace.hh,v $
  3. // Checked in by: $Author: thomas $
  4. // $Date: 1996/05/27 23:36:57 $              $Revision: 1.8 $
  5. //--------------------------------------------------------------
  6. //      Copyright (c) International Business Machines Inc, 1994
  7. //
  8. // ALL RIGHTS RESERVED. This notice is intended as a precaution
  9. // against inadvertent publication, and shall not be deemed to
  10. // consitute an acknowledgment that publication has occurred
  11. // nor to imply any waiver of confidentiality. The year included
  12. // in the notice is the year of the creation of the work.
  13. //--------------------------------------------------------------
  14. // DESCRIPTION:
  15. //      This file contains the class declaration for the
  16. //      VwpHandle and VwpPlaceable classes.
  17. //--------------------------------------------------------------
  18. #ifndef CPLACE_HH
  19. #define CPLACE_HH
  20.  
  21. #include <cdc.hh>
  22.  
  23. #ifdef VSYS_OS2
  24.   #define VwResHandle       LHANDLE
  25.   #define VwResPalette      HPAL
  26.   #define VwResTypeBitmap   CF_BITMAP
  27.   #define VwResTypeMetafile CF_METAFILE
  28.   #define VwResTypeIcon     -1
  29.   #define VwResColor        LONG
  30. #else
  31.   #define VwResHandle       HANDLE
  32.   #define VwResPalette      HPALETTE
  33.   #define VwResTypeBitmap   CF_BITMAP
  34.   #define VwResTypeMetafile CF_METAFILEPICT
  35.   #define VwResTypeIcon     -1
  36.   #define VwResColor        COLORREF
  37. #endif
  38.  
  39. #ifdef NOTEMPLATES
  40.   #ifndef CPlaceableTableDefined
  41.     #define CPlaceableTableDefined
  42.     #define CLASSNAME VwpPlaceableTable
  43.     #define ENTRYTYPE void*
  44.     #include <mst/ihash.mst>
  45.   #endif
  46. #else
  47.   #include <ihash.hh>
  48.   typedef VeIHashTable<void*> VwpPlaceableTable;
  49. #endif
  50.  
  51.  
  52. // File Types for VwLoadPlaceable. Providing a fileType to VwLoadPlaceable
  53. // will speed up the Picture creation process.
  54. #define UNKNOWN_FILETYPE        0
  55. #define BITMAP_FILETYPE         1
  56. #define ICON_FILETYPE           2
  57. #define META_FILETYPE           3
  58.  
  59.  
  60. /************************************************************************/
  61. /************************************************************************/
  62. /****************  Class Definitions ************************************/
  63. /************************************************************************/
  64.  
  65.  
  66. //*************************************************************************
  67. // The VwpHandle class is a general container or wrapper for platform handles
  68. // introduced by subclasses of the VwpPlaceable class.  It allows serveral
  69. // instances to share the same platform handle by reference count.
  70. // New CPlaceables should inherit or implement a destroy call back
  71. // (CDestroyCallback) used to dispose of the platform handle.
  72. //*************************************************************************
  73.  
  74. typedef VwBool (*CDestroyCallback)(VwResHandle);
  75.  
  76. VCLASS VwpHandle {
  77.  
  78. public:
  79.  
  80.   VOPERDECL                     VwpHandle();
  81.   VOPERDECL                     VwpHandle(VwResHandle, CDestroyCallback,
  82.                                           VwResPalette = NULL);
  83.   virtual VOPERDECL             ~VwpHandle();
  84.  
  85.   VMETHODDECL(VwResHandle)      Handle();
  86.   VMETHODDECL(void)             SetHandle(VwResHandle);
  87.   VMETHODDECL(CDestroyCallback) DestroyCallback();
  88.   VMETHODDECL(void)             SetDestroyCallback(CDestroyCallback);
  89.   VMETHODDECL(int)              Acquire();
  90.   VMETHODDECL(int)              Release();
  91.   VMETHODDECL(VwResPalette)     DIBPalette();
  92.  
  93. private:
  94.   VwBool           FireCallback();
  95.   void             Init();
  96.   VwResHandle      itsHandle;
  97.   CDestroyCallback itsCallback;
  98.   int              itsRefCount;
  99.   VwResPalette     itsDIBPal;
  100. };
  101.  
  102.  
  103. VCLASS VwpPlaceable {
  104.  
  105. public:
  106.  
  107.   VOPERDECL                   VwpPlaceable();
  108.   virtual VOPERDECL           ~VwpPlaceable();
  109.   VVIRTUALDECL(void)          Init();
  110.  
  111.   // Visual Basic functionality
  112.   VVIRTUALDECL(VwStatus)      Load(const char * = NULL, long offset = 0) = 0;
  113.   VVIRTUALDECL(VwStatus)      Load(FILE *) = 0;
  114.   VVIRTUALDECL(VwStatus)      Load(void * buffer, LONG buflen) = 0;
  115.   VVIRTUALDECL(VwStatus)      Paint(VwpDC *, VwpRect *) = 0;
  116.   VVIRTUALDECL(VwStatus)      Save(const char * = NULL) = 0;
  117.   VVIRTUALDECL(VwStatus)      Save(FILE *) = 0;
  118.   VVIRTUALDECL(int)           GraphicFormat() = 0;
  119.   VVIRTUALDECL(LONG)          GraphicLength() = 0;
  120.   VVIRTUALDECL(VwStatus)      DumpGraphic(void *buffer) = 0;
  121.   VVIRTUALDECL(VwResHandle)   CloneGraphic() = 0;
  122.   VVIRTUALDECL(VwpPlaceable *)  Copy() = 0;
  123.  
  124.   static VMETHODDECL(VwBool)  CanLoadFrom(void *, LONG, VeString, FILE *, VwpPlaceable **);
  125.  
  126.   // Platform handle manipulation interface
  127.   VVIRTUALDECL(VwpHandle*)      Handle();
  128.   VVIRTUALDECL(void)          SetHandle(VwpHandle *);
  129.   VVIRTUALDECL(VwResHandle)   PlatformHandle();
  130.   VVIRTUALDECL(VwBool)        FreeHandle();
  131.  
  132.   // Reference Counting Interface
  133.   VVIRTUALDECL(int)           AddRef();
  134.   VVIRTUALDECL(int)           RemoveRef();
  135.   VVIRTUALDECL(int)           Reference();
  136.  
  137.   VMETHODDECL(void*)          SetPlatformData(void *);
  138.   VMETHODDECL(void*)          PlatformData();
  139.  
  140.   // Property Interface
  141.   VMETHODDECL(VwBool)         Stretch();
  142.   VMETHODDECL(void)           SetStretch(VwBool);
  143.  
  144.   // Additional Function
  145.   VMETHODDECL(VwStatus)       Size(VwpSize &);
  146.   VMETHODDECL(void)           SetSize(int, int);
  147.   VMETHODDECL(void)           SetSize(VwpSize);
  148.   VMETHODDECL(VwStatus)       Position(VwpPoint &);
  149.   VMETHODDECL(void)           SetPosition(int, int);
  150.  
  151.   VMETHODDECL(VeString)        FileName();
  152.   VMETHODDECL(void)           SetFileName(const char *);
  153.  
  154.   // Function to determine if a pointer of unknown origin points to a VwpPlaceable
  155.   static VMETHODDECL(VwBool)  IsValidCPlaceable(void*);
  156.  
  157. protected:
  158.  
  159.   VwpPoint    itsPos;
  160.   VwpSize     itsSize;
  161.   void      *itsPlatformData;
  162.   VwpHandle   *itsHandle;
  163.  
  164. private:
  165.  
  166.   static VwpPlaceableTable*     theCPlaceableTable;
  167.   VeString   itsFileName;
  168.   int       itsRefCount;
  169.   struct  {
  170.     short stretch:1;
  171.   } itsDisplayFlags;
  172.  
  173. };
  174.  
  175.  
  176. #endif
  177.