Example #1
0
void
CmdInterface::onEditRecord(PhoneBook & pb)
{
    long index = -1;
    Record tmp;
    println("Input the record's index to Edit(0 to cancel):");
    if ((index = getNumber()) != 0)
    {
        if (tmp = pb.searchByIndex(index))
        {
            println("The record is: ");
            show(tmp);
            edit_menu();
            char cmd;
            do{
                cmd = getCommand();
                switch (cmd)
                {
                    case '1': 
                        println("Input the new name:");
                        tmp.setName(getLine());
                        println("Name successfully modified.");
                        break;

                    case '2': 
                        println("Input the new phone:");
                        tmp.setPhone(getLine());
                        println("Phone successfully modified.");
                        break;

                    case '3': 
                        println("Input the new address:");
                        tmp.setAddr(getLine()); 
                        println("Address successfully modified.");
                        break;
                    case '0': println("Finish Modification."); break;
                    default : println("Error Command!"); break;
                }
                edit_menu();
            }while (cmd != '0');
            pb.setRecord(index, tmp);
            cout << "Record #" << index << " successfully modified." << endl;
        }
        else
            println("Index not found!");
    }
    else
        println("Canceled"); 
}
Example #2
0
void menu :: main_menu(void)
{
	clrscr() ;
	char ch ;
	while (1)
	{
		clrscr() ;
		box() ;
		gotoxy(32,6) ;
		cout <<"F A S T  F O O D" ;
		gotoxy(32,7) ;
		cout <<"~~~~~~~~~~~~~~~~" ;
		gotoxy(32,9) ;
		cout <<"1: PURCHASE" ;
		gotoxy(32,11) ;
		cout <<"2: SEE MENU" ;
		gotoxy(32,13) ;
		cout <<"3: EDIT" ;
		gotoxy(32,15) ;
		cout <<"4: TOTAL BILL" ;
		gotoxy(32,17) ;
		cout <<"0: QUIT" ;
		gotoxy(32,20) ;
		cout <<"Enter Choice : " ;
		ch = getche() ;
		if (ch == 27)
			return ;
		else
		if (ch == '1')
		{
			food f ;
			f.purchase() ;
		}
		else
		if (ch == '2')
		{
			food f ;
			f.list_of_item() ;
		}
		else
		if (ch == '3')
			edit_menu() ;
		else
		if (ch == '4')
		{
			account a ;
			a.bill_list();
		}
		else
		if (ch == '0')
			break ;
	}
}
Example #3
0
void
QueryEditor::create_ui()
{
  Wait_Cursor bob;

  XmStringLocalized mtfstring;
  String	    string;
  KeySym	    mnemonic;

  f_shell = WTopLevelShell(window_system().toplevel(), WPopup, "query_editor");
  window_system().register_shell (&f_shell);

  string = CATGETS(Set_QueryEditor, 1, "Dtinfo: Query Editor");
  XtVaSetValues((Widget)f_shell, XmNtitle, string, NULL);

  // Main form and menu bar. 
  WXmForm form                      (f_shell,    "form"                );
  WXmMenuBar menu_bar               (form,       "menu_bar"            );

  WXmPulldownMenu scope_menu        (form,       "scope_menu");
  Arg args[1];
  int n = 0;
  XtSetArg(args[n], XmNsubMenuId, (Widget) scope_menu); n++;
  f_scope_option = WXmOptionMenu    (form,       "scope_option", AM, args, n);

  mtfstring = CATGETS(Set_AgentLabel, 212, "Scope Name");
  XtVaSetValues(f_scope_option, XmNlabelString, (XmString)mtfstring, NULL);

  // Menu definitions.   how about using AddPushButton (name, obj, fun)??
  WXmCascadeButton edit_cascade     (menu_bar,   "edit",             AM);
  WXmPulldownMenu edit_menu         (menu_bar,   "edit_menu"           );
  f_cut_btn = WXmPushButton         (edit_menu,  "cut",              AM);
  f_copy_btn = WXmPushButton        (edit_menu,  "copy",             AM);
  f_paste_btn = WXmPushButton       (edit_menu,  "paste",            AM);
  f_paste_btn = WXmPushButton       (edit_menu,  "new_term",         AM);
  WXmSeparator group_sep            (edit_menu,  "group_sep",        AM);
  f_group_btn = WXmPushButton       (edit_menu,  "group",            AM);
  f_ungroup_btn = WXmPushButton     (edit_menu,  "ungroup",          AM);
  WXmSeparator undo_sep             (edit_menu,  "undo_sep",         AM);
  f_undo_btn = WXmPushButton        (edit_menu,  "undo",             AM);
  f_redo_btn = WXmPushButton        (edit_menu,  "redo",             AM);

  mtfstring =  CATGETS(Set_AgentLabel, 16, "Edit");
  mnemonic  = *CATGETS(Set_AgentLabel, 17, "E");
  XtVaSetValues(edit_cascade, XmNlabelString, (XmString)mtfstring,
			      XmNmnemonic, mnemonic, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 224, "Cut");
  XtVaSetValues(f_cut_btn, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 18, "Copy");
  XtVaSetValues(f_copy_btn, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 225, "Paste");
  XtVaSetValues(f_paste_btn, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 226, "Group");
  XtVaSetValues(f_group_btn, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 227, "Ungroup");
  XtVaSetValues(f_ungroup_btn, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 228, "Undo");
  XtVaSetValues(f_undo_btn, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 229, "Redo");
  XtVaSetValues(f_redo_btn, XmNlabelString, (XmString)mtfstring, NULL);

  // Button area at the bottom 
  WXmForm hform                     (form,       "hform"               );
  f_hist_prev = WXmArrowButton      (hform,      "hist_prev",        AM);
  f_hist_next = WXmArrowButton      (hform,      "hist_next",        AM);
  WXmLabel history                  (hform,      "history",          AM);
  f_search_btn = WXmPushButton      (form,       "search",           AM);
  WXmPushButton cancel              (form,       "cancel",           AM);
  WXmPushButton clear               (form,       "clear",            AM);
  WXmPushButton scope		    (form,	 "scope",	     AM);
  WXmPushButton help                (form,       "help",             AM);
  WXmSeparator separator            (form,       "separator",        AM);

  mtfstring =  CATGETS(Set_AgentLabel, 92, "History");
  XtVaSetValues(history, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 102, "Search");
  XtVaSetValues(f_search_btn, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 231, "Clear All");
  XtVaSetValues(clear, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 46, "Scope Editor");
  XtVaSetValues(scope, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 12, "Close");
  XtVaSetValues(cancel, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 48, "Help");
  XtVaSetValues(help, XmNlabelString, (XmString)mtfstring, NULL);

  help_agent().add_activate_help (help, "query_editor_help");

  // Main "work" area 
  WXmPanedWindow pane               (form,       "pane"                );
  WXmForm qform                     (pane,       "qform"               );
  WXmLabel qlabel                   (qform,      "qlabel",           AM);

  mtfstring =  CATGETS(Set_AgentLabel, 230, "Query");
  XtVaSetValues(qlabel, XmNlabelString, (XmString)mtfstring, NULL);
  
  f_query_text = WXmScrolledText    (qform,      "qtext",            AM);
//  f_query_text.SetEditable(False);
  f_query_area = WXmScrolledWindow  (pane,       "query_area",       AM);
  XtUnmanageChild (f_query_area.HorizontalScrollBar());

  edit_cascade.SubMenuId (edit_menu);

  // Callbacks
  ON_ACTIVATE (f_search_btn, search_activate);
  ON_ACTIVATE (cancel, cancel);
  ON_ACTIVATE (clear, clear);
  ON_ACTIVATE (scope, scope);

//  f_query_text.SetFocusCallback (this,
//			    (WWL_FUN) &QueryEditor::modify_verify);
//  f_query_text.SetModifyVerifyCallback (this,
//			    (WWL_FUN) &QueryEditor::modify_verify);

  // Set minimum sizes.
  qform.Manage();
  pane.Manage();
  //  hform.Manage();
  form.DefaultButton (f_search_btn);
  form.ShadowThickness (0);

  form.InitialFocus (pane);
  pane.InitialFocus (f_query_area);
  qform.PaneMinimum (f_query_text.Height());
  form.Manage();

  f_shell.Realize();
  f_shell.MinWidth (f_shell.Width());
  f_shell.MinHeight (f_shell.Height());
  ON_DEBUG(printf ("Query for height = %d\n", qform.Height()));
  //cerr << "Query for height = " << qform.Height() << endl;

//#ifndef UseFJMTF
#if 1
  // Swap the entries in the pane around.  Have to do this now
  // to get initial sizes right.
  qform.PositionIndex (1);
#endif

  fill_menu();

  UAS_SearchScope::request ((UAS_Receiver<ScopeCreated> *) this);
  UAS_SearchScope::request ((UAS_Receiver<ScopeDeleted> *) this);
  UAS_SearchScope::request ((UAS_Receiver<ScopeRenamed> *) this);

  search_scope_mgr().option_menu(this);
}