public TreeIter AddAddin(AddinHeader info, object dataItem, AddinStatus status) { addinData [info] = dataItem; TreeIter iter; if (ShowCategories) { TreeIter piter = TreeIter.Zero; if (info.Category == "") { string otherCat = Catalog.GetString("Other"); piter = FindCategory(otherCat); } else { piter = FindCategory(info.Category); } iter = treeStore.AppendNode(piter); } else { iter = treeStore.AppendNode(); } UpdateRow(iter, info, dataItem, status); return(iter); }
public static TreeModel CreateLeagueList(Country country) { #if DEBUG Console.WriteLine("TreeViewHelper.CreateLeagueList"); #endif TreeStore ls = new TreeStore (typeof(string)); TreeIter iter = ls.AppendNode (); ls.SetValue (iter, 0, Catalog.GetString ("Current league")); foreach (League league in country.Leagues) { iter = ls.AppendNode (); ls.SetValue (iter, 0, league.name); } return ls; }
public TreePosition AddChild(TreePosition pos) { version++; IterPos tpos = GetIterPos(pos); Gtk.TreeIter it; if (pos == null) { it = Tree.AppendNode(); } else { it = Tree.AppendNode(tpos.Iter); } return(new IterPos(version, it)); }
public TreeIter AddAddin(AddinHeader info, object dataItem, bool enabled, bool userDir) { Gdk.Pixbuf icon; if (userDir) { icon = userPackage; } else { icon = package; } addinData [info] = dataItem; TreeIter piter = TreeIter.Zero; if (info.Category == "") { string otherCat = Catalog.GetString("Other"); piter = FindCategory(otherCat); } else { piter = FindCategory(info.Category); } TreeIter iter = treeStore.AppendNode(piter); UpdateRow(iter, info, dataItem, enabled, icon); return(iter); }
public OriginView(Battle.Core.BattleSession session, Battle.Core.OriginDefinition orig) : base(5, 2, false) { this.SizeRequested += HandleSizeRequested; this.SizeAllocated += HandleSizeAllocated; //this.session = session; //this.orig = orig; Label label1 = new Label("Name: "); Label label2 = new Label("Description: "); Entry entry1 = new Entry(); Entry entry2 = new Entry(); entry1.IsEditable = false; entry1.Text = orig.Name; entry2.IsEditable = false; entry2.Text = orig.Description; Gtk.TreeStore store1 = new Gtk.TreeStore(typeof(string)); foreach (string prov in orig.Provides()) { //string[] vs = new string[1]; //vs[0] = prov; //store1.AppendValues(vs); TreeIter i = store1.AppendNode(); store1.SetValue(i, 0, prov); } TreeView treeview1 = new TreeView(store1); treeview1.AppendColumn("Provides", new CellRendererText(), "text", 0); Gtk.TreeStore store2 = new Gtk.TreeStore(typeof(string)); foreach (string req in orig.Requires()) { string[] vs = new string[1]; vs[0] = req; store1.AppendValues(vs); } TreeView treeview2 = new TreeView(store2); treeview2.AppendColumn("Requires", new CellRendererText(), "text", 0); this.Attach(new Label("Origin"), 0, 2, 0, 1, AttachOptions.Expand, AttachOptions.Fill, 0, 0); this.Attach(label1, 0, 1, 1, 2, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); this.Attach(entry1, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Fill, 0, 0); this.Attach(label2, 0, 1, 2, 3, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); this.Attach(entry2, 1, 2, 2, 3, AttachOptions.Fill, AttachOptions.Fill, 0, 0); this.Attach(treeview1, 0, 2, 3, 4, AttachOptions.Fill, AttachOptions.Fill, 1, 1); this.Attach(treeview2, 0, 2, 4, 5, AttachOptions.Fill, AttachOptions.Fill, 1, 1); }
public OriginView(Battle.Core.BattleSession session, Battle.Core.OriginDefinition orig) : base(5, 2, false) { this.SizeRequested += HandleSizeRequested; this.SizeAllocated += HandleSizeAllocated; //this.session = session; //this.orig = orig; Label label1 = new Label("Name: "); Label label2 = new Label("Description: "); Entry entry1 = new Entry(); Entry entry2 = new Entry(); entry1.IsEditable = false; entry1.Text = orig.Name; entry2.IsEditable = false; entry2.Text = orig.Description; Gtk.TreeStore store1 = new Gtk.TreeStore(typeof(string)); foreach (string prov in orig.Provides()) { //string[] vs = new string[1]; //vs[0] = prov; //store1.AppendValues(vs); TreeIter i = store1.AppendNode(); store1.SetValue(i, 0, prov); } TreeView treeview1 = new TreeView(store1); treeview1.AppendColumn("Provides", new CellRendererText(), "text", 0); Gtk.TreeStore store2 = new Gtk.TreeStore(typeof(string)); foreach (string req in orig.Requires()) { string[] vs = new string[1]; vs[0] = req; store1.AppendValues(vs); } TreeView treeview2 = new TreeView(store2); treeview2.AppendColumn("Requires", new CellRendererText(), "text", 0); this.Attach(new Label("Origin"), 0, 2, 0, 1, AttachOptions.Expand, AttachOptions.Fill, 0, 0); this.Attach(label1, 0, 1, 1, 2, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); this.Attach(entry1, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Fill, 0, 0); this.Attach(label2, 0, 1, 2, 3, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); this.Attach(entry2, 1, 2, 2, 3, AttachOptions.Fill, AttachOptions.Fill, 0, 0); this.Attach(treeview1, 0, 2, 3, 4, AttachOptions.Fill, AttachOptions.Fill, 1, 1); this.Attach(treeview2, 0, 2, 4, 5, AttachOptions.Fill, AttachOptions.Fill, 1, 1); }
/** Create the model for the startup country files combo. * @param countryList The List of country files found */ public static TreeModel CreateCountryList(string[] countryList) { #if DEBUG Console.WriteLine("TreeViewHelper.CreateCountryList"); #endif TreeStore ls = new TreeStore(typeof(Pixbuf), typeof(string)); TreeIter iterContinent = new TreeIter (); string currentContinent = string.Empty; foreach (string country in countryList) { string[] elements = country.Split(new char[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries); string continent = elements [0]; if (continent != currentContinent) { iterContinent = ls.AppendNode (); ls.SetValue(iterContinent, 1, continent); currentContinent = continent; } Pixbuf flag = PixbufFromFilename (string.Format ("flag_{0}.png", elements [1])); TreeIter iterCountry = ls.AppendNode (iterContinent); ls.SetValues(iterCountry, flag, elements[1]); } return ls; }
/** Fill a tree model with the users. */ public static TreeModel CreateUsers() { #if DEBUG Console.WriteLine("TreeViewHelper.CreateUsers"); #endif TreeStore ls = new TreeStore(typeof(int), typeof(string), typeof(string), typeof(string)); for (int i = 0; i < Variables.Users.Count; i++) { TreeIter iter = ls.AppendNode (); ls.SetValues (iter, i + 1, Variables.Users [i].Name, Variables.Users [i].Team.name); if (Variables.status [0] == StatusValue.STATUS_TEAM_SELECTION) { if (Variables.Users [i].Scout == Quality.QUALITY_NONE) { ls.SetValue (iter, 3, Variables.LeagueCupGetName(Variables.Users[i].Team.clid)); } else { int index = (int)Variables.Users [i].Scout; ls.SetValue (iter, 3, Variables.Country.Leagues[index].name); } } else { ls.SetValue (iter, 3, Variables.LeagueCupGetName(Variables.Users[i].Team.clid)); } } return ls; }
/** * Creates the model for the treeview in the team selection window. * The model contains a list of all the teams from the leagues in * the country::leagues array; if show_cup_teams is TRUE, the * teams from international cups are shown, too. * @param show_cup_teams Whether or not teams from international * cups are shown. * @param show_user_teams Whether or not user teams are shown. * @return The model containing the team names. **/ public static TreeModel CreateTeamSelectionList(Country country, bool showCupTeams, bool showUserTeams) { #if DEBUG Console.WriteLine("TreeViewHelper.CreateTeamSelectionList"); #endif int count = 1; TreeStore ls = new TreeStore(typeof(int), typeof(Gdk.Pixbuf), typeof(Team), typeof(string), typeof(Team)); for (int i = 0; i < country.Leagues.Count; i++) { League league = country.Leagues [i]; for (int j = 0; j < league.teams.Count; j++) { Team team = league.teams [j]; if (!team.IsUserTeam()) { Pixbuf symbol = PixbufFromFilename (!string.IsNullOrEmpty (team.symbol) ? team.symbol : league.symbol); TreeIter iter = ls.AppendNode(); ls.SetValues (iter, count++, symbol, team, league.name, team); } } } if (showCupTeams) { } return ls; }
private TreeStore populateTreeStoreFromSession() { TreeStore ts = new TreeStore(typeof(string), typeof(string)); TreeIter iter; TreeIter parent = ts.AppendNode(); iter = parent; ts.SetValues(iter, "Nanoc","Human, male"); iter = ts.AppendNode(iter); ts.SetValues(iter, "Abilities", ""); ts.AppendValues(iter, "Charisma","0"); ts.AppendValues(iter, "Dexterity","+1"); ts.AppendValues(iter, "Intelligence", "0"); ts.AppendValues(iter, "Power","0"); ts.AppendValues(iter, "Perception","+1"); ts.AppendValues(iter, "Strength","+4"); ts.AppendValues(iter, "Stamina","+2"); ts.AppendValues(iter, "Willpower","+1"); iter = ts.AppendNode(parent); ts.SetValues(iter, "Experience", ""); ts.AppendValues(iter, "Level", "1"); ts.AppendValues(iter, "Barbarian", "230"); iter = ts.AppendNode(parent); ts.SetValues(iter, "Adventures", ""); return ts; }
private void ShowAdd2Page() { Header = CmisSync.Properties_Resources.ResourceManager.GetString("Which", CultureInfo.CurrentCulture); VBox layout_vertical = new VBox (false, 12); Button cancel_button = new Button (cancelText); cancel_button.Clicked += delegate { Controller.PageCancelled (); }; Button continue_button = new Button (continueText) { Sensitive = false }; continue_button.Clicked += delegate { Controller.Add2PageCompleted( Controller.saved_repository, Controller.saved_remote_path); }; Button back_button = new Button (backText) { Sensitive = true }; back_button.Clicked += delegate { Controller.BackToPage1(); }; TreeStore repoStore = new Gtk.TreeStore(typeof (string), typeof (SelectionTreeItem)); TreeIter iter; foreach (KeyValuePair<String, String> repository in Controller.repositories) { iter = repoStore.AppendNode(); repoStore.SetValues(iter, repository.Value , new SelectionTreeItem(repository.Key, "/")); } Gtk.TreeView treeView = new Gtk.TreeView(repoStore); treeView.HeadersVisible = false; treeView.Selection.Mode = SelectionMode.Single; treeView.AppendColumn("Name", new CellRendererText(), "text", 0); treeView.CursorChanged += delegate(object o, EventArgs args) { TreeSelection selection = (o as TreeView).Selection; TreeModel model; if (selection.GetSelected(out model, out iter)) { SelectionTreeItem sti = model.GetValue(iter, 1) as SelectionTreeItem; // Identify the selected remote path. Controller.saved_remote_path = sti.fullPath; // Identify the selected repository. TreeIter cnode = iter; TreeIter pnode = iter; while (model.IterParent(out pnode, cnode)) { cnode = pnode; } Controller.saved_repository = (model.GetValue(cnode, 1) as SelectionTreeItem).repository; // Load sub-folders if it has not been done already. // We use each item's Tag to store metadata: whether this item's subfolders have been loaded or not. if (sti.childrenLoaded == false) { this.GdkWindow.Cursor = wait_cursor; // Get list of subfolders asynchronously GetSubfoldersDelegate dlgt = new GetSubfoldersDelegate(CmisUtils.GetSubfolders); IAsyncResult ar = dlgt.BeginInvoke(Controller.saved_repository, Controller.saved_remote_path, Controller.saved_address, Controller.saved_user, Controller.saved_password, null, null); while (!ar.AsyncWaitHandle.WaitOne(100)) { while (Application.EventsPending()) { Application.RunIteration(); } } string[] subfolders = dlgt.EndInvoke(ar); TreePath tp = null; // Create a sub-item for each subfolder foreach (string subfolder in subfolders) { TreeIter newchild = repoStore.AppendNode(iter); repoStore.SetValues(newchild, System.IO.Path.GetFileName(subfolder), new SelectionTreeItem(null, subfolder)); if (null == tp) { tp = repoStore.GetPath(newchild); } } sti.childrenLoaded = true; if (null != tp) { treeView.ExpandToPath(tp); } this.GdkWindow.Cursor = default_cursor; } continue_button.Sensitive = true; } }; ScrolledWindow sw = new ScrolledWindow() { ShadowType = Gtk.ShadowType.In }; sw.Add(treeView); layout_vertical.PackStart (new Label(""), false, false, 0); layout_vertical.PackStart (sw, true, true, 0); Add(layout_vertical); AddButton(back_button); AddButton(continue_button); AddButton(cancel_button); }
private void ShowAdd2Page() { Header = CmisSync.Properties_Resources.ResourceManager.GetString("Which", CultureInfo.CurrentCulture); VBox layout_vertical = new VBox(false, 12); Button cancel_button = new Button(cancelText); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button continue_button = new Button(continueText) { Sensitive = false }; continue_button.Clicked += delegate { Controller.Add2PageCompleted( Controller.saved_repository, Controller.saved_remote_path); }; Button back_button = new Button(backText) { Sensitive = true }; back_button.Clicked += delegate { Controller.BackToPage1(); }; TreeStore repoStore = new Gtk.TreeStore(typeof(string), typeof(SelectionTreeItem)); TreeIter iter; foreach (KeyValuePair <String, String> repository in Controller.repositories) { iter = repoStore.AppendNode(); repoStore.SetValues(iter, repository.Value, new SelectionTreeItem(repository.Key, "/")); } Gtk.TreeView treeView = new Gtk.TreeView(repoStore); treeView.HeadersVisible = false; treeView.Selection.Mode = SelectionMode.Single; treeView.AppendColumn("Name", new CellRendererText(), "text", 0); treeView.CursorChanged += delegate(object o, EventArgs args) { TreeSelection selection = (o as TreeView).Selection; TreeModel model; if (selection.GetSelected(out model, out iter)) { SelectionTreeItem sti = model.GetValue(iter, 1) as SelectionTreeItem; // Identify the selected remote path. Controller.saved_remote_path = sti.fullPath; // Identify the selected repository. TreeIter cnode = iter; TreeIter pnode = iter; while (model.IterParent(out pnode, cnode)) { cnode = pnode; } Controller.saved_repository = (model.GetValue(cnode, 1) as SelectionTreeItem).repository; // Load sub-folders if it has not been done already. // We use each item's Tag to store metadata: whether this item's subfolders have been loaded or not. if (sti.childrenLoaded == false) { this.GdkWindow.Cursor = wait_cursor; // Get list of subfolders asynchronously GetSubfoldersDelegate dlgt = new GetSubfoldersDelegate(CmisUtils.GetSubfolders); IAsyncResult ar = dlgt.BeginInvoke(Controller.saved_repository, Controller.saved_remote_path, Controller.saved_address.ToString(), Controller.saved_user, Controller.saved_password, null, null); while (!ar.AsyncWaitHandle.WaitOne(100)) { while (Application.EventsPending()) { Application.RunIteration(); } } string[] subfolders = dlgt.EndInvoke(ar); TreePath tp = null; // Create a sub-item for each subfolder foreach (string subfolder in subfolders) { TreeIter newchild = repoStore.AppendNode(iter); repoStore.SetValues(newchild, System.IO.Path.GetFileName(subfolder), new SelectionTreeItem(null, subfolder)); if (null == tp) { tp = repoStore.GetPath(newchild); } } sti.childrenLoaded = true; if (null != tp) { treeView.ExpandToPath(tp); } this.GdkWindow.Cursor = default_cursor; } continue_button.Sensitive = true; } }; ScrolledWindow sw = new ScrolledWindow() { ShadowType = Gtk.ShadowType.In }; sw.Add(treeView); layout_vertical.PackStart(new Label(""), false, false, 0); layout_vertical.PackStart(sw, true, true, 0); Add(layout_vertical); AddButton(back_button); AddButton(continue_button); AddButton(cancel_button); }
public DemoMain() { window = new Gtk.Window("TestForm1"); Gtk.HBox hbox = new Gtk.HBox(false, 0); hbox1 = new Gtk.HBox(false, 0); Gtk.HBox hbox2 = new Gtk.HBox(false, 0); Gtk.HBox hbox3 = new Gtk.HBox(false, 0); hbox.Add(hbox1); window.SetDefaultSize(600, 400); window.DeleteEvent += new DeleteEventHandler(WindowDelete); button1 = new Gtk.Button("button1"); button1.Clicked += Button1Clicked; button2 = new Gtk.Button("button2"); button3 = new Gtk.Button("button3"); Gtk.Button button4 = new Gtk.Button("button4"); button4.Clicked += Button4Clicked; Gtk.Button button5 = new Gtk.Button("button5"); Gtk.Button button6 = new Gtk.Button("button6"); Gtk.Button button7 = new Gtk.Button("button7"); button7.Sensitive = false; scaleButton1 = new Gtk.ScaleButton(0, 0, 100, 10, new string [0]); hbox1.Add(hbox3); hbox1.Add(hbox2); hbox1.Add(button3); hbox1.Add(button2); button3.Accessible.Description = "help text 3"; button3.Sensitive = false; label1 = new Gtk.Label("label1"); textBox1 = new Gtk.Entry(); Gtk.Entry textBox2 = new Gtk.Entry(); textBox2.Visibility = false; textBox2.Sensitive = false; textBox2.IsEditable = false; textBox3 = new Gtk.TextView(); // TODO: scrollbars Gtk.CheckButton checkbox1 = new Gtk.CheckButton("checkbox1"); Gtk.CheckButton checkbox2 = new Gtk.CheckButton("checkbox2"); checkbox2.Sensitive = false; Gtk.TreeStore store = new Gtk.TreeStore(typeof(string), typeof(string)); Gtk.TreeIter [] iters = new Gtk.TreeIter [2]; iters [0] = store.AppendNode(); store.SetValues(iters [0], "item 1", "item 1 (2)"); iters [1] = store.AppendNode(iters [0]); store.SetValues(iters [1], "item 1a", "item 1a (2)"); iters [0] = store.AppendNode(); store.SetValues(iters [0], "item 2", "item 2 (2)"); iters [1] = store.AppendNode(iters [0]); store.SetValues(iters [1], "item 2a", "item 2a (2)"); iters [1] = store.AppendNode(iters [0]); store.SetValues(iters [1], "item 2b", "item 2b (2)"); treeView1 = new Gtk.TreeView(store); AddTreeViewColumn(treeView1, 0, "column 1"); treeView1.CollapseAll(); treeView2 = new Gtk.TreeView(store); AddTreeViewColumn(treeView2, 0, "column 1"); AddTreeViewColumn(treeView2, 1, "column 2"); treeView2.CollapseAll(); treeView2.Accessible.Name = "treeView2"; tableStore = new Gtk.TreeStore(typeof(string), typeof(string), typeof(string), typeof(string)); iters [0] = tableStore.AppendNode(); tableStore.SetValues(iters [0], "False", "Alice", "24", ""); iters [0] = tableStore.AppendNode(); tableStore.SetValues(iters [0], "True", "Bob", "28", ""); dataGridView1 = new Gtk.TreeView(tableStore); dataGridView1 = new Gtk.TreeView(tableStore); dataGridView1 = new Gtk.TreeView(tableStore); AddTreeViewColumn(dataGridView1, 0, "Gender"); AddTreeViewColumn(dataGridView1, 1, "Name"); AddTreeViewColumn(dataGridView1, 2, "Age"); dataGridView1.Accessible.Name = "dataGridView1"; hboxPanel = new Gtk.HBox(); Gtk.Button btnRemoveTextBox = new Gtk.Button("Remove"); btnRemoveTextBox.Clicked += RemoveTextBoxClicked; Gtk.Button btnAddTextBox = new Gtk.Button("Add"); btnAddTextBox.Clicked += AddTextBoxClicked; txtCommand = new Gtk.Entry(); txtCommand.Accessible.Name = "txtCommand"; Gtk.Button btnRun = new Gtk.Button("Run"); btnRun.Clicked += btnRunClicked; hboxPanel.Add(btnRemoveTextBox); hboxPanel.Add(btnAddTextBox); Gtk.TreeStore treeStore = new Gtk.TreeStore(typeof(string)); Gtk.TreeIter iter = treeStore.AppendNode(); treeStore.SetValue(iter, 0, "Item 0"); iter = treeStore.AppendNode(); treeStore.SetValue(iter, 0, "Item 1"); listView1 = new Gtk.TreeView(treeStore); AddTreeViewColumn(listView1, 0, "items"); listView1.Accessible.Name = "listView1"; listView1.ExpandAll(); hbox2.Add(button5); hbox2.Add(checkbox1); hbox2.Add(checkbox2); hbox2.Add(button4); hbox2.Accessible.Name = "groupBox2"; hbox3.Add(button7); hbox3.Add(button6); hbox3.Sensitive = false; hbox3.Accessible.Name = "groupBox3"; hbox.Add(textBox3); hbox.Add(textBox2); hbox.Add(textBox1); hbox.Add(label1); hbox.Add(button1); hbox.Add(treeView1); hbox.Add(treeView2); hbox.Add(listView1); hbox.Add(dataGridView1); hbox.Add(txtCommand); hbox.Add(btnRun); hbox.Add(hboxPanel); hbox.Add(scaleButton1); Gtk.Menu file = new Gtk.Menu(); file.Append(new Gtk.MenuItem("_New")); file.Append(new Gtk.MenuItem("_Open")); file.Append(new Gtk.CheckMenuItem("Check")); Gtk.MenuItem fileItem = new Gtk.MenuItem("File"); fileItem.Submenu = file; Gtk.Menu edit = new Gtk.Menu(); edit.Append(new Gtk.MenuItem("_Undo")); edit.Append(new Gtk.SeparatorMenuItem()); edit.Append(new Gtk.MenuItem("_Cut")); edit.Append(new Gtk.MenuItem("Copy")); edit.Append(new Gtk.MenuItem("_Paste")); Gtk.MenuItem editItem = new Gtk.MenuItem("Edit"); editItem.Submenu = edit; Gtk.MenuBar menuBar = new Gtk.MenuBar(); menuBar.Append(fileItem); menuBar.Append(editItem); hbox.Add(menuBar); hbox.Add(new Gtk.SpinButton(0, 100, 1)); hbox.Add(new Gtk.ToggleButton("ToggleButton")); Gtk.Adjustment adj = new Gtk.Adjustment(50, 0, 100, 1, 10, 10); hbox.Add(new Gtk.VScrollbar(adj)); window.Add(hbox); window.ShowAll(); }
private void btnRunClicked(object o, EventArgs args) { const string sampleText = "Lorem ipsum dolor sit amet"; string cmd = txtCommand.Text; if (cmd == "click button1") { button1.Activate(); } else if (cmd == "set textbox3 text") { textBox3.Buffer.Text = sampleText; } else if (cmd == "set textBox3 long text") { textBox3.Buffer.Text = "very very very very very very very very long text to enable the horizontal scroll bar"; } else if (cmd.StartsWith("set textbox3 to ")) { textBox3.Buffer.Text = cmd.Substring(16). Replace("\\n", "\n"). Replace("\\r", "\r"); } else if (cmd == "select textbox3") { if (textBox3.Buffer.Text.Length < 4) { textBox3.Buffer.Text = sampleText; } Gtk.TextIter startIter, endIter; textBox3.Buffer.GetSelectionBounds(out startIter, out endIter); int start, end; start = startIter.Offset; end = endIter.Offset; end = (end - start == 3? 4: 3); start = 0; startIter = textBox3.Buffer.GetIterAtOffset(start); endIter = textBox3.Buffer.GetIterAtOffset(end); textBox3.Buffer.MoveMark("selection_bound", startIter); textBox3.Buffer.MoveMark("insert", endIter); } else if (cmd == "add table row") { Gtk.TreeIter iter; iter = tableStore.AppendNode(); tableStore.SetValues(iter, "true", "Mallory", "40"); } else if (cmd == "add table column") { AddTreeViewColumn(treeView2, 3, "more"); } else if (cmd == "enable multiselect") { listView1.Selection.Mode = Gtk.SelectionMode.Multiple; } else if (cmd == "disable multiselect") { listView1.Selection.Mode = Gtk.SelectionMode.Single; } else if (cmd == "change button3 name") { button3.Accessible.Name = "xyzzy"; } else if (cmd == "change button3 helptext") { button3.Accessible.Description = "plugh"; } else if (cmd == "enable button3") { button3.Sensitive = true; } else if (cmd == "disable button3") { button3.Sensitive = false; } else if (cmd == "focus textBox3") { textBox3.GrabFocus(); } else if (cmd == "focus button2") { button2.GrabFocus(); } else if (cmd.StartsWith("change title:")) { window.Title = cmd.Substring(cmd.IndexOf(':') + 1); } else if (cmd == "open FileChooser" && chooser == null) { chooser = new Gtk.FileChooserDialog("FileChooser", window, FileChooserAction.Open, "data", 0); chooser.Show(); } else if (cmd == "close FileChooser" && chooser != null) { chooser.Destroy(); chooser = null; } }
public DemoMain () { window = new Gtk.Window ("TestForm1"); Gtk.HBox hbox = new Gtk.HBox (false, 0); hbox1 = new Gtk.HBox (false, 0); Gtk.HBox hbox2 = new Gtk.HBox (false, 0); Gtk.HBox hbox3 = new Gtk.HBox (false, 0); hbox.Add (hbox1); window.SetDefaultSize (600, 400); window.DeleteEvent += new DeleteEventHandler (WindowDelete); button1 = new Gtk.Button ("button1"); button1.Clicked += Button1Clicked; button2 = new Gtk.Button ("button2"); button3 = new Gtk.Button ("button3"); Gtk.Button button4 = new Gtk.Button ("button4"); button4.Clicked += Button4Clicked; Gtk.Button button5 = new Gtk.Button ("button5"); Gtk.Button button6 = new Gtk.Button ("button6"); Gtk.Button button7 = new Gtk.Button ("button7"); button7.Sensitive = false; scaleButton1 = new Gtk.ScaleButton (0, 0, 100, 10, new string [0]); hbox1.Add (hbox3); hbox1.Add (hbox2); hbox1.Add (button3); hbox1.Add (button2); button3.Accessible.Description = "help text 3"; button3.Sensitive = false; label1 = new Gtk.Label ("label1"); textBox1 = new Gtk.Entry (); Gtk.Entry textBox2 = new Gtk.Entry (); textBox2.Visibility = false; textBox2.Sensitive = false; textBox2.IsEditable = false; textBox3 = new Gtk.TextView (); // TODO: scrollbars Gtk.CheckButton checkbox1 = new Gtk.CheckButton ("checkbox1"); Gtk.CheckButton checkbox2 = new Gtk.CheckButton ("checkbox2"); checkbox2.Sensitive = false; Gtk.TreeStore store = new Gtk.TreeStore (typeof (string), typeof (string)); Gtk.TreeIter [] iters = new Gtk.TreeIter [2]; iters [0] = store.AppendNode (); store.SetValues (iters [0], "item 1", "item 1 (2)"); iters [1] = store.AppendNode (iters [0]); store.SetValues (iters [1], "item 1a", "item 1a (2)"); iters [0] = store.AppendNode (); store.SetValues (iters [0], "item 2", "item 2 (2)"); iters [1] = store.AppendNode (iters [0]); store.SetValues (iters [1], "item 2a", "item 2a (2)"); iters [1] = store.AppendNode (iters [0]); store.SetValues (iters [1], "item 2b", "item 2b (2)"); treeView1 = new Gtk.TreeView (store); AddTreeViewColumn (treeView1, 0, "column 1"); treeView1.CollapseAll (); treeView2 = new Gtk.TreeView (store); AddTreeViewColumn (treeView2, 0, "column 1"); AddTreeViewColumn (treeView2, 1, "column 2"); treeView2.CollapseAll (); treeView2.Accessible.Name = "treeView2"; tableStore = new Gtk.TreeStore (typeof (string), typeof (string), typeof (string), typeof (string)); iters [0] = tableStore.AppendNode (); tableStore.SetValues (iters [0], "False", "Alice", "24", ""); iters [0] = tableStore.AppendNode (); tableStore.SetValues (iters [0], "True", "Bob", "28", ""); dataGridView1 = new Gtk.TreeView (tableStore); dataGridView1 = new Gtk.TreeView (tableStore); dataGridView1 = new Gtk.TreeView (tableStore); AddTreeViewColumn (dataGridView1, 0, "Gender"); AddTreeViewColumn (dataGridView1, 1, "Name"); AddTreeViewColumn (dataGridView1, 2, "Age"); dataGridView1.Accessible.Name = "dataGridView1"; hboxPanel = new Gtk.HBox (); Gtk.Button btnRemoveTextBox = new Gtk.Button ("Remove"); btnRemoveTextBox.Clicked += RemoveTextBoxClicked; Gtk.Button btnAddTextBox = new Gtk.Button ("Add"); btnAddTextBox.Clicked += AddTextBoxClicked; txtCommand = new Gtk.Entry (); txtCommand.Accessible.Name = "txtCommand"; Gtk.Button btnRun = new Gtk.Button ("Run"); btnRun.Clicked += btnRunClicked; hboxPanel.Add (btnRemoveTextBox); hboxPanel.Add (btnAddTextBox); Gtk.TreeStore treeStore = new Gtk.TreeStore (typeof (string)); Gtk.TreeIter iter = treeStore.AppendNode (); treeStore.SetValue (iter, 0, "Item 0"); iter = treeStore.AppendNode (); treeStore.SetValue (iter, 0, "Item 1"); listView1 = new Gtk.TreeView (treeStore); AddTreeViewColumn (listView1, 0, "items"); listView1.Accessible.Name = "listView1"; listView1.ExpandAll (); hbox2.Add (button5); hbox2.Add (checkbox1); hbox2.Add (checkbox2); hbox2.Add (button4); hbox2.Accessible.Name = "groupBox2"; hbox3.Add (button7); hbox3.Add (button6); hbox3.Sensitive = false; hbox3.Accessible.Name = "groupBox3"; hbox.Add (textBox3); hbox.Add (textBox2); hbox.Add (textBox1); hbox.Add (label1); hbox.Add (button1); hbox.Add (treeView1); hbox.Add (treeView2); hbox.Add (listView1); hbox.Add (dataGridView1); hbox.Add (txtCommand); hbox.Add (btnRun); hbox.Add (hboxPanel); hbox.Add (scaleButton1); Gtk.Menu file = new Gtk.Menu (); file.Append (new Gtk.MenuItem ("_New")); file.Append (new Gtk.MenuItem ("_Open")); file.Append (new Gtk.CheckMenuItem ("Check")); Gtk.MenuItem fileItem = new Gtk.MenuItem ("File"); fileItem.Submenu = file; Gtk.Menu edit = new Gtk.Menu (); edit.Append (new Gtk.MenuItem ("_Undo")); edit.Append (new Gtk.SeparatorMenuItem ()); edit.Append (new Gtk.MenuItem ("_Cut")); edit.Append (new Gtk.MenuItem ("Copy")); edit.Append (new Gtk.MenuItem ("_Paste")); Gtk.MenuItem editItem = new Gtk.MenuItem ("Edit"); editItem.Submenu = edit; Gtk.MenuBar menuBar = new Gtk.MenuBar (); menuBar.Append (fileItem); menuBar.Append (editItem); hbox.Add (menuBar); hbox.Add (new Gtk.SpinButton (0, 100, 1)); hbox.Add (new Gtk.ToggleButton ("ToggleButton")); Gtk.Adjustment adj = new Gtk.Adjustment (50, 0, 100, 1, 10, 10); hbox.Add (new Gtk.VScrollbar (adj)); window.Add (hbox); window.ShowAll (); }
public CoverageView(string fileName, ProgressBar status) { store = new TreeStore (typeof (string), typeof (string), typeof (string), typeof (string), typeof (object)); tree = new TreeView (store); CellRendererText renderer = new CellRendererText (); CellRendererText coverageRenderer = new CellRendererText (); // LAME: Why is this property a float instead of a double ? renderer.Xalign = 0.5f; tree.AppendColumn ("Classes", new CellRendererText (), "text", 0); tree.AppendColumn ("Lines Hit", renderer, "text", 1); tree.AppendColumn ("Lines Missed", renderer, "text", 2); tree.AppendColumn ("Coverage", coverageRenderer, "text", 3); tree.GetColumn (0).Resizable = true; tree.GetColumn (1).Alignment = 0.0f; tree.GetColumn (1).Resizable = true; tree.GetColumn (2).Alignment = 0.0f; tree.GetColumn (2).Resizable = true; tree.GetColumn (3).Alignment = 0.0f; tree.GetColumn (3).Resizable = true; tree.GetColumn (3).SetCellDataFunc (coverageRenderer, new TreeCellDataFunc (RenderCoverage)); tree.HeadersVisible = true; model = new CoverageModel (); foreach (string filter in DEFAULT_FILTERS) { model.AddFilter (filter); } this.status = status; model.Progress += Progress; model.ReadFromFile (fileName); TreeItem root = new TreeItem (store, null, model, "PROJECT"); Hashtable classes2 = model.Classes; namespaces = new Hashtable (); string[] sorted_names = new string [classes2.Count]; classes2.Keys.CopyTo (sorted_names, 0); Array.Sort (sorted_names); Progress ("Building tree", 0.95); foreach (string name in sorted_names) { ClassCoverageItem klass = (ClassCoverageItem)classes2 [name]; if (klass.filtered) continue; string namespace2 = klass.name_space; TreeItem nsItem = (TreeItem)namespaces [namespace2]; if (nsItem == null) { nsItem = new TreeItem (store, root, (CoverageItem)model.Namespaces [namespace2], namespace2); // nsItem.SetPixmap (0, namespaceOpenPixmap); namespaces [namespace2] = nsItem; } if (nsItem.model.filtered) continue; ClassItem classItem = new ClassItem (store, nsItem, klass, klass.name); if (klass.ChildCount != 0) { TreeIter treeIter = store.AppendNode (classItem.iter); store.SetValues (treeIter, "<loading>"); } } tree.ExpandRow (store.GetPath (root.Iter), false); // it becomes very hard to navigate if everything is expanded //foreach (string ns in namespaces.Keys) // tree.ExpandRow (store.GetPath (((TreeItem)namespaces [ns]).Iter), false); tree.RowExpanded += new RowExpandedHandler (OnRowExpanded); tree.RowCollapsed += new RowCollapsedHandler (OnRowCollapsed); tree.ButtonPressEvent += new ButtonPressEventHandler (OnButtonPress); tree.Selection.Mode = SelectionMode.Single; source_views = new Hashtable (); window_maps = new Hashtable (); Progress ("Done", 1.0); // LAME: Why doesn't widgets visible by default ??? tree.Show (); }