home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / vmsnet / vmstrek / part46 < prev    next >
Encoding:
Text File  |  1992-11-20  |  14.4 KB  |  551 lines

  1. Newsgroups: vmsnet.sources.games
  2. Path: uunet!zaphod.mps.ohio-state.edu!rpi!usenet.coe.montana.edu!news.u.washington.edu!raven.alaska.edu!acad2.alaska.edu!asdmf
  3. From: asdmf@acad2.alaska.edu
  4. Subject: Vmsnetrek 46/47
  5. Message-ID: <1992Nov20.211109.1@acad2.alaska.edu>
  6. Lines: 538
  7. Sender: news@raven.alaska.edu (USENET News System)
  8. Nntp-Posting-Host: acad2.alaska.edu
  9. Organization: University of Alaska
  10. Date: Sat, 21 Nov 1992 01:11:09 GMT
  11. Xref: uunet vmsnet.sources.games:546
  12.  
  13. -+-+-+-+-+-+-+-+ START OF PART 46 -+-+-+-+-+-+-+-+
  14. X`009`009break;
  15. X`009    case GREY:
  16. X`009`009foo.pixel=pixel`124planes`0910`093`124planes`0911`093;
  17. X`009`009break;
  18. X`009    case GREEN:
  19. X`009`009foo.pixel=pixel`124planes`0911`093`124planes`0912`093;
  20. X`009`009break;
  21. X`009    `125
  22. X`009    XStoreColor(W_Display, W_Colormap, &foo);
  23. X`009    colortable`091i`093.pixelValue = foo.pixel;
  24. X`009    colortable`091i`093.pixmap = XCreatePixmapFromBitmapData(W_Display,
  25. X`009`009W_Root, solid, TILESIDE, TILESIDE, foo.pixel, foo.pixel,
  26. X`009`009DefaultDepth(W_Display, W_Screen));
  27. X`009`125
  28. X    `125
  29. X    for (i=0; i<NCOLORS; i++) `123
  30. X`009for (j=0; j<FONTS+1; j++) `123
  31. X`009    XSetForeground(W_Display, colortable`091i`093.contexts`091j`093,`032
  32. X`009`009colortable`091i`093.pixelValue);
  33. X`009    XSetBackground(W_Display, colortable`091i`093.contexts`091j`093,
  34. X`009`009colortable`091W_Black`093.pixelValue);
  35. X`009`125
  36. X    `125
  37. X`125
  38. X
  39. XW_Window W_MakeWindow(name,x,y,width,height,parent,border,color)
  40. Xchar *name;
  41. Xint x,y,width,height;
  42. XW_Window parent;
  43. Xint border;
  44. XW_Color color;
  45. X`123
  46. X    struct window *newwin;
  47. X    Window wparent;
  48. X    XSetWindowAttributes attrs;
  49. X`009
  50. X#ifdef DEBUG
  51. X    printf("New window...\n");
  52. X#endif
  53. X    checkGeometry(name, &x, &y, &width, &height);
  54. X    checkParent(name, &parent);
  55. X    wparent=W_Void2Window(parent)->window;
  56. X    attrs.override_redirect=False;
  57. X    attrs.border_pixel=colortable`091color`093.pixelValue;
  58. X    attrs.event_mask=KeyPressMask`124ButtonPressMask`124ExposureMask;
  59. X    attrs.background_pixel=colortable`091W_Black`093.pixelValue;
  60. X    attrs.do_not_propagate_mask=KeyPressMask`124ButtonPressMask`124ExposureM
  61. Vask;
  62. X    newwin=newWindow(
  63. X`009XCreateWindow(W_Display, wparent, x, y, width, height, border,
  64. X`009    CopyFromParent, InputOutput, CopyFromParent,`032
  65. X`009    CWBackPixel`124CWEventMask`124CWOverrideRedirect`124CWBorderPixel,`0
  66. V32
  67. X`009    &attrs),
  68. X`009WIN_GRAPH);
  69. X    XSetClassHint(W_Display, newwin->window, &class_hint);
  70. X    XSetWMHints(W_Display, newwin->window, &wm_hint);
  71. X    newwin->name=strdup(name);
  72. X    newwin->width=width;
  73. X    newwin->height=height;
  74. X    if (checkMapped(name)) W_MapWindow(W_Window2Void(newwin));
  75. X
  76. X#ifdef DEBUG
  77. X    printf("New graphics window %d, child of %d\n", newwin, parent);
  78. X#endif
  79. X
  80. X    return(W_Window2Void(newwin));
  81. X`125
  82. X
  83. Xvoid W_ChangeBorder(window, color)
  84. XW_Window window;
  85. Xint color;
  86. X`123
  87. X#ifdef DEBUG
  88. X    printf("Changing border of %d\n", window);
  89. X#endif
  90. X`009
  91. X    XSetWindowBorderPixmap(W_Display, W_Void2Window(window)->window,
  92. X`009colortable`091color`093.pixmap);
  93. X`125
  94. X
  95. Xvoid W_WarpPointer(window)
  96. XW_Window window;
  97. X`123
  98. X  XWarpPointer(W_Display, None, W_Void2Window(window)->window, 0, 0, 0, 0,
  99. X`009       10,10);
  100. X`125
  101. X
  102. Xvoid W_MapWindow(window)
  103. XW_Window window;
  104. X`123
  105. X    struct window *win;
  106. X
  107. X#ifdef DEBUG
  108. X    printf("Mapping %d\n", window);
  109. X#endif
  110. X    win=W_Void2Window(window);
  111. X    if (win->mapped) return;
  112. X    win->mapped=1;
  113. X    XMapRaised(W_Display, win->window);
  114. X`125
  115. X
  116. Xvoid W_UnmapWindow(window)
  117. XW_Window window;
  118. X`123
  119. X    struct window *win;
  120. X
  121. X#ifdef DEBUG
  122. X    printf("UnMapping %d\n", window);
  123. X#endif
  124. X    win=W_Void2Window(window);
  125. X    if (win->mapped==0) return;
  126. X    win->mapped=0;
  127. X    XUnmapWindow(W_Display, win->window);
  128. X`125
  129. X
  130. Xint W_IsMapped(window)
  131. XW_Window window;
  132. X`123
  133. X    struct window *win;
  134. X
  135. X    win=W_Void2Window(window);
  136. X    if (win==NULL) return(0);
  137. X    return(win->mapped);
  138. X`125
  139. X
  140. Xvoid W_ClearArea(window, x, y, width, height, color)
  141. XW_Window window;
  142. Xint x, y, width, height;
  143. XW_Color color;
  144. X`123
  145. X    struct window *win;
  146. X
  147. X#ifdef DEBUG
  148. X    printf("Clearing (%d %d) x (%d %d) with %d on %d\n", x,y,width,height,
  149. X`009color,window);
  150. X#endif
  151. X    win=W_Void2Window(window);
  152. X    switch(win->type) `123
  153. X    case WIN_GRAPH:
  154. X`009XFillRectangle(W_Display, win->window, colortable`091color`093.contexts`
  155. V0910`093,
  156. X`009    x, y, width, height);
  157. X`009break;
  158. X    default:
  159. X`009XFillRectangle(W_Display, win->window, colortable`091color`093.contexts`
  160. V0910`093,
  161. X`009    WIN_EDGE+x*W_Textwidth, MENU_PAD+y*W_Textheight,`032
  162. X`009    width*W_Textwidth, height*W_Textheight);
  163. X`009break;
  164. X    `125
  165. X`125
  166. X
  167. Xvoid W_ClearWindow(window)
  168. XW_Window window;
  169. X`123
  170. X#ifdef DEBUG
  171. X    printf("Clearing %d\n", window);
  172. X#endif
  173. X    XClearWindow(W_Display, W_Void2Window(window)->window);
  174. X`125
  175. X
  176. Xint W_EventsPending()
  177. X`123
  178. X    if (W_isEvent) return(1);
  179. X    while (XPending(W_Display)) `123
  180. X`009if (W_SpNextEvent(&W_myevent)) `123
  181. X`009    W_isEvent=1;
  182. X`009    return(1);
  183. X`009`125
  184. X    `125
  185. X    return(0);
  186. X`125
  187. X
  188. Xvoid W_NextEvent(wevent)
  189. XW_Event *wevent;
  190. X`123
  191. X    if (W_isEvent) `123
  192. X`009*wevent=W_myevent;
  193. X`009W_isEvent=0;
  194. X`009return;
  195. X    `125
  196. X    while (W_SpNextEvent(wevent)==0);
  197. X`125
  198. X
  199. Xint W_SpNextEvent(wevent)
  200. XW_Event *wevent;
  201. X`123
  202. X    XEvent event;
  203. X    XKeyEvent *key;
  204. X    XButtonEvent *button;
  205. X    XExposeEvent *expose;
  206. X    XResizeRequestEvent *resize;
  207. X    char ch;
  208. X    int nchars;
  209. X    struct window *win;
  210. X
  211. X#ifdef DEBUG
  212. X    printf("Getting an event...\n");
  213. X#endif
  214. X    key=(XKeyEvent *) &event;
  215. X    button=(XButtonEvent *) &event;
  216. X    expose=(XExposeEvent *) &event;
  217. X    resize=(XResizeRequestEvent *) &event;
  218. X    for (;;) `123
  219. X`009XNextEvent(W_Display, &event);
  220. X`009win=findWindow(key->window);
  221. X        if (win==NULL) return(0);
  222. X`009if ((event.type==KeyPress `124`124 event.type==ButtonPress) &&
  223. X`009    win->type == WIN_MENU) `123
  224. X`009    if (key->y % (W_Textheight + MENU_PAD*2+MENU_BAR) >=`032
  225. X`009`009W_Textheight+MENU_PAD*2) return(0);
  226. X`009    key->y=key->y/(W_Textheight+MENU_PAD*2+MENU_BAR);
  227. X`009`125
  228. X`009switch((int) event.type) `123
  229. X`009case KeyPress:
  230. X`009    if (XLookupString(key,&ch,1,NULL,NULL)>0) `123
  231. X`009`009wevent->type=W_EV_KEY;
  232. X`009`009wevent->Window=W_Window2Void(win);
  233. X`009`009wevent->x=key->x;
  234. X`009`009wevent->y=key->y;
  235. X`009`009wevent->key=ch;
  236. X`009`009return(1);
  237. X`009    `125
  238. X`009    return(0);
  239. X`009    break;
  240. X`009case ButtonPress:
  241. X`009    wevent->type=W_EV_BUTTON;
  242. X`009    wevent->Window=W_Window2Void(win);
  243. X`009    wevent->x=button->x;
  244. X`009    wevent->y=button->y;
  245. X`009    switch(button->button & 0xf) `123
  246. X`009    case Button3:
  247. X`009`009wevent->key=W_RBUTTON;
  248. X`009`009break;
  249. X`009    case Button1:
  250. X`009`009wevent->key=W_LBUTTON;
  251. X`009`009break;
  252. X`009    case Button2:
  253. X`009`009wevent->key=W_MBUTTON;
  254. X`009`009break;
  255. X`009    `125
  256. X`009    return(1);
  257. X`009case Expose:
  258. X`009    if (expose->count != 0) return(0);
  259. X`009    if (win->type == WIN_SCROLL) `123
  260. X`009`009redrawScrolling(win);
  261. X`009`009return(0);
  262. X`009    `125
  263. X`009    if (win->type == WIN_MENU) `123
  264. X`009`009redrawMenu(win);
  265. X`009`009return(0);
  266. X`009    `125
  267. X`009    wevent->type=W_EV_EXPOSE;
  268. X`009    wevent->Window=W_Window2Void(win);
  269. X`009    return(1);
  270. X`009case ResizeRequest:
  271. X`009    resizeScrolling(win, resize->width, resize->height);
  272. X`009    break;
  273. X`009default:
  274. X`009    return(0);
  275. X`009    break;
  276. X`009`125
  277. X    `125
  278. X`125
  279. X
  280. Xvoid W_MakeLine(window, x0, y0, x1, y1, color)
  281. XW_Window window;
  282. Xint x0, y0, x1, y1;
  283. XW_Color color;
  284. X`123
  285. X    Window win;
  286. X
  287. X#ifdef DEBUG
  288. X    printf("Line on %d\n", window);
  289. X#endif
  290. X    win=W_Void2Window(window)->window;
  291. X    XDrawLine(W_Display, win, colortable`091color`093.contexts`0910`093, x0,
  292. V y0, x1, y1);
  293. X`125
  294. X
  295. Xvoid W_WriteText(window, x, y, color, str, len, font)
  296. XW_Window window;
  297. Xint x, y,len;
  298. XW_Color color;
  299. XW_Font font;
  300. Xchar *str;
  301. X`123
  302. X    struct window *win;
  303. X    int addr;
  304. X
  305. X#ifdef DEBUG
  306. X    printf("Text for %d @ (%d, %d) in %d: `091%s`093\n", window, x,y,color,s
  307. Vtr);
  308. X#endif
  309. X    win=W_Void2Window(window);
  310. X    switch(win->type) `123
  311. X    case WIN_GRAPH:
  312. X`009addr=fonts`091fontNum(font)`093.baseline;
  313. X`009XDrawImageString(W_Display, win->window,`032
  314. X`009    colortable`091color`093.contexts`091fontNum(font)`093,x,y+addr,str,l
  315. Ven);
  316. X`009break;
  317. X    case WIN_SCROLL:
  318. X`009XCopyArea(W_Display, win->window, win->window,
  319. X`009    colortable`091W_White`093.contexts`0910`093, WIN_EDGE, MENU_PAD+W_Te
  320. Vxtheight,
  321. X`009    win->width*W_Textwidth, (win->height-1)*W_Textheight,
  322. X`009    WIN_EDGE, MENU_PAD);
  323. X`009XClearArea(W_Display, win->window,`032
  324. X`009    WIN_EDGE, MENU_PAD+W_Textheight*(win->height-1),
  325. X`009    W_Textwidth*win->width, W_Textheight, False);
  326. X`009XDrawImageString(W_Display, win->window,
  327. X`009    colortable`091color`093.contexts`0911`093,
  328. X`009    WIN_EDGE, MENU_PAD+W_Textheight*(win->height-1)+fonts`0911`093.basel
  329. Vine,
  330. X`009    str, len);
  331. X`009AddToScrolling(win, color, str, len);
  332. X`009break;
  333. X    case WIN_MENU:
  334. X`009changeMenuItem(win, y, str, len, color);
  335. X`009break;
  336. X    default:
  337. X`009addr=fonts`091fontNum(font)`093.baseline;
  338. X`009XDrawImageString(W_Display, win->window,
  339. X`009    colortable`091color`093.contexts`091fontNum(font)`093,
  340. X`009    x*W_Textwidth+WIN_EDGE, MENU_PAD+y*W_Textheight+addr,
  341. X`009    str, len);
  342. X`009break;
  343. X    `125
  344. X`125
  345. X
  346. Xvoid W_MaskText(window, x, y, color, str, len, font)
  347. XW_Window window;
  348. Xint x, y,len;
  349. XW_Color color;
  350. XW_Font font;
  351. Xchar *str;
  352. X`123
  353. X    struct window *win;
  354. X    int addr;
  355. X
  356. X    addr=fonts`091fontNum(font)`093.baseline;
  357. X#ifdef DEBUG
  358. X    printf("TextMask for %d @ (%d, %d) in %d: `091%s`093\n", window, x,y,col
  359. Vor,str);
  360. X#endif
  361. X    win=W_Void2Window(window);
  362. X    XDrawString(W_Display, win->window,`032
  363. X`009colortable`091color`093.contexts`091fontNum(font)`093, x,y+addr, str, le
  364. Vn);
  365. X`125
  366. X
  367. XW_Icon W_StoreBitmap(width, height, data, window)
  368. Xint width, height;
  369. XW_Window window;
  370. Xunsigned char *data;
  371. X`123
  372. X    struct icon *newicon;
  373. X    struct window *win;
  374. X
  375. X#ifdef DEBUG
  376. X    printf("Storing bitmap for %d (%d x %d)\n", window,width,height);
  377. X    fflush(stdout);
  378. X#endif
  379. X    win=W_Void2Window(window);
  380. X    newicon=(struct icon *) malloc(sizeof(struct icon));
  381. X    newicon->width=width;
  382. X    newicon->height=height;
  383. X    newicon->bitmap=XCreateBitmapFromData(W_Display, win->window,
  384. X`009data, width, height);
  385. X    newicon->window=win->window;
  386. X    newicon->pixmap=0;
  387. X
  388. X    return(W_Icon2Void(newicon));
  389. X`125
  390. X
  391. Xvoid W_WriteBitmap(x, y, bit, color)
  392. Xint x,y;
  393. XW_Icon bit;
  394. XW_Color color;
  395. X`123
  396. X    struct icon *icon;
  397. X
  398. X    icon=W_Void2Icon(bit);
  399. X#ifdef DEBUG
  400. X    printf("Writing bitmap to %d\n", icon->window);
  401. X#endif
  402. X    XCopyPlane(W_Display, icon->bitmap, icon->window,
  403. X`009colortable`091color`093.contexts`091BITGC`093, 0, 0, icon->width, icon->
  404. Vheight,
  405. X`009x, y, 1);
  406. X`125
  407. X
  408. Xvoid W_TileWindow(window, bit)
  409. XW_Window window;
  410. XW_Icon bit;
  411. X`123
  412. X    Window win;
  413. X    struct icon *icon;
  414. X
  415. X#ifdef DEBUG
  416. X    printf("Tiling window %d\n", window);
  417. X#endif
  418. X    icon=W_Void2Icon(bit);
  419. X    win=W_Void2Window(window)->window;
  420. X
  421. X    if (icon->pixmap==0) `123
  422. X`009icon->pixmap=XCreatePixmap(W_Display, W_Root,
  423. X`009    icon->width, icon->height, DefaultDepth(W_Display, W_Screen));
  424. X`009XCopyPlane(W_Display, icon->bitmap, icon->pixmap,`032
  425. X`009    colortable`091W_White`093.contexts`0910`093, 0, 0, icon->width, icon
  426. V->height,
  427. X`009    0, 0, 1);
  428. X    `125
  429. X    XSetWindowBackgroundPixmap(W_Display, win, icon->pixmap);
  430. X    XClearWindow(W_Display, win);
  431. X
  432. X/*
  433. X    if (icon->pixmap==0) `123
  434. X`009icon->pixmap=XMakePixmap(icon->bitmap, colortable`091W_White`093.pixelVa
  435. Vlue,
  436. X`009    colortable`091W_Black`093.pixelValue);
  437. X    `125
  438. X    XChangeBackground(win, icon->pixmap);
  439. X    XClear(win);
  440. X */
  441. X`125
  442. X
  443. Xvoid W_UnTileWindow(window)
  444. XW_Window window;
  445. X`123
  446. X    Window win;
  447. X
  448. X#ifdef DEBUG
  449. X    printf("Untiling window %d\n", window);
  450. X#endif
  451. X    win=W_Void2Window(window)->window;
  452. X
  453. X    XSetWindowBackground(W_Display, win, colortable`091W_Black`093.pixelValu
  454. Ve);
  455. X    XClearWindow(W_Display, win);
  456. X`125
  457. X
  458. XW_Window W_MakeTextWindow(name,x,y,width,height,parent,border)
  459. Xchar *name;
  460. Xint x,y,width,height;
  461. XW_Window parent;
  462. Xint border;
  463. X`123
  464. X    struct window *newwin;
  465. X    Window wparent;
  466. X    XSetWindowAttributes attrs;
  467. X`009
  468. X#ifdef DEBUG
  469. X    printf("New window...\n");
  470. X#endif
  471. X    checkGeometry(name, &x, &y, &width, &height);
  472. X    checkParent(name, &parent);
  473. X    attrs.override_redirect=False;
  474. X    attrs.border_pixel=colortable`091W_White`093.pixelValue;
  475. X    attrs.event_mask=ExposureMask;
  476. X    attrs.background_pixel=colortable`091W_Black`093.pixelValue;
  477. X    attrs.do_not_propagate_mask=ExposureMask;
  478. X    wparent=W_Void2Window(parent)->window;
  479. X    newwin=newWindow(
  480. X`009XCreateWindow(W_Display, wparent, x, y,`032
  481. X`009    width*W_Textwidth+WIN_EDGE*2, MENU_PAD*2+height*W_Textheight,`032
  482. X`009    border, CopyFromParent, InputOutput, CopyFromParent,
  483. X`009    CWBackPixel`124CWEventMask`124
  484. X`009    CWOverrideRedirect`124CWBorderPixel,`032
  485. X`009    &attrs),
  486. X`009WIN_TEXT);
  487. X    XSetClassHint(W_Display, newwin->window, &class_hint);
  488. X    XSetWMHints(W_Display, newwin->window, &wm_hint);
  489. X    newwin->name=strdup(name);
  490. X    newwin->width=width;
  491. X    newwin->height=height;
  492. X    if (checkMapped(name)) W_MapWindow(W_Window2Void(newwin));
  493. X#ifdef DEBUG
  494. X    printf("New text window %d, child of %d\n", newwin, parent);
  495. X#endif
  496. X    return(W_Window2Void(newwin));
  497. X`125
  498. X
  499. Xstruct window *newWindow(window, type)
  500. XWindow window;
  501. Xint type;
  502. X`123
  503. X    struct window *newwin;
  504. X
  505. X    newwin=(struct window *) malloc(sizeof(struct window));
  506. X    newwin->window=window;
  507. X    newwin->type=type;
  508. X    newwin->mapped=0;
  509. X    addToHash(newwin);
  510. X    return(newwin);
  511. X`125
  512. X
  513. Xstruct window *findWindow(window)
  514. XWindow window;
  515. X`123
  516. X    struct windowlist *entry;
  517. X
  518. X    entry=hashtable`091hash(window)`093;
  519. X    while (entry!=NULL) `123
  520. X`009if (entry->window->window == window) return(entry->window);
  521. X`009entry=entry->next;
  522. X    `125
  523. X    return(NULL);
  524. X`125
  525. X
  526. XaddToHash(win)
  527. Xstruct window *win;
  528. X`123
  529. X    struct windowlist **new;
  530. X
  531. X#ifdef DEBUG
  532. X    printf("Adding to %d\n", hash(win->window));
  533. X#endif
  534. X    new= &hashtable`091hash(win->window)`093;
  535. X    while (*new != NULL) `123
  536. X`009new= &((*new)->next);
  537. X    `125
  538. X    *new=(struct windowlist *) malloc(sizeof(struct windowlist));
  539. X    (*new)->next=NULL;
  540. X    (*new)->window=win;
  541. X`125
  542. X
  543. XW_Window W_MakeScrollingWindow(name,x,y,width,height,parent,border)
  544. Xchar *name;
  545. Xint x,y,width,height;
  546. XW_Window parent;
  547. Xint border;
  548. X`123
  549. X    struct window *newwin;
  550. +-+-+-+-+-+-+-+-  END  OF PART 46 +-+-+-+-+-+-+-+-
  551.