Danh mục

Programming the Be Operating System-Chapter 7: Menus

Số trang: 46      Loại file: pdf      Dung lượng: 504.79 KB      Lượt xem: 9      Lượt tải: 0    
tailieu_vip

Hỗ trợ phí lưu trữ khi tải xuống: 15,000 VND Tải xuống file đầy đủ (46 trang) 0
Xem trước 5 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Tham khảo tài liệu programming the be operating system-chapter 7: menus, công nghệ thông tin, hệ điều hành phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả
Nội dung trích xuất từ tài liệu:
Programming the Be Operating System-Chapter 7: Menus Chapter 77 In this chapter: • Menu Basics • Working with Menus • Multiple Menus • Pop-up Menus • SubmenusMenus 7.Menus are the interface between the user and the program, and are the primarymeans by which a user carries out tasks. A Be program that makes use of menususually places a menubar along the top of the content area of each applicationwindow—though it’s easy enough to instead specify that a menubar appear else-where in a window.A menu is composed of menu items, and resides in a menubar. You’ll rely on theBMenuBar, BMenu, and BMenuItem classes to create menubar, menu, and menuitem objects. Early in this chapter, you’ll see how to create objects of these typesand how to interrelate them to form a functioning menubar. After these menubarbasics are described, the chapter moves to specific menu-related tasks such aschanging a menu item’s name during runtime and disabling a menu item or entiremenu.To offer the user a number of related options, create a single menu that allowsonly one item to be marked. Such a menu is said to be in radio mode, and placesa checkmark beside the name of the most recently selected item. If these relateditems all form a subcategory of a topic that is itself a menu item, consider creatinga submenu. A submenu is a menu item that, when selected, reveals still anothermenu. Another type of menu that typically holds numerous related options is apop-up menu. A pop-up menu exists outside of a menubar, so it can be placedanywhere in a window. You’ll find all the details of how to put a menu into radiomode, create a submenu, and create a pop-up menu in this chapter.Menu BasicsA Be application can optionally include a menubar within any of its windows, asshown in Figure 7-1. In this figure, a document window belonging to the226Menu Basics 227StyledEdit program includes a menubar that holds four menus. As shown in theFont menu, a menu can include nested menus (submenus) within it.Figure 7-1. An application window can have its own menubarMenus can be accessed via the keyboard rather than the mouse. To make themenubar the focus of keyboard keystrokes, the user presses both the Commandand Escape keys. Once the menubar is the target of keystrokes, the left and rightarrow keys can be used to drop, or display, a menu. Once displayed, items in amenu can be highlighted using the up and down arrow keys. The Enter keyselects a highlighted item.A second means of navigating menus and choosing menu items from the key-board is through the use of triggers. One character in each menu name and ineach menu item name is underlined. This trigger character is used to access amenu or menu item. After making the menubar the focus of the keyboard, press-ing a menu’s trigger character drops that menu. Pressing the trigger character of anitem in that menu selects that item.The topics of menubars, menus, and menu items are intertwined in such a waythat moving immediately into a detailed examination of each in turn doesn’t makesense. Instead, it makes more sense to conduct a general discussion of menubasics: creating menu item, menu, and menubar objects, adding menu item objectsto a menu object, and adding a menu object to a menubar. That’s what takes placeon the next several pages. Included are a couple of example projects that includethe code to add a simple menubar to a window. With knowledge of the interrela-tionship of the various menu elements, and a look at the code that implements afunctional menubar with menus, it will be appropriate to move on to studies ofthe individual menu-related elements.228 Chapter 7: MenusAdding a Menubar to a WindowThe menubar, menu, and menu item are represented by objects of type BMenuBar,BMenu, and BMenuItem, respectively. To add these menu-related elements to yourprogram, carry out the following steps: 1. Create a BMenuBar object to hold any number of menus. 2. Add the BMenuBar object to the window that is to display the menu. 3. For each menu that is to appear in the menubar: a. Create a BMenu object to hold any number of menu items. b. Add the BMenu object to the menubar that is to hold the menu. c. Create a BMenuItem object for each menu item that is to appear in the ...

Tài liệu được xem nhiều: