Пример #1
0
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));
  }
}
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;
}
Пример #3
0
static Layer* position_layer(Layer *parent, GPoint *pos, ElementConfig *config, bool actually_make_layer) {
  Layer *layer = NULL;

  int width;
  if (config->w == 0) {
    width = layer_get_bounds(parent).size.w - pos->x;
  } else {
    width = config->w;
  }
  width += config->right;
  int height = config->h + config->bottom;

  if (actually_make_layer) {
    layer = layer_create_with_data(
      GRect(pos->x, pos->y, width, height),
      sizeof(ElementConfig)
    );
    memcpy(get_element_data(layer), config, sizeof(ElementConfig));
    layer_add_child(parent, layer);
    layer_set_update_proc(layer, draw_background_and_borders);
  }

  pos->x += width;
  if (pos->x >= layer_get_bounds(parent).size.w) {
    pos->x = 0;
    pos->y += height;
  }

  return layer;
}
Пример #4
0
void print_results(Event *e){
    int i, total_hours, total_mins;
    Entrant *entrant;

    printf("-------------------------------------------------------------------------------\n");
    printf("|Competitor           |  Course  |  Start Time |   End Time  |     Total      |\n");
    printf("|-----------------------------------------------------------------------------|\n");
    
    for (i=0; i< e->no_of_entrants-1; i++) {
        total_hours = 0;
        total_mins = 0;
    
        entrant = (Entrant*)get_element_data(e->entrantlist.head, i);
        
        if(entrant->state.type == COMPLETED) {
                total_hours = calc_total_time(entrant->start_time, entrant->end_time);
                total_mins = calc_total_time(&entrant->start_time[3], &entrant->start_time[3]);
        }
        
        printf("|%-21s|    %c     |    %s    |    %s    |  %.2dhrs %.2dmins  |\n", 
                entrant->name, entrant->course, 
                entrant->start_time, entrant->end_time, 
                total_hours, total_mins);
    }
    
    printf("-------------------------------------------------------------------------------\n");
}
Пример #5
0
static Layer* get_layer_for_element(int element) {
  for(int i = 0; i < get_prefs()->num_elements; i++) {
    if(get_element_data(s_layers[i])->el == element) {
      return s_layers[i];
    }
  }
  return NULL;
}
/*!
\param size_bytes size in bytes of the buffer
*/
void * btGenericMemoryPool::allocate(size_t size_bytes)
{

	size_t module = size_bytes%m_element_size;
	size_t element_count = size_bytes/m_element_size;
	if(module>0) element_count++;

	size_t alloc_pos = allocate_from_free_nodes(element_count);
	// a free node is found
	if(alloc_pos != BT_UINT_MAX)
	{
		return get_element_data(alloc_pos);
	}
	// allocate directly on pool
	alloc_pos = allocate_from_pool(element_count);

	if(alloc_pos == BT_UINT_MAX) return NULL; // not space
	return get_element_data(alloc_pos);
}
Пример #7
0
GColor element_fg(Layer* layer) {
  return get_element_data(layer)->black ? GColorWhite : GColorBlack;
}
Пример #8
0
GCompOp element_comp_op(Layer* layer) {
  return get_element_data(layer)->black ? GCompOpSet : GCompOpAnd;
}