]> git.saurik.com Git - wxWidgets.git/blobdiff - src/x11/utils.cpp
A bit of scrolling works under GTK 2.0
[wxWidgets.git] / src / x11 / utils.cpp
index ea472dcc6ec6a3e6c00e85164d83cf5f42da4779..fc15ff0ce18e9336a9b6bccf17efad4ad88a90f8 100644 (file)
 #pragma message disable nosimpint
 #endif
 
-#ifdef __WXMOTIF__
-#include <Xm/Xm.h>
-#endif
-
-#ifdef __VMS__
-#pragma message enable nosimpint
-#endif
-
 #include "wx/unix/execute.h"
 
 #ifdef __WXMOTIF__
+#include <Xm/Xm.h>
 #include "wx/motif/private.h"
 #endif
 
 #include "wx/x11/private.h"
 #endif
 
+#if wxUSE_RESOURCES
 #include "X11/Xresource.h"
+#endif
+
 #include "X11/Xutil.h"
 
+#ifdef __VMS__
+#pragma message enable nosimpint
+#endif
+
 // ----------------------------------------------------------------------------
 // private functions
 // ----------------------------------------------------------------------------
@@ -568,6 +568,11 @@ wxSetDefaultResources (const Widget w, const char **resourceSpec, const char *na
 
 void wxGetMousePosition( int* x, int* y )
 {
+#if wxUSE_NANOX
+    // TODO
+    *x = 0;
+    *y = 0;
+#else
     XMotionEvent xev;
     Window root, child;
     XQueryPointer((Display*) wxGetDisplay(),
@@ -578,6 +583,7 @@ void wxGetMousePosition( int* x, int* y )
                   &(xev.state));
     *x = xev.x_root;
     *y = xev.y_root;
+#endif
 };
 
 // Return TRUE if we have a colour display
@@ -683,7 +689,7 @@ bool wxSetDisplay(const wxString& display_name)
             return FALSE;
 #endif
 #ifdef __WXX11__
-        Display* display = XOpenDisplay((const char*) display_name);
+        Display* display = XOpenDisplay((char*) display_name.c_str());
 
         if (display)
         {
@@ -1015,6 +1021,7 @@ void wxXColorToHSV(wxHSV *hsv,XColor *rgb)
 
 void wxAllocNearestColor(Display *d,Colormap cmp,XColor *xc)
 {
+#if !wxUSE_NANOX
     int llp;
 
     int screen = DefaultScreen(d);
@@ -1051,6 +1058,7 @@ void wxAllocNearestColor(Display *d,Colormap cmp,XColor *xc)
 */
 
     delete[] color_defs;
+#endif
 }
 
 void wxAllocColor(Display *d,Colormap cmp,XColor *xc)
@@ -1062,6 +1070,34 @@ void wxAllocColor(Display *d,Colormap cmp,XColor *xc)
     }
 }
 
+#ifdef __WXDEBUG__
+wxString wxGetXEventName(XEvent& event)
+{
+#if wxUSE_NANOX
+    wxString str(wxT("(some event)"));
+    return str;
+#else
+    int type = event.xany.type;
+           static char* event_name[] = {
+               "", "unknown(-)",                                         // 0-1
+               "KeyPress", "KeyRelease", "ButtonPress", "ButtonRelease", // 2-5
+               "MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn",  // 6-9
+               "FocusOut", "KeymapNotify", "Expose", "GraphicsExpose",   // 10-13
+               "NoExpose", "VisibilityNotify", "CreateNotify",           // 14-16
+               "DestroyNotify", "UnmapNotify", "MapNotify", "MapRequest",// 17-20
+               "ReparentNotify", "ConfigureNotify", "ConfigureRequest",  // 21-23
+               "GravityNotify", "ResizeRequest", "CirculateNotify",      // 24-26
+               "CirculateRequest", "PropertyNotify", "SelectionClear",   // 27-29
+               "SelectionRequest", "SelectionNotify", "ColormapNotify",  // 30-32
+               "ClientMessage", "MappingNotify",                         // 33-34
+               "unknown(+)"};                                            // 35
+           type = wxMin(35, type); type = wxMax(1, type);
+        wxString str(event_name[type]);
+        return str;
+#endif
+}
+#endif
+
 #ifdef __WXMOTIF__
 // ----------------------------------------------------------------------------
 // accelerators
@@ -1115,7 +1151,8 @@ char * wxFindAccelerator (const char *s)
 
     */
 
-    wxBuffer[0] = '\0';
+    static char buf[256];
+    buf[0] = '\0';
     char *tmp = copystring (s);
     s = tmp;
     char *p = tmp;
@@ -1127,23 +1164,23 @@ char * wxFindAccelerator (const char *s)
         if (*p)
         {
             *p = '\0';
-            if (wxBuffer[0])
-                strcat (wxBuffer, " ");
+            if (buf[0])
+                strcat (buf, " ");
             if (strcmp (s, "Alt"))
-                strcat (wxBuffer, s);
+                strcat (buf, s);
             else
-                strcat (wxBuffer, "Meta");
+                strcat (buf, "Meta");
             s = p++;
         }
         else
         {
-            strcat (wxBuffer, "<Key>");
-            strcat (wxBuffer, s);
+            strcat (buf, "<Key>");
+            strcat (buf, s);
             break;
         }
     }
     delete[]tmp;
-    return wxBuffer;
+    return buf;
 #endif
 }
 
@@ -1207,3 +1244,11 @@ void wxDoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, boo
 
 #endif
     // __WXMOTIF__
+
+bool wxWindowIsVisible(Window win)
+{
+    XWindowAttributes wa;
+    XGetWindowAttributes(wxGlobalDisplay(), win, &wa);
+
+    return (wa.map_state == IsViewable);
+}