X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f97c985452b20a8c2f0bbfb1d0275298bf09fb45..2d956b58023a4955313a1c1531bc70a0deb0b831:/src/motif/cursor.cpp diff --git a/src/motif/cursor.cpp b/src/motif/cursor.cpp index 24c94be559..60cfddfd78 100644 --- a/src/motif/cursor.cpp +++ b/src/motif/cursor.cpp @@ -19,15 +19,19 @@ #include "wx/app.h" #include "wx/utils.h" +#ifdef __VMS__ +#pragma message disable nosimpint +#endif #include #include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif #include "wx/motif/private.h" -#if !USE_SHARED_LIBRARIES IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap) IMPLEMENT_DYNAMIC_CLASS(wxXCursor, wxObject) -#endif wxCursorRefData::wxCursorRefData() { @@ -188,8 +192,13 @@ wxCursor::wxCursor(wxStockCursor id) { m_refData = new wxCursorRefData; M_CURSORDATA->m_cursorId = id; + M_CURSORDATA->m_ok = TRUE; - WXCursor cursor = GetXCursor(wxGetDisplay()); + WXDisplay* display = wxGetDisplay(); + if (!display) + return; + + WXCursor cursor = GetXCursor(display); if (cursor) { wxXCursor* c = new wxXCursor; @@ -423,9 +432,87 @@ WXCursor wxCursor::MakeCursor(WXDisplay* display, wxStockCursor id) } // Global cursor setting -void wxSetCursor(const wxCursor& cursor) +void wxSetCursor(const wxCursor& WXUNUSED(cursor)) { // Nothing to do for Motif (no global cursor) } +// ---------------------------------------------------------------------------- +// busy cursor stuff +// ---------------------------------------------------------------------------- + +static int wxBusyCursorCount = 0; + +// Helper function +static void +wxXSetBusyCursor (wxWindow * win, wxCursor * cursor) +{ + Display *display = (Display*) win->GetXDisplay(); + + Window xwin = (Window) win->GetXWindow(); + if (!xwin) + return; + + XSetWindowAttributes attrs; + + if (cursor) + { + attrs.cursor = (Cursor) cursor->GetXCursor(display); + } + else + { + // Restore old cursor + if (win->GetCursor().Ok()) + attrs.cursor = (Cursor) win->GetCursor().GetXCursor(display); + else + attrs.cursor = None; + } + if (xwin) + XChangeWindowAttributes (display, xwin, CWCursor, &attrs); + + XFlush (display); + + for(wxNode *node = win->GetChildren().First (); node; node = node->Next()) + { + wxWindow *child = (wxWindow *) node->Data (); + wxXSetBusyCursor (child, cursor); + } +} + +// Set the cursor to the busy cursor for all windows +void wxBeginBusyCursor(wxCursor *cursor) +{ + wxBusyCursorCount++; + if (wxBusyCursorCount == 1) + { + for(wxNode *node = wxTopLevelWindows.First (); node; node = node->Next()) + { + wxWindow *win = (wxWindow *) node->Data (); + wxXSetBusyCursor (win, cursor); + } + } +} + +// Restore cursor to normal +void wxEndBusyCursor() +{ + if (wxBusyCursorCount == 0) + return; + + wxBusyCursorCount--; + if (wxBusyCursorCount == 0) + { + for(wxNode *node = wxTopLevelWindows.First (); node; node = node->Next()) + { + wxWindow *win = (wxWindow *) node->Data (); + wxXSetBusyCursor (win, NULL); + } + } +} + +// TRUE if we're between the above two calls +bool wxIsBusy() +{ + return (wxBusyCursorCount > 0); +}