예제 #1
0
void display_layer_update_callback(Layer *me, GContext* ctx) {
  (void)me;

  PblTm t;

  get_time(&t);

  unsigned short display_hour = get_display_hour(t.tm_hour);

  draw_cell_row_for_digit(ctx, display_hour, HOURS_MAX_COLS, HOURS_ROW);
  draw_cell_row_for_digit(ctx, t.tm_min, MINUTES_MAX_COLS, MINUTES_ROW);
  draw_cell_row_for_digit(ctx, t.tm_sec, SECONDS_MAX_COLS, SECONDS_ROW);

// Yeah, there's a better way to do this

/*
  graphics_text_draw(ctx, "1", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect(SECONDS_MAX_COLS*CELL_SIZE, TEXT_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);
  graphics_text_draw(ctx, "2", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect((SECONDS_MAX_COLS-1)*CELL_SIZE, TEXT_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);
  graphics_text_draw(ctx, "4", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect((SECONDS_MAX_COLS-2)*CELL_SIZE, TEXT_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);
  graphics_text_draw(ctx, "8", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect((SECONDS_MAX_COLS-3)*CELL_SIZE, TEXT_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);
  graphics_text_draw(ctx, "16", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect((SECONDS_MAX_COLS-4)*CELL_SIZE-4, TEXT_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);
  graphics_text_draw(ctx, "32", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect((SECONDS_MAX_COLS-5)*CELL_SIZE-4, TEXT_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);
*/

  graphics_text_draw(ctx, "H", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect(0, HOURS_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);
  graphics_text_draw(ctx, "M", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect(0, MINUTES_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);
  graphics_text_draw(ctx, "S", fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect(0, SECONDS_ROW*CELL_SIZE, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);

}
예제 #2
0
static void hand_layer_update( Layer * const me, GContext * ctx )
{
    ( void ) me;
    
    // Draw the hour hand outline in black and filled with white
    int hour_angle = ( ( now.tm_hour * 60 + now.tm_min ) * TRIG_MAX_ANGLE ) / ( 60 * 24 );    
    
    gpath_rotate_to(&hour_path, hour_angle);
    graphics_context_set_fill_color(ctx, GColorWhite);
    gpath_draw_filled(ctx, &hour_path);
    graphics_context_set_stroke_color(ctx, GColorBlack);
    gpath_draw_outline(ctx, &hour_path);

    // Draw the minute hand outline in black and filled with white
    int minute_angle = ( now.tm_min * TRIG_MAX_ANGLE ) / 60;
    
    gpath_rotate_to(&minute_path, minute_angle);
    graphics_context_set_fill_color(ctx, GColorWhite);
    gpath_draw_filled(ctx, &minute_path);
    graphics_context_set_stroke_color(ctx, GColorBlack);
    gpath_draw_outline(ctx, &minute_path);
    
    // Draw the second hand outline in black and filled with white
    int second_angle = ( now.tm_sec * TRIG_MAX_ANGLE ) / 60;
    
    gpath_rotate_to( &second_path, second_angle );
    graphics_context_set_fill_color( ctx, GColorWhite );
    gpath_draw_filled( ctx, &second_path );
    graphics_context_set_stroke_color( ctx, GColorBlack );
    gpath_draw_outline(ctx, &second_path);

    // Black circle over the hands.  Looks nice.
    graphics_context_set_fill_color( ctx, GColorBlack );
    graphics_fill_circle( ctx, GPoint( W / 2, H / 2 ), 30);

    // Put some date info in the center space.
    graphics_context_set_text_color( ctx, GColorWhite );
    string_format_time( buffer, sizeof( buffer ), "%a", &now );
    graphics_text_draw( ctx,
                        buffer,
                        font_date,
                        GRect( W / 2 - 30, H / 2 - 30, 60, 24 ),
                        GTextOverflowModeTrailingEllipsis,
                        GTextAlignmentCenter,
                        NULL
                       );

    string_format_time( buffer, sizeof( buffer ), "%m/%d", &now );
    graphics_text_draw( ctx,
                        buffer,
                        font_date,
                        GRect( W / 2 - 30 , H / 2 - 8, 60, 24 ),
                        GTextOverflowModeTrailingEllipsis,
                        GTextAlignmentCenter,
                        NULL
                       );
}
예제 #3
0
/* Called by the graphics layers when the time layer needs to be updated.
*/
void time_layer_update_proc(TimeLayer *tl, GContext* ctx)
{
    if (tl->background_color != GColorClear)
    {
        graphics_context_set_fill_color(ctx, tl->background_color);
        graphics_fill_rect(ctx, tl->layer.bounds, 0, GCornerNone);
    }
    graphics_context_set_text_color(ctx, tl->text_color);

    if (tl->hour_text && tl->minute_text)
    {
        GSize hour_sz =
            graphics_text_layout_get_max_used_size(ctx,
                                                   tl->hour_text,
                                                   tl->hour_font,
                                                   tl->layer.bounds,
                                                   tl->overflow_mode,
                                                   GTextAlignmentLeft,
                                                   tl->layout_cache);
        GSize minute_sz =
            graphics_text_layout_get_max_used_size(ctx,
                                                   tl->minute_text,
                                                   tl->minute_font,
                                                   tl->layer.bounds,
                                                   tl->overflow_mode,
                                                   GTextAlignmentLeft,
                                                   tl->layout_cache);
        int width = minute_sz.w + hour_sz.w;
        int half = tl->layer.bounds.size.w / 2;
        GRect hour_bounds = tl->layer.bounds;
        GRect minute_bounds = tl->layer.bounds;

        hour_bounds.size.w = half - (width / 2) + hour_sz.w;
        minute_bounds.origin.x = hour_bounds.size.w - 1;
        minute_bounds.size.w = minute_sz.w;
		
        graphics_text_draw(ctx,
                           tl->hour_text,
                           tl->hour_font,
						   hour_bounds,
                           tl->overflow_mode,
                           GTextAlignmentRight,
                           tl->layout_cache);
        graphics_text_draw(ctx,
                           tl->minute_text,
                           tl->minute_font,
						   minute_bounds,
                           tl->overflow_mode,
                           GTextAlignmentLeft,
                           tl->layout_cache);
    }
}
예제 #4
0
void draw_number(GContext* ctx, int x, int y, bool show, const char* txt)  {
  
    if(show) {
      graphics_text_draw(ctx, txt, fonts_get_system_font(FONT_KEY_FONT_FALLBACK), GRect(x, y, CELL_SIZE, CELL_SIZE), GTextOverflowModeWordWrap, GAlignLeft,NULL);
    }
    
}
// This is a layer update callback where compositing will take place
void layer_update_callback(Layer *me, GContext* ctx) {
    // Display the name of the current compositing operation
    graphics_context_set_text_color(ctx, GColorBlack);
    graphics_text_draw(ctx,
                       gcompops[current_gcompop].name,
                       fonts_get_system_font(FONT_KEY_GOTHIC_18),
                       me->frame,
                       GTextOverflowModeTrailingEllipsis,
                       GTextAlignmentCenter,
                       NULL);

    // Draw the large circle the image will composite with
    graphics_context_set_fill_color(ctx, GColorBlack);
    graphics_fill_circle(ctx, GPoint(window.layer.frame.size.w/2, window.layer.frame.size.h+110), 180);

    // Use the image size to help center the image
    GRect destination = image.bmp.bounds;

    // Center horizontally using the window frame size
    destination.origin.x = (window.layer.frame.size.w-destination.size.w)/2;
    destination.origin.y = 50;

    // Set the current compositing operation
    // This will only cause bitmaps to composite
    graphics_context_set_compositing_mode(ctx, gcompops[current_gcompop].op);

    // Draw the bitmap; it will use current compositing operation set
    graphics_draw_bitmap_in_rect(ctx, &image.bmp, destination);
}
예제 #6
0
파일: font.c 프로젝트: robhh/PebbleLocalSim
void text_layer_update_func (Layer* me,GContext* ctx) {
    GRect rect=GRect(0,0,me->frame.size.w,me->frame.size.h);
    TextLayer* textLayer=(TextLayer*)me;
    graphics_context_set_fill_color(ctx,textLayer->background_color);
    graphics_fill_rect (ctx,rect,0,0);
    graphics_context_set_text_color(ctx,textLayer->text_color);
    graphics_text_draw (ctx,textLayer->text,textLayer->font,rect,textLayer->overflow_mode,textLayer->text_alignment,0);
}
예제 #7
0
void phase_layer_update_callback(Layer *me, GContext* ctx) {
    (void)me;
    
    graphics_context_set_text_color(ctx, GColorWhite);
    graphics_text_draw(
        ctx, 
        phases[ph],  
        fonts_get_system_font(FONT_KEY_GOTHIC_24), 
        GRect(0, 138, 144, 30), 
        GTextOverflowModeWordWrap, 
        GTextAlignmentCenter, 
        NULL);
}
예제 #8
0
void update_score_layer_opponent_callback(Layer *me, GContext* ctx) {
  (void)me;

  graphics_context_set_text_color(ctx, TEXT_COLOR);

  static char txt[11];
  mini_snprintf(txt, 10, TXT_SCORE_OPPONENT, score_opponent);
  graphics_text_draw(ctx,
         txt,
         fonts_get_system_font(FONT_SCORE),
         FRAME_SCORE_OPPONENT,
         GTextOverflowModeWordWrap,
         GTextAlignmentLeft,
         NULL);
}
예제 #9
0
void update_match_layer_callback(Layer *me, GContext* ctx) {
  (void)me;

  graphics_context_set_text_color(ctx, TEXT_COLOR);

  static char txt[21];
  mini_snprintf(txt, 20, TXT_MATCH, match_me, match_opponent);
  graphics_text_draw(ctx,
         txt,
         fonts_get_system_font(FONT_MATCH),
         FRAME_MATCH,
         GTextOverflowModeWordWrap,
         GTextAlignmentCenter,
         NULL);
}
예제 #10
0
void arrivals_draw_row(GContext *ctx, const Layer *cell_layer, MenuIndex *cell_index, void *callback_context) {
    static char *options[1] = {
        "Refresh"
    };

    static char buffer[16]; //Long enough for "99:99 scheduled\0"

    switch(cell_index->section) {
        case ARRIVAL_SECTION_MAIN:
            graphics_context_set_text_color(ctx, GColorBlack);
            graphics_text_draw(ctx, ARRIVALS[cell_index->row].route, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD), GRect(4, 3, 140, 28), 0, GTextAlignmentLeft, NULL);
            snprintf(buffer, sizeof(buffer), "%s expected", ARRIVALS[cell_index->row].actual);
            graphics_text_draw(ctx, buffer, fonts_get_system_font(FONT_KEY_GOTHIC_18), GRect(32, 0, 108, 36), 0, GTextAlignmentLeft, NULL);
            snprintf(buffer, sizeof(buffer), "%s scheduled", ARRIVALS[cell_index->row].scheduled);
            graphics_text_draw(ctx, buffer, fonts_get_system_font(FONT_KEY_GOTHIC_18), GRect(32, 18, 108, 36), 0, GTextAlignmentLeft, NULL);
            break;
        case ARRIVAL_SECTION_OPTIONS:
            graphics_context_set_text_color(ctx, GColorBlack);
            graphics_text_draw(ctx, options[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_18), GRect(8, 8, 140, 18), 0, GTextAlignmentLeft, NULL);
            break;
        default:
            APP_LOG(APP_LOG_LEVEL_ERROR, "arrivals_draw_row: unknown section %d", cell_index->section);
    }
}
예제 #11
0
void update_duration_layer_callback(Layer *me, GContext* ctx) {
  (void)me;

  graphics_context_set_text_color(ctx, TEXT_COLOR);

  int minutes = (int)duration_seconds / 60;
  int seconds = duration_seconds % 60;
  static char txt[21];
  mini_snprintf(txt, 20, TXT_DURATION, minutes, seconds);
  graphics_text_draw(ctx,
         txt,
         fonts_get_system_font(FONT_DURATION),
         FRAME_DURATION,
         GTextOverflowModeWordWrap,
         GTextAlignmentCenter,
         NULL);
}
예제 #12
0
void draw_card(Layer *me, GContext* ctx, const char *text) {
  GFont font;
  GRect box;

  font = fonts_get_system_font(FONT_KEY_GOTHIC_18);
  box = layer_get_frame(me);
  box.origin.x = 0;
  box.origin.y = 0;
  graphics_context_set_text_color(ctx, GColorBlack);
  graphics_context_set_stroke_color(ctx, GColorBlack);
  //  graphics_draw_round_rect(ctx, box, 0);

  box.origin.y -= 3;  // Determined empirically.

  graphics_text_draw(ctx, text, font, box,
                     GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter,
                     NULL);
}
예제 #13
0
void graphics_sun_layer_update_callback(Layer *me, GContext* ctx) 
{
  (void)me;

  gpath_init(&sun_path, &sun_path_info);
  gpath_move_to(&sun_path, grect_center_point(&graphics_sun_layer.frame));

  graphics_context_set_fill_color(ctx, GColorBlack);
  gpath_draw_filled(ctx, &sun_path);  

  graphics_context_set_text_color(ctx, GColorWhite);

  graphics_text_draw(ctx,
         moonphase_text,
         fontMoonPhases,
         moonRect, //GRect(0, 100, 144, 50),
         GTextOverflowModeWordWrap,
         GTextAlignmentCenter,
         NULL);
}
예제 #14
0
void m_MenuLayerDrawRowCallback(GContext *ctx, const Layer *cell_layer, MenuIndex *cell_index, void *callback_context)
{
    graphics_context_set_text_color(ctx, GColorBlack);

    if (md_unread(cell_index->row))
    {
    	graphics_text_draw(ctx, "U", fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(0,10,11,14), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
    }
    if (md_isNew(cell_index->row))
    {
    	graphics_text_draw(ctx, "N", fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(0,45-18,11,14), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
    }

    GFont fSender;
    int fSenderHeight;
    GFont fSubject;
    int fSubjectHeight;
    switch (md_inboxTextSize())
    {
    case eSize_Small:
    	fSender = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
    	fSubject = fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD);
        fSenderHeight = 18;
        fSubjectHeight = 16;
    	break;
    case eSize_Large:
    	fSender = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);
    	fSubject = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
        fSenderHeight = 28;
        fSubjectHeight = 26;
    	break;
    case eSize_Regular:
    default:
    	fSender = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
    	fSubject = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
        fSenderHeight = 24;
        fSubjectHeight = 20;
    	break;
    }

	graphics_text_draw(ctx, md_sender(cell_index->row),
			fSender,
			GRect(12,0,cell_layer->bounds.size.w - 12,fSenderHeight),
			GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
	graphics_text_draw(ctx, md_subject(cell_index->row),
			fSubject,
			GRect(12,fSenderHeight + 1,cell_layer->bounds.size.w - 12,fSubjectHeight),
			GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);

    if (md_isDeleted(cell_index->row))
    {
    	int SenlinePos = fSenderHeight + fSenderHeight/2;
    	int SublinePos = (fSubjectHeight/3) *2;
		graphics_context_set_stroke_color(ctx, GColorBlack);
		graphics_draw_line(ctx, GPoint(12, SenlinePos), GPoint(cell_layer->bounds.size.w - 12, SenlinePos));
		graphics_draw_line(ctx, GPoint(12, SenlinePos + 1), GPoint(cell_layer->bounds.size.w - 12, SenlinePos + 1));
		graphics_draw_line(ctx, GPoint(12, SublinePos), GPoint(cell_layer->bounds.size.w - 12, SublinePos));
		graphics_draw_line(ctx, GPoint(12, SublinePos+1), GPoint(cell_layer->bounds.size.w - 12, SublinePos + 1));
    }
	//menu_cell_basic_draw(ctx, cell_layer, md_sender(cell_index->row), md_subject(cell_index->row),
	//		&N_IMG.bmp // icon, tod
	//	);
/*	menu_cell_basic_draw(ctx, cell_layer,
			"Foo",
			"Bar",
			0 // icon, todo
		);
*/
}
예제 #15
0
static void
timezone_layer_update(
					  Layer * const me,
					  GContext * ctx
					  )
{
	const timezone_t * const tz = container_of(me, timezone_t, layer);
	
	const int orig_hour = now.tm_hour;
	const int orig_min = now.tm_min;
	
	now.tm_min += (tz->offset - gmt_offset) % 60;
	if (now.tm_min > 60)
	{
		now.tm_hour++;
		now.tm_min -= 60;
	} else
        if (now.tm_min < 0)
        {
			now.tm_hour--;
			now.tm_min += 60;
        }
	
	now.tm_hour += (tz->offset - gmt_offset) / 60;
	if (now.tm_hour > 24)
		now.tm_hour -= 24;
	if (now.tm_hour < 0)
		now.tm_hour += 24;
	
	char buf[32];
	string_format_time(
					   buf,
					   sizeof(buf),
					   "%H:%M",
					   &now
					   );
	
	//Swaps the background/foreground colors for night and day. Day=6 and later. Night=18 and later.
	const int night_time = (now.tm_hour > 17 || now.tm_hour < 6);
	now.tm_hour = orig_hour;
	now.tm_min = orig_min;
	
	const int w = me->bounds.size.w;
	const int h = me->bounds.size.h;
	
	// it is night there, draw in black video
	graphics_context_set_fill_color(ctx, night_time ? GColorBlack : GColorWhite);
	graphics_context_set_text_color(ctx, !night_time ? GColorBlack : GColorWhite);
	graphics_fill_rect(ctx, GRect(0, 0, w, h), 0, 0);
	
	graphics_text_draw(ctx,
					   tz->name,
					   font_thin,
					   GRect(0, 0, w, h/3),
					   GTextOverflowModeTrailingEllipsis,
					   GTextAlignmentCenter,
					   NULL
					   );
	
	graphics_text_draw(ctx,
					   buf,
					   font_thick,
					   GRect(0, h/3, w, 2*h/3),
					   GTextOverflowModeTrailingEllipsis,
					   GTextAlignmentCenter,
					   NULL
					   );
}
예제 #16
0
void updateMonth(Layer *layer, GContext *ctx) {
	static char numStr[3] = "";
	int i, x, s, numWeeks, dy, firstday, numDays, l=0, c=0, w;
	Date first, d;
	GFont f, fontNorm, fontBold;
	GRect rect, fillRect;
	
	first = Date(1, displayedMonth, displayedYear);
#if WEEK_STARTS_ON_SUNDAY
	firstday = dayOfWeek(&first);
#else
	firstday = (dayOfWeek(&first)+6)%7;
#endif
	numDays = numDaysInMonth(displayedMonth, displayedYear);
	
	numWeeks = (firstday+6+numDays)/7;
	
	dy = DY + DH*(6-numWeeks)/2;
	
	graphics_context_set_stroke_color(ctx, GColorBlack);
	graphics_context_set_fill_color(ctx, GColorBlack);
	
	// Calendar Grid
#if SHOW_WEEK_NUMBERS
	x = DX+DW;
#else
	x = DX;
#endif

	// Black Top Line with days of week
	graphics_fill_rect(ctx, GRect(x, dy, DW*7+1, DH), 4, GCornersTop);

#if SHOW_WEEK_NUMBERS
	// Black left column for week numbers
	graphics_fill_rect(ctx, GRect(DX, dy+DH, DW, numWeeks*DH+1), 4, GCornersLeft);
#endif

#if SHOW_WEEK_NUMBERS
	x = DX+DW;
	w = DW*7;
#else
	x = DX+1;
	w = DW*7-1;
#endif
	// Double line on the outside
	graphics_draw_round_rect(ctx, GRect(x, dy+DH, w, numWeeks*DH), 0);
	
	// Column(s) for the week-end or sunday
#if WEEK_STARTS_ON_SUNDAY
	x = DX+DW+1;
#else
	x = DX+5*DW+1;
#endif

#if SHOW_WEEK_NUMBERS
	x += DW;
#endif

	graphics_draw_line(ctx, GPoint(x, dy+DH), GPoint(x, dy+DH+numWeeks*DH-1));
	
#if SHOW_WEEK_NUMBERS
	x = 1;
#else
	x = 0;
#endif

	// Vertical lines
	for (i=x; i<=x+7; i++) {
		graphics_draw_line(ctx, GPoint(DX+DW*i,dy+DH), GPoint(DX+DW*i,dy+(numWeeks+1)*DH));
	}
	// Horizontal lines
	for (i=1; i<=(numWeeks+1); i++) {
		graphics_draw_line(ctx, GPoint(DX+x*DW,dy+DH*i), GPoint(DX+DW*(7+x),dy+DH*i));
	}
	
	fontNorm = fonts_get_system_font(FONT_KEY_GOTHIC_18);
	fontBold = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
	f = fontNorm;
	
#if WEEK_STARTS_ON_SUNDAY
	s = 0;
#else
	s = 1;
#endif

#if SHOW_WEEK_NUMBERS
	x = 1;
#else
	x = 0;
#endif

	// Days of week
	graphics_context_set_text_color(ctx, GColorWhite);
	
	for (i=s; i<s+7; i++) {
		graphics_text_draw(ctx, weekDays[i%7], fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(DX+DW*(i+x-s), dy, DW+2, DH+1), GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
	}
	
#if SHOW_WEEK_NUMBERS
	// Week numbers
	for (i=0, d=first; i<=numWeeks; i++, d.day+=7) {
		xsprintf(numStr, "%d", weekNumber(&d));
		graphics_text_draw(ctx, numStr, fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(DX, dy+DH*(i+1), DW, DH+1), GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
	}
#endif
	
	// Day numbers
	graphics_context_set_text_color(ctx, GColorBlack);
	
	for (i=1; i<=numDays; i++) {
		c = (firstday - 1 + i)%7;
		if (c == 0 && i != 1) {
			l++;
		}
		
		xsprintf(numStr, "%d", i);

		if (isNonWorkingDay(&Date(i, displayedMonth, displayedYear))) {
			f = fontBold;
		} else {
			f = fontNorm;
		}
		
		fillRect = GRect(DX+DW*(c+x), dy+DH*(l+1), DW, DH);
		rect = GRect(DX+DW*(c+x), dy+DH*(l+1)-3, DW+1, DH+1);
		
		if (today.day == i && today.month == displayedMonth && today.year == displayedYear) {
			graphics_fill_rect(ctx, fillRect, 0, GCornerNone);
			graphics_context_set_text_color(ctx, GColorWhite);
			graphics_text_draw(ctx, numStr, f, rect, GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
		} else {
			graphics_context_set_text_color(ctx, GColorBlack);
			graphics_text_draw(ctx, numStr, f, rect, GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
		}
	}
}
예제 #17
0
// ** Draw the initial background image
static void bg_layer_update( Layer * const me, GContext * ctx )
{
    ( void ) me;
    
    graphics_context_set_stroke_color( ctx, GColorWhite );
    graphics_context_set_fill_color( ctx, GColorWhite );
    
    // Draw the outside marks
    for( int min = 0; min < 60; min++ )
    {
        const int angle = ( min * TRIG_MAX_ANGLE ) / 60;
        if( ( min % 15 ) == 0 )
        {
          gpath_rotate_to( &hour_tick_path, angle );
          gpath_draw_filled( ctx, &hour_tick_path );
        } 
        else if( ( min % 5 ) == 0 )
        {
     			gpath_rotate_to( &major_tick_path, angle );
          gpath_draw_filled( ctx, &major_tick_path );
        }
        else
        {
        	gpath_rotate_to( &minor_tick_path, angle );
          gpath_draw_outline( ctx, &minor_tick_path );
        }
    }
    
    // And the large labels
    graphics_context_set_text_color( ctx, GColorWhite );
    graphics_text_draw( ctx,
                        "24",
                        font_time,
                        GRect( W / 2 - 30, 4, 60, 50 ),
                        GTextOverflowModeTrailingEllipsis,
                        GTextAlignmentCenter,
                        NULL
                       );
    
    graphics_text_draw( ctx,
                        "06",
                        font_time,
                        GRect( W / 2, H / 2 - 26, 70, 50 ),
                        GTextOverflowModeTrailingEllipsis,
                        GTextAlignmentRight,
                        NULL
                       );
    
    graphics_text_draw( ctx,
                        "12",
                        font_time,
                        GRect( W / 2 - 30, 110, 60, 50 ),
                        GTextOverflowModeTrailingEllipsis,
                        GTextAlignmentCenter,
                        NULL
                       );
    
    graphics_text_draw( ctx,
                        "18",
                        font_time,
                        GRect( W / 2 - 70, H / 2 - 26, 60, 50 ),
                        GTextOverflowModeTrailingEllipsis,
                        GTextAlignmentLeft,
                        NULL
                       ); 
}