Esempio n. 1
0
//
// Go back in the menu hierachy after the left key has been pressed
// in an applet (or double clicked)
//
static void menu_back_after_applet()
{
    void (*callback)(int) = g_menu[g_index][g_item].activate;
	//printf("Item %d %x\r\n", g_item, callback);
    if (callback)
    	callback(0); // deactivate

    g_item = -1;
    menu_update();
    g_menu_applet = NULL;
    menu_run_callback(1);
}
Esempio n. 2
0
void menu_touch(int xx, int yy)
{
    if (g_menu_applet) {
    	if (g_menu_applet(xx, yy))
    		menu_back_after_applet();
        return;
    }

    menu_touch_y = yy;
    menu_touch_x = xx;    
    //menu_update();       

    int old = g_item;
    g_item = menu_get_selected();

    lcd_lock();

    if (old != -1)
    	menu_paint_cell(old);
    if (g_item != -1)
    	menu_paint_cell(g_item);

    lcd_release();

    if (xx == -1 || yy == -1 || g_item == -1)
    {
    	if (old != -1)
    	{
    		if (g_menu[g_index][old].press_handler)
    		{
    			g_menu[g_index][old].press_handler(0);
    		}

    	    void (*callback)(int) = g_menu[g_index][old].activate;
    	    g_crumbs[g_index] = old;

    	    if (g_menu[g_index][old].next && g_index < MAX_DEPTH)
    	    {
    	        g_index++;
    	        g_menu[g_index] = g_menu[g_index-1][old].next;
    	        menu_update();
    	    }
    	    else if (g_menu[g_index][old].touch_handler)
    	    {
    	        g_menu_applet = g_menu[g_index][old].touch_handler;
    	        g_item = old;
    	        menu_clear();
    	    }
    	    else if (strcmp(g_menu[g_index][old].text, "Back") == 0)
    	    {
    	        menu_run_callback(0);    	

    	        if (g_index > 0)
    	            g_index--;
    	        menu_update();
    	        menu_run_callback(1);    	
    	    }
    	    
    	    // run the callback which should start the applet or update the display
    	    if (callback)
    	    {
    	        callback(1);
    	    }
    	}
    	return;
    }
    
    menu_touch_y = 0;
    menu_touch_x = 0;

    if (g_menu[g_index][g_item].press_handler)
    {
    	g_menu[g_index][g_item].press_handler(1);
    }
}
Esempio n. 3
0
void menu_touch(int xx, int yy)
{
  //char c[15];
  vConsolePrint("Menu Touch Called\r\n");
  //sprintf(c, "x %d y %d\r\n", xx, yy);
   //vConsolePrint(c);


    if (g_menu_applet) {
    	if (g_menu_applet(xx, yy))
    		menu_back_after_applet();
        return;
    }

    menu_touch_y = yy;
    menu_touch_x = xx;    
    //menu_update();       
    char bb[30];
    int old = g_item;
    if (g_incoming_command == 1)
      {
       g_item = g_command_item;

      }
    else
      {
        g_item = menu_get_selected();
      }
      g_incoming_command=0;

   // sprintf(bb, "Item Selected is: %u\r\n", g_item);
  //  vConsolePrint(bb);
  //  fflush(stdout);
    lcd_lock();

    if (old != -1)
    	menu_paint_cell(old);
    if (g_item != -1)
    	menu_paint_cell(g_item);

    lcd_release();

    if (xx == -1 || yy == -1 || g_item == -1)
    {
    	if (old != -1)
    	{
    		if (g_menu[g_index][old].press_handler)
    		{
    			g_menu[g_index][old].press_handler(0);
    		}

    	    void (*callback)(int) = g_menu[g_index][old].activate;
    	    g_crumbs[g_index] = old;

    	    if (g_menu[g_index][old].next && g_index < MAX_DEPTH)
    	    {
    	        g_index++;
    	        g_menu[g_index] = g_menu[g_index-1][old].next;
    	        menu_update();
    	    }
    	    else if (g_menu[g_index][old].touch_handler)
    	    {
    	        g_menu_applet = g_menu[g_index][old].touch_handler;
    	        g_item = old;
    	        menu_clear();
    	    }
    	    else if (strcmp(g_menu[g_index][old].text, "Back") == 0)
    	    {
    	        menu_run_callback(0);    	

    	        if (g_index > 0)
    	            g_index--;
    	        menu_update();
    	        menu_run_callback(1);    	
    	    }
    	    
    	    // run the callback which should start the applet or update the display
    	    if (callback)
    	    {
    	        callback(1);
    	    }
    	}
    	return;
    }
    
    menu_touch_y = 0;
    menu_touch_x = 0;

    if (g_menu[g_index][g_item].press_handler)
    {
    	g_menu[g_index][g_item].press_handler(1);
    }
}