public ExportToHtmlDialog (string default_file) : base (Catalog.GetString ("Destination for HTML Export"), null, Gtk.FileChooserAction.Save, new object[] {}) { AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel); AddButton (Gtk.Stock.Save, Gtk.ResponseType.Ok); DefaultResponse = Gtk.ResponseType.Ok; Gtk.Table table = new Gtk.Table (2, 2, false); export_linked = new Gtk.CheckButton (Catalog.GetString ("Export linked notes")); export_linked.Toggled += OnExportLinkedToggled; table.Attach (export_linked, 0, 2, 0, 1, Gtk.AttachOptions.Fill, 0, 0, 0); export_linked_all = new Gtk.CheckButton (Catalog.GetString ("Include all other linked notes")); table.Attach (export_linked_all, 1, 2, 1, 2, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, 0, 20, 0); ExtraWidget = table; DoOverwriteConfirmation = true; LocalOnly = true; ShowAll (); LoadPreferences (default_file); }
public ExportToHtmlDialog(string default_file) : base(Catalog.GetString("Destination for HTML Export"), null, Gtk.FileChooserAction.Save, new object[] {}) { AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel); AddButton(Gtk.Stock.Save, Gtk.ResponseType.Ok); DefaultResponse = Gtk.ResponseType.Ok; Gtk.Table table = new Gtk.Table(2, 2, false); export_linked = new Gtk.CheckButton(Catalog.GetString("Export linked notes")); export_linked.Toggled += OnExportLinkedToggled; table.Attach(export_linked, 0, 2, 0, 1, Gtk.AttachOptions.Fill, 0, 0, 0); export_linked_all = new Gtk.CheckButton(Catalog.GetString("Include all other linked notes")); table.Attach(export_linked_all, 1, 2, 1, 2, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, 0, 20, 0); ExtraWidget = table; DoOverwriteConfirmation = true; LocalOnly = true; ShowAll(); LoadPreferences(default_file); SetExportLinkedAllSensitivity(); }
void AddRow(Gtk.Table table, uint row, string label, Gtk.Widget widget) { table.Attach(new Gtk.Label(label ?? string.Empty) { Xalign = 1 }, 0, 1, row, row + 1, Gtk.AttachOptions.Shrink, Gtk.AttachOptions.Shrink, 0, 0); table.Attach(widget, 1, 2, row, row + 1, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, Gtk.AttachOptions.Shrink, 0, 0); }
//TODO: dropdown menus for picking string substitutions. also substitutions for port, ip public clsDebuggerOptionsDialog() : base( "SSH Debug", MonoDevelop.Ide.MessageService.RootWindow, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal) { properties = PropertyService.Get("MonoDevelop.Debugger.Soft.SSHDebug", new Properties()); AddActionWidget(connectButton, connectResponse); AddActionWidget(newButton, newResponse); AddActionWidget(new Gtk.Button(Gtk.Stock.Cancel), Gtk.ResponseType.Cancel); var table = new Gtk.Table(1, 2, false); table.BorderWidth = 6; VBox.PackStart(table, true, true, 0); table.Attach(new Gtk.Label("Host") { Xalign = 0 }, 0, 1, 0, 1); var values = clsSSHDebuggerEngine.HostsList.Select(x => String.Format("{0} ({1})", x.Name, System.IO.Path.GetFileName(x.ScriptPath))).ToArray(); combo = new Gtk.ComboBox(values); int row = 0; if (clsSSHDebuggerEngine.HostsList.Count == 0) { connectButton.Sensitive = false; } else { var lastSelected = clsSSHDebuggerEngine.HostsList.Find(x => x.ScriptPath == properties.Get <string> ("host", "")); if (lastSelected != null) { row = clsSSHDebuggerEngine.HostsList.IndexOf(lastSelected); if (row == -1) { row = 0; } } Gtk.TreeIter iter; combo.Model.IterNthChild(out iter, row); combo.SetActiveIter(iter); SelectedHost = clsSSHDebuggerEngine.HostsList [combo.Active]; combo.Changed += (object sender, EventArgs e) => { SelectedHost = clsSSHDebuggerEngine.HostsList [combo.Active]; }; } table.Attach(combo, 1, 2, 0, 1); VBox.ShowAll(); }
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; } }
public CreateNotebookDialog(Gtk.Window parent, Gtk.DialogFlags flags) : base(parent, flags, Gtk.MessageType.Info, Gtk.ButtonsType.None, Catalog.GetString("Create a new notebook"), Catalog.GetString("Type the name of the notebook you'd like to create.")) { this.Pixbuf = newNotebookIconDialog; Gtk.Table table = new Gtk.Table(2, 2, false); Gtk.Label label = new Gtk.Label(Catalog.GetString("N_otebook name:")); label.Xalign = 0; label.UseUnderline = true; label.Show(); nameEntry = new Gtk.Entry(); nameEntry.Changed += OnNameEntryChanged; nameEntry.ActivatesDefault = true; nameEntry.Show(); label.MnemonicWidget = nameEntry; errorLabel = new Gtk.Label(); errorLabel.Xalign = 0; errorLabel.Markup = string.Format("<span foreground='red' style='italic'>{0}</span>", Catalog.GetString("Name already taken")); table.Attach(label, 0, 1, 0, 1); table.Attach(nameEntry, 1, 2, 0, 1); table.Attach(errorLabel, 1, 2, 1, 2); table.Show(); ExtraWidget = table; AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, false); AddButton( newNotebookIcon, // Translation note: This is the Create button in the Create // New Note Dialog. Catalog.GetString("C_reate"), Gtk.ResponseType.Ok, true); // Only let the Ok response be sensitive when // there's something in nameEntry SetResponseSensitive(Gtk.ResponseType.Ok, false); errorLabel.Hide(); }
public CreateNotebookDialog(Gtk.Window parent, Gtk.DialogFlags flags) : base (parent, flags, Gtk.MessageType.Info, Gtk.ButtonsType.None, Catalog.GetString ("Create a new notebook"), Catalog.GetString ("Type the name of the notebook you'd like to create.")) { this.Pixbuf = newNotebookIconDialog; Gtk.Table table = new Gtk.Table (2, 2, false); Gtk.Label label = new Gtk.Label (Catalog.GetString ("N_otebook name:")); label.Xalign = 0; label.UseUnderline = true; label.Show (); nameEntry = new Gtk.Entry (); nameEntry.Changed += OnNameEntryChanged; nameEntry.ActivatesDefault = true; nameEntry.Show (); label.MnemonicWidget = nameEntry; errorLabel = new Gtk.Label (); errorLabel.Xalign = 0; errorLabel.Markup = string.Format("<span foreground='red' style='italic'>{0}</span>", Catalog.GetString ("Name already taken")); table.Attach (label, 0, 1, 0, 1); table.Attach (nameEntry, 1, 2, 0, 1); table.Attach (errorLabel, 1, 2, 1, 2); table.Show (); ExtraWidget = table; AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, false); AddButton ( newNotebookIcon, // Translation note: This is the Create button in the Create // New Note Dialog. Catalog.GetString ("C_reate"), Gtk.ResponseType.Ok, true); // Only let the Ok response be sensitive when // there's something in nameEntry SetResponseSensitive (Gtk.ResponseType.Ok, false); errorLabel.Hide (); }
//This shows a loading graphic and a message //it uses a table to center both items private void showLoadingScreen(string message = "Loading") { clearContainer(); Gtk.Table table = new Gtk.Table(((uint)(6)), ((uint)(6)), true); table.BorderWidth = 2; Gtk.Image img = new Gtk.Image(loadingAnimation); table.Attach(img, 2, 4, 2, 3); Gtk.Label lbl = new Gtk.Label(message); lbl.ModifyFont(Pango.FontDescription.FromString("12")); table.Attach(lbl, 2, 4, 3, 4); container.PackStart(table); this.ShowAll(); }
public void ReplaceWidget(int i, Gtk.Widget newWidget) { table.Remove(widgets[i]); var pos = widgetPositions[i]; table.Attach(newWidget, pos.Item1 + 1, pos.Item1 + 2, pos.Item2, pos.Item2 + 1); widgets[i] = newWidget; }
void SetImagePosition(bool removeImage = true) { uint left, top; bool shouldHideLabel = false; switch (ImagePosition) { case ButtonImagePosition.Above: left = 1; top = 0; shouldHideLabel = true; break; case ButtonImagePosition.Below: left = 1; top = 2; shouldHideLabel = true; break; case ButtonImagePosition.Left: left = 0; top = 1; break; case ButtonImagePosition.Right: left = 2; top = 1; break; case ButtonImagePosition.Overlay: left = 1; top = 1; break; default: throw new NotSupportedException(); } shouldHideLabel &= string.IsNullOrEmpty(label.Text); if (shouldHideLabel) { label.Hide(); } else { label.Show(); } var right = left + 1; var bottom = top + 1; var options = shouldHideLabel ? Gtk.AttachOptions.Expand : Gtk.AttachOptions.Shrink; if (removeImage) { table.Remove(gtkimage); } table.Attach(gtkimage, left, right, top, bottom, options, options, 0, 0); Control.QueueResize(); }
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 }
public ButtonHandler() { // need separate widgets as the theme can (and usually) disables images on buttons // gtk3 can override the theme per button, but gtk2 cannot table = new Gtk.Table(3, 3, false); table.ColumnSpacing = 0; table.RowSpacing = 0; label = new Gtk.AccelLabel(string.Empty); label.NoShowAll = true; table.Attach(label, 1, 2, 1, 2, Gtk.AttachOptions.Expand, Gtk.AttachOptions.Expand, 0, 0); gtkimage = new Gtk.Image(); gtkimage.NoShowAll = true; }
//TODO: dropdown menus for picking string substitutions. also substitutions for port, ip public clsDebuggerOptionsDialog() : base("SSH Debug", MonoDevelop.Ide.MessageService.RootWindow, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal) { properties = PropertyService.Get ("MonoDevelop.Debugger.Soft.SSHDebug", new Properties()); AddActionWidget (connectButton, connectResponse); AddActionWidget (newButton, newResponse); AddActionWidget (new Gtk.Button (Gtk.Stock.Cancel), Gtk.ResponseType.Cancel); var table = new Gtk.Table (1, 2, false); table.BorderWidth = 6; VBox.PackStart (table, true, true, 0); table.Attach (new Gtk.Label ("Host") { Xalign = 0 }, 0, 1, 0, 1); var values = clsSSHDebuggerEngine.HostsList.Select (x => String.Format ("{0} ({1})", x.Name, System.IO.Path.GetFileName (x.ScriptPath))).ToArray (); combo = new Gtk.ComboBox (values); int row=0; if (clsSSHDebuggerEngine.HostsList.Count == 0) { connectButton.Sensitive = false; } else { var lastSelected = clsSSHDebuggerEngine.HostsList.Find (x => x.ScriptPath == properties.Get<string> ("host", "")); if (lastSelected != null) { row = clsSSHDebuggerEngine.HostsList.IndexOf (lastSelected); if (row == -1) row = 0; } Gtk.TreeIter iter; combo.Model.IterNthChild (out iter, row); combo.SetActiveIter (iter); SelectedHost = clsSSHDebuggerEngine.HostsList [combo.Active]; combo.Changed += (object sender, EventArgs e) => { SelectedHost = clsSSHDebuggerEngine.HostsList [combo.Active]; }; } table.Attach (combo, 1, 2, 0, 1); VBox.ShowAll (); }
public GTKRenderer(Gtk.Table table) { this._table = table; foreach (Position position in Positions()) { Gtk.Button button = new Gtk.Button(); _buttonMap.Add(position, button); table.Attach( button, (uint)(position.Col), (uint)(position.Col + 1), (uint)(Grid.MaxRows - position.Row - 1), (uint)(Grid.MaxRows - position.Row) ); ChangeColor(position, "red"); } }
public PreferenceView() { vbox1 = new Gtk.VBox() { Spacing = 6 }; table1 = new Gtk.Table(3, 2, true) { RowSpacing = 6, ColumnSpacing = 6 }; entPassword = new Gtk.Entry() { CanFocus = true, IsEditable = true, Visibility = false, InvisibleChar = '●' }; table1.Attach(entPassword, 1, 2, 2, 3); entUrl = new Gtk.Entry() { CanFocus = true, IsEditable = true }; table1.Attach(entUrl, 1, 2, 0, 1); entUser = new Gtk.Entry() { CanFocus = true, IsEditable = true }; table1.Attach(entUser, 1, 2, 1, 2); lblPassword = new Gtk.Label("Password:"******"Ampache Server Name:"); table1.Attach(lblUrl, 0, 1, 0, 1); lblUser = new Gtk.Label("User Name:"); table1.Attach(lblUser, 0, 1, 1, 2); vbox1.PackStart(table1, true, false, 0); hbox1 = new Gtk.HBox(); btnSave = new Gtk.Button(); btnSave.Label = "Save"; btnSave.Clicked += Save_OnClicked; hbox1.PackStart(btnSave, false, false, 0); btnClear = new Gtk.Button(); btnClear.Label = "Clear"; btnClear.Clicked += Clean_OnClicked; hbox1.PackStart(btnClear, true, false, 0); vbox1.PackStart(hbox1, false, false, 0); this.Add(vbox1); ShowAll(); entUrl.Text = AmpacheSource.AmpacheRootAddress.Get(AmpacheSource.AmpacheRootAddress.DefaultValue); entUser.Text = AmpacheSource.UserName.Get(AmpacheSource.UserName.DefaultValue); entPassword.Text = AmpacheSource.UserPassword.Get(AmpacheSource.UserPassword.DefaultValue); }
void Fill() { menuItems.Clear(); uint n = 0; ActionMenuItem editItem = null; if (nodes.Count > 0) { foreach (ActionTreeNode node in nodes) { ActionMenuItem item = new ActionMenuItem(wrapper, this, node); item.KeyPressEvent += OnItemKeyPress; item.Attach(table, n++, 0); menuItems.Add(item); // If adding an action with an empty name, select and start editing it // if (node.Action != null && node.Action.Name.Length == 0) // editItem = item; } } emptyLabel = new Gtk.EventBox(); emptyLabel.VisibleWindow = false; Gtk.Label label = new Gtk.Label(); label.Xalign = 0; label.Markup = "<i><span foreground='darkgrey'>" + Catalog.GetString("Click to create action") + "</span></i>"; emptyLabel.Add(label); emptyLabel.ButtonPressEvent += OnAddClicked; table.Attach(emptyLabel, 1, 2, n, n + 1); ShowAll(); if (editItem != null) { // If there is an item with an empty action, it means that it was an item that was // being edited. Restart the editing now. GLib.Timeout.Add(200, delegate { editItem.Select(); editItem.EditingDone += OnEditingDone; editItem.StartEditing(); return(false); }); } }
public ButtonHandler() { Control = new Gtk.Button(); // need separate widgets as the theme can (and usually) disables images on buttons // gtk3 can override the theme per button, but gtk2 cannot table = new Gtk.Table(3, 3, false); table.ColumnSpacing = 0; table.RowSpacing = 0; label = new Gtk.AccelLabel(string.Empty); label.NoShowAll = true; table.Attach(label, 1, 2, 1, 2, Gtk.AttachOptions.Expand, Gtk.AttachOptions.Expand, 0, 0); gtkimage = new Gtk.Image(); gtkimage.NoShowAll = true; SetImagePosition(false); Control.Add(table); Control.Clicked += delegate { Widget.OnClick(EventArgs.Empty); }; var defaultSize = Button.DefaultSize; Control.SizeAllocated += delegate(object o, Gtk.SizeAllocatedArgs args) { var size = args.Allocation; if (size.Width > 1 || size.Height > 1) { if (defaultSize.Width > size.Width) { size.Width = defaultSize.Width; } if (defaultSize.Height > size.Height) { size.Height = defaultSize.Height; } if (args.Allocation != size) { Control.SetSizeRequest(size.Width, size.Height); } } }; }
public PreferenceView() { vbox1 = new Gtk.VBox () { Spacing = 6 }; table1 = new Gtk.Table (3, 2, true) { RowSpacing = 6, ColumnSpacing = 6 }; entPassword = new Gtk.Entry () { CanFocus = true, IsEditable = true, Visibility = false, InvisibleChar = '●' }; table1.Attach (entPassword, 1, 2, 2, 3); entUrl = new Gtk.Entry () { CanFocus = true, IsEditable = true }; table1.Attach (entUrl, 1, 2, 0, 1); entUser = new Gtk.Entry () { CanFocus = true, IsEditable = true }; table1.Attach (entUser, 1, 2, 1, 2); lblPassword = new Gtk.Label ("Password:"******"Ampache Server Name:"); table1.Attach (lblUrl, 0, 1, 0 ,1); lblUser = new Gtk.Label ("User Name:"); table1.Attach (lblUser, 0, 1, 1, 2); vbox1.PackStart (table1, true, false, 0); hbox1 = new Gtk.HBox (); btnSave = new Gtk.Button (); btnSave.Label = "Save"; btnSave.Clicked += Save_OnClicked; hbox1.PackStart (btnSave, false, false, 0); btnClear = new Gtk.Button (); btnClear.Label = "Clear"; btnClear.Clicked += Clean_OnClicked; hbox1.PackStart (btnClear, true, false, 0); vbox1.PackStart (hbox1, false, false, 0); this.Add (vbox1); ShowAll (); entUrl.Text = AmpacheSource.AmpacheRootAddress.Get(AmpacheSource.AmpacheRootAddress.DefaultValue); entUser.Text = AmpacheSource.UserName.Get(AmpacheSource.UserName.DefaultValue); entPassword.Text = AmpacheSource.UserPassword.Get(AmpacheSource.UserPassword.DefaultValue); }
public void CreateGui() { Gtk.Image icn_reload = new Gtk.Image(Gtk.Stock.Refresh, Gtk.IconSize.Button); _reload = new Gtk.Button(icn_reload); _reload.Clicked += OnReload; _performer = new Gtk.Entry(200); _title = new Gtk.Entry(200); _title.WidthChars = 60; _performer.WidthChars = 60; _subtitle = new Gtk.Entry(300); _subtitle.WidthChars = 60; _composer = new Gtk.Entry(200); _composer.WidthChars = 60; _year = new Gtk.Entry(20); _year.WidthChars = 20; _image = new Gtk.Image(); _image.SetSizeRequest(100, 100); _imagefile = new Gtk.FileChooserButton("Choose image file", Gtk.FileChooserAction.Open); _imagefile.FileSet += new EventHandler(EvtImageSet); Gtk.Image icn_add_track = new Gtk.Image(Gtk.Stock.Add, Gtk.IconSize.Button); _add_track = new Gtk.Button(icn_add_track); _add_track.Clicked += OnAddTrack; Gtk.Image icn_del_track = new Gtk.Image(Gtk.Stock.Delete, Gtk.IconSize.Button); _del_track = new Gtk.Button(icn_del_track); _del_track.Clicked += OnDelTrack; Gtk.Image icn_save = new Gtk.Image(Gtk.Stock.Save, Gtk.IconSize.Button); _save = new Gtk.Button(icn_save); _save.Clicked += OnSave; _store = new Gtk.ListStore(typeof(int), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string)); _tracks = new Gtk.TreeView(); { Gtk.CellRendererText cr0 = new Gtk.CellRendererText(); cr0.Scale = 0.8; _tracks.AppendColumn("Nr.", cr0, "text", 0); Gtk.CellRendererText cr_title = new Gtk.CellRendererText(); cr_title.Scale = 0.8; cr_title.Editable = true; cr_title.Edited += new Gtk.EditedHandler(delegate(object sender, Gtk.EditedArgs args) { setCell(1, args.NewText, new Gtk.TreePath(args.Path)); }); _tracks.AppendColumn("Title", cr_title, "text", 1); Gtk.CellRendererText cr_artist = new Gtk.CellRendererText(); cr_artist.Editable = true; cr_artist.Scale = 0.8; cr_artist.Edited += new Gtk.EditedHandler(delegate(object sender, Gtk.EditedArgs args) { setCell(2, args.NewText, new Gtk.TreePath(args.Path)); }); _tracks.AppendColumn("Artist", cr_artist, "text", 2); Gtk.CellRendererText cr_composer = new Gtk.CellRendererText(); cr_composer.Editable = true; cr_composer.Scale = 0.8; cr_composer.Edited += new Gtk.EditedHandler(delegate(object sender, Gtk.EditedArgs args) { setCell(3, args.NewText, new Gtk.TreePath(args.Path)); }); _tracks.AppendColumn("Composer", cr_composer, "text", 3); Gtk.CellRendererText cr_piece = new Gtk.CellRendererText(); cr_piece.Editable = true; cr_piece.Scale = 0.8; cr_piece.Edited += new Gtk.EditedHandler(delegate(object sender, Gtk.EditedArgs args) { setCell(4, args.NewText, new Gtk.TreePath(args.Path)); }); _tracks.AppendColumn("Piece", cr_piece, "text", 4); Gtk.CellRendererText cr_time = new Gtk.CellRendererText(); cr_time.Editable = true; cr_time.Scale = 0.8; cr_time.Edited += new Gtk.EditedHandler(delegate(object sender, Gtk.EditedArgs args) { setCell(5, args.NewText, new Gtk.TreePath(args.Path)); }); _tracks.AppendColumn("Offset", cr_time, "text", 5); } _tracks.Model = _store; Gtk.Table tbl = new Gtk.Table(2, 5, false); tbl.Attach(new Gtk.Label("Album:"), 0, 1, 0, 1); tbl.Attach(_title, 1, 2, 0, 1); tbl.Attach(new Gtk.Label("Artist:"), 0, 1, 1, 2); tbl.Attach(_performer, 1, 2, 1, 2); tbl.Attach(new Gtk.Label("Composer:"), 0, 1, 2, 3); tbl.Attach(_composer, 1, 2, 2, 3); tbl.Attach(new Gtk.Label("Subtitle:"), 0, 1, 3, 4); tbl.Attach(_subtitle, 1, 2, 3, 4); tbl.Attach(new Gtk.Label("year:"), 0, 1, 4, 5); tbl.Attach(_year, 1, 2, 4, 5); Gtk.Frame frm = new Gtk.Frame(); frm.Add(tbl); Gtk.HBox hb2 = new Gtk.HBox(); hb2.PackEnd(_reload, false, false, 1); hb2.PackEnd(_del_track, false, false, 1); hb2.PackEnd(_add_track, false, false, 1); hb2.PackEnd(_save, false, false, 1); Gtk.HBox hb = new Gtk.HBox(); Gtk.VBox vb1 = new Gtk.VBox(); vb1.PackStart(frm, false, false, 0); vb1.PackStart(hb2, true, true, 0); hb.PackStart(vb1, false, false, 0); Gtk.Frame frm2 = new Gtk.Frame(); frm2.Add(_image); Gtk.VBox vbi = new Gtk.VBox(); Gtk.HBox bb = new Gtk.HBox(); bb.PackStart(new Gtk.VBox(), true, true, 0); bb.PackStart(frm2, false, false, 0); bb.PackEnd(new Gtk.VBox(), true, true, 0); vbi.PackStart(bb, true, true, 2); vbi.PackEnd(_imagefile, false, false, 2); hb.PackEnd(vbi, true, true, 2); Gtk.ScrolledWindow scroll = new Gtk.ScrolledWindow(); scroll.Add(_tracks); scroll.SetSizeRequest(800, 300); base.VBox.PackStart(hb, false, false, 4); base.VBox.PackStart(scroll, true, true, 0); base.VBox.ShowAll(); base.AddButton("Close", 0); }
protected override void DoSync() { if (!AllowPlaceholders) { return; } using (UndoManager.AtomicChange) { uint left, right, top, bottom; uint row, col; Gtk.Widget w; Gtk.Widget[,] grid; Gtk.Table.TableChild tc; Gtk.Widget[] children; bool addedPlaceholders = false; children = table.Children; grid = new Gtk.Widget[NRows, NColumns]; // First fill in the placeholders in the grid. If we find any // placeholders covering more than one grid square, remove them. // (New ones will be created below.) foreach (Gtk.Widget child in children) { if (!(child is Placeholder)) { continue; } tc = table[child] as Gtk.Table.TableChild; left = tc.LeftAttach; right = tc.RightAttach; top = tc.TopAttach; bottom = tc.BottomAttach; if (right == left + 1 && bottom == top + 1) { grid[top, left] = child; } else { table.Remove(child); child.Destroy(); } } // Now fill in the real widgets, knocking out any placeholders // they overlap. (If there are real widgets that overlap // placeholders, neither will be knocked out, and the layout // will probably end up wrong as well. But this situation // happens at least temporarily during glade import.) foreach (Gtk.Widget child in children) { if (child is Placeholder) { continue; } tc = table[child] as Gtk.Table.TableChild; left = tc.LeftAttach; right = tc.RightAttach; top = tc.TopAttach; bottom = tc.BottomAttach; for (row = top; row < bottom; row++) { for (col = left; col < right; col++) { w = grid[row, col]; if (w is Placeholder) { table.Remove(w); w.Destroy(); } grid[row, col] = child; } } } // Scan each row; if there are any empty cells, fill them in // with placeholders. If a row contains only placeholders, then // set them all to expand vertically so the row won't collapse. // OTOH, if the row contains any real widget, set any placeholders // in that row to not expand vertically, so they don't force the // real widgets to expand further than they should. If any row // is vertically expandable, then the table as a whole is. vexpandable = false; for (row = 0; row < NRows; row++) { bool allPlaceholders = true; for (col = 0; col < NColumns; col++) { w = grid[row, col]; if (w == null) { w = CreatePlaceholder(); table.Attach(w, col, col + 1, row, row + 1); NotifyChildAdded(w); grid[row, col] = w; addedPlaceholders = true; } else if (!ChildVExpandable(w) || !AutoSize[w]) { allPlaceholders = false; } } for (col = 0; col < NColumns; col++) { w = grid[row, col]; if (!AutoSize[w]) { continue; } tc = table[w] as Gtk.Table.TableChild; // We can't play with the vertical expansion property of // widgets which span more than one row if (tc.BottomAttach != tc.TopAttach + 1) { continue; } Gtk.AttachOptions opts = allPlaceholders ? expandOpts : fillOpts; if (tc.YOptions != opts) { tc.YOptions = opts; } } if (allPlaceholders) { vexpandable = true; } } // Now do the same for columns and horizontal expansion (but we // don't have to worry about empty cells this time). hexpandable = false; for (col = 0; col < NColumns; col++) { bool allPlaceholders = true; for (row = 0; row < NRows; row++) { w = grid[row, col]; if (!ChildHExpandable(w) || !AutoSize[w]) { allPlaceholders = false; break; } } for (row = 0; row < NRows; row++) { w = grid[row, col]; if (!AutoSize[w]) { continue; } tc = table[w] as Gtk.Table.TableChild; // We can't play with the horizontal expansion property of // widgets which span more than one column if (tc.RightAttach != tc.LeftAttach + 1) { continue; } Gtk.AttachOptions opts = allPlaceholders ? expandOpts : fillOpts; if (tc.XOptions != opts) { tc.XOptions = opts; } } if (allPlaceholders) { hexpandable = true; } } if (addedPlaceholders) { EmitContentsChanged(); } } }
Gtk.Widget CreateFakeWidget(string typeName) { Stetic.Custom c = new Stetic.Custom(); // Give it some default size c.WidthRequest = 20; c.HeightRequest = 20; Gtk.Container box = null; switch (typeClassDescriptor.Name) { case "Gtk.Alignment": box = new Gtk.Alignment(0.5f, 0.5f, 1f, 1f); break; case "Gtk.Fixed": box = new Gtk.Alignment(0.5f, 0.5f, 1f, 1f); break; case "Gtk.Frame": box = new Gtk.Frame(); break; case "Gtk.Box": case "Gtk.HBox": { Gtk.HBox cc = new Gtk.HBox(); cc.PackStart(c, true, true, 0); return(cc); } case "Gtk.VBox": { Gtk.VBox cc = new Gtk.VBox(); cc.PackStart(c, true, true, 0); return(cc); } case "Gtk.Paned": case "Gtk.VPaned": { Gtk.VPaned cc = new Gtk.VPaned(); cc.Add1(c); return(cc); } case "Gtk.HPaned": { Gtk.HPaned cc = new Gtk.HPaned(); cc.Add1(c); return(cc); } case "Gtk.Notebook": { Gtk.Notebook nb = new Gtk.Notebook(); nb.ShowTabs = false; nb.AppendPage(c, null); return(nb); } case "Gtk.ScrolledWindow": { Gtk.ScrolledWindow cc = new Gtk.ScrolledWindow(); cc.VscrollbarPolicy = Gtk.PolicyType.Never; cc.HscrollbarPolicy = Gtk.PolicyType.Never; cc.AddWithViewport(c); return(cc); } case "Gtk.Table": { Gtk.Table t = new Gtk.Table(1, 1, false); t.Attach(c, 0, 1, 0, 1); return(t); } case "Gtk.ButtonBox": return(new Gtk.HButtonBox()); } if (box != null) { box.Add(c); return(box); } else { Stetic.CustomWidget custom = new Stetic.CustomWidget(); if (custom.Child != null) { custom.Remove(custom.Child); } custom.Add(c); return(custom); } }
protected override Gtk.Widget CreateWidget(WindowContext context) { uint rows = 0; uint columns = 0; uint wrow = 0; uint wcolumn = 0; uint startrow = 0; uint startcolumn = 0; bool rowmode = GetAttribute<bool>("rowmode", true); rowmode = !GetAttribute<bool>("colmode", !rowmode); List<WidgetTableInfo> wlist = new List<WidgetTableInfo>(Childs.Count); foreach(IWidgetBuilder b in Childs) { WidgetTableInfo w = new WidgetTableInfo(); w.Widget = b.Build(context); startcolumn = b.GetAttribute<uint>("col", startcolumn); startrow = b.GetAttribute<uint>("row", startrow); wcolumn = b.GetAttribute<uint>("col", wcolumn); wrow = b.GetAttribute<uint>("row", wrow); if(b.GetAttribute<bool>("newcol", false)) { wrow = startrow; wcolumn = ++startcolumn; } else if(b.GetAttribute<bool>("newrow", false)) { wcolumn = startcolumn; wrow = ++startrow; } w.Left = wcolumn; w.Right = wcolumn + b.GetAttribute<uint>("colspan", 1u); w.Top = wrow; w.Bottom = wrow + b.GetAttribute<uint>("rowspan", 1u); if(!b.GetAttribute<bool>("xnoexpand", false)) w.XOptions |= Gtk.AttachOptions.Expand; if(!b.GetAttribute<bool>("xnofill", false)) w.XOptions |= Gtk.AttachOptions.Fill; if(b.GetAttribute<bool>("xshrink", false)) w.XOptions |= Gtk.AttachOptions.Shrink; if(!b.GetAttribute<bool>("ynoexpand", false)) w.YOptions |= Gtk.AttachOptions.Expand; if(!b.GetAttribute<bool>("ynofill", false)) w.YOptions |= Gtk.AttachOptions.Fill; if(b.GetAttribute<bool>("yshrink", false)) w.YOptions |= Gtk.AttachOptions.Shrink; w.XPadding = b.GetAttribute<uint>("xpadding", 0u); w.YPadding = b.GetAttribute<uint>("ypadding", 0u); wlist.Add(w); if(rows < w.Bottom) rows = (uint)w.Bottom; if(columns < w.Right) columns = (uint)w.Right; if(rowmode) wcolumn++; else wrow++; } Gtk.Table table = new Gtk.Table(rows, columns, GetAttribute<bool>("homogeneous", false)); List<Gtk.Widget> focuschain = new List<Gtk.Widget>(wlist.Count); foreach(WidgetTableInfo w in wlist) { table.Attach(w.Widget, w.Left, w.Right, w.Top, w.Bottom, w.XOptions, w.YOptions, w.XPadding, w.YPadding); if(w.Widget.CanFocus) focuschain.Add(w.Widget); } table.FocusChain = focuschain.ToArray(); return table; }
Gtk.Widget CreateFakeWidget (string typeName) { Stetic.Custom c = new Stetic.Custom (); // Give it some default size c.WidthRequest = 20; c.HeightRequest = 20; Gtk.Container box = null; switch (typeClassDescriptor.Name) { case "Gtk.Alignment": box = new Gtk.Alignment (0.5f, 0.5f, 1f, 1f); break; case "Gtk.Fixed": box = new Gtk.Alignment (0.5f, 0.5f, 1f, 1f); break; case "Gtk.Frame": box = new Gtk.Frame (); break; case "Gtk.Box": case "Gtk.HBox": { Gtk.HBox cc = new Gtk.HBox (); cc.PackStart (c, true, true, 0); return cc; } case "Gtk.VBox": { Gtk.VBox cc = new Gtk.VBox (); cc.PackStart (c, true, true, 0); return cc; } case "Gtk.Paned": case "Gtk.VPaned": { Gtk.VPaned cc = new Gtk.VPaned (); cc.Add1 (c); return cc; } case "Gtk.HPaned": { Gtk.HPaned cc = new Gtk.HPaned (); cc.Add1 (c); return cc; } case "Gtk.Notebook": { Gtk.Notebook nb = new Gtk.Notebook (); nb.ShowTabs = false; nb.AppendPage (c, null); return nb; } case "Gtk.ScrolledWindow": { Gtk.ScrolledWindow cc = new Gtk.ScrolledWindow (); cc.VscrollbarPolicy = Gtk.PolicyType.Never; cc.HscrollbarPolicy = Gtk.PolicyType.Never; cc.AddWithViewport (c); return cc; } case "Gtk.Table": { Gtk.Table t = new Gtk.Table (1, 1, false); t.Attach (c, 0, 1, 0, 1); return t; } case "Gtk.ButtonBox": return new Gtk.HButtonBox (); } if (box != null) { box.Add (c); return box; } else { Stetic.CustomWidget custom = new Stetic.CustomWidget (); if (custom.Child != null) custom.Remove (custom.Child); custom.Add (c); return custom; } }
//TODO: dropdown menus for picking string substitutions. also substitutions for port, ip public DebuggerOptionsDialog() : base( "Launch Soft Debugger", MonoDevelop.Ide.MessageService.RootWindow, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal) { properties = PropertyService.Get("MonoDevelop.Debugger.Soft.CustomSoftDebugger", new Properties()); AddActionWidget(new Gtk.Button(Gtk.Stock.Cancel), Gtk.ResponseType.Cancel); AddActionWidget(listenButton, listenResponse); AddActionWidget(connectButton, connectResponse); var table = new Gtk.Table(5, 2, false); table.BorderWidth = 6; VBox.PackStart(table, true, true, 0); table.Attach(new Gtk.Label(GettextCatalog.GetString("Command:")) { Xalign = 0 }, 0, 1, 0, 1); table.Attach(new Gtk.Label(GettextCatalog.GetString("Arguments:")) { Xalign = 0 }, 0, 1, 1, 2); table.Attach(new Gtk.Label(GettextCatalog.GetString("IP:")) { Xalign = 0 }, 0, 1, 2, 3); table.Attach(new Gtk.Label(GettextCatalog.GetString("Port:")) { Xalign = 0 }, 0, 1, 3, 4); table.Attach(new Gtk.Label(GettextCatalog.GetString("Output:")) { Xalign = 0 }, 0, 1, 4, 5); table.Attach(commandEntry, 1, 2, 0, 1); table.Attach(argsEntry, 1, 2, 1, 2); table.Attach(ipEntry, 1, 2, 2, 3); table.Attach(portEntry, 1, 2, 3, 4); table.Attach(consolePortEntry, 1, 2, 4, 5); argsEntry.WidthRequest = 500; commandEntry.PathChanged += delegate { try { //check it parses MonoDevelop.Core.StringParserService.Parse(commandEntry.Path); command = commandEntry.Path; } catch { command = null; } CheckValid(); }; argsEntry.Changed += delegate { try { //check it parses MonoDevelop.Core.StringParserService.Parse(argsEntry.Text); args = argsEntry.Text; } catch { args = null; } CheckValid(); }; ipEntry.Changed += delegate { if (string.IsNullOrEmpty(ipEntry.Text)) { ip = IPAddress.Loopback; } else if (!IPAddress.TryParse(ipEntry.Text, out ip)) { ip = null; } CheckValid(); }; portEntry.Changed += delegate { port = ParsePort(portEntry.Text); CheckValid(); }; consolePortEntry.Changed += delegate { consolePort = ParsePort(consolePortEntry.Text); CheckValid(); }; command = properties.Get("Command", ""); args = properties.Get("Arguments", ""); if (!IPAddress.TryParse(properties.Get("IpAddress", "127.0.0.1"), out ip) || ip == null) { ip = IPAddress.Loopback; } string portStr = properties.Get <string> ("Port"); port = ParsePort(portStr) ?? 10000; string consolePortStr = properties.Get <string> ("ConsolePort"); consolePort = ParsePort(consolePortStr); commandEntry.Path = command; argsEntry.Text = args; ipEntry.Text = ip.ToString(); portEntry.Text = PortToString(port) ?? ""; consolePortEntry.Text = PortToString(consolePort) ?? ""; CheckValid(); VBox.ShowAll(); }
public void Attach(Gtk.Table table, uint row, uint col) { table.Attach(this, col, col + 3, row, row + 1); Show(); AttachChildren(table, row, col); }
void SetImagePosition() { if (Control.Child != null) { Control.Remove(Control.Child); } (label.Parent as Gtk.Container)?.Remove(label); (gtkimage?.Parent as Gtk.Container)?.Remove(gtkimage); Gtk.Widget child = null; var showImage = Image != null; var showLabel = !string.IsNullOrEmpty(label.Text); if (showImage && showLabel) { Gtk.VBox vbox; Gtk.HBox hbox; switch (ImagePosition) { case ButtonImagePosition.Above: child = vbox = new Gtk.VBox(false, 2); vbox.PackStart(gtkimage, true, true, 0); vbox.PackEnd(label, false, true, 0); break; case ButtonImagePosition.Below: child = vbox = new Gtk.VBox(false, 2); vbox.PackStart(label, false, true, 0); vbox.PackEnd(gtkimage, true, true, 0); break; case ButtonImagePosition.Left: child = hbox = new Gtk.HBox(false, 2); hbox.PackStart(gtkimage, false, true, 0); hbox.PackStart(label, true, true, 0); break; case ButtonImagePosition.Right: child = hbox = new Gtk.HBox(false, 2); hbox.PackStart(label, true, true, 0); hbox.PackEnd(gtkimage, false, true, 0); break; case ButtonImagePosition.Overlay: #if GTK2 var table = new Gtk.Table(1, 1, false); child = table; table.Attach(label, 0, 0, 1, 1, Gtk.AttachOptions.Expand, Gtk.AttachOptions.Expand, 0, 0); table.Attach(gtkimage, 0, 0, 1, 1, Gtk.AttachOptions.Expand, Gtk.AttachOptions.Expand, 0, 0); #else var grid = new Gtk.Grid(); child = grid; label.Hexpand = label.Vexpand = true; gtkimage.Hexpand = gtkimage.Vexpand = true; grid.Attach(label, 0, 0, 1, 1); grid.Attach(gtkimage, 0, 0, 1, 1); #endif break; default: throw new NotSupportedException(); } } else if (showLabel) { child = label; } else if (showImage) { child = gtkimage; } if (child != null) { child.Show(); Control.Child = child; } Control.QueueResize(); }
public ValueReferenceEditor(Project p, ValueReferenceGroup vrg, int rows, string frameText = null) : base(1.0F, 1.0F, 1.0F, 1.0F) { Project = p; valueReferenceGroup = vrg; maxBounds = new int[valueReferenceGroup.GetNumValueReferences()]; widgetPositions = new Tuple <uint, uint> [maxBounds.Count]; widgets = new Gtk.Widget[maxBounds.Count]; helpButtonContainers = new Gtk.Container[maxBounds.Count]; table = new Gtk.Table(2, 2, false); uint x = 0, y = 0; int cnt = 0; foreach (ValueReference r in valueReferenceGroup.GetValueReferences()) { int index = cnt; cnt++; if (y >= rows) { y = 0; x += 3; } widgetPositions[index] = new Tuple <uint, uint>(x, y); // If it has a ConstantsMapping, use a combobox instead of anything else if (r.ConstantsMapping != null) { ComboBoxFromConstants comboBox = new ComboBoxFromConstants(false); comboBox.SetConstantsMapping(r.ConstantsMapping); comboBox.Changed += delegate(object sender, EventArgs e) { r.SetValue(comboBox.ActiveValue); OnDataModifiedInternal(); }; dataModifiedExternalEvent += delegate() { comboBox.ActiveValue = r.GetIntValue(); }; table.Attach(new Gtk.Label(r.Name), x + 0, x + 1, y, y + 1); table.Attach(comboBox, x + 1, x + 2, y, y + 1); widgets[index] = comboBox; helpButtonContainers[index] = new Gtk.HBox(); table.Attach(helpButtonContainers[index], x + 2, x + 3, y, y + 1, 0, Gtk.AttachOptions.Fill, 0, 0); goto loopEnd; } // ConstantsMapping == null switch (r.ValueType) { case DataValueType.String: default: { table.Attach(new Gtk.Label(r.Name), x + 0, x + 1, y, y + 1); Gtk.Entry entry = new Gtk.Entry(); if (!r.Editable) { entry.Sensitive = false; } dataModifiedExternalEvent += delegate() { entry.Text = r.GetStringValue(); OnDataModifiedInternal(); }; table.Attach(entry, x + 1, x + 2, y, y + 1); widgets[index] = entry; helpButtonContainers[index] = new Gtk.HBox(); table.Attach(helpButtonContainers[index], x + 2, x + 3, y, y + 1, 0, Gtk.AttachOptions.Fill, 0, 0); break; } case DataValueType.Byte: case DataValueType.HalfByte: byteCase: { table.Attach(new Gtk.Label(r.Name), x + 0, x + 1, y, y + 1); SpinButtonHexadecimal spinButton = new SpinButtonHexadecimal(0, 255); if (!r.Editable) { spinButton.Sensitive = false; } if (r.ValueType == DataValueType.HalfByte) { spinButton.Digits = 1; spinButton.Adjustment.Upper = 15; } else { spinButton.Digits = 2; } spinButton.ValueChanged += delegate(object sender, EventArgs e) { Gtk.SpinButton button = sender as Gtk.SpinButton; if (maxBounds[index] == 0 || button.ValueAsInt <= maxBounds[index]) { r.SetValue(button.ValueAsInt); } else { button.Value = maxBounds[index]; } OnDataModifiedInternal(); }; dataModifiedExternalEvent += delegate() { spinButton.Value = r.GetIntValue(); }; table.Attach(spinButton, x + 1, x + 2, y, y + 1); widgets[index] = spinButton; helpButtonContainers[index] = new Gtk.HBox(); table.Attach(helpButtonContainers[index], x + 2, x + 3, y, y + 1, 0, Gtk.AttachOptions.Fill, 0, 0); } break; case DataValueType.WarpDestIndex: { Gtk.Button newDestButton = new Gtk.Button("New\nDestination"); newDestButton.Clicked += delegate(object sender, EventArgs e) { WarpSourceData warpData = (WarpSourceData)r.Data; WarpDestGroup destGroup = warpData.GetReferencedDestGroup(); // Check if there's unused destination data // already for (int i = 0; i < destGroup.GetNumWarpDests(); i++) { WarpDestData destData = destGroup.GetWarpDest(i); if (destData.GetNumReferences() == 0) { Gtk.MessageDialog d = new Gtk.MessageDialog(null, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Warning, Gtk.ButtonsType.YesNo, "Destination index " + i.ToString("X2") + " is not used by any sources. Use this index?\n\n(\"No\" will create a new destination instead.)"); Gtk.ResponseType response = (Gtk.ResponseType)d.Run(); d.Destroy(); if (response == Gtk.ResponseType.Yes) { warpData.SetDestData(destGroup.GetWarpDest(i)); } else if (response == Gtk.ResponseType.No) { warpData.SetDestData(destGroup.AddDestData()); } break; } } }; table.Attach(newDestButton, x + 2, x + 3, y, y + 2); } goto byteCase; case DataValueType.Word: { table.Attach(new Gtk.Label(r.Name), x + 0, x + 1, y, y + 1); SpinButtonHexadecimal spinButton = new SpinButtonHexadecimal(0, 0xffff); if (!r.Editable) { spinButton.Sensitive = false; } spinButton.Digits = 4; spinButton.ValueChanged += delegate(object sender, EventArgs e) { Gtk.SpinButton button = sender as Gtk.SpinButton; if (maxBounds[index] == 0 || button.ValueAsInt <= maxBounds[index]) { r.SetValue(button.ValueAsInt); } else { button.Value = maxBounds[index]; } OnDataModifiedInternal(); }; dataModifiedExternalEvent += delegate() { spinButton.Value = r.GetIntValue(); }; table.Attach(spinButton, x + 1, x + 2, y, y + 1); widgets[index] = spinButton; helpButtonContainers[index] = new Gtk.HBox(); table.Attach(helpButtonContainers[index], x + 2, x + 3, y, y + 1, 0, Gtk.AttachOptions.Fill, 0, 0); } break; case DataValueType.ByteBit: { table.Attach(new Gtk.Label(r.Name), x + 0, x + 1, y, y + 1); Gtk.CheckButton checkButton = new Gtk.CheckButton(); checkButton.CanFocus = false; if (!r.Editable) { checkButton.Sensitive = false; } checkButton.Toggled += delegate(object sender, EventArgs e) { Gtk.CheckButton button = sender as Gtk.CheckButton; r.SetValue(button.Active ? 1 : 0); OnDataModifiedInternal(); }; dataModifiedExternalEvent += delegate() { checkButton.Active = r.GetIntValue() == 1; }; table.Attach(checkButton, x + 1, x + 2, y, y + 1); widgets[index] = checkButton; helpButtonContainers[index] = new Gtk.HBox(); table.Attach(helpButtonContainers[index], x + 2, x + 3, y, y + 1, 0, Gtk.AttachOptions.Fill, 0, 0); } break; case DataValueType.ByteBits: case DataValueType.WordBits: { table.Attach(new Gtk.Label(r.Name), x + 0, x + 1, y, y + 1); SpinButtonHexadecimal spinButton = new SpinButtonHexadecimal(0, r.MaxValue); if (!r.Editable) { spinButton.Sensitive = false; } spinButton.Digits = (uint)Math.Pow(r.MaxValue, ((double)1) / 16) + 1; spinButton.ValueChanged += delegate(object sender, EventArgs e) { Gtk.SpinButton button = sender as Gtk.SpinButton; if (maxBounds[index] == 0 || button.ValueAsInt <= maxBounds[index]) { r.SetValue(button.ValueAsInt); } else { button.Value = maxBounds[index]; } OnDataModifiedInternal(); }; dataModifiedExternalEvent += delegate() { spinButton.Value = r.GetIntValue(); }; table.Attach(spinButton, x + 1, x + 2, y, y + 1); widgets[index] = spinButton; helpButtonContainers[index] = new Gtk.HBox(); table.Attach(helpButtonContainers[index], x + 2, x + 3, y, y + 1, 0, Gtk.AttachOptions.Fill, 0, 0); } break; case DataValueType.ObjectPointer: { table.Attach(new Gtk.Label(r.Name), x + 0, x + 1, y, y + 1); Gtk.Entry entry = new Gtk.Entry(); if (!r.Editable) { entry.Sensitive = false; } entry.Changed += delegate(object sender, EventArgs e) { UpdatePointerTextBox(sender as Gtk.Entry, r); OnDataModifiedInternal(); }; table.Attach(entry, x + 1, x + 2, y, y + 1); widgets[index] = entry; pointerFrame = new Gtk.Frame(); pointerFrame.Label = "Pointer data (possibly shared)"; pointerFrame.BorderWidth = 5; y++; table.Attach(pointerFrame, x + 0, x + 2, y, y + 1); dataModifiedExternalEvent += delegate() { entry.Text = r.GetStringValue(); UpdatePointerTextBox(entry, r); }; helpButtonContainers[index] = new Gtk.HBox(); table.Attach(helpButtonContainers[index], x + 2, x + 3, y, y + 1, 0, Gtk.AttachOptions.Fill, 0, 0); } break; } loopEnd: y++; } table.ColumnSpacing = 6; if (frameText != null) { var frame = new Gtk.Frame(frameText); frame.Add(table); this.Add(frame); } else { this.Add(table); } this.ShowAll(); Data lastData = null; foreach (ValueReference r in valueReferenceGroup.GetValueReferences()) { if (lastData != r.Data) { lastData = r.Data; r.Data.AddDataModifiedHandler(OnDataModifiedExternal); // Destroy handler this.Destroyed += delegate(object sender, EventArgs e) { r.Data.RemoveDataModifiedHandler(OnDataModifiedExternal); }; } } // Initial values if (dataModifiedExternalEvent != null) { dataModifiedExternalEvent(); } UpdateHelpButtons(); }
public DocumentationDialog(Documentation _doc) { ContentArea.PackStart(VBox, true, true, 0); documentation = _doc; Gtk.Label nameLabel = new Gtk.Label("<b>" + documentation.Name + "</b>"); nameLabel.Wrap = true; nameLabel.UseUnderline = false; nameLabel.UseMarkup = true; nameLabel.Xalign = 0.5f; VBox.PackStart(nameLabel, false, false, 10); string desc = documentation.Description; if (desc == null) { desc = ""; } var subidEntries = documentation.Keys; Gtk.Label descLabel = new Gtk.Label(desc); descLabel.Wrap = true; descLabel.UseUnderline = false; descLabel.Xalign = 0; descLabel.WidthChars = 50; descLabel.MaxWidthChars = 50; VBox.PackStart(descLabel, false, false, 0); // Create SubID table if (subidEntries.Count > 0) { Gtk.Label valuesLabel = new Gtk.Label("\nValues:"); valuesLabel.UseUnderline = false; valuesLabel.Xalign = 0; VBox.PackStart(valuesLabel, false, false, 0); Gtk.Table subidTable = new Gtk.Table(2, (uint)subidEntries.Count * 2, false); uint subidX = 0; uint subidY = 0; foreach (string key in subidEntries) { string value = documentation.GetField(key); Gtk.Label l1 = new Gtk.Label(key); l1.UseUnderline = false; l1.Xalign = 0; l1.Yalign = 0; Gtk.Label l2 = new Gtk.Label(value); l2.UseUnderline = false; l2.Wrap = true; l2.Xalign = 0; l2.Yalign = 0; l2.WidthChars = 50; l2.MaxWidthChars = 50; subidTable.Attach(l1, subidX + 0, subidX + 1, subidY, subidY + 1, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 4, 0); subidTable.Attach(l2, subidX + 2, subidX + 3, subidY, subidY + 1); subidY++; subidTable.Attach(new Gtk.HSeparator(), subidX + 0, subidX + 3, subidY, subidY + 1, Gtk.AttachOptions.Fill, 0, 0, 0); subidY++; } subidTable.Attach(new Gtk.VSeparator(), subidX + 1, subidX + 2, 0, subidTable.NRows, 0, Gtk.AttachOptions.Fill, 4, 0); Gtk.ScrolledWindow scrolledWindow = new Gtk.ScrolledWindow(); scrolledWindow.AddWithViewport(subidTable); scrolledWindow.ShadowType = Gtk.ShadowType.EtchedIn; scrolledWindow.SetPolicy(Gtk.PolicyType.Never, Gtk.PolicyType.Automatic); subidTable.ShowAll(); // Determine width/height to request on scrolledWindow Gtk.Requisition subidTableRequest = subidTable.SizeRequest(); int width = Math.Min(subidTableRequest.Width + 20, 700); width = Math.Max(width, 400); int height = Math.Min(subidTableRequest.Height + 5, 400); height = Math.Max(height, 200); scrolledWindow.SetSizeRequest(width, height); VBox.PackStart(scrolledWindow, true, true, 0); } AddActionWidget(new Gtk.Button("gtk-ok"), 0); ShowAll(); }
public void CreateGui() { Gtk.Image icn_reload=new Gtk.Image(Gtk.Stock.Refresh,Gtk.IconSize.Button); _reload=new Gtk.Button(icn_reload); _reload.Clicked+=OnReload; _performer=new Gtk.Entry(200); _title=new Gtk.Entry(200); _title.WidthChars=60; _performer.WidthChars=60; _subtitle=new Gtk.Entry(300); _subtitle.WidthChars=60; _composer=new Gtk.Entry(200); _composer.WidthChars=60; _year=new Gtk.Entry(20); _year.WidthChars=20; _image=new Gtk.Image(); _image.SetSizeRequest (100,100); _imagefile=new Gtk.FileChooserButton("Choose image file",Gtk.FileChooserAction.Open); _imagefile.FileSet+=new EventHandler(EvtImageSet); Gtk.Image icn_add_track=new Gtk.Image(Gtk.Stock.Add,Gtk.IconSize.Button); _add_track=new Gtk.Button(icn_add_track); _add_track.Clicked+=OnAddTrack; Gtk.Image icn_del_track=new Gtk.Image(Gtk.Stock.Delete,Gtk.IconSize.Button); _del_track=new Gtk.Button(icn_del_track); _del_track.Clicked+=OnDelTrack; Gtk.Image icn_save=new Gtk.Image(Gtk.Stock.Save,Gtk.IconSize.Button); _save=new Gtk.Button(icn_save); _save.Clicked+=OnSave; _store=new Gtk.ListStore(typeof(int),typeof(string),typeof(string),typeof(string),typeof(string),typeof(string)); _tracks=new Gtk.TreeView(); { Gtk.CellRendererText cr0=new Gtk.CellRendererText(); cr0.Scale=0.8; _tracks.AppendColumn ("Nr.", cr0, "text", 0); Gtk.CellRendererText cr_title=new Gtk.CellRendererText(); cr_title.Scale=0.8; cr_title.Editable=true; cr_title.Edited+=new Gtk.EditedHandler(delegate(object sender,Gtk.EditedArgs args) { setCell(1,args.NewText,new Gtk.TreePath(args.Path)); }); _tracks.AppendColumn ("Title", cr_title, "text", 1); Gtk.CellRendererText cr_artist=new Gtk.CellRendererText(); cr_artist.Editable=true; cr_artist.Scale=0.8; cr_artist.Edited+=new Gtk.EditedHandler(delegate(object sender,Gtk.EditedArgs args) { setCell(2,args.NewText,new Gtk.TreePath(args.Path)); }); _tracks.AppendColumn ("Artist", cr_artist, "text", 2); Gtk.CellRendererText cr_composer=new Gtk.CellRendererText(); cr_composer.Editable=true; cr_composer.Scale=0.8; cr_composer.Edited+=new Gtk.EditedHandler(delegate(object sender,Gtk.EditedArgs args) { setCell(3,args.NewText,new Gtk.TreePath(args.Path)); }); _tracks.AppendColumn ("Composer", cr_composer, "text", 3); Gtk.CellRendererText cr_piece=new Gtk.CellRendererText(); cr_piece.Editable=true; cr_piece.Scale=0.8; cr_piece.Edited+=new Gtk.EditedHandler(delegate(object sender,Gtk.EditedArgs args) { setCell(4,args.NewText,new Gtk.TreePath(args.Path)); }); _tracks.AppendColumn ("Piece", cr_piece, "text", 4); Gtk.CellRendererText cr_time=new Gtk.CellRendererText(); cr_time.Editable=true; cr_time.Scale=0.8; cr_time.Edited+=new Gtk.EditedHandler(delegate(object sender,Gtk.EditedArgs args) { setCell (5,args.NewText,new Gtk.TreePath(args.Path)); }); _tracks.AppendColumn ("Offset", cr_time, "text", 5); } _tracks.Model = _store; Gtk.Table tbl=new Gtk.Table(2,5,false); tbl.Attach (new Gtk.Label("Album:"),0,1,0,1); tbl.Attach (_title,1,2,0,1); tbl.Attach (new Gtk.Label("Artist:"),0,1,1,2); tbl.Attach (_performer,1,2,1,2); tbl.Attach (new Gtk.Label("Composer:"),0,1,2,3); tbl.Attach (_composer,1,2,2,3); tbl.Attach (new Gtk.Label("Subtitle:"),0,1,3,4); tbl.Attach (_subtitle,1,2,3,4); tbl.Attach (new Gtk.Label("year:"),0,1,4,5); tbl.Attach (_year,1,2,4,5); Gtk.Frame frm=new Gtk.Frame(); frm.Add (tbl); Gtk.HBox hb2=new Gtk.HBox(); hb2.PackEnd (_reload,false,false,1); hb2.PackEnd (_del_track,false,false,1); hb2.PackEnd (_add_track,false,false,1); hb2.PackEnd (_save,false,false,1); Gtk.HBox hb=new Gtk.HBox(); Gtk.VBox vb1=new Gtk.VBox(); vb1.PackStart (frm,false,false,0); vb1.PackStart (hb2,true,true,0); hb.PackStart (vb1,false,false,0); Gtk.Frame frm2=new Gtk.Frame(); frm2.Add (_image); Gtk.VBox vbi=new Gtk.VBox(); Gtk.HBox bb=new Gtk.HBox(); bb.PackStart(new Gtk.VBox(),true,true,0); bb.PackStart(frm2,false,false,0); bb.PackEnd (new Gtk.VBox(),true,true,0); vbi.PackStart (bb,true,true,2); vbi.PackEnd (_imagefile,false,false,2); hb.PackEnd (vbi,true,true,2); Gtk.ScrolledWindow scroll=new Gtk.ScrolledWindow(); scroll.Add (_tracks); scroll.SetSizeRequest (800,300); base.VBox.PackStart(hb,false,false,4); base.VBox.PackStart(scroll,true,true,0); base.VBox.ShowAll (); base.AddButton ("Close",0); }
// Page 2 // List of Hotkey options public Gtk.Widget MakeHotkeysPane () { Gtk.Label label; Gtk.CheckButton check; Gtk.Alignment align; Gtk.Entry entry; IPropertyEditorBool keybind_peditor; IPropertyEditor peditor; Gtk.VBox hotkeys_list = new Gtk.VBox (false, 12); hotkeys_list.BorderWidth = 12; hotkeys_list.Show (); // Hotkeys... check = MakeCheckButton (Catalog.GetString ("Listen for _Hotkeys")); hotkeys_list.PackStart (check, false, false, 0); keybind_peditor = Services.Factory.CreatePropertyEditorToggleButton (Preferences.ENABLE_KEYBINDINGS, check); SetupPropertyEditor (keybind_peditor); label = MakeTipLabel ( Catalog.GetString ("Hotkeys allow you to quickly access " + "your notes from anywhere with a keypress. " + "Example Hotkeys: " + "<b><Control><Shift>F11</b>, " + "<b><Alt>N</b>")); hotkeys_list.PackStart (label, false, false, 0); align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 1.0f); align.Show (); hotkeys_list.PackStart (align, false, false, 0); Gtk.Table table = new Gtk.Table (4, 2, false); table.ColumnSpacing = 6; table.RowSpacing = 6; table.Show (); align.Add (table); // Show notes menu keybinding... label = MakeLabel (Catalog.GetString ("Show notes _menu")); table.Attach (label, 0, 1, 0, 1); entry = new Gtk.Entry (); label.MnemonicWidget = entry; entry.Show (); table.Attach (entry, 1, 2, 0, 1); peditor = Services.Factory.CreatePropertyEditorEntry (Preferences.KEYBINDING_SHOW_NOTE_MENU, entry); SetupPropertyEditor (peditor); keybind_peditor.AddGuard (entry); // Open Start Here keybinding... label = MakeLabel (Catalog.GetString ("Open \"_Start Here\"")); table.Attach (label, 0, 1, 1, 2); entry = new Gtk.Entry (); label.MnemonicWidget = entry; entry.Show (); table.Attach (entry, 1, 2, 1, 2); peditor = Services.Factory.CreatePropertyEditorEntry (Preferences.KEYBINDING_OPEN_START_HERE, entry); SetupPropertyEditor (peditor); keybind_peditor.AddGuard (entry); // Create new note keybinding... label = MakeLabel (Catalog.GetString ("Create _new note")); table.Attach (label, 0, 1, 2, 3); entry = new Gtk.Entry (); label.MnemonicWidget = entry; entry.Show (); table.Attach (entry, 1, 2, 2, 3); peditor = Services.Factory.CreatePropertyEditorEntry (Preferences.KEYBINDING_CREATE_NEW_NOTE, entry); SetupPropertyEditor (peditor); keybind_peditor.AddGuard (entry); // Open Search All Notes window keybinding... label = MakeLabel (Catalog.GetString ("Open \"Search _All Notes\"")); table.Attach (label, 0, 1, 3, 4); entry = new Gtk.Entry (); label.MnemonicWidget = entry; entry.Show (); table.Attach (entry, 1, 2, 3, 4); peditor = Services.Factory.CreatePropertyEditorEntry ( Preferences.KEYBINDING_OPEN_RECENT_CHANGES, entry); SetupPropertyEditor (peditor); keybind_peditor.AddGuard (entry); return hotkeys_list; }
public ValueReferenceEditor(Project p, ValueReferenceGroup vrg, int rows, string frameText=null) : base(1.0F,1.0F,1.0F,1.0F) { Project = p; valueReferenceGroup = vrg; maxBounds = new int[valueReferenceGroup.GetNumValueReferences()]; widgetPositions = new Tuple<uint,uint>[maxBounds.Count]; widgets = new Gtk.Widget[maxBounds.Count]; table = new Gtk.Table(2, 2, false); uint x=0,y=0; int cnt=0; foreach (ValueReference r in valueReferenceGroup.GetValueReferences()) { int index = cnt; cnt++; if (y >= rows) { y = 0; x += 3; } widgetPositions[index] = new Tuple<uint,uint>(x,y); if (r.ConstantsMapping != null) { ComboBoxFromConstants comboBox = new ComboBoxFromConstants(); comboBox.SetConstantsMapping(r.ConstantsMapping); comboBox.Changed += delegate(object sender, EventArgs e) { r.SetValue(comboBox.ActiveValue); }; dataModifiedExternalEvent += delegate() { comboBox.ActiveValue = r.GetIntValue(); }; table.Attach(new Gtk.Label(r.Name), x+0,x+1,y,y+1); table.Attach(comboBox, x+1,x+2,y,y+1); widgets[index] = comboBox; goto loopEnd; } // ConstantsMapping == null switch(r.ValueType) { case DataValueType.String: default: { table.Attach(new Gtk.Label(r.Name), x+0,x+1, y, y+1); Gtk.Entry entry = new Gtk.Entry(); if (!r.Editable) entry.Sensitive = false; dataModifiedExternalEvent += delegate() { entry.Text = r.GetStringValue(); OnDataModifiedInternal(); }; table.Attach(entry, x+1,x+2, y, y+1); widgets[index] = entry; break; } case DataValueType.Byte: case DataValueType.HalfByte: byteCase: { table.Attach(new Gtk.Label(r.Name), x+0,x+1, y, y+1); SpinButtonHexadecimal spinButton = new SpinButtonHexadecimal(0,255); if (!r.Editable) spinButton.Sensitive = false; if (r.ValueType == DataValueType.HalfByte) { spinButton.Digits = 1; spinButton.Adjustment.Upper = 15; } else spinButton.Digits = 2; spinButton.ValueChanged += delegate(object sender, EventArgs e) { Gtk.SpinButton button = sender as Gtk.SpinButton; if (maxBounds[index] == 0 || button.ValueAsInt <= maxBounds[index]) { r.SetValue(button.ValueAsInt); } else button.Value = maxBounds[index]; OnDataModifiedInternal(); }; dataModifiedExternalEvent += delegate() { spinButton.Value = r.GetIntValue(); }; table.Attach(spinButton, x+1,x+2, y, y+1); widgets[index] = spinButton; } break; case DataValueType.WarpDestIndex: { Gtk.Button newDestButton = new Gtk.Button("New\nDestination"); newDestButton.Clicked += delegate(object sender, EventArgs e) { WarpSourceData warpData = (WarpSourceData)r.Data; WarpDestGroup destGroup = warpData.GetReferencedDestGroup(); // Check if there's unused destination data // already for (int i=0; i<destGroup.GetNumWarpDests(); i++) { WarpDestData destData = destGroup.GetWarpDest(i); if (destData.GetNumReferences() == 0) { Gtk.MessageDialog d = new Gtk.MessageDialog(null, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Warning, Gtk.ButtonsType.YesNo, "Destination index " + i.ToString("X2") + " is not used by any sources. Use this index?\n\n(\"No\" will create a new destination instead.)"); Gtk.ResponseType response = (Gtk.ResponseType)d.Run(); d.Destroy(); if (response == Gtk.ResponseType.Yes) warpData.SetDestData(destGroup.GetWarpDest(i)); else if (response == Gtk.ResponseType.No) warpData.SetDestData(destGroup.AddDestData()); break; } } }; table.Attach(newDestButton, x+2,x+3, y, y+2); } goto byteCase; case DataValueType.Word: { table.Attach(new Gtk.Label(r.Name), x+0,x+1, y, y+1); SpinButtonHexadecimal spinButton = new SpinButtonHexadecimal(0,0xffff); if (!r.Editable) spinButton.Sensitive = false; spinButton.Digits = 4; spinButton.ValueChanged += delegate(object sender, EventArgs e) { Gtk.SpinButton button = sender as Gtk.SpinButton; if (maxBounds[index] == 0 || button.ValueAsInt <= maxBounds[index]) { r.SetValue(button.ValueAsInt); } else button.Value = maxBounds[index]; OnDataModifiedInternal(); }; dataModifiedExternalEvent += delegate() { spinButton.Value = r.GetIntValue(); }; table.Attach(spinButton, x+1,x+2, y, y+1); widgets[index] = spinButton; } break; case DataValueType.ByteBit: { table.Attach(new Gtk.Label(r.Name), x+0,x+1, y, y+1); Gtk.CheckButton checkButton = new Gtk.CheckButton(); checkButton.CanFocus = false; if (!r.Editable) checkButton.Sensitive = false; checkButton.Toggled += delegate(object sender, EventArgs e) { Gtk.CheckButton button = sender as Gtk.CheckButton; r.SetValue(button.Active ? 1 : 0); OnDataModifiedInternal(); }; dataModifiedExternalEvent += delegate() { checkButton.Active = r.GetIntValue() == 1; }; table.Attach(checkButton, x+1,x+2, y, y+1); widgets[index] = checkButton; } break; case DataValueType.ByteBits: { table.Attach(new Gtk.Label(r.Name), x+0,x+1, y, y+1); SpinButtonHexadecimal spinButton = new SpinButtonHexadecimal(0,r.MaxValue); if (!r.Editable) spinButton.Sensitive = false; spinButton.Digits = (uint)((r.MaxValue+0xf)/0x10); spinButton.ValueChanged += delegate(object sender, EventArgs e) { Gtk.SpinButton button = sender as Gtk.SpinButton; if (maxBounds[index] == 0 || button.ValueAsInt <= maxBounds[index]) { r.SetValue(button.ValueAsInt); } else button.Value = maxBounds[index]; OnDataModifiedInternal(); }; dataModifiedExternalEvent += delegate() { spinButton.Value = r.GetIntValue(); }; table.Attach(spinButton, x+1,x+2, y, y+1); widgets[index] = spinButton; } break; case DataValueType.ObjectPointer: { table.Attach(new Gtk.Label(r.Name), x+0,x+1, y, y+1); Gtk.Entry entry = new Gtk.Entry(); if (!r.Editable) entry.Sensitive = false; entry.Changed += delegate(object sender, EventArgs e) { UpdatePointerTextBox(sender as Gtk.Entry, r); OnDataModifiedInternal(); }; table.Attach(entry, x+1,x+2, y, y+1); widgets[index] = entry; pointerFrame = new Gtk.Frame(); pointerFrame.Label = "Pointer data (possibly shared)"; pointerFrame.BorderWidth = 5; y++; table.Attach(pointerFrame, x+0,x+2, y, y+1); dataModifiedExternalEvent += delegate() { entry.Text = r.GetStringValue(); UpdatePointerTextBox(entry, r); }; } break; } loopEnd: y++; } table.ColumnSpacing = 6; if (frameText != null) { var frame = new Gtk.Frame(frameText); frame.Add(table); this.Add(frame); } else this.Add(table); this.ShowAll(); Data lastData = null; foreach (ValueReference r in valueReferenceGroup.GetValueReferences()) { if (lastData != r.Data) { lastData = r.Data; r.Data.AddDataModifiedHandler(OnDataModifiedExternal); // Destroy handler this.Destroyed += delegate(object sender, EventArgs e) { r.Data.RemoveDataModifiedHandler(OnDataModifiedExternal); }; } } // Initial values if (dataModifiedExternalEvent != null) dataModifiedExternalEvent(); }