Got a new idea to do cursors, including global
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
This commit is contained in:
@@ -70,7 +70,7 @@ public:
|
||||
// implementation
|
||||
// --------------
|
||||
|
||||
void ComputeScaleAndOrigin();
|
||||
virtual void ComputeScaleAndOrigin();
|
||||
|
||||
long XDEV2LOG(long x) const
|
||||
{
|
||||
|
@@ -118,6 +118,8 @@ public:
|
||||
|
||||
void SetUpDC();
|
||||
void Destroy();
|
||||
void ComputeScaleAndOrigin();
|
||||
|
||||
GdkWindow *GetWindow() { return m_window; }
|
||||
};
|
||||
|
||||
|
@@ -70,7 +70,7 @@ public:
|
||||
// implementation
|
||||
// --------------
|
||||
|
||||
void ComputeScaleAndOrigin();
|
||||
virtual void ComputeScaleAndOrigin();
|
||||
|
||||
long XDEV2LOG(long x) const
|
||||
{
|
||||
|
@@ -118,6 +118,8 @@ public:
|
||||
|
||||
void SetUpDC();
|
||||
void Destroy();
|
||||
void ComputeScaleAndOrigin();
|
||||
|
||||
GdkWindow *GetWindow() { return m_window; }
|
||||
};
|
||||
|
||||
|
@@ -16,6 +16,13 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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 )
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -132,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;
|
||||
|
||||
@@ -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;
|
||||
|
@@ -16,6 +16,13 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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 )
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -132,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;
|
||||
|
||||
@@ -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;
|
||||
|
Reference in New Issue
Block a user