X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ea5c6ca7f7c3dc448da4be353a1153a792d01db4..0c0890656219df340e90c8f3ba230c50490096aa:/src/gtk1/window.cpp diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 7326273401..433694c88c 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -44,6 +44,10 @@ #include "gdk/gdkkeysyms.h" #include "wx/gtk/win_gtk.h" +#if (GTK_MINOR_VERSION == 0) +#include "gdk/gdkx.h" +#endif + //----------------------------------------------------------------------------- // documentation on internals //----------------------------------------------------------------------------- @@ -128,6 +132,7 @@ extern wxList wxPendingDelete; extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnScroll; +extern wxCursor g_globalCursor; static bool g_capturing = FALSE; static wxWindow *g_focusWindow = (wxWindow*) NULL; @@ -185,6 +190,22 @@ extern bool g_isIdle; // key event conversion routines //----------------------------------------------------------------------------- +#if (GTK_MINOR_VERSION == 0) +static guint +gdk_keyval_to_upper (guint keyval) +{ + if (keyval) + { + KeySym lower_val = 0; + KeySym upper_val = 0; + + XConvertCase (keyval, &lower_val, &upper_val); + return upper_val; + } + return 0; +} +#endif + static long map_to_unmodified_wx_keysym( KeySym keysym ) { guint key_code = 0; @@ -248,7 +269,7 @@ static long map_to_unmodified_wx_keysym( KeySym keysym ) 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_Next: key_code = WXK_NUMPAD_NEXT; 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; @@ -347,7 +368,7 @@ static long map_to_wx_keysym( KeySym keysym ) 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_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; @@ -420,7 +441,7 @@ static void draw_frame( GtkWidget *widget, wxWindow *win ) if (scroll_window->hscrollbar_visible) { dh += 15; /* dh += hscrollbar->allocation.height; */ - dw += scroll_class->scrollbar_spacing; + dh += scroll_class->scrollbar_spacing; } } @@ -553,7 +574,6 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e printf( "ControlUp.\n" ); printf( "\n" ); */ - int x = 0; int y = 0; GdkModifierType state; @@ -616,7 +636,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e } } - // win is a control: tab can be propagated up + /* win is a control: tab can be propagated up */ if ( (!ret) && ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) && (win->HasFlag(wxTE_PROCESS_TAB) == 0)) @@ -630,6 +650,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e ret = win->GetEventHandler()->ProcessEvent( new_event ); } + /* generate wxID_CANCEL if has been pressed (typically in dialogs) */ if ( (!ret) && (gdk_event->keyval == GDK_Escape) ) { @@ -637,6 +658,36 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e new_event.SetEventObject( win ); ret = win->GetEventHandler()->ProcessEvent( new_event ); } + +#if (GTK_MINOR_VERSION > 0) + /* pressing F10 will activate the menu bar of the top frame */ + if ( (!ret) && + (gdk_event->keyval == GDK_F10) ) + { + wxWindow *ancestor = win; + while (ancestor) + { + if (wxIsKindOf(ancestor,wxFrame)) + { + wxFrame *frame = (wxFrame*) ancestor; + wxMenuBar *menubar = frame->GetMenuBar(); + if (menubar) + { + wxNode *node = menubar->GetMenus().First(); + if (node) + { + wxMenu *firstMenu = (wxMenu*) node->Data(); + // doesn't work correctly + // gtk_menu_item_select( GTK_MENU_ITEM(firstMenu->m_owner) ); + // ret = TRUE; + break; + } + } + } + ancestor = ancestor->GetParent(); + } + } +#endif /* Damn, I forgot why this didn't work, but it didn't work. @@ -1200,11 +1251,10 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_ if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE; - if (widget->window && win->GetCursor().Ok() ) - gdk_window_set_cursor( widget->window, win->GetCursor().GetCursor() ); - wxMouseEvent event( wxEVT_ENTER_WINDOW ); +#if (GTK_MINOR_VERSION > 0) event.SetTimestamp( gdk_event->time ); +#endif event.SetEventObject( win ); int x = 0; @@ -1247,11 +1297,10 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_ if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE; - if (widget->window && win->GetCursor().Ok() ) - gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() ); - wxMouseEvent event( wxEVT_LEAVE_WINDOW ); +#if (GTK_MINOR_VERSION > 0) event.SetTimestamp( gdk_event->time ); +#endif event.SetEventObject( win ); int x = 0; @@ -1487,6 +1536,10 @@ gtk_window_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win ) win->SetForegroundColour( win->GetForegroundColour() ); win->SetCursor( win->GetCursor() ); + + wxWindowCreateEvent event( win ); + event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( event ); return FALSE; } @@ -1927,11 +1980,13 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight; int border = 0; + int bottom_border = 0; - if (GTK_WIDGET_HAS_DEFAULT(m_widget)) + if (GTK_WIDGET_CAN_DEFAULT(m_widget)) { /* the default button has a border around it */ - border = 5; + border = 6; + bottom_border = 5; } /* this is the result of hours of debugging: the following code @@ -1960,7 +2015,7 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) m_x-border, m_y-border, m_width+2*border, - m_height+2*border ); + m_height+border+bottom_border ); } m_sizeSet = TRUE; @@ -1974,6 +2029,19 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) void wxWindow::OnInternalIdle() { + GdkWindow *window = GetConnectWidget()->window; + if (window) + { + wxCursor cursor = m_cursor; + if (g_globalCursor.Ok()) cursor = g_globalCursor; + + if (m_currentGdkCursor != cursor) + { + gdk_window_set_cursor( window, cursor.GetCursor() ); + m_currentGdkCursor = cursor; + } + } + UpdateWindowUI(); } @@ -2040,7 +2108,7 @@ void wxWindow::DoSetClientSize( int width, int height ) if (scroll_window->hscrollbar_visible) { dh += 15; /* dh += hscrollbar->allocation.height; */ - dw += scroll_class->scrollbar_spacing; + dh += scroll_class->scrollbar_spacing; } } @@ -2333,11 +2401,7 @@ bool wxWindow::SetCursor( const wxCursor &cursor ) return TRUE; } - if ((m_widget) && (m_widget->window)) - gdk_window_set_cursor( m_widget->window, GetCursor().GetCursor() ); - - if ((m_wxwindow) && (m_wxwindow->window)) - gdk_window_set_cursor( m_wxwindow->window, GetCursor().GetCursor() ); +// gdk_window_set_cursor( connect_widget->window, GetCursor().GetCursor() ); // cursor was set return TRUE;