]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/window.cpp
missing comma for Motif compilation added
[wxWidgets.git] / src / gtk1 / window.cpp
index dcf7519e32e505a5e8a3caaa91f0abb2aa620d5a..50d64dbc9167a40e18bef2e9532f63164232b3b4 100644 (file)
@@ -339,10 +339,16 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
     if (g_blockEventsOnDrag) return FALSE;
 
 /*
     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;
 */
 
     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 );
     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);
     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;
 
 /*
     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;
 */
 
     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 );
     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);
     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 );
     }
 
     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);
     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 );
     }
 
     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);
     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 );
 */
 
     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);
     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 );
         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;
     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 );
         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;
     event.SetEventObject( win );
 
     int x = 0;
@@ -1369,35 +1388,21 @@ wxWindow *wxWindowBase::FindFocus()
    been realized, so we do this directly after realization */
 
 static gint
    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 (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;
 }
 
     return FALSE;
 }
@@ -1464,12 +1469,10 @@ void wxWindow::Init()
     m_width = 0;
     m_height = 0;
 
     m_width = 0;
     m_height = 0;
 
-    m_font = *wxSWISS_FONT;
-    m_windowName = "noname";
-
     m_sizeSet = FALSE;
     m_hasVMT = FALSE;
     m_needParent = TRUE;
     m_sizeSet = FALSE;
     m_hasVMT = FALSE;
     m_needParent = TRUE;
+    m_isBeingDeleted = FALSE;
 
     m_hasScrolling = FALSE;
     m_isScrolling = FALSE;
 
     m_hasScrolling = FALSE;
     m_isScrolling = FALSE;
@@ -1650,6 +1653,7 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
 
 wxWindow::~wxWindow()
 {
 
 wxWindow::~wxWindow()
 {
+    m_isBeingDeleted = TRUE;
     m_hasVMT = FALSE;
 
     if (m_widget)
     m_hasVMT = FALSE;
 
     if (m_widget)
@@ -2098,8 +2102,11 @@ bool wxWindow::Show( bool show )
 {
     wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") );
 
 {
     wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") );
 
-    if ( !wxWindowBase::Show(show) )
+    if (!wxWindowBase::Show(show))
+    {
+        // nothing to do
         return FALSE;
         return FALSE;
+    }
 
     if (show)
         gtk_widget_show( m_widget );
 
     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") );
 
 {
     wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") );
 
-    if ( !wxWindowBase::Enable(enable) )
+    if (!wxWindowBase::Enable(enable))
+    {
+        // nothing to do
         return FALSE;
         return FALSE;
+    }
 
     gtk_widget_set_sensitive( m_widget, enable );
     if ( m_wxwindow )
 
     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") );
 
 {
     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() );
 
         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() );
 
         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) )
 }
 
 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") );
 
 {
     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();
     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)
     {
 
     if (m_wxwindow && m_wxwindow->window)
     {
@@ -2349,7 +2381,7 @@ bool wxWindow::SetBackgroundColour( const wxColour &colour )
 
     wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
 
 
     wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
 
-    if ( sysbg == m_backgroundColour )
+    if (sysbg == m_backgroundColour)
     {
         m_backgroundColour = wxNullColour;
         ApplyWidgetStyle();
     {
         m_backgroundColour = wxNullColour;
         ApplyWidgetStyle();
@@ -2367,14 +2399,27 @@ bool wxWindow::SetForegroundColour( const wxColour &colour )
 {
     wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
 
 {
     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();
     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 );
 
     wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
-    if ( sysbg == m_foregroundColour )
+    if (sysbg == m_foregroundColour)
     {
         m_backgroundColour = wxNullColour;
         ApplyWidgetStyle();
     {
         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 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;
 {
     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") );
 
 {
     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();
     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 )
 
     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;
     }
 
         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) )
 }
 
 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;
     }
 
         m_vAdjust->value = fpos;
     }
 
-    if (!m_isScrolling)
+    if (!m_isScrolling)  /* prevent recursion */
     {
         if (m_wxwindow->window)
         {
     {
         if (m_wxwindow->window)
         {