public DemoApplicationWindow () : base ("Application Window") { SetDefaultSize (200, 200); vbox = new VBox (false, 0); Add (vbox); AddActions (); statusbar = new Statusbar (); UpdateStatus (); vbox.PackEnd (statusbar, false, false, 0); ScrolledWindow sw = new ScrolledWindow (); sw.SetPolicy (PolicyType.Automatic, PolicyType.Automatic); sw.ShadowType = ShadowType.In; vbox.PackEnd (sw, true, true, 0); TextView textview = new TextView (); textview.Buffer.MarkSet += new MarkSetHandler (MarkSet); sw.Add (textview); textview.GrabFocus (); ShowAll (); }
/// <summary> /// Initializes a new instance of the <see cref="DynamicCodeTests.DynamicCodePage"/> class. /// </summary> public DynamicCodePage(Project project, CodeWindow codeWindow) { Trace.Log(TraceEventType.Information, "project=\"{0}\", codeWindow=\"{1}\"", project.ToString(), codeWindow.ToString()); Project = project; CodeWindow = codeWindow; DynamicCompiler = new Compiler(project); lockOutput.AcquireWriterLock(0); int mark = 0; ScrolledWindow w = new ScrolledWindow(); tvInput = new TextView(); w.AddWithViewport(tvInput); Pack2(w, false, true); w = new ScrolledWindow(); tvOutput = new TextView(); tvOutput.Editable = false; w.AddWithViewport(tvOutput); Pack1(w, true, true); Position = 234; PositionSet = true; tvInput.GrabFocus(); List<string> codeHistory = project.CodeHistory; tvInput.KeyReleaseEvent += delegate(object o, KeyReleaseEventArgs args) { if (args.Event.State.HasFlag(Gdk.ModifierType.ControlMask)) { if (args.Event.Key.Equals(Gdk.Key.space)) ShowCompletions(); else if (args.Event.Key.Equals(Gdk.Key.Return)) ExecuteCode(); else if (codeHistory.Count > 0) { if (args.Event.Key.Equals(Gdk.Key.Up)) CodeHistoryUp(); else if (args.Event.Key.Equals(Gdk.Key.Down)) CodeHistoryDown(); } } else { codeHistoryIndex = -1; } tvInputPreviousText = tvInput.Buffer.Text; }; lockOutput.ReleaseWriterLock(); 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 void FocusTextArea() { textView.GrabFocus(); }
/// <summary> /// See SwitchContentView. /// This is an awkward solution and should be refactored. /// The only other way I can think if is creating two different /// EventHandlers, and they call with different parameters which /// Label and TextView to switch (Content or Title). /// </summary> /// <param name='edit'> /// If true, paint a TextView that can be edited. /// If false, paint a Label that displays memo. /// </param> public void SwitchTitleView(bool edit) { if (edit) { // Removing the label _titleLabelListener.Destroy(); // Setting up the textview _titleTextView = new TextView (); _titleTextView.FocusInEvent += new FocusInEventHandler(MemoTextViewGotFocus); _titleTextView.FocusOutEvent += new FocusOutEventHandler(MemoTitleTextViewLostFocus); TextBuffer contentBuffer = _titleTextView.Buffer; contentBuffer.Text = this._item.GetTitle(); _titleTextView.SetSizeRequest (200, 140); _titleTextView.Justification = Justification.Fill; _titleTextView.WrapMode = WrapMode.Word; _titleAlignment.Add (_titleTextView); _titleTextView.GrabFocus(); } else { // Saving information from textview and removing it this._item.SetTitle(_titleTextView.Buffer.Text); Console.WriteLine ("Setting memo title to " + _titleTextView.Buffer.Text); _titleTextView.Destroy(); // Creating label _titleLabel = new Label(); _titleLabel.Text = this._item.GetTitle (); _titleLabel.SetSizeRequest (200, 80); _titleLabel.SetAlignment (0, 0); _titleLabel.LineWrap = true; _titleLabel.Justify = Justification.Fill; // Label listener _titleLabelListener = new EventBox (); _titleLabelListener.ButtonPressEvent += new ButtonPressEventHandler (MemoTitlePressHandler); _titleLabelListener.Add (_titleLabel); _titleLabelListener.SetSizeRequest(200, 80); _titleAlignment.Add (_titleLabelListener); } this._container.ShowAll(); }