]> git.saurik.com Git - wxWidgets.git/commitdiff
Allowed for wxHAVE_LIB_XPM or using wxXPMDecoder
authorJulian Smart <julian@anthemion.co.uk>
Wed, 13 Feb 2002 18:01:38 +0000 (18:01 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Wed, 13 Feb 2002 18:01:38 +0000 (18:01 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14181 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/motif/cursor.cpp
src/x11/bitmap.cpp
src/x11/utils.cpp

index 24ce2516a07ba91ac5d28449f00b28a113dde5a5..60cfddfd7807030e9941fdd6159c14243b46707c 100644 (file)
@@ -438,3 +438,81 @@ void wxSetCursor(const wxCursor& WXUNUSED(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);
+}
index 6d4c558c3ee03d875698ff8511ac934068aaa8a1..138860acb52c489d0b3afabd8d558ad76da20b63 100644 (file)
 
 #include "wx/x11/private.h"
 
+#if wxUSE_XPM
 #if wxHAVE_LIB_XPM
-    #include <X11/xpm.h>
+#include <X11/xpm.h>
+#else
+#include "wx/xpmdecod.h"
+#include "wx/wfstream.h"
+#endif
 #endif
 #include <math.h>
 
@@ -308,6 +313,8 @@ bool wxBitmap::Create( int width, int height, int depth )
 
 bool wxBitmap::CreateFromXpm( const char **bits )
 {
+#if wxUSE_XPM
+#if wxHAVE_LIB_XPM
     UnRef();
 
     wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
@@ -358,6 +365,7 @@ bool wxBitmap::CreateFromXpm( const char **bits )
             M_BMPDATA->m_mask->SetBitmap( (WXPixmap) mask );
             M_BMPDATA->m_mask->SetDisplay( xdisplay );
         }
+       return TRUE;
     }
     else
     {
@@ -365,8 +373,16 @@ bool wxBitmap::CreateFromXpm( const char **bits )
         
         return FALSE;
     }
-
-    return TRUE;
+#else
+    wxXPMDecoder decoder;
+    wxImage image(decoder.ReadData(bits));
+    if (image.Ok())
+       return CreateFromImage(image);
+    else
+       return FALSE;
+#endif
+#endif
+    return FALSE;
 }
 
 bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
@@ -970,6 +986,8 @@ bool wxBitmap::LoadFile( const wxString &name, int type )
 
     if (type == wxBITMAP_TYPE_XPM)
     {
+#if wxUSE_XPM
+#if wxHAVE_LIB_XPM
         m_refData = new wxBitmapRefData();
 
         M_BMPDATA->m_display = wxGlobalDisplay();
@@ -1013,6 +1031,29 @@ bool wxBitmap::LoadFile( const wxString &name, int type )
             
             return FALSE;
         }
+#else
+#if wxUSE_STREAMS
+       wxXPMDecoder decoder;
+       wxFileInputStream stream(name);
+       if (stream.Ok())
+       {
+            wxImage image(decoder.Read(stream));
+           if (image.Ok())
+               return CreateFromImage(image);
+           else
+               return FALSE;
+       }
+       else
+           return FALSE;
+#else
+       return FALSE;
+#endif
+       // wxUSE_STREAMS
+#endif
+       // wxHAVE_LIB_XPM
+#endif
+       // wxUSE_XPM
+       return FALSE;
     }
     else // try if wxImage can load it
     {
index 862f96e9cc19a81e8bc9b24e89d691e37ce578c4..ea472dcc6ec6a3e6c00e85164d83cf5f42da4779 100644 (file)
@@ -165,9 +165,11 @@ static void xt_notify_end_process(XtPointer data, int *WXUNUSED(fid),
 
     XtRemoveInput(*id);
 }
+#endif
 
 int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
 {
+#ifdef __WXMOTIF__
     XtInputId id = XtAppAddInput((XtAppContext) wxTheApp->GetAppContext(),
                                  fd,
                                  (XtPointer *) XtInputReadMask,
@@ -175,8 +177,12 @@ int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
                                  (XtPointer) proc_data);
 
     return (int)id;
-}
 #endif
+#ifdef __WXX11__
+    // TODO
+    return 0;
+#endif
+}
 
 // ----------------------------------------------------------------------------
 // misc