fix for wxBusyCursorSuspender messing with wxIsBusy() state.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7553 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ron Lee
2000-06-09 21:15:49 +00:00
parent 0f9a3aaea8
commit 04e158348e
4 changed files with 58 additions and 14 deletions

View File

@@ -21,23 +21,39 @@
/* This is a small class which can be used by all ports
to temporarily suspend the busy cursor. Useful in modal
dialogs.
Actually that is not (any longer) quite true.. currently it is
only used in wxGTK Dialog::ShowModal() and now uses static
wxBusyCursor methods that are only implemented for wxGTK so far.
The BusyCursor handling code should probably be implemented in
common code somewhere instead of the separate implementations we
currently have. Also the name BusyCursorSuspender is a little
misleading since it doesn't actually suspend the BusyCursor, just
masks one that is already showing.
If another call to wxBeginBusyCursor is made while this is active
the Busy Cursor will again be shown. But at least now it doesn't
interfere with the state of wxIsBusy() -- RL
*/
class wxBusyCursorSuspender
{
public:
wxBusyCursorSuspender()
{
m_wasBusy = wxIsBusy();
if(m_wasBusy)
wxEndBusyCursor();
if( wxIsBusy() )
{
wxSetCursor( wxBusyCursor::GetStoredCursor() );
wxYield();
}
}
~wxBusyCursorSuspender()
{
if(m_wasBusy)
wxBeginBusyCursor();
if( wxIsBusy() )
{
wxSetCursor( wxBusyCursor::GetBusyCursor() );
wxYield();
}
}
private:
bool m_wasBusy;
};
#endif
// _WX_CURSOR_H_BASE_

View File

@@ -328,6 +328,14 @@ public:
{ wxBeginBusyCursor(cursor); }
~wxBusyCursor()
{ wxEndBusyCursor(); }
// FIXME: These two methods are currently only implemented (and needed?)
// in wxGTK. BusyCursor handling should probably be moved to
// common code since the wxGTK and wxMSW implementations are very
// similar except for wxMSW using HCURSOR directly instead of
// wxCursor.. -- RL.
static const wxCursor &GetStoredCursor();
static const wxCursor GetBusyCursor();
};

View File

@@ -155,6 +155,16 @@ extern wxCursor g_globalCursor;
static wxCursor gs_savedCursor;
static int gs_busyCount = 0;
const wxCursor &wxBusyCursor::GetStoredCursor()
{
return gs_savedCursor;
}
const wxCursor wxBusyCursor::GetBusyCursor()
{
return wxCursor(wxCURSOR_WATCH);
}
void wxEndBusyCursor()
{
if (--gs_busyCount > 0)

View File

@@ -155,6 +155,16 @@ extern wxCursor g_globalCursor;
static wxCursor gs_savedCursor;
static int gs_busyCount = 0;
const wxCursor &wxBusyCursor::GetStoredCursor()
{
return gs_savedCursor;
}
const wxCursor wxBusyCursor::GetBusyCursor()
{
return wxCursor(wxCURSOR_WATCH);
}
void wxEndBusyCursor()
{
if (--gs_busyCount > 0)