Esempio n. 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.");
            }
        }
Esempio n. 2
0
        // ###############################################################################
        // ### M E T H O D S
        // ###############################################################################

        #region Methods

        /// <summary> Add a widget specific callback registration. </summary>
        /// <param name="widget"> The widget to register the callback for. <see cref="System.IntPtr"/> </param>
        /// <param name="callback"> The callback to execute. <see cref="XtCallbackProc"/> </param>
        /// <returns> The managed code to native code marshalable generic callback procedure. <see cref="System.IntPtr"/> </returns>
        public static IntPtr Add(IntPtr widget, XtCallbackProc callback)
        {
            if (widget == IntPtr.Zero)
            {
                Console.WriteLine(CLASS_NAME + "::Add () WARNING: Widget is zero.");
            }
            if (callback == null)
            {
                Console.WriteLine(CLASS_NAME + "::Add () WARNING: Callback is zero.");
            }

            if (_list.ContainsKey(widget))
            {
                // Debug code.
                Console.WriteLine(CLASS_NAME + "::Add() WARNING: Callback already registered for widget (" + Xtlib.XtNameAsString(widget) + "). Perform refresh.");
                _list[widget] = callback;
            }
            else
            {
                _list.Add(widget, callback);
            }

            return(_callbackPtr);
        }
Esempio n. 3
0
        /// <summary> The generic callback procedure, that marshals to the widget specific callback procedure. </summary>
        /// <param name="widget"> The widget, that is source of the event. <see cref="System.IntPtr"/> </param>
        /// <param name="xevent"> The event, that is invoked. <see cref="XEvent"/> </param>
        /// <param name="parameters"> Additional parameters (as String[]). <see cref="System.IntPtr"/> </param>
        /// <param name="num_params"> The number of additional parameters. <see cref="XCardinal"/> </param>
        /// <remarks> The prototype must match the XtActionProc delegate. </remarks>
        public static void MarshalAction(IntPtr widget, ref X11.XEvent xevent, IntPtr parameters, ref X11.XCardinal num_params)
        {
            ActionKey actionKey = new ActionKey(widget, xevent.type);

            if (_list.ContainsKey(actionKey))
            {
                _list[actionKey] (widget, ref xevent, parameters, ref num_params);
            }
            else
            {
                // Debug code.
                Console.WriteLine(CLASS_NAME + "::MarshalAction () WARNING: Widget (" + Xtlib.XtNameAsString(widget) + ") pointer is not registered.");
            }
        }