As mentioned earlier, most widget resources can be specified through
the resource database. According to some authors this is the preferred
way of resource setting as opposed to hard wiring in the program.
During the initialization of the application the resource manager
loads the resource database. Most end-users take advantage of that
mechanism in customizing their applications without the need to
recompile or know anything about programming. There are few places
where the resource information may reside but the usual place is the
.Xdefaults in the user's home directory. Also, the application
may keep a file of the application defaults settings in the directory:
/usr/lib/X11/app-defaults, and the filename must match the
More on the syntax of specifying resource values can be found in any book on the X Toolkit. Following is another reimplementation of the first example with the widget resources and translations set through the resource database.
button_pressed(_Widget,_Event,[Param]) :- write(Param), nl. create_button :- xtAppInitialize(App,'Test',,Shell), xmCreateLabel(Shell,button,,Button), xtManageChild(Button), xtAppAddActions(App, [action(foo,button_pressed)]), xtRealizeWidget(Shell), xtAppMainLoop(App).
Entries in the resource file:
Test.button.translations: #augment <Btn1Down>:foo("Hello Quintus") Test.button.labelString: "Press Here" Test.button.height: 100 Test.button.width: 100