! ! (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC. ! ALL RIGHTS RESERVED ! ! ! Motif Release 1.2 ! ! $RCSfile: motifbur.uil,v $ $Revision: 1.4.2.2 $ $Date: 1992/03/27 02:52:45 $ !****************************************************************************** !module MotifBurger_demo module motifburger version = 'v1.0' names = case_sensitive ! toggle button must be widgets ! due to XmToggleButtonSetState call in c source objects = { XmSeparator = gadget ; XmLabel = gadget ; XmPushButton = gadget ; XmToggleButton = widget ; } procedure toggle_proc (integer); activate_proc (integer); create_proc (integer); scale_proc (integer); list_proc (integer); quit_proc (string); show_hide_proc (integer); pull_proc (integer); value k_create_order : 1; k_order_pdme : 2; k_file_pdme : 3; k_edit_pdme : 4; k_nyi : 5; k_apply : 6; k_dismiss : 7; k_noapply : 8; k_cancel_order : 9; k_submit_order : 10; k_order_box : 11; k_burger_rare : 12; k_burger_medium : 13; k_burger_well : 14; k_burger_ketchup : 15; k_burger_mustard : 16; k_burger_onion : 17; k_burger_mayo : 18; k_burger_pickle : 19; k_burger_quantity : 20; k_fries_tiny : 21; k_fries_small : 22; k_fries_medium : 23; k_fries_large : 24; k_fries_huge : 25; k_fries_quantity : 26; k_drink_list : 27; k_drink_add : 28; k_drink_sub : 29; k_drink_quantity : 30; k_total_order : 31; k_burger_label : 32; k_fries_label : 33; k_drink_label : 34; k_menu_bar : 35; k_file_menu : 36; k_edit_menu : 37; k_order_menu : 38; value k_motifburger_title : 'MOTIFburger Order-Entry Box'; k_nyi_label_text : 'Feature is not yet implemented'; k_file_label_text : 'File'; k_quit_label_text : 'Quit'; k_edit_label_text : 'Edit'; k_cut_dot_label_text : 'Cut'; k_copy_dot_label_text : 'Copy'; k_paste_dot_label_text : 'Paste'; k_clear_dot_label_text : 'Clear'; k_select_all_label_text : 'Select All'; k_order_label_text : 'Order'; k_show_controls_label_text : 'Show Controls...'; k_cancel_order_label_text : 'Cancel Order'; k_submit_order_label_text : 'Submit Order'; k_hamburgers_label_text : 'Hamburgers'; k_rare_label_text : 'Rare'; k_medium_label_text : 'Medium'; k_well_done_label_text : 'Well Done'; k_ketchup_label_text : 'Ketchup'; k_mustard_label_text : 'Mustard'; k_onion_label_text : 'Onion'; k_mayonnaise_label_text : 'Mayonnaise'; k_pickle_label_text : 'Pickle'; k_quantity_label_text : 'Quantity'; k_fries_label_text : 'Fries'; k_size_label_text : 'Size'; k_tiny_label_text : 'Tiny'; k_small_label_text : 'Small'; k_large_label_text : 'Large'; k_huge_label_text : 'Huge'; k_drinks_label_text : 'Drinks'; k_0_label_text : '0'; k_drink_list_text : string_table ('Apple Juice', 'Orange Juice', 'Grape Juice', 'Cola', 'Punch','Root beer', 'Water', 'Ginger Ale', 'Milk', 'Coffee', 'Tea'); k_drink_list_select : string_table('Apple Juice'); k_u_label_text : 'U'; k_d_label_text : 'D'; k_apply_label_text : 'Apply'; k_reset_label_text : 'Reset'; k_cancel_label_text : 'Cancel'; k_dismiss_label_text : 'Dismiss'; ! substitute another font name if this font is not available on your system value k_button_font : font('-ADOBE-Courier-Bold-R-Normal--14-140-75-75-M-90-ISO8859-1'); ! k_button_font : font('variable'); value ! menonic name ASCII Keyboard Symbol ! ---------------------- ------- --------------- k_file_mnemonic : 70; ! "F" k_quit_mnemonic : 81; ! "Q" k_edit_mnemonic : 69; ! "E" k_order_mnemonic : 79; ! "O" k_rare_mnemonic : 82; ! "R" k_medium_mnemonic : 77; ! "M" k_doneness_mnemonic : 68; ! "D" k_ketchup_mnemonic : 75; ! "K" value k_quit_accelerator : "Ctrlz:"; k_quit_accelerator_text : "Ctrl/z"; k_ketchup_accelerator : "Ctrlk:"; k_ketchup_accelerator_text : "Ctrl/k"; ! Colors, color tables, and icons. value yellow : color('yellow', foreground); red : color('red', background); green : color('green', foreground); magenta : color('magenta', background); gold : color('gold', foreground); lightblue : color('lightblue', background); value button_ct : color_table( yellow='o' ,red='.' ,background color=' '); value drink_up_icon: icon(color_table=button_ct, ' ', ' ..........oo.......... ', ' .........oooo......... ', ' ........oooooo........ ', ' .......oo....oo....... ', ' ......oo......oo...... ', ' .....oo........oo..... ', ' ....oo..........oo.... ', ' ...oo............oo... ', ' ..oo..............oo.. ', ' .oo................oo. ', ' oooooooooooooooooooooo ', ' oooooooooooooooooooooo ', ' .........oooo......... ', ' .........oooo......... ', ' .........oooo......... ', ' .........oooo......... ', ' .........oooo......... ', ' .........oooo......... ', ' '); ! First declare the 'top level' widgets. These are not controlled by ! any other widgets. They are each fetched individually as needed. object ! The main window widget. ! This displays the current order ! as it is taken. S_MAIN_WINDOW : XmMainWindow { arguments { }; controls { ! S_MAIN_WINDOW has two children. XmMenuBar s_menu_bar; XmScrolledList total_order; }; }; object ! The control panel. All order entry ! is done through this dialog box. control_box : XmBulletinBoardDialog { arguments { XmNdialogTitle = k_motifburger_title; XmNdialogStyle = XmDIALOG_MODELESS; XmNx = 600; XmNy = 200; XmNmarginWidth = 20; XmNbackground = lightblue; }; controls { ! Some labels and decoration. XmLabel burger_label; XmLabel fries_label; XmLabel drink_label; XmSeparator {arguments { XmNx = 220; XmNy = 20; XmNunitType = XmPIXELS; XmNorientation = XmVERTICAL; XmNheight = 180; };}; XmSeparator {arguments { XmNx = 410; XmNy = 20; XmNunitType = XmPIXELS; XmNorientation = XmVERTICAL; XmNheight = 180; };}; XmRowColumn button_box; ! Command push buttons inside a menu ! across the bottom. ! For the hamburger, fries, and drink ! entry we use a different mechanism ! to demonstrate various widgets and ! techniques. ! Hamburger 'doneness' uses a radio box ! because although it is a '1 of N' type ! of entry, one (and only one) entry ! is allowed. XmRadioBox burger_doneness_box; ! Toppings entry uses a menu with toggle ! buttons since more than one topping ! (M of N selection) is allowed. XmRowColumn burger_toppings_menu; ! Number of burgers uses ! a scale widget. XmScale burger_quantity; ! Fries size uses an option ! menu, for '1 of N' selection. XmOptionMenu fries_option_menu; ! Fries quantity uses a label ! and text widget. XmLabel fries_quantity_label; XmText fries_quantity; ! Drink selection uses a list ! box because this is a '1 of N' ! selection where N is a big number XmScrolledWindow drink_list_box_window; ! Drink quantity uses an ! assembly of our own widgets. XmForm drink_quantity; }; callbacks { MrmNcreateCallback = procedure create_proc (k_order_box); }; }; object ! A popup dialog box, called by any nyi : XmInformationDialog { ! code that is not finished. Useful ! for prototyping. arguments { XmNmessageString = k_nyi_label_text; XmNdefaultPosition = true; XmNautoUnmanage = true; }; callbacks { MrmNcreateCallback = procedure create_proc (k_nyi); }; }; ! Now define all remaining widgets alluded to in the definition of the top ! level widgets. ! The main window has a list box for displaying the order as it is built. object total_order : XmScrolledList { arguments { XmNwidth = 500; XmNvisibleItemCount = 15; XmNunitType = XmPIXELS; XmNlistSizePolicy = XmVARIABLE; XmNscrollBarDisplayPolicy = XmSTATIC; }; callbacks { MrmNcreateCallback = procedure create_proc (k_total_order); }; }; ! Now define the menu bar and the pulldown widgets in the menu bar. object s_menu_bar : XmMenuBar { arguments { XmNorientation = XmHORIZONTAL; XmNspacing = 15; ! Pixels between items in menu }; controls { XmCascadeButton file_menu_entry; XmCascadeButton edit_menu_entry; XmCascadeButton order_menu_entry; }; callbacks { MrmNcreateCallback = procedure create_proc (k_menu_bar); }; }; ! The file pulldown menu entry widget (what shows up in the menu bar itself). ! All these pulldown entries can be set up to function in one of two ways by ! removing comment characters: ! 1. If the 'controls' clause specifying the pulldown menu is ! commented out, then the pulldown menus are loaded by the ! cascading callback when the entry is first activated. ! 2. If the 'controls' clause is not commented out, then the pulldown ! menu is loaded when its parent is created. ! Method 1 demonstrates deferred menu creation. The pulldown entry ! creates its pulldown menu at a later time, rather than at the ! time the pulldown entry is created. ! Method 2 demonstrates the standard technique -- creating the pulldown menu at ! the time the pulldown entry is created. object file_menu_entry : XmCascadeButton { arguments { XmNlabelString = k_file_label_text; ! XmNmnemonic = k_file_mnemonic; XmNmnemonic = keysym("F"); }; controls { XmPulldownMenu file_menu; }; callbacks { XmNcascadingCallback = procedure pull_proc (k_file_pdme); MrmNcreateCallback = procedure create_proc (k_file_pdme); }; }; ! The pulldown menu with the push buttons it controls. object file_menu : XmPulldownMenu { controls { XmPushButton m_quit_button; }; callbacks { MrmNcreateCallback = procedure create_proc (k_file_menu); }; }; object m_quit_button : XmPushButton { arguments { XmNlabelString = k_quit_label_text; XmNaccelerator = k_quit_accelerator; XmNacceleratorText = k_quit_accelerator_text; ! XmNmnemonic = k_quit_mnemonic; XmNmnemonic = keysym("Q"); }; callbacks { XmNactivateCallback = procedure quit_proc ('normal demo exit'); }; }; ! The edit pulldown entry and the associated pulldown menu. object edit_menu_entry : XmCascadeButton { arguments { XmNlabelString = k_edit_label_text; ! XmNmnemonic = k_edit_mnemonic; XmNmnemonic = keysym("E"); }; controls { XmPulldownMenu edit_menu; }; callbacks { XmNcascadingCallback = procedure pull_proc (k_edit_pdme); MrmNcreateCallback = procedure create_proc (k_edit_pdme); }; }; object edit_menu : XmPulldownMenu { controls { XmPushButton m_select_all_button; XmPushButton m_clear_button; XmPushButton m_paste_button; XmPushButton m_copy_button; XmPushButton m_cut_button; }; callbacks { MrmNcreateCallback = procedure create_proc (k_edit_menu); }; }; object m_cut_button : XmPushButton { arguments { XmNlabelString = k_cut_dot_label_text; }; callbacks { XmNactivateCallback = procedure activate_proc (k_nyi); }; }; object m_copy_button : XmPushButton { arguments { XmNlabelString = k_copy_dot_label_text; }; callbacks { XmNactivateCallback = procedure activate_proc (k_nyi); }; }; object m_paste_button : XmPushButton { arguments { XmNlabelString = k_paste_dot_label_text; }; callbacks { XmNactivateCallback = procedure activate_proc (k_nyi); }; }; object m_clear_button : XmPushButton { arguments { XmNlabelString = k_clear_dot_label_text; }; callbacks { XmNactivateCallback = procedure activate_proc (k_nyi); }; }; object m_select_all_button : XmPushButton { arguments { XmNlabelString = k_select_all_label_text; }; callbacks { XmNactivateCallback = procedure activate_proc (k_nyi); }; }; ! Finally, the pulldown entry for ordering and its associated pulldown menu. object order_menu_entry : XmCascadeButton { arguments { XmNlabelString = k_order_label_text; ! XmNmnemonic = k_order_mnemonic; XmNmnemonic = keysym("O"); }; controls { XmPulldownMenu order_menu; }; callbacks { XmNcascadingCallback = procedure pull_proc (k_order_pdme); MrmNcreateCallback = procedure create_proc (k_order_pdme); }; }; object order_menu : XmPulldownMenu { controls { XmPushButton m_show_control_button; XmSeparator {}; XmPushButton m_cancel_order_button; XmPushButton m_submit_order_button; }; callbacks { MrmNcreateCallback = procedure create_proc (k_order_menu); }; }; object m_show_control_button : XmPushButton { callbacks { MrmNcreateCallback = procedure create_proc (k_create_order); XmNactivateCallback = procedure show_hide_proc (k_create_order); }; }; object m_cancel_order_button : XmPushButton { arguments { XmNlabelString = k_cancel_order_label_text; }; callbacks { XmNactivateCallback = procedure activate_proc (k_cancel_order); }; }; object m_submit_order_button : XmPushButton { arguments { XmNlabelString = k_submit_order_label_text; }; callbacks { XmNactivateCallback = procedure activate_proc (k_submit_order); }; }; object burger_label : XmLabel { arguments { XmNunitType = XmPIXELS; XmNx = 50; XmNy = 10; XmNlabelString = k_hamburgers_label_text; }; callbacks { MrmNcreateCallback = procedure create_proc (k_burger_label); }; }; object burger_doneness_box : XmRadioBox { arguments { XmNunitType = XmPIXELS; XmNx = 20; XmNy = 44; XmNorientation = XmVERTICAL; XmNborderWidth = 0; ! entry_class = class_rec_name("XmToggleButtonGadget"); XmNisHomogeneous = false; }; controls { XmToggleButton burger_rare; XmToggleButton burger_medium; XmToggleButton burger_well; }; }; object burger_rare : XmToggleButton { arguments { XmNlabelString = k_rare_label_text; ! XmNmnemonic = k_rare_mnemonic; XmNmnemonic = keysym("R"); }; callbacks { XmNvalueChangedCallback = procedure toggle_proc (k_burger_rare); MrmNcreateCallback = procedure create_proc (k_burger_rare); }; }; object burger_medium : XmToggleButton { arguments { XmNlabelString = k_medium_label_text; XmNindicatorOn = on; ! A radio box requires one toggle to be set. ! XmNmnemonic = k_medium_mnemonic; XmNmnemonic = keysym("M"); }; callbacks { XmNvalueChangedCallback = procedure toggle_proc (k_burger_medium); MrmNcreateCallback = procedure create_proc (k_burger_medium); }; }; object burger_well : XmToggleButton { arguments { XmNlabelString = k_well_done_label_text; }; callbacks { XmNvalueChangedCallback = procedure toggle_proc (k_burger_well); MrmNcreateCallback = procedure create_proc (k_burger_well); }; }; object burger_toppings_menu : XmRowColumn { arguments { XmNunitType = XmPIXELS; XmNx = 110; XmNy = 44; XmNorientation = XmVERTICAL; XmNborderWidth = 0; }; controls { XmToggleButton ketchup; XmToggleButton mustard; XmToggleButton pickle; XmToggleButton onion; XmToggleButton mayo; }; }; object ketchup : XmToggleButton { arguments { XmNlabelString = k_ketchup_label_text; ! XmNmnemonic = k_ketchup_mnemonic; XmNmnemonic = keysym("K"); XmNaccelerator = k_ketchup_accelerator; XmNacceleratorText = k_ketchup_accelerator_text; }; callbacks { XmNvalueChangedCallback = procedure toggle_proc (k_burger_ketchup); MrmNcreateCallback = procedure create_proc (k_burger_ketchup); }; }; object mustard : XmToggleButton { arguments { XmNlabelString = k_mustard_label_text; }; callbacks { XmNvalueChangedCallback = procedure toggle_proc (k_burger_mustard); MrmNcreateCallback = procedure create_proc (k_burger_mustard); }; }; object onion : XmToggleButton { arguments { XmNlabelString = k_onion_label_text; }; callbacks { XmNvalueChangedCallback = procedure toggle_proc (k_burger_onion); MrmNcreateCallback = procedure create_proc (k_burger_onion); }; }; object mayo : XmToggleButton { arguments { XmNlabelString = k_mayonnaise_label_text; }; callbacks { XmNvalueChangedCallback = procedure toggle_proc (k_burger_mayo); MrmNcreateCallback = procedure create_proc (k_burger_mayo); }; }; object pickle : XmToggleButton { arguments { XmNlabelString = k_pickle_label_text; }; callbacks { XmNvalueChangedCallback = procedure toggle_proc (k_burger_pickle); MrmNcreateCallback = procedure create_proc (k_burger_pickle); }; }; object burger_quantity : XmScale { arguments { XmNx = 20; XmNy = 175; XmNunitType = XmPIXELS; XmNminimum = 0; XmNmaximum = 10; XmNwidth = 90; XmNborderWidth = 0; XmNtitleString = k_quantity_label_text; XmNshowValue = true; }; callbacks { MrmNcreateCallback = procedure create_proc (k_burger_quantity); XmNvalueChangedCallback = procedure scale_proc (k_burger_quantity); }; }; object fries_label : XmLabel { arguments { XmNx = 300; XmNy = 10; XmNunitType = XmPIXELS; XmNlabelString = k_fries_label_text; }; callbacks { MrmNcreateCallback = procedure create_proc (k_fries_label); }; }; object fries_option_menu : XmOptionMenu { arguments { XmNx = 260; XmNy = 44; XmNunitType = XmPIXELS; XmNlabelString = k_size_label_text; XmNmenuHistory = XmPushButton medium_fries; }; controls { XmPulldownMenu fries_menu; }; }; object fries_menu : XmPulldownMenu { controls { XmPushButton tiny_fries; XmPushButton small_fries; XmPushButton medium_fries; XmPushButton large_fries; XmPushButton huge_fries; }; }; object tiny_fries : XmPushButton { arguments { XmNlabelString = k_tiny_label_text; }; callbacks { XmNactivateCallback = procedure activate_proc (k_fries_tiny); }; }; object small_fries : XmPushButton { arguments { XmNlabelString = k_small_label_text; }; callbacks { XmNactivateCallback = procedure activate_proc (k_fries_small); }; }; object medium_fries : XmPushButton { arguments { XmNlabelString = k_medium_label_text; }; callbacks { XmNactivateCallback = procedure activate_proc (k_fries_medium); }; }; object large_fries : XmPushButton { arguments { XmNlabelString = k_large_label_text; }; callbacks { XmNactivateCallback = procedure activate_proc (k_fries_large); }; }; object huge_fries : XmPushButton { arguments { XmNlabelString = k_huge_label_text; }; callbacks { XmNactivateCallback = procedure activate_proc (k_fries_huge); }; }; object fries_quantity_label : XmLabel { arguments { XmNx = 260; XmNy = 200; XmNunitType = XmPIXELS; XmNlabelString = k_quantity_label_text; }; }; object fries_quantity : XmText { arguments { XmNx = 165 + 165; XmNy = 200; XmNunitType = XmPIXELS; XmNwidth = 30; XmNmaxLength = 3; XmNvalue = k_0_label_text; }; callbacks { MrmNcreateCallback = procedure create_proc (k_fries_quantity); ! There is no text callback for text. You have to provide ! one in the application code. }; }; object drink_label : XmLabel { arguments { XmNx = 480; XmNy = 10; XmNunitType = XmPIXELS; XmNlabelString = k_drinks_label_text; }; callbacks { MrmNcreateCallback = procedure create_proc (k_drink_label); }; }; object drink_list_box_window : XmScrolledWindow { arguments { XmNx = 460; XmNy = 44; }; controls { XmList drink_list_box; }; }; object drink_list_box : XmList { arguments { XmNunitType = XmPIXELS; XmNvisibleItemCount = 4; XmNitems = k_drink_list_text; XmNselectedItems = k_drink_list_select; XmNselectionPolicy = XmSINGLE_SELECT; }; callbacks { XmNsingleSelectionCallback = procedure list_proc (k_drink_list); }; }; object drink_quantity : XmForm { arguments { XmNx = 460; XmNy = 170; XmNunitType = XmPIXELS; }; controls { XmLabel quantity_label; XmLabel value_label; XmPushButton up_value; XmPushButton down_value; }; }; object quantity_label : XmLabel widget { ! You cannot use gadgets as children arguments { ! of an attached dialog box. XmNx = 10; XmNy = 10; XmNunitType = XmPIXELS; XmNlabelString = k_quantity_label_text; }; }; object value_label : XmLabel widget { arguments { XmNleftAttachment = XmATTACH_WIDGET; XmNleftOffset = 10 ; XmNleftWidget = XmLabel quantity_label ; XmNy = 20 ; XmNlabelString = ' 0 '; }; callbacks { MrmNcreateCallback = procedure create_proc (k_drink_quantity); }; }; object up_value : XmPushButton widget { arguments { XmNy = 00 ; XmNleftAttachment = XmATTACH_WIDGET; XmNleftOffset = 20 ; XmNleftWidget = XmLabel value_label ; XmNlabelType = XmPIXMAP; XmNlabelPixmap = drink_up_icon; }; callbacks { XmNactivateCallback = procedure activate_proc (k_drink_add); }; }; object down_value : XmPushButton widget { arguments { XmNy = 30 ; XmNleftAttachment = XmATTACH_WIDGET; XmNleftOffset = 20 ; XmNleftWidget = XmLabel value_label ; XmNlabelType = XmPIXMAP; XmNlabelPixmap = xbitmapfile('icon.xbm'); }; callbacks { XmNactivateCallback = procedure activate_proc (k_drink_sub); }; }; object button_box : XmRowColumn { arguments { XmNorientation = XmHORIZONTAL; XmNspacing = 100; XmNx = 90; XmNy = 280; XmNunitType = XmPIXELS; XmNborderWidth = 0; XmNentryBorder = 3; }; controls { XmPushButton apply_button; XmPushButton dismiss_button; XmPushButton can_button; }; }; object apply_button : XmPushButton widget { ! The menu positions the buttons arguments { ! automatically. XmNlabelString = k_apply_label_text; XmNfontList = k_button_font ; XmNforeground = yellow; XmNbackground = red; XmNhighlightColor = magenta; XmNborderColor = green; }; callbacks { MrmNcreateCallback = procedure create_proc (k_apply); XmNactivateCallback = procedure activate_proc (k_apply); }; }; object can_button : XmPushButton widget { arguments { XmNlabelString = k_reset_label_text; XmNfontList = k_button_font ; XmNforeground = yellow; XmNbackground = red; XmNhighlightColor = magenta; XmNborderColor = green; }; callbacks { MrmNcreateCallback = procedure create_proc (k_noapply); XmNactivateCallback = procedure activate_proc (k_noapply); }; }; object dismiss_button : XmPushButton widget { arguments { XmNlabelString = k_dismiss_label_text; XmNfontList = k_button_font ; XmNforeground = yellow; XmNbackground = red; XmNhighlightColor = magenta; XmNborderColor = green; }; callbacks { MrmNcreateCallback = procedure create_proc (k_dismiss); XmNactivateCallback = procedure activate_proc (k_dismiss); }; }; end module;