Example #1
0
        public ScrollableHandler()
        {
            Control = new Gtk.ScrolledWindow();
            vp      = new Gtk.Viewport();
            hbox    = new Gtk.HBox();
            vbox    = new Gtk.VBox();
            vp.Add(vbox);
            vbox.Add(hbox);

            // autosize the scrolled window to the size of the content
            Control.SizeRequested += delegate(object o, Gtk.SizeRequestedArgs args) {
                if (autoSize)
                {
                    args.Requisition = vp.SizeRequest();
                }
            };
            vp.SizeRequested += delegate(object o, Gtk.SizeRequestedArgs args) {
                if (autoSize)
                {
                    var size = vp.SizeRequest();
                    //Console.WriteLine ("Autosizing to {0}x{1}", size.Width, size.Height);
                    args.Requisition = size;
                }
            };

            Control.VScrollbar.VisibilityNotifyEvent += scrollBar_VisibilityChanged;
            Control.HScrollbar.VisibilityNotifyEvent += scrollBar_VisibilityChanged;
            Control.Add(vp);
            vp.ShadowType = Gtk.ShadowType.None;
            this.Border   = BorderType.Bezel;
        }