/// <summary> Insert a widget into the list of children. </summary> /// <param name="index"> The preferred index to insert at. <see cref="System.Int32"/> </param> /// <param name="child"> The widget to add. <see cref="XrwRectObj"/> </param> public override void InsertChild(int index, XrwRectObj child) { if (!(child is XrwRadio)) { if (XrwApplicationSettings.VERBOSE_OUTPUT_TO_CONSOLE) { Console.WriteLine(CLASS_NAME + "::AddChild (); Parameter 'child' must be of type XrwRadio!"); } } if (child is XrwRadio) { if (_children.Count == 0) { (child as XrwRadio).Pressed = true; } else { (child as XrwRadio).Pressed = false; } } base.InsertChild(index, child); if (child is XrwRadio) { (child as XrwRadio).SwitchedOn += HandleChildSwitchedOn; } }
/// <summary> Add a widget, acting as page, to the list of children. </summary> /// <param name="child"> The widget to add. <see cref="XrwRectObj"/> </param> public override void AddChild(XrwRectObj child) { if (child == null) { return; } XrwRadio tab = new XrwRadio(_display, _screenNumber, _window, "__" + (_tabBox.Children.Count).ToString() + "__", null, false, null, false); _tabBox.InsertChild(_tabBox.Children.Count - 1, tab); if (_tabBox.Children.Count == 2) { tab.Pressed = true; } tab.SwitchedOn += HandleSelectionChange; for (int count = 0; count < _tabBox.Children.Count; count++) { if ((_tabBox.Children[count] is XrwVisibleRectObj) && count < _tabBox.Children.Count - 1) { (_tabBox.Children[count] as XrwVisibleRectObj).FrameTypeExt = TFrameTypeExt.RaisedTopTab; } if ((_tabBox.Children[count] is XrwVisibleRectObj) && count == _tabBox.Children.Count - 1) { (_tabBox.Children[count] as XrwVisibleRectObj).FrameTypeExt = TFrameTypeExt.UnsunkenTopTabTail; } } _pageStack.AddChild(child); }
/// <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; }
// ############################################################################### // ### D E S T R U C T I O N // ############################################################################### #region Destruction #endregion // ############################################################################### // ### P R O P E R T I E S // ############################################################################### #region Properties #endregion // ############################################################################### // ### M E T H O D S // ############################################################################### #region Methods #endregion #region Event handler /// <summary> Handle the ConfigureEvent event. </summary> /// <param name="e"> The event data. <see cref="XawClientMessageEvent"/> </param> /// <remarks> Set XawClientMessageEvent. Set result to nonzero to stop further event processing. </remarks> public virtual void OnConfigure(XrwConfigureEvent e) { // Prevent useless reconfiguration, if widt / height did not change. if (_assignedSize.Width != (int)e.Event.width || _assignedSize.Height != (int)e.Event.height) { _assignedPosition.X = (int)e.Event.x; _assignedPosition.Y = (int)e.Event.y; _assignedSize.Width = (int)e.Event.width; _assignedSize.Height = (int)e.Event.height; for (int cntChildren = 0; cntChildren < _children.Count; cntChildren++) { XrwRectObj widget = _children[cntChildren]; // Every direct child can occupy the complete size. GeometryManagerAccess.SetAssignedGeometry(widget, new TPoint(0, 0), _assignedSize); } } // Position can change without the nessesarity to calculate a new geometry. else { _assignedPosition.X = (int)e.Event.x; _assignedPosition.Y = (int)e.Event.y; } }
/// <summary> Add a widget to the list of children. </summary> /// <param name="child"> The widget to add. <see cref="XrwRectObj"/> </param> public override void AddChild(XrwRectObj child) { if (child == null) { return; } if (_children.Count == 0) { child.Show(); } else if (child.Shown) { for (int count = 0; count < _children.Count; count++) { _children[count].Hide(); } } else { child.Hide(); } _children.Add(child); child._parent = this; }
/// <summary> Handle the Motion event. </summary> /// <param name="source"> The widget, the Motion event is assigned to. <see cref="XrwRectObj"/> </param> /// <param name="e"> The event data. <see cref="XMotionEvent"/> </param> /// <remarks> Set XrwMotionEvent. Set result to nonzero to stop further event processing. </remarks> void HandleMotionDefault(XrwRectObj source, XrwMotionEvent 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 + "::HandleButtonPress () 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) { if (sme.Focused != true) { sme.Focused = true; XrwObject.SendExposeEvent(_display, sme.Window, Parent.Window); } } else { if (sme.Focused != false) { sme.Focused = false; XrwObject.SendExposeEvent(_display, sme.Window, Parent.Window); } } } } e.Result = 1; }
/// <summary> Handle the switched off event. </summary> /// <param name="selected"> The child widget, the SelectionChange event sets visible. <see cref="XrwRectObj"/> </param> public virtual void OnSelectionChanged(XrwRectObj selected) { SelectionChangedDelegate selectionChanged = SelectionChanged; if (selectionChanged != null) { selectionChanged(this, selected); } }
/// <summary> Handle the Enter event. </summary> /// <param name="source"> The widget, the Enter event is assigned to. <see cref="XrwRectObj"/> </param> /// <param name="e"> The event data. <see cref="XrwCrossingEvent"/> </param> /// <remarks> Set XrwCrossingEvent. Set result to nonzero to stop further event processing. </remarks> protected void HandleEnterDefault(XrwRectObj source, XrwCrossingEvent e) { _focused = true; if (XrwObject.SendExposeEvent(_display, _window, _window) == 0) { Console.WriteLine(CLASS_NAME + "::HandleFocusIn () ERROR. Can not send expose event."); } e.Result = 1; }
/// <summary> Remove a widget from the list of children. </summary> /// <param name="child"> The widget to remove. <see cref="XrwRectObj"/> </param> public virtual void RemoveChild(XrwRectObj child) { if (child == null) { return; } _children.Remove(child); child._parent = null; }
/// <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); }
/// <summary> Add a widget to the list of children. </summary> /// <param name="child"> The widget to add. <see cref="XrwRectObj"/> </param> public virtual void AddChild(XrwRectObj child) { if (child == null) { return; } _children.Add(child); child._parent = this; }
/// <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; }
/// <summary> Remove a widget from the list of children. </summary> /// <param name="child"> The widget to remove. <see cref="XrwRectObj"/> </param> public override void RemoveChild(XrwRectObj child) { if (!(child is XrwRadio)) { if (XrwApplicationSettings.VERBOSE_OUTPUT_TO_CONSOLE) { Console.WriteLine(CLASS_NAME + "::RemoveChild (); Parameter 'child' must be of type XrwRadio!"); } throw new ArgumentException("Parameter 'child' must be of type XrwRadio!", "child"); } throw new NotImplementedException(); }
/// <summary> Handle the SwitchedOn event. </summary> /// <param name="source"> The widget, the SwitchedOn event is assigned to. <see cref="XrwRectObj"/> </param> protected void HandleChildSwitchedOn(XrwRectObj source) { for (int count = 0; count < _children.Count; count++) { if (_children[count] == source) { continue; } if (_children[count] is XrwRadio) { (_children[count] as XrwRadio).Pressed = false; } } }
/// <summary> Handle the Leave event. </summary> /// <param name="source"> The widget, the Leave event is assigned to. <see cref="XrwRectObj"/> </param> /// <param name="e"> The event data. <see cref="XrwCrossingEvent"/> </param> /// <remarks> Set XrwCrossingEvent. Set result to nonzero to stop further event processing. </remarks> protected void HandleLeaveDefault(XrwRectObj source, XrwCrossingEvent e) { _focused = false; if (!(this is XrwToggle) && !(this is XrwRadio)) { _pressed = false; OnSwitchedOff(); } if (XrwObject.SendExposeEvent(_display, _window, _window) == 0) { Console.WriteLine(CLASS_NAME + "::HandleFocusOut () ERROR. Can not send expose event."); } e.Result = 1; }
/// <summary> Insert a widget into the list of children. </summary> /// <param name="index"> The preferred index to insert at. <see cref="System.Int32"/> </param> /// <param name="child"> The widget to insert. <see cref="XrwRectObj"/> </param> public virtual void InsertChild(int index, XrwRectObj child) { if (child == null) { return; } if (index < 0 || index > _children.Count) { index = _children.Count; } _children.Insert(index, child); child._parent = null; }
/// <summary> Set the assigned position and size, calculated by the geometry management. </summary> /// <param name="rectObj"> The rectangle object to set the assigned position and size for. <see cref="XrwRectObj"/> </param> /// <param name="position"> The assigned position to set. <see cref="TPoint"/> </param> /// <param name="size"> The assigned position to set. <see cref="TSize"/> </param> public static void SetAssignedGeometry(XrwRectObj rectObj, TPoint position, TSize size) { if (rectObj == null) { Console.WriteLine("GeometryManagerAccess::SetAssignedGeometry () ERROR: Argument null: rectObj"); return; } // Fixed size always has priority! if (rectObj.IsFixedWidth == true) { size.Width = rectObj.FixedSize.Width; } if (rectObj.IsFixedWidth == true) { size.Height = rectObj.FixedSize.Height; } rectObj._assignedSize = size; if (rectObj.HasOwnWindow && (rectObj is XrwVisibleRectObj)) { // Transfer the geometry to the underlaying window. XrwVisibleRectObj visibleRect = rectObj as XrwVisibleRectObj; if (visibleRect.Display != IntPtr.Zero && visibleRect.Window != IntPtr.Zero) { // This call causes a ConfigureNotify event. X11lib.XMoveResizeWindow(visibleRect.Display, visibleRect.Window, (TInt)position.X, (TInt)position.Y, (TUint)size.Width, (TUint)size.Height); visibleRect._assignedPosition = new TPoint(0, 0); } else { throw new AccessViolationException("XrwVisibleRectObj or inherited widget without display or window."); } } else { rectObj._assignedPosition = position; } // Child should be prevented from overwriting parent's border. size.Width -= 2 * rectObj.BorderWidth; size.Height -= 2 * rectObj.BorderWidth; rectObj.CalculateChildLayout(position, size); }
/// <summary> Handle the Leave event. </summary> /// <param name="source"> The widget, the FocusIn event is assigned to. <see cref="XrwRectObj"/> </param> /// <param name="e"> The event data. <see cref="XCrossingEvent"/> </param> /// <remarks> Set XrwCrossingEvent. Set result to nonzero to stop further event processing. </remarks> private void HandleLeaveDefault(XrwRectObj source, XrwCrossingEvent e) { _focused = false; XrwApplicationShell appShell = ApplicationShell; if (appShell != null) { if (XrwObject.SendExposeEvent(_display, _window, _window) == 0) { Console.WriteLine(CLASS_NAME + "::HandleFocusOut () ERROR. Can not send expose event."); } } else { Console.WriteLine(CLASS_NAME + "::HandleFocusOut () ERROR. Can not investigate application shell."); } e.Result = 1; }
/// <summary> Show indicated child and hide formerly shown child. </summary> /// <param name="child"> The child to show. <see cref="XrwRectObj"/> </param> public void ShowChild(XrwRectObj child) { if (child == null) { return; } if (child == this.ShownChild) { return; } if (!_children.Contains(child)) { return; } ShownChild.Hide(); child.Show(); }
/// <summary> Handle the FocusOut event. </summary> /// <param name="source"> The widget, the FocusOut event is assigned to. <see cref="XrwRectObj"/> </param> /// <param name="e"> The event data. <see cref="XawFocusChangeEvent"/> </param> /// <remarks> Set XrwFocusChangeEvent. Set result to nonzero to stop further event processing. </remarks> void HandleFocusOutDefault(XrwRectObj source, XrwFocusChangeEvent e) { XrwApplicationShell appShell = ApplicationShell; if (appShell != null) { appShell.RemoveChild(this); _parent = appShell; } else { Console.WriteLine(CLASS_NAME + "::HandleFocusOut () ERROR. Can not investigate application shell."); } if (this._shown) { this.Hide(); } e.Result = 1; }
/// <summary> Handle the SelectionChange event. </summary> /// <param name="selected"> The child widget, the SelectionChange event sets visible. <see cref="XrwRectObj"/> </param> protected void HandleSelectionChange(XrwRectObj selected) { int index = 0; for (int count = 0; count < _tabBox.Children.Count; count++) { if (_tabBox.Children[count] == selected) { break; } index++; } if (_tabBox.Children[index] == selected) { if (index <= _pageStack.Children.Count) { _pageStack.ShowChild(_pageStack.Children[index]); //_pageStack.CalculateChildLayout (_pageStack.AssignedPosition, _pageStack.AssignedSize); OnSelectionChanged(selected); } } }
/// <summary> Check wether the indicated widget is a child. </summary> /// <param name="child"> The widget to test. <see cref="XrwRectObj"/> </param> /// <returns> True, if indicated widget is a child, or false otherwise. <see cref="System.Boolean"/> </returns> public virtual bool HasChild(XrwRectObj child) { return(_children.Contains(child)); }
// ############################################################################### // ### 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; }
/// <summary> Provide original base class method AddChild(). </summary> /// <param name="child"> The widget to add. <see cref="XrwRectObj"/> </param> protected void BaseAddChild(XrwRectObj child) { base.AddChild(child); }
/// <summary> Handle the FocusIn event. </summary> /// <param name="source"> The widget, the FocusIn event is assigned to. <see cref="XrwRectObj"/> </param> /// <param name="e"> The event data. <see cref="XawFocusChangeEvent"/> </param> /// <remarks> Set XrwFocusChangeEvent. Set result to nonzero to stop further event processing. </remarks> void HandleFocusInDefault(XrwRectObj source, XrwFocusChangeEvent e) { e.Result = 1; }
public ChildData(XrwRectObj widget, TSize size) { Widget = widget; Size = size; }
// ############################################################################### // ### P R O P E R T I E S // ############################################################################### #region Properties #endregion // ############################################################################### // ### M E T H O D S // ############################################################################### #region XrwRectObj overrides #endregion #region XrwComposite overrides /// <summary> Add a widget to the list of children. </summary> /// <param name="child"> The widget to add. <see cref="XrwRectObj"/> </param> public override void AddChild(XrwRectObj child) { this.InsertChild(-1, child); }