attempt to clean up a little keyboard handling code

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@133 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 1998-06-22 22:25:07 +00:00
parent 1311c7a9bb
commit f54f3bffce

View File

@ -79,7 +79,7 @@
#undef GetClassInfo #undef GetClassInfo
#endif #endif
#define WINDOW_MARGIN 3 // This defines sensitivity of Leave events #define WINDOW_MARGIN 3 // This defines sensitivity of Leave events
wxMenu *wxCurrentPopupMenu = NULL; wxMenu *wxCurrentPopupMenu = NULL;
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
@ -1293,42 +1293,34 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
return MSWOnMeasureItem((int)wParam, (WXMEASUREITEMSTRUCT *)lParam); return MSWOnMeasureItem((int)wParam, (WXMEASUREITEMSTRUCT *)lParam);
break; break;
} }
case WM_KEYDOWN: case WM_KEYDOWN:
{ {
// return Default(); // these keys are not interesting to the application (@@ or are they?)
if ( wParam == VK_SHIFT || wParam == VK_CONTROL )
if (wParam == VK_SHIFT) return Default();
return Default();
else if (wParam == VK_CONTROL)
return Default();
// Avoid duplicate messages to OnChar // Avoid duplicate messages to OnChar
else if ((wParam != VK_ESCAPE) && (wParam != VK_SPACE) && (wParam != VK_RETURN) && (wParam != VK_BACK) && (wParam != VK_TAB)) if ((wParam == VK_ESCAPE) || (wParam == VK_SPACE) ||
{ (wParam == VK_RETURN) || (wParam == VK_BACK) ||
MSWOnChar((WORD)wParam, lParam); (wParam == VK_TAB))
if (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE) return Default();
return Default();
} MSWOnChar((WORD)wParam, lParam);
else //VZ: commented - what is it for?
return Default(); //if (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE)
break; // return Default();
}
case WM_KEYUP:
{
/*
if (wParam == VK_SHIFT)
wxShiftDown = FALSE;
else if (wParam == VK_CONTROL)
wxControlDown = FALSE;
*/
break; break;
} }
// VZ: WM_KEYUP not processed
case WM_CHAR: // Always an ASCII character case WM_CHAR: // Always an ASCII character
{ {
MSWOnChar((WORD)wParam, lParam, TRUE); MSWOnChar((WORD)wParam, lParam, TRUE);
break; break;
} }
case WM_HSCROLL: case WM_HSCROLL:
{ {
#ifdef __WIN32__ #ifdef __WIN32__
@ -1544,7 +1536,7 @@ void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win)
{ {
// adding NULL hWnd is (first) surely a result of an error and // adding NULL hWnd is (first) surely a result of an error and
// (secondly) breaks menu command processing // (secondly) breaks menu command processing
wxCHECK( hWnd != NULL ); wxCHECK_RET( hWnd != NULL, "attempt to add a NULL hWnd to window list" );
if ( !wxWinHandleList->Find((long)hWnd) ) if ( !wxWinHandleList->Find((long)hWnd) )
wxWinHandleList->Append((long)hWnd, win); wxWinHandleList->Append((long)hWnd, win);
@ -1858,7 +1850,7 @@ bool wxWindow::MSWOnDrawItem(const int id, WXDRAWITEMSTRUCT *itemStruct)
if ( id == 0 ) { // is it a menu item? if ( id == 0 ) { // is it a menu item?
DRAWITEMSTRUCT *pDrawStruct = (DRAWITEMSTRUCT *)itemStruct; DRAWITEMSTRUCT *pDrawStruct = (DRAWITEMSTRUCT *)itemStruct;
wxMenuItem *pMenuItem = (wxMenuItem *)(pDrawStruct->itemData); wxMenuItem *pMenuItem = (wxMenuItem *)(pDrawStruct->itemData);
wxCHECK_RET( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
// prepare to call OnDrawItem() // prepare to call OnDrawItem()
wxDC dc; wxDC dc;
@ -1891,7 +1883,7 @@ bool wxWindow::MSWOnMeasureItem(const int id, WXMEASUREITEMSTRUCT *itemStruct)
if ( id == 0 ) { // is it a menu item? if ( id == 0 ) { // is it a menu item?
MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct; MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct;
wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData); wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData);
wxCHECK_RET( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth, return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth,
&pMeasureStruct->itemHeight); &pMeasureStruct->itemHeight);
@ -2450,7 +2442,7 @@ void wxWindow::MSWOnMouseMove(const int x, const int y, const WXUINT flags)
if (m_windowCursor.Ok() && !wxIsBusy()) if (m_windowCursor.Ok() && !wxIsBusy())
::SetCursor((HCURSOR) m_windowCursor.GetHCURSOR()); ::SetCursor((HCURSOR) m_windowCursor.GetHCURSOR());
if (!m_mouseInWindow) if (!m_mouseInWindow)
{ {
// Generate an ENTER event // Generate an ENTER event
m_mouseInWindow = TRUE; m_mouseInWindow = TRUE;
@ -2556,11 +2548,13 @@ void wxWindow::MSWOnChar(const WXWORD wParam, const WXLPARAM lParam, const bool
} }
} }
} }
else else if ((id = wxCharCodeMSWToWX(wParam)) == 0) {
if ((id = wxCharCodeMSWToWX(wParam)) == 0) // it's ASCII and will be processed here only when called from
// WM_CHAR (i.e. when isASCII = TRUE)
id = -1; id = -1;
}
if (id > -1) if (id != -1)
{ {
wxKeyEvent event(wxEVT_CHAR); wxKeyEvent event(wxEVT_CHAR);
event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE); event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE);