]> git.saurik.com Git - wxWidgets.git/commitdiff
Got a new idea to do cursors, including global
authorRobert Roebling <robert@roebling.de>
Wed, 26 May 1999 20:40:04 +0000 (20:40 +0000)
committerRobert Roebling <robert@roebling.de>
Wed, 26 May 1999 20:40:04 +0000 (20:40 +0000)
    ones and busy etc.
  Fixed an assert in UserScaler from PS code.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2577 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

14 files changed:
include/wx/gtk/dc.h
include/wx/gtk/dcclient.h
include/wx/gtk1/dc.h
include/wx/gtk1/dcclient.h
src/gtk/cursor.cpp
src/gtk/data.cpp
src/gtk/dc.cpp
src/gtk/dcclient.cpp
src/gtk/window.cpp
src/gtk1/cursor.cpp
src/gtk1/data.cpp
src/gtk1/dc.cpp
src/gtk1/dcclient.cpp
src/gtk1/window.cpp

index 8b71e9ceb0d76273ffb838ef785e1be11efd60b9..acc56d3bcd1bdc0efb5ebef8c09ccd6774f88405 100644 (file)
@@ -70,7 +70,7 @@ public:
     // implementation
     // --------------
 
-    void ComputeScaleAndOrigin();
+    virtual void ComputeScaleAndOrigin();
 
     long XDEV2LOG(long x) const
     {
index e9b2a518da102ee52ac14666c1ce6675103a12ab..b3b0439b4a1bad8bd404cd10b232e10a45f73972 100644 (file)
@@ -118,6 +118,8 @@ public:
 
     void SetUpDC();
     void Destroy();
+    void ComputeScaleAndOrigin();
+
     GdkWindow *GetWindow() { return m_window; }
 };
 
index 8b71e9ceb0d76273ffb838ef785e1be11efd60b9..acc56d3bcd1bdc0efb5ebef8c09ccd6774f88405 100644 (file)
@@ -70,7 +70,7 @@ public:
     // implementation
     // --------------
 
-    void ComputeScaleAndOrigin();
+    virtual void ComputeScaleAndOrigin();
 
     long XDEV2LOG(long x) const
     {
index e9b2a518da102ee52ac14666c1ce6675103a12ab..b3b0439b4a1bad8bd404cd10b232e10a45f73972 100644 (file)
@@ -118,6 +118,8 @@ public:
 
     void SetUpDC();
     void Destroy();
+    void ComputeScaleAndOrigin();
+
     GdkWindow *GetWindow() { return m_window; }
 };
 
index 3c22177973243df95eff17d0fb71fea66bb32df5..2277c0aee4670e26c16370466e272addc53c1df2 100644 (file)
 
 #include "gdk/gdk.h"
 
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
 //-----------------------------------------------------------------------------
 // wxCursor
 //-----------------------------------------------------------------------------
@@ -137,38 +144,31 @@ GdkCursor *wxCursor::GetCursor() const
 // busy cursor routines
 //-----------------------------------------------------------------------------
 
-extern wxCursor *g_globalCursor;
+extern wxCursor g_globalCursor;
 
-static wxCursor *gs_savedCursor = NULL;
+static wxCursor  gs_savedCursor;
 static int       gs_busyCount = 0;
 
 void wxEndBusyCursor()
 {
-    if ( --gs_busyCount > 0 )
+    if (--gs_busyCount > 0)
         return;
 
-    wxCHECK_RET( gs_savedCursor && gs_savedCursor->Ok(),
-                 _T("calling wxEndBusyCursor() without wxBeginBusyCursor()?") );
-
-    wxSetCursor(*gs_savedCursor);
-    delete gs_savedCursor;
-    gs_savedCursor = NULL;
+    wxSetCursor( gs_savedCursor );
+    gs_savedCursor = wxNullCursor;
 }
 
 void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) )
 {
-    if ( gs_busyCount++ > 0 )
+    if (gs_busyCount++ > 0)
         return;
 
-    wxASSERT_MSG( !gs_savedCursor,
+    wxASSERT_MSG( !gs_savedCursor.Ok(),
                   _T("forgot to call wxEndBusyCursor, will leak memory") );
 
-    gs_savedCursor = new wxCursor;
-    if ( g_globalCursor && g_globalCursor->Ok() )
-        *gs_savedCursor = *g_globalCursor;
-    else
-        *gs_savedCursor = wxCursor(wxCURSOR_ARROW);
-    wxSetCursor(wxCursor(wxCURSOR_WATCH));
+    gs_savedCursor = g_globalCursor;
+    
+    wxSetCursor( wxCursor(wxCURSOR_WATCH) );
 }
 
 bool wxIsBusy()
@@ -178,5 +178,8 @@ bool wxIsBusy()
 
 void wxSetCursor( const wxCursor& cursor )
 {
-    if (g_globalCursor) (*g_globalCursor) = cursor;
+    if (g_isIdle) 
+        wxapp_install_idle_handler();
+
+    g_globalCursor = cursor;
 }
index b2fdae961cee5d1ba80d3515cb98271ab6e1b06b..ff11a0b0d601adcdc20d582e7f6c06f796e55108 100644 (file)
@@ -46,7 +46,7 @@ wxCriticalSection *wxPendingEventsLocker = NULL;
 
 /* Current cursor, in order to hang on to
  * cursor handle when setting the cursor globally */
-wxCursor *g_globalCursor = (wxCursor *) NULL;
+wxCursor g_globalCursor;
 
 /* Don't allow event propagation during drag */
 bool g_blockEventsOnDrag = FALSE;
index ad4b1373f688dba645589540a716db0aba96b806..57c1f336a796432cc9aa3d51a50e6a48e43377c5 100644 (file)
@@ -97,22 +97,8 @@ wxSize wxDC::GetPPI() const
 
 void wxDC::ComputeScaleAndOrigin()
 {
-    /* CMB: copy scale to see if it changes */
-    double origScaleX = m_scaleX;
-    double origScaleY = m_scaleY;
-
     m_scaleX = m_logicalScaleX * m_userScaleX;
     m_scaleY = m_logicalScaleY * m_userScaleY;
-
-    /* CMB: if scale has changed call SetPen to recalulate the line width */
-    if (m_scaleX != origScaleX || m_scaleY != origScaleY)
-    {
-      /* this is a bit artificial, but we need to force wxDC to think
-         the pen has changed */
-      wxPen pen = m_pen;
-      m_pen = wxNullPen;
-      SetPen( pen );
-  }
 }
 
 void wxDC::SetMapMode( int mode )
index 560c4162efe4accea169727d167644640348a7ba..d71a04d8fba22cbbe80aba0a7b559d391888aeb3 100644 (file)
@@ -1200,6 +1200,26 @@ void wxWindowDC::Destroy()
     m_bgGC = (GdkGC*) NULL;
 }
 
+void wxWindowDC::ComputeScaleAndOrigin()
+{
+    /* CMB: copy scale to see if it changes */
+    double origScaleX = m_scaleX;
+    double origScaleY = m_scaleY;
+
+    wxDC::ComputeScaleAndOrigin();
+
+    /* CMB: if scale has changed call SetPen to recalulate the line width */
+    if ((m_scaleX != origScaleX || m_scaleY != origScaleY) &&
+        (m_pen.Ok()))
+    {
+      /* this is a bit artificial, but we need to force wxDC to think
+         the pen has changed */
+      wxPen pen = m_pen;
+      m_pen = wxNullPen;
+      SetPen( pen );
+  }
+}
+
 // Resolution in pixels per logical inch
 wxSize wxWindowDC::GetPPI() const
 {
index ade9c04dc7857a12f8d12e87482365ffb4feedc9..5a676c5c1b51e304b2795506f71c3031c7df424d 100644 (file)
 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;
 
@@ -1250,9 +1251,6 @@ 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 );
@@ -1299,9 +1297,6 @@ 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 );
@@ -2032,6 +2027,15 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
 
 void wxWindow::OnInternalIdle()
 {
+    GdkWindow *window = GetConnectWidget()->window;
+    if (window)
+    {
+        if (g_globalCursor.Ok())
+           gdk_window_set_cursor( window, g_globalCursor.GetCursor() );
+        else
+           gdk_window_set_cursor( window, m_cursor.GetCursor() );
+    }
+
     UpdateWindowUI();
 }
 
@@ -2391,11 +2395,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;
index 3c22177973243df95eff17d0fb71fea66bb32df5..2277c0aee4670e26c16370466e272addc53c1df2 100644 (file)
 
 #include "gdk/gdk.h"
 
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
 //-----------------------------------------------------------------------------
 // wxCursor
 //-----------------------------------------------------------------------------
@@ -137,38 +144,31 @@ GdkCursor *wxCursor::GetCursor() const
 // busy cursor routines
 //-----------------------------------------------------------------------------
 
-extern wxCursor *g_globalCursor;
+extern wxCursor g_globalCursor;
 
-static wxCursor *gs_savedCursor = NULL;
+static wxCursor  gs_savedCursor;
 static int       gs_busyCount = 0;
 
 void wxEndBusyCursor()
 {
-    if ( --gs_busyCount > 0 )
+    if (--gs_busyCount > 0)
         return;
 
-    wxCHECK_RET( gs_savedCursor && gs_savedCursor->Ok(),
-                 _T("calling wxEndBusyCursor() without wxBeginBusyCursor()?") );
-
-    wxSetCursor(*gs_savedCursor);
-    delete gs_savedCursor;
-    gs_savedCursor = NULL;
+    wxSetCursor( gs_savedCursor );
+    gs_savedCursor = wxNullCursor;
 }
 
 void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) )
 {
-    if ( gs_busyCount++ > 0 )
+    if (gs_busyCount++ > 0)
         return;
 
-    wxASSERT_MSG( !gs_savedCursor,
+    wxASSERT_MSG( !gs_savedCursor.Ok(),
                   _T("forgot to call wxEndBusyCursor, will leak memory") );
 
-    gs_savedCursor = new wxCursor;
-    if ( g_globalCursor && g_globalCursor->Ok() )
-        *gs_savedCursor = *g_globalCursor;
-    else
-        *gs_savedCursor = wxCursor(wxCURSOR_ARROW);
-    wxSetCursor(wxCursor(wxCURSOR_WATCH));
+    gs_savedCursor = g_globalCursor;
+    
+    wxSetCursor( wxCursor(wxCURSOR_WATCH) );
 }
 
 bool wxIsBusy()
@@ -178,5 +178,8 @@ bool wxIsBusy()
 
 void wxSetCursor( const wxCursor& cursor )
 {
-    if (g_globalCursor) (*g_globalCursor) = cursor;
+    if (g_isIdle) 
+        wxapp_install_idle_handler();
+
+    g_globalCursor = cursor;
 }
index b2fdae961cee5d1ba80d3515cb98271ab6e1b06b..ff11a0b0d601adcdc20d582e7f6c06f796e55108 100644 (file)
@@ -46,7 +46,7 @@ wxCriticalSection *wxPendingEventsLocker = NULL;
 
 /* Current cursor, in order to hang on to
  * cursor handle when setting the cursor globally */
-wxCursor *g_globalCursor = (wxCursor *) NULL;
+wxCursor g_globalCursor;
 
 /* Don't allow event propagation during drag */
 bool g_blockEventsOnDrag = FALSE;
index ad4b1373f688dba645589540a716db0aba96b806..57c1f336a796432cc9aa3d51a50e6a48e43377c5 100644 (file)
@@ -97,22 +97,8 @@ wxSize wxDC::GetPPI() const
 
 void wxDC::ComputeScaleAndOrigin()
 {
-    /* CMB: copy scale to see if it changes */
-    double origScaleX = m_scaleX;
-    double origScaleY = m_scaleY;
-
     m_scaleX = m_logicalScaleX * m_userScaleX;
     m_scaleY = m_logicalScaleY * m_userScaleY;
-
-    /* CMB: if scale has changed call SetPen to recalulate the line width */
-    if (m_scaleX != origScaleX || m_scaleY != origScaleY)
-    {
-      /* this is a bit artificial, but we need to force wxDC to think
-         the pen has changed */
-      wxPen pen = m_pen;
-      m_pen = wxNullPen;
-      SetPen( pen );
-  }
 }
 
 void wxDC::SetMapMode( int mode )
index 560c4162efe4accea169727d167644640348a7ba..d71a04d8fba22cbbe80aba0a7b559d391888aeb3 100644 (file)
@@ -1200,6 +1200,26 @@ void wxWindowDC::Destroy()
     m_bgGC = (GdkGC*) NULL;
 }
 
+void wxWindowDC::ComputeScaleAndOrigin()
+{
+    /* CMB: copy scale to see if it changes */
+    double origScaleX = m_scaleX;
+    double origScaleY = m_scaleY;
+
+    wxDC::ComputeScaleAndOrigin();
+
+    /* CMB: if scale has changed call SetPen to recalulate the line width */
+    if ((m_scaleX != origScaleX || m_scaleY != origScaleY) &&
+        (m_pen.Ok()))
+    {
+      /* this is a bit artificial, but we need to force wxDC to think
+         the pen has changed */
+      wxPen pen = m_pen;
+      m_pen = wxNullPen;
+      SetPen( pen );
+  }
+}
+
 // Resolution in pixels per logical inch
 wxSize wxWindowDC::GetPPI() const
 {
index ade9c04dc7857a12f8d12e87482365ffb4feedc9..5a676c5c1b51e304b2795506f71c3031c7df424d 100644 (file)
 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;
 
@@ -1250,9 +1251,6 @@ 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 );
@@ -1299,9 +1297,6 @@ 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 );
@@ -2032,6 +2027,15 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
 
 void wxWindow::OnInternalIdle()
 {
+    GdkWindow *window = GetConnectWidget()->window;
+    if (window)
+    {
+        if (g_globalCursor.Ok())
+           gdk_window_set_cursor( window, g_globalCursor.GetCursor() );
+        else
+           gdk_window_set_cursor( window, m_cursor.GetCursor() );
+    }
+
     UpdateWindowUI();
 }
 
@@ -2391,11 +2395,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;