/*********************************************************************** * * FUNCTION: PrvSetTimeField * * DESCRIPTION: Set the given field's text to show a time and day of week. * * PARAMETERS: frm - a pointer to the form containing the field to set * timeFieldID - the ID of the field to set * timeHandle - the handle used for storing the text for this field * time - a pointer to the date and time to show in the field * drawField - whether to draw field after setting its text * * RETURNED: nothing * * REVISION HISTORY: * Name Date Description * ---- ---- ----------- * peter 3/7/00 Initial Revision * ***********************************************************************/ static void PrvSetTimeField(FormType * frm, UInt16 timeFieldID, MemHandle timeHandle, DateTimeType *time, Boolean drawField) { FieldType * timeFieldP; Char * timeString, * timeZoneDOWFormatString, * currentDOWString; MemHandle resHandle; TimeFormatType timeFormat; // Format to display time in timeFormat = (TimeFormatType)PrefGetPreference(prefTimeFormat); timeString = MemHandleLock(timeHandle); TimeToAscii(time->hour, time->minute, timeFormat, timeString); currentDOWString = timeString + StrLen(timeString); currentDOWString[0] = ' '; currentDOWString++; resHandle = DmGetResource(strRsc, DOWformatString); ErrNonFatalDisplayIf(resHandle == NULL, "Missing string resource"); timeZoneDOWFormatString = MemHandleLock(resHandle); DateTemplateToAscii(timeZoneDOWFormatString, time->month, time->day, time->year, currentDOWString, dowLongDateStrLength); MemHandleUnlock(resHandle); MemHandleUnlock(timeHandle); timeFieldP = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeFieldID)); FldSetTextHandle(timeFieldP, timeHandle); if (drawField) FldDrawField(timeFieldP); }
void PrivDrawCell(void* table, Int16 row, Int16 column, RectanglePtr bounds) { char string[50]; FontID font = stdFont; if (g_CurrentRow != row) { if (g_CurrentMemHandle) { MemHandleUnlock(g_CurrentMemHandle); g_CurrentMemHandle = NULL; } } if (g_CurrentMemHandle == NULL) { Err err = GetSMSRecord(g_SmsDb, g_SelectedCategory, row + g_CurrentPage * TABLE_PAGE_SIZE, g_CurrentRecord, g_CurrentMemHandle, true); if (err) return; g_CurrentRow = row; } switch(column) { case 0: StrCopy(string, ""); if (g_SelectedCategory == CAT_INBOX) { if (IsRecordRead(&g_CurrentRecord)) { StrCopy(string, ""); } else { font = symbolFont; StrCopy(string, "\020"); } } else if (g_SelectedCategory == CAT_SENT) { if (IsRecordRequestReport(&g_CurrentRecord)) { font = symbolFont; if (IsRecordDelivered(&g_CurrentRecord)) { StrCopy(string, "\026"); } else { StrCopy(string, "\024"); } } } break; case 1: StrNCopy(string, g_CurrentRecord.personName, 48); if (StrLen(string) == 0) { StrNCopy(string, g_CurrentRecord.phoneNumber, 48); } break; case 2: StrNCopy(string, g_CurrentRecord.content, 48); break; case 3: { DateTimeType smsDatetime; TimSecondsToDateTime(g_CurrentRecord.time, &smsDatetime); UInt32 nowSeconds = TimGetSeconds(); DateTimeType nowDatetime; TimSecondsToDateTime(nowSeconds, &nowDatetime); if ((nowDatetime.year == smsDatetime.year) && (nowDatetime.month == smsDatetime.month) && (nowDatetime.day == smsDatetime.day)) { TimeToAscii(smsDatetime.hour, smsDatetime.minute, tfColon24h, string); } else { StrCopy(string, DayOfWeekInChinese[DayOfWeek(smsDatetime.month, smsDatetime.day, smsDatetime.year)]); DateTemplateToAscii(" ^3z-^0z", smsDatetime.month, smsDatetime.day, smsDatetime.year, string + 2, 47); } MemHandleUnlock(g_CurrentMemHandle); g_CurrentMemHandle = NULL; } break; default: StrCopy(string, ""); } WinPushDrawState(); RGBColorType foreColor, backColor; foreColor.index = 0; backColor.index = 0; if ((row == g_CurrentSelection) && (column != 0)) { foreColor.r = 255; foreColor.g = 255; foreColor.b = 255; backColor.r = 10; backColor.g = 36; backColor.b = 106; } else if (row % 2 == 0) { backColor.r = 255; backColor.g = 255; backColor.b = 255; foreColor.r = 0; foreColor.g = 0; foreColor.b = 0; } else { backColor.r = 220; backColor.g = 220; backColor.b = 220; foreColor.r = 0; foreColor.g = 0; foreColor.b = 0; } WinSetForeColorRGB(&foreColor, NULL); WinSetTextColorRGB(&foreColor, NULL); WinSetBackColorRGB(&backColor, NULL); WinSetUnderlineMode(noUnderline); FntSetFont(font); Int16 width = bounds->extent.x - 2; Int16 len = StrLen(string); Boolean noFit = false; FntCharsInWidth(string, &width, &len, &noFit); UInt16 x = bounds->topLeft.x; UInt16 y = bounds->topLeft.y; bounds->topLeft.x += - 1; bounds->topLeft.y += 0; bounds->extent.x += 2; bounds->extent.y += 0; WinEraseRectangle(bounds, 0); WinDrawGrayLine( bounds->topLeft.x + bounds->extent.x - 2, bounds->topLeft.y, bounds->topLeft.x + bounds->extent.x - 2, bounds->topLeft.y + bounds->extent.y);// - 2); WinDrawChars(string, len, x, y); WinPopDrawState(); }