X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a2053b27b318fe81918a72c838944d1e8cd1524f..ea804aadf91c963d97a56e152d8372c9e689affe:/src/gtk1/window.cpp?ds=inline diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index dcf7519e32..50d64dbc91 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -339,10 +339,16 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e if (g_blockEventsOnDrag) return FALSE; /* - printf( "OnKeyPress from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); + printf( "KeyDown-ScanCode is: %d.\n", gdk_event->keyval ); + if (gdk_event->state & GDK_SHIFT_MASK) + printf( "ShiftDown.\n" ); + else + printf( "ShiftUp.\n" ); + if (gdk_event->state & GDK_CONTROL_MASK) + printf( "ControlDown.\n" ); + else + printf( "ControlUp.\n" ); + printf( "\n" ); */ long key_code = 0; @@ -427,6 +433,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e if (!key_code) return FALSE; 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); event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); @@ -521,10 +528,16 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk if (g_blockEventsOnDrag) return FALSE; /* - printf( "OnKeyRelease from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); + printf( "KeyUp-ScanCode is: %d.\n", gdk_event->keyval ); + if (gdk_event->state & GDK_SHIFT_MASK) + printf( "ShiftDown.\n" ); + else + printf( "ShiftUp.\n" ); + if (gdk_event->state & GDK_CONTROL_MASK) + printf( "ControlDown.\n" ); + else + printf( "ControlUp.\n" ); + printf( "\n" ); */ long key_code = 0; @@ -609,6 +622,7 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk if (!key_code) return FALSE; wxKeyEvent event( wxEVT_KEY_UP ); + event.SetTimestamp( gdk_event->time ); event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); @@ -703,6 +717,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton } wxMouseEvent event( event_type ); + event.SetTimestamp( gdk_event->time ); event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); @@ -813,6 +828,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto } wxMouseEvent event( event_type ); + event.SetTimestamp( gdk_event->time ); event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); @@ -922,6 +938,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion */ wxMouseEvent event( wxEVT_MOTION ); + event.SetTimestamp( gdk_event->time ); event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); @@ -1103,6 +1120,7 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_ gdk_window_set_cursor( widget->window, win->GetCursor().GetCursor() ); wxMouseEvent event( wxEVT_ENTER_WINDOW ); + event.SetTimestamp( gdk_event->time ); event.SetEventObject( win ); int x = 0; @@ -1149,6 +1167,7 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_ gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() ); wxMouseEvent event( wxEVT_LEAVE_WINDOW ); + event.SetTimestamp( gdk_event->time ); event.SetEventObject( win ); int x = 0; @@ -1369,35 +1388,21 @@ wxWindow *wxWindowBase::FindFocus() been realized, so we do this directly after realization */ static gint -gtk_window_realized_callback( GtkWidget *widget, wxWindow *win ) +gtk_window_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win ) { if (g_isIdle) wxapp_install_idle_handler(); - if (win->m_font != *wxSWISS_FONT) - { - wxFont font( win->m_font ); - win->m_font = wxNullFont; - win->SetFont( font ); - } + if (win->m_delayedFont) + win->SetFont( win->GetFont() ); - if (win->m_backgroundColour != wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE )) - { - wxColour bg( win->m_backgroundColour ); - win->m_backgroundColour = wxNullColour; - win->SetBackgroundColour( bg ); - } + if (win->m_delayedBackgroundColour) + win->SetBackgroundColour( win->GetBackgroundColour() ); - if (win->m_foregroundColour != *wxBLACK) - { - wxColour fg( win->m_foregroundColour ); - win->m_foregroundColour = wxNullColour; - win->SetForegroundColour( fg ); - } + if (win->m_delayedForegroundColour) + win->SetForegroundColour( win->GetForegroundColour() ); - wxCursor cursor( win->m_cursor ); - win->m_cursor = wxNullCursor; - win->SetCursor( cursor ); + win->SetCursor( win->GetCursor() ); return FALSE; } @@ -1464,12 +1469,10 @@ void wxWindow::Init() m_width = 0; m_height = 0; - m_font = *wxSWISS_FONT; - m_windowName = "noname"; - m_sizeSet = FALSE; m_hasVMT = FALSE; m_needParent = TRUE; + m_isBeingDeleted = FALSE; m_hasScrolling = FALSE; m_isScrolling = FALSE; @@ -1650,6 +1653,7 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, wxWindow::~wxWindow() { + m_isBeingDeleted = TRUE; m_hasVMT = FALSE; if (m_widget) @@ -2098,8 +2102,11 @@ bool wxWindow::Show( bool show ) { wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") ); - if ( !wxWindowBase::Show(show) ) + if (!wxWindowBase::Show(show)) + { + // nothing to do return FALSE; + } if (show) gtk_widget_show( m_widget ); @@ -2113,8 +2120,11 @@ bool wxWindow::Enable( bool enable ) { wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") ); - if ( !wxWindowBase::Enable(enable) ) + if (!wxWindowBase::Enable(enable)) + { + // nothing to do return FALSE; + } gtk_widget_set_sensitive( m_widget, enable ); if ( m_wxwindow ) @@ -2234,9 +2244,24 @@ bool wxWindow::SetCursor( const wxCursor &cursor ) { wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") ); - if ( wxWindowBase::SetCursor(cursor) ) + if (!wxWindowBase::SetCursor(cursor)) { - if (!m_widget->window) return TRUE; + // don't leave if the GTK widget has just + // been realized + if (!m_delayedCursor) return FALSE; + } + + GtkWidget *connect_widget = GetConnectWidget(); + if (!connect_widget->window) + { + // indicate that a new style has been set + // but it couldn't get applied as the + // widget hasn't been realized yet. + m_delayedCursor = TRUE; + + // pretend we have done something + return TRUE; + } if ((m_widget) && (m_widget->window)) gdk_window_set_cursor( m_widget->window, GetCursor().GetCursor() ); @@ -2244,14 +2269,8 @@ bool wxWindow::SetCursor( const wxCursor &cursor ) if ((m_wxwindow) && (m_wxwindow->window)) gdk_window_set_cursor( m_wxwindow->window, GetCursor().GetCursor() ); - // cursor was set - return TRUE; - } - else - { - // cursor hasn't been changed - return FALSE; - } + // cursor was set + return TRUE; } void wxWindow::WarpPointer( int WXUNUSED(x), int WXUNUSED(y) ) @@ -2332,11 +2351,24 @@ bool wxWindow::SetBackgroundColour( const wxColour &colour ) { wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") ); - if (!colour.Ok()) return FALSE; - if (m_backgroundColour == colour) return FALSE; - + if (!wxWindowBase::SetBackgroundColour(colour)) + { + // don't leave if the GTK widget has just + // been realized + if (!m_delayedBackgroundColour) return FALSE; + } + GtkWidget *connect_widget = GetConnectWidget(); - if (!connect_widget->window) return TRUE; + if (!connect_widget->window) + { + // indicate that a new style has been set + // but it couldn't get applied as the + // widget hasn't been realized yet. + m_delayedBackgroundColour = TRUE; + + // pretend we have done something + return TRUE; + } if (m_wxwindow && m_wxwindow->window) { @@ -2349,7 +2381,7 @@ bool wxWindow::SetBackgroundColour( const wxColour &colour ) wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); - if ( sysbg == m_backgroundColour ) + if (sysbg == m_backgroundColour) { m_backgroundColour = wxNullColour; ApplyWidgetStyle(); @@ -2367,14 +2399,27 @@ bool wxWindow::SetForegroundColour( const wxColour &colour ) { wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") ); - if (!colour.Ok()) return FALSE; - if (m_backgroundColour == colour) return FALSE; - + if (!wxWindowBase::SetForegroundColour(colour)) + { + // don't leave if the GTK widget has just + // been realized + if (!m_delayedForegroundColour) return FALSE; + } + GtkWidget *connect_widget = GetConnectWidget(); - if (!connect_widget->window) return TRUE; + if (!connect_widget->window) + { + // indicate that a new style has been set + // but it couldn't get applied as the + // widget hasn't been realized yet. + m_delayedForegroundColour = TRUE; + + // pretend we have done something + return TRUE; + } wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); - if ( sysbg == m_foregroundColour ) + if (sysbg == m_foregroundColour) { m_backgroundColour = wxNullColour; ApplyWidgetStyle(); @@ -2448,7 +2493,9 @@ static void SetInvokingWindow( wxMenu *menu, wxWindow *win ) static gint gs_pop_x = 0; static gint gs_pop_y = 0; -static void pop_pos_callback( GtkMenu *menu, gint *x, gint *y, wxWindow *win ) +static void pop_pos_callback( GtkMenu * WXUNUSED(menu), + gint *x, gint *y, + wxWindow *win ) { win->ClientToScreen( &gs_pop_x, &gs_pop_y ); *x = gs_pop_x; @@ -2516,11 +2563,24 @@ bool wxWindow::SetFont( const wxFont &font ) { wxCHECK_MSG( m_widget != NULL, FALSE, _T( "invalid window") ); - if (!font.Ok()) return FALSE; - if (m_font == font) return FALSE; - + if (!wxWindowBase::SetFont(font)) + { + // don't leave if the GTK widget has just + // been realized + if (!m_delayedFont) return FALSE; + } + GtkWidget *connect_widget = GetConnectWidget(); - if (!connect_widget->window) return TRUE; + if (!connect_widget->window) + { + // indicate that a new style has been set + // but it couldn't get applied as the + // widget hasn't been realized yet. + m_delayedFont = TRUE; + + // pretend we have done something + return TRUE; + } wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); if ( sysbg == m_backgroundColour ) @@ -2635,15 +2695,10 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible, m_vAdjust->page_size = fthumb; } - if (m_wxwindow->window) - { - if (orient == wxHORIZONTAL) - gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" ); - else - gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" ); - - gtk_widget_set_usize( m_widget, m_width, m_height ); - } + if (orient == wxHORIZONTAL) + gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" ); + else + gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" ); } void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) @@ -2673,7 +2728,7 @@ void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) m_vAdjust->value = fpos; } - if (!m_isScrolling) + if (!m_isScrolling) /* prevent recursion */ { if (m_wxwindow->window) {