示例#1
0
        protected override void Initialize(IPadWindow container)
        {
            base.Initialize(container);
#if MAC
            toolbox                 = new Toolbox.MacToolbox(DesignerSupport.Service.ToolboxService, container);
            widget                  = GtkMacInterop.NSViewToGtkWidget(toolbox);
            widget.CanFocus         = true;
            widget.Sensitive        = true;
            widget.KeyPressEvent   += toolbox.OnKeyPressed;
            widget.KeyReleaseEvent += toolbox.KeyReleased;

            widget.DragBegin += (o, args) => {
                if (!isDragging)
                {
                    DesignerSupport.Service.ToolboxService.DragSelectedItem(widget, args.Context);
                    isDragging = true;
                }
            };

            widget.DragEnd += (o, args) => {
                isDragging = false;
            };

            widget.Focused += (s, e) => {
                toolbox.FocusSelectedView();
            };

            toolbox.ContentFocused += (s, e) => {
                if (!widget.HasFocus)
                {
                    widget.HasFocus = true;
                    toolbox.FocusSelectedView();
                }
            };
            toolbox.DragSourceSet += (s, e) => {
                targets = new Gtk.TargetList();
                targets.AddTable(e);
            };
            toolbox.DragBegin += (object sender, EventArgs e) => {
                if (!isDragging)
                {
                    Gtk.Drag.SourceUnset(widget);

                    // Gtk.Application.CurrentEvent and other copied gdk_events seem to have a problem
                    // when used as they use gdk_event_copy which seems to crash on de-allocating the private slice.
                    IntPtr currentEvent = GtkWorkarounds.GetCurrentEventHandle();
                    Gtk.Drag.Begin(widget, targets, Gdk.DragAction.Copy | Gdk.DragAction.Move, 1, new Gdk.Event(currentEvent));

                    // gtk_drag_begin does not store the event, so we're okay
                    GtkWorkarounds.FreeEvent(currentEvent);
                }
            };

            widget.ShowAll();
#else
            widget = new Toolbox.Toolbox(DesignerSupport.Service.ToolboxService, container);
#endif
        }
示例#2
0
        public TabStrip(DockNotebook notebook)
        {
            TabWidth    = 125;
            TargetWidth = 125;
            tracker     = new MouseTracker(this);
            GtkWorkarounds.FixContainerLeak(this);

            this.notebook = notebook;
            WidgetFlags  |= Gtk.WidgetFlags.AppPaintable;
            Events       |= Gdk.EventMask.PointerMotionMask | Gdk.EventMask.LeaveNotifyMask | Gdk.EventMask.ButtonPressMask;

            var arr = new Gtk.Image(Gdk.Pixbuf.LoadFromResource("tabbar-prev.png"));

            arr.HeightRequest         = arr.WidthRequest = 10;
            PreviousButton            = new Button(arr);
            PreviousButton.Relief     = ReliefStyle.None;
            PreviousButton.CanDefault = PreviousButton.CanFocus = false;

            arr = new Gtk.Image(Gdk.Pixbuf.LoadFromResource("tabbar-next.png"));
            arr.HeightRequest     = arr.WidthRequest = 10;
            NextButton            = new Button(arr);
            NextButton.Relief     = ReliefStyle.None;
            NextButton.CanDefault = NextButton.CanFocus = false;

            DropDownButton            = new MenuButton();
            DropDownButton.Relief     = ReliefStyle.None;
            DropDownButton.CanDefault = DropDownButton.CanFocus = false;

            PreviousButton.ShowAll();
            NextButton.ShowAll();
            DropDownButton.ShowAll();

            PreviousButton.Name = "MonoDevelop.DockNotebook.BarButton";
            NextButton.Name     = "MonoDevelop.DockNotebook.BarButton";
            DropDownButton.Name = "MonoDevelop.DockNotebook.BarButton";

            PreviousButton.Parent = this;
            NextButton.Parent     = this;
            DropDownButton.Parent = this;

            children.Add(PreviousButton);
            children.Add(NextButton);
            children.Add(DropDownButton);

            tracker.HoveredChanged += (sender, e) => {
                if (!tracker.Hovered)
                {
                    SetHighlightedTab(null);
                    UpdateTabWidth(tabEndX - tabStartX);
                    QueueDraw();
                }
            };

            notebook.PageAdded   += (object sender, EventArgs e) => QueueResize();
            notebook.PageRemoved += (object sender, EventArgs e) => QueueResize();

            closingTabs = new Dictionary <int, DockNotebookTab> ();
        }
示例#3
0
        /// <summary>
        /// Places and runs a transient dialog. Does not destroy it, so values can be retrieved from its widgets.
        /// </summary>
        public static int RunCustomDialog(Dialog dlg, Window parent)
        {
            // if dialog is modal, make sure it's parented on any existing modal dialog
            Gtk.Dialog dialog = dlg;
            if (dialog.Modal)
            {
                parent = GetDefaultModalParent();
            }

            //ensure the dialog has a parent
            if (parent == null)
            {
                if (dialog.TransientFor != null)
                {
                    parent = dialog.TransientFor;
                }
                else
                {
                    parent = RootWindow;
                }
            }

            //TODO: use native parenting API for native windows
            if (parent.nativeWidget is Gtk.Window)
            {
                dialog.TransientFor      = parent;
                dialog.DestroyWithParent = true;
            }

            MonoDevelop.Components.IdeTheme.ApplyTheme(dialog);

            if (dialog.Title == null)
            {
                dialog.Title = BrandingService.ApplicationName;
            }

                        #if MAC
            Runtime.RunInMainThread(() => {
                // If there is a native NSWindow model window running, we need
                // to show the new dialog over that window.
                if (NSApplication.SharedApplication.ModalWindow != null)
                {
                    dialog.Shown += HandleShown;
                }
                else
                {
                    PlaceDialog(dialog, parent);
                }
            }).Wait();
                        #endif

            try {
                IdeApp.DisableIdleActions();
                return(GtkWorkarounds.RunDialogWithNotification(dialog));
            } finally {
                IdeApp.EnableIdleActions();
            }
        }
            public void Start()
            {
                allocation = mode.Allocation;
                var swapSurface = mode.swapIndicatorSurface;

                if (swapSurface != null)
                {
                    if (swapSurface.Width == allocation.Width && swapSurface.Height == allocation.Height)
                    {
                        surface = swapSurface;
                    }
                    else
                    {
                        mode.DestroyIndicatorSwapSurface();
                    }
                }

                var displayScale = Core.Platform.IsMac ? GtkWorkarounds.GetScaleFactor(mode) : 1.0;

                if (surface == null)
                {
                    using (var similiar = CairoHelper.Create(IdeApp.Workbench.RootWindow.GdkWindow))
                        surface = new SurfaceWrapper(similiar, (int)(allocation.Width * displayScale), (int)(allocation.Height * displayScale));
                }
                state        = IndicatorDrawingState.Create();
                state.Width  = allocation.Width;
                state.Height = allocation.Height;
                state.SearchResults.AddRange(mode.TextEditor.TextViewMargin.SearchResults);
                state.Usages.AddRange(mode.AllUsages);
                state.Tasks.AddRange(mode.AllTasks);
                state.ColorCache [IndicatorDrawingState.UsageColor]       = SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.Foreground);
                state.ColorCache [IndicatorDrawingState.UsageColor].Alpha = 0.4;

                state.ColorCache [IndicatorDrawingState.FocusColor] = Styles.FocusColor.ToCairoColor();

                state.ColorCache [IndicatorDrawingState.ChangingUsagesColor] = SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.ChangingUsagesRectangle);
                if (state.ColorCache [IndicatorDrawingState.ChangingUsagesColor].Alpha == 0.0)
                {
                    state.ColorCache [IndicatorDrawingState.ChangingUsagesColor] = SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.UsagesRectangle);
                }

                state.ColorCache [IndicatorDrawingState.UsagesRectangleColor] = SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.UsagesRectangle);
                for (int i = 0; i < 4; i++)
                {
                    state.ColorCache [i].L = 0.4;
                }

                state.ColorCache [IndicatorDrawingState.UnderlineErrorColor]      = SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.UnderlineError);
                state.ColorCache [IndicatorDrawingState.UnderlineWarningColor]    = SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.UnderlineWarning);
                state.ColorCache [IndicatorDrawingState.UnderlineSuggestionColor] = SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.UnderlineSuggestion);
                state.ColorCache [IndicatorDrawingState.BackgroundColor]          = SyntaxHighlightingService.GetColor(mode.TextEditor.EditorTheme, EditorThemeColors.Background);

                ResetEnumerators();

                cr = new Cairo.Context(surface.Surface);
                cr.Scale(displayScale, displayScale);
                GLib.Idle.Add(RunHandler);
            }
示例#5
0
        protected override void Run(object dataItem)
        {
            string filename = (string)dataItem;

            Gdk.ModifierType mtype       = GtkWorkarounds.GetCurrentKeyModifiers();
            bool             inWorkspace = (mtype & Gdk.ModifierType.ControlMask) != 0;

            IdeApp.Workspace.OpenWorkspaceItem(filename, !inWorkspace);
        }
示例#6
0
        bool ShowFixesMenu(Gtk.Widget parent, Gdk.Rectangle evt, FixMenuDescriptor entrySet)
        {
                        #if MAC
            parent.GrabFocus();
            int x, y;
            x = (int)evt.X;
            y = (int)evt.Y;

            Gtk.Application.Invoke(delegate {
                // Explicitly release the grab because the menu is shown on the mouse position, and the widget doesn't get the mouse release event
                Gdk.Pointer.Ungrab(Gtk.Global.CurrentEventTime);
                var menu      = CreateNSMenu(entrySet);
                menu.Delegate = new ClosingMenuDelegate(document.Editor);
                var nsview    = MonoDevelop.Components.Mac.GtkMacInterop.GetNSView(parent);
                var toplevel  = parent.Toplevel as Gtk.Window;
                int trans_x, trans_y;
                parent.TranslateCoordinates(toplevel, (int)x, (int)y, out trans_x, out trans_y);

                // Window coordinates in gtk are the same for cocoa, with the exception of the Y coordinate, that has to be flipped.
                var pt = new CoreGraphics.CGPoint((float)trans_x, (float)trans_y);
                int w, h;
                toplevel.GetSize(out w, out h);
                pt.Y = h - pt.Y;

                var tmp_event = AppKit.NSEvent.MouseEvent(AppKit.NSEventType.LeftMouseDown,
                                                          pt,
                                                          0, 0,
                                                          MonoDevelop.Components.Mac.GtkMacInterop.GetNSWindow(toplevel).WindowNumber,
                                                          null, 0, 0, 0);

                AppKit.NSMenu.PopUpContextMenu(menu, tmp_event, nsview);
            });
                        #else
            var menu = CreateGtkMenu(entrySet);
            menu.Events |= Gdk.EventMask.AllEventsMask;
            menu.SelectFirst(true);

            menu.Hidden += delegate {
                document.Editor.SuppressTooltips = false;
            };
            menu.ShowAll();
            menu.SelectFirst(true);
            menu.MotionNotifyEvent += (o, args) => {
                if (args.Event.Window == Editor.Parent.TextArea.GdkWindow)
                {
                    StartMenuCloseTimer();
                }
                else
                {
                    CancelMenuCloseTimer();
                }
            };

            GtkWorkarounds.ShowContextMenu(menu, parent, null, evt);
                        #endif
            return(true);
        }
示例#7
0
        public DockContainer(DockFrame frame)
        {
            GtkWorkarounds.FixContainerLeak(this);

            Accessible.SetRole(AtkCocoa.Roles.AXSplitGroup);

            this.Events = EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.PointerMotionMask | EventMask.LeaveNotifyMask;
            this.frame  = frame;
        }
示例#8
0
        protected AnimatedBox(bool horizontal)
        {
            GtkWorkarounds.FixContainerLeak(this);

            WidgetFlags            |= WidgetFlags.NoWindow;
            this.horizontal         = horizontal;
            stage.ActorStep        += OnActorStep;
            border_stage.Iteration += OnBorderIteration;
        }
示例#9
0
        // This version is used by the CommandManager to track the keystrokes the user has hit for binding lookups.
        public static KeyboardShortcut[] AccelsFromKey(Gdk.EventKey raw, out bool complete)
        {
            KeyboardShortcut[] shortcuts;
            Gdk.ModifierType   modifier;
            Gdk.Key            key;

            GtkWorkarounds.MapKeys(raw, out key, out modifier, out shortcuts);
            complete = !KeyIsModifier(key);

            return(shortcuts);
        }
 protected override bool OnButtonPressEvent(Gdk.EventButton evb)
 {
     if (evb.Type == Gdk.EventType.ButtonPress && evb.Button == 1 && !GtkWorkarounds.TriggersContextMenu(evb))
     {
         clickX      = (int)evb.XRoot;
         clickY      = (int)evb.YRoot;
         localClickX = (int)evb.X;
         localClickY = (int)evb.Y;
     }
     return(true);
 }
            int GetBufferYOffset()
            {
                var displayScale = Platform.IsWindows ? GtkWorkarounds.GetScaleFactor(this) : 1.0;
                int h            = (int)(backgroundPixbuf.ClipRegion.Clipbox.Height / displayScale) - Allocation.Height;

                if (h < 0)
                {
                    return(0);
                }
                return(Math.Max(0, (int)(h * (vadjustment.Value) / (vadjustment.Upper - vadjustment.Lower - vadjustment.PageSize))));
            }
示例#12
0
        public BlameWidget(VersionControlDocumentInfo info)
        {
            GtkWorkarounds.FixContainerLeak(this);

            this.info = info;
            var sourceEditor = info.Document.GetContent <MonoDevelop.SourceEditor.SourceEditorView> ();

            vAdjustment = new Adjustment(
                sourceEditor.TextEditor.VAdjustment.Value,
                sourceEditor.TextEditor.VAdjustment.Lower,
                sourceEditor.TextEditor.VAdjustment.Upper,
                sourceEditor.TextEditor.VAdjustment.StepIncrement,
                sourceEditor.TextEditor.VAdjustment.PageIncrement,
                sourceEditor.TextEditor.VAdjustment.PageSize);
            vAdjustment.Changed += HandleAdjustmentChanged;

            vScrollBar = new VScrollbar(vAdjustment);
            AddChild(vScrollBar);

            hAdjustment = new Adjustment(
                sourceEditor.TextEditor.HAdjustment.Value,
                sourceEditor.TextEditor.HAdjustment.Lower,
                sourceEditor.TextEditor.HAdjustment.Upper,
                sourceEditor.TextEditor.HAdjustment.StepIncrement,
                sourceEditor.TextEditor.HAdjustment.PageIncrement,
                sourceEditor.TextEditor.HAdjustment.PageSize);
            hAdjustment.Changed += HandleAdjustmentChanged;

            hScrollBar = new HScrollbar(hAdjustment);
            AddChild(hScrollBar);

            editor = new TextEditor(sourceEditor.TextEditor.Document, sourceEditor.TextEditor.Options);
            AddChild(editor);
            editor.SetScrollAdjustments(hAdjustment, vAdjustment);

            overview = new BlameRenderer(this);
            AddChild(overview);

            this.DoubleBuffered          = true;
            editor.Painted              += HandleEditorExposeEvent;
            editor.EditorOptionsChanged += delegate {
                overview.OptionsChanged();
            };
            editor.Caret.PositionChanged += ComparisonWidget.CaretPositionChanged;
            editor.FocusInEvent          += ComparisonWidget.EditorFocusIn;
            editor.Document.Folded       += delegate {
                QueueDraw();
            };
            editor.Document.FoldTreeUpdated += delegate {
                QueueDraw();
            };
            editor.DoPopupMenu = ShowPopup;
            Show();
        }
示例#13
0
        public SelectRepositoryDialog(SelectRepositoryMode mode)
        {
            Build();

            GtkWorkarounds.DisableMinimizeMaximizeButtons(this);
            Modal = true;
            foreach (VersionControlSystem vcs in VersionControlService.GetVersionControlSystems())
            {
                if (vcs.IsInstalled)
                {
                    repCombo.AppendText(vcs.Name);
                    systems.Add(vcs);
                }
            }
            repCombo.Active = 0;
            this.mode       = mode;

            store          = new Gtk.TreeStore(typeof(object), typeof(string), typeof(string), typeof(bool), typeof(string));
            repoTree.Model = store;
            TreeViewColumn col = new TreeViewColumn();

            col.Title = GettextCatalog.GetString("Repository");
            CellRendererText  crt = new CellRendererText();
            CellRendererImage crp = new CellRendererImage();

            col.PackStart(crp, false);
            col.PackStart(crt, true);
            col.AddAttribute(crp, "stock-id", IconCol);
            col.AddAttribute(crt, "text", RepoNameCol);
            repoTree.AppendColumn(col);
            repoTree.AppendColumn(GettextCatalog.GetString("Type"), new CellRendererText(), "text", VcsName);
            repoTree.TestExpandRow += new Gtk.TestExpandRowHandler(OnTestExpandRow);
            LoadRepositories();

            if (mode == SelectRepositoryMode.Checkout)
            {
                labelName.Visible    = false;
                entryName.Visible    = false;
                boxMessage.Visible   = false;
                labelMessage.Visible = false;
                defaultPath          = VersionControlDefaultPath;
                entryFolder.Text     = defaultPath;
                buttonOk.Label       = GettextCatalog.GetString("_Checkout");
                UpdateCheckoutButton();
            }
            else
            {
                labelTargetDir.Visible = false;
                boxFolder.Visible      = false;
            }

            repoContainer.SetFlag(WidgetFlags.NoWindow);
            SetupAccessibility();
        }
示例#14
0
        void HandleGtkRealized(object sender, EventArgs e)
        {
            var scale = GtkWorkarounds.GetScaleFactor(Widget);
            var size  = new System.Drawing.Size((int)(Widget.Allocation.Width * scale), (int)(Widget.Allocation.Height * scale));

            view.Size = size;

            var    browser_handle = view.Handle;
            IntPtr window_handle  = (IntPtr)socket.Id;

            SetParent(browser_handle, window_handle);
        }
示例#15
0
 protected override void OnHandleMessageRecived(object sender, MessageArgs args)
 {
     if (args.Message.Action != Action.Show || ApplicationCurrent.MainWindow == null)
     {
         return;
     }
     if (MonoDevelop.Core.Platform.IsMac)
     {
         GtkWorkarounds.GrabDesktopFocus();
     }
     ApplicationCurrent.MainWindow.Present();
 }
        public PropertyGridTable(EditorManager editorManager, PropertyGrid parentGrid)
        {
            GtkWorkarounds.FixContainerLeak(this);

            this.parentGrid    = parentGrid;
            this.editorManager = editorManager;
            WidgetFlags       |= Gtk.WidgetFlags.AppPaintable;
            Events            |= Gdk.EventMask.PointerMotionMask;
            CanFocus           = true;
            resizeCursor       = new Cursor(CursorType.SbHDoubleArrow);
            handCursor         = new Cursor(CursorType.Hand1);
        }
示例#17
0
        protected override bool OnKeyPressEvent(EventKey evnt)
        {
            Gdk.Key            key;
            Gdk.ModifierType   mod;
            KeyboardShortcut[] accels;
            GtkWorkarounds.MapKeys(evnt, out key, out mod, out accels);

            switch (accels [0].Key)
            {
            case Gdk.Key.Left:
            case Gdk.Key.KP_Left:
                LeftItem();
                break;

            case Gdk.Key.Right:
            case Gdk.Key.KP_Right:
                RightItem();
                break;

            case Gdk.Key.Up:
            case Gdk.Key.KP_Up:
                PrevItem(false);
                break;

            case Gdk.Key.Down:
            case Gdk.Key.KP_Down:
                NextItem(false);
                break;

            case Gdk.Key.Tab:
                if ((accels [0].Modifier & ModifierType.ShiftMask) == 0)
                {
                    NextItem(true);
                }
                else
                {
                    PrevItem(true);
                }
                break;

            case Gdk.Key.Return:
            case Gdk.Key.KP_Enter:
            case Gdk.Key.ISO_Enter:
                OnRequestClose(new RequestActionEventArgs(true));
                break;

            case Gdk.Key.Escape:
                OnRequestClose(new RequestActionEventArgs(false));
                break;
            }
            return(base.OnKeyPressEvent(evnt));
        }
示例#18
0
        public BlameWidget(VersionControlDocumentInfo info)
        {
            GtkWorkarounds.FixContainerLeak(this);

            this.info = info;
            var textView = info.Controller.GetContent <ITextView> ();

            vAdjustment          = new Adjustment(0, 0, 0, 0, 0, 0);
            vAdjustment.Changed += HandleAdjustmentChanged;

            vScrollBar = new VScrollbar(vAdjustment);
            AddChild(vScrollBar);

            hAdjustment          = new Adjustment(0, 0, 0, 0, 0, 0);
            hAdjustment.Changed += HandleAdjustmentChanged;

            hScrollBar = new HScrollbar(hAdjustment);
            AddChild(hScrollBar);

            var doc = new TextDocument(textView.TextSnapshot.GetText())
            {
                IsReadOnly = true,
                MimeType   = IdeServices.DesktopService.GetMimeTypeForContentType(textView.TextBuffer.ContentType)
            };
            var options = new CustomEditorOptions(DefaultSourceEditorOptions.Instance);

            options.TabsToSpaces = false;

            editor = new MonoTextEditor(doc, new SourceEditor.StyledSourceEditorOptions(options));

            AddChild(editor);
            editor.SetScrollAdjustments(hAdjustment, vAdjustment);

            overview = new BlameRenderer(this);
            AddChild(overview);

            this.DoubleBuffered          = true;
            editor.Painted              += HandleEditorExposeEvent;
            editor.EditorOptionsChanged += delegate {
                overview.OptionsChanged();
            };
            editor.Caret.PositionChanged += ComparisonWidget.CaretPositionChanged;
            editor.FocusInEvent          += ComparisonWidget.EditorFocusIn;
            editor.Document.Folded       += delegate {
                QueueDraw();
            };
            editor.Document.FoldTreeUpdated += delegate {
                QueueDraw();
            };
            editor.DoPopupMenu = ShowPopup;
            Show();
        }
示例#19
0
        public ResizableFixed()
        {
            GtkWorkarounds.FixContainerLeak(this);

            fixd = new Fixed();
            Add(fixd);
            this.CanFocus = true;
            this.Events   = EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.PointerMotionMask | EventMask.KeyPressMask;
//			fixd.ModifyBg (Gtk.StateType.Normal, this.Style.Mid (Gtk.StateType.Normal));
//			VisibleWindow = false;
            selectionBox = new SelectionHandleBox(this);
            selectionBox.Show();
        }
示例#20
0
        void ShowPopup(Gdk.EventButton evt)
        {
            view.FireCompletionContextChanged();
            CompletionWindowManager.HideWindow();
            ParameterInformationWindowManager.HideWindow(null, view);
            HideTooltip();
            if (string.IsNullOrEmpty(menuPath))
            {
                return;
            }
            var             ctx  = view.WorkbenchWindow?.ExtensionContext ?? AddinManager.AddinEngine;
            CommandEntrySet cset = IdeApp.CommandService.CreateCommandEntrySet(ctx, menuPath);

            if (Platform.IsMac)
            {
                if (evt == null)
                {
                    int x, y;
                    var pt = LocationToPoint(this.Caret.Location);
                    TranslateCoordinates(Toplevel, pt.X, pt.Y, out x, out y);

                    IdeApp.CommandService.ShowContextMenu(this, x, y, cset, this);
                }
                else
                {
                    IdeApp.CommandService.ShowContextMenu(this, evt, cset, this);
                }
            }
            else
            {
                Gtk.Menu menu   = IdeApp.CommandService.CreateMenu(cset);
                var      imMenu = CreateInputMethodMenuItem(GettextCatalog.GetString("_Input Methods"));
                if (imMenu != null)
                {
                    menu.Append(new SeparatorMenuItem());
                    menu.Append(imMenu);
                }

                menu.Hidden += HandleMenuHidden;
                if (evt != null)
                {
                    GtkWorkarounds.ShowContextMenu(menu, this, evt);
                }
                else
                {
                    var pt = LocationToPoint(this.Caret.Location);

                    GtkWorkarounds.ShowContextMenu(menu, this, (int)pt.X, (int)pt.Y);
                }
            }
        }
示例#21
0
        protected override void Render(Drawable window, Widget widget, Rectangle background_area, Rectangle cell_area, Rectangle expose_area, CellRendererState flags)
        {
            if (Template == null)
            {
                DrawTemplateCategoryText(window, widget, cell_area, flags);
                return;
            }

            using (var ctx = CairoHelper.Create(window)) {
                using (var layout = new Pango.Layout(widget.PangoContext)) {
                    Rectangle iconRect = DrawIcon(window, widget, cell_area, flags);

                    if (!Template.AvailableLanguages.Any() || !IsTemplateRowSelected(widget, flags))
                    {
                        DrawTemplateNameText(window, widget, cell_area, iconRect, Rectangle.Zero, flags);
                        return;
                    }

                    int textHeight = 0;
                    int textWidth  = 0;

                    SetMarkup(layout, GetSelectedLanguage());
                    layout.GetPixelSize(out textWidth, out textHeight);

                    double scale = GtkWorkarounds.GetPixelScale();
                    languageRect = GetLanguageButtonRectangle(window, widget, cell_area, textHeight, textWidth, scale);

                    DrawTemplateNameText(window, widget, cell_area, iconRect, languageRect, flags);

                    RoundBorder(ctx, languageRect.X, languageRect.Y, languageRect.Width, languageRect.Height);
                    SetSourceColor(ctx, Styles.NewProjectDialog.TemplateLanguageButtonBackground.ToCairoColor());
                    ctx.Fill();

                    int languageTextX = languageRect.X + GetLanguageLeftHandPadding(scale);
                    if (!TemplateHasMultipleLanguages())
                    {
                        languageTextX = languageRect.X + (languageRect.Width - textWidth) / 2;
                    }
                    int languageTextY = languageRect.Y + (languageRect.Height - textHeight) / 2;

                    window.DrawLayout(widget.Style.TextGC(StateType.Normal), languageTextX, languageTextY, layout);

                    if (TemplateHasMultipleLanguages())
                    {
                        int triangleX = languageTextX + textWidth + GetLanguageRightHandPadding(scale);
                        int triangleY = languageRect.Y + (languageRect.Height - ((int)(scale * dropdownTriangleHeight))) / 2;
                        DrawTriangle(ctx, triangleX, triangleY, scale);
                    }
                }
            }
        }
示例#22
0
        public PropertyGridTable(EditorManager editorManager, PropertyGrid parentGrid)
        {
            GtkWorkarounds.FixContainerLeak(this);

            this.parentGrid    = parentGrid;
            this.editorManager = editorManager;
            WidgetFlags       |= Gtk.WidgetFlags.AppPaintable;
            Events            |= Gdk.EventMask.PointerMotionMask;
            CanFocus           = true;
            resizeCursor       = new Cursor(CursorType.SbHDoubleArrow);
            handCursor         = new Cursor(CursorType.Hand1);
            discloseDown       = Xwt.Drawing.Image.FromResource("disclose-arrow-down-16.png");
            discloseUp         = Xwt.Drawing.Image.FromResource("disclose-arrow-up-16.png");
        }
示例#23
0
 internal void Show(string title)
 {
     this.RootWindow.Title = title;
     this.RootWindow.Realize();
     this.RootWindow.ShowAll();
     this.RootWindow.Show();
     this.RootWindow.CurrentLayout = "DefaultLayout";
     if (MonoDevelop.Core.Platform.IsMac)
     {
         GtkWorkarounds.GrabDesktopFocus();
     }
     this.RootWindow.Present();
     this.monitors.Initialize();
 }
示例#24
0
        static void AddToIconFactory(string stockId, Gdk.Pixbuf pixbuf, Gdk.Pixbuf pixbuf2x, Gtk.IconSize iconSize)
        {
            Gtk.IconSet iconSet = iconFactory.Lookup(stockId);
            if (iconSet == null)
            {
                iconSet = new Gtk.IconSet();
                iconFactory.Add(stockId, iconSet);
            }

            Gtk.IconSource source   = new Gtk.IconSource();
            Gtk.IconSource source2x = null;

            if (Platform.IsWindows)
            {
                var pixel_scale = GtkWorkarounds.GetPixelScale();
                source.Pixbuf = pixbuf.ScaleSimple((int)(pixbuf.Width * pixel_scale), (int)(pixbuf.Height * pixel_scale), Gdk.InterpType.Bilinear);
            }
            else
            {
                source.Pixbuf = pixbuf;
            }

            source.Size           = iconSize;
            source.SizeWildcarded = iconSize == Gtk.IconSize.Invalid;

            if (pixbuf2x != null)
            {
                if (GtkWorkarounds.SetSourceScale(source, 1))
                {
                    GtkWorkarounds.SetSourceScaleWildcarded(source, false);
                    source2x                = new Gtk.IconSource();
                    source2x.Pixbuf         = pixbuf2x;
                    source2x.Size           = iconSize;
                    source2x.SizeWildcarded = iconSize == Gtk.IconSize.Invalid;
                    GtkWorkarounds.SetSourceScale(source2x, 2);
                    GtkWorkarounds.SetSourceScaleWildcarded(source2x, false);
                }
            }
            else
            {
                GtkWorkarounds.SetSourceScaleWildcarded(source, true);
            }

            iconSet.AddSource(source);
            if (source2x != null)
            {
                iconSet.AddSource(source2x);
            }
        }
示例#25
0
        public AnimatedWidget(Widget widget, uint duration, Easing easing, Blocking blocking, bool horizontal)
        {
            GtkWorkarounds.FixContainerLeak(this);

            this.horizontal = horizontal;
            Widget          = widget;
            Duration        = duration;
            Easing          = easing;
            Blocking        = blocking;
            AnimationState  = AnimationState.Coming;

            Widget.Parent     = this;
            Widget.Destroyed += OnWidgetDestroyed;
            ShowAll();
        }
        void AddPackage(PackageLicenseViewModel package)
        {
            var label = new Label()
            {
                Xalign = 0,
                Yalign = 0,
                Xpad   = 5,
                Ypad   = 5,
                Wrap   = true,
                Markup = CreatePackageMarkup(package)
            };

            GtkWorkarounds.SetLinkHandler(label, DesktopService.ShowUrl);

            this.packagesVBox.PackStart(label, false, false, 0);
        }
		// This version is used by the KeyBindingsPanel to display the keystrokes that the user has hit.
		public static string AccelLabelFromKey (Gdk.EventKey raw, out bool complete)
		{
			KeyboardShortcut[] shortcuts;
			Gdk.ModifierType modifier;
			Gdk.Key key;
			
			GtkWorkarounds.MapKeys (raw, out key, out modifier, out shortcuts);
			bool keyIsModifier = KeyIsModifier (key);
			complete = !keyIsModifier;
			
			// The first shortcut is the fully decomposed version
			string accel = ModifierToString (shortcuts[0].Modifier);
			if (keyIsModifier)
				return accel + ModifierKeyToString (shortcuts[0].Key);
			
			return accel + KeyToString (shortcuts[0].Key);
		}
        public GtkAspNetProjectTemplateWizardPageWidget()
        {
            this.Build();

            if (Platform.IsMac)
            {
                int labelPaddingHeight = 5;
                if (IsYosemiteOrHigher())
                {
                    labelPaddingHeight--;
                }
                includeLabelPadding.HeightRequest = labelPaddingHeight;
                testingLabelPadding.HeightRequest = labelPaddingHeight;

                int leftPaddingWidth = 28;
                mvcDescriptionLeftHandPadding.WidthRequest      = leftPaddingWidth;
                webFormsDescriptionLeftHandPadding.WidthRequest = leftPaddingWidth;
                webApiDescriptionLeftHandPadding.WidthRequest   = leftPaddingWidth;
                includeUnitTestProjectDescriptionLeftHandPadding.WidthRequest = leftPaddingWidth;
            }

            double scale = GtkWorkarounds.GetPixelScale();

            backgroundImage            = Xwt.Drawing.Image.FromResource("aspnet-wizard-page.png");
            backgroundImageView        = new ImageView(backgroundImage);
            backgroundImageView.Xalign = (float)(1 / scale);
            backgroundImageView.Yalign = (float)(1 / scale);
            backgroundLargeImageVBox.PackStart(backgroundImageView, true, true, 0);

            var separatorColor  = Ide.Gui.Styles.NewProjectDialog.ProjectConfigurationSeparatorColor.ToGdkColor();
            var backgroundColor = Ide.Gui.Styles.NewProjectDialog.ProjectConfigurationLeftHandBackgroundColor.ToGdkColor();

            testingSeparator.ModifyBg(StateType.Normal, separatorColor);

            leftBorderEventBox.ModifyBg(StateType.Normal, backgroundColor);
            configurationTopEventBox.ModifyBg(StateType.Normal, backgroundColor);
            configurationTableEventBox.ModifyBg(StateType.Normal, backgroundColor);
            configurationBottomEventBox.ModifyBg(StateType.Normal, backgroundColor);
            backgroundLargeImageEventBox.ModifyBg(StateType.Normal, backgroundColor);

            if (Platform.IsWindows && scale > 1.0)
            {
                ScaleWidgets(scale);
            }
        }
 public MultiTaskDialogProgressMonitor(bool showProgress, bool allowCancel, bool showDetails, IDictionary <string, string> taskLabelAliases) : base(Runtime.MainSynchronizationContext)
 {
     if (showProgress)
     {
         var parent = MessageService.GetDefaultModalParent();
         dialog = new MultiTaskProgressDialog(allowCancel, showDetails, taskLabelAliases)
         {
             DestroyWithParent = true,
             Modal             = true,
             TransientFor      = parent,
         };
         MessageService.PlaceDialog(dialog, parent);
         GtkWorkarounds.PresentWindowWithNotification(dialog);
         dialog.CancellationTokenSource = CancellationTokenSource;
         DispatchService.RunPendingEvents();
         this.showDetails = showDetails;
     }
 }
        public SmartScrolledWindow(Widget vScrollBar = null)
        {
            GtkWorkarounds.FixContainerLeak(this);

            vAdjustment = new ScrollAdjustment();
            vAdjustment.ValueChanged += HandleAdjustmentChanged;

            this.vScrollBar        = vScrollBar ?? new VScrollbar(vAdjustment);
            this.vScrollBar.Parent = this;
            this.vScrollBar.Show();

            hAdjustment = new ScrollAdjustment();
            hAdjustment.ValueChanged += HandleAdjustmentChanged;

            hScrollBar        = new HScrollbar(hAdjustment);
            hScrollBar.Parent = this;
            hScrollBar.Show();
        }