+#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
+// ----------------------------------------------------------------------------
+
+// Find the letter corresponding to the mnemonic, for Motif
+char wxFindMnemonic (const char *s)
+{
+ char mnem = 0;
+ int len = strlen (s);
+ int i;
+ for (i = 0; i < len; i++)
+ {
+ if (s[i] == '&')
+ {
+ // Carefully handle &&
+ if ((i + 1) <= len && s[i + 1] == '&')
+ i++;
+ else
+ {
+ mnem = s[i + 1];
+ break;
+ }
+ }
+ }
+ return mnem;
+}
+
+char * wxFindAccelerator (const char *s)
+{
+ // VZ: this function returns incorrect keysym which completely breaks kbd
+ // handling
+ return NULL;
+
+#if 0
+ // The accelerator text is after the \t char.
+ while (*s && *s != '\t')
+ s++;
+ if (*s == '\0')
+ return (NULL);
+ s++;
+ /*
+ Now we need to format it as X standard:
+
+ input output
+
+ F7 --> <Key>F7
+ Ctrl+N --> Ctrl<Key>N
+ Alt+k --> Meta<Key>k
+ Ctrl+Shift+A --> Ctrl Shift<Key>A
+
+ */
+
+ static char buf[256];
+ buf[0] = '\0';
+ char *tmp = copystring (s);
+ s = tmp;
+ char *p = tmp;
+
+ while (1)
+ {
+ while (*p && *p != '+')
+ p++;
+ if (*p)
+ {
+ *p = '\0';
+ if (buf[0])
+ strcat (buf, " ");
+ if (strcmp (s, "Alt"))
+ strcat (buf, s);
+ else
+ strcat (buf, "Meta");
+ s = p++;
+ }
+ else
+ {
+ strcat (buf, "<Key>");
+ strcat (buf, s);
+ break;
+ }
+ }
+ delete[]tmp;
+ return buf;
+#endif
+}
+
+XmString wxFindAcceleratorText (const char *s)
+{
+ // VZ: this function returns incorrect keysym which completely breaks kbd
+ // handling
+ return NULL;
+
+#if 0
+ // The accelerator text is after the \t char.
+ while (*s && *s != '\t')
+ s++;
+ if (*s == '\0')
+ return (NULL);
+ s++;
+ XmString text = XmStringCreateSimple ((char *)s);
+ return text;
+#endif
+}
+
+
+// These functions duplicate those in wxWindow, but are needed
+// for use outside of wxWindow (e.g. wxMenu, wxMenuBar).
+
+// Change a widget's foreground and background colours.
+
+void wxDoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour)
+{
+ // When should we specify the foreground, if it's calculated
+ // by wxComputeColours?
+ // Solution: say we start with the default (computed) foreground colour.
+ // If we call SetForegroundColour explicitly for a control or window,
+ // then the foreground is changed.
+ // Therefore SetBackgroundColour computes the foreground colour, and
+ // SetForegroundColour changes the foreground colour. The ordering is
+ // important.
+
+ XtVaSetValues ((Widget) widget,
+ XmNforeground, foregroundColour.AllocColour(XtDisplay((Widget) widget)),
+ NULL);
+}
+
+void wxDoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour)
+{
+ wxComputeColours (XtDisplay((Widget) widget), & backgroundColour,
+ (wxColour*) NULL);
+
+ XtVaSetValues ((Widget) widget,
+ XmNbackground, g_itemColors[wxBACK_INDEX].pixel,
+ XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel,
+ XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel,
+ XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
+ NULL);
+
+ if (changeArmColour)
+ XtVaSetValues ((Widget) widget,
+ XmNarmColor, g_itemColors[wxSELE_INDEX].pixel,
+ NULL);
+}
+
+#endif
+ // __WXMOTIF__
+
+bool wxWindowIsVisible(Window win)
+{
+ XWindowAttributes wa;
+ XGetWindowAttributes(wxGlobalDisplay(), win, &wa);
+
+ return (wa.map_state == IsViewable);
+}