⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gvpm.c

📁 GSview 4.6 PostScript previewer。Ghostscript在MS-Windows, OS/2 and Unix下的图形化接口
💻 C
📖 第 1 页 / 共 5 页
字号:
				break;
			if (strlen(buf) - j > 28)
			    memmove(buf+3, buf+strlen(buf)+1-30, 30);
			else {
			    buf[5] = buf[6] = buf[7] = '.';
			    memmove(buf+8, buf+j, strlen(buf)+1-j);
			}
		    }
		    mii.id = IDM_LASTFILE1+i-1;
		    WinSendMsg(mi.hwndSubMenu, MM_INSERTITEM, 
			(MPARAM)&mii, (MPARAM)buf);
		}
	    }
	    break;
	case IDM_EDITMENU:
	    request_mutex();
	    enable_menu_item(IDM_EDITMENU, IDM_COPYCLIP, image.open);
	    enable_menu_item(IDM_EDITMENU, IDM_PASTETO, image.open);
    	    addeps =  (psfile.dsc != (CDSC *)NULL) && psfile.dsc->epsf && idle;
	    enable_menu_item(IDM_EDITMENU, IDM_ADDEPSMENU, addeps);
	    enable_menu_item(IDM_ADDEPSMENU, IDM_MAKEEPSU, addeps);
    	    addeps =  addeps && image.open;
	    enable_menu_item(IDM_ADDEPSMENU, IDM_MAKEEPSI, addeps);
	    enable_menu_item(IDM_ADDEPSMENU, IDM_MAKEEPST4, addeps);
	    enable_menu_item(IDM_ADDEPSMENU, IDM_MAKEEPST6U, addeps);
	    enable_menu_item(IDM_ADDEPSMENU, IDM_MAKEEPST6P, addeps);
	    enable_menu_item(IDM_EDITMENU, IDM_EXTEPSMENU, 
		    ((psfile.preview == IDS_EPST) || (psfile.preview == IDS_EPSW)) && idle);
	    enable_menu_item(IDM_EDITMENU, IDM_TEXTEXTRACT, idle);
	    enable_menu_item(IDM_EDITMENU, IDM_TEXTFIND, idle);
	    enable_menu_item(IDM_EDITMENU, IDM_TEXTFINDNEXT, idle);
	    release_mutex();
	    break;
    }
}

/* This is the window function */
MRESULT EXPENTRY ClientWndProc(HWND hwnd, ULONG mess, 
			MPARAM mp1, MPARAM mp2)
{
  char buf[MAXSTR];

  static int cxClient, cyClient;
  static int cxAdjust, cyAdjust;
  static int nHscrollMax, nHscrollPos;
  static int nVscrollMax, nVscrollPos;
  int nHscrollInc;
  int nVscrollInc;
  HWND hwndScroll;
  HPS hps;
  RECTL rect;
  ULONG ulclr;

    switch(mess) {
	case WM_CREATE:
	    break;
	case WM_ERASEBACKGROUND:
	    /* by returning TRUE, the Presentation Manager automatically clears
	     * the window each time the window is resized or moved.
	     */
	    if (!image.open) {
		WinFillRect((HPS)mp1, (PRECTL)mp2, SYSCLR_DIALOGBACKGROUND);
		return (MRESULT)FALSE;	/* say we have done it */
	    }
	    return (MRESULT)TRUE;
	case WM_GSSYNC:
	    if (!fullscreen) {
		if (!WinInvalidateRect(hwnd_image, (PRECTL)NULL, TRUE))
			error_message("error invalidating rect");
		if (!WinUpdateWindow(hwnd_image))
			error_message("error updating window");
	    }
	    return 0;
	case WM_GSPAGE:
	    play_sound(SOUND_PAGE);
	    if (display.show_find)
		scroll_to_find();
	    if (!WinInvalidateRect(hwnd_image, (PRECTL)NULL, TRUE))
		    error_message("error invalidating rect");
	    if (!WinUpdateWindow(hwnd_image))
		    error_message("error updating window");
	    return 0;
	case WM_GSTILE:
	    /* draw a tile that has changed */
	    if (fullscreen)
		return 0;
	    image_lock(&image);
	    if (image.open) {
		/* calculate area */
		DATETIME dt1, dt2;
		int td;
		RECTL rect;
		ULONG dw = LONGFROMMP(mp1);
		int tx1 = (dw >> 24) & 0xff;
		int ty1 = (dw >> 16) & 0xff;
		int tx2 = (dw >> 8) & 0xff;
		int ty2 = (dw) & 0xff;
		rect.xLeft = (tx1 * image.tile_width) 
		    + display.offset.x - scroll_pos.x;
		rect.xRight = rect.xLeft + 
		    (tx2 - tx1 + 1) * image.tile_width + 1;
		rect.yBottom = (ty1 * image.tile_height)
		    + display.offset.y - scroll_pos.y;
		rect.yTop = rect.yBottom + 
		    (ty2 - ty1 + 1) * image.tile_height + 1;
		image_unlock(&image);

		DosGetDateTime(&dt1);
		WinInvalidateRect(hwnd_image, (PRECTL)&rect, TRUE);
		WinUpdateWindow(hwnd_image);
		DosGetDateTime(&dt2);
		td = ((dt2.minutes - dt1.minutes) * 6000 +
		    (dt2.seconds - dt1.seconds) * 100 +
		    (dt2.hundredths - dt1.hundredths)) * 10;
		image_lock(&image);
		if (image.open && (td * 5 > image.tile_interval)) {
		    image.tile_interval += td + 100;
		    image.tile_verydirty_threshold += 256;
		    image.tile_threshold += image.tile_threshold;
		}
		image_unlock(&image);
		/* don't update immediately */
	    }
	    else {
		image_unlock(view.img);
	    }
	    return 0;
	case WM_GSDEVICE:
	    if (fullscreen) /* don't flash between pages */
		return 0;
	    if (!image.open) {
		if (fullscreen)
		    gsview_fullscreen_end();
	        WinInvalidateRect(hwnd, NULL, FALSE);
		if (!psfile.name[0])
		    update_scroll_bars();
	    }
	    return 0;
	case WM_GSSIZE:
	    if (image.open && scan_bitmap(&bitmap)) {
		/* bitmap has changed */
		update_scroll_bars();
	    }
	    return 0;
	case WM_GSMESSBOX:
	    /* delayed message box, usually from other thread */
	    load_string((int)mp1, buf, sizeof(buf));
	    message_box(buf, (int)mp2);
	    return 0;
	case WM_GSSHOWMESS:
	    /* delayed show message, usually from other thread */
	    gs_showmess();
	    return 0;
	case WM_GSREDISPLAY:
	    WinPostMsg(hwnd_image, WM_COMMAND, MPFROMSHORT(IDM_REDISPLAY), 
			MPFROMLONG(0));
	    return 0;
	case WM_GSTITLE:
	    /* update title */
	    request_mutex();
	    if (psfile.name[0] != '\0') {
		char buf[256];
		char *p;
		p = strrchr(psfile.name, '\\');
		if (p)
		    p++;
		else
		    p = psfile.name;
		sprintf(buf, "%s - %s", szAppName, p);
		WinSetWindowText(hwnd_frame, (unsigned char *)buf);
	    }
	    else
		WinSetWindowText(hwnd_frame, (unsigned char *)szAppName);
	    release_mutex();
	    return 0;
	case WM_GSPERCENT:
	    percent_pending = FALSE;
	    WinInvalidateRect(hwnd_status, (PRECTL)NULL, FALSE);
	    WinUpdateWindow(hwnd_status);
	    return 0;
	case WM_GSTEXTINDEX:
	    make_text_index();
	    text_marking = FALSE;
	    text_mark_first = text_mark_last = -1;
	    return 0;
	case WM_GSWAIT:
	    info_wait((int)mp1);
	    return 0;
	case WM_INITMENU:
	    init_menu((int)mp1);
	    WinSetAccelTable(hab, NULLHANDLE, hwnd_frame);	/* disable keyboard accelerators */
	    break;
	case WM_MENUEND:
	    WinSetAccelTable(hab, haccel, hwnd_frame);	/* reenable keyboard accelerators */
	    break;
	case WM_COMMAND:
	    if (LONGFROMMP(mp1) == IDM_ARGS) {
		/* delayed processing of command line arguments */
		GSVIEW_ARGS *pargs = (GSVIEW_ARGS *)mp2;
		if (pargs->print || pargs->convert) {
		    make_cwd(pargs->filename);
		    gsview_selectfile(pargs->filename);
		    if (pargs->device[0]) {
			if (pargs->print)
			    strcpy(option.printer_device, pargs->device);
			else
			    strcpy(option.convert_device, pargs->device);
		    }
		    if ((pargs->queue[0]) && pargs->print)
			strcpy(option.printer_queue, pargs->queue);
		    if (dfreopen() != 0) {
			release_mutex();
		        return 0;
		    }
		    if (psfile.name[0] != '\0') {
		        option.print_to_file = FALSE;
		        gsview_print(!pargs->print);
		    }
		    dfclose();
		}
		else if (pargs->spool) {
		    if (*pargs->filename) {
			gs_addmess("Spooling \042");
			gs_addmess(pargs->filename);
			gs_addmess("\042 to printer \042");
			if (pargs->queue)
			    gs_addmess(pargs->queue);
			gs_addmess("\042\n");
			gsview_spool(pargs->filename, pargs->queue);
			gsview_command(IDM_EXIT);
			break;
		    }
		}
		else  if (pargs->filename[0]) {
		    FILE *f;
		    /* Only display file if it exists, because starting 
		     * GSview from Desktop menu sets filename d:\Desktop
		     */
		    if ( (f=fopen(pargs->filename,"rb")) != (FILE *)NULL ) {
			fclose(f);
			make_cwd(pargs->filename);
			gsview_displayfile(pargs->filename);
		    }
		}
	    }
	    else if (LONGFROMMP(mp1) == IDM_DROP) {
		char *cmd = (char *)mp2;
		FILE *f;
		/* Only display file if it exists, because starting 
		 * GSview from Desktop menu sets cmd to d:\Desktop
		 */
		if ( (f=fopen(cmd,"rb")) != (FILE *)NULL ) {
		    fclose(f);
		    make_cwd(cmd);
		    gsview_displayfile(cmd);
		}
		free(cmd);
	    }
	    else {
		if (LONGFROMMP(mp1) == IDM_PSTOEPS) {
		    if (psfile.name[0] == '\0')	/* need open file */
			WinSendMsg(hwnd, WM_COMMAND, MPFROMSHORT(IDM_OPEN), 
				MPFROM2SHORT(CMDSRC_OTHER,FALSE));
		}
		gsview_command(LONGFROMMP(mp1));
	    }
	    break;
	case WM_REALIZEPALETTE:
	    if ((bitmap.depth == 8) && display.hasPalMan && display.hpal_exists) {
		APIRET rc;
		hps = WinGetPS(hwnd);
		GpiSelectPalette(hps, display.hpal);
	        if ( (rc = WinRealizePalette(hwnd, hps, &ulclr)) > 0)
		    WinInvalidateRect(hwnd, NULL, FALSE);
		GpiSelectPalette(hps, (HPAL)NULL);
		WinReleasePS(hps);
	        return 0;
	    }
	    break;	/* use default processing */
	case WM_PAINT:
	    if (!image.open || quitnow) {
	        hps = WinBeginPaint(hwnd, (ULONG)0, &rect);
		WinFillRect(hps, &rect, SYSCLR_DIALOGBACKGROUND);
		WinEndPaint(hwnd);
		return 0;
	    }

	    /* Refresh the window each time the WM_PAINT message is received */

	    /* get bmp mutex to stop gs.exe changing bitmap while we paint */
	    image_lock(&image);
	    if (image.open && scan_bitmap(&bitmap)) {
		update_scroll_bars(); /* bitmap has changed */
	    }

	    if (!image.open) {
		image_unlock(&image);
	        hps = WinBeginPaint(hwnd, (ULONG)0, &rect);
		WinFillRect(hps, &rect, CLR_BACKGROUND);
		WinEndPaint(hwnd);
		return 0;
	    }

	    request_mutex();
	    hps = WinBeginPaint(hwnd, (HPS)NULL, &rect);
	    if ((bitmap.depth == 8) && display.hasPalMan && display.hpal_exists) {
	        GpiSelectPalette(hps, display.hpal);
                WinRealizePalette(hwnd, hps, &ulclr);
	        paint_bitmap(hps, &rect, nHscrollPos, nVscrollMax - nVscrollPos);
	        GpiSelectPalette(hps, (HPAL)NULL);
	    }
	    else
	        paint_bitmap(hps, &rect, nHscrollPos, nVscrollMax - nVscrollPos);
	    WinEndPaint(hwnd);
	    release_mutex();
	    if (hwnd == hwnd_fullscreen)
		WinSetPointer(HWND_DESKTOP, 0);
	    image_unlock(&image);
	    return 0;
	case WM_MOVE:
	    /* don't interrogate the window location immediately since */
	    /* it causes the Diamond Stealth VL24 with IBM S3 drivers */
	    /* to corrupt the display */
	    DosSleep(50);
	    if (hwnd_frame) {
		SWP swp;
		WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
		if (!(swp.fl & SWP_MINIMIZE)) {
		    if (!(swp.fl & SWP_MAXIMIZE)) {
		        option.img_origin.x = swp.x;
		        option.img_origin.y = swp.y;
		    }
		    option.img_max = ((swp.fl & SWP_MAXIMIZE) != 0);
		}
	    }
	    break;
	case WM_SIZE:
		cyClient = SHORT2FROMMP(mp2);
		cxClient = SHORT1FROMMP(mp2);

#ifdef OLD
		cyAdjust = min(image.height, cyClient) - cyClient;
		cyClient += cyAdjust;
#else
		if (image.height < cyClient) {
		    /* shrink window */
		    cyAdjust = image.height - cyClient;
		}
		else {
		    if (!fullscreen && fit_page_enabled) {
			/* We just got a GSDLL_SIZE and option.fitpage was TRUE */
			/* enlarge window to smaller of image height */
			/* and height if client extended to bottom of screen */
		        SWP swp;
			DosSleep(50);  /* see note below */
		        WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
			cyAdjust = min(image.height, cyClient + swp.y)
			    - cyClient;
		    }
		    else
			cyAdjust = 0;
		}
		cyClient += cyAdjust;
#endif

		nVscrollMax = max(0, image.height - cyClient);
		nVscrollPos = min(nVscrollPos, nVscrollMax);
		scroll_pos.y = nVscrollMax - nVscrollPos;

		if (!image.open)
			cyClient = cyAdjust = nVscrollMax = nVscrollPos = 0;

		if (fullscreen) {
		    /* we don't have scroll bars */
		}
		else {
		    hwndScroll = WinWindowFromID(
			WinQueryWindow(hwnd, QW_PARENT), FID_VERTSCROLL);
		    WinSendMsg(hwndScroll, SBM_SETSCROLLBAR, 
			MPFROMLONG(nVscrollPos), MPFROM2SHORT(0, nVscrollMax));
		    if (image.open)
			WinSendMsg(hwndScroll, SBM_SETTHUMBSIZE, 
			    MPFROM2SHORT(cyClient, image.height),
			    MPFROMLONG(0));
		    else
			WinSendMsg(hwndScroll, SBM_SETTHUMBSIZE, 
				MPFROM2SHORT(1, 1), MPFROMLONG(0));
		}

#ifdef OLD
		cxAdjust = min(image.width,  cxClient) - cxClient;
		cxClient += cxAdjust;
#else
		if (image.width < cxClient) {
		    /* shrink window */
		    cxAdjust = image.width - cxClient;
		}
		else {
		    if (fit_page_enabled) {
			/* We just got a GSDLL_SIZE and option.fitpage was TRUE */
			/* enlarge window to smaller of image width */
			/* and width if client extended to right of screen */
		        SWP swp;
			DosSleep(50);  /* see note below */
		        WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
			cxAdjust = min(image.width, 
			    cxClient + WinQuerySysValue(HWND_DESKTOP, SV_CXFULLSCREEN) -
				(swp.x + swp.cx) /* Windows uses rect.right */)
			    - cxClient;
		    }
		    else
			cxAdjust = 0;
		}
		cxClient += cxAdjust;
#endif

		nHscrollMax = max(0, image.width - cxClient);
		nHscrollPos = min(nHscrollPos, nHscrollMax);
		scroll_pos.x = nHscrollPos;

		if (!image.open)
			cxClient = cxAdjust = nHscrollMax = nHscrollPos = 0;

		if (fullscreen) {
		    /* we don't have scroll bars */
		}
		else {
		    hwndScroll = WinWindowFromID(
			WinQueryWindow(hwnd, QW_PARENT), FID_HORZSCROLL);
		    WinSendMsg(hwndScroll, SBM_SETSCROLLBAR, 
			MPFROMLONG(nHscrollPos), MPFROM2SHORT(0, nHscrollMax));
		    if (image.open)
			WinSendMsg(hwndScroll, SBM_SETTHUMBSIZE, 
			    MPFROM2SHORT(cxClient, image.width), 
			    MPFROMLONG(0));
		    else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -