示例#1
0
        private void GenerateContent(ref Gtk.Table tableSystem, string label, int xPos, Condition cd,bool isResolution)
        {
            ListStore lstorePlatform = new ListStore(typeof(int),typeof(int),typeof(string));

            int selectRule = 0;
            if (conditionRules_Old.Count > 0) {
                ConditionRule cr = conditionRules_Old.Find(x => x.ConditionId == cd.Id);
                if (cr != null)
                    selectRule = cr.RuleId;
            }

            Label lblPlatform = new Label(label);
            lblPlatform.Name = "lbl_" + label;
            lblPlatform.Xalign = 1;
            lblPlatform.Yalign = 0.5F;

            ComboBox cboxPlatform = new ComboBox();
            cboxPlatform.Name = "cd_" + label;

            CellRendererText textRenderer = new CellRendererText();
            cboxPlatform.PackStart(textRenderer, true);
            cboxPlatform.AddAttribute(textRenderer, "text", 2);

            cboxPlatform.WidthRequest = 200;
            cboxPlatform.Model = lstorePlatform;
            cboxPlatform.Changed += delegate(object sender, EventArgs e) {

                    if (sender == null)
                        return;

                    ComboBox combo = sender as ComboBox;

                    TreeIter iter;
                    if (combo.GetActiveIter(out iter)) {
                        int ruleId = (int)combo.Model.GetValue(iter, 0);
                        int condId = (int)combo.Model.GetValue(iter, 1);
                            if (ruleId != 0){
                            ConditionRule cr = conditionRules.Find(x => x.ConditionId == condId);//cd.Id);
                            if (cr != null)
                                cr.RuleId = ruleId;
                            else
                                conditionRules.Add(new ConditionRule(condId,ruleId));
                        }
                        else {
                            ConditionRule cr = conditionRules.Find(x => x.ConditionId == condId);//cd.Id);
                            if (cr != null){
                                conditionRules.Remove(cr);
                            }
                        }
                    }

                };

            tableSystem.Attach(lblPlatform, 0, 1, (uint)(xPos - 1), (uint)xPos, AttachOptions.Shrink, AttachOptions.Shrink, 2, 2);
            tableSystem.Attach(cboxPlatform, 1, 2, (uint)(xPos - 1), (uint)xPos, AttachOptions.Shrink, AttachOptions.Shrink, 2, 2);

            TreeIter selectIter = lstorePlatform.AppendValues(0, cd.Id, "Unset");

            foreach (Rule rl in cd.Rules){

                if(!isResolution){

                    if (rl.Id == selectRule)
                        selectIter = lstorePlatform.AppendValues(rl.Id, cd.Id, rl.Name);
                    else
                        lstorePlatform.AppendValues(rl.Id, cd.Id, rl.Name);
                } else {
                    string name  = String.Format("{0} ({1}x{2})",rl.Name,rl.Width,rl.Height);
                    if (rl.Id == selectRule)
                        selectIter = lstorePlatform.AppendValues(rl.Id, cd.Id, name);
                    else
                        lstorePlatform.AppendValues(rl.Id, cd.Id, name);
                }
            }

            cboxPlatform.SetActiveIter(selectIter);
        }
		// TODO: Centralize duplicated code
		private void AddRow (Gtk.Table table, Gtk.Widget widget, string labelText, uint row)
		{
			Gtk.Label l = new Gtk.Label (labelText);
			l.UseUnderline = true;
			l.Xalign = 0.0f;
			l.Show ();
			table.Attach (l, 0, 1, row, row + 1,
			              Gtk.AttachOptions.Fill,
			              Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill,
			              0, 0);

			widget.Show ();
			table.Attach (widget, 1, 2, row, row + 1,
			              Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill,
			              Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill,
			              0, 0);

			l.MnemonicWidget = widget;

			// TODO: Tooltips
		}
示例#3
0
		void AttachChildren (Gtk.Table table, uint row, uint col)
		{
			if (icon != null) {
				table.Attach (icon, col, col + 1, row, row + 1);
				Gtk.Table.TableChild tc = (Gtk.Table.TableChild) table [icon];
				if (!editing)
					tc.YPadding = itemSpacing;
			}
			if (label != null) {
				table.Attach (label, col + 1, col + 2, row, row + 1);
				Gtk.Table.TableChild tc = (Gtk.Table.TableChild) table [label];
				if (!editing)
					tc.YPadding = itemSpacing;
				label.GrabFocus ();
			}
			if (accel != null)
				table.Attach (accel, col + 2, col + 3, row, row + 1);

			if (minWidth > 0 && label != null) {
				if (label.SizeRequest().Width < minWidth)
					label.WidthRequest = minWidth;
			}
			
			bool sens = editing || node.Action == null || node.Action.GtkAction.Sensitive;
			if (icon != null)
				icon.Sensitive = sens;
			if (label != null)
				label.Sensitive = sens;
			if (accel != null)
				accel.Sensitive = sens;
		}
示例#4
0
		public void Attach (Gtk.Table table, uint row, uint col)
		{
			table.Attach (this, col, col + 3, row, row + 1);
			Show ();
			AttachChildren (table, row, col);
		}
示例#5
0
		private void Rebuild(Gtk.Table table, uint[][][] positions, GedcomIndividualRecord activePerson, GedcomFamilyLink[] lst)
		{
			foreach (Gtk.Widget child in table.Children)
			{
				child.Destroy();
			}
			table.Resize(1,1);
			
			uint xmax = 0;
			uint ymax = 0;
			
			for (int i = 0; i < positions.Length; i ++)
			{
				uint x = positions[i][0][0] + 1;
				uint y = positions[i][0][1] + 1;
				uint w = positions[i][0][2];
				uint h = positions[i][0][3];
				
				GedcomFamilyLink famLink = (GedcomFamilyLink)lst[i];
				if (famLink == null)
				{	
					PedigreeBox pw = new PedigreeBox(null, 0, null);
					
					if (i > 0 && lst[((i+1)/2)-1] != null)
					{
						GedcomFamilyLink missingFamLink = (GedcomFamilyLink)lst[((i+1)/2)-1];
						
						// missing parent button
						pw.ForceMouseOver = true;
					}
					// FIXME: both conditions do the same thing, double checking
					// the gramps code it doesn't appear to be a mistake in porting
					if (positions[i][0][2] > 1)
					{
						table.Attach(pw,x, x+w, y, y+h, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 0, 0);
					}
					else
					{
						table.Attach(pw,x, x+w, y, y+h, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 0, 0);
					}
					
					xmax = (uint)Math.Max(xmax, x + w);
					ymax = (uint)Math.Max(ymax, y + h);
				}
				else
				{
					GedcomIndividualRecord indi = (GedcomIndividualRecord)_database[famLink.Indi];
					
					if (_showImages && i < ((positions.Length - 1) / 2) && positions[i][0][3] > 1)
					{
						
					}
					
					PedigreeBox pw = new PedigreeBox(indi, positions[i][0][3], null);
					pw.SelectIndividual += PedigreeBox_SelectIndividual;
					
					if (positions[i][0][3] < 7)
					{
						pw.TooltipMarkup = pw.FormatPerson(11, true);
					}
					
					if (positions[i][0][2] > 1)
					{
						table.Attach(pw, x, x+w, y, y+h, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, 0, 0);
					}
					else
					{
						table.Attach(pw, x, x+w, y, y+h, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 0, 0);
					}
					
					xmax = (uint)Math.Max(xmax, x + w);
					ymax = (uint)Math.Max(ymax, y + h);
				}
				
				// connection lines
				if (positions[i].Length > 1)
				{
					// separate boxes for father and mother
					x = positions[i][1][0] + 1;
					y = positions[i][1][1] + 1;
					w = 1;
					h = positions[i][1][2];
					
					Gtk.DrawingArea line = new Gtk.DrawingArea();
					line.ExposeEvent += Line_Expose;
					bool rela = false;
					if (famLink != null && (famLink.Pedigree == PedegreeLinkageType.Birth || famLink.Pedigree == PedegreeLinkageType.Unknown))
					{
						line.AddEvents((int)Gdk.EventMask.ButtonPressMask);
						rela = true;
					}
					Utility.Pair<int, bool> lineData = new Pair<int,bool>();
					lineData.First = i * 2 + 1;
					lineData.Second = rela;
					_lines[line] = lineData;
					
					table.Attach(line, x, x + w, y, y + h, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 0, 0);
					
					xmax = (uint)Math.Max(xmax, x + w);
					ymax = (uint)Math.Max(ymax, y + h);
					
					x = positions[i][2][0] + 1;
					y = positions[i][2][1] + 1;
					w = 1;
					h = positions[i][2][2];
					
					line = new Gtk.DrawingArea();
					line.ExposeEvent += Line_Expose;
					rela = false;
					if (famLink != null && (famLink.Pedigree == PedegreeLinkageType.Birth || famLink.Pedigree == PedegreeLinkageType.Unknown))
					{
						line.AddEvents((int)Gdk.EventMask.ButtonPressMask);
						rela = true;
					}
					lineData = new Pair<int,bool>();
					lineData.First = i * 2 + 2;
					lineData.Second = rela;
					_lines[line] = lineData;
					
					table.Attach(line, x, x + w, y, y + h, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 0, 0);
					
					xmax = (uint)Math.Max(xmax, x + w);
					ymax = (uint)Math.Max(ymax, y + h);
				}
				
				// marriage data
				if (_showMarriageData && positions[i].Length > 3)
				{
					string  text = string.Empty;
					if (famLink != null && (famLink.Pedigree == PedegreeLinkageType.Birth || famLink.Pedigree == PedegreeLinkageType.Unknown))
					{
						text = "foo";
					}
					Gtk.Label label = new Gtk.Label(text);
					label.Justify = Gtk.Justification.Left;
					label.LineWrap = true;
					label.SetAlignment(0.1F, 0.5F);
					
					x = positions[i][3][0] + 1;
					y = positions[i][3][1] + 1;
					w = positions[i][3][2];
					h = positions[i][3][3];
					
					table.Attach(label, x, x + w, y, y + h, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 0, 0);
				}
			}
			
			// nav arrows
			if (lst[0] != null)
			{
				Gtk.Button arrowButton = new Gtk.Button();
				arrowButton.Add(new Gtk.Arrow(Gtk.ArrowType.Left, Gtk.ShadowType.In));
				
				arrowButton.Sensitive = (_dummyFam.Children.Count > 0);
				arrowButton.Clicked += ArrowButton_Click;
				if (arrowButton.Sensitive)
				{
					arrowButton.TooltipText = "Jump to child...";
				}
				
				uint ymid = (uint)Math.Floor(ymax / 2.0F);
				table.Attach(arrowButton, 0, 1, ymid, ymid + 1, 0, 0, 0, 0);
				
				// father
				arrowButton = new Gtk.Button();
				arrowButton.Add(new Gtk.Arrow(Gtk.ArrowType.Right, Gtk.ShadowType.In));
				arrowButton.Sensitive = (lst[1] != null);
				arrowButton.Clicked += FatherButton_Click;
				if (arrowButton.Sensitive)
				{
					arrowButton.TooltipText = "Jump to father";
				}
				
				ymid = (uint)Math.Floor(ymax / 4.0F);
				table.Attach(arrowButton, xmax, xmax + 1, ymid - 1, ymid + 2, 0, 0, 0, 0);
				
				// mother
				arrowButton = new Gtk.Button();
				arrowButton.Add(new Gtk.Arrow(Gtk.ArrowType.Right, Gtk.ShadowType.In));
				arrowButton.Sensitive = (lst[2] != null);
				arrowButton.Clicked += MotherButton_Click;
				if (arrowButton.Sensitive)
				{
					arrowButton.TooltipText = "Jump to mother";
				}
				
				ymid = (uint)Math.Floor(ymax / 4.0F * 3);
				table.Attach(arrowButton, xmax, xmax + 1, ymid - 1, ymid + 2, 0, 0, 0, 0);
				
				
				// dummy widgets to allow pedigree to be centred
				Gtk.Label l = new Gtk.Label(string.Empty);
				table.Attach(l, 0, 1, 0, 1, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, 0, 0);
				l = new Gtk.Label(string.Empty);
				table.Attach(l, xmax, xmax + 1, ymax, ymax + 1, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, 0, 0);
	
				table.ShowAll();
			}
		}	
示例#6
0
        private void populatePlayers(Gtk.Table table)
        {
            //combo.Clear();
            Gtk.RadioButton btn = null;
            Gtk.RadioButton firstbtn = null;
            Gtk.CheckButton aitoggle = null;

            uint row = 0;
            ArrayList players = Game.GetInstance().Players;
            foreach (Player player in players)
            {
            if (firstbtn == null)
            {
                firstbtn = new Gtk.RadioButton(null, player.Name);
                firstbtn.Active = false;
                btn = firstbtn;
            } else {
                btn = new Gtk.RadioButton(firstbtn, player.Name);
            }

            aitoggle = new Gtk.CheckButton("AI");
            Game.putObjectDataIn(aitoggle, player.Name);

            table.Attach(btn, 0, 1, row, row+1);
            table.Attach(aitoggle, 1, 2, row, row+1);

            ++row;
            btn.Toggled += on_Player_toggled;
            aitoggle.Toggled += on_AI_toggled;

            }
        }