Chapter 14. A Complete Application

While the simple application in Chapter 3 demonstrated the most important X programming techniques, it was far from a complete application. This chapter describes a calculator program that provides for calculations in several bases. This program has a more robust event loop than the simple application in Chapter 3 and demonstrates the use of the resource manager routines for integrating user preferences.

Our basic window program in Chapter 3, did not do all the things an application normally should do. We should have more complete communication with the window manager, parse the command line, and merge these options with the user’s defaults to set up user-preferred colors and miscellaneous options. This chapter describes and demonstrates these techniques with a real application, basecalc.

The basecalc application is a programmer’s calculator that allows integer calculations in binary, octal, decimal, and hexadecimal and conversions between these bases. It is not quite as complicated as xcalc, the standard calculator for X, but it demonstrates X techniques just as well. basecalc also does base conversions, logical operations, and unsigned arithmetic, which xcalc does not.

Only the sections of the program that illustrate X concepts are shown and described in this chapter. The entire program is shown in Appendix D.

This program has one characteristic that is not strictly correct in the X environment. It has only one allowable size. If the window manager ...

Get XLIB Programming Manual, Rel. 5, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.