void DrawStatusValue (HDC hDC, int iEltOffset, FLOAT eValue, BOOL bForceRedraw) /* Called By: StatusDrawTime, StatusDrawLast, StatusDrawAvg, StatusDrawMin, StatusDrawMax. */ { // DrawStatusValue RECT rectValue ; TCHAR szValue [20] ; if (!bForceRedraw && eValue == StatusData.aElts[iEltOffset].eValue) return ; StatusData.aElts[iEltOffset].eValue = eValue ; rectValue.left = StatusData.aElts[iEltOffset].xValuePos ; rectValue.top = StatusTopMargin () + ThreeDPad + 1; rectValue.right = rectValue.left + StatusData.sizeValue.cx ; rectValue.bottom = rectValue.top + StatusData.sizeValue.cy ; if (eValue > eStatusValueMax) { if (eValue > eStatusValueTooLarge) { lstrcpy (szValue, szValueTooHigh) ; } else { TSPRINTF (szValue, (eValue > eStatusLargeValueMax) ? szStatusLargeValueFormat : szStatusMediumnValueFormat, eValue) ; ConvertDecimalPoint (szValue) ; } } else if (eValue < -eStatusValueMax) lstrcpy (szValue, szValueTooLow) ; else { TSPRINTF (szValue, szStatusValueFormat, eValue) ; ConvertDecimalPoint (szValue) ; } ExtTextOut (hDC, rectValue.right, rectValue.top, ETO_OPAQUE, &rectValue, szValue, lstrlen (szValue), NULL) ; } // DrawStatusValue
va_dcl #else NLM_EXTERN MsgAnswer CDECL Nlm_Message (Nlm_Int2 sevkey, const char *fmt, ...) #endif { const char *caption = GetProgramName(); MsgKey key = KEY_OK; ErrSev sev = SEV_INFO; MsgAnswer ans; if (sevkey < KEY_other) { key = (MsgKey) sevkey; } else { switch (sevkey) { case MSG_ERROR : Nlm_Beep(); sev = SEV_ERROR; break; case MSG_FATAL : Nlm_Beep(); sev = SEV_MAX; break; case MSG_POSTERR : Nlm_Beep(); sev = SEV_ERROR; key = KEY_NONE; break; case MSG_POST : key = KEY_NONE; break; } } {{ const Nlm_Char PNTR scratch_str = NULL; Nlm_Char PNTR message; TSPRINTF(scratch_str, fmt); message = Nlm_StringSave(scratch_str); ans = message ? MsgAlertStr(key, sev, caption, message) : ANS_NONE; Nlm_MemFree(message); }} if (sevkey == MSG_FATAL) AbnormalExit(1); return ans; }
va_dcl #else NLM_EXTERN MsgAnswer CDECL Nlm_MsgAlert (MsgKey key, ErrSev sev, const char *caption, const char *fmt, ...) #endif { MsgAnswer ans; const Nlm_Char PNTR scratch_str = NULL; Nlm_Char PNTR message; TSPRINTF(scratch_str, fmt); message = Nlm_StringSave(scratch_str); ans = message ? MsgAlertStr(key, sev, caption, message) : ANS_NONE; Nlm_MemFree(message); return ans; }
void DrawLegendItem (PLEGEND pLegend, PLINESTRUCT pLine, int yPos, HDC hDC) { TCHAR szValue [256] ; TCHAR szInstance [256] ; TCHAR szParent [256] ; TCHAR szNoName[4] ; szNoName[0] = szNoName[1] = szNoName[2] = TEXT('-') ; szNoName[3] = TEXT('\0') ; //=============================// // Determine Instance, Parent // //=============================// // It's possible that there will be no instance, therefore // the lnInstanceName would be NULL. if (pLine->lnObject.NumInstances > 0) { // Test for the parent object instance name title index. // If there is one, it implies that there will be a valid // Parent Object Name and a valid Parent Object Instance Name. // If the Parent Object title index is 0 then // just display the instance name. lstrcpy (szInstance, pLine->lnInstanceName) ; if (pLine->lnInstanceDef.ParentObjectTitleIndex && pLine->lnPINName) { // Get the Parent Object Name. lstrcpy (szParent, pLine->lnPINName) ; } else { lstrcpy (szParent, szNoName) ; } } else { lstrcpy (szInstance, szNoName) ; lstrcpy (szParent, szNoName) ; } //=============================// // Draw Color // //=============================// DrawColorCol (pLegend, pLine, LegendColorCol, hDC, yPos) ; //=============================// // Draw Scale/Value // //=============================// if (pLegend->iLineType == LineTypeChart) { if (pLine->eScale < (FLOAT) 1.0) { TSPRINTF (szValue, TEXT("%7.7f"), pLine->eScale) ; } else { TSPRINTF (szValue, TEXT("%10.3f"), pLine->eScale) ; } ConvertDecimalPoint (szValue) ; } else { FLOAT tempAlertValue ; tempAlertValue = pLine->eAlertValue ; if (tempAlertValue < (FLOAT) 0.0) { tempAlertValue = -tempAlertValue ; } if (tempAlertValue >= (FLOAT) 10000.0) { if (tempAlertValue < (FLOAT) 1.0E+8) { TSPRINTF (szValue, TEXT("%c%10.0f"), pLine->bAlertOver ? TEXT('>') : TEXT('<'), pLine->eAlertValue) ; } else { TSPRINTF (szValue, TEXT("%c%10.3e"), pLine->bAlertOver ? TEXT('>') : TEXT('<'), pLine->eAlertValue) ; } ConvertDecimalPoint (szValue) ; } else { TSPRINTF (szValue, TEXT("%c%10.4f"), pLine->bAlertOver ? TEXT('>') : TEXT('<'), pLine->eAlertValue) ; ConvertDecimalPoint (szValue) ; } } SetTextAlign (hDC, TA_TOP) ; DrawLegendCol (pLegend, LegendScaleCol, hDC, yPos, szValue) ; //=============================// // Draw Counter // //=============================// DrawLegendCol (pLegend, LegendCounterCol, hDC, yPos, pLine->lnCounterName) ; //=============================// // Draw Instance // //=============================// DrawLegendCol (pLegend, LegendInstanceCol, hDC, yPos, szInstance) ; //=============================// // Draw Parent // //=============================// DrawLegendCol (pLegend, LegendParentCol, hDC, yPos, szParent) ; //=============================// // Draw Object // //=============================// DrawLegendCol (pLegend, LegendObjectCol, hDC, yPos, pLine->lnObjectName) ; //=============================// // Draw System // //=============================// DrawLegendCol (pLegend, LegendSystemCol, hDC, yPos, pLine->lnSystemName) ; }
// This routine opens the export file and put in the header info. // It is used by ExportChart, ExportAlert, & ExportReport. INT ExportFileOpen (HWND hWnd, HANDLE *phFile, int IntervalMSecs, LPTSTR *ppFileName) { CHAR TempBuff [LongTextLen] ; TCHAR UnicodeBuff [LongTextLen] ; TCHAR UnicodeBuff1 [MiscTextLen] ; SYSTEMTIME SystemTime ; int StringLen ; INT ErrCode = 0 ; FLOAT eIntervalSecs ; // defined and setup in status.c extern TCHAR szCurrentActivity [] ; extern TCHAR szStatusFormat [] ; *phFile = 0 ; if (!FileGetName (hWnd, IDS_EXPORTFILE, UnicodeBuff)) { // user cancel goto Exit0 ; } *ppFileName = StringAllocate (UnicodeBuff) ; // open the file.. if (!(*phFile = FileHandleCreate (UnicodeBuff))) { // can't open the file ErrCode = ERR_CANT_OPEN ; goto Exit0 ; } // export header StringLoad (IDS_REPORT_HEADER, UnicodeBuff) ; ConvertUnicodeStr (TempBuff, UnicodeBuff) ; StringLen = strlen (TempBuff) ; ConvertUnicodeStr (&TempBuff[StringLen], LocalComputerName) ; strcat (TempBuff, LineEndStr) ; if (!FileWrite (*phFile, TempBuff, strlen(TempBuff))) { ErrCode = ERR_EXPORT_FILE ; goto Exit0 ; } // export today's date time GetLocalTime (&SystemTime) ; StringLoad (IDS_EXPORT_DATE, UnicodeBuff) ; StringLen = lstrlen (UnicodeBuff) ; UnicodeBuff[StringLen] = TEXT(':') ; UnicodeBuff[StringLen+1] = TEXT(' ') ; SystemTimeDateString (&SystemTime, &UnicodeBuff[StringLen+2]) ; ConvertUnicodeStr (TempBuff, UnicodeBuff) ; strcat (TempBuff, LineEndStr) ; if (!FileWrite (*phFile, TempBuff, strlen(TempBuff))) { ErrCode = ERR_EXPORT_FILE ; goto Exit0 ; } StringLoad (IDS_EXPORT_TIME, UnicodeBuff) ; StringLen = lstrlen (UnicodeBuff) ; UnicodeBuff[StringLen] = TEXT(':') ; UnicodeBuff[StringLen+1] = TEXT(' ') ; SystemTimeTimeString (&SystemTime, &UnicodeBuff[StringLen+2], FALSE) ; ConvertUnicodeStr (TempBuff, UnicodeBuff) ; strcat (TempBuff, LineEndStr) ; if (!FileWrite (*phFile, TempBuff, strlen(TempBuff))) { ErrCode = ERR_EXPORT_FILE ; goto Exit0 ; } // export data source TSPRINTF (UnicodeBuff, szStatusFormat, PlayingBackLog () ? PlaybackLog.szFileTitle : szCurrentActivity) ; ConvertUnicodeStr (TempBuff, UnicodeBuff) ; strcat (TempBuff, LineEndStr) ; if (!FileWrite (*phFile, TempBuff, strlen(TempBuff))) { ErrCode = ERR_EXPORT_FILE ; goto Exit0 ; } if (!PlayingBackLog()) { eIntervalSecs = (FLOAT)IntervalMSecs / (FLOAT) 1000.0 ; StringLoad (IDS_CHARTINT_FORMAT, UnicodeBuff1) ; TSPRINTF (UnicodeBuff, UnicodeBuff1, eIntervalSecs) ; ConvertDecimalPoint (UnicodeBuff) ; ConvertUnicodeStr (TempBuff, UnicodeBuff) ; strcat (TempBuff, LineEndStr) ; if (!FileWrite (*phFile, TempBuff, strlen(TempBuff))) { ErrCode = ERR_EXPORT_FILE ; goto Exit0 ; } } else { // export the log start and stop date/time StringLoad (IDS_START_TEXT, UnicodeBuff) ; StringLen = lstrlen (UnicodeBuff) ; LogPositionSystemTime (&(PlaybackLog.StartIndexPos), &SystemTime) ; SystemTimeDateString (&SystemTime, &UnicodeBuff[StringLen]) ; StringLen = lstrlen (UnicodeBuff) ; UnicodeBuff[StringLen] = TEXT(' ') ; StringLen++ ; SystemTimeTimeString (&SystemTime, &UnicodeBuff[StringLen], FALSE) ; ConvertUnicodeStr (TempBuff, UnicodeBuff) ; strcat (TempBuff, LineEndStr) ; if (!FileWrite (*phFile, TempBuff, strlen(TempBuff))) { ErrCode = ERR_EXPORT_FILE ; goto Exit0 ; } StringLoad (IDS_STOP_TEXT, UnicodeBuff) ; StringLen = lstrlen (UnicodeBuff) ; LogPositionSystemTime (&(PlaybackLog.StopIndexPos), &SystemTime) ; SystemTimeDateString (&SystemTime, &UnicodeBuff[StringLen]) ; StringLen = lstrlen (UnicodeBuff) ; UnicodeBuff[StringLen] = TEXT(' ') ; StringLen++ ; SystemTimeTimeString (&SystemTime, &UnicodeBuff[StringLen], FALSE) ; ConvertUnicodeStr (TempBuff, UnicodeBuff) ; strcat (TempBuff, LineEndStr) ; if (!FileWrite (*phFile, TempBuff, strlen(TempBuff))) { ErrCode = ERR_EXPORT_FILE ; goto Exit0 ; } if (hWnd == hWndAlert) { eIntervalSecs = (FLOAT)IntervalMSecs / (FLOAT) 1000.0 ; StringLoad (IDS_CHARTINT_FORMAT, UnicodeBuff1) ; TSPRINTF (UnicodeBuff, UnicodeBuff1, eIntervalSecs) ; ConvertDecimalPoint (UnicodeBuff) ; ConvertUnicodeStr (TempBuff, UnicodeBuff) ; strcat (TempBuff, LineEndStr) ; if (!FileWrite (*phFile, TempBuff, strlen(TempBuff))) { ErrCode = ERR_EXPORT_FILE ; goto Exit0 ; } } } return (0) ; Exit0: return (ErrCode) ; } // ExportFileOpen
//void static OnCreate (HWND hWnd) void OnVBarCreate (HWND hWnd) /* Effect: Perform any actions needed when a status window is created. In particular, set the instance data to initial values, determine the size and placement of the various elements of the status display. Called By: GraphStatusWndProc only, in response to a WM_CREATE message. */ { // OnCreate TCHAR szValue [20] ; HDC hDC ; int iLen ; int i ; hDC = hVBarDC = GetDC (hWnd) ; SelectFont (hDC, hFontScales) ; SetBkColor (hDC, ColorBtnFace) ; SetTextAlign (hDC, TA_RIGHT | TA_TOP) ; //=============================// // Load Text Labels // //=============================// StringLoad (IDS_STATUSLAST, StatusData.aElts[StatusLastElt].szText) ; StringLoad (IDS_STATUSAVG, StatusData.aElts[StatusAvgElt].szText) ; StringLoad (IDS_STATUSMIN, StatusData.aElts[StatusMinElt].szText) ; StringLoad (IDS_STATUSMAX, StatusData.aElts[StatusMaxElt].szText) ; StringLoad (IDS_STATUSTIME, StatusData.aElts[StatusTimeElt].szText) ; //=============================// // Determine Status Height // //=============================// StatusData.yHeight = StatusTopMargin () + StatusBottomMargin () + FontHeight (hDC, TRUE) + 2 * ThreeDPad ; //=============================// // Set position/size of elts // //=============================// // Determine the bounding box for each status value by using a max value. iLen = TSPRINTF (szValue, szStatusLargeValueFormat, -eStatusValueMax) ; GetTextExtentPoint (hDC, szValue, lstrlen(szValue), &StatusData.sizeValue) ; for (i = 0 ; i < StatusNumElts ; i++) { // for StatusData.aElts[i].eValue = (FLOAT) 0.0 ; if (i) StatusData.aElts[i].xTextPos = StatusTextMargin () + StatusData.aElts[i - 1].xValuePos + StatusData.sizeValue.cx ; else StatusData.aElts[i].xTextPos = StatusLeftMargin () ; StatusData.aElts[i].xValuePos = StatusData.aElts[i].xTextPos + StatusValueMargin () + TextWidth (hDC, StatusData.aElts[i].szText) ; } // for } // OnCreate
BOOL FAR PASCAL GraphOptionDlg(HWND hDlg, WORD msg, DWORD wParam, LONG lParam) /***************************************************************************/ { static GRAPH_OPTIONS goLocalCopy ; INT iTimeMilliseconds ; TCHAR szBuff[MiscTextLen] ; PGRAPHSTRUCT lgraph; lParam ; lgraph = pGraphs; switch(msg) { case WM_INITDIALOG: dwCurrentDlgID = HC_PM_idDlgOptionChart ; // Init the Radio button, Check boxes and text fields. goLocalCopy.iGraphOrHistogram = lgraph->gOptions.iGraphOrHistogram ; if (lgraph->gOptions.iGraphOrHistogram == LINE_GRAPH) CheckRadioButton(hDlg, ID_GRAPH, ID_HISTOGRAM, ID_GRAPH) ; else CheckRadioButton(hDlg, ID_GRAPH, ID_HISTOGRAM, ID_HISTOGRAM) ; CheckDlgButton(hDlg, ID_LEGEND, lgraph->gOptions.bLegendChecked) ; if (!(lgraph->gOptions.bLegendChecked)) { // can't display valuebar w/o legend DialogEnable (hDlg, IDD_CHARTOPTIONSVALUEBAR, FALSE) ; } CheckDlgButton(hDlg, ID_LABELS, lgraph->gOptions.bLabelsChecked) ; CheckDlgButton(hDlg, ID_VERT_GRID, lgraph->gOptions.bVertGridChecked) ; CheckDlgButton(hDlg, ID_HORZ_GRID, lgraph->gOptions.bHorzGridChecked) ; CheckDlgButton(hDlg, IDD_CHARTOPTIONSVALUEBAR, lgraph->gOptions.bStatusBarChecked) ; TSPRINTF(szBuff, TEXT("%d"), lgraph->gOptions.iVertMax) ; SendDlgItemMessage(hDlg, ID_VERT_MAX, WM_SETTEXT, 0, (LONG) szBuff) ; TSPRINTF(szBuff, TEXT("%3.3f"), lgraph->gOptions.eTimeInterval) ; ConvertDecimalPoint (szBuff); SendDlgItemMessage(hDlg, IDD_CHARTOPTIONSINTERVAL, WM_SETTEXT, 0, (LONG) szBuff) ; // Pickup a local copy of the Graph Options. goLocalCopy = lgraph->gOptions ; LocalManualRefresh = lgraph->bManualRefresh ; CheckRadioButton (hDlg, IDD_CHARTOPTIONSMANUALREFRESH, IDD_CHARTOPTIONSPERIODIC, LocalManualRefresh ? IDD_CHARTOPTIONSMANUALREFRESH : IDD_CHARTOPTIONSPERIODIC) ; if (lgraph->bManualRefresh) { DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVALTEXT, FALSE) ; DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVAL, FALSE) ; } else { DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVALTEXT, TRUE) ; DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVAL, TRUE) ; } EditSetLimit (GetDlgItem(hDlg, ID_VERT_MAX), sizeof(szBuff) / sizeof(TCHAR) - 1) ; EditSetLimit (GetDlgItem(hDlg, IDD_CHARTOPTIONSINTERVAL), ShortTextLen) ; WindowCenter (hDlg) ; return(TRUE); case WM_COMMAND: switch(LOWORD(wParam)) { case ID_VERT_MAX: if (HIWORD(wParam) == EN_CHANGE) { DialogText(hDlg, ID_VERT_MAX, szBuff) ; swscanf(szBuff, TEXT("%d"), &goLocalCopy.iVertMax) ; } break ; case IDD_CHARTOPTIONSINTERVAL: if (HIWORD(wParam) == EN_CHANGE) { goLocalCopy.eTimeInterval = DialogFloat (hDlg, IDD_CHARTOPTIONSINTERVAL, NULL) ; } break ; case IDD_CHARTOPTIONSPERIODIC: case IDD_CHARTOPTIONSMANUALREFRESH: // check if the Manual refresh is currently checked. // Then toggle the ManualRefresh button LocalManualRefresh = IsDlgButtonChecked (hDlg, IDD_CHARTOPTIONSMANUALREFRESH) ; CheckRadioButton (hDlg, IDD_CHARTOPTIONSMANUALREFRESH, IDD_CHARTOPTIONSPERIODIC, LocalManualRefresh ? IDD_CHARTOPTIONSPERIODIC : IDD_CHARTOPTIONSMANUALREFRESH) ; // gray out time interval if necessary... DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVALTEXT, LocalManualRefresh) ; DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVAL, LocalManualRefresh) ; LocalManualRefresh = !LocalManualRefresh ; break ; case IDD_CHARTOPTIONSVALUEBAR: if (goLocalCopy.bStatusBarChecked == TRUE) goLocalCopy.bStatusBarChecked = FALSE ; else goLocalCopy.bStatusBarChecked = TRUE ; break ; case ID_LEGEND: if (goLocalCopy.bLegendChecked == TRUE) goLocalCopy.bLegendChecked = FALSE ; else goLocalCopy.bLegendChecked = TRUE ; DialogEnable (hDlg, IDD_CHARTOPTIONSVALUEBAR, goLocalCopy.bLegendChecked) ; break ; case ID_LABELS: if (goLocalCopy.bLabelsChecked == TRUE) goLocalCopy.bLabelsChecked = FALSE ; else goLocalCopy.bLabelsChecked = TRUE ; break ; case ID_VERT_GRID: if (goLocalCopy.bVertGridChecked == TRUE) goLocalCopy.bVertGridChecked = FALSE ; else goLocalCopy.bVertGridChecked = TRUE ; break ; case ID_HORZ_GRID: if (goLocalCopy.bHorzGridChecked == TRUE) goLocalCopy.bHorzGridChecked = FALSE ; else goLocalCopy.bHorzGridChecked = TRUE ; break ; case ID_GRAPH: case ID_HISTOGRAM: if (goLocalCopy.iGraphOrHistogram == BAR_GRAPH) { goLocalCopy.iGraphOrHistogram = LINE_GRAPH ; } else { goLocalCopy.iGraphOrHistogram = BAR_GRAPH ; } CheckRadioButton(hDlg, ID_GRAPH, ID_HISTOGRAM, goLocalCopy.iGraphOrHistogram == LINE_GRAPH ? ID_GRAPH : ID_HISTOGRAM) ; break ; case IDOK: // verify some numeric entries first if (goLocalCopy.iVertMax > MAX_VERTICAL || goLocalCopy.iVertMax < MIN_VERTICAL) { DlgErrorBox (hDlg, ERR_BADVERTMAX) ; SetFocus (DialogControl (hDlg, ID_VERT_MAX)) ; EditSetTextEndPos (hDlg, ID_VERT_MAX) ; return (FALSE) ; break ; } if (goLocalCopy.eTimeInterval > MAX_INTERVALSEC || goLocalCopy.eTimeInterval < MIN_INTERVALSEC) { DlgErrorBox (hDlg, ERR_BADTIMEINTERVAL) ; SetFocus (DialogControl (hDlg, IDD_CHARTOPTIONSINTERVAL)) ; EditSetTextEndPos (hDlg, IDD_CHARTOPTIONSINTERVAL) ; return (FALSE) ; break ; } // We need to send a size message to the main window // so it can setup the redraw of the graph and legend. lgraph->gOptions.bLegendChecked = goLocalCopy.bLegendChecked ; lgraph->gOptions.bStatusBarChecked = goLocalCopy.bStatusBarChecked ; if (lgraph->gOptions.eTimeInterval != goLocalCopy.eTimeInterval && !LocalManualRefresh) { iTimeMilliseconds = (INT) (goLocalCopy.eTimeInterval * (FLOAT) 1000.0) ; pGraphs->gInterval = iTimeMilliseconds ; lgraph->bManualRefresh = LocalManualRefresh ; } else if (LocalManualRefresh != lgraph->bManualRefresh) { ToggleGraphRefresh (hWndGraph) ; } // Assign the local copy of the graph options to the // global copy. lgraph->gOptions = goLocalCopy ; // SizeGraphComponents (hWndGraph) ; // WindowInvalidate (hWndGraph) ; dwCurrentDlgID = 0 ; EndDialog (hDlg, 1) ; return (TRUE) ; break ; case IDCANCEL: dwCurrentDlgID = 0 ; EndDialog(hDlg,0); return(TRUE); case ID_HELP: CallWinHelp (dwCurrentDlgID) ; break ; default: break; } break; default: break; } return(FALSE); }