Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
7.0 KiB

  1. #ifndef __DATASRC_H_
  2. #define __DATASRC_H_
  3. const TW_UINT32 MIN_MEMXFER_SIZE = 16 * 1024;
  4. const TW_UINT32 MAX_MEMXFER_SIZE = 64 * 1024;
  5. const TW_UINT32 PREFERRED_MEMXFER_SIZE = 32 * 1024;
  6. //
  7. // TWAIN specific registry KEY
  8. //
  9. // Location: HKEY_CURRENT_USER\Software\Microsoft\WIA\TwainCompatLayer
  10. #define TWAIN_REG_KEY TEXT("Software\\Microsoft\\WIA\\TwainCompatLayer")
  11. #define DWORD_REGVALUE_ENABLE_MULTIPAGE_SCROLLFED TEXT("EnableMultiPageScrollFed")
  12. // Registry Key Value defines
  13. #define DWORD_REGVALUE_ENABLE_MULTIPAGE_SCROLLFED_ON 1
  14. #define MAX_BITDEPTHS 64
  15. typedef enum dsState
  16. {
  17. DS_STATE_0 = 0,
  18. DS_STATE_1,
  19. DS_STATE_2,
  20. DS_STATE_3,
  21. DS_STATE_4,
  22. DS_STATE_5,
  23. DS_STATE_6,
  24. DS_STATE_7
  25. } DS_STATE, *PDS_STATE;
  26. typedef struct tagTWMsg
  27. {
  28. TW_IDENTITY *AppId;
  29. TW_UINT32 DG;
  30. TW_UINT16 DAT;
  31. TW_UINT16 MSG;
  32. TW_MEMREF pData;
  33. }TWAIN_MSG, *PTWAIN_MSG;
  34. //
  35. // bitmap file type
  36. //
  37. const WORD BFT_BITMAP = 0x4d42;
  38. class CWiaDataSrc
  39. {
  40. public:
  41. CWiaDataSrc();
  42. virtual ~CWiaDataSrc();
  43. virtual TW_UINT16 IWiaDataSrc(LPCTSTR DeviceName);
  44. virtual void NotifyCloseReq();
  45. virtual void NotifyXferReady();
  46. TW_UINT16 DSEntry(pTW_IDENTITY pOrigin,TW_UINT32 DG,TW_UINT16 DAT,TW_UINT16 MSG,TW_MEMREF pData);
  47. TW_FIX32 FloatToFix32(FLOAT f);
  48. FLOAT Fix32ToFloat(TW_FIX32 fix32);
  49. TW_UINT16 AddWIAPrefixToString(LPTSTR szString,UINT uSize);
  50. DS_STATE SetTWAINState(DS_STATE NewTWAINState);
  51. DS_STATE GetTWAINState();
  52. TW_UINT16 SetStatusTWCC(TW_UINT16 NewConditionCode);
  53. float ConvertToTWAINUnits(LONG lValue, LONG lResolution);
  54. LONG ConvertFromTWAINUnits(float fValue, LONG lResolution);
  55. DWORD ReadTwainRegistryDWORDValue(LPTSTR szRegValue, DWORD dwDefault = 0);
  56. BOOL m_bCacheImage;
  57. protected:
  58. //
  59. // Functions for DG == DG_CONTROL
  60. //
  61. virtual TW_UINT16 OnCapabilityMsg(PTWAIN_MSG ptwMsg);
  62. virtual TW_UINT16 OnPrivateCapabilityMsg(PTWAIN_MSG ptwMsg);
  63. virtual TW_UINT16 OnPendingXfersMsg (PTWAIN_MSG ptwMsg);
  64. virtual TW_UINT16 OnIdentityMsg (PTWAIN_MSG ptwMsg);
  65. virtual TW_UINT16 OnSetupMemXferMsg (PTWAIN_MSG ptwMsg);
  66. virtual TW_UINT16 OnSetupFileXferMsg(PTWAIN_MSG ptwMsg);
  67. virtual TW_UINT16 OnUserInterfaceMsg(PTWAIN_MSG ptwMsg);
  68. virtual TW_UINT16 OnXferGroupMsg (PTWAIN_MSG ptwMsg);
  69. virtual TW_UINT16 OnStatusMsg (PTWAIN_MSG ptwMsg);
  70. //
  71. // Functions for DG == DG_IMAGE
  72. //
  73. virtual TW_UINT16 OnPalette8Msg (PTWAIN_MSG ptwMsg);
  74. virtual TW_UINT16 OnGrayResponseMsg (PTWAIN_MSG ptwMsg);
  75. virtual TW_UINT16 OnRGBResponseMsg (PTWAIN_MSG ptwMsg);
  76. virtual TW_UINT16 OnCIEColorMsg (PTWAIN_MSG ptwMsg);
  77. virtual TW_UINT16 OnJPEGCompressionMsg(PTWAIN_MSG ptwMsg);
  78. virtual TW_UINT16 OnImageInfoMsg (PTWAIN_MSG ptwMsg);
  79. virtual TW_UINT16 OnImageLayoutMsg (PTWAIN_MSG ptwMsg);
  80. virtual TW_UINT16 OnImageMemXferMsg (PTWAIN_MSG ptwMsg);
  81. virtual TW_UINT16 OnImageFileXferMsg (PTWAIN_MSG ptwMsg);
  82. virtual TW_UINT16 OnImageNativeXferMsg(PTWAIN_MSG ptwMsg);
  83. virtual TW_UINT16 DispatchControlMsg (PTWAIN_MSG ptwMsg);
  84. virtual TW_UINT16 DispatchImageMsg (PTWAIN_MSG ptwMsg);
  85. virtual TW_UINT16 EnableDS (TW_USERINTERFACE *pUI);
  86. virtual TW_UINT16 DisableDS(TW_USERINTERFACE *pUI);
  87. virtual TW_UINT16 OpenDS (PTWAIN_MSG ptwMsg);
  88. virtual TW_UINT16 CloseDS (PTWAIN_MSG ptwMsg);
  89. //
  90. // TWAIN capability negotiation
  91. //
  92. virtual CCap * FindCap(TW_UINT16 CapId);
  93. virtual TW_UINT16 CreateCapList(TW_UINT32 NumCaps, PCAPDATA pCapData);
  94. virtual TW_UINT16 DestroyCapList();
  95. virtual TW_UINT16 SetCapability(CCap *pCap, TW_CAPABILITY *ptwCap);
  96. virtual LONG GetPrivateSupportedCapsFromWIADevice(PLONG *ppCapArray);
  97. virtual TW_UINT16 GetPixelTypes();
  98. virtual TW_UINT16 GetBitDepths();
  99. virtual TW_UINT16 GetImageFileFormats();
  100. virtual TW_UINT16 GetCompressionTypes();
  101. virtual TW_UINT16 GetCommonSettings();
  102. virtual TW_UINT16 GetCommonDefaultSettings();
  103. virtual TW_UINT16 SetCommonSettings(CCap *pCap);
  104. TW_UINT16 AllocatePrivateCapBuffer(TWAIN_CAPABILITY *pHeader, BYTE** ppBuffer, DWORD dwSize);
  105. TW_UINT16 CopyContainerToPrivateCapBuffer(BYTE* pBuffer, HGLOBAL hContainer);
  106. TW_UINT16 CopyPrivateCapBufferToContainer(HGLOBAL *phContainer, BYTE* pBuffer, DWORD dwSize);
  107. //
  108. // Data transfer negotiation
  109. //
  110. virtual void ResetMemXfer();
  111. virtual TW_UINT16 TransferToFile(GUID guidFormatID);
  112. virtual TW_UINT16 TransferToDIB(HGLOBAL *phDIB);
  113. virtual TW_UINT16 TransferToMemory(GUID guidFormatID);
  114. virtual TW_UINT16 GetCachedImage(HGLOBAL *phImage);
  115. virtual TW_UINT16 TransferToThumbnail(HGLOBAL *phThumbnail);
  116. virtual TW_UINT16 GetMemoryTransferBits(BYTE* pImageData);
  117. virtual void DSError();
  118. static HRESULT CALLBACK DeviceEventCallback(LONG lEvent, LPARAM lParam);
  119. //
  120. // TWAIN specific members
  121. //
  122. DS_STATE m_dsState; // current Data Source STATE (1 - 7)
  123. TW_STATUS m_twStatus; // TWAIN status value
  124. TW_IDENTITY m_AppIdentity; // Application's Identity structure
  125. TW_IDENTITY m_dsIdentity; // Data source's Identity structure
  126. CDSM m_DSM; // Data source Manager object
  127. CCap *m_CapList; // list of capabilities supported by this source
  128. TW_UINT32 m_NumCaps; // number of capabilities
  129. TW_FRAME m_CurFrame; // Current FRAME setting (IMAGELAYOUT storage) (not used??)
  130. TW_IMAGELAYOUT m_CurImageLayout; // Current IMAGELAYOUT
  131. //
  132. // data transfer specific members
  133. //
  134. HGLOBAL m_hMemXferBits; // Handle to memory
  135. BYTE *m_pMemXferBits; // Pointer to memory
  136. TW_UINT32 m_LinesTransferred; // Number of lines transferred
  137. TW_UINT32 m_BytesPerScanline; // Bytes per scan line
  138. TW_INT32 m_ScanlineOffset; // offset, per scan line
  139. TW_UINT32 m_ImageHeight; // Image Height, in pixels
  140. TW_UINT32 m_ImageWidth; // Image Width, in pixels
  141. CHAR m_FileXferName[MAX_PATH]; // File name used in FILEXFER
  142. HGLOBAL m_hCachedImageData; // cached image data
  143. MEMORY_TRANSFER_INFO m_MemoryTransferInfo; // memory transfer information
  144. //
  145. // WIA specific members
  146. //
  147. CWiaDevice *m_pDevice; // WIA device used as the TWAIN device
  148. IWiaItem **m_pIWiaItems; // pointer to Item(s) for transferring/or setting properties
  149. LONG m_NextIWiaItemIndex; // index to next Item/Image
  150. LONG m_NumIWiaItems; // number of Items/Images
  151. IWiaItem *m_pCurrentIWiaItem; // pointer to current Item/Image
  152. };
  153. #endif // #ifndef __DATASRC_H_