Exemple #1
0
 /// <summary> Reassign a callback to a new widget. </summary>
 /// <param name="oldWidget"> The widget a calback is currently assigned to. <see cref="IntPtr"/> </param>
 /// <param name="newWidget"> The widget a callback should be reassigned to. <see cref="IntPtr"/> </param>
 public static void Reassign(IntPtr oldWidget, IntPtr newWidget)
 {
     // Complete function code is an extension for Motif.
     // Motif menu bars and menus assign "XmNsimpleCallback" at a moment, the widget ID is not known to the caller.
     if (_list.ContainsKey(oldWidget))
     {
         XtCallbackProc callback = _list[oldWidget];
         _list.Remove(oldWidget);
         _list.Add(newWidget, callback);
     }
     else
     {
         Console.WriteLine(CLASS_NAME + "::Reassign () WARNING: newWidget pointer was not registered.");
     }
 }
Exemple #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);
        }