void InitApp(CommandManager commandManager) { if (initedApp) { return; } commandManager.CommandActivating += OnCommandActivating; //mac-ify these command names commandManager.GetCommand(EditCommands.MonodevelopPreferences).Text = GettextCatalog.GetString("Preferences..."); commandManager.GetCommand(EditCommands.DefaultPolicies).Text = GettextCatalog.GetString("Policies..."); commandManager.GetCommand(HelpCommands.About).Text = GetAboutCommandText(); commandManager.GetCommand(MacIntegrationCommands.HideWindow).Text = GetHideWindowCommandText(); commandManager.GetCommand(ToolCommands.AddinManager).Text = GettextCatalog.GetString("Extensions..."); initedApp = true; IdeApp.Workbench.RootWindow.DeleteEvent += HandleDeleteEvent; if (MacSystemInformation.OsVersion >= MacSystemInformation.Lion) { IdeApp.Workbench.RootWindow.Realized += (sender, args) => { var win = GtkQuartz.GetWindow((Gtk.Window)sender); win.CollectionBehavior |= NSWindowCollectionBehavior.FullScreenPrimary; }; } PatchGtkTheme(); NSNotificationCenter.DefaultCenter.AddObserver(NSCell.ControlTintChangedNotification, notif => Core.Runtime.RunInMainThread( delegate { Styles.LoadStyle(); PatchGtkTheme(); })); Styles.Changed += (s, a) => { var colorPanel = NSColorPanel.SharedColorPanel; if (colorPanel.ContentView?.Superview?.Window == null) { LoggingService.LogWarning("Updating shared color panel appearance failed, no valid window."); } IdeTheme.ApplyTheme(colorPanel.ContentView.Superview.Window); var appearance = colorPanel.ContentView.Superview.Window.Appearance; if (appearance == null) { appearance = NSAppearance.GetAppearance(IdeApp.Preferences.UserInterfaceTheme == Theme.Light ? NSAppearance.NameAqua : NSAppearance.NameVibrantDark); } // The subviews of the shared NSColorPanel do not inherit the appearance of the main panel window // and need to be updated recursively. UpdateColorPanelSubviewsAppearance(colorPanel.ContentView.Superview, appearance); }; // FIXME: Immediate theme switching disabled, until NSAppearance issues are fixed //IdeApp.Preferences.UserInterfaceTheme.Changed += (s,a) => PatchGtkTheme (); }
internal override void RemoveWindowShadow(Gtk.Window window) { if (window == null) { throw new ArgumentNullException("window"); } NSWindow w = GtkQuartz.GetWindow(window); w.HasShadow = false; }
internal override void AddChildWindow(Gtk.Window parent, Gtk.Window child) { NSWindow w = GtkQuartz.GetWindow(parent); child.Realize(); NSWindow overlay = GtkQuartz.GetWindow(child); overlay.SetExcludedFromWindowsMenu(true); w.AddChildWindow(overlay, NSWindowOrderingMode.Above); }
public override bool GetIsFullscreen(Gtk.Window window) { if (MacSystemInformation.OsVersion < MacSystemInformation.Lion) { return(base.GetIsFullscreen(window)); } NSWindow nswin = GtkQuartz.GetWindow(window); return((nswin.StyleMask & NSWindowStyle.FullScreenWindow) != 0); }
internal static void ShowTipWindow() { var tipLoader = new TipLoader(); if (!tipLoader.LoadTips().Result) { return; } var oldMainWindow = NSApplication.SharedApplication.KeyWindow ?? NSApplication.SharedApplication.MainWindow ?? GtkQuartz.GetWindow(MessageService.RootWindow); using (var tipWindow = InflateFromNibResource <TipWindow> ("__xammac_content_TipWindow.nib")) { tipWindow.ParentWindow = oldMainWindow; tipWindow.MakeKeyAndOrderFront(tipWindow); tipWindow.ShowAtStartup = StartupHandler.ShowAtStartup; FilePath sharedAssetsPath = Mono.Addins.AddinManager.CurrentAddin.GetFilePath("content"); tipWindow.HandleUrlOpen = s => { if (s.IsFile) { return(false); } DesktopService.ShowUrl(s.ToString()); return(true); }; void nextMessage(object sender, EventArgs e) { string html; string basePath = sharedAssetsPath; try { var tip = tipLoader.GetNextTip(); basePath = System.IO.Path.GetDirectoryName(tip.Filename); html = new TipView(tip, sharedAssetsPath).GenerateString(); } catch (Exception ex) { html = $"<h1>Error</h1><p>{ex.ToString ()}</p>"; } tipWindow.LoadHtml(html, basePath); } tipWindow.NextTipClicked += nextMessage; nextMessage(null, null); tipWindow.Run(); StartupHandler.ShowAtStartup = tipWindow.ShowAtStartup; } GtkQuartz.FocusWindow(GtkQuartz.GetGtkWindow(oldMainWindow) ?? MessageService.RootWindow); }
internal override void SetMainWindowDecorations(Gtk.Window window) { NSWindow w = GtkQuartz.GetWindow(window); w.IsOpaque = false; var resource = "maintoolbarbg.png"; NSImage img = LoadImage(resource); w.BackgroundColor = NSColor.FromPatternImage(img); w.StyleMask |= NSWindowStyle.TexturedBackground; }
internal override void AttachMainToolbar(Gtk.VBox parent, IMainToolbarView toolbar) { var nativeToolbar = (MonoDevelop.MacIntegration.MainToolbar.MainToolbar)toolbar; NSWindow w = GtkQuartz.GetWindow(nativeToolbar.gtkWindow); if (MacSystemInformation.OsVersion >= MacSystemInformation.Yosemite) { w.TitleVisibility = NSWindowTitleVisibility.Hidden; } w.Toolbar = nativeToolbar.widget; nativeToolbar.Initialize(); }
public override void PlaceWindow(Gtk.Window window, int x, int y, int width, int height) { if (window.GdkWindow == null) { return; // Not yet realized } NSWindow w = GtkQuartz.GetWindow(window); var dr = FromDesktopRect(new Gdk.Rectangle(x, y, width, height)); var r = w.FrameRectFor(dr); w.SetFrame(r, true); base.PlaceWindow(window, x, y, width, height); }
void InitApp(CommandManager commandManager) { if (initedApp) { return; } MacMainMenu.SetAppQuitCommand(CommandManager.ToCommandId(FileCommands.Exit)); MacMainMenu.AddCommandIDMappings(new Dictionary <object, CarbonCommandID> () { { CommandManager.ToCommandId(EditCommands.Copy), CarbonCommandID.Copy }, { CommandManager.ToCommandId(EditCommands.Cut), CarbonCommandID.Cut }, { CommandManager.ToCommandId(EditCommands.MonodevelopPreferences), CarbonCommandID.Preferences }, { CommandManager.ToCommandId(EditCommands.Redo), CarbonCommandID.Redo }, { CommandManager.ToCommandId(EditCommands.Undo), CarbonCommandID.Undo }, { CommandManager.ToCommandId(EditCommands.SelectAll), CarbonCommandID.SelectAll }, { CommandManager.ToCommandId(FileCommands.NewFile), CarbonCommandID.New }, { CommandManager.ToCommandId(FileCommands.OpenFile), CarbonCommandID.Open }, { CommandManager.ToCommandId(FileCommands.Save), CarbonCommandID.Save }, { CommandManager.ToCommandId(FileCommands.SaveAs), CarbonCommandID.SaveAs }, { CommandManager.ToCommandId(FileCommands.CloseFile), CarbonCommandID.Close }, { CommandManager.ToCommandId(FileCommands.Exit), CarbonCommandID.Quit }, { CommandManager.ToCommandId(FileCommands.ReloadFile), CarbonCommandID.Revert }, { CommandManager.ToCommandId(HelpCommands.About), CarbonCommandID.About }, { CommandManager.ToCommandId(HelpCommands.Help), CarbonCommandID.AppHelp }, { CommandManager.ToCommandId(MacIntegrationCommands.HideWindow), CarbonCommandID.Hide }, { CommandManager.ToCommandId(MacIntegrationCommands.HideOthers), CarbonCommandID.HideOthers }, }); //mac-ify these command names commandManager.GetCommand(EditCommands.MonodevelopPreferences).Text = GettextCatalog.GetString("Preferences..."); commandManager.GetCommand(EditCommands.DefaultPolicies).Text = GettextCatalog.GetString("Custom Policies..."); commandManager.GetCommand(HelpCommands.About).Text = GettextCatalog.GetString("About {0}", BrandingService.ApplicationName); commandManager.GetCommand(MacIntegrationCommands.HideWindow).Text = GettextCatalog.GetString("Hide {0}", BrandingService.ApplicationName); commandManager.GetCommand(ToolCommands.AddinManager).Text = GettextCatalog.GetString("Add-in Manager..."); initedApp = true; IdeApp.Workbench.RootWindow.DeleteEvent += HandleDeleteEvent; if (MacSystemInformation.OsVersion >= MacSystemInformation.Lion) { IdeApp.Workbench.RootWindow.Realized += (sender, args) => { var win = GtkQuartz.GetWindow((Gtk.Window)sender); win.CollectionBehavior |= NSWindowCollectionBehavior.FullScreenPrimary; }; } }
public override void SetIsFullscreen(Window window, bool isFullscreen) { if (MacSystemInformation.OsVersion < MacSystemInformation.Lion) { base.SetIsFullscreen(window, isFullscreen); return; } NSWindow nswin = GtkQuartz.GetWindow(window); if (isFullscreen != ((nswin.StyleMask & NSWindowStyle.FullScreenWindow) != 0)) { nswin.ToggleFullScreen(null); } }
public override void SetIsFullscreen(Gtk.Window window, bool isFullscreen) { if (MacSystemInformation.OsVersion < MacSystemInformation.Lion) { base.SetIsFullscreen(window, isFullscreen); return; } NSWindow nswin = GtkQuartz.GetWindow(window); if (isFullscreen != ((nswin.StyleMask & NSWindowStyle.FullScreenWindow) != 0)) { //HACK: workaround for MonoMac not allowing null as argument MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr( nswin.Handle, MonoMac.ObjCRuntime.Selector.GetHandle("toggleFullScreen:"), IntPtr.Zero); } }
public override void Initialize() { base.Initialize(); var image = Xwt.Drawing.Image.FromResource(typeof(MacPlatformService).Assembly, "maintoolbarbg.png"); Window.Realized += delegate { NSWindow w = GtkQuartz.GetWindow(Window); w.IsOpaque = false; w.BackgroundColor = NSColor.FromPatternImage(image.ToBitmap().ToNSImage()); w.StyleMask |= NSWindowStyle.TexturedBackground; }; toolbar = new CustomToolbar(); toolbar.Background = (Gdk.Pixbuf)Xwt.Toolkit.Load(Xwt.ToolkitType.Gtk).GetNativeImage(image); toolbar.TitleBarHeight = MacPlatformService.GetTitleBarHeight(); MainBox.PackStart(toolbar, false, false, 0); ((Gtk.Box.BoxChild)MainBox [toolbar]).Position = 0; }
public override void Initialize() { base.Initialize(); var resource = "maintoolbarbg.png"; Window.Realized += delegate { NSWindow w = GtkQuartz.GetWindow(Window); w.IsOpaque = false; NSImage img = MacPlatformService.LoadImage(resource); w.BackgroundColor = NSColor.FromPatternImage(img); w.StyleMask |= NSWindowStyle.TexturedBackground; }; toolbar = new CustomToolbar(); toolbar.Background = MonoDevelop.Components.CairoExtensions.LoadImage(typeof(MacPlatformService).Assembly, resource); toolbar.TitleBarHeight = MacPlatformService.GetTitleBarHeight(); MainBox.PackStart(toolbar, false, false, 0); ((Gtk.Box.BoxChild)MainBox [toolbar]).Position = 0; }
internal override MainToolbar CreateMainToolbar(Gtk.Window window) { NSWindow w = GtkQuartz.GetWindow(window); w.IsOpaque = false; var resource = "maintoolbarbg.png"; NSImage img = LoadImage(resource); var c = NSColor.FromPatternImage(img); w.BackgroundColor = c; w.StyleMask |= NSWindowStyle.TexturedBackground; var result = new MainToolbar() { Background = MonoDevelop.Components.CairoExtensions.LoadImage(typeof(MacPlatformService).Assembly, resource), TitleBarHeight = GetTitleBarHeight() }; return(result); }
void InitApp(CommandManager commandManager) { if (initedApp) { return; } commandManager.CommandActivating += OnCommandActivating; //mac-ify these command names commandManager.GetCommand(EditCommands.MonodevelopPreferences).Text = GettextCatalog.GetString("Preferences..."); commandManager.GetCommand(EditCommands.DefaultPolicies).Text = GettextCatalog.GetString("Custom Policies..."); commandManager.GetCommand(HelpCommands.About).Text = GetAboutCommandText(); commandManager.GetCommand(MacIntegrationCommands.HideWindow).Text = GetHideWindowCommandText(); commandManager.GetCommand(ToolCommands.AddinManager).Text = GettextCatalog.GetString("Add-in Manager..."); initedApp = true; IdeApp.Workbench.RootWindow.DeleteEvent += HandleDeleteEvent; BrandingService.ApplicationNameChanged += ApplicationNameChanged; if (MacSystemInformation.OsVersion >= MacSystemInformation.Lion) { IdeApp.Workbench.RootWindow.Realized += (sender, args) => { var win = GtkQuartz.GetWindow((Gtk.Window)sender); win.CollectionBehavior |= NSWindowCollectionBehavior.FullScreenPrimary; }; } PatchGtkTheme(); NSNotificationCenter.DefaultCenter.AddObserver(NSCell.ControlTintChangedNotification, notif => Runtime.RunInMainThread( delegate { Styles.LoadStyle(); PatchGtkTheme(); })); // FIXME: Immediate theme switching disabled, until NSAppearance issues are fixed //IdeApp.Preferences.UserInterfaceTheme.Changed += (s,a) => PatchGtkTheme (); }
protected override void Run() { NSWindow w = GtkQuartz.GetWindow(IdeApp.Workbench.RootWindow); w.PerformZoom(w); }