Source code of Windows XP (NT5)
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.

419 lines
9.6 KiB

  1. /*
  2. Microsoft Corp. (C) Copyright 1994
  3. Developed under contract by Numbers & Co.
  4. ----------------------------------------------------------------------------
  5. name: Elliot Viewer - Chicago Viewer Utility
  6. Cloned from the IFAX Message Viewing Utility
  7. file: viewerob.h
  8. comments: Class definitions for Viewer and ViewPage Objects.
  9. These objects are interface wrappers for the original IFAX viewer
  10. C code. All of the viewer's static variables and whatnot are collected
  11. here so that multiple independant viewers can be created to support
  12. multiple open documents/pages. The innards of the viewer objects are
  13. essentially the same as the original except for necessary fiddles to
  14. allow functions to get at things that used to be static but are now
  15. private object data. The original innards just scream to be converted
  16. to C++ but time constraints didn't allow that...
  17. If a struct or occasional whatnot seems a bit clumsy it is probably
  18. a relic leftover from the above original clone code. It works...
  19. NOTE: This header must be used with the LARGE memory model
  20. ----------------------------------------------------------------------------
  21. Microsoft Corp. (C) Copyright 1994
  22. Developed under contract by Numbers & Co.
  23. */
  24. #ifndef VIEWEROB_H
  25. #define VIEWEROB_H
  26. //#include <ole2.h>
  27. /*
  28. Specials for WIN32 and WIN16 coexistance
  29. */
  30. #ifdef WIN32
  31. #define huge
  32. #endif
  33. /*
  34. Unicode spasms
  35. */
  36. #ifndef WIN32
  37. #ifndef TCHAR
  38. typedef char TCHAR;
  39. #endif
  40. #ifndef _T
  41. #define _T(x) x
  42. #endif
  43. #ifndef LPTSTR
  44. typedef TCHAR FAR *LPTSTR;
  45. #endif
  46. #ifndef LPTCH
  47. typedef TCHAR FAR *LPTCH;
  48. #endif
  49. #endif
  50. /*
  51. Constants and defs
  52. */
  53. #define OK 0
  54. #define FAIL -1
  55. #define TRUE 1
  56. #define FALSE 0
  57. #define RESET 2
  58. #define RESET2 3
  59. #define MAX_INI_STR 256
  60. #define MAX_STR_LEN 80
  61. #define MAX_MEDIUMSTR_LEN 40
  62. #define MAX_SHORTSTR_LEN 20
  63. #define MAX_EXTSTR_LEN 3
  64. #define MAX_COORD 32767
  65. #define MIN_COORD -32768
  66. #define BORDER_SCROLL_SCALE 2
  67. #define MAX_FILENAME_LEN 13
  68. #ifdef WIN32
  69. #define MAX_PATHNAME_LEN MAX_PATH
  70. #else
  71. #define MAX_PATHNAME_LEN 256
  72. #endif
  73. #define MAX_BANDBUFFER 65536
  74. #define MAX_VOPENBUF 65000
  75. #define MAX_STREAM_BUF 32000
  76. #define PAGESIZE_GUESS (4*MAX_BANDBUFFER)
  77. #define TEXT_FOREGROUND RGB( 255,255,255 )
  78. #define TEXT_BACKGROUND RGB( 128,128,128 )
  79. /*
  80. Zoom factors
  81. */
  82. #define MAX_ZOOM 100
  83. #define INITIAL_ZOOM 100
  84. #define THUMBNAIL_ZOOM 5
  85. #define DEFAULT_DPI 80 // 800 pixels, 10 inch screen, used
  86. // for demo bitmaps.
  87. /*
  88. Rotation "angles"
  89. */
  90. #define RA_0 0
  91. #define RA_90 90
  92. #define RA_180 180
  93. #define RA_270 270
  94. #define RA_360 360
  95. // BKD 1997-7-9: commented out. Already defined in buffers.h
  96. // Standard Bit Valued MetaData values
  97. //#define LRAW_DATA 0x00000008
  98. //#define HRAW_DATA 0x00000010
  99. #ifndef LRAW_DATA
  100. #include "buffers.h"
  101. #endif
  102. /*
  103. BitBlt display defaults
  104. */
  105. #define PRIMARY_BLTOP SRCCOPY
  106. #define ALTERNATE_BLTOP NOTSRCCOPY
  107. /*
  108. Timer ids
  109. */
  110. #define DELAYED_OPEN_TIMER 1
  111. #define DRAG_TIMER 2
  112. #define THUMB_FLAME_TIMER 3
  113. /*
  114. Misc types
  115. */
  116. typedef unsigned char uchar;
  117. typedef unsigned int uint;
  118. typedef unsigned short ushort;
  119. typedef unsigned long ulong;
  120. /*
  121. My version of RECT
  122. */
  123. typedef struct
  124. {
  125. int x_ul, y_ul; // Upper left xy loc
  126. int x_lr, y_lr; // Lower left xy loc
  127. int width, height;
  128. }
  129. winrect_type;
  130. /*
  131. The "attachment" table. This is used to save the header info in a
  132. Chicago style viewer-message file, slightly processed.
  133. */
  134. typedef struct
  135. {
  136. char *atchname; // stream name for attachment (document)
  137. LONG numpages; // number of pages in atchname
  138. short binfile; // TRUE -> something we can't look at.
  139. short isademo; // TRUE -> use demo version of viewrend (vrdemo)
  140. // document state (this section is 32bit aligned at this point)
  141. DATE dtLastChange;
  142. DWORD awdFlags;
  143. WORD Rotation;
  144. WORD ScaleX;
  145. WORD ScaleY;
  146. }
  147. attachment_table_type;
  148. /*
  149. Struct for keeping track of whats in the attachment table,
  150. whats viewable and what isn't, etc.
  151. */
  152. typedef struct
  153. {
  154. short is_displayable; // TRUE -> viewable
  155. HBITMAP hbmp; // "icon" for non viewable attachments
  156. uint page_offset; // From first displayable attachment.
  157. attachment_table_type *at; // ptr to attachment table.
  158. }
  159. attachment_type;
  160. /*
  161. Struct for keeping track of viewrend bands
  162. */
  163. typedef struct
  164. {
  165. long height_bytes;
  166. long first_scanline;
  167. }
  168. band_height_type;
  169. /*
  170. Struct defining a "viewdata" object. This should be a converted to be
  171. a real c++ object but time constaints dictated I use it as is.
  172. */
  173. typedef struct
  174. {
  175. BITMAP bmp; // Raw bitmap data (NOT a GDI bitmap)
  176. // NOTE: This data is NEVER rotated
  177. // (always RA_0) but can be
  178. // scaled.
  179. HBITMAP hbmp; // Handle for in memory bitmap
  180. HDC mem_hdc; // DC for blting it to a window
  181. RECT isa_edge; // Flags for bitmap/file edge correspondance
  182. winrect_type bmp_wrc; // Loc and size of bitmap rel to file bitmap
  183. short dragging; // Bitmap is being dragged if TRUE
  184. short copying; // Bitmap is being select/copied to clipboard
  185. RECT copy_rect; // Area to copy
  186. short copy_rect_valid; // copy_rect has valid data
  187. short first_copy_rect; // flag to init focus rect
  188. POINT copyanchor_pt;
  189. POINT viewanchor_pt;
  190. winrect_type viewwin_wrc; // Loc and size of window to drag in
  191. winrect_type view_wrc; // Loc and size of view window rel to bitmap
  192. POINT last_file_wrc_offset; // used for adjusting view_wrc before
  193. // rotations
  194. POINT last_cursor; // Last cursor loc during a drag
  195. int bdrscrl_scale; // Scale factor for border scroll increments
  196. RECT left_erase; // Rects for erasing the bitmap's
  197. RECT top_erase; // previous position during a drag.
  198. RECT right_erase;
  199. RECT bottom_erase;
  200. short left_iserased; // Draw corespnding erase rect if TRUE
  201. short top_iserased; // during a drag.
  202. short right_iserased;
  203. short bottom_iserased;
  204. /*
  205. If hfile != HFILE_ERROR then the band parameters are undefined. Otherwise
  206. they are defined only if hbmp does not contain the entire page bmp
  207. */
  208. HFILE hfile; // Handle for file bitmap
  209. band_height_type *band_heights; // Array of Rajeev band heights
  210. short num_bands; // Number of bands
  211. short current_band; // Currently selected band
  212. TCHAR filename[MAX_FILENAME_LEN+1];
  213. winrect_type file_wrc; // Loc (always=0) and size of file bitmap;
  214. winrect_type prescale_file_wrc; // file_wrc / x,y_prescale
  215. int x_dpi; // x dots per inch
  216. int y_dpi; // y dots per inch
  217. uint linebytes; // Total bytes per scanline
  218. uint num_planes; // Number of planes
  219. uint bits_per_pix; // Bits per pixel in a plane
  220. short has_data; // Bitmap and/or bmBits contains data.
  221. short in_mem; // All data fits in memory.
  222. }
  223. viewdata_type;
  224. typedef int
  225. (WINAPI *IFMESSPROC)( char *, int );
  226. /*
  227. This struct is for reading/writing SummaryStreams. It was
  228. in oleutils.h but I moved it here so every module in the
  229. Viewer doesn't have to pull in oleutils.h because of the
  230. summary_info_t variable in CViewer.
  231. */
  232. typedef struct
  233. {
  234. LPSTR revnum;
  235. DATE last_printed;
  236. DATE when_created;
  237. DATE last_saved;
  238. DWORD num_pages;
  239. LPSTR appname;
  240. DWORD security;
  241. LPSTR author;
  242. }
  243. summary_info_t;
  244. /*
  245. Macros
  246. */
  247. #define WIDTHSHORTS( width, bits_per_pix ) \
  248. ((((long)width)*bits_per_pix + 15)/16)
  249. #define V_WIDTHBYTES( width, bits_per_pix ) \
  250. (WIDTHSHORTS( width, bits_per_pix )*2)
  251. #define BITMAPSTRIDE( widthbytes, height ) \
  252. (((long)widthbytes) * height)
  253. #define BITMAPWIDTHBYTES( widthbytes, height, planes ) \
  254. (BITMAPSTRIDE( widthbytes, height )*planes)
  255. #define BITMAPBYTES( width, bits_per_pix, height, planes ) \
  256. (BITMAPWIDTHBYTES( V_WIDTHBYTES( width, bits_per_pix ), \
  257. height, \
  258. planes ))
  259. #define SWAP_SHORT_BYTES( short_to_swap ) \
  260. __asm \
  261. { \
  262. __asm mov ax, short_to_swap \
  263. __asm xchg ah, al \
  264. __asm mov short_to_swap, ax \
  265. }
  266. #define SWAP_LONG_BYTES( long_to_swap ) \
  267. __asm \
  268. { \
  269. __asm mov ax, word ptr long_to_swap[2] \
  270. __asm xchg ah, al \
  271. __asm xchg word ptr long_to_swap[0], ax \
  272. __asm xchg ah, al \
  273. __asm mov word ptr long_to_swap[2], ax \
  274. }
  275. /*
  276. Global data
  277. */
  278. extern /*IFMSGBOXPROC*/IFMESSPROC IfMessageBox_lpfn;
  279. extern TCHAR viewer_homedir[MAX_PATHNAME_LEN+1];
  280. extern short ra360_bugfix;
  281. extern DWORD cshelp_map[];
  282. /*
  283. Non object viewer functions
  284. */
  285. extern short
  286. InitializeViewer( void );
  287. /* WARNING * WARNING * WARNING * HACKHACKHACKHACKHACKHACKHACKHACK */
  288. /* hack so CViewerPage::print_viewdata can call AbortProc */
  289. typedef BOOL (CALLBACK *utils_prtabortproc_type)(HDC, int);
  290. extern utils_prtabortproc_type utils_prtabortproc;
  291. /******************************************************************/
  292. #endif