📄 gvpm.c
字号:
WinSendMsg(hwndScroll, SBM_SETTHUMBSIZE,
MPFROM2SHORT(1, 1), MPFROMLONG(0));
}
if (!fullscreen && option.fit_page && image.open &&
(cxAdjust!=0 || cyAdjust!=0) ) {
SWP swp;
/* don't interrogate the window location immediately since */
/* it causes the Diamond Stealth VL24 with IBM S3 drivers */
/* to corrupt the display */
DosSleep(50);
WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), 0,
swp.x, swp.y - cyAdjust,
swp.cx + cxAdjust, swp.cy + cyAdjust, SWP_SIZE | SWP_MOVE);
cxAdjust = cyAdjust = 0;
}
display.offset.x = -cxAdjust/2;
display.offset.y = -cyAdjust/2;
if (!fullscreen && hwnd_frame) {
SWP swp;
WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
if (!(swp.fl & SWP_MINIMIZE)) {
if (!(swp.fl & SWP_MAXIMIZE)) {
option.img_size.x = swp.cx;
option.img_size.y = swp.cy;
}
option.img_max = ((swp.fl & SWP_MAXIMIZE) != 0);
}
}
fit_page_enabled = FALSE;
break;
case WM_VSCROLL:
if (!image.open)
break;
switch(SHORT2FROMMP(mp2)) {
case SB_LINEUP:
nVscrollInc = -cyClient/16;
break;
case SB_LINEDOWN:
nVscrollInc = cyClient/16;
break;
case SB_PAGEUP:
nVscrollInc = min(-1,-cyClient);
break;
case SB_PAGEDOWN:
nVscrollInc = max(1,cyClient);
break;
#ifdef NOTUSED
case SB_SLIDERTRACK:
/* only do this for fast redraw modes */
/* these are 8bit/pixel and 1bit/pixel */
if ( (bitmap.depth == 1) ||
((bitmap.depth == 8) && display.hasPalMan && display.hpal_exists) ) {
nVscrollInc = SHORT1FROMMP(mp2) - nVscrollPos;
}
else
nVscrollInc = 0;
#endif
case SB_SLIDERPOSITION:
nVscrollInc = SHORT1FROMMP(mp2) - nVscrollPos;
break;
case SB_TOP:
nVscrollInc = -nVscrollPos;
break;
case SB_BOTTOM:
nVscrollInc = nVscrollMax - nVscrollPos;
break;
case SB_FIND:
nVscrollInc = (short)SHORT1FROMMP(mp2);
break;
default:
nVscrollInc = 0;
}
if ((nVscrollInc = max(-nVscrollPos,
min(nVscrollInc, nVscrollMax - nVscrollPos)))!=0) {
LONG lComplexity;
HPOINTER hptr;
hwndScroll = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_VERTSCROLL);
nVscrollPos += nVscrollInc;
scroll_pos.y = nVscrollMax - nVscrollPos;
/* KLUDGE BEGIN */
/* remove pointer to cope with buggy display drivers */
hptr = WinQueryPointer(HWND_DESKTOP);
WinSetPointer(HWND_DESKTOP, 0);
/* KLUDGE END */
lComplexity = WinScrollWindow(hwnd, 0, nVscrollInc, (PRECTL)NULL, (PRECTL)NULL,
(HRGN)NULLHANDLE, (PRECTL)&rect, 0);
/* KLUDGE BEGIN */
/* restore pointer after we removed it */
WinSetPointer(HWND_DESKTOP, hptr);
/* KLUDGE END */
WinSendMsg(hwndScroll, SBM_SETPOS, MPFROMLONG(nVscrollPos), 0);
if (lComplexity != RGN_RECT) {
WinInvalidateRect(hwnd, (PRECTL)NULL, FALSE);
WinUpdateWindow(hwnd);
}
else {
/* redraw exposed area */
hps = WinGetPS(hwnd);
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);
WinValidateRect(hwnd, &rect, FALSE);
WinReleasePS(hps);
}
}
else if (gsdll.state != GS_IDLE) {
/* We are at the top or bottom of the
* scroll range. Change page if
* PageUp or PageDown pressed. */
int numpages = 0;
request_mutex();
if (psfile.dsc != (CDSC *)NULL)
numpages = psfile.dsc->page_count;
release_mutex();
switch(SHORT2FROMMP(mp2)) {
case SB_PAGEUP:
if ((psfile.dsc != (CDSC *)NULL)
&& (psfile.pagenum != 1)) {
WinSendMsg(hwnd, WM_VSCROLL, MPFROMLONG(0),
MPFROM2SHORT(0, SB_BOTTOM));
gsview_command(IDM_PREV);
}
break;
case SB_PAGEDOWN:
if ((psfile.dsc == (CDSC *)NULL)
|| (psfile.pagenum < numpages)) {
WinSendMsg(hwnd, WM_VSCROLL, MPFROMLONG(0),
MPFROM2SHORT(0, SB_TOP));
gsview_command(IDM_NEXT);
}
break;
}
}
break;
case WM_HSCROLL:
if (!image.open)
break;
switch(SHORT2FROMMP(mp2)) {
case SB_LINELEFT:
nHscrollInc = -cxClient/16;
break;
case SB_LINERIGHT:
nHscrollInc = cyClient/16;
break;
case SB_PAGELEFT:
nHscrollInc = min(-1,-cxClient);
break;
case SB_PAGERIGHT:
nHscrollInc = max(1,cxClient);
break;
#ifdef NOTUSED
case SB_SLIDERTRACK:
/* only do this for fast redraw modes */
/* these are 8bit/pixel and 1bit/pixel */
if ( (bitmap.depth == 1) ||
((bitmap.depth == 8) && display.hasPalMan && display.hpal_exists) ) {
nHscrollInc = SHORT1FROMMP(mp2) - nHscrollPos;
}
else
nHscrollInc = 0;
#endif
case SB_SLIDERPOSITION:
nHscrollInc = SHORT1FROMMP(mp2) - nHscrollPos;
break;
case SB_TOP:
nHscrollInc = -nHscrollPos;
break;
case SB_BOTTOM:
nHscrollInc = nHscrollMax - nHscrollPos;
break;
case SB_FIND:
nHscrollInc = (short)SHORT1FROMMP(mp2);
break;
default:
nHscrollInc = 0;
}
if ((nHscrollInc = max(-nHscrollPos,
min(nHscrollInc, nHscrollMax - nHscrollPos)))!=0) {
LONG lComplexity;
HPOINTER hptr;
hwndScroll = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_HORZSCROLL);
nHscrollPos += nHscrollInc;
scroll_pos.x = nHscrollPos;
/* KLUDGE BEGIN */
/* remove pointer to cope with buggy display drivers */
hptr = WinQueryPointer(HWND_DESKTOP);
WinSetPointer(HWND_DESKTOP, 0);
/* KLUDGE END */
lComplexity = WinScrollWindow(hwnd, -nHscrollInc, 0, (PRECTL)NULL, (PRECTL)NULL,
(HRGN)NULLHANDLE, (PRECTL)&rect, 0);
/* KLUDGE BEGIN */
/* restore pointer after we removed it */
WinSetPointer(HWND_DESKTOP, hptr);
/* KLUDGE END */
/* need to send next message BEFORE redrawing, otherwise S3 driver screws up */
WinSendMsg(hwndScroll, SBM_SETPOS, MPFROMLONG(nHscrollPos), 0);
if (lComplexity != RGN_RECT) {
WinInvalidateRect(hwnd, (PRECTL)NULL, FALSE);
WinUpdateWindow(hwnd);
}
else {
/* redraw exposed area */
hps = WinGetPS(hwnd);
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);
WinValidateRect(hwnd, &rect, FALSE);
WinReleasePS(hps);
}
}
break;
case WM_CHAR: /* process keystrokes here */
if (!(SHORT1FROMMP(mp1) & KC_KEYUP) &&
(SHORT1FROMMP(mp1) & KC_VIRTUALKEY)) {
/* Process virtual keys only on presses, not key releases */
USHORT vkey = SHORT2FROMMP(mp2);
/* Note that the cursor keys these scroll hwnd_image, not hwnd.
* This is needed for fullscreen because the key presses
* are sent to the frame child window, not the fullscreen
* window which has the focus!
*/
switch(vkey) {
case VK_ESC:
if (fullscreen)
gsview_fullscreen_end();
break;
case VK_HOME:
if (SHORT1FROMMP(mp1) & KC_CTRL)
WinSendMsg(hwnd_image, WM_HSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_TOP));
else
WinSendMsg(hwnd_image, WM_VSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_TOP));
break;
case VK_END:
if (SHORT1FROMMP(mp1) & KC_CTRL)
WinSendMsg(hwnd_image, WM_HSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_BOTTOM));
else
WinSendMsg(hwnd_image, WM_VSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_BOTTOM));
break;
case VK_UP:
if (SHORT1FROMMP(mp1) & KC_CTRL)
WinSendMsg(hwnd_image, WM_VSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_PAGEUP));
else
WinSendMsg(hwnd_image, WM_VSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_LINEUP));
break;
case VK_DOWN:
if (SHORT1FROMMP(mp1) & KC_CTRL)
WinSendMsg(hwnd_image, WM_VSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_PAGEDOWN));
else
WinSendMsg(hwnd_image, WM_VSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_LINEDOWN));
break;
case VK_PAGEUP:
if (SHORT1FROMMP(mp1) & KC_CTRL)
WinSendMsg(hwnd_image, WM_HSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_PAGELEFT));
else
WinSendMsg(hwnd_image, WM_VSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_PAGEUP));
break;
case VK_PAGEDOWN:
if (SHORT1FROMMP(mp1) & KC_CTRL)
WinSendMsg(hwnd_image, WM_HSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_PAGERIGHT));
else
WinSendMsg(hwnd_image, WM_VSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_PAGEDOWN));
break;
case VK_LEFT:
if (SHORT1FROMMP(mp1) & KC_CTRL)
WinSendMsg(hwnd_image, WM_HSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_PAGELEFT));
else
WinSendMsg(hwnd_image, WM_HSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_LINELEFT));
break;
case VK_RIGHT:
if (SHORT1FROMMP(mp1) & KC_CTRL)
WinSendMsg(hwnd_image, WM_HSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_PAGERIGHT));
else
WinSendMsg(hwnd_image, WM_HSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_LINERIGHT));
break;
}
}
break;
case WM_BUTTON1DOWN:
if (hwnd_modeless)
WinPostMsg(hwnd_modeless, WM_COMMAND, MPFROMSHORT(BB_CLICK), MPFROMLONG(0));
else {
int iword ;
float x, y;
PDFLINK link;
BOOL full = fullscreen && (hwnd == hwnd_fullscreen);
if (get_cursorpos(&x, &y)) {
if (!full) {
HPS hps = WinGetPS(hwnd);
if ( (iword = word_find((int)x, (int)y)) >= 0 ) {
/* remove any current selection */
highlight_words(hps, text_mark_first, text_mark_last);
/* mark new selection */
text_mark_first = text_mark_last = iword;
text_marking = TRUE;
highlight_words(hps, text_mark_first, text_mark_last);
WinSetCapture(HWND_DESKTOP, hwnd);
}
else {
/* remove selection */
highlight_words(hps, text_mark_first, text_mark_last);
text_mark_first = text_mark_last = -1;
WinSetCapture(HWND_DESKTOP, NULLHANDLE);
}
WinReleasePS(hps);
}
}
/* pdfmark link */
if (is_link(x, y, &link)) {
/* found link */
if (link.page == 0) {
if (strcmp(link.action, "GoBack")==0)
history_back();
else
gserror(IDS_NOLINKTARGET, NULL, 0, SOUND_ERROR);
}
else {
gsview_unzoom();
pending.pagenum = link.page;
history_add(pending.pagenum);
pending.now = TRUE;
}
}
else if (full) {
WinPostMsg(hwnd_image, WM_COMMAND,
MPFROMSHORT(IDM_NEXT), MPFROMLONG(0));
}
measure_setpoint(x, y);
}
break;
case WM_BUTTON2DOWN:
if (fullscreen && (hwnd == hwnd_fullscreen)) {
WinPostMsg(hwnd_image, WM_COMMAND, MPFROMSHORT(IDM_PREV),
MPFROMLONG(0));
}
else {
float x, y;
int zwidth, zheight;
if (hwnd_modeless) {
play_sound(SOUND_BUSY);
break;
}
request_mutex();
if (get_cursorpos(&x, &y)) {
zoom = !zoom;
display.zoom_xoffset = (int)x;
display.zoom_yoffset = (int)y;
if (cxClient > image.width)
zwidth = image.width;
else
zwidth = cxClient;
if (cyClient > image.height)
zheight = image.height;
else
zheight = cyClient;
x = (scroll_pos.x+zwidth/2)*72.0/option.xdpi;
y = (scroll_pos.y+zheight/2)*72.0/option.ydpi;
transform_point(&x, &y);
x *= option.xdpi/72.0;
y *= option.ydpi/72.0;
display.zoom_xoffset -= (int)(x*72.0/option.zoom_xdpi);
display.zoom_yoffset -= (int)(y*72.0/option.zoom_ydpi);
}
else {
zoom = FALSE;
}
release_mutex();
WinPostMsg(hwnd_bmp, WM_COMMAND, (MPARAM)IDM_ZOOM, MPFROMLONG(0));
}
break;
case WM_MOUSEMOVE:
/* track cursor and display coordinates */
request_mutex();
hps = WinGetPS(hwnd_status);
WinFillRect(hps, &info_coord, SYSCLR_BUTTONMIDDLE);
cursorpos_paint(hps);
WinReleasePS(hps);
release_mutex();
/* extend marked text */
if (text_marking) {
int iword ;
float x, y;
RECTL rect;
POINTL pt;
do {
if (!WinQueryPointerPos(HWND_DESKTOP, &pt))
return FALSE;
WinMapWindowPoints(HWND_DESKTOP, hwnd_bmp, &pt, 1);
WinQueryWindowRect(hwnd_bmp, &rect);
if (pt.x > rect.xRight)
WinSendMsg(hwnd, WM_HSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_LINERIGHT));
if (pt.x < rect.xLeft)
WinSendMsg(hwnd, WM_HSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_LINELEFT));
if (pt.y < rect.yBottom)
WinSendMsg(hwnd, WM_VSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_LINEDOWN));
if (pt.y > rect.yTop)
WinSendMsg(hwnd, WM_VSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_LINEUP));
DosSleep(100);
} while ( (pt.x > rect.xRight) || (pt.x < rect.xLeft)
|| (pt.y > rect.yTop) || (pt.y < rect.yBottom) );
if (get_cursorpos(&x, &y)) {
if ( (iword = word_find((int)x, (int)y)) >= 0 ) {
if (iword != text_mark_last) {
HPS hps = WinGetPS(hwnd);
int first, last;
if ((text_mark_last-text_mark_first >= 0) != (iword-text_mark_first >= 0)) {
/* changing direction */
/* clear everything */
highlight_words(hps, text_mark_first, text_mark_last);
/* reinstate first word */
text_mark_last = text_mark_first;
highlight_words(hps, text_mark_first, text_mark_last);
}
if (iword != text_mark_last) {
if (iword >= text_mark_first) {
if (iword > text_mark_last)
first=text_mark_last+1, last=iword;
else
first=iword+1, last=text_mark_last;
}
else {
if (iword > text_mark_last)
first=text_mark_last, last=iword-1;
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -