home *** CD-ROM | disk | FTP | other *** search
/ swCHIP 1991 January / swCHIP_95-1.bin / utility / gsview13 / src / gvpinit.c < prev    next >
C/C++ Source or Header  |  1995-12-09  |  18KB  |  575 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. /* gvpinit.c */
  19. /* Initialisation routines for PM GSview */
  20. /* by Russell Lang */
  21. #include "gvpm.h"
  22.  
  23. APIRET init1(void); 
  24. APIRET init2(void); 
  25. APIRET restore_window_position(SWP *pswp);
  26. void init_options(void);
  27. ULONG frame_flags = 
  28.         FCF_TITLEBAR |    /* have a title bar */
  29.             FCF_SIZEBORDER |    /* have a sizeable window */
  30.             FCF_MINMAX |    /* have a min and max button */
  31.             FCF_SYSMENU |     /* include a system menu */
  32.             FCF_VERTSCROLL |    /* vertical scroll bar */
  33.             FCF_HORZSCROLL |    /* horizontal scroll bar */
  34.         FCF_TASKLIST |    /* show it in window list */
  35.         FCF_ICON |        /* Load icon from resources */
  36.         FCF_MENU |        /* Load menu from resources */
  37.         FCF_ACCELTABLE;    /* Load accelerator table from resources */
  38.  
  39. APIRET
  40. gsview_init(int argc, char *argv[])
  41. {
  42.   unsigned char class[] = "gvBmpClass";  /* class name */
  43.   unsigned char status_class[] = "gvStatusClass";
  44.   unsigned char button_class[] = "gvButtonClass";
  45.   APIRET rc = 0;
  46.   SWP swp;
  47.   char *cmd, *cmdbase, *p;
  48.   char **argp;
  49.   char filedir[MAXSTR];
  50.   char workdir[MAXSTR];
  51.   FONTMETRICS fm;
  52.   POINTL char_size;
  53.   RECTL rect;
  54.   HPS hps;
  55.   PVOID pResource;
  56.   int i;
  57.   short *pButtonID;
  58.   ULONG version[3];
  59.  
  60.     _getcwd(workdir, sizeof(workdir));    /* remember the working directory */
  61.     if (DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_REVISION, &version, sizeof(version)))
  62.     os_version = 201000;  /* a guess */
  63.     else {
  64.     os_version = version[0]*10000 + version[1]*100 + version[2];
  65.     }
  66.  
  67.     rc = init1();
  68.     if (rc)
  69.     return rc;
  70.  
  71.     /* save SHELL default size and location */
  72.     rc = WinQueryTaskSizePos(hab, 0, &swp);
  73.     if (rc)
  74.     return rc;
  75.  
  76.     rc = DosCreateThread(&queue_tid, queue_thread, 0, 0, 8192);
  77.     if (rc) {
  78.         error_message("gsview_init: Failed to create queue thread");
  79.         return rc;
  80.     }
  81.  
  82.     rc = DosCreateThread(&term_tid, term_thread, 0, 0, 8192);
  83.     if (rc) {
  84.         error_message("gsview_init: Failed to create termination queue thread");
  85.         return rc;
  86.     }
  87.     load_string(IDS_WAIT, szWait, sizeof(szWait));
  88.  
  89.     init_options();
  90.     read_profile();
  91.  
  92.     if (!WinRegisterClass(    /* register this window class */
  93.       hab,            /* anchor block */
  94.       (PSZ)class,        /* class name */
  95.       (PFNWP) ClientWndProc,    /* window function */
  96.       CS_SIZEREDRAW |        /* window style */
  97.     CS_MOVENOTIFY,        
  98.       0))            /* no storage */
  99.     return -1;
  100.  
  101.     hwnd_frame = WinCreateStdWindow(
  102.       HWND_DESKTOP,        /* window type */
  103.     0,            /* frame style is not WS_VISIBLE */
  104.       &frame_flags,        /* definitions */
  105.       (PSZ)class,        /* client class */
  106.       (PSZ)"PM GSview",    /* title */
  107.       WS_VISIBLE,        /* client style */
  108.       0,            /* resource module */
  109.       ID_GSVIEW,        /* resource identifier */
  110.       &hwnd_bmp);        /* pointer to client */
  111.  
  112.     if (!WinRegisterClass(    /* register this window class */
  113.       hab,            /* anchor block */
  114.       (PSZ)status_class,    /* class name */
  115.       (PFNWP) StatusWndProc,    /* window function */
  116.       CS_SIZEREDRAW,        /* window style */
  117.       0))            /* no storage */
  118.     return -1;
  119.  
  120.     if (!WinRegisterClass(    /* register this window class */
  121.       hab,            /* anchor block */
  122.       (PSZ)button_class,    /* class name */
  123.       (PFNWP) ButtonWndProc,    /* window function */
  124.       CS_SIZEREDRAW | CS_MOVENOTIFY,        /* window style */
  125.       0))            /* no storage */
  126.     return -1;
  127.  
  128.     hptr_crosshair = WinLoadPointer(HWND_DESKTOP, 0, IDP_CROSSHAIR);
  129.  
  130.     /* get initial size and position of status window */
  131.     WinQueryWindowRect(hwnd_bmp, &rect);
  132.     statusbar.x = rect.xRight - rect.xLeft;
  133.     hps = WinGetPS(hwnd_bmp);
  134.     GpiQueryFontMetrics(hps, sizeof(FONTMETRICS), &fm);
  135.     char_size.y = fm.lMaxAscender + fm.lMaxDescender + fm.lExternalLeading + 2;
  136.     char_size.x = fm.lAveCharWidth;
  137.     statusbar.y = char_size.y;
  138.     WinReleasePS(hwnd_bmp);
  139.  
  140.     hwnd_status = WinCreateWindow(
  141.         hwnd_frame,
  142.         status_class,
  143.         "status bar",
  144.     WS_VISIBLE | WS_SYNCPAINT,
  145.     rect.xLeft, rect.yTop, rect.xRight, statusbar.y,
  146.     hwnd_frame,
  147.     HWND_TOP,
  148.     ID_STATUSBAR,
  149.     NULL,
  150.     NULL);
  151.  
  152.     button_size.x = 24;
  153.     button_size.y = 24;
  154.     button_shift.x = 0;
  155.     button_shift.y = button_size.y;
  156.     buttonbar.x = button_size.x;
  157.     hwnd_button = WinCreateWindow(
  158.         hwnd_frame,
  159.         button_class,
  160.         "button bar",
  161.     (option.button_show ? WS_VISIBLE : 0) | WS_SYNCPAINT,
  162.     rect.xLeft, rect.yBottom, rect.xLeft+buttonbar.x, rect.yTop - rect.yBottom,
  163.     hwnd_frame,
  164.     hwnd_bmp,
  165.     ID_BUTTONBAR,
  166.     NULL,
  167.     NULL);
  168.     
  169.     rc = DosGetResource((HMODULE)0, RT_RCDATA, IDR_BUTTON ,&pResource);
  170.     if ( rc || (pResource == NULL) )
  171.     return rc;
  172.     pButtonID = (short *)pResource;
  173.     WinQueryWindowRect(hwnd_button, &rect);
  174.     hps = WinGetPS(hwnd_button);
  175.     for (i=0; pButtonID[i]; i++) {
  176.         char title[16];
  177.     HBITMAP hbm;
  178.     title[0] = '\0';
  179.     hbm = GpiLoadBitmap(hps, 0, pButtonID[i], 0, 0);
  180.     if (!hbm) {
  181.         load_string(pButtonID[i], title, sizeof(title));
  182.     }
  183.         if (buttonhead == (struct button *)NULL)
  184.                 buttontail = buttonhead = (struct button *)malloc(sizeof(struct button));
  185.         else {
  186.                 buttontail->next = (struct button *)malloc(sizeof(struct button));
  187.                 buttontail = buttontail->next;
  188.         }
  189.     buttontail->id = pButtonID[i];
  190.         buttontail->hbitmap = hbm;
  191.     buttontail->rect.xLeft = rect.xLeft + i * button_shift.x;
  192.     buttontail->rect.yBottom = rect.yTop - button_size.y - i * button_shift.y;
  193.     buttontail->rect.xRight = buttontail->rect.xLeft + button_size.x;
  194.     buttontail->rect.yTop = buttontail->rect.yBottom + button_size.y;
  195.     strcpy(buttontail->str, title);
  196.         buttontail->next = NULL;
  197.     }
  198.     WinReleasePS(hps);
  199.     DosFreeResource(pResource);
  200.  
  201.     OldFrameWndProc = WinSubclassWindow(hwnd_frame, (PFNWP)FrameWndProc);
  202.  
  203.     rc = restore_window_position(&swp);
  204.     if (rc)
  205.     return rc;
  206.  
  207.     init2();
  208.  
  209.     if (_emx_vcmp < 0x302e3868) {
  210.     char buf[256];
  211.     sprintf(buf, "You have emx %s.\rYou need emx %s or later.\rPM GSview will not run correctly.",
  212.         _emx_vprt, EMX_NEEDED);
  213.     message_box(buf, MB_ICONEXCLAMATION);
  214.     }
  215.     if (changed_version) {
  216.     message_box("The installed version of GSview has changed.  \
  217. Please read the Installation help and then correctly set\r\
  218. Options | Ghostscript Command", MB_ICONEXCLAMATION);
  219.     load_string(IDS_TOPICINSTALL, szHelpTopic, sizeof(szHelpTopic));
  220.     get_help();
  221.     }
  222.  
  223.     if (argc == 1)
  224.     return rc;
  225.  
  226.     if ( (strlen(argv[1]) >= 2)
  227.      &&  ((argv[1][0] == '/') || (argv[1][0] == '-'))
  228.      &&  ((argv[1][1] == 'D') || (argv[1][1] == 'd')) ) {
  229.         debug = TRUE;
  230.         argv++;
  231.         argc--;
  232.     }
  233.  
  234.     if ( (cmdbase = malloc(MAXSTR)) == (char *)NULL )
  235.     return rc;
  236.  
  237.     cmd = cmdbase;
  238.     cmd[0] = '\0';
  239.     for (argp = &argv[1]; argc > 1; argc--, argp++) {
  240.     if ( strlen(*argp) + strlen(cmd) > MAXSTR-1 )
  241.         break;
  242.     strcat(cmd, *argp);
  243.     if (argc > 2)
  244.         strcat(cmd, " ");
  245.     }
  246.  
  247.     if (strlen(cmd) > 2) {
  248.     /* file given on command line, so use current directory not saved one */
  249.     _chdir(workdir);
  250.     /* skip commands /F /P or /S */
  251.     if ((cmd[0] == '/') || (cmd[0] == '-')) {
  252.         cmd += 2;
  253.         while (*cmd && (*cmd == ' '))
  254.             cmd++;
  255.     }
  256.     /* build full path to file */
  257.         if (cmd[0]=='\\') {
  258.         /* fully specified path on current drive */
  259.         /* need to prefix with current drive */
  260.         strcpy(filedir, cmd);    /* temporary save path */
  261.         strncpy(cmd, workdir, 2);    /* copy current drive */
  262.         strcpy(cmd+2, filedir);    /* append path */
  263.     }
  264.     else if (cmd[0] && isalpha(cmd[0]) && cmd[1]==':') {
  265.         /* drive code specified */
  266.         if ( (strlen(cmd) >= 3) && (cmd[2]=='\\') ) {
  267.         /* fully specified path and drive */
  268.         /* no action */
  269.         }
  270.         else if ( (strlen(cmd) >= 3) && (cmd[2]=='/') ) {
  271.         /* fully specified path and drive */
  272.         /* no action */
  273.         }
  274.         else {
  275.         /* relative path on specified drive */
  276.         /* change to drive, get directory, append relative path */
  277.         strncpy(filedir, cmd, 2); /* copy drive code */
  278.         filedir[2] = '\0';
  279.         i = _chdir(filedir);
  280.         _getcwd(filedir, sizeof(filedir));    /* get path on specified drive */
  281.         if (filedir[0] && (filedir[strlen(filedir)-1]!='/')
  282.             && (filedir[strlen(filedir)-1]!='\\'))
  283.             strcat(filedir, "\\");
  284.         strcat(filedir, cmd+2);    /* append relative path */
  285.         strcpy(cmd, filedir);
  286.         i = _chdir(workdir);
  287.         }
  288.     }
  289.     else {
  290.         /* relative path on current drive */
  291.         /* construct full path */
  292.         strcpy(filedir, cmd);    /* temporary save */
  293.         strcpy(cmd, workdir);    /* copy current drive */
  294.         if (cmd[0] && (cmd[strlen(cmd)-1]!='/')
  295.             && (cmd[strlen(cmd)-1]!='\\'))
  296.             strcat(cmd, "\\");
  297.         strcat(cmd, filedir);    /* append relative path */
  298.     }
  299.     /* load given file */
  300.     WinPostMsg(hwnd_bmp, WM_COMMAND, (MPARAM)IDM_DROP, MPFROMP(cmdbase));    /* mp2 is not strictly correct */
  301.     }
  302.     return rc;
  303. }
  304.  
  305. APIRET
  306. restore_window_position(SWP *pswp)
  307. {
  308.     SWP swp;
  309.     swp.fl = SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW;
  310.  
  311.     if ((option.img_size.x   != CW_USEDEFAULT) &&
  312.     (option.img_size.y   != CW_USEDEFAULT) &&
  313.     (option.img_origin.y != CW_USEDEFAULT) &&
  314.     (option.img_origin.y != CW_USEDEFAULT)) {
  315.         LONG cxClientMax ;
  316.         LONG cyClientMax ;
  317.         LONG cyTitleBar ;
  318.         LONG cxSizeBorder ;
  319.         LONG cySizeBorder ;
  320.  
  321.         /* get maximum client window size */
  322.         cxClientMax = WinQuerySysValue (HWND_DESKTOP, SV_CXFULLSCREEN) ;
  323.         cyClientMax = WinQuerySysValue (HWND_DESKTOP, SV_CYFULLSCREEN) ;
  324.         cyTitleBar = WinQuerySysValue (HWND_DESKTOP, SV_CYTITLEBAR) ;
  325.         cxSizeBorder = WinQuerySysValue (HWND_DESKTOP, SV_CXSIZEBORDER) ;
  326.         cySizeBorder = WinQuerySysValue (HWND_DESKTOP, SV_CYSIZEBORDER) ;
  327.         cyClientMax += cyTitleBar ;
  328.  
  329.         if (option.img_max)
  330.             swp.fl |= SWP_MAXIMIZE;
  331.  
  332.         /* Make sure x origin is within display boundaries */
  333.         swp.x = option.img_origin.x ;
  334.         if (swp.x < -cxSizeBorder)
  335.             swp.x = 0 ;
  336.  
  337.         /* Make sure window isn't too wide, or negative value */
  338.         swp.cx = option.img_size.x ;
  339.         if (swp.cx >= cxClientMax || swp.cx < 0) {
  340.             swp.cx = cxClientMax ;
  341.             swp.x = 0 ;
  342.         }
  343.  
  344.         if ((swp.x + swp.cx) > (cxClientMax + cxSizeBorder))
  345.             swp.x = cxClientMax + cxSizeBorder - swp.cx ;
  346.  
  347.         /* Make sure y origin is within display boundaries */
  348.         swp.y = option.img_origin.y ;
  349.         if (swp.y < -cySizeBorder)
  350.             swp.y = 0 ;
  351.  
  352.         /* Make sure window isn't too high, or negative value */
  353.         swp.cy = option.img_size.y ;
  354.         if (swp.cy > cyClientMax || swp.cy < 0) {
  355.             swp.cy = cyClientMax ;
  356.             swp.y = 0 ;
  357.         }
  358.  
  359.         if ((swp.y + swp.cy) > (cyClientMax + cySizeBorder))
  360.             swp.y = cyClientMax + cySizeBorder - swp.cy ;
  361.     }
  362.     else { /* No saved position -- use supplied position */
  363.     swp = *pswp;
  364.         swp.fl = SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW;
  365.     }
  366.  
  367.     /* Position and size this frame window */
  368.     if (!WinSetWindowPos(hwnd_frame, HWND_TOP,
  369.     swp.x, swp.y, swp.cx, swp.cy, swp.fl))
  370.     return 1;
  371.  
  372.     return 0;
  373. }
  374.  
  375. APIRET init1() 
  376. {
  377.     char buf[256];
  378.     char name[256];
  379.     char *tail, *env;
  380.     APIRET rc = 0;
  381.  
  382.     PTIB pptib;
  383.     PPIB pppib;
  384.  
  385.     if ( (rc = DosGetInfoBlocks(&pptib, &pppib)) != 0 ) {
  386.     sprintf(buf,"init1: Couldn't get pid, rc = \n", rc);
  387.     error_message(buf);
  388.     return rc;
  389.     }
  390.     gsview.pid = pppib->pib_ulpid;
  391.     sprintf(gsview.id, "GSVIEW_%u", gsview.pid);
  392.  
  393.     /* get path to EXE */
  394.     if ( (rc = DosQueryModuleName(pppib->pib_hmte, sizeof(szExePath), szExePath)) != 0 ) {
  395.     sprintf(buf,"init1: Couldn't get module name, rc = %d\n", rc);
  396.     error_message(buf);
  397.     return FALSE;
  398.     }
  399.     if ((tail = strrchr(szExePath,'\\')) != (PCHAR)NULL) {
  400.     tail++;
  401.     *tail = '\0';
  402.     }
  403.     strcat(szHelpFile, szExePath);
  404.     strcat(szHelpFile, HELPFILE);
  405.  
  406.     /* get path to INI directory */
  407.     if ((env = getenv("SYSTEM_INI")) != (char *)NULL) {
  408.     strcpy(szIniFile, env);
  409.         if ((tail = strrchr(szIniFile,'\\')) != (PCHAR)NULL) {
  410.         tail++;
  411.         *tail = '\0';
  412.     }
  413.     }
  414.     else
  415.         strcpy(szIniFile, szExePath);
  416.     strcat(szIniFile, INIFILE);
  417.  
  418.     if ((env = getenv("MMBASE")) != (char *)NULL) {
  419.     char buf[MAXSTR];
  420.     HMODULE hmodMCIAPI;
  421.         strcpy(szMMini, env);
  422.     strtok(szMMini, ";");
  423.     strcat(szMMini, "\\MMPM.INI");
  424.     /* attempt to load MCIAPI.DLL ourselves so gvpm will work without MMOS2 */
  425.     if (!DosLoadModule(buf, sizeof(buf), "MCIAPI", &hmodMCIAPI)) {
  426.         DosQueryProcAddr(hmodMCIAPI, 0, "mciPlayFile", (PFN *)(&pfnMciPlayFile));
  427.     }
  428.     }
  429.  
  430.  
  431.     if (!rc) {
  432.     sprintf(name, NEXT_NAME, gsview.id);
  433.     rc = DosCreateEventSem(name, &gsview.next_event, 0, FALSE);
  434.       if (rc) {
  435.         sprintf(buf, "Failed to create: next page event semaphore \"%s\" rc = %d", name, rc);
  436.         error_message(buf);
  437.     }
  438.     }
  439.     if (!rc) {
  440.     sprintf(name, MUTEX_NAME, gsview.id);
  441.     rc = DosCreateMutexSem(name, &gsview.bmp_mutex, 0, FALSE);
  442.       if (rc) {
  443.         sprintf(buf, "Failed to create: bmp mutex semaphore \"%s\" rc = %d", name, rc);
  444.         error_message(buf);
  445.     }
  446.     }
  447.     if (!rc) {
  448.     sprintf(name, QUEUE_NAME, gsview.id);
  449.     if ( (rc = DosCreateQueue(&gsview.queue, QUE_FIFO, name)) != 0 ) {
  450.         sprintf(buf,"Failed to create: \"%s\", rc = %d\n", name, rc);
  451.         error_message(buf);
  452.     }
  453.  
  454.     }
  455.     if (!rc) {
  456.     sprintf(gsview.term_queue_name, "\\QUEUES\\TERM_%s", gsview.id);
  457.     if ( (rc = DosCreateQueue(&gsview.term_queue, QUE_FIFO, gsview.term_queue_name)) != 0 ) {
  458.         sprintf(buf,"Failed to create: \"%s\", rc = %d\n", gsview.term_queue_name, rc);
  459.         error_message(buf);
  460.     }
  461.     }
  462.  
  463.     /* local stuff */
  464.     if (!rc) {
  465.     rc = DosCreateEventSem(NULL, &display.done, 0, FALSE);
  466.       if (rc)
  467.         error_message("Failed to create: display.done semaphore");
  468.     }
  469.  
  470.     if (!rc) {
  471.     HPS ps = WinGetPS(HWND_DESKTOP);
  472.     HDC hdc = GpiQueryDevice(ps);
  473.     DevQueryCaps(hdc, CAPS_COLOR_PLANES, 1, &display.planes);
  474.     DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, &display.bitcount);
  475.     DevQueryCaps(hdc, CAPS_ADDITIONAL_GRAPHICS, 1, &display.hasPalMan);
  476.     display.hasPalMan &= CAPS_PALETTE_MANAGER;
  477.     WinReleasePS(ps);
  478. /*
  479.     { char buf[256];
  480.     sprintf(buf,"main: display planes = %d, bitcount = %d",display.planes,display.bitcount);
  481.     message_box(buf, 0);
  482.     }
  483. */
  484.     }
  485.     bitmap.valid = FALSE;
  486.     return rc;
  487. }
  488.  
  489. APIRET
  490. init2(void)
  491. {
  492.     int i;
  493.     char thismedia[20];
  494.     for (i=IDM_LETTER; i<IDM_USERSIZE; i++) {
  495.         get_menu_string(IDM_MEDIAMENU, i, thismedia, sizeof(thismedia));
  496.         if (!stricmp(thismedia, option.medianame)) {
  497.         break;
  498.         }
  499.     }
  500.     option.media = i;
  501.     strncpy(option.medianame,thismedia,sizeof(option.medianame));
  502.     /* update menus */
  503.     if (option.quick) check_menu_item(IDM_OPTIONMENU, IDM_QUICK, TRUE);
  504.     if (option.settings) check_menu_item(IDM_OPTIONMENU, IDM_SAVESETTINGS, TRUE);
  505.     if (option.button_show) check_menu_item(IDM_OPTIONMENU, IDM_BUTTONSHOW, TRUE);
  506.     if (option.fit_page) check_menu_item(IDM_OPTIONMENU, IDM_FITPAGE, TRUE);
  507.     if (option.safer) check_menu_item(IDM_OPTIONMENU, IDM_SAFER, TRUE);
  508.     if (option.save_dir) check_menu_item(IDM_OPTIONMENU, IDM_SAVEDIR, TRUE);
  509.     if (option.redisplay) check_menu_item(IDM_OPTIONMENU, IDM_AUTOREDISPLAY, TRUE);
  510.     if (option.epsf_clip) check_menu_item(IDM_OPTIONMENU, IDM_EPSFCLIP, TRUE);
  511.     if (option.epsf_warn) check_menu_item(IDM_OPTIONMENU, IDM_EPSFWARN, TRUE);
  512.     if (option.ignore_dsc) check_menu_item(IDM_OPTIONMENU, IDM_IGNOREDSC, TRUE);
  513.     if (option.show_bbox) check_menu_item(IDM_OPTIONMENU, IDM_SHOWBBOX, TRUE);
  514.     check_menu_item(IDM_UNITMENU, option.unit, TRUE);
  515.     check_menu_item(IDM_ORIENTMENU, option.orientation, TRUE);
  516.     check_menu_item(IDM_MEDIAMENU, option.media, TRUE);
  517.     check_menu_item(IDM_DEPTHMENU, gsview_depth_to_menu(option.depth), TRUE);
  518.     update_scroll_bars();
  519.     return 0;
  520. }
  521.  
  522.  
  523. void
  524. init_options()
  525. {
  526. int i;
  527.     /* make an educated guess about gs command */
  528.     strcpy(option.gscommand, szExePath);
  529.     strcat(option.gscommand, DEFAULT_GSCOMMAND);
  530.     strcat(option.gscommand, " -I");
  531.     strcat(option.gscommand, szExePath);
  532.     strcpy(option.gscommand+strlen(option.gscommand)-1, ";");
  533.     strcat(option.gscommand, szExePath);
  534.     strcat(option.gscommand, "fonts;");
  535.     i = strlen(option.gscommand);
  536.     option.gscommand[i++] = tolower(szIniFile[0]);
  537.     option.gscommand[i] = '\0';
  538.     strcat(option.gscommand, ":\\psfonts");
  539.     option.img_origin.x = CW_USEDEFAULT;
  540.     option.img_origin.y = CW_USEDEFAULT;
  541.     option.img_size.x = CW_USEDEFAULT;
  542.     option.img_size.y = CW_USEDEFAULT;
  543.     option.img_max = FALSE;
  544.     option.gsversion = IDM_GS3;
  545.     option.unit = IDM_UNITPT;
  546.     option.quick = TRUE;
  547.     option.settings = TRUE;
  548.     option.button_show = TRUE;
  549.     option.fit_page = TRUE;
  550.     option.safer = TRUE;
  551.     option.media = IDM_LETTER;
  552.     strcpy(option.medianame, "letter");
  553.     option.user_width = 610;
  554.     option.user_height = 792;
  555.     option.epsf_clip = FALSE;
  556.     option.epsf_warn = FALSE;
  557.     option.ignore_dsc = FALSE;
  558.     option.show_bbox = FALSE;
  559.     option.redisplay = TRUE;
  560.     option.orientation = IDM_PORTRAIT;
  561.     option.swap_landscape = FALSE;
  562.     option.xdpi = DEFAULT_RESOLUTION;
  563.     option.ydpi = DEFAULT_RESOLUTION;
  564.     option.save_dir = TRUE;
  565.     strcpy(option.device_name, "deskjet");
  566.     strcpy(option.device_resolution, "300");
  567. }
  568.  
  569. void
  570. show_buttons(void)
  571. {
  572.     WinSendMsg(hwnd_frame, WM_UPDATEFRAME, (MPARAM)frame_flags, (MPARAM)0);
  573. }
  574.  
  575.