3.2 The Main of basicwin
As usual, the code is composed of a main program and several
subroutines. The main does everything described at the start of this
chapter except create the GC, load the font, and draw the text and
graphics. These tasks are done in the draw_graphics
,
draw_text
, get_GC
, and
load_font
, routines, which are shown with the
complete code in 3.2.20 Complete Code for basicwin but not
described fully until Chapter 6. You
can get the general idea of what they do just by looking at them,
though.
In the following sections, the code is shown and described in small pieces. In some cases, the relevant declarations of variables are shown again in each segment of the code as well as at the top of the program (where they would normally appear). This has been done to increase clarity when showing the individual pieces of the program.
3.2.1 Include Files and Declarations
Example 3-1 shows the include files and declarations from basicwin.c.
Example 3-1. basicwin — include files and declarations
/* Xlib include files */ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xos.h> #include <X11/Xatom.h> /* Standard C include file */ #include <stdio.h> /* Bitmap data for icon */ #include "bitmaps/icon_bitmap" #define BITMAPDEPTH 1 /* Values for window_size in main -- is window big enough to be * useful? */ #define TOO_SMALL 0 #define BIG_ENOUGH 1 /* Display and screen_num are used as arguments to nearly every * Xlib routine, so it simplifies routine calls to declare them * global; ...
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.