home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume10 / calctool24 / part05 < prev    next >
Encoding:
Text File  |  1990-01-15  |  44.5 KB  |  1,290 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v10i010: Calctool V2.4 - a simple calculator (Part 5 of 6).
  3. from: richb@Aus.Sun.COM (Rich Burridge)
  4. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5.  
  6. Posting-number: Volume 10, Issue 10
  7. Submitted-by: richb@Aus.Sun.COM (Rich Burridge)
  8. Archive-name: calctool24/part05
  9.  
  10. ---- Cut Here and unpack ----
  11. #!/bin/sh
  12. # this is part 5 of a multipart archive
  13. # do not concatenate these parts, unpack them in order with /bin/sh
  14. # file x11.c continued
  15. #
  16. CurArch=5
  17. if test ! -r s2_seq_.tmp
  18. then echo "Please unpack part 1 first!"
  19.      exit 1; fi
  20. ( read Scheck
  21.   if test "$Scheck" != $CurArch
  22.   then echo "Please unpack part $Scheck next!"
  23.        exit 1;
  24.   else exit 0; fi
  25. ) < s2_seq_.tmp || exit 1
  26. echo "x - Continuing file x11.c"
  27. sed 's/^X//' << 'SHAR_EOF' >> x11.c
  28. X           
  29. X  load_colors() ;
  30. X  if (iscolor) calctool_icon = load_icon(cicon_image) ;
  31. X  else calctool_icon = load_icon(icon_image) ;
  32. X
  33. X  size.flags = PMinSize | PMaxSize | PPosition | PSize ;
  34. X  size.x = 0 ;
  35. X  size.y = 0 ;
  36. X  size.max_width = size.min_width = size.width = TWIDTH ;
  37. X  size.max_height = size.min_height = size.height = THEIGHT + DISPLAY ;
  38. X
  39. X  if (strlen(geometry))
  40. X    {
  41. X      flags = XParseGeometry(geometry, &x, &y, &w, &h) ;
  42. X      if (XValue & flags)
  43. X        {
  44. X          if (XNegative & flags)
  45. X            x = DisplayWidth(dpy, screen) + x - size.width ;
  46. X            size.flags |= USPosition ;
  47. X            size.x = x ;
  48. X        }
  49. X      if (YValue & flags)
  50. X        {
  51. X          if (YNegative & flags)
  52. X            y = DisplayHeight(dpy, screen) + y - size.height ;
  53. X            size.flags |= USPosition ;
  54. X            size.y = y ;
  55. X        }      
  56. X    }
  57. X
  58. X  frame = XCreateSimpleWindow(dpy, RootWindow(dpy, screen),
  59. X                              size.x, size.y, size.width, size.height,
  60. X                              CALCTOOL_BORDER_WIDTH, foregnd, backgnd) ;
  61. X
  62. X  rframe = XCreateSimpleWindow(dpy, RootWindow(dpy, screen),
  63. X                               size.x + TWIDTH + 15, size.y,
  64. X                               size.width, 200,
  65. X                               CALCTOOL_BORDER_WIDTH, foregnd, backgnd) ;
  66. X
  67. X  protocol_atom = XInternAtom(dpy, "WM_PROTOCOLS", False) ;
  68. X  kill_atom = XInternAtom(dpy, "WM_DELETE_WINDOW", False) ;
  69. X
  70. X  XSetStandardProperties(dpy, frame, "calctool", NULL, calctool_icon,
  71. X                         argv, argc, &size) ;
  72. X
  73. X  wm_hints.icon_x = ix ;
  74. X  wm_hints.icon_y = iy ;
  75. X  wm_hints.input = True ;
  76. X  wm_hints.icon_pixmap = calctool_icon ;
  77. X  wm_hints.flags = IconPositionHint | InputHint | IconPixmapHint ;
  78. X  if (iconic)
  79. X    {
  80. X      wm_hints.initial_state = IconicState ;
  81. X      wm_hints.flags |= StateHint ;
  82. X    }
  83. X  XSetWMHints(dpy, frame, &wm_hints) ;
  84. X
  85. X  gc_mask = GCFont | GCForeground | GCBackground | GCGraphicsExposures ;
  86. X  gc_val.font = nfont->fid ;
  87. X  gc_val.foreground = foregnd ;
  88. X  gc_val.background = backgnd ;
  89. X  gc_val.graphics_exposures = False ;
  90. X  gc = XCreateGC(dpy, RootWindow(dpy, screen), gc_mask, &gc_val) ;
  91. X  XSetFunction(dpy, gc, GXcopy) ;
  92. X
  93. X  main_cursor = XCreateFontCursor(dpy, XC_top_left_arrow) ;
  94. X  FGcolor.red = FGcolor.green = FGcolor.blue = 0 ;
  95. X  BGcolor.red = BGcolor.green = BGcolor.blue = 0xffff ;
  96. X  help_cursor = load_cursor(help_cursor_array) ;
  97. X}
  98. X
  99. X
  100. Xmake_icon() {}        /* Null routine - icon created in make_frame. */
  101. X
  102. X
  103. Xmake_items()
  104. X{
  105. X  XSelectInput(dpy, frame, FRAME_MASK) ;
  106. X  XMapWindow(dpy, frame) ;
  107. X
  108. X  XSelectInput(dpy, rframe, ExposureMask) ;
  109. X}
  110. X
  111. X
  112. Xmake_subframes() {}          /* Null routine, see the make_frame routine. */
  113. X
  114. X
  115. Xprocess_expose(event)
  116. XXExposeEvent *event ;
  117. X{
  118. X  int doframe, dorframe ;
  119. X
  120. X  doframe = dorframe = 0 ;
  121. X  do
  122. X    {
  123. X      if (event->count == 0)
  124. X        {
  125. X               if (event->window == frame) doframe++ ;
  126. X          else if (event->window == rframe) dorframe++ ;
  127. X        }
  128. X    }
  129. X  while (XCheckMaskEvent(dpy, ExposureMask, event)) ;
  130. X  if (dorframe && rstate) make_registers() ;
  131. X  if (doframe) return(CFRAME_REPAINT) ;
  132. X}
  133. X
  134. X
  135. Xset_cursor(type)
  136. Xint type ;
  137. X{
  138. X  switch (type)
  139. X    {
  140. X      case HELPCURSOR : XDefineCursor(dpy, frame, help_cursor) ;
  141. X                        break ;
  142. X      case MAINCURSOR : XDefineCursor(dpy, frame, main_cursor) ;
  143. X    }
  144. X}
  145. X
  146. X
  147. Xstart_tool()
  148. X{
  149. X  while (1)
  150. X    process_event(get_next_event()) ;
  151. X}
  152. X
  153. X
  154. Xtoggle_reg_canvas()
  155. X{
  156. X  rstate = !rstate ;
  157. X  if (rstate) XMapWindow(dpy, rframe) ;
  158. X  else XUnmapWindow(dpy, rframe) ;
  159. X}
  160. SHAR_EOF
  161. echo "File x11.c is complete"
  162. chmod 0444 x11.c || echo "restore of x11.c fails"
  163. set `wc -c x11.c`;Sum=$1
  164. if test "$Sum" != "13680"
  165. then echo original size 13680, current size $Sum;fi
  166. echo "x - extracting xview.c (Text)"
  167. sed 's/^X//' << 'SHAR_EOF' > xview.c &&
  168. X
  169. X/*  @(#)xview.c 1.11 89/12/21
  170. X *
  171. X *  These are the XView dependent graphics routines used by calctool.
  172. X *
  173. X *  Copyright (c) Rich Burridge.
  174. X *                Sun Microsystems, Australia - All rights reserved.
  175. X *
  176. X *  Permission is given to distribute these sources, as long as the
  177. X *  copyright messages are not removed, and no monies are exchanged.
  178. X *
  179. X *  No responsibility is taken for any errors or inaccuracies inherent
  180. X *  either to the comments or the code of this program, but if
  181. X *  reported to me then an attempt will be made to fix them.
  182. X */
  183. X
  184. X#include "calctool.h"
  185. X#include "color.h"
  186. X#include "extern.h"
  187. X#include <xview/xview.h>
  188. X#include <xview/canvas.h>
  189. X#include <xview/cms.h>
  190. X#include <xview/cursor.h>
  191. X#include <xview/sel_svc.h>
  192. X#include <xview/sel_attrs.h>
  193. X
  194. X#define  MENU_SET                       (void) menu_set
  195. X#define  NOTIFY_DO_DISPATCH             (void) notify_do_dispatch
  196. X#define  NOTIFY_INTERPOSE_DESTROY_FUNC  (void) notify_interpose_destroy_func
  197. X#define  PW_SETCMSNAME                  (void) pw_setcmsname
  198. X#define  PW_PUTCOLORMAP                 (void) pw_putcolormap
  199. X#define  PW_TTEXT                       (void) pw_ttext
  200. X#define  PW_WRITEBACKGROUND             (void) pw_writebackground
  201. X#define  SELN_QUERY                     (void) seln_query
  202. X#define  XV_SET                         (void) xv_set
  203. X#define  WINDOW_DONE                    (void) window_done
  204. X
  205. X#define  SMALLFONT   "/usr/lib/fonts/fixedwidthfonts/screen.r.7"
  206. X#define  NORMALFONT  "/usr/lib/fonts/fixedwidthfonts/screen.b.14"
  207. X#define  BIGFONT     "/usr/lib/fonts/fixedwidthfonts/gallant.r.19"
  208. X
  209. Xvoid func_key_proc() ;
  210. Xint menu_proc() ;
  211. X
  212. XCanvas kcanvas, rcanvas ;
  213. XEvent *cur_event ;
  214. XFrame frame, rframe ;
  215. XIcon calctool_icon ;
  216. XMenu menus[MAXMENUS] ;
  217. XNotify_value destroy_proc() ;
  218. XPixfont *bfont, *font, *nfont, *sfont, *xv_pf_default(), *xv_pf_open() ;
  219. XCanvas_paint_window pw, cpw, rcpw ;
  220. XSeln_client sel_client ;
  221. XSeln_holder holder ;
  222. XSeln_rank rank = SELN_PRIMARY ;
  223. XSeln_result get_proc(), reply_proc() ;
  224. XXv_cmsdata cms_data ;
  225. XXv_Cursor help_cursor, main_cursor ;
  226. X
  227. Xchar colorname[CMS_NAMESIZE] ;
  228. Xu_char red[CALC_COLORSIZE], green[CALC_COLORSIZE], blue[CALC_COLORSIZE] ;
  229. X
  230. Xenum menu_type curmenu ;   /* Current menu (if any) being processed. */
  231. Xint started ;              /* Set just before window is displayed. */
  232. X
  233. Xshort help_cursor_array[16] = {
  234. X#include "help.cursor"
  235. X} ;
  236. Xmpr_static(help_cursor_pr, 16, 16, 1, help_cursor_array) ;
  237. X
  238. Xunsigned short icon_image[] = {
  239. X#include "calctool.icon"
  240. X} ;
  241. Xmpr_static(icon_pr, 64, 64, 1, icon_image) ;
  242. X
  243. Xshort cicon_image[] = {
  244. X#include "calctool.color.icon"
  245. X} ;
  246. Xmpr_static(cicon_pr, 64, 64, 8, cicon_image) ;
  247. X
  248. X
  249. X/*ARGSUSED*/
  250. Xvoid
  251. Xcanvas_event_proc(canvas, event, arg)
  252. XCanvas canvas ;
  253. XEvent *event ;
  254. Xcaddr_t arg ;
  255. X{
  256. X  if (!started) return ;
  257. X  cur_event = event ;
  258. X  process_event(get_next_event(event)) ;
  259. X}
  260. X
  261. X
  262. Xclear_canvas(window, color)
  263. Xenum can_type window ;
  264. Xint color ;
  265. X{
  266. X  int height,width ;
  267. X  Canvas ctype ;
  268. X
  269. X  if (window == KEYCANVAS)
  270. X    {
  271. X      pw = cpw ;
  272. X      ctype = frame ;
  273. X    } 
  274. X  else if (window == REGCANVAS)
  275. X    {
  276. X      pw = rcpw ;
  277. X      ctype = rframe ;
  278. X    }
  279. X  height = (int) xv_get(ctype, XV_HEIGHT) ;
  280. X  width = (int) xv_get(ctype, XV_WIDTH) ;
  281. X  PW_WRITEBACKGROUND(pw, 0, 0, width, height, PIX_SRC | PIX_COLOR(color)) ;
  282. X}
  283. X
  284. X
  285. Xclose_frame()
  286. X{
  287. X  if ((int) xv_get(rframe, XV_SHOW) == TRUE)
  288. X    XV_SET(rframe, XV_SHOW, FALSE, 0) ;
  289. X  XV_SET(frame, FRAME_CLOSED, TRUE, 0) ;
  290. X  rstate = 0 ;
  291. X}
  292. X
  293. X
  294. Xcolor_area(x, y, width, height, color)
  295. Xint x, y, width, height, color ;
  296. X{
  297. X  PW_WRITEBACKGROUND(cpw, x, y, width, height, PIX_SRC | PIX_COLOR(color)) ;
  298. X}
  299. X
  300. X
  301. Xcreate_menu(mtype)    /* Create popup menu for right button press. */
  302. Xenum menu_type mtype ;
  303. X{
  304. X  int i ;
  305. X
  306. X  menus[(int) mtype] = xv_create(XV_NULL, MENU_COMMAND_MENU,
  307. X                                 MENU_NOTIFY_PROC, menu_proc,
  308. X                                 MENU_FONT, nfont,
  309. X                                 0) ;
  310. X  for (i = 0; i < MAXREGS; i++)
  311. X    {
  312. X      switch (mtype)
  313. X        {
  314. X          case M_ACC    :                              /* Accuracies. */
  315. X          case M_EXCH   :                              /* Register exchange. */
  316. X          case M_LSHIFT :                              /* Left shift. */
  317. X          case M_RCL    :                              /* Register recall. */
  318. X          case M_RSHIFT :                              /* Right shift. */
  319. X          case M_STO    : MENU_SET(menus[(int) mtype], /* Register store. */
  320. X                                   MENU_STRING_ITEM, num_names[i], i+1,
  321. X                                   0) ;
  322. X                          break ;
  323. X          case M_CON    : if (strlen(con_names[i]))    /* Constants. */
  324. X                            MENU_SET(menus[(int) mtype],
  325. X                                     MENU_STRING_ITEM, con_names[i], i+1,
  326. X                                     0) ;
  327. X                          break ;
  328. X          case M_FUN    : if (strlen(fun_names[i]))    /* Functions. */
  329. X                            MENU_SET(menus[(int) mtype],
  330. X                                     MENU_STRING_ITEM, fun_names[i], i+1,
  331. X                                     0) ;
  332. X        }
  333. X    }
  334. X}
  335. X
  336. X
  337. Xdestroy_frame()
  338. X{
  339. X  WINDOW_DONE(frame) ;
  340. X  exit(0) ;
  341. X}
  342. X
  343. X
  344. Xdestroy_rframe(frame)
  345. XFrame frame ;
  346. X{
  347. X  rstate = 0 ;
  348. X  XV_SET(frame, XV_SHOW, FALSE, 0) ;
  349. X}
  350. X
  351. X
  352. X/*ARGSUSED*/
  353. XNotify_value
  354. Xdestroy_proc(client, status)
  355. XNotify_client client ;
  356. XDestroy_status status ;
  357. X{
  358. X  exit(0) ;
  359. X}
  360. X
  361. X
  362. X/*  This routine works rather strangely. Because menu_show does not block
  363. X *  under XView, do_menu cannot return a valid selection. So the menu
  364. X *  selection handling has been moved to the notification procedure, and
  365. X *  the appropriate code in graphics.c has been isolated into a separate
  366. X *  routine. All in all, a bit of a kludge.
  367. X */
  368. X
  369. Xdo_menu(mtype)      /* Popup appropriate menu. */
  370. Xenum menu_type mtype ;
  371. X{
  372. X  curmenu =  mtype ;
  373. X  menu_show(menus[(int) mtype], kcanvas, cur_event, 0) ;
  374. X  return(0) ;
  375. X}
  376. X
  377. X
  378. Xdrawline(x1, y1, x2, y2)
  379. Xint x1, y1, x2, y2 ;
  380. X{
  381. X  (void) pw_vector(cpw, x1, y1, x2, y2, PIX_SET, 0) ;
  382. X}
  383. X
  384. X
  385. Xdraw_regs()
  386. X{
  387. X  make_registers() ;
  388. X  XV_SET(rframe, XV_SHOW, TRUE, 0) ;
  389. X}
  390. X
  391. X
  392. Xdrawtext(x, y, window, fontno, color, str)
  393. Xenum font_type fontno ;
  394. Xenum can_type window ;
  395. Xint x, y, color ;
  396. Xchar *str ;
  397. X{
  398. X       if (fontno == SFONT) font = sfont ;
  399. X  else if (fontno == NFONT) font = nfont ;
  400. X  else if (fontno == BFONT) font = bfont ;
  401. X       if (window == KEYCANVAS) pw = cpw ;
  402. X  else if (window == REGCANVAS) pw = rcpw ;
  403. X
  404. X  if (color == BLACK)
  405. X    (void) pw_text(pw, x, y, PIX_SRC | PIX_DST, font, str) ;
  406. X  else if (color == WHITE)
  407. X    PW_TTEXT(pw, x, y, PIX_SRC | PIX_COLOR(color), font, str) ;
  408. X}
  409. X
  410. X
  411. X/*ARGSUSED*/
  412. Xvoid
  413. Xfunc_key_proc(client_data, args)
  414. Xchar *client_data ;
  415. XSeln_function_buffer *args ;
  416. X{
  417. X  get_display() ;
  418. X}
  419. X
  420. X
  421. Xget_display()     /* The GET function key has been pressed. */
  422. X{
  423. X  if (seln_acquire(sel_client, SELN_SHELF) == SELN_SHELF)
  424. X    {
  425. X      if (shelf != NULL) free(shelf) ;
  426. X      shelf = malloc((unsigned) strlen(display)) ;
  427. X      STRCPY(shelf, display) ;         /* Safely keep copy of display. */
  428. X    }
  429. X}
  430. X
  431. X
  432. XPixfont *
  433. Xget_font(name)
  434. Xchar *name ;
  435. X{
  436. X  Pixfont *font ;
  437. X
  438. X  font = xv_pf_open(name) ;
  439. X  if (font == NULL) font = xv_pf_default() ;
  440. X  if (font == NULL)
  441. X    {
  442. X      perror("couldn't get the default font.") ;
  443. X      exit(1) ;
  444. X    }
  445. X  return font ;
  446. X}
  447. X
  448. X
  449. Xget_next_event(event)
  450. XEvent *event ;
  451. X{
  452. X  static char eb[4] ;      /* Event buffer. */
  453. X  int i ;
  454. X
  455. X#ifdef   SUN4_KEYBOARD
  456. X  char *rpad = "\000\000\000=/*789456123" ;
  457. X  char *akeys = "8264" ;
  458. X  char *sun4keys = "\000\000\000+-\000\0000\000." ;
  459. X#else
  460. X  char *rpad = "\000\000\00078945612301=" ;
  461. X  char *akeys = "5.31" ;
  462. X#endif /*SUN4_KEYBOARD*/
  463. X  nextc = event_id(event) ;
  464. X  curx = event_x(event) ;
  465. X  cury = event_y(event) ;
  466. X
  467. X  if (event_is_button(event))
  468. X         if (event_is_down(event) && nextc == MS_LEFT) return(LEFT_DOWN) ;
  469. X    else if (event_is_down(event) && nextc == MS_MIDDLE) return(MIDDLE_DOWN) ;
  470. X    else if (event_is_down(event) && nextc == MS_RIGHT) return(RIGHT_DOWN) ;
  471. X    else if (event_is_up(event) && nextc == MS_LEFT) return(LEFT_UP) ;
  472. X    else if (event_is_up(event) && nextc == MS_MIDDLE) return(MIDDLE_UP) ;
  473. X    else if (event_is_up(event) && nextc == MS_RIGHT) return(RIGHT_UP) ;
  474. X
  475. X/*  The following code attempts to handle a numeric keypad using the right
  476. X *  function keys. This pad differs on the Sun3 and Sun4 keyboards. There
  477. X *  is a compile-time define which determines which keyboard setup is
  478. X *  looked for.
  479. X */
  480. X  if (event_is_ascii(event) && event_is_down(event))
  481. X    {
  482. X   
  483. X/*  If the last two events were escape and left square bracket.. */
  484. X   
  485. X      if (eb[0] && eb[1])
  486. X        {
  487. X          switch (nextc)
  488. X            {
  489. X   
  490. X/*  Interpret the arrow keys (if they are set).
  491. X *  R8 = ^[A     R14 = ^[B     R12 = ^[C     R10 = ^[B
  492. X */
  493. X   
  494. X              case 'A' :
  495. X              case 'B' :
  496. X              case 'C' :
  497. X              case 'D' : cur_ch = akeys[nextc - 'A'] ;
  498. X                         eb[0] = eb[1] = '\0' ;
  499. X                         return(KEYBOARD) ;
  500. X   
  501. X/*  Interpret the extra keys found on Sun4 keyboards.
  502. X *  These have codes of the form: ^[<int>z where <int> is a number
  503. X *  between 247 and 255.  We're only interested in 4 of these keys.
  504. X *  These are:
  505. X *    ^[253z = +     ^[254z = -     ^[257z = 0     ^[259z = .
  506. X */
  507. X#ifdef SUN4_KEYBOARD
  508. X              case '2' : eb[2] = '2' ;
  509. X                         break ;
  510. X
  511. X              case '5' : if (eb[0] && eb[1] && eb[2])
  512. X                           {
  513. X                             eb[3] = '5' ;
  514. X                             break ;
  515. X                           }
  516. X                         else
  517. X
  518. X/*  Clear event_buf and treat as normal ascii char. */
  519. X
  520. X                           {
  521. X                             eb[0] = eb[1] = '\0' ;
  522. X                             cur_ch = nextc ;
  523. X                             return(KEYBOARD) ;
  524. X                           }
  525. X
  526. X              case '3' :
  527. X              case '4' :
  528. X              case '7' :
  529. X              case '9' : if (eb[0] && eb[1] && eb[2] && eb[3])
  530. X                           {
  531. X                             cur_ch = sun4keys[nextc - '0'] ;
  532. X                             eb[0] = eb[1] = eb[2] = eb[3] = '\0' ;
  533. X                             return(KEYBOARD) ;
  534. X                           }
  535. X                         else if (eb[0] && eb[1] && eb[2] && nextc == '4')
  536. X                           {
  537. X                             eb[3] = nextc ;
  538. X                             break ;
  539. X                           }
  540. X                         else
  541. X
  542. X/*  Clear event_buf and treat as normal ascii char. */
  543. X
  544. X                           {
  545. X                             eb[0] = eb[1] = '\0' ;
  546. X                             cur_ch = nextc ;
  547. X                             return(KEYBOARD) ;
  548. X                           }
  549. X#endif /*SUN4_KEYBOARD*/
  550. X
  551. X               default : eb[0] = eb[1] = eb[2] = eb[3] = '\0' ;
  552. X            }
  553. X        }    
  554. X
  555. X/*  If previous events are ^[[ : set buffer   */
  556. X
  557. X      else if (nextc == '[' && eb[0])    /* Check for left square bracket. */
  558. X        eb[1] = '[' ;
  559. X      else if (nextc == '\033')          /* Check for escape char. */
  560. X        eb[0] = '\033' ;
  561. X      else
  562. X        {
  563. X
  564. X/*  All the rest of the ASCII characters. */
  565. X                              
  566. X          eb[0] = eb[1] = '\0' ;
  567. X          cur_ch = nextc ;    
  568. X          return(KEYBOARD) ;
  569. X        }                     
  570. X    }                         
  571. X                            
  572. X  if (event_is_key_right(event) && event_is_up(event))
  573. X    {
  574. X      for (i = 1; i < 16; i++)
  575. X        if (nextc == KEY_RIGHT(i))
  576. X          {                 
  577. X            cur_ch = rpad[i-1] ;
  578. X            return(KEYBOARD) ;
  579. X          }                   
  580. X    }
  581. X
  582. X  if (nextc == KBD_DONE && down) return(EXIT_WINDOW) ;
  583. X  if (nextc == LOC_WINEXIT) return(EXIT_WINDOW) ;
  584. X  if (nextc == LOC_WINENTER) return(ENTER_WINDOW) ;
  585. X
  586. X  if (nextc == WIN_RESIZE) return(CFRAME_REPAINT) ;
  587. X  if (nextc == WIN_REPAINT) return(CFRAME_REPAINT) ;
  588. X
  589. X  if ((nextc == KEY_LEFT(6)) & event_is_up(event)) return(PUT_ON_SHELF) ;
  590. X  if ((nextc == KEY_LEFT(8)) && event_is_up(event)) return(TAKE_FROM_SHELF) ;
  591. X  return(LASTEVENTPLUSONE) ;
  592. X}
  593. X
  594. X
  595. XSeln_result
  596. Xget_proc(buffer)
  597. XSeln_request *buffer ;
  598. X{
  599. X  issel = 0 ;
  600. X  if (*buffer->requester.context == 0)
  601. X    {
  602. X      if (buffer == (Seln_request *) NULL ||
  603. X          *((Seln_attribute *) buffer->data) != SELN_REQ_CONTENTS_ASCII)
  604. X        return ;
  605. X      selection = buffer->data + sizeof(Seln_attribute) ;
  606. X      *buffer->requester.context = 1 ;
  607. X    }
  608. X  else selection = buffer->data ;
  609. X  issel = 1 ;
  610. X}
  611. X
  612. X
  613. Xhandle_selection()  /* Handle the GET function key being pressed. */
  614. X{
  615. X  char context = 0 ;
  616. X
  617. X  holder = seln_inquire(rank) ;
  618. X  if (holder.state == SELN_NONE) return ;
  619. X  SELN_QUERY(&holder, get_proc, &context, SELN_REQ_CONTENTS_ASCII, 0, 0) ;
  620. X}
  621. X
  622. X
  623. Xinit_fonts()
  624. X{
  625. X  bfont = get_font(BIGFONT) ;
  626. X  nfont = get_font(NORMALFONT) ;
  627. X  nfont_width = nfont->pf_defaultsize.x ;
  628. X  sfont = get_font(SMALLFONT) ;
  629. X}
  630. X
  631. X
  632. Xinit_ws_type()
  633. X{
  634. X  gtype = XVIEW ;
  635. X  started = 0 ;               /* Kludge to correctly handle repaints. */
  636. X  return 0 ;
  637. X}
  638. X
  639. X
  640. Xload_colors()      /* Create and load color map - done in make_subframes. */
  641. X{
  642. X}
  643. X
  644. X
  645. Xmake_frames(argc, argv)
  646. Xint argc ;
  647. Xchar *argv[] ;
  648. X{
  649. X  int x, y ;
  650. X
  651. X  xv_init(XV_INIT_ARGS, argc, argv, 0) ;
  652. X  frame = xv_create(0, FRAME,
  653. X                    FRAME_ICON,        calctool_icon,
  654. X                    FRAME_SHOW_LABEL,  FALSE,
  655. X                    FRAME_NO_CONFIRM,  TRUE,
  656. X                    XV_WIDTH,          TWIDTH,
  657. X                    XV_HEIGHT,         THEIGHT + DISPLAY,
  658. X                    0) ;
  659. X  iscolor = ((int) xv_get(frame, WIN_DEPTH) > 1) ? 1 : 0 ;
  660. X  sel_client = seln_create(func_key_proc, reply_proc, (char *) 0) ;
  661. X  NOTIFY_INTERPOSE_DESTROY_FUNC(frame, destroy_proc) ;
  662. X  rframe = xv_create(frame, FRAME,
  663. X                     FRAME_SHOW_LABEL, FALSE,
  664. X                     FRAME_NO_CONFIRM, TRUE,
  665. X                     FRAME_DONE_PROC,  destroy_rframe,
  666. X                     XV_X,             TWIDTH + 15,
  667. X                     XV_Y,             0,
  668. X                     XV_SHOW,          FALSE,
  669. X                     XV_WIDTH,         TWIDTH,
  670. X                     XV_HEIGHT,        200,
  671. X                     XV_FONT,          nfont,
  672. X                     0) ;
  673. X}
  674. X
  675. X
  676. Xmake_icon()
  677. X{
  678. X  calctool_icon = xv_create(0, ICON,
  679. X                            XV_WIDTH,   ICONWIDTH,
  680. X                            ICON_IMAGE, &icon_pr,
  681. X                            0) ;
  682. X}
  683. X
  684. X
  685. Xmake_items()
  686. X{
  687. X  main_cursor = xv_get(kcanvas, WIN_CURSOR) ;
  688. X
  689. X  if (iscolor)
  690. X    {
  691. X      calctool_icon = (Icon) xv_get(frame, FRAME_ICON) ;
  692. X      XV_SET(calctool_icon,
  693. X             ICON_IMAGE, &cicon_pr,
  694. X             WIN_CMS_NAME, colorname,
  695. X             0) ;
  696. X      XV_SET(frame, FRAME_ICON, calctool_icon, 0) ;
  697. X    }
  698. X
  699. X  help_cursor = xv_create(NULL, CURSOR,
  700. X                          CURSOR_XHOT,  0,
  701. X                          CURSOR_YHOT,  0,
  702. X                          CURSOR_OP,    PIX_SRC | PIX_DST,
  703. X                          CURSOR_IMAGE, &help_cursor_pr,
  704. X                          0) ;
  705. X}
  706. X
  707. X
  708. Xmake_subframes()
  709. X{
  710. X  rcanvas = xv_create(rframe, CANVAS, 0) ;
  711. X
  712. X  SPRINTF(colorname, "%s%D", CALC_COLOR, getpid()) ;
  713. X  calc_colorsetup(red, green, blue) ;
  714. X
  715. X  cms_data.type = XV_STATIC_CMS ;
  716. X  cms_data.size = CALC_COLORSIZE ;
  717. X  cms_data.rgb_count = CALC_COLORSIZE ;
  718. X  cms_data.index = 0 ;
  719. X  cms_data.red = red ;
  720. X  cms_data.green = green ;
  721. X  cms_data.blue = blue ;
  722. X
  723. X  kcanvas = xv_create(frame, CANVAS,
  724. X                      CANVAS_RETAINED,     FALSE,
  725. X                      OPENWIN_AUTO_CLEAR,  FALSE,
  726. X                      XV_WIDTH,            TWIDTH,
  727. X                      XV_HEIGHT,           THEIGHT + DISPLAY,
  728. X                      XV_FONT,             nfont,
  729. X                      CANVAS_PAINTWINDOW_ATTRS,
  730. X                          WIN_CMS_NAME, colorname,
  731. X                          WIN_CMS_DATA, &cms_data,
  732. X                          WIN_CONSUME_EVENTS,
  733. X                            MS_LEFT, MS_MIDDLE, MS_RIGHT,
  734. X                            WIN_ASCII_EVENTS, KBD_USE, KBD_DONE,
  735. X                            LOC_WINENTER, LOC_WINEXIT,
  736. X                            WIN_LEFT_KEYS, WIN_TOP_KEYS, WIN_RIGHT_KEYS,
  737. X                            0,
  738. X                          WIN_IGNORE_EVENTS,
  739. X                            LOC_MOVE, LOC_DRAG,
  740. X                            0,
  741. X                          WIN_EVENT_PROC, canvas_event_proc,
  742. X                          0,
  743. X                      0) ;
  744. X
  745. X  rcpw = canvas_paint_window(rcanvas) ;
  746. X  cpw = canvas_paint_window(kcanvas) ;
  747. X}
  748. X
  749. X
  750. Xmenu_proc(menu, menu_item)
  751. XMenu menu ;
  752. XMenu_item menu_item ;
  753. X{
  754. X  int choice ;
  755. X
  756. X  choice = (int) menu_get(menu_item, MENU_VALUE) ;
  757. X  if (choice) handle_menu_selection(curmenu, choice) ;
  758. X}
  759. X
  760. X
  761. X/*ARGSUSED*/
  762. XSeln_result
  763. Xreply_proc(item, context, length)
  764. XSeln_attribute item ;
  765. XSeln_replier_data *context ;
  766. Xint length ;
  767. X{
  768. X  int size ;
  769. X  char *destp ;
  770. X
  771. X  switch (item)
  772. X    {
  773. X      case SELN_REQ_CONTENTS_ASCII :
  774. X
  775. X             if (context->context == NULL)
  776. X               {
  777. X                 if (shelf == NULL) return(SELN_DIDNT_HAVE) ;
  778. X                 context->context = shelf ;
  779. X               }
  780. X             size = strlen(context->context) ;
  781. X             destp = (char *) context->response_pointer ;
  782. X             STRCPY(destp, context->context) ;
  783. X             destp += size ;
  784. X             while ((int) destp % 4 != 0) *destp++ = '\0' ;
  785. X             context->response_pointer = (char **) destp ;
  786. X             *context->response_pointer++ = 0 ;
  787. X             return(SELN_SUCCESS) ;
  788. X
  789. X      case SELN_REQ_YIELD :
  790. X
  791. X             *context->response_pointer++ = (char *) SELN_SUCCESS ;
  792. X             return(SELN_SUCCESS) ;
  793. X
  794. X      case SELN_REQ_BYTESIZE :
  795. X
  796. X             if (shelf == NULL) return(SELN_DIDNT_HAVE) ;
  797. X             *context->response_pointer++ = (char *) strlen(shelf) ;
  798. X             return(SELN_SUCCESS) ;
  799. X
  800. X      case SELN_REQ_END_REQUEST : return(SELN_SUCCESS) ;
  801. X
  802. X      default                   : return(SELN_UNRECOGNIZED) ;
  803. X    }
  804. X}
  805. X
  806. X
  807. Xset_cursor(type)
  808. Xint type ;
  809. X{
  810. X  switch (type)
  811. X    {
  812. X      case HELPCURSOR : XV_SET(kcanvas, WIN_CURSOR, help_cursor, 0) ;
  813. X                        break ;
  814. X      case MAINCURSOR : XV_SET(kcanvas, WIN_CURSOR, main_cursor, 0) ;
  815. X    }
  816. X}
  817. X
  818. X
  819. Xstart_tool()
  820. X{
  821. X  started = 1 ;
  822. X  xv_main_loop(frame) ;
  823. X}
  824. X
  825. X
  826. Xtoggle_reg_canvas()
  827. X{
  828. X  rstate = !rstate ;
  829. X  if (rstate) draw_regs() ;
  830. X  else XV_SET(rframe, XV_SHOW, FALSE, 0) ;
  831. X}
  832. SHAR_EOF
  833. chmod 0444 xview.c || echo "restore of xview.c fails"
  834. set `wc -c xview.c`;Sum=$1
  835. if test "$Sum" != "18237"
  836. then echo original size 18237, current size $Sum;fi
  837. echo "x - extracting calctool.h (Text)"
  838. sed 's/^X//' << 'SHAR_EOF' > calctool.h &&
  839. X
  840. X/*  @(#)calctool.h 1.10 89/11/06
  841. X *
  842. X *  Contains all the global definitions used by calctool.
  843. X *
  844. X *  Copyright (c) Rich Burridge.
  845. X *                Sun Microsystems, Australia - All rights reserved.
  846. X *
  847. X *  Permission is given to distribute these sources, as long as the
  848. X *  copyright messages are not removed, and no monies are exchanged.
  849. X *
  850. X *  No responsibility is taken for any errors or inaccuracies inherent
  851. X *  either to the comments or the code of this program, but if
  852. X *  reported to me then an attempt will be made to fix them.
  853. X */
  854. X
  855. X#include <stdio.h>
  856. X#include <strings.h>
  857. X#include <ctype.h>
  858. X#include <signal.h>
  859. X#include <sys/types.h>
  860. X#include <sys/ioctl.h>
  861. X#include <sys/time.h>
  862. X#include <pwd.h>
  863. X#include <math.h>
  864. X
  865. Xchar *getenv(), *sprintf() ;
  866. X
  867. X#define  CLOSE          (void) close      /* To make lint happy. */
  868. X#define  FCLOSE         (void) fclose
  869. X#define  FFLUSH         (void) fflush
  870. X#define  FGETS          (void) fgets
  871. X#define  FPRINTF        (void) fprintf
  872. X#define  IOCTL          (void) ioctl
  873. X#define  PUTC           (void) putc
  874. X#define  READ           (void) read
  875. X#define  SELECT         (void) select
  876. X#define  SIGNAL         (void) signal
  877. X#define  SPRINTF        (void) sprintf
  878. X#define  SSCANF         (void) sscanf
  879. X#define  STRCAT         (void) strcat
  880. X#define  STRCPY         (void) strcpy
  881. X#define  STRNCAT        (void) strncat
  882. X#define  STRNCPY        (void) strncpy
  883. X#define  WRITE          (void) write
  884. X
  885. X/* Various pseudo events used by the calctool program. */
  886. X#define  CFRAME_REPAINT   100    /* Main frame needs repainting. */
  887. X#define  RFRAME_REPAINT   101    /* Register frame needs repainting. */
  888. X#define  ENTER_WINDOW     102    /* Mouse has enter calctool window. */
  889. X#define  EXIT_WINDOW      103    /* Mouse has exited calctool window. */ 
  890. X#define  KEYBOARD         104    /* Keyboard character was pressed. */
  891. X#define  LEFT_DOWN        105    /* Left mouse button was depressed. */
  892. X#define  LEFT_UP          106    /* Left mouse button was debounced. */
  893. X#define  MIDDLE_DOWN      107    /* Middle mouse button was depressed. */
  894. X#define  MIDDLE_UP        108    /* Middle mouse button was debounced. */
  895. X#define  RIGHT_DOWN       109    /* Right mouse button was depressed. */
  896. X#define  RIGHT_UP         110    /* Right mouse button was debounced. */
  897. X#define  TAKE_FROM_SHELF  111    /* PUT function key was pressed. */
  898. X#define  PUT_ON_SHELF     112    /* GET function key was pressed. */
  899. X#define  DIED             113    /* Calctool window has been destroyed. */
  900. X#define  LASTEVENTPLUSONE 114    /* Not one of the above. */
  901. X
  902. X#define  HELPCURSOR     0      /* Cursor types. */
  903. X#define  MAINCURSOR     1
  904. X
  905. Xenum base_type { BIN, OCT, DEC, HEX } ;      /* Base definitions. */
  906. X
  907. Xenum but_state { NORMAL, INVERTED } ;        /* Calculator button states. */
  908. Xenum can_type { KEYCANVAS, REGCANVAS, PANELCANVAS } ;  /* Canvas types. */
  909. X
  910. Xenum font_type { SFONT, NFONT, BFONT } ;     /* Text font definitions. */
  911. X
  912. X/* Graphics supported. */
  913. Xenum gr_type  { MGR, NEWS, SVIEW, TTY, X11, XVIEW } ;
  914. X
  915. X/* Pseudo panel items. */
  916. Xenum item_type { BASEITEM, DISPLAYITEM, TTYPEITEM, NUMITEM,
  917. X                 HYPITEM,  INVITEM,     OPITEM } ;
  918. X
  919. X/* Popup menu types. Used with some of the graphics versions. */
  920. Xenum menu_type {
  921. X       M_ACC,    M_CON,   M_EXCH,   M_FUN,
  922. X       M_LSHIFT, M_RCL,   M_RSHIFT, M_STO
  923. X} ;
  924. X
  925. Xenum num_type { FIX, SCI } ;                 /* Number display mode. */
  926. X
  927. Xenum op_type { OP_SET, OP_CLEAR, OP_NOP } ;  /* Operation item settings. */
  928. X
  929. Xenum trig_type { DEG, GRAD, RAD } ;          /* Trigonometric types. */
  930. X
  931. X#define  BBORDER        10     /* No of pixels in border. */
  932. X#define  BCOLS          6      /* No of columns of buttons. */
  933. X#define  BGAP           5      /* No of pixels between buttons. */
  934. X#define  BHEIGHT        52     /* Number of pixels for height. */
  935. X#define  BROWS          6      /* No of rows of buttons. */
  936. X#define  BWIDTH         44     /* No of pixels for width. */
  937. X
  938. X#define  CCTRL(n)       n - 96     /* Generate control character value. */
  939. X#define  DISPLAY        30         /* Calculators numerical display. */
  940. X
  941. X#define  EQUAL          !strcmp    /* For character comparisons. */
  942. X#define  EXTRA          5          /* Extra useful character definitions. */
  943. X
  944. X#ifndef  HELPGIVEN
  945. X#define  HELPNAME       "calctool.help"
  946. X#endif /*HELPGIVEN*/
  947. X
  948. X#define  ICONHEIGHT     64         /* Height of calctool icon. */
  949. X#define  ICONWIDTH      42         /* Width of calctool icon. */
  950. X#define  INC            argc-- ; argv++ ;
  951. X#define  MAX_DIGITS     32         /* Maximum displayable number of digits. */
  952. X#define  MAXITEMS       7          /* Maximum number of panel items. */
  953. X
  954. X#ifndef  MAXLINE
  955. X#define  MAXLINE        256        /* Length of character strings. */
  956. X#endif /*MAXLINE*/
  957. X
  958. X#define  MAXMENUS       8          /* Maximum number of popup menus. */
  959. X#define  MAXREGS        10         /* Maximum number of memory registers. */
  960. X#define  MAXVKEYS       7          /* Number of valid keys after an error. */
  961. X#define  MIN(x,y)       ((x) < (y) ? (x) : (y))
  962. X
  963. X#ifndef  NEWSGIVEN
  964. X#define  NEWSNAME       "calctool.ps"
  965. X#endif /*NEWSGIVEN*/
  966. X
  967. X#define  NOBUTTONS      BROWS * BCOLS
  968. X
  969. X#ifndef  RCGIVEN
  970. X#define  RCNAME         ".calctoolrc"
  971. X#endif /*RCGIVEN*/
  972. X
  973. X#ifndef  NO_4_3SIGNAL
  974. X#define  SIGRET         void
  975. X#else
  976. X#define  SIGRET         int
  977. X#endif /*NO_4_3SIGNAL*/
  978. X
  979. X#define  THEIGHT        (BROWS*BHEIGHT) + ((BROWS-1) * BGAP) + (2*BBORDER)
  980. X#define  TITEMS         NOBUTTONS*2 + EXTRA    /* Total definitions. */
  981. X#define  TWIDTH         (BCOLS*BWIDTH) + ((BCOLS-1) * BGAP) + (2*BBORDER)
  982. X
  983. Xtypedef  unsigned long  BOOLEAN ;
  984. X
  985. Xstruct iteminfo                  /* Panel item information record. */
  986. X  {
  987. X    enum font_type font ;        /* Font type for this panel item. */
  988. X    int x ;                      /* X position of item. */
  989. X    int y ;                      /* Y position of item. */
  990. X    char text[60] ;              /* Text string associated with this item. */
  991. X  } ;
  992. X
  993. Xstruct button {
  994. X         char *str ;             /* Button display string. */
  995. X         char value ;            /* Unique button keyboard equivalent. */
  996. X         enum op_type opdisp ;   /* Display operation code during operation. */
  997. X         char color ;            /* Color of button portion. */
  998. X         int  (*func)() ;        /* Function to obey on button press. */
  999. X} ;
  1000. SHAR_EOF
  1001. chmod 0444 calctool.h || echo "restore of calctool.h fails"
  1002. set `wc -c calctool.h`;Sum=$1
  1003. if test "$Sum" != "6292"
  1004. then echo original size 6292, current size $Sum;fi
  1005. echo "x - extracting color.h (Text)"
  1006. sed 's/^X//' << 'SHAR_EOF' > color.h &&
  1007. X
  1008. X/*  @(#)color.h 1.1 89/03/21
  1009. X *
  1010. X *  Colormap definitions used by calctool.
  1011. X *
  1012. X *  Copyright (c) Rich Burridge.
  1013. X *               Sun Microsystems, Australia - All rights reserved.
  1014. X *
  1015. X *  Permission is given to distribute these sources, as long as the
  1016. X *  copyright messages are not removed, and no monies are exchanged.
  1017. X *
  1018. X *  No responsibility is taken for any errors or inaccuracies inherent
  1019. X *  either to the comments or the code of this program, but if
  1020. X *  reported to me then an attempt will be made to fix them.
  1021. X */
  1022. X
  1023. X#define  CALC_COLOR      "calcolor"
  1024. X#define  CALC_COLORSIZE  16
  1025. X
  1026. X#define  WHITE    0
  1027. X#define  RED      1
  1028. X#define  ORANGE   2
  1029. X#define  YELLOW   3
  1030. X#define  LGREEN   4
  1031. X#define  BLUE     5
  1032. X#define  MAUVE    6
  1033. X#define  GREEN    7
  1034. X#define  PINK     8
  1035. X#define  LBLUE    9
  1036. X#define  GREY     10
  1037. X#define  LGREY    11
  1038. X#define  LPURPLE  12
  1039. X#define  BLACK    13
  1040. X#define  SPARE14  14
  1041. X#define  SPARE15  15
  1042. X
  1043. X#define calc_colorsetup(r,g,b) \
  1044. X        (r)[WHITE] = 255 ;       (g)[WHITE] = 255 ;       (b)[WHITE] = 255 ; \
  1045. X        (r)[RED] = 255 ;         (g)[RED] = 50 ;          (b)[RED] = 0 ; \
  1046. X        (r)[ORANGE] = 255 ;      (g)[ORANGE] = 128 ;      (b)[ORANGE] = 0 ; \
  1047. X        (r)[YELLOW] = 255 ;      (g)[YELLOW] = 255 ;      (b)[YELLOW] = 0 ; \
  1048. X        (r)[LGREEN] = 128 ;      (g)[LGREEN] = 255 ;      (b)[LGREEN] = 128 ; \
  1049. X        (r)[BLUE] = 50 ;         (g)[BLUE] = 128 ;        (b)[BLUE] = 255 ; \
  1050. X        (r)[MAUVE] = 128 ;       (g)[MAUVE] = 128 ;       (b)[MAUVE] = 255 ; \
  1051. X        (r)[GREEN] = 0 ;         (g)[GREEN] = 158 ;       (b)[GREEN] = 158 ; \
  1052. X        (r)[PINK] = 255 ;        (g)[PINK] = 192 ;        (b)[PINK] = 192 ; \
  1053. X        (r)[LBLUE] = 50 ;        (g)[LBLUE] = 178 ;       (b)[LBLUE] = 255 ; \
  1054. X        (r)[GREY] = 128 ;        (g)[GREY] = 128 ;        (b)[GREY] = 128 ; \
  1055. X        (r)[LGREY] = 200 ;       (g)[LGREY] = 200 ;       (b)[LGREY] = 200 ; \
  1056. X        (r)[LPURPLE] = 225 ;     (g)[LPURPLE] = 225 ;     (b)[LPURPLE] = 255 ; \
  1057. X        (r)[BLACK] = 0 ;         (g)[BLACK] = 0 ;         (b)[BLACK] = 0 ; \
  1058. X        (r)[SPARE14] = 0 ;       (g)[SPARE14] = 0 ;       (b)[SPARE14] = 0 ; \
  1059. X        (r)[SPARE15] = 0 ;       (g)[SPARE15] = 0 ;       (b)[SPARE15] = 0 ;
  1060. SHAR_EOF
  1061. chmod 0444 color.h || echo "restore of color.h fails"
  1062. set `wc -c color.h`;Sum=$1
  1063. if test "$Sum" != "2202"
  1064. then echo original size 2202, current size $Sum;fi
  1065. echo "x - extracting extern.h (Text)"
  1066. sed 's/^X//' << 'SHAR_EOF' > extern.h &&
  1067. X
  1068. X/*  @(#)extern.h 1.9 89/11/01
  1069. X *
  1070. X *  Contains the external variable definitions used by calctool.
  1071. X *
  1072. X *  Copyright (c) Rich Burridge.
  1073. X *                Sun Microsystems, Australia - All rights reserved.
  1074. X *
  1075. X *  Permission is given to distribute these sources, as long as the
  1076. X *  copyright messages are not removed, and no monies are exchanged.
  1077. X *
  1078. X *  No responsibility is taken for any errors or inaccuracies inherent
  1079. X *  either to the comments or the code of this program, but if
  1080. X *  reported to me then an attempt will be made to fix them.
  1081. X */
  1082. X
  1083. Xextern char *make_fixed(), *make_number(), *make_scientific() ;
  1084. Xextern char base_str[4][4] ;               /* Strings for each base value. */
  1085. Xextern char con_names[MAXREGS][MAXLINE] ;  /* .calctoolrc constant names. */
  1086. Xextern char cur_op ;            /* Current arithmetic operation. */
  1087. Xextern char current ;           /* Current button or character pressed. */
  1088. Xextern char digits[] ;          /* Valid numerical digits. */
  1089. Xextern char display[] ;         /* Current calculator display. */
  1090. Xextern char dtype_str[2][4] ;   /* Strings for each display mode value. */
  1091. Xextern char *exp_posn ;         /* Position of the exponent sign. */
  1092. Xextern char fnum[] ;            /* Scratch area for fixed point numbers. */
  1093. Xextern char fun_names[MAXREGS][MAXLINE] ; /* .calctoolrc function names. */
  1094. Xextern char fun_vals[MAXREGS][MAXLINE] ;  /* .calctoolrc function defs. */
  1095. Xextern char geometry[] ;        /* X11 geometry information. */
  1096. Xextern char helpname[] ;        /* Filename for helpfile. */
  1097. Xextern char num_names[MAXREGS][2] ;       /* Used by the popup menus. */
  1098. Xextern char old_cal_value ;     /* Previous calculation operator. */
  1099. Xextern char progname[] ;        /* Name of this program. */
  1100. Xextern char pstr[] ;            /* Current button text string. */
  1101. Xextern char revtable[] ;        /* Table for reversing the bits in a byte. */
  1102. Xextern char *selection ;        /* Current [Get] selection. */
  1103. Xextern char *shelf ;            /* PUT selection shelf contents. */
  1104. Xextern char snum[] ;            /* Scratch are for scientific numbers. */
  1105. Xextern char ttype_str[3][5] ;   /* Strings for each trig type value. */
  1106. Xextern char validkeys[] ;       /* Valid keys after an error condition. */
  1107. Xextern char validmenu[] ;       /* Valid keys with popup menus. */
  1108. Xextern char x11_display[] ;     /* X11 display information. */
  1109. X
  1110. Xextern double convert_display() ;
  1111. Xextern double con_vals[] ;        /* Selectable constants. */
  1112. Xextern double disp_val ;           /* Value of the current display. */
  1113. Xextern double exp_p1[10][4] ;
  1114. Xextern double last_input ;         /* Previous number input by user. */
  1115. Xextern double max_fix[] ;          /* Maximum showable fixed values. */
  1116. Xextern double mem_vals[] ;         /* Memory register values. */
  1117. Xextern double powers[11][4] ;      /* Table of power values for each base. */
  1118. Xextern double result ;             /* Current calculator total value. */
  1119. Xextern double tresults[] ;         /* Current trigonometric results. */
  1120. X
  1121. Xextern enum base_type base ;       /* Current base: BIN, OCT, DEC or HEX. */
  1122. Xextern enum gr_type gtype ;        /* What graphics system is being used. */
  1123. Xextern enum num_type dtype ;       /* Number display mode. */
  1124. Xextern enum trig_type ttype ;      /* Trigonometric type (deg, grad or rad). */
  1125. X
  1126. Xextern int accuracy ;       /* Number of digits precision (Max 9). */
  1127. Xextern int basevals[] ;     /* Supported arithmetic bases. */
  1128. Xextern int chxoff[] ;       /* X offset for various length button strings. */
  1129. Xextern int color ;          /* Color used for current raster operation. */
  1130. Xextern int column ;         /* Column number of current key/mouse press. */
  1131. Xextern int cur_ch ;         /* Current character if keyboard event. */
  1132. Xextern int curx ;           /* Current mouse X position. */
  1133. Xextern int cury ;           /* Current mouse Y position. */
  1134. Xextern int disp_length[] ;  /* Display length in characters for each base. */
  1135. Xextern int down ;           /* Indicates if mouse button is down. */
  1136. Xextern int error ;          /* Indicates some kind of display error. */
  1137. Xextern int hyperbolic ;     /* If set, trig functions will be hyperbolic. */
  1138. Xextern int iconic ;         /* Set if window is currently iconic. */
  1139. Xextern int inv_video ;      /* Set if user wants inverse video mode. */
  1140. Xextern int inverse ;        /* If set, trig & log functions will be inversed. */
  1141. Xextern int iscolor ;        /* Set if this is a color screen. */
  1142. Xextern int ishelp ;         /* Set if there is a help file. */
  1143. Xextern int issel ;          /* Set if valid [Get] selection. */
  1144. Xextern int ix ;             /* Initial X position of the icon. */
  1145. Xextern int iy ;             /* Initial Y position of the icon. */
  1146. Xextern int key_exp ;        /* Set if entering exponent number. */
  1147. Xextern int new_input ;      /* New number input since last op. */
  1148. Xextern int nextc ;          /* Current event identifier. */
  1149. Xextern int nfont_width ;    /* Width of the normal font characters. */
  1150. Xextern int pending ;        /* Set for command with on multiple presses. */
  1151. Xextern int pending_op ;     /* Arithmetic operation for pending command. */
  1152. Xextern int pointed ;        /* Whether a decimal point has been given. */
  1153. Xextern int portion ;        /* Button portion on current key/mouse press. */
  1154. Xextern int posspec ;        /* Set if -Wp or -g option is present (for X11) */
  1155. Xextern int row ;            /* Row number of current key/mouse press. */
  1156. Xextern int rstate ;         /* Is memory register frame displayed? */
  1157. Xextern int signgam ;
  1158. Xextern int spaces ;         /* Number of spaces in current button string. */
  1159. Xextern int toclear ;        /* Indicates if display should be cleared. */
  1160. Xextern int tstate ;         /* Current button set being displayed. */
  1161. Xextern int wx ;             /* Initial X position of the window. */
  1162. Xextern int wy ;             /* Initial Y position of the window. */
  1163. Xextern int x ;              /* X offset for text for button. */
  1164. Xextern int y ;              /* Y offset for text for button. */
  1165. X
  1166. Xextern FILE *hfd ;          /* File descriptor for help information. */
  1167. X
  1168. Xextern struct iteminfo items[] ;  /* Panel items. */
  1169. Xextern struct button buttons[] ;  /* Calculator button values. */
  1170. SHAR_EOF
  1171. chmod 0444 extern.h || echo "restore of extern.h fails"
  1172. set `wc -c extern.h`;Sum=$1
  1173. if test "$Sum" != "6171"
  1174. then echo original size 6171, current size $Sum;fi
  1175. echo "x - extracting calctool.icon (Text)"
  1176. sed 's/^X//' << 'SHAR_EOF' > calctool.icon &&
  1177. X/* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  1178. X */
  1179. X    0x9555,0x5555,0x5540,0x0000,0xAAAA,0xAAAA,0xAA80,0x0000,
  1180. X    0x5555,0x5555,0x5540,0x0000,0xFFFF,0xFFFF,0xFE80,0x0000,
  1181. X    0x8000,0x0000,0x0340,0x0000,0xBFFF,0xFFFF,0xFA80,0x0000,
  1182. X    0xA000,0x0000,0x0B40,0x0000,0xA000,0x0000,0x0A80,0x0000,
  1183. X    0xA003,0x0030,0xCB40,0x0000,0xA004,0x8049,0x2A80,0x0000,
  1184. X    0xA005,0x8059,0x6B40,0x0000,0xA006,0x8069,0xAA80,0x0000,
  1185. X    0xA004,0x8449,0x2B40,0x0000,0xA003,0x0430,0xCA80,0x0000,
  1186. X    0xA000,0x0000,0x0B40,0x0000,0xA000,0x0000,0x0A80,0x0000,
  1187. X    0xBFFF,0xFFFF,0xFB40,0x0000,0x8000,0x0000,0x0280,0x0000,
  1188. X    0x8000,0x0000,0x0340,0x0000,0xBFDF,0xEFF7,0xFA80,0x0000,
  1189. X    0xA050,0x2814,0x0B40,0x0000,0xAF53,0x2994,0x0A80,0x0000,
  1190. X    0xA154,0xAA55,0x1340,0x0000,0xA253,0x2A54,0xAA80,0x0000,
  1191. X    0xA254,0xA9D4,0x4B40,0x0000,0xA454,0xA854,0xAA80,0x0000,
  1192. X    0xA453,0x2995,0x1B40,0x0000,0xA050,0x2814,0x0A80,0x0000,
  1193. X    0xBFDF,0xEFF7,0xFB40,0x0000,0x8000,0x0000,0x0280,0x0000,
  1194. X    0xBFDF,0xEFF7,0xFB40,0x0000,0xA050,0x2814,0x0A80,0x0000,
  1195. X    0xA257,0xA994,0x2B40,0x0000,0xA654,0x2A14,0x4A80,0x0000,
  1196. X    0xAA57,0x2B94,0x4B40,0x0000,0xAF50,0xAA54,0x8A80,0x0000,
  1197. X    0xA254,0xAA54,0x8B40,0x0000,0xA253,0x2995,0x0A80,0x0000,
  1198. X    0xA050,0x2814,0x0B40,0x0000,0xBFDF,0xEFF7,0xFA80,0x0000,
  1199. X    0x8000,0x0000,0x0340,0x0000,0xBFDF,0xEFF7,0xFA80,0x0000,
  1200. X    0xA050,0x2814,0x0B40,0x0000,0xA253,0x2994,0x0A80,0x0000,
  1201. X    0xA654,0xAA54,0x0B40,0x0000,0xA250,0xA895,0xEA80,0x0000,
  1202. X    0xA253,0x2854,0x0B40,0x0000,0xA254,0x2A54,0x0A80,0x0000,
  1203. X    0xA757,0xA994,0x0B40,0x0000,0xA050,0x2814,0x0A80,0x0000,
  1204. X    0xBFDF,0xEFF7,0xFB40,0x0000,0x8000,0x0000,0x0280,0x0000,
  1205. X    0xBFDF,0xEFF7,0xFB40,0x0000,0xA050,0x2814,0x0A80,0x0000,
  1206. X    0xA650,0x2814,0x0B40,0x0000,0xA950,0x2814,0x4A80,0x0000,
  1207. X    0xAB50,0x2BD4,0x4B40,0x0000,0xAD50,0x2815,0xFA80,0x0000,
  1208. X    0xA951,0x2BD4,0x4B40,0x0000,0xA651,0x2814,0x4A80,0x0000,
  1209. X    0xA050,0x2814,0x0B40,0x0000,0xBFDF,0xEFF7,0xFA80,0x0000,
  1210. X    0x8000,0x0000,0x0300,0x0000,0xFFFF,0xFFFF,0xFE00,0x0000
  1211. SHAR_EOF
  1212. chmod 0444 calctool.icon || echo "restore of calctool.icon fails"
  1213. set `wc -c calctool.icon`;Sum=$1
  1214. if test "$Sum" != "1933"
  1215. then echo original size 1933, current size $Sum;fi
  1216. echo "x - extracting calctool.color.icon (Text)"
  1217. sed 's/^X//' << 'SHAR_EOF' > calctool.color.icon &&
  1218. X/* Format_version=1, Width=64, Height=64, Depth=8, Valid_bits_per_item=16
  1219. X */
  1220. X    0x0d00,0x000d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,
  1221. X    0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,
  1222. X    0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0000,0x0000,0x0000,
  1223. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1224. X    0x0d00,0x0d0a,0x0d0a,0x0d0a,0x0d0a,0x0d0a,0x0d0a,0x0d0a,
  1225. X    0x0d0a,0x0d0a,0x0d0a,0x0d0a,0x0d0a,0x0d0a,0x0d0a,0x0d0a,
  1226. X    0x0d0a,0x0d0a,0x0d0a,0x0d0a,0x0d0a,0x0000,0x0000,0x0000,
  1227. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1228. X    0x000d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,
  1229. X    0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,
  1230. X    0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0a0d,0x0000,0x0000,0x0000,
  1231. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1232. X    0x0d0d,0x0d0d,0x0d0d,0x0d0d,0x0d0d,0x0d0d,0x0d0d,0x0d0d,
  1233. X    0x0d0d,0x0d0d,0x0d0d,0x0d0d,0x0d0d,0x0d0d,0x0d0d,0x0d0d,
  1234. X    0x0d0d,0x0d0d,0x0d0d,0x0d0a,0x0d0a,0x0000,0x0000,0x0000,
  1235. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1236. X    0x0d0b,0x0b0b,0x0b0b,0x0b0b,0x0b0b,0x0b0b,0x0b0b,0x0b0b,
  1237. X    0x0b0b,0x0b0b,0x0b0b,0x0b0b,0x0b0b,0x0b0b,0x0b0b,0x0b0b,
  1238. X    0x0b0b,0x0b0b,0x0b0b,0x0d0d,0x0a0d,0x0000,0x0000,0x0000,
  1239. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1240. X    0x0d0b,0x0d0d,0x0d0d,0x0d0d,0x0d0d,0x0d0d,0x0d0d,0x0d0d,
  1241. X    0x0d0d,0x0d0d,0x0d0d,0x0d0d,0x0d0d,0x0d0d,0x0d0d,0x0d0d,
  1242. X    0x0d0d,0x0d0d,0x0d0b,0x0d0a,0x0d0a,0x0000,0x0000,0x0000,
  1243. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1244. X    0x0d0b,0x0d00,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1245. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1246. X    0x0000,0x0000,0x0d0b,0x0d0d,0x0a0d,0x0000,0x0000,0x0000,
  1247. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1248. X    0x0d0b,0x0d00,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1249. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1250. X    0x0000,0x0000,0x0d0b,0x0d0a,0x0d0a,0x0000,0x0000,0x0000,
  1251. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1252. X    0x0d0b,0x0d00,0x0000,0x0000,0x0000,0x0000,0x0000,0x0d0d,
  1253. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0d0d,0x0000,0x0000,
  1254. X    0x0d0d,0x0000,0x0d0b,0x0d0d,0x0a0d,0x0000,0x0000,0x0000,
  1255. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1256. X    0x0d0b,0x0d00,0x0000,0x0000,0x0000,0x0000,0x000d,0x0000,
  1257. X    0x0d00,0x0000,0x0000,0x0000,0x000d,0x0000,0x0d00,0x000d,
  1258. X    0x0000,0x0d00,0x0d0b,0x0d0a,0x0d0a,0x0000,0x0000,0x0000,
  1259. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1260. X    0x0d0b,0x0d00,0x0000,0x0000,0x0000,0x0000,0x000d,0x000d,
  1261. X    0x0d00,0x0000,0x0000,0x0000,0x000d,0x000d,0x0d00,0x000d,
  1262. X    0x000d,0x0d00,0x0d0b,0x0d0d,0x0a0d,0x0000,0x0000,0x0000,
  1263. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1264. X    0x0d0b,0x0d00,0x0000,0x0000,0x0000,0x0000,0x000d,0x0d00,
  1265. X    0x0d00,0x0000,0x0000,0x0000,0x000d,0x0d00,0x0d00,0x000d,
  1266. X    0x0d00,0x0d00,0x0d0b,0x0d0a,0x0d0a,0x0000,0x0000,0x0000,
  1267. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1268. X    0x0d0b,0x0d00,0x0000,0x0000,0x0000,0x0000,0x000d,0x0000,
  1269. X    0x0d00,0x0000,0x000d,0x0000,0x000d,0x0000,0x0d00,0x000d,
  1270. X    0x0000,0x0d00,0x0d0b,0x0d0d,0x0a0d,0x0000,0x0000,0x0000,
  1271. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1272. X    0x0d0b,0x0d00,0x0000,0x0000,0x0000,0x0000,0x0000,0x0d0d,
  1273. X    0x0000,0x0000,0x000d,0x0000,0x0000,0x0d0d,0x0000,0x0000,
  1274. X    0x0d0d,0x0000,0x0d0b,0x0d0a,0x0d0a,0x0000,0x0000,0x0000,
  1275. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1276. X    0x0d0b,0x0d00,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1277. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  1278. X    0x0000,0x0000,0x0d0b,0x0d0d,0x0a0d,0x0000,0x0000,0x0000,
  1279. SHAR_EOF
  1280. echo "End of part 5"
  1281. echo "File calctool.color.icon is continued in part 6"
  1282. echo "6" > s2_seq_.tmp
  1283. exit 0
  1284.  
  1285.