/// <summary> /// Removes a widget from the container. /// </summary> /// <param name="widget"> /// The <see cref="ExpressionItemWidget"/> that will be removed /// </param> public void RemoveItem(ExpressionItemWidget widget) { expItemsBox.Remove(widget); if (expItemsBox.Children.Length == 0) { expItemsScroller.HeightRequest = 85; } else { int maxRequest = -1; foreach (ExpressionItemWidget childWidget in expItemsBox.Children) { if (maxRequest < childWidget.HeightRequest) { maxRequest = childWidget.HeightRequest; } childWidget.CheckPosition(); } expItemsScroller.HeightRequest = maxRequest + 20; } }
/// <summary> /// Moves the widget towards the beginning of the expression. /// </summary> /// <param name="widget"> /// A <see cref="ExpressionItemWidget"/> /// </param> public void MoveItemBackwards(ExpressionItemWidget widget) { int position = (expItemsBox[widget] as Gtk.Box.BoxChild).Position; expItemsBox.ReorderChild(widget, position - 1); widget.CheckPosition(); (expItemsBox.Children[position] as ExpressionItemWidget).CheckPosition(); }
/// <summary> /// Removes an item from the container. /// </summary> /// <param name="widget"> /// A <see cref="ExpressionItemWidget"/> /// </param> public void RemoveItem(ExpressionItemWidget widget) { itemOpRelatedItemsBox.Remove(widget); foreach (RelatedItemWidget relWidget in itemOpRelatedItemsBox.Children) { relWidget.CheckPosition(); } }
/// <summary> /// Moves an item towards the end of the container. /// </summary> /// <param name="widget"> /// A <see cref="ExpressionItemWidget"/> /// </param> public void MoveItemFordwards(ExpressionItemWidget widget) { int position = this[widget].Position; itemOpRelatedItemsBox.ReorderChild(widget, position + 1); widget.CheckPosition(); ((RelatedItemWidget)itemOpRelatedItemsBox.Children[position]).CheckPosition(); }
/// <summary> /// Remove an item from this container. /// </summary> /// <param name="widget"> /// A <see cref="ExpressionItemWidget"/> /// </param> public void RemoveItem(ExpressionItemWidget widget) { expGroupItemsBox.Remove(widget); foreach (ExpressionItemWidget childWidget in expGroupItemsBox) { childWidget.CheckPosition(); } CheckHeight(); }
/// <summary> /// <see cref="RelatedItemWidget"/>'s constructor. /// </summary> public RelatedItemWidget(ExpressionItemWidget itemWidget, IExpressionItemContainer container) : base(container) { Glade.XML gladeXml = new XML("mathtextrecognizer.glade", "relatedItemWidgetBase"); gladeXml.Autoconnect(this); this.itemWidget = itemWidget; this.Add(relatedItemWidgetBase); this.relatedItemPlaceholder.Add(itemWidget); this.ShowAll(); }
/// <summary> /// <see cref="RelatedItemWidget"/>'s constructor. /// </summary> public RelatedItemWidget(ExpressionItemWidget itemWidget, IExpressionItemContainer container) :base(container) { Glade.XML gladeXml = new XML("mathtextrecognizer.glade", "relatedItemWidgetBase"); gladeXml.Autoconnect(this); this.itemWidget = itemWidget; this.Add(relatedItemWidgetBase); this.relatedItemPlaceholder.Add(itemWidget); this.ShowAll(); }
/// <summary> /// Adds an item to the container. /// </summary> /// <param name="widget"> /// A <see cref="ExpressionItemWidget"/> /// </param> public void AddItem(ExpressionItemWidget widget) { RelatedItemWidget relatedItemWidget = new RelatedItemWidget(widget, this); widget.SetRelatedMode(); this.itemOpRelatedItemsBox.Add(relatedItemWidget); foreach (RelatedItemWidget relWidget in itemOpRelatedItemsBox.Children) { relWidget.CheckPosition(); } itemOpRelatedItemsScroller.Vadjustment.Value = itemOpRelatedItemsScroller.Vadjustment.Upper; }
/// <summary> /// Adds an item widget to the group. /// </summary> /// <param name="widget"> /// A <see cref="ExpressionItemWidget"/> /// </param> public void AddItem(ExpressionItemWidget widget) { expGroupItemsBox.Add(widget); foreach (ExpressionItemWidget childWidget in expGroupItemsBox) { childWidget.CheckPosition(); } CheckHeight(); expGroupItemsScroller.Hadjustment.Value = expGroupItemsScroller.Hadjustment.Upper; // We need to listen to changes in the childrens' height to // adjust the container's own. widget.HeightRequestChanged += new EventHandler(OnChildWidgetHeightRequestChanged); }
/// <summary> /// Adds an item to the items container. /// </summary> /// <param name="widget"> /// A <see cref="ExpressionItemWidget"/> /// </param> public void AddItem(ExpressionItemWidget widget) { expItemsBox.Add(widget); foreach (ExpressionItemWidget w in expItemsBox.Children) { w.CheckPosition(); } widget.HeightRequestChanged += new EventHandler(OnChildWidgetHeightRequestChanged); // We expand the scroller is it's necessary to show the whole widget. if (widget.HeightRequest + 20 > expItemsScroller.HeightRequest) { expItemsScroller.HeightRequest = widget.HeightRequest + 20; } expItemsScroller.Hadjustment.Value = expItemsScroller.Hadjustment.Upper; }
/// <summary> /// Creates a widget based on the type of the item pased. /// </summary> /// <param name="item"> /// The <see cref="ExpressionItem"/> that will be contained in the /// widget. /// </param> /// <param name="container"> /// The container holding the new widget. /// </param> /// <returns> /// The widget holding the given item. /// </returns> public static ExpressionItemWidget CreateWidget(ExpressionItem item, IExpressionItemContainer container) { ExpressionItemWidget widget = null; if (item.GetType() == typeof(ExpressionGroupItem)) { widget = new ExpressionGroupWidget(container); } else if (item.GetType() == typeof(ExpressionTokenItem)) { widget = new ExpressionTokenWidget(container); } if (item.GetType() == typeof(ExpressionRuleCallItem)) { widget = new ExpressionRuleCallWidget(container); } widget.ExpressionItem = item; return(widget); }
/// <summary> /// Moves the widget towards the start of the item group. /// </summary> /// <param name="widget"> /// A <see cref="ExpressionItemWidget"/> /// </param> public void MoveItemBackwards(ExpressionItemWidget widget) { int position = (expGroupItemsBox[widget] as Gtk.Box.BoxChild).Position; expGroupItemsBox.ReorderChild(widget, position-1); widget.CheckPosition(); (expGroupItemsBox.Children[position] as ExpressionItemWidget).CheckPosition(); }
/// <summary> /// Adds an item widget to the group. /// </summary> /// <param name="widget"> /// A <see cref="ExpressionItemWidget"/> /// </param> public void AddItem (ExpressionItemWidget widget) { expGroupItemsBox.Add(widget); foreach (ExpressionItemWidget childWidget in expGroupItemsBox) { childWidget.CheckPosition(); } CheckHeight(); expGroupItemsScroller.Hadjustment.Value = expGroupItemsScroller.Hadjustment.Upper; // We need to listen to changes in the childrens' height to // adjust the container's own. widget.HeightRequestChanged += new EventHandler(OnChildWidgetHeightRequestChanged); }
/// <summary> /// Remove an item from this container. /// </summary> /// <param name="widget"> /// A <see cref="ExpressionItemWidget"/> /// </param> public void RemoveItem (ExpressionItemWidget widget) { expGroupItemsBox.Remove(widget); foreach (ExpressionItemWidget childWidget in expGroupItemsBox) { childWidget.CheckPosition(); } CheckHeight(); }
/// <summary> /// Moves an item towards the end of the container. /// </summary> /// <param name="widget"> /// A <see cref="ExpressionItemWidget"/> /// </param> public void MoveItemFordwards (ExpressionItemWidget widget) { int position = this[widget].Position; itemOpRelatedItemsBox.ReorderChild(widget, position+1); widget.CheckPosition(); ((RelatedItemWidget)itemOpRelatedItemsBox.Children[position]).CheckPosition(); }
/// <summary> /// Adds an item to the container. /// </summary> /// <param name="widget"> /// A <see cref="ExpressionItemWidget"/> /// </param> private RelatedItemWidget AddItemAux (ExpressionItemWidget widget) { RelatedItemWidget relatedItemWidget = new RelatedItemWidget(widget, this); widget.SetRelatedMode(); this.itemOpRelatedItemsBox.Add(relatedItemWidget); foreach (RelatedItemWidget relWidget in itemOpRelatedItemsBox.Children) { relWidget.CheckPosition(); } itemOpRelatedItemsScroller.Vadjustment.Value = itemOpRelatedItemsScroller.Vadjustment.Upper; return relatedItemWidget; }
/// <summary> /// Adds an item to the items container. /// </summary> /// <param name="widget"> /// A <see cref="ExpressionItemWidget"/> /// </param> public void AddItem (ExpressionItemWidget widget) { expItemsBox.Add(widget); foreach (ExpressionItemWidget w in expItemsBox.Children) { w.CheckPosition(); } widget.HeightRequestChanged += new EventHandler(OnChildWidgetHeightRequestChanged); // We expand the scroller is it's necessary to show the whole widget. if(widget.HeightRequest + 20 > expItemsScroller.HeightRequest) expItemsScroller.HeightRequest = widget.HeightRequest + 20; expItemsScroller.Hadjustment.Value = expItemsScroller.Hadjustment.Upper; }
/// <summary> /// Removes a widget from the container. /// </summary> /// <param name="widget"> /// The <see cref="ExpressionItemWidget"/> that will be removed /// </param> public void RemoveItem(ExpressionItemWidget widget) { expItemsBox.Remove(widget); if(expItemsBox.Children.Length ==0) { expItemsScroller.HeightRequest = 85; } else { int maxRequest = -1; foreach (ExpressionItemWidget childWidget in expItemsBox.Children) { if (maxRequest < childWidget.HeightRequest) maxRequest = childWidget.HeightRequest; childWidget.CheckPosition(); } expItemsScroller.HeightRequest = maxRequest + 20; } }
/// <summary> /// Removes an item from the container. /// </summary> /// <param name="widget"> /// A <see cref="ExpressionItemWidget"/> /// </param> public void RemoveItem (ExpressionItemWidget widget) { itemOpRelatedItemsBox.Remove(widget); foreach (RelatedItemWidget relWidget in itemOpRelatedItemsBox.Children) { relWidget.CheckPosition(); } }