home *** CD-ROM | disk | FTP | other *** search
/ swCHIP 1991 January / swCHIP_95-1.bin / utility / gsview13 / src / gvwin.h < prev    next >
C/C++ Source or Header  |  1995-12-09  |  14KB  |  438 lines

  1. /* Copyright (C) 1993, 1994, 1995, Russell Lang.  All rights reserved.
  2.   
  3.   This file is part of GSview.
  4.   
  5.   This program is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the GSview Free Public Licence 
  9.   (the "Licence") for full details.
  10.   
  11.   Every copy of GSview must include a copy of the Licence, normally in a 
  12.   plain ASCII text file named LICENCE.  The Licence grants you the right 
  13.   to copy, modify and redistribute GSview, but only under certain conditions 
  14.   described in the Licence.  Among other things, the Licence requires that 
  15.   the copyright notice and this notice be preserved on all copies.
  16. */
  17.  
  18. /* gvwin.h */
  19. /* Header includes for Windows GSview */
  20.  
  21. #define STRICT
  22. #include <windows.h>
  23. #include <windowsx.h>
  24. #include <commdlg.h>
  25. #include <shellapi.h>
  26. #include <mmsystem.h>
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29. #include <string.h>
  30. #include <ctype.h>
  31. #include <dir.h>
  32. #include <io.h>
  33. #include <time.h>
  34. #define NeedFunctionPrototypes 1
  35. #include "ps.h"
  36. #include "gvcrc.h"
  37.  
  38. #ifndef RC_INVOKED
  39.  
  40. /* messages used between gsview and gswin */
  41. #define WM_GSVIEW WM_USER+0
  42. /* from gswin to gsview */
  43. #define HWND_TEXT    0
  44. #define HWND_IMGCHILD    1
  45. #define GSWIN_CLOSE    2
  46. #define SYNC_OUTPUT    3
  47. #define OUTPUT_PAGE    4
  48. #define SCROLL_POSITION 5
  49. #define PIPE_REQUEST    6
  50. #define BEGIN        7
  51. #define END        8
  52. /* from gsview to gswin image window */
  53. #define NEXT_PAGE    10
  54. #define COPY_CLIPBOARD    11
  55. /* from gsview to gswin text window */
  56. #define PIPE_DATA    12
  57.  
  58.  
  59. #define PROFILE_SIZE 2048
  60. #ifdef WIN32
  61. #define MAXSTR 256    /* maximum file name length and general string length */
  62. #define DEFAULT_GSCOMMAND "gswin32.exe"
  63. #define INIFILE "gsview32.ini"
  64. #else
  65. #define MAXSTR 80    /* maximum file name length and general string length */
  66. #define DEFAULT_GSCOMMAND "gswin"
  67. #define INIFILE "gsview.ini"
  68. #endif
  69. #define DEFAULT_RESOLUTION 96.0
  70. #define DEFAULT_ZOOMRES 300.0
  71. #define INISECTION "Options"
  72. #define DEVSECTION "Devices"
  73. #define EOLSTR "\r\n"
  74. #define COPY_BUF_SIZE 4096
  75. /* don't have to worry about segments/selectors */
  76. #define GVFAR FAR
  77. #define GVHUGE _huge
  78.  
  79.  
  80. /* program details */
  81. typedef struct tagPROG {
  82.     BOOL    valid;
  83.     HINSTANCE    hinst;
  84.     FILE    *input;        /* pipe to stdin */
  85. } PROG;
  86.  
  87. typedef struct document PSDOC;
  88.  
  89. typedef struct tagPSBBOX {
  90.     int    llx;
  91.     int    lly;
  92.     int    urx;
  93.     int    ury;
  94.     int    valid;
  95. } PSBBOX;
  96.  
  97. typedef struct tagPSFILE {
  98.     BOOL    ignore_dsc;    /* true if DSC to be ignored */
  99.     PSDOC    *doc;        /* DSC structure.  NULL if not DSC */
  100.     int     pagenum;    /* current page number */
  101.     char     name[MAXSTR];    /* name of selected document file */
  102.     FILE     *file;        /* selected file */
  103.     BOOL    ctrld;        /* TRUE if file starts with ^D */
  104.     int     preview;    /* preview type IDS_EPSF, IDS_EPSI, etc. */
  105. #ifdef _Windows
  106.     struct    ftime datetime;    /* time/date of selected file */
  107. #else
  108.     time_t    datetime;    /* time/date of selected file */
  109. #endif
  110.     long    length;        /* length of selected file */
  111.     char    previous_name[MAXSTR];
  112.     BOOL    previous_was_dsc;
  113.     long    previous_begintrailer;
  114.     long    previous_endtrailer;
  115.     BOOL    ispdf;        /* true if PDF document */
  116.     char     pdftemp[MAXSTR]; /* name of temporary DSC file */
  117. } PSFILE;
  118.  
  119. /* options that are saved in INI file */
  120. typedef struct tagOPTIONS {
  121.     char    gscommand[MAXSTR];
  122.     int    gsversion;
  123.     POINT    img_origin;
  124.     POINT    img_size;
  125.     BOOL    img_max;
  126.     int    unit;
  127.     BOOL    quick;
  128.     BOOL    settings;
  129.     BOOL    button_show;
  130.     BOOL    fit_page;
  131.     BOOL    safer;
  132.     int    media;
  133.     char    medianame[32];
  134.     int    user_width;
  135.     int    user_height;
  136.     BOOL    epsf_clip;
  137.     BOOL    epsf_warn;
  138.     BOOL    redisplay;
  139.     BOOL    ignore_dsc;
  140.     BOOL    show_bbox;
  141.     int    orientation;
  142.     BOOL    swap_landscape;
  143.     float    xdpi;
  144.     float    ydpi;
  145.     float    zoom_xdpi;
  146.     float    zoom_ydpi;
  147.     int    depth;
  148.     BOOL    save_dir;
  149.     char    device_name[32];
  150.     char    device_resolution[32];
  151.     char    printer_port[32];
  152. } OPTIONS;
  153.  
  154. typedef struct tagDISPLAY {
  155.     BOOL    abort;
  156.     BOOL    busy;
  157.     int    width;
  158.     int    height;
  159.     int    planes;
  160.     int    bitcount;
  161.     BOOL    do_endfile;    
  162.     BOOL    do_resize;
  163.     BOOL    do_display;
  164.     BOOL    epsf_clipped;    /* display is clipped to bbox */
  165.     int    zoom_xoffset;    /* in 1/72" */
  166.     int    zoom_yoffset;
  167.     BOOL    saved;        /* interpreter state saved */
  168.     BOOL    page;        /* GS_PAGE received */
  169.     BOOL    sync;        /* GS_SYNC received */
  170. } DISPLAY;
  171.  
  172. struct prfentry {
  173.     char *name;
  174.     char *value;
  175.     struct prfentry *next;
  176. };
  177.  
  178. struct prfsection {
  179.     char *name;
  180.     struct prfentry *entry;
  181.     struct prfsection *next;
  182. };
  183.  
  184. struct prop_item_s {
  185.     char    name[MAXSTR];
  186.     char    value[MAXSTR];
  187. };
  188.  
  189. typedef struct tagPROFILE {
  190.     char *name;
  191.     FILE *file;
  192.     BOOL changed;
  193.     struct prfsection *section;
  194. } PROFILE;
  195.  
  196. extern BOOL debug;            /* /D command line option used */
  197. extern FILE *debug_file;        /* for gs input logging */
  198. struct page_list_s {
  199.     int current;    /* index of current selection */
  200.     BOOL multiple;    /* true if multiple selection allowed */
  201.     BOOL *select;    /* array of selection flags */
  202. };
  203. extern struct page_list_s page_list;
  204.  
  205. #define SOUND_PAGE 0
  206. #define SOUND_NOPAGE 1
  207. #define SOUND_NONUMBER 2
  208. #define SOUND_NOTOPEN 3
  209. #define SOUND_ERROR 4
  210. #define SOUND_TIMEOUT 5
  211. #define SOUND_START 6
  212. #define SOUND_EXIT 7
  213. #define NUMSOUND 8
  214. struct sound_s {
  215.     char *entry;        /* profile entry */
  216.     int title;        /* Resource string */
  217.     char file[MAXSTR];    /* empty, "beep", or .WAV sound to play */
  218. };
  219. extern struct sound_s sound[NUMSOUND];
  220. #define BEEP "beep"        /* profile entry for a speaker beep */
  221. typedef BOOL (WINAPI *FPSPS)(LPCSTR, UINT);
  222. extern HINSTANCE hlib_mmsystem;    /* DLL containing sndPlaySound function */
  223. extern FPSPS lpfnSndPlaySound;    /* pointer to sndPlaySound function if loaded */
  224.  
  225. extern const char szClassName[];
  226. extern const char szScratch[];  /* temporary filename prefix */
  227. extern char szAppName[MAXSTR];
  228. extern char szHelpTopic[MAXSTR];
  229. extern char szWait[MAXSTR];
  230. extern char szExePath[MAXSTR];
  231. extern char szIniFile[MAXSTR];
  232. extern char szFindText[MAXSTR];
  233. extern char szHelpName[MAXSTR];        /* buffer for building help filename */
  234. extern char previous_filename[MAXSTR];    /* to remember name between file dlg boxes */
  235. extern UINT help_message;        /* message sent by OFN_SHOWHELP */
  236. extern HWND hwndimg;            /* gsview main window */
  237. extern HWND hDlgModeless;        /* any modeless dialog box */
  238. extern HWND hwndtext;            /* gswin text window */
  239. extern HWND hwndimgchild;        /* gswin image child window */
  240. extern HINSTANCE phInstance;        /* instance of gsview */
  241. extern BOOL is_win31;            /* To allow selective use of win 3.1 features */
  242. extern BOOL is_winnt;            /* To allow selective use of Windows NT features */
  243. extern BOOL is_win95;            /* To allow selective use of Windows 95 features */
  244. extern HMENU hmenu;            /* main menu */
  245. extern HACCEL haccel;            /* menu accelerators */
  246. extern HCURSOR hcWait;
  247. extern int bitmap_scrollx;    /* offset from bitmap to origin of child window */
  248. extern int bitmap_scrolly;
  249. extern HFONT info_font;
  250. extern POINT img_offset;        /* offset to gswin child window */
  251. extern POINT info_file;        /* position of file information */
  252. extern POINT info_page;        /* position of page information */
  253. extern RECT  info_rect;        /* position and size of brief info area */
  254. extern RECT  info_coord;        /* position and size of coordinate information */
  255. extern RECT  button_rect;        /* position and size of button area */
  256. #define CLOSE_TIMEOUT    20    /* 20 seconds */
  257. extern OPENFILENAME ofn;
  258. extern BOOL waiting;        /* true when 'wait' to be displayed in info area */
  259. extern BOOL bTimeout;        /* true if timeout occured */
  260. extern WNDPROC lpfnButtonWndProc;
  261.  
  262. extern PROG gsprog;
  263. extern OPTIONS option;
  264. extern PSFILE psfile; 
  265. extern DISPLAY display;
  266. extern PSDOC *doc;
  267. extern int page_extra;
  268. extern int page_skip;
  269. extern BOOL changed_version;
  270. extern BOOL zoom;
  271.  
  272. extern PSBBOX bbox;
  273.  
  274.  
  275. #ifdef __WIN32__
  276. #define _huge
  277. #define MoveTo(hdc,x,y) MoveToEx((hdc),(x),(y),(LPPOINT)NULL)
  278. #define SetWindowOrg(hdc, x, y) SetWindowOrgEx(hdc, x, y, (LPPOINT)NULL);
  279. #define    SetWindowExt(hdc, x, y) SetWindowExtEx(hdc, x, y, (LPSIZE)NULL);
  280. #define SetClassCursor(hwnd, hcursor) SetClassLong((hwnd), GCL_HCURSOR, (LONG)(hcursor))
  281. #define GetClassCursor(hwnd) ((HCURSOR)GetClassLong((hwnd), GCL_HCURSOR))
  282. #define GetNotification(wParam,lParam) (HIWORD(wParam))
  283. #define SendDlgNotification(hwnd, id, notice) \
  284.     SendMessage((hwnd), WM_COMMAND, MAKELONG((id),(notice)), (LPARAM)GetDlgItem((hwnd),(id)))
  285. #else
  286. #define SetClassCursor(hwnd, hcursor) SetClassWord(hwnd, GCW_HCURSOR, (WORD)(hcursor))
  287. #define GetClassCursor(hwnd) ((HCURSOR)GetClassWord(hwnd, GCW_HCURSOR))
  288. #define GetNotification(wParam,lParam) (HIWORD(lParam))
  289. #define SendDlgNotification(hwnd, id, notice) \
  290.     SendMessage((hwnd), WM_COMMAND, id, MAKELPARAM(GetDlgItem((hwnd),(id)),(notice)))
  291. #endif
  292.  
  293. /* in gvwin.c */
  294. LRESULT CALLBACK _export MenuButtonProc(HWND, UINT, WPARAM, LPARAM);
  295. LRESULT CALLBACK _export WndImgProc(HWND, UINT, WPARAM, LPARAM);
  296. BOOL in_child_client_area(void);
  297. BOOL set_timer(UINT);
  298. void clear_timer(void);
  299. void copy_clipboard(void);
  300. BOOL get_cursorpos(float *x, float *y);
  301.  
  302. /* in gvcmisc.c */
  303. void error_message(char *str);
  304. void info_init(HWND hwnd);
  305. void read_profile(void);
  306. void write_profile(void);
  307.  
  308. /* in gvwmisc.c */
  309. /* BOOL SetDlgItemText(HWND hwnd, int id, char *str); */
  310. void post_close(void);
  311. void get_help(void);
  312. int message_box(char *str, int icon);
  313. void check_menu_item(int menuid, int itemid, BOOL checked);
  314. int get_menu_string(int menuid, int itemid, char *str, int len);
  315. int load_string(int id, char *str, int len);
  316. void play_sound(int i);
  317. void info_wait(BOOL flag);
  318. int _chdir(char *dirname);
  319. char * _getcwd(char *dirname, int size);
  320. void send_prolog(FILE *f, int resource);
  321. void profile_create_section(PROFILE *prf, char *section, int id);
  322.  
  323. /* in gvcdisp.c */
  324. void transform_cursorpos(float *x, float *y);
  325. void transform_point(float *x, float *y);
  326. void iransform_point(float *x, float *y);
  327. int get_paper_size_index(void);
  328. void gs_size(void);
  329. void gs_resize(void);
  330. void gs_magnify(float scale);
  331. void gsview_orientation(int new_orientation);
  332. void gsview_media(int new_media);
  333. void gsview_unit(int new_unit);
  334. void gsview_endfile(void);
  335. void gsview_openfile(char *filename);
  336. void gsview_select(void);
  337. void gsview_selectfile(char *filename);
  338. void gsview_display(void);
  339. void gsview_displayfile(char *filename);
  340. void send_orientation_prolog(FILE *f);
  341. void send_epswarn_prolog(FILE *f);
  342. void fix_orientation(FILE *f);
  343. FILE * gp_open_scratch_file(const char *prefix, char *fname, const char *mode);
  344. BOOL dfreopen(void);
  345. void dfclose(void);
  346. BOOL dsc_scan(char *filename);
  347. void dsc_getpages(FILE *f, int first, int last);
  348. void dsc_header(FILE *f);
  349. void dsc_dopage(void);
  350. void dsc_skip(int skip);
  351. int map_page(int page);
  352. BOOL do_output(void);
  353.  
  354. /* in gvwdisp.c */
  355. void do_message(void);
  356. BOOL exec_pgm(char *name, char *arg, char *id, PROG* prog);
  357. void stop_pgm(PROG* prog);
  358. void cleanup_pgm(PROG *prog);
  359. BOOL gs_open(void);
  360. BOOL gs_close(void);
  361. void next_page(void);
  362. BOOL psfile_changed(void);
  363. void psfile_savestat(void);
  364. BOOL is_pipe_done(void);    /* true if pipe has just been reset */
  365.  
  366. /* in gvccmd.c */
  367. int gsview_command(int command);
  368. BOOL not_open(void);
  369. BOOL not_dsc(void);
  370. void gserror(UINT id, char *str, UINT icon, int sound);
  371. void pserror(char *str);
  372. int not_implemented(void);
  373. void gsview_check_usersize(void);
  374. int gsview_depth_to_menu(int depth);
  375.  
  376. /* in gvwdlg.c */
  377. BOOL get_filename(char *filename, BOOL save, int filter, int title, int help);
  378. BOOL get_string(char *, char *);
  379. BOOL get_page(int *, BOOL);
  380. void show_info(void);
  381. void show_about(void);
  382. void change_sounds(void);
  383.  
  384. /* in gvwpipe.c */
  385. void pipeinit(void);    /* prepare pipe for opening */
  386. FILE *pipeopen(void);    /* open pipe for first time */
  387. void pipeclose(void);    /* finished with pipe, close & delete temp files */
  388. void pipereset(void);    /* pipe is empty, do cleanup */
  389. void piperequest(void);    /* request from gswin for pipe data */
  390. void pipeflush(void);    /* start sending data through pipe */
  391. BOOL is_pipe_done(void);    /* true if pipe has just been reset */
  392.  
  393. /* in gvwinit.c */
  394. void gsview_init0(LPSTR lpszCmdLine);
  395. void gsview_init1(LPSTR lpszCmdLine);
  396. void gsview_create(void);
  397. void show_buttons(void);
  398.  
  399. /* in gvcprn.c */
  400. struct prop_item_s * get_properties(char *device);
  401. void gsview_spool(char *, char *);
  402. void psfile_extract(FILE *f);
  403. char *get_devices(void);
  404. void print_cleanup(void);
  405. void gsview_saveas(void);
  406. void gsview_extract(void);
  407. BOOL gsview_cprint(BOOL to_file, char *cfname, char *optfname);
  408.  
  409. /* in gvwprn.c */
  410. int gp_printfile(char *filename, char *port);
  411. void gsview_print(BOOL);
  412. extern char not_defined[];
  413.  
  414. /* in gvceps.c */
  415. void extract_doseps(int);
  416. void make_eps_metafile(void);
  417. void make_eps_tiff(int);
  418. void make_eps_interchange(BOOL calc_bbox);
  419. void ps_to_eps(void);
  420. BOOL get_bbox(void);
  421.  
  422. /* in gvwclip.c */
  423. void paste_to_file(void);
  424. void clip_convert(void);
  425.  
  426. /* in gvwprf.c */
  427. PROFILE * profile_open(char *filename);
  428. int profile_read_string(PROFILE *prf, char *section, char GVFAR *entry, char *def, char *buffer, int len);
  429. BOOL profile_write_string(PROFILE *prf, char *section, char *entry, char *value);
  430. BOOL profile_close(PROFILE *prf);
  431.  
  432. /* in gvctext.c */
  433. void gsview_text_extract(void);
  434. void gsview_text_find(void);
  435. void gsview_text_findnext(void);
  436.  
  437. #endif
  438.