CS 551. Programming Graphical User Interfaces

Review Questions Associated with Readings


Sections 1.1-1.5 (Jan. 7)

1. Define the following terms in your own words: window, window manager, pointer, keyboard focus, X server, X client, X Protocol, Xlib, Xt Intrinsics, widget set.

2. Why is it important that you, as an X programmer, use only the standard programming interface for X routines, even if you could get a better result by accessing the routine's hidden data directly?

3. Explain the following statement: It is X's modeless operation which gives the user complete control over the interface.


Sections 2.1-2.3 (Jan. 9)

1. Define in your own words: simple widget, composite widget, shell widget, popup widget, class, instance, superclass, subclass, inheritance, encapsulation.

2. Which of the widget types in (1) are invisible at certain times? Which are always invisible?

3. Why is the Athena widget set a good choice for an introductory course? Name two other widget sets and explain why they might be better for application development.

4. Because it is written in C, the X toolkit can only approximate object-oriented programming.

5. Explain why, in calls to XtVaAppInitialize, the fifth argument is specified as &argc, not argc.


Sections 2.4-2.7 (Jan. 10)

1. Define: callback, callback function, callback list, arglist interface, varargs interface.

2. Why is it necessary to code an ampersand (&) as part of the second argument in each resource pair when calling XtVaGetValues or when setting the arglist for a call to XtGetValues?

3. From your knowledge of C, what will happen if you neglect to include the final NULL on a call to a varargs routine like XtVaSetValues?


Sections 10.1-10.2 (Jan. 14)

1. Define: resource, resource setting, resource specification, resource value, resource database, resource files.

2. Why does X provide more than one way of customizing resources? Name three places a resource value can be set.

3. Since widget sets are collections of OOP objects, the resources defined for one widget class are inherited by its subclasses.

4. If resource settings for the same resource were included in the following places, which would take precedence:

5. Suppose, in the example of section 10.2.4, that the resource setting "*background: red" were re-written as "xbox*background: red." Would this affect the outcome? Explain.


Sections 11.1, Appendix B.5 (Jan. 16)

1. Define: application shell, transient shell, override shell, window manager hints, aspect ratio, reparenting, geometry option.

2. Which kind of shell is created by XtAppInitialize?

3. Describe how to determine the global position of a Shell widget

4. As an application writer, how can you insure that the main window always be brought up at 200 pixels down from, and 200 pixels to the right of, the upper left-hand corner of the screen?


Sections 5, 3.1-3.4 (Jan. 17)

1. Define: instance hierarchy, geometry management, composite widget, constraint widget, constraint, compound widget, panner, toggle, radio buttons.

2. What are the advantages and disadvantages of using a composite widget (such as Box) versus a constraint widget (such as Form)? Versus a compound widget (such as Dialog)?

3. Must XtNfromVert always be used when XtNvertDistance is applied as a constraint resource? If so, why; if not, what are the effects when one is missing?

4. Since constraint resources describe how the child widget should be placed, why are they considered as belonging to the parent rather than the child?

5. The window manager interfaces only with Shell widgets, not with their children. Use this fact to explain how popup widgets are positioned on the display.


Sections 3.5-3.8 (Jan. 21)

1. Define: client data, call data, callback list, application resources, application context, arg list.

2. What is type XtPointer used for? Why?

3. Why is it common to have more than one function in a callback list when a standard popup callback function will be used?

4. Suppose you want to provide a user-configurable resource. What factors would determine whether it is done via a command-line option or a resource file setting?

5. Why would a resource be supported both as a command-line option and as a resource file setting?

6. Why is it important to use XtApp routines?

7. Why was XtVaTypedArg needed to set the background color in Example 3-14?

8. The argument list interface described in Section 3.7 is the "old" (prior to X11R4) way to set resources. Why is the varargs interface preferred in newer X applications?


Sections 13.1-13.3 (Jan. 24)

1. Define: pull-down menu, drop-down menu, spring-loaded menu, cascading menu, keyboard grab, pointer grab, server grab, active grab, passive grab.

2. Why is it necessary to position a popup shell before it is displayed?

3. What is the difference between modeless and modal popups? How does this relate to X's concept of modeless operation (see question 3 for Chapter 1)?

4. Why must input be grabbed by a springloaded menu? Which should be used, an active grab or a passive grab, and why?

5. Why could the pop-up menu in Example 13-3 be placed with a callback, while Example 12-2 required an action?

6. In Example 13-5, why are XtPopup/XtPopdown used instead of XtMenuPopup/ XtMenuPopdown?

7. SimpleMenu widgets can only have three types of children. What are they, and what do they do?


Sections 4.1-4.3 (Jan. 30)

1. Define: action, action procedure, action table, translation table.

2. Why is Core (not Label) selected to display the small pixmaps in xbitmap? How does this affect the size resource?

3. Why are two GCs needed in xbitmap3? Why does xbitmap4 require another one?

4. Why does Example 4-6 sometimes use XCopyArea and sometimes XCopyPlane?

5. Why is a callback generally preferred to an action? Under what circumstances is it necessary to use an action?

6. Compare and contrast the data passed from the application (a) to a callback via its second argument, and (b) to an action procedure via its third and fourth arguments, in terms of: amount of data, type of data, and when that data is defined (receives its value).

7. In an action procedure, why is there no mechanism for passing data from the widget (i.e., what the third argument does in a callback)?

8. Why are the translations for the example hardcoded rather than in the defaults file?

9. In xbitmap4, Redraw_picture (p. 130) is crucial since it handles expose events (an integral part of any widget). As the text describes, this function is designed to be invoked by both Xt and the application. What trick is used so the function can determine which one called it?


Section 8.1 (Jan. 31)

1. Define: event, event modifier, event sequence.

2. Describe what the user would do to cause each of the following events: KeyRelease, EnterNotify, FocusIn, CirculateNotify, DestroyNotify.

3. Give an example when you might want to use #augment instead of #replace for the translation table. When would #override be more appropriate?

4. If an X event is specified in a translation table entry, does that take precedence over the widget's "normal" response to the event? Why do you suppose Xt is set up this way?

5. If two translations name the same event, which will be used? What if they name overlapping event sequences?


Section 6.1-6.6 (Feb. 11)

1. Define: public header file, private header file, class structure, instance structure, core methods, self-contained method, chained method, downward chaining, upward chaining.

2. Why does X distinguish between a "part" and a "record" for classes and instances? What is included in each?

3. How does the private header file reflect a widget's superclass structure?

4. When is the class record created and initialized? Why does this differ from the way the instance record is handled?

5. What are the two basic kinds of methods, and why do they differ? What is the rationale for making this distinction? Explain why the destroy method is upward chained, while set-values is downward chained. Be specific about how this affects widget behavior/appearance.

6. What are the two ways in which self-contained methods can be inherited?

7. What declarations are "obligatory" for the public header file, and why?

8. The text states that "The only reason to create a new resource with the same name as a superclass resource is to give it a new, subclass-specific default value." Explain how this works by using the example of BitmapEdit's foreground resource.


Section 7.1-7.8 (Feb. 13)

1. Define: public instance variables, private instance variables, event compression, resize strategy, preferred size.

2. Unlike other object-oriented systems, Xt makes a distinction between "methods" and "actions". Where does each occur in the widget code?

3. What does it mean to say that "when the class is initialized, Xt reconciles all the inherited methods"?

4. List the duties of the initialize method, relating them to the information contained in its four parameters.

5. What is XtWarning and when is it used?


Section 7.1-7.8 (Feb. 21)

1. In the examples, whenever a widget is passed as an argument, the first thing the function does is to cast it to type BitmapEditWidget. Is this really necessary? Explain.

2. In section 7.3, the author mentions a third argument to expose, not shown in the examples. When should this be used? There is also a visible field in the Core widget instance structure that can help reduce drawing time. Consult Vol. 5 (under the expose method) and describe how this field should be used.

3. Why does the expose method test XtIsRealized? Under what circumstances should set_values do the same thing?

4. There are two routines to create graphical contexts, XCreateGC and XtGetGC. Under what circumstances should each be used?


Sections 9.1-9.6 (Feb. 18)

1. Define: event handler, nonmaskable event handler, raw event handler, timeout, visible_interest field, work procedure.

2. How does the use of the "Input source mask" differ from other masks in X?

3. The title of Section 9.3 mentions sockets explicitly, but the text doesn't. From your knowledge of C and UNIX, how would you modify Example 9-5 to read input through a socket?

4. Tremendous overhead can be associated with Xt's input handlers. Show how you could use a timeout to solve this problem for Example 9-5 (keep your code portable as well as efficient).

5. Automatically removing the timeout when the registered function is called seems like unnecessary work, since most timeout functions immediately reinstate themselves with another call to XtAppAddTimeOut. How does the Xt work procedure mechanism handle this problem?

6. Example 9-10 shows a common use of work procs. It is possible, however, for a popup to be needed before its work proc has been called. How could you handle this situation?


Section 10.3 (Feb. 13)

1. Define: resource list, representation type, language string, fallback resource.

2. What is the purpose of specifying a representation type in a resource list entry?

3. Give an example of circumstances under which you would need to use a fallback resource rather than defining a new resource with a default value.

4. Explain where and under what circumstances XtRImmediate is used.

5. Suppose you allow the user to provide his/her own bitmap file to be used as the cursor shape in your application. Should you use XtRCursor or XmuCvtStringToCursor, and why?

6. When is XtSetTypeConverter needed?