]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/window.cpp
add missing parens to bitwise expression
[wxWidgets.git] / src / gtk1 / window.cpp
index f7dd7acaebeb5e3cb94f377a3e045951c26de581..d74a0e0e3fae2d1290eb6b0741de7c328f7e94fb 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        gtk/window.cpp
+// Name:        src/gtk1/window.cpp
 // Purpose:
 // Author:      Robert Roebling
 // Id:          $Id$
 #endif
 
 #include "wx/window.h"
-#include "wx/dcclient.h"
-#include "wx/frame.h"
-#include "wx/app.h"
-#include "wx/layout.h"
-#include "wx/utils.h"
-#include "wx/dialog.h"
-#include "wx/msgdlg.h"
-#include "wx/module.h"
-#include "wx/combobox.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/intl.h"
+    #include "wx/log.h"
+    #include "wx/app.h"
+    #include "wx/utils.h"
+    #include "wx/frame.h"
+    #include "wx/dcclient.h"
+    #include "wx/menu.h"
+    #include "wx/dialog.h"
+    #include "wx/settings.h"
+    #include "wx/msgdlg.h"
+    #include "wx/textctrl.h"
+    #include "wx/combobox.h"
+    #include "wx/layout.h"
+    #include "wx/statusbr.h"
+    #include "wx/math.h"
+    #include "wx/module.h"
+#endif
 
 #if wxUSE_DRAG_AND_DROP
     #include "wx/dnd.h"
     #include "wx/caret.h"
 #endif // wxUSE_CARET
 
-#if wxUSE_TEXTCTRL
-    #include "wx/textctrl.h"
-#endif
-
-#include "wx/menu.h"
-#include "wx/statusbr.h"
-#include "wx/intl.h"
-#include "wx/settings.h"
-#include "wx/log.h"
 #include "wx/fontutil.h"
 
 #ifdef __WXDEBUG__
     #include "wx/thread.h"
 #endif
 
-#include "wx/math.h"
 #include <ctype.h>
 
 #include "wx/gtk1/private.h"
 // data
 //-----------------------------------------------------------------------------
 
-extern wxList     wxPendingDelete;
 extern bool       g_blockEventsOnDrag;
 extern bool       g_blockEventsOnScroll;
 extern wxCursor   g_globalCursor;
@@ -226,6 +225,11 @@ wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL;
 // the last click here (extern: used from gtk/menu.cpp)
 guint32 wxGtkTimeLastClick = 0;
 
+// global variables because GTK+ DnD want to have the
+// mouse event that caused it
+GdkEvent *g_lastMouseEvent = (GdkEvent*) NULL;
+int g_lastButtonNumber = 0;
+
 extern bool g_mainThreadLocked;
 
 //-----------------------------------------------------------------------------
@@ -739,11 +743,11 @@ static long wxTranslateKeySymToWXKey(KeySym keysym, bool isChar)
             break;
 
         case GDK_Prior:     // == GDK_Page_Up
-            key_code = WXK_PRIOR;
+            key_code = WXK_PAGEUP;
             break;
 
         case GDK_Next:      // == GDK_Page_Down
-            key_code = WXK_NEXT;
+            key_code = WXK_PAGEDOWN;
             break;
 
         case GDK_End:
@@ -822,11 +826,11 @@ static long wxTranslateKeySymToWXKey(KeySym keysym, bool isChar)
             break;
 
         case GDK_KP_Prior: // == GDK_KP_Page_Up
-            key_code = isChar ? WXK_PRIOR : WXK_NUMPAD_PRIOR;
+            key_code = isChar ? WXK_PAGEUP : WXK_NUMPAD_PAGEUP;
             break;
 
         case GDK_KP_Next: // == GDK_KP_Page_Down
-            key_code = isChar ? WXK_NEXT : WXK_NUMPAD_NEXT;
+            key_code = isChar ? WXK_PAGEDOWN : WXK_NUMPAD_PAGEDOWN;
             break;
 
         case GDK_KP_End:
@@ -1056,7 +1060,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
     bool ret = false;
     bool return_after_IM = false;
 
-    if( wxTranslateGTKKeyEventToWx(event, win, gdk_event) == false )
+    if ( wxTranslateGTKKeyEventToWx(event, win, gdk_event) )
     {
         // Emit KEY_DOWN event
         ret = win->GetEventHandler()->ProcessEvent( event );
@@ -1348,7 +1352,7 @@ template<typename T> void InitMouseEvent(wxWindowGTK *win,
 static void AdjustEventButtonState(wxMouseEvent& event)
 {
     // GDK reports the old state of the button for a button press event, but
-    // for compatibility with MSW and common sense we want m_leftDown be TRUE
+    // for compatibility with MSW and common sense we want m_leftDown be true
     // for a LEFT_DOWN event, not FALSE, so we will invert
     // left/right/middleDown for the corresponding click events
 
@@ -1469,7 +1473,9 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
 
     if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
 
-    if (win->m_wxwindow && (g_focusWindow != win) && win->AcceptsFocus())
+    g_lastButtonNumber = gdk_event->button;
+
+    if (win->m_wxwindow && (g_focusWindow != win) && win->IsFocusable())
     {
         gtk_widget_grab_focus( win->m_wxwindow );
 /*
@@ -1576,6 +1582,8 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
         return FALSE;
     }
 
+    g_lastMouseEvent = (GdkEvent*) gdk_event;
+    
     wxMouseEvent event( event_type );
     InitMouseEvent( win, event, gdk_event );
 
@@ -1608,8 +1616,10 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
     if (win->GetEventHandler()->ProcessEvent( event ))
     {
         gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" );
+        g_lastMouseEvent = NULL;
         return TRUE;
     }
+    g_lastMouseEvent = NULL;
 
     if (event_type == wxEVT_RIGHT_DOWN)
     {
@@ -1652,6 +1662,8 @@ static gint gtk_window_button_release_callback( GtkWidget *widget,
 
     if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
 
+    g_lastButtonNumber = 0;
+
     wxEventType event_type = wxEVT_NULL;
 
     switch (gdk_event->button)
@@ -1673,6 +1685,8 @@ static gint gtk_window_button_release_callback( GtkWidget *widget,
             return FALSE;
     }
 
+    g_lastMouseEvent = (GdkEvent*) gdk_event;
+    
     wxMouseEvent event( event_type );
     InitMouseEvent( win, event, gdk_event );
 
@@ -1724,6 +1738,8 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget,
         gdk_event->y = y;
     }
 
+    g_lastMouseEvent = (GdkEvent*) gdk_event;
+
 /*
     printf( "OnMotion from " );
     if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
@@ -1760,13 +1776,15 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget,
         win = FindWindowForMouseEvent(win, event.m_x, event.m_y);
     }
 
-    if (win->GetEventHandler()->ProcessEvent( event ))
+    bool ret = win->GetEventHandler()->ProcessEvent( event );
+    g_lastMouseEvent = NULL;
+
+    if ( ret )
     {
         gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "motion_notify_event" );
-        return TRUE;
     }
 
-    return FALSE;
+    return ret ? TRUE : FALSE;
 }
 }
 
@@ -2932,13 +2950,11 @@ void wxWindowGTK::OnInternalIdle()
                 gdk_window_set_cursor( window, cursor.GetCursor() );
 
         }
-        else
+        else if ( m_widget )
         {
-
             GdkWindow *window = m_widget->window;
-            if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget)))
+            if ( window && !GTK_WIDGET_NO_WINDOW(m_widget) )
                gdk_window_set_cursor( window, cursor.GetCursor() );
-
         }
     }
 
@@ -3187,40 +3203,13 @@ bool wxWindowGTK::Show( bool show )
     return true;
 }
 
-static void wxWindowNotifyEnable(wxWindowGTK* win, bool enable)
-{
-    win->OnParentEnable(enable);
-
-    // Recurse, so that children have the opportunity to Do The Right Thing
-    // and reset colours that have been messed up by a parent's (really ancestor's)
-    // Enable call
-    for ( wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst();
-          node;
-          node = node->GetNext() )
-    {
-        wxWindow *child = node->GetData();
-        if (!child->IsKindOf(CLASSINFO(wxDialog)) && !child->IsKindOf(CLASSINFO(wxFrame)))
-            wxWindowNotifyEnable(child, enable);
-    }
-}
-
-bool wxWindowGTK::Enable( bool enable )
+void wxWindowGTK::DoEnable( bool enable )
 {
-    wxCHECK_MSG( (m_widget != NULL), false, wxT("invalid window") );
-
-    if (!wxWindowBase::Enable(enable))
-    {
-        // nothing to do
-        return false;
-    }
+    wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
 
     gtk_widget_set_sensitive( m_widget, enable );
     if ( m_wxwindow )
         gtk_widget_set_sensitive( m_wxwindow, enable );
-
-    wxWindowNotifyEnable(this, enable);
-
-    return true;
 }
 
 int wxWindowGTK::GetCharHeight() const
@@ -3415,16 +3404,14 @@ bool wxWindowGTK::SetCursor( const wxCursor &cursor )
 {
     wxCHECK_MSG( (m_widget != NULL), false, wxT("invalid window") );
 
-    if (cursor == m_cursor)
+    if ( cursor.IsSameAs(m_cursor) )
        return false;
 
     if (g_isIdle)
         wxapp_install_idle_handler();
 
-    if (cursor == wxNullCursor)
-       return wxWindowBase::SetCursor( *wxSTANDARD_CURSOR );
-    else
-       return wxWindowBase::SetCursor( cursor );
+    return wxWindowBase::SetCursor( cursor.IsOk() ? cursor
+                                                  : *wxSTANDARD_CURSOR );
 }
 
 void wxWindowGTK::WarpPointer( int x, int y )
@@ -3928,7 +3915,7 @@ void wxWindowGTK::DoCaptureMouse()
 
     wxCHECK_RET( window, _T("CaptureMouse() failed") );
 
-    wxCursor* cursor = & m_cursor;
+    const wxCursor* cursor = &m_cursor;
     if (!cursor->Ok())
         cursor = wxSTANDARD_CURSOR;
 
@@ -4232,4 +4219,3 @@ void wxWinModule::OnExit()
     if (g_eraseGC)
         gdk_gc_unref( g_eraseGC );
 }
-