home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / 2582 < prev    next >
Encoding:
Text File  |  1992-11-20  |  55.3 KB  |  1,873 lines

  1. Path: sparky!uunet!stanford.edu!morrow.stanford.edu!sep!steve
  2. From: steve@sep.Stanford.EDU (Steve Cole)
  3. Newsgroups: alt.sources
  4. Subject: xtpanel 2.0 - interactive program builder - part 06/10
  5. Followup-To: alt.sources.d
  6. Date: 21 Nov 1992 00:32:51 GMT
  7. Organization: Stanford Exploration Project
  8. Lines: 1860
  9. Distribution: world
  10. Message-ID: <1ek03jINN194@morrow.stanford.edu>
  11. NNTP-Posting-Host: taal.stanford.edu
  12.  
  13.  
  14. Submitted-by: steve@sep.Stanford.EDU
  15. Archive-name: xtpanel/part06
  16.  
  17. #!/bin/sh
  18. # This is part 06 of a multipart archive
  19. # ============= xtpanel/button.c ==============
  20. if test ! -d 'xtpanel'; then
  21.     echo 'x - creating directory xtpanel'
  22.     mkdir 'xtpanel'
  23. fi
  24. if test -f 'xtpanel/button.c' -a X"$1" != X"-c"; then
  25.     echo 'x - skipping xtpanel/button.c (File already exists)'
  26. else
  27. echo 'x - extracting xtpanel/button.c (Text)'
  28. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/button.c' &&
  29. /*
  30. X * Copyright 1992 the Board of Trustees of the Leland Stanford Junior
  31. X * University. Official permission to use this software is included in
  32. X * the documentation. It authorizes you to use this file for any
  33. X * non-commercial purpose, provided that this copyright notice is not
  34. X * removed and that any modifications made to this file are commented
  35. X * and dated in the style of the example below.
  36. X */
  37. X
  38. /*
  39. X *
  40. X *  source file:   ./xtpanel/button.c
  41. X *
  42. X * Steve Cole, Dave Nichols (SEP), August 28 1992
  43. X *      Inserted this sample edit history entry.
  44. X *      Please log any further modifications made to this file:
  45. X * Steve Cole, Dave Nichols (SEP), November 20 1992 -  version 2.00
  46. X * 1) added new objects: toggle, scrollbar, graph.
  47. X * 2) added new actions: ASSIGN, SET.
  48. X * 3) objects can have multiple actions.
  49. X * 4) backquoted strings in actions get executed at action time.
  50. X */
  51. X
  52. #include <X11/Intrinsic.h>
  53. #include <X11/StringDefs.h>
  54. X
  55. #include <X11/Xaw/Cardinals.h>
  56. #include <X11/Xaw/Command.h>
  57. #include <X11/Xaw/Toggle.h>
  58. X
  59. #include <stdio.h>
  60. X
  61. #include "object.h" 
  62. #include "tree.h"
  63. #include "builders.h"
  64. X
  65. typedef struct buttoninfo {
  66. X    char* type;
  67. X    char* value;
  68. } _binf;
  69. X
  70. void build_button(root,parent,type)
  71. X     entry *root;
  72. X     Widget parent;
  73. X     char *type;
  74. {
  75. X    Objdef *object;
  76. X    char* label;
  77. X    struct buttoninfo *button_info;
  78. X    char defname[12];
  79. X    Widget button;
  80. X    Arg args[20];
  81. X    int narg;
  82. X    static int numbutt=1;
  83. X    extern void button_callback();
  84. X    extern void button_update();
  85. X    
  86. X    /* create new object */
  87. X    object = new_object();
  88. X
  89. X    /* construct default button name */
  90. X    sprintf(defname,"button%d",numbutt++);
  91. X    
  92. X    /* find label, name, action in tree */
  93. X    object->name = get_value(root,"name",defname);
  94. X    label = get_value(root,"label",object->name);
  95. X    object->action = parse_actions(object->name,root);
  96. X    button_info = (struct buttoninfo*) malloc( sizeof( struct buttoninfo ) );
  97. X    /* save type (button, toggle) for use by callback routines */
  98. X    button_info->type = strdupl(type);
  99. X    /* save value for toggles */
  100. X    button_info->value = get_value(root,"value",label);
  101. X    if (!strcmp(button_info->type,"toggle")) {
  102. X    object->value = strdupl("");
  103. X    }else{
  104. X    object->value = strdupl(button_info->value);
  105. X    }
  106. X
  107. X    narg = 0;
  108. X    XtSetArg(args[narg], XtNlabel, label); narg++;
  109. X
  110. X    /* common parameters */
  111. X    common_tags(root,args,&narg,SET_ALL);
  112. X
  113. X    if (!strcmp(type,"button")) 
  114. X    {
  115. X        button = XtCreateManagedWidget(object->name,commandWidgetClass,
  116. X                   parent,args,narg);
  117. X    } else {
  118. X        button = XtCreateManagedWidget(object->name,toggleWidgetClass,
  119. X                   parent,args,narg);
  120. X    }
  121. X
  122. X    object->widgetname = button;
  123. X    object->info = button_info;
  124. X    object->updater = button_update;
  125. X    
  126. X    XtAddCallback( button, XtNcallback, button_callback, (XtPointer) object);
  127. }
  128. X
  129. /* callback used for buttons */
  130. void
  131. X  button_callback(widget, client_data, callData)
  132. Widget widget;
  133. XXtPointer client_data, callData;
  134. {
  135. X    Objdef *object;
  136. X    struct buttoninfo *button_info;
  137. X    extern int quitflag;
  138. X    Arg arg[1];
  139. X    Boolean state;
  140. X    
  141. X    object = (Objdef *) client_data;
  142. X    button_info = (struct buttoninfo *) object->info;
  143. X
  144. X    /* set toggle value if it is on */
  145. X    if (!strcmp(button_info->type,"toggle"))
  146. X    {
  147. X        XtSetArg( arg[0], XtNstate, &state );
  148. X        XtGetValues( object->widgetname, arg, ONE );
  149. X        if (state == TRUE ) 
  150. X            object->value = strdupl(button_info->value);
  151. X        else
  152. X        object->value = strdupl("");
  153. X    }
  154. X
  155. X    if ( perform_actions(object->name,object->action,1) && !quitflag ) 
  156. X      quit_xtpanel();
  157. }
  158. X
  159. void button_update(object,value)
  160. Objdef* object;
  161. char* value;
  162. {
  163. X    struct buttoninfo *button_info;
  164. X    Arg arg[1];
  165. X    Boolean state;
  166. X
  167. X    button_info = (struct buttoninfo *) object->info;
  168. X
  169. X    /* set toggle value if it is on */
  170. X    if (!strcmp(button_info->type,"toggle"))
  171. X    {
  172. X        button_info->value = strdupl(value);
  173. X        XtSetArg( arg[0], XtNstate, &state );
  174. X        XtGetValues( object->widgetname, arg, ONE );
  175. X        if (state == TRUE ) 
  176. X            object->value = strdupl(button_info->value);
  177. X    } else {
  178. X        object->value = strdupl(value);
  179. X    }
  180. }
  181. SHAR_EOF
  182. chmod 0664 xtpanel/button.c ||
  183. echo 'restore of xtpanel/button.c failed'
  184. Wc_c="`wc -c < 'xtpanel/button.c'`"
  185. test 4189 -eq "$Wc_c" ||
  186.     echo 'xtpanel/button.c: original size 4189, current size' "$Wc_c"
  187. fi
  188. # ============= xtpanel/object.h ==============
  189. if test -f 'xtpanel/object.h' -a X"$1" != X"-c"; then
  190.     echo 'x - skipping xtpanel/object.h (File already exists)'
  191. else
  192. echo 'x - extracting xtpanel/object.h (Text)'
  193. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/object.h' &&
  194. #ifndef OBJECT_H
  195. #define OBJECT_H
  196. X
  197. #include <X11/Intrinsic.h>
  198. X
  199. #include "actions.h"
  200. X
  201. typedef struct objdef {
  202. X    char* name;
  203. X    action* action;
  204. X    char* value;
  205. X    Widget widgetname;
  206. X    void* info;
  207. X    void (*updater)();
  208. X    struct objdef* next;
  209. X    } Objdef, *PObjdef; 
  210. X
  211. #ifndef _NO_PROTO
  212. X
  213. extern Objdef* new_object();
  214. extern Objdef* find_by_name( char*);
  215. extern Objdef* find_by_widget( Widget );
  216. extern char* get_string( char* );
  217. extern void set_string( char*, char* );
  218. extern void all_actions(void);
  219. X
  220. #else
  221. X
  222. extern Objdef* new_object();
  223. extern Objdef* find_by_name();
  224. extern Objdef* find_by_widget();
  225. extern char* get_string();
  226. extern void set_string();
  227. extern void all_actions();
  228. X
  229. #endif
  230. X
  231. #endif
  232. SHAR_EOF
  233. chmod 0664 xtpanel/object.h ||
  234. echo 'restore of xtpanel/object.h failed'
  235. Wc_c="`wc -c < 'xtpanel/object.h'`"
  236. test 679 -eq "$Wc_c" ||
  237.     echo 'xtpanel/object.h: original size 679, current size' "$Wc_c"
  238. fi
  239. # ============= xtpanel/INSTALL ==============
  240. if test -f 'xtpanel/INSTALL' -a X"$1" != X"-c"; then
  241.     echo 'x - skipping xtpanel/INSTALL (File already exists)'
  242. else
  243. echo 'x - extracting xtpanel/INSTALL (Text)'
  244. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/INSTALL' &&
  245. To install xtpanel,
  246. X
  247. If you have a working imake setup (the recommended way).
  248. --------------------------------------------------------
  249. You should edit Imake.config to reflect where you wish 
  250. the system xtpanel files to be installed. The default is to put them 
  251. in the X11 library directory in a sub-directory called xtpanel.
  252. X
  253. Type "xmkmf -a" 
  254. X     or "imake" followed by "make Makefiles"
  255. X     or whatever you use to invoke imake at your site.
  256. X
  257. Type "make"  to build the software.
  258. X
  259. Type "make install "  to install the software.
  260. X
  261. Type "make install.man"  to install the man page.
  262. X
  263. X
  264. If you haven't figure out imake yet, or your vendor didn't provide it
  265. ----------------------------------------------------------------------
  266. Edit the NoImake.cpp file to reflect where your X11 include files and 
  267. libraries live and where you want the software installed.
  268. X
  269. Type "NoImake" 
  270. X   or"NoImake MACH" where MACH is one of SUN4, RS6000, HP700 or DEC3100
  271. X
  272. Then follow the make steps as above. You may need to edit NoImake.cpp
  273. to make it work on your machine.
  274. X
  275. X
  276. Machines tested:
  277. ----------------
  278. X
  279. Sun 4, OS 4.1.1, MIT X11R5
  280. Sun 4, OS 4.1.1, Openwindows-3 (see the file OW3 for more info)
  281. Sun 3, OS 3.5, MIT X11R5
  282. DEC 3100, ULTRIX V4.2, MIT X11R5
  283. DEC 3100, ULTRIX V4.2, UWS V4.2 (with optional MIT compatible subset)
  284. IBM RS6000, AIX V3.2, MIT X11R5
  285. IBM RS6000, AIX V3.2, IBM X11R4
  286. HP 700, HP-UX 8.05, HP X11R4
  287. Convex C-1, OS 9.0, MIT X11R4
  288. SHAR_EOF
  289. chmod 0664 xtpanel/INSTALL ||
  290. echo 'restore of xtpanel/INSTALL failed'
  291. Wc_c="`wc -c < 'xtpanel/INSTALL'`"
  292. test 1423 -eq "$Wc_c" ||
  293.     echo 'xtpanel/INSTALL: original size 1423, current size' "$Wc_c"
  294. fi
  295. # ============= xtpanel/dialog.c ==============
  296. if test -f 'xtpanel/dialog.c' -a X"$1" != X"-c"; then
  297.     echo 'x - skipping xtpanel/dialog.c (File already exists)'
  298. else
  299. echo 'x - extracting xtpanel/dialog.c (Text)'
  300. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/dialog.c' &&
  301. /*
  302. X * Copyright 1992 the Board of Trustees of the Leland Stanford Junior
  303. X * University. Official permission to use this software is included in
  304. X * the documentation. It authorizes you to use this file for any
  305. X * non-commercial purpose, provided that this copyright notice is not
  306. X * removed and that any modifications made to this file are commented
  307. X * and dated in the style of the example below.
  308. X */
  309. X
  310. /*
  311. X *
  312. X *  source file:   ./xtpanel/dialog.c
  313. X *
  314. X * Steve Cole, Dave Nichols (SEP), August 28 1992
  315. X *      Inserted this sample edit history entry.
  316. X *      Please log any further modifications made to this file:
  317. X * Steve Cole, Dave Nichols (SEP), November 20 1992 -  version 2.00
  318. X * 1) added new objects: toggle, scrollbar, graph.
  319. X * 2) added new actions: ASSIGN, SET.
  320. X * 3) objects can have multiple actions.
  321. X * 4) backquoted strings in actions get executed at action time.
  322. X */
  323. X
  324. #include <X11/Intrinsic.h>
  325. #include <X11/StringDefs.h>
  326. X
  327. #include <X11/Xaw/Cardinals.h>
  328. #include <X11/Xaw/Command.h>
  329. #include <X11/Xaw/Dialog.h>
  330. X
  331. #include "object.h" 
  332. #include "tree.h"
  333. #include "builders.h"
  334. X
  335. /* translation table used for dialog widget */
  336. char trans[] =         
  337. X  "<Leave>:         update_dialog()\n\
  338. X   <Key>Return:     return_key()";
  339. X
  340. void build_dialog(root,parent)
  341. X     entry *root;
  342. X     Widget parent;
  343. {
  344. X    Objdef *object;
  345. X    char *label;
  346. X    Arg args[20];
  347. X    Widget dialog, button;
  348. X    char defname[12];
  349. X    static int numdiag=1;
  350. X    int narg;
  351. X    extern void dialog_callback();
  352. X    extern void dialog_update();
  353. X    
  354. X    /* create new object */
  355. X    object = new_object();
  356. X
  357. X    /* construct default dialog name */
  358. X    sprintf(defname,"dialog%d",numdiag++);
  359. X    
  360. X    /* find label, name, action, etc. in tree */
  361. X    object->name = get_value(root,"name",defname);
  362. X    label = get_value(root,"label",object->name);
  363. X    object->action = parse_actions(object->name,root);
  364. X    object->value = get_value(root,"value","");
  365. X    
  366. X    narg=0;
  367. X    XtSetArg(args[narg], XtNlabel, label ); narg++;
  368. X    XtSetArg(args[narg], XtNvalue, object->value); narg++;
  369. X    /* common parameters */
  370. X    common_tags(root,args,&narg,SET_WIDTH|SET_FG|SET_BG|SET_BORDER);
  371. X
  372. X    dialog = XtCreateManagedWidget(object->name,dialogWidgetClass,parent,
  373. X                   args,narg);
  374. X
  375. X    object->widgetname = dialog;
  376. X    object->updater = dialog_update;
  377. X    
  378. X    /* use translations to update value whenever mouse leaves dialog widget */
  379. X    XtAugmentTranslations(dialog,XtParseTranslationTable(trans));
  380. X    
  381. X    /* add a button */
  382. X    button = XtCreateManagedWidget(object->name,commandWidgetClass,
  383. X                       dialog,NULL,ZERO);
  384. X    XtAddCallback(button, XtNcallback, dialog_callback, 
  385. X              (XtPointer) object );
  386. }
  387. X
  388. /* 
  389. X * this routine gets called when the optional button of a dialog
  390. X * item is pressed 
  391. X */
  392. void  dialog_callback(widget, client_data, callData)
  393. X     Widget widget;
  394. X     XtPointer client_data, callData;
  395. {
  396. X    Objdef *object;
  397. X    Arg arg[1];
  398. X    extern int quitflag;
  399. X    
  400. X    object = (Objdef *) client_data;
  401. X    /* get the value of the dialog */
  402. X    object->value = 
  403. X      strdupl((char *) XawDialogGetValueString(object->widgetname));
  404. X
  405. X    if (perform_actions(object->name,object->action,1) && !quitflag)
  406. X      quit_xtpanel();
  407. }
  408. X
  409. /*
  410. X * this routine gets called whenever we leave
  411. X * a dialog widget, to be sure its value is up to date
  412. X */
  413. void dialog_update_callback( w, event, params, num_params)
  414. X     Widget w;
  415. X     XEvent *event;
  416. X     String *params;
  417. X     Cardinal *num_params;
  418. {
  419. X    Objdef* obj;
  420. X    
  421. X    obj = find_by_widget(w);  
  422. X    obj->value = strdupl((char *) XawDialogGetValueString(w));
  423. }
  424. X
  425. /*
  426. X * this routine gets called whenever we press return
  427. X * in a dialog widget.
  428. X */
  429. void return_key_callback( w, event, params, num_params)
  430. X     Widget w;
  431. X     XEvent *event;
  432. X     String *params;
  433. X     Cardinal *num_params;
  434. {
  435. X    Objdef *object;
  436. X    Widget dialog = XtParent(w);
  437. X    extern int quitflag;
  438. X   
  439. X    object = find_by_widget(dialog);  
  440. X    /* get the value of the dialog */
  441. X    object->value = 
  442. X      strdupl((char *) XawDialogGetValueString(object->widgetname));
  443. X
  444. X    if (perform_actions(object->name,object->action,1) && !quitflag)
  445. X      quit_xtpanel();
  446. X    return;
  447. }
  448. X
  449. void dialog_update(object,value)
  450. Objdef *object;
  451. char *value;
  452. {
  453. X    char *label;
  454. X    Arg args[10];
  455. X    int narg;
  456. X    
  457. X    narg=0;
  458. X    XtSetArg(args[narg], XtNvalue, value); narg++;
  459. X    XtSetValues(object->widgetname,args,narg);
  460. }
  461. SHAR_EOF
  462. chmod 0664 xtpanel/dialog.c ||
  463. echo 'restore of xtpanel/dialog.c failed'
  464. Wc_c="`wc -c < 'xtpanel/dialog.c'`"
  465. test 4381 -eq "$Wc_c" ||
  466.     echo 'xtpanel/dialog.c: original size 4381, current size' "$Wc_c"
  467. fi
  468. # ============= xtpanel/list.c ==============
  469. if test -f 'xtpanel/list.c' -a X"$1" != X"-c"; then
  470.     echo 'x - skipping xtpanel/list.c (File already exists)'
  471. else
  472. echo 'x - extracting xtpanel/list.c (Text)'
  473. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/list.c' &&
  474. /*
  475. X * Copyright 1992 the Board of Trustees of the Leland Stanford Junior
  476. X * University. Official permission to use this software is included in
  477. X * the documentation. It authorizes you to use this file for any
  478. X * non-commercial purpose, provided that this copyright notice is not
  479. X * removed and that any modifications made to this file are commented
  480. X * and dated in the style of the example below.
  481. X */
  482. X
  483. /*
  484. X *
  485. X *  source file:   ./xtpanel/list.c
  486. X *
  487. X * Steve Cole, Dave Nichols (SEP), August 28 1992
  488. X *      Inserted this sample edit history entry.
  489. X *      Please log any further modifications made to this file:
  490. X * Steve Cole, Dave Nichols (SEP), November 20 1992 -  version 2.00
  491. X * 1) added new objects: toggle, scrollbar, graph.
  492. X * 2) added new actions: ASSIGN, SET.
  493. X * 3) objects can have multiple actions.
  494. X * 4) backquoted strings in actions get executed at action time.
  495. X */
  496. #include <X11/Intrinsic.h>
  497. #include <X11/StringDefs.h>
  498. X
  499. #include <X11/Xaw/Box.h>
  500. #include <X11/Xaw/Cardinals.h>
  501. #include <X11/Xaw/Label.h>
  502. #include <X11/Xaw/List.h>
  503. #include <X11/Xaw/Viewport.h>
  504. X
  505. #include "object.h" 
  506. #include "item.h" 
  507. #include "tree.h"
  508. #include "builders.h"
  509. X
  510. void build_list(root,parent)
  511. X     entry *root;
  512. X     Widget parent;
  513. {
  514. X    Objdef *object;
  515. X    entry *curr, *lower;
  516. X    char *label, *value;
  517. X    struct itemdef *item;
  518. X    struct itemizedinfo *list_info;
  519. X    Arg args[10];
  520. X    int narg;
  521. X    Widget box,viewport,list;
  522. X    int first;
  523. X    char defname[12];
  524. X    static int numlist=1;
  525. X    int nitem=0;
  526. X    String * liststring = NULL; 
  527. X    int allocated_items = 0;
  528. X    extern void list_callback();
  529. X    extern void list_update();
  530. X    
  531. X    /* list gets its own box */
  532. X    box = XtCreateManagedWidget("listbox",boxWidgetClass,parent,NULL,ZERO);
  533. X    
  534. X    /* create new object */
  535. X    object = new_object();
  536. X
  537. X    /* construct default button name */
  538. X    sprintf(defname,"list%d",numlist++);
  539. X    
  540. X    /* find label, name, action in tree */
  541. X    object->name = get_value(root,"name",defname);
  542. X    label = get_value(root,"label",object->name);
  543. X    object->action = parse_actions(object->name,root);
  544. X    list_info = (struct itemizedinfo*) 
  545. X            malloc( sizeof( struct itemizedinfo ) );
  546. X    list_info->firstitem = (struct itemdef*) 0;
  547. X    object->info = list_info;
  548. X    
  549. X    /* the list label */
  550. X    narg = 0;
  551. X    XtSetArg(args[narg], XtNborderWidth, 0); narg++;
  552. X    XtSetArg(args[narg], XtNlabel, label); narg++;
  553. X    (void) XtCreateManagedWidget(object->name,labelWidgetClass,
  554. X                  box,args,narg);
  555. X    
  556. X    /* create the list in a viewport */
  557. X    narg=0;
  558. X    XtSetArg(args[narg], XtNallowHoriz, TRUE ); narg++;
  559. X    XtSetArg(args[narg], XtNallowVert, TRUE ); narg++;
  560. X    /* common parameters */
  561. X    common_tags(root,args,&narg,SET_ALL);
  562. X
  563. X    viewport = XtCreateManagedWidget( object->name,viewportWidgetClass,
  564. X                     box,args,narg);
  565. X    narg=0;
  566. X    /* common parameters */
  567. X    common_tags(root,args,&narg,SET_ALL);
  568. X    list = XtCreateManagedWidget(object->name,listWidgetClass,viewport,
  569. X                 args,narg);
  570. X    
  571. X    /* first parse any itemlist entries into items */
  572. X    parse_itemlist( root );
  573. X    
  574. X    /* loop over again to get items */
  575. X    for (curr = get_next(root,"item",(entry*) 0), nitem=0; 
  576. X     curr != ((entry*) 0); 
  577. X     curr = get_next(root,"item",curr), nitem++){
  578. X    
  579. X    /* construct default item name */
  580. X    sprintf(defname,"item%d",nitem+1);
  581. X    
  582. X    /* allocate structure to hold info for list item */
  583. X    item =  new_item(list_info);
  584. X    
  585. X    /* find label, value in the next level of the tree */
  586. X    label = get_value(curr,"label",defname);
  587. X    item->value = get_value(curr,"value",label);
  588. X    
  589. X    /* add an item */
  590. X    if (nitem == allocated_items) {
  591. X        allocated_items += 5;
  592. X        liststring = (String *) XtRealloc((char *)liststring, 
  593. X                       sizeof(String) * allocated_items);
  594. X    }
  595. X    liststring[nitem] = XtNewString(label);
  596. X    XawListChange(list, liststring, nitem+1, 0, True);
  597. X    
  598. X    item->label = strdupl(label);
  599. X    item->widgetname = list;
  600. X    /* callback routine needs to know the object name */
  601. X    item->object = object;
  602. X    
  603. X    /* info structure points to first item for find_item routine */
  604. X    if (nitem == 0) list_info->firstitem = item;
  605. X    
  606. X    /* value is default; we select the button whose value matches this */
  607. X    if (nitem == 0) value = get_value(root,"value",item->value);
  608. X    
  609. X    }
  610. X    
  611. X    /* loop over items - look for one that matches the default */
  612. X    for (item = list_info->firstitem,nitem=0; 
  613. X         item != (struct itemdef*) 0; item=item->next,nitem++) {
  614. X        if (!strcmp(item->value,value)) {
  615. X            XawListHighlight(list,nitem);
  616. X            object->value = value;
  617. X        }
  618. X    }
  619. X    
  620. X    XtAddCallback( list, XtNcallback, list_callback, (XtPointer) object );
  621. X    object->widgetname = list;
  622. X    object->updater = list_update;
  623. }
  624. X
  625. void
  626. X  list_callback(widget, client_data, callData)
  627. Widget widget;
  628. XXtPointer client_data, callData;
  629. {
  630. X    Objdef *object;
  631. X    XawListReturnStruct *item;
  632. X    struct itemdef *listitem;
  633. X    Arg arg[1];
  634. X    int num;
  635. X    extern int quitflag;
  636. X    
  637. X    object = (Objdef *) client_data;
  638. X    /* XawListReturnStruct just tells us the label */
  639. X    item = (XawListReturnStruct *) callData;
  640. X    
  641. X    /* find the item whose label matches */
  642. X    listitem = find_item(object,item->string);
  643. X    
  644. X    /* get the value of the text field */
  645. X    object->value = strdupl((char *) listitem->value);
  646. X    
  647. X    if (perform_actions(object->name,object->action,1) && !quitflag)
  648. X       quit_xtpanel();
  649. }
  650. X
  651. void list_update(object,value)
  652. Objdef *object;
  653. char *value;
  654. {
  655. X    struct itemdef *item;
  656. X    struct itemizedinfo *list_info;
  657. X    Arg args[10];
  658. X    int narg;
  659. X    int nitem=0;
  660. X    
  661. X    list_info = object->info;
  662. X
  663. X    /* loop over items - look for one that matches the value */
  664. X    for (item = list_info->firstitem,nitem=0; 
  665. X         item != (struct itemdef*) 0; item=item->next,nitem++) {
  666. X        if (!strcmp(item->value,value)) {
  667. X        XawListHighlight(object->widgetname,nitem);
  668. X               object->value = value;
  669. X        }
  670. X    }
  671. X    
  672. }
  673. SHAR_EOF
  674. chmod 0664 xtpanel/list.c ||
  675. echo 'restore of xtpanel/list.c failed'
  676. Wc_c="`wc -c < 'xtpanel/list.c'`"
  677. test 5904 -eq "$Wc_c" ||
  678.     echo 'xtpanel/list.c: original size 5904, current size' "$Wc_c"
  679. fi
  680. # ============= xtpanel/xtpanel-examples.script.sed ==============
  681. if test -f 'xtpanel/xtpanel-examples.script.sed' -a X"$1" != X"-c"; then
  682.     echo 'x - skipping xtpanel/xtpanel-examples.script.sed (File already exists)'
  683. else
  684. echo 'x - extracting xtpanel/xtpanel-examples.script.sed (Text)'
  685. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/xtpanel-examples.script.sed' &&
  686. #!/bin/csh -f
  687. X
  688. if( ! -d SYS_XTPANELDIR/examples ) then
  689. X   echo ""
  690. X   echo " It looks like someone has moved the system xtpanel directory"
  691. X   echo " It used to be in SYS_XTPANELDIR/examples "
  692. X   echo " You need to update this shell ( $0 )  "
  693. X   echo " by rebuilding the software."
  694. X   echo ""
  695. X   exit -1
  696. endif
  697. X
  698. cd SYS_XTPANELDIR/examples
  699. X
  700. xtpanel < all_examples
  701. SHAR_EOF
  702. chmod 0664 xtpanel/xtpanel-examples.script.sed ||
  703. echo 'restore of xtpanel/xtpanel-examples.script.sed failed'
  704. Wc_c="`wc -c < 'xtpanel/xtpanel-examples.script.sed'`"
  705. test 360 -eq "$Wc_c" ||
  706.     echo 'xtpanel/xtpanel-examples.script.sed: original size 360, current size' "$Wc_c"
  707. fi
  708. # ============= xtpanel/item.h ==============
  709. if test -f 'xtpanel/item.h' -a X"$1" != X"-c"; then
  710.     echo 'x - skipping xtpanel/item.h (File already exists)'
  711. else
  712. echo 'x - extracting xtpanel/item.h (Text)'
  713. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/item.h' &&
  714. #ifndef ITEM_H
  715. #define ITEM_H
  716. X
  717. #include "object.h"
  718. X
  719. typedef struct itemizedinfo {
  720. X    struct itemdef* firstitem;
  721. X    };
  722. X
  723. typedef struct itemdef {
  724. X    char* label;
  725. X    char* value;
  726. X    Widget widgetname;
  727. X    Objdef* object;
  728. X    struct itemdef* next;
  729. X    } _idef;
  730. X
  731. X
  732. #ifndef _NO_PROTO
  733. X
  734. extern struct itemdef* find_item( Objdef*, char * );
  735. extern struct itemdef* new_item( struct itemizedinfo* info );
  736. X
  737. #else
  738. X
  739. extern struct itemdef* find_item();
  740. extern struct itemdef* new_item();
  741. X
  742. #endif
  743. X
  744. X
  745. X
  746. #endif
  747. SHAR_EOF
  748. chmod 0664 xtpanel/item.h ||
  749. echo 'restore of xtpanel/item.h failed'
  750. Wc_c="`wc -c < 'xtpanel/item.h'`"
  751. test 471 -eq "$Wc_c" ||
  752.     echo 'xtpanel/item.h: original size 471, current size' "$Wc_c"
  753. fi
  754. # ============= xtpanel/menubutton.c ==============
  755. if test -f 'xtpanel/menubutton.c' -a X"$1" != X"-c"; then
  756.     echo 'x - skipping xtpanel/menubutton.c (File already exists)'
  757. else
  758. echo 'x - extracting xtpanel/menubutton.c (Text)'
  759. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/menubutton.c' &&
  760. /*
  761. X * Copyright 1992 the Board of Trustees of the Leland Stanford Junior
  762. X * University. Official permission to use this software is included in
  763. X * the documentation. It authorizes you to use this file for any
  764. X * non-commercial purpose, provided that this copyright notice is not
  765. X * removed and that any modifications made to this file are commented
  766. X * and dated in the style of the example below.
  767. X */
  768. X
  769. /*
  770. X *
  771. X *  source file:   ./xtpanel/menubutton.c
  772. X *
  773. X * Steve Cole, Dave Nichols (SEP), August 28 1992
  774. X *      Inserted this sample edit history entry.
  775. X *      Please log any further modifications made to this file:
  776. X * Steve Cole, Dave Nichols (SEP), November 20 1992 -  version 2.00
  777. X * 1) added new objects: toggle, scrollbar, graph.
  778. X * 2) added new actions: ASSIGN, SET.
  779. X * 3) objects can have multiple actions.
  780. X * 4) backquoted strings in actions get executed at action time.
  781. X */
  782. X
  783. #include <X11/Intrinsic.h>
  784. #include <X11/StringDefs.h>
  785. #include <X11/bitmaps/dot>
  786. X
  787. #include <X11/Xaw/Cardinals.h>
  788. #include <X11/Xaw/MenuButton.h>
  789. #include <X11/Xaw/SimpleMenu.h>
  790. #include <X11/Xaw/SmeBSB.h>
  791. X
  792. #include "object.h" 
  793. #include "item.h"
  794. #include "tree.h"
  795. #include "builders.h"
  796. X
  797. void build_menubutton(root,parent)
  798. X     entry *root;
  799. X     Widget parent;
  800. {
  801. X    Objdef *object;
  802. X    entry *curr, *lower;
  803. X    char *label, *value;
  804. X    struct itemizedinfo *menu_info;
  805. X    struct itemdef *item;
  806. X    Arg args[10];
  807. X    int narg;
  808. X    Widget button, menu, menuitem;
  809. X    int first;
  810. X    char defname[14];
  811. X    static int nummenu=1;
  812. X    int nitem=0;
  813. X    Pixmap mark;
  814. X    extern void menubutton_callback();
  815. X    extern void menubutton_update();
  816. X    
  817. X    /* create new object */
  818. X    object = new_object();
  819. X
  820. X    /* construct default button name */
  821. X    sprintf(defname,"menubutton%d",nummenu++);
  822. X    
  823. X    /* find label, name, action in tree */
  824. X    object->name = get_value(root,"name",defname);
  825. X    label = get_value(root,"label",object->name);
  826. X    object->action = parse_actions(object->name,root);
  827. X    menu_info = (struct itemizedinfo*) 
  828. X             malloc( sizeof( struct itemizedinfo ) );
  829. X    menu_info->firstitem = (struct itemdef*) 0;
  830. X    
  831. X    object->info = menu_info;
  832. X    object->updater = menubutton_update;
  833. X    
  834. X    /* create the button and the menu */
  835. X    narg = 0;
  836. X    XtSetArg(args[narg], XtNlabel, label); narg++;
  837. X    /* common parameters */
  838. X    common_tags(root,args,&narg,SET_ALL);
  839. X
  840. X    button = XtCreateManagedWidget(object->name,menuButtonWidgetClass,
  841. X                 parent,args,narg);
  842. X    menu = XtCreatePopupShell("menu",simpleMenuWidgetClass,button,NULL,ZERO);
  843. X    
  844. X    /* first parse any itemlist entries into items */
  845. X    parse_itemlist( root );
  846. X    
  847. X    /* loop over again to get items */
  848. X    for (curr = get_next(root,"item",(entry*) 0), nitem=0; 
  849. X     curr != ((entry*) 0); 
  850. X     curr = get_next(root,"item",curr), nitem++){
  851. X    
  852. X    /* construct default item name */
  853. X    sprintf(defname,"item%d",nitem+1);
  854. X    
  855. X    /* allocate structure to hold info for menu item */
  856. X    item = new_item(menu_info);
  857. X    
  858. X    /* find label, value in the next level of the tree */
  859. X    label = get_value(curr,"label",defname);
  860. X    item->value = get_value(curr,"value",label);
  861. X    
  862. X    /* add an item */
  863. X    narg = 0;
  864. X
  865. X        /* common parameters */
  866. X        common_tags(curr,args,&narg,SET_ALL);
  867. X
  868. X    XtSetArg(args[narg], XtNlabel, label); narg++;
  869. X    menuitem =  XtCreateManagedWidget(object->name,smeBSBObjectClass,
  870. X                          menu,args,narg);
  871. X
  872. X    XtAddCallback( menuitem, XtNcallback, menubutton_callback, 
  873. X              (XtPointer) item );
  874. X
  875. X    item->label = strdupl(label);
  876. X    item->widgetname = menuitem;
  877. X    /* callback routine needs to know the object name */
  878. X    item->object = object;
  879. X    
  880. X    /* info structure points to first item for find_item routine */
  881. X    if (nitem == 0) menu_info->firstitem = item;
  882. X    
  883. X    /* value is default; we select the button whose value matches this */
  884. X    if (nitem == 0) value = get_value(root,"value",item->value);
  885. X    
  886. X    /* check to see if this is the default item */
  887. X    /* indicate the default item with an X */
  888. X    narg = 0;
  889. X    
  890. X        if (!strcmp(value,item->value)) {
  891. X         mark = XCreateBitmapFromData(XtDisplay(parent),
  892. X                 RootWindowOfScreen(XtScreen(parent)),
  893. X                 (char *) dot_bits,
  894. X                 dot_width, dot_height);
  895. X        XtSetArg(args[narg], XtNleftBitmap, mark); narg++;
  896. X        object->value = value;
  897. X        XtSetValues(menuitem,args,narg);
  898. X    }
  899. X    }
  900. }
  901. X
  902. extern Widget toplevel;
  903. X
  904. void
  905. X  menubutton_callback(widget, client_data, callData)
  906. Widget widget;
  907. XXtPointer client_data, callData;
  908. {
  909. X    Objdef *object;
  910. X    struct itemdef *menuitem;
  911. X    struct itemizedinfo *menu_info;
  912. X    Arg args[10];
  913. X    int narg;
  914. X    Pixmap mark;
  915. X    extern int quitflag;
  916. X    extern void unmark_all_items();
  917. X    
  918. X    menuitem = (struct itemdef *) client_data;
  919. X    object = (Objdef *) menuitem->object;
  920. X    menu_info = (struct itemizedinfo *) object->info;
  921. X    
  922. X    /* first unmark the previous choice, if any */
  923. X    unmark_all_items(menu_info);
  924. X    
  925. X    object->value = strdupl((char *) menuitem->value);
  926. X    if (perform_actions(object->name,object->action,1) && !quitflag)
  927. X        quit_xtpanel();
  928. X    
  929. X    /* indicate the current choice */
  930. X    mark = XCreateBitmapFromData(XtDisplay(toplevel),
  931. X                 RootWindowOfScreen(XtScreen(toplevel)),
  932. X                 (char *) dot_bits,
  933. X                 dot_width, dot_height);
  934. X    narg = 0;
  935. X    XtSetArg(args[narg], XtNleftBitmap, mark); narg++;
  936. X    XtSetValues(menuitem->widgetname,args,narg);
  937. X    
  938. }
  939. X
  940. void
  941. X  unmark_all_items(menu_info)
  942. struct itemizedinfo *menu_info;
  943. {
  944. X    struct itemdef *item;
  945. X    Arg args[10];
  946. X    int narg;
  947. X    
  948. X    for( item=menu_info->firstitem; 
  949. X     item != (struct itemdef*)0; 
  950. X     item = item->next )
  951. X      {
  952. X      narg = 0;
  953. X      XtSetArg(args[narg], XtNleftBitmap, None); narg++;
  954. X      XtSetValues(item->widgetname,args,narg);
  955. X      }
  956. }
  957. X
  958. void
  959. X  menubutton_update(object,value)
  960. Objdef* object;
  961. char* value;
  962. {
  963. X    struct itemizedinfo *menu_info;
  964. X    struct itemdef *item;
  965. X    Arg args[10];
  966. X    int narg;
  967. X    Pixmap mark;
  968. X    
  969. X    menu_info = object->info;
  970. X
  971. X    for( item=menu_info->firstitem; 
  972. X     item != (struct itemdef*)0; 
  973. X     item = item->next )
  974. X      {
  975. X    if (!strcmp(item->value,value)) {
  976. X      unmark_all_items(menu_info);
  977. X      narg = 0;
  978. X      XtSetArg(args[narg], XtNleftBitmap, None); narg++;
  979. X      XtSetValues(item->widgetname,args,narg);
  980. X      mark = XCreateBitmapFromData(XtDisplay(toplevel),
  981. X                 RootWindowOfScreen(XtScreen(toplevel)),
  982. X                 (char *) dot_bits,
  983. X                 dot_width, dot_height);
  984. X      narg = 0;
  985. X      XtSetArg(args[narg], XtNleftBitmap, mark); narg++;
  986. X      XtSetValues(item->widgetname,args,narg);
  987. X    }
  988. X      }
  989. }
  990. SHAR_EOF
  991. chmod 0664 xtpanel/menubutton.c ||
  992. echo 'restore of xtpanel/menubutton.c failed'
  993. Wc_c="`wc -c < 'xtpanel/menubutton.c'`"
  994. test 6487 -eq "$Wc_c" ||
  995.     echo 'xtpanel/menubutton.c: original size 6487, current size' "$Wc_c"
  996. fi
  997. # ============= xtpanel/message.c ==============
  998. if test -f 'xtpanel/message.c' -a X"$1" != X"-c"; then
  999.     echo 'x - skipping xtpanel/message.c (File already exists)'
  1000. else
  1001. echo 'x - extracting xtpanel/message.c (Text)'
  1002. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/message.c' &&
  1003. /*
  1004. X * Copyright 1992 the Board of Trustees of the Leland Stanford Junior
  1005. X * University. Official permission to use this software is included in
  1006. X * the documentation. It authorizes you to use this file for any
  1007. X * non-commercial purpose, provided that this copyright notice is not
  1008. X * removed and that any modifications made to this file are commented
  1009. X * and dated in the style of the example below.
  1010. X */
  1011. X
  1012. /*
  1013. X *
  1014. X *  source file:   ./xtpanel/message.c
  1015. X *
  1016. X * Steve Cole, Dave Nichols (SEP), August 28 1992
  1017. X *      Inserted this sample edit history entry.
  1018. X *      Please log any further modifications made to this file:
  1019. X * Steve Cole, Dave Nichols (SEP), November 20 1992 -  version 2.00
  1020. X * 1) added new objects: toggle, scrollbar, graph.
  1021. X * 2) added new actions: ASSIGN, SET.
  1022. X * 3) objects can have multiple actions.
  1023. X * 4) backquoted strings in actions get executed at action time.
  1024. X */
  1025. X
  1026. #include <X11/Intrinsic.h>
  1027. #include <X11/StringDefs.h>
  1028. X
  1029. #include <X11/Xaw/Cardinals.h>
  1030. #include <X11/Xaw/Label.h>
  1031. X
  1032. #include "object.h"
  1033. #include "tree.h"
  1034. #include "builders.h"
  1035. X
  1036. void build_message(root,parent)
  1037. X     entry *root;
  1038. X     Widget parent;
  1039. {
  1040. X    Objdef *object;
  1041. X    char *name,*label;
  1042. X    Widget message;
  1043. X    Arg args[10];
  1044. X    int narg;
  1045. X    char defname[12];
  1046. X    int numess=1;
  1047. X    extern void message_update();
  1048. X    
  1049. X    /* create new object */
  1050. X    object = new_object();
  1051. X
  1052. X    /* construct default dialog name */
  1053. X    sprintf(defname,"message%d",numess++);
  1054. X    
  1055. X    /* find label, name in tree */
  1056. X    object->name = get_value(root,"name",defname);
  1057. X    object->value = get_value(root,"value","");
  1058. X
  1059. X    /* messages do not have a border drawn around them */
  1060. X    narg = 0;
  1061. X    XtSetArg(args[narg], XtNborderWidth, 0); narg++;
  1062. X    XtSetArg(args[narg], XtNlabel, object->value); narg++;
  1063. X    /* common parameters */
  1064. X    common_tags(root,args,&narg,SET_ALL);
  1065. X    
  1066. X    message = XtCreateManagedWidget(object->name,labelWidgetClass,
  1067. X                    parent,args,narg);
  1068. X
  1069. X    object->widgetname = message;
  1070. X    object->updater = message_update;
  1071. }
  1072. X
  1073. void message_update(object,value)
  1074. Objdef* object;
  1075. char* value;
  1076. {
  1077. X    Arg args[10];
  1078. X    int narg;
  1079. X
  1080. X    narg = 0;
  1081. X    XtSetArg(args[narg], XtNlabel, value); narg++;
  1082. X    XtSetValues(object->widgetname,args,narg);
  1083. }
  1084. X
  1085. SHAR_EOF
  1086. chmod 0664 xtpanel/message.c ||
  1087. echo 'restore of xtpanel/message.c failed'
  1088. Wc_c="`wc -c < 'xtpanel/message.c'`"
  1089. test 2221 -eq "$Wc_c" ||
  1090.     echo 'xtpanel/message.c: original size 2221, current size' "$Wc_c"
  1091. fi
  1092. # ============= xtpanel/slider.c ==============
  1093. if test -f 'xtpanel/slider.c' -a X"$1" != X"-c"; then
  1094.     echo 'x - skipping xtpanel/slider.c (File already exists)'
  1095. else
  1096. echo 'x - extracting xtpanel/slider.c (Text)'
  1097. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/slider.c' &&
  1098. /*
  1099. X * Copyright 1992 the Board of Trustees of the Leland Stanford Junior
  1100. X * University. Official permission to use this software is included in
  1101. X * the documentation. It authorizes you to use this file for any
  1102. X * non-commercial purpose, provided that this copyright notice is not
  1103. X * removed and that any modifications made to this file are commented
  1104. X * and dated in the style of the example below.
  1105. X */
  1106. X
  1107. /*
  1108. X *
  1109. X *  source file:   ./xtpanel/slider.c
  1110. X *
  1111. X * Steve Cole, Dave Nichols (SEP), August 28 1992
  1112. X *      Inserted this sample edit history entry.
  1113. X *      Please log any further modifications made to this file:
  1114. X * Steve Cole, Dave Nichols (SEP), November 20 1992 -  version 2.00
  1115. X * 1) added new objects: toggle, scrollbar, graph.
  1116. X * 2) added new actions: ASSIGN, SET.
  1117. X * 3) objects can have multiple actions.
  1118. X * 4) backquoted strings in actions get executed at action time.
  1119. X */
  1120. X
  1121. #include <X11/Intrinsic.h>
  1122. #include <X11/StringDefs.h>
  1123. X
  1124. #include <X11/Xaw/Box.h>
  1125. #include <X11/Xaw/Cardinals.h>
  1126. #include <X11/Xaw/Command.h>
  1127. #include <X11/Xaw/Label.h>
  1128. #include <X11/Xaw/Scrollbar.h>
  1129. X
  1130. #include "object.h" 
  1131. #include "tree.h"
  1132. #include "builders.h"
  1133. X
  1134. #include <stdio.h>
  1135. X
  1136. typedef struct sliderinfo {
  1137. X    float minval;
  1138. X    float maxval;
  1139. X    Widget label;
  1140. X    char* format;
  1141. X    char* type;
  1142. };
  1143. X
  1144. void build_slider(root,parent,type)
  1145. X     entry *root;
  1146. X     Widget parent;
  1147. X     char *type;
  1148. {
  1149. X    Objdef *object;
  1150. X    entry *curr;
  1151. X    char* label;
  1152. X    struct sliderinfo *slider_info;
  1153. X    Arg args[10];
  1154. X    int narg;
  1155. X    Widget box, scrollbar, vlabel, button;
  1156. X    float valmin,valmax,val,top;
  1157. X    char text[100];
  1158. X    int width,height;
  1159. X    char *orient;
  1160. X    char defname[12];
  1161. X    static int numslid=1;
  1162. X    static int numscroll=1;
  1163. X    extern void slider_button_callback();
  1164. X    extern void slider_jump_callback();
  1165. X    extern void slider_scroll_callback();
  1166. X    extern void slider_update();
  1167. X    
  1168. X    /* slider gets its own box */
  1169. X    if (!strcmp(type,"slider")) {
  1170. X      narg = 0;
  1171. X      box = XtCreateManagedWidget("sliderbox",boxWidgetClass,
  1172. X                 parent,args,narg);
  1173. X    }
  1174. X    else {
  1175. X      box = parent;
  1176. X    }
  1177. X    
  1178. X    /* create new object */
  1179. X    object = new_object();
  1180. X
  1181. X    /* construct default slider name */
  1182. X    if (!strcmp(type,"slider")) {
  1183. X       sprintf(defname,"slider%d",numslid++);
  1184. X    } else {
  1185. X       sprintf(defname,"scrollbar%d",numscroll++);
  1186. X    }
  1187. X    
  1188. X    /* find label, name, action in tree */
  1189. X    object->name = get_value(root,"name",defname);
  1190. X    label = get_value(root,"label",object->name);
  1191. X    object->action = parse_actions(object->name,root);
  1192. X    slider_info = (struct sliderinfo*) 
  1193. X                   malloc( sizeof( struct sliderinfo ) );
  1194. X    object->info = slider_info;
  1195. X    slider_info->minval = ((float) atof(get_value(root,"min","0")));
  1196. X    slider_info->maxval = ((float) atof(get_value(root,"max","1")));
  1197. X    slider_info->label = (Widget)0;
  1198. X    /* slider value defaults to minimum */
  1199. X    val = (float) atof(get_value(root,"value",get_value(root,"min","0")));
  1200. X    slider_info->format = get_value(root,"format","%f");
  1201. X    /* save type (scrollbar, slider) for use by callback routines */
  1202. X    slider_info->type = strdupl(type);
  1203. X    
  1204. X    /* the slider label */
  1205. X    /* for type scrollbar, no label is displayed */
  1206. X    if (!strcmp(type,"slider")) {
  1207. X    narg = 0;
  1208. X    XtSetArg(args[narg], XtNlabel, label); narg++;
  1209. X    XtSetArg(args[narg], XtNborderWidth, 0); narg++;
  1210. X    (void) XtCreateManagedWidget(object->name,labelWidgetClass,box,
  1211. X                     args,narg);
  1212. X    }
  1213. X    
  1214. X    /* determine the correct starting point for the slider */
  1215. X    narg = 0;
  1216. X    top = val/slider_info->maxval;
  1217. X    if (sizeof(float) > sizeof(XtArgVal))
  1218. X      {
  1219. X      XtSetArg(args[narg], XtNtopOfThumb, top); narg++;
  1220. X      }
  1221. X    else
  1222. X      {
  1223. X      XtArgVal * l_top = (XtArgVal *) ⊤
  1224. X      XtSetArg(args[narg], XtNtopOfThumb, *l_top); narg++;
  1225. X      }
  1226. X
  1227. X    /* common parameters */
  1228. X    common_tags(root,args,&narg,SET_FG|SET_BG|SET_BORDER);
  1229. X
  1230. X    /* height, width, orient */
  1231. X    /* done here instead of common_tags so we could have defaults */
  1232. X    height = (int) atoi(get_value(root,"height","25"));
  1233. X    width = (int) atoi(get_value(root,"width","100"));
  1234. X    orient = get_value(root,"orientation","horizontal");
  1235. X    XtSetArg(args[narg], XtNlength, width); narg++;
  1236. X    XtSetArg(args[narg], XtNthickness, height); narg++;
  1237. X    /* the SetTag routine in builders.c does the necessary conversion */
  1238. X    SetTag(box,args,&narg,"orientation",orient);
  1239. X
  1240. X    /* slider is actually an athena scrollbar widget */
  1241. X    scrollbar = XtCreateManagedWidget(object->name,scrollbarWidgetClass,
  1242. X                      box,args,narg);
  1243. X    
  1244. X    /* jump callback is for middle mouse button */
  1245. X    XtAddCallback( scrollbar, XtNjumpProc, slider_jump_callback, 
  1246. X          (XtPointer) object );
  1247. X    
  1248. X    /* scroll callback is for incremental scrolling with left and 
  1249. X       right buttons */
  1250. X    XtAddCallback( scrollbar, XtNscrollProc, slider_scroll_callback, 
  1251. X          (XtPointer) object );
  1252. X    
  1253. X    /* set to the correct starting point */
  1254. X    (void) XawScrollbarSetThumb(scrollbar,
  1255. X    (val-slider_info->minval)/
  1256. X             (slider_info->maxval-slider_info->minval),-1.);
  1257. X    
  1258. X    /* add a button to print out slider value */
  1259. X    if (!strcmp(type,"slider")) {
  1260. X    button = XtCreateManagedWidget(object->name,commandWidgetClass,box,
  1261. X                       NULL,ZERO);
  1262. X    XtAddCallback(button, XtNcallback, slider_button_callback, 
  1263. X              (XtPointer) object );
  1264. X    }
  1265. X    
  1266. X    sprintf( text, slider_info->format, (float) val);
  1267. X    object->value = strdupl(text);
  1268. X    object->widgetname = scrollbar;
  1269. X    object->updater = slider_update;
  1270. X    
  1271. X    /* indicate the slider value using another label */
  1272. X    if (!strcmp(type,"slider")) {
  1273. X    narg = 0;
  1274. X    XtSetArg( args[narg], XtNlabel, object->value); narg++;
  1275. X    vlabel = XtCreateManagedWidget(object->name,labelWidgetClass,box,
  1276. X                       args,narg);
  1277. X    slider_info->label = vlabel;
  1278. X    }
  1279. }
  1280. X
  1281. void
  1282. X  slider_jump_callback(widget, client_data, top_ptr)
  1283. Widget widget;
  1284. XXtPointer client_data, top_ptr;
  1285. {
  1286. X    Objdef *object;
  1287. X    struct sliderinfo *slider_info;
  1288. X    Arg arg[1];
  1289. X    char text[20];
  1290. X    /* top is new location of slider */
  1291. X    float top = *((float *) top_ptr);
  1292. X    object = (Objdef *) client_data;
  1293. X    slider_info = (struct sliderinfo *) object->info;
  1294. X    /* compute new value */
  1295. X    sprintf( text, slider_info->format, 
  1296. X        (float) slider_info->minval + 
  1297. X        top*(slider_info->maxval - slider_info->minval));
  1298. X    object->value = strdupl(text);
  1299. X    /* set the label to the new value */
  1300. X    if (slider_info->label != (Widget) 0) {
  1301. X    XtSetArg( arg[0], XtNlabel, text );
  1302. X    XtSetValues( slider_info->label, arg, ONE );
  1303. X    }
  1304. X    if (!strcmp(slider_info->type,"scrollbar")) 
  1305. X       perform_actions(object->name,object->action,1);
  1306. }
  1307. X
  1308. void
  1309. X  slider_scroll_callback(widget, client_data, pos_ptr)
  1310. Widget widget;
  1311. XXtPointer client_data, pos_ptr;
  1312. {
  1313. X    Objdef *object;
  1314. X    struct sliderinfo *slider_info;
  1315. X    Arg arg[1];
  1316. X    char text[10];
  1317. X    float top;
  1318. X    Dimension len;
  1319. X    int pos;
  1320. X    pos = (int) pos_ptr;
  1321. X    object = (Objdef *) client_data;
  1322. X    slider_info = (struct sliderinfo *) object->info;
  1323. X    /* get the current position of the slider */
  1324. X    XtSetArg( arg[0], XtNtopOfThumb, &top );
  1325. X    XtGetValues( object->widgetname, arg, ONE );
  1326. X    /* now compute new position - 5% change */
  1327. X    top -= pos/abs(pos) * 0.05;
  1328. X    if (top > 1.) top = 1.;
  1329. X    if (top < 0.) top = 0.;
  1330. X    /* compute new value */
  1331. X    sprintf( text, slider_info->format, 
  1332. X        (float) slider_info->minval +
  1333. X        top*(slider_info->maxval - slider_info->minval));
  1334. X    object->value = strdupl(text);
  1335. X    /* update label */
  1336. X    if (slider_info->label != (Widget) 0) {
  1337. X    XtSetArg( arg[0], XtNlabel, text );
  1338. X    XtSetValues( slider_info->label, arg, ONE );
  1339. X    }
  1340. X    /* update the slider */
  1341. X    if (sizeof(float) > sizeof(XtArgVal))
  1342. X      {
  1343. X      XtSetArg(arg[0], XtNtopOfThumb, top);
  1344. X      }
  1345. X    else
  1346. X      {
  1347. X      XtArgVal * l_top = (XtArgVal *) ⊤
  1348. X      XtSetArg(arg[0], XtNtopOfThumb, *l_top);
  1349. X      }
  1350. X    XtSetValues( object->widgetname, arg, ONE );
  1351. X    if (!strcmp(slider_info->type,"scrollbar")) 
  1352. X       perform_actions(object->name,object->action,1);
  1353. }
  1354. X
  1355. /* called when ok button of slider is pressed */
  1356. void
  1357. X  slider_button_callback(widget, client_data, callData)
  1358. Widget widget;
  1359. XXtPointer client_data, callData;
  1360. {
  1361. X    Objdef *object;
  1362. X    extern int quitflag;
  1363. X    
  1364. X    object = (Objdef *) client_data;
  1365. X    if ( perform_actions(object->name,object->action,1) && !quitflag ) 
  1366. X      quit_xtpanel();
  1367. }
  1368. X
  1369. void
  1370. X  slider_update(object, value)
  1371. Objdef *object;
  1372. char *value;
  1373. {
  1374. X    struct sliderinfo *slider_info;
  1375. X    Arg arg[1];
  1376. X    char text[10];
  1377. X    float top,val;
  1378. X    Dimension len;
  1379. X    int pos;
  1380. X
  1381. X    slider_info = (struct sliderinfo *) object->info;
  1382. X    sscanf( value,"%f",&val);
  1383. X    top = (val - slider_info->minval)/
  1384. X              (slider_info->maxval-slider_info->minval);
  1385. X    if (top > 1.) top = 1.;
  1386. X    if (top < 0.) top = 0.;
  1387. X    /* compute new value */
  1388. X    sprintf( text, slider_info->format, 
  1389. X        (float) slider_info->minval +
  1390. X        top*(slider_info->maxval - slider_info->minval));
  1391. X    object->value = strdupl(text);
  1392. X    /* update label */
  1393. X    if (slider_info->label != (Widget) 0) {
  1394. X    XtSetArg( arg[0], XtNlabel, text );
  1395. X    XtSetValues( slider_info->label, arg, ONE );
  1396. X    }
  1397. X    /* update the slider */
  1398. X    if (sizeof(float) > sizeof(XtArgVal))
  1399. X      {
  1400. X      XtSetArg(arg[0], XtNtopOfThumb, top);
  1401. X      }
  1402. X    else
  1403. X      {
  1404. X      XtArgVal * l_top = (XtArgVal *) ⊤
  1405. X      XtSetArg(arg[0], XtNtopOfThumb, *l_top);
  1406. X      }
  1407. X    XtSetValues( object->widgetname, arg, ONE );
  1408. }
  1409. SHAR_EOF
  1410. chmod 0664 xtpanel/slider.c ||
  1411. echo 'restore of xtpanel/slider.c failed'
  1412. Wc_c="`wc -c < 'xtpanel/slider.c'`"
  1413. test 9457 -eq "$Wc_c" ||
  1414.     echo 'xtpanel/slider.c: original size 9457, current size' "$Wc_c"
  1415. fi
  1416. # ============= xtpanel/Imake.config ==============
  1417. if test -f 'xtpanel/Imake.config' -a X"$1" != X"-c"; then
  1418.     echo 'x - skipping xtpanel/Imake.config (File already exists)'
  1419. else
  1420. echo 'x - extracting xtpanel/Imake.config (Text)'
  1421. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/Imake.config' &&
  1422. X
  1423. /* This is the directory where the system xtpanel files will be installed */
  1424. SYS_XTPANELDIR = $(LIBDIR)/xtpanel
  1425. #ifdef OW3
  1426. IMAKE_DEFINES = -DLibDir=/usr/openwin/lib -DIncRoot=/usr/openwin/include
  1427. #endif
  1428. X
  1429. SHAR_EOF
  1430. chmod 0664 xtpanel/Imake.config ||
  1431. echo 'restore of xtpanel/Imake.config failed'
  1432. Wc_c="`wc -c < 'xtpanel/Imake.config'`"
  1433. test 205 -eq "$Wc_c" ||
  1434.     echo 'xtpanel/Imake.config: original size 205, current size' "$Wc_c"
  1435. fi
  1436. # ============= xtpanel/choice.c ==============
  1437. if test -f 'xtpanel/choice.c' -a X"$1" != X"-c"; then
  1438.     echo 'x - skipping xtpanel/choice.c (File already exists)'
  1439. else
  1440. echo 'x - extracting xtpanel/choice.c (Text)'
  1441. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/choice.c' &&
  1442. /*
  1443. X * Copyright 1992 the Board of Trustees of the Leland Stanford Junior
  1444. X * University. Official permission to use this software is included in
  1445. X * the documentation. It authorizes you to use this file for any
  1446. X * non-commercial purpose, provided that this copyright notice is not
  1447. X * removed and that any modifications made to this file are commented
  1448. X * and dated in the style of the example below.
  1449. X */
  1450. X
  1451. /*
  1452. X *
  1453. X *  source file:   ./xtpanel/choice.c
  1454. X *
  1455. X * Steve Cole, Dave Nichols (SEP), August 28 1992
  1456. X *      Inserted this sample edit history entry.
  1457. X *      Please log any further modifications made to this file:
  1458. X * Steve Cole, Dave Nichols (SEP), November 20 1992 -  version 2.00
  1459. X * 1) added new objects: toggle, scrollbar, graph.
  1460. X * 2) added new actions: ASSIGN, SET.
  1461. X * 3) objects can have multiple actions.
  1462. X * 4) backquoted strings in actions get executed at action time.
  1463. X */
  1464. X
  1465. #include <X11/Intrinsic.h>
  1466. #include <X11/StringDefs.h>
  1467. X
  1468. #include <X11/Xaw/Box.h>
  1469. #include <X11/Xaw/Cardinals.h>
  1470. #include <X11/Xaw/Label.h>
  1471. #include <X11/Xaw/Toggle.h>
  1472. X
  1473. #include "object.h" 
  1474. #include "item.h"
  1475. #include "tree.h"
  1476. #include "builders.h"
  1477. X
  1478. typedef struct choicedef {
  1479. X    char* value;
  1480. X    Widget widgetname;
  1481. X    Objdef* object;
  1482. X    struct choicedef* next;
  1483. } _cdef;
  1484. X
  1485. /* translation table used for toggle widgets in a choice object */
  1486. char choice_trans[] =
  1487. X  "<EnterWindow>:   highlight(Always)\n\
  1488. X   <LeaveWindow>:   unhighlight()\n\
  1489. X   <Btn1Down>,<Btn1Up>:   set() notify()";
  1490. X
  1491. void build_choice(root,parent)
  1492. X     entry *root;
  1493. X     Widget parent;
  1494. {
  1495. X    Objdef *object;
  1496. X    entry *curr;
  1497. X    struct itemdef *item;
  1498. X    struct itemizedinfo *choice_info;
  1499. X    char *label,*value;
  1500. X    Arg args[20];
  1501. X    int narg;
  1502. X    Widget box,labl,choice1,choice2;
  1503. X    char defname[12];
  1504. X    static int numtog=1;
  1505. X    int nitem;
  1506. X    extern void choice_callback();
  1507. X    extern void choice_update();
  1508. X    
  1509. X    narg = 0;
  1510. X    /* common parameters */
  1511. X    common_tags(root,args,&narg,SET_BG | SET_ORIENT);
  1512. X
  1513. X    /* choice object gets its own box */
  1514. X    box = XtCreateManagedWidget("choicebox",boxWidgetClass,parent,args,narg);
  1515. X    
  1516. X    /* create new object */
  1517. X    object = new_object();
  1518. X
  1519. X    /* construct default button name */
  1520. X    sprintf(defname,"choice%d",numtog++);
  1521. X    
  1522. X    /* find label, name, action in tree */
  1523. X    object->name = get_value(root,"name",defname);
  1524. X    label = get_value(root,"label",object->name);
  1525. X    object->action = parse_actions(object->name,root);
  1526. X    
  1527. X    choice_info = (struct itemizedinfo*) 
  1528. X                   malloc( sizeof( struct itemizedinfo));
  1529. X    choice_info->firstitem = (struct itemdef*) 0;
  1530. X    object->info = choice_info;
  1531. X
  1532. X    /* make the label */
  1533. X    /* if label is blank, skip displaying it */
  1534. X    if (strcmp(label,"")) {
  1535. X    narg = 0;
  1536. X         XtSetArg(args[narg], XtNborderWidth, 0); narg++;
  1537. X         XtSetArg(args[narg], XtNlabel, label); narg++;
  1538. X        /* common parameters */
  1539. X        common_tags(root,args,&narg,SET_ALL);
  1540. X
  1541. X         labl = XtCreateManagedWidget(object->name,labelWidgetClass,box,
  1542. X                     args,narg);
  1543. X    }
  1544. X    
  1545. X    /* first parse any itemlist entries into items */
  1546. X    parse_itemlist( root );
  1547. X    
  1548. X    /* loop over items */
  1549. X    for (curr = get_next(root,"item",(entry*) 0), nitem=0; 
  1550. X     curr != ((entry*) 0); 
  1551. X     curr = get_next(root,"item",curr), nitem++){
  1552. X    
  1553. X    /* construct default item name */
  1554. X    sprintf(defname,"item%d",nitem+1);
  1555. X    
  1556. X    /* allocate structure to hold info for choice item */
  1557. X    item = new_item(choice_info);
  1558. X    
  1559. X    /* find label, value in the next level of the tree */
  1560. X    label = get_value(curr,"label",defname);
  1561. X    item->value = get_value(curr,"value",label);
  1562. X    
  1563. X    /* value is default; we set a button to on if its value matches this */
  1564. X    if (nitem == 0) value = get_value(root,"value",item->value);
  1565. X    
  1566. X    /* check to see if this is the default item */
  1567. X    /* choice object always needs to have one button set */
  1568. X    narg = 0;
  1569. X    if (!strcmp(value,item->value)) {
  1570. X        XtSetArg(args[narg], XtNstate, True); narg++;
  1571. X        object->value = item->value;
  1572. X    }
  1573. X    
  1574. X    /* first button stands alone; others have to point to it 
  1575. X       with radioGroup */
  1576. X    if (nitem == 0) {
  1577. X        XtSetArg(args[narg], XtNlabel, label); narg++;
  1578. X        /* radioData is used by choice_update routine */
  1579. X        XtSetArg(args[narg], XtNradioData, item->value); narg++;
  1580. X        /* common parameters */
  1581. X            common_tags(curr,args,&narg,SET_ALL);
  1582. X
  1583. X        choice1 = XtCreateManagedWidget(object->name,toggleWidgetClass,box,
  1584. X                        args,narg);
  1585. X            /* use translations */
  1586. X            XtOverrideTranslations(choice1,
  1587. X                   XtParseTranslationTable(choice_trans));
  1588. X        XtAddCallback(choice1, XtNcallback,choice_callback, 
  1589. X              (XtPointer)item );
  1590. X        item->widgetname = choice1;
  1591. X    }
  1592. X    else {
  1593. X        XtSetArg(args[narg], XtNradioGroup, choice1); narg++;
  1594. X        XtSetArg(args[narg], XtNlabel, label); narg++;
  1595. X        XtSetArg(args[narg], XtNradioData, item->value); narg++;
  1596. X        /* common parameters */
  1597. X            common_tags(curr,args,&narg,SET_ALL);
  1598. X
  1599. X        choice2 = XtCreateManagedWidget(object->name,toggleWidgetClass,
  1600. X                         box,args,narg);
  1601. X
  1602. X            /* use translations */
  1603. X            XtOverrideTranslations(choice2,
  1604. X                   XtParseTranslationTable(choice_trans));
  1605. X        XtAddCallback(choice2, XtNcallback,choice_callback, 
  1606. X              (XtPointer)item );
  1607. X        item->widgetname = choice2;
  1608. X    }
  1609. X    
  1610. X    item->object = object;
  1611. X    item->label = strdupl(label);
  1612. X        if (nitem == 0) choice_info->firstitem = item;
  1613. X
  1614. X    /* set object->widgetname to any of the choice widgets */
  1615. X    /* for use by choice_update */
  1616. X    object->widgetname = choice1;
  1617. X        object->updater = choice_update;
  1618. X    }
  1619. }
  1620. X
  1621. void choice_callback(widget, client_data, callData)
  1622. X     Widget widget;
  1623. X     XtPointer client_data, callData;
  1624. {
  1625. X    Objdef *object;
  1626. X    struct itemdef *item;
  1627. X    Arg arg[1];
  1628. X    Boolean state;
  1629. X    extern int quitflag; 
  1630. X    
  1631. X    item = (struct itemdef *) client_data;
  1632. X    object = (Objdef *) item->object;
  1633. X    /* get current state of button */
  1634. X    XtSetArg( arg[0], XtNstate, &state );
  1635. X    XtGetValues( item->widgetname, arg, ONE );
  1636. X    /* if button is now selected, perform its action */
  1637. X    if (state == TRUE) 
  1638. X      {
  1639. X      object->value = strdupl((char *) item->value);
  1640. X      if (perform_actions(object->name,object->action,1) && !quitflag) 
  1641. X        quit_xtpanel();
  1642. X      }
  1643. }
  1644. X
  1645. void choice_update(object,value)
  1646. Objdef *object;
  1647. char *value;
  1648. {
  1649. X    struct itemdef *item;
  1650. X    struct itemizedinfo *choice_info;
  1651. X    Arg arg[1];
  1652. X    int nitem;
  1653. X
  1654. X    choice_info = object->info;
  1655. X
  1656. X    /* loop over items - look for one that matches value and highlight */
  1657. X    for (item = choice_info->firstitem,nitem=0;
  1658. X    item != (struct itemdef*) 0; item=item->next,nitem++) {
  1659. X    if (!strcmp(item->value,value)) {
  1660. X            XawToggleUnsetCurrent(object->widgetname);
  1661. X            XtSetArg( arg[0], XtNstate, TRUE );
  1662. X            XtSetValues( item->widgetname, arg, ONE );
  1663. X    }
  1664. X    }
  1665. }
  1666. SHAR_EOF
  1667. chmod 0664 xtpanel/choice.c ||
  1668. echo 'restore of xtpanel/choice.c failed'
  1669. Wc_c="`wc -c < 'xtpanel/choice.c'`"
  1670. test 6770 -eq "$Wc_c" ||
  1671.     echo 'xtpanel/choice.c: original size 6770, current size' "$Wc_c"
  1672. fi
  1673. # ============= xtpanel/text.c ==============
  1674. if test -f 'xtpanel/text.c' -a X"$1" != X"-c"; then
  1675.     echo 'x - skipping xtpanel/text.c (File already exists)'
  1676. else
  1677. echo 'x - extracting xtpanel/text.c (Text)'
  1678. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/text.c' &&
  1679. /*
  1680. X * Copyright 1992 the Board of Trustees of the Leland Stanford Junior
  1681. X * University. Official permission to use this software is included in
  1682. X * the documentation. It authorizes you to use this file for any
  1683. X * non-commercial purpose, provided that this copyright notice is not
  1684. X * removed and that any modifications made to this file are commented
  1685. X * and dated in the style of the example below.
  1686. X */
  1687. X
  1688. /*
  1689. X *
  1690. X *  source file:   ./xtpanel/text.c
  1691. X *
  1692. X * Steve Cole, Dave Nichols (SEP), August 28 1992
  1693. X *      Inserted this sample edit history entry.
  1694. X *      Please log any further modifications made to this file:
  1695. X * Steve Cole, Dave Nichols (SEP), November 20 1992 -  version 2.00
  1696. X * 1) added new objects: toggle, scrollbar, graph.
  1697. X * 2) added new actions: ASSIGN, SET.
  1698. X * 3) objects can have multiple actions.
  1699. X * 4) backquoted strings in actions get executed at action time.
  1700. X */
  1701. #include <X11/Intrinsic.h>
  1702. #include <X11/StringDefs.h>
  1703. X
  1704. #include <X11/Xaw/AsciiText.h>
  1705. #include <X11/Xaw/Cardinals.h>
  1706. #include <X11/Xaw/Text.h>
  1707. X
  1708. #include "object.h"
  1709. #include "tree.h"
  1710. #include "builders.h"
  1711. X
  1712. /* translation table used for text widget */
  1713. char text_trans[] =
  1714. X  "<Leave>:         update_text()";
  1715. X
  1716. void build_text(root,parent)
  1717. X     entry *root;
  1718. X     Widget parent;
  1719. {
  1720. X    Objdef *object;
  1721. X    Arg args[20];
  1722. X    int narg;
  1723. X    Widget text;
  1724. X    char defname[8];
  1725. X    int width,height;
  1726. X    int numtext=1;
  1727. X    extern void text_update();
  1728. X    
  1729. X    /* create new object */
  1730. X    object = new_object();
  1731. X
  1732. X    /* construct default dialog name */
  1733. X    sprintf(defname,"text%d",numtext++);
  1734. X    
  1735. X    /* find value, name, etc. in tree */
  1736. X    object->name = get_value(root,"name",defname);
  1737. X    object->action = parse_actions(object->name,root);
  1738. X    object->value = get_value(root,"value","");
  1739. X    width = (int) atoi(get_value(root,"width","500"));
  1740. X    height = (int) atoi(get_value(root,"height","100"));
  1741. X    
  1742. X    narg=0;
  1743. X    XtSetArg(args[narg], XtNscrollVertical, XawtextScrollWhenNeeded); 
  1744. X    narg++;
  1745. X    XtSetArg(args[narg], XtNscrollHorizontal, XawtextScrollWhenNeeded); 
  1746. X    narg++;
  1747. X    XtSetArg(args[narg], XtNwidth, width); narg++;
  1748. X    XtSetArg(args[narg], XtNheight, height); narg++;
  1749. X    XtSetArg(args[narg], XtNstring, object->value); narg++;
  1750. X    /* common parameters */
  1751. X    common_tags(root,args,&narg,SET_ALL);
  1752. X
  1753. X    text = XtCreateManagedWidget(object->name,asciiTextWidgetClass,
  1754. X               parent,args,narg);
  1755. X    
  1756. X    object->widgetname = text;
  1757. X    object->updater = text_update;
  1758. X
  1759. X    /* use translations to update value whenever mouse leaves widget */
  1760. X    XtAugmentTranslations(text,XtParseTranslationTable(text_trans));
  1761. }
  1762. X
  1763. /*
  1764. X * this routine gets called whenever we leave
  1765. X * a text widget, to be sure its value is up to date
  1766. X */
  1767. void text_update_callback( w, event, params, num_params)
  1768. X     Widget w;
  1769. X     XEvent *event;
  1770. X     String *params;
  1771. X     Cardinal *num_params;
  1772. {
  1773. X    Objdef* object;
  1774. X    char *value;
  1775. X    Arg args[10];
  1776. X    int narg;
  1777. X
  1778. X    object = find_by_widget(w);
  1779. X    narg = 0;
  1780. X    XtSetArg(args[narg], XtNstring, &value); narg++;
  1781. X    XtGetValues(object->widgetname,args,narg);
  1782. X    object->value = strdupl(value);
  1783. X    perform_actions(object->name,object->action,1);
  1784. }
  1785. X
  1786. void text_update(object,value)
  1787. Objdef* object;
  1788. char* value;
  1789. {
  1790. X    Arg args[10];
  1791. X    int narg;
  1792. X
  1793. X    narg = 0;
  1794. X    XtSetArg(args[narg], XtNstring, value); narg++;
  1795. X    XtSetValues(object->widgetname,args,narg);
  1796. }
  1797. SHAR_EOF
  1798. chmod 0664 xtpanel/text.c ||
  1799. echo 'restore of xtpanel/text.c failed'
  1800. Wc_c="`wc -c < 'xtpanel/text.c'`"
  1801. test 3373 -eq "$Wc_c" ||
  1802.     echo 'xtpanel/text.c: original size 3373, current size' "$Wc_c"
  1803. fi
  1804. # ============= xtpanel/variable.c ==============
  1805. if test -f 'xtpanel/variable.c' -a X"$1" != X"-c"; then
  1806.     echo 'x - skipping xtpanel/variable.c (File already exists)'
  1807. else
  1808. echo 'x - extracting xtpanel/variable.c (Text)'
  1809. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/variable.c' &&
  1810. /*
  1811. X * Copyright 1992 the Board of Trustees of the Leland Stanford Junior
  1812. X * University. Official permission to use this software is included in
  1813. X * the documentation. It authorizes you to use this file for any
  1814. X * non-commercial purpose, provided that this copyright notice is not
  1815. X * removed and that any modifications made to this file are commented
  1816. X * and dated in the style of the example below.
  1817. X */
  1818. X
  1819. /*
  1820. X *
  1821. X *  source file:   ./xtpanel/variable.c
  1822. X *
  1823. X * Steve Cole, Dave Nichols (SEP), August 28 1992
  1824. X *      Inserted this sample edit history entry.
  1825. X *      Please log any further modifications made to this file:
  1826. X * Steve Cole, Dave Nichols (SEP), November 20 1992 -  version 2.00
  1827. X * 1) added new objects: toggle, scrollbar, graph.
  1828. X * 2) added new actions: ASSIGN, SET.
  1829. X * 3) objects can have multiple actions.
  1830. X * 4) backquoted strings in actions get executed at action time.
  1831. X */
  1832. X
  1833. #include <X11/Intrinsic.h>
  1834. X
  1835. #include "object.h" 
  1836. #include "tree.h"
  1837. #include "builders.h"
  1838. X
  1839. /* a variable has no screen representation it is just an object
  1840. X * with a name and a value */
  1841. void build_variable(root,parent)
  1842. X     entry *root;
  1843. X     Widget parent;
  1844. {
  1845. X    Objdef *object;
  1846. X    char defname[12];
  1847. X    static int numvar=1;
  1848. X
  1849. X    /* create new object */
  1850. X    object = new_object();
  1851. X
  1852. X    /* construct default variable name */
  1853. X    sprintf(defname,"var%d",numvar++);
  1854. X    
  1855. X    /* find name, value */
  1856. X    object->name = get_value(root,"name",defname);
  1857. X    object->value = get_value(root,"value",object->name);
  1858. X    object->updater = 0; /* nothing to do */
  1859. }
  1860. SHAR_EOF
  1861. chmod 0664 xtpanel/variable.c ||
  1862. echo 'restore of xtpanel/variable.c failed'
  1863. Wc_c="`wc -c < 'xtpanel/variable.c'`"
  1864. test 1532 -eq "$Wc_c" ||
  1865.     echo 'xtpanel/variable.c: original size 1532, current size' "$Wc_c"
  1866. fi
  1867. true || echo 'restore of xtpanel/xtpanel.man.sed failed'
  1868. echo End of part 6, continue with part 7
  1869. exit 0
  1870. -----------------------------------------------------------------
  1871. Steve Cole  (steve@sep.stanford.edu, apple!sep!steve)
  1872. Department of Geophysics, Stanford University, Stanford, CA 94305
  1873.