#include #include //compile with amulet files: "console.cpp" & "console.h" for console output //Define callback function for File menu Open... option Am_Define_Method(Am_Object_Method, void, my_open_do, (Am_Object self)) { cout << endl << "my_open_do() called" << endl << flush; } //Define callback function for File menu Save As... option Am_Define_Method(Am_Object_Method, void, my_saveas_do, (Am_Object self)) { cout << endl << "my_saveas_do() called" << endl << flush; } //Define callback function for File menu Close option Am_Define_Method(Am_Object_Method, void, my_close_do, (Am_Object self)) { cout << endl << "my_close_do() called" << endl << flush; } void InitMenus (Am_Object& my_menu_bar); int main (void) { Am_Initialize (); //Initialize Amulet //Create an Amulet Window Am_Object my_win = Am_Window.Create ("my_win") .Set (Am_LEFT, 20) .Set (Am_TOP, 50) .Set (Am_WIDTH, 500) .Set (Am_HEIGHT, 500) .Set (Am_TITLE, "My Window"); Am_Object my_menu_bar; InitMenus (my_menu_bar); my_win.Add_Part(my_menu_bar); Am_Screen.Add_Part (my_win); 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("File_Command") .Set(Am_LABEL, "File") .Set(Am_IMPLEMENTATION_PARENT, true) //not undoable //File menu has no callback Fn .Set(Am_ITEMS, Am_Value_List () .Add (Am_Command.Create("New_Command") .Set(Am_LABEL, "New...") .Set(Am_ACCELERATOR, "^n") .Set(Am_ACTIVE, false) .Set(Am_IMPLEMENTATION_PARENT, true) ) //not undoable //New option has no callback Fn .Add (Am_Command.Create("Open_Command") .Set(Am_LABEL, "Open...") .Set(Am_ACCELERATOR, "^o") .Set(Am_ACTIVE, true) .Set(Am_DO_METHOD, my_open_do)) //callback Fn for Open option .Add (Am_Menu_Line_Command.Create("my menu line")) //menu spacer line .Add (Am_Command.Create("Save_Command") .Set(Am_LABEL, "Save") .Set(Am_ACCELERATOR, "^s") .Set(Am_ACTIVE, false) .Set(Am_IMPLEMENTATION_PARENT, true) ) //not undoable //Save option has no callback Fn .Add (Am_Command.Create("Save_As_Command") .Set(Am_LABEL, "Save As...") .Set(Am_ACCELERATOR, "^a") .Set(Am_DO_METHOD, my_saveas_do)) //callback Fn for Save As... option .Add (Am_Command.Create("Close_Command") .Set(Am_LABEL, "Close") .Set(Am_ACCELERATOR, "^w") .Set(Am_DO_METHOD, my_close_do)) //callback Fn for Close option .Add (Am_Menu_Line_Command.Create("my menu line")) //menu spacer line .Add (Am_Quit_No_Ask_Command.Create() ) //Amulet Quit FN callback ) ) ) ; } // InitMenus