Пример #1
0
static void window_load(Window *window)
{
    unsigned int i;
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Loading %d items into menu...", num_stops);
    for (i = 0; i < num_stops; i++)
    {
        first_menu_items[i] = (SimpleMenuItem) {
            .title = stops_data[i][ROUTE_TITLE],
             .subtitle = stops_data[i][STOP_TITLE],
              .callback = menu_select_callback,
        };
    }

    menu_sections[0] = (SimpleMenuSection) {
        .title = "Favourited Stops",
         .num_items = num_stops,
          .items = first_menu_items,
    };

    Layer *menu_layer = window_get_root_layer(window);
    GRect menu_bounds = layer_get_frame(menu_layer);
    main_menu = simple_menu_layer_create(menu_bounds, window, menu_sections, NUM_MENU_SECTIONS, NULL);
    layer_add_child(menu_layer, simple_menu_layer_get_layer(main_menu));
}

void window_unload(Window *window) {
    simple_menu_layer_destroy(main_menu);
}
Пример #2
0
void menu_init(Layer *root_layer, GRect bounds)
{
	int item_index = 0;
	
	menu_items[item_index++] = (SimpleMenuItem) {
		.title = "Quick Departures",
		.callback = menu_select_callback
	};
	menu_items[item_index++] = (SimpleMenuItem) {
		.title = "Select Station",
		.callback = menu_select_callback
	};
	
	menu_sections[0] = (SimpleMenuSection) {
		.num_items = NUM_MENU_ITEMS,
		.items = menu_items
	};
	
	menu = simple_menu_layer_create(bounds, my_window, menu_sections, NUM_SECTIONS, NULL);
	
	layer_add_child(root_layer, simple_menu_layer_get_layer(menu));
}

void window_load(Window *window)
{
	Layer *root_layer = window_get_root_layer(my_window);
	title_layer_init(root_layer, GRect(0, 0, 144, 60));
	menu_init(root_layer, GRect(0, 63, 144, 105));
}

void window_unload(Window *window)
{
	text_layer_destroy(title_layer);
	simple_menu_layer_destroy(menu);
}
Пример #3
0
void nav_menu_window_unload(Window *mWindow) {// Deinitialize resources on window unload that were initialized on window load
	window_destroy(mWindow);
	setCurrentWindow("none");
  	simple_menu_layer_destroy(nav_menu_layer);
	nav_menu_layer = NULL;
	//APP_LOG(APP_LOG_LEVEL_DEBUG, "exiting show_nav_menu. Free: %d", heap_bytes_free());	 

}
Пример #4
0
static void main_window_load(Window *window) {
  s_menu_icon_image = gbitmap_create_with_resource(RESOURCE_ID_dice2);
  s_menu_score_image = gbitmap_create_with_resource(RESOURCE_ID_score);
   
  // an int as such to easily change the order of menu items later
  int num_a_items = 0;

  s_first_menu_items[num_a_items++] = (SimpleMenuItem) {
    .icon=s_menu_score_image, 
    .title = "Score Counter",
    .subtitle = "Up to 6 players,",
    .callback = menu_select_callback,
    
  };
  s_second_menu_items[0] = (SimpleMenuItem) {
    .icon=s_menu_icon_image,
    .title = "Dice Simulator",
    .callback = menu_select_callback,
  };

  s_second_menu_items[1] = (SimpleMenuItem) {
    .title = "Previous Dice Rolls",
    .callback = special_select_callback,
  };
  

  s_menu_sections[0] = (SimpleMenuSection) {
    .num_items = NUM_FIRST_MENU_ITEMS,
    .items = s_first_menu_items,
  };
  s_menu_sections[1] = (SimpleMenuSection) {
    .num_items = NUM_SECOND_MENU_ITEMS,
    .items = s_second_menu_items,
  };
  
//gBitmap_set_bounds(s_menu_icon_image,
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);

  s_simple_menu_layer = simple_menu_layer_create(bounds, window, s_menu_sections, NUM_MENU_SECTIONS, NULL);

  layer_add_child(window_layer, simple_menu_layer_get_layer(s_simple_menu_layer));
}

void main_window_unload(Window *window) {
  simple_menu_layer_destroy(s_simple_menu_layer);
  gbitmap_destroy(s_menu_icon_image);
}

static void init() {
  s_main_window = window_create();
  window_set_window_handlers(s_main_window, (WindowHandlers) {
    .load = main_window_load,
    .unload = main_window_unload,
  });
  window_stack_push(s_main_window, true);
}
Пример #5
0
static void window_unload(Window *window) {
 	free(new_str);	
	free(newDivString);	 	
	free(dispCourseDiv[0]);	
	free(dispCourseDiv);
	simple_menu_layer_destroy(menu_layer);
	free(menu_items); 
	window_destroy(window);
}
Пример #6
0
Файл: main.c Проект: asyba/UR
static void window_load(Window *window) {

  int num_a_items = 0;

  bus_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Media Players",
        .subtitle = "",
    .callback = bus1_select_callback,
  };
  bus_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "PC",
        .subtitle = "",
    .callback = bus2_select_callback,
  };
  bus_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Monitor",
        .subtitle = "",
    .callback = bus3_select_callback,
  };
  
  menu_sections[0] = (SimpleMenuSection){
  .title ="Control Category",
  .num_items = NUM_CLIENT_MENU_ITEMS,
  .items = bus_menu_items,
  };
      
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);

  simple_menu_layer = simple_menu_layer_create(bounds, window, menu_sections,NUM_MENU_SECTIONS, NULL);

  layer_add_child(window_layer, simple_menu_layer_get_layer(simple_menu_layer));
}
static void window_unload(Window *window) {
  simple_menu_layer_destroy(simple_menu_layer);
}

int main(void) {
  window = window_create();
    appmessage_init();

  window_set_window_handlers(window, (WindowHandlers) {
    .load = window_load,
    .unload = window_unload,
  });

  window_stack_push(window, true /* Animated */);

  APP_LOG(APP_LOG_LEVEL_DEBUG, "Done initializing, pushed window: %p", window);
	

  app_event_loop();

  window_destroy(window);
}
Пример #7
0
static void window_load(Window *window) {
  	num_a_items = 0;
	menu_items[num_a_items++] = (SimpleMenuItem){
      	.title = "-- START BOAT --",
	 	.subtitle = "Ping the stbd (boat) end. ",
    	.callback = menu_select_callback,
  };
  menu_items[num_a_items++] = (SimpleMenuItem){
    .title =  "---- START PIN ----",
	.subtitle = "Ping the port (pin) end. ",
     .callback = menu_select_callback,
  };
/*
	  menu_items[num_a_items++] = (SimpleMenuItem){
    .title =  "---- FINISH ----",
	.subtitle = "Ping the finish (time&loc'n). ",
     .callback = menu_select_callback,
  };	  menu_items[num_a_items++] = (SimpleMenuItem){
    .title =  "---- POI --(TBA) ----",
	.subtitle = "Ping a Point of Interest. ",
     .callback = menu_select_callback,
  };
*/
	// Bind the menu items to the corresponding menu sections
  menu_sections[0] = (SimpleMenuSection){
	  .title = "Ping Line menu",
    .num_items = 2,
    .items = menu_items,
  };
   Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
	menu_layer = simple_menu_layer_create(bounds, window, menu_sections, 1, NULL);

  layer_add_child(window_layer, simple_menu_layer_get_layer(menu_layer));
}
static void window_appear(){

}
static void window_unload(Window *window) {// Deinitialize resources on window unload that were initialized on window load
	window_destroy(window);
  	simple_menu_layer_destroy(menu_layer);
}

 void show_start_ping_menu(){
   	window = window_create();
	//window_set_fullscreen(window, true);
  	window_set_window_handlers(window, (WindowHandlers) {
    	.load = window_load,
    	.unload = window_unload,
		.appear = window_appear,
  });
	window_stack_push(window, true /* Animated */);
}
Пример #8
0
static void window_load(Window *window) {
  	num_a_items = 0;
	menu_items[num_a_items++] = (SimpleMenuItem){
      	.title = "---10 TEN mins ---",
	 	.subtitle = "Start 10 minute timer ",
    	.callback = menu_select_callback,
  };
  menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "---5 FIVE mins ---",
	.subtitle = "Start 5 minute timer ",
     .callback = menu_select_callback,
  };
	  menu_items[num_a_items++] = (SimpleMenuItem){
    .title =  "---4 FOUR mins ---",
	.subtitle = "Start 4 minute timer ",
     .callback = menu_select_callback,
  };
	// Bind the menu items to the corresponding menu sections
  menu_sections[0] = (SimpleMenuSection){
	  .title = "Start Timer Menu",
    .num_items = 3,
    .items = menu_items,
  };
	
	displayFields[GPSTIME] = text_layer_create(GRect(0, 0, 144, 30)); //GPS Time
  	text_layer_set_font( displayFields[GPSTIME],displayFont1);
	layer_add_child(window_get_root_layer(window), (Layer *)displayFields[GPSTIME]);
 	menu_layer = simple_menu_layer_create(GRect(0,30,144,138), window, menu_sections, 1, NULL);
	layer_set_update_proc((Layer *) menu_layer, refreshData);
 
  layer_add_child(window_get_root_layer(window), simple_menu_layer_get_layer(menu_layer));
}
static void window_appear(){

}
static void window_unload(Window *window) {// Deinitialize resources on window unload that were initialized on window load
	setCurrentWindow("none");
	window_destroy(window);
  	simple_menu_layer_destroy(menu_layer);
}

 void show_start_time_menu(){
   	window = window_create();
	//window_set_fullscreen(window, true);
	setCurrentWindow("start_time"); //Just GPS time
  	window_set_window_handlers(window, (WindowHandlers) {
    	.load = window_load,
    	.unload = window_unload,
		.appear = window_appear,
  });
	window_stack_push(window, true /* Animated */);
}
Пример #9
0
void destroy_run_menu_controller(RunMenuController* self) {
  if (active_controller == 0) {
    return;
  }
  
  simple_menu_layer_destroy(active_controller->menu);
  window_stack_remove(self->window, false);
  window_destroy(self->window);  

  active_controller = 0;
  
  free(self);
}
Пример #10
0
// what happens when you select a function
// initializing the menu when the window loads
void window_load(Window *window) {

    //Initialize the layer so that it is the same size on the watch face as the window
    Layer *window_layer = window_get_root_layer(window);
    GRect bounds = layer_get_frame(window_layer);

    /* Beginning here, we will set the menu items:
     * 	1) Quick Text
     *	2) Dial 911
     */

    int menu_item_count = 0;

    // define menu item number one
    main_menu_items[menu_item_count++] = (SimpleMenuItem) {
        .callback = menu_select_callback_text,
         .icon = gbitmap_create_with_resource(RESOURCE_ID_TEXT_PEBBLE_1), //TODO: will update later
          .title = "QuickText"
    };

    main_menu_items[menu_item_count++] = (SimpleMenuItem) {
        .callback = menu_select_callback,
         .icon = gbitmap_create_with_resource(RESOURCE_ID_ALERT_PEBBLE_1), //TODO: Will update later
          .title = "Call 911"
    };

    menu_sections[0] = (SimpleMenuSection) {
        .num_items = NUM_FIRST_MENU_ITEMS,
         .items = main_menu_items,
          .title = "Alertr"
    };

    main_menu = simple_menu_layer_create(bounds, main_window, menu_sections, NUM_MENU_SECTIONS, NULL);

    // add the main menu to the window
    layer_add_child(window_layer, simple_menu_layer_get_layer(main_menu));
}

void window_unload(Window *window) {
    simple_menu_layer_destroy(main_menu);
}

static void init() {
    main_window = window_create();
    window_set_window_handlers(main_window, (WindowHandlers) {
        .load = window_load,
         .unload =window_unload
    });

    window_stack_push(main_window, true);
}
Пример #11
0
void contact_window_load(Window *window){
  int curr_item = 0;

  contact_menu[curr_item++] = (SimpleMenuItem){
    .title = "C_Ryan",
    .callback = generic_callback,
  };

  contact_menu[curr_item++] = (SimpleMenuItem){
    .title = "C_Fedor",
    .callback = generic_callback,
  };

  contact_menu[curr_item++] = (SimpleMenuItem){
    .title = "C_Mike",
    .callback = generic_callback,
    .icon = contact_icon_image,
  };

  contact_menu_sections[0] = (SimpleMenuSection){
    .num_items = NUM_C_ITEMS,
    .items = contact_menu,
  };
  
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);

  contact_menu_layer = simple_menu_layer_create(bounds, window, contact_menu_sections, NUM_C_SECTIONS, NULL);

  layer_add_child(window_layer, simple_menu_layer_get_layer(contact_menu_layer));
}


void contact_window_unload(Window *window) {
  simple_menu_layer_destroy(contact_menu_layer);

  gbitmap_destroy(contact_icon_image);
}

void contact_list_callback(int index, void *ctx) {
  contact_window = window_create();

  window_set_window_handlers(contact_window, (WindowHandlers) {
    .load = contact_window_load,
    .unload = contact_window_unload,
  });

  window_stack_push(contact_window, true);

}
Пример #12
0
static void main_window_load(Window *window) {

    // Although we already defined NUM_FIRST_MENU_ITEMS, you can define
    // an int as such to easily change the order of menu items later
    int num_a_items = 0;

    s_first_menu_items[num_a_items++] = (SimpleMenuItem) {
        .title = "Quick Reply",
         .callback = menu_select_callback,
    };
    s_first_menu_items[num_a_items++] = (SimpleMenuItem) {
        .title = "Text Reply",

         .callback = menu_select_callback,
    };

    s_menu_sections[0] = (SimpleMenuSection) {
        .num_items = NUM_FIRST_MENU_ITEMS,
         .items = s_first_menu_items,
    };


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

    s_simple_menu_layer = simple_menu_layer_create(bounds, window, s_menu_sections, NUM_MENU_SECTIONS, NULL);

    layer_add_child(window_layer, simple_menu_layer_get_layer(s_simple_menu_layer));
}

void main_window_unload(Window *window) {
    simple_menu_layer_destroy(s_simple_menu_layer);

}

static void init() {
    app_message_register_inbox_received(in_received_handler); //
    app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum()); //
    s_main_window = window_create();
    window_set_window_handlers(s_main_window, (WindowHandlers) {
        .load = main_window_load,
         .unload = main_window_unload,
    });
Пример #13
0
/* Create the main menu window */
static void window_load(Window *window) {  
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  
  s_first_menu_items[0] = (SimpleMenuItem) {
    .title = "Current Temperature",
    .callback = current_temp_callback,
  };
  
  s_first_menu_items[1] = (SimpleMenuItem) {
    .title = "Statistics",
    .callback = statistics_callback,
  };
  
  s_first_menu_items[2] = (SimpleMenuItem) {
    .title = "Change Units",
    .subtitle = "Celsius",
    .callback = units_callback,
  };
  
  s_menu_sections[0] = (SimpleMenuSection) {
    .num_items = NUM_FIRST_MENU_ITEMS,
    .items = s_first_menu_items,
  };

  s_simple_menu_layer = simple_menu_layer_create(bounds, window, s_menu_sections, NUM_MENU_SECTIONS, NULL);
  
  hello_layer = text_layer_create((GRect) { .origin = { 0, 35 }, .size = { bounds.size.w, 120 } });
  text_layer_set_text_alignment(hello_layer, GTextAlignmentCenter);
  
  layer_add_child(window_layer, simple_menu_layer_get_layer(s_simple_menu_layer));
}

/* Called when the app is exited */
static void window_unload(Window *window) {
  text_layer_destroy(hello_layer);
  simple_menu_layer_destroy(s_simple_menu_layer);
}
Пример #14
0
static void window_load(Window *window) {

  int num_a_items = 0;
  int num_a2_items = 0;
  int num_a3_items = 0;
  int num_a4_items = 0;

  math_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Algebra",
	.subtitle = "Algebraic Formulas",
    .callback = algebra_select_callback,
  };
  math_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Geometry",
	.subtitle = "Geometric Formulas",
    .callback = geometry_select_callback,
  };
  math_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Trigonometry",
	.subtitle = "Trig Formulas",
    .callback = trig_select_callback,
  };
  math_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Calculus",
	.subtitle = "Calc Formulas",
    .callback = calc_select_callback,
  };
  //TC BEGIN
  trig_calc_menu_items[num_a2_items++] = (SimpleMenuItem){
    .title = "Trig",
	.subtitle = "Normal Trig",
    .callback = trig_deriv_select_callback,
  };
  trig_calc_menu_items[num_a2_items++] = (SimpleMenuItem){
    .title = "Inverse Trig",
  .subtitle = "Inverse Trig",
    .callback = inverse_trig_deriv_select_callback,
  };
  trig_calc_menu_items[num_a2_items++] = (SimpleMenuItem){
    .title = "Hyp. Trig",
  .subtitle = "Hyperbolic Trig",
    .callback = hyp_trig_select_callback,
  };
  trig_calc_menu_items[num_a2_items++] = (SimpleMenuItem){
    .title = "Inv. Hyp. Trig",
  .subtitle = "Inverse Hyp. Trig",
    .callback = inverse_hyp_trig_select_callback,
  };
  trig_calc_menu_items[num_a2_items++] = (SimpleMenuItem){
    .title = "Trig Limits",
  .subtitle = "Limits!",
    .callback = trig_limits_select_callback,
  };
  //TC END
  menu_sections[0] = (SimpleMenuSection){
  .title ="Math Formulas",
  .num_items = NUM_MATH_MENU_ITEMS,
  .items = math_menu_items,
  };
  menu_sections[1] = (SimpleMenuSection){
  .title ="Trig Calc Formulas",
  .num_items = NUM_TRIG_CALC_MENU_ITEMS,
  .items = trig_calc_menu_items,
  };
	
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);

  simple_menu_layer = simple_menu_layer_create(bounds, window, menu_sections,NUM_MENU_SECTIONS, NULL);

  layer_add_child(window_layer, simple_menu_layer_get_layer(simple_menu_layer));
}

static void window_unload(Window *window) {
  simple_menu_layer_destroy(simple_menu_layer);
}

int main(void) {
  window = window_create();


  window_set_window_handlers(window, (WindowHandlers) {
    .load = window_load,
    .unload = window_unload,
  });

  window_stack_push(window, true /* Animated */);

  app_event_loop();

  window_destroy(window);
}
Пример #15
0
void products_window_unload(Window *window) {
  data_framework_save_checkboxes();
  simple_menu_layer_destroy(s_products_menu_layer);
}
Пример #16
0
static void window_handler_unload(Window *w) {
  unload_expenses();
  simple_menu_layer_destroy(menu);
}
Пример #17
0
static void main_window_load(Window *window) {
/*  menu icon load
  s_menu_icon_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_MENU_ICON_1);
*/
  // Although we already defined NUM_FIRST_MENU_ITEMS, you can define
  // an int as such to easily change the order of menu items later
  int num_a_items = 0;

  s_first_menu_items[num_a_items++] = (SimpleMenuItem) {
    .title = "Weapon 1",
    .subtitle = "Choose This Weapon?",
    .callback = menu_select_callback,
  };
  s_first_menu_items[num_a_items++] = (SimpleMenuItem) {
    .title = "Weapon 2",
    .subtitle = "Choose This Weapon?",
    .callback = menu_select_callback,
  };
  s_first_menu_items[num_a_items++] = (SimpleMenuItem) {
    .title = "Third Item",
    .subtitle = "Choose This Weapon?",
    .callback = menu_select_callback,
    .icon = s_menu_icon_image,
  };

  s_second_menu_items[0] = (SimpleMenuItem) {
    .title = "Special Item",
    .callback = special_select_callback,
  };

  s_menu_sections[0] = (SimpleMenuSection) {
    .num_items = NUM_FIRST_MENU_ITEMS,
    .items = s_first_menu_items,
  };
  s_menu_sections[1] = (SimpleMenuSection) {
    .title = "Yet Another Section",
    .num_items = NUM_SECOND_MENU_ITEMS,
    .items = s_second_menu_items,
  };

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

  s_simple_menu_layer = simple_menu_layer_create(bounds, window, s_menu_sections, NUM_MENU_SECTIONS, NULL);

  layer_add_child(window_layer, simple_menu_layer_get_layer(s_simple_menu_layer));
}

void main_window_unload(Window *window) {
  simple_menu_layer_destroy(s_simple_menu_layer);
  gbitmap_destroy(s_menu_icon_image);
}

static void init() {
  s_main_window = window_create();
  window_set_window_handlers(s_main_window, (WindowHandlers) {
    .load = main_window_load,
    .unload = main_window_unload,
  });
  window_stack_push(s_main_window, true);
}

static void deinit() {
  window_destroy(s_main_window);
}

int main(void) {
  init();
  app_event_loop();
  deinit();
}
Пример #18
0
void makeRecipeSelectWindow(int index) {
  
  GRect frame;
  
	window2 = window_create();
	frame = layer_get_bounds(window_get_root_layer(window2));
  switch(index){
    case 0:
      menu_items[0] = (SimpleMenuItem){.title = "Asian-Chicken-Noodle-Soup", NULL, .callback = call_back_for_item,};
	    menu_items[1] = (SimpleMenuItem){.title = "Cilantro-Chicken-and-Spicy-Thai-Noodles", NULL, .callback = call_back_for_item,};
	    menu_items[2] = (SimpleMenuItem){.title = "Moroccan-Chicken-with-Green-Olives-and-Lemon", NULL, .callback = call_back_for_item,};
	    menu_items[3] = (SimpleMenuItem){.title = "Collard-Greens-with-Lentils-Tomatoes-and-Indian-Spices", NULL, .callback = call_back_for_item,};
	    menu_items[4] = (SimpleMenuItem){.title = "Aloo-Gobi", NULL, .callback = call_back_for_item,};   
    
    break;
    case 1:
      menu_items[0] = (SimpleMenuItem){.title = "Joes-Screaming-Stuffed-Jalapeno-Poppers", NULL, .callback = call_back_for_item,};
	    menu_items[1] = (SimpleMenuItem){.title = "Saucy-Asian-Meatballs", NULL, .callback = call_back_for_item,};
	    menu_items[2] = (SimpleMenuItem){.title = "Crme-De-Brie-Apple-Pinwheels", NULL, .callback = call_back_for_item,};
	    menu_items[3] = (SimpleMenuItem){.title = "Chicken-Enchilada-Puffs", NULL, .callback = call_back_for_item,};
	    menu_items[4] = (SimpleMenuItem){.title = "Spicy-Vegetable-Dip", NULL, .callback = call_back_for_item,};
	    
    break;
    case 2:
      menu_items[0] = (SimpleMenuItem){.title = "Potato-Casserole", NULL, .callback = call_back_for_item,};
	    menu_items[1] = (SimpleMenuItem){.title = "Egg-Sandwich", NULL, .callback = call_back_for_item,};
	    menu_items[2] = (SimpleMenuItem){.title = "Grilled-Cheese-Roast-Beef-Sandwiches", NULL, .callback = call_back_for_item,};
	    menu_items[3] = (SimpleMenuItem){.title = "Bacon-and-Cheese-Stuffed-Chicken", NULL, .callback = call_back_for_item,};
	    menu_items[4] = (SimpleMenuItem){.title = "Hot-Dog-Filled-Crescents", NULL, .callback = call_back_for_item,};
	   
      break;
   case 3:
      menu_items[0] = (SimpleMenuItem){.title = "Pizza-Pasta", NULL, .callback = call_back_for_item,};
	    menu_items[1] = (SimpleMenuItem){.title = "Pasta-Primavera", NULL, .callback = call_back_for_item,};
	    menu_items[2] = (SimpleMenuItem){.title = "Pasta-with-Pesto", NULL, .callback = call_back_for_item,};
	    menu_items[3] = (SimpleMenuItem){.title = "Pasta-Fagioli", NULL, .callback = call_back_for_item,};
	    menu_items[4] = (SimpleMenuItem){.title = "Pasta-Salad", NULL, .callback = call_back_for_item,};   
    
    break;
    case 4:
      menu_items[0] = (SimpleMenuItem){.title = "Green-Salad-with-Cranberry-Vinaigrette", NULL, .callback = call_back_for_item,};
	    menu_items[1] = (SimpleMenuItem){.title = "Spinach-Salad-with-Orzo-and-Feta", NULL, .callback = call_back_for_item,};
	    menu_items[2] = (SimpleMenuItem){.title = "Buffalo-Style-Chicken-Salad", NULL, .callback = call_back_for_item,};
	    menu_items[3] = (SimpleMenuItem){.title = "Cindys-Grilled-Salad", NULL, .callback = call_back_for_item,};
	    menu_items[4] = (SimpleMenuItem){.title = "Ceasar-Salad", NULL, .callback = call_back_for_item,};
	   
    break;
    case 5:
      menu_items[0] = (SimpleMenuItem){.title = "Helens-Lentil-Soup", NULL, .callback = call_back_for_item,};
	    menu_items[1] = (SimpleMenuItem){.title = "Boracho-Bean-Soup-or-Frijoles-a-La-Charra-Restaurant-Style", NULL, .callback = call_back_for_item,};
	    menu_items[2] = (SimpleMenuItem){.title = "Hearty-White-Bean-Soup", NULL, .callback = call_back_for_item,};
	    menu_items[3] = (SimpleMenuItem){.title = "Ham-Bean-Soup", NULL, .callback = call_back_for_item,};
	    menu_items[4] = (SimpleMenuItem){.title = "Easy-Bean-Soup-aka-Petras-Kitchen-Sink-Soup", NULL, .callback = call_back_for_item,};
    break;
    
  }
  menu_section2[0] = (SimpleMenuSection){.items = menu_items, .num_items = 6, .title = "receipe gettera 91241",};
	
	simple_menu_layer2 = simple_menu_layer_create(frame, window2, menu_section2, 1, NULL);

	layer_add_child(window_get_root_layer(window2), simple_menu_layer_get_layer(simple_menu_layer2));
  
	window_stack_push(window2, true);
  
}
void call_back_cat(int index, void *ctx){
  makeRecipeSelectWindow(index);
}

void init(void){
	GRect frame;
	window = window_create();
	frame = layer_get_bounds(window_get_root_layer(window));
	menu_items[0] = (SimpleMenuItem){.title = "Ethnic", .subtitle = "for the pastafarians", NULL, .callback = call_back_cat,};
	menu_items[1] = (SimpleMenuItem){.title = "Hors d'oeuvre", .subtitle = "when don't feel chew", NULL, .callback = call_back_cat,};
	menu_items[2] = (SimpleMenuItem){.title = "Kid-Friendly", .subtitle = "is this even a food", NULL, .callback = call_back_cat,};
	menu_items[3] = (SimpleMenuItem){.title = "Pasta", .subtitle = "for cool kids", NULL, .callback = call_back_cat,};
	menu_items[4] = (SimpleMenuItem){.title = "Salad", .subtitle = "this was a bird", NULL, .callback = call_back_cat,};
	menu_items[5] = (SimpleMenuItem){.title = "Soups", .subtitle = "aria", NULL, .callback = call_back_cat,};

	menu_section[0] = (SimpleMenuSection){.items = menu_items, .num_items = 6, .title = "receipe gettera 91241",};
	
	simple_menu_layer = simple_menu_layer_create(frame, window, menu_section, 1, NULL);

	layer_add_child(window_get_root_layer(window), simple_menu_layer_get_layer(simple_menu_layer));
  
	window_stack_push(window, true);

  

}

void deinit(void) {
	simple_menu_layer_destroy(simple_menu_layer);
  window_destroy(window);
}

int main(void) {
  init();
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Done initializing, pushed window: %p", window);
  app_event_loop();
  deinit();
}
Пример #19
0
static void window_load(Window *window) {

  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  
  settings = (Settings)
    { .num_sets = 3
    , .num_points = 21
    , .max_points = 30
    , .first_server = PLAYER
    };

  load_settings(&settings);

  main_menu_sections[0] = (SimpleMenuSection) {
    .num_items = 1,
    .items = main_menu_items
  };

  main_menu_items[0] = (SimpleMenuItem) {
    .title = "Start Match",
    .callback = start_match
  };

  main_menu_sections[1] = (SimpleMenuSection) {
    .title = "Match Settings",
    .items = main_menu_item_options,
    .num_items = 2
  };

  main_menu_item_options[0] = (SimpleMenuItem) {
    .title = "Sets",
    .subtitle = setting_to_string(settings.num_sets),
    .callback = cycle_set_num
  };
  
  main_menu_item_options[1] = (SimpleMenuItem) {
    .title = "Points",
    .subtitle = setting_to_string(settings.num_points),
    .callback = cycle_points
  };
  
  main_menu_layer = simple_menu_layer_create(bounds, window, main_menu_sections, 2, NULL);
  layer_add_child(window_layer, simple_menu_layer_get_layer(main_menu_layer));

#ifdef PBL_COLOR
  menu_layer_set_highlight_colors(simple_menu_layer_get_menu_layer(main_menu_layer), GColorVividCerulean, GColorWhite);
#endif
}

static void window_unload(Window *window) {
  simple_menu_layer_destroy(main_menu_layer);
  window_destroy(window);
  s_main_window = NULL;
}

void menu_window_push() {
  if (!s_main_window) {
    s_main_window = window_create();
    window_set_window_handlers(s_main_window, (WindowHandlers) {
      .load = window_load,
      .unload = window_unload
    });
  }
  window_stack_push(s_main_window, true);
}
Пример #20
0
void program_window_unload(Window *window) {
  simple_menu_layer_destroy(program_menu_layer);
}
Пример #21
0
static void reset_menu()
{
	
  	int num_a_items = 0;
	menu_items[num_a_items++] = (SimpleMenuItem){
		.title = "Start",
		.subtitle = "Lets Push-ups",
		.callback = select_menu_handler,
	};
	persist_exists(GOAL_KEY)?1: persist_write_int(GOAL_KEY,15);

	snprintf(goal_str,sizeof(goal_str), "%ld once", 
			persist_read_int(GOAL_KEY));
	menu_items[num_a_items++] = (SimpleMenuItem){
		.title= "Goal",
		.subtitle = goal_str,
		.callback = select_menu_handler,
	};
	
	snprintf(history_str,sizeof(history_str), "Total: %ld  Top: %ld", 
			persist_exists(TOTAL_PUSHUPS_KEY)?persist_read_int(TOTAL_PUSHUPS_KEY) : 0,
			persist_exists(MAX_PUSHUPS_KEY)?persist_read_int(MAX_PUSHUPS_KEY) : 0);
	menu_items[num_a_items++] = (SimpleMenuItem){
		.title = "History",
		.subtitle = history_str,
		.callback = select_menu_handler,
	};

	menu_items[num_a_items++] = (SimpleMenuItem){
		.title= "Version",
		.subtitle = "1.0  @copyright shanfeng",
		.callback = select_menu_handler,
	};

	sections[0] = (SimpleMenuSection){
    		.num_items = SECTION_COUNT,
    		.items = menu_items,
  	};

	if(menu_layer)
	{
		layer_remove_from_parent(simple_menu_layer_get_layer(menu_layer));
		simple_menu_layer_destroy(menu_layer);
	}
	
  	Layer *window_layer = window_get_root_layer(window);
  	GRect bounds = layer_get_bounds(window_layer);
  	menu_layer = simple_menu_layer_create(bounds,window,sections, 1,NULL);
	simple_menu_layer_set_selected_index(menu_layer,menu_select,false);
  	layer_add_child(window_layer, simple_menu_layer_get_layer(menu_layer));
}

static void goal_select(struct NumberWindow *number_window, void *context)
{
	persist_write_int(GOAL_KEY,number_window_get_value(number_window));
	window_stack_pop(true);
}

static void select_menu_handler(int index, void *context)
{
	APP_LOG(APP_LOG_LEVEL_DEBUG,"%d",index);
	switch(index)
	{
		case 0:
			if(!pushups_window)
			{
				APP_LOG(APP_LOG_LEVEL_DEBUG,
					"pushups_window create");
  			 	pushups_window = create_pushups_window();
			}
  			window_stack_push(pushups_window, true);
			break;
		case 1:
			if(!number_window)
			{
				number_window = number_window_create("Goal",(NumberWindowCallbacks){
					.selected = goal_select,
				},NULL);
				number_window_set_value(number_window,
					persist_read_int(GOAL_KEY));
				number_window_set_min(number_window,5);
				number_window_set_step_size(number_window, 5);
				number_window_set_max(number_window,1000);
			}
			window_stack_push((Window*)number_window,true);
			break;
		case 3:
			{
				if(!info_window)
				{
					info_window = aboutinfo_window_create();
				}
				window_stack_push(info_window,true);	
			} 

	}
	menu_select = index;
}
Пример #22
0
static void init(void) {
    int i = 0;

    window = window_create();
    if (window == 0) {
        // error...
        return;
    }
    window_set_fullscreen(window, true);
    window_layer = window_get_root_layer(window);
    window_stack_push(window, true);

    /*
    ** Build the main menu.
    */
    menu[i++] = (SimpleMenuItem) {
        .title = "Play",
        .callback = play,
        // .icon = play_icon,
    };
    menu[i++] = (SimpleMenuItem) {
        .title = "High Score",
        // .callback = highscore,
        // .icon = highscore_icon,
    };
    menu[i++] = (SimpleMenuItem) {
        .title = "About",
        .callback = about,
        // .icon = about_icon,
    };
    assert(i == MENU_SIZE);

    /*
    ** Load the menu on the phone and away we go...!
    */
    menu_layer = simple_menu_layer_create(layer_get_frame(window_layer),
                                          window, menu_sections, 1, 0);
    if (menu_layer != 0) {
        layer_add_child(window_layer,
                        simple_menu_layer_get_layer(menu_layer));
    }
}

static void deinit(void) {
    if (about_window != 0) {
        if (about_text_layer != 0) text_layer_destroy(about_text_layer);
        window_destroy(about_window);
    }

    if (window != 0) {
        if (menu_layer != 0) simple_menu_layer_destroy(menu_layer);
        window_destroy(window);
    }
}

static void play(int index,
                 void *ctx) {

    message_init(0);

    if (game == 0) game = game_init();
    assert(game != 0);

    go(game);
}

static void about(int index,
                  void *ctx) {

    if (about_window == 0) {
        about_window = window_create();
        if (about_window != 0) {
            window_set_click_config_provider(about_window, about_click_config);
            about_text_layer = text_layer_create(layer_get_frame(window_layer));
            if (about_text_layer != 0) {
                //
            }
        }
    }

    if (about_window != 0) {
        window_stack_push(about_window, true);
    }
}

static void about_click_config(void *ctx) {
    window_single_click_subscribe(BUTTON_ID_BACK, about_click_handler);
    window_single_click_subscribe(BUTTON_ID_DOWN, about_click_handler);
    window_single_click_subscribe(BUTTON_ID_SELECT, about_click_handler);
    window_single_click_subscribe(BUTTON_ID_UP, about_click_handler);
}

static void about_click_handler(ClickRecognizerRef recognizer,
                                void *context) {
    window_stack_remove(about_window, true);
}
Пример #23
0
// Deinitialize resources on window unload that were initialized on window load
void main_window_unload(Window *window) {
  simple_menu_layer_destroy(main_menu_layer);
}
Пример #24
0
static void main_window_unload(Window *window) {
  text_layer_destroy(s_text_layer);
  simple_menu_layer_destroy(s_simple_menu_layer);
  action_menu_hierarchy_destroy(s_action_menu, NULL, NULL);
}
Пример #25
0
static void window_load(Window *window) {

  int num_a_items = 0;
  int num_a2_items = 0;
  int num_a3_items = 0;
  int num_a4_items = 0;

  math_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Algebra",
	.subtitle = "Formule Algebriche",
    .callback = algebra_select_callback,
  };
  math_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Geometria",
	.subtitle = "Formule Geometriche",
    .callback = geometry_select_callback,
  };
  math_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Analisi",
	.subtitle = "Formule Analitiche",
    .callback = calc_select_callback,
  };
  math_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Trigonometia",
	.subtitle = "Formule Trigonometriche",
    .callback = trig_select_callback,
  };
  science_menu_items[num_a2_items++] = (SimpleMenuItem){
    .title = "Fisica",
	.subtitle = "Formule Fisiche",
    .callback = physics_select_callback,
  };
  science_menu_items[num_a2_items++] = (SimpleMenuItem){
    .title = "Chimica",
	.subtitle = "Formule Chimiche",
    .callback = chemistry_select_callback,
  };
  science_menu_items[num_a2_items++] = (SimpleMenuItem){
    .title = "Biologia",
	.subtitle = "Bio-Formule",
    .callback = bio_select_callback,
  };
  other_menu_items[num_a4_items++] = (SimpleMenuItem){
    .title = "Conversioni",
	.subtitle = "Conversioni d'unità",
    .callback = conversion_select_callback,
  };
  about_menu_items[num_a3_items++] = (SimpleMenuItem){
    .title = "Contattami",
	.subtitle = "[email protected]",
  };
  about_menu_items[num_a3_items++] = (SimpleMenuItem){
    .title = "Contattalo",
	.subtitle = "[email protected]",
  };
  menu_sections[0] = (SimpleMenuSection){
  .title ="Matematica",
  .num_items = NUM_MATH_MENU_ITEMS,
  .items = math_menu_items,
  };
  menu_sections[1] = (SimpleMenuSection){
  .title ="Scienze",
  .num_items = NUM_SCIENCE_MENU_ITEMS,
  .items = science_menu_items,
  };
  menu_sections[2] = (SimpleMenuSection){
  .title ="Altro",
  .num_items = NUM_OTHER_MENU_ITEMS,
  .items = other_menu_items,
  };

  menu_sections[3] = (SimpleMenuSection){
  .title ="About",
  .num_items = NUM_ABOUT_MENU_ITEMS,
  .items = about_menu_items,
  };
	
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);

  simple_menu_layer = simple_menu_layer_create(bounds, window, menu_sections,NUM_MENU_SECTIONS, NULL);

  layer_add_child(window_layer, simple_menu_layer_get_layer(simple_menu_layer));
}

static void window_unload(Window *window) {
  simple_menu_layer_destroy(simple_menu_layer);
}

int main(void) {
  window = window_create();


  window_set_window_handlers(window, (WindowHandlers) {
    .load = window_load,
    .unload = window_unload,
  });

  window_stack_push(window, true /* Animated */);

  app_event_loop();

  window_destroy(window);
}
Пример #26
0
static void main_window_unload(Window *window) {
    //destroy main menu
    simple_menu_layer_destroy(s_main_menu_layer);
    text_layer_destroy(s_selected_text);
}
Пример #27
0
static void window_load(Window *window) {
  
  // Load the bitmap asset
  // resource_init_current_app must be called before all asset loading.
  menu_icons[0] = gbitmap_create_with_resource(RESOURCE_ID_HAPPY);
  menu_icons[1] = gbitmap_create_with_resource(RESOURCE_ID_SAD);
  menu_icons[2] = gbitmap_create_with_resource(RESOURCE_ID_STRESSED);
  menu_icons[3] = gbitmap_create_with_resource(RESOURCE_ID_CALM);
  
  // ******** Menu Items ********
  // First menu item.
  first_menu_items[0] = (SimpleMenuItem) {
    .icon = menu_icons[0],
    .title = "Happy",
    .subtitle = "Sweet!",
    .callback = menu_select_callback,
  };
  
  // Second menu item.
  first_menu_items[1] = (SimpleMenuItem) {
    .icon = menu_icons[1],
    .title = "Sad",
    .subtitle = "Cheer Up!",
    .callback = menu_select_callback,
  };
  
  // Third menu item.
  first_menu_items[2] = (SimpleMenuItem) {
    .icon = menu_icons[2],
    .title = "Stressed",
    .subtitle = "Take a chill pill!",
    .callback = menu_select_callback,
  };

  // Fourth menu item.
  first_menu_items[3] = (SimpleMenuItem){
    .icon = menu_icons[3],
    .title = "Calm",
    .subtitle = "Like a felon!",
    .callback = menu_select_callback,
  };
  
  // ******** SECTIONS ********
  menu_sections[0] = (SimpleMenuSection) {
    .num_items = NUM_FIRST_MENU_ITEM,
    .items = first_menu_items,
  };
  
  // Required: gets the root layer. ( base layer )
  Layer *window_layer = window_get_root_layer(window);
  
  // Required: Gets the dimensions of the whole pebble screen.
  GRect bounds = layer_get_bounds(window_layer);

  // initialize the menu.
  simple_menu_layer = simple_menu_layer_create(bounds, window, menu_sections, NUM_MENU_SECTIONS, NULL);
  
  // Required: add the window for display
  layer_add_child(window_layer, simple_menu_layer_get_layer(simple_menu_layer));
}

/************************************************************/
/* window_unload                                            */
/*                                                          */
/* Handles all the clean up before destroying the window.   */
/************************************************************/
static void window_unload(Window *window) {
  simple_menu_layer_destroy(simple_menu_layer);
  
  // Destroy the images
  for(int i = 0; i < NUM_MENU_ICONS; i++){
    gbitmap_destroy(menu_icons[i]);
  }
}

/************************************************************/
/* init                                                     */
/*                                                          */
/* Creates the window, sets the click_config_provider, sets */
/* the window handlers, and pushes the window onto the  top */
/* of the stack so it is visible.                           */
/************************************************************/
static void init(void) {
  
  // Required: Creates the window. Needed to display everything.
  window = window_create();
  
  // Required. Sets the hanldlers for the window. window_load for when the user enters the watchapp and
  // window_unload, for when the user leave the watch app.
  window_set_window_handlers(window, (WindowHandlers) {
    .load = window_load,
    .unload = window_unload,
  });
  
  // Setup the messaging handlers.
  app_message_register_outbox_sent(out_sent_handler);
  app_message_register_outbox_failed(out_failed_handler);
  const uint32_t inbound_size = 10;
  const uint32_t outbound_size = 64;
  app_message_open(inbound_size, outbound_size);
  
  
  // Vibrate to let the user know.
  vibes_short_pulse();
  
  // Required: Will push the window to the top of the stack and therefore making it visible.
  const bool animated = true;
  window_stack_push(window, animated);
}

/************************************************************/
/* deinit                                                   */
/*                                                          */
/* Destroys the window and performs all of the necessary    */
/* clean up.                                                */
/************************************************************/
static void deinit(void) {
  window_destroy(window);
}
Пример #28
0
static void menu_window_unload(Window *window) {
  simple_menu_layer_destroy(menu_list_layer);
}
Пример #29
0
static void window_unload(Window *window) {
  simple_menu_layer_destroy(simple_menu_layer);
  window_destroy(window);
}
Пример #30
0
/*
 * Called when the window is first pushed to the screen when it's not already loaded.
 * Do the layout of the window.
 */
static void tabs_menu_window_load(Window *window) {
    // Retrieve icon resources
    nearby_icon = gbitmap_create_with_resource(RESOURCE_ID_LOCATION_ICON);
    saved_icon = gbitmap_create_with_resource(RESOURCE_ID_STAR_ICON);
    
    // Create the menu items
    items[0] = (SimpleMenuItem) {
        .icon = nearby_icon,
        .title = "NEARBY",
        .callback = call_nearby_selected_callback
    };
    items[1] = (SimpleMenuItem) {
        .icon = saved_icon,
        .title = "SAVED",
        .callback = call_saved_selected_callback
    };

    // Create the menu section
    sections[0] = (SimpleMenuSection) {
        .items = items,
        .num_items = 2,
        .title = "Stops"
    };

    // Create the menu layer
    Layer *window_layer = window_get_root_layer(window);
    GRect bounds = layer_get_frame(window_layer);
    simple_menu_layer = simple_menu_layer_create(bounds, window, sections, 1 /* num_sections */, NULL /* callback_context */);

    // Add it to the window for display
    layer_add_child(window_layer, simple_menu_layer_get_layer(simple_menu_layer));
}

/*
 * Called when the window resumes after already being loaded.
 */
static void tabs_menu_window_appear(Window *window) {

}

/*
 * Called when the window leaves the screen.
 */
static void tabs_menu_window_disappear(Window *window) {

}

/*
 * Called when the window is removed from the window stack.
 * Destroy any layers associated with the window.
 */
static void tabs_menu_window_unload(Window *window) {
    simple_menu_layer_destroy(simple_menu_layer);
}

/*
 * Create the menu window and set handlers.
 * Return the created window.
 */
Window *init_tabs_menu_window(void (*on_nearby_selected)(void), void (*on_saved_selected)(void)) {
    // Save callback functions
    nearby_selected_callback = on_nearby_selected;
    saved_selected_callback = on_saved_selected;

    Window *tabs_menu_window = window_create();
    window_set_window_handlers(tabs_menu_window, (WindowHandlers) {
        .load = tabs_menu_window_load,
        .appear = tabs_menu_window_appear,
        .disappear = tabs_menu_window_disappear,
        .unload = tabs_menu_window_unload,
    });
    return tabs_menu_window;
}