Exemplo n.º 1
0
static void window_load(Window *window)
{ 
  char * buff = (char*)malloc(100 * sizeof(char*));
  if(amount > 1) snprintf(buff, 100, "Are you sure you want to send $%2d.00 to %s?", (int)amount, cont_name);
  else snprintf(buff, 100, "Are you sure you want to send $0.10 to %s?", cont_name);
  tlayer = text_layer_create(GRect(0, 0, 144, 55 + 12));
  text_layer_set_text(tlayer, buff);
  text_layer_set_background_color(tlayer, GColorClear);
  text_layer_set_text_color(tlayer, GColorBlack);
  text_layer_set_text_alignment(tlayer, GTextAlignmentCenter);
  text_layer_set_font(tlayer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(tlayer));
  
  menu_layer = menu_layer_create(GRect(0, 55 + 12, 144, 152 - 55 - 12));
  menu_layer_set_click_config_onto_window(menu_layer, cpay_window);
  MenuLayerCallbacks callbacks = {
    .draw_row = (MenuLayerDrawRowCallback) draw_row_callback,
    .get_num_rows = (MenuLayerGetNumberOfRowsInSectionsCallback) num_rows_callback,
    .select_click = (MenuLayerSelectCallback) select_click_callback,
  };
  menu_layer_set_callbacks(menu_layer, NULL, callbacks);
  layer_add_child(window_get_root_layer(cpay_window), menu_layer_get_layer(menu_layer));
  free(buff);
}
 
void cpay_deinit()
{
  window_push--;
  window_destroy(cpay_window);
  menu_layer_destroy(menu_layer);
}
Exemplo n.º 2
0
void arrivals_init_menu(char *stop) {
	static char title[16];
	snprintf(title, sizeof(title), "Arrivals: %s", current_stop_id);

	window_init(&arrival_window, title);

	//15px to make room for the title bar.
	menu_layer_init(&_arrivalsMenu, GRect(0, 0, arrival_window.layer.frame.size.w, arrival_window.layer.frame.size.h-15));
	menu_layer_set_click_config_onto_window(&_arrivalsMenu, &arrival_window);

	static MenuLayerCallbacks arrivals_callbacks = {
		.draw_header = arrivals_draw_header,
		.draw_row = arrivals_draw_row,
		.get_cell_height = arrivals_get_cell_height,
		.get_header_height = arrivals_get_header_height,
		.get_num_rows = arrivals_get_num_rows,
		.get_num_sections = arrivals_get_num_sections,
		.select_click = arrivals_select_click,
		.select_long_click = arrivals_select_long_click,
		.selection_changed = arrivals_selection_changed
	};

	menu_layer_set_callbacks(&_arrivalsMenu, ctx, arrivals_callbacks);

	layer_add_child(&arrival_window.layer, menu_layer_get_layer(&_arrivalsMenu));

	window_stack_push(&arrival_window, true);

	arrivalsCount = 0;
	http_request_arrivals(stop);

}
Exemplo n.º 3
0
void window_load(Window *window)
{
  // Create time TextLayer
  window_layer = text_layer_create(GRect(0, 15, 144, 50));
  text_layer_set_background_color(window_layer, GColorClear);
  text_layer_set_text_color(window_layer, GColorBlack);
  text_layer_set_text(window_layer, "Article Topics");
  
  // Improve the layout to be more like a watchface
  text_layer_set_font(window_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  text_layer_set_text_alignment(window_layer, GTextAlignmentCenter);

  // Add it as a child layer to the Window's root layer
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(window_layer));
  
  
  // Menu Layer
  //Create it - 12 is approx height of the top bar
  menu_layer = menu_layer_create(GRect(0, 55, 144, 113 - 16));
 
  //Let it receive clicks
  menu_layer_set_click_config_onto_window(menu_layer, window);
 
  //Give it its callbacks
  MenuLayerCallbacks callbacks = {
      .draw_row = (MenuLayerDrawRowCallback) draw_row_callback,
      .get_num_rows = (MenuLayerGetNumberOfRowsInSectionsCallback) num_rows_callback,
      .select_click = (MenuLayerSelectCallback) select_click_callback
  };
  menu_layer_set_callbacks(menu_layer, NULL, callbacks);
  //Add to Window
  layer_add_child(window_get_root_layer(window), menu_layer_get_layer(menu_layer));
  // Menu Layer
  
}
Exemplo n.º 4
0
/*
 * Main window load callback
 */
static void main_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);

  menu_layer = menu_layer_create(layer_get_bounds(window_layer));
  menu_layer_set_callbacks(menu_layer, pebble_fonts, menu_callbacks);
  menu_layer_set_click_config_onto_window(menu_layer, window);

  layer_add_child(window_layer, menu_layer_get_layer(menu_layer));
}
Exemplo n.º 5
0
//----- Begin main menu window load/unload
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect frame = layer_get_frame(window_layer);

  menu_layer_main_menu = menu_layer_create(frame);
  menu_layer_set_click_config_onto_window(menu_layer_main_menu, window);
  menu_layer_set_callbacks(menu_layer_main_menu, NULL, menu_layer_callbacks);
  
  layer_add_child(window_layer, menu_layer_get_layer(menu_layer_main_menu));
}
Exemplo n.º 6
0
static void window_load(Window *window) {
    Layer* window_layer = window_get_root_layer(window);
    GRect bounds = layer_get_bounds(window_layer);
    
    menu_layer = menu_layer_create(GRect(0,0,bounds.size.w,bounds.size.h));
	menu_layer_set_click_config_onto_window(menu_layer, window);
	cbacks.get_num_rows = &menu_layer_get_num_rows_in_section;
	cbacks.get_cell_height = &menu_layer_get_cell_height; 
	cbacks.select_click = &menu_layer_select_click; 
	cbacks.draw_row = &menu_layer_draw_row;
	menu_layer_set_callbacks(menu_layer, NULL, cbacks);
	layer_add_child(window_get_root_layer(window), menu_layer_get_layer(menu_layer));
}
Exemplo n.º 7
0
void menu_load(Window *window) {
  menu_layer = menu_layer_create(GRect(0, 0, 144, 154));

  num_rows = (uint16_t) get_data_keys(keys);

  // Prepare the callbacks
  menu_callbacks.draw_row = draw_row_callback;
  menu_callbacks.get_num_rows = get_num_rows_callback;
  menu_callbacks.select_click = select_click_callback;
  menu_layer_set_callbacks(menu_layer, 0, menu_callbacks);

  layer_add_child(window_get_root_layer(window), menu_layer_get_layer(menu_layer));

  menu_layer_set_click_config_onto_window(menu_layer, window);
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Menu layer added");
}
Exemplo n.º 8
0
void InboxCreate()
{
	window_init	(&s_window, "email window");
	window_set_fullscreen(&s_window, true);
	menu_layer_init	(&s_menu_layer, s_window.layer.frame);
	layer_add_child(&s_window.layer, &s_menu_layer.scroll_layer.layer);
	s_waitingForData = false;
	menu_layer_set_callbacks(&s_menu_layer,  0, s_callbacks);

	menu_layer_set_click_config_onto_window	(&s_menu_layer, &s_window);

	WindowHandlers wh =  {.appear = s_appear, .disappear = s_disapear};

	window_set_window_handlers(&s_window, wh);

}
Exemplo n.º 9
0
void emergency_conf_window_load(Window *window)
{
  //Create it - 12 is approx height of the top bar
  menu_layer = menu_layer_create(GRect(0, 0, 144, 168 - 16));

  //Let it receive clicks
  //menu_layer_set_click_config_onto_window(menu_layer, window);

  //Give it its callbacks
  MenuLayerCallbacks callbacks = {
    .draw_row = (MenuLayerDrawRowCallback) emergency_conf_draw_row_callback,
    .get_num_rows = (MenuLayerGetNumberOfRowsInSectionsCallback) emergency_conf_num_rows_callback,
    .select_click = (MenuLayerSelectCallback) emergency_conf_select_click_callback
  };
  menu_layer_set_callbacks(menu_layer, NULL, callbacks);

  //Add to Window
  layer_add_child(window_get_root_layer(window), menu_layer_get_layer(menu_layer));

}
Exemplo n.º 10
0
static inline void discover_menu_layer_callbacks_offset(MenuLayer *menu_layer) {
  if (menu_layer_callbacks_word_offset) return;
  MenuLayerCallbacks callbacks = {
    .get_num_rows = no_row_count_callback,
    .draw_row = no_draw_row
  };
  memset(&callbacks, 0, sizeof(callbacks));
  callbacks.get_num_rows = no_row_count_callback;
  callbacks.draw_row = no_draw_row;
  const void* callback_context = 0x32100123;
  menu_layer_set_callbacks(menu_layer, callback_context, callbacks);
  // There's no menu_layer_get_callbacks, we need to reverse-engineer it
  for (menu_layer_callbacks_word_offset = 0; menu_layer_callbacks_word_offset < 1024; menu_layer_callbacks_word_offset += 1) {
    if (MENULAYER_CALLBACKS(menu_layer).get_num_rows == callbacks.get_num_rows) break; // It's the first member in the struct
  }

  // Similarly for the callback context - it might be at a constant offset from the callbacks, but better safe than sorry
  for (menu_layer_context_word_offset = 0; menu_layer_context_word_offset < 1024; menu_layer_context_word_offset += 1) {
    if (MENULAYER_CALLBACK_CONTEXT(menu_layer) == callback_context) break;
  }
}
Exemplo n.º 11
0
void handle_init(AppContextRef ctx) {
  (void)ctx;

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


  menuCallbacks = (MenuLayerCallbacks) {
    .get_num_rows = num_rows,
    .get_num_sections = num_sections,
    .draw_row = draw_row,
    .selection_changed = selection_changed
  };

  menu_layer_init(&menu,GRect(0,0,144,168-16));
  menu_layer_set_callbacks(&menu, NULL, menuCallbacks);

  layer_add_child(&window.layer, menu_layer_get_layer(&menu));

  // Attach our desired button functionality
  window_set_click_config_provider(&window, (ClickConfigProvider) click_config_provider);
}
Exemplo n.º 12
0
void create_menu(Window *window) {
    menu_layer = menu_layer_create(GRect(0, STATUS_BAR_LAYER_HEIGHT, 144, MENU_HEIHGT));
    menu_layer_set_click_config_onto_window(menu_layer, window);
    
    MenuLayerCallbacks callbacks = {
        .draw_row = (MenuLayerDrawRowCallback) draw_row_callback,
        .get_num_rows = (MenuLayerGetNumberOfRowsInSectionsCallback)num_rows_callback,
        .get_num_sections = (MenuLayerGetNumberOfSectionsCallback)num_sections_callback,
        .get_header_height = (MenuLayerGetHeaderHeightCallback)header_height,
        .draw_header = (MenuLayerDrawHeaderCallback)draw_header_callback,
        .select_click = (MenuLayerSelectCallback)select_click_callback,
        .select_long_click = (MenuLayerSelectCallback)select_long_click_callback
    };
    menu_layer_set_callbacks(menu_layer, NULL, callbacks);
    
#ifdef PBL_COLOR
    menu_layer_set_normal_colors(menu_layer, GColorWhite, GColorDukeBlue);
    menu_layer_set_highlight_colors(menu_layer, GColorVividCerulean, GColorWhite);
#endif
    
    layer_add_child(window_get_root_layer(window), menu_layer_get_layer(menu_layer));
}
Exemplo n.º 13
0
void mainMenu_load(){
    Layer *window_layer = window_get_root_layer(window);
    GRect frame = layer_get_bounds(window_layer);

    mainMenu_layer = menu_layer_create(GRect(0,40,frame.size.w,frame.size.h-40));
    // set window's button callbacks to the MenuLayer's default button callbacks
    menu_layer_set_click_config_onto_window(mainMenu_layer, window);

    // http://developer.getpebble.com/2/api-reference/group___menu_layer.html#struct_menu_layer_callbacks
    mainMenu_callbacks.draw_header = &mainMenu_draw_header;
    mainMenu_callbacks.draw_row = &mainMenu_draw_row;
    // mainMenu_callbacks.draw_separator = NULL;       // get_seperator_height must also be null
    mainMenu_callbacks.get_cell_height = &mainMenu_get_cell_height;
    mainMenu_callbacks.get_header_height = &mainMenu_get_header_height;
    mainMenu_callbacks.get_num_rows = &mainMenu_get_num_rows_in_section;
    mainMenu_callbacks.get_num_sections = &mainMenu_get_num_sections;
    // mainMenu_callbacks.get_separator_height = NULL; // defaults to 1
    mainMenu_callbacks.select_click = &mainMenu_select_click;
    mainMenu_callbacks.select_long_click = &mainMenu_select_long_click;
    mainMenu_callbacks.selection_changed = NULL;    // ignore selection changes

    menu_layer_set_callbacks(mainMenu_layer, NULL, mainMenu_callbacks);
    layer_add_child(window_layer, menu_layer_get_layer(mainMenu_layer));
}
Exemplo n.º 14
0
void init(void)
{
	GRect frame;
	window = window_create();

	frame = layer_get_bounds(window_get_root_layer(window));

	mainMenu = menu_layer_create(GRect(0,0,frame.size.w,frame.size.h));
	menu_layer_set_click_config_onto_window(mainMenu, window); // Sets the Window's button callbacks to the MenuLayer's default button callbacks.
	// Set all of our callbacks.
	cbacks.get_num_sections = &mainMenu_get_num_sections; // Gets called at the beginning of drawing the table.
	cbacks.get_num_rows = &mainMenu_get_num_rows_in_section; // Gets called at the beginning of drawing each section.
	cbacks.get_cell_height = &mainMenu_get_cell_height; // Gets called at the beginning of drawing each normal cell.
	cbacks.get_header_height = &mainMenu_get_header_height; // Gets called at the beginning of drawing each header cell.
	cbacks.select_click = &mainMenu_select_click; // Gets called when select is pressed.
	cbacks.draw_row = &mainMenu_draw_row; // Gets called to set the content of a normal cell.
	cbacks.draw_header = &mainMenu_draw_header; // Gets called to set the content of a header cell.
	// cbacks.selection_changed = &func(struct MenuLayer *menu_layer, MenuIndex new_index, MenuIndex old_index, void *callback_context) // I assume this would be called whenever an up or down button was pressed.
	// cbacks.select_long_click = &func(struct MenuLayer *menu_layer, MenuIndex *cell_index, void *callback_context) // I didn't use this.
	menu_layer_set_callbacks(mainMenu, NULL, cbacks); // I have no user data to supply to the callback functions, so 
	layer_add_child(window_get_root_layer(window), menu_layer_get_layer(mainMenu));

	window_stack_push(window, true);
}