/// <summary>
/// </summary>
using System.ComponentModel;
- public abstract class Menu : Component {
+ public abstract class Menu : Component {
//
// -- Public Methods
[MonoTODO]
public virtual void MergeMenu(Menu menuSrc) {
- // FIXME:
+ //FIXME:
}
[MonoTODO]
//
protected void CloneMenu(Menu menuSrc) {
- // FIXME:
+ //FIXME:
}
protected Menu( MenuItem[] items) {
// -- Public Properties
//
- private bool menuStructureModified_ = true;
-
- internal bool MenuStructureModified {
- set {
- menuStructureModified_ = value;
- }
- }
-
+ protected internal bool menuStructureModified_ = true;
- internal void BuildMenuStructure () {
+ internal void BuildMenuStructure ()
+ {
if( menuStructureModified_) {
- Win32.SetMenuDefaultItem(menuHandle_, -1, 0);
while( Win32.RemoveMenu( menuHandle_, 0, (uint)MF_.MF_BYPOSITION) != 0);
foreach(MenuItem mi in MenuItems) {
- //System.Console.WriteLine("MenuItem {0} Parent {1}", mi.Text, mi.IsParent);
+ System.Console.WriteLine("MenuItem {0} Parent {1}", mi.Text, mi.IsParent);
if( mi.IsParent){
Win32.AppendMenuA( menuHandle_, (int)MF_.MF_ENABLED | (int)MF_.MF_STRING | (int)MF_.MF_POPUP,
mi.Handle, mi.Text);
}
else {
- Win32.AppendMenuA( menuHandle_, mi.MenuItemFlags,
+ Win32.AppendMenuA( menuHandle_, (int)MF_.MF_ENABLED | (int)MF_.MF_STRING,
(IntPtr) mi.GetID(), mi.Text);
- if(mi.DefaultItem) {
- Win32.SetMenuDefaultItem(menuHandle_, mi.GetID(), 0);
- }
}
}
menuStructureModified_ = false;
protected Menu parent_ = null;
protected IntPtr menuHandle_ = IntPtr.Zero;
- internal void CreateMenuHandle() {
+ internal void CreateMenuHandle()
+ {
if( menuHandle_ == IntPtr.Zero) {
menuHandle_ = Win32.CreateMenu();
//System.Console.WriteLine("Create menu {0}", menuHandle_);
}
}
-
// Library interface
// Recursively searches for specified item in menu.
// Goes immediately into child, when mets one.
- internal MenuItem GetMenuItemByID (uint id) {
+ internal MenuItem GetMenuItemByID (uint id)
+ {
foreach( MenuItem mi in MenuItems) {
if( mi.IsParent) {
MenuItem submi = mi.GetMenuItemByID(id);
private static Hashtable allMenus_ = new Hashtable();
- internal static Menu GetMenuByHandle (IntPtr hMenu) {
+ internal static Menu GetMenuByHandle (IntPtr hMenu)
+ {
Menu result = null;
try {
result = allMenus_[hMenu] as Menu;
return result;
}
- internal void OnNewMenuItemAdd (MenuItem mi){
+ internal void OnNewMenuItemAdd (MenuItem mi)
+ {
menuStructureModified_ = true;
mi.SetParent( this);
}
menuHandle_ = IntPtr.Zero;
if( parent_ != null) {
- parent_.MenuStructureModified = true;
+ parent_.menuStructureModified_ = true;
}
}
}
BuildMenuStructure();
}
+ //
+ // -- Protected Properties
+ //
+
//
// System.Windows.Forms.Menu.MenuItemCollection.cs
//
parentMenu_ = m;
}
- internal void MoveItemToIndex( int index, MenuItem mi) {
+ internal void MoveItemToIndex( int index, MenuItem mi)
+ {
if( index >= items_.Count){
// FIXME: Set exception parameters
throw new ArgumentException();
items_.Add(mi);
result = items_.Count - 1;
mi.SetIndex(result);
+ //System.Console.WriteLine("Adding menuItem {0}, parent {1}", mi.Text, mi.IsParent);
+/*
+ if( mi.IsParent){
+ Win32.AppendMenuA( parentMenu_.Handle, (int)MF_.MF_ENABLED | (int)MF_.MF_STRING | (int)MF_.MF_POPUP,
+ mi.Handle, mi.Text);
+ }
+ else {
+ Win32.AppendMenuA( parentMenu_.Handle, (int)MF_.MF_ENABLED | (int)MF_.MF_STRING,
+ (IntPtr) mi.GetID(), mi.Text);
+ }
+*/
}
return result;
}
items_.Insert(i, mi);
result = i;
mi.SetIndex(result);
+/*
+ if( mi.IsParent){
+ Win32.InsertMenuA( parentMenu_.Handle, (uint)i,
+ (int)MF_.MF_ENABLED | (int)MF_.MF_STRING | (int)MF_.MF_POPUP | (int)MF_.MF_BYPOSITION,
+ mi.Handle, mi.Text);
+ }
+ else {
+ Win32.InsertMenuA( parentMenu_.Handle, (uint)i,
+ (int)MF_.MF_ENABLED | (int)MF_.MF_STRING | (int)MF_.MF_BYPOSITION,
+ (IntPtr) mi.GetID(), mi.Text);
+ }
+*/
}
return result;
}
}
}
- private void DoClear() {
- if( parentMenu_ != null) {
+ public virtual void Clear() {
+ if( parentMenu_ != null){
foreach( MenuItem mi in items_) {
parentMenu_.OnRemoveMenuItem( mi);
}
}
items_.Clear();
- if( parentMenu_ != null) {
+ if( parentMenu_ != null){
parentMenu_.OnLastSubItemRemoved();
}
}
- public virtual void Clear() {
- DoClear();
- }
-
public bool Contains(MenuItem m) {
return items_.Contains(m);
}
}
}
- public override bool Equals(object o) {
- return base.Equals(o);
- }
-
- [MonoTODO]
- public override int GetHashCode() {
- //FIXME add our proprities
- return base.GetHashCode();
- }
-
public IEnumerator GetEnumerator() {
return items_.GetEnumerator();
}
Remove(items_[i] as MenuItem);
}
- public override string ToString() {
- throw new NotImplementedException ();
- }
-
- //
- // -- Protected Methods
- //
-
- ~MenuItemCollection() {
- Clear();
- }
-
- //inherited
- //protected object MemberwiseClone() {
- // throw new NotImplementedException ();
- //}
-
//
// -- Public Properties
//
/// <summary>
/// IList Interface implmentation.
/// </summary>
- bool IList.IsReadOnly {
- get {
+ bool IList.IsReadOnly{
+ get{
// We allow addition, removeal, and editing of items after creation of the list.
return false;
}
}
-
- bool IList.IsFixedSize {
- get {
+ bool IList.IsFixedSize{
+ get{
// We allow addition and removeal of items after creation of the list.
return false;
}
}
- public MenuItem this[int index] {
- get {
- return items_[index] as MenuItem;
- }
- }
-
- //[MonoTODO]
- object IList.this[int index] {
- get {
- return items_[index];
- }
- set {
- // FIXME: Set exception members
- throw new System.NotSupportedException();
- }
+ object IList.this[int index]{
+ [MonoTODO] get { throw new NotImplementedException (); }
+ [MonoTODO] set { throw new NotImplementedException (); }
}
[MonoTODO]
- void IList.Clear() {
- DoClear();
+ void IList.Clear(){
+ //FIXME:
}
-
- private MenuItem Object2MenuItem( object value) {
- MenuItem result = value as MenuItem;
- if( result == null) {
- // FIXME: Set exception parameters
- throw new System.ArgumentException();
- }
- return result;
- }
-
+
[MonoTODO]
- int IList.Add( object value) {
- return Add( Object2MenuItem(value));
+ int IList.Add( object value){
+ throw new NotImplementedException ();
}
[MonoTODO]
- bool IList.Contains( object value) {
- return Contains(Object2MenuItem(value));
+ bool IList.Contains( object value){
+ throw new NotImplementedException ();
}
[MonoTODO]
- int IList.IndexOf( object value) {
- return IndexOf(Object2MenuItem(value));
+ int IList.IndexOf( object value){
+ throw new NotImplementedException ();
}
[MonoTODO]
- void IList.Insert(int index, object value) {
- Add( index, Object2MenuItem(value));
+ void IList.Insert(int index, object value){
+ //FIXME:
}
[MonoTODO]
- void IList.Remove( object value) {
- Remove( Object2MenuItem(value));
+ void IList.Remove( object value){
+ //FIXME:
}
[MonoTODO]
void IList.RemoveAt( int index){
- RemoveAt(index);
+ //FIXME:
}
// End of IList interface
-
/// <summary>
/// ICollection Interface implmentation.
/// </summary>
- int ICollection.Count {
- get {
- return Count;
+ int ICollection.Count{
+ get{
+ throw new NotImplementedException ();
}
}
- bool ICollection.IsSynchronized {
- get {
+ bool ICollection.IsSynchronized{
+ get{
throw new NotImplementedException ();
}
}
- object ICollection.SyncRoot {
- get {
+ object ICollection.SyncRoot{
+ get{
throw new NotImplementedException ();
}
}
void ICollection.CopyTo(Array array, int index){
- CopyTo(array, index);
+ throw new NotImplementedException ();
}
// End Of ICollection
}
namespace System.Windows.Forms {
/// <summary>
- /// ToDo note:
/// </summary>
public class MenuItem : Menu {
}
public MenuItem(string s) : this(){
- Text = s;
+ text_ = s;
}
public MenuItem(string s, EventHandler e) : this() {
- Text = s;
+ text_ = s;
Click += e;
}
public MenuItem(string s, MenuItem[] items) : base(items) {
- Text = s;
+ text_ = s;
}
public MenuItem(string s, EventHandler e, Shortcut sc) : this() {
//
// -- Public Properties
//
- private void ModifyParent()
- {
- if( Parent != null)
- {
- Parent.MenuStructureModified = true;
- }
- }
-
- private uint MenuItemFlags_ = (uint)MF_.MF_ENABLED | (uint)MF_.MF_STRING;
- internal uint MenuItemFlags
- {
- get
- {
- return MenuItemFlags_;
- }
- }
-
- private bool GetPropertyByFlag( MF_ flag)
- {
- return (MenuItemFlags_ & (uint)flag) != 0 ? true : false;
- }
-
- private void SetPropertyByFlag( MF_ flag, bool SetOrClear)
- {
- uint PrevState = MenuItemFlags_;
- if( SetOrClear)
- {
- MenuItemFlags_ |= (uint)flag;
- }
- else
- {
- MenuItemFlags_ &= ~(uint)flag;
- }
- if( PrevState != MenuItemFlags_)
- ModifyParent();
- }
public bool BarBreak {
+
get {
- return GetPropertyByFlag(MF_.MF_MENUBARBREAK);
+ throw new NotImplementedException ();
}
set {
- SetPropertyByFlag(MF_.MF_MENUBARBREAK, value);
+ throw new NotImplementedException ();
}
}
- public bool Break
- {
+ public bool Break {
+
get {
- return GetPropertyByFlag(MF_.MF_MENUBREAK);
+ throw new NotImplementedException ();
}
set {
- SetPropertyByFlag(MF_.MF_MENUBREAK, value);
+ throw new NotImplementedException ();
}
}
- public bool Checked
- {
- get
- {
- return GetPropertyByFlag(MF_.MF_CHECKED);
+ public bool Checked {
+
+ get {
+ throw new NotImplementedException ();
}
- set
- {
- SetPropertyByFlag(MF_.MF_CHECKED, value);
+ set {
+ throw new NotImplementedException ();
}
}
//}
public bool DefaultItem {
- get
- {
- return GetPropertyByFlag(MF_.MF_DEFAULT);
+
+ get {
+ throw new NotImplementedException ();
}
- set
- {
- SetPropertyByFlag(MF_.MF_DEFAULT, value);
+ set {
+ throw new NotImplementedException ();
}
}
public bool Enabled {
- get
- {
- return !GetPropertyByFlag(MF_.MF_DISABLED | MF_.MF_GRAYED);
+
+ get {
+ throw new NotImplementedException ();
}
- set
- {
- SetPropertyByFlag(MF_.MF_DISABLED | MF_.MF_GRAYED, !value);
+ set {
+ throw new NotImplementedException ();
}
}
/*
}
set {
if( index_ != value){
- if(Parent != null) {
+ if(Parent != null){
Parent.MenuItems.MoveItemToIndex(value, this);
- Parent.MenuStructureModified = true;
+ Parent.menuStructureModified_ = true;
}
}
}
}
public bool OwnerDraw {
+
get {
- return GetPropertyByFlag(MF_.MF_OWNERDRAW);
+ throw new NotImplementedException ();
}
set {
- SetPropertyByFlag(MF_.MF_OWNERDRAW, value);
+ throw new NotImplementedException ();
}
}
}
}
- private bool RadioCheck_ = false;
public bool RadioCheck {
get {
- return RadioCheck_;
+ throw new NotImplementedException ();
}
set {
- RadioCheck_ = value;
- ModifyParent();
+ throw new NotImplementedException ();
}
}
}
set {
text_ = value;
- if( text_ == "-") {
- SetPropertyByFlag(MF_.MF_SEPARATOR, true);
- }
- else {
- SetPropertyByFlag(MF_.MF_SEPARATOR, false);
- //SetPropertyByFlag(MF_.MF_STRING, true);
- }
-
- ModifyParent();
}
}
- private bool Visible_ = true;
public bool Visible {
get {
- return Visible_;
+ throw new NotImplementedException ();
}
set {
- Visible_ = value;
- ModifyParent();
+ throw new NotImplementedException ();
}
}
//
internal const int INVALID_MENU_ID = -1; //0xffffffff;
+ // Variables are stored here to provide access for the base functions
protected int MenuID_ = INVALID_MENU_ID;
// Provides unique id to all items in all menus, hopefully space is enougth.
// and reuse them.
protected static int MenuIDs_ = 1;
- protected int GetNewMenuID() {
+ protected int GetNewMenuID()
+ {
return MenuIDs_++;
}
// Btw, this function is funky, it is being used by routines that are supposed
// to be passing an IntPtr to the AppendMenu function
//
- internal int GetID() {
+ internal int GetID()
+ {
return MenuID;
}