示例#1
0
        public CodeSegmentEditorWindow(TextEditor editor)
        {
            //TODO: Set to top level

            ScrollView scrolledWindow = new ScrollView();

            scrolledWindow.Content = codeSegmentEditor;
            //scrolledWindow.ShadowType = Gtk.ShadowType.In;
            Content = scrolledWindow;
            codeSegmentEditor.Show();
            ((SimpleEditMode)codeSegmentEditor.CurrentMode).AddBinding(Key.Escape, Close);
            TextEditorOptions options = new TextEditorOptions();

            options.FontName             = editor.Options.FontName;
            options.ColorScheme          = editor.Options.ColorScheme;
            options.ShowRuler            = false;
            options.ShowLineNumberMargin = false;
            options.ShowFoldMargin       = false;
            options.ShowIconMargin       = false;
            options.Zoom = 0.8;
            codeSegmentEditor.Document.MimeType = editor.MimeType;
            codeSegmentEditor.Document.ReadOnly = true;
            codeSegmentEditor.Options           = options;

            codeSegmentEditor.KeyPressed += delegate(object o, KeyEventArgs args) {
                if (args.Key == Key.Escape)
                {
                    Dispose();
                }
            };
            var parent = editor.Parent;

            while (parent != null && !(parent is Window))
            {
                parent = parent.Parent;
            }
            if (parent is Window)
            {
                this.TransientFor = (Window)parent;
            }
            //this.SkipTaskbarHint = true;
            ShowInTaskbar  = false;
            this.Decorated = false;

            /*Gdk.Pointer.Grab (this.GdkWindow, true, Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask, null, null, Gtk.Global.CurrentEventTime);
             * Gtk.Grab.Add (this);
             * GrabBrokenEvent += delegate {
             *      Destroy ();
             * };*/

            codeSegmentEditor.LostFocus += (object o, EventArgs ea) => { Visible = false; Dispose(); };

            codeSegmentEditor.SetFocus();
        }