Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes | Properties | Events
Silverstone.Manticore.Toolkit.BaseMenuBuilder Class Reference
Inheritance diagram for Silverstone.Manticore.Toolkit.BaseMenuBuilder:
Inheritance graph
[legend]
Collaboration diagram for Silverstone.Manticore.Toolkit.BaseMenuBuilder:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 BaseMenuBuilder (MainMenu aMainMenu, MenuItem aParent)
 BaseMenuBuilder (MainMenu aMainMenu, MenuItem aParent, MenuItem aBefore, MenuItem aAfter)
void OnNodeChanging (Object aOldNode, Object aNewNode)
void OnNodeChanged (Object aOldNode, Object aNewNode)
void OnNodeAdding (Object aNewNode, Object aParentNode, int aIndex)
void OnNodeAdded (Object aChildNode, Object aParentNode, int aIndex)
void OnNodeRemoving (Object aNodeRemoving)
void OnNodeRemoved (Object aNodeRemoved)
override void Build ()
 Build content. Builds all content if |LazyState| is set to false.
void Recurse (String aRoot, Menu.MenuItemCollection aParentItems)

Protected Member Functions

override void InitializeComponent ()
void OnParentPopup (Object sender, EventArgs e)
void OnCommandInternal (Object sender, EventArgs e)
 Calls |OnCommand| EventHandler on interested clients indicating a generated |MenuItem| has been selected.

Protected Attributes

MenuItem mParent = null
 The |MenuItem| that is the parent of the content builder.
Menu.MenuItemCollection mParentItems = null
MenuItem mBefore = null
 |mBefore| and |mAfter| define the static boundaries within which the DynamicMenuBuilder operates. Used if the builder builds items which are siblings to static |MenuItem|s.
MenuItem mAfter = null
Hashtable mMenus = null
 All of this builder's |MenuItem|s, keyed by DataStore id.
int mInsertionPoint = 0
 This is the default point of insertion of new menus. Initially, this is the index of |mBefore|, or 0 if |mBefore| is null. As items are added, it is incremented.
IDataStore mDataStore = null
String mRoot = null

Properties

MenuItem Parent [get, set]
MenuItem Before [get, set]
MenuItem After [get, set]
IDataStore DataStore [get, set]
String Root [get, set]

Events

EventHandler OnCommand
 Clients wishing to observe for |MenuItem| selection will want to listen to this event.

Detailed Description

Definition at line 341 of file MenuBuilder.cs.


Constructor & Destructor Documentation

Silverstone.Manticore.Toolkit.BaseMenuBuilder.BaseMenuBuilder ( MainMenu  aMainMenu,
MenuItem  aParent 
) [inline]

Definition at line 343 of file MenuBuilder.cs.

                                             : base(aMainMenu, aParent)
    {
      InitializeComponent();
    }
Silverstone.Manticore.Toolkit.BaseMenuBuilder.BaseMenuBuilder ( MainMenu  aMainMenu,
MenuItem  aParent,
MenuItem  aBefore,
MenuItem  aAfter 
) [inline]

Definition at line 349 of file MenuBuilder.cs.

                                            : base(aMainMenu, aParent, aBefore, aAfter)
    {
      InitializeComponent();
    }

Member Function Documentation

override void Silverstone.Manticore.Toolkit.DynamicMenuBuilder.Build ( ) [inline, virtual, inherited]

Build content. Builds all content if |LazyState| is set to false.

Reimplemented from Silverstone.Manticore.Toolkit.ContentBuilder.

Definition at line 233 of file MenuBuilder.cs.

    {
      if (mDataStore == null || mRoot == null) 
        throw new Exception();

      // XXX implement acknowledgement of |LazyState|

      Recurse(mRoot, mParentItems);
    }

Here is the call graph for this function:

Reimplemented from Silverstone.Manticore.Toolkit.DynamicMenuBuilder.

Definition at line 357 of file MenuBuilder.cs.

    {
      base.InitializeComponent();

      mDataStore = new SampleDataStore();
      mDataStore.AddObserver(this as IDataStoreObserver);
    } 
void Silverstone.Manticore.Toolkit.DynamicMenuBuilder.OnCommandInternal ( Object  sender,
EventArgs  e 
) [inline, protected, inherited]

Calls |OnCommand| EventHandler on interested clients indicating a generated |MenuItem| has been selected.

Parameters:
sender
e

Definition at line 295 of file MenuBuilder.cs.

    {
      if (OnCommand != null) 
        OnCommand(sender, e);
    }
void Silverstone.Manticore.Toolkit.DynamicMenuBuilder.OnNodeAdded ( Object  aChildNode,
Object  aParentNode,
int  aIndex 
) [inline, inherited]

Implements Silverstone.Manticore.Core.IDataStoreObserver.

Definition at line 171 of file MenuBuilder.cs.

    {
      // A new Element has been added somewhere. We must find the 
      // parent menu and append it. To interoperate with the Content Builder,
      // the DataStore must provide |CommandTarget|s to this method. 
      CommandTarget childTarget = aChildNode as CommandTarget;
      CommandTarget parentTarget = aParentNode as CommandTarget;
      if (childTarget == null && parentTarget == null)
        return;

      int childKey = childTarget.Data.GetHashCode();
      if (!mMenus.ContainsKey(childKey)) 
      {
        int parentKey = parentTarget.Data.GetHashCode();

        ManticoreMenuItem parentMenu;
        if (mMenus.ContainsKey(parentKey))
          parentMenu = mMenus[parentKey] as ManticoreMenuItem;
        else
          parentMenu = mParent as ManticoreMenuItem;
        
        if (parentMenu != null) 
        {
          String label = childTarget.Label;
          if (childTarget.AccessKey != "")
            label = ManticoreMenuItem.GenerateAccessKeyString(childTarget.Label, 
              childTarget.AccessKey);
          ManticoreMenuItem childMenu = new ManticoreMenuItem(label, 
                                                              new EventHandler(OnCommandInternal), 
                                                              "bookmarks-item", childTarget.Data);
          if (parentMenu != null) 
          {
            int pos = aIndex == -1 ? parentMenu.MenuItems.Count : aIndex;
            parentMenu.MenuItems.Add(pos, childMenu);
            mMenus.Add(childKey, childMenu);
          }
        }
      }
    }

Here is the call graph for this function:

void Silverstone.Manticore.Toolkit.DynamicMenuBuilder.OnNodeAdding ( Object  aNewNode,
Object  aParentNode,
int  aIndex 
) [inline, inherited]

Implements Silverstone.Manticore.Core.IDataStoreObserver.

Definition at line 167 of file MenuBuilder.cs.

    {
      // Not Implemented. 
    }
void Silverstone.Manticore.Toolkit.DynamicMenuBuilder.OnNodeChanged ( Object  aOldNode,
Object  aNewNode 
) [inline, inherited]

Implements Silverstone.Manticore.Core.IDataStoreObserver.

Definition at line 143 of file MenuBuilder.cs.

    {
      // Enumerate each of the properties that affect FE presentation, test
      // for difference, and update the FE if necessary.
      
      CommandTarget oldTarget = aOldNode as CommandTarget;
      CommandTarget newTarget = aNewNode as CommandTarget;
      
      if (oldTarget == null && newTarget == null)
        return;
      
      // Check for Label/AccessKey change. 
      if (newTarget.Label != oldTarget.Label || newTarget.AccessKey != oldTarget.AccessKey) 
      {
        int itemKey = newTarget.Data.GetHashCode();
        if (mMenus.ContainsKey(itemKey)) 
        {
          ManticoreMenuItem item = mMenus[itemKey] as ManticoreMenuItem;
          // Re-generate AccessKey and update display Text
          item.Text = ManticoreMenuItem.GenerateAccessKeyString(newTarget.Label, newTarget.AccessKey);;
        }
      }
    }

Here is the call graph for this function:

void Silverstone.Manticore.Toolkit.DynamicMenuBuilder.OnNodeChanging ( Object  aOldNode,
Object  aNewNode 
) [inline, inherited]

Implements Silverstone.Manticore.Core.IDataStoreObserver.

Definition at line 139 of file MenuBuilder.cs.

    {
      // Not Implemented.
    }

Implements Silverstone.Manticore.Core.IDataStoreObserver.

Definition at line 215 of file MenuBuilder.cs.

    {
      CommandTarget childTarget = aNodeRemoved as CommandTarget;

      // Remove |MenuItem| representation of |aChildNode|.
      int childKey = childTarget.Data.GetHashCode();
      if (mMenus.ContainsKey(childKey)) 
      {
        ManticoreMenuItem childMenu = mMenus[childKey] as ManticoreMenuItem;
        ManticoreMenuItem parentMenu = childMenu.Parent as ManticoreMenuItem;
        parentMenu.MenuItems.Remove(childMenu);
        mMenus.Remove(childKey);
      }
    }

Implements Silverstone.Manticore.Core.IDataStoreObserver.

Definition at line 211 of file MenuBuilder.cs.

    {
      // Not Implemented.
    }
void Silverstone.Manticore.Toolkit.DynamicMenuBuilder.OnParentPopup ( Object  sender,
EventArgs  e 
) [inline, protected, inherited]

Definition at line 130 of file MenuBuilder.cs.

    {
      // XXX make this smarter. 
      Build();
    }
void Silverstone.Manticore.Toolkit.DynamicMenuBuilder.Recurse ( String  aRoot,
Menu.MenuItemCollection  aParentItems 
) [inline, inherited]

Definition at line 243 of file MenuBuilder.cs.

    {
      IEnumerator items;
      mDataStore.GetElements(aRoot, out items);
      items.Reset();
      
      MenuItem item;
      
      while (items.MoveNext()) 
      {
        // |id| is the item's unique identifier within the DataStore. 
        // The handling code can use this to probe for more information
        // about the selected item. 
        CommandTarget current = items.Current as CommandTarget;
        if (current != null) 
        {
          String id = current.Data as String; 
          
          int idKey = id.GetHashCode();
          
          if (!mMenus.ContainsKey(idKey)) 
          {
            item = new ManticoreMenuItem(current.Label, 
                                         new EventHandler(OnCommandInternal), 
                                         "bookmarks-item", id);
            if (aRoot != Root)
              aParentItems.Add(item);
            else
              aParentItems.Add(mInsertionPoint++, item);
            mMenus.Add(id.GetHashCode(), item);

            if (current.IsContainer)
              Recurse(current.Data as String, item.MenuItems);
          }
        }
      }
      
      ResetInsertionPoint();
    }

Here is the call graph for this function:


Member Data Documentation

Definition at line 63 of file MenuBuilder.cs.

|mBefore| and |mAfter| define the static boundaries within which the DynamicMenuBuilder operates. Used if the builder builds items which are siblings to static |MenuItem|s.

Definition at line 62 of file MenuBuilder.cs.

Definition at line 53 of file ContentBuilder.cs.

This is the default point of insertion of new menus. Initially, this is the index of |mBefore|, or 0 if |mBefore| is null. As items are added, it is incremented.

Definition at line 75 of file MenuBuilder.cs.

All of this builder's |MenuItem|s, keyed by DataStore id.

Definition at line 68 of file MenuBuilder.cs.

The |MenuItem| that is the parent of the content builder.

Definition at line 53 of file MenuBuilder.cs.

Menu.MenuItemCollection Silverstone.Manticore.Toolkit.DynamicMenuBuilder.mParentItems = null [protected, inherited]

Definition at line 55 of file MenuBuilder.cs.

Definition at line 54 of file ContentBuilder.cs.


Property Documentation

Definition at line 329 of file MenuBuilder.cs.

Definition at line 317 of file MenuBuilder.cs.

Definition at line 65 of file ContentBuilder.cs.

Definition at line 305 of file MenuBuilder.cs.

Definition at line 75 of file ContentBuilder.cs.


Event Documentation

Clients wishing to observe for |MenuItem| selection will want to listen to this event.

Definition at line 287 of file MenuBuilder.cs.


The documentation for this class was generated from the following file: