/// <summary>
		/// <see cref="ExpressionRuleCallWidget"/>'s constructor.
		/// </summary>
		/// <param name="container">
		/// A <see cref="IExpressionItemContainer"/>
		/// </param>
		public ExpressionGroupWidget(IExpressionItemContainer container) 
			: base(container)
		{
			// We load the glade widgets.
			Glade.XML gladeXml = new XML("mathtextrecognizer.glade",
			                             "expressionGroupWidgetBase");
			
			gladeXml.Autoconnect(this);
			
			this.Add(expressionGroupWidgetBase);
			
			this.HeightRequest = expressionGroupWidgetBase.HeightRequest;
			
			// The menu is created.
			addItemMenu = new AddSubItemMenu(this);
			
			// We tell the widget to redraw itself when the size is changed,
			// fixs some graphical glitches.
			expGroupItemsScroller.Hadjustment.ValueChanged +=
				delegate(object sender, EventArgs args)
			{
				expGroupItemsScroller.QueueDraw();
			};
			
			this.ShowAll();
		}
		/// <summary>
		///	<see cref="ExpressionItemWidget"/>'s constructor.
		/// </summary>
		/// <param name="container">
		/// The item widget container.
		/// </param>
		public ExpressionItemWidget(IExpressionItemContainer container) 
			: base(0.5f, 0.5f, 1,1)
		{
			this.container = container;
			
			options = new ExpressionItemOptions();
		}
		/// <summary>
		/// <see cref="AddSubItemMenu"/>'s constructor.
		/// </summary>
		/// <param name="container">
		/// A <see cref="IExpressionItemContainer"/> 
		/// Where the elements created by the menu items
		/// will be stored.
		/// </param>
		public AddSubItemMenu(IExpressionItemContainer container)
		{
			Glade.XML gladeXml =new XML("mathtextrecognizer.glade",
			                            "addExpressionItemMenu");
			
			gladeXml.Autoconnect(this);				
			
			this.container = container;
		}
		/// <summary>
		/// <see cref="ExpressionRuleCallWidget"/>'s constructor.
		/// </summary>
		/// <param name="container">
		/// A <see cref="IExpressionItemContainer"/>
		/// </param>
		public ExpressionRuleCallWidget(IExpressionItemContainer container) 
			: base(container)
		{
			Glade.XML gladeXml = new XML("mathtextrecognizer.glade",
			                             "expressionRuleWidgetBase");
			
			gladeXml.Autoconnect(this);
			
			this.Add(expressionRuleWidgetBase);
			
			this.HeightRequest = expressionRuleWidgetBase.HeightRequest;
			
			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>
		/// 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;
		}