Пример #1
0
        public WindowView(Main _view, Controller.Window _ctl)
        {
            View = _view;
            Window = _ctl;
            Homogeneous = false;
            Spacing = 0;
            BorderWidth = 0;
            var topLevelBox = new Gtk.VBox();
            topLevelBox.Homogeneous = false;
            topLevelBox.Spacing = 0;
            topLevelBox.BorderWidth = 0;
            textView = new WindowTextView(Window);
            scroll = new Gtk.ScrolledWindow {
                HscrollbarPolicy = Gtk.PolicyType.Automatic,
                VscrollbarPolicy = Gtk.PolicyType.Automatic
            };
            scroll.Add(textView);
            Window.CursorMovedByCommand.Add(i =>
            {
                textView.ScrollToIter(i.GtkIter, 0, false, 0, 0);
            });
            topLevelBox.PackStart(scroll, true, true, 0);
            status = new Gtk.Statusbar();
            status.HasResizeGrip = false;
            status.Push(StatusbarMode, Window.CurrentMode.GetName());
            Window.CurrentMode.Event.Changed += m =>
            {
                status.Pop(StatusbarMode);
                status.Push(StatusbarMode, Window.CurrentMode.GetName());
            };
            Window.Model.Changed += m =>
            {
                textView.Buffer = m;
            };
            topLevelBox.PackStart(status, false, false, 0);

            // Wrap the topLevelBox with borders on the left and right
            var hlBox = new Gtk.DrawingArea();
            NormalColor = hlBox.Style.Background(Gtk.StateType.Normal);
            hlBox.WidthRequest = 10;
            var borderBox = new Gtk.HBox();
            borderBox.Homogeneous = false;
            borderBox.Spacing = 0;
            borderBox.BorderWidth = 0;
            borderBox.PackStart(hlBox, false, false, 0);
            borderBox.PackStart(topLevelBox, true, true, 0);

            textView.FocusInEvent += (object o, Gtk.FocusInEventArgs args) =>
            {
                Window.Controller.FocusedWindow.Value = Window;
                hlBox.ModifyBg(Gtk.StateType.Normal, HighlightColor);
            };

            textView.FocusOutEvent += (object o, Gtk.FocusOutEventArgs args) =>
            {
                hlBox.ModifyBg(Gtk.StateType.Normal, NormalColor);
            };

            Add(borderBox);
        }
Пример #2
0
 public Window(Buffer _buf, Controller.Window _ctl)
 {
     buf = _buf;
     win = _ctl;
     // TODO get visible offset
     AddHandlers();
 }
Пример #3
0
        public WindowView(Main _view, Controller.Window _ctl)
        {
            View = _view;
            Window = _ctl;
            Homogeneous = false;
            Spacing = 0;
            BorderWidth = 0;
            var topLevelBox = new Gtk.VBox();
            topLevelBox.Homogeneous = false;
            topLevelBox.Spacing = 0;
            topLevelBox.BorderWidth = 0;
            textView = new WindowTextView(Window);
            scroll = new Gtk.ScrolledWindow {
                HscrollbarPolicy = Gtk.PolicyType.Automatic,
                VscrollbarPolicy = Gtk.PolicyType.Automatic
            };
            scroll.Add(textView);
            Window.CursorMovedByCommand.Add(i =>
            {
                textView.ScrollToIter(i.GtkIter, 0, false, 0, 0);
            });
            topLevelBox.PackStart(scroll, true, true, 0);

            status = new MultiStatusbar();
            status.Add(StatusbarItem.Create(100, () => Window.CurrentMode.GetName(), Window.CurrentMode.Changed));
            status.Add(StatusbarItem.Create(50, Window.Model.Value.HasUnsavedChanges, b => b ? "" : "Saved"));
            status.AddLast(StatusbarItem.Create(400, Window.Model.Value.File.ProjectRelativeFullName()));
            topLevelBox.PackStart(status, false, false, 0);

            Window.Model.Changed += m =>
            {
                textView.Buffer = m;
            };

            // Wrap the topLevelBox with borders on the left and right
            var hlBox = new Gtk.DrawingArea();
            NormalColor = hlBox.Style.Background(Gtk.StateType.Normal);
            hlBox.WidthRequest = 10;
            var borderBox = new Gtk.HBox();
            borderBox.Homogeneous = false;
            borderBox.Spacing = 0;
            borderBox.BorderWidth = 0;
            borderBox.PackStart(hlBox, false, false, 0);
            borderBox.PackStart(topLevelBox, true, true, 0);

            textView.FocusInEvent += (object o, Gtk.FocusInEventArgs args) =>
            {
                Window.Controller.Windows.Current = Window;
                hlBox.ModifyBg(Gtk.StateType.Normal, HighlightColor);
            };

            textView.FocusOutEvent += (object o, Gtk.FocusOutEventArgs args) =>
            {
                hlBox.ModifyBg(Gtk.StateType.Normal, NormalColor);
            };

            Add(borderBox);
        }
Пример #4
0
 public void Restore(Model.Main model, Controller.Main ctl)
 {
     if (buf.buf == null)
     {
         throw new CannotRestore();
     }
     var cWin = ctl.FindOrCreateWindow(model.Files.Get(File.Get(model.Root.FullName.AppendFsPath(buf.projectRelativeFileName))));
     win = cWin;
     // TODO set visible offset
     AddHandlers();
 }
Пример #5
0
 public WindowTextView(Controller.Window _ctl)
     : base(_ctl.Model)
 {
     ctl = _ctl;
     WrapMode = Gtk.WrapMode.WordChar;
     ModifyFont(new Font(14, FontFamily.Monospace));
 }