📄 mmi.cpp
字号:
* RETURNS
* nil
* GLOBALS AFFECTED
* nil
*****************************************************************************/
static void LoadSkins(HINSTANCE hInstance, HWND hwnd)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
HWND hLB, hCB;
char buffer[BUFFER_LENGTH];
RECT dlg_rect, wnd_rect;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
hDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_LOADSKIN), hwnd, (DLGPROC)LoadSkinsProc);
hCB = GetDlgItem(hDlg, IDC_SKIN_SIZE);
SendMessage(hCB, CB_RESETCONTENT, 0, 0);
/* add items to the combo box */
strcpy(buffer, "128 x 128");
SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)buffer);
strcpy(buffer, "128 x 160");
SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)buffer);
strcpy(buffer, "176 x 220");
SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)buffer);
strcpy(buffer, "240 x 320");
SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)buffer);
hLB = GetDlgItem(hDlg, IDC_SKIN_NAMES);
/* move to the directory containing the skin directories */
/* the default skin size is 176x220 */
SendMessage(hCB, CB_SETCURSEL, 2, 0);
strcpy(buffer, PATH_FOR_176x220);
/* show all skins in this dimension */
ListSkinsInDir(hDlg, buffer, hLB);
/* shift the dialog to be align with the main windows */
GetWindowRect(hwnd, &wnd_rect);
GetWindowRect(hDlg, &dlg_rect);
MoveWindow(hDlg, wnd_rect.right, wnd_rect.top, dlg_rect.right - dlg_rect.left + 1, dlg_rect.bottom - dlg_rect.top + 1, TRUE);
ShowWindow(hDlg, SW_SHOW);
} /* end of LoadSkins */
/*****************************************************************************
* FUNCTION
* LoadSkinsProc
* DESCRIPTION
* Procedure for loading-skin dialog
*
* PARAMETERS
* hwndDlg IN handle for dialog
* message IN message
* wParam IN WPARAM
* lParam IN LPARAM
* RETURNS
* BOOL CALLBACK
* GLOBALS AFFECTED
* nil
*****************************************************************************/
BOOL CALLBACK LoadSkinsProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
char buffer[BUFFER_LENGTH];
int selected_index;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (message)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
/* backup current skin setting */
strcpy(old_skin_name_buffer, skin_name_buffer);
EndDialog(hwndDlg, wParam);
/* write the current skin setting to the INI file */
WritePrivateProfileString("Log", "LAST_SKIN_NAME", skin_name_buffer, "../Skins/SkinStyleLog.ini");
return TRUE;
case IDCANCEL:
/* restore the skin setting to the original one */
strcpy(skin_name_buffer, old_skin_name_buffer);
/* display the skin */
ReadKeyProfile(skin_name_buffer, hWnd);
IsLcdFirstInit = TRUE;
SkinDisplay(hWnd);
SendMessage(hWnd, WM_PAINT, 0, 0);
EndDialog(hwndDlg, wParam);
return TRUE;
/* message from the list box */
case IDC_SKIN_NAMES:
if (HIWORD(wParam) == LBN_SELCHANGE)
{
selected_index = SendMessage(GetDlgItem(hwndDlg, IDC_SKIN_NAMES), LB_GETCURSEL, 0, 0);
/* if there is a skin selected */
if (selected_index >= 0)
{
SendMessage(GetDlgItem(hwndDlg, IDC_SKIN_NAMES), LB_GETTEXT, selected_index, (LPARAM)buffer);
/* get the type of skin */
switch (SendMessage(GetDlgItem(hwndDlg, IDC_SKIN_SIZE), CB_GETCURSEL, 0, 0))
{
case SKIN_128x128:
strcpy(skin_name_buffer, PATH_FOR_128x128);
break;
case SKIN_128x160:
strcpy(skin_name_buffer, PATH_FOR_128x160);
break;
case SKIN_176x220:
strcpy(skin_name_buffer, PATH_FOR_176x220);
break;
case SKIN_240x320:
strcpy(skin_name_buffer, PATH_FOR_240x320);
break;
}
/* remove the brace "[]" from the string */
buffer[strlen(buffer) - 1] = '\0';
strcpy(buffer, &buffer[1]);
sprintf(skin_name_buffer, "%s%c%s", skin_name_buffer, '/', buffer);
/* display the skin */
ReadKeyProfile(skin_name_buffer, hWnd);
IsLcdFirstInit = TRUE;
SkinDisplay(hWnd);
SendMessage(hWnd, WM_PAINT, 0, 0);
}
}
break;
/* message from the combo box */
case IDC_SKIN_SIZE:
switch (HIWORD(wParam))
{
case CBN_SELCHANGE:
/* detect which skin dimension is selected */
switch (SendMessage(GetDlgItem(hwndDlg, IDC_SKIN_SIZE), CB_GETCURSEL, 0, 0))
{
case SKIN_128x128:
strcpy(buffer, PATH_FOR_128x128);
ListSkinsInDir(hwndDlg, buffer, GetDlgItem(hwndDlg, IDC_SKIN_NAMES));
break;
case SKIN_128x160:
strcpy(buffer, PATH_FOR_128x160);
ListSkinsInDir(hwndDlg, buffer, GetDlgItem(hwndDlg, IDC_SKIN_NAMES));
break;
case SKIN_176x220:
strcpy(buffer, PATH_FOR_176x220);
ListSkinsInDir(hwndDlg, buffer, GetDlgItem(hwndDlg, IDC_SKIN_NAMES));
break;
case SKIN_240x320:
strcpy(buffer, PATH_FOR_240x320);
ListSkinsInDir(hwndDlg, buffer, GetDlgItem(hwndDlg, IDC_SKIN_NAMES));
break;
}
break;
}
break;
}
}
return FALSE;
} /* end of LoadSkinsProc */
/*****************************************************************************
* FUNCTION
* ListSkinsInDir
* DESCRIPTION
* Setup the dialog for loading skin
*
* PARAMETERS
* hDlg IN handle for dialog
* path IN where the skin is
* hLB IN handle for list box
* RETURNS
* nil
* GLOBALS AFFECTED
* nil
*****************************************************************************/
static void ListSkinsInDir(HWND hDlg, char path[], HWND hLB)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
char buffer[BUFFER_LENGTH];
LRESULT result = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* get current working directory */
GetCurrentDirectory(BUFFER_LENGTH, buffer);
/* fill the list box with all skins in this directory */
DlgDirList(hDlg, path, IDC_SKIN_NAMES, 0, DDL_DIRECTORY | DDL_EXCLUSIVE);
/* deletet the ".." directory showed in the list box */
SendMessage(hLB, LB_DELETESTRING, 0, 0);
/* select the first item in the list box */
result = SendMessage(hLB, LB_GETCOUNT, 0, 0);
/* if there is no skin in that directory, make the OK button unavailable */
if (result == 0)
{
EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
}
else
{
EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
}
/* restore the working directory back */
SetCurrentDirectory(buffer);
} /* end of ListSkinsInDir */
/*****************************************************************************
* FUNCTION
* GetSimulatorBootStatus
* DESCRIPTION
* Get simulator boot status
*
* PARAMETERS
* nil
* RETURNS
* BOOL
* GLOBALS AFFECTED
* nil
*****************************************************************************/
BOOL GetSimulatorBootStatus()
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
return bFlagNWSimulatorStart;
} /* end of GetSimulatorBootStatus */
/*****************************************************************************
* FUNCTION
* GetDialogHandle
* DESCRIPTION
* Get the handle of the skin-loading dialog
*
* PARAMETERS
* nil
* RETURNS
* HWND
* GLOBALS AFFECTED
* nil
*****************************************************************************/
HWND GetDialogHandle()
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
return hDlg;
} /* end of GetDialogHandle */
/*****************************************************************************
* FUNCTION
* GetWindowHandle
* DESCRIPTION
* Get the handle of the main window
*
* PARAMETERS
* nil
* RETURNS
* HWND
* GLOBALS AFFECTED
* nil
*****************************************************************************/
HWND GetWindowHandle()
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
return hWnd;
} /* end of GetDialogHandle */
/*****************************************************************************
* FUNCTION
* keydown_by_mouse
* DESCRIPTION
* function for mouse button down
*
* PARAMETERS
* hWnd IN window handle
* xPos IN X position
* yPos IN Y position
* RETURNS
* void
* GLOBALS AFFECTED
* void
*****************************************************************************/
void keydown_by_mouse(HWND hWnd, int xPos, int yPos)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
UINT i;
void *tempKeyBrdMsg;
static MYQUEUE Message;
KEYBRD_MESSAGE *KeyBrdMsg;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
#if defined(__MMI_TOUCH_SCREEN__) || defined(__MMI_HANDWRITING_PAD__)
if(!TouchScreenSimButtonDown() && (i = GetKeyCode()) != KEY_INVALID)
#else
if((i = GetKeyCode()) != KEY_INVALID)
#endif
{
MessageBeep(0xFFFFFFFF);
Message.oslSrcId = 0xFFFF;
Message.oslDestId = MOD_PRT;
Message.oslMsgId = WM_LBUTTONDOWN;
/* OslFreeDataPtr(Message.oslDataPtr); */
tempKeyBrdMsg=OslConstructDataPtr(sizeof(KEYBRD_MESSAGE));
KeyBrdMsg =(KEYBRD_MESSAGE *)tempKeyBrdMsg;
/* KeyBrdMsg = (KEYBRD_MESSAGE *)OslConstructDataPtr(sizeof(KEYBRD_MESSAGE)); */
KeyBrdMsg->nKeyCode = i;
Message.oslDataPtr = KeyBrdMsg;
if (writeKeyMsgOnCondition(&Message) != TRUE)
OslFreeDataPtr(tempKeyBrdMsg);
/* JL/PLUTO: To draw the feedback feeling button */
FeedBackFeelingKeyAction(i);
}
} /* end of keydown_by_mouse */
/*****************************************************************************
* FUNCTION
* keyup_by_mouse
* DESCRIPTION
* function for mouse button up
*
* PARAMETERS
* hWnd IN window handle
* RETURNS
* void
* GLOBALS AFFECTED
* void
*****************************************************************************/
void keyup_by_mouse(HWND hWnd)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
UINT i;
void *tempKeyBrdMsg;
static MYQUEUE Message;
KEYBRD_MESSAGE *KeyBrdMsg;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* MessageBeep(0xFFFFFFFF); */
#if defined(__MMI_TOUCH_SCREEN__) || defined(__MMI_HANDWRITING_PAD__)
if(!TouchScreenSimButtonUp() && (i = GetKeyCode()) != KEY_INVALID)
#else
if((i = GetKeyCode()) != KEY_INVALID)
#endif
{
/* JL/PLUTO: To recover the original skin */
draw_main_bitmap(NULL);
Message.oslSrcId = 0xFFFF;
Message.oslDestId=MOD_PRT;
Message.oslMsgId =WM_LBUTTONUP;
/* OslFreeDataPtr(Message.oslDataPtr); */
tempKeyBrdMsg = OslConstructDataPtr(sizeof(KEYBRD_MESSAGE));
KeyBrdMsg = (KEYBRD_MESSAGE *)tempKeyBrdMsg;
/* KeyBrdMsg = (KEYBRD_MESSAGE *)OslConstructDataPtr(sizeof(KEYBRD_MESSAGE)); */
KeyBrdMsg->nKeyCode = i;
Message.oslDataPtr=KeyBrdMsg;
if (writeKeyMsgOnCondition(&Message) != TRUE)
OslFreeDataPtr(tempKeyBrdMsg);
}
} /* end of keyup_by_mouse */
/*****************************************************************************
* FUNCTION
* keyup_by_shortcut
* DESCRIPTION
* function for key down
*
* PARAMETERS
* hWnd IN window handle
* wParam IN wParam
* RETURNS
* void
* GLOBALS AFFECTED
* void
*****************************************************************************/
void keyup_by_shortcut(HWND hWnd, unsigned int wParam)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -