Beispiel #1
0
void draw_histogram(int from_idx, int to_idx) {
  int i, y;
  char tmp_text[200];

  // Draw everything if scaling has changed.
  if (old_scaling != scaling) {
    from_idx = 0;
    to_idx = region_stack_idx;
  }
    
  // Draw regions as horizontal lines.
  for (i=from_idx;i<=to_idx;i=i+1) {
    y = 160-(int)(90.0*region_stat[i]/scaling);
    if (y<70) {
	StrPrintF(tmp_text, "scaling with y=%i, region_sta[i]=%lu and scaling %lu",y, region_stat[i],(UInt32)scaling);
	panic(tmp_text);
    }
    if (i == max_reg_idx)
      WinDrawLine (i*2, y, i*2, 159);
    else
      WinDrawGrayLine (i*2, y, i*2, 159);
    WinEraseLine(i*2, 70, i*2, y-1);
  }
  if (old_max_reg_idx != max_reg_idx) {
    // Draw old max idx
    y = 160-(90*region_stat[old_max_reg_idx]/scaling);
    WinDrawGrayLine (old_max_reg_idx*2, y, old_max_reg_idx*2, 159);
    WinEraseLine(old_max_reg_idx*2, 70, old_max_reg_idx*2, y-1);
    // Draw new max idx
    y = 160-(90*region_stat[max_reg_idx]/scaling);
    WinDrawLine (max_reg_idx*2, y, max_reg_idx*2, 159);
    WinEraseLine(max_reg_idx*2, 70, max_reg_idx*2, y-1);
  }
}
Beispiel #2
0
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();
}
Beispiel #3
0
/*****************************************************************************
* Function: GadgetDraw
*
* Description: Draws the basic gadget (grid, days, times)
*****************************************************************************/
void
GadgetDraw(Boolean eraseFirst)
{
  RectangleType bounds;
  UInt8 i, gadgetWidth;
  RGBColorType color, prevColor;
  UInt16 gadgetIndex;
  RectangleType rect;
  FormType *frm=gForm;

  // Check if GadgetSet has already been called. If not => die
  if (! frm) return;

  gadgetIndex = FrmGetObjectIndex(frm, gGadgetID);
  FrmGetObjectBounds(frm, gadgetIndex, &bounds);

  // Erase background
  if (eraseFirst)  WinEraseRectangle(&bounds, 0);

  // Write Times
  if (gGadgetCurScreen == GADGET_SCREEN_DAY) {
    for (i=0; i < 7; i++) { // 7 because we have to write 7 times 08:00, 10:00,..., 20:00
      Char time[timeStringLength];
      if (i < 1)  StrPrintF(time, "0%u:00", 8+i*2);
      else  StrPrintF(time, "%u:00", 8+i*2);
      WinDrawChars(time, StrLen(time), bounds.topLeft.x+GADGET_BASELEFT,
                   (i != 7 - 1) ? bounds.topLeft.y+GADGET_STRINGS_TOP+i*GADGET_STRINGS_OFFSET
                   /* ^last^ */ : bounds.topLeft.y+GADGET_STRINGS_TOP+i*GADGET_STRINGS_OFFSET-2);
    }
  } else {
    for (i=0; i < 2; i++) {
      Char time[timeStringLength];
      StrPrintF(time, "%u:00", 20+i*2);
      WinDrawChars(time, StrLen(time), bounds.topLeft.x+GADGET_BASELEFT,
                   bounds.topLeft.y+GADGET_STRINGS_TOP+i*GADGET_STRINGS_OFFSET);
    }
    for (i=2; i < 7; i++) {
      Char time[timeStringLength];
      StrPrintF(time, "0%u:00", (i-2)*2);
      WinDrawChars(time, StrLen(time), bounds.topLeft.x+GADGET_BASELEFT,
                   (i != 7 - 1) ? bounds.topLeft.y+GADGET_STRINGS_TOP+i*GADGET_STRINGS_OFFSET
                   /* ^last^ */ : bounds.topLeft.y+GADGET_STRINGS_TOP+i*GADGET_STRINGS_OFFSET-2);
    }
  }

  // Write Weekdays
  GadgetDrawWeekdays();

  // Draw Grid: Color is light gray on colored palms, dark gray on gray palms
  if (TNisColored()) {
    color.r = 0x77;  color.g = 0x77;  color.b = 0x77;
  } else {
    color.r = 0x44;  color.g = 0x44;  color.b = 0x44;
  }

  TNSetForeColorRGB(&color, &prevColor);

  gadgetWidth=gGadgetDaysNum * gGadgetDaysWidth + gGadgetDaysNum - 1;
  RctSetRectangle(&rect, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y+GADGET_TOP, gadgetWidth, GADGET_HEIGHT);
  WinDrawRectangleFrame(simpleFrame, &rect);
  for(i=1; i <= 5; ++i) { // Draw the 5 gray dashed lines
    if ( (gGadgetCurScreen == GADGET_SCREEN_NIGHT) && (i == 2)) {
      WinDrawLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y+GADGET_TOP+i*GADGET_STRINGS_OFFSET,
                  bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gadgetWidth-1, bounds.topLeft.y+GADGET_TOP+i*GADGET_STRINGS_OFFSET);
    } else {
      WinDrawGrayLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y+GADGET_TOP+i*GADGET_STRINGS_OFFSET,
                      bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gadgetWidth-1, bounds.topLeft.y+GADGET_TOP+i*GADGET_STRINGS_OFFSET);
    }
  }
  for(i=1; i <= gGadgetDaysNum -1; ++i) {
    WinDrawLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+i*gGadgetDaysWidth+(i-1), bounds.topLeft.y+GADGET_TOP,
                bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+i*gGadgetDaysWidth+(i-1), bounds.topLeft.y+GADGET_TOP+GADGET_HEIGHT-1);
  }

  TNSetForeColorRGB(&prevColor, NULL);
}