Ejemplo n.º 1
0
        // Override the key press event from Xsharp.
        protected override bool OnKeyPress(KeyName key,
                                           ModifierMask modifiers, String str)
        {
            bool processed = false;

            if (sink != null)
            {
                // Emit the "KeyDown" event.
                ToolkitKeys keyData = DrawingWindow.MapKey(key, modifiers);
                if (sink.ToolkitKeyDown(keyData))
                {
                    processed = true;
                }

                // Emit the "KeyChar" event if necessary.
                if (str != null)
                {
                    foreach (char ch in str)
                    {
                        if (sink.ToolkitKeyChar(ch))
                        {
                            processed = true;
                        }
                    }
                }
            }
            return(processed);
        }
Ejemplo n.º 2
0
        // Override the key press event from Xsharp.
        protected override bool OnKeyPress(KeyName key,
                                           ModifierMask modifiers, String str)
        {
            bool processed = false;

            if (sink != null)
            {
                // Emit the "KeyDown" event.
                ToolkitKeys keyData = MapKey(key, modifiers);
                if (sink.ToolkitKeyDown(keyData))
                {
                    processed = true;
                }

                // Emit the "KeyChar" event if necessary.
                if (str != null)
                {
                    foreach (char ch in str)
                    {
                        // Clean old ASCII DEL (0x7F)
                        if (ch != (char)0x7F)
                        {
                            if (sink != null)                                         // window might be closed by sink.ToolkitKeyDown
                            {
                                if (sink.ToolkitKeyChar(ch))
                                {
                                    processed = true;
                                }
                            }
                        }
                    }
                }
            }
            return(processed);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// <para>Method that is called when the mouse pointer leaves
 /// this widget.</para>
 /// </summary>
 ///
 /// <param name="child">
 /// <para>The child widget that contained the previous or final
 /// position, or <see langword="null"/> if no applicable child
 /// widget.</para>
 /// </param>
 ///
 /// <param name="x">
 /// <para>The X co-ordinate of the pointer position.</para>
 /// </param>
 ///
 /// <param name="y">
 /// <para>The Y co-ordinate of the pointer position.</para>
 /// </param>
 ///
 /// <param name="modifiers">
 /// <para>Button and shift flags that were active.</para>
 /// </param>
 ///
 /// <param name="mode">
 /// <para>The notification mode value from the event.</para>
 /// </param>
 ///
 /// <param name="detail">
 /// <para>The notification detail value from the event.</para>
 /// </param>
 protected virtual void OnLeave(Widget child, int x, int y,
                                ModifierMask modifiers,
                                CrossingMode mode,
                                CrossingDetail detail)
 {
     // Nothing to do in this class.
 }
Ejemplo n.º 4
0
 // Handle a button press.
 protected override void OnButtonPress
     (int x, int y, ButtonName button, ModifierMask modifiers)
 {
     if (IsSelect(button))
     {
         entered = true;
         pressed = true;
         Draw();
     }
 }
Ejemplo n.º 5
0
 // Override the key release event from Xsharp.
 protected override bool OnKeyRelease(KeyName key, ModifierMask modifiers)
 {
     if (sink != null)
     {
         // Emit the "KeyUp" event.
         ToolkitKeys keyData = DrawingWindow.MapKey(key, modifiers);
         return(sink.ToolkitKeyUp(keyData));
     }
     return(false);
 }
Ejemplo n.º 6
0
 // Override the mouse leave event from Xsharp.
 protected override void OnLeave(Widget child, int x, int y,
                                 ModifierMask modifiers,
                                 CrossingMode mode,
                                 CrossingDetail detail)
 {
     if (sink != null)
     {
         sink.ToolkitMouseLeave();
     }
 }
Ejemplo n.º 7
0
 // Override the button double click event from Xsharp.
 protected override void OnButtonDoubleClick
     (int x, int y, ButtonName button, ModifierMask modifiers)
 {
     if (sink != null)
     {
         sink.ToolkitMouseDown
             (DrawingWindow.MapButton(button),
             DrawingWindow.MapKey(KeyName.XK_VoidSymbol, modifiers),
             2, x, y, 0);
     }
 }
Ejemplo n.º 8
0
 // Override the button release event from Xsharp.
 protected override void OnButtonRelease(int x, int y, ButtonName button,
                                         ModifierMask modifiers)
 {
     if (sink != null)
     {
         sink.ToolkitMouseUp
             (DrawingWindow.MapButton(button),
             DrawingWindow.MapKey(KeyName.XK_VoidSymbol, modifiers),
             1, x, y, 0);
     }
 }
Ejemplo n.º 9
0
 // Dispatch a key release event to this widget from the top-level window.
 internal bool DispatchKeyReleaseEvent(KeyName key, ModifierMask modifiers)
 {
     if (FullSensitive)
     {
         return(OnKeyRelease(key, modifiers));
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 10
0
            // Handle pointer motion events.
            protected override void OnPointerMotion
                (int x, int y, ModifierMask modifiers)
            {
                bool before = (entered && pressed);

                entered = (x >= 0 && y >= 0 && x < width && y < height);
                if ((entered && pressed) != before)
                {
                    Draw();
                }
            }
Ejemplo n.º 11
0
 // Override the pointer motion event from Xsharp.
 protected override void OnPointerMotion
     (int x, int y, ModifierMask modifiers)
 {
     if (sink != null)
     {
         sink.ToolkitMouseMove
             (DrawingWindow.MapButton(button),
             DrawingWindow.MapKey(KeyName.XK_VoidSymbol, modifiers),
             0, x, y, 0);
     }
 }
Ejemplo n.º 12
0
 // Override the button press event from Xsharp.
 protected override void OnButtonPress(int x, int y, ButtonName button,
                                       ModifierMask modifiers)
 {
     if (sink != null)
     {
         sink.ToolkitMouseDown
             (MapButton(button),
             MapKey(KeyName.XK_VoidSymbol, modifiers),
             1, x, y, 0);
     }
     this.button = button;
 }
Ejemplo n.º 13
0
 // Dispatch a key event to this widget from the top-level window.
 internal bool DispatchKeyEvent(KeyName key, ModifierMask modifiers,
                                String str)
 {
     if (FullSensitive)
     {
         return(OnKeyPress(key, modifiers, str));
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 14
0
        protected override bool OnButtonWheel(int x, int y, ButtonName button,
                                              ModifierMask modifiers, int iDelta)
        {
            if (sink != null)
            {
                sink.ToolkitMouseWheel
                    (MapButton(button),
                    MapKey(KeyName.XK_VoidSymbol, modifiers),
                    1, x, y, iDelta);
            }

            return(true);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// <para>Method that is called if a key is pressed when this
        /// widget has the focus.</para>
        /// </summary>
        ///
        /// <param name="key">
        /// <para>The key code.</para>
        /// </param>
        ///
        /// <param name="modifiers">
        /// <para>Other button and shift flags that were active.</para>
        /// </param>
        ///
        /// <param name="str">
        /// <para>The translated string that corresponds to the key, or
        /// <see langword="null"/> if the key does not have a translation.</para>
        /// </param>
        ///
        /// <returns>
        /// <para>Returns <see langword="true"/> if the key has been processed
        /// and it should not be passed further up the focus tree.  Returns
        /// <see langword="false"/> if the key should be passed further up
        /// the focus tree.</para>
        /// </returns>
        ///
        /// <remarks>The <paramref name="key"/> parameter indicates the X11
        /// symbol that corresponds to the key, which allows cursor control
        /// and function keys to be easily distinguished.  The
        /// <paramref name="str"/> is primarily of use to text
        /// input widgets.</remarks>
        protected override bool OnKeyPress(KeyName key,
                                           ModifierMask modifiers, String str)
        {
            // Check for "Ctrl+F4" to close the active MDI child.
            // We also allow "Shift+F4" and "Mod4+F4" because some
            // window managers redirect "Ctrl+F4" for desktop switching.
            // "Mod4" is usually the "Windows" key on PC keyboards.
            if ((key == KeyName.XK_F4 || key == KeyName.XK_KP_F4) &&
                (modifiers & (ModifierMask.ControlMask |
                              ModifierMask.ShiftMask |
                              ModifierMask.Mod4Mask)) != 0)
            {
                if (activeChild != null)
                {
                    activeChild.Child.Close();
                }
                return(true);
            }

            // Check for Ctrl+Tab and Ctrl+Shift+Tab.  "Mod4" can be
            // used in place of "Ctrl", same as above.  Windows also
            // allows "Ctrl+F6" to be used instead of "Ctrl+Tab".
            if ((key == KeyName.XK_Tab || key == KeyName.XK_KP_Tab ||
                 key == KeyName.XK_F6) &&
                (modifiers & (ModifierMask.ControlMask |
                              ModifierMask.Mod4Mask)) != 0)
            {
                if ((modifiers & ModifierMask.ShiftMask) != 0)
                {
                    TabBackward();
                }
                else
                {
                    TabForward();
                }
                return(true);
            }
            if (key == KeyName.XK_ISO_Left_Tab &&
                (modifiers & (ModifierMask.ControlMask |
                              ModifierMask.Mod4Mask)) != 0)
            {
                TabBackward();
                return(true);
            }

            // We don't know what this key is.
            return(false);
        }
Ejemplo n.º 16
0
        // Map an Xsharp key description into a "ToolkitKeys" value.
        internal static ToolkitKeys MapKey(KeyName key, ModifierMask modifiers)
        {
            ToolkitKeys toolkitKey = MapKey(key);

            if ((modifiers & ModifierMask.ControlMask) != 0)
            {
                toolkitKey |= ToolkitKeys.Control;
            }
            if ((modifiers & ModifierMask.ShiftMask) != 0)
            {
                toolkitKey |= ToolkitKeys.Shift;
            }
            if ((modifiers & ModifierMask.Mod1Mask) != 0)
            {
                toolkitKey |= ToolkitKeys.Alt;
            }
            return(toolkitKey);
        }
Ejemplo n.º 17
0
 // Handle a button release.
 protected override void OnButtonRelease
     (int x, int y, ButtonName button, ModifierMask modifiers)
 {
     if (IsSelect(button))
     {
         pressed = false;
         Draw();
         if (entered)
         {
             CaptionWidget child = mdi.activeChild;
             if (child != null)
             {
                 if ((flags &
                      CaptionWidget.CaptionFlags.HasClose) != 0)
                 {
                     child.Child.Close();
                 }
                 else if ((flags & CaptionWidget.CaptionFlags.
                           HasRestore) != 0)
                 {
                     if (child.Child.iconic)
                     {
                         child.Child.Deiconify();
                     }
                     else
                     {
                         child.Child.Restore();
                     }
                 }
                 else
                 {
                     child.Child.Iconify();
                 }
             }
         }
     }
 }
Ejemplo n.º 18
0
	/// <summary>
	/// <para>Determine if the mouse button that corresponds to "Menu"
	/// is part of a modifier mask.</para>
	/// </summary>
	///
	/// <param name="modifiers">
	/// <para>The modifier mask to test.</para>
	/// </param>
	public bool IsMenu(ModifierMask modifiers)
			{
				return ((((int)modifiers) &
							(((int)(ModifierMask.Button1Mask)) <<
								(((int)(dpy.menuButton)) - 1))) != 0);
			}
Ejemplo n.º 19
0
	// Handle a button release.
	protected void OnButtonRelease(int x, int y, int x_root, int y_root,
								   ButtonName button, ModifierMask modifiers)
			{
				// Set the cursor and bail out if we aren't in a click mode.
				if(clickMode == HitTest.Outside)
				{
					SetCursor(x, y);
					return;
				}

				// Bail out if it wasn't the select button that was released.
				if(!IsSelect(button))
				{
					return;
				}

				// Get the area currently occupied by the cursor.
				HitTest hitTest = PerformHitTest(x, y);

				// Process the button release according to the click mode.
				switch(clickMode)
				{
					case HitTest.Close:
					case HitTest.Maximize:
					case HitTest.Minimize:
					case HitTest.Restore:
					case HitTest.Help:
					{
						if(ChangeButtonState(clickMode, false) &&
						   clickMode == hitTest)
						{
							// A caption button has been clicked.
							switch(clickMode)
							{
								case HitTest.Close:
									child.Close();
									break;
								case HitTest.Maximize:
									if(child.IsIconic)
									{
										child.Deiconify();
									}
									child.Maximize();
									break;
								case HitTest.Minimize:
									child.Iconify();
									break;
								case HitTest.Restore:
									if(child.IsIconic)
									{
										child.Deiconify();
									}
									else
									{
										child.Restore();
									}
									break;
								case HitTest.Help:
									child.Help();
									break;
							}
						}
					}
					break;
				}

				// Exit the click mode and return to normal.
				clickMode = HitTest.Outside;
				SetCursor(x, y);
			}
Ejemplo n.º 20
0
 /// <summary>
 /// <para>Method that is called if a key is pressed when this
 /// widget has the focus.</para>
 /// </summary>
 ///
 /// <param name="key">
 /// <para>The key code.</para>
 /// </param>
 ///
 /// <param name="modifiers">
 /// <para>Other button and shift flags that were active.</para>
 /// </param>
 ///
 /// <param name="str">
 /// <para>The translated string that corresponds to the key, or
 /// <see langword="null"/> if the key does not have a translation.</para>
 /// </param>
 ///
 /// <returns>
 /// <para>Returns <see langword="true"/> if the key has been processed
 /// and it should not be passed further up the focus tree.  Returns
 /// <see langword="false"/> if the key should be passed further up
 /// the focus tree.</para>
 /// </returns>
 ///
 /// <remarks>The <paramref name="key"/> parameter indicates the X11
 /// symbol that corresponds to the key, which allows cursor control
 /// and function keys to be easily distinguished.  The
 /// <paramref name="str"/> is primarily of use to text
 /// input widgets.</remarks>
 protected virtual bool OnKeyPress(KeyName key,
                                   ModifierMask modifiers, String str)
 {
     // Nothing to do in this class.
     return(false);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// <para>Method that is called if a key is released when this
 /// widget has the focus.</para>
 /// </summary>
 ///
 /// <param name="key">
 /// <para>The key code.</para>
 /// </param>
 ///
 /// <param name="modifiers">
 /// <para>Other button and shift flags that were active.</para>
 /// </param>
 ///
 /// <returns>
 /// <para>Returns <see langword="true"/> if the key has been processed
 /// and it should not be passed further up the focus tree.  Returns
 /// <see langword="false"/> if the key should be passed further up
 /// the focus tree.</para>
 /// </returns>
 protected virtual bool OnKeyRelease(KeyName key, ModifierMask modifiers)
 {
     // Nothing to do in this class.
     return(false);
 }
	// Dispatch a key event to this widget from the top-level window.
	internal bool DispatchKeyEvent(KeyName key, ModifierMask modifiers,
								   String str)
			{
				if(FullSensitive)
				{
					return OnKeyPress(key, modifiers, str);
				}
				else
				{
					return false;
				}
			}
Ejemplo n.º 23
0
	/// <summary>
	/// <para>Determine if the mouse button that corresponds to "Select"
	/// is part of a modifier mask.</para>
	/// </summary>
	///
	/// <param name="modifiers">
	/// <para>The modifier mask to test.</para>
	/// </param>
	public bool IsSelect(ModifierMask modifiers)
			{
				return ((((int)modifiers) &
							(((int)(ModifierMask.Button1Mask)) <<
								(((int)(dpy.selectButton)) - 1))) != 0);
			}
Ejemplo n.º 24
0
	// Handle a button double-click.
	protected void OnButtonDoubleClick
				(int x, int y, int x_root, int y_root,
				 ButtonName button, ModifierMask modifiers)
			{
				HitTest hitTest = SetCursor(x, y);
				if(IsSelect(button))
				{
					if(hitTest == HitTest.Caption)
					{
						// Double-clicking the caption de-iconifies, maximizes,
						// or restores.
						if(child.IsIconic)
						{
							child.Deiconify();
						}
						else if((flags & CaptionFlags.HasMaximize) != 0)
						{
							child.Maximize();
						}
						else if((flags & CaptionFlags.HasRestore) != 0)
						{
							child.Restore();
						}
					}
					else
					{
						// Double-click elsewhere is the same as single-click.
						OnButtonPress(x, y, x_root, y_root, button, modifiers);
					}
				}
			}
Ejemplo n.º 25
0
	// Handle pointer enters.
	protected override void OnEnter(Widget child, int x, int y,
								   ModifierMask modifiers,
								   CrossingMode mode,
								   CrossingDetail detail)
			{
				if(clickMode == HitTest.Outside)
				{
					SetCursor(x, y);
				}
			}
	// Override the button double click event from Xsharp.
	protected override void OnButtonDoubleClick
				(int x, int y, ButtonName button, ModifierMask modifiers)
			{
				if(sink != null)
				{
					sink.ToolkitMouseDown
						(DrawingWindow.MapButton(button),
						 DrawingWindow.MapKey
						 	(KeyName.XK_VoidSymbol, modifiers),
						 2, x, y, 0);
				}
			}
	// Override the key press event from Xsharp.
	protected override bool OnKeyPress(KeyName key,
									   ModifierMask modifiers, String str)
			{
				bool processed = false;
				if(sink != null)
				{
					// Emit the "KeyDown" event.
					ToolkitKeys keyData = DrawingWindow.MapKey(key, modifiers);
					if(sink.ToolkitKeyDown(keyData))
					{
						processed = true;
					}

					// Emit the "KeyChar" event if necessary.
					if(str != null)
					{
						foreach(char ch in str)
						{
							if(sink.ToolkitKeyChar(ch))
							{
								processed = true;
							}
						}
					}
				}
				return processed;
			}
		// Handle pointer motion events.
		protected override void OnPointerMotion
					(int x, int y, ModifierMask modifiers)
				{
					bool before = (entered && pressed);
					entered = (x >= 0 && y >= 0 && x < width && y < height);
					if((entered && pressed) != before)
					{
						Draw();
					}
				}
		// Handle a button press.
		protected override void OnButtonPress
					(int x, int y, ButtonName button, ModifierMask modifiers)
				{
					if(IsSelect(button))
					{
						entered = true;
						pressed = true;
						Draw();
					}
				}
Ejemplo n.º 30
0
	// Handle pointer motion events.
	protected void OnPointerMotion
				(int x, int y, int x_root, int y_root, ModifierMask modifiers)
			{
				// Set the cursor and bail out if we aren't in a click mode.
				if(clickMode == HitTest.Outside)
				{
					SetCursor(x, y);
					return;
				}

				// Get the area currently occupied by the cursor.
				HitTest hitTest = PerformHitTest(x, y);

				// Get the root co-ordinates of the MDI client window
				// and restrict (x_root, y_root) to its boundaries.
				Widget mdiClient = Parent;
				int clientLeft = mdiClient.X;
				int clientTop = mdiClient.Y;
				Widget parent = mdiClient.Parent;
				while(parent != null)
				{
					clientLeft += parent.X;
					clientTop += parent.Y;
					parent = parent.Parent;
				}
				int clientRight = clientLeft + mdiClient.Width;
				int clientBottom = clientTop + mdiClient.Height;
				if(x_root < clientLeft)
				{
					x_root = clientLeft;
				}
				else if(x_root >= clientRight)
				{
					x_root = clientRight - 1;
				}
				if(y_root < clientTop)
				{
					y_root = clientTop;
				}
				else if(y_root >= clientBottom)
				{
					y_root = clientBottom - 1;
				}

				// Get the amount by which the mouse pointer has moved
				// since we started the drag operation.
				int diffx = x_root - startRootX;
				int diffy = y_root - startRootY;

				// Get the root co-ordinates of the window pre-drag.
				int left, top, right, bottom;
				left = startRootX - startX;
				top = startRootY - startY;
				right = left + startWidth;
				bottom = top + startHeight;

				// Process the pointer motion according to the click mode.
				switch(clickMode)
				{
					case HitTest.TopLeft:
					{
						left += diffx;
						top += diffy;
						if((right - left) < MinWidth)
						{
							left = right - MinWidth;
						}
						else if((right - left) > MaxWidth)
						{
							left = right - MaxWidth;
						}
						if((bottom - top) < MinHeight)
						{
							top = bottom - MinHeight;
						}
						else if((bottom - top) > MaxHeight)
						{
							top = bottom - MaxHeight;
						}
					}
					break;

					case HitTest.TopRight:
					{
						right += diffx;
						top += diffy;
						if((right - left) < MinWidth)
						{
							right = left + MinWidth;
						}
						else if((right - left) > MaxWidth)
						{
							right = left + MaxWidth;
						}
						if((bottom - top) < MinHeight)
						{
							top = bottom - MinHeight;
						}
						else if((bottom - top) > MaxHeight)
						{
							top = bottom - MaxHeight;
						}
					}
					break;

					case HitTest.BottomLeft:
					{
						left += diffx;
						bottom += diffy;
						if((right - left) < MinWidth)
						{
							left = right - MinWidth;
						}
						else if((right - left) > MaxWidth)
						{
							left = right - MaxWidth;
						}
						if((bottom - top) < MinHeight)
						{
							bottom = top + MinHeight;
						}
						else if((bottom - top) > MaxHeight)
						{
							bottom = top + MaxHeight;
						}
					}
					break;

					case HitTest.BottomRight:
					{
						right += diffx;
						bottom += diffy;
						if((right - left) < MinWidth)
						{
							right = left + MinWidth;
						}
						else if((right - left) > MaxWidth)
						{
							right = left + MaxWidth;
						}
						if((bottom - top) < MinHeight)
						{
							bottom = top + MinHeight;
						}
						else if((bottom - top) > MaxHeight)
						{
							bottom = top + MaxHeight;
						}
					}
					break;

					case HitTest.Top:
					{
						top += diffy;
						if((bottom - top) < MinHeight)
						{
							top = bottom - MinHeight;
						}
						else if((bottom - top) > MaxHeight)
						{
							top = bottom - MaxHeight;
						}
					}
					break;

					case HitTest.Bottom:
					{
						bottom += diffy;
						if((bottom - top) < MinHeight)
						{
							bottom = top + MinHeight;
						}
						else if((bottom - top) > MaxHeight)
						{
							bottom = top + MaxHeight;
						}
					}
					break;

					case HitTest.Left:
					{
						left += diffx;
						if((right - left) < MinWidth)
						{
							left = right - MinWidth;
						}
						else if((right - left) > MaxWidth)
						{
							left = right - MaxWidth;
						}
					}
					break;

					case HitTest.Right:
					{
						right += diffx;
						if((right - left) < MinWidth)
						{
							right = left + MinWidth;
						}
						else if((right - left) > MaxWidth)
						{
							right = left + MaxWidth;
						}
					}
					break;

					case HitTest.Close:
					case HitTest.Maximize:
					case HitTest.Minimize:
					case HitTest.Restore:
					case HitTest.Help:
					{
						// Change the button state if we have left or
						// re-entered the caption button we started with.
						ChangeButtonState(clickMode, clickMode == hitTest);
					}
					return;

					case HitTest.Caption:
					{
						// If the mouse has moved sufficiently away from
						// the starting position, then switch into move mode.
						if(diffx < -4 || diffx > 4 || diffy < -4 || diffy > 4)
						{
							// We cannot enter move mode if maximized.
							if(!(child.IsMaximized))
							{
								clickMode = HitTest.Move;
								goto case HitTest.Move;
							}
						}
					}
					return;

					case HitTest.Move:
					{
						// Move the window to a new location.
						left += diffx;
						right += diffx;
						top += diffy;
						bottom += diffy;
					}
					break;
				}

				// Convert root co-ordinates back into normal co-ordinates.
				left -= clientLeft;
				right -= clientLeft;
				top -= clientTop;
				bottom -= clientTop;

				// Move the window to its new location.
				MoveResize(left, top, right - left, bottom - top);
			}
Ejemplo n.º 31
0
	// Handle a button press.
	protected void OnButtonPress(int x, int y, int x_root, int y_root,
								 ButtonName button, ModifierMask modifiers)
			{
				// Ignore button presses in a click mode because they
				// will be for something other than the select button.
				if(clickMode != HitTest.Outside)
				{
					return;
				}

				// Adjust the cursor to match the current position.
				HitTest hitTest = SetCursor(x, y);

				// Bail out if we are not processing the select button.
				if(!IsSelect(button))
				{
					return;
				}

				// Enter the appropriate click mode.
				if(hitTest != HitTest.Outside && hitTest != HitTest.Client)
				{
					clickMode = hitTest;
					startX = x;
					startY = y;
					startWidth = width;
					startHeight = height;
					startRootX = x_root;
					startRootY = y_root;
				}

				// Depress a button if one was pressed.
				switch(hitTest)
				{
					case HitTest.Close:
					case HitTest.Maximize:
					case HitTest.Minimize:
					case HitTest.Restore:
					case HitTest.Help:
					{
						ChangeButtonState(hitTest, true);
					}
					break;
				}
			}
	/// <summary>
	/// <para>Method that is called if a key is released when this
	/// widget has the focus.</para>
	/// </summary>
	///
	/// <param name="key">
	/// <para>The key code.</para>
	/// </param>
	///
	/// <param name="modifiers">
	/// <para>Other button and shift flags that were active.</para>
	/// </param>
	///
	/// <returns>
	/// <para>Returns <see langword="true"/> if the key has been processed
	/// and it should not be passed further up the focus tree.  Returns
	/// <see langword="false"/> if the key should be passed further up
	/// the focus tree.</para>
	/// </returns>
	protected virtual bool OnKeyRelease(KeyName key, ModifierMask modifiers)
			{
				// Nothing to do in this class.
				return false;
			}
	/// <summary>
	/// <para>Method that is called if a key is pressed when this
	/// widget has the focus.</para>
	/// </summary>
	///
	/// <param name="key">
	/// <para>The key code.</para>
	/// </param>
	///
	/// <param name="modifiers">
	/// <para>Other button and shift flags that were active.</para>
	/// </param>
	///
	/// <param name="str">
	/// <para>The translated string that corresponds to the key, or
	/// <see langword="null"/> if the key does not have a translation.</para>
	/// </param>
	///
	/// <returns>
	/// <para>Returns <see langword="true"/> if the key has been processed
	/// and it should not be passed further up the focus tree.  Returns
	/// <see langword="false"/> if the key should be passed further up
	/// the focus tree.</para>
	/// </returns>
	///
	/// <remarks>The <paramref name="key"/> parameter indicates the X11
	/// symbol that corresponds to the key, which allows cursor control
	/// and function keys to be easily distinguished.  The
	/// <paramref name="str"/> is primarily of use to text
	/// input widgets.</remarks>
	protected override bool OnKeyPress(KeyName key,
									   ModifierMask modifiers, String str)
			{
				// Check for "Ctrl+F4" to close the active MDI child.
				// We also allow "Shift+F4" and "Mod4+F4" because some
				// window managers redirect "Ctrl+F4" for desktop switching.
				// "Mod4" is usually the "Windows" key on PC keyboards.
				if((key == KeyName.XK_F4 || key == KeyName.XK_KP_F4) &&
				   (modifiers & (ModifierMask.ControlMask |
				   				 ModifierMask.ShiftMask |
								 ModifierMask.Mod4Mask)) != 0)
				{
					if(activeChild != null)
					{
						activeChild.Child.Close();
					}
					return true;
				}

				// Check for Ctrl+Tab and Ctrl+Shift+Tab.  "Mod4" can be
				// used in place of "Ctrl", same as above.  Windows also
				// allows "Ctrl+F6" to be used instead of "Ctrl+Tab".
				if((key == KeyName.XK_Tab || key == KeyName.XK_KP_Tab ||
				    key == KeyName.XK_F6) &&
				   (modifiers & (ModifierMask.ControlMask |
								 ModifierMask.Mod4Mask)) != 0)
				{
					if((modifiers & ModifierMask.ShiftMask) != 0)
					{
						TabBackward();
					}
					else
					{
						TabForward();
					}
					return true;
				}
				if(key == KeyName.XK_ISO_Left_Tab &&
				   (modifiers & (ModifierMask.ControlMask |
								 ModifierMask.Mod4Mask)) != 0)
				{
					TabBackward();
					return true;
				}

				// We don't know what this key is.
				return false;
			}
Ejemplo n.º 34
0
	// Handle pointer leaves.
	protected override void OnLeave(Widget child, int x, int y,
								   ModifierMask modifiers,
								   CrossingMode mode,
								   CrossingDetail detail)
			{
				if(clickMode == HitTest.Outside)
				{
					Cursor = null;
				}
			}
		// Handle a button release.
		protected override void OnButtonRelease
					(int x, int y, ButtonName button, ModifierMask modifiers)
				{
					if(IsSelect(button))
					{
						pressed = false;
						Draw();
						if(entered)
						{
							CaptionWidget child = mdi.activeChild;
							if(child != null)
							{
								if((flags &
									CaptionWidget.CaptionFlags.HasClose) != 0)
								{
									child.Child.Close();
								}
								else if((flags & CaptionWidget.CaptionFlags.
											HasRestore) != 0)
								{
									if(child.Child.iconic)
									{
										child.Child.Deiconify();
									}
									else
									{
										child.Child.Restore();
									}
								}
								else
								{
									child.Child.Iconify();
								}
							}
						}
					}
				}
	// Override the mouse leave event from Xsharp.
	protected override void OnLeave(Widget child, int x, int y,
								    ModifierMask modifiers,
								    CrossingMode mode,
								    CrossingDetail detail)
			{
				if(sink != null)
				{
					sink.ToolkitMouseLeave();
				}
			}
	// Override the button release event from Xsharp.
	protected override void OnButtonRelease(int x, int y, ButtonName button,
									  	    ModifierMask modifiers)
			{
				if(sink != null)
				{
					sink.ToolkitMouseUp
						(DrawingWindow.MapButton(button),
						 DrawingWindow.MapKey
						 	(KeyName.XK_VoidSymbol, modifiers),
						 1, x, y, 0);
				}
			}
	// Map an Xsharp key description into a "ToolkitKeys" value.
	internal static ToolkitKeys MapKey(KeyName key, ModifierMask modifiers)
			{
				ToolkitKeys toolkitKey =  ToolkitKeys.None;
				if((modifiers & ModifierMask.ControlMask) != 0)
				{
					toolkitKey |= ToolkitKeys.Control;
				}
				if((modifiers & ModifierMask.ShiftMask) != 0)
				{
					toolkitKey |= ToolkitKeys.Shift;
				}
				if((modifiers & ModifierMask.Mod1Mask) != 0)
				{
					toolkitKey |= ToolkitKeys.Alt;
				}
				return toolkitKey;
			}
	// Override the pointer motion event from Xsharp.
	protected override void OnPointerMotion
				(int x, int y, ModifierMask modifiers)
			{
				if(sink != null)
				{
					sink.ToolkitMouseMove
						(ToolkitMouseButtons.None,
						 DrawingWindow.MapKey
						 	(KeyName.XK_VoidSymbol, modifiers),
						 0, x, y, 0);
				}
			}
	/// <summary>
	/// <para>Method that is called when any mouse button is released
	/// while the pointer is inside this widget.</para>
	/// </summary>
	///
	/// <param name="x">
	/// <para>The X co-ordinate of the pointer position.</para>
	/// </param>
	///
	/// <param name="y">
	/// <para>The Y co-ordinate of the pointer position.</para>
	/// </param>
	///
	/// <param name="button">
	/// <para>The button that was released.</para>
	/// </param>
	///
	/// <param name="modifiers">
	/// <para>Other button and shift flags that were active.</para>
	/// </param>
	protected virtual void OnButtonRelease(int x, int y, ButtonName button,
									  	   ModifierMask modifiers)
			{
				// Nothing to do in this class.
			}
	// Override the key release event from Xsharp.
	protected override bool OnKeyRelease(KeyName key, ModifierMask modifiers)
			{
				if(sink != null)
				{
					// Emit the "KeyUp" event.
					ToolkitKeys keyData = DrawingWindow.MapKey(key, modifiers);
					return sink.ToolkitKeyUp(keyData);
				}
				return false;
			}
	/// <summary>
	/// <para>Method that is called when the mouse pointer is moved inside
	/// this widget.</para>
	/// </summary>
	///
	/// <param name="x">
	/// <para>The X co-ordinate of the pointer position.</para>
	/// </param>
	///
	/// <param name="y">
	/// <para>The Y co-ordinate of the pointer position.</para>
	/// </param>
	///
	/// <param name="modifiers">
	/// <para>Other button and shift flags that were active.</para>
	/// </param>
	protected virtual void OnPointerMotion
				(int x, int y, ModifierMask modifiers)
			{
				// Nothing to do in this class.
			}
	protected override bool OnButtonWheel(int x, int y, ButtonName button,
									  	   ModifierMask modifiers, int iDelta)
			{
				if(sink != null)
				{
					sink.ToolkitMouseWheel
						(MapButton(button),
						MapKey(KeyName.XK_VoidSymbol, modifiers),
						1, x, y, iDelta);
				}

				return true;
			}
Ejemplo n.º 44
0
        // Dispatch an event to this widget.
        internal override void DispatchEvent(ref XEvent xevent)
        {
            XKeySym           keysym;
            PopupWindow       popup;
            InputOutputWidget child = null;

            switch ((EventType)(xevent.xany.type__))
            {
            case EventType.ButtonPress:
            {
                // A mouse button was pressed during the grab.
                lock (this)
                {
                    if (lastButton != null)
                    {
                        // We currently have a button window, so
                        // all mouse events should go to it.
                        popup = lastButton;
                    }
                    else
                    {
                        // Determine which popup contains the mouse.
                        // If nothing contains, then use the top.
                        popup = Find(xevent.xbutton.x_root,
                                     xevent.xbutton.y_root, true);
                    }
                    lastButton = popup;
                }
                // Find the child window.
                child = FindChild(popup, xevent.xbutton.x_root,
                                  xevent.xbutton.y_root);
                ChangeEntered(popup, child);
                if (popup != null)
                {
                    // Adjust the co-ordinates and re-dispatch.
                    xevent.xbutton.x__ =
                        (Xlib.Xint)(xevent.xbutton.x_root - popup.x);
                    xevent.xbutton.y__ =
                        (Xlib.Xint)(xevent.xbutton.y_root - popup.y);
                    popup.DispatchEvent(ref xevent);
                    // Re-dispatch to the child window if necessary.
                    if (child != null)
                    {
                        xevent.xbutton.x__ -= child.x;
                        xevent.xbutton.y__ -= child.y;
                        child.DispatchEvent(ref xevent);
                    }
                }
            }
            break;

            case EventType.ButtonRelease:
            {
                // A mouse button was released during the grab.
                lock (this)
                {
                    popup = lastButton;
                    if (popup != null)
                    {
                        // Reset "lastButton" if this is the last
                        // button to be released.
                        ModifierMask mask = ModifierMask.AllButtons;
                        mask &= (ModifierMask) ~((int)ModifierMask.Button1Mask <<
                                                 ((int)(xevent.xbutton.button__) - 1));
                        if ((xevent.xbutton.state & mask) == 0)
                        {
                            lastButton = null;
                        }
                    }
                }
                // Find the child window.
                child = FindChild(popup, xevent.xbutton.x_root,
                                  xevent.xbutton.y_root);
                ChangeEntered(popup, child);
                if (popup != null)
                {
                    // Adjust the co-ordinates and re-dispatch.
                    xevent.xbutton.x__ =
                        (Xlib.Xint)(xevent.xbutton.x_root - popup.x);
                    xevent.xbutton.y__ =
                        (Xlib.Xint)(xevent.xbutton.y_root - popup.y);
                    popup.DispatchEvent(ref xevent);
                    // Re-dispatch to the child window if necessary.
                    if (child != null)
                    {
                        xevent.xbutton.x__ -= child.x;
                        xevent.xbutton.y__ -= child.y;
                        child.DispatchEvent(ref xevent);
                    }
                }
            }
            break;

            case EventType.MotionNotify:
            {
                // The mouse pointer was moved during the grab.
                lock (this)
                {
                    // If there is a last button window, then use
                    // that, otherwise find the one under the mouse.
                    popup = lastButton;
                    if (popup == null)
                    {
                        popup = Find(xevent.xmotion.x_root,
                                     xevent.xmotion.y_root, false);
                    }
                }
                // Find the child window.
                child = FindChild(popup, xevent.xbutton.x_root,
                                  xevent.xbutton.y_root);
                ChangeEntered(popup, child);
                if (popup != null)
                {
                    // Adjust the co-ordinates and re-dispatch.
                    xevent.xmotion.x__ =
                        (Xlib.Xint)(xevent.xmotion.x_root - popup.x);
                    xevent.xmotion.y__ =
                        (Xlib.Xint)(xevent.xmotion.y_root - popup.y);
                    popup.DispatchEvent(ref xevent);
                    // Re-dispatch to the child window if necessary.
                    if (child != null)
                    {
                        xevent.xbutton.x__ -= child.x;
                        xevent.xbutton.y__ -= child.y;
                        child.DispatchEvent(ref xevent);
                    }
                }
            }
            break;

            case EventType.KeyPress:
            {
                // Convert the event into a symbol and a string.
                if (keyBuffer == IntPtr.Zero)
                {
                    keyBuffer = Marshal.AllocHGlobal(32);
                }
                keysym = 0;
                int len = Xlib.XLookupString
                              (ref xevent.xkey, keyBuffer, 32,
                              ref keysym, IntPtr.Zero);
                String str;
                if (len > 0)
                {
                    str = Marshal.PtrToStringAnsi(keyBuffer, len);
                }
                else
                {
                    str = null;
                }

                // Dispatch the event to the top-most popup.
                lock (this)
                {
                    if (list.Length > 0)
                    {
                        popup = list[list.Length - 1];
                    }
                    else
                    {
                        popup = null;
                    }
                }
                if (popup != null)
                {
                    // Find the child window.
                    child = FindFocusedChild(popup);
                    if (child == null)
                    {
                        popup.DispatchKeyEvent
                            ((KeyName)keysym, xevent.xkey.state, str);
                    }
                    else
                    {
                        child.DispatchKeyEvent
                            ((KeyName)keysym, xevent.xkey.state, str);
                    }
                }
            }
            break;

            case EventType.KeyRelease:
            {
                // Convert the event into a symbol and a string.
                if (keyBuffer == IntPtr.Zero)
                {
                    keyBuffer = Marshal.AllocHGlobal(32);
                }
                keysym = 0;
                int len = Xlib.XLookupString
                              (ref xevent.xkey, keyBuffer, 32,
                              ref keysym, IntPtr.Zero);

                // Dispatch the event to the top-most popup.
                lock (this)
                {
                    if (list.Length > 0)
                    {
                        popup = list[list.Length - 1];
                    }
                    else
                    {
                        popup = null;
                    }
                }
                if (popup != null)
                {
                    // Find the child window.
                    child = FindFocusedChild(popup);
                    if (child == null)
                    {
                        popup.DispatchKeyReleaseEvent
                            ((KeyName)keysym, xevent.xkey.state);
                    }
                    else
                    {
                        child.DispatchKeyReleaseEvent
                            ((KeyName)keysym, xevent.xkey.state);
                    }
                }
            }
            break;

            default:
            {
                // Everything else is handled normally.
                base.DispatchEvent(ref xevent);
            }
            break;
            }
        }
	/// <summary>
	/// <para>Method that is called when the mouse wheel is turned.</para>
	/// </summary>
	///
	/// <param name="x">
	/// <para>The X co-ordinate of the pointer position.</para>
	/// </param>
	///
	/// <param name="y">
	/// <para>The Y co-ordinate of the pointer position.</para>
	/// </param>
	///
	/// <param name="button">
	/// <para>The button that was pressed.</para>
	/// </param>
	///
	/// <param name="modifiers">
	/// <para>Other button and shift flags that were active.</para>
	/// </param>
	///
	/// <param name="iDelta">
	/// <para>Delta indicating how far the wheel was turned.</para>
	/// </param>
	protected virtual bool OnButtonWheel(int x, int y, ButtonName button,
									  	   ModifierMask modifiers, int iDelta)
			{
				// Nothing to do in this class.
				return true;
			}
Ejemplo n.º 46
0
 /// <summary>
 /// <para>Method that is called when the mouse wheel is turned.</para>
 /// </summary>
 ///
 /// <param name="x">
 /// <para>The X co-ordinate of the pointer position.</para>
 /// </param>
 ///
 /// <param name="y">
 /// <para>The Y co-ordinate of the pointer position.</para>
 /// </param>
 ///
 /// <param name="button">
 /// <para>The button that was pressed.</para>
 /// </param>
 ///
 /// <param name="modifiers">
 /// <para>Other button and shift flags that were active.</para>
 /// </param>
 ///
 /// <param name="iDelta">
 /// <para>Delta indicating how far the wheel was turned.</para>
 /// </param>
 protected virtual bool OnButtonWheel(int x, int y, ButtonName button,
                                      ModifierMask modifiers, int iDelta)
 {
     // Nothing to do in this class.
     return(true);
 }
	/// <summary>
	/// <para>Method that is called when any mouse button is double-clicked
	/// while the pointer is inside this widget.</para>
	/// </summary>
	///
	/// <param name="x">
	/// <para>The X co-ordinate of the pointer position.</para>
	/// </param>
	///
	/// <param name="y">
	/// <para>The Y co-ordinate of the pointer position.</para>
	/// </param>
	///
	/// <param name="button">
	/// <para>The button that was pressed.</para>
	/// </param>
	///
	/// <param name="modifiers">
	/// <para>Other button and shift flags that were active.</para>
	/// </param>
	protected virtual void OnButtonDoubleClick
				(int x, int y, ButtonName button, ModifierMask modifiers)
			{
				// Nothing to do in this class.
			}
Ejemplo n.º 48
0
 /// <summary>
 /// <para>Method that is called when any mouse button is released
 /// while the pointer is inside this widget.</para>
 /// </summary>
 ///
 /// <param name="x">
 /// <para>The X co-ordinate of the pointer position.</para>
 /// </param>
 ///
 /// <param name="y">
 /// <para>The Y co-ordinate of the pointer position.</para>
 /// </param>
 ///
 /// <param name="button">
 /// <para>The button that was released.</para>
 /// </param>
 ///
 /// <param name="modifiers">
 /// <para>Other button and shift flags that were active.</para>
 /// </param>
 protected virtual void OnButtonRelease(int x, int y, ButtonName button,
                                        ModifierMask modifiers)
 {
     // Nothing to do in this class.
 }
	/// <summary>
	/// <para>Method that is called if a key is pressed when this
	/// widget has the focus.</para>
	/// </summary>
	///
	/// <param name="key">
	/// <para>The key code.</para>
	/// </param>
	///
	/// <param name="modifiers">
	/// <para>Other button and shift flags that were active.</para>
	/// </param>
	///
	/// <param name="str">
	/// <para>The translated string that corresponds to the key, or
	/// <see langword="null"/> if the key does not have a translation.</para>
	/// </param>
	///
	/// <returns>
	/// <para>Returns <see langword="true"/> if the key has been processed
	/// and it should not be passed further up the focus tree.  Returns
	/// <see langword="false"/> if the key should be passed further up
	/// the focus tree.</para>
	/// </returns>
	///
	/// <remarks>The <paramref name="key"/> parameter indicates the X11
	/// symbol that corresponds to the key, which allows cursor control
	/// and function keys to be easily distinguished.  The
	/// <paramref name="str"/> is primarily of use to text
	/// input widgets.</remarks>
	protected virtual bool OnKeyPress(KeyName key,
									  ModifierMask modifiers, String str)
			{
				// Nothing to do in this class.
				return false;
			}
Ejemplo n.º 50
0
 /// <summary>
 /// <para>Method that is called when any mouse button is double-clicked
 /// while the pointer is inside this widget.</para>
 /// </summary>
 ///
 /// <param name="x">
 /// <para>The X co-ordinate of the pointer position.</para>
 /// </param>
 ///
 /// <param name="y">
 /// <para>The Y co-ordinate of the pointer position.</para>
 /// </param>
 ///
 /// <param name="button">
 /// <para>The button that was pressed.</para>
 /// </param>
 ///
 /// <param name="modifiers">
 /// <para>Other button and shift flags that were active.</para>
 /// </param>
 protected virtual void OnButtonDoubleClick
     (int x, int y, ButtonName button, ModifierMask modifiers)
 {
     // Nothing to do in this class.
 }
	/// <summary>
	/// <para>Method that is called when the mouse pointer leaves
	/// this widget.</para>
	/// </summary>
	///
	/// <param name="child">
	/// <para>The child widget that contained the previous or final
	/// position, or <see langword="null"/> if no applicable child
	/// widget.</para>
	/// </param>
	///
	/// <param name="x">
	/// <para>The X co-ordinate of the pointer position.</para>
	/// </param>
	///
	/// <param name="y">
	/// <para>The Y co-ordinate of the pointer position.</para>
	/// </param>
	///
	/// <param name="modifiers">
	/// <para>Button and shift flags that were active.</para>
	/// </param>
	///
	/// <param name="mode">
	/// <para>The notification mode value from the event.</para>
	/// </param>
	///
	/// <param name="detail">
	/// <para>The notification detail value from the event.</para>
	/// </param>
	protected virtual void OnLeave(Widget child, int x, int y,
								   ModifierMask modifiers,
								   CrossingMode mode,
								   CrossingDetail detail)
			{
				// Nothing to do in this class.
			}
Ejemplo n.º 52
0
 /// <summary>
 /// <para>Method that is called when the mouse pointer is moved inside
 /// this widget.</para>
 /// </summary>
 ///
 /// <param name="x">
 /// <para>The X co-ordinate of the pointer position.</para>
 /// </param>
 ///
 /// <param name="y">
 /// <para>The Y co-ordinate of the pointer position.</para>
 /// </param>
 ///
 /// <param name="modifiers">
 /// <para>Other button and shift flags that were active.</para>
 /// </param>
 protected virtual void OnPointerMotion
     (int x, int y, ModifierMask modifiers)
 {
     // Nothing to do in this class.
 }
	// Dispatch a key release event to this widget from the top-level window.
	internal bool DispatchKeyReleaseEvent(KeyName key, ModifierMask modifiers)
			{
				if(FullSensitive)
				{
					return OnKeyRelease(key, modifiers);
				}
				else
				{
					return false;
				}
			}
Ejemplo n.º 54
0
	// Override the pointer motion event from Xsharp.
	protected override void OnPointerMotion
				(int x, int y, ModifierMask modifiers)
			{
				if(sink != null)
				{
					sink.ToolkitMouseMove
						(MapButton(button),
						 MapKey(KeyName.XK_VoidSymbol, modifiers),
						 0, x, y, 0);
				}
			}