Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Events
Silverstone.Manticore.Toolkit.MenuBuilder Class Reference
Collaboration diagram for Silverstone.Manticore.Toolkit.MenuBuilder:
Collaboration graph

List of all members.

Public Member Functions

 MenuBuilder (String aFile, Form aForm)
void Build ()

Public Attributes

Hashtable mItems
Hashtable mBuilders

Protected Member Functions

void Recurse (XmlTextReader reader, Menu root)
void OnCommandInternal (Object sender, EventArgs e)

Protected Attributes

String mMenuFile = ""
Form mForm = null
MainMenu mMainMenu = null


EventHandler OnCommand
MenuItem mCurrentMenuItem

Detailed Description

Definition at line 55 of file toolkit.menus.cs.

Constructor & Destructor Documentation

Silverstone.Manticore.Toolkit.MenuBuilder.MenuBuilder ( String  aFile,
Form  aForm 
) [inline]

Definition at line 66 of file toolkit.menus.cs.

      mMenuFile = aFile;
      mForm = aForm;
      mItems = new Hashtable();
      mBuilders = new Hashtable();

      mMainMenu = new MainMenu();
      mForm.Menu = mMainMenu;

Member Function Documentation

Definition at line 77 of file toolkit.menus.cs.

      XmlTextReader reader;
      reader = new XmlTextReader(mMenuFile);
      reader.WhitespaceHandling = WhitespaceHandling.None;

      Recurse(reader, mMainMenu);

Here is the call graph for this function:

void Silverstone.Manticore.Toolkit.MenuBuilder.OnCommandInternal ( Object  sender,
EventArgs  e 
) [inline, protected]

Definition at line 156 of file toolkit.menus.cs.

      if (OnCommand != null) 
        OnCommand(sender, e);
void Silverstone.Manticore.Toolkit.MenuBuilder.Recurse ( XmlTextReader  reader,
Menu  root 
) [inline, protected]

Definition at line 89 of file toolkit.menus.cs.

      String inner = reader.ReadInnerXml();
      NameTable nt = new NameTable();
      XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
      XmlParserContext ctxt = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
      XmlTextReader reader2 = new XmlTextReader(inner, XmlNodeType.Element, ctxt);

      while (reader2.Read()) 
        if (reader2.NodeType == XmlNodeType.Element) 
          switch (reader2.LocalName) 
            case "menu":
              // Menuitem. Find the name, accesskey, command and id strings
              String[] values = new String[3] {"", "", ""};
              String[] names = new String[3] {"label", "accesskey", "command"};
              for (int i = 0; i < names.Length; ++i) 
                if (reader2.MoveToAttribute(names[i]) &&
                  values[i] = reader2.Value; // XXX need to handle entities

              // Handle Accesskey
              values[0] = ManticoreMenuItem.GenerateAccessKeyString(values[0], values[1]);

              // Create menu item and attach an event handler
              // BLUESKY - should we support data stored in the XML file as an attribute?
              mCurrentMenuItem = new ManticoreMenuItem(values[0], 
                                                       new EventHandler(OnCommandInternal),
                                                       values[2], "");
              if (values[2] != "")
                mItems.Add(values[2], mCurrentMenuItem);
              Recurse(reader2, mCurrentMenuItem);
            case "menuseparator":
              mCurrentMenuItem = new MenuItem("-");
            case "menubuilder":
              String id = "";
              if (reader2.MoveToAttribute("id") &&
                id = reader2.Value;
              String datastore = "";
              if (reader2.MoveToAttribute("datastore") && 
                datastore = reader2.Value;

              BaseMenuBuilder builder = new BaseMenuBuilder(mMainMenu, root as MenuItem, mCurrentMenuItem, null);
              builder.Root = id;
              builder.DataStore = DataStoreRegistry.GetDataStore(datastore);
              builder.OnCommand += new EventHandler(OnCommandInternal);
              mBuilders.Add(builder.GetHashCode(), builder);

Here is the call graph for this function:

Member Data Documentation

Definition at line 62 of file toolkit.menus.cs.

Definition at line 58 of file toolkit.menus.cs.

Definition at line 61 of file toolkit.menus.cs.

Definition at line 59 of file toolkit.menus.cs.

Definition at line 57 of file toolkit.menus.cs.

Event Documentation

Definition at line 88 of file toolkit.menus.cs.

Definition at line 64 of file toolkit.menus.cs.

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