📄 mmidynamenu.c
字号:
/*******************************************************************************
CONDAT (UK)
********************************************************************************
This software product is the property of Condat (UK) Ltd and may not be
disclosed to any third party without the express permission of the owner.
********************************************************************************
$Project name: Basic MMI
$Project code: BMI (6349)
$Module: MMI
$File: Mmi_dynamenu.c
$Revision: 1.0
$Author: Condat(UK)
$Date: 25/10/00
********************************************************************************
Description: Dynamic Menu Handling
********************************************************************************
$History: Mmi_dynamenu.c
25/10/00 Original Condat(UK) BMI version.
$End
*******************************************************************************/
/*******************************************************************************
Include Files
*******************************************************************************/
#define ENTITY_MFW
/* includes */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#if defined (NEW_FRAME)
#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"
#else
#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"
#endif
#include "dspl.h"
//#include "resourceapi.h"
#include "mmidynamenu.h"
/* ------------- Constants definition --------------- */
// default menu dimensions
#define MENU_LEFT 0
#define MENU_INDENT 10
#define MENU_TOP 0
#define MENU_RIGHT 96
#define MENU_BOTTOM 50
// scroll bar dimensions
#define SCROLL_BAR_LEFT 87
#define SMALL_RECT 91
#define ELEVAT_RECT (SMALL_RECT-2)
void menu_SetSelected(ST_MENU *menu, int id)
// sets selected and current to item containing id
{
menu->current = menu->selected = menu_FindIdIndex(menu, id);
}
int menu_Select(ST_MENU *menu)
// makes current item selected and returns id
{
menu->selected = menu->current ;
return menu->items[menu->current].id;
}
int menu_GetCurrentID(const ST_MENU *menu)
// returns the id of the current menu item
{
return menu->items[menu->current].id;
}
int menu_FindIdIndex(const ST_MENU *menu, UINT16 id )
// returns entry number in menu that matches id, or zero
{
int menu_ctr;
for (menu_ctr = 0; menu_ctr<menu->count; menu_ctr++ )
{
if ( menu->items[menu_ctr].id == id)
return menu_ctr;
}
return 0 ;
}
void menu_Next(ST_MENU *menu)
// steps forward one menu item
{
if (menu->current == menu->count-1)
menu->current = 0;
else
menu->current++;
}
void menu_Prev(ST_MENU *menu)
// steps forward one menu item
{
if (menu->current == 0)
menu->current = menu->count-1;
else
menu->current--;
}
void menu_DrawMenu(const ST_MENU *menu )
// draws a simple menu from information given
{
// calc text positioning
USHORT text_height = dspl_GetFontHeight()+1;
USHORT nLines = MENU_BOTTOM / text_height;
USHORT nPage = nPage = menu->current / nLines;
USHORT line_ctr;
// clear menu area
dspl_Clear(MENU_LEFT,MENU_TOP,MENU_RIGHT, MENU_BOTTOM);
// iterate through the visible menu items
for (line_ctr = 0; line_ctr < nLines; line_ctr++)
{
USHORT Attribute = DSPL_TXTATTR_NORMAL;
int nIdx = line_ctr + nPage * nLines;
int line = MENU_TOP+1+line_ctr*text_height ;
if (nIdx >= menu->count)
break;
if (nIdx == menu->current) // draw highlight
{
Attribute = DSPL_TXTATTR_INVERS;
//JVJE dspl_DrawFilledRect(MENU_INDENT-1, line-1, SCROLL_BAR_LEFT,text_height+line-1, DSPL_BLACK);
}
if (nIdx == menu->selected) // draw selected marker
{
}
// draw menu text
switch (menu->items[nIdx].menu_type)
{
case ST_PROMPT_MENU:
//JVJE dspl_Prompt (MENU_INDENT,line, Attribute, menu->items[nIdx].str.prompt);
break;
case ST_TEXT_MENU:
{
char MenuItem[80];
//JVJE memcpy( MenuItem, menu->items[nIdx].str.text->chars, string_GetLength( menu->items[nIdx].str.text ) );
//JVJE MenuItem[ string_GetLength( menu->items[nIdx].str.text ) ] = '\0';
dspl_TextOut( MENU_INDENT, line, Attribute, MenuItem );
}
break;
case ST_PICTURE_MENU:
//JVJE dspl_DrawIconEx(MENU_INDENT,line, &Attribute, menu->items[nIdx].str.icon, DSPL_ICON_STATE_SHOW);
break;
}
}
menu_DrawScrollBar(menu->current, menu->count);
}
void menu_DrawScrollBar(int pos, int max )
// draws proportional scroll bar
{
int box_top = pos * MENU_BOTTOM / max;
int box_bottom = (pos + 1) * MENU_BOTTOM / max;
if (box_bottom-box_top<2) box_bottom = box_top + 2 ;
dspl_Clear(SCROLL_BAR_LEFT,MENU_TOP,MENU_RIGHT,MENU_BOTTOM );
dspl_DrawRect(SMALL_RECT,MENU_TOP,SMALL_RECT+1, MENU_BOTTOM );
dspl_DrawRect(ELEVAT_RECT, box_top,ELEVAT_RECT+5, box_bottom );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -