brew菜单初探一

,

最新研究Brew这个新的平台,最开始接触的就是菜单。废话不多说进入正题。

说起菜单,我们自然而然就会浮现手机中经常使用的菜单造型,对,brew为我们提供的菜单控件接口就能满足这一点。

首先让我们来看看brew帮助文档里面怎样来解释brew菜单控件接口的

The IMenuCtl interface is deprecated

Menu controls allow the device user to make a selection from a list of items. The UP, DOWN, LEFT and RIGHT arrow keys are used to identify the currently selected menu item, which appears highlighted on the screen. When the device user presses the SELECT key and command sending is enabled (see later in this section), an EVT_COMMAND is sent to the application or dialog that created the menu, which includes the identifier of the currently selected item. Following are four types of menu controls:

  • A standard menu control (ClassID AEECLSID_MENUCTL) displays one menu item per row on the screen, with each row containing the item's icon or text string. If all the items do not fit on the screen, use the UP and DOWN arrow keys to scroll the menu up or down.
  • A list control (ClassID AEECLSID_LISTCTL) displays only the currently selected menu item on the screen. This type of menu is useful in applications where the available screen real estate is limited. Items in a list control menu contain only text (there are no images). Use the UP and DOWN arrow keys to navigate to the specified menu selection.
  • A Soft Key menu control (ClassID AEECLSID_SOFTKEYCTL) displays the menu items side by side along the bottom portion of the screen. Use the LEFT and RIGHT arrow keys to designate the selected menu item. Soft Key menu controls contain icons and/or text strings.
  • An Icon View menu control (ClassID AEECLSID_ICONVIEWCTL) uses a bitmap icon to represent each menu item. The bitmap icons are displayed in one or more rows on the screen, and the arrow keys are used to move between rows and between the icons in each row. The text string corresponding to the currently selected item appears at the bottom of the screen.

Select the type you want by specifying its ClassID when you create an instance of the menu control. IMENUCTL_HandleEvent () handles the UP, DOWN, LEFT, and RIGHT arrow keys and the SELECT key.


很简 单,我们可以发现IMENUCTL可以实现4种view模型

1,标准菜单模型 ,用AEECLSID_MENUCTL

2,列表模型,用AEECLSID_LISTCTL

3,软按键模型 ,用AEECLSID_SOFTKEYCTL

4,iconview模型,用AEECLSID_ICONVIEWCTL

我们可以通过IMENUCTL_HandleEvent()来获取上,下,左,右以及选择键的事件。IMENUCTL默认处理

 

接下来我们看看IMENUCTL究竟怎么使用呢

文档解析

To create and use a menu control

1. Call ISHELL_CreateInstance () to create the menu control instance and obtain an interface pointer to it, specifying which of the four types of menu control you choose by its ClassID.

2. Call IMENUCTL_SetRect () to define the screen rectangle in which the menu is to be drawn.

3. Call IMENUCTL_SetProperties () to set any of the menu control properties, and call IMENUCTL_SetStyle to customize the appearance of your menu items.

4. Call IMENUCTL_SetTitle () to specify a menu title, and call IMENUCTL_AddItem () or IMENUCTL_AddItemEx () for each item to be added to the menu.

5. When you have completely specified the properties and contents of the menu control, call IMENUCTL_SetActive () to draw the control on the screen and enable it to receive key events from the device user. While the menu control is active, your application's IAPPLET_HandleEvent() function must call IMENUCTL_HandleEvent () to pass all handled key events to the menu control for processing.

6. Determine how you are to obtain the device user's menu selection. If you process the selection when the device user presses the SELECT key, the IAPPLET_HandleEvent() function can contain logic to handle the selection of each menu item when the EVT_COMMAND is received. If your application receives EVT_COMMAND events from more than one control, be sure that the item IDs passed in the wParam parameter are unique. If you retrieve the device user's selection at some other time, you must call IMENUCTL_GetSel () or IMENUCTL_GetItemData () at this time to access the currently selected menu item and its double-word data, if any.

  • 7. When you no longer need the menu control, call IMENUCTL_Release () to free it.

    好,我们可以知道这个过程了
    1,用ISHELL_CreateInstance创建实例
    2,用IMENUCTL_SetRect设置控件的显示范围
    3,用IMENUCTL_SetProerties来设置控件属性,IMENUCTL_SetStyle设置项属性
    4,用IMENUCTL_SetTitle设置标题,用IMENUCTL_AddItem或者IMENUCTL_AddItemEx添加项
    5,做了以上操作之后必须用IMENUCTL_SetActive才能激活菜单,正常显示,用IMENUCTL_HandleEvent来处理事件
    6,用IMENUCTL_GetItemData来取出item的关联数据
    7,最后用IMENUCTL_Release来释放实例数据

    光说不练肯定不行,我们下面来做个小小的测试
    新建立一个brew工程,MenuTest
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值