private void AttachWidgets(TextView textView) { // This is really different from the C version, but the // C versions seems a little pointless. Button button = new Button("Click Me"); button.Clicked += new EventHandler(EasterEggCB); textView.AddChildAtAnchor(button, buttonAnchor); button.ShowAll(); ComboBox combo = ComboBox.NewText(); combo.AppendText("Option 1"); combo.AppendText("Option 2"); combo.AppendText("Option 3"); textView.AddChildAtAnchor(combo, menuAnchor); HScale scale = new HScale(null); scale.SetRange(0, 100); scale.SetSizeRequest(70, -1); textView.AddChildAtAnchor(scale, scaleAnchor); scale.ShowAll(); Gtk.Image image = Gtk.Image.LoadFromResource("floppybuddy.gif"); textView.AddChildAtAnchor(image, animationAnchor); image.ShowAll(); Entry entry = new Entry(); textView.AddChildAtAnchor(entry, entryAnchor); entry.ShowAll(); }
private void RecursiveAttach(int depth, TextView view, TextChildAnchor anchor) { if (depth > 4) { return; } TextView childView = new TextView(view.Buffer); // Event box is to add a black border around each child view EventBox eventBox = new EventBox(); Gdk.Color color = new Gdk.Color(); Gdk.Color.Parse("black", ref color); eventBox.ModifyBg(StateType.Normal, color); Alignment align = new Alignment(0.5f, 0.5f, 1.0f, 1.0f); align.BorderWidth = 1; eventBox.Add(align); align.Add(childView); view.AddChildAtAnchor(eventBox, anchor); RecursiveAttach(depth + 1, childView, anchor); }
private void AddButtonToStatusWindow(string buttonName, int buttonID) { TextIter iter = StatusWindow.Buffer.EndIter; TextChildAnchor anchor = StatusWindow.Buffer.CreateChildAnchor(ref iter); EventBox box = new EventBox(); ApsimNG.Classes.CustomButton moreInfo = new ApsimNG.Classes.CustomButton(buttonName, buttonID); moreInfo.Clicked += ShowDetailedErrorMessage; box.Add(moreInfo); StatusWindow.AddChildAtAnchor(box, anchor); box.ShowAll(); box.Realize(); box.ShowAll(); moreInfo.ParentWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Arrow); }
public CASGui() : base("CAS.NET") { textView = new TextView(); buffer = textView.Buffer; DeleteEvent += (o, a) => Application.Quit(); SetSizeRequest(300, 500); #region Menu MenuBar menuBar = new MenuBar(); Menu fileMenu = new Menu(); Menu addMenu = new Menu(); Menu serverMenu = new Menu(); MenuItem file = new MenuItem("File"); file.Submenu = fileMenu; MenuItem newFile = new MenuItem("New File"); //newFile.Activated += (o, a) => ClearWindow(); MenuItem openFile = new MenuItem("Open File"); //openFile.Activated += (o, a) => OpenFile(); MenuItem saveFile = new MenuItem("Save File"); //saveFile.Activated += (o, a) => SaveFile(); MenuItem addItem = new MenuItem("Add"); addItem.Submenu = addMenu; MenuItem addEntry = new MenuItem("Entry"); // addEntry.Activated += (object sender, EventArgs e) => AddEntryWidget(); MenuItem addTextView = new MenuItem("TextView"); addTextView.Activated += (object sender, EventArgs e) => AddTextViewWidget(); MenuItem serverItem = new MenuItem("Server"); serverItem.Submenu = serverMenu; MenuItem loginItem = new MenuItem("Login"); //loginItem.Activated += (object sender, EventArgs e) => LoginScreen(); MenuItem logoutItem = new MenuItem("Logout"); //logoutItem.Activated += delegate(object sender, EventArgs e) fileMenu.Append(newFile); fileMenu.Append(openFile); fileMenu.Append(saveFile); addMenu.Append(addEntry); addMenu.Append(addTextView); serverMenu.Append(loginItem); serverMenu.Append(logoutItem); menuBar.Append(file); menuBar.Append(addItem); menuBar.Append(serverItem); #endregion vboxWindow.PackStart(menuBar, false, false, 2); // vboxWindow.Add(globalGrid); Add(vboxWindow); vboxWindow.Add(textView); TextChildAnchor buttonAnchor; TextIter insertIter = buffer.StartIter; buttonAnchor = buffer.CreateChildAnchor(ref insertIter); textView.AddChildAtAnchor(ButtonWidget(), buttonAnchor); ShowAll(); }