コード例 #1
0
        /// <summary> Handle the ButtonRelease event. </summary>
        /// <param name="source"> The widget, the ButtonRelease event is assigned to. <see cref="XrwRectObj"/> </param>
        /// <param name="e"> The event data. <see cref="XrwButtonEvent"/> </param>
        /// <remarks> Set XrwButtonEvent. Set result to nonzero to stop further event processing. </remarks>
        protected void HandleButtonReleaseDefault(XrwRectObj source, XrwButtonEvent e)
        {
            if (this is XrwRadio)
            {
                _pressed = true;
                OnSwitchedOn();
            }
            else if (this is XrwToggle)
            {
                _pressed = !_pressed;
                if (_pressed == true)
                {
                    OnSwitchedOn();
                }
                else
                {
                    OnSwitchedOff();
                }
            }

            if (XrwObject.SendExposeEvent(_display, _window, _window) == 0)
            {
                Console.WriteLine(CLASS_NAME + "::HandleFocusOut () ERROR. Can not send expose event.");
            }
            e.Result = 1;
        }
コード例 #2
0
        /// <summary> Handle the ButtonRelease event. </summary>
        /// <param name="e"> The event data. <see cref="XawButtonEvent"/> </param>
        /// <remarks> Set XawButtonEvent. Set result to nonzero to stop further event processing. </remarks>
        internal virtual void OnButtonRelease(XrwButtonEvent e)
        {
            ButtonReleaseDelegate buttonRelease = ButtonRelease;

            if (buttonRelease != null)
            {
                buttonRelease(this, e);
            }
        }
コード例 #3
0
        /// <summary> Handle the ButtonPress event. </summary>
        /// <param name="e"> The event data. <see cref="XButtonEvent"/> </param>
        /// <remarks> Set XawButtonEvent. Set result to nonzero to stop further event processing. </remarks>
        internal virtual void OnButtonPress(XrwButtonEvent e)
        {
            ButtonPressDelegate buttonPress = ButtonPress;

            if (buttonPress != null)
            {
                buttonPress(this, e);
            }
        }
コード例 #4
0
        /// <summary> Handle the ButtonPress event. </summary>
        /// <param name="source"> The widget, the ButtonPress event is assigned to. <see cref="XrwRectObj"/> </param>
        /// <param name="e"> The event data. <see cref="XawButtonEvent"/> </param>
        /// <remarks> Set XawButtonEvent. Set result to nonzero to stop further event processing. </remarks>
        void HandleCbCancelButtonRelease(XrwRectObj source, XrwButtonEvent e)
        {
            this.DefaultClose();

            // Stop event processing here!
            e.Result = 1;

            _result = XrwDialogShell.Result.Cancel;
            this.OnEnd(_result);
        }
コード例 #5
0
        /// <summary> Handle the ButtonRelease event. </summary>
        /// <param name="source"> The widget, the ButtonRelease event is assigned to. <see cref="XrwRectObj"/> </param>
        /// <param name="e"> The event data. <see cref="XrwButtonEvent"/> </param>
        /// <remarks> Set XrwButtonEvent. Set result to nonzero to stop further event processing. </remarks>
        protected void HandleButtonReleaseDefault(XrwRectObj source, XrwButtonEvent e)
        {
            _pressed = false;

            if (XrwObject.SendExposeEvent(_display, _window, _window) == 0)
            {
                Console.WriteLine(CLASS_NAME + "::HandleFocusOut () ERROR. Can not send expose event.");
            }
            OnSwitchedOff();
            e.Result = 1;
        }
コード例 #6
0
        /// <summary> Handle the ButtonRelease event. </summary>
        /// <param name="source"> The widget, the ButtonRelease event is assigned to. <see cref="XrwRectObj"/> </param>
        /// <param name="e"> The event data. <see cref="XawButtonEvent"/> </param>
        /// <remarks> Set XawButtonEvent. Set result to nonzero to stop further event processing. </remarks>
        void HandleButtonReleaseDefault(XrwRectObj source, XrwButtonEvent e)
        {
            // Determine pranslated position.
            TPoint translatedPosition = new TPoint(0, 0);

            // Anywhere on the way from GNOME 2.3.0 to 3.6.2 the values x_root and y_root habe been fixed.
            if (e.Event.x_root > e.Event.x && e.Event.y_root > e.Event.y)
            {
                translatedPosition.X = e.Event.x_root;
                translatedPosition.Y = e.Event.y_root;
            }
            else
            {
                translatedPosition.X = e.Event.x;
                translatedPosition.Y = e.Event.y;
            }

            translatedPosition.X -= _assignedPosition.X;
            translatedPosition.Y -= _assignedPosition.Y;

            X11lib.XWindowAttributes menuShellAttributes = new X11lib.XWindowAttributes();
            if (this.GetWindowAttributes(ref menuShellAttributes) == true)
            {
                translatedPosition.X -= (int)menuShellAttributes.x;
                translatedPosition.Y -= (int)menuShellAttributes.y;
            }
            else
            {
                Console.WriteLine(CLASS_NAME + "::HandleButtonRelease () ERROR: Unable to determine window attributes.");
            }

            for (int countChildren = 0; countChildren < _children.Count; countChildren++)
            {
                XrwSme sme = _children[countChildren] as XrwSme;
                if (sme != null)
                {
                    if (translatedPosition.X > sme._assignedPosition.X && translatedPosition.Y > sme._assignedPosition.Y &&
                        translatedPosition.X < sme._assignedPosition.X + sme._assignedSize.Width && translatedPosition.Y < sme._assignedPosition.Y + sme._assignedSize.Height)
                    {
                        sme.OnButtonRelease(e);
                        this.Hide();
                        e.Result = 1;
                    }
                }
            }
        }
コード例 #7
0
        // ###############################################################################
        // ### M E T H O D S
        // ###############################################################################

        #region Methods

        #endregion

        #region Event handler

        /// <summary> Handle the ButtonPress event. </summary>
        /// <param name="source"> The widget, the ButtonPress event is assigned to. <see cref="XrwRectObj"/> </param>
        /// <param name="e"> The event data. <see cref="XawButtonEvent"/> </param>
        /// <remarks> Set XawButtonEvent. Set result to nonzero to stop further event processing. </remarks>
        private new void HandleButtonPressDefault(XrwRectObj source, XrwButtonEvent e)
        {
            if (_menu != null)
            {
                // Set position and size.
                TPoint position = new TPoint(20, 20);
                X11lib.XWindowAttributes menuButtonAttributes = new X11lib.XWindowAttributes();
                if (this.GetWindowAttributes(ref menuButtonAttributes) == true)
                {
                    position.X = (int)menuButtonAttributes.x;
                    position.Y = (int)menuButtonAttributes.y + (int)menuButtonAttributes.height;
                }
                else
                {
                    Console.WriteLine(CLASS_NAME + "::HandleButtonPress () ERROR: Unable to determine window attributes.");
                }

                XrwObject parent = this.Parent;
                while (parent != null && (parent is XrwVisibleRectObj))
                {
                    if (parent is XrwWmShell)
                    {
                        position.X += (parent as XrwWmShell).AssignedPosition.X;
                        position.Y += (parent as XrwWmShell).AssignedPosition.Y;
                    }
                    else if (parent.HasOwnWindow)
                    {
                        if ((parent as XrwVisibleRectObj).GetWindowAttributes(ref menuButtonAttributes) == true)
                        {
                            position.X += (int)menuButtonAttributes.x;
                            position.Y += (int)menuButtonAttributes.y;
                        }
                        else
                        {
                            Console.WriteLine(CLASS_NAME + "::HandleButtonPress () ERROR: Unable to determine parent window attributes.");
                        }
                    }
                    else
                    {
                        // Windowless widgets positions must not be added!
                    }
                    parent = (parent as XrwVisibleRectObj).Parent;
                }

                TSize size = _menu.AssignedSize;
                _menu.MoveResize(ref position, ref size);

                // Register menu shell to her application shell for integrating into their event loop.
                XrwApplicationShell appShell = _menu.ApplicationShell;
                if (appShell != null)
                {
                    if (!appShell.HasChild(_menu))
                    {
                        appShell.AddChild(_menu);
                    }
                }
                else
                {
                    Console.WriteLine(CLASS_NAME + "::HandleButtonPress () ERROR. Can not investigate menu's application shell.");
                }

                _menu.Show();
            }
            else
            {
                Console.WriteLine(CLASS_NAME + "::HandleButtonPress () ERROR: No menu registered.");
            }
            e.Result = 1;
        }