Exemple #1
0
        /// <summary> The generic callback procedure, that marshals to the widget specific callback procedure. </summary>
        /// <param name="widget"> The widget, that initiated the callback procedure. <see cref="System.IntPtr"/> </param>
        /// <param name="clientData"> Additional callback data from the client. <see cref="System.IntPtr"/> </param>
        /// <param name="callData"> Additional data defined for the call. <see cref="System.IntPtr"/> </param>
        /// <remarks> The prototype must match the XtCallbackProc delegate. </remarks>
        public static void MarshalCallback(IntPtr widget, IntPtr clientData, IntPtr callData)
        {
            // Debug code.
            // IntPtr hName = Xtlib.XtName (widget);
            // string sName = Marshal.PtrToStringAuto(hName);
            // Console.WriteLine (CLASS_NAME + "::MarshalCallback () INFORMATION: Widget name is: " + sName);

            if (_list.ContainsKey(widget))
            {
                _list[widget] (widget, clientData, callData);
                return;
            }

            // Subsequent code is an extension for Motif.
            // Motif menu bars and menus assign "XmNsimpleCallback" to their child widgets.
            IntPtr parentWidget = Xtlib.XtParent(widget);

            if (parentWidget != IntPtr.Zero && _list.ContainsKey(parentWidget))
            {
                _list[parentWidget] (widget, clientData, callData);
                return;
            }
            else
            {
                // Debug code.
                Console.WriteLine(CLASS_NAME + "::MarshalCallback () WARNING: Widget (" + Xtlib.XtNameAsString(widget) + ") pointer and widget's parent pointer are not registered.");
            }
        }