#include "camulet.h" //use MSVC wrapper directives for use with standard namespace //#include //included by "console.h" and "am_io.h" #include #include //compile with amulet files: "console.cpp" & "console.h" for console output using namespace std; Am_Object my_win; //define window to be global so callback functions have access //Define slot/part objects and register with amulet Am_Slot_Key AlleyLabel = Am_Register_Slot_Name ("AlleyLabel"); Am_Slot_Key AlleyField = Am_Register_Slot_Name ("AlleyField"); //Define callback function for Alley menu Hilltop option Am_Define_Method(Am_Object_Method, void, hilltop_do, (Am_Object self)) { cout << endl << "hilltop_do() called" << endl << flush; //change alleyfield text to object - get the AlleyField object and set its Am_Text value my_win.Get_Object(AlleyField).Set(Am_TEXT, "Hilltop Lanes"); } //Define callback function for Alley menu Mountaineer option Am_Define_Method(Am_Object_Method, void, mountaineer_do, (Am_Object self)) { cout << endl << "mountaineer_do() called" << endl << flush; //change alleyfield text to object - get the AlleyField object and set its Am_Text value my_win.Get_Object(AlleyField).Set(Am_TEXT, "Mountaineer Lanes"); } void InitMenus (Am_Object& my_menu_bar); int main (void) { Am_Initialize (); //Initialize Amulet my_win = Am_Window.Create ("my_win") //Create an Amulet Window .Set (Am_LEFT, 20) .Set (Am_TOP, 50) .Set (Am_WIDTH, 500) .Set (Am_HEIGHT, 500) .Set (Am_TITLE, "My Window"); //add the alley label & AlleyField objects to the window my_win.Add_Part(AlleyLabel, Am_Text.Create("AlleyLabel") .Set(Am_LEFT, 10) .Set(Am_TOP, 37) .Set(Am_WIDTH, 42) .Set(Am_HEIGHT, 14) .Set(Am_TEXT, "Alley:") .Set(Am_LINE_STYLE, Am_Black) .Set(Am_FILL_STYLE, Am_No_Style) ) .Add_Part(AlleyField, Am_Text.Create("AlleyField") .Set(Am_LEFT, 58) .Set(Am_TOP, 37) .Set(Am_WIDTH, 119) .Set(Am_HEIGHT, 14) .Set(Am_TEXT, "Mountaineer Lanes") .Set(Am_LINE_STYLE, Am_Black) .Set(Am_FILL_STYLE, Am_No_Style) ); Am_Object my_menu_bar; InitMenus (my_menu_bar); my_win.Add_Part(my_menu_bar); Am_Screen.Add_Part (my_win); cout << endl << "Start Event Loop" << endl << flush ; Am_Main_Event_Loop (); Am_Cleanup (); return 0; } void InitMenus (Am_Object& my_menu_bar) { my_menu_bar = Am_Menu_Bar.Create("my_menu_bar") .Set(Am_FILL_STYLE, Am_Motif_Gray) .Set(Am_ITEMS, Am_Value_List () .Add (Am_Command.Create("Alley_Command") .Set(Am_LABEL, "Alleys") .Set(Am_IMPLEMENTATION_PARENT, true) //not undoable //Alley menu has no callback Fn .Set(Am_ITEMS, Am_Value_List () .Add (Am_Command.Create("Hilltop_Command") .Set(Am_LABEL, "Hilltop") .Set(Am_ACTIVE, true) .Set(Am_DO_METHOD, hilltop_do)) //callback Fn for Hilltop option .Add (Am_Command.Create("Mountaineer_Command") .Set(Am_LABEL, "Mountaineer") .Set(Am_ACTIVE, true) .Set(Am_DO_METHOD, mountaineer_do)) //callback Fn for Mountaineer option .Add (Am_Command.Create("Triangle_Command") .Set(Am_LABEL, "Triangle") .Set(Am_ACTIVE, false) .Set(Am_IMPLEMENTATION_PARENT, true) ) //not undoable //Triangle option has no callback Fn .Add (Am_Menu_Line_Command.Create("my menu line")) .Add (Am_Quit_No_Ask_Command.Create() ) //Amulet Quit FN callback ) ) ) ; } // InitMenus