ConnectionStatusComponent* connection_status_component_create(Layer *parent, int x, int y) { BitmapLayer *icon_layer = bitmap_layer_create(GRect(x, y, REASON_ICON_WIDTH, REASON_ICON_WIDTH)); // draw the icon background over the graph bitmap_layer_set_compositing_mode(icon_layer, get_element_data(parent)->black ? GCompOpAssignInverted : GCompOpAssign); layer_set_hidden(bitmap_layer_get_layer(icon_layer), true); layer_add_child(parent, bitmap_layer_get_layer(icon_layer)); FontChoice font = get_font(FONT_18_BOLD); TextLayer *staleness_text = text_layer_create(GRect( x + REASON_ICON_WIDTH + 1, y + (REASON_ICON_WIDTH - font.height) / 2 - font.padding_top, INITIAL_TEXT_SIZE, font.height + font.padding_top + font.padding_bottom )); text_layer_set_font(staleness_text, fonts_get_system_font(font.key)); text_layer_set_background_color(staleness_text, element_bg(parent)); text_layer_set_text_color(staleness_text, element_fg(parent)); text_layer_set_text_alignment(staleness_text, GTextAlignmentLeft); layer_set_hidden(text_layer_get_layer(staleness_text), true); layer_add_child(parent, text_layer_get_layer(staleness_text)); ConnectionStatusComponent *c = malloc(sizeof(ConnectionStatusComponent)); c->icon_layer = icon_layer; c->icon_bitmap = NULL; c->staleness_text = staleness_text; return c; }
static void draw_background_and_borders(Layer *layer, GContext *ctx) { GRect bounds = layer_get_bounds(layer); if (get_element_data(layer)->black) { graphics_context_set_fill_color(ctx, element_bg(layer)); graphics_fill_rect(ctx, GRect(0, 0, bounds.size.w, bounds.size.h), 0, GCornerNone); } graphics_context_set_stroke_color(ctx, element_fg(layer)); if (get_element_data(layer)->bottom) { graphics_draw_line(ctx, GPoint(0, bounds.size.h - 1), GPoint(bounds.size.w - 1, bounds.size.h - 1)); } if (get_element_data(layer)->right) { graphics_draw_line(ctx, GPoint(bounds.size.w - 1, 0), GPoint(bounds.size.w - 1, bounds.size.h - 1)); } }