fix bug in key handling code: toupper() shouldn't be applied to the values outside of the ASCII range (patch 631236)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17715 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-11-04 23:05:00 +00:00
parent 5b47d4f175
commit 8bbb50ba61
4 changed files with 49 additions and 78 deletions

View File

@@ -3336,6 +3336,11 @@ bool wxWindowGTK::Show( bool show )
else else
gtk_widget_hide( m_widget ); gtk_widget_hide( m_widget );
wxShowEvent eventShow(GetId(), show);
eventShow.m_eventObject = this;
GetEventHandler()->ProcessEvent(eventShow);
return TRUE; return TRUE;
} }

View File

@@ -3336,6 +3336,11 @@ bool wxWindowGTK::Show( bool show )
else else
gtk_widget_hide( m_widget ); gtk_widget_hide( m_widget );
wxShowEvent eventShow(GetId(), show);
eventShow.m_eventObject = this;
GetEventHandler()->ProcessEvent(eventShow);
return TRUE; return TRUE;
} }

View File

@@ -404,7 +404,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
wxWindow::~wxWindow() wxWindow::~wxWindow()
{ {
if (g_captureWindow == this) if (g_captureWindow == this)
g_captureWindow = NULL; g_captureWindow = NULL;
m_isBeingDeleted = TRUE; m_isBeingDeleted = TRUE;
@@ -437,7 +437,7 @@ wxWindow::~wxWindow()
if (w) if (w)
{ {
XtDestroyWidget(w); XtDestroyWidget(w);
m_drawingArea = (WXWidget) 0; m_drawingArea = (WXWidget) 0;
} }
// Only if we're _really_ a canvas (not a dialog box/panel) // Only if we're _really_ a canvas (not a dialog box/panel)
@@ -449,18 +449,18 @@ wxWindow::~wxWindow()
if (m_hScrollBar) if (m_hScrollBar)
{ {
wxDeleteWindowFromTable((Widget) m_hScrollBar); wxDeleteWindowFromTable((Widget) m_hScrollBar);
XtUnmanageChild((Widget) m_hScrollBar); XtUnmanageChild((Widget) m_hScrollBar);
} }
if (m_vScrollBar) if (m_vScrollBar)
{ {
wxDeleteWindowFromTable((Widget) m_vScrollBar); wxDeleteWindowFromTable((Widget) m_vScrollBar);
XtUnmanageChild((Widget) m_vScrollBar); XtUnmanageChild((Widget) m_vScrollBar);
} }
if (m_hScrollBar) if (m_hScrollBar)
XtDestroyWidget((Widget) m_hScrollBar); XtDestroyWidget((Widget) m_hScrollBar);
if (m_vScrollBar) if (m_vScrollBar)
XtDestroyWidget((Widget) m_vScrollBar); XtDestroyWidget((Widget) m_vScrollBar);
UnmanageAndDestroy(m_scrolledWindow); UnmanageAndDestroy(m_scrolledWindow);
@@ -958,12 +958,12 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
while (cnode) while (cnode)
{ {
wxWindow *child = (wxWindow*) cnode->Data(); wxWindow *child = (wxWindow*) cnode->Data();
int sx = 0; int sx = 0;
int sy = 0; int sy = 0;
child->GetSize( &sx, &sy ); child->GetSize( &sx, &sy );
wxPoint pos( child->GetPosition() ); wxPoint pos( child->GetPosition() );
child->SetSize( pos.x + dx, pos.y + dy, sx, sy, wxSIZE_ALLOW_MINUS_ONE ); child->SetSize( pos.x + dx, pos.y + dy, sx, sy, wxSIZE_ALLOW_MINUS_ONE );
cnode = cnode->Next(); cnode = cnode->Next();
} }
int x1 = (dx >= 0) ? x : x - dx; int x1 = (dx >= 0) ? x : x - dx;
@@ -1207,15 +1207,15 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y)
XmMenuPosition (menuWidget, &event); XmMenuPosition (menuWidget, &event);
XtManageChild (menuWidget); XtManageChild (menuWidget);
XEvent x_event; XEvent x_event;
// The ID of a pop-up menu is 1 when active, and is set to 0 by the // The ID of a pop-up menu is 1 when active, and is set to 0 by the
// idle-time destroy routine. // idle-time destroy routine.
// Waiting until this ID changes causes this function to block until // Waiting until this ID changes causes this function to block until
// the menu has been dismissed and the widgets cleaned up. // the menu has been dismissed and the widgets cleaned up.
// In other words, once this routine returns, it is safe to delete // In other words, once this routine returns, it is safe to delete
// the menu object. // the menu object.
// Ian Brown <ian.brown@printsoft.de> // Ian Brown <ian.brown@printsoft.de>
while (menu->GetId() == 1) while (menu->GetId() == 1)
{ {
XtAppNextEvent( (XtAppContext) wxTheApp->GetAppContext(), &x_event); XtAppNextEvent( (XtAppContext) wxTheApp->GetAppContext(), &x_event);
@@ -1732,7 +1732,7 @@ bool wxWindow::ProcessAccelerator(wxKeyEvent& event)
if (entry->MatchesEvent(event)) if (entry->MatchesEvent(event))
{ {
// Bingo, we have a match. Now find a control that matches the // Bingo, we have a match. Now find a control that matches the
// entry command id. // entry command id.
// Need to go up to the top of the window hierarchy, since it might // Need to go up to the top of the window hierarchy, since it might
// be e.g. a menu item // be e.g. a menu item
@@ -2201,33 +2201,8 @@ static void wxCanvasInputEvent(Widget drawingArea,
} }
case KeyPress: case KeyPress:
{ {
KeySym keySym; wxKeyEvent event (wxEVT_CHAR);
static char buf[100]; if (wxTranslateKeyEvent (event, canvas, (Widget) 0, &local_event))
#if 0
XComposeStatus compose;
(void) XLookupString ((XKeyEvent *) & local_event, buf, 20, &keySym, &compose);
#endif // 0
(void) XLookupString ((XKeyEvent *) & local_event, buf, 20, &keySym, NULL);
int id = wxCharCodeXToWX (keySym);
wxEventType eventType = wxEVT_CHAR;
wxKeyEvent event (eventType);
if (local_event.xkey.state & ShiftMask)
event.m_shiftDown = TRUE;
if (local_event.xkey.state & ControlMask)
event.m_controlDown = TRUE;
if (local_event.xkey.state & Mod3Mask)
event.m_altDown = TRUE;
if (local_event.xkey.state & Mod1Mask)
event.m_metaDown = TRUE;
event.SetEventObject(canvas);
event.m_keyCode = id;
event.SetTimestamp(local_event.xkey.time);
if (id > -1)
{ {
// Implement wxFrame::OnCharHook by checking ancestor. // Implement wxFrame::OnCharHook by checking ancestor.
wxWindow *parent = canvas->GetParent(); wxWindow *parent = canvas->GetParent();
@@ -2256,26 +2231,8 @@ static void wxCanvasInputEvent(Widget drawingArea,
} }
case KeyRelease: case KeyRelease:
{ {
static char buf[100];
KeySym keySym;
(void) XLookupString ((XKeyEvent *) & local_event, buf, 20, &keySym, NULL);
int id = wxCharCodeXToWX (keySym);
wxKeyEvent event (wxEVT_KEY_UP); wxKeyEvent event (wxEVT_KEY_UP);
if (wxTranslateKeyEvent (event, canvas, (Widget) 0, &local_event))
if (local_event.xkey.state & ShiftMask)
event.m_shiftDown = TRUE;
if (local_event.xkey.state & ControlMask)
event.m_controlDown = TRUE;
if (local_event.xkey.state & Mod3Mask)
event.m_altDown = TRUE;
if (local_event.xkey.state & Mod1Mask)
event.m_metaDown = TRUE;
event.SetEventObject(canvas);
event.m_keyCode = id;
event.SetTimestamp(local_event.xkey.time);
if (id > -1)
{ {
canvas->GetEventHandler()->ProcessEvent (event); canvas->GetEventHandler()->ProcessEvent (event);
} }
@@ -2828,6 +2785,10 @@ bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Widget WXUNUSED(wid
#endif // 0 #endif // 0
(void) XLookupString ((XKeyEvent *) xevent, buf, 20, &keySym, NULL); (void) XLookupString ((XKeyEvent *) xevent, buf, 20, &keySym, NULL);
int id = wxCharCodeXToWX (keySym); int id = wxCharCodeXToWX (keySym);
// id may be WXK_xxx code - these are outside ASCII range, so we
// can't just use toupper() on id
if (id >= 'a' && id <= 'z')
id = toupper(id);
if (xevent->xkey.state & ShiftMask) if (xevent->xkey.state & ShiftMask)
wxevent.m_shiftDown = TRUE; wxevent.m_shiftDown = TRUE;
@@ -3075,8 +3036,8 @@ wxPoint wxGetMousePosition()
unsigned int maskReturn; unsigned int maskReturn;
XQueryPointer (display, XQueryPointer (display,
rootWindow, rootWindow,
&rootReturn, &rootReturn,
&childReturn, &childReturn,
&rootX, &rootY, &winX, &winY, &maskReturn); &rootX, &rootY, &winX, &winY, &maskReturn);
return wxPoint(rootX, rootY); return wxPoint(rootX, rootY);

View File

@@ -151,15 +151,15 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id,
// Note: The Xlib manual doesn't mention this restriction of XCreateWindow. // Note: The Xlib manual doesn't mention this restriction of XCreateWindow.
wxSize size2(size); wxSize size2(size);
if (size2.x <= 0) if (size2.x <= 0)
size2.x = 20; size2.x = 20;
if (size2.y <= 0) if (size2.y <= 0)
size2.y = 20; size2.y = 20;
wxPoint pos2(pos); wxPoint pos2(pos);
if (pos2.x == -1) if (pos2.x == -1)
pos2.x = 0; pos2.x = 0;
if (pos2.y == -1) if (pos2.y == -1)
pos2.y = 0; pos2.y = 0;
#if wxUSE_TWO_WINDOWS #if wxUSE_TWO_WINDOWS
bool need_two_windows = bool need_two_windows =
@@ -340,7 +340,7 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id,
wxWindowX11::~wxWindowX11() wxWindowX11::~wxWindowX11()
{ {
if (g_captureWindow == this) if (g_captureWindow == this)
g_captureWindow = NULL; g_captureWindow = NULL;
m_isBeingDeleted = TRUE; m_isBeingDeleted = TRUE;
@@ -490,7 +490,7 @@ void wxWindowX11::DoCaptureMouse()
FALSE, FALSE,
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
GrabModeAsync, GrabModeAsync,
GrabModeAsync, GrabModeAsync,
None, None,
None, /* cursor */ // TODO: This may need to be set to the cursor of this window None, /* cursor */ // TODO: This may need to be set to the cursor of this window
CurrentTime ); CurrentTime );
@@ -1474,23 +1474,23 @@ bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Window WXUNUSED(win
KeySym keySym; KeySym keySym;
(void) XLookupString ((XKeyEvent *) xevent, buf, 20, &keySym, NULL); (void) XLookupString ((XKeyEvent *) xevent, buf, 20, &keySym, NULL);
int id = wxCharCodeXToWX (keySym); int id = wxCharCodeXToWX (keySym);
// id may be WXK_xxx code - these are outside ASCII range, so we
// can't just use toupper() on id
if (id >= 'a' && id <= 'z')
id = toupper(id);
wxevent.m_shiftDown = XKeyEventShiftIsDown(xevent); wxevent.m_shiftDown = XKeyEventShiftIsDown(xevent);
wxevent.m_controlDown = XKeyEventCtrlIsDown(xevent); wxevent.m_controlDown = XKeyEventCtrlIsDown(xevent);
wxevent.m_altDown = XKeyEventAltIsDown(xevent); wxevent.m_altDown = XKeyEventAltIsDown(xevent);
wxevent.m_metaDown = XKeyEventMetaIsDown(xevent); wxevent.m_metaDown = XKeyEventMetaIsDown(xevent);
wxevent.SetEventObject(win); wxevent.SetEventObject(win);
wxevent.m_keyCode = wxToupper(id); wxevent.m_keyCode = id;
wxevent.SetTimestamp(XKeyEventGetTime(xevent)); wxevent.SetTimestamp(XKeyEventGetTime(xevent));
wxevent.m_x = XKeyEventGetX(xevent); wxevent.m_x = XKeyEventGetX(xevent);
wxevent.m_y = XKeyEventGetY(xevent); wxevent.m_y = XKeyEventGetY(xevent);
if (id > -1) return id > -1;
return TRUE;
else
return FALSE;
break;
} }
default: default:
break; break;
@@ -1566,8 +1566,8 @@ wxPoint wxGetMousePosition()
unsigned int maskReturn; unsigned int maskReturn;
XQueryPointer (display, XQueryPointer (display,
rootWindow, rootWindow,
&rootReturn, &rootReturn,
&childReturn, &childReturn,
&rootX, &rootY, &winX, &winY, &maskReturn); &rootX, &rootY, &winX, &winY, &maskReturn);
return wxPoint(rootX, rootY); return wxPoint(rootX, rootY);