コード例 #1
0
ファイル: main.c プロジェクト: tristanbell/PebbleTrainTimes
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);
}
コード例 #2
0
ファイル: justice.c プロジェクト: LabLayers/pennapps
static void appWindow_load(Window *window) {
 int num_a_items = 0;
    first_menu_items[num_a_items++] = (SimpleMenuItem){
    // You should give each menu item a title and callback
    .title = first_string,
  };
  // The menu items appear in the order saved in the menu items array
  first_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = second_string,
  };
  first_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = third_string,
  };

  // Bind the menu items to the corresponding menu sections
  menu_sections[0] = (SimpleMenuSection){
    .num_items = NUM_FIRST_MENU_ITEMS,
    .items = first_menu_items,
  };

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

  // Initialize the simple menu layer
  simple_menu_layer = simple_menu_layer_create(bounds, window, menu_sections, NUM_MENU_SECTIONS, NULL);

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

}
コード例 #3
0
ファイル: app.c プロジェクト: geoffmomin/transit-watch
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);
}
コード例 #4
0
ファイル: main.c プロジェクト: Captain-Dude/Pebble-FRC
static void team_select_callback(int index, void *ctx) {
  
first_menu_items[index].title = "Make new window";
  first_menu_items[index].subtitle = "I need to learn how";
  layer_mark_dirty(simple_menu_layer_get_layer(simple_menu_layer));

}
コード例 #5
0
ファイル: pc.c プロジェクト: asyba/UR
static void window_load(Window *window) {

  int num_a_items = 0;
	
  menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Shutdown",
        .subtitle ="",
	.callback = shutdown_select_callback,
  };
  menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Restart",
        .subtitle ="",
	 .callback = restart_select_callback,
  };
  menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Lock",
        .subtitle =  "",
	  .callback = lock_select_callback,
  };
  menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Log Off",
        .subtitle =  "",
	  .callback = log_off_select_callback,
  };
  menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Sleep",
        .subtitle =  "",
	  .callback = sleep_select_callback,
  };
  menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Abort",
        .subtitle =  "",
	  .callback = abort_select_callback,
  };
 
  menu_sections[0] = (SimpleMenuSection){
  	.title = "Power",
  	.num_items = NUM_MENU_ITEMS,
  	.items = 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));
}

void show_menu_pc(){
  window = window_create();
  window_set_window_handlers(window, (WindowHandlers) {
    .load = window_load,

    .unload = window_unload,
  });
         
  window_stack_push(window, true /* Animated */);
}
コード例 #6
0
ファイル: main.c プロジェクト: Hexvane/Reddit2
void menu_load(Window *menu)
{
	int num_menu_items = 0;
	
	main_menu_items[num_menu_items++] = (SimpleMenuItem) {
		.title = "Ask",
		.callback = search_select_callback,
	};
	
	main_menu_items[num_menu_items++] = (SimpleMenuItem) {
		.title = "Answers",
		//.callback = //callback to what you want this item to do when clicked
	};
	
	main_menu_items[num_menu_items++] = (SimpleMenuItem) {
		.title = "Questions",
		//.callback = //callback to what you want this item to do when clicked
	};
	
	main_menu_items[num_menu_items++] = (SimpleMenuItem) {
		.title = "Help",
		.callback = help_select_callback,
	};
	
	main_menu_sections[0] = (SimpleMenuSection) {
		.num_items = MENU_NUM_ITEMS,
		.items = main_menu_items
	};
	
	GRect bounds = layer_get_bounds(window_get_root_layer(menu));
	main_menu_layer = simple_menu_layer_create(bounds, menu, main_menu_sections, MENU_NUM_SECTIONS, NULL);
	
	layer_add_child(window_get_root_layer(menu), simple_menu_layer_get_layer(main_menu_layer));
}

void menu_unload(Window *menu)
{
	text_layer_destroy(menu_text);
	text_layer_destroy(select_text);
}

void title_load(Window *title)
{
	title_bitmap = gbitmap_create_with_resource(RESOURCE_ID_REDDIT_TITLE_IMAGE);
	title_layer = bitmap_layer_create(GRect(0, 0, 144, 180));
	bitmap_layer_set_bitmap(title_layer, title_bitmap);
	layer_add_child(window_get_root_layer(title), bitmap_layer_get_layer(title_layer));
}

void title_unload(Window *title)
{
	bitmap_layer_destroy(title_layer);
}

void title_click_handler(ClickRecognizerRef recognizer, void *context)
{
	window_stack_push(menu, true);
}
コード例 #7
0
ファイル: menu.c プロジェクト: ckhawks/PebblePoints
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);
}
コード例 #8
0
ファイル: addmenu.c プロジェクト: dae3/pebble-budget-tracker
// window load and unload
static void window_handler_load(Window *w) {
  load_expenses();

  menu_section.title = section_title;
  menu_section.items = menu_items;
  menu_section.num_items = ninitdata;

  menu = simple_menu_layer_create(GRect(0,0,150,150), w, &menu_section, 1, NULL);
  layer_add_child(window_get_root_layer(me), simple_menu_layer_get_layer(menu));
}
コード例 #9
0
ファイル: app.c プロジェクト: abi93k/explore
 /**
  * Called when category window is loaded
  * @param window
  */
  static void c_window_load(Window *window) {
    createMenu();

    
    bounds = layer_get_frame(window_get_root_layer(c_window));
    c_menu_layer = simple_menu_layer_create(bounds,c_window, c_sections, 1, NULL);
    layer_add_child(window_get_root_layer(c_window), simple_menu_layer_get_layer(c_menu_layer));


  }
コード例 #10
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);
}
コード例 #11
0
ファイル: items.c プロジェクト: amanmomin/AssistList
static void checkmark_select_callback(int index, void *ctx) {
    booleans.checkmark_account[items_index][index]=!booleans.checkmark_account[items_index][index];
    if (booleans.checkmark_account[items_index][index]){
      s_first_products_items[index].icon= checked;
      
    }
  else{
      s_first_products_items[index].icon=unchecked;
  }
  layer_mark_dirty(simple_menu_layer_get_layer(s_products_menu_layer));
}  
コード例 #12
0
ファイル: run.c プロジェクト: dheeratp/CityTrail_IoT
void start_callback(int index, void *ctx) {
   APP_LOG(APP_LOG_LEVEL_DEBUG, "In Start_Callback!!");
	accel_data_service_subscribe(0, NULL);

	menu_items[0].title = "Continue Trail";
	menu_items[0].subtitle = "Ready for more?";
	layer_mark_dirty(simple_menu_layer_get_layer(pedometer_settings));

	pedometer = window_create();

	window_set_window_handlers(pedometer, (WindowHandlers ) { .load = ped_load,
					.unload = ped_unload, });
コード例 #13
0
ファイル: menu.c プロジェクト: FraBoCH/pebble-badminton
void cycle_set_num() {
  switch (settings.num_sets) {
    case 1: 
      settings.num_sets = 3;
      break;
    case 3: 
      settings.num_sets = 1;
      break;
  }
  main_menu_item_options[0].subtitle = setting_to_string(settings.num_sets);
  layer_mark_dirty(simple_menu_layer_get_layer(main_menu_layer));
}
コード例 #14
0
/* This is called when change units is selected */
static void units_callback(int index, void *ctx) {

  if (celsius) {
    s_first_menu_items[2].subtitle = "Fahrenheit";
    celsius = false;
  } else {
    s_first_menu_items[2].subtitle = "Celsius";
    celsius = true;
  }
  send_change_units_message();
  layer_mark_dirty(simple_menu_layer_get_layer(s_simple_menu_layer));
}
コード例 #15
0
ファイル: start_ping_menu.c プロジェクト: StarTraX/tactician
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 */);
}
コード例 #16
0
ファイル: start_time_menu.c プロジェクト: StarTraX/tactician
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 */);
}
コード例 #17
0
ファイル: physics.c プロジェクト: Adrenocortico/FormulePebble
static void window_load(Window *window) {

  int num_a_items = 0;

  physics_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Meccanica",
	.callback = cin_select_callback
  };
  physics_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Fluidodinamica",
	.callback = fluid_select_callback
  };
  physics_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Termodinamica",
	.callback = termo_select_callback
  };
  physics_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Circuiti",
	.callback = elec_select_callback
  };
  physics_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Elettromagnetismo",
	.callback = elet_select_callback
  };
  physics_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Quantistica",
	.callback = quant_select_callback
  };

  menu_sections.num_items = NUM_PHYSICS_MENU_ITEMS;
  menu_sections.items = physics_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, 1, NULL);
	
  layer_add_child(window_layer, simple_menu_layer_get_layer(simple_menu_layer));
}

void show_physics_menu(){
   window = window_create();

  window_set_window_handlers(window, (WindowHandlers) {
    .load = window_load,
    .unload = window_unload,
  });
	
  
	
  window_stack_push(window, true /* Animated */);
}
コード例 #18
0
static void window_load(Window *window) {
  int num_a_items = 0;

  conversion_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Farenheit in C",
	.subtitle = "C = 5/9*(F-32)",
  };
  conversion_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Celcius in K",
	.subtitle = "K = C+273",
  };
  conversion_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Celcius in F",
	.subtitle = "F = 9/5*(C+32)",
  };
  conversion_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Miglia in Kilometri",
	.subtitle = "Km = mi/0.62137",
  };
  conversion_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Grammi in Once",
	.subtitle = "oz = 0.035274 g",
  };
  conversion_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Km/h in m/s",
	.subtitle = "1 km/h = 0.278 m/s",
  };


  menu_sections.num_items = NUM_CONVERSION_MENU_ITEMS;
  menu_sections.items = conversion_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, 1, NULL);

  layer_add_child(window_layer, simple_menu_layer_get_layer(simple_menu_layer));
}

void show_conversion_menu(){
   window = window_create();

  window_set_window_handlers(window, (WindowHandlers) {
    .load = window_load,
    .unload = window_unload,
  });
	
  
	
  window_stack_push(window, true /* Animated */);
}
コード例 #19
0
ファイル: running_coach.c プロジェクト: jango/pebble_running
// This callback will remove the main menu layer and draw the program menu instead.
static void main_menu_callback(int index, void *ctx) {
  selected_program_menu = &main_menu[index];
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Selected '%s' program menu.", selected_program_menu -> title);  

  Layer *window_layer = window_get_root_layer(program_window);

  build_menu_from_struc(selected_program_menu->program_menu, selected_program_menu->program_menu_size, program_menu_sections, program_menu_items, program_menu_callback);

  // The order of the next two statements are important.
  window_stack_push(program_window, true);

  layer_add_child(window_layer, simple_menu_layer_get_layer(program_menu_layer)); 
}
コード例 #20
0
ファイル: inverse_hyp_trig.c プロジェクト: itguy51/mathapp2
static void window_load(Window *window) {
  int num_a_items = 0;

  inverse_hyp_trig_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "arcsinh'(x)",
	.subtitle = "1/(x²+1)^½",
  };
  inverse_hyp_trig_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "arccosh'(x)",
	.subtitle = "1/(x²-1)^½",
  };
  inverse_hyp_trig_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "arctanh'(x)",
	.subtitle = "1/(1-x²)",
  };
  inverse_hyp_trig_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "arcsech'(x)",
  .subtitle = "-1/x(1-x²)^½",
  };
  inverse_hyp_trig_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "arccoth'(x)",
  .subtitle = "1/(1-x²)",
  };
  inverse_hyp_trig_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "arccsch'(x)",
  .subtitle = "-1/|x|(1+x²)^½",
  };

  menu_sections.num_items = NUM_INVERSE_HYP_TRIG_MENU_ITEMS;
  menu_sections.items = inverse_hyp_trig_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, 1, NULL);

  layer_add_child(window_layer, simple_menu_layer_get_layer(simple_menu_layer));
}

void show_inverse_hyp_trig_menu(){
   window = window_create();

  window_set_window_handlers(window, (WindowHandlers) {
    .load = window_load,
    .unload = window_unload,
  });
	
  
	
  window_stack_push(window, true /* Animated */);
}
コード例 #21
0
ファイル: main.c プロジェクト: weianwang/Alertr
// 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);
}
コード例 #22
0
ファイル: main.c プロジェクト: rudylacrete/ims-remote-control
static void allValveSetCallback(Valve_s* valves) {
  static char text[100];
  snprintf(text, sizeof(text), "Fetch done (%d valves)", getValveNumber());
  text_layer_set_text(s_text_layer, text);
  
  s_first_menu_items = (SimpleMenuItem*)malloc(sizeof(SimpleMenuItem) * getValveNumber());
  for(int i=0; i < getValveNumber(); i++){
    char* guid_str = malloc(20);
    snprintf(guid_str, 20, "GUID %d", valves[i].guid);
    s_first_menu_items[i] = (SimpleMenuItem) {
      .title = valves[i].name,
      .subtitle = guid_str,
      .callback = menu_select_callback,
    };
  }

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

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

  s_simple_menu_layer = simple_menu_layer_create(bounds, s_window, s_menu_sections, NUM_MENU_SECTIONS, NULL);
  
  initActionMenu();
  layer_add_child(window_layer, simple_menu_layer_get_layer(s_simple_menu_layer));
}

static void main_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
	
  // Create a text layer and set the text
	s_text_layer = text_layer_create(bounds);
	text_layer_set_text(s_text_layer, "Fetching valves ...");
  
  // Set the font and text alignment
	text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
	text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);

	// Add the text layer to the window
	layer_add_child(window_layer, text_layer_get_layer(s_text_layer));
  
  // Enable text flow and paging on the text layer, with a slight inset of 10, for round screens
  text_layer_enable_screen_text_flow_and_paging(s_text_layer, 10);
  
  setValveSetCompleteCallback(allValveSetCallback);
}
コード例 #23
0
ファイル: contacts.c プロジェクト: Mahoward/LeavingNow
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);

}
コード例 #24
0
ファイル: main.c プロジェクト: yaochie/PebbleSerendipity
static void main_window_load(Window *window) {
    //load main menu
    Layer* window_layer = window_get_root_layer(window);
    s_selected_text = text_layer_create(GRect(0, 90, 144, 40));
    text_layer_set_text(s_selected_text, "Selection goes here");
    
    init_menu();
    s_main_menu_layer = simple_menu_layer_create(GRect(0, 0, 144, 168), window, &s_menu_list, 2, NULL);
    if (s_main_menu_layer == NULL) {
        APP_LOG(APP_LOG_LEVEL_ERROR, "Could not create simple menu!");
    } else {
        layer_add_child(window_layer, simple_menu_layer_get_layer(s_main_menu_layer));
        layer_add_child(window_layer, text_layer_get_layer(s_selected_text));
    }
    
    init_message_handling();
}
コード例 #25
0
 void in_received_handler(DictionaryIterator *received, void *context) {
	int count = 0;
	Tuple *tuple = dict_read_first(received);
	static char* section_title = "Menu title";
	while(tuple){
			count ++;
			if (tuple->key == 0) {
				menu_action = tuple->value->cstring;
			}
			tuple = dict_read_next(received);
	}
	int number_of_entries = count - 1;
	list_menu_items = malloc(number_of_entries * sizeof(SimpleMenuItem));
	int i = 0;
	tuple = dict_read_first(received);
	while (tuple) {
			if(tuple->key != 0){
					list_menu_items[i] = (SimpleMenuItem){
							.title = tuple->value->cstring,
							.callback = select_menu_callback
					};
					i++;
			}
			tuple = dict_read_next(received);
	}
	if  (strcmp(menu_action, "c") == 0) {
			section_title = "Clients";
	} else if(strcmp(menu_action, "t") == 0) {
			section_title = "Tasks";
	} else if (strcmp(menu_action, "p") == 0) {
			section_title = "Projects";
	} else {
			section_title = "Select";
	}
	list_menu_sections[0] = (SimpleMenuSection){
			.title = section_title,
			.num_items = number_of_entries,
			.items = list_menu_items
	};
	window_stack_push(menu_window, true);

	Layer *window_layer = window_get_root_layer(menu_window);
	menu_list_layer = simple_menu_layer_create(GRect(0, 5, 144, 163), menu_window, list_menu_sections, 1, NULL);
	layer_add_child(window_layer, simple_menu_layer_get_layer(menu_list_layer));
 }
コード例 #26
0
// SPECIAL SELECT CALLBACK
static void special_select_callback(int index, void *ctx) {
        // Of course, you can do more complicated things in a menu item select callback
        // Here, we have a simple toggle
        special_flag = !special_flag;

        SimpleMenuItem *menu_item = &second_menu_items[index];

        if (special_flag) {
        menu_item->subtitle = "Au revoir";
        } else {
        menu_item->subtitle = "Merci de votre visite.";
          window_destroy(window);
        }


        // Mark the layer to be updated
        layer_mark_dirty(simple_menu_layer_get_layer(simple_menu_layer));
        }
コード例 #27
0
static void menu_select_callback(int index, void *ctx) {
        

        if (special_flag) {
        first_menu_items[index].subtitle = "Allumé";
          send_message(2);
          special_flag = !special_flag;
        

        } else {
        first_menu_items[index].subtitle = "Éteint";
          send_message(3);
          special_flag = !special_flag;
        }

        // Mark the layer to be updated
        layer_mark_dirty(simple_menu_layer_get_layer(simple_menu_layer));
        }
コード例 #28
0
ファイル: menu.c プロジェクト: FraBoCH/pebble-badminton
void cycle_points() {
  switch (settings.num_points) {
    case 15: 
      settings.num_points = 21;
      break;
    case 21: 
      settings.num_points = 15;
      break;
    default:
      settings.num_points = 99;
      break;
  }
  // compute max_points depending on num points according to badminton law
  settings.max_points = settings.num_points == 21 ? 30 : settings.num_points + 5;
  
  main_menu_item_options[1].subtitle = setting_to_string(settings.num_points);
  layer_mark_dirty(simple_menu_layer_get_layer(main_menu_layer));
}
コード例 #29
0
ファイル: navigation_menu.c プロジェクト: StarTraX/tactician
static void nav_menu_window_load(Window *mWindow) {
  	num_a_items = 0;
	nav_menu_items[num_a_items++] = (SimpleMenuItem){
      .title = "Next Mark",
 	 .subtitle = wptName,
   	.callback = nav_menu_select_callback,
  };
  nav_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Next Leg",
	 .subtitle = nextLegName,
     .callback = nav_menu_select_callback,
  };
  nav_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Speed, heading etc. ",
    .subtitle = "Current, water temp, depth ",
    .callback = nav_menu_select_callback,
  };
 nav_menu_items[num_a_items++] = (SimpleMenuItem){
    .title = "Course details ",
	 .subtitle = "Club, series,course. ",
    .callback = nav_menu_select_callback,
  };
 
 menu_sections[0] = (SimpleMenuSection){
	  .title = "Course Tracking Menu",
    .num_items = 4,
    .items = nav_menu_items,
  };
   	Layer *window_layer = window_get_root_layer(mWindow);
  	GRect bounds = layer_get_frame(window_layer); 
	nav_menu_layer = simple_menu_layer_create(bounds, mWindow, menu_sections, 1, NULL);
	layer_set_update_proc((Layer *) nav_menu_layer, refreshData);
   	layer_add_child(window_layer, simple_menu_layer_get_layer(nav_menu_layer));
}
void show_nav_menu(){
	//APP_LOG(APP_LOG_LEVEL_DEBUG, "In show_nav_menu free: %d", heap_bytes_free());	 
	//setCurrentWindow("nav_menu");
 mWindow = window_create();
  window_set_window_handlers(mWindow, (WindowHandlers) {
    .load = nav_menu_window_load,
    .unload = nav_menu_window_unload,
  });
		 window_stack_push(mWindow, true /* Animated */);
}
コード例 #30
0
ファイル: main.c プロジェクト: Bowsewr/PebbleDareV2
static void special_select_callback(int index, void *ctx) {
  // Of course, you can do more complicated things in a menu item select callback
  // Here, we have a simple toggle
  s_special_flag = !s_special_flag;

  SimpleMenuItem *menu_item = &s_second_menu_items[index];

  if (s_special_flag) {
    menu_item->subtitle = "Okay, it's not so special.";
  } else {
    menu_item->subtitle = "Well, maybe a little.";
  }

  if (++s_hit_count > 5) {
    menu_item->title = "Very Special Item";
  }

  layer_mark_dirty(simple_menu_layer_get_layer(s_simple_menu_layer));
}