home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / vmsnet / sources / games / 459 < prev    next >
Encoding:
Text File  |  1992-11-20  |  11.1 KB  |  411 lines

  1. Newsgroups: vmsnet.sources.games
  2. Path: sparky!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 47/47 <- FINALLY!
  5. Message-ID: <1992Nov20.211158.1@acad2.alaska.edu>
  6. Lines: 399
  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:58 GMT
  11.  
  12. -+-+-+-+-+-+-+-+ START OF PART 47 -+-+-+-+-+-+-+-+
  13. X    Window wparent;
  14. X    XSetWindowAttributes attrs;
  15. X
  16. X#ifdef DEBUG
  17. X    printf("New window...\n");
  18. X#endif
  19. X    checkGeometry(name, &x, &y, &width, &height);
  20. X    checkParent(name, &parent);
  21. X    wparent=W_Void2Window(parent)->window;
  22. X    attrs.override_redirect=False;
  23. X    attrs.border_pixel=colortable`091W_White`093.pixelValue;
  24. X    attrs.event_mask=ResizeRedirectMask`124ExposureMask;
  25. X    attrs.background_pixel=colortable`091W_Black`093.pixelValue;
  26. X    attrs.do_not_propagate_mask=ResizeRedirectMask`124ExposureMask;
  27. X    newwin=newWindow(
  28. X`009XCreateWindow(W_Display, wparent, x, y,
  29. X            width*W_Textwidth+WIN_EDGE*2, MENU_PAD*2+height*W_Textheight,`03
  30. V2
  31. X`009    border, CopyFromParent, InputOutput, CopyFromParent,
  32. X`009    CWBackPixel`124CWEventMask`124
  33. X`009    CWOverrideRedirect`124CWBorderPixel,`032
  34. X`009    &attrs),
  35. X        WIN_SCROLL);
  36. X    XSetClassHint(W_Display, newwin->window, &class_hint);
  37. X    XSetWMHints(W_Display, newwin->window, &wm_hint);
  38. X    newwin->name=strdup(name);
  39. X    newwin->data=NULL;
  40. X    newwin->width=width;
  41. X    newwin->height=height;
  42. X    if (checkMapped(name)) W_MapWindow(W_Window2Void(newwin));
  43. X#ifdef DEBUG
  44. X    printf("New scroll window %d, child of %d\n", newwin, parent);
  45. X#endif
  46. X    return(W_Window2Void(newwin));
  47. X`125
  48. X
  49. X/* Add a string to the string list of the scrolling window.`032
  50. X */
  51. XAddToScrolling(win, color, str, len)
  52. Xstruct window *win;
  53. XW_Color color;
  54. Xchar *str;
  55. Xint len;
  56. X`123
  57. X    struct stringList **strings;
  58. X    char *newstring;
  59. X    int count;
  60. X
  61. X    strings= (struct stringList **) &(win->data);
  62. X    count=0;
  63. X    while ((*strings)!=NULL) `123
  64. X`009count++;
  65. X`009strings= &((*strings)->next);
  66. X    `125
  67. X    (*strings)=(struct stringList *) malloc(sizeof(struct stringList));
  68. X    (*strings)->next=NULL;
  69. X    (*strings)->color=color;
  70. X    newstring=(char *) malloc(len+1);
  71. X    strncpy(newstring, str, len);
  72. X    newstring`091len`093=0;
  73. X    (*strings)->string=newstring;
  74. X    if (count >= 100) `123`009`009/* Arbitrary large size. */
  75. X`009struct stringList *temp;
  76. X
  77. X`009temp=(struct stringList *) win->data;
  78. X`009free(temp->string);
  79. X`009temp=temp->next;
  80. X`009free((char *) win->data);
  81. X`009win->data=(char *) temp;
  82. X    `125
  83. X`125
  84. X
  85. XredrawScrolling(win)
  86. Xstruct window *win;
  87. X`123
  88. X    int count;
  89. X    struct stringList *list;
  90. X    int y;
  91. X
  92. X    XClearWindow(W_Display, win->window);
  93. X    count=0;
  94. X    list = (struct stringList *) win->data;
  95. X    while (list != NULL) `123
  96. X`009list=list->next;
  97. X`009count++;
  98. X    `125
  99. X    list = (struct stringList *) win->data;
  100. X    while (count > win->height) `123
  101. X`009list=list->next;
  102. X`009count--;
  103. X    `125
  104. X    y=(win->height-count)*W_Textheight+fonts`0911`093.baseline;
  105. X    if (count==0) return;
  106. X    while (list != NULL) `123
  107. X`009XDrawImageString(W_Display, win->window,`032
  108. X`009    colortable`091list->color`093.contexts`0911`093,
  109. X`009    WIN_EDGE, MENU_PAD+y, list->string, strlen(list->string));
  110. X`009list=list->next;
  111. X`009y=y+W_Textheight;
  112. X    `125
  113. X`125
  114. X
  115. XresizeScrolling(win, width, height)
  116. Xstruct window *win;
  117. Xint width, height;
  118. X`123
  119. X    win->height=(height - MENU_PAD*2)/W_Textheight;
  120. X    win->width=(width - WIN_EDGE*2)/W_Textwidth;
  121. X    XResizeWindow(W_Display, win->window, win->width*W_Textwidth+WIN_EDGE*2,
  122. X`009win->height*W_Textheight+MENU_PAD*2);
  123. X`125
  124. X
  125. XW_Window W_MakeMenu(name,x,y,width,height,parent,border)
  126. Xchar *name;
  127. Xint x,y,width,height;
  128. XW_Window parent;
  129. Xint border;
  130. X`123
  131. X    struct window *newwin;
  132. X    struct menuItem *items;
  133. X    Window wparent;
  134. X    int i;
  135. X    XSetWindowAttributes attrs;
  136. X
  137. X#ifdef DEBUG
  138. X    printf("New window...\n");
  139. X#endif
  140. X    checkGeometry(name, &x, &y, &width, &height);
  141. X    checkParent(name, &parent);
  142. X    wparent=W_Void2Window(parent)->window;
  143. X    attrs.override_redirect=False;
  144. X    attrs.border_pixel=colortable`091W_White`093.pixelValue;
  145. X    attrs.event_mask=KeyPressMask`124ButtonPressMask`124ExposureMask;
  146. X    attrs.background_pixel=colortable`091W_Black`093.pixelValue;
  147. X    attrs.do_not_propagate_mask=KeyPressMask`124ButtonPressMask`124ExposureM
  148. Vask;
  149. X    newwin=newWindow(
  150. X`009XCreateWindow(W_Display, wparent, x, y,
  151. X`009    width*W_Textwidth+WIN_EDGE*2,
  152. X`009    height*(W_Textheight+MENU_PAD*2)+(height-1)*MENU_BAR, border,
  153. X`009    CopyFromParent, InputOutput, CopyFromParent,
  154. X`009    CWBackPixel`124CWEventMask`124
  155. X`009    CWOverrideRedirect`124CWBorderPixel,`032
  156. X`009    &attrs),
  157. X        WIN_MENU);
  158. X    XSetClassHint(W_Display, newwin->window, &class_hint);
  159. X    XSetWMHints(W_Display, newwin->window, &wm_hint);
  160. X    newwin->name=strdup(name);
  161. X    items=(struct menuItem *) malloc(height*sizeof(struct menuItem));
  162. X    for (i=0; i<height; i++) `123
  163. X`009items`091i`093.string=NULL;
  164. X`009items`091i`093.color=W_White;
  165. X    `125
  166. X    newwin->data=(char *) items;
  167. X    newwin->width=width;
  168. X    newwin->height=height;
  169. X    if (checkMapped(name)) W_MapWindow(W_Window2Void(newwin));
  170. X#ifdef DEBUG
  171. X    printf("New menu window %d, child of %d\n", newwin, parent);
  172. X#endif
  173. X    return(W_Window2Void(newwin));
  174. X`125
  175. X
  176. XredrawMenu(win)
  177. Xstruct window *win;
  178. X`123
  179. X    int count;
  180. X
  181. X    for (count=1; count<win->height; count++) `123
  182. X`009XFillRectangle(W_Display, win->window,`032
  183. X`009    colortable`091W_White`093.contexts`0910`093,`032
  184. X`009    0, count*(W_Textheight+MENU_PAD*2)+(count-1)*MENU_BAR,
  185. X`009    win->width*W_Textwidth+WIN_EDGE*2, MENU_BAR);
  186. X    `125
  187. X    for (count=0; count<win->height; count++) `123
  188. X`009redrawMenuItem(win,count);
  189. X    `125
  190. X`125
  191. X
  192. XredrawMenuItem(win, n)
  193. Xstruct window *win;
  194. Xint n;
  195. X`123
  196. X    struct menuItem *items;
  197. X
  198. X    items=(struct menuItem *) win->data;
  199. X    XFillRectangle(W_Display, win->window,
  200. X`009colortable`091W_Black`093.contexts`0910`093,
  201. X`009WIN_EDGE, n*(W_Textheight+MENU_PAD*2+MENU_BAR)+MENU_PAD,
  202. X`009win->width*W_Textwidth,W_Textheight);
  203. X    if (items`091n`093.string) `123
  204. X`009XDrawImageString(W_Display, win->window,`032
  205. X`009    colortable`091items`091n`093.color`093.contexts`0911`093,
  206. X`009    WIN_EDGE, `009
  207. X`009    n*(W_Textheight+MENU_PAD*2+MENU_BAR)+MENU_PAD+fonts`0911`093.baselin
  208. Ve,
  209. X`009    items`091n`093.string, strlen(items`091n`093.string));
  210. X    `125
  211. X`125
  212. X
  213. XchangeMenuItem(win, n, str, len, color)
  214. Xstruct window *win;
  215. Xint n;
  216. Xchar *str;
  217. Xint len;
  218. XW_Color color;
  219. X`123
  220. X    struct menuItem *items;
  221. X    char *news;
  222. X
  223. X    items=(struct menuItem *) win->data;
  224. X    if (items`091n`093.string) `123
  225. X`009free(items`091n`093.string);
  226. X    `125
  227. X    news=malloc(len+1);
  228. X    strncpy(news,str,len);
  229. X    news`091len`093=0;
  230. X    items`091n`093.string=news;
  231. X    items`091n`093.color=color;
  232. X    redrawMenuItem(win, n);
  233. X`125
  234. X
  235. Xvoid W_DefineCursor(window,width,height,bits,mask,xhot,yhot)
  236. XW_Window window;
  237. Xint width, height, xhot, yhot;
  238. Xunsigned char *bits, *mask;
  239. X`123
  240. X    static unsigned char *oldbits=NULL;
  241. X    static Cursor curs;
  242. X    Pixmap cursbits;
  243. X    Pixmap cursmask;
  244. X    short *curdata;
  245. X    short *maskdata;
  246. X    struct window *win;
  247. X    XColor whiteCol, blackCol;
  248. X
  249. X#ifdef DEBUG
  250. X    printf("Defining cursor for %d\n", window);
  251. X#endif
  252. X    win=W_Void2Window(window);
  253. X    whiteCol.pixel=colortable`091W_White`093.pixelValue;
  254. X    XQueryColor(W_Display, W_Colormap, &whiteCol);
  255. X    blackCol.pixel=colortable`091W_Black`093.pixelValue;
  256. X    XQueryColor(W_Display, W_Colormap, &blackCol);
  257. X    if (!oldbits `124`124 oldbits!=bits) `123
  258. X`009cursbits=XCreateBitmapFromData(W_Display, win->window,
  259. X`009    bits, width, height);
  260. X`009cursmask=XCreateBitmapFromData(W_Display, win->window,
  261. X`009    mask, width, height);
  262. X`009oldbits=bits;
  263. X`009curs=XCreatePixmapCursor(W_Display, cursbits, cursmask,`032
  264. X`009    &whiteCol, &blackCol, xhot, yhot);
  265. X`009XFreePixmap(W_Display, cursbits);
  266. X`009XFreePixmap(W_Display, cursmask);
  267. X    `125
  268. X    XDefineCursor(W_Display, win->window, curs);
  269. X`125
  270. X
  271. Xvoid W_Beep()
  272. X`123
  273. X    XBell(W_Display, 0);
  274. X`125
  275. X
  276. Xint W_WindowWidth(window)
  277. XW_Window window;
  278. X`123
  279. X    return(W_Void2Window(window)->width);
  280. X`125
  281. X
  282. Xint W_WindowHeight(window)
  283. XW_Window window;
  284. X`123
  285. X    return(W_Void2Window(window)->height);
  286. X`125
  287. X
  288. Xint W_Socket()
  289. X`123
  290. X    return(ConnectionNumber(W_Display));
  291. X`125
  292. X
  293. Xvoid W_DestroyWindow(window)
  294. XW_Window window;
  295. X`123
  296. X    struct window *win;
  297. X
  298. X#ifdef DEBUG
  299. X    printf("Destroying %d\n", window);
  300. X#endif
  301. X    win=W_Void2Window(window);
  302. X    deleteWindow(win);
  303. X    XDestroyWindow(W_Display, win->window);
  304. X    free((char *) win);
  305. X`125
  306. X
  307. XdeleteWindow(window)
  308. Xstruct window *window;
  309. X`123
  310. X    struct windowlist **rm;
  311. X    struct windowlist *temp;
  312. X
  313. X    rm= &hashtable`091hash(window->window)`093;
  314. X    while (*rm != NULL && (*rm)->window!=window) `123
  315. X`009rm= &((*rm)->next);
  316. X    `125
  317. X    if (*rm==NULL) `123
  318. X`009printf("Attempt to delete non-existent window!\n");
  319. X`009return;
  320. X    `125
  321. X    temp= *rm;
  322. X    *rm=temp->next;
  323. X    free((char *) temp);
  324. X`125
  325. X
  326. Xvoid W_SetIconWindow(main, icon)
  327. XW_Window main;
  328. XW_Window icon;
  329. X`123
  330. X    XWMHints hints;
  331. X
  332. X    hints.flags=IconWindowHint;
  333. X    hints.icon_window=W_Void2Window(icon)->window;
  334. X    XSetWMHints(W_Display, W_Void2Window(main)->window, &hints);
  335. X`125
  336. X
  337. XcheckGeometry(name, x, y, width, height)
  338. Xchar *name;
  339. Xint *x, *y, *width, *height;
  340. X`123
  341. X    char *adefault;
  342. X    char buf`091100`093;
  343. X    char *s;
  344. X
  345. X    sprintf(buf, "%s.geometry", name);
  346. X    adefault=getdefault(buf);
  347. X    if (adefault==NULL) return;
  348. X    /* geometry should be of the form 502x885+1+1, 502x885, or +1+1 */
  349. X    s=adefault;
  350. X    if (*s!='+') `123
  351. X`009while (*s!='x' && *s!=0) s++;
  352. X`009*width = atoi(adefault);
  353. X`009if (*s==0) return;
  354. X`009s++;
  355. X`009adefault=s;
  356. X`009while (*s!='+' && *s!=0) s++;
  357. X`009*height = atoi(adefault);
  358. X`009if (*s==0) return;
  359. X    `125
  360. X    s++;
  361. X    adefault=s;
  362. X    while (*s!='+' && *s!=0) s++;
  363. X    *x = atoi(adefault);
  364. X    if (*s==0) return;
  365. X    s++;
  366. X    adefault=s;
  367. X    *y = atoi(adefault);
  368. X    return;
  369. X`125
  370. X
  371. XcheckParent(name, parent)
  372. Xchar *name;
  373. XW_Window *parent;
  374. X`123
  375. X    char *adefault;
  376. X    char buf`091100`093;
  377. X    int i;
  378. X    struct windowlist *windows;
  379. X
  380. X    sprintf(buf, "%s.parent", name);
  381. X    adefault=getdefault(buf);
  382. X    if (adefault==NULL) return;
  383. X    /* parent must be name of other window or "root" */
  384. X    if (strcmpi(adefault, "root")==0) `123
  385. X`009*parent=W_Window2Void(&myroot);
  386. X`009return;
  387. X    `125
  388. X    for (i=0; i<HASHSIZE; i++) `123
  389. X`009windows=hashtable`091i`093;
  390. X`009while (windows != NULL) `123
  391. X`009    if (strcmpi(adefault, windows->window->name)==0) `123
  392. X`009`009*parent=W_Window2Void(windows->window);
  393. X`009`009return;
  394. X`009    `125
  395. X`009    windows=windows->next;
  396. X`009`125
  397. X    `125
  398. X`125
  399. X
  400. XcheckMapped(name)
  401. Xchar *name;
  402. X`123
  403. X    char *adefault;
  404. X    char buf`091100`093;
  405. X
  406. X    sprintf(buf, "%s.mapped", name);
  407. X    return(booleanDefault(buf, 0));
  408. X`125
  409. $ CALL UNPACK X11WINDOW.C;1 1281524238
  410. $ EXIT
  411.