Esempio n. 1
0
static void draw_time(Layer *layer, GContext *ctx) {
    graphics_context_set_text_color(ctx, GColorWhite);
    // Draw title
    graphics_draw_text(ctx, s_alarmtitle, s_res_gothic_18_bold, GRect(3, 20, 117, 37),
                       GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);

    // Draw separater
    graphics_draw_text(ctx, ":", s_res_bitham_30_black, GRect(56, 68, 12, 42),
                       GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);

    // Draw AM/PM indicator
    if (!clock_is_24h_style())
        graphics_draw_text(ctx, s_hour >= 12 ? "PM" : "AM", s_res_bitham_30_black, GRect(36, 99, 52, 37),
                           GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);

    // Set highlighted component
    graphics_context_set_fill_color(ctx, GColorWhite);
    graphics_fill_rect(ctx, GRect((s_selected == HOUR) ? 8 : 67, 68, 48, 36), 0, GCornerNone);

    // Draw hour
    graphics_context_set_text_color(ctx, (s_selected == HOUR) ? GColorBlack : GColorWhite);
    graphics_draw_text(ctx, s_hourstr, s_res_bitham_30_black, GRect(8, 68, 48, 36),
                       GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);

    // Draw minutes
    graphics_context_set_text_color(ctx, (s_selected == MINUTE) ? GColorBlack : GColorWhite);
    graphics_draw_text(ctx, s_minutestr, s_res_bitham_30_black, GRect(67, 68, 48, 36),
                       GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);

}
Esempio n. 2
0
static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) {
  TimeSlot *ts = &schedule.slots[cell_index->section];
  #ifndef PBL_COLOR
  graphics_context_set_text_color(ctx, ROW_FG_COLOR);
  graphics_context_set_fill_color(ctx, ROW_BG_COLOR);
  #endif
  if (ts->is_common) {
      graphics_draw_text(ctx, ts->title, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD),
              layer_get_bounds(cell_layer), GTextOverflowModeWordWrap, GTextAlignmentLeft, NULL);
  } else {
      GRect title_bounds = layer_get_bounds(cell_layer);
      title_bounds.origin.x += 30;
      title_bounds.size.w -= 30;
      title_bounds.origin.y += 3;
      title_bounds.size.h -= 3;
      GRect icon_bounds = layer_get_bounds(cell_layer);
      icon_bounds.size.w = 24;
      icon_bounds.size.h = 28;
      Session *s = &(ts->sessions[cell_index->row]); 
      graphics_draw_text(ctx, s->title, fonts_get_system_font(FONT_KEY_GOTHIC_14), title_bounds,
              GTextOverflowModeWordWrap, GTextAlignmentLeft, NULL);
      char *room_number_str = "0";
      snprintf(room_number_str, 2, "%d", s->room);

      #ifdef PBL_COLOR
      GFont room_font = fonts_get_system_font(FONT_KEY_LECO_26_BOLD_NUMBERS_AM_PM);
      graphics_context_set_text_color(ctx, ROOM_NUMBER_COLOR);
      #else
      GFont room_font = fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK);
      #endif
      graphics_draw_text(ctx, room_number_str, room_font, icon_bounds, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
  }
}
Esempio n. 3
0
static void paint_temperature_icon(TemperatureIcon *aIcon, GContext *aCtx, GRect r, GPoint aCenter, int32_t aRadius, bool aZoomedIn) {
#ifdef PBL_COLOR
    graphics_context_set_fill_color(aCtx, GColorMidnightGreen);
    graphics_fill_circle(aCtx, aCenter, aRadius);
#else
    graphics_context_set_stroke_color(aCtx, GColorWhite);
    fill_dithered_circle(aCtx, aCenter, aRadius, PATTERN_75_2);
#endif

    if (temperature_unit() == 'n') {
        // don't show temperature
        return;
    }

    // text
    static char buffer[] = "-000°";
    int32_t temp = temperature_icon_get_temperature(aIcon);
    snprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), "%ld°", temp);

#ifdef PBL_COLOR
    graphics_context_set_text_color(aCtx, GColorElectricBlue);
#else
    graphics_context_set_text_color(aCtx, GColorBlack);
    for (int dy = -1; dy <= +1; ++dy) {
        for (int dx = -1; dx <= +1; ++dx) {
            if (dx == 0 && dy == 0) {
                continue;
            }
            draw_degree(aCtx, r, buffer, dx, dy);
        }
    }
    graphics_context_set_text_color(aCtx, GColorWhite);
#endif
    draw_degree(aCtx, r, buffer, 0, 0);
}
Esempio n. 4
0
// Draw text onto the image
void drawing_text(GContext *ctx, GSize window_size, uint8_t activity, int32_t period_time,
                  bool in_activity, bool unstarted) {
#ifdef PBL_COLOR
  graphics_context_set_text_color(ctx, GColorBlack);
#else
  graphics_context_set_text_color(ctx, GColorWhite);
#endif
  const char *buff;
  if (unstarted) {
    buff = StickFigureRestName[PoseWaitingForStart];
  }
  else if (in_activity) {
    buff = StickFigureActivityName[activity];
  }
  else {
    buff = StickFigureRestName[activity];
  }
  graphics_draw_text(ctx, buff, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD),
    GRect(0, window_size.h - 20, window_size.w, 20), GTextOverflowModeTrailingEllipsis,
    GTextAlignmentCenter, NULL);

  // draw "Switch" half way through the side planks
  if (activity == 13 && period_time >= EXERCISE_ACTIVITY_PERIOD / 2 &&
      period_time < EXERCISE_ACTIVITY_PERIOD / 2 + 5000) {
    graphics_context_set_text_color(ctx, GColorBlack);
    graphics_draw_text(ctx, "Switch", fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD),
                       GRect(0, window_size.h / 2 + 35, window_size.w, 20),
                       GTextOverflowModeFill, GTextAlignmentCenter, NULL);
  }
}
Esempio n. 5
0
static void hands_update_proc(Layer *layer, GContext *hands_ctx) {
  time_t now = time(NULL);
  struct tm *t = localtime(&now);
  
  graphics_context_set_fill_color(hands_ctx, GColorDukeBlue);

  gpath_rotate_to(minute_arrow_path, TRIG_MAX_ANGLE * t->tm_min / 60);
  gpath_draw_filled(hands_ctx, minute_arrow_path);
  gpath_draw_outline(hands_ctx, minute_arrow_path);

  gpath_rotate_to(hour_arrow_path, (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10))) / (12 * 6));
  gpath_draw_filled(hands_ctx, hour_arrow_path);
  gpath_draw_outline(hands_ctx, hour_arrow_path);

  // dot in the middle
  GRect hands_bounds = layer_get_bounds(s_hands_layer);

    if (BTConnected == 1) {
       graphics_context_set_text_color(hands_ctx, GColorDukeBlue);
       graphics_context_set_fill_color(hands_ctx, GColorYellow);
    } else {
       graphics_context_set_text_color(hands_ctx, GColorWhite);
       graphics_context_set_fill_color(hands_ctx, GColorRed);
    }  

  graphics_fill_circle(hands_ctx, GPoint(hands_bounds.size.w / 2, hands_bounds.size.h / 2), 13);
  #ifdef PBL_PLATFORM_BASALT
      graphics_draw_text(hands_ctx, day_text, fontRobotoCondensed19, GRect(61, 72, 24, 24), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
  #else   //  PEBBLE_PLATFORM_CHALK
      graphics_draw_text(hands_ctx, day_text, fontRobotoCondensed19, GRect(78, 78, 24, 24), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
  #endif

}
Esempio n. 6
0
// Draw configure on phone dialog
void drawing_config(GContext *ctx, GSize window_size, GBitmap *bmp) {
  // set drawing colors
  graphics_context_set_fill_color(ctx, COLOR_PAUSED_FORE);
#ifdef PBL_COLOR
  graphics_context_set_text_color(ctx, GColorBlack);
#else
  graphics_context_set_text_color(ctx, GColorWhite);
#endif
  // draw background
  graphics_fill_rect(ctx, GRect(0, 0, window_size.w, window_size.h), 1, GCornerNone);
  // draw image
  GRect bmp_size = gbitmap_get_bounds(bmp);
#ifdef PBL_COLOR
  graphics_context_set_compositing_mode(ctx, GCompOpSet);
#endif
  graphics_draw_bitmap_in_rect(ctx, bmp, GRect((window_size.w - bmp_size.size.w) / 2,
                                               (window_size.h - bmp_size.size.h) / 2 - 5,
                                               bmp_size.size.w, bmp_size.size.h));
  // draw title
  graphics_draw_text(ctx, "7 Minute+", fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD),
                     GRect(0, 7, window_size.w, 28), GTextOverflowModeFill,
                     GTextAlignmentCenter, NULL);
  // draw footer
  graphics_draw_text(ctx, "Set up in the Pebble app",
                     fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD),
                     GRect(10, 120, window_size.w - 20, 48), GTextOverflowModeWordWrap,
                     GTextAlignmentCenter, NULL);
}
static void menu_draw_header_callback(GContext* ctx, const Layer *cell_layer, uint16_t section_index, void *data) {
  #ifdef PBL_COLOR
    graphics_context_set_fill_color(ctx, GColorBulgarianRose);
    graphics_context_set_text_color(ctx, GColorWhite);
  #else
    graphics_context_set_fill_color(ctx, GColorWhite);
    graphics_context_set_text_color(ctx, GColorBlack);
  #endif
    
  graphics_fill_rect(ctx, GRect(0, 0, bounds.size.w, 18), 0, GCornerNone);
    
  graphics_draw_text(ctx, "Choose race", fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD), GRect(0, -3, bounds.size.w, 18), GTextOverflowModeFill, GTextAlignmentCenter, NULL);
}
Esempio n. 8
0
static void render_time(Layer* layer, GContext* ctx) 
{
    APP_LOG(APP_LOG_LEVEL_DEBUG, "render_time");
#ifdef PBL_COLOR
    graphics_context_set_text_color(ctx, mLightColor);
#else
    graphics_context_set_text_color(ctx, mTextColor);
#endif // PBL_COLOR

    // Draw the time.
    APP_LOG(APP_LOG_LEVEL_DEBUG, "render_time: draw time text");

    if (mIs24HourStyle)
    {
        if (mHour == 1)
        {
            graphics_draw_text(ctx, "0", mTimeFontSmall, GRect(TIMEX+TIME_SIZE*3+SMALL_TEXT_OFFSET, TIMEY+(TIME_SIZE-16), 16, 16), GTextOverflowModeTrailingEllipsis, GTextAlignmentRight, NULL);
        }
        else if (mHour < 10)
        {
            graphics_draw_text(ctx, "0", mTimeFontSmall, GRect(TIMEX+TIME_SIZE*2+SMALL_TEXT_OFFSET, TIMEY+(TIME_SIZE-16), 16, 16), GTextOverflowModeTrailingEllipsis, GTextAlignmentRight, NULL);
        }
    }
    else if ((mHour == 1) || (mHour == 13))
    {
        graphics_draw_text(ctx, "0", mTimeFontSmall, GRect(TIMEX+TIME_SIZE*2.3+SMALL_TEXT_OFFSET, TIMEY+(TIME_SIZE-16), 16, 16), GTextOverflowModeTrailingEllipsis, GTextAlignmentRight, NULL);
    }
    else if ((mHour < 10 || (mHour > 12 && mHour < 22)))
    {
        // Draw the leading 0 smaller, then the time.
        APP_LOG(APP_LOG_LEVEL_DEBUG, "render_time: draw leading 0");
        graphics_draw_text(ctx, "0", mTimeFontSmall, GRect(TIMEX+TIME_SIZE*2+SMALL_TEXT_OFFSET, TIMEY+(TIME_SIZE-16), 16, 16), GTextOverflowModeTrailingEllipsis, GTextAlignmentRight, NULL);
    }

    graphics_draw_text(ctx, mTimeText, mTimeFont, GRect(TIMEX, TIMEY, TIME_SIZE*5, TIME_SIZE), GTextOverflowModeTrailingEllipsis, GTextAlignmentRight, NULL);

    // Draw the date.
    APP_LOG(APP_LOG_LEVEL_DEBUG, "render_time: draw date text");
    //if (mShakeForDate == false)
    //{
        /*if (mMonth < 9)
        {
            graphics_draw_text(ctx, "0", mDateFontSmall, GRect(DATEX, TIMEY-DATE_SIZE-DATE_OFFSETY, DATE_SIZE*5, DATE_SIZE), GTextOverflowModeTrailingEllipsis, GTextAlignmentRight, NULL);
        }*/
        graphics_draw_text(ctx, mDateText, mDateFont, GRect(DATEX, TIMEY-DATE_SIZE-DATE_OFFSETY, DATE_SIZE*5, DATE_SIZE), GTextOverflowModeTrailingEllipsis, GTextAlignmentRight, NULL);
    //}

    // Draw the other text.
    graphics_draw_text(ctx, mTopText, mDayFont, GRect(TOP_TEXT_X, TOP_TEXT_Y, SCREEN_WIDTH, TEXT_SIZE), GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
    graphics_draw_text(ctx, mDayText, mDayFont, GRect(BOT_TEXT_X, BOT_TEXT_Y, SCREEN_WIDTH, TEXT_SIZE), GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
}
Esempio n. 9
0
static void text_layer_update(Layer *layer, GContext *ctx) {
  char text[50];  //Buffer to hold text

  #if(PBL_COLOR)
    if(!grayscale)
      snprintf(text, sizeof(text), "%cr:%d\n%cg:%d\n%cb:%d", cursor==0 ?'>':' ', color[red], cursor==1?'>':' ', color[green], cursor==2?'>':' ', color[blue]);
    else 
  #endif
      snprintf(text, sizeof(text), "%d", color[gray]);
  
  
  GRect bounds = layer_get_bounds(layer);
  GFont font = fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK);
  GSize text_size = graphics_text_layout_get_content_size(text, font, bounds, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft); // Get how big the text is
  
  #if(PBL_COLOR)
    // Set up text box
    if (text_size.w<111) text_size.w = 111;  // Stop text from boppin' around
    GRect text_rect = GRect((bounds.size.w - text_size.w)/2, (bounds.size.h - text_size.h)/2, text_size.w, text_size.h);
  
    // Set Replacement Color
    // Making sure text color isn't anywhere else within the rect (to prevent accidental replacements)
    GColor replace = (color[red]>127 || color[green]>127 || color[blue]>127) ? GColorOxfordBlue : GColorCeleste;
      
    // Write Text in the "Color To Be Replaced"
    graphics_context_set_text_color(ctx, replace);
    graphics_draw_text(ctx, text, font, text_rect, GTextOverflowModeTrailingEllipsis, grayscale ? GTextAlignmentCenter : GTextAlignmentLeft, NULL);

    // Replace the color the text was drawn in (limiting to the text_rect region)
    if(!grayscale)
      replace_color_in_rect_with_dithered(ctx, text_rect, replace, 128+color[red], 128+color[green], 128+color[blue]);
    else
      replace_color_in_rect_with_dithered(ctx, text_rect, replace, 128+color[gray], 128+color[gray], 128+color[gray]);
  #else
    // Set up text box
    text_size.h += 10; text_size.w += 10;    // Add some nice padding on B&W
    GRect text_rect = GRect((bounds.size.w - text_size.w)/2, (bounds.size.h - text_size.h)/2, text_size.w, text_size.h);

    // So, since there's only 2 colors on B&W, replacement color looks kinda bad.  Adding a solid background
    graphics_context_set_fill_color(ctx, GColorBlack);  // Text Background Color
    graphics_fill_rect(ctx, text_rect, 0, GCornerNone); // Draw Background Rectangle
  
    // Write Text in the "Color To Be Replaced" (GColorWhite on this B&W example)
    graphics_context_set_text_color(ctx, GColorWhite);
    graphics_draw_text(ctx, text, font, text_rect, GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);

    // Replace the color (GColorWhite for example) the text was drawn in. Restricted to the text_rect region.
    replace_color_in_rect_with_dithered(ctx, text_rect, GColorWhite, 64+color[gray], 64+color[gray], 64+color[gray]);
  #endif
}
Esempio n. 10
0
void textOutline(GContext *ctx, const char *text, const GFont font, const GRect box, const GTextOverflowMode overflow_mode, const GTextAlignment alignment, GTextAttributes *text_attributes, const GColor fg, const GColor bg){
	int w = box.size.w;
	int h = box.size.h;
	int x = box.origin.x;
	int y = box.origin.y;
	graphics_context_set_text_color(ctx, bg);
	graphics_draw_text(ctx, text, font, GRect(x+1,y,w,h), overflow_mode, alignment, text_attributes);
	graphics_draw_text(ctx, text, font, GRect(x-1,y,w,h), overflow_mode, alignment, text_attributes);
	graphics_draw_text(ctx, text, font, GRect(x,y+1,w,h), overflow_mode, alignment, text_attributes);
	graphics_draw_text(ctx, text, font, GRect(x,y-1,w,h), overflow_mode, alignment, text_attributes);
	
	graphics_context_set_text_color(ctx, fg);
	graphics_draw_text(ctx, text, font, box, overflow_mode, alignment, text_attributes);
}
Esempio n. 11
0
void home_draw_row(GContext *ctx, const Layer *cell_layer, MenuIndex *index, void *data){
	if(index->row == 0) menu_cell_basic_draw(ctx, cell_layer, "Current Matchup", home_matchup_subtitle, NULL);
	else if(index->row == 1) menu_cell_basic_draw(ctx, cell_layer, "League Standings", home_league_subtitle, NULL);
	else if(index->row == 2) menu_cell_basic_draw(ctx, cell_layer, "My Team", home_team_subtitle, NULL);
	else{
	  #ifdef PBL_COLOR
		graphics_context_set_text_color(ctx, GColorWhite);
	  #endif
	  menu_cell_basic_draw(ctx, cell_layer, "Credits", NULL, NULL);
	  #ifdef PBL_COLOR
		if(pre_draft)
		  graphics_context_set_text_color(ctx, GColorLightGray);
	  #endif
	}
}
Esempio n. 12
0
void menu_cell_basic_draw_multiline_with_extra_title(GContext* ctx, const Layer *cell_layer, char *title, char *right_title, char *subtitle, GBitmap *icon) {
	GRect bounds = layer_get_frame(cell_layer);
	graphics_context_set_text_color	(ctx, GColorBlack);
	// Line 1
	if (icon != NULL) {
		graphics_draw_bitmap_in_rect(ctx,
			icon,
            GRect(2, 2, 20, 20));
	}
	graphics_draw_text(ctx,
		title,
		fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD),
		GRect(26, -5, bounds.size.w - 5, 26),
		GTextOverflowModeTrailingEllipsis,
		GTextAlignmentLeft,
		NULL);
	graphics_draw_text(ctx,
		right_title,
		fonts_get_system_font(FONT_KEY_GOTHIC_24),
		GRect(bounds.size.w/2, 16, bounds.size.w/2 - 5, 26),
		GTextOverflowModeWordWrap,
		GTextAlignmentRight,
		NULL);
	// Line 2
	graphics_draw_text(ctx,
		subtitle,
		fonts_get_system_font(FONT_KEY_GOTHIC_18),
		GRect(5, 21, bounds.size.w-10, 40),
		GTextOverflowModeWordWrap,
		GTextAlignmentLeft,
		NULL);
}
Esempio n. 13
0
void date_layer_update_callback(Layer *layer, GContext* ctx) {

#if SCREENSHOT
  now->tm_wday = 0;
  now->tm_mday = 25;
#endif

  graphics_context_set_text_color(ctx, FG_COLOR);

  // weekday
  if (date_mode < DATE_MODE_FIRST || date_mode > DATE_MODE_LAST)
    date_mode = DATE_MODE_FIRST;
  graphics_draw_text(ctx,
    WEEKDAY_NAMES[date_mode - DATE_MODE_FIRST][now->tm_wday],
    font,
    GRect(0, -6, EXTENT, 32),
    GTextOverflowModeWordWrap,
    GTextAlignmentLeft,
    NULL);

  // day of month
  strftime(date_buffer, DATE_BUFFER_BYTES, "%e", now);
  graphics_draw_text(ctx,
    date_buffer,
    font,
    GRect(0, -6, EXTENT, 32),
    GTextOverflowModeWordWrap,
    GTextAlignmentRight,
    NULL);

  date_wday = now->tm_wday;
  date_mday = now->tm_mday;
}
Esempio n. 14
0
static void main_layer_update_proc(Layer *layer, GContext *ctx) {
  GRect bounds = layer_get_bounds(layer);

  bool small_font = (s_packet_id > 9999);

  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_fill_circle(ctx, GPoint(bounds.size.w / 2, bounds.size.h / 2),
                            (small_font ? 66 : 60));

  GRect text_bounds;
  text_bounds.origin.x = bounds.origin.x + 12;
  text_bounds.origin.y = (bounds.size.h / 2) - (small_font ? 20 : 30);
  text_bounds.size.w = bounds.size.w - (text_bounds.origin.x * 2);
  text_bounds.size.h = 64;

  static char s_packet_id_text[8];
  snprintf(s_packet_id_text, 8, "%d", (int) s_packet_id);

  GFont id_font = fonts_get_system_font(small_font ? FONT_KEY_LECO_26_BOLD_NUMBERS_AM_PM
                                                   : FONT_KEY_LECO_38_BOLD_NUMBERS);

  graphics_context_set_text_color(ctx, GColorBlack);
  graphics_draw_text(ctx, s_packet_id_text, id_font, text_bounds,
                     GTextOverflowModeFill, GTextAlignmentCenter, NULL);

  text_bounds.origin.y += (small_font ? 36 : 48);

  graphics_draw_text(ctx, "packets", fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD),
                     text_bounds, GTextOverflowModeFill, GTextAlignmentCenter, NULL);
}
// This is a layer update callback where compositing will take place
static void layer_update_callback(Layer *layer, GContext* ctx) {
  GRect bounds = layer_get_frame(layer);

  // Display the name of the current compositing operation
  graphics_context_set_text_color(ctx, GColorBlack);
  graphics_draw_text(ctx,
    gcompops[current_gcompop].name,
    fonts_get_system_font(FONT_KEY_GOTHIC_18),
    bounds,
    GTextOverflowModeTrailingEllipsis,
    GTextAlignmentCenter,
    NULL);

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

  // Use the image size to help center the image
  GRect destination = image->bounds;

  // Center horizontally using the window frame size
  destination.origin.x = (bounds.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, destination);
}
Esempio n. 16
0
// Draws a date window with the specified text contents.  Usually this is
// something like a numeric date or the weekday name.
void draw_window(Layer *me, GContext *ctx, const char *text, struct FontPlacement *font_placement, 
		 GFont *font, bool invert, bool opaque_layer) {
  GRect box = date_window_box;

  unsigned int draw_mode = invert ^ config.draw_mode;
  draw_date_window_background(ctx, draw_mode, draw_mode, opaque_layer);

  graphics_context_set_text_color(ctx, draw_mode_table[draw_mode].colors[1]);

  box.origin.y += font_placement->vshift;

  // The Pebble text routines seem to be a bit too conservative when
  // deciding whether a given bit of text will fit within its assigned
  // box, meaning the text is likely to be trimmed even if it would
  // have fit.  We avoid this problem by cheating and expanding the
  // box a bit wider and taller than we actually intend it to be.
  box.origin.x -= 4;
  box.size.w += 8;
  box.size.h += 4;

  if ((*font) == NULL) {
    (*font) = safe_load_custom_font(font_placement->resource_id);
  }

  graphics_draw_text(ctx, text, (*font), box,
                     GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter,
                     NULL);
}
Esempio n. 17
0
static void menu_draw_header_callback(GContext* ctx, const Layer *cell_layer, uint16_t section_index, void *data) {
  // Draw title text in the section header
	graphics_context_set_fill_color(ctx, GColorWhite);
	graphics_fill_rect(ctx, layer_get_frame(cell_layer), 1, GCornersAll);
	graphics_context_set_text_color(ctx, GColorBlack);
	graphics_draw_text(ctx, "OTAKU", fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD), layer_get_frame(cell_layer), GTextOverflowModeFill, GTextAlignmentCenter, NULL);
}
Esempio n. 18
0
static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) {
	bool hasNumberType = strlen(getNumber(cell_index->row)) > 0;

	graphics_context_set_text_color(ctx, GColorBlack);

	graphics_draw_text(ctx, getName(cell_index->row), fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD), GRect(35, 0, SCREEN_WIDTH - 30, 20), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
	graphics_draw_text(ctx, getDate(cell_index->row), fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(35, 20, SCREEN_WIDTH - 30, 15), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
	if (hasNumberType)
		graphics_draw_text(ctx, getNumber(cell_index->row), fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD), GRect(35, 35, SCREEN_WIDTH - 30, 20), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);

	GBitmap* image;
	switch (getType(cell_index->row))
	{
	case 1:
		image = incomingCall;
		break;
	case 2:
		image = outgoingCall;
		break;
	default:
		image = missedCall;
		break;
	}

	graphics_context_set_compositing_mode(ctx, PNG_COMPOSITING_MODE);
	graphics_draw_bitmap_in_rect(ctx, image, GRect(3, hasNumberType ? 14 : 5, 28, 28));
}
Esempio n. 19
0
static void layer_update(Layer* me, GContext* ctx) {
  if (timer == NULL) {
    return;
  }

  graphics_context_set_text_color(ctx, GColorBlack);
  graphics_context_set_stroke_color(ctx, GColorBlack);

  char summary_str[32];
  timer_duration_str(timer->length, settings()->timers_hours, summary_str, 32);
  graphics_draw_text(ctx, summary_str, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD), GRect(0, 0, 144 - 16, 28), GTextOverflowModeFill, GTextAlignmentCenter, NULL);

  // Draw Minutes
  char* time_str = "000";
  char mode_str[16];
  switch (mode) {
    case MODE_HOURS:
      snprintf(time_str, 3, "%02d", hours);
      snprintf(mode_str, 16, hours == 1 ? "HOUR" : "HOURS");
    break;
    case MODE_MINUTES:
      snprintf(time_str, 3, "%02d", minutes);
      snprintf(mode_str, 16, seconds == 1 ? "MINUTE" : "MINUTES");
    break;
    case MODE_SECONDS:
      snprintf(time_str, 3, "%02d", seconds);
      snprintf(mode_str, 16, seconds == 1 ? "SECOND" : "SECONDS");
    break;
  }
  graphics_draw_text(ctx, time_str, font_duration, GRect(0, 27, 144 - 16, 70), GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
  graphics_draw_text(ctx, mode_str, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD), GRect(0, 98, 144 - 16, 18), GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
}
Esempio n. 20
0
void handle_init(AppContextRef ctx) {
    (void)ctx;

    window_init(&window, "Demo");
    window_stack_push(&window, true /* Animated */);

    resource_init_current_app(&FUZZYZEIT_RESOURCES);

    custom_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_MPC_32));
    custom_font2 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_MPBC_32));

    window_set_background_color(&window, GColorBlack);
    graphics_context_set_text_color(ctx, GColorWhite);

    text_layer_init(&min_layer, GRect(4, 35, 144 /* width */, 50 /* height */));
    text_layer_set_text_color(&min_layer, GColorWhite);
    text_layer_set_text(&min_layer, "");
    text_layer_set_font(&min_layer, custom_font);
    text_layer_set_background_color(&min_layer, GColorClear);

    layer_add_child(&window.layer, &min_layer.layer);
    layer_mark_dirty(&min_layer.layer);

    text_layer_init(&hour_layer, GRect(4, 80, 144 /* width */, 50 /* height */));
    text_layer_set_text_color(&hour_layer, GColorWhite);
    text_layer_set_text(&hour_layer, "");
    text_layer_set_font(&hour_layer, custom_font2);
    text_layer_set_background_color(&hour_layer, GColorClear);

    layer_add_child(&window.layer, &hour_layer.layer);
    layer_mark_dirty(&hour_layer.layer);

    update_layer(ctx);

}
Esempio n. 21
0
void date_layer_update_callback(Layer *layer, GContext* ctx) {

#if SCREENSHOT
  now->tm_wday = 0;
  now->tm_mday = 25;
#endif

  graphics_context_set_text_color(ctx, GColorWhite);

  // weekday
  strftime(date_buffer, DATE_BUFFER_BYTES, "%a", now);
  graphics_draw_text(ctx,
    date_buffer,
    font,
    GRect(0, -6, 144, 32),
    GTextOverflowModeWordWrap,
    GTextAlignmentLeft,
    NULL);

  // day of month
  strftime(date_buffer, DATE_BUFFER_BYTES, "%e", now);
  graphics_draw_text(ctx,
    date_buffer,
    font,
    GRect(0, -6, 144, 32),
    GTextOverflowModeWordWrap,
    GTextAlignmentRight,
    NULL);

  date_wday = now->tm_wday;
  date_mday = now->tm_mday;
}
Esempio n. 22
0
void update_layer_callback(Layer *me, GContext *ctx) {
    // Get the amount of seconds and the milliseconds part since the Epoch
    // time_ms also returns the milliseconds, so you can optionally pass in null
    // for any output parameters you don't need
    time_t t = 0;
    uint16_t t_ms = 0;
    time_ms(&t, &t_ms);

    // Get the next pseudo-random number
    int r = rand();

    // Print formatted text into a buffer
    snprintf(info_text, sizeof(info_text),
             "str: %s\n"
             "time: %lu\n"
             "milliseconds: %u\n"
             "rand: %d",
             str_example, t, t_ms, r);

    // Draw the formatted text
    graphics_context_set_text_color(ctx, GColorBlack);
    graphics_text_draw(ctx,
                       info_text,
                       fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD),
    (GRect) {
        .origin = GPoint(10, 5), .size = window.layer.frame.size
    },
void update_display(struct Layer *layer, GContext *ctx) {
    
    // Load the font
    GFont font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
    // Set the color
    graphics_context_set_text_color(ctx, GColorBlack);
    
    // Determine a reduced bounding box
    GRect layer_bounds = layer_get_bounds(window_get_root_layer(window));
    GRect bounds = GRect(layer_bounds.origin.x+5, layer_bounds.origin.y+5,
                         layer_bounds.size.w-10, layer_bounds.size.h-10);

    // Clear the window
    graphics_context_set_fill_color(ctx, GColorWhite);
    graphics_fill_rect(ctx, layer_bounds, 0, GCornerNone);

    // Draw the text
    if (stats_display) {
        snprintf(madlibstr, 50, "nouns: %d\nverbs: %d\nadjectives: %d\nadverbs: %d", 
                                nouns, verbs, adjectives, adverbs);
    } 
    graphics_draw_text(ctx, madlibstr, font, bounds, GTextOverflowModeWordWrap, 
                                                     GTextAlignmentCenter, NULL);

}
Esempio n. 24
0
static void menu_draw_row_callback_aplite(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) {
    GBitmap* image = getImage(_latestSource[cell_index->row]);
    if (image != NULL) {
        GRect bounds = GRect(5, 8, 48, 48);
        graphics_draw_bitmap_in_rect(ctx, image, bounds);
    }

    if (selectedMenuCell == cell_index->row) {
        graphics_context_set_text_color(ctx, GColorWhite);
    } else {
        graphics_context_set_text_color(ctx, GColorBlack);
    }
    graphics_draw_text(ctx, _latestSource[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(59, 8, 90, 20), GTextOverflowModeWordWrap, GTextAlignmentLeft, NULL);
    graphics_draw_text(ctx, _latestCategory[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(59, 37, 90, 10), GTextOverflowModeWordWrap, GTextAlignmentLeft, NULL);
    graphics_draw_text(ctx, _latest[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(5, 59, 136, row_height(cell_index)), GTextOverflowModeWordWrap, GTextAlignmentLeft, NULL);
}
static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) {
    
    graphics_context_set_text_color(ctx, GColorBlack);
  
    if (cell_index->section == 0) {
        graphics_draw_text(ctx, "Y Combinator", fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD), GRect(5, -4, 139, 98), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
        graphics_draw_text(ctx, "320 Pioneer Way\nMountain View\nCA 94041", fonts_get_system_font(FONT_KEY_GOTHIC_18), GRect(5, 20, 139, 78), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
        graphics_draw_text(ctx, "*****@*****.**", fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(5, 76, 139, 22), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
    } else if (cell_index->section == 1) {
        float text_height = graphics_text_layout_get_content_size(thursday_events[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(3, 0, 100, 44), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft).h;
        graphics_draw_text(ctx, thursday_events[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(3, (44 / 2) - (text_height / 2) - 3, 100, text_height), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
        graphics_draw_text(ctx, thursday_times[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD), GRect(100, 10, 41, 20), GTextOverflowModeTrailingEllipsis, GTextAlignmentRight, NULL);
    } else if (cell_index->section == 2) {
        float text_height = graphics_text_layout_get_content_size(friday_events[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(3, 0, 100, 44), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft).h;
        graphics_draw_text(ctx, friday_events[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(3, (44 / 2) - (text_height / 2) - 3, 100, text_height), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
        graphics_draw_text(ctx, friday_times[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD), GRect(100, 10, 41, 20), GTextOverflowModeTrailingEllipsis, GTextAlignmentRight, NULL);
    } else if (cell_index->section == 3) {
        float text_height = graphics_text_layout_get_content_size(saturday_events[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(3, 0, 100, 44), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft).h;
        graphics_draw_text(ctx, saturday_events[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(3, (44 / 2) - (text_height / 2) - 3, 100, text_height), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
        graphics_draw_text(ctx, saturday_times[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD), GRect(100, 10, 41, 20), GTextOverflowModeTrailingEllipsis, GTextAlignmentRight, NULL);
    } else if (cell_index->section == 4) {
        float text_height = graphics_text_layout_get_content_size(sunday_events[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(3, 0, 100, 44), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft).h;
        graphics_draw_text(ctx, sunday_events[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect(3, (44 / 2) - (text_height / 2) - 3, 100, text_height), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
        graphics_draw_text(ctx, sunday_times[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD), GRect(100, 10, 41, 20), GTextOverflowModeTrailingEllipsis, GTextAlignmentRight, NULL);
    }
}
Esempio n. 26
0
static void draw_matchup_custom_layer(Layer *layer, GContext *ctx){
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_fill_rect(ctx, GRect(0,0,144,152), 0, GCornerNone);
	
  graphics_context_set_fill_color(ctx, APP_COLOR);
  if(matchup_ally_score_int > matchup_enemy_score_int) graphics_fill_rect(ctx, TOP_HALF, 0, GCornerNone);
  else if(matchup_enemy_score_int > matchup_ally_score_int) graphics_fill_rect(ctx, BOTTOM_HALF, 0, GCornerNone);
	
  graphics_context_set_text_color(ctx, GColorWhite);

#ifdef PBL_BW
  if(matchup_ally_score_int > matchup_enemy_score_int){
	graphics_draw_text(ctx, matchup_ally_name, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD), GRect(4,0,136,22), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
	graphics_draw_text(ctx, matchup_enemy_name, fonts_get_system_font(FONT_KEY_GOTHIC_24), GRect(4,76,136,22), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
  }
  else if(matchup_ally_score_int < matchup_enemy_score_int){
	graphics_draw_text(ctx, matchup_ally_name, fonts_get_system_font(FONT_KEY_GOTHIC_24), GRect(4,0,136,22), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
	graphics_draw_text(ctx, matchup_enemy_name, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD), GRect(4,76,136,22), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
  }
  else{
	graphics_draw_text(ctx, matchup_ally_name, fonts_get_system_font(FONT_KEY_GOTHIC_24), GRect(4,0,136,22), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
	graphics_draw_text(ctx, matchup_enemy_name, fonts_get_system_font(FONT_KEY_GOTHIC_24), GRect(4,76,136,22), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);  
  }
#else
  graphics_draw_text(ctx, matchup_ally_name, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD), GRect(4,0,136,22), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
  graphics_draw_text(ctx, matchup_enemy_name, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD), GRect(4,76,136,22), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);  
#endif	

  graphics_draw_text(ctx, matchup_ally_score_char, fonts_get_system_font(FONT_KEY_LECO_42_NUMBERS), GRect(2, 22, 140, 42), GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
  graphics_draw_text(ctx, matchup_enemy_score_char, fonts_get_system_font(FONT_KEY_LECO_42_NUMBERS), GRect(2, 98, 140, 42), GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
}
Esempio n. 27
0
static void minute_display_layer_update_callback(Layer *layer, GContext* ctx) {

  time_t now = time(NULL);
  struct tm *t = localtime(&now);

  unsigned int angle = t->tm_min * 6;

  GRect bounds = layer_get_bounds(layer);
  GRect min_rect;
  GPoint center = grect_center_point(&bounds);
  
  GPoint min_center; // center of the minute circle
  min_center.x = sin_lookup((TRIG_MAX_ANGLE / 360) * angle)*54/TRIG_MAX_RATIO + center.x;
  min_center.y = -cos_lookup((TRIG_MAX_ANGLE / 360) * angle)*54/TRIG_MAX_RATIO + center.y;
  graphics_context_set_fill_color(ctx, FOREGROUND_COLOR);
  graphics_context_set_stroke_color(ctx, FOREGROUND_COLOR);
  graphics_fill_circle(ctx, min_center, 17);
  
  strftime(min_text,sizeof(hour_text),"%M",t);

  min_rect.origin.x = min_center.x - 15;
  min_rect.origin.y = min_center.y - 18;
  min_rect.size.w = 30;
  min_rect.size.h = 15;
  graphics_context_set_text_color(ctx,BACKGROUND_COLOR);
  graphics_draw_text(ctx,min_text,fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD),min_rect,GTextOverflowModeWordWrap,GTextAlignmentCenter,NULL);
}
Esempio n. 28
0
void WeekNumber_draw(GContext* ctx, int yPosition) {
  graphics_context_set_text_color(ctx, globalSettings.sidebarTextColor);

  // note that it draws "above" the y position to correct for
  // the vertical padding
  graphics_draw_text(ctx,
                     wordForWeek[globalSettings.languageId],
                     smSidebarFont,
                     GRect(-4 + SidebarWidgets_xOffset, yPosition - 4, 38, 20),
                     GTextOverflowModeFill,
                     GTextAlignmentCenter,
                     NULL);

  if(!globalSettings.useLargeFonts) {
    graphics_draw_text(ctx,
                       currentWeekNum,
                       mdSidebarFont,
                       GRect(0 + SidebarWidgets_xOffset, yPosition + 9, 30, 20),
                       GTextOverflowModeFill,
                       GTextAlignmentCenter,
                       NULL);
  } else {
    graphics_draw_text(ctx,
                       currentWeekNum,
                       lgSidebarFont,
                       GRect(0 + SidebarWidgets_xOffset, yPosition + 6, 30, 20),
                       GTextOverflowModeFill,
                       GTextAlignmentCenter,
                       NULL);
  }
}
Esempio n. 29
0
static void main_menu_header(GContext *ctx, const Layer *cell_layer, uint16_t section_index, void *menu_ctx) {
	graphics_context_set_fill_color(ctx, GColorBlack);
	graphics_context_set_text_color(ctx, GColorWhite);
	graphics_fill_rect(ctx, layer_get_bounds(cell_layer), 0, GCornersAll);
	graphics_draw_text(ctx, "[Restrooms]", fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD),
			layer_get_bounds(cell_layer), GTextOverflowModeFill, GTextAlignmentCenter, NULL);
}
// Draw the lizard by calling from the layer redraw proc
void draw_lizard(GContext* ctx) {
  GPath *lizard_path = gpath_create(&lizard_points);
  GPath *bug_path = gpath_create(&bug_points);

  //gpath_rotate_to(lizard_path, TRIG_MAX_ANGLE / 360 * 20);
  gpath_move_to(lizard_path, GPoint(10, 0));
    
  graphics_context_set_fill_color(ctx, GColorGreen);
  gpath_draw_filled(ctx, lizard_path);
  graphics_context_set_stroke_color(ctx, GColorBlack);
  gpath_draw_outline(ctx, lizard_path);
  graphics_context_set_fill_color(ctx, GColorBlack);
  gpath_draw_filled(ctx, bug_path);
    
  GPoint center = {
      .x = 41,
      .y = 59
  };
  graphics_fill_circle(ctx, center, 3);
  graphics_draw_circle(ctx, center, 8);
  graphics_draw_line(ctx, GPoint(6, 73), GPoint(16, 72));
    
  graphics_context_set_text_color(ctx, GColorRed);
  graphics_draw_text(ctx,
	    		"Lizzy",
	    		fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD),
	    		GRect(0,120,144,140),
	    		GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
    
}

// Only need to draw the lizard
static void drawing_layer_update_callback(Layer *me, GContext *ctx) { 
    draw_lizard(ctx);
}