event.m_altDown = (gdk_event->state & GDK_MOD1_MASK) != 0;
event.m_metaDown = (gdk_event->state & GDK_META_MASK) != 0;
+ // At least with current Linux systems, MOD5 corresponds to AltGr key and
+ // we represent it, for consistency with Windows, which really allows to
+ // use Ctrl+Alt as a replacement for AltGr if this key is not present, as a
+ // combination of these two modifiers.
+ if ( gdk_event->state & GDK_MOD5_MASK )
+ {
+ event.m_controlDown =
+ event.m_altDown = true;
+ }
+
// Normally we take the state of modifiers directly from the low level GDK
// event but unfortunately GDK uses a different convention from MSW for the
// key events corresponding to the modifier keys themselves: in it, when
event.m_rawCode = (wxUint32) gdk_event->keyval;
event.m_rawFlags = gdk_event->hardware_keycode;
- wxGetMousePosition(&event.m_x, &event.m_y);
- win->ScreenToClient(&event.m_x, &event.m_y);
event.SetEventObject( win );
}
// will only be sent if it is not in an accelerator table.
if (!ret)
{
- long key_code;
KeySym keysym = gdk_event->keyval;
// Find key code for EVT_CHAR and EVT_CHAR_HOOK events
- key_code = wxTranslateKeySymToWXKey(keysym, true /* isChar */);
+ long key_code = wxTranslateKeySymToWXKey(keysym, true /* isChar */);
if ( !key_code )
{
if ( wxIsAsciiKeysym(keysym) )
wxLogTrace(TRACE_KEYS, wxT("Char event: %ld"), key_code);
eventChar.m_keyCode = key_code;
+#if wxUSE_UNICODE
+ eventChar.m_uniChar = gdk_keyval_to_unicode(key_code);
+#endif // wxUSE_UNICODE
AdjustCharEventKeyCodes(eventChar);
Create( parent, id, pos, size, style, name );
}
+void wxWindowGTK::GTKCreateScrolledWindowWith(GtkWidget* view)
+{
+ wxASSERT_MSG( HasFlag(wxHSCROLL) || HasFlag(wxVSCROLL),
+ wxS("Must not be called if scrolling is not needed.") );
+
+ m_widget = gtk_scrolled_window_new( NULL, NULL );
+
+ GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
+
+ // There is a conflict with default bindings at GTK+
+ // level between scrolled windows and notebooks both of which want to use
+ // Ctrl-PageUp/Down: scrolled windows for scrolling in the horizontal
+ // direction and notebooks for changing pages -- we decide that if we don't
+ // have wxHSCROLL style we can safely sacrifice horizontal scrolling if it
+ // means we can get working keyboard navigation in notebooks
+ if ( !HasFlag(wxHSCROLL) )
+ {
+ GtkBindingSet *
+ bindings = gtk_binding_set_by_class(G_OBJECT_GET_CLASS(m_widget));
+ if ( bindings )
+ {
+ gtk_binding_entry_remove(bindings, GDK_Page_Up, GDK_CONTROL_MASK);
+ gtk_binding_entry_remove(bindings, GDK_Page_Down, GDK_CONTROL_MASK);
+ }
+ }
+
+ if (HasFlag(wxALWAYS_SHOW_SB))
+ {
+ gtk_scrolled_window_set_policy( scrolledWindow, GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS );
+ }
+ else
+ {
+ gtk_scrolled_window_set_policy( scrolledWindow, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
+ }
+
+ m_scrollBar[ScrollDir_Horz] = GTK_RANGE(gtk_scrolled_window_get_hscrollbar(scrolledWindow));
+ m_scrollBar[ScrollDir_Vert] = GTK_RANGE(gtk_scrolled_window_get_vscrollbar(scrolledWindow));
+ if (GetLayoutDirection() == wxLayout_RightToLeft)
+ gtk_range_set_inverted( m_scrollBar[ScrollDir_Horz], TRUE );
+
+ gtk_container_add( GTK_CONTAINER(m_widget), view );
+
+ // connect various scroll-related events
+ for ( int dir = 0; dir < ScrollDir_Max; dir++ )
+ {
+ // these handlers block mouse events to any window during scrolling
+ // such as motion events and prevent GTK and wxWidgets from fighting
+ // over where the slider should be
+ g_signal_connect(m_scrollBar[dir], "button_press_event",
+ G_CALLBACK(gtk_scrollbar_button_press_event), this);
+ g_signal_connect(m_scrollBar[dir], "button_release_event",
+ G_CALLBACK(gtk_scrollbar_button_release_event), this);
+
+ gulong handler_id = g_signal_connect(m_scrollBar[dir], "event_after",
+ G_CALLBACK(gtk_scrollbar_event_after), this);
+ g_signal_handler_block(m_scrollBar[dir], handler_id);
+
+ // these handlers get notified when scrollbar slider moves
+ g_signal_connect_after(m_scrollBar[dir], "value_changed",
+ G_CALLBACK(gtk_scrollbar_value_changed), this);
+ }
+
+ gtk_widget_show( view );
+}
+
bool wxWindowGTK::Create( wxWindow *parent,
wxWindowID id,
const wxPoint &pos,
if (!HasFlag(wxHSCROLL) && !HasFlag(wxVSCROLL))
m_widget = m_wxwindow;
else
- {
- m_widget = gtk_scrolled_window_new( NULL, NULL );
-
- GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
-
- // There is a conflict with default bindings at GTK+
- // level between scrolled windows and notebooks both of which want to use
- // Ctrl-PageUp/Down: scrolled windows for scrolling in the horizontal
- // direction and notebooks for changing pages -- we decide that if we don't
- // have wxHSCROLL style we can safely sacrifice horizontal scrolling if it
- // means we can get working keyboard navigation in notebooks
- if ( !HasFlag(wxHSCROLL) )
- {
- GtkBindingSet *
- bindings = gtk_binding_set_by_class(G_OBJECT_GET_CLASS(m_widget));
- if ( bindings )
- {
- gtk_binding_entry_remove(bindings, GDK_Page_Up, GDK_CONTROL_MASK);
- gtk_binding_entry_remove(bindings, GDK_Page_Down, GDK_CONTROL_MASK);
- }
- }
-
- if (HasFlag(wxALWAYS_SHOW_SB))
- {
- gtk_scrolled_window_set_policy( scrolledWindow, GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS );
- }
- else
- {
- gtk_scrolled_window_set_policy( scrolledWindow, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
- }
-
- m_scrollBar[ScrollDir_Horz] = GTK_RANGE(gtk_scrolled_window_get_hscrollbar(scrolledWindow));
- m_scrollBar[ScrollDir_Vert] = GTK_RANGE(gtk_scrolled_window_get_vscrollbar(scrolledWindow));
- if (GetLayoutDirection() == wxLayout_RightToLeft)
- gtk_range_set_inverted( m_scrollBar[ScrollDir_Horz], TRUE );
-
- gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
-
- // connect various scroll-related events
- for ( int dir = 0; dir < ScrollDir_Max; dir++ )
- {
- // these handlers block mouse events to any window during scrolling
- // such as motion events and prevent GTK and wxWidgets from fighting
- // over where the slider should be
- g_signal_connect(m_scrollBar[dir], "button_press_event",
- G_CALLBACK(gtk_scrollbar_button_press_event), this);
- g_signal_connect(m_scrollBar[dir], "button_release_event",
- G_CALLBACK(gtk_scrollbar_button_release_event), this);
-
- gulong handler_id = g_signal_connect(m_scrollBar[dir], "event_after",
- G_CALLBACK(gtk_scrollbar_event_after), this);
- g_signal_handler_block(m_scrollBar[dir], handler_id);
-
- // these handlers get notified when scrollbar slider moves
- g_signal_connect_after(m_scrollBar[dir], "value_changed",
- G_CALLBACK(gtk_scrollbar_value_changed), this);
- }
-
- gtk_widget_show( m_wxwindow );
- }
+ GTKCreateScrolledWindowWith(m_wxwindow);
g_object_ref(m_widget);
if (m_parent)