Example #1
0
void thread_window_load(Window *window)
{
	struct ThreadData *thread = GetSelectedThread();
	
	thread_scroll_layer = scroll_layer_create(window_frame);

	scroll_layer_set_shadow_hidden(thread_scroll_layer, true);
	scroll_layer_set_click_config_onto_window(thread_scroll_layer, window);
	scroll_layer_set_content_size(thread_scroll_layer, GSize(window_frame.size.w, 0));
	scroll_layer_set_content_offset(thread_scroll_layer, GPoint(0, 0), false);

	ScrollLayerCallbacks scrollOverride =
	{
		.click_config_provider = &thread_click_config,
		.content_offset_changed_handler = &thread_offset_changed_handler
	};
	scroll_layer_set_callbacks(thread_scroll_layer, scrollOverride);

	thread_title_layer = layer_create(GRect(0, 0, window_frame.size.w, 22));
	layer_set_update_proc(thread_title_layer, thread_title_layer_update_proc);
	scroll_layer_add_child(thread_scroll_layer, thread_title_layer);

	layer_add_child(window_get_root_layer(window), scroll_layer_get_layer(thread_scroll_layer));

	thread_view_comments_layer = text_layer_create(GRect(0, 0, window_frame.size.w, LOAD_COMMENTS_HEIGHT));
	text_layer_set_text(thread_view_comments_layer, "View Comments");
	text_layer_set_font(thread_view_comments_layer, GetBiggerFont());
	text_layer_set_text_alignment(thread_view_comments_layer, GTextAlignmentCenter);
	scroll_layer_add_child(thread_scroll_layer, text_layer_get_layer(thread_view_comments_layer));

	thread_inverter_hidden = true;
	thread_inverter_layer = inverter_layer_create(GRect(0, 0, window_frame.size.w, LOAD_COMMENTS_HEIGHT));
	layer_set_hidden(inverter_layer_get_layer(thread_inverter_layer), true);
	scroll_layer_add_child(thread_scroll_layer, inverter_layer_get_layer(thread_inverter_layer));

	if(thread->type == 1)
	{
		// we are an image
		thread_body_layer = NULL;

		thread_bitmap_layer = bitmap_layer_create(GRect(0, 22, window_frame.size.w, window_frame.size.h));
		scroll_layer_add_child(thread_scroll_layer, bitmap_layer_get_layer(thread_bitmap_layer));

		scroll_layer_set_content_size(thread_scroll_layer, GSize(window_frame.size.w, 22 + window_frame.size.h + 10));

		thread_update_comments_position();
	}
	else
	{
		//current_thread.image = NULL;
		thread_bitmap_layer = NULL;

		thread_body_layer = text_layer_create(GRect(0, 22, window_frame.size.w, 10000));
		text_layer_set_font(thread_body_layer, GetFont());
		scroll_layer_add_child(thread_scroll_layer, text_layer_get_layer(thread_body_layer));
	}
}
Example #2
0
void storyview_init(char *title, char *summary) {
	window = window_create();

	Layer *window_layer = window_get_root_layer(window);
	GRect bounds = layer_get_bounds(window_layer);
	GRect max_text_bounds = GRect(2, 0, bounds.size.w - 4, 2000);

	scroll_layer = scroll_layer_create(bounds);
	scroll_layer_set_click_config_onto_window(scroll_layer, window);

	title_layer = text_layer_create(max_text_bounds);
	text_layer_set_font(title_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
	text_layer_set_text(title_layer, title);

	GSize title_max_size = text_layer_get_content_size(title_layer);
	text_layer_set_size(title_layer, GSize(title_max_size.w, title_max_size.h + 14));

	summary_layer = text_layer_create(GRect(2, title_max_size.h + 14, max_text_bounds.size.w, max_text_bounds.size.h - (title_max_size.h + 14)));
	text_layer_set_font(summary_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
	text_layer_set_text(summary_layer, summary);

	GSize summary_max_size = text_layer_get_content_size(summary_layer);
	text_layer_set_size(summary_layer, GSize(summary_max_size.w, summary_max_size.h + 14));

	scroll_layer_set_content_size(scroll_layer, GSize(bounds.size.w, title_max_size.h + 14 + summary_max_size.h + 8));

	scroll_layer_add_child(scroll_layer, text_layer_get_layer(title_layer));
	scroll_layer_add_child(scroll_layer, text_layer_get_layer(summary_layer));

	layer_add_child(window_layer, scroll_layer_get_layer(scroll_layer));
}
Example #3
0
/**
 * Initializates the GUI Elements
 */
void about_window_load (Window *window) {
	GRect windowBounds = layer_get_frame(ui.windowLayer);
	GRect titleBounds = GRect(0, 0, windowBounds.size.w, 30);
	ui.titleLayer = text_layer_create(titleBounds);
	text_layer_set_text_color(ui.titleLayer, GColorWhite);
	text_layer_set_background_color(ui.titleLayer, GColorBlack);
	text_layer_set_text(ui.titleLayer, "About");
  	text_layer_set_font(ui.titleLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  	text_layer_set_text_alignment(ui.titleLayer, GTextAlignmentCenter);
	layer_add_child(ui.windowLayer, text_layer_get_layer(ui.titleLayer));
	
	// Creates the Scroll
	GRect scrollBounds = GRect(0, 30, windowBounds.size.w, (windowBounds.size.h - 30));
	ui.scroll = scroll_layer_create(scrollBounds);
	scroll_layer_set_click_config_onto_window(ui.scroll, ui.window);
	layer_add_child(ui.windowLayer, scroll_layer_get_layer(ui.scroll));
	
	GRect textBounds = GRect(0, 0, scrollBounds.size.w, 2000);
	ui.textLayer = text_layer_create(textBounds);
	text_layer_set_text_color(ui.textLayer, GColorBlack);
	text_layer_set_background_color(ui.textLayer, GColorClear);
	text_layer_set_text(ui.textLayer, "Developer:\nYago Carballo ([email protected])\n\nGame By...\nameiga 2014\n\n");
  	text_layer_set_font(ui.textLayer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  	text_layer_set_text_alignment(ui.textLayer, GTextAlignmentCenter);
	
	GSize max_size = text_layer_get_content_size(ui.textLayer);
	text_layer_set_size(ui.textLayer, max_size);
	scroll_layer_set_content_size(ui.scroll, GSize(windowBounds.size.w, max_size.h + 5));
	scroll_layer_add_child(ui.scroll, text_layer_get_layer(ui.textLayer));
}
// Setup the scroll layer on window load
// We do this here in order to be able to get the max used text size
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  GRect max_text_bounds = GRect(0, 0, bounds.size.w, 2000);

  // Initialize the scroll layer
  scroll_layer = scroll_layer_create(bounds);

  // This binds the scroll layer to the window so that up and down map to scrolling
  // You may use scroll_layer_set_callbacks to add or override interactivity
  scroll_layer_set_click_config_onto_window(scroll_layer, window);

  // Initialize the text layer
  text_layer = text_layer_create(max_text_bounds);
  text_layer_set_text(text_layer, scroll_text);

  // Change the font to a nice readable one
  // This is system font; you can inspect pebble_fonts.h for all system fonts
  // or you can take a look at feature_custom_font to add your own font
  text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));

  // Trim text layer and scroll content to fit text box
  GSize max_size = text_layer_get_content_size(text_layer);
  text_layer_set_size(text_layer, max_size);
  scroll_layer_set_content_size(scroll_layer, GSize(bounds.size.w, max_size.h + vert_scroll_text_padding));

  // Add the layers for display
  scroll_layer_add_child(scroll_layer, text_layer_get_layer(text_layer));

  // The inverter layer will highlight some text
  inverter_layer = inverter_layer_create(GRect(0, 28, bounds.size.w, 28));
  scroll_layer_add_child(scroll_layer, inverter_layer_get_layer(inverter_layer));

  layer_add_child(window_layer, scroll_layer_get_layer(scroll_layer));
}
Example #5
0
void setup_message_layer() {
	int header_height = get_header_height();
	int text_height = get_text_height();
	setup_header(header_height);
	layer_set_frame(text_layer_get_layer(messagetext_layer), GRect(0, header_height, 144, text_height));
	scroll_layer_set_content_offset(message_layer, GPoint(0, 0), false);
	scroll_layer_set_content_size(message_layer, GSize(144, header_height + text_height));
	layer_set_hidden(scroll_layer_get_layer(message_layer), false);
}
Example #6
0
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  s_scroll_layer = scroll_layer_create(bounds);
  scroll_layer_set_click_config_onto_window(s_scroll_layer, window);
  scroll_layer_set_shadow_hidden(s_scroll_layer, true);
  layer_add_child(window_layer, scroll_layer_get_layer(s_scroll_layer));

  // Get the ContentIndicator from the ScrollLayer
  s_indicator = scroll_layer_get_content_indicator(s_scroll_layer);
  
  // Create two Layers to draw the arrows
  s_indicator_up_layer = layer_create(GRect(bounds.origin.x, bounds.origin.y, 
                                      bounds.size.w, STATUS_BAR_LAYER_HEIGHT));
  s_indicator_down_layer = layer_create(GRect(0, bounds.size.h - STATUS_BAR_LAYER_HEIGHT, 
                                        bounds.size.w, STATUS_BAR_LAYER_HEIGHT));
  layer_add_child(window_layer, s_indicator_up_layer);
  layer_add_child(window_layer, s_indicator_down_layer);

  // Configure the properties of each indicator
  const ContentIndicatorConfig up_config = (ContentIndicatorConfig) {
    .layer = s_indicator_up_layer,
    .times_out = false,
    .alignment = GAlignCenter,
    .colors = {
      .foreground = GColorBlack,
      .background = GColorWhite
    }
  };
  content_indicator_configure_direction(s_indicator, ContentIndicatorDirectionUp, 
                                        &up_config);

  const ContentIndicatorConfig down_config = (ContentIndicatorConfig) {
    .layer = s_indicator_down_layer,
    .times_out = false,
    .alignment = GAlignCenter,
    .colors = {
      .foreground = GColorBlack,
      .background = GColorWhite
    }
  };
  content_indicator_configure_direction(s_indicator, ContentIndicatorDirectionDown, 
                                        &down_config);

  s_content_layer = text_layer_create(GRect(bounds.origin.x, bounds.origin.y, bounds.size.w, 2000));
  text_layer_set_text(s_content_layer, s_content);
  text_layer_set_text_alignment(s_content_layer, GTextAlignmentCenter);
  text_layer_set_font(s_content_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_content_layer));

  GSize text_size = text_layer_get_content_size(s_content_layer);
  layer_set_frame(text_layer_get_layer(s_content_layer), 
                  GRect(bounds.origin.x, bounds.origin.y, bounds.size.w, text_size.h));
  scroll_layer_set_content_size(s_scroll_layer, text_size);
}
static void window_load(Window *window) {
    Layer *window_layer = window_get_root_layer(window);
    GRect bounds = layer_get_bounds(window_layer);

    s_title_layer = stats_window_common_create_title(bounds,  "SETS DURATION");
    
    s_scroll_layer = scroll_layer_create(bounds);
    scroll_layer_set_click_config_onto_window(s_scroll_layer, window);
    scroll_layer_set_content_size(s_scroll_layer, GSize(bounds.size.w, bounds.size.h * 1.7));
    
    scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_title_layer));

    MatchStatistics score_detail= match_statistics_get();

    // score_detail.set_duration[0] = 45* 60;
    // score_detail.set_duration[1] = 53 * 60;
    // score_detail.set_duration[2] = 33 * 60;
    // score_detail.set_duration[3] = 62 * 60;
    // score_detail.set_duration[4] = 39 * 60;    

    int start_from_y =PBL_IF_ROUND_ELSE(40, 30);

    int box_h = 40;
    float every_y = box_h +2;

    for (int i = 0; i < 5; ++i)
    {
        int hours = score_detail.set_duration[i] / 3600;
        int minutes = (score_detail.set_duration[i] / 60) % 60; 
        int seconds = score_detail.set_duration[i] % 60;        
        
        snprintf(buffer_sets_time[i], sizeof(buffer_sets_time[i]), "%.2d:%.2d:%.2d\n", hours, minutes, seconds);
        
        APP_LOG(APP_LOG_LEVEL_DEBUG, "*** window_load  *** set %d lasted %d seconds", 
            i, (int)score_detail.set_duration[i]);

        int padding = PBL_IF_ROUND_ELSE(64, 28);
        int box_x = padding / 2 ;
        int box_w = bounds.size.w - padding;
        s_sets_time_layer[i] = stats_window_common_create_layer(
            GRect(
                box_x, start_from_y + (i * every_y),
                box_w, box_h), 
            buffer_sets_time[i]);

        
        int num_x = PBL_IF_ROUND_ELSE(18, 2);;
        int num_y = start_from_y + (i * every_y) + (box_h / 4);        
        snprintf(buffer_sets_num[i], sizeof(buffer_sets_num[i]), "%d\n", i + 1);
        s_sets_num_layer[i] =create_set_num_layer(GRect(num_x, num_y, 13, 20), buffer_sets_num[i]);

        scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_sets_time_layer[i]));
        scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_sets_num_layer[i]));
        layer_add_child(window_layer, scroll_layer_get_layer(s_scroll_layer));
    }
}
void scroll_text_layer_set_text(ScrollTextLayer* layer, char* text) {
  if (layer == NULL) {
    return;
  }
  text_layer_set_text(layer->text_layer, text);
  GSize max_size = text_layer_get_content_size(layer->text_layer);
  text_layer_set_size(layer->text_layer, max_size);
  GRect bounds = layer_get_bounds(scroll_layer_get_layer(layer->scroll_layer));
  scroll_layer_set_content_size(layer->scroll_layer, GSize(bounds.size.w, max_size.h + (PADDING_Y * 3)));
}
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);

  s_icon_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ICONO_PRINCIPAL);
  GRect bitmap_bounds = gbitmap_get_bounds(s_icon_bitmap);


  s_fondo_layer = bitmap_layer_create(GRect(0, 0, 144, 40));
  bitmap_layer_set_background_color(s_fondo_layer, COLOR_CABECERA);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_fondo_layer));



  s_scroll_layer = scroll_layer_create(GRect(10, 10 + bitmap_bounds.size.h + 5, 124, 168 - (10 + bitmap_bounds.size.h + 10)));
  scroll_layer_set_click_config_onto_window(s_scroll_layer, window);
  
  GRect bounds = layer_get_frame(window_layer);
  GRect max_text_bounds = GRect(0, 0, 120, 2000);
  s_label_layer = text_layer_create(max_text_bounds);
  text_layer_set_text(s_label_layer, i_lineas);
  text_layer_set_text_color(s_label_layer, COLOR_TEXTO_CUERPO);  
  text_layer_set_background_color(s_label_layer, GColorClear);
  if (i_total_lineas> 3)
    text_layer_set_font(s_label_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  else
    text_layer_set_font(s_label_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
    
  //layer_add_child(window_layer, text_layer_get_layer(s_label_layer));
  
  
  
    // Trim text layer and scroll content to fit text box
  GSize max_size = text_layer_get_content_size(s_label_layer);
  text_layer_set_size(s_label_layer, max_size);
  scroll_layer_set_content_size(s_scroll_layer, GSize(bounds.size.w, max_size.h + 4));
  scroll_layer_set_shadow_hidden(s_scroll_layer, true);
  scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_label_layer));
  layer_add_child(window_layer, scroll_layer_get_layer(s_scroll_layer));

  // CAPA DE LA PARADA
  s_titulo_layer = text_layer_create(GRect(38, 0 , 101, 40));
  text_layer_set_text(s_titulo_layer, string_parada);
  text_layer_set_background_color(s_titulo_layer, GColorClear );
  text_layer_set_text_color(s_titulo_layer, COLOR_TEXTO_CABECERA );
  text_layer_set_text_alignment(s_titulo_layer, GTextAlignmentCenter);
  text_layer_set_font(s_titulo_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  layer_add_child(window_layer, text_layer_get_layer(s_titulo_layer));
  // FIN DE CAPA DE LA PARADA
  
  // CAPA DEL ICONO DEL BUS
  s_icon_layer = bitmap_layer_create(GRect(5, 5, bitmap_bounds.size.w, bitmap_bounds.size.h));
  bitmap_layer_set_bitmap(s_icon_layer, s_icon_bitmap);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_icon_layer));
  // FIN DE LA CAPA
}
Example #10
0
// Setup the scroll layer on window load
// We do this here in order to be able to get the max used text size
static void traveltime_details_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  GRect max_text_bounds = GRect(10, 90, bounds.size.w - 20, 60);
  GRect from_text_bounds = GRect(10, 10, bounds.size.w - 20, 30);
  GRect name_text_bounds = GRect(10, 30, bounds.size.w - 20, 40);
  GRect bkg_text_bounds = GRect(0, 70, bounds.size.w, bounds.size.h);
  
  // Initialize the scroll layer
  traveltime_details_scroll_layer = scroll_layer_create(bounds);
  
  // This binds the scroll layer to the window so that up and down map to scrolling
  // You may use scroll_layer_set_callbacks to add or override interactivity
  scroll_layer_set_click_config_onto_window(traveltime_details_scroll_layer, window);
  
  // Initialize the text layers
  traveltime_from_text_layer = text_layer_create(from_text_bounds);
  text_layer_set_text(traveltime_from_text_layer, "Depuis");
  text_layer_set_font(traveltime_from_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
  
  traveltime_name_text_layer = text_layer_create(name_text_bounds);
  text_layer_set_text(traveltime_name_text_layer, traveltimes_menu_items[current_traveltime_idx].title);
  text_layer_set_font(traveltime_name_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  
  traveltime_details_text_layer = text_layer_create(max_text_bounds);
  text_layer_set_text(traveltime_details_text_layer, traveltimes_menu_items[current_traveltime_idx].subtitle);
  text_layer_set_font(traveltime_details_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  
  // Trim text layer and scroll content to fit text box
  GSize max_size = text_layer_get_content_size(traveltime_details_text_layer);
  //text_layer_set_size(traveltime_details_text_layer, max_size);
  scroll_layer_set_content_size(traveltime_details_scroll_layer, GSize(bounds.size.w, max_size.h + 104));
  
  traveltime_bkg_text_layer = text_layer_create(bkg_text_bounds);
  
#ifdef PBL_COLOR
  text_layer_set_background_color(traveltime_bkg_text_layer, GColorBlack);
  text_layer_set_background_color(traveltime_from_text_layer, GColorIslamicGreen);
  text_layer_set_background_color(traveltime_name_text_layer, GColorIslamicGreen);
  text_layer_set_background_color(traveltime_details_text_layer, GColorBlack);
  text_layer_set_text_color(traveltime_from_text_layer, GColorWhite);
  text_layer_set_text_color(traveltime_name_text_layer, GColorWhite);
  text_layer_set_text_color(traveltime_details_text_layer, GColorYellow);
#endif
  
  // Add the layers for display
  scroll_layer_add_child(traveltime_details_scroll_layer, text_layer_get_layer(traveltime_bkg_text_layer));
  scroll_layer_add_child(traveltime_details_scroll_layer, text_layer_get_layer(traveltime_from_text_layer));
  scroll_layer_add_child(traveltime_details_scroll_layer, text_layer_get_layer(traveltime_name_text_layer));
  scroll_layer_add_child(traveltime_details_scroll_layer, text_layer_get_layer(traveltime_details_text_layer));

  layer_add_child(window_layer, scroll_layer_get_layer(traveltime_details_scroll_layer));
}
Example #11
0
File: app.c Project: abi93k/explore
/**
 * Called when a result item is selected
 * @param index
 * @param ctx
 */
static void result_select_callback(int index, void *ctx) { //Called when a caregory menu item is selected 
  g_index=index;
  

  window_stack_push(d_window, animated); 
  text_layer_set_text(d_text_layer, detail[index]);
  GSize max_size = text_layer_get_content_size(d_text_layer);


  scroll_layer_set_content_size (d_scroll_layer, max_size );


}
Example #12
0
void thread_update_comments_position()
{
	scroll_layer_size = scroll_layer_get_content_size(thread_scroll_layer);

	Layer *layer = text_layer_get_layer(thread_view_comments_layer);

	GRect rect = layer_get_frame(layer);
	rect.origin.y = scroll_layer_size.h;
	layer_set_frame(layer, rect);

	scroll_layer_size.h += LOAD_COMMENTS_HEIGHT;

	scroll_layer_set_content_size(thread_scroll_layer, scroll_layer_size);
}
Example #13
0
static void window_load(Window *window) {

  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  GRect max_text_bounds = GRect(0, 0, bounds.size.w, 2000);

  // Initialize the scroll layer
  s_scroll_layer = scroll_layer_create(GRect(0, 55, bounds.size.w, 98));

  // This binds the scroll layer to the window so that up and down map to scrolling
  // You may use scroll_layer_set_callbacks to add or override interactivity
  scroll_layer_set_click_config_onto_window(s_scroll_layer, window);
  
  // Initialize the social messages scrolling text layer
  s_text_layer = text_layer_create(max_text_bounds);
  text_layer_set_text(s_text_layer, s_scroll_text);
  text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));

  // Trim text layer and scroll content to fit text box
  GSize max_size = text_layer_get_content_size(s_text_layer);
  text_layer_set_size(s_text_layer, max_size);
  scroll_layer_set_content_size(s_scroll_layer, GSize(bounds.size.w, max_size.h + 4));

  // Add the layers for display
  scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_text_layer));
  layer_add_child(window_layer, scroll_layer_get_layer(s_scroll_layer));

  // Set the text of the application name layer
  text_layer_app_name = text_layer_create(GRect(0, 0, bounds.size.w, 20));
  text_layer_set_text(text_layer_app_name, "UbiSwim.org");
  text_layer_set_text_alignment(text_layer_app_name, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(text_layer_app_name));

  // Set the text of the social likes layer
  text_layer_likes = text_layer_create(GRect(0, 20, bounds.size.w, 40));
  text_layer_set_font(text_layer_likes, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); 
  text_layer_set_text(text_layer_likes, "Likes:");
  text_layer_set_text_alignment(text_layer_likes, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(text_layer_likes));

  // Set the text of the info layer
  text_layer_msg = text_layer_create(GRect(0, 150, bounds.size.w, 30));
  text_layer_set_text(text_layer_msg, "U:Prev M:Like D:Next");
  text_layer_set_text_alignment(text_layer_msg, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(text_layer_msg));

  // Set the click config provider for the scrolling text layer
  scroll_layer_set_callbacks(s_scroll_layer, (ScrollLayerCallbacks) {
        .click_config_provider = &click_config_provider_updown
      });
static void detail_window_load(Window *window)
{
  #ifdef PBL_COLOR
    window_colorize(window);
  #endif

  // set up text layer
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  int16_t content_width = bounds.size.w-10;

  // Initialize the text layers
  GRect max_title_bounds = GRect(5, 0, content_width, 2000);
  s_detail_title_text_layer = detail_text_layer_create(max_title_bounds, s_detail_title, true);
  GSize title_size = text_layer_get_content_size(s_detail_title_text_layer);
  title_size.w = content_width;

  GRect max_text_bounds = GRect(5, title_size.h+2, content_width, 2000);
  s_detail_text_layer = detail_text_layer_create(max_text_bounds, s_detail_text, false);

  // Initialize the scroll layer
  s_detail_scroll_layer = scroll_layer_create(bounds);

  // This binds the scroll layer to the window so that up and down map to scrolling
  // You may use scroll_layer_set_callbacks to add or override interactivity
  scroll_layer_set_click_config_onto_window(s_detail_scroll_layer, window);

  // Add the layers for display

  scroll_layer_add_child(s_detail_scroll_layer, text_layer_get_layer(s_detail_text_layer));
  scroll_layer_add_child(s_detail_scroll_layer, text_layer_get_layer(s_detail_title_text_layer));

  layer_add_child(window_layer, scroll_layer_get_layer(s_detail_scroll_layer));

  // Trim text layer and scroll content to fit text box
  // GSize title_size = text_layer_get_content_size(s_detail_title_text_layer);
  title_size.w = content_width;
  title_size.h += 5;
  GSize text_size = text_layer_get_content_size(s_detail_text_layer);
  text_size.h += title_size.h;
  text_size.w = content_width;

  text_layer_set_size(s_detail_title_text_layer, title_size);
  text_layer_set_size(s_detail_text_layer, text_size);

  scroll_layer_set_content_size(s_detail_scroll_layer, GSize(bounds.size.w, title_size.h + text_size.h));
}
Example #15
0
static void history_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  history_scroller = scroll_layer_create(bounds);
  scroll_layer_set_click_config_onto_window(history_scroller, window);

  int items = current_history_batch * HISTORY_BATCH_SIZE +
    history[current_history_batch].last_event + 1;
  int width = 142;
  int margin = (bounds.size.w - width)/2;
  GSize max_size = GSize(bounds.size.w, (items + 9) * 19); // font size is 18, 5 newlines before and 4 after
  history_layer = text_layer_create(GRect(margin, 0, width, max_size.h));
  if ((current_history_batch == 0) && (history[0].last_event < 0)) {
    strcpy(history_text, "No history recorded.");
  }
  else {
    // int history_events = current_history_batch * HISTORY_BATCH_SIZE + history[current_history_batch].last_event + 1;
    // APP_LOG(APP_LOG_LEVEL_DEBUG, "%d history events", history_events);
    strcpy(history_text, "\n\n\n\n\n");
    for (int b=current_history_batch; b>=0; b--) {
      // APP_LOG(APP_LOG_LEVEL_DEBUG, "Processing batch %d", b);
      for (int e=history[b].last_event; e>=0; e--) {
        // APP_LOG(APP_LOG_LEVEL_DEBUG, "Feeling %d at %d (%d/%d)", history[b].mood[e], (int) history[b].event_time[e], e, b);
        struct tm *lt = localtime(&history[b].event_time[e]);
        strftime(timestr, sizeof(timestr), "%V %a %k:%M", lt);
        snprintf(event_text, sizeof(event_text), "%s %s\n", timestr, Moods[history[b].mood[e]]);
        strncat(history_text, event_text, sizeof(event_text));
      }
    }
  }
  strncat(history_text, "\n\n\n\n", 5);
  text_layer_set_text(history_layer, history_text);
  text_layer_set_font(history_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
  text_layer_set_overflow_mode(history_layer, GTextOverflowModeWordWrap);
  text_layer_set_text_color(history_layer, GColorBlack);
  text_layer_set_background_color(history_layer, GColorWhite);
  max_size = text_layer_get_content_size(history_layer);
  max_size.w = bounds.size.w;
  text_layer_set_size(history_layer, max_size);
  scroll_layer_set_content_size(history_scroller, max_size);
  scroll_layer_add_child(history_scroller, text_layer_get_layer(history_layer));
  scroll_layer_set_content_offset(history_scroller, GPoint(0, 40), true);
  layer_add_child(window_layer, scroll_layer_get_layer(history_scroller));
}
Example #16
0
static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  Tuple *tuple = dict_find(iterator, 0);
  if (!tuple) {
    APP_LOG(APP_LOG_LEVEL_ERROR, "The tuple was missing!");
    return;
  }
  s_speaking_enabled = true;
  APP_LOG(APP_LOG_LEVEL_INFO, "Got message: %s", tuple->value->cstring);
  snprintf(s_defn_buffer, sizeof(s_defn_buffer), "%s", tuple->value->cstring);
  //where the word and def show up
  
  GSize size = graphics_text_layout_get_content_size(s_defn_buffer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD),
                                        GRect(0, 0, 134, 1000), GTextOverflowModeWordWrap, GTextAlignmentCenter);
  layer_set_frame((Layer *)s_def_layer, GRect(5, 40, 134, size.h));
  scroll_layer_set_content_size(s_scroll_layer, GSize(144, 50 + size.h));
  text_layer_set_text(s_word_layer, s_last_text_buffer); 
  text_layer_set_text(s_def_layer, s_defn_buffer);
  window_stack_push(s_def_window, true);
}
Example #17
0
void note_data_received(DictionaryIterator* iterator){
  
  Tuple *t = dict_read_first(iterator);

  // For all items
  while(t != NULL) {
    // Which key was received?
    
      APP_LOG(APP_LOG_LEVEL_ERROR, "Key %d ", (int)t->key);
    
  
    // Look for next item
    t = dict_read_next(iterator);
  }
  uint16_t location = dict_find(iterator, 1)->value->uint16;
  uint16_t segmentLength = dict_find(iterator, 2)->value->uint16;
  memcpy((void *) &fullNote[location], dict_find(iterator, 4)->value->cstring, segmentLength);
  GSize maxSize = graphics_text_layout_get_content_size(fullNote, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD),
                                                        GRect(0, 0, 144, 1000), GTextOverflowModeWordWrap, GTextAlignmentLeft);
  if (maxSize.h < 168 - 16)
    maxSize.h = 168 - 16;

  text_layer_set_size(fullNoteText, maxSize);
  scroll_layer_set_content_size(scroller, maxSize);


  text_layer_set_text(fullNoteText, fullNote);

  if (segmentLength == 75){
    DictionaryIterator *iterator;
    app_message_outbox_begin(&iterator);
    
    dict_write_uint8(iterator, 0, 3);
    dict_write_uint16(iterator, 1, location + 75);
    
    app_message_outbox_send();
    
    app_comm_set_sniff_interval(SNIFF_INTERVAL_REDUCED);
    app_comm_set_sniff_interval(SNIFF_INTERVAL_NORMAL);
  }

}
static void parseStringIntoArray(char *passedString, char a_delim[]) {
	char *tmp = passedString;
	//char a_delim[] = ",";
	// Find the number of delimiters
	int delimNum = 1;		// Increment from 1 for the trailing string
	while (*tmp) {
		if (*a_delim == *tmp) {
			delimNum++;
		}
		tmp++;
	}
	//dispVal(delimNum, "Number of unique strings:");
	if (delimNum > CHECKLIST_MAX_ITEMS) {
		delimNum = CHECKLIST_MAX_ITEMS;		// Reset the number of items to show only the maximum amount
	}
	numItems = delimNum;
	//APP_LOG(APP_LOG_LEVEL_INFO, "Parsing string, heap usage: %d", (int)heap_bytes_used());

	//checklistItems = iso_realloc(checklistItems, delimNum * sizeof(char*) * MAXIMUM_LIST_ITEM_SIZE);
	if (checklistItems == NULL) {
		APP_LOG(APP_LOG_LEVEL_ERROR, "The reallocation of memory for checklistItems failed, most probably a lack of available heap.");
	}		// Reallocate enough memory for the checklist item array, returns null if failed and will error out.
	//memset(checklistItems, 0, sizeof(checklistItems));		// Reset all bytes in checklist items array to zero value
	tmp = passedString;
	int i = 0;
	for (int j = 0; j < delimNum; j++) {
		i = 0;
		while (*a_delim != *tmp && *tmp) {
			memcpy(&checklistItems[j][i], tmp, sizeof(char*));		// The address of the checklist item array increments by row every maximum list size (in characters)
			i++;
			tmp++;
		}
		tmp++;		// Increment to get passed the delimiter that stopped the while loop
		checklistItems[j][i] = 0;
		//APP_LOG(APP_LOG_LEVEL_INFO, "%s", checklistItems[j]);
	}

	sizeOfContent = CHECK_ICON_START + ((numItems + PBL_IF_RECT_ELSE(0,2)) * CHECK_ICON_HEIGHT);        // Add two extra items when using a round face to create an infinite scroll
	scroll_layer_set_content_size(s_checklist_scroll, GSize(144, sizeOfContent));
}
Example #19
0
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  GRect max_text_bounds = GRect(0, 0, bounds.size.w, 2000);

  // Initialize the scroll layer
  s_scroll_layer = scroll_layer_create(bounds);

  // This binds the scroll layer to the window so that up and down map to scrolling
  // You may use scroll_layer_set_callbacks to add or override interactivity
  scroll_layer_set_click_config_onto_window(s_scroll_layer, window);

  // Initialize the text layer
  s_text_layer = text_layer_create(max_text_bounds);
  text_layer_set_text(s_text_layer, s_scroll_text);

  // Change the font to a nice readable one
  // This is system font; you can inspect pebble_fonts.h for all system fonts
  // or you can take a look at feature_custom_font to add your own font
  text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  text_layer_set_background_color(s_text_layer, GColorClear);

#if defined(PBL_PLATFORM_APLITE)
  text_layer_set_text_color(s_text_layer, GColorBlack);
#else
  text_layer_set_text_color(s_text_layer, GColorWhite);
#endif

  // Trim text layer and scroll content to fit text box
  GSize max_size = text_layer_get_content_size(s_text_layer);
  text_layer_set_size(s_text_layer, max_size);
  scroll_layer_set_content_size(s_scroll_layer, GSize(bounds.size.w, max_size.h + 4));

  // Add the layers for display
  scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_text_layer));

  layer_add_child(window_layer, scroll_layer_get_layer(s_scroll_layer));
 
}
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  s_scroll_layer = scroll_layer_create(bounds);
  scroll_layer_set_click_config_onto_window(s_scroll_layer, window);
  layer_add_child(window_layer, scroll_layer_get_layer(s_scroll_layer));

  s_text_layer = text_layer_create(GRect(bounds.origin.x, bounds.origin.y, bounds.size.w, 2000));
  text_layer_set_text(s_text_layer, s_long_text);
  text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);
  text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_text_layer));

  scroll_layer_set_content_size(s_scroll_layer, text_layer_get_content_size(s_text_layer));

  // Must be after added to the view heirachy
  text_layer_enable_screen_text_flow_and_paging(s_text_layer, 2);

  // Enable ScrollLayer paging
  scroll_layer_set_paging(s_scroll_layer, true);
}
Example #21
0
void instruction_window_load(Window *window) {
  // set size variables for instructions
  short size = get_instruction_size(instruction_type);
  short height = get_instruction_height(instruction_type);
  ResHandle rh = get_resource_handle(instruction_type);

  // allocate text holder and load resource
  instruction_text_ptr = malloc(size*sizeof(char));
  reset_text();
  resource_load(rh, (uint8_t *)instruction_text_ptr, size*sizeof(char));

  // get bounds of the window and set bounds of text
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  GRect text_bounds = GRect(0, 0, bounds.size.w, height);

  // create layers
  s_instruction_scroll_layer = scroll_layer_create(bounds);
  s_instruction_text_layer = text_layer_create(text_bounds);

  // setup scroll view
  scroll_layer_set_content_size(s_instruction_scroll_layer, GSize(SCROLL_WIDTH,height));
  scroll_layer_set_click_config_onto_window(s_instruction_scroll_layer, s_instruction_window);

  // setup text view
  text_layer_set_text(s_instruction_text_layer, instruction_text_ptr);
  text_layer_set_text_alignment(s_instruction_text_layer, GTextAlignmentCenter);
  
  // add children
  layer_add_child(window_get_root_layer(s_instruction_window), scroll_layer_get_layer(s_instruction_scroll_layer));
  scroll_layer_add_child(s_instruction_scroll_layer, text_layer_get_layer(s_instruction_text_layer));

  scroll_layer_set_content_offset(s_instruction_scroll_layer, GPoint(0,0), false);

  // free memory
  free(instruction_text_ptr);
}
Example #22
0
static void window_appear(Window* window) {

  Layer* window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  scroll_layer = scroll_layer_create(bounds);
  scroll_layer_set_click_config_onto_window(scroll_layer, window);

#ifdef PBL_ROUND
  scroll_layer_set_paging(scroll_layer, true);
#endif

  urlab_logo = gbitmap_create_with_resource(RESOURCE_ID_URLAB_LOGO);
  GRect image_bound = gbitmap_get_bounds(urlab_logo);

  image_layer = bitmap_layer_create(GRect(0, 0, bounds.size.w, image_bound.size.h));
  bitmap_layer_set_bitmap(image_layer, urlab_logo);
  bitmap_layer_set_alignment(image_layer, GAlignCenter);

  scroll_layer_add_child(scroll_layer, bitmap_layer_get_layer(image_layer));

  text_layer = text_layer_create(GRect(0, image_bound.size.h, bounds.size.w , bounds.size.h / 2));
  text_layer_set_text (text_layer, about_text);
  text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);
#ifdef PBL_ROUND
  uint8_t inset = 4;
  text_layer_enable_screen_text_flow_and_paging(text_layer, inset);
#endif
  layer_add_child(window_layer, text_layer_get_layer(text_layer));

  scroll_layer_add_child(scroll_layer, text_layer_get_layer(text_layer));

  layer_add_child(window_layer, scroll_layer_get_layer(scroll_layer));

  scroll_layer_set_content_size(scroll_layer, GSize(bounds.size.w, image_bound.size.h + bounds.size.h / 2));
}
static void scroll_text_layer_update(ScrollTextLayer* layer) {
  GSize max_size = text_layer_get_content_size(layer->text_layer);
  text_layer_set_size(layer->text_layer, max_size);
  GRect bounds = layer_get_bounds(scroll_layer_get_layer(layer->scroll_layer));
  scroll_layer_set_content_size(layer->scroll_layer, GSize(bounds.size.w, max_size.h + (PADDING_Y * 3)));
}
Example #24
0
// load from beginning to end (to calculate runtimes) and put the text allways onto the top:
static void load_data(void){
  time_t time_stamp = 0;
  time_t period_since_begin = 0;
  time_t period_since_last_event = 0;
  
  if (app_worker_is_running()){
    snprintf(text_header, sizeof(text_header), "Worker is running\nLaunch result = %d\n%s", (int)AWresult, text_devider);
  } else {
    snprintf(text_header, sizeof(text_header), "Worker is NOT running\nLaunch result = %d\n%s", (int)AWresult, text_devider);
  }
  strcpy(text, "");
  //snprintf(text, TEXT_LENGTH, "%s", text_header);
  
  int read_pos = -1, write_pos = -1;
  int key = KEY_CURRENT_INDEX;
  int number_of_entries_read = 0;
  if (persist_exists(key)){
    read_pos = persist_read_int(key);
    write_pos = read_pos; //save which was the write_pos from the worker
    while (1){
      
      read_pos++;
      if (read_pos > NUMBER_OF_ENTRIES) read_pos = 0;
      if (read_pos < 0) read_pos = NUMBER_OF_ENTRIES-1;
      
      key = KEY_EVENT_STRING_001+read_pos;
      if (persist_exists(key)){
        uint8_t byte_array[3];
        persist_read_data(key, byte_array, sizeof(byte_array));
        
        //read time stamp:
        key = KEY_EVENT_TIME_STAMP_001+read_pos;
        if (persist_exists(key)){
          time_stamp = (time_t)persist_read_int(key);
          struct tm* loctime = localtime(&time_stamp);
          strftime(time_str, sizeof(time_str), "%Y-%m-%d_%H:%M:%S:\n", loctime);
          number_of_entries_read++;
        } else {
          snprintf(time_str, sizeof(time_str), "no time stamp found:\n");
          time_stamp = 0;
        }
        switch (byte_array[0]){ //message
          case 1: 
          case 2:
          case 3:
            period_begin = time_stamp;
            strcpy(text_buffer, text);
            snprintf(text, sizeof(text), "%s%s", text_devider, text_buffer);
            break;
        }
        period_since_begin = time_stamp - period_begin;
        period_since_last_event = time_stamp - last_event;
        if (byte_array[0] > 0) last_event = time_stamp;
        
        print_time(time1_str, sizeof(time1_str), period_since_begin, 0);
        print_time(time2_str, sizeof(time2_str), period_since_last_event, 0);
        
        strcpy(text_buffer, text);
        snprintf(text, TEXT_LENGTH, "%s    %d: %d %% --> %d %%\n    %s [%s]\n%s", time_str, byte_array[0], byte_array[2], byte_array[1], time1_str, time2_str, text_buffer);
      }
      
      if (read_pos == write_pos) break;
      if (number_of_entries_read > NUMBER_OF_ENTRIES_TO_SHOW) break;
    }
    
    strcpy(text_buffer, text);
    snprintf(text, TEXT_LENGTH, "%s%s\n", text_header, text_buffer);
  } else {
    snprintf(text, TEXT_LENGTH, "%sNo data found.\n", text_header);
  }
  
  text_layer_set_size(text_layer, GSize(bounds.size.w, 2000));
  text_layer_set_text(text_layer, text); 
  GSize max_size = text_layer_get_content_size(text_layer);
  text_layer_set_size(text_layer, max_size);
  scroll_layer_set_content_size(scroll_layer, GSize(bounds.size.w, max_size.h + 4 + STATUS_HIGH));
}
Example #25
0
static void main_window_load(Window *window) {

  Layer *window_layer = window_get_root_layer(window);
  GRect window_bounds = layer_get_bounds(window_layer);


  title_layer = text_layer_create(
    GRect(0, 0,window_bounds.size.w, window_bounds.size.h));
  text_layer_set_text_alignment(title_layer, GTextAlignmentCenter);
  text_layer_set_text(title_layer, "FloodWatch");
  text_layer_set_text_color(title_layer, GColorBlack);
  text_layer_set_background_color(title_layer, GColorClear);
  text_layer_set_font(title_layer, fonts_get_system_font(FONT_KEY_ROBOTO_CONDENSED_21));
  layer_add_child(window_layer, text_layer_get_layer(title_layer));

  region_layer = text_layer_create(
    GRect(0, 20,window_bounds.size.w, window_bounds.size.h));
  text_layer_set_text_alignment(region_layer, GTextAlignmentCenter);
  text_layer_set_text(region_layer, "Jakarta - Timur");
  text_layer_set_text_color(region_layer, GColorWhite);
  text_layer_set_background_color(region_layer, GColorClear);
  text_layer_set_font(region_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  layer_add_child(window_layer, text_layer_get_layer(region_layer));


  s_scroll_layer = scroll_layer_create(window_bounds);
 scroll_layer_set_click_config_onto_window(s_scroll_layer, window);
 scroll_layer_set_shadow_hidden(s_scroll_layer, true);
 layer_add_child(window_layer, scroll_layer_get_layer(s_scroll_layer));

 // Get the ContentIndicator from the ScrollLayer
 s_indicator = scroll_layer_get_content_indicator(s_scroll_layer);

 // Create two Layers to draw the arrows
 s_indicator_up_layer = layer_create(GRect(window_bounds.origin.x, window_bounds.origin.y,
                                     window_bounds.size.w, STATUS_BAR_LAYER_HEIGHT));
 s_indicator_down_layer = layer_create(GRect(0, window_bounds.size.h - STATUS_BAR_LAYER_HEIGHT,
                                       window_bounds.size.w, STATUS_BAR_LAYER_HEIGHT));
 layer_add_child(window_layer, s_indicator_up_layer);
 layer_add_child(window_layer, s_indicator_down_layer);

 // Configure the properties of each indicator
 const ContentIndicatorConfig up_config = (ContentIndicatorConfig) {
   .layer = s_indicator_up_layer,
   .times_out = false,
   .alignment = GAlignCenter,
   .colors = {
     .foreground = GColorBlack,
     .background = GColorLightGray
   }
 };
 content_indicator_configure_direction(s_indicator, ContentIndicatorDirectionUp,
                                       &up_config);

 const ContentIndicatorConfig down_config = (ContentIndicatorConfig) {
   .layer = s_indicator_down_layer,
   .times_out = false,
   .alignment = GAlignCenter,
   .colors = {
     .foreground = GColorBlack,
     .background = GColorLightGray
   }
 };
 content_indicator_configure_direction(s_indicator, ContentIndicatorDirectionDown,
                                       &down_config);

 reports_layer = text_layer_create(GRect(0, 50, window_bounds.size.w, 2000));
 text_layer_set_text(reports_layer, reports);
 text_layer_set_text_alignment(reports_layer, GTextAlignmentCenter);
 text_layer_set_font(reports_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
 text_layer_set_text_color(region_layer, GColorBlack);
 text_layer_set_background_color(region_layer, GColorClear);
 scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(reports_layer));

 GSize text_size = text_layer_get_content_size(reports_layer);
 layer_set_frame(text_layer_get_layer(reports_layer),
                 GRect(0, 50, window_bounds.size.w, text_size.h));
 scroll_layer_set_content_size(s_scroll_layer, text_size);
}