Esempio n. 1
0
        /// <summary>Default constructor for ExplorerView</summary>
        public ExplorerView(ViewBase owner) : base(owner)
        {
            Builder builder = new Builder("ApsimNG.Resources.Glade.ExplorerView.glade");

            vbox1                    = (VBox)builder.GetObject("vbox1");
            toolStrip                = (Toolbar)builder.GetObject("toolStrip");
            treeview1                = (TreeView)builder.GetObject("treeview1");
            RightHandView            = (Viewport)builder.GetObject("RightHandView");
            toolbarlabel             = (Label)builder.GetObject("toolbarlabel");
            _mainWidget              = vbox1;
            RightHandView.ShadowType = ShadowType.EtchedOut;

            treeview1.Model = treemodel;
            TreeViewColumn     column     = new TreeViewColumn();
            CellRendererPixbuf iconRender = new Gtk.CellRendererPixbuf();

            column.PackStart(iconRender, false);
            textRender                 = new Gtk.CellRendererText();
            textRender.Editable        = false;
            textRender.EditingStarted += OnBeforeLabelEdit;
            textRender.Edited         += OnAfterLabelEdit;
            column.PackStart(textRender, true);
            column.SetAttributes(iconRender, "pixbuf", 1);
            column.SetAttributes(textRender, "text", 0);
            // column.SetCellDataFunc(textRender, treecelldatafunc);
            treeview1.AppendColumn(column);
            treeview1.TooltipColumn = 2;

            treeview1.CursorChanged      += OnAfterSelect;
            treeview1.ButtonReleaseEvent += OnButtonUp;
            treeview1.ButtonPressEvent   += OnButtonPress;
            treeview1.RowActivated       += OnRowActivated;

            TargetEntry[] target_table = new TargetEntry[] {
                new TargetEntry(modelMime, TargetFlags.App, 0)
            };

            Gdk.DragAction actions = Gdk.DragAction.Copy | Gdk.DragAction.Link | Gdk.DragAction.Move;
            // treeview1.EnableModelDragDest(target_table, actions);
            // treeview1.EnableModelDragSource(Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.SourceSet(treeview1, Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.DestSet(treeview1, 0, target_table, actions);
            treeview1.DragMotion       += OnDragOver;
            treeview1.DragDrop         += OnDragDrop;
            treeview1.DragBegin        += OnDragBegin;
            treeview1.DragDataGet      += OnDragDataGet;
            treeview1.DragDataReceived += OnDragDataReceived;
            treeview1.DragEnd          += OnDragEnd;
            treeview1.FocusInEvent     += Treeview1_FocusInEvent;
            treeview1.FocusOutEvent    += Treeview1_FocusOutEvent;
            _mainWidget.Destroyed      += _mainWidget_Destroyed;
            timer.Elapsed += Timer_Elapsed;
        }
Esempio n. 2
0
        protected override void Initialise(ViewBase ownerView, GLib.Object gtkControl)
        {
            treeview1       = (Gtk.TreeView)gtkControl;
            mainWidget      = treeview1;
            treeview1.Model = treemodel;
            TreeViewColumn     column     = new TreeViewColumn();
            CellRendererPixbuf iconRender = new Gtk.CellRendererPixbuf();

            iconRender.SetPadding(2, 1);
            column.PackStart(iconRender, false);
            textRender                 = new Gtk.CellRendererText();
            textRender.Editable        = false;
            textRender.EditingStarted += OnBeforeLabelEdit;
            textRender.Edited         += OnAfterLabelEdit;
            column.PackStart(textRender, true);
            column.SetCellDataFunc(textRender, OnSetCellData);

            CellRendererText tickCell = new CellRendererText();

            tickCell.Editable = false;
            column.PackEnd(tickCell, false);
            column.SetAttributes(iconRender, "pixbuf", 1);
            column.SetAttributes(textRender, "text", 0);
            column.SetAttributes(tickCell, "text", 3);
            treeview1.AppendColumn(column);
            treeview1.TooltipColumn = 2;

            treeview1.CursorChanged      += OnAfterSelect;
            treeview1.ButtonReleaseEvent += OnButtonUp;
            treeview1.ButtonPressEvent   += OnButtonPress;
            treeview1.RowActivated       += OnRowActivated;
            treeview1.FocusInEvent       += OnTreeGainFocus;
            treeview1.FocusOutEvent      += OnTreeLoseFocus;

            TargetEntry[] target_table = new TargetEntry[] {
                new TargetEntry(modelMime, TargetFlags.App, 0)
            };

            Gdk.DragAction actions = Gdk.DragAction.Copy | Gdk.DragAction.Link | Gdk.DragAction.Move;
            Drag.SourceSet(treeview1, Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.DestSet(treeview1, 0, target_table, actions);
            treeview1.DragMotion       += OnDragOver;
            treeview1.DragDrop         += OnDragDrop;
            treeview1.DragBegin        += OnDragBegin;
            treeview1.DragDataGet      += OnDragDataGet;
            treeview1.DragDataReceived += OnDragDataReceived;
            treeview1.DragEnd          += OnDragEnd;
            timer.Elapsed        += OnTimerElapsed;
            mainWidget.Destroyed += OnDestroyed;
        }
Esempio n. 3
0
        /// <summary>Constructor</summary>
        public TreeView(ViewBase owner, Gtk.TreeView treeView) : base(owner)
        {
            treeview1       = treeView;
            treeview1.Model = treemodel;
            TreeViewColumn     column     = new TreeViewColumn();
            CellRendererPixbuf iconRender = new Gtk.CellRendererPixbuf();

            column.PackStart(iconRender, false);
            textRender                 = new Gtk.CellRendererText();
            textRender.Editable        = false;
            textRender.EditingStarted += OnBeforeLabelEdit;
            textRender.Edited         += OnAfterLabelEdit;
            column.PackStart(textRender, true);
            column.SetCellDataFunc(textRender, OnSetCellData);

            CellRendererText tickCell = new CellRendererText();

            tickCell.Editable = false;
            column.PackEnd(tickCell, false);
            column.SetAttributes(iconRender, "pixbuf", 1);
            column.SetAttributes(textRender, "text", 0);
            column.SetAttributes(tickCell, "text", 3);
            // column.SetCellDataFunc(textRender, treecelldatafunc);
            treeview1.AppendColumn(column);
            treeview1.TooltipColumn = 2;

            treeview1.CursorChanged      += OnAfterSelect;
            treeview1.ButtonReleaseEvent += OnButtonUp;
            treeview1.ButtonPressEvent   += OnButtonPress;
            treeview1.RowActivated       += OnRowActivated;
            treeview1.FocusInEvent       += OnTreeGainFocus;
            treeview1.FocusOutEvent      += OnTreeLoseFocus;

            TargetEntry[] target_table = new TargetEntry[] {
                new TargetEntry(modelMime, TargetFlags.App, 0)
            };

            Gdk.DragAction actions = Gdk.DragAction.Copy | Gdk.DragAction.Link | Gdk.DragAction.Move;
            // treeview1.EnableModelDragDest(target_table, actions);
            // treeview1.EnableModelDragSource(Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.SourceSet(treeview1, Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.DestSet(treeview1, 0, target_table, actions);
            treeview1.DragMotion       += OnDragOver;
            treeview1.DragDrop         += OnDragDrop;
            treeview1.DragBegin        += OnDragBegin;
            treeview1.DragDataGet      += OnDragDataGet;
            treeview1.DragDataReceived += OnDragDataReceived;
            treeview1.DragEnd          += OnDragEnd;
            timer.Elapsed += OnTimerElapsed;
        }
Esempio n. 4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="holder">iFolder Holder</param>
        /// <param name="group">iFolderViewGroup</param>
        public iFolderViewItem(iFolderHolder holder, iFolderViewGroup group, TreeIter iter, int maxWidth)
        {
            this.holder   = holder;
            this.group    = group;
            this.iter     = iter;
            this.maxWidth = maxWidth;

            this.CanFocus = true;

            this.bSelected        = false;
            this.bMouseIsHovering = false;

            this.ModifyBg(StateType.Normal, this.Style.Base(StateType.Normal));
            this.ModifyBase(StateType.Normal, this.Style.Base(StateType.Normal));

            currentName     = "";
            currentLocation = "";
            currentStatus   = "";

//			domainController = DomainController.GetDomainController();

            LoadImages();
            SetPixbufs();

            this.Add(CreateWidgets());

            this.WidthRequest = this.maxWidth;

            this.Realized +=
                new EventHandler(OnWidgetRealized);

// FIXME: Fix things up so that if the user changes the theme, our icons will refresh too
//			if (!registeredForThemeChangeEvent)
//			{
//				IconTheme.Changed += new EventHandler(OnGtkIconThemeChanged);
//			}
            ///
            /// Set up drag and drop
            ///
            TargetEntry[] targets =
                new TargetEntry[]
            {
                new TargetEntry("text/ifolder-id", 0, (uint)iFolderWindow.DragTargetType.iFolderID)
            };

            this.DragDataGet += new DragDataGetHandler(HandleDragDataGet);
            Drag.SourceSet(this, Gdk.ModifierType.Button1Mask, targets, Gdk.DragAction.Move);
        }
Esempio n. 5
0
        /// <summary>Default constructor for ExplorerView</summary>
        public ExplorerView(ViewBase owner) : base(owner)
        {
            Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.ExplorerView.glade", "vbox1");
            gxml.Autoconnect(this);
            _mainWidget = vbox1;
            RightHandView.ShadowType = ShadowType.EtchedOut;

            treeview1.Model = treemodel;
            TreeViewColumn     column     = new TreeViewColumn();
            CellRendererPixbuf iconRender = new Gtk.CellRendererPixbuf();

            column.PackStart(iconRender, false);
            textRender                 = new Gtk.CellRendererText();
            textRender.Editable        = true;
            textRender.EditingStarted += OnBeforeLabelEdit;
            textRender.Edited         += OnAfterLabelEdit;
            column.PackStart(textRender, true);
            column.SetAttributes(iconRender, "pixbuf", 1);
            column.SetAttributes(textRender, "text", 0);
            // column.SetCellDataFunc(textRender, treecelldatafunc);
            treeview1.AppendColumn(column);
            treeview1.TooltipColumn = 2;

            treeview1.CursorChanged      += OnAfterSelect;
            treeview1.ButtonReleaseEvent += OnButtonUp;

            TargetEntry[] target_table = new TargetEntry[] {
                new TargetEntry("application/x-model-component", TargetFlags.App, 0)
            };

            Gdk.DragAction actions = Gdk.DragAction.Copy | Gdk.DragAction.Link | Gdk.DragAction.Move;
            // treeview1.EnableModelDragDest(target_table, actions);
            // treeview1.EnableModelDragSource(Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.SourceSet(treeview1, Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.DestSet(treeview1, 0, target_table, actions);
            treeview1.DragMotion       += OnDragOver;
            treeview1.DragDrop         += OnDragDrop;
            treeview1.DragBegin        += OnDragBegin;
            treeview1.DragDataGet      += OnDragDataGet;
            treeview1.DragDataReceived += OnDragDataReceived;
            treeview1.DragEnd          += OnDragEnd;
            treeview1.DragDataDelete   += OnDragDataDelete;
            treeview1.FocusInEvent     += Treeview1_FocusInEvent;
            treeview1.FocusOutEvent    += Treeview1_FocusOutEvent;
            _mainWidget.Destroyed      += _mainWidget_Destroyed;
        }
Esempio n. 6
0
 // FIRST  : SourceSet
 // SECOND : Add IDragDropWidget to container
 // THIRD  : DestSet and DragDataReceived
 public static void SetupDragDropSourceButton(MyButton btn,
                                              string t,
                                              object data)
 {
     if (btn == null)
     {
         return;
     }
     Drag.SourceSet(btn,
                    Gdk.ModifierType.Button1Mask,
                    TgtFromString(t),
                    Gdk.DragAction.Move);
     btn.DragDataGet += delegate(object o, DragDataGetArgs args_) {
         // save after drag & drop
         Tournament.I.Save();
         DragDropHelpers.Serialize(args_.SelectionData, data);
     };
 }
Esempio n. 7
0
 private void UpdateButton()
 {
     if (calendarItem != null && calendarItem.id > 0)
     {
         this.Image = null;
         PangoText.SetText(calendarItem.Text);
         this.TooltipText = calendarItem.FullText;
         this.Relief      = ReliefStyle.Normal;
         Drag.DestUnset(this);
         Drag.SourceSet(this, Gdk.ModifierType.Button1Mask, null, Gdk.DragAction.Move);
         Gdk.Color col = new Gdk.Color();
         Gdk.Color.Parse(calendarItem.Color, ref col);
         logger.Debug("a={0} - {1} - {2}", col.Red, col.Green, col.Blue);
         this.ModifyBg(StateType.Normal, col);
         byte r = (byte)Math.Min(((double)col.Red / ushort.MaxValue) * byte.MaxValue + 30, byte.MaxValue);
         byte g = (byte)Math.Min(((double)col.Green / ushort.MaxValue) * byte.MaxValue + 30, byte.MaxValue);
         byte b = (byte)Math.Min(((double)col.Blue / ushort.MaxValue) * byte.MaxValue + 30, byte.MaxValue);
         col = new Gdk.Color(r, g, b);
         this.ModifyBg(StateType.Prelight, col);
         logger.Debug("b={0} - {1} - {2}", col.Red, col.Green, col.Blue);
         //Tag
         PangoTag.SetText(calendarItem.Tag);
         PangoMessages.SetText(calendarItem.MessageCount + "✉");
     }
     else if (calendarItem != null && calendarItem.id == 0)
     {
         Pango.FontDescription desc = Pango.FontDescription.FromString("Serif Bold 35");
         PangoText.FontDescription = desc;
         PangoText.SetText(calendarItem.Text);
         this.Relief = ReliefStyle.Normal;
         Gdk.Color col = new Gdk.Color();
         Gdk.Color.Parse(calendarItem.Color, ref col);
         this.ModifyBg(StateType.Normal, col);
         this.ModifyBg(StateType.Prelight, col);
     }
     else
     {
         this.Image       = null;
         this.TooltipText = null;
         Drag.SourceUnset(this);
         this.Relief = ReliefStyle.None;
         this.ModifyBg(StateType.Normal);
     }
 }
Esempio n. 8
0
        public ProjectView()
        {
            Build();

            basename = "base";

            var column = new TreeViewColumn();

            var iconCell = new CellRendererPixbuf();
            var textCell = new CellRendererText();
            var idCell   = new CellRendererText();

            idCell.Visible = false;

            column.PackStart(iconCell, false);
            column.PackStart(textCell, false);
            column.PackStart(idCell, false);

            treeview1.AppendColumn(column);

            column.AddAttribute(iconCell, "pixbuf", 0);
            column.AddAttribute(textCell, "text", 1);
            column.AddAttribute(idCell, "text", 2);

            listStore = new TreeStore(typeof(Gdk.Pixbuf), typeof(string), typeof(string));

            treeview1.Reorderable    = true;
            treeview1.Model          = listStore;
            treeview1.Selection.Mode = SelectionMode.Multiple;

            treeview1.ButtonPressEvent   += OnTreeview1ButtonPressEvent;
            treeview1.KeyReleaseEvent    += HandleKeyReleaseEvent;
            treeview1.ButtonReleaseEvent += OnTreeview1ButtonReleaseEvent;
            treeview1.CursorChanged      += OnTreeview1CursorChanged;

            Drag.SourceSet(this.treeview1, 0, null, Gdk.DragAction.Move);
            Drag.DestSet(this.treeview1, 0, null, 0);

            treeview1.DragBegin        += Treeview1_DragBegin;
            treeview1.DragMotion       += Treeview1_DragMotion;
            treeview1.DragDrop         += Treeview1_DragDrop;
            treeview1.DragDataReceived += Treeview1_DragDataReceived;
            treeview1.DragEnd          += Treeview1_DragEnd;
        }
Esempio n. 9
0
        public static void SourceSet(Widget widget, object data)
        {
            List <string> targets = new List <string>();

            targets.Add(data.GetType().Name);
            if (data is GameObject)
            {
                targets.Add("GameObject");
                if (data is IAgent)
                {
                    targets.Add("IAgent");
                    if (((IAgent)data).active)
                    {
                        targets.Add("Active IAgent");
                    }
                }
            }
            Drag.SourceSet(widget, Gdk.ModifierType.Button1Mask, targets.ConvertAll(
                               (target) => new TargetEntry(target, TargetFlags.App, 0)
                               ).ToArray(), Gdk.DragAction.Move);
            widget.DragBegin += (o, a) => currentDragged = data;
        }
Esempio n. 10
0
        public void Refresh()
        {
            // GUI assert here is to catch Bug 434065 - Exception while going to the editor
            Runtime.AssertMainThread();

            if (toolboxService.Initializing)
            {
                toolboxWidget.CustomMessage = GettextCatalog.GetString("Initializing...");
                return;
            }

            ConfigureToolbar();

            toolboxWidget.CustomMessage = null;

            categories.Clear();
            AddItems(toolboxService.GetCurrentToolboxItems());

            Drag.SourceUnset(toolboxWidget);
            toolboxWidget.ClearCategories();

            var cats = categories.Values.ToList();

            cats.Sort((a, b) => a.Priority != b.Priority ? a.Priority.CompareTo(b.Priority) : a.Text.CompareTo(b.Text));
            cats.Reverse();
            foreach (Category category in cats)
            {
                category.IsExpanded = true;
                toolboxWidget.AddCategory(category);
            }
            toolboxWidget.QueueResize();
            Gtk.TargetEntry[] targetTable = toolboxService.GetCurrentDragTargetTable();
            if (targetTable != null)
            {
                Drag.SourceSet(toolboxWidget, Gdk.ModifierType.Button1Mask, targetTable, Gdk.DragAction.Copy | Gdk.DragAction.Move);
            }
            compactModeToggleButton.Visible = toolboxWidget.CanIconizeToolboxCategories;
            refilter();
        }
Esempio n. 11
0
        public FolderTreeView(FolderTreeModel tree_model) : base(tree_model)
        {
            folder_tree_model = tree_model;

            HeadersVisible = false;

            var column = new TreeViewColumn();

            var pixbuf_renderer = new CellRendererPixbuf();

            column.PackStart(pixbuf_renderer, false);
            column.SetCellDataFunc(pixbuf_renderer, PixbufDataFunc);

            var folder_renderer = new CellRendererTextProgress();

            column.PackStart(folder_renderer, true);
            column.SetCellDataFunc(folder_renderer, FolderDataFunc);

            AppendColumn(column);

            Drag.SourceSet(this, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
                           (TargetEntry[])folderTreeSourceTargetList, Gdk.DragAction.Copy | Gdk.DragAction.Move);
        }