From c5b42c871b189a0199ff138ee094c00746bfc46a Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 17 May 1999 19:17:28 +0000 Subject: [PATCH] Use wxScrollWinEvent instead of wxScrollEvent in wxWindow and wxScrolledWindow. This breaks all ports! Added Layout() call to wxSplitter. wxDialog at least tries to set its position before its shown. wxGTK now emits char/key events as wxMSW does. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2491 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/event.h | 23 +- include/wx/generic/scrolwin.h | 16 +- include/wx/gtk/window.h | 4 - include/wx/gtk1/window.h | 4 - src/common/event.cpp | 2 +- src/generic/scrolwin.cpp | 22 +- src/generic/splitter.cpp | 13 + src/gtk/dialog.cpp | 14 +- src/gtk/window.cpp | 474 +++++++++++++++++++--------------- src/gtk1/dialog.cpp | 14 +- src/gtk1/window.cpp | 474 +++++++++++++++++++--------------- 11 files changed, 607 insertions(+), 453 deletions(-) diff --git a/include/wx/event.h b/include/wx/event.h index bdcc916e04..692d9f18d5 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -1308,6 +1308,7 @@ protected: typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&); typedef void (wxEvtHandler::*wxCommandEventFunction)(wxCommandEvent&); typedef void (wxEvtHandler::*wxScrollEventFunction)(wxScrollEvent&); +typedef void (wxEvtHandler::*wxScrollWinEventFunction)(wxScrollWinEvent&); typedef void (wxEvtHandler::*wxSizeEventFunction)(wxSizeEvent&); typedef void (wxEvtHandler::*wxMoveEventFunction)(wxMoveEvent&); typedef void (wxEvtHandler::*wxPaintEventFunction)(wxPaintEvent&); @@ -1421,7 +1422,25 @@ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ #define EVT_COMMAND(id, event, fn) { event, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, #define EVT_COMMAND_RANGE(id1, id2, event, fn) { event, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, -// Scrolling +// Scrolling from wxWindow (sent to wxScrolledWindow) +#define EVT_SCROLLWIN(func) \ + { wxEVT_SCROLLWIN_TOP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL },\ + { wxEVT_SCROLLWIN_BOTTOM, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL },\ + { wxEVT_SCROLLWIN_LINEUP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL },\ + { wxEVT_SCROLLWIN_LINEDOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL },\ + { wxEVT_SCROLLWIN_PAGEUP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL },\ + { wxEVT_SCROLLWIN_PAGEDOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL },\ + { wxEVT_SCROLLWIN_THUMBTRACK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL }, + +#define EVT_SCROLLWIN_TOP(func) { wxEVT_SCROLLWIN_TOP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL }, +#define EVT_SCROLLWIN_BOTTOM(func) { wxEVT_SCROLLWIN_BOTTOM, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL }, +#define EVT_SCROLLWIN_LINEUP(func) { wxEVT_SCROLLWIN_LINEUP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL }, +#define EVT_SCROLLWIN_LINEDOWN(func) { wxEVT_SCROLLWIN_LINEDOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL }, +#define EVT_SCROLLWIN_PAGEUP(func) { wxEVT_SCROLLWIN_PAGEUP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL }, +#define EVT_SCROLLWIN_PAGEDOWN(func) { wxEVT_SCROLLWIN_PAGEDOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL }, +#define EVT_SCROLLWIN_THUMBTRACK(func) { wxEVT_SCROLLWIN_THUMBTRACK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollWinEventFunction) & func, (wxObject *) NULL }, + +// Scrolling from wxSlider and wxScrollBar #define EVT_SCROLL(func) \ { wxEVT_SCROLL_TOP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL },\ { wxEVT_SCROLL_BOTTOM, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL },\ @@ -1439,7 +1458,7 @@ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ #define EVT_SCROLL_PAGEDOWN(func) { wxEVT_SCROLL_PAGEDOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL }, #define EVT_SCROLL_THUMBTRACK(func) { wxEVT_SCROLL_THUMBTRACK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL }, -// Scrolling, with an id +// Scrolling from wxSlider and wxScrollBar, with an id #define EVT_COMMAND_SCROLL(id, func) \ { wxEVT_SCROLL_TOP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL },\ { wxEVT_SCROLL_BOTTOM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) & func, (wxObject *) NULL },\ diff --git a/include/wx/generic/scrolwin.h b/include/wx/generic/scrolwin.h index 6368dfb0b2..f7478972ab 100644 --- a/include/wx/generic/scrolwin.h +++ b/include/wx/generic/scrolwin.h @@ -25,7 +25,7 @@ class WXDLLEXPORT wxScrolledWindow: public wxWindow DECLARE_ABSTRACT_CLASS(wxScrolledWindow) public: - wxScrolledWindow(void); + wxScrolledWindow(); inline wxScrolledWindow(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, @@ -35,7 +35,7 @@ public: Create(parent, id, pos, size, style, name); } - inline ~wxScrolledWindow(void) {} + ~wxScrolledWindow() {} bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, @@ -94,7 +94,7 @@ public: // Adjust the scrollbars virtual void AdjustScrollbars(void); - void OnScroll(wxScrollEvent& event); + void OnScroll(wxScrollWinEvent& event); void OnSize(wxSizeEvent& event); void OnPaint(wxPaintEvent& event); @@ -106,14 +106,11 @@ public: virtual void PrepareDC(wxDC& dc); public: - //////////////////////////////////////////////////////////////////////// - //// IMPLEMENTATION + // IMPLEMENTATION // Calculate scroll increment - virtual int CalcScrollInc(wxScrollEvent& event); + virtual int CalcScrollInc(wxScrollWinEvent& event); - //////////////////////////////////////////////////////////////////////// - //// PROTECTED DATA protected: int m_xScrollPixelsPerLine; int m_yScrollPixelsPerLine; @@ -131,8 +128,5 @@ protected: DECLARE_EVENT_TABLE() }; -//////////////////////////////////////////////////////////////////////// -//// INLINES - #endif // __SCROLWINH_G__ diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index c4d7073bd2..4c6fc6fa8f 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -113,9 +113,6 @@ public: virtual WXWidget GetHandle() const { return m_widget; } - // wxWindows callbacks - void OnKeyDown( wxKeyEvent &event ); - // also sets the global flag void SetScrolling(bool scroll); @@ -235,7 +232,6 @@ public: private: DECLARE_NO_COPY_CLASS(wxWindow); - DECLARE_EVENT_TABLE() }; #endif // __GTKWINDOWH__ diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index c4d7073bd2..4c6fc6fa8f 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -113,9 +113,6 @@ public: virtual WXWidget GetHandle() const { return m_widget; } - // wxWindows callbacks - void OnKeyDown( wxKeyEvent &event ); - // also sets the global flag void SetScrolling(bool scroll); @@ -235,7 +232,6 @@ public: private: DECLARE_NO_COPY_CLASS(wxWindow); - DECLARE_EVENT_TABLE() }; #endif // __GTKWINDOWH__ diff --git a/src/common/event.cpp b/src/common/event.cpp index 3db1b841b3..34cb92fcf7 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -164,8 +164,8 @@ wxScrollEvent::wxScrollEvent(wxEventType commandType, wxScrollWinEvent::wxScrollWinEvent(wxEventType commandType, int pos, int orient) - : wxEvent(commandType) { + m_eventType = commandType; m_extraLong = orient; m_commandInt = pos; } diff --git a/src/generic/scrolwin.cpp b/src/generic/scrolwin.cpp index acce71b175..de7ed95ef1 100644 --- a/src/generic/scrolwin.cpp +++ b/src/generic/scrolwin.cpp @@ -28,7 +28,7 @@ #if !USE_SHARED_LIBRARY BEGIN_EVENT_TABLE(wxScrolledWindow, wxWindow) - EVT_SCROLL(wxScrolledWindow::OnScroll) + EVT_SCROLLWIN(wxScrolledWindow::OnScroll) EVT_SIZE(wxScrolledWindow::OnSize) EVT_PAINT(wxScrolledWindow::OnPaint) END_EVENT_TABLE() @@ -45,7 +45,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow, wxWindow) #include #endif -wxScrolledWindow::wxScrolledWindow(void) +wxScrolledWindow::wxScrolledWindow() { m_xScrollPixelsPerLine = 0; m_yScrollPixelsPerLine = 0; @@ -153,7 +153,7 @@ void wxScrolledWindow::SetScrollbars (int pixelsPerUnitX, int pixelsPerUnitY, #endif } -void wxScrolledWindow::OnScroll(wxScrollEvent& event) +void wxScrolledWindow::OnScroll(wxScrollWinEvent& event) { int orient = event.GetOrientation(); @@ -196,7 +196,7 @@ void wxScrolledWindow::OnScroll(wxScrollEvent& event) } } -int wxScrolledWindow::CalcScrollInc(wxScrollEvent& event) +int wxScrolledWindow::CalcScrollInc(wxScrollWinEvent& event) { int pos = event.GetPosition(); int orient = event.GetOrientation(); @@ -204,7 +204,7 @@ int wxScrolledWindow::CalcScrollInc(wxScrollEvent& event) int nScrollInc = 0; switch (event.GetEventType()) { - case wxEVT_SCROLL_TOP: + case wxEVT_SCROLLWIN_TOP: { if (orient == wxHORIZONTAL) nScrollInc = - m_xScrollPosition; @@ -212,7 +212,7 @@ int wxScrolledWindow::CalcScrollInc(wxScrollEvent& event) nScrollInc = - m_yScrollPosition; break; } - case wxEVT_SCROLL_BOTTOM: + case wxEVT_SCROLLWIN_BOTTOM: { if (orient == wxHORIZONTAL) nScrollInc = m_xScrollLines - m_xScrollPosition; @@ -220,17 +220,17 @@ int wxScrolledWindow::CalcScrollInc(wxScrollEvent& event) nScrollInc = m_yScrollLines - m_yScrollPosition; break; } - case wxEVT_SCROLL_LINEUP: + case wxEVT_SCROLLWIN_LINEUP: { nScrollInc = -1; break; } - case wxEVT_SCROLL_LINEDOWN: + case wxEVT_SCROLLWIN_LINEDOWN: { nScrollInc = 1; break; } - case wxEVT_SCROLL_PAGEUP: + case wxEVT_SCROLLWIN_PAGEUP: { if (orient == wxHORIZONTAL) nScrollInc = -GetScrollPageSize(wxHORIZONTAL); @@ -238,7 +238,7 @@ int wxScrolledWindow::CalcScrollInc(wxScrollEvent& event) nScrollInc = -GetScrollPageSize(wxVERTICAL); break; } - case wxEVT_SCROLL_PAGEDOWN: + case wxEVT_SCROLLWIN_PAGEDOWN: { if (orient == wxHORIZONTAL) nScrollInc = GetScrollPageSize(wxHORIZONTAL); @@ -246,7 +246,7 @@ int wxScrolledWindow::CalcScrollInc(wxScrollEvent& event) nScrollInc = GetScrollPageSize(wxVERTICAL); break; } - case wxEVT_SCROLL_THUMBTRACK: + case wxEVT_SCROLLWIN_THUMBTRACK: { if (orient == wxHORIZONTAL) nScrollInc = pos - m_xScrollPosition; diff --git a/src/generic/splitter.cpp b/src/generic/splitter.cpp index 0d926085d4..f535bf2b6e 100644 --- a/src/generic/splitter.cpp +++ b/src/generic/splitter.cpp @@ -486,6 +486,9 @@ void wxSplitterWindow::SizeWindows() if ( m_windowOne && !m_windowTwo ) { m_windowOne->SetSize(m_borderSize, m_borderSize, w - 2*m_borderSize, h - 2*m_borderSize); + + if (m_windowOne->GetAutoLayout()) + m_windowOne->Layout(); } else if ( m_windowOne && m_windowTwo ) { @@ -503,6 +506,11 @@ void wxSplitterWindow::SizeWindows() m_windowOne->SetSize(x1, y1, w1, h1); m_windowTwo->SetSize(x2, y2, w2, h2); + + if (m_windowOne->GetAutoLayout()) + m_windowOne->Layout(); + if (m_windowTwo->GetAutoLayout()) + m_windowTwo->Layout(); } else { @@ -510,6 +518,11 @@ void wxSplitterWindow::SizeWindows() w - 2*m_borderSize, m_sashPosition - m_borderSize); m_windowTwo->SetSize(m_borderSize, m_sashPosition + m_sashSize, w - 2*m_borderSize, h - 2*m_borderSize - m_sashSize - (m_sashPosition - m_borderSize)); + + if (m_windowOne->GetAutoLayout()) + m_windowOne->Layout(); + if (m_windowTwo->GetAutoLayout()) + m_windowTwo->Layout(); } } wxClientDC dc(this); diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index a6616c919c..987c3b9c34 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -96,7 +96,13 @@ static gint gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEvent static gint gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win ) { - if (g_isIdle) wxapp_install_idle_handler(); + if (g_isIdle) + wxapp_install_idle_handler(); + + /* I haven''t been able to set the position of + the dialog before it is shown, so I set the + position in "realize" and "map" */ + gtk_widget_set_uposition( widget, win->m_x, win->m_y ); /* reset the icon */ if (win->m_icon != wxNullIcon) @@ -116,8 +122,12 @@ gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win ) static gint gtk_dialog_map_callback( GtkWidget *widget, wxDialog *win ) { + if (g_isIdle) + wxapp_install_idle_handler(); + /* I haven''t been able to set the position of - the dialog before it is shown, so I do it here */ + the dialog before it is shown, so I set the + position in "realize" and "map" */ gtk_widget_set_uposition( widget, win->m_x, win->m_y ); /* all this is for Motif Window Manager "hints" and is supposed to be diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index fa72030a8c..a66604c1d7 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -42,6 +42,7 @@ #include "gtk/gtk.h" #include "gdk/gdkprivate.h" #include "gdk/gdkkeysyms.h" +#include "gdk/gdkx.h" #include "wx/gtk/win_gtk.h" //----------------------------------------------------------------------------- @@ -181,6 +182,222 @@ void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window extern void wxapp_install_idle_handler(); extern bool g_isIdle; +//----------------------------------------------------------------------------- +// key event conversion routines +//----------------------------------------------------------------------------- + +static long map_to_unmodified_wx_keysym( KeySym keysym ) +{ + guint key_code = 0; + + switch (keysym) + { + case GDK_Shift_L: + case GDK_Shift_R: key_code = WXK_SHIFT; break; + case GDK_Control_L: + case GDK_Control_R: key_code = WXK_CONTROL; break; + case GDK_Menu: key_code = WXK_MENU; break; + case GDK_Help: key_code = WXK_HELP; break; + case GDK_BackSpace: key_code = WXK_BACK; break; + case GDK_ISO_Left_Tab: + case GDK_Tab: key_code = WXK_TAB; break; + case GDK_Linefeed: key_code = WXK_RETURN; break; + case GDK_Clear: key_code = WXK_CLEAR; break; + case GDK_Return: key_code = WXK_RETURN; break; + case GDK_Pause: key_code = WXK_PAUSE; break; + case GDK_Scroll_Lock: key_code = WXK_SCROLL; break; + case GDK_Escape: key_code = WXK_ESCAPE; break; + case GDK_Delete: key_code = WXK_DELETE; break; + case GDK_Home: key_code = WXK_HOME; break; + case GDK_Left: key_code = WXK_LEFT; break; + case GDK_Up: key_code = WXK_UP; break; + case GDK_Right: key_code = WXK_RIGHT; break; + case GDK_Down: key_code = WXK_DOWN; break; + case GDK_Prior: key_code = WXK_PRIOR; break; +// case GDK_Page_Up: key_code = WXK_PAGEUP; break; + case GDK_Next: key_code = WXK_NEXT; break; +// case GDK_Page_Down: key_code = WXK_PAGEDOWN; break; + case GDK_End: key_code = WXK_END; break; + case GDK_Begin: key_code = WXK_HOME; break; + case GDK_Select: key_code = WXK_SELECT; break; + case GDK_Print: key_code = WXK_PRINT; break; + case GDK_Execute: key_code = WXK_EXECUTE; break; + case GDK_Insert: key_code = WXK_INSERT; break; + case GDK_Num_Lock: key_code = WXK_NUMLOCK; break; + + case GDK_KP_0: key_code = WXK_NUMPAD0; break; + case GDK_KP_1: key_code = WXK_NUMPAD1; break; + case GDK_KP_2: key_code = WXK_NUMPAD2; break; + case GDK_KP_3: key_code = WXK_NUMPAD3; break; + case GDK_KP_4: key_code = WXK_NUMPAD4; break; + case GDK_KP_5: key_code = WXK_NUMPAD5; break; + case GDK_KP_6: key_code = WXK_NUMPAD6; break; + case GDK_KP_7: key_code = WXK_NUMPAD7; break; + case GDK_KP_8: key_code = WXK_NUMPAD8; break; + case GDK_KP_9: key_code = WXK_NUMPAD9; break; + case GDK_KP_Space: key_code = WXK_NUMPAD_SPACE; break; + case GDK_KP_Tab: key_code = WXK_NUMPAD_TAB; break; + case GDK_KP_Enter: key_code = WXK_NUMPAD_ENTER; break; + case GDK_KP_F1: key_code = WXK_NUMPAD_F1; break; + case GDK_KP_F2: key_code = WXK_NUMPAD_F2; break; + case GDK_KP_F3: key_code = WXK_NUMPAD_F3; break; + case GDK_KP_F4: key_code = WXK_NUMPAD_F4; break; + case GDK_KP_Home: key_code = WXK_NUMPAD_HOME; break; + case GDK_KP_Left: key_code = WXK_NUMPAD_LEFT; break; + case GDK_KP_Up: key_code = WXK_NUMPAD_UP; break; + case GDK_KP_Right: key_code = WXK_NUMPAD_RIGHT; break; + case GDK_KP_Down: key_code = WXK_NUMPAD_DOWN; break; + case GDK_KP_Prior: key_code = WXK_NUMPAD_PRIOR; break; +// case GDK_KP_Page_Up: key_code = WXK_NUMPAD_PAGEUP; break; + case GDK_KP_Next: key_code = WXK_NUMPAD_PRIOR; break; +// case GDK_KP_Page_Down: key_code = WXK_NUMPAD_PAGEDOWN; break; + case GDK_KP_End: key_code = WXK_NUMPAD_END; break; + case GDK_KP_Begin: key_code = WXK_NUMPAD_BEGIN; break; + case GDK_KP_Insert: key_code = WXK_NUMPAD_INSERT; break; + case GDK_KP_Delete: key_code = WXK_NUMPAD_DELETE; break; + case GDK_KP_Equal: key_code = WXK_NUMPAD_EQUAL; break; + case GDK_KP_Multiply: key_code = WXK_NUMPAD_MULTIPLY; break; + case GDK_KP_Add: key_code = WXK_NUMPAD_ADD; break; + case GDK_KP_Separator: key_code = WXK_NUMPAD_SEPARATOR; break; + case GDK_KP_Subtract: key_code = WXK_NUMPAD_SUBTRACT; break; + case GDK_KP_Decimal: key_code = WXK_NUMPAD_DECIMAL; break; + case GDK_KP_Divide: key_code = WXK_NUMPAD_DIVIDE; break; + + case GDK_F1: key_code = WXK_F1; break; + case GDK_F2: key_code = WXK_F2; break; + case GDK_F3: key_code = WXK_F3; break; + case GDK_F4: key_code = WXK_F4; break; + case GDK_F5: key_code = WXK_F5; break; + case GDK_F6: key_code = WXK_F6; break; + case GDK_F7: key_code = WXK_F7; break; + case GDK_F8: key_code = WXK_F8; break; + case GDK_F9: key_code = WXK_F9; break; + case GDK_F10: key_code = WXK_F10; break; + case GDK_F11: key_code = WXK_F11; break; + case GDK_F12: key_code = WXK_F12; break; + default: + { + if (keysym <= 0xFF) + { + guint upper = gdk_keyval_to_upper( keysym ); + keysym = (upper != 0 ? upper : keysym ); /* to be MSW compatible */ + key_code = keysym; + } + } + } + + return (key_code); +} + +static long map_to_wx_keysym( KeySym keysym ) +{ + guint key_code = 0; + + switch (keysym) + { + case GDK_Shift_L: + case GDK_Shift_R: key_code = WXK_SHIFT; break; + case GDK_Control_L: + case GDK_Control_R: key_code = WXK_CONTROL; break; + case GDK_Menu: key_code = WXK_MENU; break; + case GDK_Help: key_code = WXK_HELP; break; + case GDK_BackSpace: key_code = WXK_BACK; break; + case GDK_ISO_Left_Tab: + case GDK_Tab: key_code = WXK_TAB; break; + case GDK_Linefeed: key_code = WXK_RETURN; break; + case GDK_Clear: key_code = WXK_CLEAR; break; + case GDK_Return: key_code = WXK_RETURN; break; + case GDK_Pause: key_code = WXK_PAUSE; break; + case GDK_Scroll_Lock: key_code = WXK_SCROLL; break; + case GDK_Escape: key_code = WXK_ESCAPE; break; + case GDK_Delete: key_code = WXK_DELETE; break; + case GDK_Home: key_code = WXK_HOME; break; + case GDK_Left: key_code = WXK_LEFT; break; + case GDK_Up: key_code = WXK_UP; break; + case GDK_Right: key_code = WXK_RIGHT; break; + case GDK_Down: key_code = WXK_DOWN; break; + case GDK_Prior: key_code = WXK_PRIOR; break; +// case GDK_Page_Up: key_code = WXK_PAGEUP; break; + case GDK_Next: key_code = WXK_NEXT; break; +// case GDK_Page_Down: key_code = WXK_PAGEDOWN; break; + case GDK_End: key_code = WXK_END; break; + case GDK_Begin: key_code = WXK_HOME; break; + case GDK_Select: key_code = WXK_SELECT; break; + case GDK_Print: key_code = WXK_PRINT; break; + case GDK_Execute: key_code = WXK_EXECUTE; break; + case GDK_Insert: key_code = WXK_INSERT; break; + case GDK_Num_Lock: key_code = WXK_NUMLOCK; break; + + case GDK_KP_0: key_code = '0'; break; + case GDK_KP_1: key_code = '1'; break; + case GDK_KP_2: key_code = '2'; break; + case GDK_KP_3: key_code = '3'; break; + case GDK_KP_4: key_code = '4'; break; + case GDK_KP_5: key_code = '5'; break; + case GDK_KP_6: key_code = '6'; break; + case GDK_KP_7: key_code = '7'; break; + case GDK_KP_8: key_code = '8'; break; + case GDK_KP_9: key_code = '9'; break; + case GDK_KP_Space: key_code = ' '; break; + case GDK_KP_Tab: key_code = WXK_TAB; break; /* or '\t' ??? */ + case GDK_KP_Enter: key_code = WXK_RETURN; break; /* or '\r' ??? */ + case GDK_KP_F1: key_code = WXK_NUMPAD_F1; break; + case GDK_KP_F2: key_code = WXK_NUMPAD_F2; break; + case GDK_KP_F3: key_code = WXK_NUMPAD_F3; break; + case GDK_KP_F4: key_code = WXK_NUMPAD_F4; break; + case GDK_KP_Home: key_code = WXK_HOME; break; + case GDK_KP_Left: key_code = WXK_LEFT; break; + case GDK_KP_Up: key_code = WXK_UP; break; + case GDK_KP_Right: key_code = WXK_RIGHT; break; + case GDK_KP_Down: key_code = WXK_DOWN; break; + case GDK_KP_Prior: key_code = WXK_PRIOR; break; +// case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break; + case GDK_KP_Next: key_code = WXK_PRIOR; break; +// case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break; + case GDK_KP_End: key_code = WXK_END; break; + case GDK_KP_Begin: key_code = WXK_HOME; break; + case GDK_KP_Insert: key_code = WXK_INSERT; break; + case GDK_KP_Delete: key_code = WXK_DELETE; break; + case GDK_KP_Equal: key_code = '='; break; + case GDK_KP_Multiply: key_code = '*'; break; + case GDK_KP_Add: key_code = '+'; break; + case GDK_KP_Separator: key_code = ','; break; + case GDK_KP_Subtract: key_code = '-'; break; + case GDK_KP_Decimal: key_code = '.'; break; + case GDK_KP_Divide: key_code = '/'; break; + + case GDK_F1: key_code = WXK_F1; break; + case GDK_F2: key_code = WXK_F2; break; + case GDK_F3: key_code = WXK_F3; break; + case GDK_F4: key_code = WXK_F4; break; + case GDK_F5: key_code = WXK_F5; break; + case GDK_F6: key_code = WXK_F6; break; + case GDK_F7: key_code = WXK_F7; break; + case GDK_F8: key_code = WXK_F8; break; + case GDK_F9: key_code = WXK_F9; break; + case GDK_F10: key_code = WXK_F10; break; + case GDK_F11: key_code = WXK_F11; break; + case GDK_F12: key_code = WXK_F12; break; + default: + { + if (keysym <= 0xFF) + { + key_code = keysym; + } + } + } + + return (key_code); +} + +static long get_unmodified_wx_keysym( GdkEventKey *event ) +{ + KeyCode keycode = XKeysymToKeycode( GDK_DISPLAY(), event->keyval ); + KeySym keysym = XKeycodeToKeysym( GDK_DISPLAY(), keycode, 0 ); + + return (map_to_unmodified_wx_keysym( keysym )); +} + //----------------------------------------------------------------------------- // local code (see below) //----------------------------------------------------------------------------- @@ -350,97 +567,16 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e printf( "\n" ); */ - long key_code = 0; - switch (gdk_event->keyval) - { - case GDK_Shift_L: - case GDK_Shift_R: key_code = WXK_SHIFT; break; - case GDK_Control_L: - case GDK_Control_R: key_code = WXK_CONTROL; break; - case GDK_Menu: key_code = WXK_MENU; break; - case GDK_Help: key_code = WXK_HELP; break; - case GDK_BackSpace: key_code = WXK_BACK; break; - case GDK_ISO_Left_Tab: - case GDK_KP_Tab: - case GDK_Tab: key_code = WXK_TAB; break; - case GDK_Linefeed: key_code = WXK_RETURN; break; - case GDK_Clear: key_code = WXK_CLEAR; break; - case GDK_Return: key_code = WXK_RETURN; break; - case GDK_Pause: key_code = WXK_PAUSE; break; - case GDK_Scroll_Lock: key_code = WXK_SCROLL; break; - case GDK_Escape: key_code = WXK_ESCAPE; break; - case GDK_Delete: key_code = WXK_DELETE; break; - case GDK_Home: key_code = WXK_HOME; break; - case GDK_Left: key_code = WXK_LEFT; break; - case GDK_Up: key_code = WXK_UP; break; - case GDK_Right: key_code = WXK_RIGHT; break; - case GDK_Down: key_code = WXK_DOWN; break; - case GDK_Prior: key_code = WXK_PRIOR; break; -// case GDK_Page_Up: key_code = WXK_PAGEUP; break; - case GDK_Next: key_code = WXK_NEXT; break; -// case GDK_Page_Down: key_code = WXK_PAGEDOWN; break; - case GDK_End: key_code = WXK_END; break; - case GDK_Begin: key_code = WXK_HOME; break; - case GDK_Select: key_code = WXK_SELECT; break; - case GDK_Print: key_code = WXK_PRINT; break; - case GDK_Execute: key_code = WXK_EXECUTE; break; - case GDK_Insert: key_code = WXK_INSERT; break; - case GDK_Num_Lock: key_code = WXK_NUMLOCK; break; - case GDK_KP_Enter: key_code = WXK_RETURN; break; - case GDK_KP_Home: key_code = WXK_HOME; break; - case GDK_KP_Left: key_code = WXK_LEFT; break; - case GDK_KP_Up: key_code = WXK_UP; break; - case GDK_KP_Right: key_code = WXK_RIGHT; break; - case GDK_KP_Down: key_code = WXK_DOWN; break; - case GDK_KP_Prior: key_code = WXK_PRIOR; break; -// case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break; - case GDK_KP_Next: key_code = WXK_NEXT; break; -// case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break; - case GDK_KP_End: key_code = WXK_END; break; - case GDK_KP_Begin: key_code = WXK_HOME; break; - case GDK_KP_Insert: key_code = WXK_INSERT; break; - case GDK_KP_Delete: key_code = WXK_DELETE; break; - case GDK_KP_Multiply: key_code = WXK_MULTIPLY; break; - case GDK_KP_Add: key_code = WXK_ADD; break; - case GDK_KP_Separator: key_code = WXK_SEPARATOR; break; - case GDK_KP_Subtract: key_code = WXK_SUBTRACT; break; - case GDK_KP_Decimal: key_code = WXK_DECIMAL; break; - case GDK_KP_Divide: key_code = WXK_DIVIDE; break; - case GDK_KP_0: key_code = WXK_NUMPAD0; break; - case GDK_KP_1: key_code = WXK_NUMPAD1; break; - case GDK_KP_2: key_code = WXK_NUMPAD2; break; - case GDK_KP_3: key_code = WXK_NUMPAD3; break; - case GDK_KP_4: key_code = WXK_NUMPAD4; break; - case GDK_KP_5: key_code = WXK_NUMPAD5; break; - case GDK_KP_6: key_code = WXK_NUMPAD6; break; - case GDK_KP_7: key_code = WXK_NUMPAD7; break; - case GDK_KP_8: key_code = WXK_NUMPAD7; break; - case GDK_KP_9: key_code = WXK_NUMPAD9; break; - case GDK_F1: key_code = WXK_F1; break; - case GDK_F2: key_code = WXK_F2; break; - case GDK_F3: key_code = WXK_F3; break; - case GDK_F4: key_code = WXK_F4; break; - case GDK_F5: key_code = WXK_F5; break; - case GDK_F6: key_code = WXK_F6; break; - case GDK_F7: key_code = WXK_F7; break; - case GDK_F8: key_code = WXK_F8; break; - case GDK_F9: key_code = WXK_F9; break; - case GDK_F10: key_code = WXK_F10; break; - case GDK_F11: key_code = WXK_F11; break; - case GDK_F12: key_code = WXK_F12; break; - default: - { - if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF)) - key_code = gdk_event->keyval; - } - } - + bool ret = FALSE; + int x = 0; int y = 0; GdkModifierType state; if (gdk_event->window) gdk_window_get_pointer(gdk_event->window, &x, &y, &state); - wxKeyEvent event( wxEVT_KEY_DOWN ); + long key_code = get_unmodified_wx_keysym( gdk_event ); + + wxKeyEvent event( wxEVT_KEY_DOWN ); event.SetTimestamp( gdk_event->time ); event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); @@ -451,8 +587,27 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e event.m_x = x; event.m_y = y; event.SetEventObject( win ); - - bool ret = win->GetEventHandler()->ProcessEvent( event ); + ret = win->GetEventHandler()->ProcessEvent( event ); + + key_code = map_to_wx_keysym( gdk_event->keyval ); + + /* wxMSW doesn't send char events with Alt pressed */ + if (((gdk_event->state & GDK_MOD1_MASK) == 0) && + ((gdk_event->state & GDK_MOD1_MASK) == 0)) + { + wxKeyEvent event2( wxEVT_CHAR ); + event2.SetTimestamp( gdk_event->time ); + event2.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); + event2.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); +// event2.m_altDown = (gdk_event->state & GDK_MOD1_MASK); +// event2.m_metaDown = (gdk_event->state & GDK_MOD2_MASK); + event2.m_keyCode = key_code; + event2.m_scanCode = gdk_event->keyval; + event2.m_x = x; + event2.m_y = y; + event2.SetEventObject( win ); + ret = (ret || win->GetEventHandler()->ProcessEvent( event2 )); + } if (!ret) { @@ -549,90 +704,7 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk printf( "\n" ); */ - long key_code = 0; - switch (gdk_event->keyval) - { - case GDK_Shift_L: - case GDK_Shift_R: key_code = WXK_SHIFT; break; - case GDK_Control_L: - case GDK_Control_R: key_code = WXK_CONTROL; break; - case GDK_Menu: key_code = WXK_MENU; break; - case GDK_Help: key_code = WXK_HELP; break; - case GDK_BackSpace: key_code = WXK_BACK; break; - case GDK_ISO_Left_Tab: - case GDK_KP_Tab: - case GDK_Tab: key_code = WXK_TAB; break; - case GDK_Linefeed: key_code = WXK_RETURN; break; - case GDK_Clear: key_code = WXK_CLEAR; break; - case GDK_Return: key_code = WXK_RETURN; break; - case GDK_Pause: key_code = WXK_PAUSE; break; - case GDK_Scroll_Lock: key_code = WXK_SCROLL; break; - case GDK_Escape: key_code = WXK_ESCAPE; break; - case GDK_Delete: key_code = WXK_DELETE; break; - case GDK_Home: key_code = WXK_HOME; break; - case GDK_Left: key_code = WXK_LEFT; break; - case GDK_Up: key_code = WXK_UP; break; - case GDK_Right: key_code = WXK_RIGHT; break; - case GDK_Down: key_code = WXK_DOWN; break; - case GDK_Prior: key_code = WXK_PRIOR; break; -// case GDK_Page_Up: key_code = WXK_PAGEUP; break; - case GDK_Next: key_code = WXK_NEXT; break; -// case GDK_Page_Down: key_code = WXK_PAGEDOWN; break; - case GDK_End: key_code = WXK_END; break; - case GDK_Begin: key_code = WXK_HOME; break; - case GDK_Select: key_code = WXK_SELECT; break; - case GDK_Print: key_code = WXK_PRINT; break; - case GDK_Execute: key_code = WXK_EXECUTE; break; - case GDK_Insert: key_code = WXK_INSERT; break; - case GDK_Num_Lock: key_code = WXK_NUMLOCK; break; - case GDK_KP_Enter: key_code = WXK_RETURN; break; - case GDK_KP_Home: key_code = WXK_HOME; break; - case GDK_KP_Left: key_code = WXK_LEFT; break; - case GDK_KP_Up: key_code = WXK_UP; break; - case GDK_KP_Right: key_code = WXK_RIGHT; break; - case GDK_KP_Down: key_code = WXK_DOWN; break; - case GDK_KP_Prior: key_code = WXK_PRIOR; break; -// case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break; - case GDK_KP_Next: key_code = WXK_NEXT; break; -// case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break; - case GDK_KP_End: key_code = WXK_END; break; - case GDK_KP_Begin: key_code = WXK_HOME; break; - case GDK_KP_Insert: key_code = WXK_INSERT; break; - case GDK_KP_Delete: key_code = WXK_DELETE; break; - case GDK_KP_Multiply: key_code = WXK_MULTIPLY; break; - case GDK_KP_Add: key_code = WXK_ADD; break; - case GDK_KP_Separator: key_code = WXK_SEPARATOR; break; - case GDK_KP_Subtract: key_code = WXK_SUBTRACT; break; - case GDK_KP_Decimal: key_code = WXK_DECIMAL; break; - case GDK_KP_Divide: key_code = WXK_DIVIDE; break; - case GDK_KP_0: key_code = WXK_NUMPAD0; break; - case GDK_KP_1: key_code = WXK_NUMPAD1; break; - case GDK_KP_2: key_code = WXK_NUMPAD2; break; - case GDK_KP_3: key_code = WXK_NUMPAD3; break; - case GDK_KP_4: key_code = WXK_NUMPAD4; break; - case GDK_KP_5: key_code = WXK_NUMPAD5; break; - case GDK_KP_6: key_code = WXK_NUMPAD6; break; - case GDK_KP_7: key_code = WXK_NUMPAD7; break; - case GDK_KP_8: key_code = WXK_NUMPAD7; break; - case GDK_KP_9: key_code = WXK_NUMPAD9; break; - case GDK_F1: key_code = WXK_F1; break; - case GDK_F2: key_code = WXK_F2; break; - case GDK_F3: key_code = WXK_F3; break; - case GDK_F4: key_code = WXK_F4; break; - case GDK_F5: key_code = WXK_F5; break; - case GDK_F6: key_code = WXK_F6; break; - case GDK_F7: key_code = WXK_F7; break; - case GDK_F8: key_code = WXK_F8; break; - case GDK_F9: key_code = WXK_F9; break; - case GDK_F10: key_code = WXK_F10; break; - case GDK_F11: key_code = WXK_F11; break; - case GDK_F12: key_code = WXK_F12; break; - default: - { - if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF)) - key_code = gdk_event->keyval; - } - } + long key_code = get_unmodified_wx_keysym( gdk_event ); int x = 0; int y = 0; @@ -1238,22 +1310,22 @@ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * if (win->IsScrolling()) { - command = wxEVT_SCROLL_THUMBTRACK; + command = wxEVT_SCROLLWIN_THUMBTRACK; } else { - if (fabs(win->m_vAdjust->value-win->m_vAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; - else if (fabs(win->m_vAdjust->value-win->m_vAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP; - else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; - else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; - else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; - else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP; - else command = wxEVT_SCROLL_THUMBTRACK; + if (fabs(win->m_vAdjust->value-win->m_vAdjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM; + else if (fabs(win->m_vAdjust->value-win->m_vAdjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP; + else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEDOWN; + else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEUP; + else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEDOWN; + else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEUP; + else command = wxEVT_SCROLLWIN_THUMBTRACK; } int value = (int)(win->m_vAdjust->value+0.5); - wxScrollEvent event( command, win->GetId(), value, wxVERTICAL ); + wxScrollWinEvent event( command, value, wxVERTICAL ); event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( event ); } @@ -1281,22 +1353,22 @@ static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * if (win->IsScrolling()) { - command = wxEVT_SCROLL_THUMBTRACK; + command = wxEVT_SCROLLWIN_THUMBTRACK; } else { - if (fabs(win->m_hAdjust->value-win->m_hAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; - else if (fabs(win->m_hAdjust->value-win->m_hAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP; - else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; - else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; - else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; - else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP; - else command = wxEVT_SCROLL_THUMBTRACK; + if (fabs(win->m_hAdjust->value-win->m_hAdjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM; + else if (fabs(win->m_hAdjust->value-win->m_hAdjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP; + else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEDOWN; + else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEUP; + else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEDOWN; + else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEUP; + else command = wxEVT_SCROLLWIN_THUMBTRACK; } int value = (int)(win->m_hAdjust->value+0.5); - wxScrollEvent event( command, win->GetId(), value, wxHORIZONTAL ); + wxScrollWinEvent event( command, value, wxHORIZONTAL ); event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( event ); } @@ -1313,10 +1385,10 @@ static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxW if (g_blockEventsOnDrag) return; if (!win->m_hasVMT) return; - wxEventType command = wxEVT_SCROLL_THUMBTRACK; + wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK; int value = (int)(win->m_vAdjust->value+0.5); - wxScrollEvent event( command, win->GetId(), value, wxVERTICAL ); + wxScrollWinEvent event( command, value, wxVERTICAL ); event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( event ); } @@ -1333,10 +1405,10 @@ static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxW if (g_blockEventsOnDrag) return; if (!win->m_hasVMT) return; - wxEventType command = wxEVT_SCROLL_THUMBTRACK; + wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK; int value = (int)(win->m_hAdjust->value+0.5); - wxScrollEvent event( command, win->GetId(), value, wxHORIZONTAL ); + wxScrollWinEvent event( command, value, wxHORIZONTAL ); event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( event ); } @@ -1468,10 +1540,6 @@ wxWindow* wxGetActiveWindow() IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) -BEGIN_EVENT_TABLE(wxWindow, wxWindowBase) - EVT_KEY_DOWN(wxWindow::OnKeyDown) -END_EVENT_TABLE() - void wxWindow::Init() { // common init @@ -2192,16 +2260,6 @@ void wxWindow::GetTextExtent( const wxString& string, if (externalLeading) (*externalLeading) = 0; // ?? } -void wxWindow::OnKeyDown( wxKeyEvent &event ) -{ - event.SetEventType( wxEVT_CHAR ); - - if (!GetEventHandler()->ProcessEvent( event )) - { - event.Skip(); - } -} - void wxWindow::SetFocus() { wxCHECK_RET( (m_widget != NULL), _T("invalid window") ); diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index a6616c919c..987c3b9c34 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -96,7 +96,13 @@ static gint gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEvent static gint gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win ) { - if (g_isIdle) wxapp_install_idle_handler(); + if (g_isIdle) + wxapp_install_idle_handler(); + + /* I haven''t been able to set the position of + the dialog before it is shown, so I set the + position in "realize" and "map" */ + gtk_widget_set_uposition( widget, win->m_x, win->m_y ); /* reset the icon */ if (win->m_icon != wxNullIcon) @@ -116,8 +122,12 @@ gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win ) static gint gtk_dialog_map_callback( GtkWidget *widget, wxDialog *win ) { + if (g_isIdle) + wxapp_install_idle_handler(); + /* I haven''t been able to set the position of - the dialog before it is shown, so I do it here */ + the dialog before it is shown, so I set the + position in "realize" and "map" */ gtk_widget_set_uposition( widget, win->m_x, win->m_y ); /* all this is for Motif Window Manager "hints" and is supposed to be diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index fa72030a8c..a66604c1d7 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -42,6 +42,7 @@ #include "gtk/gtk.h" #include "gdk/gdkprivate.h" #include "gdk/gdkkeysyms.h" +#include "gdk/gdkx.h" #include "wx/gtk/win_gtk.h" //----------------------------------------------------------------------------- @@ -181,6 +182,222 @@ void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window extern void wxapp_install_idle_handler(); extern bool g_isIdle; +//----------------------------------------------------------------------------- +// key event conversion routines +//----------------------------------------------------------------------------- + +static long map_to_unmodified_wx_keysym( KeySym keysym ) +{ + guint key_code = 0; + + switch (keysym) + { + case GDK_Shift_L: + case GDK_Shift_R: key_code = WXK_SHIFT; break; + case GDK_Control_L: + case GDK_Control_R: key_code = WXK_CONTROL; break; + case GDK_Menu: key_code = WXK_MENU; break; + case GDK_Help: key_code = WXK_HELP; break; + case GDK_BackSpace: key_code = WXK_BACK; break; + case GDK_ISO_Left_Tab: + case GDK_Tab: key_code = WXK_TAB; break; + case GDK_Linefeed: key_code = WXK_RETURN; break; + case GDK_Clear: key_code = WXK_CLEAR; break; + case GDK_Return: key_code = WXK_RETURN; break; + case GDK_Pause: key_code = WXK_PAUSE; break; + case GDK_Scroll_Lock: key_code = WXK_SCROLL; break; + case GDK_Escape: key_code = WXK_ESCAPE; break; + case GDK_Delete: key_code = WXK_DELETE; break; + case GDK_Home: key_code = WXK_HOME; break; + case GDK_Left: key_code = WXK_LEFT; break; + case GDK_Up: key_code = WXK_UP; break; + case GDK_Right: key_code = WXK_RIGHT; break; + case GDK_Down: key_code = WXK_DOWN; break; + case GDK_Prior: key_code = WXK_PRIOR; break; +// case GDK_Page_Up: key_code = WXK_PAGEUP; break; + case GDK_Next: key_code = WXK_NEXT; break; +// case GDK_Page_Down: key_code = WXK_PAGEDOWN; break; + case GDK_End: key_code = WXK_END; break; + case GDK_Begin: key_code = WXK_HOME; break; + case GDK_Select: key_code = WXK_SELECT; break; + case GDK_Print: key_code = WXK_PRINT; break; + case GDK_Execute: key_code = WXK_EXECUTE; break; + case GDK_Insert: key_code = WXK_INSERT; break; + case GDK_Num_Lock: key_code = WXK_NUMLOCK; break; + + case GDK_KP_0: key_code = WXK_NUMPAD0; break; + case GDK_KP_1: key_code = WXK_NUMPAD1; break; + case GDK_KP_2: key_code = WXK_NUMPAD2; break; + case GDK_KP_3: key_code = WXK_NUMPAD3; break; + case GDK_KP_4: key_code = WXK_NUMPAD4; break; + case GDK_KP_5: key_code = WXK_NUMPAD5; break; + case GDK_KP_6: key_code = WXK_NUMPAD6; break; + case GDK_KP_7: key_code = WXK_NUMPAD7; break; + case GDK_KP_8: key_code = WXK_NUMPAD8; break; + case GDK_KP_9: key_code = WXK_NUMPAD9; break; + case GDK_KP_Space: key_code = WXK_NUMPAD_SPACE; break; + case GDK_KP_Tab: key_code = WXK_NUMPAD_TAB; break; + case GDK_KP_Enter: key_code = WXK_NUMPAD_ENTER; break; + case GDK_KP_F1: key_code = WXK_NUMPAD_F1; break; + case GDK_KP_F2: key_code = WXK_NUMPAD_F2; break; + case GDK_KP_F3: key_code = WXK_NUMPAD_F3; break; + case GDK_KP_F4: key_code = WXK_NUMPAD_F4; break; + case GDK_KP_Home: key_code = WXK_NUMPAD_HOME; break; + case GDK_KP_Left: key_code = WXK_NUMPAD_LEFT; break; + case GDK_KP_Up: key_code = WXK_NUMPAD_UP; break; + case GDK_KP_Right: key_code = WXK_NUMPAD_RIGHT; break; + case GDK_KP_Down: key_code = WXK_NUMPAD_DOWN; break; + case GDK_KP_Prior: key_code = WXK_NUMPAD_PRIOR; break; +// case GDK_KP_Page_Up: key_code = WXK_NUMPAD_PAGEUP; break; + case GDK_KP_Next: key_code = WXK_NUMPAD_PRIOR; break; +// case GDK_KP_Page_Down: key_code = WXK_NUMPAD_PAGEDOWN; break; + case GDK_KP_End: key_code = WXK_NUMPAD_END; break; + case GDK_KP_Begin: key_code = WXK_NUMPAD_BEGIN; break; + case GDK_KP_Insert: key_code = WXK_NUMPAD_INSERT; break; + case GDK_KP_Delete: key_code = WXK_NUMPAD_DELETE; break; + case GDK_KP_Equal: key_code = WXK_NUMPAD_EQUAL; break; + case GDK_KP_Multiply: key_code = WXK_NUMPAD_MULTIPLY; break; + case GDK_KP_Add: key_code = WXK_NUMPAD_ADD; break; + case GDK_KP_Separator: key_code = WXK_NUMPAD_SEPARATOR; break; + case GDK_KP_Subtract: key_code = WXK_NUMPAD_SUBTRACT; break; + case GDK_KP_Decimal: key_code = WXK_NUMPAD_DECIMAL; break; + case GDK_KP_Divide: key_code = WXK_NUMPAD_DIVIDE; break; + + case GDK_F1: key_code = WXK_F1; break; + case GDK_F2: key_code = WXK_F2; break; + case GDK_F3: key_code = WXK_F3; break; + case GDK_F4: key_code = WXK_F4; break; + case GDK_F5: key_code = WXK_F5; break; + case GDK_F6: key_code = WXK_F6; break; + case GDK_F7: key_code = WXK_F7; break; + case GDK_F8: key_code = WXK_F8; break; + case GDK_F9: key_code = WXK_F9; break; + case GDK_F10: key_code = WXK_F10; break; + case GDK_F11: key_code = WXK_F11; break; + case GDK_F12: key_code = WXK_F12; break; + default: + { + if (keysym <= 0xFF) + { + guint upper = gdk_keyval_to_upper( keysym ); + keysym = (upper != 0 ? upper : keysym ); /* to be MSW compatible */ + key_code = keysym; + } + } + } + + return (key_code); +} + +static long map_to_wx_keysym( KeySym keysym ) +{ + guint key_code = 0; + + switch (keysym) + { + case GDK_Shift_L: + case GDK_Shift_R: key_code = WXK_SHIFT; break; + case GDK_Control_L: + case GDK_Control_R: key_code = WXK_CONTROL; break; + case GDK_Menu: key_code = WXK_MENU; break; + case GDK_Help: key_code = WXK_HELP; break; + case GDK_BackSpace: key_code = WXK_BACK; break; + case GDK_ISO_Left_Tab: + case GDK_Tab: key_code = WXK_TAB; break; + case GDK_Linefeed: key_code = WXK_RETURN; break; + case GDK_Clear: key_code = WXK_CLEAR; break; + case GDK_Return: key_code = WXK_RETURN; break; + case GDK_Pause: key_code = WXK_PAUSE; break; + case GDK_Scroll_Lock: key_code = WXK_SCROLL; break; + case GDK_Escape: key_code = WXK_ESCAPE; break; + case GDK_Delete: key_code = WXK_DELETE; break; + case GDK_Home: key_code = WXK_HOME; break; + case GDK_Left: key_code = WXK_LEFT; break; + case GDK_Up: key_code = WXK_UP; break; + case GDK_Right: key_code = WXK_RIGHT; break; + case GDK_Down: key_code = WXK_DOWN; break; + case GDK_Prior: key_code = WXK_PRIOR; break; +// case GDK_Page_Up: key_code = WXK_PAGEUP; break; + case GDK_Next: key_code = WXK_NEXT; break; +// case GDK_Page_Down: key_code = WXK_PAGEDOWN; break; + case GDK_End: key_code = WXK_END; break; + case GDK_Begin: key_code = WXK_HOME; break; + case GDK_Select: key_code = WXK_SELECT; break; + case GDK_Print: key_code = WXK_PRINT; break; + case GDK_Execute: key_code = WXK_EXECUTE; break; + case GDK_Insert: key_code = WXK_INSERT; break; + case GDK_Num_Lock: key_code = WXK_NUMLOCK; break; + + case GDK_KP_0: key_code = '0'; break; + case GDK_KP_1: key_code = '1'; break; + case GDK_KP_2: key_code = '2'; break; + case GDK_KP_3: key_code = '3'; break; + case GDK_KP_4: key_code = '4'; break; + case GDK_KP_5: key_code = '5'; break; + case GDK_KP_6: key_code = '6'; break; + case GDK_KP_7: key_code = '7'; break; + case GDK_KP_8: key_code = '8'; break; + case GDK_KP_9: key_code = '9'; break; + case GDK_KP_Space: key_code = ' '; break; + case GDK_KP_Tab: key_code = WXK_TAB; break; /* or '\t' ??? */ + case GDK_KP_Enter: key_code = WXK_RETURN; break; /* or '\r' ??? */ + case GDK_KP_F1: key_code = WXK_NUMPAD_F1; break; + case GDK_KP_F2: key_code = WXK_NUMPAD_F2; break; + case GDK_KP_F3: key_code = WXK_NUMPAD_F3; break; + case GDK_KP_F4: key_code = WXK_NUMPAD_F4; break; + case GDK_KP_Home: key_code = WXK_HOME; break; + case GDK_KP_Left: key_code = WXK_LEFT; break; + case GDK_KP_Up: key_code = WXK_UP; break; + case GDK_KP_Right: key_code = WXK_RIGHT; break; + case GDK_KP_Down: key_code = WXK_DOWN; break; + case GDK_KP_Prior: key_code = WXK_PRIOR; break; +// case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break; + case GDK_KP_Next: key_code = WXK_PRIOR; break; +// case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break; + case GDK_KP_End: key_code = WXK_END; break; + case GDK_KP_Begin: key_code = WXK_HOME; break; + case GDK_KP_Insert: key_code = WXK_INSERT; break; + case GDK_KP_Delete: key_code = WXK_DELETE; break; + case GDK_KP_Equal: key_code = '='; break; + case GDK_KP_Multiply: key_code = '*'; break; + case GDK_KP_Add: key_code = '+'; break; + case GDK_KP_Separator: key_code = ','; break; + case GDK_KP_Subtract: key_code = '-'; break; + case GDK_KP_Decimal: key_code = '.'; break; + case GDK_KP_Divide: key_code = '/'; break; + + case GDK_F1: key_code = WXK_F1; break; + case GDK_F2: key_code = WXK_F2; break; + case GDK_F3: key_code = WXK_F3; break; + case GDK_F4: key_code = WXK_F4; break; + case GDK_F5: key_code = WXK_F5; break; + case GDK_F6: key_code = WXK_F6; break; + case GDK_F7: key_code = WXK_F7; break; + case GDK_F8: key_code = WXK_F8; break; + case GDK_F9: key_code = WXK_F9; break; + case GDK_F10: key_code = WXK_F10; break; + case GDK_F11: key_code = WXK_F11; break; + case GDK_F12: key_code = WXK_F12; break; + default: + { + if (keysym <= 0xFF) + { + key_code = keysym; + } + } + } + + return (key_code); +} + +static long get_unmodified_wx_keysym( GdkEventKey *event ) +{ + KeyCode keycode = XKeysymToKeycode( GDK_DISPLAY(), event->keyval ); + KeySym keysym = XKeycodeToKeysym( GDK_DISPLAY(), keycode, 0 ); + + return (map_to_unmodified_wx_keysym( keysym )); +} + //----------------------------------------------------------------------------- // local code (see below) //----------------------------------------------------------------------------- @@ -350,97 +567,16 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e printf( "\n" ); */ - long key_code = 0; - switch (gdk_event->keyval) - { - case GDK_Shift_L: - case GDK_Shift_R: key_code = WXK_SHIFT; break; - case GDK_Control_L: - case GDK_Control_R: key_code = WXK_CONTROL; break; - case GDK_Menu: key_code = WXK_MENU; break; - case GDK_Help: key_code = WXK_HELP; break; - case GDK_BackSpace: key_code = WXK_BACK; break; - case GDK_ISO_Left_Tab: - case GDK_KP_Tab: - case GDK_Tab: key_code = WXK_TAB; break; - case GDK_Linefeed: key_code = WXK_RETURN; break; - case GDK_Clear: key_code = WXK_CLEAR; break; - case GDK_Return: key_code = WXK_RETURN; break; - case GDK_Pause: key_code = WXK_PAUSE; break; - case GDK_Scroll_Lock: key_code = WXK_SCROLL; break; - case GDK_Escape: key_code = WXK_ESCAPE; break; - case GDK_Delete: key_code = WXK_DELETE; break; - case GDK_Home: key_code = WXK_HOME; break; - case GDK_Left: key_code = WXK_LEFT; break; - case GDK_Up: key_code = WXK_UP; break; - case GDK_Right: key_code = WXK_RIGHT; break; - case GDK_Down: key_code = WXK_DOWN; break; - case GDK_Prior: key_code = WXK_PRIOR; break; -// case GDK_Page_Up: key_code = WXK_PAGEUP; break; - case GDK_Next: key_code = WXK_NEXT; break; -// case GDK_Page_Down: key_code = WXK_PAGEDOWN; break; - case GDK_End: key_code = WXK_END; break; - case GDK_Begin: key_code = WXK_HOME; break; - case GDK_Select: key_code = WXK_SELECT; break; - case GDK_Print: key_code = WXK_PRINT; break; - case GDK_Execute: key_code = WXK_EXECUTE; break; - case GDK_Insert: key_code = WXK_INSERT; break; - case GDK_Num_Lock: key_code = WXK_NUMLOCK; break; - case GDK_KP_Enter: key_code = WXK_RETURN; break; - case GDK_KP_Home: key_code = WXK_HOME; break; - case GDK_KP_Left: key_code = WXK_LEFT; break; - case GDK_KP_Up: key_code = WXK_UP; break; - case GDK_KP_Right: key_code = WXK_RIGHT; break; - case GDK_KP_Down: key_code = WXK_DOWN; break; - case GDK_KP_Prior: key_code = WXK_PRIOR; break; -// case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break; - case GDK_KP_Next: key_code = WXK_NEXT; break; -// case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break; - case GDK_KP_End: key_code = WXK_END; break; - case GDK_KP_Begin: key_code = WXK_HOME; break; - case GDK_KP_Insert: key_code = WXK_INSERT; break; - case GDK_KP_Delete: key_code = WXK_DELETE; break; - case GDK_KP_Multiply: key_code = WXK_MULTIPLY; break; - case GDK_KP_Add: key_code = WXK_ADD; break; - case GDK_KP_Separator: key_code = WXK_SEPARATOR; break; - case GDK_KP_Subtract: key_code = WXK_SUBTRACT; break; - case GDK_KP_Decimal: key_code = WXK_DECIMAL; break; - case GDK_KP_Divide: key_code = WXK_DIVIDE; break; - case GDK_KP_0: key_code = WXK_NUMPAD0; break; - case GDK_KP_1: key_code = WXK_NUMPAD1; break; - case GDK_KP_2: key_code = WXK_NUMPAD2; break; - case GDK_KP_3: key_code = WXK_NUMPAD3; break; - case GDK_KP_4: key_code = WXK_NUMPAD4; break; - case GDK_KP_5: key_code = WXK_NUMPAD5; break; - case GDK_KP_6: key_code = WXK_NUMPAD6; break; - case GDK_KP_7: key_code = WXK_NUMPAD7; break; - case GDK_KP_8: key_code = WXK_NUMPAD7; break; - case GDK_KP_9: key_code = WXK_NUMPAD9; break; - case GDK_F1: key_code = WXK_F1; break; - case GDK_F2: key_code = WXK_F2; break; - case GDK_F3: key_code = WXK_F3; break; - case GDK_F4: key_code = WXK_F4; break; - case GDK_F5: key_code = WXK_F5; break; - case GDK_F6: key_code = WXK_F6; break; - case GDK_F7: key_code = WXK_F7; break; - case GDK_F8: key_code = WXK_F8; break; - case GDK_F9: key_code = WXK_F9; break; - case GDK_F10: key_code = WXK_F10; break; - case GDK_F11: key_code = WXK_F11; break; - case GDK_F12: key_code = WXK_F12; break; - default: - { - if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF)) - key_code = gdk_event->keyval; - } - } - + bool ret = FALSE; + int x = 0; int y = 0; GdkModifierType state; if (gdk_event->window) gdk_window_get_pointer(gdk_event->window, &x, &y, &state); - wxKeyEvent event( wxEVT_KEY_DOWN ); + long key_code = get_unmodified_wx_keysym( gdk_event ); + + wxKeyEvent event( wxEVT_KEY_DOWN ); event.SetTimestamp( gdk_event->time ); event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); @@ -451,8 +587,27 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e event.m_x = x; event.m_y = y; event.SetEventObject( win ); - - bool ret = win->GetEventHandler()->ProcessEvent( event ); + ret = win->GetEventHandler()->ProcessEvent( event ); + + key_code = map_to_wx_keysym( gdk_event->keyval ); + + /* wxMSW doesn't send char events with Alt pressed */ + if (((gdk_event->state & GDK_MOD1_MASK) == 0) && + ((gdk_event->state & GDK_MOD1_MASK) == 0)) + { + wxKeyEvent event2( wxEVT_CHAR ); + event2.SetTimestamp( gdk_event->time ); + event2.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); + event2.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); +// event2.m_altDown = (gdk_event->state & GDK_MOD1_MASK); +// event2.m_metaDown = (gdk_event->state & GDK_MOD2_MASK); + event2.m_keyCode = key_code; + event2.m_scanCode = gdk_event->keyval; + event2.m_x = x; + event2.m_y = y; + event2.SetEventObject( win ); + ret = (ret || win->GetEventHandler()->ProcessEvent( event2 )); + } if (!ret) { @@ -549,90 +704,7 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk printf( "\n" ); */ - long key_code = 0; - switch (gdk_event->keyval) - { - case GDK_Shift_L: - case GDK_Shift_R: key_code = WXK_SHIFT; break; - case GDK_Control_L: - case GDK_Control_R: key_code = WXK_CONTROL; break; - case GDK_Menu: key_code = WXK_MENU; break; - case GDK_Help: key_code = WXK_HELP; break; - case GDK_BackSpace: key_code = WXK_BACK; break; - case GDK_ISO_Left_Tab: - case GDK_KP_Tab: - case GDK_Tab: key_code = WXK_TAB; break; - case GDK_Linefeed: key_code = WXK_RETURN; break; - case GDK_Clear: key_code = WXK_CLEAR; break; - case GDK_Return: key_code = WXK_RETURN; break; - case GDK_Pause: key_code = WXK_PAUSE; break; - case GDK_Scroll_Lock: key_code = WXK_SCROLL; break; - case GDK_Escape: key_code = WXK_ESCAPE; break; - case GDK_Delete: key_code = WXK_DELETE; break; - case GDK_Home: key_code = WXK_HOME; break; - case GDK_Left: key_code = WXK_LEFT; break; - case GDK_Up: key_code = WXK_UP; break; - case GDK_Right: key_code = WXK_RIGHT; break; - case GDK_Down: key_code = WXK_DOWN; break; - case GDK_Prior: key_code = WXK_PRIOR; break; -// case GDK_Page_Up: key_code = WXK_PAGEUP; break; - case GDK_Next: key_code = WXK_NEXT; break; -// case GDK_Page_Down: key_code = WXK_PAGEDOWN; break; - case GDK_End: key_code = WXK_END; break; - case GDK_Begin: key_code = WXK_HOME; break; - case GDK_Select: key_code = WXK_SELECT; break; - case GDK_Print: key_code = WXK_PRINT; break; - case GDK_Execute: key_code = WXK_EXECUTE; break; - case GDK_Insert: key_code = WXK_INSERT; break; - case GDK_Num_Lock: key_code = WXK_NUMLOCK; break; - case GDK_KP_Enter: key_code = WXK_RETURN; break; - case GDK_KP_Home: key_code = WXK_HOME; break; - case GDK_KP_Left: key_code = WXK_LEFT; break; - case GDK_KP_Up: key_code = WXK_UP; break; - case GDK_KP_Right: key_code = WXK_RIGHT; break; - case GDK_KP_Down: key_code = WXK_DOWN; break; - case GDK_KP_Prior: key_code = WXK_PRIOR; break; -// case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break; - case GDK_KP_Next: key_code = WXK_NEXT; break; -// case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break; - case GDK_KP_End: key_code = WXK_END; break; - case GDK_KP_Begin: key_code = WXK_HOME; break; - case GDK_KP_Insert: key_code = WXK_INSERT; break; - case GDK_KP_Delete: key_code = WXK_DELETE; break; - case GDK_KP_Multiply: key_code = WXK_MULTIPLY; break; - case GDK_KP_Add: key_code = WXK_ADD; break; - case GDK_KP_Separator: key_code = WXK_SEPARATOR; break; - case GDK_KP_Subtract: key_code = WXK_SUBTRACT; break; - case GDK_KP_Decimal: key_code = WXK_DECIMAL; break; - case GDK_KP_Divide: key_code = WXK_DIVIDE; break; - case GDK_KP_0: key_code = WXK_NUMPAD0; break; - case GDK_KP_1: key_code = WXK_NUMPAD1; break; - case GDK_KP_2: key_code = WXK_NUMPAD2; break; - case GDK_KP_3: key_code = WXK_NUMPAD3; break; - case GDK_KP_4: key_code = WXK_NUMPAD4; break; - case GDK_KP_5: key_code = WXK_NUMPAD5; break; - case GDK_KP_6: key_code = WXK_NUMPAD6; break; - case GDK_KP_7: key_code = WXK_NUMPAD7; break; - case GDK_KP_8: key_code = WXK_NUMPAD7; break; - case GDK_KP_9: key_code = WXK_NUMPAD9; break; - case GDK_F1: key_code = WXK_F1; break; - case GDK_F2: key_code = WXK_F2; break; - case GDK_F3: key_code = WXK_F3; break; - case GDK_F4: key_code = WXK_F4; break; - case GDK_F5: key_code = WXK_F5; break; - case GDK_F6: key_code = WXK_F6; break; - case GDK_F7: key_code = WXK_F7; break; - case GDK_F8: key_code = WXK_F8; break; - case GDK_F9: key_code = WXK_F9; break; - case GDK_F10: key_code = WXK_F10; break; - case GDK_F11: key_code = WXK_F11; break; - case GDK_F12: key_code = WXK_F12; break; - default: - { - if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF)) - key_code = gdk_event->keyval; - } - } + long key_code = get_unmodified_wx_keysym( gdk_event ); int x = 0; int y = 0; @@ -1238,22 +1310,22 @@ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * if (win->IsScrolling()) { - command = wxEVT_SCROLL_THUMBTRACK; + command = wxEVT_SCROLLWIN_THUMBTRACK; } else { - if (fabs(win->m_vAdjust->value-win->m_vAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; - else if (fabs(win->m_vAdjust->value-win->m_vAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP; - else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; - else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; - else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; - else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP; - else command = wxEVT_SCROLL_THUMBTRACK; + if (fabs(win->m_vAdjust->value-win->m_vAdjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM; + else if (fabs(win->m_vAdjust->value-win->m_vAdjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP; + else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEDOWN; + else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEUP; + else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEDOWN; + else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEUP; + else command = wxEVT_SCROLLWIN_THUMBTRACK; } int value = (int)(win->m_vAdjust->value+0.5); - wxScrollEvent event( command, win->GetId(), value, wxVERTICAL ); + wxScrollWinEvent event( command, value, wxVERTICAL ); event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( event ); } @@ -1281,22 +1353,22 @@ static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * if (win->IsScrolling()) { - command = wxEVT_SCROLL_THUMBTRACK; + command = wxEVT_SCROLLWIN_THUMBTRACK; } else { - if (fabs(win->m_hAdjust->value-win->m_hAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; - else if (fabs(win->m_hAdjust->value-win->m_hAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP; - else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; - else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; - else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; - else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP; - else command = wxEVT_SCROLL_THUMBTRACK; + if (fabs(win->m_hAdjust->value-win->m_hAdjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM; + else if (fabs(win->m_hAdjust->value-win->m_hAdjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP; + else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEDOWN; + else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEUP; + else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEDOWN; + else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEUP; + else command = wxEVT_SCROLLWIN_THUMBTRACK; } int value = (int)(win->m_hAdjust->value+0.5); - wxScrollEvent event( command, win->GetId(), value, wxHORIZONTAL ); + wxScrollWinEvent event( command, value, wxHORIZONTAL ); event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( event ); } @@ -1313,10 +1385,10 @@ static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxW if (g_blockEventsOnDrag) return; if (!win->m_hasVMT) return; - wxEventType command = wxEVT_SCROLL_THUMBTRACK; + wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK; int value = (int)(win->m_vAdjust->value+0.5); - wxScrollEvent event( command, win->GetId(), value, wxVERTICAL ); + wxScrollWinEvent event( command, value, wxVERTICAL ); event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( event ); } @@ -1333,10 +1405,10 @@ static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxW if (g_blockEventsOnDrag) return; if (!win->m_hasVMT) return; - wxEventType command = wxEVT_SCROLL_THUMBTRACK; + wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK; int value = (int)(win->m_hAdjust->value+0.5); - wxScrollEvent event( command, win->GetId(), value, wxHORIZONTAL ); + wxScrollWinEvent event( command, value, wxHORIZONTAL ); event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( event ); } @@ -1468,10 +1540,6 @@ wxWindow* wxGetActiveWindow() IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) -BEGIN_EVENT_TABLE(wxWindow, wxWindowBase) - EVT_KEY_DOWN(wxWindow::OnKeyDown) -END_EVENT_TABLE() - void wxWindow::Init() { // common init @@ -2192,16 +2260,6 @@ void wxWindow::GetTextExtent( const wxString& string, if (externalLeading) (*externalLeading) = 0; // ?? } -void wxWindow::OnKeyDown( wxKeyEvent &event ) -{ - event.SetEventType( wxEVT_CHAR ); - - if (!GetEventHandler()->ProcessEvent( event )) - { - event.Skip(); - } -} - void wxWindow::SetFocus() { wxCHECK_RET( (m_widget != NULL), _T("invalid window") ); -- 2.45.2