SGraph.c

Go to the documentation of this file.
00001  /*------------------------------------------------------------------------
00002  *    X11 interface 
00003  *    Copyright (C) 1998-2001 Enpc/Jean-Philippe Chancelier
00004  *    jpc@cermics.enpc.fr 
00005  --------------------------------------------------------------------------*/
00006 
00007 #include <stdio.h>                      /* For the Syntax message */
00008 #include <signal.h>
00009 #include <stdlib.h>
00010 #include <string.h>
00011 
00012 #include "sci_mem_alloc.h"
00013 #include "GetProperty.h"
00014 #include "DestroyObjects.h"
00015 #include "SGraph.h"
00016 #include "xs2file.h" /* for scig_toPs */
00017 #include "Xcall1.h" /* dr_ */
00018 #include "WindowList.h"
00019 #include "Actions.h" /* scig_resize ... */
00020 #include "periWin.h" /* DeleteSGWin */
00021 extern int StoreCommand  __PARAMS((char *command));
00022 
00023 
00025 #ifdef __STDC__
00026 #include <sys/types.h>
00027 #include <unistd.h>
00028 #else 
00029 extern char * getenv();
00030 extern int getpid();
00031 #endif
00032 
00033 #include "math.h"
00034 #include "men_Sutils.h"
00035 #include "men_scilab.h"
00036 #include "All-extern.h"
00037 #include "All-extern-x1.h"
00038 #include "Events.h"
00039 
00040 extern XtAppContext app_con;
00041 
00042 
00043 extern Widget initColors  __PARAMS((Widget));  
00044 extern Window GetBGWindowNumber __PARAMS((int));
00045 extern void DisplayInit __PARAMS((char *string,Display **dpy,Widget *toplevel));
00046 extern void ChangeBandF __PARAMS((int win_num,Pixel fg, Pixel bg));
00047 extern integer F2C(fbutn) __PARAMS((char *,integer*,integer*));
00048 extern void DeleteObjs __PARAMS((int win_num)); /* NG */
00049 extern int demo_menu_activate; /* add a demo menu in the graphic Window */
00050 extern int GetEventWindow(XEvent* event);
00051 /*---------------------------------------------------------------
00052   Functions and buttons associated with the Graphic Scilab Window 
00053   -----------------------------------------------------------------*/
00054 static void ChangeBF1 __PARAMS(( Widget w,     char *str,     Pixel fg,     Pixel bg));
00055 static void SetHints  __PARAMS((Widget topW));  
00056 static int AddNewWin  __PARAMS((int, struct BCG *));
00057 /* static XtEventHandler EventProc  __PARAMS((Widget widget, XtPointer , XEvent *));   */
00058 static XtEventHandler EventProc1  __PARAMS((Widget widget, XtPointer , XEvent *));  
00059 /*static XtEventHandler ResizeWindow  __PARAMS((Widget, XtPointer , XConfigureEvent *));  */
00060 
00061 static void Efface  __PARAMS((Widget, XtPointer , XtPointer ));  
00062 static void Select  __PARAMS((Widget, XtPointer , XtPointer ));  
00063 static void Delete  __PARAMS((Widget, XtPointer , XtPointer ));  
00064 static void Print  __PARAMS((Widget, XtPointer , XtPointer ));  
00065 static void SavePs  __PARAMS((Widget, XtPointer , XtPointer ));  
00066 static void Save  __PARAMS((Widget, XtPointer , XtPointer ));  
00067 static void Load  __PARAMS((Widget, XtPointer , XtPointer ));  
00068 static void Zoom  __PARAMS((Widget, XtPointer , XtPointer ));  
00069 static void UnZoom  __PARAMS((Widget, XtPointer , XtPointer ));  
00070 static void Rot3D  __PARAMS((Widget, XtPointer , XtPointer ));  
00071 static void ChangeBF1  __PARAMS((Widget, char *str, Pixel fg, Pixel bg));  
00072 static void KillButton  __PARAMS((Widget, XtPointer , caddr_t ));  
00073 static void SelMenu  __PARAMS((Widget, XtPointer , caddr_t));
00074 static void SetUnsetMenu  __PARAMS((integer *, char *, integer *, int));  
00075 static void PannerCallback __PARAMS((Widget, XtPointer , XtPointer ));
00076 static void ViewportCallback __PARAMS((Widget, XtPointer , XtPointer ));
00077 static void MoveChild  __PARAMS((Widget viewp, Position x,Position  y));
00078 static int GetChilds __PARAMS((int win_num, int *nc,WidgetList *wL,Widget *outer,char *name,
00079                               int *name_pos) );
00080 static void ignore_events( Widget widget, XEvent *event2,long mask );
00081 
00082 
00083 static char popupname[sizeof("ScilabGraphic")+32];
00084 static Arg args[10] ;
00085 static int iargs=0;
00086 static int MultiClickTime=200;/* to be changed after 3.1rc1, uncomment  also in  CreatePopupWindow below*/
00087 /*
00088  * Fixes hints for the graphic windows (min sizes and wm delete window flag)
00089  */
00090 
00091 static  Atom            wmDeleteWindow;
00092 static  Atom  Close_SG_Window_Activated ;
00093 
00094 static void SetHints(topW)
00095      Widget topW;
00096 {
00097  XSizeHints             size_hints;
00098  size_hints.width       = 600;
00099  size_hints.height      = 400;
00100  size_hints.min_width   = 400;
00101  size_hints.min_height  = 300;
00102  size_hints.flags =  USSize | PMinSize;
00103  XSetNormalHints(XtDisplay(topW),XtWindow(topW), &size_hints);
00104  /*
00105   *  Add a protocol flag indicating we wish to handle
00106   *  WM_DELETE_WINDOW requests (in fact we ignore it)
00107   */
00108  wmDeleteWindow = XInternAtom(XtDisplay(topW), "WM_DELETE_WINDOW", False);
00109  XSetWMProtocols(XtDisplay(topW),XtWindow(topW),&wmDeleteWindow, 1);
00111  Close_SG_Window_Activated = XInternAtom(XtDisplay(topW), 
00112                                          "SCI_DELETE_WINDOW", False);
00113 }
00114 
00117 int IswmDeleteWindow(XEvent *event) 
00118 {
00119   return event->type == ClientMessage &&
00120     event->xclient.data.l[0] == (int)wmDeleteWindow ;
00121 }
00122 
00126 int IsCloseSGWindow(XEvent *event)
00127 {
00128   if ( event->type == ClientMessage &&
00129        ((XClientMessageEvent *)event)->message_type == Close_SG_Window_Activated )
00130     return event->xclient.data.l[0];
00131   else
00132     return -1;
00133 }
00134 
00135 /* Following variables are used for click, double-click detection
00136  * the associated code comes from the wx_canvs.cc code written by Julian Smart 1993
00137  * http://www.mit.edu/afs/athena/astaff/project/bugsquash/wx/src/x/wx_canvs.cc
00138  */
00139 static Bool wait_dclick = FALSE;
00140 static Bool dclick = FALSE;
00141 static Bool lose_up = FALSE;
00142 static long timerId;
00143 static void
00144 reset_click_counter (XtPointer ptr)
00145 {
00146   dclick = FALSE;
00147   wait_dclick = FALSE;
00148 }
00149 
00150 
00151 void
00152 btn_pressed(Widget widget, XEvent*      event, String*  params, Cardinal*       num_params)
00153 {
00154   
00155   /* The following instruction has been commented out not to lose btn_pressed 
00156      emited just before an xclick or xgemouse call
00157     if (!get_wait_click()) return;
00158   */
00159 
00160   if (wait_dclick) {
00161    /* If we are waiting for a double-click, we only handle Button events
00162       in a special fashion.*/
00163       wait_dclick = FALSE;
00164       dclick = TRUE;
00165       lose_up = FALSE;
00166       XtRemoveTimeOut (timerId);
00167       return;
00168  }
00169   timerId = XtAppAddTimeOut(app_con, MultiClickTime,
00170                              (XtTimerCallbackProc) reset_click_counter, (XtPointer) NULL);
00171   wait_dclick = TRUE;
00172   lose_up = FALSE;
00173   dclick = FALSE;
00174 
00175   /*Wait until wait_dclick becomes FALSE 
00176     - either because of two consecutive btn press
00177     - either because of timeout 
00178     - either because of a mouse move  */
00179   do {
00180     if (XtAppPending (app_con))
00181       XtAppProcessEvent (app_con, XtIMAll);
00182   }  while (wait_dclick); 
00183 
00184   /* So here, dclick&lose_up have correct values.*/
00185 
00186   if (dclick ) { /* double click detected [10 11 12]*/
00187      PushClickQueue(GetEventWindow(event),event->xbutton.x,
00188                      event->xbutton.y,
00189                      event->xbutton.button-1+10,0,0);
00190   }
00191   else  {
00192     if  (lose_up) { /* simple click detected [3 4 5]*/
00193       if (params[0][0]=='0')
00194         PushClickQueue(GetEventWindow(event),event->xbutton.x,
00195                        event->xbutton.y,
00196                        event->xbutton.button-1+3,0,0);
00197       else if (params[0][0]=='1') /*shift press*/
00198         PushClickQueue(GetEventWindow(event),event->xbutton.x,
00199                        event->xbutton.y,
00200                        event->xbutton.button-1+3+2000,0,0);
00201       else if (params[0][0]=='2') /*ctrl press*/
00202         PushClickQueue(GetEventWindow(event),event->xbutton.x,
00203                        event->xbutton.y,
00204                        event->xbutton.button-1+3+1000,0,0);
00205 
00206       lose_up = FALSE;
00207       
00208     }
00209     else { /* button pressed detected [0 1 2]*/
00210       if (params[0][0]=='0')
00211         PushClickQueue(GetEventWindow(event),event->xbutton.x,
00212                        event->xbutton.y,
00213                        event->xbutton.button-1,0,0);
00214       else if (params[0][0]=='1') /*shift press*/
00215         PushClickQueue(GetEventWindow(event),event->xbutton.x,
00216                        event->xbutton.y,
00217                        event->xbutton.button-1+2000,0,0);
00218       else if (params[0][0]=='2') /*ctrl press*/
00219         PushClickQueue(GetEventWindow(event),event->xbutton.x,
00220                        event->xbutton.y,
00221                        event->xbutton.button-1+1000,0,0);
00222 
00223     }
00224    
00225  }
00226 
00227 
00228 
00229 }
00230 
00231 void
00232 btn_released(Widget     widget, XEvent* event,String*   params, Cardinal*       num_params)
00233 {
00234   if (wait_dclick) {
00235     lose_up = TRUE;
00236     return;
00237   }
00238   if (dclick)  return;
00239  /* button released detected [-5 -4 -3]*/
00240   PushClickQueue(GetEventWindow(event),event->xbutton.x,
00241                  event->xbutton.y,
00242                  event->xbutton.button-6,0,1);
00243 }
00244 
00245 void
00246 ctrl_key(Widget widget, XEvent* event, String*  params, Cardinal*       num_params)
00247 {
00248   char buf[10];
00249   int ten=10;
00250   KeySym keysym;
00251   XComposeStatus compose_status = {NULL, 0};
00252   XLookupString((XKeyEvent *)&(event->xkey), buf, 
00253                 ten, &keysym,&compose_status);
00254   /* <Ctrl> key  detected return  )keysym+1000 */
00255   PushClickQueue(GetEventWindow(event),event->xkey.x,
00256                  event->xkey.y,(int)keysym+1000,0,0);
00257 }
00258 
00259 void
00260 key_pressed(Widget      widget, XEvent* event, String*  params, Cardinal*       num_params)
00261 {
00262   char buf[10];
00263   int ten=10;
00264   KeySym keysym;
00265   XComposeStatus compose_status = {NULL, 0};
00266   XLookupString((XKeyEvent *)&(event->xkey), buf, 
00267                 ten, &keysym,&compose_status);
00268   if ((int)keysym < XK_Shift_L ||(int)keysym ==XK_Delete ){
00269     /* regular key pressed detected. return  keysym */
00270     PushClickQueue(GetEventWindow(event),event->xkey.x,
00271                    event->xkey.y,(int)keysym,0,0);
00272   }
00273 }
00274 void
00275 key_released(Widget     widget,XEvent*  event, String*  params, Cardinal*       num_params)
00276 {
00277   char buf[10];
00278   int ten=10;
00279   KeySym keysym;
00280   XComposeStatus compose_status = {NULL, 0};
00281   XLookupString((XKeyEvent *)&(event->xkey), buf, 
00282                 ten, &keysym,&compose_status);
00283   if ((int)keysym <65000) {
00284     /* regular key released detected. return  -keysym */
00285     PushClickQueue(GetEventWindow(event),event->xkey.x,
00286                    event->xkey.y,-(int)keysym,0,1);
00287   }
00288 }
00289 void
00290 mouse_moved(Widget      widget, XEvent* event, String*  params, Cardinal*       num_params)
00291 {
00292   /*ignore_events(widget,&event2, ExposureMask) ;*/
00293   if (wait_dclick) { /*move during a double click detection*/
00294     wait_dclick=FALSE;
00295     XtRemoveTimeOut (timerId);
00296     return;
00297   }
00298   PushClickQueue(GetEventWindow(event),event->xbutton.x,
00299                  event->xbutton.y,
00300                  -1,1,0);
00301 }
00302 
00303 /*
00304 <Btn1Motion>:MouseMoved(1)\n\
00305 
00306  */
00307 
00308 static XtActionsRec event_actions[] =
00309 {
00310     {"BtnPressed", (XtActionProc) btn_pressed},
00311     {"BtnReleased", (XtActionProc) btn_released},
00312     {"CtrlKey", (XtActionProc) ctrl_key},
00313     {"KeyPressed", (XtActionProc) key_pressed},
00314     {"KeyReleased", (XtActionProc) key_released},
00315     {"MouseMoved", (XtActionProc) mouse_moved},
00316 };
00317 
00318 static String   event_translations =
00319 "\
00320 <MouseMoved>:MouseMoved()\n\
00321 Ctrl<Key>:CtrlKey()\n\
00322 !Shift<KeyDown>:KeyPressed(1)\n\
00323 !Lock<KeyDown>:KeyPressed(1)\n\
00324 !Lock Shift <KeyDown>:KeyPressed(0)\n\
00325 None<KeyDown>:KeyPressed(0)\n\
00326 !Shift<KeyUp>:KeyReleased(1)\n\
00327 !Lock<KeyUp>:KeyReleased(1)\n\
00328 !Lock Shift<KeyUp>:KeyReleased(1)\n\
00329 None<KeyUp>:KeyReleased(0)\n\
00330 <BtnUp>:BtnReleased()\n\
00331 !Shift<BtnDown>:BtnPressed(1)\n\
00332 !Ctrl<BtnDown>:BtnPressed(2)\n\
00333 <BtnDown>:BtnPressed(0)\n\
00334 ";
00335 /*
00336  * Creates a new graphic window 
00337  */
00338 #define DEFAULT_MES "graphic window"
00339 
00340 static int AddNewWin( int popupc,   struct BCG *ScilabXgc)
00341 {
00342   Widget bbox,color;
00343   Widget outer,zoom_,rot3d,unzoom_,sel,menuform;
00344   Widget filebutton,filemenu,clear,prnt,save,load,delete,saveps;
00345 
00346   iargs=0;
00347   /* eventually add a box to check for visual type */
00348   color = initColors(ScilabXgc->popup); 
00349   outer = XtCreateManagedWidget( "scigForm", panedWidgetClass,
00350                                  color,
00351                                  args, iargs);
00352 
00354   iargs = 0;
00355   menuform = XtCreateManagedWidget( "scigmForm", formWidgetClass,outer,
00356                                   args, iargs);
00357 
00358   ScilabXgc->Panner = XtCreateManagedWidget("Panner", pannerWidgetClass, 
00359                                  menuform , NULL, ZERO);
00360 
00361   iargs=0;
00362   XtSetArg(args[iargs], XtNlabel," ");iargs++;
00363   ScilabXgc->CinfoW = XtCreateManagedWidget("scigraphicinfo",labelWidgetClass, 
00364                                      menuform, args, iargs);
00365 
00367   /* Menu File */
00368   iargs=0;
00369   filebutton = XtCreateManagedWidget("File",
00370                                   menuButtonWidgetClass,menuform,args, iargs);
00371   iargs=0;
00372   filemenu = XtCreatePopupShell("menu", simpleMenuWidgetClass, 
00373                             filebutton,args, iargs);
00374   iargs=0;
00375   clear = XtCreateManagedWidget("Clear", smeBSBObjectClass,filemenu,args, iargs);
00376   XtAddCallback(clear, XtNcallback,(XtCallbackProc) Efface,(XtPointer) popupc); 
00377   sel = XtCreateManagedWidget("Select", smeBSBObjectClass,filemenu,args, iargs);
00378   XtAddCallback(sel, XtNcallback,(XtCallbackProc) Select,(XtPointer) popupc); 
00379   prnt = XtCreateManagedWidget("Print", smeBSBObjectClass,filemenu,args, iargs);
00380   XtAddCallback(prnt, XtNcallback,(XtCallbackProc)  Print,(XtPointer) popupc);
00381   saveps = XtCreateManagedWidget("Export", smeBSBObjectClass,filemenu,args, iargs);
00382   XtAddCallback(saveps, XtNcallback,(XtCallbackProc)  SavePs,(XtPointer)popupc);
00383   save = XtCreateManagedWidget("Save", smeBSBObjectClass,filemenu,args, iargs);
00384   XtAddCallback(save, XtNcallback,(XtCallbackProc)  Save,(XtPointer)popupc);
00385   load = XtCreateManagedWidget("Load", smeBSBObjectClass,filemenu,args, iargs);
00386   XtAddCallback(load, XtNcallback,(XtCallbackProc)  Load,(XtPointer)popupc);
00387   delete = XtCreateManagedWidget("Close", smeBSBObjectClass,filemenu,args, iargs);
00388   XtAddCallback(delete, XtNcallback,(XtCallbackProc)  Delete,(XtPointer)popupc);
00389   
00390   /* Other buttons */
00391   zoom_ = XtCreateManagedWidget("Zoom", commandWidgetClass,menuform,args, iargs);
00392   XtAddCallback(zoom_, XtNcallback,(XtCallbackProc)  Zoom,
00393                 (XtPointer) popupc);
00394   unzoom_ = XtCreateManagedWidget("UnZoom", commandWidgetClass,menuform,args, iargs);
00395   XtAddCallback(unzoom_, XtNcallback,(XtCallbackProc)  UnZoom,
00396                 (XtPointer) popupc);
00397   rot3d = XtCreateManagedWidget("Rot3D", commandWidgetClass,menuform,args, iargs);
00398   XtAddCallback(rot3d, XtNcallback,(XtCallbackProc) Rot3D,
00399                 (XtPointer) popupc);
00400 
00403   iargs =0;
00404 
00405   ScilabXgc->Viewport = XtCreateManagedWidget("graphicviewport",viewportWidgetClass,outer,args,iargs);
00406 
00407   bbox= XtCreateManagedWidget("bbox",boxWidgetClass,ScilabXgc->Viewport, args, iargs);
00408 
00409   /* I use a label in order to have foreground and background */
00410   iargs=0;
00411   XtSetArg(args[iargs], XtNlabel," ");iargs++;
00412   ScilabXgc->drawbox= XtCreateManagedWidget("scigraphic",labelWidgetClass,bbox, args, iargs);
00413 
00414   /* EventProc Must select the client Message Events */
00415 
00416   XtAddEventHandler(ScilabXgc->drawbox, ExposureMask| StructureNotifyMask,
00417                     False,
00418                     (XtEventHandler) EventProc1,
00419                     (XtPointer) popupc);  
00420 
00421   /* even if EventProc is unused by xclick or xgetmouse : the next line 
00422      set the proper mask for the drawbox window and this is necessary for 
00423      xclick and xgetmouse to work. Moreover this EventHandler keeps the 
00424      queue of unused events ok 
00425   */
00426 
00427   /* XtAddEventHandler(ScilabXgc->drawbox, 
00428                     ButtonPressMask|PointerMotionMask|ButtonReleaseMask|
00429                     KeyPressMask|KeyReleaseMask,False,
00430                     (XtEventHandler) EventProc, (XtPointer) popupc); */
00431 
00432   XtOverrideTranslations(ScilabXgc->drawbox,
00433                  XtParseTranslationTable(event_translations));
00434   XtAppAddActions(app_con, event_actions, XtNumber(event_actions));
00435 
00438   XtAddCallback( ScilabXgc->Viewport,
00439                 XtNreportCallback, ViewportCallback, (XtPointer) ScilabXgc);
00440   XtAddCallback(ScilabXgc->Panner, 
00441                 XtNreportCallback, PannerCallback, (XtPointer) ScilabXgc);
00442 
00443   /* For Graphic demo */
00444   if ( demo_menu_activate == 1 )  AddNewMenu(outer,ScilabXgc->drawbox);
00445   return(0);
00446 }
00447 
00448 
00449 /*      Function Name: PannerCallback
00450  *      Description: called when the slider is moved inside the panner 
00451  *      Arguments: w - the panner widget.
00452  *                 scigc_ptr -  scilabgc associated to win .
00453  *                 report_ptr - the panner record.
00454  *      Returns: none.
00455  */
00456 
00457 
00458 /* ARGSUSED */
00459 void PannerCallback(w, scigc_ptr , report_ptr)
00460      Widget w;
00461      XtPointer scigc_ptr, report_ptr;
00462 {
00463   struct BCG *ScilabXgc = ((struct BCG *) scigc_ptr);
00464   Widget viewport = ScilabXgc->Viewport;
00465   XawPannerReport *report = (XawPannerReport *) report_ptr;
00466   MoveChild(viewport, report->slider_x ,report->slider_y);
00467 }
00468 
00469 
00470 void SciViewportMove(struct BCG *ScilabXgc, int x, int y)
00471      
00472 {
00473   Widget viewport,panner;
00474   Cardinal n=0;
00475   if ( ScilabXgc != NULL) 
00476     {
00477       viewport = ScilabXgc->Viewport;
00478       panner = ScilabXgc->Panner;
00479       MoveChild(viewport,x,y);
00480       XtSetArg (args[n], XtNsliderX, x); n++;  
00481       XtSetArg (args[n], XtNsliderY, y); n++;
00482       XtSetValues (panner, args, n);
00483     }
00484 }
00485 
00486 
00487 
00488 void SciViewportGet(struct BCG *ScilabXgc, int *x, int *y)
00489 {
00490   Widget panner;
00491   Cardinal n=0;
00492   if ( ScilabXgc != NULL) 
00493     {
00494       Dimension dx,dy;
00495       panner = ScilabXgc->Panner;
00496       XtSetArg (args[n], XtNsliderX, &dx); n++;  
00497       XtSetArg (args[n], XtNsliderY, &dy); n++;
00498       XtGetValues (panner, args, n);
00499       *x = dx; *y=dy;
00500     }
00501   else
00502     {
00503       *x=0;*y=0;
00504     }
00505 }
00506 
00507 /*      Function Name: SciViewportClipGetSize
00508  *      Description: used to get clip size 
00509  *      Arguments: ScilabXgc : structure associated to a Scilab Graphic window
00510  *                 w,h : returned size ;
00511  */
00512 
00513 void SciViewportClipGetSize(struct BCG *ScilabXgc,int *w,int *h)
00514 {
00515   if ( ScilabXgc != NULL) 
00516     {
00517       ViewportWidget widg = (  ViewportWidget ) ScilabXgc->Viewport;
00518       register Widget clip = widg->viewport.clip;
00519       *w = clip->core.width;
00520       *h = clip->core.height;
00521     }
00522 }
00523 
00524 /*      Function Name: ViewportCallback
00525  *      Description: called when the viewport or its child has
00526  *                   changed 
00527  *      Arguments: viewport - the viewport widget.
00528  *                 scigc_ptr -  scilabgc associated to win .
00529  *                 report_ptr - the viewport record.
00530  *      Returns: none.
00531  */
00532 
00533 extern void sci_pixmap_resize(struct BCG *Xgc,int x,int y);
00534 
00535 /* ARGSUSED */
00536 
00537 
00538 void ViewportCallback(Widget w,XtPointer scigc_ptr, XtPointer report_ptr)
00539 {
00540   Dimension cwidth,cheight,clwidth,clheight,gwidth,gheight;
00541   ViewportWidget viewpw = (  ViewportWidget ) w;
00542   register Widget clip = viewpw->viewport.clip;
00543   register Widget child = viewpw->viewport.child;
00544 
00545   Cardinal n = 0;
00546   XawPannerReport *report = (XawPannerReport *) report_ptr;
00547   struct BCG *ScilabXgc = ((struct BCG *) scigc_ptr);
00548   Widget panner = ScilabXgc->Panner;
00549   
00550 
00551   if ( ScilabXgc->CurResizeStatus  == 0) 
00552     {
00553 
00554       XtSetArg (args[n], XtNsliderX, report->slider_x); n++;
00555       XtSetArg (args[n], XtNsliderY, report->slider_y); n++;
00556       if (report->changed != (XawPRSliderX | XawPRSliderY)) {
00557         XtSetArg (args[n], XtNsliderWidth, report->slider_width); n++;
00558         XtSetArg (args[n], XtNsliderHeight, report->slider_height); n++;
00559         XtSetArg (args[n], XtNcanvasWidth, report->canvas_width); n++;
00560         XtSetArg (args[n], XtNcanvasHeight, report->canvas_height); n++;
00561         /*
00562           fprintf(stderr,"new reported %d %d %d %d \n",report->slider_width, report->slider_height,
00563           report->canvas_width, report->canvas_height);
00564         */
00565       }
00566       XtSetValues (panner, args, n);
00567 
00571       iargs = 0 ;
00572       XtSetArg (args[iargs], XtNwidth, &cwidth ); iargs++;
00573       XtSetArg (args[iargs], XtNheight, &cheight); iargs++;
00574       XtGetValues (child, args, iargs);
00575       iargs = 0;
00576       XtSetArg (args[iargs], XtNwidth, &clwidth ); iargs++;
00577       XtSetArg (args[iargs], XtNheight, &clheight); iargs++;
00578       XtGetValues (clip, args, iargs);
00579 
00580       if (  ScilabXgc->drawbox != NULL) 
00581         {
00582           int nw,nh;
00583           iargs = 0;
00584           XtSetArg (args[iargs], XtNwidth, &gwidth ); iargs++;
00585           XtSetArg (args[iargs], XtNheight, &gheight); iargs++;
00586           XtGetValues (ScilabXgc->drawbox, args, iargs);
00587           nw= Max(gwidth,clwidth);
00588           nh= Max(gheight,clheight);
00589           if ( nw < cwidth || nh < cheight )
00590             {
00591               XtResizeWidget(child,nw,nh,0);
00592               n=0;
00593               XtSetArg (args[n], XtNcanvasWidth, nw); n++;
00594               XtSetArg (args[n], XtNcanvasHeight,nh); n++;
00595               XtSetValues (panner, args, n);
00596             }
00597         }
00598     }
00599   else
00600     {
00605       iargs = 0 ;
00606       XtSetArg (args[iargs], XtNwidth, &cwidth ); iargs++;
00607       XtSetArg (args[iargs], XtNheight, &cheight); iargs++;
00608       XtGetValues (child, args, iargs);
00609       iargs = 0;
00610       XtSetArg (args[iargs], XtNwidth, &clwidth ); iargs++;
00611       XtSetArg (args[iargs], XtNheight, &clheight); iargs++;
00612       XtGetValues (clip, args, iargs);
00613       if (   ScilabXgc->drawbox != NULL) 
00614         {
00615           /* We resize Scilab drawbox and update window dimensions */
00616           XtResizeWidget(ScilabXgc->drawbox,clwidth,clheight,0);
00617           ScilabXgc->CWindowWidth  = clwidth;
00618           ScilabXgc->CWindowHeight = clheight;
00619           XtResizeWidget(child,clwidth,clheight,0);
00620           /* if necessary we must resize the pixmap */
00621           if (ScilabXgc->Cdrawable != (Drawable) NULL) /* ScilabXgc->CWindow ) */
00622             {
00623               /* here the best stuff to do is a scig_resize 
00624                * scig_resize(ScilabXgc->CurWindow); 
00625                * unfortunately this callback is called too 
00626                * frequently when resizing and scig_resize can be slow 
00627                * thus we just resize the window pixmap 
00628                * and set a flag.
00629                * Thus the last expose will have to properly redraw the window
00630                */
00631               /* will be done by expose 
00632                  sci_pixmap_resize(ScilabXgc,ScilabXgc->CWindowWidth, 
00633                  ScilabXgc->CWindowHeight);
00634               */
00635               ScilabXgc->Cdrawable_flag=1;
00636             }
00637           n=0;
00638           XtSetArg (args[n], XtNsliderWidth, clwidth); n++;
00639           XtSetArg (args[n], XtNsliderHeight,clheight); n++;
00640           XtSetArg (args[n], XtNcanvasWidth, clwidth); n++;
00641           XtSetArg (args[n], XtNcanvasHeight,clheight); n++;
00642           XtSetValues (panner, args, n);
00643         }
00644     }
00645 }
00646 
00647 void SetBar(Widget w, Position top, Dimension length, Dimension total)
00648 {
00649   XawScrollbarSetThumb(w, (float) top / (float) total, 
00650                        (float) length / (float) total );
00651 }
00652 
00653 /* reposition viewport bars */
00654 
00655 void RedrawThumbs(ViewportWidget w)
00656 {
00657   register Widget child = w->viewport.child;
00658   register Widget clip = w->viewport.clip;
00659 
00660   if (w->viewport.horiz_bar)
00661     SetBar( w->viewport.horiz_bar, -(child->core.x),
00662            clip->core.width, child->core.width );
00663 
00664   if (w->viewport.vert_bar)
00665     SetBar( w->viewport.vert_bar, -(child->core.y),
00666            clip->core.height, child->core.height );
00667 }
00668 
00669 /* move the child of the viewport */
00670 
00671 static void MoveChild(Widget viewp, Position x, Position y)
00672 {
00673   ViewportWidget w =   (ViewportWidget) viewp;
00674   register Widget child = w->viewport.child;
00675   register Widget clip = w->viewport.clip;
00676 
00677   /* make sure we never move past right/bottom borders */
00678   if ((int) (x + clip->core.width) > (int) child->core.width)
00679     x = child->core.width - clip->core.width;
00680 
00681   if ((int) (y + clip->core.height) > (int ) child->core.height)
00682     y = child->core.height - clip->core.height;
00683 
00684   /* make sure we never move past left/top borders */
00685   if (x < 0) x = 0;
00686   if (y < 0) y = 0;
00687 
00688   XtMoveWidget(child, - x, - y);
00689   RedrawThumbs(w);
00690 }
00691 
00694 #define WINMINW 100 
00695 #define WINMINH 100 
00696 
00697 void GViewportResize(struct BCG *ScilabXgc, int *width,int *height)
00698 {
00699   int Width = Max(*width,  WINMINW);
00700   int Height= Max(*height, WINMINH);
00701   Position x,y;
00702   Dimension cwidth,cheight,clwidth,clheight,wv,hv;
00703   ViewportWidget w = (  ViewportWidget ) ScilabXgc->Viewport;
00704   register Widget clip = w->viewport.clip;
00705   register Widget child = w->viewport.child;
00706 
00707   if ( ScilabXgc->CurResizeStatus == 0) 
00708     {
00710       XtResizeWidget(ScilabXgc->drawbox ,Width,Height,0);
00712       if (ScilabXgc->Cdrawable != (Drawable) 0 ) /* ScilabXgc->CWindow ) */
00713         {
00714           sci_pixmap_resize(ScilabXgc,Width,Height);
00715         }
00716       /*
00717        * Resize the viewport child which contains the graphic widget 
00718        * we don't want the viewport child to be smaller than the 
00719        * clip region 
00720        */
00721       wv = Max(Width,clip->core.width);
00722       hv = Max(Height,clip->core.height);
00723       XtResizeWidget(child,wv,hv,0);
00724       RedrawThumbs(w);
00725       
00728       iargs = 0 ;
00729       XtSetArg (args[iargs], XtNx, &x); iargs++;
00730       XtSetArg (args[iargs], XtNy, &y); iargs++;
00731       XtSetArg (args[iargs], XtNwidth, &cwidth ); iargs++;
00732       XtSetArg (args[iargs], XtNheight, &cheight); iargs++;
00733       XtGetValues (child, args, iargs);
00735       iargs = 0 ;
00736       XtSetArg (args[iargs], XtNwidth, &clwidth ); iargs++;
00737       XtSetArg (args[iargs], XtNheight, &clheight); iargs++;
00738       XtGetValues (clip, args, iargs);
00741       iargs =0;
00742       XtSetArg (args[iargs], XtNsliderX, -x); iargs++;
00743       XtSetArg (args[iargs], XtNsliderY, -y); iargs++;
00744       XtSetArg (args[iargs], XtNsliderWidth, clwidth ); iargs++;
00745       XtSetArg (args[iargs], XtNsliderHeight, clheight); iargs++;
00746       XtSetArg (args[iargs], XtNcanvasWidth,  cwidth); iargs++;
00747       XtSetArg (args[iargs], XtNcanvasHeight,  cheight); iargs++;
00750       XtSetValues (ScilabXgc->Panner, args, iargs);
00751     }
00752   else
00753     {
00754       /* 
00755        * in order to resize the drawbox, we must resize the 
00756        * popup window.
00757        */
00758       iargs =0;
00759       XtSetArg (args[iargs], XtNwidth, &clwidth ); iargs++;
00760       XtSetArg (args[iargs], XtNheight, &clheight); iargs++;
00761       XtGetValues (ScilabXgc->popup, args, iargs);
00762       iargs =0;
00763       XtSetArg (args[iargs], XtNwidth, &cwidth ); iargs++;
00764       XtSetArg (args[iargs], XtNheight, &cheight); iargs++;
00765       XtGetValues (ScilabXgc->drawbox, args, iargs);
00766       /* we add to Width and Height the expected offset 
00767        * the drawbox can be bigger than the popup if 
00768        * we are comming back from a ScilabXgc->CurResizeStatus==0 state 
00769        */
00770       clwidth = Width  + Max(0,(int)clwidth - (int)cwidth);
00771       clheight= Height + Max(0,(int)clheight - (int)cheight);
00772       iargs = 0;
00773       XtSetArg (args[iargs], XtNwidth, clwidth ); iargs++;
00774       XtSetArg (args[iargs], XtNheight,clheight); iargs++;
00775       XtSetValues (ScilabXgc->popup, args, iargs);
00777       if (ScilabXgc->Cdrawable != (Drawable) 0 ) /* ScilabXgc->CWindow ) */
00778         {
00780           iargs =0;
00781           XtSetArg (args[iargs], XtNwidth, &cwidth ); iargs++;
00782           XtSetArg (args[iargs], XtNheight, &cheight); iargs++;
00783           XtGetValues (ScilabXgc->drawbox, args, iargs);
00784           sci_pixmap_resize(ScilabXgc,cwidth,cheight); 
00785           /* scig_resize(ScilabXgc->CurWindow);  */
00786         }
00787     }
00788 }
00789 
00791 void GPopupResize(struct BCG *ScilabXgc, int *width,int *height)
00792 {
00793   Dimension clwidth = Max(*width,  WINMINW);
00794   Dimension clheight= Max(*height, WINMINH);
00795   if ( ScilabXgc->popup!=(Widget)0) { /* check if it is not a tk canvas */
00796     iargs = 0;
00797     XtSetArg (args[iargs], XtNwidth, clwidth ); iargs++;
00798     XtSetArg (args[iargs], XtNheight,clheight); iargs++;
00799     XtSetValues (ScilabXgc->popup, args, iargs);
00800   }
00801 }
00802 
00803 /* 
00804  * Checking events in the Graphic Window 
00805  * in fact just the XtAddEventHandler is used 
00806  * used in xclick 
00807  * We keep the last  MaxCB click events on a queue just in case 
00808  * xclick wants them ( xclick(1)) 
00809  */
00810 
00811 
00812 #ifdef  EPDEBUG
00813 #define FDEBUG(x) fprintf x 
00814 #else 
00815 #define FDEBUG(x) 
00816 #endif 
00817 
00818 
00819 static void ignore_events( Widget widget, XEvent *event2,long mask )
00820 {
00821   while (XCheckWindowEvent(XtDisplay(widget),XtWindow(widget),mask ,event2)==True)
00822     { 
00823       FDEBUG((stderr,"inside ignore_events count = %d\n",((XExposeEvent *) event2)->count));
00824     }
00825 }
00826 
00827 
00828 
00829 /* static XtEventHandler */
00830 /* EventProc( Widget widget, XtPointer number, XEvent *event) */
00831 /* { */
00832 /*   /\*EventWindow = (int)number;*\/ */
00833 /*   return(0); */
00834 /* } */
00835 
00836 
00837 /*******************************************************
00838  * StructureNotifyMask | ExposureMask  Handler for graphic windows
00839  *******************************************************/
00840 
00841 #ifdef  EP1DEBUG
00842 #define FDEBUG_EP1(x) fprintf x 
00843 #else 
00844 #define FDEBUG_EP1(x) 
00845 #endif 
00846 
00847 
00848 static XtEventHandler 
00849 EventProc1( Widget widget,  XtPointer number,  XEvent *event)
00850 {
00851   XEvent event2;
00852   integer win_num= (integer) number;
00853   XExposeEvent *event1;
00854 #ifdef EP1DEBUG
00855   static int counter=0;
00856   counter++;
00857 #endif 
00858   switch (event->type) 
00859     {
00860     case Expose :
00862       event1= (XExposeEvent *) event;
00863       /* 
00864          FDEBUG_EP1((stderr,"EventProc1: Expose: count %d x %d y %d width %d height %d\n",
00865          event1->count ,event1->x,event1->y,event1->width,event1->height));
00866       */
00867       if ( event1->count == 0) 
00868         {
00869           struct BCG *SciGc =  getWindowXgcNumber(win_num );
00870           if ( SciGc->Cdrawable_flag ==  1) 
00871             {
00872               FDEBUG_EP1((stderr,"EventProc1: Expose: --> scig_resize %d \r\n",counter)); 
00873               SciGc->Cdrawable_flag = 0;
00874               scig_resize(win_num);
00875             }
00876           else 
00877             {
00878               FDEBUG_EP1((stderr,"EventProc1: Expose: --> scig_expose %d \r\n",counter)); 
00879               scig_expose(win_num);
00880             }
00881           ignore_events(widget,&event2, ExposureMask | StructureNotifyMask) ;
00882         }
00883       break;
00884     case VisibilityNotify :
00885       /* We should get there only if server does not performs save_under */
00886       FDEBUG_EP1((stderr,"EventProc1: VisibilityNotify\n"));
00887       break;
00888     case ConfigureNotify :
00889       FDEBUG_EP1((stderr,"EventProc1: ConfigureNotify %d \n",counter));
00890       scig_resize(win_num);
00892       ignore_events(widget,&event2, ExposureMask | StructureNotifyMask);
00893       break; 
00894     case CreateNotify  :
00895       FDEBUG_EP1((stderr,"EventProc1: CreateNotify\r\n",counter));
00896       break ;
00897     case MapNotify : 
00898       FDEBUG_EP1((stderr,"EventProc1: MapNotify\r\n",counter)); 
00900       ignore_events(widget,&event2, ExposureMask );
00901       break;
00902     case ReparentNotify :
00903       FDEBUG_EP1((stderr,"EventProc1: ReparentNotify\r\n"));
00904       break;
00905     default:
00906       FDEBUG_EP1((stderr,"EventProc1: default, event=%d window=%d\r\n",event->type,(int) win_num));
00907       return(0);
00908     }
00909   return(0);
00910 }
00911 
00912 
00913 /**************************************************************
00914  *
00915  * To clear the graphic window and clear the recorded graphics 
00916  * w and client_data are unused 
00917  * 
00918  *************************************************************/
00919 
00920 static void 
00921 Efface(w, number, client_data)
00922      Widget w;
00923      XtPointer number;
00924      XtPointer client_data;
00925 {
00926   integer win_num = (integer) number ;
00927   scig_erase(win_num);
00928 }
00929 
00930 /**************************************************************
00931  *
00932  * To select the graphic window 
00933  * 
00934  *************************************************************/
00935 
00936 static void
00937 Select(w, number, client_data)
00938      Widget w;
00939      XtPointer number;
00940      XtPointer client_data;
00941 {
00942   integer win_num = (integer) number ;
00943   scig_sel(win_num);
00944 }
00945 
00946 /*
00947  * send a ClientMessage to say that we have 
00948  * deleted a graphic window ( used in xclick_any)
00949  */
00950 
00951 /* static void SendSGDeleteMessage(int win_num) */
00952 /* { */
00953 /*   Window Win; */
00954 /*   Widget toplevel; */
00955 /*   Display * dpy; */
00956 /*   XClientMessageEvent ev; */
00957 /*   DisplayInit("",&dpy,&toplevel); */
00958 /*   Win=GetBGWindowNumber(win_num); */
00959 /*   /\** sending a message for xclick_any **\/ */
00960 /*   ev.type = ClientMessage; */
00961 /*   ev.window = Win; */
00962 /*   ev.message_type = Close_SG_Window_Activated; */
00963 /*   ev.format = 32; */
00964 /*   ev.data.l[0] =  win_num; */
00965 /*   ev.data.l[1] =  CurrentTime;  */
00966 /*   XSendEvent (dpy,Win , False, 0L, (XEvent *) &ev); */
00967 /* }  */ 
00968 
00969 
00970 /*------------------------------------------------------------------
00971  * Delete Window 
00972  *------------------------------------------------------------------*/
00973 
00974 
00975 extern int  get_xclick_client_message_flag(void);
00976  
00977 static void
00978 Delete(Widget w, XtPointer number, XtPointer client_data)
00979 {
00980   int v_flag = 1;
00981   integer win_num = (integer) number ;
00982   if (  get_delete_win_mode() == 1 )
00983     {
00984       wininfo("Cannot destroy window while acquiring zoom rectangle ");
00985       return;
00986     }
00987   if ( get_xclick_client_message_flag() == 1 ) 
00988     {
00989       /* the client message is only used while waiting for 
00990        * a mouse click 
00991        */
00992       PushClickQueue(win_num,0,0,-100,0,0);
00993     }
00995   Efface((Widget) 0,(XtPointer) number, (XtPointer) 0);
00996   DeleteObjs(win_num);
00997   v_flag = 0;
00998   scig_deletegwin_handler(win_num);
00999   DeleteSGWin(win_num); /* Here we 1) destroy the ScilabXgc (set to NULL) if it is the last window in the list */
01000                         /*         2) or reset the ScilabXgc to the next one see DeleteSGWin*/
01001 
01002   /* So, we use another flag named v_flag :*/
01003   delete_sgwin_entities(win_num);
01004 }
01005 
01006 /* for Fortran call */
01007 
01008 int C2F(deletewin)(integer *number) {
01009   Delete((Widget) 0,(XtPointer) *number,(XtPointer) 0);
01010   return(0);
01011 }
01012 
01013 
01014 /*********************************************************
01015  * Replot in Postscript style and send to printer 
01016  ********************************************************/
01017 
01018 static  char bufname[256];
01019 static  char printer[128];
01020 static  char file[256];
01021 
01022 static void
01023 Print(Widget w,XtPointer number, XtPointer client_data)
01024 {
01025   char *p1;
01026   integer win_num = (integer) number ;
01027   integer colored,orientation,flag=1,ok;
01028 
01029   prtdlg(&flag,printer,&colored,&orientation,file,&ok);
01030   if (ok==1) 
01031     {
01032       if ( ( p1 = getenv("TMPDIR"))  == (char *) 0 )
01033         {
01034           sciprint("Cannot find environment variable TMPDIR\r\n");
01035         }
01036 
01037       sprintf(bufname,"%s/scilab-%d",p1,(int)win_num);
01038       scig_toPs(win_num,colored,bufname,"Pos");
01039       sprintf(bufname,"$SCI/bin/scilab -%s %s/scilab-%d %s",
01040               (orientation == 1) ? "print_l" : "print_p",
01041               p1,(int)win_num,printer);
01042       system(bufname);
01043   }
01044 }
01045 
01046 /* for use inside menus */
01047 
01048 void scig_print(integer number) 
01049 {
01050   Print(NULL,(XtPointer) number,NULL);
01051 }
01052 
01053 /*********************************************************
01054  * Replot in Postscript or Xfig style and save 
01055  ********************************************************/
01056 
01057 static void
01058 SavePs(Widget w, XtPointer number, XtPointer client_data)
01059 {
01060   integer win_num = (integer) number ;
01061   integer colored,orientation,flag=2,ok;
01062   prtdlg(&flag,printer,&colored,&orientation,file,&ok);
01063   if (ok==1) 
01064     {
01065       if (strncmp(printer,"Postscript",10)==0 ) 
01066         {
01068           scig_toPs(win_num,colored,file,"Pos");
01069         }
01070       else if (strcmp(printer,"Xfig")==0)
01071         {
01073           scig_toPs(win_num,colored,file,"Fig");
01074         }
01075       else if (strcmp(printer,"Gif")==0)
01076         {
01078           scig_toPs(win_num,colored,file,"GIF");
01079         }
01080       else if (strcmp(printer,"PPM")==0)
01081         {
01083           scig_toPs(win_num,colored,file,"PPM");
01084         }
01085       if ( strcmp(printer,"Postscript No Preamble") != 0)
01086         {
01087           sprintf(bufname,"$SCI/bin/scilab -%s %s %s",
01088                   ( orientation == 1) ? "save_l" : "save_p",file,printer);
01089           system(bufname);
01090         }
01091   }
01092 }
01093 
01094 /* for use inside menus */
01095 
01096 void scig_export(integer number) 
01097 {
01098   SavePs(NULL,(XtPointer) number,NULL);
01099 }
01100 
01101 /******************************************************
01102  * Binary File save 
01103  ******************************************************/
01104 
01105 static void
01106 Save(Widget w, XtPointer number, XtPointer client_data)
01107 {
01108   char *filename;
01109   //  integer win_num = (integer) number ;
01110   int ierr=0,rep;
01111   static char *init ="*.scg";
01112   rep=GetFileWindow(init,&filename,".",0,&ierr,"Save Graphic File");
01113   if ( ierr == 0 && rep == TRUE )
01114     {
01115                 //      C2F(xsaveplots)(&win_num,filename,0L);
01116     }
01117 }
01118 
01119 /******************************************************
01120  * Binary File load 
01121  ******************************************************/
01122 
01123 static void
01124 Load(Widget w, XtPointer number, XtPointer client_data)
01125 {
01126   char *filename;
01127   integer win_num = (integer) number ;
01128   int ierr=0,rep;
01129   static char *init ="*.scg";
01130   rep=GetFileWindow(init,&filename,".",0,&ierr,"Load Graphic File");
01131   if ( ierr == 0 && rep == TRUE )
01132     {
01133       integer verb=0,cur,na;
01134       C2F(dr)("xget","window",&verb,&cur,&na,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
01135       C2F(dr)("xset","window",&win_num,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01136           //      C2F(xloadplots)(filename,0L);
01137       C2F(dr)("xset","window",&cur,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01138     }
01139 }
01140 
01141 /*
01142  * Inhinit zoom,unoom,rot3d 
01143  */
01144 
01145 /*******************************************************
01146  * 2D Zoom calback 
01147  ******************************************************/
01148 
01149 static void
01150 Zoom(Widget w, XtPointer number, XtPointer client_data)
01151 {
01152 
01153   integer win_num = (integer) number,ne=0;
01154   iargs = 0;
01155   XtSetArg(args[iargs], XtNsensitive, False); iargs++;
01156   XtSetValues(w, args, iargs);
01157   SetUnsetMenu(&win_num,"3D Rot.",&ne,False);
01158   SetUnsetMenu(&win_num,"UnZoom",&ne,False);
01159   SetUnsetMenu(&win_num,"File",&ne,False);
01160   if(scig_2dzoom(win_num) != 1){ /* ==1 <=> zoom failed (the window has been closed while zooming ) */
01161     iargs = 0;
01162     XtSetArg(args[iargs], XtNsensitive,True); iargs++;
01163     XtSetValues(w, args, iargs);
01164   }
01165   SetUnsetMenu(&win_num,"3D Rot.",&ne,True);
01166   SetUnsetMenu(&win_num,"UnZoom",&ne,True);
01167   SetUnsetMenu(&win_num,"File",&ne,True);
01168 }
01169 
01170 
01171 /*******************************************************
01172  * Unzoom Callback 
01173  ******************************************************/
01174 
01175 static void
01176 UnZoom(w, number, client_data)
01177      Widget w;
01178      XtPointer number;
01179      XtPointer client_data;
01180 {
01181   integer win_num = (integer) number;
01182   iargs = 0;
01183   XtSetArg(args[iargs], XtNsensitive, False); iargs++;
01184   XtSetValues(w, args, iargs);
01185   scig_unzoom(win_num);
01186   iargs = 0;
01187   XtSetArg(args[iargs], XtNsensitive,True); iargs++;
01188   XtSetValues(w, args, iargs);
01189 }
01190 
01191 
01192 /*******************************************************
01193  * 3D Rotation callback 
01194  ******************************************************/
01195 
01196 
01197 static void
01198 Rot3D(w, number, client_data)
01199      Widget w;
01200      XtPointer number;
01201      XtPointer client_data;
01202 {
01203   integer win_num = (integer) number,ne=0;
01204   iargs=0;
01205   XtSetArg(args[iargs], XtNsensitive, False); iargs++;
01206   XtSetValues(w, args, iargs);
01207   SetUnsetMenu(&win_num,"UnZoom",&ne,False);
01208   SetUnsetMenu(&win_num,"Zoom",&ne,False);
01209   SetUnsetMenu(&win_num,"File",&ne,False);
01210   scig_3drot(win_num);
01211   iargs = 0;
01212   XtSetArg(args[iargs], XtNsensitive,True); iargs++;
01213   XtSetValues(w, args, iargs);
01214   SetUnsetMenu(&win_num,"UnZoom",&ne,True);
01215   SetUnsetMenu(&win_num,"Zoom",&ne,True);
01216   SetUnsetMenu(&win_num,"File",&ne,True);
01217 }
01218 
01219 
01220 /*      Function Name: CreatePopupWindow
01221  *      Description: Creates and pops up the New Graphic Window
01222  *      Returns the graphic window id (CWindow) and the window of the top level widget (SciGWindow)
01223  *      and the info widget associated with the graphic window 
01224  */
01225 
01226 /*
01227  * DeleteWindow(): Action proc to implement ICCCM delete_window.
01228  */
01229 
01230 
01233 void SGDeleteWindow(w, event, params, num__PARAMS)
01234      Widget w;
01235      XEvent *event;
01236      String *params;
01237      Cardinal *num__PARAMS;
01238 {
01239   int i;
01240   Window Win = XtWindow(w), Win1;
01241   int wincount =  getWinsMaxId()+1;
01242   for (i=0 ; i < wincount ; i++) 
01243     {
01244       Win1=GetBGWindowNumber(i);
01245       if (Win1 == Win ) 
01246         {
01248           Delete((Widget) 0,(XtPointer) i,(XtPointer) 0);
01249           return ;
01250         }
01251     }
01252   return ;
01253 }
01254 
01255 
01256 static String sg_trans =
01257 "<Message>WM_PROTOCOLS: SGDeleteWindow()\n\
01258      <ClientMessage>WM_PROTOCOLS: SGDeleteWindow()\n";
01259 
01260 void CreatePopupWindow(integer WinNum, Widget button, struct BCG *ScilabXgc, Pixel *fg, Pixel *bg)
01261 {
01262   Widget toplevel;
01263   Display *dpy;
01264   XColor x_fg_color,x_bg_color;
01265   static XSetWindowAttributes attributes;
01266   unsigned char winname[6];
01267   iargs=0;
01268   XtSetArg(args[iargs], XtNx, 100+20*WinNum % 200);     iargs++;
01269   XtSetArg(args[iargs], XtNy, 100+20*WinNum % 200);     iargs++;
01270   sprintf(popupname,"ScilabGraphic%d",(int)WinNum);
01271   XtSetArg(args[iargs],XtNtitle,popupname);iargs++;
01272   
01273   DisplayInit("",&dpy,&toplevel);
01274   MultiClickTime=XtGetMultiClickTime(dpy);
01275 
01276   /* 
01277   ScilabXgc->popup = XtCreatePopupShell(popupname,
01278                              topLevelShellWidgetClass, button, args, iargs); 
01279                              */
01280   ScilabXgc->popup = XtAppCreateShell("Xscilab",popupname,topLevelShellWidgetClass,dpy,
01281                                       args,iargs);
01282   AddNewWin((int) WinNum,ScilabXgc);
01283   XtPopup(ScilabXgc->popup, XtGrabNone);
01284   SetHints(ScilabXgc->popup);
01285   
01286   sprintf((char *)winname,"BG%d",(int)WinNum);
01287   XChangeProperty(XtDisplay(ScilabXgc->drawbox),
01288                   XtWindow(ScilabXgc->drawbox), XA_WM_NAME, XA_STRING, 8, 
01289                   PropModeReplace, winname, 5);
01290   attributes.backing_store = Always;
01291   attributes.bit_gravity = NorthWestGravity;
01292   XChangeWindowAttributes(XtDisplay((ScilabXgc->drawbox)), 
01293                           XtWindow((ScilabXgc->drawbox)),
01294                           CWBackingStore | CWBitGravity,&attributes);
01295   XSync(XtDisplay(ScilabXgc->popup),0);
01296   ScilabXgc->CWindow=XtWindow(ScilabXgc->drawbox);
01297   ScilabXgc->CBGWindow=XtWindow(ScilabXgc->popup);
01298   XtOverrideTranslations(ScilabXgc->popup, XtParseTranslationTable(sg_trans));
01299   /*  Getting the values of foreground and background */
01300   XtSetArg(args[0],XtNforeground, &x_fg_color.pixel);
01301   XtSetArg(args[1],XtNbackground, &x_bg_color.pixel);
01302   XtGetValues(ScilabXgc->drawbox,args,2);
01303   *fg = x_fg_color.pixel;
01304   *bg = x_bg_color.pixel;
01305 }
01306 
01307 
01308 /*******************************************************
01309  * recursively changes the background and foreground 
01310  * of widgets 
01311  ******************************************************/
01312 
01313 void ChangeBandF(win_num,fg,bg)
01314      int win_num;
01315      Pixel fg;
01316      Pixel bg;
01317 {
01318   struct BCG *SciGc;
01319   Widget popup,toplevel;
01320   static Display *dpy = (Display *) NULL;
01321   DisplayInit("",&dpy,&toplevel);
01322   SciGc = getWindowXgcNumber(win_num);
01323   if ( SciGc != NULL ) 
01324     {
01325       popup = SciGc->popup;
01326       if (popup == NULL) return;
01327       ChangeBF1(popup,"*.scigForm.scigmForm.File",fg,bg);
01328       ChangeBF1(popup,"*.scigForm.scigmForm.File.menu",fg,bg);
01329       ChangeBF1(popup,"*.scigForm.scigmForm.File.menu.Clear",fg,bg);
01330       ChangeBF1(popup,"*.scigForm.scigmForm.File.menu.Select",fg,bg);
01331       ChangeBF1(popup,"*.scigForm.scigmForm.File.menu.Print",fg,bg);
01332       ChangeBF1(popup,"*.scigForm.scigmForm.File.menu.Export",fg,bg);
01333       ChangeBF1(popup,"*.scigForm.scigmForm.File.menu.Save",fg,bg);
01334       ChangeBF1(popup,"*.scigForm.scigmForm.File.menu.Load",fg,bg);
01335       ChangeBF1(popup,"*.scigForm.scigmForm.File.menu.Close",fg,bg);
01336       ChangeBF1(popup,"*.scigForm.scigmForm.Zoom",fg,bg);
01337       ChangeBF1(popup,"*.scigForm.scigmForm.UnZoom",fg,bg);
01338       ChangeBF1(popup,"*.scigForm.scigmForm.Rot3D",fg,bg);
01339     }
01340 }
01341 
01342 static void ChangeBF1(w,str,fg,bg)
01343      Widget w;
01344      char *str;
01345      Pixel fg;
01346      Pixel bg;
01347 {
01348   Widget loc;
01349   loc = XtNameToWidget(w,str);
01350   if ( loc != NULL)  
01351     {
01352       iargs=0;
01353       XtSetArg(args[iargs], XtNforeground, fg); iargs++;
01354       XtSetArg(args[iargs], XtNbackground, bg); iargs++;
01355       XtSetValues(loc, args, iargs);
01356     }
01357   else
01358     {
01359       sciprint("widget %s not found\r\n",str);
01360     }
01361 }
01362 
01363 /*--------------------------------------------------------------
01364  *  Add dynamically buttons and menus in The Scilab Graphic Window
01365  * or in the Scilab main window 
01366  ----------------------------------------------------------------*/
01367 
01368 typedef struct {
01369   int    win_num;      /* graphic window number or -1 for main window */
01370   int    entry;        /* clicked sub_menu number */
01371   int    type;         /* interpreded action (0), hard coded action(1) */
01372   char   *fname;       /* name of the action function  */
01373 } MenuData,*MenuDataPtr;
01374 
01375 extern Widget commandWindow; /* Scilab main window */
01376 
01377 static void
01378 KillButton(w, client_data, call_data)
01379      Widget w;
01380      XtPointer client_data;
01381      caddr_t call_data;
01382 {
01383   MenuDataPtr datas =(MenuDataPtr)client_data;
01385   if ( datas->entry == 0)
01386     FREE(datas->fname);
01387   FREE(datas);
01388 }
01389 /****************************************************
01390  * callBack associated to a user defined menu 
01391  ****************************************************/
01392 
01393 static void
01394 SelMenu(w, client_data, call_data)
01395      Widget w;
01396      XtPointer client_data;
01397      caddr_t call_data;
01398 {
01399   static char buf[256];
01400   MenuDataPtr datas = (MenuDataPtr) client_data;
01401   if (datas->type == 0) 
01402     { 
01403       /* Interpreted mode : we store the action on a queue */
01404       if ( datas->win_num < 0 ) 
01405         {
01406           sprintf(buf,"execstr(%s(%d))",datas->fname,datas->entry+1);
01407         }
01408       else 
01409         {
01410           sprintf(buf,"execstr(%s_%d(%d))",datas->fname,datas->win_num,datas->entry+1);
01411         }
01412       StoreCommand(buf);
01413     }
01414   else if (datas->type == 2) 
01415     { 
01416       /* Interpreted mode : we store the action on a queue */
01417       if ( datas->win_num < 0 ) 
01418         {
01419           sprintf(buf,"%s(%d)",datas->fname,datas->entry+1);
01420         }
01421       else 
01422         {
01423           sprintf(buf,"%s(%d,%d)",datas->fname,datas->entry+1,datas->win_num);
01424         }
01425       StoreCommand(buf);
01426     }
01427   else
01428     { 
01429       /* hard coded mode */
01430       int rep ;
01431       C2F(setfbutn)(datas->fname,&rep);
01432       if ( rep == 0) 
01433         F2C(fbutn)((datas->fname),&(datas->win_num),&(datas->entry));
01434     }
01435 }
01436 
01437 
01438 /****************************************************
01439  *Delete the button named button_name in window 
01440  * number win_num
01441  ****************************************************/
01442 
01443 int C2F(delbtn)(win_num,button_name)
01444      integer *win_num;
01445      char *button_name;
01446 {  
01447   int nc=0;
01448   WidgetList childs;
01449   Widget outer,h,v,w;
01450   int i,pos=0;
01451   int name_pos ;
01452 
01453   if (GetChilds(*win_num,&nc,&childs,&outer,button_name,&name_pos)== FALSE)
01454     return 0;
01455   if (name_pos  == -1 ) return 0; /* button_name not found */
01456   /* position in widget list */
01457   pos = name_pos +1;
01458   if ( pos==(int)nc ) 
01459     {
01460       /* button_name is the  last button : simply destroy it */
01461       XtDestroyWidget(childs[name_pos]);
01462       return 0;
01463     }
01464   iargs=0;
01465   XtSetArg(args[iargs], XtNfromHoriz,&h);    iargs++;
01466   XtSetArg(args[iargs], XtNfromVert,&v);     iargs++;
01467   XtGetValues(childs[pos-1], args, iargs);
01468   /* reconstruct next widget layout */
01469   iargs=0;
01470   XtSetArg(args[iargs], XtNfromHoriz,h);    iargs++;
01471   XtSetArg(args[iargs], XtNtop,XawChainTop); iargs++;
01472   XtSetArg(args[iargs], XtNbottom,XawChainTop); iargs++;
01473   XtSetValues(childs[pos], args, iargs);
01474 
01475   if (v!=NULL) {
01476     iargs=0;
01477     XtSetArg(args[iargs], XtNfromVert,v);    iargs++;
01478     XtSetArg(args[iargs], XtNtop,XawChainTop); iargs++;
01479     XtSetArg(args[iargs], XtNbottom,XawChainTop); iargs++;
01480     XtSetValues(childs[pos], args, iargs);
01481     for (i=pos+1;i<(int)nc;i++) {
01482       iargs=0;
01483       XtSetArg(args[iargs], XtNfromVert,&w);     iargs++;
01484       XtGetValues(childs[i], args, iargs);
01485       if (w== childs[pos-1]) {
01486         iargs=0;
01487         XtSetArg(args[iargs], XtNfromVert,v);     iargs++;
01488         XtSetArg(args[iargs], XtNtop,XawChainTop); iargs++;
01489         XtSetArg(args[iargs], XtNbottom,XawChainTop); iargs++;
01490         XtSetValues(childs[i], args, iargs);
01491       }
01492     }
01493   }
01494   /* destroy widget */
01495   if ( childs[pos-1] != NULL)
01496     XtDestroyWidget(childs[pos-1]);
01497   return(0);
01498 }
01499 
01500 /****************************************************
01501  * Add a menu in  window  number wun_num or in Main window
01502  *  win_num     : graphic window number or -1 for main scilab window
01503  *  button_name : label of button
01504  *  entries     : labels of submenus if any
01505  *  ne          : number of submenus
01506  *  typ         : Action mode
01507  *                typ==0 : interpreted (execution of scilab instruction
01508  *  typ!=0 : hard coded a routine is called
01509  *  fname;      : name of the action function  
01510  ****************************************************/
01511 
01512 void AddMenu(win_num, button_name, entries, ne, typ, fname, ierr)
01513      integer *win_num;
01514      char *button_name;
01515      char **entries;
01516      integer *ne;
01517      integer *typ;
01518      char *fname;
01519      integer *ierr;
01520 {  
01521   int newline,i;
01522   WidgetList childs;
01523   Widget outer,command,w,menu,entry;
01524   Position x;
01525   Dimension width,height,mainwidth,mainheight,bw=0;
01526   XFontStruct     *temp_font;
01527   char *func;
01528   MenuDataPtr datas;
01529   int nc, name_pos;
01530   if (GetChilds(*win_num,&nc,&childs,&outer,NULL,&name_pos)== FALSE) return;
01531   if ( nc < 2 ) return ; 
01532   iargs=0;
01533   XtSetArg(args[iargs], XtNx,&x);             iargs++;
01534   XtSetArg(args[iargs], XtNwidth,&width);     iargs++;
01535   XtSetArg(args[iargs], XtNheight,&height);     iargs++;
01536   XtSetArg(args[iargs], XtNfont, &temp_font);  iargs++;
01537   XtGetValues(childs[nc-1], args, iargs);
01538   iargs=0;
01539   XtSetArg(args[iargs], XtNwidth,&mainwidth);       iargs++;
01540   XtSetArg(args[iargs], XtNheight,&mainheight);       iargs++;
01541   XtGetValues(outer, args, iargs);
01542 
01543   bw= ( temp_font != NULL )? strlen(button_name)*((temp_font)->max_bounds.width) : 0;
01544   if ( (Dimension) (width+bw+x)  < mainwidth)
01545     {
01547       newline=0;
01548       iargs=0;
01549       XtSetArg(args[iargs], XtNfromVert,&w);  iargs++;
01550       XtGetValues(childs[nc-1], args, iargs);
01551       iargs=0;
01552       XtSetArg(args[iargs], XtNfromHoriz,childs[nc-1]);  iargs++;
01553       XtSetArg(args[iargs], XtNfromVert,w);  iargs++;
01554     }
01555   else
01556     {
01558       newline=1;
01559       iargs=0;
01560       XtSetArg(args[iargs], XtNfromVert,childs[nc-1]);  iargs++;
01561       XtSetArg(args[iargs], XtNfromHoriz,childs[0]);  iargs++;
01562     }
01563 
01564   func=(char *) MALLOC( (strlen(fname)+1)*(sizeof(char)));
01565   if ( func == ( char *) 0 ) 
01566     {
01567       *ierr=1 ;return;
01568     }
01569   strcpy(func,fname);
01570 
01571   XtSetArg(args[iargs], XtNheight,height);     iargs++;
01572   if (*ne==0) {
01573     command = XtCreateManagedWidget(button_name,
01574                                     commandWidgetClass,outer,args, iargs);
01575     datas= (MenuDataPtr) MALLOC(sizeof(MenuData) );
01576     if ( datas == (MenuDataPtr) 0) 
01577       {
01578         *ierr=1 ;return;
01579       }
01580     datas->win_num= *win_num;
01581     datas->entry=0;
01582     datas->type=*typ;
01583     datas->fname=func;
01584     XtAddCallback(command, XtNcallback,(XtCallbackProc) SelMenu,
01585                   (XtPointer)datas);
01586     XtAddCallback(command, XtNdestroyCallback,(XtCallbackProc) KillButton,
01587                   (XtPointer)datas);
01588   }
01589   else {
01590     command = XtCreateManagedWidget(button_name,
01591                                     menuButtonWidgetClass,outer,args, iargs);
01592     iargs=0;
01593     menu = XtCreatePopupShell("menu", simpleMenuWidgetClass, 
01594                               command,args, iargs);
01595     for (i=0;i<*ne;i++){
01596       iargs=0;
01597       entry= XtCreateManagedWidget(entries[i], smeBSBObjectClass, menu,
01598                                    args, iargs);
01599       datas= (MenuDataPtr) MALLOC(sizeof(MenuData) );
01600       if ( datas == (MenuDataPtr) 0) 
01601         {
01602           *ierr=1 ;return;
01603         }
01604       datas->win_num = *win_num;
01605       datas->entry=i;
01606       datas->type=*typ;
01607       datas->fname=func;
01608       XtAddCallback(entry,XtNcallback,(XtCallbackProc)SelMenu, 
01609                     (XtPointer)datas);
01610       XtAddCallback(entry, XtNdestroyCallback,(XtCallbackProc) KillButton,
01611                     (XtPointer)datas);
01612     }
01613   }
01614   if (newline==1) {
01615     /* here we should increase the height of scigmForm */
01616   }
01617 }
01618 
01619 /****************************************************
01620  * Scilab interface for the AddMenu function 
01621  *  Add a menu in  window  number win_num or in Main window
01622  *
01623  *  win_num     : graphic window number or -1 for main scilab window
01624  *  button_name : label of button
01625  *  entries     : labels of submenus if any (in scilab code)
01626  *  ptrentries  : table of pointers on each entries
01627  *  ne          : number of submenus
01628  *  typ         : Action mode
01629  *                typ==0 : interpreted (execution of scilab instruction
01630  *                typ!=0 : hard coded a routine is called
01631  *  fname;      : name of the action function  
01632  *******************************************************/
01633 
01634 int C2F(addmen)(win_num,button_name,entries,ptrentries,ne,typ,fname,ierr)
01635      integer *win_num,*entries,*ptrentries,*ne,*ierr,*typ;
01636      char *button_name,*fname;
01637 {
01638   char ** menu_entries = NULL ;
01639   int i ;
01640   *ierr =0;
01641   if (*ne!=0) {
01642     ScilabMStr2CM(entries,ne,ptrentries,&menu_entries,ierr);
01643     if ( *ierr == 1) return(0);
01644   }
01645   AddMenu(win_num,button_name,menu_entries,ne,typ,fname,ierr);
01646   /* ScilabMStr2CM allocate menu_entries */
01647   for ( i = 0 ; i  < *ne ; i++ )
01648   {
01649     FREE( menu_entries[i] ) ;
01650   }
01651   FREE( menu_entries ) ;
01652   return(0);
01653 }
01654 
01655 /***************************************************
01656  * Activate or deactivate a menu 
01657  ***************************************************/
01658 
01659 static void SetUnsetMenu(win_num, button_name, ne,flag)
01660      integer *win_num;
01661      char *button_name;
01662      integer *ne;
01663      int flag;
01664 {  
01665   Cardinal nc=0;
01666   WidgetList childs;
01667   Widget outer;
01668   int nc1,name_pos;
01669   if (GetChilds(*win_num,&nc1,&childs,&outer,button_name,&name_pos)== FALSE) return;
01670   if (name_pos  == -1 ) return; /* button_name not found */
01671   if (*ne==0) 
01672     {
01674       iargs=0;
01675       XtSetArg(args[iargs],XtNsensitive,flag); iargs++;
01676       XtSetValues(childs[name_pos], args, iargs );
01677     }
01678   else 
01679     {
01680       Widget w1;
01681       String mname=NULL;
01682       /* a submenu is specified by its position 
01683        * in the menu item list  (*ne) 
01684        */
01685       iargs=0;
01686       XtSetArg(args[iargs], XtNmenuName, &mname);    iargs++;
01687       XtGetValues(childs[name_pos], args, iargs); 
01688       w1= (mname == NULL) ? NULL : XtNameToWidget(childs[name_pos],mname);
01689       if (w1==NULL) {
01690         iargs=0;
01691         XtSetArg(args[iargs],XtNsensitive,flag); iargs++;
01692         XtSetValues(childs[name_pos], args, iargs );
01693         return;
01694       }
01695       iargs=0;
01696       XtSetArg(args[iargs], XtNnumChildren, &nc);    iargs++;
01697       XtSetArg(args[iargs], XtNchildren, &childs);   iargs++;
01698       XtGetValues(w1, args, iargs); 
01699       if (*ne <= (int)nc) {
01700         iargs=0;
01701         XtSetArg(args[iargs],XtNsensitive,flag); iargs++;
01702         XtSetValues(childs[*ne-1], args, iargs ); 
01703       }
01704     }
01705 }
01706 
01707 
01710 int C2F(setmen)(win_num,button_name,entries,ptrentries,ne,ierr)
01711      integer *win_num,*entries,*ptrentries,*ne,*ierr;
01712      char *button_name;
01713 {
01714   SetUnsetMenu(win_num,button_name,ne,True);
01715   return(0);
01716 }
01717 
01718 int C2F(unsmen)(win_num,button_name,entries,ptrentries,ne,ierr)
01719      integer *win_num,*entries,*ptrentries,*ne,*ierr;
01720      char *button_name;
01721 {
01722   SetUnsetMenu(win_num,button_name,ne,False);
01723   return(0);
01724 }
01725 
01726 
01727 /************************************
01728  * Utility function : 
01729  * find the child list of graphic window win_num 
01730  * or scilab main window if win_num == -1 
01731  * then if name is non nul name_pos is set to 
01732  * the position in wL of the child which has label <<name>>
01733  * or to  -1 in case of error  
01734  * outer : the parent of the widgets contained in wL
01735  ************************************/
01736 
01737 static int GetChilds(win_num,nc,wL,outer,name,name_pos) 
01738   int win_num; /* id of the window */
01739   int *nc; /* number of children */
01740   WidgetList *wL;
01741   Widget *outer;
01742   char *name; /* name of the menu */
01743   int * name_pos; /* id of the menu */
01744 { 
01745   Cardinal nc1=0;
01746   Widget popup,toplevel;
01747   char * label;
01748   static Display *dpy = (Display *) NULL;
01749   DisplayInit("",&dpy,&toplevel);
01750   if ( win_num == -1) 
01751     {
01752       *outer = commandWindow;
01753     }
01754   else 
01755     {
01756       struct BCG *SciGc;
01757       SciGc = getWindowXgcNumber(win_num);
01758       if ( SciGc ==  NULL ) return FALSE;
01759       if ((popup = SciGc->popup)== NULL) return FALSE;
01760       *outer=XtNameToWidget(popup,"*.scigForm.scigmForm");
01761       if (*outer == NULL) return FALSE;
01762     }
01763   iargs=0;
01764   XtSetArg(args[iargs], XtNnumChildren, &nc1);    iargs++;
01765   XtSetArg(args[iargs], XtNchildren, wL);   iargs++;
01766   XtGetValues(*outer, args, iargs);
01767   *nc=nc1;
01768   *name_pos = -1;
01769   if ( name != NULL) 
01770     {
01771       int i;
01772       for (i=0; i < (int)nc1;i++) 
01773         {
01774           iargs=0;
01775           label=NULL;
01776           XtSetArg(args[iargs], XtNlabel,&label);   iargs++;
01777           XtGetValues( (*wL)[i], args, iargs);
01778           if ( label != NULL && (strcmp(label,name)==0))
01779             {
01780               *name_pos = i;
01781               break;
01782             }
01783         }
01784     }
01785   return TRUE;
01786 }
01787 
01788 /*------------------------------------------------------------------------------------*/
01789 /* get the number of submenus of a given menu                                         */
01790 /*------------------------------------------------------------------------------------*/
01791 int getNbSubMenus( int winNumber, char * menuName )
01792 {
01793   int        nbMenus        ;
01794   WidgetList subMenus       ;
01795   Widget     menu           ;
01796   Widget     subMenu        ;
01797   int        menuId         ;
01798   int        nbSubMenus = 0 ;
01799   String     mname      = NULL ;
01800 
01801   if ( GetChilds( winNumber ,
01802                   &nbMenus   ,
01803                   &subMenus ,
01804                   &menu     ,
01805                   menuName  ,
01806                   &menuId    )  == FALSE )
01807   { 
01808     return 0 ;
01809   }
01810   /* a submenu is specified by its position 
01811    * in the menu item list  (*ne) 
01812    */
01813   iargs=0;
01814   XtSetArg(args[iargs], XtNmenuName, &mname);
01815   iargs++;
01816   XtGetValues(subMenus[menuId], args, iargs);
01817   
01818   if ( mname == NULL )
01819   {
01820     return 0 ;
01821   }
01822   
01823   subMenu = XtNameToWidget(subMenus[menuId],mname) ;
01824   iargs = 0 ;
01825   XtSetArg(args[iargs], XtNnumChildren, &nbSubMenus);
01826   iargs++;
01827   XtGetValues( subMenu , args, iargs);
01828   
01829   return nbSubMenus ;
01830 }
01831 
01832 /*------------------------------------------------------------------------------------*/
01833 void refreshMenus( struct BCG * ScilabGC ) {}
01834 /*------------------------------------------------------------------------------------*/

Generated on Sun Mar 4 15:03:56 2007 for Scilab [trunk] by  doxygen 1.5.1