00001 /*******************************************************/ 00002 /* "C" Language Integrated Production System */ 00003 /* */ 00004 /* X Windows Version 2.01 06/15/03 */ 00005 /* */ 00006 /* XMENU_EXEC MODULE */ 00007 /*******************************************************/ 00008 00009 /*************************************************************/ 00010 /* Purpose: */ 00011 /* */ 00012 /* Principal Programmer(s): */ 00013 /* Bebe Ly */ 00014 /* Daniel J. McCoy */ 00015 /* */ 00016 /* Contributing Programmer(s): */ 00017 /* Gary D. Riley */ 00018 /* */ 00019 /* Revision History: */ 00020 /* */ 00021 /*************************************************************/ 00022 00023 #include <stdio.h> 00024 #include "xsetup.h" 00025 00026 #include "xclipstext.h" 00027 #include "xmenu_exec.h" 00028 #include "xmain.h" 00029 #include "xmenu.h" 00030 00031 #include "setup.h" 00032 #include "router.h" 00033 #include "factmngr.h" 00034 #include "commline.h" 00035 00036 /********** local functions not visible outside this file **********/ 00037 static void ResetClips(Widget,XtPointer,XtPointer); 00038 static void ClearClips(Widget,XtPointer,XtPointer); 00039 00040 /******************************************************************************* 00041 Name: ResetCallback 00042 Description: Called when Reset is selected form Execution menu 00043 Arguments: w - menu item that was selected 00044 client_data - entry number on menu 00045 call_data - not used 00046 Returns: None 00047 *******************************************************************************/ 00048 void ResetCallback( 00049 Widget w, 00050 XtPointer client_data, 00051 XtPointer call_data) 00052 { 00053 void *theEnv = GetCurrentEnvironment(); 00054 MoveEndOfFile(dialog_text, &TheEvent); 00055 if(EnvGetNextFact(theEnv,NULL)) 00056 { 00057 Widget confirmshell, confirm; 00058 00059 confirmshell = XtCreatePopupShell("Confirmation", 00060 topLevelShellWidgetClass, 00061 toplevel, 00062 NULL, 0); 00063 00064 XtSetArg(TheArgs[0], XtNlabel, "The fact list\nis not empty!"); 00065 XtSetArg(TheArgs[1], XtNicon, clips_logo); 00066 confirm = XtCreateManagedWidget("confirm", 00067 dialogWidgetClass, 00068 confirmshell, TheArgs, 2); 00069 00070 XawDialogAddButton(confirm, "Reset", ResetClips, (XtPointer) confirm); 00071 XawDialogAddButton(confirm, "Cancel", CancelPopupSelect, 00072 (XtPointer) confirm); 00073 00074 XtPopup(confirmshell, XtGrabNonexclusive); 00075 } 00076 00077 else 00078 { 00079 PrintCLIPS("wclips", "(reset)\n"); 00080 SetCommandString(GetCurrentEnvironment(),"(reset)\n"); 00081 00082 /* ============================================ */ 00083 /* Set this flag to True to break out of the */ 00084 /* event loop so CLIPS could process the */ 00085 /* command. */ 00086 /* ============================================ */ 00087 00088 quit_get_event = True; 00089 } 00090 } 00091 00092 /******************************************************************************* 00093 Name: RunCallback 00094 Description: Called when Run is selected form Execution menu 00095 Arguments: w - menu item that was selected 00096 client_data - entry number on menu 00097 call_data - not used 00098 Returns: None 00099 *******************************************************************************/ 00100 void RunCallback( 00101 Widget w, 00102 XtPointer client_data, 00103 XtPointer call_data) 00104 { 00105 /* if(CommandLineData(GetCurrentEnvironment())->EvaluatingTopLevelCommand) 00106 return;*/ 00107 MoveEndOfFile(dialog_text, &TheEvent); 00108 PrintCLIPS("wclips", "(run)\n"); 00109 SetCommandString(GetCurrentEnvironment(),"(run)\n"); 00110 /* ============================================ */ 00111 /* Set this flag to True to break out of the */ 00112 /* event loop so CLIPS could process the */ 00113 /* command. */ 00114 /* ============================================ */ 00115 00116 quit_get_event = True; 00117 00118 } 00119 00120 /******************************************************************************* 00121 Name: StepCallback 00122 Description: Called when Step is selected form Execution menu 00123 Arguments: w - menu item that was selected 00124 client_data - entry number on menu 00125 call_data - not used 00126 Returns: None 00127 *******************************************************************************/ 00128 void StepCallback( 00129 Widget w, 00130 XtPointer client_data, 00131 XtPointer call_data) 00132 { 00133 /* if(CommandLineData(GetCurrentEnvironment())->EvaluatingTopLevelCommand) 00134 return;*/ 00135 MoveEndOfFile(dialog_text, &TheEvent); 00136 PrintCLIPS("wclips", "(run 1)\n"); 00137 SetCommandString(GetCurrentEnvironment(),"(run 1)\n"); 00138 /* ============================================ */ 00139 /* Set this flag to True to break out of the */ 00140 /* event loop so CLIPS could process the */ 00141 /* command. */ 00142 /* ============================================ */ 00143 00144 quit_get_event = True; 00145 } 00146 00147 /******************************************************************************* 00148 Name: ClearCLIPSCallback 00149 Description: Called when Clear CLIPS is selected form Execution menu 00150 Arguments: w - menu item that was selected 00151 client_data - entry number on menu 00152 call_data - not used 00153 Returns: None 00154 *******************************************************************************/ 00155 void ClearCLIPSCallback( 00156 Widget w, 00157 XtPointer client_data, 00158 XtPointer call_data) 00159 { 00160 Widget confirmshell, confirm; 00161 00162 /* if(CommandLineData(GetCurrentEnvironment())->EvaluatingTopLevelCommand) 00163 return;*/ 00164 confirmshell = XtCreatePopupShell("Confirmation", 00165 topLevelShellWidgetClass, 00166 toplevel, 00167 NULL, 0); 00168 00169 XtSetArg(TheArgs[0], XtNlabel, "Clear CLIPS!\nAre you sure?"); 00170 XtSetArg(TheArgs[1], XtNicon, clips_logo); 00171 confirm = XtCreateManagedWidget("confirm", 00172 dialogWidgetClass, 00173 confirmshell, 00174 TheArgs, 2); 00175 00176 XawDialogAddButton(confirm, "Clear", ClearClips, (XtPointer) confirm); 00177 XawDialogAddButton(confirm, "Cancel", CancelPopupSelect, (XtPointer) confirm); 00178 00179 XtPopup(confirmshell, XtGrabNonexclusive); 00180 00181 /* ============================================ */ 00182 /* Set this flag to True to break out of the */ 00183 /* event loop so CLIPS could process the */ 00184 /* command. */ 00185 /* ============================================ */ 00186 00187 quit_get_event = True; 00188 } 00189 00190 /******************************************************************************* 00191 Name: ResetClips 00192 Description: Calls the command `reset' in CLIPS 00193 Arguments: w - Not Used 00194 client_data - Child of widget to destroy 00195 call_data - Not Used 00196 Returns: None 00197 *******************************************************************************/ 00198 static void ResetClips( 00199 Widget w, 00200 XtPointer client_data, 00201 XtPointer call_data) 00202 { 00203 XtDestroyWidget(XtParent((Widget) client_data)); 00204 PrintCLIPS("wclips","(reset)\n"); 00205 SetCommandString(GetCurrentEnvironment(),"(reset)\n"); 00206 /* ============================================ */ 00207 /* Set this flag to True to break out of the */ 00208 /* event loop so CLIPS could process the */ 00209 /* command. */ 00210 /* ============================================ */ 00211 00212 quit_get_event = True; 00213 } 00214 00215 /******************************************************************************* 00216 Name: ClearClips 00217 Description: Calls the `clear' command in CLIPS 00218 Arguments: w - Not Used 00219 client_data - Not Used 00220 call_data - Not Used 00221 Returns: None 00222 *******************************************************************************/ 00223 static void ClearClips( 00224 Widget w, 00225 XtPointer client_data, 00226 XtPointer call_data) 00227 { 00228 XtDestroyWidget(XtParent((Widget) client_data)); 00229 PrintCLIPS("wclips","(clear)\n"); 00230 SetCommandString(GetCurrentEnvironment(),"(clear)\n"); 00231 /* ============================================ */ 00232 /* Set this flag to True to break out of the */ 00233 /* event loop so CLIPS could process the */ 00234 /* command. */ 00235 /* ============================================ */ 00236 00237 quit_get_event = True; 00238 } 00239 00240 /******************************************************************************* 00241 * ClearScreenCallback 00242 * Description: is called when a clear screen is requested 00243 * Input : unused 00244 *******************************************************************************/ 00245 void ClearScreenCallback( 00246 Widget w, 00247 XtPointer client_data, 00248 XtPointer call_data) 00249 { 00250 int n = 0; 00251 00252 XtSetArg(TheArgs[n],XtNstring,"");n++; 00253 XtSetValues(dialog_text,TheArgs,n); 00254 PrintPrompt(GetCurrentEnvironment()); 00255 } 00256
1.5.6