Example #1
0
//---------------------------------------------------------------------------
static void ZoneList_OnEnter(app_menu_t *pMenu, menu_item_t *pItem)
  // Called ONCE when "entering" the 'Zone List' display.
  // Tries to find out how many zones exist in the codeplug,
  // and the array-index of the currently active zone . 
{ int i=0;
  char sz20[22];
  char sz20CurrZone[22];
  scroll_list_control_t *pSL = &pMenu->scroll_list;

  ScrollList_Init( pSL ); // set all struct members to defaults
  pSL->current_item = -1; // currently active zone still unknown

  wide_to_C_string( zone_name, sz20CurrZone, 16+1/*maxlen*/ );

  while( i < CODEPLUG_MAX_ZONE_LIST_ENTRIES )
   { if(! ZoneList_ReadNameByIndex( i, sz20 ) ) // guess all zones are through
      { break; 
      }
     if( strcmp( sz20, sz20CurrZone) == 0 )
      { pSL->current_item = i;
      }
     ++i;
   }
  pSL->num_items = i;

  // Begin navigating through the list at the currently active zone:
  if( pSL->current_item >= 0 )
   {  pSL->focused_item = pSL->current_item;
#    if( CONFIG_MORSE_OUTPUT ) // autonomously report the first item in Morse code:
      pMenu->morse_request = AMENU_MORSE_REQUEST_ITEM_TEXT | AMENU_MORSE_REQUEST_ITEM_VALUE;
#    endif
   }

} // end ZoneList_OnEnter()
Example #2
0
void Menu_AddItem(menuframework_s *menu, void *item)
{
	menucommon_s	*itemptr;

	if (menu->nitems >= MAX_MENUITEMS) {
		trap_Error ("Menu_AddItem: excessive items");
	}

	menu->items[menu->nitems] = item;
	((menucommon_s*)menu->items[menu->nitems])->parent = menu;
	((menucommon_s*)menu->items[menu->nitems])->menuPosition = menu->nitems;
	((menucommon_s*)menu->items[menu->nitems])->flags &= ~QMF_HASMOUSEFOCUS;

	// perform any item specific initializations
	itemptr = (menucommon_s*)item;
	if (!(itemptr->flags & QMF_NODEFAULTINIT)) {
		switch (itemptr->type) {
		case MTYPE_ACTION:
			Action_Init((menuaction_s*)item);
			break;

		case MTYPE_FIELD:
			MenuField_Init((menufield_s*)item);
			break;

		case MTYPE_SPINCONTROL:
			SpinControl_Init((menulist_s*)item);
			break;

		case MTYPE_RADIOBUTTON:
			RadioButton_Init((menuradiobutton_s*)item);
			break;

		case MTYPE_SLIDER:
			Slider_Init((menuslider_s*)item);
			break;

		case MTYPE_BITMAP:
			Bitmap_Init((menubitmap_s*)item);
			break;

		case MTYPE_TEXT:
			Text_Init((menutext_s*)item);
			break;

		case MTYPE_SCROLLLIST:
			ScrollList_Init((menulist_s*)item);
			break;

		case MTYPE_PTEXT:
			PText_Init((menutext_s*)item);
			break;

		case MTYPE_BTEXT:
			BText_Init((menutext_s*)item);
			break;

		case MTYPE_BUTTON:
			Button_Init((menubutton_s*)item);
			break;

		default:
			trap_Error(va("Menu_Init: unknown type %d", itemptr->type));
		}
	}

	menu->nitems++;
}