示例#1
0
        protected override void OnSetScrollAdjustments(Gtk.Adjustment hadjustment, Gtk.Adjustment vadjustment)
        {
            Log.Debug("\n\nLayout.OnSetScrollAdjustments");
            if (hadjustment == null)
            {
                hadjustment = new Gtk.Adjustment(0, 0, 0, 0, 0, 0);
            }
            if (vadjustment == null)
            {
                vadjustment = new Gtk.Adjustment(0, 0, 0, 0, 0, 0);
            }
            bool need_change = false;

            if (Hadjustment != hadjustment)
            {
                this.hadjustment               = hadjustment;
                this.hadjustment.Upper         = Width;
                this.hadjustment.ValueChanged += HandleAdjustmentsValueChanged;
                need_change = true;
            }
            if (Vadjustment != vadjustment)
            {
                this.vadjustment               = vadjustment;
                this.vadjustment.Upper         = Width;
                this.vadjustment.ValueChanged += HandleAdjustmentsValueChanged;
                need_change = true;
            }

            if (need_change)
            {
                HandleAdjustmentsValueChanged(this, EventArgs.Empty);
            }
        }
示例#2
0
        protected override void OnSetScrollAdjustments(Gtk.Adjustment hadj, Gtk.Adjustment vadj)
        {
            var hsa = new ScrollAdjustmentBackend(hadj);
            var vsa = new ScrollAdjustmentBackend(vadj);

            eventSink.SetScrollAdjustments(hsa, vsa);
        }
示例#3
0
 public void Initialize(object frontend)
 {
     if (adjustment == null)
     {
         adjustment = new Gtk.Adjustment(0, 0, 0, 0, 0, 0);
     }
 }
示例#4
0
 public void InitializeBackend(object frontend, ApplicationContext context)
 {
     this.context = context;
     if (adjustment == null)
     {
         adjustment = new Gtk.Adjustment(0, 0, 0, 0, 0, 0);
     }
 }
示例#5
0
 public IconList(uint icon_width, Gtk.Adjustment adj, int flags) : base(IntPtr.Zero)
 {
     if (GetType() != typeof(IconList))
     {
         CreateNativeObject(new string[0], new GLib.Value[0]);
         Construct(icon_width, adj, flags);
         return;
     }
     Raw = gnome_icon_list_new(icon_width, (adj != null) ? adj.Handle : IntPtr.Zero, flags);
 }
示例#6
0
		public void Initialize (Orientation dir)
		{
			adjustment = new Gtk.Adjustment (0, 0, 1, 1, 1, 1);

			if (dir == Orientation.Horizontal)
				Widget = new Gtk.HScrollbar (adjustment);
			else
				Widget = new Gtk.VScrollbar (adjustment);
			Widget.Show ();
		}
 protected void DetachEvents()
 {
     if (vAdjustment == null)
     {
         return;
     }
     vAdjustment.ValueChanged -= HandleEditorVAdjustmentValueChanged;
     hAdjustment.ValueChanged -= HandleEditorHAdjustmentValueChanged;
     vAdjustment = null;
     hAdjustment = null;
 }
示例#8
0
 /// <summary>
 /// Resets the current progress.
 /// </summary>
 public void Reset()
 {
     //assure that value is set using GTK+ main loop thread to avoid any threading problems
     Gtk.Application.Invoke(delegate
     {
         CurrentStep     = 0;
         IsIndeterminate = false;
         CurrentStatus   = string.Empty;
         Adjustment      = new Gtk.Adjustment(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
         //Fraction = 0; //setting fraction to 0 resets the bar after pulsing in inteterminate state
     });
 }
示例#9
0
 public Scale(Gtk.Orientation orientation, Gtk.Adjustment adjustment) : base(IntPtr.Zero)
 {
     if (GetType() != typeof(Scale))
     {
         var vals  = new List <GLib.Value> ();
         var names = new List <string> ();
         names.Add("adjustment");
         vals.Add(new GLib.Value(adjustment));
         CreateNativeObject(names.ToArray(), vals.ToArray());
         return;
     }
     Raw = gtk_scale_new((int)orientation, adjustment == null ? IntPtr.Zero : adjustment.Handle);
 }
        protected void ListenToEvents()
        {
            if (vAdjustment == null)
            {
                vAdjustment = editor.VAdjustment;
                hAdjustment = editor.HAdjustment;

                vAdjustment.ValueChanged += HandleEditorVAdjustmentValueChanged;
                hAdjustment.ValueChanged += HandleEditorHAdjustmentValueChanged;
            }
            vValue = vAdjustment.Value;
            hValue = hAdjustment.Value;
        }
示例#11
0
        public void Initialize(Orientation dir)
        {
            adjustment = new Gtk.Adjustment(0, 0, 1, 1, 1, 1);

            if (dir == Orientation.Horizontal)
            {
                Widget = new Gtk.HScrollbar(adjustment);
            }
            else
            {
                Widget = new Gtk.VScrollbar(adjustment);
            }
            Widget.Show();
        }
示例#12
0
 public HScrollbar(Gtk.Adjustment adjustment) : base(IntPtr.Zero)
 {
     if (GetType() != typeof(HScrollbar))
     {
         var vals  = new List <GLib.Value> ();
         var names = new List <string> ();
         if (adjustment != null)
         {
             names.Add("adjustment");
             vals.Add(new GLib.Value(adjustment));
         }
         CreateNativeObject(names.ToArray(), vals.ToArray());
         return;
     }
     Raw = gtk_hscrollbar_new(adjustment == null ? IntPtr.Zero : adjustment.Handle);
 }
示例#13
0
 public VScale(Gtk.Adjustment adjustment) : base(IntPtr.Zero)
 {
     if (GetType() != typeof(VScale))
     {
         var vals  = new List <GLib.Value> ();
         var names = new List <string> ();
         if (adjustment != null)
         {
             names.Add("adjustment");
             vals.Add(new GLib.Value(adjustment));
         }
         CreateNativeObject(names.ToArray(), vals.ToArray());
         return;
     }
     owned = true;
     Raw   = gtk_vscale_new(adjustment == null ? IntPtr.Zero : adjustment.Handle);
 }
示例#14
0
文件: ChatView.cs 项目: licnep/smuxi
        public virtual void ScrollDown()
        {
            Trace.Call();

            // note: Upper - PageSize is the farest scrollable position!
            Gtk.Adjustment adj = _OutputScrolledWindow.Vadjustment;
            if ((adj.Value + adj.PageSize) <= (adj.Upper - adj.PageSize))
            {
                adj.Value += adj.PageSize - adj.StepIncrement;
            }
            else
            {
                // there is no page left to scroll, so let's just scroll to the
                // farest position instead
                adj.Value = adj.Upper - adj.PageSize;
            }
        }
示例#15
0
文件: ChatView.cs 项目: licnep/smuxi
        public virtual void ScrollToEnd()
        {
            // logging noise
            //Trace.Call();

            Gtk.Adjustment adj = _OutputScrolledWindow.Vadjustment;
#if LOG4NET
            _Logger.Debug("ScrollToEnd(): Vadjustment.Value: " + adj.Value +
                          " Vadjustment.Upper: " + adj.Upper +
                          " Vadjustment.PageSize: " + adj.PageSize);
#endif

            // BUG? doesn't work always for some reason
            // seems like GTK+ doesn't update the adjustment till we give back control
            //adj.Value = adj.Upper - adj.PageSize;

            //_OutputTextView.Buffer.MoveMark(_EndMark, _OutputTextView.Buffer.EndIter);
            //_OutputTextView.ScrollMarkOnscreen(_EndMark);
            //_OutputTextView.ScrollToMark(_EndMark, 0.49, true, 0.0, 0.0);

            //_OutputTextView.ScrollMarkOnscreen(_OutputTextView.Buffer.InsertMark);

            //_OutputTextView.ScrollMarkOnscreen(_OutputTextView.Buffer.GetMark("tail"));

            System.Reflection.MethodBase mb = Trace.GetMethodBase();
            // WORKAROUND1: scroll after one second delay

            /*
             * GLib.Timeout.Add(1000, new GLib.TimeoutHandler(delegate {
             *  Trace.Call(mb);
             *
             *  _OutputTextView.ScrollMarkOnscreen(_EndMark);
             *  return false;
             * }));
             */
            // WORKAROUND2: scroll when GTK+ mainloop is idle
            GLib.Idle.Add(new GLib.IdleHandler(delegate {
                Trace.Call(mb);

                _OutputMessageTextView.ScrollMarkOnscreen(_EndMark);
                return(false);
            }));
        }
示例#16
0
 public SpinButton(Gtk.Adjustment adjustment, double climb_rate, uint digits) : base(IntPtr.Zero)
 {
     if (GetType() != typeof(SpinButton))
     {
         var vals  = new List <GLib.Value> ();
         var names = new List <string> ();
         if (adjustment != null)
         {
             names.Add("adjustment");
             vals.Add(new GLib.Value(adjustment));
         }
         names.Add("climb_rate");
         vals.Add(new GLib.Value(climb_rate));
         names.Add("digits");
         vals.Add(new GLib.Value(digits));
         CreateNativeObject(names.ToArray(), vals.ToArray());
         return;
     }
     Raw = gtk_spin_button_new(adjustment == null ? IntPtr.Zero : adjustment.Handle, climb_rate, digits);
 }
示例#17
0
 public Layout(Gtk.Adjustment hadjustment, Gtk.Adjustment vadjustment) : base(IntPtr.Zero)
 {
     if (GetType() != typeof(Layout))
     {
         var vals  = new List <GLib.Value> ();
         var names = new List <string> ();
         if (hadjustment != null)
         {
             names.Add("hadjustment");
             vals.Add(new GLib.Value(hadjustment));
         }
         if (vadjustment != null)
         {
             names.Add("vadjustment");
             vals.Add(new GLib.Value(vadjustment));
         }
         CreateNativeObject(names.ToArray(), vals.ToArray());
         return;
     }
     Raw = gtk_layout_new(hadjustment == null ? IntPtr.Zero : hadjustment.Handle, vadjustment == null ? IntPtr.Zero : vadjustment.Handle);
 }
示例#18
0
 public ScrolledWindow(Gtk.Adjustment hadjustment, Gtk.Adjustment vadjustment) : base(IntPtr.Zero)
 {
     if (GetType() != typeof(ScrolledWindow))
     {
         var vals  = new List <GLib.Value> ();
         var names = new List <string> ();
         if (hadjustment != null)
         {
             names.Add("hadjustment");
             vals.Add(new GLib.Value(hadjustment));
         }
         if (vadjustment != null)
         {
             names.Add("vadjustment");
             vals.Add(new GLib.Value(vadjustment));
         }
         CreateNativeObject(names.ToArray(), vals.ToArray());
         return;
     }
     owned = true;
     Raw   = gtk_scrolled_window_new(hadjustment == null ? IntPtr.Zero : hadjustment.Handle, vadjustment == null ? IntPtr.Zero : vadjustment.Handle);
 }
示例#19
0
文件: Layout.cs 项目: iainlane/f-spot
        protected override void OnSetScrollAdjustments(Gtk.Adjustment hadjustment, Gtk.Adjustment vadjustment)
        {
            Console.WriteLine ("\n\nLayout.OnSetScrollAdjustments");
            if (hadjustment == null)
                hadjustment = new Gtk.Adjustment (0, 0, 0, 0, 0, 0);
            if (vadjustment == null)
                vadjustment = new Gtk.Adjustment (0, 0, 0, 0, 0, 0);
            bool need_change = false;
            if (Hadjustment != hadjustment) {
                this.hadjustment = hadjustment;
                this.hadjustment.Upper = Width;
                this.hadjustment.ValueChanged += HandleAdjustmentsValueChanged;
                need_change = true;
            }
            if (Vadjustment != vadjustment) {
                this.vadjustment = vadjustment;
                this.vadjustment.Upper = Width;
                this.vadjustment.ValueChanged += HandleAdjustmentsValueChanged;
                need_change = true;
            }

            if (need_change)
                HandleAdjustmentsValueChanged (this, EventArgs.Empty);
        }
		protected void ListenToEvents ()
		{
			if (vAdjustment == null) {
				vAdjustment = editor.VAdjustment;
				hAdjustment = editor.HAdjustment;

				vAdjustment.ValueChanged += HandleEditorVAdjustmentValueChanged;
				hAdjustment.ValueChanged += HandleEditorHAdjustmentValueChanged;
			}
			vValue = vAdjustment.Value;
			hValue = hAdjustment.Value;
		}
示例#21
0
 public void Configure(Gtk.Adjustment adjustment, double climb_rate, uint digits)
 {
     gtk_spin_button_configure(Handle, adjustment == null ? IntPtr.Zero : adjustment.Handle, climb_rate, digits);
 }
示例#22
0
 protected virtual void OnSetScrollAdjustments(Gtk.Adjustment hadj, Gtk.Adjustment vadj)
 {
 }
示例#23
0
        private Atk.Object GetAccessible(BasicWidgetType type, string text, object preWidget, bool real, bool embeddedImage)
        {
            Atk.Object     accessible = null;
            Gtk.Widget     widget     = null;
            Gtk.Adjustment adj        = new Gtk.Adjustment(50, 0, 100, 1, 10, 20);
            switch (type)
            {
            case BasicWidgetType.Label:
                widget = new Gtk.Label();
                if (real)
                {
                    widget = GailTestApp.MainClass.GiveMeARealLabel();
                }
                ((Gtk.Label)widget).Text = text;
                break;

            case BasicWidgetType.NormalButton:
                widget = new Gtk.Button();
                if (real)
                {
                    widget = GailTestApp.MainClass.GiveMeARealButton(embeddedImage);
                }
                ((Gtk.Button)widget).Label = text;
                break;

            case BasicWidgetType.Window:
                widget = new Gtk.Window(text);
                if (real)
                {
                    widget = GailTestApp.MainClass.GiveMeARealWindow();
                }
                break;

            case BasicWidgetType.CheckBox:
                widget = new Gtk.CheckButton();
                if (real)
                {
                    widget = GailTestApp.MainClass.GiveMeARealCheckBox(embeddedImage);
                }
                ((Gtk.CheckButton)widget).Label = text;
                break;

            case BasicWidgetType.RadioButton:
                if (!real)
                {
                    throw new NotSupportedException("We cannot use non-real radio buttons because of some wierd behaviour");
                }

                widget = GailTestApp.MainClass.GiveMeARealRadioButton(embeddedImage);
                RunInGuiThread(delegate {
                    ((Gtk.CheckButton)widget).Label = text;
                });
                break;

            case BasicWidgetType.StatusBar:
                widget = new Gtk.Statusbar();
                if (real)
                {
                    widget = GailTestApp.MainClass.GiveMeARealStatusbar();
                }
                ((Gtk.Statusbar)widget).Push(0, text);
                break;

            case BasicWidgetType.TextBoxEntry:
                if (!real)
                {
                    throw new NotSupportedException();
                }

                widget = GailTestApp.MainClass.GiveMeARealEntry(true);
                RunInGuiThread(delegate {
                    ((Gtk.Entry)widget).Text = text;
                });
                break;

            case BasicWidgetType.RichTextBox:
            case BasicWidgetType.TextBoxView:
                if (!real)
                {
                    throw new NotSupportedException();
                }

                widget = GailTestApp.MainClass.GiveMeARealTextView();
                RunInGuiThread(delegate {
                    ((Gtk.TextView)widget).Buffer.Text = text;
                });
                break;

            case BasicWidgetType.PasswordCharTextBoxEntry:
                if (!real)
                {
                    throw new NotSupportedException();
                }

                widget = GailTestApp.MainClass.GiveMeARealEntry(false);
                RunInGuiThread(delegate {
                    ((Gtk.Entry)widget).Text = text;
                });
                break;

            case BasicWidgetType.HScrollBar:
                widget = new Gtk.HScrollbar(adj);
                if (real)
                {
                    widget = GailTestApp.MainClass.GiveMeARealHScrollbar();
                }
                break;

            case BasicWidgetType.VScrollBar:
                widget = new Gtk.VScrollbar(adj);
                if (real)
                {
                    widget = GailTestApp.MainClass.GiveMeARealVScrollbar();
                }
                break;

            case BasicWidgetType.ProgressBar:
                widget = new Gtk.ProgressBar(adj);
                if (real)
                {
                    widget = GailTestApp.MainClass.GiveMeARealProgressBar();
                }
                break;

            case BasicWidgetType.Spinner:
                widget = new Gtk.SpinButton(adj, 1, 2);
                if (real)
                {
                    widget = GailTestApp.MainClass.GiveMeARealSpinButton();
                }
                break;

            case BasicWidgetType.PictureBox:
                widget = new Gtk.Image();
                if (real)
                {
                    widget = GailTestApp.MainClass.GiveMeARealImage(embeddedImage);
                }
                break;

            case BasicWidgetType.ListView:
            case BasicWidgetType.TreeView:
                Gtk.TreeStore store       = null;
                List <string> columnNames = new List <String> ();
                XmlDocument   xml         = new XmlDocument();
                xml.LoadXml(text);
                foreach (XmlElement th in xml.GetElementsByTagName("th"))
                {
                    foreach (XmlElement td in th.GetElementsByTagName("td"))
                    {
                        columnNames.Add(td.InnerText);
                    }
                }
                if (columnNames.Count == 0)
                {
                    columnNames.Add(string.Empty);
                }
                if (columnNames.Count == 1)
                {
                    store = new Gtk.TreeStore(typeof(string));
                }
                else if (columnNames.Count == 2)
                {
                    store = new Gtk.TreeStore(typeof(string), typeof(string));
                }
                else if (columnNames.Count == 3)
                {
                    store = new Gtk.TreeStore(typeof(string), typeof(string), typeof(string));
                }
                else
                {
                    Assert.Fail("This test only supports 1-3 columns; got " + columnNames.Count);
                }
                Gtk.TreeIter[] iters = new Gtk.TreeIter [8];
                XmlElement     root  = xml.DocumentElement;
                for (XmlNode node = root.FirstChild; node != null; node = node.NextSibling)
                {
                    if (node.Name == "tr")
                    {
                        AddToTreeStore(store, iters, 0, node);
                    }
                }
                widget = new Gtk.TreeView(store);
                if (real)
                {
                    widget = GailTestApp.MainClass.GiveMeARealTreeView();
                    RunInGuiThread(delegate {
                        ((Gtk.TreeView)widget).Model = store;
                    });
                }

                RunInGuiThread(delegate {
                    Gtk.TreeView treeView = (Gtk.TreeView)widget;
                    int i;
                    for (i = treeView.Columns.Length - 1; i >= 0; i--)
                    {
                        treeView.RemoveColumn(treeView.Columns [i]);
                    }
                    i = 0;
                    foreach (string columnName in columnNames)
                    {
                        Gtk.TreeViewColumn col = new Gtk.TreeViewColumn();
                        col.Title = columnName;
                        treeView.AppendColumn(col);
                        Gtk.CellRendererText cell = new Gtk.CellRendererText();
                        col.PackStart(cell, true);
                        col.AddAttribute(cell, "text", i++);
                    }
                    ((Gtk.TreeView)widget).HeadersClickable = text.Contains("<th>");
                    ((Gtk.TreeView)widget).HeadersVisible   = ((Gtk.TreeView)widget).HeadersClickable;
                });
                break;

            case BasicWidgetType.ContainerPanel:
                widget = new Gtk.Frame();
                if (real)
                {
                    widget = GailTestApp.MainClass.GiveMeARealFrame();
                }
                break;

            case BasicWidgetType.HSplitContainer:
                widget = new Gtk.HPaned();
                if (real)
                {
                    widget = GailTestApp.MainClass.GiveMeARealHPaned();
                }
                break;

            case BasicWidgetType.VTrackBar:
                widget = new Gtk.VScale(adj);
                if (real)
                {
                    widget = GailTestApp.MainClass.GiveMeARealVScale();
                }
                break;

            case BasicWidgetType.ComboBoxDropDownEntry:
            case BasicWidgetType.ComboBoxDropDownList:
            case BasicWidgetType.ComboBoxSimple:
                throw new NotSupportedException("You have to use the GetObject overload that receives a name array");

            default:
                throw new NotImplementedException("The widget finder backend still hasn't got support for " +
                                                  type.ToString());
            }

            accessible            = widget.Accessible;
            mappings [accessible] = widget;

            return(accessible);
        }
示例#24
0
        void InitializeWindow(object _sender, EventArgs ev)
        {
            Gtk.Adjustment h = new Gtk.Adjustment(0, 0, 0, 0, 0, 0);
            Gtk.Adjustment v = new Gtk.Adjustment(0, 0, 0, 0, 0, 0);
            v.Changed += delegate (object sender, EventArgs e) {
                DebugHelper.WriteLine ("vertical scroll Changed " + v.Value);
            };
            v.ValueChanged += delegate (object sender, EventArgs e) {
                DebugHelper.WriteLine ("vertical scroll ValueChanged " + v.Value);
            };

            widget = new EmbedWidget(handle, h, v);
            widget.Unrealized += delegate {
                Dispose (true);
            };

            widget.Init ();
            webview = new webkit.WebView();

            webview.LoadCommitted += delegate (object o, webkit.LoadCommittedArgs args) {
            };
            webview.LoadProgressChanged += delegate (object o, webkit.LoadProgressChangedArgs args) {
            };

            webview.SetScrollAdjustments (h, v);
            widget.Add (webview);
            widget.ShowAll ();
            initialized = true;
        }
示例#25
0
		public ScrollControltBackend (Gtk.Adjustment adjustment)
		{
			this.adjustment = adjustment;
		}
示例#26
0
        private void HandleKeyPressEvent(object sender, Gtk.KeyPressEventArgs args)
        {
            bool alt = Gdk.ModifierType.Mod1Mask == (args.Event.State & Gdk.ModifierType.Mod1Mask);

            // FIXME I really need to figure out why overriding is not working
            // for any of the default handlers.
            args.RetVal = true;

            // Scroll if image is zoomed in (scrollbars are visible)
            Gtk.ScrolledWindow scrolled = this.Parent as Gtk.ScrolledWindow;
            if (scrolled != null && !this.Fit)
            {
                Gtk.Adjustment vadj = scrolled.Vadjustment;
                Gtk.Adjustment hadj = scrolled.Hadjustment;
                switch (args.Event.Key)
                {
                case Gdk.Key.Up:
                case Gdk.Key.KP_Up:
                case Gdk.Key.k:
                case Gdk.Key.K:
                    vadj.Value -= vadj.StepIncrement;
                    if (vadj.Value < vadj.Lower)
                    {
                        vadj.Value = vadj.Lower;
                    }
                    return;

                case Gdk.Key.Left:
                case Gdk.Key.KP_Left:
                case Gdk.Key.h:
                    hadj.Value -= hadj.StepIncrement;
                    if (hadj.Value < hadj.Lower)
                    {
                        hadj.Value = hadj.Lower;
                    }
                    return;

                case Gdk.Key.Down:
                case Gdk.Key.KP_Down:
                case Gdk.Key.j:
                case Gdk.Key.J:
                    vadj.Value += vadj.StepIncrement;
                    if (vadj.Value > vadj.Upper - vadj.PageSize)
                    {
                        vadj.Value = vadj.Upper - vadj.PageSize;
                    }
                    return;

                case Gdk.Key.Right:
                case Gdk.Key.KP_Right:
                case Gdk.Key.l:
                    hadj.Value += hadj.StepIncrement;
                    if (hadj.Value > hadj.Upper - hadj.PageSize)
                    {
                        hadj.Value = hadj.Upper - hadj.PageSize;
                    }
                    return;
                }
            }

            // Go to the next/previous photo when not zoomed (no scrollbars)
            switch (args.Event.Key)
            {
            case Gdk.Key.Up:
            case Gdk.Key.KP_Up:
            case Gdk.Key.Left:
            case Gdk.Key.KP_Left:
            case Gdk.Key.Page_Up:
            case Gdk.Key.KP_Page_Up:
            case Gdk.Key.BackSpace:
            case Gdk.Key.h:
            case Gdk.Key.H:
            case Gdk.Key.k:
            case Gdk.Key.K:
            case Gdk.Key.b:
            case Gdk.Key.B:
                this.Item.MovePrevious();
                break;

            case Gdk.Key.Down:
            case Gdk.Key.KP_Down:
            case Gdk.Key.Right:
            case Gdk.Key.KP_Right:
            case Gdk.Key.Page_Down:
            case Gdk.Key.KP_Page_Down:
            case Gdk.Key.space:
            case Gdk.Key.KP_Space:
            case Gdk.Key.j:
            case Gdk.Key.J:
            case Gdk.Key.l:
            case Gdk.Key.L:
            case Gdk.Key.n:
            case Gdk.Key.N:
                this.Item.MoveNext();
                break;

            case Gdk.Key.Home:
            case Gdk.Key.KP_Home:
                this.Item.Index = 0;
                break;

            case Gdk.Key.End:
            case Gdk.Key.KP_End:
                this.Item.Index = this.Query.Count - 1;
                break;

            case Gdk.Key.Key_0:
            case Gdk.Key.KP_0:
                if (alt)
                {
                    args.RetVal = false;
                }
                else
                {
                    this.Fit = true;
                }
                break;

            case Gdk.Key.Key_1:
            case Gdk.Key.KP_1:
                if (alt)
                {
                    args.RetVal = false;
                }
                else
                {
                    this.Zoom = 1.0;
                }
                break;

            case Gdk.Key.Key_2:
            case Gdk.Key.KP_2:
                if (alt)
                {
                    args.RetVal = false;
                }
                else
                {
                    this.Zoom = 2.0;
                }
                break;

            case Gdk.Key.minus:
            case Gdk.Key.KP_Subtract:
                ZoomOut();
                break;

            case Gdk.Key.equal:
            case Gdk.Key.plus:
            case Gdk.Key.KP_Add:
                ZoomIn();
                break;

            default:
                args.RetVal = false;
                return;
            }

            return;
        }
示例#27
0
 public ScrollControltBackend(Gtk.Adjustment adjustment)
 {
     this.adjustment = adjustment;
 }
        public void AdjustScrollBars(object sender, DocumentEventArgs e)
        {
            double v_curval = vScrollBar.Adjustment.Value;
            int v_min = 0;
            int v_max = (Document.TotalNumberOfLines + textArea.TextView.VisibleLineCount - 2) * textArea.TextView.FontHeight;
            int v_lc = Math.Max(0, textArea.TextView.DrawingPosition.Height);
            int v_sc = Math.Max(0, textArea.TextView.FontHeight);

            double h_curval = hScrollBar.Adjustment.Value;
            int h_min = 0;
            int h_max = (int)(1000 * textArea.TextView.GetWidth(' ')) ; //Math.Max(0, max + textArea.TextView.VisibleColumnCount - 1);
            int h_lc = Math.Max(0, textArea.TextView.DrawingPosition.Width);
            int h_sc = Math.Max(0, (int)textArea.TextView.GetWidth(' '));

            Gtk.Adjustment ha = new Gtk.Adjustment(h_curval, h_min, h_max, h_sc, h_lc, 100);
            Gtk.Adjustment va = new Gtk.Adjustment(v_curval, v_min, v_max, v_sc, v_lc, 100);

            hScrollBar.Adjustment = ha;
            vScrollBar.Adjustment = va;
        }
 /// <summary>
 /// Resets the current progress.
 /// </summary>
 public void Reset()
 {
     //assure that value is set using GTK+ main loop thread to avoid any threading problems
     Gtk.Application.Invoke(delegate 
     {
         CurrentStep = 0;
         IsIndeterminate = false;
         CurrentStatus = string.Empty;
         Adjustment = new Gtk.Adjustment(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
         //Fraction = 0; //setting fraction to 0 resets the bar after pulsing in inteterminate state
     });
 }
示例#30
0
 public void Construct(uint icon_width, Gtk.Adjustment adj, int flags)
 {
     gnome_icon_list_construct(Handle, icon_width, adj == null ? IntPtr.Zero : adj.Handle, flags);
 }
示例#31
0
		public void InitializeBackend (object frontend, ApplicationContext context)
		{
			this.context = context;
			if (adjustment == null)
				adjustment = new Gtk.Adjustment (0, 0, 0, 0, 0, 0);
		}
		protected void DetachEvents ()
		{
			if (vAdjustment == null)
				return;
			vAdjustment.ValueChanged -= HandleEditorVAdjustmentValueChanged;
			hAdjustment.ValueChanged -= HandleEditorHAdjustmentValueChanged;
			vAdjustment = null;
			hAdjustment = null;
		}
示例#33
0
 public static void AddValueClamped(this Gtk.Adjustment adj, double value)
 {
     adj.Value = System.Math.Max(adj.Lower, System.Math.Min(adj.Value + value, adj.Upper - adj.PageSize));
 }
 public void InitializeBackend(object frontend)
 {
     if (adjustment == null)
         adjustment = new Gtk.Adjustment (0, 0, 0, 0, 0, 0);
 }
示例#35
0
文件: Layout.cs 项目: swgshaw/f-spot
 public Layout(Gtk.Adjustment hadjustment, Gtk.Adjustment vadjustment) : base()
 {
     OnSetScrollAdjustments(hadjustment, vadjustment);
     children = new List <LayoutChild> ();
 }
示例#36
0
        static string PropToString(ObjectWrapper wrapper, TypedPropertyDescriptor prop)
        {
            object value;

            if (!prop.GladeOverride)
            {
                Stetic.Wrapper.Container.ContainerChild ccwrap = wrapper as Stetic.Wrapper.Container.ContainerChild;
                GLib.Value gval;

                if (ccwrap != null)
                {
                    Gtk.Container.ContainerChild cc = (Gtk.Container.ContainerChild)ccwrap.Wrapped;
                    gval = new GLib.Value((GLib.GType)prop.PropertyType);
                    gtk_container_child_get_property(cc.Parent.Handle, cc.Child.Handle, prop.GladeName, ref gval);
                }
                else
                {
                    Gtk.Widget widget = wrapper.Wrapped as Gtk.Widget;
                    gval = new GLib.Value(widget, prop.GladeName);
                    g_object_get_property(widget.Handle, prop.GladeName, ref gval);
                }
                value = gval.Val;
            }
            else
            {
                value = prop.GetValue(wrapper.Wrapped);
            }
            if (value == null)
            {
                return(null);
            }

            // If the property has its default value, we don't need to write it
            if (prop.HasDefault && prop.ParamSpec.IsDefaultValue(value))
            {
                return(null);
            }

            if (value is Gtk.Adjustment)
            {
                Gtk.Adjustment adj = value as Gtk.Adjustment;
                return(String.Format("{0:G} {1:G} {2:G} {3:G} {4:G} {5:G}",
                                     adj.Value, adj.Lower, adj.Upper,
                                     adj.StepIncrement, adj.PageIncrement,
                                     adj.PageSize));
            }
            else if (value is Enum && prop.ParamSpec != null)
            {
                IntPtr klass = g_type_class_ref(((GLib.GType)prop.PropertyType).Val);

                if (prop.PropertyType.IsDefined(typeof(FlagsAttribute), false))
                {
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    uint val = (uint)System.Convert.ChangeType(value, typeof(uint));

                    while (val != 0)
                    {
                        IntPtr flags_value = g_flags_get_first_value(klass, val);
                        if (flags_value == IntPtr.Zero)
                        {
                            break;
                        }
                        IntPtr fval = Marshal.ReadIntPtr(flags_value);
                        val &= ~(uint)fval;

                        IntPtr name = Marshal.ReadIntPtr(flags_value, Marshal.SizeOf(typeof(IntPtr)));
                        if (name != IntPtr.Zero)
                        {
                            if (sb.Length != 0)
                            {
                                sb.Append('|');
                            }
                            sb.Append(GLib.Marshaller.Utf8PtrToString(name));
                        }
                    }

                    g_type_class_unref(klass);
                    return(sb.ToString());
                }
                else
                {
                    int    val        = (int)System.Convert.ChangeType(value, typeof(int));
                    IntPtr enum_value = g_enum_get_value(klass, val);
                    g_type_class_unref(klass);

                    IntPtr name = Marshal.ReadIntPtr(enum_value, Marshal.SizeOf(typeof(IntPtr)));
                    return(GLib.Marshaller.Utf8PtrToString(name));
                }
            }
            else if (value is bool)
            {
                return((bool)value ? "True" : "False");
            }
            else
            {
                return(value.ToString());
            }
        }
示例#37
0
        public CodeExpression GenerateValue(object value, Type type, bool translatable)
        {
            if (value == null)
            {
                return(new CodePrimitiveExpression(value));
            }

            if (value.GetType().IsEnum)
            {
                if (!type.IsEnum)
                {
                    object ival = Convert.ChangeType(value, type);
                    return(new CodePrimitiveExpression(ival));
                }
                else
                {
                    long ival = (long)Convert.ChangeType(value, typeof(long));
                    return(new CodeCastExpression(
                               value.GetType().ToGlobalTypeRef(),
                               new CodePrimitiveExpression(ival)
                               ));
                }
            }

            if (value is Gtk.Adjustment)
            {
                Gtk.Adjustment adj = value as Gtk.Adjustment;
                return(new CodeObjectCreateExpression(
                           typeof(Gtk.Adjustment).ToGlobalTypeRef(),
                           new CodePrimitiveExpression(adj.Value),
                           new CodePrimitiveExpression(adj.Lower),
                           new CodePrimitiveExpression(adj.Upper),
                           new CodePrimitiveExpression(adj.StepIncrement),
                           new CodePrimitiveExpression(adj.PageIncrement),
                           new CodePrimitiveExpression(adj.PageSize)));
            }
            if (value is ushort || value is uint)
            {
                return(new CodeCastExpression(
                           value.GetType().ToGlobalTypeRef(),
                           new CodePrimitiveExpression(Convert.ChangeType(value, typeof(long)))));
            }
            if (value is ulong)
            {
                return(new CodeMethodInvokeExpression(
                           new CodeTypeReferenceExpression(value.GetType()),
                           "Parse",
                           new CodePrimitiveExpression(value.ToString())));
            }

            if (value is ImageInfo && typeof(Gdk.Pixbuf).IsAssignableFrom(type))
            {
                return(((ImageInfo)value).ToCodeExpression(this));
            }

            if (value is Wrapper.ActionGroup)
            {
                return(new CodeMethodInvokeExpression(
                           new CodeMethodReferenceExpression(
                               new CodeTypeReferenceExpression(new CodeTypeReference(GlobalCodeNamespace.Name + ".ActionGroups", CodeTypeReferenceOptions.GlobalReference)),
                               "GetActionGroup"
                               ),
                           new CodePrimitiveExpression(((Wrapper.ActionGroup)value).Name)
                           ));
            }

            if (value is Array)
            {
                ArrayList list = new ArrayList();
                foreach (object val in (Array)value)
                {
                    list.Add(GenerateValue(val, val != null ? val.GetType() : null, translatable));
                }
                return(new CodeArrayCreateExpression(value.GetType().GetElementType(), (CodeExpression[])list.ToArray(typeof(CodeExpression))));
            }

            if (value is DateTime)
            {
                return(new CodeObjectCreateExpression(
                           typeof(DateTime).ToGlobalTypeRef(),
                           new CodePrimitiveExpression(((DateTime)value).Ticks)
                           ));
            }

            if (value is TimeSpan)
            {
                return(new CodeObjectCreateExpression(
                           typeof(TimeSpan).ToGlobalTypeRef(),
                           new CodePrimitiveExpression(((TimeSpan)value).Ticks)
                           ));
            }

            string str = value as string;

            if (translatable && str != null && str.Length > 0 && options.UseGettext)
            {
                return(new CodeMethodInvokeExpression(
                           new CodeTypeReferenceExpression(new CodeTypeReference(options.GettextClass, CodeTypeReferenceOptions.GlobalReference)),
                           "GetString",
                           new CodePrimitiveExpression(str)
                           ));
            }

            return(new CodePrimitiveExpression(value));
        }