Exemple #1
0
 public static extern CarbonMenuStatus SetMenuItemData(IntPtr menu, uint indexOrCommandID, bool isCommandID, ref MenuItemData data);
		public static extern CarbonMenuStatus SetMenuItemData (IntPtr menu, uint indexOrCommandID, bool isCommandID, ref MenuItemData data);
Exemple #3
0
		static void SetMenuItemAttributes (HIMenuItem item, CommandInfo ci, uint refcon)
		{
			MenuItemData data = new MenuItemData ();
			IntPtr text = IntPtr.Zero;
			try {
				if (ci.IsArraySeparator) {
					data.Attributes |= MenuItemAttributes.Separator;
				} else if (!ci.Visible) {
					data.Attributes |= MenuItemAttributes.Hidden;
				} else {
					data.Attributes &= ~MenuItemAttributes.Hidden;
					data.CFText = CoreFoundation.CreateString (GetCleanCommandText (ci));
					
					//disable also when MD main window doesn't have toplevel focus, or commands will be 
					//accessible when modal dialogs are active
					bool disabled = !ci.Enabled || IsGloballyDisabled;
					data.Enabled = !disabled;
					if (disabled)
						data.Attributes |= MenuItemAttributes.Disabled;
					
					ushort glyphCode, charCode, hardwareCode; 
					MenuAccelModifier mod;
					if (GetAcceleratorKeys (ci.AccelKey, out glyphCode, out charCode, out hardwareCode, out mod)) {
						data.CommandKeyModifiers = mod;
						if (glyphCode != 0) {
							data.CommandKeyGlyph = glyphCode;
							data.Attributes ^= MenuItemAttributes.UseVirtualKey;
						} else if (hardwareCode != 0) {
							data.CommandVirtualKey = (char)hardwareCode;
							data.Attributes |= MenuItemAttributes.UseVirtualKey;
						} else {
							data.CommandKey = (char)charCode;
							data.Attributes ^= MenuItemAttributes.UseVirtualKey;
						}
					}
					//else{
				 	//FIXME: remove existing commands if necessary
					
					data.Mark = ci.Checked
						? ci.CheckedInconsistent
							? '-' //FIXME: is this a good symbol for CheckedInconsistent?
							: (char)MenuGlyphs.Checkmark
						: '\0';
					
					data.ReferenceConstant = refcon;
				}
				HIToolbox.SetMenuItemData (item.MenuRef, item.Index, false, ref data);
			} finally {
				if (text != IntPtr.Zero)
					CoreFoundation.Release (text);
			}
		}