コード例 #1
0
static char* test_id(void) {
  const uint32_t id = 123422;
  GFont font = fonts_get_font(id);
  mu_assert(NULL != font, "Loading font by ID returned NULL.");
  mu_assert(id == ((FakeFont*)font)->id, "Loading font by ID returned mismatched ID.");
  return 0;
}
コード例 #2
0
ファイル: title_layer.c プロジェクト: Mevin1/slabforpebble
static void title_layer_update_proc(Layer *layer, GContext* ctx) {

    GRect b = layer_get_bounds(layer);

    TitleLayer *  title_layer = (TitleLayer*)(layer_get_data(layer));

    graphics_context_set_stroke_color(ctx, GColorWhite);

    graphics_context_set_fill_color(ctx, COLOR_SECONDARY);
    graphics_fill_rect(ctx,GRect(b.origin.x,b.origin.y,b.size.w,b.size.h),0,GCornersAll);

    graphics_context_set_text_color(ctx,GColorWhite);
    // Draw the text
#ifdef PBL_ROUND
    // Create the attributes object used for text rendering
    GTextAttributes *s_attributes
        = graphics_text_attributes_create();

    // Enable text flow with an inset of 5 pixels
    graphics_text_attributes_enable_screen_text_flow(s_attributes, 5);

    graphics_draw_text(ctx, title_layer->icon,
                       fonts_get_font(RESOURCE_ID_FONT_ICONS_16), GRect(0, 2, PEBBLE_WIDTH, 16),
                       GTextOverflowModeFill, GTextAlignmentCenter, NULL);
    graphics_draw_text(ctx, title_layer->title,
                       fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD),
                       GRect(0, 16, PEBBLE_WIDTH, 18), GTextOverflowModeTrailingEllipsis,
                       GTextAlignmentCenter, s_attributes);
    graphics_text_attributes_destroy(s_attributes);


#else

    graphics_draw_text(ctx, title_layer->icon,
                       fonts_get_font(RESOURCE_ID_FONT_ICONS_16), GRect(3, 2, 16, 16),
                       GTextOverflowModeFill, GTextAlignmentCenter, NULL);
    graphics_draw_text(ctx, title_layer->title,
                       fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD),
                       GRect(22, -2, PEBBLE_WIDTH - 24, 18), GTextOverflowModeTrailingEllipsis,
                       GTextAlignmentLeft, NULL);
#endif
}
コード例 #3
0
ファイル: channelwindow.c プロジェクト: Mevin1/slabforpebble
// This is the menu item draw callback where you specify what each item should look like
static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) {
    
#ifdef PBL_BW
    graphics_context_set_text_color(ctx, GColorBlack);
#endif
    
    
    
    if (cell_index->section > NUM_SECTIONS) return;
    if (cell_index->row > channels[cell_index->section].num) return;
    
    chan_info* channel = &channels[cell_index->section].chans[cell_index->row];
    
    int left_pad=0;
    
    // Title and icon
#ifdef PBL_ROUND
    GTextAttributes *s_attributes
    = graphics_text_attributes_create();
    
    // Enable text flow with an inset of 5 pixels
    graphics_text_attributes_enable_screen_text_flow(s_attributes, 5);
    
    MenuIndex sel = menu_layer_get_selected_index(menu_layer);
    
    if ((sel.section==cell_index->section) && (sel.row==cell_index->row)) {
        
        graphics_draw_text(ctx, channel_icon_str(channel),
                           fonts_get_font(RESOURCE_ID_FONT_ICONS_16), GRect(4, 4, PEBBLE_WIDTH-4, 16),
                           GTextOverflowModeFill, GTextAlignmentCenter, s_attributes);
        
        graphics_draw_text(ctx, channel->name,
                           fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD),
                           GRect(4, 14, PEBBLE_WIDTH - 4, 24), GTextOverflowModeTrailingEllipsis,
                           GTextAlignmentCenter, s_attributes);

        graphics_draw_text(ctx, channel->unread_msg,
                           fonts_get_system_font(channel->unread == 0 ? FONT_KEY_GOTHIC_14 : FONT_KEY_GOTHIC_14_BOLD),
                           GRect(4, 36, PEBBLE_WIDTH - 4 - left_pad, 14),
                           GTextOverflowModeTrailingEllipsis,
                           GTextAlignmentCenter, s_attributes);
        
        
//        graphics_draw_text(ctx, channel_icon_str(channel),
//                           fonts_get_font(RESOURCE_ID_FONT_ICONS_16), GRect(4, 4, 16, 16),
//                           GTextOverflowModeFill, GTextAlignmentCenter, s_attributes);
//        
//        graphics_draw_text(ctx, channel->name,
//                           fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD),
//                           GRect(24, -6, PEBBLE_WIDTH - 24, 24), GTextOverflowModeTrailingEllipsis,
//                           GTextAlignmentLeft, s_attributes);
    } else {
        graphics_draw_text(ctx, channel->name,
                           fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD),
                           GRect(4, -6, PEBBLE_WIDTH - 4, 24), GTextOverflowModeTrailingEllipsis,
                           GTextAlignmentCenter, s_attributes);
        
        graphics_draw_text(ctx, channel->unread_msg,
                           fonts_get_system_font(channel->unread == 0 ? FONT_KEY_GOTHIC_14 : FONT_KEY_GOTHIC_14_BOLD),
                           GRect(4, 20, PEBBLE_WIDTH - 4 - left_pad, 14),
                           GTextOverflowModeTrailingEllipsis,
                           GTextAlignmentCenter, s_attributes);
    }

    
    graphics_text_attributes_destroy(s_attributes);
#else
    graphics_draw_text(ctx, channel_icon_str(channel),
                       fonts_get_font(RESOURCE_ID_FONT_ICONS_16), GRect(4+left_pad, 4, 16, 16),
                       GTextOverflowModeFill, GTextAlignmentCenter, NULL);
    
    graphics_draw_text(ctx, channel->name,
                       fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD),
                       GRect(22+left_pad, -6, PEBBLE_WIDTH - 24- left_pad, 24), GTextOverflowModeTrailingEllipsis,
                       GTextAlignmentLeft, NULL);
    
    graphics_draw_text(ctx, channel->unread_msg,
                       fonts_get_system_font(channel->unread == 0 ? FONT_KEY_GOTHIC_14 : FONT_KEY_GOTHIC_14_BOLD),
                       GRect(4+left_pad, 20, PEBBLE_WIDTH - 8 - left_pad, 14),
                       GTextOverflowModeTrailingEllipsis,
                       GTextAlignmentLeft, NULL);
#endif
    
    
}