Skip to Main Content
Volume 7A: XView Programming Manual
book

Volume 7A: XView Programming Manual

by Dan Heller
October 1994
Intermediate to advanced content levelIntermediate to advanced
770 pages
22h 58m
English
O'Reilly Media, Inc.
Content preview from Volume 7A: XView Programming Manual
Example F-2. The scroll_cells2.c program (continued)
xv_set(vert_scrollbar,
SCROLLBAR_OBJECT_LENGTH, CELLS_PER_COL,
SCROLLBAR_PAGE_LENGTH, page_h,
SCROLLBAR_VIEW_LENGTH, page_h,
NULL);
}
F.3 menu_dir2.c
In Chapter 11, Menus, the program menu_dir.c demonstrates the use of an XView menu in a
canvas subwindow. A menu is brought up with the MENU mouse button and displays menu
choices representing the files in the directory. The problem with menu_dir.c is that the entire
menu cascade is created for all the subdirectories at the very beginning of the program. If the
directory stack is very deep, it could take a very long time to build. You could also run out of
memory in the process. Further, if the contents of the directory tree is dynamic, the menu
entries could become invalid over time.
These problems are solved in menu_dir2.c because it creates only the top-level menu. For
each directory entry under the top-level, rather than creating an associated pullright menu, a
MENU_GEN_PULLRIGHT procedure is specified. This routine creates that menu only at the
time it is needed. So, when the user invokes the menu and tries to descend into a submenu
representing a subdirectory in the directory tree, only then is the directory entry searched and
a new submenu created. When the user backs out of the menu, the menu is des-
troyed—attempting to re-enter the submenu causes the process to be repeated.
An exercise for
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Volume 6A: Motif Programming Manual

Volume 6A: Motif Programming Manual

David Brennan, Dan Heller, Paula Ferguson
Java™ Media APIs: Cross-Platform Imaging, Media, and Visualization

Java™ Media APIs: Cross-Platform Imaging, Media, and Visualization

Alejandro Terrazas, John Ostuni, Michael Barlow

Publisher Resources

ISBN: 9780937175873