Menu bar resource statements

To define resources for an Options menu:

  1. Determine the requirements of your application.

  2. Declare the MENU_BAR and MENU_TITLE resource statements:

    • Depending on your application's structure, declare menubar = r_name4 in either the EIK_APP_INFO or AVKON_VIEW statements, where r_name16 is a unique identifier in your application.

    • Create a resource statement for the menu bar.

      The syntax is as follows:

      RESOURCE MENU_BAR r_name4
      {
      	titles = 
      		{
      		MENU_TITLE
      			{
      			menu_pane = r_name5;
      			}
      		};
      	}

      ,where:

      • r_name4 is the resource name that uniquely identifies this RESOURCE statement in the application.

      • titles is the name defined for an array that contains the menu titles for the menu bar.

      • MENU_TITLE is a structure defined in eikon.rh.

      Note that you may add as many MENU_TITLE structures as you desire. The application framework combines them together when constructing the Options menu. This feature allows you to break your Options menu up into different segments, which may be useful when constructing context sensitive Options menus. For more information, see Using menu sections in menu bar resource statements

  3. Create a resource statement for the MENU_PANE resource:

    The MENU_PANE resource is defined in eikon.rh, and contains an array of items defined by the MENU_ITEM structure. The syntax is as follows:

    RESOURCE MENU_PANE r_name5
    {
    	items =
    	{
    	MENU_ITEM
    		{
    		command = enumerated command;
    		txt = STRING_r_string1;
    		},
    	MENU_ITEM
    		{
    		command = enumerated command other;
    		txt = STRING_r_string2;
    		}
    	};
    }

    , where:

    • r_name5 is the resource name that uniquely identifies this resource statement in this application.

    • items is the name defined for an array that contains the items for the menu pane.

    • MENU_ITEM is a structure defined in eikon.rh. The MENU_ITEM structure is used to define the option presented. The typical syntax is as follows:

      MENU_ITEM
      	{
      	command = enumerated command;
      	txt = STRING_r_string1;
      	}
      

      , where:

      • command is an enumerated value for the command that is associated with the button. The value used can be provided either by the underlying S60 platform or by your application. The are collected by the event loop of the application framework and delivered to your application for command handling

      • txt defines the text that is displayed in the Options menu.

  4. Create submenus as needed:

    Menu panes can also be nested by using the cascade declaration.

    The following example creates a menu pane with two items, each of which opens up another menu pane as a submenu.

    RESOURCE MENU_PANE r_name7
    	{
    	items =
    		{
    		MENU_ITEM
    			{
    			cascade = r_name8;
    			txt = STRING_r_string3;
    			},
    		MENU_ITEM
    			{
    			cascade = r_name9;
    			txt = STRING_r_string4;
    			}
    		};
    	}

    The resource statements for r_name8 and r_name9 need to be defined in a menu pane structure in the resource file.

    txt defines the text that is displayed in the Options menu.

    Note that it is also possible to have icons associated with the menu items in the pane.

The Options Menu API provides access to the MENU_BAR resource. For more information, see Symbian C++ API specifications.