[comp.windows.x] More on AI/X Toolkit

tnt@ADEA-ATT.ARPA (Tom Teng) (04/22/88)

I have recieved many inquires for more information on the AI/X Toolkit. 
Instead of directing this information to individual E-mail, I am posting 
this information on XPERT for all to see. (I am also in the process of getting
approval from the U.S. Army on releasing AI/X to the general X Community).

AI/X is an attempt to make programming development under X more pallettable 
for the average application (client) developer. It is implemented as a layer
on top of the X Toolkit and adds two features currently not available under 
the X Toolkit: (1) an extension of the Resource DB to include composite widget
structure definition, instead of only attributes information, and (2) the 
incorporation of an object oriented style in the use and definition of X 
resources.

AI/X consists of two parts: the AI/X Intrinsic and libraries of "method 
wrappers" around either X Toolkit or resource defined widgets. The AI/X 
Intrinsic (as seen from the application developer perspective) consists of 
four C functions: AIXinit, loadResource, makeWidget, and sendMsg. When an
application developer use the AI/X Toolkit, he/she first create one or more
resource script file(s) defining the structure and attributes of their
application specific widget(s). For instance, suppose that a program needed
two confirmer widgets to prompt the user to save a file and quit the 
program. Then the resouce script file would contain:

		! File name: demo.res
		! (Sample script file for confirmer widget,  tnt 03/21/88)
		! confirmer widget structure & attribute definition
		
		! some global labels
		*yesButton.label:						Yes
		*noButton.label:						No
		*okButton.label:						Ok
		*cancelButton.label:					Cancel
		
		! yesNoButton widget
		! (structure)
		yesNoButton.class:					Box
		yesNoButton.yesButton.class:		Command
		yesNoButton.noButton.class:		Command
		
		! confirmer widget
		! (structure)
		confirmer.class:						VPaned
		confirmer.methodClass:				confirmer
		confirmer.message.class:			Label
		confirmer.yesNoButton.class:		yesNoButton
		
		! (demo quit confirmer attributes)
		demo.quit.confirmer.message.label:	Do you really want to quit?
		demo.quit.confirmer.yesNoButton.yesButton.label:	Quit
		demo.quit.confirmer.yesNoButton.noButton.label:		Don't Quit

Then in the demo program, he would initialize the AI/X Toolkit, load any 
resource script file that he needs (e.g. demo.res), create instances of 
widgets he wanted (e.g. quitConfirmer, fileSaveConfirmer), and sendMsg to
the widget to illict the proper behavior that he wanted. A sample program
that pop up the quit & filesave confirmers would look like:

		#include <AIX/Intrinsic.h>
		#include <Widget/confirmer.h>
		
		...
		
		void main(argc, argv)
		unsigned int argc;
		char **argv;
		{
			Widget quitConfirmer, fileSaveConfirmer;
			
			.
			.
			.

			/* initialize AI/X Toolkit */
			AIXinit("demo", "Demo", NULL, 0, &argc, argv);
			
			/* load resource script files */
			loadResource("demo.res");
			
			/* create the quitConfirmer & fileSaveConfirmer widget */
			quitConfirmer = makeWidget("quit", confirmer_Widget, PopupDialog);
			fileSaveConfirmer = makeWidget("fileSave", confirmer_Widget, PopupDialog);
			
			/* setup some of the widget attributes */
			sendMsg(quitConfirmer, Msg_setXY, 100, 200);
			sendMsg(quitConfirmer, Msg_setWidthHeight, 200, 100);
			sendMsg(fileSaveConfirmer, Msg_setMessageLabel, "Save file before quiting?");
			sendMsg(fileSaveConfirmer, Msg_setYesButtonLabel, "Save");
			sendMsg(fileSaveConfirmer, Msg_setNoButtoLabel, "Don't Save");
			
			.
			.
			.
			
			/* go for it */
			switch (sendMsg(quitConfirmer, Msg_popup)) {
				case YES:   switch(sendMsg(fileSaveConfirmer, Msg_popup)) {
									case YES:  .....
									case NO:   .....
								}
								exit();
				case NO:		....
			}
			
			.
			.
		}
		

By layering AI/X on top of the X Toolkit, as oppose 
to modifying the X Toolkit, AI/X becomes fully upward 
compatible with the X Toolkit. Hence, one can (if needed) 
mix the X Toolkit and AI/X Toolkit style in a single 
program. 

From a widget developer perspective, AI/X provides the
infrastructure neccessary to process the structure definition
of resource defined widgets (composite widgets such as the
confirmer widget that are defined in resource script files), 
and provide the object orient programming style of sending
messages to the widget instances. AI/X allows widget developers
the define "method wrappers" around resource defined and
X Toolkit Widgets. These methods are defined in <widget>M.c files
and contain code to implement the messages that a widget can
recieve.  AI/X follows the same single inheritance heirarchy that 
is used by the X Toolkit. The method wrappers and the sendMsg mechanism
extends the X Toolkit inheritance mechanism to be directly useable
by the application (client) developer.

The Intrinsics for AI/X is mostly completed and I am now filling out 
the Widget Hierarchy with X Widgets, Resource defined Widgets, and 
their associated methods. (We are also developing Ada bindings around
AI/X). I would hate to reinvent the wheel and have to implement some 
of the basic primitive widgets such as PushButton, RadioButton, CheckBox,
ScrollList, etc.. , as well as a decent composite widget that handles 
constraints and positioning of children widgets. Some one out there must 
be developing these widgets on top of the X Toolkit. If so, how about
sharing these widgets with the rest of us, so that the wheel doesn't have 
to be reinvented. Any comments?

For more information or comments, you can contact me via E-mail 
(tnt@adea-att.arpa) or reach me at (206) 964-6152.  Thanks.

Thomas "tnt" Teng
BDM Corporation
10116 36th Av Ct SW, Suite 300
Tacoma, WA  98499