home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume27 / sfs / part09 < prev    next >
Encoding:
Text File  |  1991-12-27  |  55.2 KB  |  2,038 lines

  1. Newsgroups: comp.sources.misc
  2. From: tcamp@hercules.acpub.duke.edu (Ted Campbell)
  3. Subject:  v27i009:  sfs - Space Flight Simulator, Part09/21
  4. Message-ID: <1991Dec24.045505.194@sparky.imd.sterling.com>
  5. X-Md4-Signature: cea7f441b8b27559ebbe15c019dbc851
  6. Date: Tue, 24 Dec 1991 04:55:05 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: tcamp@hercules.acpub.duke.edu (Ted Campbell)
  10. Posting-number: Volume 27, Issue 9
  11. Archive-name: sfs/part09
  12. Environment: IBMPC && EGA/VGA, UNIX-PC && MGR, UNIX && X11,
  13.  
  14. #!/bin/sh
  15. # do not concatenate these parts, unpack them in order with /bin/sh
  16. # file io/ui/ui_icon.c continued
  17. #
  18. if test ! -r _shar_seq_.tmp; then
  19.     echo 'Please unpack part 1 first!'
  20.     exit 1
  21. fi
  22. (read Scheck
  23.  if test "$Scheck" != 9; then
  24.     echo Please unpack part "$Scheck" next!
  25.     exit 1
  26.  else
  27.     exit 0
  28.  fi
  29. ) < _shar_seq_.tmp || exit 1
  30. if test ! -f _shar_wnt_.tmp; then
  31.     echo 'x - still skipping io/ui/ui_icon.c'
  32. else
  33. echo 'x - continuing file io/ui/ui_icon.c'
  34. sed 's/^X//' << 'SHAR_EOF' >> 'io/ui/ui_icon.c' &&
  35. X               TRUE );
  36. X
  37. X
  38. #ifdef  USESMALLFONT
  39. X   gr_font( ui_screen, m_box->save_font,
  40. X      m_box->save_fysize );
  41. #endif
  42. X
  43. X            }
  44. X
  45. X     *item = m_box->current;
  46. X     return EVENT_CHANGE;
  47. X         break;
  48. X
  49. X      case MO_SEL:
  50. X         if ( ((( y_sel + m_box->y_start ) * m_box->x_logical )
  51. X            + x_sel + m_box->x_start ) == m_box->current )
  52. X            {
  53. X            *item = m_box->current;
  54. X            return EVENT_SELECTED;
  55. X            }
  56. X         else
  57. X            {
  58. X
  59. #ifdef  USESMALLFONT
  60. X   m_box->save_font = ui_grwind->font;
  61. X   m_box->save_fysize = ui_grwind->fysize;
  62. X   gr_font( ui_screen, F_DEFAULT, ui_grwind->ymax / SMALLFONTSIZE );
  63. #endif
  64. X
  65. X        uii_icon( m_box, m_box->current, FALSE );
  66. X            m_box->current = (( y_sel + m_box->y_start )
  67. X               * m_box->x_logical )
  68. X               + m_box->x_start + x_sel;
  69. X            m_box->x_pos = x_sel;
  70. X            m_box->y_pos = y_sel;
  71. X        uii_icon( m_box, m_box->current, TRUE );
  72. X
  73. #ifdef  USESMALLFONT
  74. X   gr_font( ui_screen, m_box->save_font,
  75. X      m_box->save_fysize );
  76. #endif
  77. X
  78. X            }
  79. X     *item = m_box->current;
  80. X     return EVENT_CHANGE;
  81. X         break;
  82. X
  83. X      case MO_SRC:
  84. X
  85. X          *item = (( y_sel + m_box->y_start ) * m_box->x_logical )
  86. X               + m_box->x_start + x_sel;
  87. X         return EVENT_SOURCE;
  88. X         break;
  89. X
  90. X      default:
  91. X         *item = 0;
  92. X         return EVENT_NULL;
  93. X         break;
  94. X
  95. X      }
  96. X   }
  97. X
  98. /****************************************************************
  99. X
  100. X   uii_source()   Query if keyboard or mouse actions indicate a
  101. X          source within a menu box
  102. X
  103. ****************************************************************/
  104. X
  105. uii_source( m_box, key, mo_xsrc, mo_ysrc, mo_xdest, mo_ydest, item )
  106. X   struct menu_box *m_box;
  107. X   int key, mo_xsrc, mo_ysrc, mo_xdest, mo_ydest;
  108. X   int *item;
  109. X   {
  110. X   static int how_far, x_sel, y_sel;
  111. X   int carry_on;
  112. X   register int c;
  113. X
  114. X   how_far = 0;
  115. X   x_sel = 0;
  116. X   y_sel = 0;
  117. X   c = ui_event( m_box, key, mo_xsrc, mo_ysrc, mo_xdest, mo_ydest,
  118. X      &how_far, &x_sel, &y_sel );
  119. X
  120. X   if ( c == MO_SRC )
  121. X      {
  122. X      *item = (( y_sel + m_box->y_start ) * m_box->x_logical )
  123. X     + m_box->x_start + x_sel;
  124. X      return TRUE;
  125. X      }
  126. X   else
  127. X      {
  128. X      return FALSE;
  129. X      }
  130. X   }
  131. X
  132. /****************************************************************
  133. X
  134. X   uii_display()      Show all file icons
  135. X
  136. ****************************************************************/
  137. X
  138. uii_display( m_box )
  139. X   struct menu_box *m_box;
  140. X   {
  141. X   register int c;
  142. X
  143. X   /* blank the entire icon area */
  144. X
  145. X   ui_fbox( m_box->i_x1, m_box->i_y1, m_box->i_x2, m_box->i_y2,
  146. X      m_box->back, SOLID );
  147. X
  148. X   /* attempt to show each icon */
  149. X
  150. X   for ( c = 0; c < m_box->number; ++c )
  151. X      {
  152. X      uii_icon( m_box, c,
  153. X         FALSE );
  154. X      }
  155. X
  156. X   /* show elevators */
  157. X
  158. X   uil_vel( m_box, m_box->y_start );            /* show vertical elevator */
  159. X   uil_hel( m_box, m_box->x_start );            /* show horizontal elevator */
  160. X
  161. X   }
  162. X
  163. /****************************************************************
  164. X
  165. X   uii_icon()   Draw file icon
  166. X
  167. ****************************************************************/
  168. X
  169. uii_icon( m_box, n, selected )
  170. X   int n, selected;
  171. X   struct menu_box *m_box;
  172. X   {
  173. X   register int x, y;
  174. X   int x1, y1, x2, y2, textxpos;
  175. X   int restore_clip, clx1, cly1, clx2, cly2;
  176. X   static char buf[ 20 ];
  177. X
  178. #ifdef  OLD_DEBUG
  179. X   sprintf( ui_tbuf, "uii_icon() called; item %d ", n );
  180. X   ui_wtitle( m_box->window, ui_tbuf );
  181. X   ui_wait();
  182. #endif
  183. X
  184. X   x = ( n % m_box->x_logical ) - m_box->x_start;
  185. X   y = ( n / m_box->x_logical ) - m_box->y_start;
  186. X
  187. #ifdef  OLD_DEBUG
  188. X   sprintf( ui_tbuf, "x = %d, y = %d", x, y );
  189. X   ui_text( m_box->i_x1, m_box->i_y1, m_box->i_x2,
  190. X      m_box->i_y2, 35, m_box->back, m_box->fore, ui_tbuf );
  191. X   ui_wait();
  192. #endif
  193. X
  194. X   if ( ( x < 0 ) || ( y < 0 ))
  195. X      {
  196. X      return FALSE;
  197. X      }
  198. X
  199. X   if ( ( x >= ( m_box->x_items + gr_clipping ))
  200. X      || ( y >= ( m_box->y_items + gr_clipping )))
  201. X      {
  202. X      return FALSE;
  203. X      }
  204. X
  205. X   x1 = m_box->i_x1 + ( x * m_box->xsize );
  206. X   y1 = m_box->i_y2 - ( ( 1 + y ) * m_box->ysize ) - 1;
  207. X   x2 = m_box->i_x1 + ( ( 1 + x ) * m_box->xsize ) - 1;
  208. X   y2 = m_box->i_y2 - ( y * m_box->ysize );
  209. X
  210. X   /* see if cliiping is in effect */
  211. X
  212. X   if ( ( gr_clipping == TRUE ) && ( ui_grwind->clipping == TRUE ))
  213. X      {
  214. X      restore_clip = TRUE;
  215. X      clx1 = ui_grwind->cl_x1;
  216. X      cly1 = ui_grwind->cl_y1;
  217. X      clx2 = ui_grwind->cl_x2;
  218. X      cly2 = ui_grwind->cl_y2;
  219. X      }
  220. X   else
  221. X      {
  222. X      restore_clip = FALSE;
  223. X      }
  224. X
  225. X   if ( gr_clipping == TRUE )
  226. X      {
  227. X      gr_clip( ui_screen, TRUE, m_box->i_x1, m_box->i_y1,
  228. X         m_box->i_x2, m_box->i_y2 );
  229. X      }
  230. X
  231. X   /* blank the icon area */
  232. X
  233. X   ui_fbox( x1, y1, x2, y2, m_box->back, SOLID );
  234. X
  235. X   /* add two blanks if the name is small */
  236. X
  237. X   if ( strlen( m_box->d_entries[ n ]->filename ) < 6 )
  238. X      {
  239. X      sprintf( buf, " %s ", m_box->d_entries[ n ]->filename );
  240. X      }
  241. X   else
  242. X      {
  243. X      strcpy( buf, m_box->d_entries[ n ]->filename );
  244. X      }
  245. X
  246. X   /* calculate centered text position */
  247. X
  248. X   textxpos = ( x1 + ( m_box->xsize / 2 ))
  249. X      - ( gr_strlen( buf ) / 2 );
  250. X
  251. X   /* print the text */
  252. X
  253. X   if ( selected == TRUE )
  254. X      {
  255. X      gr_text( ui_screen, textxpos, y1 + 2,
  256. X          buf, m_box->back, m_box->fore );
  257. X      }
  258. X   else
  259. X      {
  260. X      gr_text( ui_screen, textxpos, y1 + 2,
  261. X         buf, m_box->fore, m_box->back );
  262. X      }
  263. X
  264. X   /* increment y1 out of text area */
  265. X
  266. X   y1 += ui_grwind->fysize;
  267. X
  268. X   /* draw the icon */
  269. X
  270. X   switch( m_box->d_entries[ n ]->type )
  271. X      {
  272. X
  273. X      case    FILE_DIRECTORY:
  274. X     uii_folder( x1, y1, x2, y2, m_box->fore );
  275. X         break;
  276. X
  277. X      case    FILE_EXECUTABLE:
  278. X     uii_exec( x1, y1, x2, y2, m_box->fore );
  279. X         break;
  280. X
  281. X      case    FILE_NORMAL:
  282. X      default:
  283. X     uii_default( x1, y1, x2, y2, m_box->fore );
  284. X         break;
  285. X      }
  286. X
  287. X   /* restore clipping or turn off clipping */
  288. X
  289. X   if ( restore_clip == TRUE )
  290. X      {
  291. X      gr_clip( ui_screen, TRUE, clx1, cly1, clx2, cly2 );
  292. X      }
  293. X   else if ( gr_clipping == TRUE )
  294. X      {
  295. X      gr_clip( ui_screen, FALSE, 0, 0, 0, 0 );
  296. X      }
  297. X   }
  298. X
  299. /****************************************************************
  300. X
  301. X   uii_default()   Default (blank or generic) file icon
  302. X
  303. ****************************************************************/
  304. X
  305. uii_default( x1, y1, x2, y2, color )
  306. X   int x1, y1, x2, y2, color;
  307. X   {
  308. #ifdef USE_ICONS
  309. X   ui_pbmcenter( ui_screen, x1, y1, x2, y2, &ui_deficon );
  310. #else
  311. X   int x, y, y_center, x_center;
  312. X
  313. X   /* calculate the center of the icon area */
  314. X
  315. X   y_center = y1 + (( y2 - y1 ) / 2 );
  316. X   x_center = x1 + (( x2 - x1 ) / 2 );
  317. X
  318. X   /* calculate appropriate sizes for the icon */
  319. X
  320. X   y = ( y2 - y1 ) / 3;
  321. X   x = ((( y * gr_pysize ) / gr_pxsize ) * 3 ) / 4;
  322. X
  323. X   /* draw the icon rectangle */
  324. X
  325. X   gr_rectangle( ui_screen, x_center - x,
  326. X      y_center - y,
  327. X      x_center + x,
  328. X      y_center + y, color, HOLLOW );
  329. X
  330. X   /* draw demarking line across the top */
  331. X
  332. X   gr_line( ui_screen, x_center - x, ( y_center + y ) - 3,
  333. X      x_center + x, ( y_center + y ) - 3, color, SOLID );
  334. X
  335. #endif
  336. X
  337. X   }
  338. X
  339. /****************************************************************
  340. X
  341. X   uii_folder()    File folder (directory) icon
  342. X
  343. ****************************************************************/
  344. X
  345. uii_folder( x1, y1, x2, y2, color )
  346. X   int x1, y1, x2, y2, color;
  347. X   {
  348. #ifdef USE_ICONS
  349. X   ui_pbmcenter( ui_screen, x1, y1, x2, y2, &ui_foldicon );
  350. #else
  351. X   int x, y, y_center, x_center;
  352. X
  353. X   /* calculate the center of the icon area */
  354. X
  355. X   y_center = y1 + (( y2 - y1 ) / 2 );
  356. X   x_center = x1 + (( x2 - x1 ) / 2 );
  357. X
  358. X   /* calculate appropriate sizes for the folder */
  359. X
  360. X   y = ( y2 - y1 ) / 4;
  361. X   x = ((( y * gr_pysize ) / gr_pxsize ) * 3 ) / 2;
  362. X
  363. X   /* draw left side of folder */
  364. X
  365. X   gr_line( ui_screen, x_center - x, y_center - y,
  366. X      x_center - x, y_center + y, color, SOLID );
  367. X
  368. X   /* draw bottom of folder */
  369. X
  370. X   gr_line( ui_screen, x_center - x, y_center - y,
  371. X      x_center + x, y_center - y, color, SOLID );
  372. X
  373. X   /* draw right side of folder */
  374. X
  375. X   gr_line( ui_screen, x_center + x, y_center - y,
  376. X      x_center + x, y_center + y, color, SOLID );
  377. X
  378. X   /* draw file tab (upper) */
  379. X
  380. X   gr_line( ui_screen, x_center + x, y_center + y,
  381. X      x_center + x - 4, y_center + y + 2, color, SOLID );
  382. X   gr_line( ui_screen, x_center + x - 4, y_center + y + 2,
  383. X      x_center + 4, y_center + y + 2, color, SOLID );
  384. X   gr_line( ui_screen, x_center + 4, y_center + y + 2,
  385. X      x_center, y_center + y, color, SOLID );
  386. X
  387. X   /* draw top of folder (upper) */
  388. X
  389. X   gr_line( ui_screen, x_center - x, y_center + y,
  390. X      x_center, y_center + y, color, SOLID );
  391. X
  392. X   /* draw file tab (lower) */
  393. X
  394. X   gr_line( ui_screen, x_center + x, y_center + y - 4,
  395. X      x_center + 4, y_center + y - 4, color, SOLID );
  396. X   gr_line( ui_screen, x_center + 4, y_center + y - 4,
  397. X      x_center, y_center + y - 2, color, SOLID );
  398. X
  399. X   /* draw top of folder (lower) */
  400. X
  401. X   gr_line( ui_screen, x_center - x, y_center + y - 2,
  402. X      x_center, y_center + y - 2, color, SOLID );
  403. X
  404. #endif
  405. X
  406. X   }
  407. X
  408. /****************************************************************
  409. X
  410. X   uii_exec()      Icon for executable files
  411. X
  412. ****************************************************************/
  413. X
  414. uii_exec( x1, y1, x2, y2, color )
  415. X   int x1, y1, x2, y2, color;
  416. X   {
  417. #ifdef USE_ICONS
  418. X   ui_pbmcenter( ui_screen, x1, y1, x2, y2, &ui_exicon );
  419. #else
  420. X   int x, y, y_center, x_center;
  421. X
  422. X   /* calculate the center of the icon area */
  423. X
  424. X   y_center = y1 + (( y2 - y1 ) / 2 );
  425. X   x_center = x1 + (( x2 - x1 ) / 2 );
  426. X
  427. X   /* calculate appropriate sizes for the icon */
  428. X
  429. X   y = ( y2 - y1 ) / 4;
  430. X   x = ( y * gr_pysize ) / gr_pxsize;
  431. X
  432. X   /* draw the icon rectangle */
  433. X
  434. X   gr_rectangle( ui_screen, x_center - x,
  435. X      y_center - y,
  436. X      x_center + x,
  437. X      y_center + y, color, HOLLOW );
  438. X
  439. X   /* show circle to indicate executable */
  440. X
  441. X   gr_circle( ui_screen, x_center, y_center,
  442. X      y / 3, color, GRID );
  443. X
  444. #endif
  445. X
  446. X   }
  447. X
  448. SHAR_EOF
  449. echo 'File io/ui/ui_icon.c is complete' &&
  450. chmod 0644 io/ui/ui_icon.c ||
  451. echo 'restore of io/ui/ui_icon.c failed'
  452. Wc_c="`wc -c < 'io/ui/ui_icon.c'`"
  453. test 31158 -eq "$Wc_c" ||
  454.     echo 'io/ui/ui_icon.c: original size 31158, current size' "$Wc_c"
  455. rm -f _shar_wnt_.tmp
  456. fi
  457. # ============= io/ui/ui_init.c ==============
  458. if test -f 'io/ui/ui_init.c' -a X"$1" != X"-c"; then
  459.     echo 'x - skipping io/ui/ui_init.c (File already exists)'
  460.     rm -f _shar_wnt_.tmp
  461. else
  462. > _shar_wnt_.tmp
  463. echo 'x - extracting io/ui/ui_init.c (Text)'
  464. sed 's/^X//' << 'SHAR_EOF' > 'io/ui/ui_init.c' &&
  465. /****************************************************************
  466. X
  467. X    ui_init.c       Initialization routines for
  468. X            The Bywater Graphical User Interface
  469. X
  470. X            Copyright (c) 1991, Ted A. Campbell
  471. X
  472. X            Bywater Software
  473. X            P. O. Box 4023 
  474. X            Duke Station 
  475. X            Durham, NC  27706
  476. X
  477. X            email: tcamp@hercules.acpub.duke.edu
  478. X
  479. X    Copyright and Permissions Information:
  480. X
  481. X    All U.S. and international copyrights are claimed by the
  482. X    author. The author grants permission to use this code
  483. X    and software based on it under the following conditions:
  484. X    (a) in general, the code and software based upon it may be 
  485. X    used by individuals and by non-profit organizations; (b) it
  486. X    may also be utilized by governmental agencies in any country,
  487. X    with the exception of military agencies; (c) the code and/or
  488. X    software based upon it may not be sold for a profit without
  489. X    an explicit and specific permission from the author, except
  490. X    that a minimal fee may be charged for media on which it is
  491. X    copied, and for copying and handling; (d) the code must be 
  492. X    distributed in the form in which it has been released by the
  493. X    author; and (e) the code and software based upon it may not 
  494. X    be used for illegal activities. 
  495. X
  496. ****************************************************************/
  497. X
  498. #include "stdio.h"
  499. #include "gr.h"
  500. #include "kb.h"
  501. #include "dr.h"
  502. #include "ui.h"
  503. X
  504. #ifdef __STDC__
  505. #include "stdlib.h"
  506. #else
  507. extern char *getenv();
  508. #endif
  509. X
  510. static struct  gr_window ui_fullscreen;
  511. char ui_tbuf[ 128 ];
  512. int  ui_screen = GR_PRIMARY;
  513. int  x_savescreen;
  514. struct gr_window    *ui_grwind;
  515. char   ui_ready = 0;
  516. char   ui_fontpath[ 128 ];
  517. struct pbm_struct ui_elicon;         /* elevator icon */
  518. struct pbm_struct ui_lefticn;        /* left icon */
  519. struct pbm_struct ui_righticn;       /* right icon */
  520. struct pbm_struct ui_upicn;          /* up icon */
  521. struct pbm_struct ui_downicn;        /* down icon */
  522. struct pbm_struct ui_clicon;         /* close window icon */
  523. struct pbm_struct ui_reicon;         /* resize window icon */
  524. struct pbm_struct ui_mvicon;         /* move window icon */
  525. struct pbm_struct ui_deficon;        /* default file icon */
  526. struct pbm_struct ui_foldicon;       /* file folder icon */
  527. struct pbm_struct ui_exicon;         /* executable file icon */
  528. X
  529. ui_init()
  530. X   {
  531. X   char *pp;                            /* temp path pointer */
  532. X
  533. X   /* See if BWPATH variable is set */
  534. X
  535. X   if ( ( pp = getenv( BWENVARNAME ) ) != NULL )
  536. X      {
  537. X      sprintf( ui_fontpath, "%s%c", pp, dr_fs );
  538. X      }
  539. X
  540. X   /* Initialize the screen and keyboard */
  541. X
  542. X   gr_init( &ui_fullscreen, ui_fontpath );
  543. X   kb_init();
  544. X
  545. X   gr_font( GR_PRIMARY, F_DEFAULT,
  546. X      ui_fullscreen.ymax / DEFAULT_FONT_SIZE );
  547. X
  548. X   ui_grwind = &ui_fullscreen;
  549. X   ui_setscreen( GR_PRIMARY );
  550. X
  551. X   ui_ready = TRUE;
  552. X
  553. X   /* initialize icons */
  554. X
  555. X   ui_seticons( BLACK, WHITE );
  556. X
  557. X   }
  558. X
  559. ui_setscreen( screen )
  560. X   int screen;
  561. X   {
  562. X   ui_screen = screen;
  563. X   }
  564. X
  565. ui_push()
  566. X   {
  567. X   x_savescreen = ui_screen;
  568. X   }
  569. X
  570. ui_pop()
  571. X   {
  572. X   ui_screen = x_savescreen;
  573. X   }
  574. X
  575. ui_seticons( foreground, background )
  576. X   int foreground, background;
  577. X   {
  578. X
  579. X   ui_pbmread( "elevator.pbm", &ui_elicon, background, foreground );
  580. X   ui_pbmread( "left.pbm", &ui_lefticn, foreground, background );
  581. X   ui_pbmread( "right.pbm", &ui_righticn, foreground, background );
  582. X   ui_pbmread( "up.pbm", &ui_upicn, foreground, background );
  583. X   ui_pbmread( "down.pbm", &ui_downicn, foreground, background );
  584. X   ui_pbmread( "close.pbm", &ui_clicon, foreground, background );
  585. X   ui_pbmread( "resize.pbm", &ui_reicon, foreground, background );
  586. X   ui_pbmread( "move.pbm", &ui_mvicon, foreground, background );
  587. X   ui_pbmread( "default.pbm", &ui_deficon, foreground, background );
  588. X   ui_pbmread( "folder.pbm", &ui_foldicon, foreground, background );
  589. X   ui_pbmread( "exec.pbm", &ui_exicon, foreground, background );
  590. X
  591. X   }
  592. SHAR_EOF
  593. chmod 0644 io/ui/ui_init.c ||
  594. echo 'restore of io/ui/ui_init.c failed'
  595. Wc_c="`wc -c < 'io/ui/ui_init.c'`"
  596. test 3779 -eq "$Wc_c" ||
  597.     echo 'io/ui/ui_init.c: original size 3779, current size' "$Wc_c"
  598. rm -f _shar_wnt_.tmp
  599. fi
  600. # ============= io/ui/ui_list.c ==============
  601. if test -f 'io/ui/ui_list.c' -a X"$1" != X"-c"; then
  602.     echo 'x - skipping io/ui/ui_list.c (File already exists)'
  603.     rm -f _shar_wnt_.tmp
  604. else
  605. > _shar_wnt_.tmp
  606. echo 'x - extracting io/ui/ui_list.c (Text)'
  607. sed 's/^X//' << 'SHAR_EOF' > 'io/ui/ui_list.c' &&
  608. /***************************************************************
  609. X
  610. X    ui_list.c       List (Menu) Routines
  611. X            for the Bywater Graphical User Interface
  612. X
  613. X            Copyright (c) 1991, Ted A. Campbell
  614. X
  615. X            Bywater Software
  616. X            P. O. Box 4023 
  617. X            Duke Station 
  618. X            Durham, NC  27706
  619. X
  620. X            email: tcamp@hercules.acpub.duke.edu
  621. X
  622. X    Copyright and Permissions Information:
  623. X
  624. X    All U.S. and international copyrights are claimed by the
  625. X    author. The author grants permission to use this code
  626. X    and software based on it under the following conditions:
  627. X    (a) in general, the code and software based upon it may be 
  628. X    used by individuals and by non-profit organizations; (b) it
  629. X    may also be utilized by governmental agencies in any country,
  630. X    with the exception of military agencies; (c) the code and/or
  631. X    software based upon it may not be sold for a profit without
  632. X    an explicit and specific permission from the author, except
  633. X    that a minimal fee may be charged for media on which it is
  634. X    copied, and for copying and handling; (d) the code must be 
  635. X    distributed in the form in which it has been released by the
  636. X    author; and (e) the code and software based upon it may not 
  637. X    be used for illegal activities. 
  638. X
  639. ***************************************************************/
  640. X
  641. #include "stdio.h"
  642. #include "bw.h"
  643. #include "gr.h"
  644. #include "kb.h"
  645. #include "dr.h"
  646. #include "ui.h"
  647. X
  648. #define   EXTENSION  1         /* number of pixels to extend
  649. X                           size of each menu item beyond
  650. X                                the height of the text */
  651. #define EL_OFFSET    1
  652. #define ACC          20
  653. #define SL_YSIZE     3
  654. #define SL_XMAX      18
  655. X
  656. /****************************************************************
  657. X
  658. X   ui_ftext()   File selection -- text based
  659. X
  660. ****************************************************************/
  661. X
  662. ui_ftext( x1, y1, x2, y2, specifier, title, m_box,
  663. X   d_titles, d_entries, max_entries,
  664. X   background, foreground, highlight )
  665. X   int x1, y1, x2, y2, background, foreground, highlight, max_entries;
  666. X   struct menu_box *m_box;
  667. X   char *specifier, *title;
  668. X   char **d_titles;
  669. X   struct dir_ent **d_entries;
  670. X   {
  671. X   register int number, c;
  672. X
  673. X   /* First check for existence of the file */
  674. X
  675. X   number = 0;
  676. X   if ( dr_first( specifier, d_entries[ number ] ) == FALSE )
  677. X      {
  678. X      return FALSE;
  679. X      }
  680. X   strcpy( d_titles[ number ], d_entries[ number ]->filename );
  681. X
  682. X   /* Find all entries */
  683. X
  684. X   number = 1;
  685. X   while( ( dr_next( d_entries[ number ] ) == TRUE ) && ( number < max_entries ))
  686. X      {
  687. X      strcpy( d_titles[ number ], d_entries[ number ]->filename );
  688. X      ++number;
  689. X      }
  690. X   m_box->number = number;
  691. X
  692. X   m_box->d_titles = d_titles;
  693. X   m_box->d_entries = d_entries;
  694. X   m_box->max_entries = max_entries;
  695. X
  696. X   /* menu */ 
  697. X
  698. X   c = ui_list( MENU_SLIDERS, x1, y1, x2, y2,
  699. X      title, number, d_titles, foreground, background, highlight,
  700. X      m_box, TRUE );
  701. X
  702. X   return c;
  703. X
  704. X   }
  705. X
  706. /****************************************************************
  707. X
  708. X   ui_list()   Scrolling list (menu)
  709. X
  710. ****************************************************************/
  711. X
  712. ui_list( type, x1, y1, x2, y2, title, number, titles,
  713. X   foreground, background, highlight, m_box )
  714. X   int type, x1, y1, x2, y2, foreground, background,
  715. X      highlight, number;
  716. X   char *title;
  717. X   char **titles;
  718. X   struct menu_box *m_box;
  719. X   {
  720. X   int carry_on;
  721. X   static int c, test;
  722. X   int mo_xsrc, mo_ysrc;
  723. X   static int x_pos, y_pos, b_stat, item;
  724. X
  725. X   /* draw the list */
  726. X
  727. X   uil_draw( type, x1, y1, x2, y2, title, number, titles,
  728. X      foreground, background, highlight, m_box );
  729. X
  730. X   /* activate the list */
  731. X
  732. X   uil_activate( m_box, type, 0 );
  733. X
  734. X   /* poll while waiting for keyboard or mouse input, carry_on == TRUE */
  735. X
  736. X   test = FALSE;
  737. X   carry_on = TRUE;
  738. X   while( carry_on == TRUE )
  739. X      {
  740. X      if ( kb_rxstat() == TRUE )
  741. X     {
  742. X     c = kb_rx();
  743. X     test = TRUE;
  744. X     }
  745. X      else if ( gr_ismouse == TRUE )
  746. X     {
  747. X     if ( gr_mouse( SAMPLE, &x_pos, &y_pos, &b_stat )
  748. X        == TRUE )
  749. X        {
  750. X        c = 0;
  751. X        test = TRUE;
  752. X        gr_mouse( WAIT, &x_pos, &y_pos, &b_stat );
  753. X        mo_xsrc = x_pos;
  754. X        mo_ysrc = y_pos;
  755. X        gr_mouse( WAIT, &x_pos, &y_pos, &b_stat );
  756. X        }
  757. X     }
  758. X
  759. X      if ( test == TRUE )
  760. X     {
  761. #ifdef  OLD_DEBUG
  762. X     bw_error( "ready to call uil_event()" );
  763. #endif
  764. X     c = uil_event( m_box, c, mo_xsrc, mo_ysrc, x_pos, y_pos, type,
  765. X        &item );
  766. X     switch( c )
  767. X        {
  768. X        case EVENT_SELECTED:
  769. X           carry_on = FALSE;
  770. X           break;
  771. X        case EVENT_EXIT:
  772. X           item = TK_EXIT;
  773. X           carry_on = FALSE;
  774. X           break;
  775. X        case EVENT_ERROR:
  776. X           bw_error( "Error return from uil_event()" );
  777. X           carry_on = FALSE;
  778. X           break;
  779. X        case EVENT_NULL:
  780. X        default:
  781. X           test = FALSE;
  782. X           break;
  783. X        }
  784. X     }
  785. X
  786. X      ui_poll();
  787. X
  788. X      }                         /* end of main list loop */
  789. X
  790. #ifdef  OLD_DEBUG
  791. X   bw_error( "Ready to deactivate list box" );
  792. #endif
  793. X
  794. X   uil_deactivate( m_box, type );
  795. X
  796. #ifdef  OLD_DEBUG
  797. X   bw_error( "List box deactivated" );
  798. #endif
  799. X
  800. X   return item;
  801. X
  802. X   }
  803. X
  804. /****************************************************************
  805. X
  806. X    uil_draw() - draw a list box
  807. X
  808. ****************************************************************/
  809. X
  810. uil_draw( type, x1, y1, x2, y2, title, number, titles,
  811. X   foreground, background, highlight, m_box )
  812. X   int type, x1, y1, x2, y2, foreground, background,
  813. X      highlight, number;
  814. X   char *title;
  815. X   char **titles;
  816. X   struct menu_box *m_box;
  817. X   {
  818. X   register int y;
  819. X
  820. #ifdef    OLD_DEBUG
  821. X   ui_debug( "entered uil_draw()" );
  822. #endif
  823. X
  824. X   /* initial assignments */
  825. X
  826. X   m_box->current = 0;
  827. X   m_box->x_pos = m_box->y_pos = m_box->y_start = 0;
  828. X   m_box->y_logical = m_box->number = number;
  829. X   m_box->x_items = m_box->x_logical = 1;
  830. X   m_box->ysize = ui_grwind->fysize + EXTENSION;
  831. X   m_box->type = type;
  832. X   m_box->d_titles = titles;
  833. X   m_box->x_start = 0;
  834. X   
  835. X   if ( m_box->is_drawn == FALSE )
  836. X      {
  837. X
  838. X      /* assign colors to structure */
  839. X
  840. X      m_box->fore = foreground;
  841. X      m_box->back = background;
  842. X      m_box->high = highlight;
  843. X
  844. X      /* draw the menu window */
  845. X
  846. X      if ( m_box->window == NULL )
  847. X         {
  848. X         switch( m_box->type )
  849. X            {
  850. X
  851. X            case MENU_SLIDERS:
  852. #ifdef OLD_DEBUG
  853. X               sprintf( bw_ebuf, "make slider window %d %d %d %d", 
  854. X                  x1, y1, x2, y2 );
  855. X               bw_debug( bw_ebuf );
  856. #endif
  857. X           m_box->window = ui_window( x1, y1,
  858. X                  x2, y2, TRUE, 
  859. X                  highlight, foreground,
  860. X                  title, TRUE, BLACK, 
  861. X                  FALSE, BLACK, background, 
  862. X          SOLID, BUT_CLOSE | BUT_MOVE | BUT_RESIZE );
  863. #ifdef OLD_DEBUG
  864. X               sprintf( bw_ebuf, "made slider window %d %d %d %d", 
  865. X                  m_box->window->x1, m_box->window->y1, m_box->window->x2, m_box->window->y2 );
  866. X               bw_debug( bw_ebuf );
  867. #endif
  868. X               break;
  869. X
  870. X            case MENU_TITLED:
  871. X               y = ( m_box->y_logical * m_box->ysize )
  872. X          + ( ui_grwind->fysize * 3 );
  873. X           m_box->window = ui_window( x1, y2 - y,
  874. X                  x2, y2, TRUE, 
  875. X                  highlight, foreground,
  876. X                  title, TRUE, BLACK, 
  877. X                  TRUE, BLACK, background, 
  878. X          SOLID, BUT_CLOSE | BUT_MOVE | BUT_RESIZE  );
  879. X               break;
  880. X
  881. X            case MENU_PLAIN:
  882. X            default:
  883. X
  884. X
  885. #ifdef    OLD_DEBUG
  886. X   sprintf( ui_tbuf, "called uil_draw(): %d %d %d %d (xmax %d) (ymax %d)",
  887. X      x1, y2 - y, 
  888. X          x2, y2, ui_grwind->xmax, ui_grwind->ymax );
  889. X   ui_debug( ui_tbuf );
  890. #endif
  891. X
  892. X               y = ( m_box->y_logical * m_box->ysize )
  893. X          + ( ui_grwind->fysize );
  894. X           m_box->window = ui_window( x1, y2 - y,
  895. X                  x2, y2, FALSE,
  896. X                  background, foreground,
  897. X                  title, FALSE, BLACK, 
  898. X                  TRUE, BLACK, background, 
  899. X          SOLID, 0 );
  900. X               break;
  901. X            }
  902. X         }
  903. X
  904. X      else
  905. X         {
  906. X     ui_rewindow( m_box->window, title );
  907. X         }
  908. X
  909. X      /* display the menu */
  910. X
  911. X      uil_display( m_box );
  912. X
  913. X      }
  914. X   }
  915. X
  916. /****************************************************************
  917. X
  918. X   uil_activate()   Activate a list box
  919. X
  920. ****************************************************************/
  921. X
  922. uil_activate( m_box, type, item )
  923. X   struct menu_box *m_box;
  924. X   int type, item;
  925. X   {
  926. X   register int x, y;
  927. X   int carry_on;
  928. X   
  929. #ifdef    DEBUG
  930. X   if ( m_box->d_titles == NULL )
  931. X      {
  932. X      bw_error( "Programmer error: menu box has not been drawn!" );
  933. X      return FALSE;
  934. X      }
  935. #endif
  936. X
  937. X   if ( item > m_box->number )
  938. X      {
  939. X      item = 0;
  940. X      }
  941. X
  942. X   if ( item == 0 )
  943. X      {
  944. X      m_box->x_start = m_box->y_start = m_box->x_pos = m_box->y_pos
  945. X         = m_box->current = 0;
  946. X      }
  947. X   else if ( item != m_box->current )
  948. X      {
  949. X
  950. X      m_box->current = item;
  951. X      
  952. X      /* calculate y_start */
  953. X
  954. X      y = 0;
  955. X      carry_on = TRUE;
  956. X      if ( m_box->y_logical <= m_box->y_items )
  957. X         {
  958. X         y = 0;
  959. X         }
  960. X      else while( ( y < m_box->y_logical ) && ( carry_on == TRUE ))
  961. X         {
  962. X         if ( (( m_box->x_logical * y ) +
  963. X            ( m_box->x_logical * m_box->y_items )) > item )
  964. X            {
  965. X            carry_on = FALSE;
  966. X            }
  967. X         else
  968. X            {
  969. X            ++y;
  970. X            }
  971. X         }
  972. X
  973. X      /* calculate x_start */
  974. X
  975. X      x = 0;
  976. X      carry_on = TRUE;
  977. X      if ( m_box->x_logical <= m_box->x_items )
  978. X         {
  979. X         x = 0;
  980. X
  981. #ifdef OLD_DEBUG
  982. X      sprintf( ui_tbuf, "x_logical <= x_items" );
  983. X      ui_wtitle( m_box->window, ui_tbuf );
  984. X      ui_wait();
  985. #endif
  986. X         }
  987. X      else while( ( x < m_box->x_logical ) && ( carry_on == TRUE ))
  988. X         {
  989. X
  990. #ifdef OLD_DEUG
  991. X      sprintf( ui_tbuf, "item <> x_logical = %d",  item % m_box->x_logical );
  992. X      ui_wtitle( m_box->window, ui_tbuf );
  993. X      ui_wait();
  994. X      
  995. X      sprintf( ui_tbuf, "trying %d", x );
  996. X      ui_wtitle( m_box->window, ui_tbuf );
  997. X      ui_wait();
  998. #endif
  999. X
  1000. X         if (( m_box->x_items + x ) > ( item % m_box->x_logical ))
  1001. X            {
  1002. X            carry_on = FALSE;
  1003. X            }
  1004. X         else
  1005. X            {
  1006. X            ++x;
  1007. X            }
  1008. X         }
  1009. X
  1010. #ifdef OLD_DEBUG
  1011. X      sprintf( ui_tbuf, "i %d; x %d; y %d", item, x, y );
  1012. X      ui_wtitle( m_box->window, ui_tbuf );
  1013. #endif
  1014. X
  1015. X      m_box->y_start = y;
  1016. X      m_box->x_start = x;
  1017. X      m_box->y_pos = ( item / m_box->x_logical ) - m_box->y_start;
  1018. X      m_box->x_pos = ( item % m_box->x_logical ) - m_box->x_start;
  1019. X
  1020. X      uil_display( m_box );
  1021. X      }
  1022. X
  1023. X   /* display the exit button */
  1024. X
  1025. X   if ( type != MENU_PLAIN )
  1026. X      {
  1027. #ifdef USE_ICONS
  1028. #else
  1029. X      ui_fbox( m_box->window->bt_x1, m_box->window->bt_y1,
  1030. X     m_box->window->bt_x2, m_box->window->bt_y2, BLACK, SOLID );
  1031. X      ui_fbox( m_box->window->bt_x1 + 1, m_box->window->bt_y1 + 1,
  1032. X     m_box->window->bt_x2 - 1, m_box->window->bt_y2 - 1, WHITE, GRID );
  1033. #endif
  1034. X      }
  1035. X
  1036. X   /* show current item selected */
  1037. X
  1038. X   uil_item( m_box, m_box->current,
  1039. X      m_box->d_titles[ m_box->current ], TRUE );
  1040. X
  1041. X   }
  1042. X
  1043. /****************************************************************
  1044. X
  1045. X   uil_deactivate()   Deactivate a list menu box
  1046. X
  1047. ****************************************************************/
  1048. X
  1049. uil_deactivate( m_box, type )
  1050. X   struct menu_box *m_box;
  1051. X   int type;
  1052. X   {
  1053. X
  1054. #ifdef  OLD_DEBUG
  1055. X   bw_error( "enter deactivate" );
  1056. #endif
  1057. X
  1058. X   uil_item( m_box, m_box->current,
  1059. X      m_box->d_titles[ m_box->current ], FALSE );
  1060. X
  1061. #ifdef  OLD_DEBUG
  1062. X   bw_error( "exit deactivate" );
  1063. #endif
  1064. X
  1065. X   }
  1066. X
  1067. /****************************************************************
  1068. X
  1069. X   uil_event()   Query if an event affects a list box
  1070. X
  1071. ****************************************************************/
  1072. X
  1073. uil_event( m_box, key, mo_xsrc, mo_ysrc, mo_xdest, mo_ydest, type, item )
  1074. X   struct menu_box *m_box;
  1075. X   int key, mo_xsrc, mo_ysrc, mo_xdest, mo_ydest, type;
  1076. X   int *item;
  1077. X   {
  1078. X   static int how_far, x_sel, y_sel;
  1079. X   register int c;
  1080. X
  1081. X   how_far = 0;
  1082. X   c = ui_event( m_box, key, mo_xsrc, mo_ysrc, mo_xdest, mo_ydest,
  1083. X      &how_far, &x_sel, &y_sel );
  1084. X
  1085. X   switch( c )
  1086. X      {
  1087. X
  1088. X      case FALSE:
  1089. X         *item = TK_EXIT;
  1090. X         return EVENT_NULL;
  1091. X
  1092. X      case CR:
  1093. X      case LF:
  1094. X     uil_exit( m_box, type );
  1095. X         *item = m_box->current;
  1096. X         return EVENT_SELECTED;
  1097. X         break;
  1098. X
  1099. X      case KB_DOWN:
  1100. X         if ( m_box->current < ( m_box->number - 1 ))
  1101. X            {
  1102. X        uil_item( m_box, m_box->current,
  1103. X               m_box->d_titles[ m_box->current ],
  1104. X               FALSE );
  1105. X            ++m_box->current;
  1106. X            ++m_box->y_pos;
  1107. X            if ( m_box->y_pos == m_box->y_items )
  1108. X               {
  1109. X               ++m_box->y_start;
  1110. X               --m_box->y_pos;
  1111. X           uil_display( m_box );
  1112. X           uil_item( m_box, m_box->current,
  1113. X                  m_box->d_titles[ m_box->current ],
  1114. X                  TRUE );
  1115. X               }
  1116. X            else
  1117. X               {
  1118. X           uil_item( m_box, m_box->current,
  1119. X                  m_box->d_titles[ m_box->current ],
  1120. X                  TRUE );
  1121. X               }
  1122. X            }
  1123. X         *item = 0;
  1124. X         return EVENT_NULL;
  1125. X         break;
  1126. X
  1127. X      case KB_UP:
  1128. X         if ( m_box->current > 0 )
  1129. X            {
  1130. X        uil_item( m_box, m_box->current,
  1131. X               m_box->d_titles[ m_box->current ],
  1132. X               FALSE );
  1133. X            --m_box->current;
  1134. X            --m_box->y_pos;
  1135. X            if ( ( m_box->y_start > 0  ) && ( m_box->y_pos < 0 ))
  1136. X               {
  1137. X               --m_box->y_start;
  1138. X               ++m_box->y_pos;
  1139. X           uil_display( m_box );
  1140. X           uil_item( m_box, m_box->current,
  1141. X                  m_box->d_titles[ m_box->current ],
  1142. X                  TRUE );
  1143. X               }
  1144. X            else
  1145. X               {
  1146. X           uil_item( m_box, m_box->current,
  1147. X                  m_box->d_titles[ m_box->current ],
  1148. X                  TRUE ); 
  1149. X               }
  1150. X            }
  1151. X         *item = 0;
  1152. X         return EVENT_NULL;
  1153. X         break;
  1154. X
  1155. X      case ESCAPE:
  1156. X      case MO_EXIT:
  1157. X     uil_exit( m_box, type );
  1158. X         *item = 0;
  1159. X         return TK_EXIT;
  1160. X         break;
  1161. X
  1162. X      case MO_UP:
  1163. X         if ( m_box->y_start > 0 )
  1164. X            {
  1165. X            while ( ( m_box->y_start - how_far ) < 0 )
  1166. X               {
  1167. X               --how_far;
  1168. X               }
  1169. X            m_box->y_start -= how_far;
  1170. X            m_box->current -= how_far;
  1171. X        uil_display( m_box );
  1172. X        uil_item( m_box, m_box->current,
  1173. X               m_box->d_titles[ m_box->current ],
  1174. X               TRUE );
  1175. X            }
  1176. X         *item = 0;
  1177. X         return EVENT_NULL;
  1178. X         break;
  1179. X
  1180. X      case MO_DN:
  1181. X         if ( ( m_box->y_start + m_box->y_items )
  1182. X            < m_box->number )
  1183. X            {
  1184. X            while ( ( m_box->y_start + how_far + m_box->y_items )
  1185. X               > m_box->number )
  1186. X               {
  1187. X               --how_far;
  1188. X               }
  1189. X            m_box->y_start += how_far;
  1190. X            m_box->current += how_far;
  1191. X        uil_display( m_box );
  1192. X        uil_item( m_box, m_box->current,
  1193. X               m_box->d_titles[ m_box->current ],
  1194. X               TRUE );
  1195. X            }
  1196. X         *item = 0;
  1197. X         return EVENT_NULL;
  1198. X         break;            
  1199. X
  1200. X      case MO_SEL:
  1201. X          if ( y_sel == m_box->y_pos )
  1202. X               {
  1203. X           uil_exit( m_box, type );
  1204. X               *item = m_box->current;
  1205. X               return EVENT_SELECTED;
  1206. X               }
  1207. X        uil_item( m_box, m_box->current,
  1208. X               m_box->d_titles[ m_box->current ], FALSE );
  1209. X            m_box->current = m_box->y_start + y_sel;
  1210. X            m_box->y_pos = y_sel;
  1211. X        uil_item( m_box, m_box->current,
  1212. X               m_box->d_titles[ m_box->current ], TRUE );
  1213. X            *item = 0;
  1214. X            return EVENT_NULL;
  1215. X            break;
  1216. X
  1217. X         default:
  1218. X            *item = 0;
  1219. X            return EVENT_NULL;
  1220. X            break;
  1221. X      }
  1222. X   }
  1223. X
  1224. /****************************************************************
  1225. X
  1226. X   uil_display()   Show all items in a list box
  1227. X
  1228. ****************************************************************/
  1229. X
  1230. uil_display( m_box )
  1231. X   struct menu_box *m_box;
  1232. X   {
  1233. X   register int c, v;
  1234. X   int x, y;
  1235. X
  1236. X   if ( m_box->is_drawn == FALSE )
  1237. X      {
  1238. X      switch( m_box->type )
  1239. X         {
  1240. X         case MENU_SLIDERS:
  1241. X            uil_sliders( m_box );
  1242. X            break;
  1243. X         case MENU_TITLED:
  1244. X         case MENU_PLAIN:
  1245. X         default:
  1246. X        uil_plain( m_box );
  1247. X            break;
  1248. X         }
  1249. X      }
  1250. X
  1251. X   /* calculate visible lines */
  1252. X
  1253. X   m_box->y_items = ( m_box->i_y2 - m_box->i_y1 )
  1254. X      / m_box->ysize;
  1255. X   m_box->xsize = ( m_box->i_x2 - m_box->i_x1 ) / m_box->x_logical;
  1256. X
  1257. X   if ( m_box->type == MENU_SLIDERS )
  1258. X      {
  1259. X
  1260. X      /* calculate increments for elevators */
  1261. X   
  1262. X      x = ui_grwind->ymax / 15;
  1263. X      y = ( x * gr_pxsize ) / gr_pysize;
  1264. X   
  1265. X      if ( m_box->y_logical <= m_box->y_items )
  1266. X         {
  1267. X         m_box->vel_inc = 1;
  1268. X         }
  1269. X      else
  1270. X         {
  1271. X         m_box->vel_inc = ((( m_box->ve_y2 - ( m_box->ve_y1 + y )) 
  1272. X            * INC_ACCURACY )
  1273. X            / ( m_box->y_logical - m_box->y_items ));
  1274. X         }
  1275. X   
  1276. X      if ( m_box->vel_inc <= 0 )      /* increment cannot be <= 0 */
  1277. X         {
  1278. X         m_box->vel_inc = 1;
  1279. X         }
  1280. X   
  1281. X      if ( m_box->x_logical <= m_box->x_items )
  1282. X         {
  1283. X         m_box->hel_inc = 1;
  1284. X         }
  1285. X      else
  1286. X         {
  1287. X         m_box->hel_inc = ((( m_box->he_x2 - ( m_box->he_x1 + x ))
  1288. X            * INC_ACCURACY )
  1289. X            / ( m_box->x_logical - m_box->x_items ));
  1290. X         }
  1291. X   
  1292. X      if ( m_box->vel_inc <= 0 )      /* increment cannot be <= 0 */
  1293. X         {
  1294. X         m_box->vel_inc = 1;
  1295. X         }
  1296. X   
  1297. X      uil_vel( m_box );              /* show vertical elevator */
  1298. X      if ( m_box->is_drawn == FALSE )
  1299. X         {
  1300. X     uil_hel( m_box );            /* show horizontal elevator */
  1301. X         }
  1302. X      }
  1303. X
  1304. X   c = 0;
  1305. X   v = m_box->y_start;
  1306. X   while ( ( c < m_box->y_items ) && ( v < m_box->number ))
  1307. X      {
  1308. X
  1309. X      uil_item( m_box, v, m_box->d_titles[ v ], FALSE );
  1310. X      ++c;
  1311. X      ++v;
  1312. X      }
  1313. X
  1314. X   m_box->is_drawn = TRUE;
  1315. X
  1316. X   }
  1317. X
  1318. /****************************************************************
  1319. X
  1320. X   uil_item()   Show a particular item in a list box
  1321. X
  1322. ****************************************************************/
  1323. X
  1324. uil_item( m_box, item, text, selected )
  1325. X   struct menu_box *m_box;
  1326. X   int item, selected;
  1327. X   char *text;
  1328. X   {
  1329. X   int x1, y1, x2, y2;
  1330. X
  1331. X   x1 = m_box->i_x1;
  1332. X   y1 = m_box->i_y2 - ( m_box->ysize *
  1333. X      ( 1 + item - m_box->y_start ));
  1334. X   x2 = m_box->i_x2;
  1335. X   y2 = m_box->i_y2 - ( m_box->ysize *
  1336. X      ( item - m_box->y_start ));
  1337. X
  1338. X   if ( selected == TRUE )
  1339. X      {
  1340. X      ui_fbox( x1, y1, x2, y2, m_box->fore, SOLID );
  1341. X      ui_str( x1, y1 + EXTENSION, x2, m_box->fore, m_box->back,
  1342. X         text );
  1343. X      }
  1344. X   else
  1345. X      {
  1346. X      ui_fbox( x1, y1, x2, y2, m_box->back, SOLID );
  1347. X      ui_str( x1, y1 + EXTENSION, x2, m_box->back, m_box->fore,
  1348. X         text );
  1349. X      }
  1350. X   }
  1351. X
  1352. /****************************************************************
  1353. X
  1354. X   uil_vel()   Show vertical elevator
  1355. X
  1356. ****************************************************************/
  1357. X
  1358. uil_vel( m_box )
  1359. X   struct menu_box *m_box;
  1360. X   {
  1361. X   int y_pos;
  1362. X
  1363. X   /* return if no area (box too small ) */
  1364. X
  1365. X   if ( m_box->ve_y2 <= m_box->ve_y1 )
  1366. X      {
  1367. #ifdef OLD_DEBUG
  1368. X      bw_debug( "No room for vertical slider" );
  1369. #endif
  1370. X      return FALSE;
  1371. X      }
  1372. X   
  1373. #ifdef OLD_DEBUG
  1374. X   bw_debug( "Drawing vertical slider" );
  1375. #endif
  1376. X
  1377. X   /* first blank the elevator area */
  1378. X
  1379. X   ui_fbox( m_box->vs_x1, m_box->ve_y1, m_box->vs_x2, m_box->ve_y2,
  1380. X      BLACK, SOLID );
  1381. X   ui_fbox( m_box->vs_x1 + 1, m_box->ve_y1 + 1,
  1382. X      m_box->vs_x2 - 1, m_box->ve_y2 - 1,
  1383. X      m_box->back, GRID );
  1384. X
  1385. X   /* calculate size and current position */
  1386. X
  1387. X   y_pos = m_box->ve_y2 - (( m_box->y_start * m_box->vel_inc ) / INC_ACCURACY );
  1388. X
  1389. X   m_box->vel_y1 = y_pos - ( m_box->ve_y1 - m_box->vs_y1 );
  1390. X   m_box->vel_x1 = m_box->vs_x1;
  1391. X   m_box->vel_x2 = m_box->vs_x2;
  1392. X   m_box->vel_y2 = y_pos;
  1393. X
  1394. #ifdef  OLD_DEBUG
  1395. X   sprintf( bw_ebuf, "vel y1 %d   y2 %d   y_pos %d",
  1396. X      m_box->vel_y1, m_box->vel_y2, y_pos );
  1397. X   bw_debug( bw_ebuf );
  1398. #endif
  1399. X
  1400. X   /* draw the elevator */
  1401. X
  1402. #ifdef USE_ICONS
  1403. X   ui_pbmcenter( ui_screen, m_box->vel_x1, m_box->vel_y1, m_box->vel_x2,
  1404. X      m_box->vel_y2, &ui_elicon );
  1405. #else
  1406. X   ui_fbox( m_box->vel_x1 + EL_OFFSET, m_box->vel_y1 + EL_OFFSET,
  1407. X      m_box->vel_x2 - EL_OFFSET, m_box->vel_y2 - EL_OFFSET,
  1408. X      BLACK, SOLID );
  1409. X   ui_fbox( m_box->vel_x1 + EL_OFFSET + 1,
  1410. X      m_box->vel_y1 + EL_OFFSET + 1,
  1411. X      m_box->vel_x2 - ( EL_OFFSET + 1 ),
  1412. X      m_box->vel_y2 - ( EL_OFFSET + 1 ),
  1413. X      m_box->back, SOLID );
  1414. X   gr_circle( ui_screen,
  1415. X      m_box->vel_x1 + (( m_box->vel_x2 - m_box->vel_x1 ) / 2 ),
  1416. X      m_box->vel_y1 + ( ( m_box->ve_y1 - m_box->vs_y1 ) / 2 ),
  1417. X      ( m_box->ve_y1 - m_box->vs_y1 ) / 4, BLACK, SOLID );
  1418. X   gr_circle( ui_screen,
  1419. X      m_box->vel_x1 + (( m_box->vel_x2 - m_box->vel_x1 ) / 2 ),
  1420. X      m_box->vel_y1 + ( ( m_box->ve_y1 - m_box->vs_y1 ) / 2 ),
  1421. X      ( m_box->ve_y1 - m_box->vs_y1 ) / 4, m_box->high, GRID );
  1422. #endif
  1423. X   }
  1424. X
  1425. /****************************************************************
  1426. X
  1427. X   uil_hel()   Show horizontal elevator
  1428. X
  1429. ****************************************************************/
  1430. X
  1431. uil_hel( m_box )
  1432. X   struct menu_box *m_box;
  1433. X   {
  1434. X   int x_pos;
  1435. X
  1436. X   /* first blank the elevator area */
  1437. X
  1438. X   ui_fbox( m_box->he_x1, m_box->hs_y1,
  1439. X      m_box->he_x2, m_box->hs_y2,
  1440. X      BLACK, SOLID );
  1441. X   ui_fbox( m_box->he_x1 + 1, m_box->hs_y1,
  1442. X      m_box->he_x2 - 1, m_box->hs_y2,
  1443. X      m_box->back, GRID );
  1444. X
  1445. X   /* calculate size and current position */
  1446. X
  1447. X   m_box->hel_x1 = x_pos = m_box->he_x1 
  1448. X      + (( m_box->hel_inc * m_box->x_start ) / INC_ACCURACY );
  1449. X   m_box->hel_x2 = m_box->hel_x1 + ( m_box->hs_x2 - m_box->he_x2 );
  1450. X   m_box->hel_y1 = m_box->hs_y1;
  1451. X   m_box->hel_y2 = m_box->hs_y2;
  1452. X
  1453. #ifdef  OLD_DEBUG
  1454. X   sprintf( ui_tbuf, "he_x1 = %d, inc * start = %d, inc = %d, start = %d, x_pos = %d, hel = %d",
  1455. X      m_box->he_x1, ( m_box->hel_inc * start ) / INC_ACCURACY,
  1456. X      m_box->hel_inc, m_box->x_start, x_pos, m_box->hel_x1 );
  1457. X   ui_wtitle( m_box->window, ui_tbuf );
  1458. X   ui_wait();
  1459. #endif
  1460. X
  1461. X   /* draw the elevator */
  1462. X
  1463. #ifdef USE_ICONS
  1464. X   ui_pbmcenter( ui_screen, m_box->hel_x1, m_box->hel_y1, m_box->hel_x2,
  1465. X      m_box->hel_y2, &ui_elicon );
  1466. #else
  1467. X   ui_fbox( m_box->hel_x1 + EL_OFFSET, m_box->hel_y1 + EL_OFFSET,
  1468. X      m_box->hel_x2 - EL_OFFSET, m_box->hel_y2 - EL_OFFSET,
  1469. X      BLACK, SOLID );
  1470. X   ui_fbox( m_box->hel_x1 + EL_OFFSET + 1,
  1471. X      m_box->hel_y1 + EL_OFFSET + 1,
  1472. X      m_box->hel_x2 - ( EL_OFFSET + 1),
  1473. X      m_box->hel_y2 - (EL_OFFSET + 1),
  1474. X      m_box->back, SOLID );
  1475. X   gr_circle( ui_screen,
  1476. X      m_box->hel_x1 + ( ( m_box->hs_x2 - m_box->he_x2 ) / 2 ),
  1477. X      m_box->hel_y1 + ( ( m_box->hel_y2 - m_box->hel_y1 ) / 2 ),
  1478. X      ( m_box->hel_y2 - m_box->hel_y1 ) / 4,
  1479. X      BLACK, SOLID );
  1480. X   gr_circle( ui_screen,
  1481. X      m_box->hel_x1 + ( ( m_box->hs_x2 - m_box->he_x2 ) / 2 ),
  1482. X      m_box->hel_y1 + ( ( m_box->hel_y2 - m_box->hel_y1 ) / 2 ),
  1483. X      ( m_box->hel_y2 - m_box->hel_y1 ) / 4,
  1484. X      m_box->high, GRID );
  1485. #endif
  1486. X
  1487. X   }
  1488. X
  1489. uil_exit( m_box, type )
  1490. X   struct menu_box *m_box;
  1491. X   int type;
  1492. X   {
  1493. X
  1494. X   /* blank the exit button */
  1495. X
  1496. X   if ( type != MENU_PLAIN )
  1497. X      {
  1498. #ifdef USE_ICONS
  1499. #else
  1500. X      ui_fbox( m_box->window->bt_x1, m_box->window->bt_y1,
  1501. X     m_box->window->bt_x2, m_box->window->bt_y2, BLACK, SOLID );
  1502. #endif
  1503. X      }
  1504. X
  1505. X   /* fill elevators with grid */
  1506. X
  1507. X   if ( type == MENU_SLIDERS )
  1508. X      {
  1509. X      if ( m_box->ve_y2 > m_box->ve_y1 )
  1510. X         {
  1511. X         ui_fbox( m_box->vs_x1, m_box->ve_y1,
  1512. X           m_box->vs_x2, m_box->ve_y2, BLACK, SOLID );   /* blank */
  1513. X         ui_fbox( m_box->vs_x1 + 1, m_box->ve_y1 + 1,
  1514. X            m_box->vs_x2 - 1, m_box->ve_y2 - 1,
  1515. X            m_box->back, GRID );
  1516. X         }
  1517. X      ui_fbox( m_box->he_x1, m_box->hs_y1,
  1518. X     m_box->he_x2, m_box->hs_y2, BLACK, SOLID );     /* blank */
  1519. X      ui_fbox( m_box->he_x1 + 1, m_box->hs_y1,
  1520. X     m_box->he_x2 - 1, m_box->hs_y2,
  1521. X     m_box->back, GRID );
  1522. X      }
  1523. X
  1524. X   }
  1525. X
  1526. /****************************************************************
  1527. X
  1528. X   ui_event()   Query if keyboard or mouse actions affect
  1529. X                 a list or icon menu box
  1530. X
  1531. ****************************************************************/
  1532. X
  1533. ui_event( m_box, key, mo_xsrc, mo_ysrc, mo_xdest, mo_ydest,
  1534. X   how_far, x_sel, y_sel )
  1535. X   struct menu_box *m_box;
  1536. X   int key, mo_xsrc, mo_ysrc, mo_xdest, mo_ydest;
  1537. X   int *how_far, *x_sel, *y_sel;
  1538. X   {
  1539. X   register int c, d;
  1540. X
  1541. X   /* if a key is available, simply return it */
  1542. X
  1543. X   if ( key != FALSE )
  1544. X      {
  1545. X      return key;
  1546. X      }
  1547. X
  1548. X   /* else presume that a mouse event has occurred */ 
  1549. X
  1550. X   /* if the destination point is not within the window check to see if
  1551. X      the source point is */
  1552. X
  1553. X   else if ( uil_bounds( mo_xdest, mo_ydest, m_box->window->x1,
  1554. X      m_box->window->y1, m_box->window->x2, m_box->window->y2 ) == FALSE )
  1555. X      {
  1556. X      if ( uil_bounds( mo_xsrc, mo_ysrc, m_box->window->x1,
  1557. X         m_box->window->y1, m_box->window->x2, m_box->window->y2 ) == TRUE )
  1558. X         {
  1559. X
  1560. X         /* test for selection bounds */
  1561. X
  1562. X         for ( c = 0; c < m_box->y_items; ++c )
  1563. X            {
  1564. X            for ( d = 0; d < m_box->x_items; ++d )
  1565. X               {
  1566. X           if ( uil_bounds( mo_xsrc, mo_ysrc,
  1567. X                  m_box->i_x1 + ( d * m_box->xsize ),
  1568. X                  m_box->i_y2 - ( ( c + 1 ) * m_box->ysize ),
  1569. X                  m_box->i_x1 + ( ( d + 1 ) * m_box->xsize ),
  1570. X                  m_box->i_y2 - ( c * m_box->ysize ) ) == TRUE )
  1571. X                  {
  1572. X                  *y_sel = c;
  1573. X                  *x_sel = d;
  1574. X                  return MO_SRC;
  1575. X                  }
  1576. X               }
  1577. X            }
  1578. X
  1579. X         /* selection bounds tests failed */
  1580. X
  1581. X         return FALSE;
  1582. X         }
  1583. X      else
  1584. X         {
  1585. X         return FALSE;
  1586. X         }
  1587. X      } 
  1588. X   
  1589. X   /* Check to see if source is within range of the vertical elevator */
  1590. X
  1591. X   else if ( uil_bounds( mo_xsrc, mo_ysrc, m_box->vel_x1, m_box->vel_y1,
  1592. X      m_box->vel_x2, m_box->vel_y2 ) == TRUE )
  1593. X      {
  1594. X      if ( ( mo_ysrc - mo_ydest ) == 0 )
  1595. X         {
  1596. X         return FALSE; 
  1597. X         }
  1598. X      else if ( ( mo_ysrc - mo_ydest ) > 0 )
  1599. X         {
  1600. X         *how_far = (( mo_ysrc - mo_ydest ) 
  1601. X            * INC_ACCURACY )
  1602. X            / m_box->vel_inc;
  1603. X         return MO_DN;
  1604. X         }
  1605. X      else
  1606. X         {
  1607. X         *how_far = (( mo_ydest - mo_ysrc ) 
  1608. X            * INC_ACCURACY )
  1609. X            / m_box->vel_inc;
  1610. X         return MO_UP;
  1611. X         }
  1612. X      }
  1613. X
  1614. X   if ( uil_bounds( mo_xsrc, mo_ysrc, m_box->hel_x1, m_box->hel_y1,
  1615. X      m_box->hel_x2, m_box->hel_y2 ) == TRUE )
  1616. X      {
  1617. X      if ( ( mo_xsrc - mo_xdest ) == 0 )
  1618. X         {
  1619. X         return FALSE;
  1620. X         }
  1621. X      else if ( ( mo_xsrc - mo_xdest ) > 0 )
  1622. X         {
  1623. X         *how_far = (( mo_xsrc - mo_xdest ) 
  1624. X            * INC_ACCURACY )
  1625. X            / m_box->hel_inc;
  1626. X         return MO_LEFT;
  1627. X         }
  1628. X      else
  1629. X         {
  1630. X         *how_far = (( mo_xdest - mo_xsrc ) 
  1631. X            * INC_ACCURACY )
  1632. X            / m_box->hel_inc;
  1633. X         return MO_RIGHT;
  1634. X         }
  1635. X      }
  1636. X
  1637. X   /* test for exit button bounds */
  1638. X
  1639. X   if ( uil_bounds( mo_xdest, mo_ydest, m_box->window->bt_x1, m_box->window->bt_y1,
  1640. X      m_box->window->bt_x2, m_box->window->bt_y2 ) == TRUE )
  1641. X      {
  1642. X      return MO_EXIT;
  1643. X      }
  1644. X
  1645. X   /* test for up arrow bounds */
  1646. X
  1647. X   if ( uil_bounds( mo_xdest, mo_ydest, m_box->vs_x1, m_box->ve_y2,
  1648. X      m_box->vs_x2, m_box->vs_y2 ) == TRUE )
  1649. X      {
  1650. X      *how_far = 1;
  1651. X      return MO_UP;
  1652. X      }
  1653. X
  1654. X   /* test for down arrow bounds */
  1655. X
  1656. X   if ( uil_bounds( mo_xdest, mo_ydest, m_box->vs_x1, m_box->vs_y1,
  1657. X      m_box->vs_x2, m_box->ve_y1 ) == TRUE )
  1658. X      {
  1659. X      *how_far = 1;
  1660. X      return MO_DN;
  1661. X      }
  1662. X
  1663. X   /* test for left arrow bounds */
  1664. X
  1665. X   if ( uil_bounds( mo_xdest, mo_ydest, m_box->hs_x1, m_box->hs_y1,
  1666. X      m_box->he_x1, m_box->hs_y2 ) == TRUE )
  1667. X      {
  1668. X      *how_far = 1;
  1669. X      return MO_LEFT;
  1670. X      }
  1671. X
  1672. X   /* test for right arrow bounds */
  1673. X
  1674. X   if ( uil_bounds( mo_xdest, mo_ydest, m_box->he_x2, m_box->hs_y1,
  1675. X      m_box->hs_x2, m_box->hs_y2 ) == TRUE )
  1676. X      {
  1677. X      *how_far = 1;
  1678. X      return MO_RIGHT;
  1679. X      }
  1680. X
  1681. X   /* test for selection bounds */
  1682. X
  1683. X   for ( c = 0; c < m_box->y_items; ++c )
  1684. X      {
  1685. X      for ( d = 0; d < m_box->x_items; ++d )
  1686. X         {
  1687. X     if ( uil_bounds( mo_xdest, mo_ydest,
  1688. X            m_box->i_x1 + ( d * m_box->xsize ),
  1689. X            m_box->i_y2 - ( ( c + 1 ) * m_box->ysize ),
  1690. X            m_box->i_x1 + ( ( d + 1 ) * m_box->xsize ),
  1691. X            m_box->i_y2 - ( c * m_box->ysize ) ) == TRUE )
  1692. X            {
  1693. X            *y_sel = c;
  1694. X            *x_sel = d;
  1695. X            return MO_SEL;
  1696. X            }
  1697. X         }
  1698. X      }
  1699. X   }
  1700. X
  1701. /****************************************************************
  1702. X
  1703. X   uil_bounds()  See if x and y are within bounds of x1, y1, x2, y2
  1704. X
  1705. ****************************************************************/
  1706. X
  1707. uil_bounds( x, y, x1, y1, x2, y2 )
  1708. X   int x, y, x1, y1, x2, y2;
  1709. X   {
  1710. X    if ( x < x1 )
  1711. X      {
  1712. X      return FALSE;
  1713. X      }
  1714. X    if ( x > x2 )
  1715. X      {
  1716. X      return FALSE;
  1717. X      }
  1718. X    if ( y < y1 )
  1719. X      {
  1720. X      return FALSE;
  1721. X      }
  1722. X    if ( y > y2 )
  1723. X      {
  1724. X      return FALSE;
  1725. X      }
  1726. X   return TRUE;
  1727. X   }
  1728. X
  1729. /****************************************************************
  1730. X
  1731. X   uil_sliders()      Calculate and draw sliders
  1732. X                      for menu/icon box
  1733. X
  1734. ****************************************************************/
  1735. X
  1736. uil_sliders( m_box )
  1737. X   struct menu_box *m_box;
  1738. X   {
  1739. X   int midv, midh, toph, both, leftv, rightv;
  1740. X   int halfh, halfv, x, y;
  1741. X
  1742. X   /* assign sizes to icon area and sliders */
  1743. X
  1744. X   x = ui_grwind->fxsize * SL_YSIZE;
  1745. X   if ( x > SL_XMAX )
  1746. X      {
  1747. X      x = SL_XMAX;
  1748. X      }
  1749. X   y = (( x * gr_pxsize ) * ACC ) / ( gr_pysize * ACC );
  1750. X
  1751. #ifdef OLD_DEBUG
  1752. X   sprintf( bw_ebuf, "SL_XMAX = %d; x = %d, y = %d", SL_XMAX, x, y );
  1753. X   bw_debug( bw_ebuf );
  1754. #endif
  1755. X
  1756. X   m_box->i_x1  = m_box->window->u_x1 + 2;
  1757. X   m_box->i_y1  = m_box->window->u_y1 + y;
  1758. X   m_box->i_x2  = m_box->window->u_x2 - ( x + 3 );
  1759. X   m_box->i_y2  = m_box->window->u_y2 - 1;
  1760. X   m_box->vs_x1 = m_box->window->u_x2 - ( x + 1 );
  1761. X   m_box->vs_y1 = m_box->i_y1;
  1762. X   m_box->vs_x2 = m_box->window->u_x2;
  1763. X   m_box->vs_y2 = m_box->window->u_y2 - 1;
  1764. X   m_box->hs_x1 = m_box->window->u_x1 + 1;
  1765. X   m_box->hs_y1 = m_box->window->u_y1;
  1766. X   m_box->hs_x2 = m_box->i_x2;
  1767. X   m_box->hs_y2 = m_box->i_y1 - 1;
  1768. X   m_box->ve_y1 = m_box->vs_y1 + y;
  1769. X   m_box->ve_y2 = m_box->vs_y2 - y;
  1770. X   m_box->he_x1 = m_box->window->u_x1 + x;
  1771. X   m_box->he_x2 = m_box->hs_x2 - x;
  1772. X
  1773. #ifdef OLD_DEBUG
  1774. X               sprintf( bw_ebuf, "made horizontal slider %d %d %d %d", 
  1775. X                  m_box->hs_x1, m_box->hs_y1, m_box->hs_x2, m_box->hs_y2 );
  1776. X               bw_debug( bw_ebuf );
  1777. #endif
  1778. X
  1779. X   /* outline the areas */
  1780. X
  1781. X   gr_line( ui_screen, m_box->window->u_x1, m_box->hs_y2,
  1782. X      m_box->vs_x2, m_box->hs_y2, m_box->fore, SOLID );
  1783. X   --m_box->hs_y2;
  1784. X   gr_line( ui_screen, m_box->vs_x1, m_box->hs_y1,
  1785. X      m_box->vs_x1, m_box->window->u_y2, m_box->fore, SOLID );
  1786. X   ++m_box->vs_x1;
  1787. X
  1788. X   /* demarcate arrow areas */
  1789. X
  1790. X   gr_line( ui_screen, m_box->he_x1, m_box->hs_y1,
  1791. X      m_box->he_x1, m_box->hs_y2, m_box->fore, SOLID );
  1792. X   gr_line( ui_screen, m_box->he_x2, m_box->hs_y1,
  1793. X      m_box->he_x2, m_box->hs_y2, m_box->fore, SOLID );
  1794. X   gr_line( ui_screen, m_box->vs_x1, m_box->ve_y1,
  1795. X      m_box->vs_x2, m_box->ve_y1, m_box->fore, SOLID );
  1796. X   gr_line( ui_screen, m_box->vs_x1, m_box->ve_y2,
  1797. X      m_box->vs_x2, m_box->ve_y2, m_box->fore, SOLID );
  1798. X
  1799. X   /* calculate some midpoints */
  1800. X
  1801. X   midh   = m_box->hs_y1 + (( m_box->hs_y2 - m_box->hs_y1 ) / 2 );
  1802. X   toph   = m_box->hs_y2 - (( m_box->hs_y2 - m_box->hs_y1 ) / 3 );
  1803. X   both   = m_box->hs_y1 + (( m_box->hs_y2 - m_box->hs_y1 ) / 3 );
  1804. X   midv   = m_box->vs_x1 + (( m_box->vs_x2 - m_box->vs_x1 ) / 2 );
  1805. X   leftv  = m_box->vs_x1 + (( m_box->vs_x2 - m_box->vs_x1 ) / 3 );
  1806. X   rightv = m_box->vs_x2 - (( m_box->vs_x2 - m_box->vs_x1 ) / 3 );
  1807. X
  1808. X   /* left arrow */
  1809. X
  1810. X   ui_fbox( m_box->hs_x1, m_box->hs_y1, m_box->he_x1, m_box->hs_y2,
  1811. X      m_box->high, SOLID );
  1812. #ifdef USE_ICONS
  1813. X   ui_pbmcenter( ui_screen, m_box->hs_x1, m_box->hs_y1, m_box->he_x1, m_box->hs_y2,
  1814. X      &ui_lefticn );
  1815. #else
  1816. X   halfh  = m_box->hs_x1 + (( m_box->he_x1 - m_box->hs_x1 ) / 2 );
  1817. X   uil_arrow(  m_box,
  1818. X      m_box->hs_x1, midh,
  1819. X      halfh, m_box->hs_y1 + 1,
  1820. X      halfh, both,
  1821. X      m_box->he_x1, both,
  1822. X      m_box->he_x1, toph,
  1823. X      halfh, toph,
  1824. X      halfh, m_box->hs_y2 - 1,
  1825. X      m_box->hs_x1, midh );
  1826. X   gr_line( ui_screen, halfh + 1, m_box->hs_y1 + 1,
  1827. X      halfh + 1, both, m_box->fore, SOLID );  /* shadow */
  1828. X   gr_line( ui_screen, halfh + 1, toph,
  1829. X      halfh + 1, m_box->hs_y2 - 1, m_box->fore, SOLID );
  1830. X   gr_line( ui_screen, halfh, both - 1,
  1831. X      m_box->he_x1, both - 1, m_box->fore, SOLID );
  1832. #endif
  1833. X
  1834. X   /* right arrow */
  1835. X
  1836. X   ui_fbox( m_box->he_x2, m_box->hs_y1, m_box->hs_x2, m_box->hs_y2,
  1837. X      m_box->high, SOLID );
  1838. #ifdef USE_ICONS
  1839. X   ui_pbmcenter( ui_screen, m_box->he_x2, m_box->hs_y1, m_box->hs_x2, m_box->hs_y2,
  1840. X      &ui_righticn );
  1841. #else
  1842. X   halfh  = m_box->he_x2 + (( m_box->hs_x2 - m_box->he_x2 ) / 2 );
  1843. X   uil_arrow(  m_box,
  1844. X      m_box->hs_x2, midh,
  1845. X      halfh, m_box->hs_y1 + 1,
  1846. X      halfh, both,
  1847. X      m_box->he_x2, both,
  1848. X      m_box->he_x2, toph,
  1849. X      halfh, toph,
  1850. X      halfh, m_box->hs_y2 - 1,
  1851. X      m_box->hs_x2, midh );
  1852. X   gr_line( ui_screen, halfh, both - 1,
  1853. X      m_box->he_x2, both - 1, m_box->fore, SOLID );
  1854. X   gr_line( ui_screen, halfh + 1, m_box->hs_y1 + 1,
  1855. X      m_box->hs_x2, midh - 1, m_box->fore, SOLID );  /* shadow */
  1856. #endif
  1857. X
  1858. X   /* up arrow */
  1859. X
  1860. X   ui_fbox( m_box->vs_x1, m_box->ve_y2, m_box->vs_x2, m_box->vs_y2,
  1861. X      m_box->high, SOLID );
  1862. #ifdef USE_ICONS
  1863. X   ui_pbmcenter( ui_screen, m_box->vs_x1, m_box->ve_y2, m_box->vs_x2, m_box->vs_y2,
  1864. X      &ui_upicn );
  1865. #else
  1866. X   halfv  = m_box->ve_y2 + (( m_box->vs_y2 - m_box->ve_y2 ) / 2 );
  1867. X   uil_arrow(  m_box,
  1868. X      midv, m_box->vs_y2,             /* point 1 */
  1869. X      m_box->vs_x1 + 1, halfv,            /* point 2 */
  1870. X      leftv, halfv,                   /* point 3 */
  1871. X      leftv, m_box->ve_y2,            /* point 4 */
  1872. X      rightv, m_box->ve_y2,           /* point 5 */
  1873. X      rightv, halfv,                  /* point 6 */
  1874. X      m_box->vs_x2 - 1, halfv,            /* point 7 */
  1875. X      midv, m_box->vs_y2 );           /* point 8 */
  1876. X   gr_line( ui_screen, m_box->vs_x1 + 1, halfv - 1,
  1877. X      leftv, halfv - 1, m_box->fore, SOLID );
  1878. X   gr_line( ui_screen, rightv, halfv - 1,
  1879. X      m_box->vs_x2 - 1, halfv - 1, m_box->fore, SOLID );
  1880. X   gr_line( ui_screen, rightv + 1, m_box->ve_y2,
  1881. X      rightv + 1, halfv, m_box->fore, SOLID );  /* shadow */
  1882. #endif
  1883. X
  1884. X   /* down arrow */
  1885. X
  1886. X   ui_fbox( m_box->vs_x1, m_box->vs_y1, m_box->vs_x2, m_box->ve_y1,
  1887. X      m_box->high, SOLID );
  1888. #ifdef USE_ICONS
  1889. X   ui_pbmcenter( ui_screen, m_box->vs_x1, m_box->vs_y1, m_box->vs_x2, m_box->ve_y1,
  1890. X      &ui_downicn );
  1891. #else
  1892. X   halfv  = m_box->vs_y1 + (( m_box->ve_y1 - m_box->vs_y1 ) / 2 );
  1893. X   uil_arrow(  m_box,
  1894. X      midv, m_box->vs_y1,             /* point 1 */
  1895. X      m_box->vs_x1 + 1, halfv,            /* point 2 */
  1896. X      leftv, halfv,                   /* point 3 */
  1897. X      leftv, m_box->ve_y1,            /* point 4 */
  1898. X      rightv, m_box->ve_y1,           /* point 5 */
  1899. X      rightv, halfv,                  /* point 6 */
  1900. X      m_box->vs_x2 - 1, halfv,            /* point 7 */
  1901. X      midv, m_box->vs_y1 );           /* point 8 */
  1902. X   gr_line( ui_screen, rightv + 1, halfv,
  1903. X      rightv + 1, m_box->ve_y1, m_box->fore, SOLID );
  1904. X   gr_line( ui_screen, midv + 1, m_box->vs_y1,
  1905. X      m_box->vs_x2 - 1, halfv - 1, m_box->fore, SOLID );  /* shadow */
  1906. #endif
  1907. X
  1908. X   /* blank elevator areas with grid */
  1909. X
  1910. #ifdef OLD_DEBUG
  1911. X               sprintf( bw_ebuf, "draw horizontal slider %d %d %d %d", 
  1912. X                  m_box->hs_x1, m_box->hs_y1, m_box->hs_x2, m_box->hs_y2 );
  1913. X               bw_debug( bw_ebuf );
  1914. #endif
  1915. X
  1916. X   if ( m_box->hs_y2 > m_box->hs_y1 )
  1917. X      {
  1918. /*           gr_rectangle( ui_screen, m_box->he_x1, m_box->hs_y1,
  1919. X         m_box->he_x2, m_box->hs_y2, m_box->fore, HOLLOW ); */
  1920. X      gr_rectangle( ui_screen, m_box->he_x1 + 1, m_box->hs_y1,
  1921. X         m_box->he_x2 - 1, m_box->hs_y2, m_box->fore, GRID );
  1922. #ifdef OLD_DEBUG
  1923. X               sprintf( bw_ebuf, "made horizontal slider %d %d %d %d", 
  1924. X                  m_box->hs_x1, m_box->hs_y1, m_box->hs_x2, m_box->hs_y2 );
  1925. X               bw_debug( bw_ebuf );
  1926. #endif
  1927. X      }
  1928. X      
  1929. X   if ( m_box->ve_y2 > m_box->ve_y1 )
  1930. X      {
  1931. X      gr_rectangle( ui_screen, m_box->vs_x1, m_box->ve_y1,
  1932. X         m_box->vs_x2, m_box->ve_y2, m_box->fore, HOLLOW );
  1933. X      gr_rectangle( ui_screen, m_box->vs_x1 + 1, m_box->ve_y1 + 1,
  1934. X         m_box->vs_x2 - 1, m_box->ve_y2 - 1, m_box->fore, GRID );
  1935. X      }
  1936. X   }
  1937. X
  1938. X
  1939. /****************************************************************
  1940. X
  1941. X   uil_arrow()  Draw an arrow for the slider box
  1942. X
  1943. ****************************************************************/
  1944. X
  1945. uil_arrow( m_box,
  1946. X   x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8 )
  1947. X   struct menu_box *m_box;
  1948. X   int x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8;
  1949. X   {
  1950. X   gr_line( ui_screen, x1, y1, x2, y2, m_box->fore, SOLID );
  1951. X   gr_line( ui_screen, x2, y2, x3, y3, m_box->fore, SOLID );
  1952. X   gr_line( ui_screen, x3, y3, x4, y4, m_box->fore, SOLID );
  1953. X   gr_line( ui_screen, x4, y4, x5, y5, m_box->fore, SOLID );
  1954. X   gr_line( ui_screen, x5, y5, x6, y6, m_box->fore, SOLID );
  1955. X   gr_line( ui_screen, x6, y6, x7, y7, m_box->fore, SOLID );
  1956. X   gr_line( ui_screen, x7, y7, x8, y8, m_box->fore, SOLID );
  1957. X   }
  1958. X
  1959. /****************************************************************
  1960. X
  1961. X   uil_plain()      Calculate sizes
  1962. X          for plain menu box
  1963. X
  1964. ****************************************************************/
  1965. X
  1966. uil_plain( m_box )
  1967. X   struct menu_box *m_box;
  1968. X   {
  1969. X
  1970. X   /* assign sizes to icon area */
  1971. X
  1972. X   m_box->i_x1  = m_box->window->u_x1 + 2;
  1973. X   m_box->i_y1  = m_box->window->u_y1;
  1974. X   m_box->i_x2  = m_box->window->u_x2 - 2;
  1975. X   m_box->i_y2  = m_box->window->u_y2 - 1;
  1976. X   m_box->vs_x1 = 1;
  1977. X   m_box->vs_y1 = 1;
  1978. X   m_box->vs_x2 = 1;
  1979. X   m_box->vs_y2 = 1;
  1980. X   m_box->hs_x1 = 1;
  1981. X   m_box->hs_y1 = 1;
  1982. X   m_box->hs_x2 = 1;
  1983. X   m_box->hs_y2 = 1;
  1984. X   m_box->ve_y1 = 1;
  1985. X   m_box->ve_y2 = 1;
  1986. X   m_box->he_x1 = 1;
  1987. X   m_box->he_x2 = 1;
  1988. X   }
  1989. X
  1990. X
  1991. SHAR_EOF
  1992. chmod 0644 io/ui/ui_list.c ||
  1993. echo 'restore of io/ui/ui_list.c failed'
  1994. Wc_c="`wc -c < 'io/ui/ui_list.c'`"
  1995. test 37627 -eq "$Wc_c" ||
  1996.     echo 'io/ui/ui_list.c: original size 37627, current size' "$Wc_c"
  1997. rm -f _shar_wnt_.tmp
  1998. fi
  1999. # ============= io/ui/ui_pbm.c ==============
  2000. if test -f 'io/ui/ui_pbm.c' -a X"$1" != X"-c"; then
  2001.     echo 'x - skipping io/ui/ui_pbm.c (File already exists)'
  2002.     rm -f _shar_wnt_.tmp
  2003. else
  2004. > _shar_wnt_.tmp
  2005. echo 'x - extracting io/ui/ui_pbm.c (Text)'
  2006. sed 's/^X//' << 'SHAR_EOF' > 'io/ui/ui_pbm.c' &&
  2007. /***************************************************************
  2008. X
  2009. X    ui_pbm.c        Portable Bit-Map Routines
  2010. X            for the Bywater Graphical User Interface
  2011. X
  2012. X            Copyright (c) 1991, Ted A. Campbell
  2013. X
  2014. X            Bywater Software
  2015. X            P. O. Box 4023 
  2016. X            Duke Station 
  2017. X            Durham, NC  27706
  2018. X
  2019. X            email: tcamp@hercules.acpub.duke.edu
  2020. X
  2021. X    Copyright and Permissions Information:
  2022. X
  2023. X    All U.S. and international copyrights are claimed by the
  2024. X    author. The author grants permission to use this code
  2025. SHAR_EOF
  2026. true || echo 'restore of io/ui/ui_pbm.c failed'
  2027. fi
  2028. echo 'End of  part 9'
  2029. echo 'File io/ui/ui_pbm.c is continued in part 10'
  2030. echo 10 > _shar_seq_.tmp
  2031. exit 0
  2032. exit 0 # Just in case...
  2033. -- 
  2034. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  2035. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  2036. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  2037. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  2038.