private Gtk.Menu MakeMenu(Gtk.Widget parent) { Gtk.Menu menu = new Gtk.Menu(); menu.AttachToWidget(parent, new Gtk.MenuDetachFunc(DetachWidget)); Gtk.ImageMenuItem item; // Quick Search menu items if (recent_searches.Count == 0) { item = new Gtk.ImageMenuItem(Catalog.GetString("No Recent Searches")); item.Sensitive = false; menu.Append(item); menu_to_query_map = null; } else { item = new Gtk.ImageMenuItem(Catalog.GetString("Recent Searches")); item.Sensitive = false; item.Image = new Gtk.Image(Stock.Find, IconSize.Menu); menu.Append(item); menu_to_query_map = new Hashtable(); foreach (string s in recent_searches) { // Replace all occurences of '_' with "__" // so that underscores don't become mnemonics. string query = s.Replace("_", "__"); item = new Gtk.ImageMenuItem(query); item.Activated += new EventHandler(OnSearch); menu.Append(item); menu_to_query_map [item] = s; } } if (recent_searches.Count > 0) { item = new Gtk.ImageMenuItem(Catalog.GetString("Clear")); item.Image = new Gtk.Image(Gtk.Stock.Clear, Gtk.IconSize.Menu); item.Activated += new EventHandler(OnClear); menu.Append(item); } menu.Append(new Gtk.SeparatorMenuItem()); item = new Gtk.ImageMenuItem(Catalog.GetString("Quit")); item.Image = new Gtk.Image(Gtk.Stock.Quit, Gtk.IconSize.Menu); item.Activated += new EventHandler(OnQuit); menu.Append(item); menu.ShowAll(); return(menu); }
private Gtk.Menu MakeMenu(Gtk.Widget parent) { Gtk.Menu menu = new Gtk.Menu(); menu.AttachToWidget(parent, new Gtk.MenuDetachFunc(DetachWidget)); Gtk.ImageMenuItem item; // Quick Search menu items ArrayList list = win.RetriveSearches(); if (list == null || list.Count == 0) { item = new Gtk.ImageMenuItem(Catalog.GetString("No Recent Searches")); item.Sensitive = false; menu.Append(item); menu_to_query_map = null; } else { item = new Gtk.ImageMenuItem(Catalog.GetString("Recent Searches")); item.Sensitive = false; item.Image = new Gtk.Image(Images.GetPixbuf("icon-search.png")); menu.Append(item); menu_to_query_map = new Hashtable(); foreach (string s in list) { item = new Gtk.ImageMenuItem(s); item.Activated += new EventHandler(QuickSearchEvent); menu.Append(item); menu_to_query_map [item] = s; } } if (list != null && list.Count > 0) { item = new Gtk.ImageMenuItem(Catalog.GetString("Clear")); item.Image = new Gtk.Image(Gtk.Stock.Clear, Gtk.IconSize.Menu); item.Activated += new EventHandler(ClearEvent); menu.Append(item); } menu.Append(new Gtk.SeparatorMenuItem()); item = new Gtk.ImageMenuItem(Catalog.GetString("Quit")); item.Image = new Gtk.Image(Gtk.Stock.Quit, Gtk.IconSize.Menu); item.Activated += new EventHandler(QuitEvent); menu.Append(item); menu.ShowAll(); return(menu); }
private Gtk.Menu MakeMenu (Gtk.Widget parent) { Gtk.Menu menu = new Gtk.Menu (); menu.AttachToWidget (parent, new Gtk.MenuDetachFunc (DetachWidget)); Gtk.ImageMenuItem item; // Quick Search menu items if (recent_searches.Count == 0) { item = new Gtk.ImageMenuItem (Catalog.GetString ("No Recent Searches")); item.Sensitive = false; menu.Append (item); menu_to_query_map = null; } else { item = new Gtk.ImageMenuItem (Catalog.GetString ("Recent Searches")); item.Sensitive = false; item.Image = new Gtk.Image (Stock.Find, IconSize.Menu); menu.Append (item); menu_to_query_map = new Hashtable (); foreach (string s in recent_searches) { // Replace all occurences of '_' with "__" // so that underscores don't become mnemonics. string query = s.Replace ("_", "__"); item = new Gtk.ImageMenuItem (query); item.Activated += new EventHandler (OnSearch); menu.Append (item); menu_to_query_map [item] = s; } } if (recent_searches.Count > 0) { item = new Gtk.ImageMenuItem (Catalog.GetString ("Clear")); item.Image = new Gtk.Image (Gtk.Stock.Clear, Gtk.IconSize.Menu); item.Activated += new EventHandler (OnClear); menu.Append (item); } menu.Append (new Gtk.SeparatorMenuItem ()); item = new Gtk.ImageMenuItem (Catalog.GetString ("Quit")); item.Image = new Gtk.Image (Gtk.Stock.Quit, Gtk.IconSize.Menu); item.Activated += new EventHandler (OnQuit); menu.Append (item); menu.ShowAll (); return menu; }
public FileMaskEntry(List <string> mask, object parent, Gtk.Window parentWindow) : base(false, 6) //(string name, bool isFolder) : base (false, 6) { windowParent = parentWindow; text = new Entry(); this.parent = parent; browse = Button.NewWithMnemonic(MainClass.Languages.Translate("browse")); text.Changed += new EventHandler(OnTextChanged); browse.Clicked += new EventHandler(OnButtonClicked); PackStart(text, true, true, 0); PackEnd(browse, false, false, 0); Gdk.Pixbuf default_pixbuf = null; string file = System.IO.Path.Combine(MainClass.Paths.ResDir, "stock-menu.png"); popupCondition = new Gtk.Menu(); if (System.IO.File.Exists(file)) { default_pixbuf = new Gdk.Pixbuf(file); Gtk.Button btnClose = new Gtk.Button(new Gtk.Image(default_pixbuf)); btnClose.TooltipText = MainClass.Languages.Translate("insert_path_mask"); btnClose.Relief = Gtk.ReliefStyle.None; btnClose.CanFocus = false; btnClose.WidthRequest = btnClose.HeightRequest = 22; popupCondition.AttachToWidget(btnClose, new Gtk.MenuDetachFunc(DetachWidget)); btnClose.Clicked += delegate { popupCondition.Popup(null, null, new Gtk.MenuPositionFunc(GetPosition), 3, Gtk.Global.CurrentEventTime); }; PackEnd(btnClose, false, false, 0); } if (mask != null) { foreach (string cd in mask) { AddMenuItem(cd); } } popupCondition.ShowAll(); this.ShowAll(); }
//(string name, bool isFolder) : base (false, 6) public FileMaskEntry(List<string> mask, object parent,Gtk.Window parentWindow) : base(false, 6) { windowParent =parentWindow; text = new Entry (); this.parent= parent; browse = Button.NewWithMnemonic (MainClass.Languages.Translate("browse")); text.Changed += new EventHandler (OnTextChanged); browse.Clicked += new EventHandler (OnButtonClicked); PackStart (text, true, true, 0); PackEnd (browse, false, false, 0); Gdk.Pixbuf default_pixbuf = null; string file = System.IO.Path.Combine(MainClass.Paths.ResDir, "stock-menu.png"); popupCondition = new Gtk.Menu(); if (System.IO.File.Exists(file)) { default_pixbuf = new Gdk.Pixbuf(file); Gtk.Button btnClose = new Gtk.Button(new Gtk.Image(default_pixbuf)); btnClose.TooltipText = MainClass.Languages.Translate("insert_path_mask"); btnClose.Relief = Gtk.ReliefStyle.None; btnClose.CanFocus = false; btnClose.WidthRequest = btnClose.HeightRequest = 22; popupCondition.AttachToWidget(btnClose,new Gtk.MenuDetachFunc(DetachWidget)); btnClose.Clicked += delegate { popupCondition.Popup(null,null, new Gtk.MenuPositionFunc (GetPosition) ,3,Gtk.Global.CurrentEventTime); }; PackEnd (btnClose, false, false, 0); } if (mask != null) foreach (string cd in mask) { AddMenuItem(cd); } popupCondition.ShowAll(); this.ShowAll(); }
public void ReloadPanel() { popupCondition = new Gtk.Menu(); popupCondition.AttachToWidget(btnPopUp, new Gtk.MenuDetachFunc(DetachWidget)); AddMenuItem(MainClass.Settings.Platform.Name); AddMenuItem(MainClass.Settings.Resolution.Name); if (project.ConditoinsDefine != null) { foreach (Condition cd in project.ConditoinsDefine) { AddMenuItem(cd.Name); } } popupCondition.ShowAll(); }
protected override void ShowPopupMenu(Gdk.Event ev) { Gtk.Menu menu = new Gtk.Menu(); { Gtk.MenuItem item = new Gtk.MenuItem("Add standard warp"); menu.Append(item); item.Activated += (sender, args) => { SelectedIndex = WarpGroup.AddWarp(WarpSourceType.Standard); }; } { Gtk.MenuItem item = new Gtk.MenuItem("Add specific-position warp"); menu.Append(item); item.Activated += (sender, args) => { SelectedIndex = WarpGroup.AddWarp(WarpSourceType.Pointed); }; } if (HoveringIndex != -1) { menu.Append(new Gtk.SeparatorMenuItem()); Gtk.MenuItem deleteItem = new Gtk.MenuItem("Delete"); deleteItem.Activated += (sender, args) => { if (SelectedIndex != -1) { WarpGroup.RemoveWarp(SelectedIndex); } }; menu.Append(deleteItem); } menu.AttachToWidget(this, null); menu.ShowAll(); menu.PopupAtPointer(ev); }
public GlobalOptionsWidget(Gtk.Window parent) { parentWindow = parent; this.Build(); this.chbShowUnsupportDevic.Sensitive = false; feLib = new FavoriteEntry(NavigationBar.NavigationType.libs); feLib.IsFolder = true; fePublishTool = new FavoriteEntry(NavigationBar.NavigationType.publish); fePublishTool.IsFolder = true; feEmulator = new FavoriteEntry(NavigationBar.NavigationType.emulator); feEmulator.IsFolder = true; if (!String.IsNullOrEmpty(MainClass.Settings.EmulatorDirectory)) { feEmulator.Path = MainClass.Settings.EmulatorDirectory; } if (!String.IsNullOrEmpty(MainClass.Settings.LibDirectory)) { feLib.Path = MainClass.Settings.LibDirectory; } if (!String.IsNullOrEmpty(MainClass.Settings.PublishDirectory)) { fePublishTool.Path = MainClass.Settings.PublishDirectory; } table1.Attach(fePublishTool, 1, 2, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 0); table1.Attach(feLib, 1, 2, 1, 2, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 0); table1.Attach(feEmulator, 1, 2, 2, 3, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 0); fontbutton1.FontName = MainClass.Settings.ConsoleTaskFont; chbAutoselectProject.Active = MainClass.Settings.AutoSelectProject; chbOpenLastOpenedW.Active = MainClass.Settings.OpenLastOpenedWorkspace; chbShowUnsupportDevic.Active = MainClass.Settings.ShowUnsupportedDevices; chbShowDebugDevic.Active = MainClass.Settings.ShowDebugDevices; cbBackground.UseAlpha = false; cbBackground.Color = new Gdk.Color(MainClass.Settings.BackgroundColor.Red, MainClass.Settings.BackgroundColor.Green, MainClass.Settings.BackgroundColor.Blue); ignoreFolder = new List <IgnoreFolder>(MainClass.Settings.IgnoresFolders.ToArray()); tvIgnoreFolder.AppendColumn(MainClass.Languages.Translate("name"), new Gtk.CellRendererText(), "text", 0); CellRendererToggle crt = new CellRendererToggle(); crt.Activatable = true; crt.Toggled += delegate(object o, ToggledArgs args) { TreeIter iter; if (storeIFo.GetIter(out iter, new TreePath(args.Path))) { bool old = (bool)storeIFo.GetValue(iter, 1); IgnoreFolder iFol = (IgnoreFolder)storeIFo.GetValue(iter, 3); iFol.IsForIde = !old; storeIFo.SetValue(iter, 1, !old); } }; tvIgnoreFolder.AppendColumn(MainClass.Languages.Translate("ignore_for_ide"), crt, "active", 1); CellRendererToggle crt2 = new CellRendererToggle(); crt2.Activatable = true; crt2.Toggled += delegate(object o, ToggledArgs args) { TreeIter iter; if (storeIFo.GetIter(out iter, new TreePath(args.Path))) { bool old = (bool)storeIFo.GetValue(iter, 2); IgnoreFolder iFol = (IgnoreFolder)storeIFo.GetValue(iter, 3); //CombinePublish cp =(CombinePublish) fontListStore.GetValue(iter,2); //cp.IsSelected = !old; iFol.IsForPublish = !old; storeIFo.SetValue(iter, 2, !old); } }; tvIgnoreFolder.AppendColumn(MainClass.Languages.Translate("ignore_for_Pub"), crt2, "active", 2); tvIgnoreFolder.Model = storeIFo; foreach (IgnoreFolder ignoref in MainClass.Settings.IgnoresFolders) { storeIFo.AppendValues(ignoref.Folder, ignoref.IsForIde, ignoref.IsForPublish, ignoref); } /* Ignore Files */ ignoreFile = new List <IgnoreFolder>(MainClass.Settings.IgnoresFiles.ToArray()); tvIgnoreFiles.AppendColumn(MainClass.Languages.Translate("name"), new Gtk.CellRendererText(), "text", 0); CellRendererToggle crtFi = new CellRendererToggle(); crtFi.Activatable = true; crtFi.Toggled += delegate(object o, ToggledArgs args) { TreeIter iter; if (storeIFi.GetIter(out iter, new TreePath(args.Path))) { bool old = (bool)storeIFi.GetValue(iter, 1); IgnoreFolder iFol = (IgnoreFolder)storeIFi.GetValue(iter, 3); iFol.IsForIde = !old; storeIFi.SetValue(iter, 1, !old); } }; tvIgnoreFiles.AppendColumn(MainClass.Languages.Translate("ignore_for_ide"), crtFi, "active", 1); CellRendererToggle crtFi2 = new CellRendererToggle(); crtFi2.Activatable = true; crtFi2.Toggled += delegate(object o, ToggledArgs args) { TreeIter iter; if (storeIFi.GetIter(out iter, new TreePath(args.Path))) { bool old = (bool)storeIFi.GetValue(iter, 2); IgnoreFolder iFol = (IgnoreFolder)storeIFi.GetValue(iter, 3); iFol.IsForPublish = !old; storeIFi.SetValue(iter, 2, !old); } }; tvIgnoreFiles.AppendColumn(MainClass.Languages.Translate("ignore_for_Pub"), crtFi2, "active", 2); tvIgnoreFiles.Model = storeIFi; foreach (IgnoreFolder ignoref in MainClass.Settings.IgnoresFiles) { storeIFi.AppendValues(ignoref.Folder, ignoref.IsForIde, ignoref.IsForPublish, ignoref); } /**/ Gdk.Pixbuf default_pixbuf = null; string file = System.IO.Path.Combine(MainClass.Paths.ResDir, "stock-menu.png"); if (System.IO.File.Exists(file)) { default_pixbuf = new Gdk.Pixbuf(file); popupColor = new Gtk.Menu(); CreateMenu(); Gtk.Button btnClose = new Gtk.Button(new Gtk.Image(default_pixbuf)); btnClose.TooltipText = MainClass.Languages.Translate("select_color"); btnClose.Relief = Gtk.ReliefStyle.None; btnClose.CanFocus = false; btnClose.WidthRequest = btnClose.HeightRequest = 22; popupColor.AttachToWidget(btnClose, new Gtk.MenuDetachFunc(DetachWidget)); btnClose.Clicked += delegate { popupColor.Popup(null, null, new Gtk.MenuPositionFunc(GetPosition), 3, Gtk.Global.CurrentEventTime); }; table1.Attach(btnClose, 2, 3, 3, 4, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); popupColor.ShowAll(); } }
public void ReloadPanel() { popupCondition = new Gtk.Menu(); popupCondition.AttachToWidget(btnPopUp,new Gtk.MenuDetachFunc(DetachWidget)); AddMenuItem(MainClass.Settings.Platform.Name); AddMenuItem(MainClass.Settings.Resolution.Name); if (project.ConditoinsDefine != null){ foreach (Condition cd in project.ConditoinsDefine) { AddMenuItem(cd.Name); } } popupCondition.ShowAll(); }
/// <summary>Shows a context menu.</summary> /// <param name='menu'>The menu.</param> /// <param name='parent'>The parent widget.</param> /// <param name='evt'>The mouse event. May be null if triggered by keyboard.</param> /// <param name='caret'>The caret/selection position within the parent, if the EventButton is null.</param> public static void ShowContextMenu(Menu menu, Widget parent, Gdk.EventButton evt, Gdk.Rectangle caret) { MenuPositionFunc posFunc = null; if (parent != null) { menu.AttachToWidget (parent, null); menu.Hidden += (sender, e) => { if (menu.AttachWidget != null) menu.Detach (); }; posFunc = delegate (Menu m, out int x, out int y, out bool pushIn) { Gdk.Window window = evt != null? evt.Window : parent.GdkWindow; window.GetOrigin (out x, out y); var alloc = parent.Allocation; if (evt != null) { x += (int) evt.X; y += (int) evt.Y; } else if (caret.X >= alloc.X && caret.Y >= alloc.Y) { x += caret.X; y += caret.Y + caret.Height; } else { x += alloc.X; y += alloc.Y; } Requisition request = m.SizeRequest (); var screen = parent.Screen; Gdk.Rectangle geometry = screen.GetMonitorGeometry(screen.GetMonitorAtPoint (x, y)); //whether to push or flip menus that would extend offscreen //FIXME: this is the correct behaviour for mac, check other platforms bool flip_left = true; bool flip_up = false; if (x + request.Width > geometry.X + geometry.Width) { if (flip_left) { x -= request.Width; } else { x = geometry.X + geometry.Width - request.Width; } if (x < geometry.Left) x = geometry.Left; } if (y + request.Height > geometry.Y + geometry.Height) { if (flip_up) { y -= request.Height; } else { y = geometry.Y + geometry.Height - request.Height; } if (y < geometry.Top) y = geometry.Top; } pushIn = false; }; } uint time; uint button; if (evt == null) { time = Global.CurrentEventTime; button = 0; } else { time = evt.Time; button = evt.Button; } //HACK: work around GTK menu issues on mac when passing button to menu.Popup //some menus appear and immediately hide, and submenus don't activate // if (Platform.IsMac) { // button = 0; // } menu.Popup (null, null, posFunc, button, time); }
public SettingPlatformDialog(bool isRequired) { this.Build(); //this.isRequired = isRequired; if(isRequired){ button34.Visible=false; } if(MainClass.Settings.BackgroundColor==null){ MainClass.Settings.BackgroundColor = new Option.Settings.BackgroundColors(218,218,218); /*if(MainClass.Platform.IsMac) MainClass.Settings.BackgroundColor = new Moscrif.IDE.Settings.Settings.BackgroundColors(218,218,218); else MainClass.Settings.BackgroundColor = new Moscrif.IDE.Settings.Settings.BackgroundColors(224,41,47); */ } if(!isRequired){ cbKeyBinding.AppendText(NOTHING); cbKeyBinding.Active = 0; } cbKeyBinding.AppendText(WIN); cbKeyBinding.AppendText(MACOSX); cbKeyBinding.AppendText(JAVA); cbKeyBinding.AppendText(VisualC); if(isRequired){ if(MainClass.Platform.IsMac){ cbKeyBinding.Active = 1; } else { cbKeyBinding.Active = 0; } } Gdk.Pixbuf default_pixbuf = null; string file = System.IO.Path.Combine(MainClass.Paths.ResDir, "stock-menu.png"); if (System.IO.File.Exists(file)) { default_pixbuf = new Gdk.Pixbuf(file); popupColor = new Gtk.Menu(); CreateMenu(); Gtk.Button btnClose = new Gtk.Button(new Gtk.Image(default_pixbuf)); btnClose.TooltipText = MainClass.Languages.Translate("select_color"); btnClose.Relief = Gtk.ReliefStyle.None; btnClose.CanFocus = false; btnClose.WidthRequest = btnClose.HeightRequest = 22; popupColor.AttachToWidget(btnClose,new Gtk.MenuDetachFunc(DetachWidget)); btnClose.Clicked += delegate { popupColor.Popup(null,null, new Gtk.MenuPositionFunc (GetPosition) ,3,Gtk.Global.CurrentEventTime); }; table1.Attach(btnClose,2,3,0,1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); table1.ShowAll(); popupColor.ShowAll(); } cbBackground.Color = new Gdk.Color(MainClass.Settings.BackgroundColor.Red, MainClass.Settings.BackgroundColor.Green,MainClass.Settings.BackgroundColor.Blue); }
public EntryMenu(List <string> menu1, string labelMenu1, List <string> menu2, string labelMenu2, string defValue) : base(false, 6) { if (!String.IsNullOrEmpty(defValue)) { LabelText = defValue; entryTxt.Text = defValue; } this.PackStart(entryTxt, true, true, 0); Gdk.Pixbuf default_pixbuf = null; string file = System.IO.Path.Combine(MainClass.Paths.ResDir, "stock-menu.png"); if (System.IO.File.Exists(file)) { default_pixbuf = new Gdk.Pixbuf(file); Gtk.Button btnClose = new Gtk.Button(new Gtk.Image(default_pixbuf)); btnClose.TooltipText = MainClass.Languages.Translate("insert_condition_name"); btnClose.Relief = Gtk.ReliefStyle.None; btnClose.CanFocus = false; btnClose.WidthRequest = btnClose.HeightRequest = 22; popupCondition.AttachToWidget(btnClose, new Gtk.MenuDetachFunc(DetachWidget)); btnClose.Clicked += delegate { popupCondition.Popup(); //popupCondition.Popup(btnClose,null,new Gtk.MenuPositionFunc (GetPosition),3,Gtk.Global.CurrentEventTime); }; this.PackEnd(btnClose, false, false, 0); } rbGroup = new GLib.SList(typeof(RadioMenuItem)); Gtk.MenuItem mi = new Gtk.MenuItem(labelMenu1); mi.Name = labelMenu1; mi.Sensitive = false; popupCondition.Add(mi); foreach (string m in menu1) { AddMenuItem(popupCondition, m); } Gtk.MenuItem mi2 = new Gtk.MenuItem(labelMenu2); mi2.Name = labelMenu2; mi2.Sensitive = false; popupCondition.Add(mi2); //Gtk.Menu subPopup2 = new Gtk.Menu(); foreach (string m in menu2) { AddMenuItem(popupCondition, m); } //popupCondition.State = StateType.Insensitive; //popupCondition. popupCondition.ShowAll(); this.ShowAll(); }
public SettingPlatformDialog(bool isRequired) { this.Build(); //this.isRequired = isRequired; if (isRequired) { button34.Visible = false; } if (MainClass.Settings.BackgroundColor == null) { MainClass.Settings.BackgroundColor = new Option.Settings.BackgroundColors(218, 218, 218); /*if(MainClass.Platform.IsMac) * MainClass.Settings.BackgroundColor = new Moscrif.IDE.Settings.Settings.BackgroundColors(218,218,218); * else * MainClass.Settings.BackgroundColor = new Moscrif.IDE.Settings.Settings.BackgroundColors(224,41,47); */ } if (!isRequired) { cbKeyBinding.AppendText(NOTHING); cbKeyBinding.Active = 0; } cbKeyBinding.AppendText(WIN); cbKeyBinding.AppendText(MACOSX); cbKeyBinding.AppendText(JAVA); cbKeyBinding.AppendText(VisualC); if (isRequired) { if (MainClass.Platform.IsMac) { cbKeyBinding.Active = 1; } else { cbKeyBinding.Active = 0; } } Gdk.Pixbuf default_pixbuf = null; string file = System.IO.Path.Combine(MainClass.Paths.ResDir, "stock-menu.png"); if (System.IO.File.Exists(file)) { default_pixbuf = new Gdk.Pixbuf(file); popupColor = new Gtk.Menu(); CreateMenu(); Gtk.Button btnClose = new Gtk.Button(new Gtk.Image(default_pixbuf)); btnClose.TooltipText = MainClass.Languages.Translate("select_color"); btnClose.Relief = Gtk.ReliefStyle.None; btnClose.CanFocus = false; btnClose.WidthRequest = btnClose.HeightRequest = 22; popupColor.AttachToWidget(btnClose, new Gtk.MenuDetachFunc(DetachWidget)); btnClose.Clicked += delegate { popupColor.Popup(null, null, new Gtk.MenuPositionFunc(GetPosition), 3, Gtk.Global.CurrentEventTime); }; table1.Attach(btnClose, 2, 3, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); table1.ShowAll(); popupColor.ShowAll(); } cbBackground.Color = new Gdk.Color(MainClass.Settings.BackgroundColor.Red, MainClass.Settings.BackgroundColor.Green, MainClass.Settings.BackgroundColor.Blue); }
private Gtk.Menu MakeMenu (Gtk.Widget parent) { Gtk.Menu menu = new Gtk.Menu (); menu.AttachToWidget (parent, new Gtk.MenuDetachFunc (DetachWidget)); Gtk.ImageMenuItem item; // Quick Search menu items ArrayList list = win.RetriveSearches (); if (list == null || list.Count == 0 ) { item = new Gtk.ImageMenuItem (Catalog.GetString ("No Recent Searches")); item.Sensitive = false; menu.Append (item); menu_to_query_map = null; } else { item = new Gtk.ImageMenuItem (Catalog.GetString ("Recent Searches")); item.Sensitive = false; item.Image = new Gtk.Image (Images.GetPixbuf ("icon-search.png")); menu.Append (item); menu_to_query_map = new Hashtable (); foreach (string s in list) { item = new Gtk.ImageMenuItem (s); item.Activated += new EventHandler (QuickSearchEvent); menu.Append (item); menu_to_query_map [item] = s; } } if (list != null && list.Count > 0) { item = new Gtk.ImageMenuItem (Catalog.GetString ("Clear")); item.Image = new Gtk.Image (Gtk.Stock.Clear, Gtk.IconSize.Menu); item.Activated += new EventHandler (ClearEvent); menu.Append (item); } menu.Append (new Gtk.SeparatorMenuItem ()); item = new Gtk.ImageMenuItem (Catalog.GetString ("Quit")); item.Image = new Gtk.Image (Gtk.Stock.Quit, Gtk.IconSize.Menu); item.Activated += new EventHandler (QuitEvent); menu.Append (item); menu.ShowAll (); return menu; }
private void BuildMenu() { list.Clear (); if (optionMenu.Menu != null) optionMenu.Menu.Destroy (); currentMenu = new Menu (); currentMenu.AttachToWidget (trayIcon, null); Menu menu = new Menu (); string[] files = Directory.GetFiles (didiwikidir); for (int i = 0; i < files.Length ; i++) { string file = files[i]; if (!file.EndsWith (".css")) { string fname = System.IO.Path.GetFileName (file); MenuItem item = new MenuItem (fname); item.Data["File"] = fname; item.Data["Position"] = i; ImageMenuItem trayMenuItem = new ImageMenuItem (fname); Image img = new Image (); img.Pixbuf = new Gdk.Pixbuf (null, "page.png"); img.IconSize = (int)IconSize.Menu; trayMenuItem.Image = img; trayMenuItem.Activated += ItemActivated; trayMenuItem.Data ["File"] = fname; trayMenuItem.Data ["Position"] = i; menu.Append (item); currentMenu.Append (trayMenuItem); list.Add (fname); } } currentMenu.Append (new SeparatorMenuItem ()); ImageMenuItem closeItem = new ImageMenuItem ("_Quit"); closeItem.Image = new Image (Gtk.Stock.Quit, Gtk.IconSize.Menu); closeItem.Activated += Quit; currentMenu.Append (closeItem); optionMenu.Menu = menu; menu.ShowAll (); }
public void DockPopupMenu(uint button, uint time) { if (menu == null) { // Create popup menu and attach it to the dock item menu = new Menu (); menu.AttachToWidget (this, new MenuDetachFunc (DetachMenu)); // Hide menuitem MenuItem mitem = new MenuItem ("Hide"); mitem.Activated += new EventHandler (ItemHideCb); menu.Append (mitem); // Lock menuitem CheckMenuItem citem = new CheckMenuItem ("Lock"); citem.Active = this.Locked; citem.Toggled += new EventHandler (ItemLockCb); menu.Append (citem); } menu.ShowAll (); menu.Popup (null, null, null, button, time); }
public SplashScreenForm(bool showSetting) : base(Gtk.WindowType.Toplevel) { Console.WriteLine("splash.bild.start-{0}",DateTime.Now); waitingSplash =showSetting; AppPaintable = true; this.Decorated = false; this.WindowPosition = WindowPosition.Center; this.TypeHint = Gdk.WindowTypeHint.Splashscreen; try { bitmap = new Gdk.Pixbuf(System.IO.Path.Combine( MainClass.Paths.ResDir, "moscrif.png")); } catch (Exception ex) { Tool.Logger.Error(ex.Message); Tool.Logger.Error("Can't load splash screen pixbuf 'moscrif.png'."); } progress = new ProgressBar(); progress.Fraction = 0.00; progress.HeightRequest = 6; vbox = new VBox(); vbox.BorderWidth = 12; label = new Gtk.Label(); label.UseMarkup = true; label.Xalign = 0; //vbox.PackEnd(progress, false, true, 0); if(showSetting){ Table table= new Table(3,3,false); Label lbl1 = new Label("Color Scheme :"); Label lbl2 = new Label("Keybinding :"); table.Attach(lbl1,0,1,0,1,AttachOptions.Shrink,AttachOptions.Shrink,0,0); table.Attach(lbl2,0,1,1,2,AttachOptions.Shrink,AttachOptions.Shrink,0,0); cbBackground = new ColorButton(); table.Attach(cbBackground,1,2,0,1,AttachOptions.Fill,AttachOptions.Shrink,0,0); cbKeyBinding = Gtk.ComboBox.NewText ();//new ComboBox(); cbKeyBinding.Name="cbKeyBinding"; if(MainClass.Settings.BackgroundColor==null){ MainClass.Settings.BackgroundColor = new Moscrif.IDE.Option.Settings.BackgroundColors(218,218,218); /*if(MainClass.Platform.IsMac) MainClass.Settings.BackgroundColor = new Moscrif.IDE.Settings.Settings.BackgroundColors(218,218,218); else MainClass.Settings.BackgroundColor = new Moscrif.IDE.Settings.Settings.BackgroundColors(224,41,47); */ } cbKeyBinding.AppendText(WIN); cbKeyBinding.AppendText(MACOSX); cbKeyBinding.AppendText(JAVA); cbKeyBinding.AppendText(VisualC); if(MainClass.Platform.IsMac){ cbKeyBinding.Active = 1; } else { cbKeyBinding.Active = 0; } Gdk.Pixbuf default_pixbuf = null; string file = System.IO.Path.Combine(MainClass.Paths.ResDir, "stock-menu.png"); //if (System.IO.File.Exists(file)) { try { default_pixbuf = new Gdk.Pixbuf(file); } catch (Exception ex) { Tool.Logger.Error(ex.Message); } popupColor = new Gtk.Menu(); CreateMenu(); Gtk.Button btnClose = new Gtk.Button(new Gtk.Image(default_pixbuf)); btnClose.TooltipText = MainClass.Languages.Translate("select_color"); btnClose.Relief = Gtk.ReliefStyle.None; btnClose.CanFocus = false; btnClose.WidthRequest = btnClose.HeightRequest = 22; popupColor.AttachToWidget(btnClose,new Gtk.MenuDetachFunc(DetachWidget)); btnClose.Clicked += delegate { popupColor.Popup(null,null, new Gtk.MenuPositionFunc (GetPosition) ,3,Gtk.Global.CurrentEventTime); }; table.Attach(btnClose,2,3,0,1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); popupColor.ShowAll(); //} cbBackground.Color = new Gdk.Color(MainClass.Settings.BackgroundColor.Red, MainClass.Settings.BackgroundColor.Green,MainClass.Settings.BackgroundColor.Blue); table.Attach(cbKeyBinding,1,2,1,2,AttachOptions.Fill,AttachOptions.Shrink,0,0); btnOk = new Gtk.Button(); btnOk.Label = "_Ok"; btnOk.UseUnderline = true; btnOk.Clicked+= OnButtonOkClicked; table.Attach(btnOk,0,1,2,3,AttachOptions.Fill,AttachOptions.Shrink,0,0); vbox.PackEnd(table, false, true, 3); } vbox.PackEnd(label, false, true, 3); this.Add(vbox); if (bitmap != null) this.Resize(bitmap.Width, bitmap.Height); Console.WriteLine("splash.bild.end-{0}",DateTime.Now); this.ShowAll(); }
public GlobalOptionsWidget(Gtk.Window parent) { parentWindow = parent; this.Build(); this.chbShowUnsupportDevic.Sensitive = false; feLib = new FavoriteEntry(NavigationBar.NavigationType.libs); feLib.IsFolder = true; fePublishTool = new FavoriteEntry(NavigationBar.NavigationType.publish); fePublishTool.IsFolder = true; feEmulator = new FavoriteEntry(NavigationBar.NavigationType.emulator); feEmulator.IsFolder = true; if (!String.IsNullOrEmpty(MainClass.Settings.EmulatorDirectory) ){ feEmulator.Path= MainClass.Settings.EmulatorDirectory; } if (!String.IsNullOrEmpty(MainClass.Settings.LibDirectory) ){ feLib.Path= MainClass.Settings.LibDirectory; } if (!String.IsNullOrEmpty(MainClass.Settings.PublishDirectory) ){ fePublishTool.Path = MainClass.Settings.PublishDirectory; } table1.Attach(fePublishTool,1,2,0,1,AttachOptions.Fill|AttachOptions.Expand,AttachOptions.Fill,0,0); table1.Attach(feLib,1,2,1,2,AttachOptions.Fill|AttachOptions.Expand,AttachOptions.Fill,0,0); table1.Attach(feEmulator,1,2,2,3,AttachOptions.Fill|AttachOptions.Expand,AttachOptions.Fill,0,0); fontbutton1.FontName = MainClass.Settings.ConsoleTaskFont; chbAutoselectProject.Active = MainClass.Settings.AutoSelectProject; chbOpenLastOpenedW.Active= MainClass.Settings.OpenLastOpenedWorkspace; chbShowUnsupportDevic.Active = MainClass.Settings.ShowUnsupportedDevices; chbShowDebugDevic.Active =MainClass.Settings.ShowDebugDevices; cbBackground.UseAlpha = false; cbBackground.Color = new Gdk.Color(MainClass.Settings.BackgroundColor.Red, MainClass.Settings.BackgroundColor.Green,MainClass.Settings.BackgroundColor.Blue); ignoreFolder = new List<IgnoreFolder>( MainClass.Settings.IgnoresFolders.ToArray()); tvIgnoreFolder.AppendColumn(MainClass.Languages.Translate("name"), new Gtk.CellRendererText(), "text", 0); CellRendererToggle crt = new CellRendererToggle(); crt.Activatable = true; crt.Toggled += delegate(object o, ToggledArgs args) { TreeIter iter; if (storeIFo.GetIter (out iter, new TreePath(args.Path))) { bool old = (bool) storeIFo.GetValue(iter,1); IgnoreFolder iFol = (IgnoreFolder) storeIFo.GetValue(iter,3); iFol.IsForIde =!old; storeIFo.SetValue(iter,1,!old); } }; tvIgnoreFolder.AppendColumn(MainClass.Languages.Translate("ignore_for_ide"), crt , "active", 1); CellRendererToggle crt2 = new CellRendererToggle(); crt2.Activatable = true; crt2.Toggled += delegate(object o, ToggledArgs args) { TreeIter iter; if (storeIFo.GetIter (out iter, new TreePath(args.Path))) { bool old = (bool) storeIFo.GetValue(iter,2); IgnoreFolder iFol = (IgnoreFolder) storeIFo.GetValue(iter,3); //CombinePublish cp =(CombinePublish) fontListStore.GetValue(iter,2); //cp.IsSelected = !old; iFol.IsForPublish =!old; storeIFo.SetValue(iter,2,!old); } }; tvIgnoreFolder.AppendColumn(MainClass.Languages.Translate("ignore_for_Pub"), crt2 , "active", 2); tvIgnoreFolder.Model = storeIFo; foreach (IgnoreFolder ignoref in MainClass.Settings.IgnoresFolders){ storeIFo.AppendValues(ignoref.Folder,ignoref.IsForIde,ignoref.IsForPublish,ignoref); } /* Ignore Files */ ignoreFile = new List<IgnoreFolder>( MainClass.Settings.IgnoresFiles.ToArray()); tvIgnoreFiles.AppendColumn(MainClass.Languages.Translate("name"), new Gtk.CellRendererText(), "text", 0); CellRendererToggle crtFi = new CellRendererToggle(); crtFi.Activatable = true; crtFi.Toggled += delegate(object o, ToggledArgs args) { TreeIter iter; if (storeIFi.GetIter (out iter, new TreePath(args.Path))) { bool old = (bool) storeIFi.GetValue(iter,1); IgnoreFolder iFol = (IgnoreFolder) storeIFi.GetValue(iter,3); iFol.IsForIde =!old; storeIFi.SetValue(iter,1,!old); } }; tvIgnoreFiles.AppendColumn(MainClass.Languages.Translate("ignore_for_ide"), crtFi , "active", 1); CellRendererToggle crtFi2 = new CellRendererToggle(); crtFi2.Activatable = true; crtFi2.Toggled += delegate(object o, ToggledArgs args) { TreeIter iter; if (storeIFi.GetIter (out iter, new TreePath(args.Path))) { bool old = (bool) storeIFi.GetValue(iter,2); IgnoreFolder iFol = (IgnoreFolder) storeIFi.GetValue(iter,3); iFol.IsForPublish =!old; storeIFi.SetValue(iter,2,!old); } }; tvIgnoreFiles.AppendColumn(MainClass.Languages.Translate("ignore_for_Pub"), crtFi2 , "active", 2); tvIgnoreFiles.Model = storeIFi; foreach (IgnoreFolder ignoref in MainClass.Settings.IgnoresFiles){ storeIFi.AppendValues(ignoref.Folder,ignoref.IsForIde,ignoref.IsForPublish,ignoref); } /**/ Gdk.Pixbuf default_pixbuf = null; string file = System.IO.Path.Combine(MainClass.Paths.ResDir, "stock-menu.png"); if (System.IO.File.Exists(file)) { default_pixbuf = new Gdk.Pixbuf(file); popupColor = new Gtk.Menu(); CreateMenu(); Gtk.Button btnClose = new Gtk.Button(new Gtk.Image(default_pixbuf)); btnClose.TooltipText = MainClass.Languages.Translate("select_color"); btnClose.Relief = Gtk.ReliefStyle.None; btnClose.CanFocus = false; btnClose.WidthRequest = btnClose.HeightRequest = 22; popupColor.AttachToWidget(btnClose,new Gtk.MenuDetachFunc(DetachWidget)); btnClose.Clicked += delegate { popupColor.Popup(null,null, new Gtk.MenuPositionFunc (GetPosition) ,3,Gtk.Global.CurrentEventTime); }; table1.Attach(btnClose,2,3,3,4, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); popupColor.ShowAll(); } }
void OnClicked(int posX, int posY, Gdk.Event triggerEvent, uint button) { Cairo.Point p = GetGridPosition(posX, posY, scale: false, offset: false); if (EnableTileEditing && hoveringComponent == null) { if (!IsInBounds(posX, posY, scale: false, offset: false)) { return; } if (button == 1) // Left-click { RoomLayout.SetTile(p.X, p.Y, TilesetViewer.SelectedIndex); draggingTile = true; } else if (button == 3) // Right-click { TilesetViewer.SelectedIndex = RoomLayout.GetTile(p.X, p.Y); } } if (DrawRoomComponents) { if (hoveringComponent != null) { selectedComponent = hoveringComponent; hoveringComponent.Select(); if (button == 1) // Left click { draggingObject = true; } else if (button == 3) // Right click { Gtk.Menu menu = new Gtk.Menu(); foreach (Gtk.MenuItem item in selectedComponent.GetRightClickMenuItems()) { menu.Add(item); } RoomComponent comp = selectedComponent; if (comp.Deletable) { if (menu.Children.Length != 0) { menu.Add(new Gtk.SeparatorMenuItem()); } var deleteButton = new Gtk.MenuItem("Delete"); deleteButton.Activated += (sender, args) => { comp.Delete(); }; menu.Add(deleteButton); } menu.AttachToWidget(this, null); menu.ShowAll(); menu.PopupAtPointer(triggerEvent); } } } QueueDraw(); }
/// <summary>Shows a context menu.</summary> /// <param name='menu'>The menu.</param> /// <param name='parent'>The parent widget.</param> /// <param name='evt'>The mouse event. May be null if triggered by keyboard.</param> /// <param name='caret'>The caret/selection position within the parent, if the EventButton is null.</param> public static void ShowContextMenu(Gtk.Menu menu, Gtk.Widget parent, Gdk.EventButton evt, Gdk.Rectangle caret) { Gtk.MenuPositionFunc posFunc = null; if (parent != null) { menu.AttachToWidget(parent, null); menu.Hidden += (sender, e) => { menu.Detach(); }; posFunc = delegate(Gtk.Menu m, out int x, out int y, out bool pushIn) { Gdk.Window window = evt != null? evt.Window : parent.GdkWindow; window.GetOrigin(out x, out y); var alloc = parent.Allocation; if (evt != null) { x += (int)evt.X; y += (int)evt.Y; } else if (caret.X >= alloc.X && caret.Y >= alloc.Y) { x += caret.X; y += caret.Y + caret.Height; } else { x += alloc.X; y += alloc.Y; } Gtk.Requisition request = m.SizeRequest(); var screen = parent.Screen; Gdk.Rectangle geometry = GetUsableMonitorGeometry(screen, screen.GetMonitorAtPoint(x, y)); //whether to push or flip menus that would extend offscreen //FIXME: this is the correct behaviour for mac, check other platforms bool flip_left = true; bool flip_up = false; if (x + request.Width > geometry.X + geometry.Width) { if (flip_left) { x -= request.Width; } else { x = geometry.X + geometry.Width - request.Width; } if (x < geometry.Left) { x = geometry.Left; } } if (y + request.Height > geometry.Y + geometry.Height) { if (flip_up) { y -= request.Height; } else { y = geometry.Y + geometry.Height - request.Height; } if (y < geometry.Top) { y = geometry.Top; } } pushIn = false; }; } uint time; uint button; if (evt == null) { time = Gtk.Global.CurrentEventTime; button = 0; } else { time = evt.Time; button = evt.Button; } //HACK: work around GTK menu issues on mac when passing button to menu.Popup //some menus appear and immediately hide, and submenus don't activate if (Platform.IsMac) { button = 0; } menu.Popup(null, null, posFunc, button, time); }
void TemplatesTreeViewButtonPressed (object o, ButtonPressEventArgs args) { SolutionTemplate template = GetSelectedTemplate (); if ((template == null) || (template.AvailableLanguages.Count <= 1)) { return; } if (templateTextRenderer.IsLanguageButtonPressed (args.Event)) { if (popupMenu == null) { popupMenu = new Menu (); popupMenu.AttachToWidget (this, null); } ClearPopupMenuItems (); AddLanguageMenuItems (popupMenu, template); popupMenu.ModifyBg (StateType.Normal, GtkTemplateCellRenderer.LanguageButtonBackgroundColor); popupMenu.ShowAll (); MenuPositionFunc posFunc = (Menu m, out int x, out int y, out bool pushIn) => { Gdk.Rectangle rect = templateTextRenderer.GetLanguageRect (); Gdk.Rectangle screenRect = GtkUtil.ToScreenCoordinates (templatesTreeView, templatesTreeView.GdkWindow, rect); x = screenRect.X; y = screenRect.Bottom; pushIn = false; }; popupMenu.Popup (null, null, posFunc, 0, args.Event.Time); } }
public SplashScreenForm(bool showSetting) : base(Gtk.WindowType.Toplevel) { Console.WriteLine("splash.bild.start-{0}", DateTime.Now); waitingSplash = showSetting; AppPaintable = true; this.Decorated = false; this.WindowPosition = WindowPosition.Center; this.TypeHint = Gdk.WindowTypeHint.Splashscreen; try { bitmap = new Gdk.Pixbuf(System.IO.Path.Combine(MainClass.Paths.ResDir, "moscrif.png")); } catch (Exception ex) { Tool.Logger.Error(ex.Message); Tool.Logger.Error("Can't load splash screen pixbuf 'moscrif.png'."); } progress = new ProgressBar(); progress.Fraction = 0.00; progress.HeightRequest = 6; vbox = new VBox(); vbox.BorderWidth = 12; label = new Gtk.Label(); label.UseMarkup = true; label.Xalign = 0; //vbox.PackEnd(progress, false, true, 0); if (showSetting) { Table table = new Table(3, 3, false); Label lbl1 = new Label("Color Scheme :"); Label lbl2 = new Label("Keybinding :"); table.Attach(lbl1, 0, 1, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); table.Attach(lbl2, 0, 1, 1, 2, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); cbBackground = new ColorButton(); table.Attach(cbBackground, 1, 2, 0, 1, AttachOptions.Fill, AttachOptions.Shrink, 0, 0); cbKeyBinding = Gtk.ComboBox.NewText(); //new ComboBox(); cbKeyBinding.Name = "cbKeyBinding"; if (MainClass.Settings.BackgroundColor == null) { MainClass.Settings.BackgroundColor = new Moscrif.IDE.Option.Settings.BackgroundColors(218, 218, 218); /*if(MainClass.Platform.IsMac) * MainClass.Settings.BackgroundColor = new Moscrif.IDE.Settings.Settings.BackgroundColors(218,218,218); * else * MainClass.Settings.BackgroundColor = new Moscrif.IDE.Settings.Settings.BackgroundColors(224,41,47); */ } cbKeyBinding.AppendText(WIN); cbKeyBinding.AppendText(MACOSX); cbKeyBinding.AppendText(JAVA); cbKeyBinding.AppendText(VisualC); if (MainClass.Platform.IsMac) { cbKeyBinding.Active = 1; } else { cbKeyBinding.Active = 0; } Gdk.Pixbuf default_pixbuf = null; string file = System.IO.Path.Combine(MainClass.Paths.ResDir, "stock-menu.png"); //if (System.IO.File.Exists(file)) { try { default_pixbuf = new Gdk.Pixbuf(file); } catch (Exception ex) { Tool.Logger.Error(ex.Message); } popupColor = new Gtk.Menu(); CreateMenu(); Gtk.Button btnClose = new Gtk.Button(new Gtk.Image(default_pixbuf)); btnClose.TooltipText = MainClass.Languages.Translate("select_color"); btnClose.Relief = Gtk.ReliefStyle.None; btnClose.CanFocus = false; btnClose.WidthRequest = btnClose.HeightRequest = 22; popupColor.AttachToWidget(btnClose, new Gtk.MenuDetachFunc(DetachWidget)); btnClose.Clicked += delegate { popupColor.Popup(null, null, new Gtk.MenuPositionFunc(GetPosition), 3, Gtk.Global.CurrentEventTime); }; table.Attach(btnClose, 2, 3, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); popupColor.ShowAll(); //} cbBackground.Color = new Gdk.Color(MainClass.Settings.BackgroundColor.Red, MainClass.Settings.BackgroundColor.Green, MainClass.Settings.BackgroundColor.Blue); table.Attach(cbKeyBinding, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Shrink, 0, 0); btnOk = new Gtk.Button(); btnOk.Label = "_Ok"; btnOk.UseUnderline = true; btnOk.Clicked += OnButtonOkClicked; table.Attach(btnOk, 0, 1, 2, 3, AttachOptions.Fill, AttachOptions.Shrink, 0, 0); vbox.PackEnd(table, false, true, 3); } vbox.PackEnd(label, false, true, 3); this.Add(vbox); if (bitmap != null) { this.Resize(bitmap.Width, bitmap.Height); } Console.WriteLine("splash.bild.end-{0}", DateTime.Now); this.ShowAll(); }