📄 mmi_men.c
字号:
/*
+-----------------------------------------------------------------------------
| Project : GSM-F&D (8411)
| Modul : MMI_MEN
+-----------------------------------------------------------------------------
| Copyright 2002 Texas Instruments Berlin, AG
| All rights reserved.
|
| This file is confidential and a trade secret of Texas
| Instruments Berlin, AG
| The receipt of or possession of this file does not convey
| any rights to reproduce or disclose its contents or to
| manufacture, use, or sell anything it may describe, in
| whole, or in part, without the specific written consent of
| Texas Instruments Berlin, AG.
+-----------------------------------------------------------------------------
| Purpose : This Modul defines functions for menu processing in
| display areas.
+-----------------------------------------------------------------------------
*/
#ifndef MMI_MEN_C
#define MMI_MEN_C
#endif
#ifdef SMI
#define ENTITY_SMI
#else
#define ENTITY_MMI
#endif
/*==== INCLUDES ===================================================*/
#include <string.h>
#include "typedefs.h"
#include "vsi.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "tok.h"
#include "message.h"
#ifdef SMI
#include "aci_cmh.h"
#include "ksd.h"
#include "aca.h"
#include "smi.h"
#else
#include "mmi.h"
#endif
/*==== CONSTANTS ==================================================*/
#define MAX_MENUS 5
/*==== TYPES ======================================================*/
/*==== EXPORT =====================================================*/
/*==== VARIABLES ==================================================*/
LOCAL T_MENU menuTable[MAX_MENUS];
LOCAL USHORT numOfMenues;
/*==== FUNCTIONS ==================================================*/
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : MMI_MEN |
| STATE : code ROUTINE : men_init |
+--------------------------------------------------------------------+
PURPOSE : Initialize the menu module.
*/
GLOBAL void men_init (void)
{
numOfMenues = MAX_MENUS;
while (numOfMenues)
menuTable[--numOfMenues].free = TRUE;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : MMI_MEN |
| STATE : code ROUTINE : men_refreshMenu |
+--------------------------------------------------------------------+
PURPOSE : displays the menu in the area. The selected line
will be marked with a '>' character.
*/
LOCAL void men_refreshMenu (T_AREA *a)
{
T_MENU *men;
USHORT selectLine, end, outY;
SHORT i, start;
char emptyLine[MAX_OUTPUT_SIZE+1];
if (a->funcType NEQ FN_MENU)
return;
men = &menuTable[a->func];
/*
* calculate the line in the menu window wich is active
*/
if (men->numVisible > 2)
{
selectLine = men->numVisible / 2;
if (! (men->numVisible & 1))
selectLine++;
}
else
selectLine = 0;
start = (men->aktMenuIdx - selectLine);
end = start+men->numVisible;
outY = 0;
if (strlen (men->title))
outY++;
for (i=start; i<end; i++, outY++)
{
/*
* the selected line mark with a '>' character
*/
if (i EQ men->aktMenuIdx)
wm_areaOutput (a, outY, 0, ">");
/*
* if the index is negativ we display an empty string
*/
if (i < 0 OR i >= men->numEntries)
{
/*
* build a empty line
*/
memset (emptyLine, ' ', MAX_OUTPUT_SIZE);
emptyLine[a->dx] = '\0';
wm_areaOutput (a, outY, 0, emptyLine);
}
else
{
/*
* build a empty line and copy the menu entry string into it
*/
memset (emptyLine, ' ', MAX_OUTPUT_SIZE);
memcpy (emptyLine, men->menEntries[i],
MINIMUM (strlen (men->menEntries[i]), MAX_OUTPUT_SIZE));
emptyLine[a->dx] = '\0';
wm_areaOutput (a, outY, 1, emptyLine);
}
}
wm_areaRefresh (a);
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : MMI_MEN |
| STATE : code ROUTINE : io_upMenu |
+--------------------------------------------------------------------+
PURPOSE : Selecting the previous entry in the active menu.
*/
GLOBAL void men_upMenu (USHORT aHandle)
{
T_MENU *men;
T_AREA *a = wm_getArea (aHandle);
if (a NEQ NULL AND a->funcType EQ FN_MENU)
{
men = &menuTable[a->func];
if (men->aktMenuIdx > 0)
{
men->aktMenuIdx--;
men_refreshMenu (a);
}
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : MMI_MEN |
| STATE : code ROUTINE : men_downMenu |
+--------------------------------------------------------------------+
PURPOSE : Selecting the next entry in the area menu.
*/
GLOBAL void men_downMenu (USHORT aHandle)
{
T_MENU *men;
T_AREA *a = wm_getArea (aHandle);
if (a NEQ NULL AND a->funcType EQ FN_MENU)
{
men = &menuTable[a->func];
if (men->aktMenuIdx < (men->numEntries-1))
{
men->aktMenuIdx++;
men_refreshMenu (a);
}
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : MMI_MEN |
| STATE : code ROUTINE : men_startMenu |
+--------------------------------------------------------------------+
PURPOSE : Start the Menu processing.
*/
GLOBAL void men_startMenu (USHORT aHandle,
char *title,
char *menu[])
{
T_MENU *men;
USHORT i=0;
T_AREA *a;
if (numOfMenues < MAX_MENUS AND (a = wm_getArea (aHandle)) NEQ NULL)
{
while (i<MAX_MENUS)
{
if (menuTable[i].free)
{
men = &menuTable[i];
men->free = FALSE;
numOfMenues++;
a->func = (UBYTE) i;
wm_setCursor (a, FALSE, 0, 0);
break;
}
i++;
}
if (i < MAX_MENUS)
{
a->funcType = FN_MENU;
men->aktMenuIdx = 0;
men->numVisible = a->dy;
if (title NEQ NULL)
{
strcpy (men->title, title);
wm_areaOutput (a, 0, 0, title);
men->numVisible--;
}
else
strcpy (men->title, "");
men->menEntries = menu;
men->numEntries = 0;
while (menu[men->numEntries] NEQ NULL)
men->numEntries++;
men_refreshMenu (a);
}
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : MMI_MEN |
| STATE : code ROUTINE : men_getMenuIdx |
+--------------------------------------------------------------------+
PURPOSE : retrieves the aktual selected linenumber of
the active menu.
*/
GLOBAL USHORT men_getMenuIdx (USHORT aHandle)
{
T_MENU *men;
T_AREA *a = wm_getArea (aHandle);
if (a NEQ NULL AND a->funcType EQ FN_MENU)
{
men = &menuTable[a->func];
return men->aktMenuIdx;
}
return 0;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : MMI_MEN |
| STATE : code ROUTINE : men_stopMenu |
+--------------------------------------------------------------------+
PURPOSE : stops the menu selection process for the given area.
*/
GLOBAL void men_stopMenu (USHORT aHandle)
{
T_AREA *a = wm_getArea (aHandle);
if (a NEQ NULL AND a->funcType EQ FN_MENU)
{
a->funcType = FN_NONE;
if (!menuTable[a->func].free)
{
menuTable[a->func].free = TRUE;
numOfMenues--;
a->func = 0;
}
wm_clearArea (aHandle);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -