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

📄 wview.c

📁 mit数据库ecg波形观察软件
💻 C
📖 第 1 页 / 共 4 页
字号:
	  case VK_RIGHT:        /* <right arrow> */
	    SendMessage(hWnd, WM_HSCROLL, SB_LINEDOWN, 0L);
	    break;
	  case VK_PRIOR:        /* <Page Up> */
	    SendMessage(hWnd, WM_HSCROLL, SB_PAGEUP, 0L);
	    break;
	  case VK_NEXT:         /* <Page Down> */
	    SendMessage(hWnd, WM_HSCROLL, SB_PAGEDOWN, 0L);
	    break;
	  case VK_BACK:         /* <backspace> */
	    switch (find_previous()) {
	      case 1:   /* target found, reset scrollbar and redraw */
		scrollpos = (int)(2048.*t0/tf);
		SetScrollPos(hWnd, SB_HORZ, scrollpos, TRUE);
		InvalidateRect(hWnd, NULL, TRUE);
		break;
	      case 0:   /* not found, ignore */
		break;
	      case -1:  /* no target defined, handle as for page up */
		SendMessage(hWnd, WM_HSCROLL, SB_PAGEUP, 0L);
		break;
	    }
	    break;
	  case VK_RETURN:       /* <enter> */
	    switch (find_next()) {
	      case 1:   /* target found, reset scrollbar and redraw */
		scrollpos = (int)(2048.*t0/tf);
		SetScrollPos(hWnd, SB_HORZ, scrollpos, TRUE);
		InvalidateRect(hWnd, NULL, TRUE);
		break;
	      case 0:   /* not found, ignore */
		break;
	      case -1:  /* no target defined, handle as for page down */
		SendMessage(hWnd, WM_HSCROLL, SB_PAGEDOWN, 0L);
		break;
	    }
	    break;
	  case VK_UP:   /* <up arrow>: zoom in (increase time scale) */
	    if (tsi < MAXTSI) {
		tscale = tsc[++tsi];
		/* Adjust time of left edge such that the time of
		   the center of the window will be unchanged. */
		t0 += (WFDB_Time)(sps*wwidth/(2.*xppmm)*
			       (1./tsc[tsi-1] - 1./tscale));
		InvalidateRect(hWnd, NULL, TRUE);
	    }
	    break;
	  case VK_DOWN: /* <down arrow>: zoom out (decrease time scale) */
	    if (tsi > 0) {
		tscale = tsc[--tsi];
		/* Adjust time of left edge such that the time of
		   the center of the window will be unchanged. */
		t0 += (WFDB_Time)(sps*wwidth/(2.*xppmm)*
			       (1./tsc[tsi+1] - 1./tscale));
		if (t0 < 0L) t0 = 0L;
		InvalidateRect(hWnd, NULL, TRUE);
	    }
	    break;
	  default:
	    break;
	}
	
      case WM_CHAR:
	switch (wParam) {
	  case '+':     /* increase amplitude scale */
	    if (vsi < MAXVSI) {
		vscale = vsc[++vsi];
		InvalidateRect(hWnd, NULL, TRUE);
	    }
	    break;
	  case '-':     /* decrease amplitude scale */
	    if (vsi > 0) {
		vscale = vsc[--vsi];
		InvalidateRect(hWnd, NULL, TRUE);
	    }
	    break;
	  default:
	    break;
	}
	break;
	
      case WM_PAINT:
	paint_main_window(hWnd);
	break;
	
      case WM_DESTROY:
	DeleteObject(signal_pen);
	DeleteObject(grid_pen);
	DeleteObject(pgrid_pen);
	DeleteObject(marker_pen);
	if (hLibrary >= 32) FreeLibrary(hLibrary);
	WinHelp(hWnd, "wview.hlp", HELP_QUIT, NULL);
	PostQuitMessage(0);
	break;
	
      default:
	return (DefWindowProc(hWnd, message, wParam, lParam));
    }
    return (NULL);
}

BOOL FAR PASCAL Choose(hDlg, message, wParam, lParam)
HWND hDlg;
unsigned message;
WORD wParam;
LONG lParam;
{
    static char rtemp[200], *r, *s, *t;
    
    switch (message) {
      case WM_INITDIALOG:
	SetDlgItemText(hDlg, IDD_RECORD, record);
	SetDlgItemText(hDlg, IDD_ANNOTATOR, annotator);
	if ((t = getwfdb()) != wfdbpath) {
	    strncpy(wfdbpath, t, sizeof(wfdbpath)-1);
	    setwfdb(wfdbpath);	/* *** 16 July 2003 (GBM).  This call is
				   necessary for WFDB 10.3.9 and later, in
				   which setwfdb keeps its own copy of the
				   WFDB path. */
	}
	SetDlgItemText(hDlg, IDD_WFDBPATH, wfdbpath);
	SetDlgItemText(hDlg, IDD_WFDBCAL, cfname);
	return (TRUE);
	
      case WM_COMMAND:
	switch (wParam) {
	  case IDOK:
	    GetDlgItemText(hDlg, IDD_RECORD, rtemp, sizeof(rtemp)-1);
	    for (t = rtemp; t < rtemp+20 && *t == ' '; t++) ;
	    for (r = record; t < rtemp+20 && *t && *t != ' '; *r++ = *t++) ;
	    if (r > record) *r = '\0';
	    GetDlgItemText(hDlg, IDD_ANNOTATOR, rtemp, sizeof(rtemp)-1);
	    for (t = rtemp; t < rtemp+20 && *t == ' '; t++) ;
	    for (s = annotator; t < rtemp+20 && *t && *t != ' '; *s++ = *t++) ;
	    if (s > annotator) *s = '\0';
	    GetDlgItemText(hDlg, IDD_WFDBPATH, rtemp, sizeof(rtemp)-1);
	    for (t = rtemp; t < rtemp+200 && *t == ' '; t++) ;
	    if (strcmp(wfdbpath, t)) {
		strcpy(wfdbpath, t);
		setwfdb(wfdbpath);
	    }
	    GetDlgItemText(hDlg, IDD_WFDBCAL, rtemp, sizeof(rtemp)-1);
	    for (t = rtemp; t < rtemp+200 && *t == ' '; t++) ;
	    if (strcmp(cfname, t)) {
		strcpy(cfname, t);
		calopen(cfname);
	    }
	    if (r > record || s >  annotator) { open_record(); nann = 0; }
	    if (s > annotator) open_annotation_file();
	    EndDialog(hDlg, 1);
	    return (TRUE);
	    
	  case IDCANCEL:
	    EndDialog(hDlg, 0);
	    return (TRUE);
	    
	  default:
	    return (FALSE);
	}
	break;
    }
    return (FALSE);
}

int strnsubtyp(s)
char *s;
{
    int i = 0;
    
    while (*s) {
	i <<= 1;
	switch (*s) {
	  case 'n':     i |= 1; break;
	  case 'u':     i |= 0x11; break;
	  case 'U':     return (-1);
	  default:      break;
	}
	s++;
    }
    return (i);
}

static int match_anntyp, match_subtyp, match_chan, match_num, match_aux;

void asparse(char *s, WFDB_Annotation *annp)
{
    match_anntyp = match_subtyp = match_chan = match_num = match_aux = FALSE;
    if ((annp->anntyp = strann(s)) == NOTQRS) {
	switch (*s) {
	  case 'c':     /* search for a signal quality annotation */
	  case 'n':
	  case 'u':
	  case 'U':
	    annp->anntyp = NOISE;
	    annp->subtyp = strnsubtyp(s);
	    match_anntyp = match_subtyp = TRUE;
	    break;
	  case '*':     /* accept any annotation as a match */
	  case '\0':
	    break;
	  default:      /* match aux field only */
	    *(s-1) = strlen(s);
	    annp->aux = s-1;
	    match_aux = TRUE;
	    break;
	}
    }
    else
	match_anntyp = TRUE;
}

int match(WFDB_Annotation *annp, WFDB_Annotation*temp)
{
    return ((!match_anntyp || annp->anntyp == temp->anntyp) &&
	    (!match_subtyp || annp->subtyp == temp->subtyp) &&
	    /*          (!match_chan   || annp->chan   == temp->chan  ) &&
			(!match_num    || annp->num    == temp->num   ) &&  */
	    (!match_aux    || (annp->aux &&
			       strncmp(annp->aux+1,temp->aux+1,*(temp->aux)) == 0)));
}

static char fns[20], fps[20];

int find_next()
{
    WFDB_Annotation annot, target;
    
    if (fns[1] == '\0') return (-1);
    asparse(fns+1, &target);
    while (getann(0, &annot) == 0)
	if (match(&annot, &target) && annot.time > t1) {
	    t0 = annot.time - (t1-t0)/2L;
	    if (t0 < 0L) t0 = 0L;
	    return (1);
	}
    return (0);
}

int find_previous()
{
    WFDB_Annotation annot, target;
    WFDB_Time ts = -1L;
    
    if (fps[1] == '\0') return (-1);
    asparse(fps+1, &target);
    iannsettime(0L);
    while (getann(0, &annot) == 0 && annot.time < t0)
	if (match(&annot, &target))
	    ts = annot.time;
    if (ts >= 0L) {
	t0 = ts - (t1-t0)/2L;
	if (t0 < 0L) t0 = 0L;
	return (1);
    }
    return (0);
}

BOOL FAR PASCAL Find(hDlg, message, wParam, lParam)
HWND hDlg;
unsigned message;
WORD wParam;
LONG lParam;
{
    static char rcs[20];
    static WORD find_mode = IDD_RECENTER;
    
    switch (message) {
      case WM_INITDIALOG:
	CheckRadioButton(hDlg, IDD_FINDN, IDD_RECENTER, find_mode);
	SetDlgItemText(hDlg, IDD_FNTYPE, fns+1);
	SetDlgItemText(hDlg, IDD_FPTYPE, fps+1);
	SetDlgItemText(hDlg, IDD_RCTIME, rcs);
	return (TRUE);
	
      case WM_COMMAND:
	switch (wParam) {
	  case IDD_FINDN:
	  case IDD_FINDP:
	  case IDD_RECENTER:
	    CheckRadioButton(hDlg, IDD_FINDN, IDD_RECENTER, find_mode=wParam);
	    break;
	  case IDOK:
	    switch (find_mode) {
	      case IDD_FINDN:
		GetDlgItemText(hDlg, IDD_FNTYPE, fns+1, sizeof(fns)-2);
		if (find_next() > 0) {
		    EndDialog(hDlg, 1);
		    return (TRUE);
		}
		return (FALSE);
		
	      case IDD_FINDP:
		GetDlgItemText(hDlg, IDD_FPTYPE, fps+1, sizeof(fps)-2);
		if (find_previous() > 0) {
		    EndDialog(hDlg, 1);
		    return (TRUE);
		}
		return (FALSE);
		
	      case IDD_RECENTER:
		GetDlgItemText(hDlg, IDD_RCTIME, rcs, sizeof(rcs)-1);
		t0 = strtim(rcs) - (t1-t0)/2L;
		if (t0 < 0L) t0 = 0L;
		EndDialog(hDlg, 1);
		return (TRUE);
	    }
	    break;
	  case IDCANCEL:
	    EndDialog(hDlg, 0);
	    return (TRUE);
	    
	  default:
	    return (FALSE);
	}
	break;
    }
    return (FALSE);
}

BOOL FAR PASCAL About(hDlg, message, wParam, lParam)
HWND hDlg;
unsigned message;
WORD wParam;
LONG lParam;
{
    switch (message) {
      case WM_INITDIALOG:
	return (TRUE);
	
      case WM_COMMAND:
	if (wParam == IDOK || wParam == IDCANCEL) {
	    EndDialog(hDlg, TRUE);
	    return (TRUE);
	}
	break;
    }
    return (FALSE);
}

HDC GetPrinterDC(char *device)
{
    char devspec[80], *driver, *output;
    
    GetProfileString("devices", device, "", devspec, sizeof(devspec));
    if ((driver = strtok(devspec, ", ")) &&
	(output = strtok(NULL, ", ")))
	return (CreateDC(driver, device, output, NULL));
    else
	return ((HDC)0);
}

typedef VOID (FAR PASCAL *DEVMODEPROC) (HWND, HANDLE, LPSTR, LPSTR);

void printer_setup(HWND hWnd, char *printer)
{
    static char driver[16], drivername[20], *output;
    DEVMODEPROC devmodeproc;
    
    GetProfileString("devices", printer, "", driver, sizeof(driver));
    output = strtok(driver, ", ");
    sprintf(drivername, "%s.DRV", driver);
    if (hLibrary >= 32) FreeLibrary(hLibrary);
    hLibrary = LoadLibrary(drivername);
    if (hLibrary >= 32) {
	devmodeproc = (DEVMODEPROC)GetProcAddress(hLibrary, "DEVICEMODE");
	devmodeproc(hWnd, hLibrary, printer, output);
    }
}

WFDB_Time pt0, pt1;
WORD collate = 1, ncopies = 1, print_to_file = 0;

BOOL FAR PASCAL Print(hDlg, message, wParam, lParam)
HWND hDlg;
unsigned message;
WORD wParam;
LONG lParam;
{
    unsigned int i;
    static char *adp, alldev[4096], curdev[80], *printer, prtst[40],
    *driver, *output, cprdevstr[80], *tprinter;
    static FARPROC lpProcPrintOptions;
    static WORD print_range = IDD_PRWIN, tprint_range = IDD_PRWIN;
    HWND hlist;
    
    switch (message) {
      case WM_INITDIALOG:
	CheckRadioButton(hDlg, IDD_PRREC, IDD_PRSEG, print_range);
	EnableWindow(GetDlgItem(hDlg, IDD_PRFLABEL), print_range == IDD_PRSEG);
	EnableWindow(GetDlgItem(hDlg, IDD_PRFROM), print_range == IDD_PRSEG);
	EnableWindow(GetDlgItem(hDlg, IDD_PRTLABEL), print_range == IDD_PRSEG);
	EnableWindow(GetDlgItem(hDlg, IDD_PRTO), print_range == IDD_PRSEG);
	if (print_range == IDD_PRSEG) {
	    SetDlgItemText(hDlg, IDD_PRFROM, mstimstr(pt0));
	    SetDlgItemText(hDlg, IDD_PRTO, mstimstr(pt1));
	}
	CheckDlgButton(hDlg, IDD_PFILE, print_to_file);
	CheckDlgButton(hDlg, IDD_PCOLLATE, collate);
	SetDlgItemInt(hDlg, IDD_PCOPIES, ncopies, FALSE);
	hlist = GetDlgItem(hDlg, IDD_PPRINTER);
	if (printer == NULL) {
	    GetProfileString("windows", "device", "...", curdev,
			     sizeof(curdev));
	    if ((printer = strtok(curdev, ",")) &&
		(driver = strtok(NULL, ", ")) &&
		(output = strtok(NULL, ", ")))
		sprintf(cprdevstr, "%s on %s", printer, output);
	}
	if (*cprdevstr) {
	    SendMessage(hlist, CB_ADDSTRING, 0, (LONG)(LPSTR)cprdevstr);
	    SendMessage(hlist, CB_SETCURSEL, 0, 0L);
	}
	GetProfileString("devices", NULL, "", alldev, sizeof(alldev));
	for (adp = alldev; *adp; adp += strlen(adp) + 1) {
	    char devspec[80], prdevstr[80];
	    
	    GetProfileString("devices", adp, "", devspec, sizeof(devspec));
	    if ((driver = strtok(devspec, ", ")) &&
		(output = strtok(NULL, ", "))) {
		sprintf(prdevstr, "%s on %s", adp, output);
		if (strcmp(prdevstr, cprdevstr))
		    SendMessage(hlist, CB_ADDSTRING, 0, (LONG)(LPSTR)prdevstr);
	    }
	}
	return (TRUE);
	
      case WM_COMMAND:
	switch (wParam) {
	  case IDD_POPTIONS:
	    lpProcPrintOptions = MakeProcInstance(PrintOptions, hInst);
	    DialogBox(hInst, "PrintOptionsBox", hDlg, lpProcPrintOptions);
	    FreeProcInstance(lpProcPrintOptions);
	    break;
	  case IDD_PRSEG:
	    if (!IsWindowEnabled(GetDlgItem(hDlg, IDD_PRFROM))) {
		EnableWindow(GetDlgItem(hDlg, IDD_PRFLABEL), TRUE);
		EnableWindow(GetDlgItem(hDlg, IDD_PRFROM), TRUE);
		EnableWindow(GetDlgItem(hDlg, IDD_PRTLABEL), TRUE);
		EnableWindow(GetDlgItem(hDlg, IDD_PRTO), TRUE);
	    }
	    CheckRadioButton(hDlg, IDD_PRREC, IDD_PRSEG, tprint_range=wParam);
	    break;
	  case IDD_PRWIN:
	  case IDD_PRREC:
	    if (IsWindowEnabled(GetDlgItem(hDlg, IDD_PRFROM))) {
		EnableWindow(GetDlgItem(hDlg, IDD_PRFLABEL), FALSE);
		EnableWindow(GetDlgItem(hDlg, IDD_PRFROM), FALSE);
		EnableWindow(GetDlgItem(hDlg, IDD_PRTLABEL), FALSE);
		EnableWindow(GetDlgItem(hDlg, IDD_PRTO), FALSE);
	    }
	    CheckRadioButton(hDlg, IDD_PRREC, IDD_PRSEG, tprint_range=wParam);
	    break;
	  case IDD_PSETUP:
	    GetDlgItemText(hDlg, IDD_PPRINTER, curdev, sizeof(curdev));
	    for (adp = alldev; *adp; adp += strlen(adp) + 1)
		if (strncmp(curdev, adp, strlen(adp)) == 0)
		    tprinter = adp;

⌨️ 快捷键说明

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