Ejemplo n.º 1
0
        public override NSToolbarItem WillInsertItem(NSToolbar toolbar, string itemIdentifier, bool willBeInserted)
        {
            var group = new NSToolbarItemGroup(itemIdentifier);
            var view  = new NSView();

            group.View = view;

            if (itemIdentifier == NavigationGroupIdentifier)
            {
                _navigationGroup = new NativeToolbarGroup(group, BackButtonItemWidth);
            }
            else if (itemIdentifier == TitleGroupIdentifier)
            {
                _titleGroup = new NativeToolbarGroup(group);
            }
            else if (itemIdentifier == TabbedGroupIdentifier)
            {
                _tabbedGroup = new NativeToolbarGroup(group);
            }
            else if (itemIdentifier == ToolbarItemsGroupIdentifier)
            {
                _toolbarGroup = new NativeToolbarGroup(group, ToolbarItemWidth, ToolbarItemSpacing);
            }

            return(group);
        }
Ejemplo n.º 2
0
        public override NSToolbarItem WillInsertItem(NSToolbar toolbar, string itemIdentifier, bool willBeInserted)
        {
            NSToolbarItem toolbarItem = null;

            if (itemIdentifier == ToggleRectProps)
            {
                toolbarItem = ToolbarItemWithIdentifier(
                    ToggleRectProps,
                    "Rectangle Properties",
                    "Rectangle Properties",
                    "Toggle the rectangle properties drawer",
                    this.Controller,
                    NSImage.ImageNamed("Drawer"),
                    new Selector("toggleDrawer"),
                    null
                );

            }
            else if (itemIdentifier == ZoomInOut)
            {
                toolbarItem = ToolbarItemWithIdentifier(
                    ZoomInOut,
                    "100%",
                    "",
                    "Zoom canvas in or out",
                    this.Controller,
                    this.Controller.ZoomInOutView,
                    null,
                    ZoomInOutMenu
                );
            }

            return toolbarItem;
        }
Ejemplo n.º 3
0
        public MainToolbar(Gtk.Window window)
        {
            gtkWindow = window;
            widget    = new NSToolbar(MainToolbarId)
            {
                DisplayMode = NSToolbarDisplayMode.Icon,
            };
            widget.WillInsertItem = (tool, id, send) => {
                switch (id)
                {
                case RunButtonId:
                    return(CreateRunToolbarItem());

                case ButtonBarId:
                    return(CreateButtonBarToolbarItem());

                case SearchBarId:
                    return(CreateSearchBarToolbarItem());

                case SelectorId:
                    return(CreateSelectorToolbarItem());

                case StatusBarId:
                    return(CreateStatusBarToolbarItem());

                case CenteringSpaceId:
                    return(CreateCenteringSpaceItem());
                }
                throw new NotImplementedException();
            };
        }
 // Creates a toolbar item for each preferences tab. This method is called by Cocoa framework.
 // Notice that tab name is used as identifier. This identifier is used in PreferencesWindowController
 // to find a correct view to be displayed when toolbar item has been activated (clicked).
 public override NSToolbarItem WillInsertItem(NSToolbar toolbar, string itemIdentifier, bool willBeInserted)
 {
     var tab = tabs.Single(s => s.Name.Equals(itemIdentifier));
     var item = new NSToolbarItem(tab.Name) { Image = tab.Icon, Label = tab.Name};
     item.Activated += HandleActivated;
     return item;
 }
Ejemplo n.º 5
0
        public override void WindowDidLoad()
        {
            MainThread.Ensure();

            Session = SessionDocument.InstanceForWindowControllers?.Session;
            if (Session == null)
            {
                Log.Error(TAG, "Unable to get ClientSession from SessionDocument");
                throw new InvalidOperationException();
            }

            var viewControllers = new MacClientSessionViewControllers(this);

            Session.InitializeViewControllers(viewControllers);

            ShouldCascadeWindows     = false;
            Window.FrameAutosaveName = "SessionWindow";

            Window.TitleVisibility = NSWindowTitleVisibility.Hidden;

            var toolbar = new NSToolbar("xi-toolbar-main-toolbar-" + Guid.NewGuid())
            {
                SizeMode                = NSToolbarSizeMode.Regular,
                DisplayMode             = NSToolbarDisplayMode.Icon,
                AllowsUserCustomization = false
            };

            new SessionToolbarDelegate(Session, viewControllers, toolbar);

            Window.Toolbar = toolbar;

            base.WindowDidLoad();
        }
		NSToolbar CreateToolbar ()
		{
			var tb = new NSToolbar ("PreferencesToolbar");
			tb.AllowsUserCustomization = false;
			tb.Delegate = toolbarDelegate;
			tb.SelectedItemIdentifier = tabs.First().Name;
			return tb;
		}
Ejemplo n.º 7
0
 public override NSToolbarItem WillInsertItem(NSToolbar toolbar, string itemIdentifier, bool willBeInserted)
 {
     var toolBarItem = new NSToolbarItem (itemIdentifier) {Label = itemIdentifier, ToolTip = itemIdentifier, 
         PaletteLabel = itemIdentifier, Image = NSImage.ImageNamed ("hand_32x32.png")};
     toolBarItemList.Add (toolBarItem);
     toolBarItem.Activated += Item_Activated;
     return toolBarItem;
 }
Ejemplo n.º 8
0
 public override string[] DefaultItemIdentifiers(NSToolbar toolbar)
 {
     return new string[]
     {
         ZoomInOut,
         NSToolbar.NSToolbarFlexibleSpaceItemIdentifier,
         ToggleRectProps
     };
 }
        NSToolbar CreateToolbar()
        {
            var tb = new NSToolbar("PreferencesToolbar");

            tb.AllowsUserCustomization = false;
            tb.Delegate = toolbarDelegate;
            tb.SelectedItemIdentifier = tabs.First().Name;
            return(tb);
        }
Ejemplo n.º 10
0
 public void AwakeFromNib()
 {
     // Create the toolbar and install it
     NSToolbar toolbar = new NSToolbar(TOOLBAR);
     toolbar.AllowsUserCustomization = true;
     toolbar.DisplayMode = NSToolbarDisplayMode.NSToolbarDisplayModeDefault;
     toolbar.Delegate = this;
     this.window.Toolbar = toolbar;
     toolbar.Release();
 }
Ejemplo n.º 11
0
        // Creates a toolbar item for each preferences tab. This method is called by Cocoa framework.
        // Notice that tab name is used as identifier. This identifier is used in PreferencesWindowController
        // to find a correct view to be displayed when toolbar item has been activated (clicked).
        public override NSToolbarItem WillInsertItem(NSToolbar toolbar, string itemIdentifier, bool willBeInserted)
        {
            var tab  = tabs.Single(s => s.Name.Equals(itemIdentifier));
            var item = new NSToolbarItem(tab.Name)
            {
                Image = tab.Icon, Label = tab.Name
            };

            item.Activated += HandleActivated;
            return(item);
        }
Ejemplo n.º 12
0
 public override string[] AllowedItemIdentifiers(NSToolbar toolbar)
 {
     return(Handler.items.Select(r => r.Identifier)
            .Union(
                new string[] {
         NSToolbar.NSToolbarSeparatorItemIdentifier,
         NSToolbar.NSToolbarSpaceItemIdentifier,
         NSToolbar.NSToolbarFlexibleSpaceItemIdentifier,
         NSToolbar.NSToolbarCustomizeToolbarItemIdentifier
     }).ToArray());
 }
Ejemplo n.º 13
0
        private NSToolbar CreateToolbar()
        {
            var tb = new NSToolbar("PreferencesToolbar")
            {
                AllowsUserCustomization = false,
                Delegate = _toolbarDelegate,
                SelectedItemIdentifier = _tabControllers.First().Name
            };

            return(tb);
        }
Ejemplo n.º 14
0
        internal void UpdateToolBar()
        {
            if (NSApplication.SharedApplication.MainWindow == null)
            {
                return;
            }

            if (_navigation == null)
            {
                if (_toolbar != null)
                {
                    _toolbar.Visible = false;
                }
                _toolbar = null;
                return;
            }

            var currentPage = _navigation.Peek(0);

            if (NavigationPage.GetHasNavigationBar(currentPage))
            {
                if (_toolbar == null)
                {
                    _toolbar = ConfigureToolbar();
                    NSApplication.SharedApplication.MainWindow.Toolbar = _toolbar;

                    _toolbar.InsertItem(NavigationGroupIdentifier, 0);
                    _toolbar.InsertItem(
                        HasTabs ? NSToolbar.NSToolbarSpaceItemIdentifier : NSToolbar.NSToolbarFlexibleSpaceItemIdentifier, 1);
                    _toolbar.InsertItem(HasTabs ? TabbedGroupIdentifier : TitleGroupIdentifier, 2);
                    _toolbar.InsertItem(NSToolbar.NSToolbarFlexibleSpaceItemIdentifier, 3);
                    _toolbar.InsertItem(ToolbarItemsGroupIdentifier, 4);
                }

                _toolbar.Visible = true;
                UpdateToolbarItems();
                UpdateTitle();
                UpdateNavigationItems();
                if (HasTabs)
                {
                    UpdateTabbedItems();
                }
                UpdateBarBackgroundColor();
            }
            else
            {
                if (_toolbar != null)
                {
                    _toolbar.Visible = false;
                }
            }
        }
        protected virtual NSToolbar ConfigureToolbar()
        {
            var toolbar = new NSToolbar(ToolBarId)
            {
                DisplayMode             = NSToolbarDisplayMode.Icon,
                AllowsUserCustomization = false,
                ShowsBaselineSeparator  = true,
                SizeMode = NSToolbarSizeMode.Regular,
                Delegate = this
            };

            return(toolbar);
        }
Ejemplo n.º 16
0
            public override NSToolbarItem WillInsertItem(NSToolbar toolbar, string itemIdentifier, bool willBeInserted)
            {
                var item = Handler.items.FirstOrDefault(r => r.Identifier == itemIdentifier);

                if (item != null)
                {
                    return(item.Control);
                }
                else
                {
                    return(null);
                }
            }
Ejemplo n.º 17
0
 public virtual NSArray ToolbarAllowedItemIdentifiers(NSToolbar toolbar)
 {
     NSArray array = NSArray.ArrayWithObjects(
         NSToolbarItem.NSToolbarCustomizeToolbarItemIdentifier,
         NSToolbarItem.NSToolbarFlexibleSpaceItemIdentifier,
         NSToolbarItem.NSToolbarSeparatorItemIdentifier,
         NSToolbarItem.NSToolbarSpaceItemIdentifier,
         TOOLBAR_ITEM1,
         TOOLBAR_ITEM2,
         TOOLBAR_ITEM3,
         null);
     return array;
 }
Ejemplo n.º 18
0
        public void AwakeFromNib()
        {
            NSFont theFont;
            NSToolbar toolbar = new NSToolbar("myToolbar");

            // Here we create the dictionary to hold all of our "master" NSToolbarItems.
            this.toolbarItems = new NSMutableDictionary();
            this.toolbarItems.Retain();

            // Now lets create three NSToolbarItems; 2 using custom views, and a standard one using an image.
            // We call our special processing function to do the initialization and add them to the dictionary.
            AddToolbarItem(this.toolbarItems, "FontStyle", "Font Style", "Font Style", "Change your font style", this, ObjectiveCRuntime.Selector("setView:"), this.popUpView, IntPtr.Zero, this.fontStyleMenu);
            AddToolbarItem(this.toolbarItems, "FontSize", "Font Size", "Font Size", "Grow or shrink the size of your font", this, ObjectiveCRuntime.Selector("setView:"), this.fontSizeView, IntPtr.Zero, this.fontSizeMenu);
            // often using an image will be your standard case.  You'll notice that a selector is passed
            // for the action (blueText:), which will be called when the image-containing toolbar item is clicked.
            AddToolbarItem(this.toolbarItems, "BlueLetter", "Blue Text", "Blue Text", "This toggles blue text on/off", this, ObjectiveCRuntime.Selector("setImage:"), NSImage.ImageNamed("blueLetter.tif"), ObjectiveCRuntime.Selector("blueText:"), null);

            // the toolbar wants to know who is going to handle processing of NSToolbarItems for it.  This controller will.
            toolbar.SetDelegate(d =>
                                    {
                                        d.ToolbarAllowedItemIdentifiers += this.ToolbarAllowedItemIdentifiers;
                                        d.ToolbarDefaultItemIdentifiers += this.ToolbarDefaultItemIdentifiers;
                                        d.ToolbarItemForItemIdentifierWillBeInsertedIntoToolbar += this.ToolbarItemForItemIdentifierWillBeInsertedIntoToolbar;
                                        d.ToolbarWillAddItem += this.ToolbarWillAddItem;
                                    });

            // If you pass NO here, you turn off the customization palette.  The palette is normally handled automatically
            // for you by NSWindow's -runToolbarCustomizationPalette: method; you'll notice that the "Customize Toolbar"
            // menu item is hooked up to that method in Interface Builder.  Interface Builder currently doesn't automatically
            // show this action (or the -toggleToolbarShown: action) for First Responder/NSWindow (this is a bug), so you
            // have to manually add those methods to the First Responder in Interface Builder (by hitting return on the First Responder and
            // adding the new actions in the usual way) if you want to wire up menus to them.
            toolbar.AllowsUserCustomization = true;

            // tell the toolbar that it should save any configuration changes to user defaults.  ie. mode changes, or reordering will persist.
            // specifically they will be written in the app domain using the toolbar identifier as the key.
            toolbar.AutosavesConfiguration = true;

            // tell the toolbar to show icons only by default
            toolbar.DisplayMode = NSToolbarDisplayMode.NSToolbarDisplayModeIconOnly;
            // install the toolbar.
            this.theWindow.Toolbar = toolbar;

            // We initialize our font size control here to 12-point font, and set our contentView (an NSTextView) to that size
            this.fontSizeStepper.IntValue = 12;
            theFont = NSFont.UserFontOfSize(this.fontSizeStepper.IntValue);
            this.contentView.Font = theFont;

            this.fontStylePicked = 1;
        }
Ejemplo n.º 19
0
 public LaunchWindow(CoreGraphics.CGRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation) :
     base(contentRect, aStyle, bufferingType, deferCreation)
 {
     Appearance = NSAppearance.GetAppearance(NSAppearance.NameVibrantDark);
     IsOpaque   = true;
     MovableByWindowBackground = true;
     ReleasedWhenClosed        = false;
     Title = NSBundle.MainBundle.GetName();
     TitlebarAppearsTransparent = true;
     TitleVisibility            = NSWindowTitleVisibility.Hidden;
     Toolbar = new NSToolbar()
     {
         ShowsBaselineSeparator = false
     };
 }
Ejemplo n.º 20
0
        protected virtual NSToolbar ConfigureToolbar()
        {
            var toolbar = new NSToolbar(ToolBarId)
            {
                DisplayMode             = NSToolbarDisplayMode.Icon,
                AllowsUserCustomization = false,
                ShowsBaselineSeparator  = true,
                SizeMode = NSToolbarSizeMode.Regular,
                Delegate = this
            };

            if (System.Maui.Maui.IsMojaveOrNewer)
            {
                toolbar.CenteredItemIdentifier = TitleGroupIdentifier;
            }

            return(toolbar);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Adds an item to a toolbar.
        /// </summary>
        /// <param name="toolbar">The <see cref=">NSToolbar"/> to which an item is to be added.</param>
        /// <param name="toolbarItem">The <see cref="NSToolbarItem"/> to be added to the toolbar.</param>
        /// <param name="itemIdentifier">The item's unique identifier.</param>
        /// <param name="insertLocation">The location in the toolbar at which the item is to be inserted.</param>
        public static void AddToolbarItem(this NSToolbar toolbar, NSToolbarItem toolbarItem, string itemIdentifier, int insertLocation)
        {
            if (toolbar.DefaultItemIdentifiers == null)
            {
                toolbar.DefaultItemIdentifiers = NSToolbarIdentifiers;
            }
            if (toolbar.AllowedItemIdentifiers == null)
            {
                toolbar.AllowedItemIdentifiers = NSToolbarIdentifiers;
            }
            if (toolbar.SelectableItemIdentifiers == null)
            {
                // HACK WORKAROUND for bug https://bugzilla.xamarin.com/show_bug.cgi?id=21680
                toolbar.SelectableItemIdentifiers = BugWorkaround;
            }
            var prevWillAdd = toolbar.WillInsertItem;

            toolbar.WillInsertItem = (t, i, b) => toolbarItem;
            toolbar.InsertItem(itemIdentifier, insertLocation);
            toolbar.WillInsertItem = prevWillAdd;
        }
Ejemplo n.º 22
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                MessagingCenter.Unsubscribe <IVisualElementRenderer> (this, "Xamarin.UpdateToolbarButtons");
                foreach (NSObject nsObject in ChildViewControllers)
                {
                    nsObject.Dispose();
                }

                if (this.tracker != null)
                {
                    this.tracker.Dispose();
                }

                //this.secondaryToolbar.RemoveFromSuperview ();
                this.secondaryToolbar.Dispose();
                this.secondaryToolbar = null;

                this.parentMasterDetailPage = null;
                this.Current = (Page)null;
                NavigationPage navigationPage = (NavigationPage)this.Element;

                navigationPage.PropertyChanged           -= HandlePropertyChanged;
                navigationPage.PushRequested             -= OnPushRequested;
                navigationPage.PopRequested              -= OnPopRequested;
                navigationPage.PopToRootRequested        -= OnPopToRootRequested;
                navigationPage.RemovePageRequested       -= OnRemovedPageRequested;
                navigationPage.InsertPageBeforeRequested -= OnInsertPageBeforeRequested;

                if (this.appeared)
                {
                    ((Page)this.Element).SendDisappearing();
                }

                this.appeared = false;
                this.Element  = null;
            }
            base.Dispose(disposing);
        }
Ejemplo n.º 23
0
        protected override void OnElementChanged(ElementChangedEventArgs <Editor> e)
        {
            this.OnElementChanged(e);
            if (this.Control == null)
            {
                this.SetNativeControl(new NSTextView(CGRect.Empty));
                if (Device.Idiom == TargetIdiom.Phone)
                {
                    accessoryView = new NSToolbar(this.ToString());
                    //accessoryView = new NSToolbar (new CGRect ((nfloat)0, (nfloat)0, NSScreen.MainScreen.Frame.Width, (nfloat)44));
                    //uiToolbar.BarStyle = UIBarStyle.Default;
                    //int num = 1;
                    //uiToolbar.Translucent = num != 0;

                    var toolBarItem = new NSToolbarItem("");
                    toolBarItem.Activated += (sender, ev) => {
                        this.Control.ResignFirstResponder();
                        this.Element.SendCompleted();
                    };

                    accessoryView.Items.Append(toolBarItem);

                    // TODO:
                    //this.Control.InputAccessoryView = accessoryView;
                }
                this.Control.TextDidChange       += HandleChanged;
                this.Control.TextDidBeginEditing += OnStarted;
                this.Control.TextDidEndEditing   += OnEnded;
            }
            if (e.NewElement == null)
            {
                return;
            }
            this.UpdateText();
            this.UpdateFont();
            this.UpdateTextColor();
            //this.UpdateKeyboard ();
            this.UpdateEditable();
        }
Ejemplo n.º 24
0
        public override NSToolbarItem WillInsertItem(
            NSToolbar toolbar,
            string itemIdentifier,
            bool willBeInserted)
        {
            foreach (var item in toolbar.Items)
            {
                if (item.Identifier == itemIdentifier)
                {
                    return(null);
                }
            }

            switch (itemIdentifier)
            {
            case Identifiers.RunAll:
                return(runAllItem);

            case Identifiers.TargetSelector:
                return(targetSelectorItem);

            case Identifiers.CenteringSpacer:
                return(centeringItem);

            case Identifiers.Status:
                return(statusItem);

            case Identifiers.TabView:
                return(tabViewItem);

            case Identifiers.Refresh:
                return(refreshItem);

            case Identifiers.Inspect:
                return(inspectItem);
            }

            return(null);
        }
Ejemplo n.º 25
0
 public override string[] AllowedItemIdentifiers(NSToolbar toolbar)
 {
     return new string[0];
 }
Ejemplo n.º 26
0
 public override string[] SelectableItemIdentifiers(NSToolbar toolbar)
 {
     return(Handler.items.Where(r => r.Selectable).Select(r => r.Identifier).ToArray());
 }
Ejemplo n.º 27
0
 public override string[] DefaultItemIdentifiers(NSToolbar toolbar)
 {
     return(Handler.items.Select(r => r.Identifier).ToArray());
 }
Ejemplo n.º 28
0
        public MainToolbar(Gtk.Window window)
        {
            gtkWindow = window;
            widget    = new NSToolbar(MainToolbarId)
            {
                DisplayMode = NSToolbarDisplayMode.Icon,
            };

            awesomeBar = new AwesomeBar();
            awesomeBar.RunButton.Activated += (o, e) => {
                if (RunButtonClicked != null)
                {
                    RunButtonClicked(o, e);
                }
            };

            // Remove the focus from the Gtk system when Cocoa has focus
            // Fixes BXC #29601
            awesomeBar.SearchBar.GainedFocus += (o, e) => IdeApp.Workbench.RootWindow.Focus = null;

            AttachToolbarEvents(awesomeBar.SearchBar);

            selectorView.ConfigurationChanged += (sender, e) => {
                if (ConfigurationChanged != null)
                {
                    ConfigurationChanged(sender, e);
                }
            };

            selectorView.RunConfigurationChanged += (sender, e) => {
                if (RunConfigurationChanged != null)
                {
                    RunConfigurationChanged(sender, e);
                }
            };

            selectorView.RuntimeChanged += (sender, ea) => {
                if (RuntimeChanged != null)
                {
                    RuntimeChanged(sender, ea);
                }
            };

            widget.WillInsertItem = (tool, id, send) => {
                switch (id)
                {
                case AwesomeBarId:
                    return(new NSToolbarItem(AwesomeBarId)
                    {
                        View = awesomeBar,
                        MinSize = new CGSize(1024, AwesomeBar.ToolbarWidgetHeight),
                        MaxSize = new CGSize(float.PositiveInfinity, AwesomeBar.ToolbarWidgetHeight)
                    });

                default:
                    throw new NotImplementedException();
                }
            };

            Action <NSNotification> resizeAction = notif => Runtime.RunInMainThread(() => {
                var win = awesomeBar.Window;
                if (win == null)
                {
                    return;
                }

                var item = widget.Items[0];

                var abFrameInWindow  = awesomeBar.ConvertRectToView(awesomeBar.Frame, null);
                var awesomebarHeight = AwesomeBar.ToolbarWidgetHeight;
                var size             = new CGSize(win.Frame.Width - abFrameInWindow.X - 4, awesomebarHeight);

                if (item.MinSize != size)
                {
                    item.MinSize = size;
                }
            });

            // We can't use the events that Xamarin.Mac adds for delegate methods as they will overwrite
            // the delegate that Gtk has added
            NSWindow nswin = GtkMacInterop.GetNSWindow(window);

            NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidResizeNotification, resizeAction, nswin);
            NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidEndLiveResizeNotification, resizeAction, nswin);

            NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.WillEnterFullScreenNotification, (note) => IsFullscreen = true, nswin);
            NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.WillExitFullScreenNotification, (note) => IsFullscreen  = false, nswin);
        }
Ejemplo n.º 29
0
		public MainToolbar (Gtk.Window window)
		{
			gtkWindow = window;
			widget = new NSToolbar (MainToolbarId) {
				DisplayMode = NSToolbarDisplayMode.Icon,
			};
			widget.WillInsertItem = (tool, id, send) => {
				switch (id) {
				case RunButtonId:
					return CreateRunToolbarItem ();
				case ButtonBarId:
					return CreateButtonBarToolbarItem ();
				case SearchBarId:
					return CreateSearchBarToolbarItem ();
				case SelectorId:
					return CreateSelectorToolbarItem ();
				case StatusBarId:
					return CreateStatusBarToolbarItem ();
				case CenteringSpaceId:
					return CreateCenteringSpaceItem ();
				}
				throw new NotImplementedException ();
			};
		}
Ejemplo n.º 30
0
 public override string[] AllowedItemIdentifiers(NSToolbar toolbar)
 {
     return(TabNames);
 }
Ejemplo n.º 31
0
 public NSArray ToolbarDefaultItemIdentifiers(NSToolbar toolbar)
 {
     NSMutableArray array = new NSMutableArray();
     array.AddObject((NSString) "FontStyle");
     array.AddObject((NSString) "FontSize");
     array.AddObject(NSToolbarItem.NSToolbarSeparatorItemIdentifier);
     array.AddObject((NSString) "BlueLetter");
     array.AddObject(NSToolbarItem.NSToolbarPrintItemIdentifier);
     return array;
 }
Ejemplo n.º 32
0
        public virtual NSToolbarItem ToolbarItemForItemIdentifierWillBeInsertedIntoToolbar(NSToolbar toolbar, NSString itemIdentifier, bool flag)
        {
            NSToolbarItem item = new NSToolbarItem(itemIdentifier);

            if (itemIdentifier.IsEqualToString(TOOLBAR_ITEM1)) {
                item.Image = NSImage.ImageNamed(NSImage.NSImageNameAdvanced);
                item.Label = "Toolbar Item 1";
                item.Target = this;
                item.Action = ObjectiveCRuntime.Selector("doSomething1:");
            }
            if (itemIdentifier.IsEqualToString(TOOLBAR_ITEM2)) {
                item.Image = NSImage.ImageNamed(NSImage.NSImageNameEveryone);
                item.Label = "Toolbar Item 2";
                item.Target = this;
                item.Action = ObjectiveCRuntime.Selector("doSomething2:");
            }
            if (itemIdentifier.IsEqualToString(TOOLBAR_ITEM3)) {
                item.Image = NSImage.ImageNamed(NSImage.NSImageNameDotMac);
                item.Label = "Toolbar Item 3";
                item.Target = this;
                item.Action = ObjectiveCRuntime.Selector("doSomething3:");
            }

            item.PaletteLabel = item.Label;

            return item;
        }
Ejemplo n.º 33
0
		public MainToolbar (Gtk.Window window)
		{
			gtkWindow = window;
			widget = new NSToolbar (MainToolbarId) {
				DisplayMode = NSToolbarDisplayMode.Icon,
			};

			awesomeBar = new AwesomeBar ();
			awesomeBar.RunButton.Activated += (o, e) => {
				if (RunButtonClicked != null)
					RunButtonClicked (o, e);
			};

			// Remove the focus from the Gtk system when Cocoa has focus
			// Fixes BXC #29601
			awesomeBar.SearchBar.GainedFocus += (o, e) => IdeApp.Workbench.RootWindow.Focus = null;

			AttachToolbarEvents (awesomeBar.SearchBar);

			selectorView.ConfigurationChanged += (sender, e) => {
				if (ConfigurationChanged != null)
					ConfigurationChanged (sender, e);
			};

			selectorView.RuntimeChanged += (sender, ea) => {
				if (RuntimeChanged != null)
					RuntimeChanged (sender, ea);
			};

			widget.WillInsertItem = (tool, id, send) => {
				switch (id) {
				case AwesomeBarId:
					return new NSToolbarItem (AwesomeBarId) {
						View = awesomeBar,
						MinSize = new CGSize (1024, AwesomeBar.ToolbarWidgetHeight),
						MaxSize = new CGSize (1024, AwesomeBar.ToolbarWidgetHeight)
					};

				default:
					throw new NotImplementedException ();
				}
			};

			Action<NSNotification> resizeAction = notif => Runtime.RunInMainThread (() => {
				var win = awesomeBar.Window;
				if (win == null) {
					return;
				}

				var item = widget.Items[0];

				var abFrameInWindow = awesomeBar.ConvertRectToView (awesomeBar.Frame, null);
				var awesomebarHeight = AwesomeBar.ToolbarWidgetHeight;//MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan ? 24 : 22;
				var size = new CGSize (win.Frame.Width - abFrameInWindow.X - 4, awesomebarHeight);
				item.MinSize = size;
				item.MaxSize = size;
			});

			NSWindow nswin = GtkMacInterop.GetNSWindow (window);
			NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidResizeNotification, resizeAction, nswin);
			NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidEndLiveResizeNotification, resizeAction, nswin);
		}
Ejemplo n.º 34
0
        public SessionToolbarDelegate(
            ClientSession clientSession,
            MacClientSessionViewControllers viewControllers,
            NSToolbar toolbar)
        {
            if (clientSession == null)
            {
                throw new ArgumentNullException(nameof(clientSession));
            }

            if (viewControllers == null)
            {
                throw new ArgumentNullException(nameof(viewControllers));
            }

            if (toolbar == null)
            {
                throw new ArgumentNullException(nameof(toolbar));
            }

            allowedItemIdentifiers = clientSession.SessionKind == ClientSessionKind.LiveInspection
                ? Identifiers.InspectorDefault
                : Identifiers.WorkbooksDefault;

            this.toolbar = toolbar;

            toolbar.Delegate = this;

            runAllItem = CreateButton(
                Identifiers.RunAll,
                "runAllSubmissions:",
                Catalog.GetString("Run All"),
                Catalog.GetString("Run the whole workbook from top to bottom"),
                "ToolbarRunTemplate");

            refreshItem = CreateButton(
                Identifiers.Refresh,
                "refreshVisualTree:",
                Catalog.GetString("Refresh"),
                Catalog.GetString("Refresh the application's visual tree in Inspector"),
                "ToolbarRefreshTemplate");

            inspectItem = CreateButton(
                Identifiers.Inspect,
                "inspectView:",
                Catalog.GetString("Inspect"),
                Catalog.GetString("Select a UI element to inspect in the running application"),
                "ToolbarInspectTemplate");

            var targetSelector = new WorkbookTargetSelector(
                clientSession.ViewControllers.WorkbookTargets)
            {
                Font = NSFont.SystemFontOfSize(NSFont.SmallSystemFontSize)
            };

            var targetSelectorItemMenu = new NSMenuItem(Catalog.GetString("Target"));

            targetSelectorItemMenu.Submenu = targetSelector.Menu;

            targetSelectorItem = new NSToolbarItem(Identifiers.TargetSelector)
            {
                View                   = targetSelector,
                MinSize                = targetSelector.Frame.Size,
                MaxSize                = targetSelector.Frame.Size,
                VisibilityPriority     = -1000,
                MenuFormRepresentation = targetSelectorItemMenu
            };

            targetSelector.Activated += (sender, e) => {
                var size = targetSelector.GetToolbarSize();
                targetSelectorItem.MinSize = size;
                targetSelectorItem.MaxSize = size;
                centeringItem.UpdateWidth();
                viewControllers.WindowTabs.SelectedTabViewItemIndex = 0;
            };

            centeringItem = new CenteringToolbarItem(Identifiers.CenteringSpacer);

            statusItem = new StatusToolbarItem {
                View = viewControllers.Status.View
            };

            tabViewItem = new NSToolbarItem(Identifiers.TabView)
            {
                PaletteLabel = Catalog.GetString("Views")
            };

            tabViewItem.View = viewControllers.WindowTabs.ToolbarSegmentedControl;

            viewControllers.WindowTabs.ItemSelected += (sender, e) => {
                switch (viewControllers.WindowTabs.SelectedTabViewItemIndex)
                {
                case 0:
                    RemoveItem(Identifiers.Inspect);
                    RemoveItem(Identifiers.Refresh);
                    if (clientSession.SessionKind != ClientSessionKind.LiveInspection)
                    {
                        toolbar.InsertItem(Identifiers.RunAll, 0);
                    }
                    ((XcbWorkbookPageView)clientSession.EvaluationService).DelayNewCodeCellFocus = false;
                    break;

                case 1:
                    RemoveItem(Identifiers.RunAll);
                    toolbar.InsertItem(Identifiers.Inspect, 0);
                    toolbar.InsertItem(Identifiers.Refresh, 0);
                    ((XcbWorkbookPageView)clientSession.EvaluationService).DelayNewCodeCellFocus = true;
                    break;
                }

                centeringItem.UpdateWidth();
            };

            NSWindow.Notifications.ObserveDidResize((sender, e) => {
                statusItem.UpdateSize(e.Notification.Object as NSWindow);
                centeringItem.UpdateWidth();
            });
        }
Ejemplo n.º 35
0
 public override string[] SelectableItemIdentifiers(NSToolbar toolbar)
 {
     string[] identifiers = {};
     return identifiers;
 }
Ejemplo n.º 36
0
 public override string[] DefaultItemIdentifiers(NSToolbar toolbar)
 {
     string[] identifiers = {"Pan"};
     return identifiers;
 }
Ejemplo n.º 37
0
 public virtual NSArray ToolbarDefaultItemIdentifiers(NSToolbar toolbar)
 {
     NSArray array = NSArray.ArrayWithObjects(
         TOOLBAR_ITEM1,
         NSToolbarItem.NSToolbarSeparatorItemIdentifier,
         TOOLBAR_ITEM2,
         NSToolbarItem.NSToolbarFlexibleSpaceItemIdentifier,
         TOOLBAR_ITEM3,
         null);
     return array;
 }
Ejemplo n.º 38
0
        List <AppResult> ResultSetFromWindows()
        {
            Gtk.Window[] windows = Gtk.Window.ListToplevels();

            // null for AppResult signifies root node
            rootNode = new GtkWidgetResult(null)
            {
                SourceQuery = ToString()
            };
            List <AppResult> fullResultSet = new List <AppResult> ();

            // Build the tree and full result set recursively
            AppResult lastChild = null;

            foreach (var window in windows)
            {
                AppResult node = new GtkWidgetResult(window)
                {
                    SourceQuery = ToString()
                };
                fullResultSet.Add(node);

                if (rootNode.FirstChild == null)
                {
                    rootNode.FirstChild = node;
                    lastChild           = node;
                }
                else
                {
                    // Add the new node into the chain
                    lastChild.NextSibling = node;
                    node.PreviousSibling  = lastChild;
                    lastChild             = node;
                }

                // Create the children list and link them onto the node
                AppResult children = GenerateChildrenForContainer((Gtk.Container)window, fullResultSet);
                node.FirstChild = children;
            }

#if MAC
            NSWindow[] nswindows = NSApplication.SharedApplication.Windows;
            if (nswindows != null)
            {
                foreach (var window in nswindows)
                {
                    AppResult node = new NSObjectResult(window)
                    {
                        SourceQuery = ToString()
                    };
                    AppResult nsWindowLastNode = null;
                    fullResultSet.Add(node);

                    if (rootNode.FirstChild == null)
                    {
                        rootNode.FirstChild = node;
                        lastChild           = node;
                    }
                    else
                    {
                        lastChild.NextSibling = node;
                        node.PreviousSibling  = lastChild;
                        lastChild             = node;
                    }

                    foreach (var child in window.ContentView.Subviews)
                    {
                        AppResult childNode = new NSObjectResult(child)
                        {
                            SourceQuery = ToString()
                        };
                        fullResultSet.Add(childNode);

                        if (node.FirstChild == null)
                        {
                            node.FirstChild  = childNode;
                            nsWindowLastNode = childNode;
                        }
                        else
                        {
                            nsWindowLastNode.NextSibling = childNode;
                            childNode.PreviousSibling    = nsWindowLastNode;
                            nsWindowLastNode             = childNode;
                        }

                        if (child.Subviews != null)
                        {
                            AppResult children = GenerateChildrenForNSView(child, fullResultSet);
                            childNode.FirstChild = children;
                        }
                    }

                    NSToolbar toolbar     = window.Toolbar;
                    AppResult toolbarNode = new NSObjectResult(toolbar)
                    {
                        SourceQuery = ToString()
                    };

                    if (node.FirstChild == null)
                    {
                        node.FirstChild  = toolbarNode;
                        nsWindowLastNode = toolbarNode;
                    }
                    else
                    {
                        nsWindowLastNode.NextSibling = toolbarNode;
                        toolbarNode.PreviousSibling  = nsWindowLastNode;
                        nsWindowLastNode             = toolbarNode;
                    }

                    if (toolbar != null)
                    {
                        AppResult lastItemNode = null;
                        foreach (var item in toolbar.Items)
                        {
                            if (item.View != null)
                            {
                                AppResult itemNode = new NSObjectResult(item.View)
                                {
                                    SourceQuery = ToString()
                                };
                                fullResultSet.Add(itemNode);

                                if (toolbarNode.FirstChild == null)
                                {
                                    toolbarNode.FirstChild = itemNode;
                                    lastItemNode           = itemNode;
                                }
                                else
                                {
                                    lastItemNode.NextSibling = itemNode;
                                    itemNode.PreviousSibling = lastItemNode;
                                    lastItemNode             = itemNode;
                                }

                                if (item.View.Subviews != null)
                                {
                                    AppResult children = GenerateChildrenForNSView(item.View, fullResultSet);
                                    itemNode.FirstChild = children;
                                }
                            }
                        }
                    }
                }
            }
#endif
            return(fullResultSet);
        }
Ejemplo n.º 39
0
 public override string[] DefaultItemIdentifiers(NSToolbar toolbar)
 {
     return(TabNames);
 }
Ejemplo n.º 40
0
        void ProcessNSWindow(NSWindow window, AppResult rootNode, ref AppResult lastChild)
        {
            // Don't process hidden windows.
            if (!includeHidden && !window.IsVisible)
            {
                return;
            }

            AppResult node = new NSObjectResult(window)
            {
                SourceQuery = sourceQuery
            };

            AddToResultSet(node);
            AddChild(rootNode, node, ref lastChild);

            AppResult nsWindowLastNode = null;

            foreach (var child in window.ContentView.Subviews)
            {
                AppResult childNode = AddNSObjectResult(child);
                if (childNode == null)
                {
                    continue;
                }

                AddChild(node, childNode, ref nsWindowLastNode);
                GenerateChildrenForNSView(childNode, child);
            }

            NSToolbar toolbar = window.Toolbar;

            if (toolbar == null)
            {
                return;
            }

            AppResult toolbarNode = new NSObjectResult(toolbar)
            {
                SourceQuery = sourceQuery
            };

            // Was missing before too, maybe should be added to fullResultSet?

            AddChild(node, toolbarNode, ref nsWindowLastNode);

            if (toolbar == null)
            {
                return;
            }

            AppResult lastItemNode = null;

            foreach (var item in toolbar.Items)
            {
                AppResult itemNode = AddNSObjectResult(item.View);
                if (itemNode == null)
                {
                    continue;
                }

                AddChild(toolbarNode, itemNode, ref lastItemNode);
                GenerateChildrenForNSView(itemNode, item.View);
            }
        }
Ejemplo n.º 41
0
 public override string[] SelectableItemIdentifiers(NSToolbar toolbar)
 {
     return(TabNames);
 }
Ejemplo n.º 42
0
 public override string [] DefaultItemIdentifiers(NSToolbar toolbar)
 => allowedItemIdentifiers;
Ejemplo n.º 43
0
        public NSToolbarItem ToolbarItemForItemIdentifierWillBeInsertedIntoToolbar(NSToolbar toolbar, NSString itemIdentifier, bool flag)
        {
            // We create and autorelease a new NSToolbarItem, and then go through the process of setting up its
            // attributes from the master toolbar item matching that identifier in our dictionary of items.
            NSToolbarItem newItem = new NSToolbarItem(itemIdentifier);
            newItem.Autorelease();
            NSToolbarItem item = this.toolbarItems[itemIdentifier].CastTo<NSToolbarItem>();

            newItem.Label = item.Label;
            newItem.PaletteLabel = item.PaletteLabel;
            if (item.View != null)
            {
                newItem.View = item.View;
            }
            else
            {
                newItem.Image = item.Image;
            }
            newItem.ToolTip = item.ToolTip;
            newItem.Target = item.Target;
            newItem.Action = item.Action;
            newItem.MenuFormRepresentation = item.MenuFormRepresentation;
            // If we have a custom view, we *have* to set the min/max size - otherwise, it'll default to 0,0 and the custom
            // view won't show up at all!  This doesn't affect toolbar items with images, however.
            if (newItem.View != null)
            {
                newItem.MinSize = item.View.Bounds.size;
                newItem.MaxSize = item.View.Bounds.size;
            }

            return newItem;
        }
Ejemplo n.º 44
0
 public override string[] AllowedItemIdentifiers(NSToolbar toolbar)
 {
     return(new string[] { });
 }
Ejemplo n.º 45
0
        public MainToolbar(Gtk.Window window)
        {
            gtkWindow = window;
            widget    = new NSToolbar(MainToolbarId)
            {
                DisplayMode = NSToolbarDisplayMode.Icon,
            };

            awesomeBar = new AwesomeBar();
            awesomeBar.RunButton.Activated += (o, e) => {
                if (RunButtonClicked != null)
                {
                    RunButtonClicked(o, e);
                }
            };

            // Remove the focus from the Gtk system when Cocoa has focus
            // Fixes BXC #29601
            awesomeBar.SearchBar.GainedFocus += (o, e) => IdeApp.Workbench.RootWindow.Focus = null;

            AttachToolbarEvents(awesomeBar.SearchBar);

            selectorView.ConfigurationChanged += (sender, e) => {
                if (ConfigurationChanged != null)
                {
                    ConfigurationChanged(sender, e);
                }
            };

            selectorView.RuntimeChanged += (sender, ea) => {
                if (RuntimeChanged != null)
                {
                    RuntimeChanged(sender, ea);
                }
            };

            widget.WillInsertItem = (tool, id, send) => {
                switch (id)
                {
                case AwesomeBarId:
                    return(new NSToolbarItem(AwesomeBarId)
                    {
                        View = awesomeBar,
                        MinSize = new CGSize(1024, 25),
                        MaxSize = new CGSize(1024, 25)
                    });

                default:
                    throw new NotImplementedException();
                }
            };

            Action <NSNotification> resizeAction = notif => Runtime.RunInMainThread(() => {
                var win = awesomeBar.Window;
                if (win == null)
                {
                    return;
                }

                var item = widget.Items[0];

                var abFrameInWindow = awesomeBar.ConvertRectToView(awesomeBar.Frame, null);
                var size            = new CGSize(win.Frame.Width - abFrameInWindow.X - 4, 25);
                item.MinSize        = size;
                item.MaxSize        = size;
            });

            NSWindow nswin = GtkMacInterop.GetNSWindow(window);

            NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidResizeNotification, resizeAction, nswin);
            NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidEndLiveResizeNotification, resizeAction, nswin);
        }
Ejemplo n.º 46
0
 public override string[] DefaultItemIdentifiers(NSToolbar toolbar)
 {
     return(new string[] { });
 }
 public override string[] AllowedItemIdentifiers(NSToolbar toolbar)
 {
     return TabNames;
 }
Ejemplo n.º 48
0
 public override string[] SelectableItemIdentifiers(NSToolbar toolbar)
 {
     return new string[0];
 }
Ejemplo n.º 49
0
 public override string[] AllowedItemIdentifiers(NSToolbar toolbar)
 {
     string[] identifiers = {"Pan"};
     return identifiers;
 }
 public override string[] DefaultItemIdentifiers(NSToolbar toolbar)
 {
     return TabNames;
 }
Ejemplo n.º 51
0
 public void SetUp()
 {
     toolbar = new NSToolbar(NSToolbar.NSToolbarSeparatorItemIdentifier);
 }
 public override string[] SelectableItemIdentifiers(NSToolbar toolbar)
 {
     return TabNames;
 }