/// <summary>
        /// Adds a new rule to the rule set.
        /// </summary>
        /// <param name="sender">
        /// A <see cref="System.Object"/>
        /// </param>
        /// <param name="args">
        /// A <see cref="EventArgs"/>
        /// </param>
        private void OnAddSynRuleBtnClicked(object sender, EventArgs args)
        {
            SyntacticalRuleEditorDialog dialog =
                new SyntacticalRuleEditorDialog(this);

            ResponseType res = dialog.Show();

            if (res == ResponseType.Ok)
            {
                AddRule(dialog.Rule);
            }

            dialog.Destroy();
        }
        /// <summary>
        /// <see cref="SyntacticalExpressionWidget"/>'s constructor.
        /// </summary>
        public SyntacticalExpressionWidget(SyntacticalRuleEditorDialog dialog)
            : base(0, 0, 1, 1)
        {
            Glade.XML gladeXml = new XML("mathtextrecognizer.glade",
                                         "syntacticalExpressionWidgetBase");

            gladeXml.Autoconnect(this);

            this.dialog = dialog;

            this.Add(syntacticalExpressionWidgetBase);

            InitializeWidgets();

            this.CanFocus = true;

            this.ShowAll();
        }
		/// <summary>
		/// <see cref="SyntacticalExpressionWidget"/>'s constructor.
		/// </summary>
		public SyntacticalExpressionWidget(SyntacticalRuleEditorDialog dialog) 
			: base(0, 0, 1, 1)			
		{
			Glade.XML gladeXml = new XML("mathtextrecognizer.glade",			     
			                             "syntacticalExpressionWidgetBase");
			
			gladeXml.Autoconnect(this);
			
			this.dialog =  dialog;			
			
			this.Add(syntacticalExpressionWidgetBase);
			
			InitializeWidgets();
			
			this.CanFocus = true;
			
			this.ShowAll();
		}
        /// <summary>
        /// Launches the rule editor dialog for the selected rule.
        /// </summary>
        /// <param name="sender">
        /// A <see cref="System.Object"/>
        /// </param>
        /// <param name="args">
        /// A <see cref="EventArgs"/>
        /// </param>
        private void OnSynRuleEditBtnClicked(object sender, EventArgs args)
        {
            SyntacticalRuleEditorDialog dialog =
                new SyntacticalRuleEditorDialog(this);

            TreeIter iter;

            synRulesTree.Selection.GetSelected(out iter);

            dialog.Rule = synRulesModel.GetValue(iter, 2) as  SyntacticalRule;

            ResponseType res = dialog.Show();

            if (res == ResponseType.Ok)
            {
                SyntacticalRule rule  = dialog.Rule;
                string []       parts = rule.ToString().Split(':');
                synRulesModel.SetValue(iter, 0, parts[0] + " :");
                synRulesModel.SetValue(iter, 1, parts[1]);
                synRulesModel.SetValue(iter, 2, rule);
            }

            dialog.Destroy();
        }
		/// <summary>
		/// Launches the rule editor dialog for the selected rule.
		/// </summary>
		/// <param name="sender">
		/// A <see cref="System.Object"/>
		/// </param>
		/// <param name="args">
		/// A <see cref="EventArgs"/>
		/// </param>
		private void OnSynRuleEditBtnClicked(object sender, EventArgs args)
		{
			SyntacticalRuleEditorDialog dialog = 
				new SyntacticalRuleEditorDialog(this);
			
			TreeIter iter;
			synRulesTree.Selection.GetSelected(out iter);
			
			dialog.Rule = synRulesModel.GetValue(iter, 2) as  SyntacticalRule;
			
			ResponseType res = dialog.Show();
			if(res == ResponseType.Ok)
			{			
				SyntacticalRule rule = dialog.Rule;
				string [] parts = rule.ToString().Split(':');
				synRulesModel.SetValue(iter, 0,parts[0] +" :");
				synRulesModel.SetValue(iter, 1,parts[1]);
				synRulesModel.SetValue(iter, 2,rule);
			}
			
			dialog.Destroy();
		}
		/// <summary>
		/// Adds a new rule to the rule set.
		/// </summary>
		/// <param name="sender">
		/// A <see cref="System.Object"/>
		/// </param>
		/// <param name="args">
		/// A <see cref="EventArgs"/>
		/// </param>
		private void OnAddSynRuleBtnClicked(object sender, EventArgs args)
		{
			SyntacticalRuleEditorDialog dialog = 
				new SyntacticalRuleEditorDialog(this);
			
			ResponseType res = dialog.Show();
			if(res == ResponseType.Ok)
			{
				AddRule(dialog.Rule);
			}
			
			dialog.Destroy();
		}