📄 mmisoftkeys.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: Softkeys
$File: MmiSoftkeys.c
$Revision: 1.0
$Author: Condat(UK)
$Date: 22/02/01
********************************************************************************
Description:
********************************************************************************
$History:
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 "mfw_sys.h"
#include "p_sim.h"
//#include <stdio.h>
//#include <string.h>
//#include "mfw_sys.h"
//#include "stddefs.h" // needed for mfw_mfw.h
#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#include "mfw_lng.h"
#include "mfw_phb.h"
#include "mfw_nm.h"
#include "dspl.h"
#include "ksd.h"
#include "psa.h"
#include "MmiMmi.h"
#include "MmiMain.h"
#include "MmiUserData.h"
#include "MmiSoftKeys.h"
#include "MmiResources.h"
#include "Mmi3dframe.h"
#include "mmiiconresource.h"
typedef struct
{
MfwHnd leftKeyHandler;
MfwHnd rightKeyHandler;
LangTxt leftKeyLabel;
LangTxt rightKeyLabel;
} SoftKeysData, *SoftKeys;
#define HorizontalOffset 0 //zy 09/10
#define VerticalOffset 1
#define LeftMargin HorizontalOffset
#define RightMargin (mmiScrX - HorizontalOffset)
#define TopMargin (SCREEN_SIZE_Y)
#define FIFTH_LINE (TopMargin-LINE_HEIGHT)
#define ALLOC_MEMORY mfwAlloc
#define FREE_MEMORY mfwFree
static U8 softKeyFont = 0;
static UBYTE softKeysDisplayAttibutes = DSPL_TXTATTR_NORMAL;
/*
* Change the <font> and <displayAttibutes> for _all_ softkeys.
* All consecutive calls of softKeysUpdate() will reflect the change.
* Returns SOFTKEYS_CHANGED when everything went fine,
* or SOFTKEYS_FAILURE on failure.
*/
SoftKeysResult softKeysAttributes( U8 font, UBYTE displayAttibutes)
{
if( font == (U8)-1 )
{
return SOFTKEYS_FAILURE;
}
softKeyFont = font;
softKeysDisplayAttibutes = displayAttibutes;
return SOFTKEYS_CHANGED;
}
/*
* Creates the softkeys for <window>, which will display the
* <leftKeyLabel> and <rightKeyLabel> in the softkey area
* on the screen, and invoke <leftKeyCallBack> or <rightKeyCallBack>
* when the approrpiate key is pressed. Returns SOFTKEYS_CREATED when
* everything went fine, or SOFTKEYS_FAILURE on failure.
*/
SoftKeysResult softKeysHndCreate( MfwHnd window, SoftKeysSetup *setup)
{
if( window == NULL || setup == NULL )
{
return SOFTKEYS_FAILURE;
}
return softKeysWinCreate( (MfwWin *)((MfwHdr *)window)->data, setup);
}
SoftKeysResult softKeysWinCreate( MfwWin *window, SoftKeysSetup *setup)
{
SoftKeys newKeys;
if( window == NULL || setup == NULL )
{
return SOFTKEYS_FAILURE;
}
newKeys = (SoftKeys)ALLOC_MEMORY(sizeof(SoftKeysData));
if( newKeys == NULL )
{
return SOFTKEYS_FAILURE;
}
if( userDataWinSet( window, UD_SOFTKEYS, (void *)newKeys) == NULL )
{
FREE_MEMORY( (void *)newKeys, sizeof(SoftKeysData));
return SOFTKEYS_FAILURE;
}
newKeys->leftKeyHandler = kbdCreate( NULL, KEY_LEFT,
setup->leftKeyCallBack);
newKeys->rightKeyHandler = kbdCreate( NULL, KEY_RIGHT,
setup->rightKeyCallBack);
newKeys->leftKeyLabel = setup->leftKeyLabel;
newKeys->rightKeyLabel = setup->rightKeyLabel;
if( newKeys->leftKeyHandler == NULL || newKeys->rightKeyHandler == NULL )
{
kbdDelete(newKeys->leftKeyHandler);
kbdDelete(newKeys->rightKeyHandler);
userDataWinDelete( window, UD_SOFTKEYS);
FREE_MEMORY( (void *)newKeys, sizeof(SoftKeysData));
return SOFTKEYS_FAILURE;
}
return SOFTKEYS_CREATED;
}
/*
* Change the setup of the softkeys for <window>. Use TxtNull if you
* don't want to change a ...Label, and NULL if you don't want to change
* a ...CallBack. Returns SOFTKEYS_CHANGED when everything went fine,
* or SOFTKEYS_FAILURE on failure.
*/
SoftKeysResult softKeysHndSet( MfwHnd window, SoftKeysSetup *changes)
{
if( window == NULL || changes == NULL )
{
return SOFTKEYS_FAILURE;
}
return softKeysWinSet( (MfwWin *)((MfwHdr *)window)->data, changes);
}
SoftKeysResult softKeysWinSet( MfwWin *window, SoftKeysSetup *changes)
{
SoftKeys softKeys = (SoftKeys)userDataWinGet( window, UD_SOFTKEYS);
if( window == NULL || softKeys == NULL || changes == NULL )
{
return SOFTKEYS_FAILURE;
}
if( changes->leftKeyCallBack != NULL )
{
MfwHnd NewKeyHandler = kbdCreate( NULL, KEY_LEFT,
changes->leftKeyCallBack);
if( NewKeyHandler == NULL )
{
return SOFTKEYS_FAILURE;
}
else
{
kbdDelete(softKeys->leftKeyHandler);
softKeys->leftKeyHandler = NewKeyHandler;
}
}
if( changes->rightKeyCallBack != NULL )
{
MfwHnd NewKeyHandler = kbdCreate( NULL, KEY_LEFT,
changes->rightKeyCallBack);
if( NewKeyHandler == NULL )
{
return SOFTKEYS_FAILURE;
}
else
{
kbdDelete(softKeys->rightKeyHandler);
softKeys->rightKeyHandler = NewKeyHandler;
}
}
if( changes->leftKeyLabel != TxtNull )
{
softKeys->leftKeyLabel = changes->leftKeyLabel;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -