Windows CE changes (from <Someone>)

The changes did not apply to the main trunk as easily as I wouuld have
hoped, so I attempted a number of manual applications. I hope <Someone>
can tell me if there is a problem.

Changelist:
- bugfix: help text windows close immediately after open (unhandled WM_KEYDOWN in mhtext.c)
- bugfix: action button uses hero coordinates instead of cursor position
- pocketpc: bugfix: menu window closes on up/down keys from first/last position
- smartphone: do not translate input when command helper is hidden (fixes Motorola Q keyboard bug)
- smartphone: new keypad layouts
- smartphone: wizard mode command layout
- smartphone: option to feed arbitrary text as a command to nethack core
- wrap/unwrap text option for text windows
- hardware keyboard detection
- hide keypad when hardware keyboard is present
- backport message window highlighting from winnt port
- new icon with recommended image sizes
This commit is contained in:
nethack.allison
2009-10-10 14:39:53 +00:00
parent 1ad1e07d7a
commit 142f13de3f
18 changed files with 844 additions and 81 deletions
+84 -24
View File
@@ -21,6 +21,7 @@ LRESULT CALLBACK TextWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK NHTextControlWndProc(HWND, UINT, WPARAM, LPARAM);
static void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam);
static void LayoutText(HWND hwnd);
static void ToggleWrapStatus(HWND hDlg, BOOL bWrap);
HWND mswin_init_text_window () {
HWND ret;
@@ -51,11 +52,7 @@ void mswin_display_text_window (HWND hWnd)
data = (PNHTextWindow)GetWindowLong(hWnd, GWL_USERDATA);
if( data ) {
HWND control;
control = GetDlgItem(hWnd, IDC_TEXT_CONTROL);
SendMessage(control, EM_FMTLINES, 1, 0 );
mswin_render_text(data->window_text, GetDlgItem(hWnd, IDC_TEXT_CONTROL));
ToggleWrapStatus(hWnd, mswin_get_text_wrap(data->window_text));
data->done = 0;
mswin_popup_display(hWnd, &data->done);
mswin_popup_destroy(hWnd);
@@ -84,22 +81,12 @@ LRESULT CALLBACK TextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
#if defined(WIN_CE_SMARTPHONE)
/* special initialization for SmartPhone dialogs */
NHSPhoneDialogSetup(hWnd, FALSE, GetNHApp()->bFullScreen);
NHSPhoneDialogSetup(hWnd, IDC_SPHONE_TEXTDIALOGBAR, FALSE, GetNHApp()->bFullScreen);
#endif
/* subclass edit control */
editControlWndProc = (WNDPROC)GetWindowLong(control, GWL_WNDPROC);
SetWindowLong(control, GWL_WNDPROC, (LONG)NHTextControlWndProc);
if( !program_state.gameover && GetNHApp()->bWrapText ) {
DWORD styles;
styles = GetWindowLong(control, GWL_STYLE);
if( styles ) {
SetWindowLong(control, GWL_STYLE, styles & (~WS_HSCROLL));
SetWindowPos(control, NULL, 0, 0, 0, 0,
SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE );
}
}
SetFocus(control);
return FALSE;
@@ -116,8 +103,11 @@ LRESULT CALLBACK TextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
{
case IDOK:
case IDCANCEL:
data->done = 1;
return TRUE;
data->done = 1;
return TRUE;
case IDC_TEXT_TOGGLE_WRAP:
ToggleWrapStatus(hWnd, !mswin_get_text_wrap(data->window_text));
return TRUE;
}
break;
@@ -159,16 +149,80 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
}
}
void ToggleWrapStatus(HWND hDlg, BOOL bWrap)
{
DWORD styles;
PNHTextWindow data;
HWND control;
TCHAR wbuf[BUFSZ];
data = (PNHTextWindow)GetWindowLong(hDlg, GWL_USERDATA);
control = GetDlgItem(hDlg, IDC_TEXT_CONTROL);
if( !control ) {
panic("cannot get text view window");
}
/* set horizontal scrollbar status */
styles = GetWindowLong(control, GWL_STYLE);
if( styles ) {
SetWindowLong(control, GWL_STYLE, (bWrap? (styles & (~WS_HSCROLL)) : (styles | WS_HSCROLL)));
SetWindowPos(control, NULL, 0, 0, 0, 0,
SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE );
}
/* set text wrap mode */
mswin_set_text_wrap(data->window_text, bWrap);
mswin_render_text(data->window_text, control);
/* change button status */
ZeroMemory( wbuf, sizeof(wbuf) );
if( !LoadString(
GetNHApp()->hApp,
(bWrap? IDS_TEXT_UNWRAP : IDS_TEXT_WRAP),
wbuf,
BUFSZ) ) {
panic("cannot load text window strings");
}
#if defined(WIN_CE_SMARTPHONE)
{
TBBUTTONINFO tbbi;
ZeroMemory( &tbbi, sizeof(tbbi) );
tbbi.cbSize = sizeof(tbbi);
tbbi.dwMask = TBIF_TEXT;
tbbi.pszText = wbuf;
if( !SendMessage(
SHFindMenuBar(hDlg),
TB_SETBUTTONINFO,
IDC_TEXT_TOGGLE_WRAP,
(LPARAM)&tbbi) ) {
error( "Cannot update IDC_TEXT_TOGGLE_WRAP menu item." );
}
}
#else
SendDlgItemMessage(
hDlg,
IDC_TEXT_TOGGLE_WRAP,
WM_SETTEXT,
(WPARAM)0,
(LPARAM)wbuf
);
#endif
}
void LayoutText(HWND hWnd)
{
HWND btn_ok;
HWND btn_ok, btn_wrap;
HWND text;
RECT clrt, rt;
POINT pt_elem, pt_ok;
SIZE sz_elem, sz_ok;
POINT pt_elem, pt_ok, pt_wrap;
SIZE sz_elem, sz_ok, sz_wrap;
text = GetDlgItem(hWnd, IDC_TEXT_CONTROL);
btn_ok = GetDlgItem(hWnd, IDOK);
btn_wrap = GetDlgItem(hWnd, IDC_TEXT_TOGGLE_WRAP);
/* get window coordinates */
GetClientRect(hWnd, &clrt );
@@ -176,12 +230,18 @@ void LayoutText(HWND hWnd)
/* set window placements */
if( IsWindow(btn_ok) ) {
GetWindowRect(btn_ok, &rt);
sz_ok.cx = clrt.right - clrt.left;
sz_ok.cx = (clrt.right - clrt.left)/2;
sz_ok.cy = rt.bottom-rt.top;
pt_ok.x = clrt.left;
pt_ok.y = clrt.bottom - sz_ok.cy;
MoveWindow(btn_ok, pt_ok.x, pt_ok.y, sz_ok.cx, sz_ok.cy, TRUE );
sz_wrap.cx = (clrt.right - clrt.left)/2;
sz_wrap.cy = rt.bottom-rt.top;
pt_wrap.x = clrt.left + sz_ok.cx;
pt_wrap.y = clrt.bottom - sz_ok.cy;
MoveWindow(btn_wrap, pt_wrap.x, pt_wrap.y, sz_wrap.cx, sz_wrap.cy, TRUE );
pt_elem.x = clrt.left;
pt_elem.y = clrt.top;
sz_elem.cx = clrt.right - clrt.left;
@@ -200,7 +260,7 @@ void LayoutText(HWND hWnd)
LRESULT CALLBACK NHTextControlWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) {
case WM_KEYUP:
case WM_KEYDOWN:
switch( wParam ) {
case VK_SPACE:
case VK_RETURN:
@@ -228,7 +288,7 @@ LRESULT CALLBACK NHTextControlWndProc(HWND hWnd, UINT message, WPARAM wParam, LP
PostMessage(hWnd, WM_HSCROLL, MAKEWPARAM(SB_LINERIGHT, 0), (LPARAM)NULL);
return 0;
}
break; /* case WM_KEYUP: */
break; /* case WM_KEYDOWN: */
}
if( editControlWndProc )