05-830, User Interface Software, Spring, 1997
Lecture 9,   March 5, 1997
Copyright © 1997 - Brad Myers


        Previous Lecture     . . .      Next Lecture

Toolkits: Intrinsics, Callbacks, Resources,
Widget Hierarchies, Geometry Management

(About 30-40 minutes)


Widgets as objects

Intrinsics

Resources

Callbacks

Widget Hierarchies

Geometry Management

Standard Motif Application

  1. Include Motif and widget header files
  2. Initialize the toolkit: XtAppInitialize
  3. Create the widgets and put them in composites ("parent")
  4. Register call-backs with the widges
  5. "Realize" the top level widget
  6. Start the main loop: XtAppMainLoop


Simple Hello World Program in Amulet:
#include <amulet.h>

main (void) {

Am_Initialize ();

Am_Screen

.Add_Part (Am_Window.Create ("window")

.Set (Am_WIDTH, 200)

.Set (Am_HEIGHT, 50)

.Add_Part (Am_Text.Create ("string")

.Set (Am_TEXT, "Hello World!")));

Am_Main_Event_Loop ();

Am_Cleanup ();

}


Goodbye-world Amulet program with button
#include <amulet.h>

main (void) {

Am_Initialize ();

Am_Screen

.Add_Part (Am_Window.Create ("window")

.Set (Am_WIDTH, 200)

.Set (Am_HEIGHT, 50)

.Set (Am_FILL_STYLE, Am_Amulet_Purple)

.Add_Part (Am_Button.Create ("button")

.Set_Part(Am_COMMAND,

Am_Quit_No_Ask_Command.Create()

.Set (Am_LABEL, "Goodbye, world!"))));

Am_Main_Event_Loop ();

Am_Cleanup ();

}


Goodbye-world Amulet program without button
#include <amulet.h>

Am_Define_Method (Am_Object_Method, void, quit_method, (Am_Object)) {

cerr << "It was nice knowing you.\n" << flush;

Am_Exit_Main_Event_Loop();

}

main (void) {

Am_Object inter;

Am_Initialize ();

Am_Screen

.Add_Part(Am_Window.Create ("window")

.Set (Am_WIDTH, 200)

.Set (Am_HEIGHT, 50)

.Add_Part(Am_Text.Create ("string")

.Set (Am_TEXT, "Goodbye World!")

.Add_Part(inter = Am_One_Shot_Interactor.Create())

)

);

inter.Get_Part(Am_COMMAND)

Set (Am_DO_METHOD, quit_method);

Am_Main_Event_Loop ();

Am_Cleanup ();

}


Back to 05-830 main page