home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume17 / xbae / part05 < prev    next >
Encoding:
Text File  |  1992-03-22  |  50.2 KB  |  1,644 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!mips!msi!dcmartin
  3. From: Andrew Wason <aw@bae.bellcore.com>
  4. Subject: v17i032: Xbae widgets (MOTIF), Part05/12
  5. Message-ID: <1992Mar23.180026.16043@msi.com>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. References: <csx-17i028-xbae@uunet.UU.NET>
  10. Date: Mon, 23 Mar 1992 18:00:26 GMT
  11. Approved: dcmartin@msi.com
  12.  
  13. Submitted-by: Andrew Wason <aw@bae.bellcore.com>
  14. Posting-number: Volume 17, Issue 32
  15. Archive-name: xbae/part05
  16.  
  17. Submitted-by: aw@jello
  18. Archive-name: Xbae/part05
  19.  
  20. ---- Cut Here and feed the following to sh ----
  21. #!/bin/sh
  22. # this is Xbae.shar.05 (part 5 of Xbae)
  23. # do not concatenate these parts, unpack them in order with /bin/sh
  24. # file Xbae/src/Caption.c continued
  25. #
  26. if test ! -r _shar_seq_.tmp; then
  27.     echo 'Please unpack part 1 first!'
  28.     exit 1
  29. fi
  30. (read Scheck
  31.  if test "$Scheck" != 5; then
  32.     echo Please unpack part "$Scheck" next!
  33.     exit 1
  34.  else
  35.     exit 0
  36.  fi
  37. ) < _shar_seq_.tmp || exit 1
  38. if test ! -f _shar_wnt_.tmp; then
  39.     echo 'x - still skipping Xbae/src/Caption.c'
  40. else
  41. echo 'x - continuing file Xbae/src/Caption.c'
  42. sed 's/^X//' << 'SHAR_EOF' >> 'Xbae/src/Caption.c' &&
  43. X        ((int)LabelChild(cw)->core.height - cw->caption.label_offset);
  44. X    user_y = 0;
  45. X    break;
  46. X    }
  47. X
  48. X    /*
  49. X     * Position our label widget.
  50. X     */
  51. X    XtMoveWidget(LabelChild(cw), label_x, label_y);
  52. X
  53. X
  54. X    if (configure) {
  55. X    /*
  56. X     * Calculate the size of the user's child widget.
  57. X     */
  58. X    ComputeUserChildSize(cw, cw->core.width, cw->core.height,
  59. X                 &user_width, &user_height,
  60. X                 UserChild(cw)->core.border_width);
  61. X
  62. X    /*
  63. X     * Position and size the user's child.
  64. X     * XXX must use _XmConfigureObject instead of XtConfigureWidget
  65. X     * to handle gadgets (the Motif function always calls the gadgets
  66. X     * resize method)
  67. X     */
  68. X    _XmConfigureObject((RectObj)UserChild(cw),
  69. X               (int)user_x, (int)user_y,
  70. X               (int)user_width, (int)user_height,
  71. X               (int)UserChild(cw)->core.border_width);
  72. X    }
  73. }
  74. X
  75. static void
  76. Resize(cw)
  77. XXbaeCaptionWidget cw;
  78. {
  79. X    Layout(cw, True);
  80. }
  81. X
  82. /*
  83. X * Given a width/height for the caption widget and the border width
  84. X * of the user's child, compute the width and height of the user's child.
  85. X */
  86. static void
  87. ComputeUserChildSize(cw, cwWidth, cwHeight, childWidth, childHeight,
  88. X             childBorderWidth)
  89. XXbaeCaptionWidget cw;
  90. Dimension cwWidth;
  91. Dimension cwHeight;
  92. Dimension *childWidth;
  93. Dimension *childHeight;
  94. Dimension childBorderWidth;
  95. {
  96. X    int width = cwWidth - 2 * childBorderWidth;
  97. X    int height = cwHeight - 2 * childBorderWidth;
  98. X
  99. X    /*
  100. X     * Remember, cw->caption.label_offset can be negative.
  101. X     * If the label width plus the offset is positive, then the label
  102. X     * is off the edge of the user's child, so we subtract that space
  103. X     * from the user's child space.  Otherwise the label is offset into
  104. X     * the space of the user's child widget, so the user's child gets
  105. X     * the full space and the label will be on top of it (or off the opposite
  106. X     * side).
  107. X     */
  108. X
  109. X    switch (cw->caption.label_position) {
  110. X    case XbaePositionLeft:
  111. X    case XbaePositionRight:
  112. X    if ((int)LabelChild(cw)->core.width + cw->caption.label_offset > 0)
  113. X        width -= (int)LabelChild(cw)->core.width +
  114. X        cw->caption.label_offset;
  115. X    break;
  116. X    case XbaePositionTop:
  117. X    case XbaePositionBottom:
  118. X    if ((int)LabelChild(cw)->core.height + cw->caption.label_offset > 0)
  119. X        height -= (int)LabelChild(cw)->core.height +
  120. X        cw->caption.label_offset;
  121. X    break;
  122. X    }
  123. X
  124. X    if (width <= 0)
  125. X    *childWidth = 1;
  126. X    else
  127. X    *childWidth = width;
  128. X
  129. X    if (height <= 0)
  130. X    *childHeight = 1;
  131. X    else
  132. X    *childHeight = height;
  133. }
  134. X
  135. /*
  136. X * Compute our size, taking into account the sizes of
  137. X * both of our children (the user's child size is passed in; we use the
  138. X * current size of the label child)
  139. X */
  140. static void
  141. ComputeSize(cw, cwWidth, cwHeight, childWidth, childHeight, childBorderWidth)
  142. XXbaeCaptionWidget cw;
  143. Dimension *cwWidth;
  144. Dimension *cwHeight;
  145. Dimension childWidth;
  146. Dimension childHeight;
  147. Dimension childBorderWidth;
  148. {
  149. X    childWidth += 2 * childBorderWidth;
  150. X    childHeight += 2 * childBorderWidth;
  151. X
  152. X    /*
  153. X     * Remember, cw->caption.label_offset can be negative.
  154. X     */
  155. X
  156. X    switch (cw->caption.label_position) {
  157. X    case XbaePositionRight:
  158. X    case XbaePositionLeft:
  159. X    if ((int)LabelChild(cw)->core.width + cw->caption.label_offset > 0)
  160. X        *cwWidth = childWidth + LabelChild(cw)->core.width +
  161. X        cw->caption.label_offset;
  162. X    else
  163. X        *cwWidth = childWidth;
  164. X
  165. X    *cwHeight = childHeight > LabelChild(cw)->core.height
  166. X                ? childHeight
  167. X            : LabelChild(cw)->core.height;
  168. X    break;
  169. X
  170. X    case XbaePositionTop:
  171. X    case XbaePositionBottom:
  172. X    if ((int)LabelChild(cw)->core.height + cw->caption.label_offset > 0)
  173. X        *cwHeight = childHeight + LabelChild(cw)->core.height +
  174. X        cw->caption.label_offset;
  175. X    else
  176. X        *cwHeight = childHeight;
  177. X
  178. X    *cwWidth = childWidth > LabelChild(cw)->core.width
  179. X                ? childWidth
  180. X            : LabelChild(cw)->core.width;
  181. X    break;
  182. X    }
  183. }
  184. X
  185. static void
  186. ChangeManaged(cw)
  187. XXbaeCaptionWidget cw;
  188. {
  189. X    Dimension width, height;
  190. X    XtGeometryResult result;
  191. X
  192. X    /*
  193. X     * Figure out what size we want to be.  If we don't have a user child,
  194. X     * we just want to be as big as the label.  Otherwise we must
  195. X     * take the label and user child into account.
  196. X     */
  197. X    if (!HaveUserChild(cw)) {
  198. X    width = LabelChild(cw)->core.width;
  199. X    height = LabelChild(cw)->core.height;
  200. X    }
  201. X    else {
  202. X    ComputeSize(cw, &width, &height,
  203. X            UserChild(cw)->core.width, UserChild(cw)->core.height,
  204. X            UserChild(cw)->core.border_width);
  205. X    }
  206. X
  207. X    /*
  208. X     * If our calculated size is not our current size,
  209. X     * then request our calculated size.
  210. X     */
  211. X    if (width != cw->core.width || height != cw->core.height) {
  212. X    do {
  213. X        result = XtMakeResizeRequest((Widget)cw, width, height,
  214. X                     &width, &height);
  215. X    } while (result == XtGeometryAlmost);
  216. X    }
  217. X
  218. X    /*
  219. X     * Layout for the new configuration
  220. X     */
  221. X    Layout(cw, True);
  222. }
  223. X
  224. /* ARGSUSED */
  225. static XtGeometryResult
  226. GeometryManager(w, desired, allowed)
  227. Widget w;
  228. XXtWidgetGeometry *desired, *allowed;
  229. {
  230. X    XbaeCaptionWidget cw = (XbaeCaptionWidget) XtParent(w);
  231. X    Dimension save_width, save_height, save_border_width;
  232. X
  233. #define Wants(flag) (desired->request_mode & flag)
  234. X
  235. X    /*
  236. X     * If this is our label widget child, and it is querying, then return
  237. X     * Yes since we always grant the labels requests.
  238. X     */
  239. X    if (w == LabelChild(cw) && Wants(XtCWQueryOnly))
  240. X    return XtGeometryYes;
  241. X
  242. X    /*
  243. X     * Disallow position-only changes for the user's child.
  244. X     */
  245. X    if (w == UserChild(cw) &&
  246. X    !Wants(CWWidth) && !Wants(CWHeight) && !Wants(CWBorderWidth))
  247. X    return XtGeometryNo;
  248. X
  249. X    /*
  250. X     * Save the childs current geometry in case we have to back it out.
  251. X     */
  252. X    save_width = w->core.width;
  253. X    save_height = w->core.height;
  254. X    save_border_width = w->core.border_width;
  255. X
  256. X    /*
  257. X     * Store the childs desired geometry into it's widget record.
  258. X     */
  259. X    if (Wants(CWWidth))
  260. X    w->core.width = desired->width;
  261. X    if (Wants(CWHeight))
  262. X    w->core.height = desired->height;
  263. X    if (Wants(CWBorderWidth))
  264. X    w->core.border_width = desired->border_width;
  265. X
  266. X    /*
  267. X     * If this is our label widget child, then return Yes.  We stored the
  268. X     * changes into the widget above (except for position which we do now),
  269. X     * so Xt will reconfigure the label.
  270. X     * We let our label widget do whatever it wants since we control
  271. X     * when it requests a new size in our set_values.
  272. X     */
  273. X    if (w == LabelChild(cw)) {
  274. X    if (Wants(CWX))
  275. X        w->core.x = desired->x;
  276. X    if (Wants(CWY))
  277. X        w->core.y = desired->y;
  278. X    return XtGeometryYes;
  279. X    }
  280. X
  281. X    /*
  282. X     * Otherwise this must be our user's child widget.
  283. X     * We will attempt to resize to accomodate it.
  284. X     */
  285. X    else {
  286. X    XtWidgetGeometry request;
  287. X    XtGeometryResult result;
  288. X
  289. X    /*
  290. X     * Compute the size we want to be based on the new geometry
  291. X     * stored in the user's child above.
  292. X     */
  293. X    ComputeSize(cw, &request.width, &request.height,
  294. X            w->core.width, w->core.height, w->core.border_width);
  295. X
  296. X    /*
  297. X     * If our calculated size is not our current size,
  298. X     * then request our calculated size.
  299. X     */
  300. X    if (request.width != cw->core.width ||
  301. X        request.height != cw->core.height) {
  302. X        request.request_mode = 0;
  303. X        if (request.width != cw->core.width)
  304. X        request.request_mode |= CWWidth;
  305. X        if (request.height != cw->core.height)
  306. X        request.request_mode |= CWHeight;
  307. X        if (Wants(XtCWQueryOnly))
  308. X        request.request_mode |= XtCWQueryOnly;
  309. X        do {
  310. X        result = XtMakeGeometryRequest((Widget)cw, &request, &request);
  311. X        } while (result == XtGeometryAlmost);
  312. X
  313. X        /*
  314. X         * If our request was granted, we need to layout (we are assuming
  315. X         * our parent implements an XtGeometryYes policy and not
  316. X         * XtGeometryDone)
  317. X         */
  318. X        if (result == XtGeometryYes && !Wants(XtCWQueryOnly))
  319. X        Layout(cw, False);
  320. X    }
  321. X    else
  322. X        result = XtGeometryYes;
  323. X
  324. X    /*
  325. X     * A Yes result means we either got the size we wanted, or we agreed
  326. X     * to a compromise.
  327. X     */
  328. X    if (result == XtGeometryYes) {
  329. X        Dimension childWidth, childHeight;
  330. X
  331. X        /*
  332. X         * Compute the size of the user's child given the size
  333. X         * we got from our geometry negotiations above.
  334. X         */
  335. X        ComputeUserChildSize(cw, request.width, request.height,
  336. X                 &childWidth, &childHeight,
  337. X                 w->core.border_width);
  338. X
  339. X        /*
  340. X         * If the child wants to change it's position, or it wants
  341. X         * to change it's size but our compromize size is not an
  342. X         * exact fit, then we need to return Almost and the new geometry.
  343. X         */
  344. X        if (((Wants(CWX) || Wants(CWY)) ||
  345. X         (Wants(CWWidth) && childWidth != w->core.width) ||
  346. X         (Wants(CWHeight) && childHeight != w->core.height))) {
  347. X        result = XtGeometryAlmost;
  348. X        allowed->request_mode = desired->request_mode & ~(CWX | CWY);
  349. X        allowed->width = childWidth;
  350. X        allowed->height = childHeight;
  351. X        allowed->border_width = w->core.border_width;
  352. X        }
  353. X    }
  354. X
  355. X    /*
  356. X     * Restore the childs geometry for No or Almost or QueryOnly.
  357. X     */
  358. X    if (result == XtGeometryNo || result == XtGeometryAlmost ||
  359. X        Wants(XtCWQueryOnly)) {
  360. X        w->core.width = save_width;
  361. X        w->core.height = save_height;
  362. X        w->core.border_width = save_border_width;
  363. X    }
  364. X
  365. X    return result;
  366. X    }
  367. X
  368. #undef Wants
  369. }
  370. X
  371. static XtGeometryResult
  372. QueryGeometry(cw, proposed, desired)
  373. XXbaeCaptionWidget cw;
  374. XXtWidgetGeometry *proposed, *desired;
  375. {
  376. #define Set(bit) (proposed->request_mode & bit)
  377. X
  378. X    /*
  379. X     * If we don't have a user child, we want to be the size of the label.
  380. X     */
  381. X    if (!HaveUserChild(cw)) {
  382. X    desired->width = LabelChild(cw)->core.width;
  383. X    desired->height = LabelChild(cw)->core.height;
  384. X    desired->request_mode = CWWidth | CWHeight;
  385. X
  386. X    if (Set(CWWidth) && proposed->width == desired->width &&
  387. X        Set(CWHeight) && proposed->height == desired->height)
  388. X        return XtGeometryYes;
  389. X
  390. X    if (desired->width == cw->core.width &&
  391. X        desired->height == cw->core.height)
  392. X        return XtGeometryNo;
  393. X
  394. X    return XtGeometryAlmost;
  395. X    }
  396. X
  397. X    /*
  398. X     * Otherwise we must take into account what size the user child wants to be
  399. X     */
  400. X    else {
  401. X    XtWidgetGeometry childProposed, childDesired;
  402. X    Dimension childWidth, childHeight, childBorderWidth;
  403. X    Dimension cwWidth, cwHeight;
  404. X    XtGeometryResult result;
  405. X
  406. X    /*
  407. X     * Get our size based on the proposed size for use in computing
  408. X     * the user's child size.
  409. X     */
  410. X    if (Set(CWWidth))
  411. X        cwWidth = proposed->width;
  412. X    else
  413. X        cwWidth = cw->core.width;
  414. X    if (Set(CWHeight))
  415. X        cwHeight = proposed->height;
  416. X    else
  417. X        cwHeight = cw->core.height;
  418. X
  419. X    /*
  420. X     * Compute the size of the user's child based on our proposed new size.
  421. X     */
  422. X    ComputeUserChildSize(cw, cwWidth, cwHeight,
  423. X                 &childWidth, &childHeight,
  424. X                 UserChild(cw)->core.border_width);
  425. X
  426. X    /*
  427. X     * Build a geometry request to query the user's child with.
  428. X     */
  429. X    childProposed.request_mode = 0;
  430. X    if (Set(CWWidth)) {
  431. X        childProposed.width = childWidth;
  432. X        childProposed.request_mode |= CWWidth;
  433. X    }
  434. X    if (Set(CWHeight)) {
  435. X        childProposed.height = childHeight;
  436. X        childProposed.request_mode |= CWHeight;
  437. X    }
  438. X
  439. X    /*
  440. X     * Query the child.
  441. X     */
  442. X    result = XtQueryGeometry(UserChild(cw), &childProposed, &childDesired);
  443. X
  444. X    /*
  445. X     * Save the childs desired geometry.
  446. X     */
  447. X    switch (result) {
  448. X    case XtGeometryYes:
  449. X        /* use our computed childWidth and childHeight */
  450. X        childBorderWidth = UserChild(cw)->core.border_width;
  451. X        break;
  452. X    case XtGeometryAlmost:
  453. X        childWidth = childDesired.width;
  454. X        childHeight = childDesired.height;
  455. X        childBorderWidth = childDesired.border_width;
  456. X        break;
  457. X    case XtGeometryNo:
  458. X        childWidth = UserChild(cw)->core.width;
  459. X        childHeight = UserChild(cw)->core.height;
  460. X        childBorderWidth = UserChild(cw)->core.border_width;
  461. X        break;
  462. X    }
  463. X
  464. X    /*
  465. X     * Calculate what size we need to be to handle the childs
  466. X     * desired geometry and store it in our own desired record.
  467. X     */
  468. X    ComputeSize(cw, &desired->width, &desired->height,
  469. X            childWidth, childHeight, childBorderWidth);
  470. X
  471. X    /*
  472. X     * If the proposed geometry changed, or if the child cares about
  473. X     * it's geometry, then set the flag in desired
  474. X     */
  475. X    desired->request_mode = 0;
  476. X    if ((Set(CWWidth) && proposed->width != desired->width) ||
  477. X        childDesired.request_mode & CWWidth)
  478. X        desired->request_mode |= CWWidth;
  479. X    if ((Set(CWHeight) && proposed->height != desired->height) ||
  480. X        childDesired.request_mode & CWHeight)
  481. X        desired->request_mode |= CWHeight;
  482. X
  483. X    /*
  484. X     * If our desired geometry differs from the proposed one, or if
  485. X     * we care about a geometry which was not proposed, we return
  486. X     * Almost.  Otherwise we return whatever our child returned.
  487. X     */
  488. X    if ((Set(CWWidth) && proposed->width != desired->width) ||
  489. X        (!Set(CWWidth) && desired->request_mode & CWWidth) ||
  490. X        (Set(CWHeight) && proposed->height != desired->height) ||
  491. X        (!Set(CWHeight) && desired->request_mode & CWHeight))
  492. X        return XtGeometryAlmost;
  493. X    else
  494. X        return result;
  495. X    }
  496. X
  497. #undef Set
  498. }
  499. X
  500. X
  501. /*
  502. X * Compare two strings.  The test string must be lower case
  503. X * and NULL terminated.  Leading and trailing whitespace in the in
  504. X * string is ignored.
  505. X */
  506. static Boolean
  507. CompareStrings(in, test)
  508. String in, test;
  509. {
  510. X    /*
  511. X     * Strip leading whitespace off the in string.
  512. X     */
  513. X    while (isspace(*in))
  514. X    in++;
  515. X
  516. X    for (; *test != '\0' && !isspace(*in); test++, in++) {
  517. X    char c = *in;
  518. X
  519. X    if (isupper(c))
  520. X            c = tolower(c);
  521. X
  522. X        if (c != *test)
  523. X            return False;
  524. X    }
  525. X
  526. X    if (*test == '\0' && (*in == '\0' || isspace(*in)))
  527. X    return True;
  528. X    else
  529. X    return False;
  530. }
  531. X
  532. /* ARGSUSED */
  533. static Boolean
  534. CvtStringToLabelPosition(dpy, args, num_args, from, to, data)
  535. Display *dpy;
  536. XXrmValuePtr args;
  537. Cardinal *num_args;
  538. XXrmValuePtr from, to;
  539. XXtPointer *data;
  540. {
  541. X    static XbaeLabelPosition position;
  542. X
  543. X    if (*num_args != 0)
  544. X        XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
  545. X                        "cvtStringToLabelPosition", "wrongParameters",
  546. X                        "XbaeCaption",
  547. X                        "String to LabelPosition conversion needs no extra arguments",
  548. X                        NULL, NULL);
  549. X
  550. X    /*
  551. X     * User didn't provide enough space
  552. X     */
  553. X    if (to->addr != NULL && to->size < sizeof(XbaeLabelPosition)) {
  554. X        to->size = sizeof(XbaeLabelPosition);
  555. X        return False;
  556. X    }
  557. X
  558. X    if (CompareStrings(from->addr, "left"))
  559. X    position = XbaePositionLeft;
  560. X    else if (CompareStrings(from->addr, "right"))
  561. X    position = XbaePositionRight;
  562. X    else if (CompareStrings(from->addr, "top"))
  563. X    position = XbaePositionTop;
  564. X    else if (CompareStrings(from->addr, "bottom"))
  565. X    position = XbaePositionBottom;
  566. X    else {
  567. X    XtDisplayStringConversionWarning(dpy, from->addr, XmRLabelPosition);
  568. X    return False;
  569. X    }
  570. X
  571. X    /*
  572. X     * Store our return value
  573. X     */
  574. X    if (to->addr == NULL)
  575. X        to->addr = (caddr_t) &position;
  576. X    else
  577. X        *(XbaeLabelPosition *) to->addr = position;
  578. X    to->size = sizeof(XbaeLabelPosition);
  579. X
  580. X    return True;
  581. }
  582. X
  583. /* ARGSUSED */
  584. static Boolean
  585. CvtStringToLabelAlignment(dpy, args, num_args, from, to, data)
  586. Display *dpy;
  587. XXrmValuePtr args;
  588. Cardinal *num_args;
  589. XXrmValuePtr from, to;
  590. XXtPointer *data;
  591. {
  592. X    static XbaeLabelAlignment alignment;
  593. X
  594. X    if (*num_args != 0)
  595. X        XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
  596. X                        "cvtStringToLabelAlignment", "wrongParameters",
  597. X                        "XbaeCaption",
  598. X                        "String to LabelAlignment conversion needs no extra arguments",
  599. X                        NULL, NULL);
  600. X
  601. X    /*
  602. X     * User didn't provide enough space
  603. X     */
  604. X    if (to->addr != NULL && to->size < sizeof(XbaeLabelAlignment)) {
  605. X        to->size = sizeof(XbaeLabelAlignment);
  606. X        return False;
  607. X    }
  608. X
  609. X    if (CompareStrings(from->addr, "toporleft") ||
  610. X    CompareStrings(from->addr, "top") ||
  611. X    CompareStrings(from->addr, "left"))
  612. X    alignment = XbaeAlignmentTopOrLeft;
  613. X    else if (CompareStrings(from->addr, "center"))
  614. X    alignment = XbaeAlignmentCenter;
  615. X    else if (CompareStrings(from->addr, "bottomorright") ||
  616. X         CompareStrings(from->addr, "bottom") ||
  617. X         CompareStrings(from->addr, "right"))
  618. X    alignment = XbaeAlignmentBottomOrRight;
  619. X    else {
  620. X    XtDisplayStringConversionWarning(dpy, from->addr, XmRLabelAlignment);
  621. X    return False;
  622. X    }
  623. X
  624. X    /*
  625. X     * Store our return value
  626. X     */
  627. X    if (to->addr == NULL)
  628. X        to->addr = (caddr_t) &alignment;
  629. X    else
  630. X        *(XbaeLabelAlignment *) to->addr = alignment;
  631. X    to->size = sizeof(XbaeLabelAlignment);
  632. X
  633. X    return True;
  634. }
  635. SHAR_EOF
  636. echo 'File Xbae/src/Caption.c is complete' &&
  637. chmod 0444 Xbae/src/Caption.c ||
  638. echo 'restore of Xbae/src/Caption.c failed'
  639. Wc_c="`wc -c < 'Xbae/src/Caption.c'`"
  640. test 33046 -eq "$Wc_c" ||
  641.     echo 'Xbae/src/Caption.c: original size 33046, current size' "$Wc_c"
  642. rm -f _shar_wnt_.tmp
  643. fi
  644. # ============= Xbae/src/Clip.c ==============
  645. if test -f 'Xbae/src/Clip.c' -a X"$1" != X"-c"; then
  646.     echo 'x - skipping Xbae/src/Clip.c (File already exists)'
  647.     rm -f _shar_wnt_.tmp
  648. else
  649. > _shar_wnt_.tmp
  650. echo 'x - extracting Xbae/src/Clip.c (Text)'
  651. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/src/Clip.c' &&
  652. /*
  653. X * Copyright(c) 1992 Bell Communications Research, Inc. (Bellcore)
  654. X *                        All rights reserved
  655. X * Permission to use, copy, modify and distribute this material for
  656. X * any purpose and without fee is hereby granted, provided that the
  657. X * above copyright notice and this permission notice appear in all
  658. X * copies, and that the name of Bellcore not be used in advertising
  659. X * or publicity pertaining to this material without the specific,
  660. X * prior written permission of an authorized representative of
  661. X * Bellcore.
  662. X *
  663. X * BELLCORE MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, EX-
  664. X * PRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT
  665. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  666. X * FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST IN-
  667. X * FRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS.  THE
  668. X * SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL BELLCORE OR
  669. X * ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY
  670. X * LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELAT-
  671. X * ING TO THE SOFTWARE.
  672. X *
  673. X * ClipWidget Author: Andrew Wason, Bellcore, aw@bae.bellcore.com
  674. X */
  675. X
  676. /*
  677. X * Clip.c - private child of Matrix - used to clip Matrix's textField child
  678. X */
  679. X
  680. #include <X11/StringDefs.h>
  681. #include <Xm/XmP.h>
  682. #include <Xbae/ClipP.h>
  683. X
  684. #ifndef SABER
  685. static char sccsid[] = "@(#)Clip.c    3.3 2/18/92";
  686. #endif
  687. X
  688. static char defaultTranslations[] =
  689. X    "<FocusIn>:            FocusIn()";
  690. X
  691. static XtResource resources[] = {
  692. X    { XmNexposeProc, XmCFunction, XtRFunction, sizeof(XtExposeProc),
  693. X      XtOffsetOf(XbaeClipRec, clip.expose_proc),
  694. X      XtRFunction, (XtPointer) NULL },
  695. X    { XmNfocusCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
  696. X      XtOffsetOf(XbaeClipRec, clip.focus_callback),
  697. X      XtRImmediate, (XtPointer) NULL },
  698. };
  699. X
  700. /*
  701. X * Declaration of methods
  702. X */
  703. static void ClassPartInitialize();
  704. static void Realize();
  705. static void Redisplay();
  706. static void Redraw();
  707. X
  708. /*
  709. X * Public convenience function
  710. X */
  711. void XbaeClipRedraw();
  712. X
  713. /*
  714. X * Clip actions
  715. X */
  716. static void FocusInACT();
  717. X
  718. static XtActionsRec actions[] =
  719. {
  720. X    {"FocusIn", FocusInACT},
  721. };
  722. X
  723. XXbaeClipClassRec xbaeClipClassRec = {
  724. X    {
  725. X    /* core_class fields */
  726. X    /* superclass        */ (WidgetClass) &xmPrimitiveClassRec,
  727. X    /* class_name        */ "XbaeClip",
  728. X    /* widget_size        */ sizeof(XbaeClipRec),
  729. X    /* class_initialize    */ NULL,
  730. X    /* class_part_initialize*/ ClassPartInitialize,
  731. X    /* class_inited        */ False,
  732. X    /* initialize        */ NULL,
  733. X    /* initialize_hook    */ NULL,
  734. X    /* realize        */ Realize,
  735. X    /* actions        */ actions,
  736. X    /* num_actions        */ XtNumber(actions),
  737. X    /* resources        */ resources,
  738. X    /* num_resources    */ XtNumber(resources),
  739. X    /* xrm_class        */ NULLQUARK,
  740. X    /* compress_motion    */ True,
  741. X    /* compress_exposure    */ XtExposeCompressSeries |
  742. X                    XtExposeGraphicsExpose |
  743. X                        XtExposeNoExpose,
  744. X    /* compress_enterleave    */ True,
  745. X    /* visible_interest    */ False,
  746. X    /* destroy        */ NULL,
  747. X    /* resize        */ NULL,
  748. X    /* expose        */ Redisplay,
  749. X    /* set_values        */ NULL,
  750. X    /* set_values_hook    */ NULL,
  751. X    /* set_values_almost    */ XtInheritSetValuesAlmost,
  752. X    /* get_values_hook    */ NULL,
  753. X    /* accept_focus        */ NULL,
  754. X    /* version        */ XtVersion,
  755. X    /* callback_private    */ NULL,
  756. X    /* tm_table        */ defaultTranslations,
  757. X    /* query_geometry    */ NULL,
  758. X    /* display_accelerator    */ NULL,
  759. X    /* extension        */ NULL
  760. X    },
  761. X    /* primitive_class fields */
  762. X    {
  763. X    /* border_highlight    */ NULL,
  764. X    /* border_unhighlight    */ NULL,
  765. X    /* translations        */ NULL,
  766. X    /* arm_and_activate    */ NULL,
  767. X    /* syn_resources    */ NULL,
  768. X    /* num_syn_resources    */ 0,
  769. X    /* extension        */ NULL
  770. X    },
  771. X    /* clip_class fields */
  772. X    {
  773. X    /* redraw        */ Redraw,
  774. X    /* extension        */ NULL,
  775. X    }
  776. };
  777. X
  778. WidgetClass xbaeClipWidgetClass = (WidgetClass) & xbaeClipClassRec;
  779. X
  780. X
  781. static void
  782. ClassPartInitialize(cwc)
  783. XXbaeClipWidgetClass cwc;
  784. {
  785. X    register XbaeClipWidgetClass super =
  786. X    (XbaeClipWidgetClass) cwc->core_class.superclass;
  787. X
  788. X    /*
  789. X     * Allow subclasses to inherit our redraw method
  790. X     */
  791. X    if (cwc->clip_class.redraw == XbaeInheritRedraw)
  792. X    cwc->clip_class.redraw = super->clip_class.redraw;
  793. }
  794. X
  795. static void
  796. Realize(cw, valueMask, attributes)
  797. XXbaeClipWidget cw;
  798. XXtValueMask *valueMask;
  799. XXSetWindowAttributes *attributes;
  800. {
  801. X    /*
  802. X     * Don't call our superclasses realize method, because Primitive sets
  803. X     * bit_gravity and do_not_propagate
  804. X     */
  805. X    XtCreateWindow((Widget)cw, InputOutput, CopyFromParent,
  806. X           *valueMask, attributes);
  807. }
  808. X
  809. /* ARGSUSED */
  810. static void
  811. Redisplay(cw, event, region)
  812. XXbaeClipWidget cw;
  813. XXEvent *event;
  814. Region region;
  815. {
  816. X    if (cw->clip.expose_proc)
  817. X    cw->clip.expose_proc((Widget)cw, event, region);
  818. }
  819. X
  820. /*
  821. X * Clip redraw method
  822. X */
  823. /* ARGSUSED */
  824. static void
  825. Redraw(cw)
  826. XXbaeClipWidget cw;
  827. {
  828. X    /*
  829. X     * Clear the window generating Expose events.
  830. X     * XXX It might be more efficient to fake up an Expose event
  831. X     * and call Redisplay directly
  832. X     */
  833. X    if (XtIsRealized(cw))
  834. X    XClearArea(XtDisplay(cw), XtWindow(cw),
  835. X           0, 0,
  836. X           0 /*Full Width*/, 0 /*Full Height*/,
  837. X           True);
  838. }
  839. X
  840. /*
  841. X * Public interface to redraw method
  842. X */
  843. void
  844. XXbaeClipRedraw(w)
  845. Widget w;
  846. {
  847. X    /*
  848. X     * Make sure w is a Clip or a subclass
  849. X     */
  850. X    XtCheckSubclass(w, xbaeClipWidgetClass, NULL);
  851. X
  852. X    /*
  853. X     * Call the redraw method
  854. X     */
  855. X    if (XtIsRealized(w))
  856. X    (*((XbaeClipWidgetClass) XtClass(w))->clip_class.redraw)
  857. X        ((XbaeClipWidget)w);
  858. }
  859. X
  860. /* ARGSUSED */
  861. static void
  862. FocusInACT(cw, event, params, nparams)
  863. XXbaeClipWidget cw;
  864. XXEvent *event;
  865. String *params;
  866. Cardinal *nparams;
  867. {
  868. X    if (event->xany.type != FocusIn)
  869. X    return;
  870. X
  871. X    if (cw->clip.focus_callback)
  872. X    XtCallCallbackList((Widget)cw, cw->clip.focus_callback, NULL);
  873. }
  874. SHAR_EOF
  875. chmod 0444 Xbae/src/Clip.c ||
  876. echo 'restore of Xbae/src/Clip.c failed'
  877. Wc_c="`wc -c < 'Xbae/src/Clip.c'`"
  878. test 5586 -eq "$Wc_c" ||
  879.     echo 'Xbae/src/Clip.c: original size 5586, current size' "$Wc_c"
  880. rm -f _shar_wnt_.tmp
  881. fi
  882. # ============= Xbae/src/Matrix.c ==============
  883. if test -f 'Xbae/src/Matrix.c' -a X"$1" != X"-c"; then
  884.     echo 'x - skipping Xbae/src/Matrix.c (File already exists)'
  885.     rm -f _shar_wnt_.tmp
  886. else
  887. > _shar_wnt_.tmp
  888. echo 'x - extracting Xbae/src/Matrix.c (Text)'
  889. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/src/Matrix.c' &&
  890. /*
  891. X * Copyright(c) 1992 Bell Communications Research, Inc. (Bellcore)
  892. X *                        All rights reserved
  893. X * Permission to use, copy, modify and distribute this material for
  894. X * any purpose and without fee is hereby granted, provided that the
  895. X * above copyright notice and this permission notice appear in all
  896. X * copies, and that the name of Bellcore not be used in advertising
  897. X * or publicity pertaining to this material without the specific,
  898. X * prior written permission of an authorized representative of
  899. X * Bellcore.
  900. X *
  901. X * BELLCORE MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, EX-
  902. X * PRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT
  903. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  904. X * FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST IN-
  905. X * FRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS.  THE
  906. X * SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL BELLCORE OR
  907. X * ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY
  908. X * LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELAT-
  909. X * ING TO THE SOFTWARE.
  910. X *
  911. X * MatrixWidget Author: Andrew Wason, Bellcore, aw@bae.bellcore.com
  912. X */
  913. X
  914. /*
  915. X * Matrix.c - row/column editable matrix widget
  916. X */
  917. X
  918. #include <stdio.h>
  919. #include <ctype.h>
  920. #include <X11/Xos.h>
  921. #include <X11/StringDefs.h>
  922. #include <Xm/XmP.h>
  923. #include <Xm/AtomMgr.h>
  924. #include <Xm/ScrollBar.h>
  925. #include <Xm/TextF.h>
  926. #include <Xbae/Clip.h>
  927. #include <Xbae/MatrixP.h>
  928. X
  929. #ifndef SABER
  930. static char sccsid[] = "@(#)Matrix.c    3.12 3/11/92";
  931. #endif
  932. X
  933. /*
  934. X * Translations for Matrix (these will also be used by the Clip child).
  935. X */
  936. static char defaultTranslations[] =
  937. X    ":<Btn1Down>:        EditCell(Pointer)";
  938. X
  939. /*
  940. X * Default translations for XmNtextTranslations resource
  941. X */
  942. #define TEXT_TRANSLATIONS \
  943. X    "#override\n\
  944. X     Shift ~Ctrl ~Meta ~Alt <Key>Tab:    EditCell(Left)\n\
  945. X     ~Ctrl ~Meta ~Alt <Key>Tab:        EditCell(Right)\n\
  946. X     <Key>osfUp:            EditCell(Up)\n\
  947. X     <Key>osfDown:            EditCell(Down)\n\
  948. X     <Key>osfActivate:            CommitEdit(False)\n\
  949. X     ~Shift ~Meta ~Alt <Key>Return:    CommitEdit(False)\n\
  950. X     <Key>osfCancel:            CancelEdit(False)\n\
  951. X     Shift Ctrl ~Meta ~Alt <Key>Tab:    TraversePrev()\n\
  952. X     Ctrl ~Meta ~Alt <Key>Tab:        TraverseNext()"
  953. X
  954. #define offset(field)    XtOffsetOf(XbaeMatrixRec, field)
  955. X
  956. static XtResource resources[] = {
  957. X    { XmNboldLabels, XmCBoldLabels, XmRBoolean, sizeof(Boolean),
  958. X      offset(matrix.bold_labels), XmRImmediate, (XtPointer) False },
  959. X    { XmNcellHighlightThickness, XmCHighlightThickness, XmRHorizontalDimension,
  960. X      sizeof(Dimension), offset(matrix.cell_highlight_thickness),
  961. X      XmRImmediate, (XtPointer) 2 },
  962. X    { XmNcellMarginHeight, XmCMarginHeight, XmRVerticalDimension,
  963. X      sizeof(Dimension), offset(matrix.cell_margin_height),
  964. X      XmRImmediate, (XtPointer) 5 },
  965. X    { XmNcellMarginWidth, XmCMarginWidth, XmRHorizontalDimension,
  966. X      sizeof(Dimension), offset(matrix.cell_margin_width),
  967. X      XmRImmediate, (XtPointer) 5 },
  968. X    { XmNcells, XmCCells, XmRStringTable, sizeof(String **),
  969. X      offset(matrix.cells), XmRImmediate, NULL },
  970. X    { XmNcellShadowThickness, XmCShadowThickness, XmRHorizontalDimension,
  971. X      sizeof(Dimension), offset(matrix.cell_shadow_thickness),
  972. X      XmRImmediate, (XtPointer) 2 },
  973. X    { XmNcolors, XmCColors, XmRPixelTable, sizeof(Pixel **),
  974. X      offset(matrix.colors), XmRImmediate, (XtPointer) NULL },
  975. X    { XmNcolumnAlignments, XmCAlignments, XmRAlignmentArray,
  976. X      sizeof(unsigned char *), offset(matrix.column_alignments),
  977. X      XmRImmediate, (XtPointer) NULL },
  978. X    { XmNcolumnLabelAlignments, XmCAlignments, XmRAlignmentArray,
  979. X      sizeof(unsigned char *), offset(matrix.column_label_alignments),
  980. X      XmRImmediate, (XtPointer) NULL },
  981. X    { XmNcolumnLabels, XmCLabels, XmRStringArray, sizeof(String *),
  982. X      offset(matrix.column_labels), XmRImmediate, NULL },
  983. X    { XmNcolumnMaxLengths, XmCColumnMaxLengths, XmRMaxLengthArray,
  984. X      sizeof(int *), offset(matrix.column_max_lengths),
  985. X      XmRImmediate, NULL },
  986. X    { XmNcolumnWidths, XmCColumnWidths, XmRWidthArray, sizeof(short *),
  987. X      offset(matrix.column_widths), XmRImmediate, NULL },
  988. X    { XmNcolumns, XmCColumns, XmRInt, sizeof(int),
  989. X      offset(matrix.columns), XmRImmediate, (XtPointer) 0 },
  990. X    { XmNenterCellCallback, XmCCallback, XmRCallback,sizeof(XtCallbackList),
  991. X      offset(matrix.enter_cell_callback), XmRCallback, NULL },
  992. X    { XmNfixedColumns, XmCFixedColumns, XmRDimension, sizeof(Dimension),
  993. X      offset(matrix.fixed_columns), XmRImmediate, (XtPointer) 0 },
  994. X    { XmNfixedRows, XmCFixedRows, XmRDimension, sizeof(Dimension),
  995. X      offset(matrix.fixed_rows), XmRImmediate, (XtPointer) 0 },
  996. X    { XmNfontList, XmCFontList, XmRFontList, sizeof(XmFontList),
  997. X      offset(matrix.font_list), XmRString, (XtPointer) "fixed" },
  998. X    { XmNleaveCellCallback, XmCCallback, XmRCallback,sizeof(XtCallbackList),
  999. X      offset(matrix.leave_cell_callback), XmRCallback, NULL },
  1000. X    { XmNmodifyVerifyCallback, XmCCallback, XmRCallback,sizeof(XtCallbackList),
  1001. X      offset(matrix.modify_verify_callback), XmRCallback, NULL },
  1002. X    { XmNrowLabelAlignment, XmCAlignment, XmRAlignment, sizeof(unsigned char),
  1003. X      offset(matrix.row_label_alignment),
  1004. X      XmRImmediate, (XtPointer) XmALIGNMENT_END },
  1005. X    { XmNrowLabelWidth, XmCRowLabelWidth, XmRShort, sizeof(short),
  1006. X      offset(matrix.row_label_width), XmRImmediate, (XtPointer) 0 },
  1007. X    { XmNrowLabels, XmCLabels, XmRStringArray, sizeof(String *),
  1008. X      offset(matrix.row_labels), XmRImmediate, NULL },
  1009. X    { XmNrows, XmCRows, XmRInt, sizeof(int),
  1010. X      offset(matrix.rows), XmRImmediate, (XtPointer) 0 },
  1011. X    { XmNselectCellCallback, XmCCallback, XmRCallback,
  1012. X      sizeof(XtCallbackList), offset(matrix.select_cell_callback),
  1013. X      XmRCallback, NULL },
  1014. X    { XmNselectedCells, XmCSelectedCells, XmRBooleanTable, sizeof(Boolean **),
  1015. X      offset(matrix.selected_cells), XmRImmediate, (XtPointer) NULL },
  1016. X    { XmNspace, XmCSpace, XmRHorizontalDimension, sizeof(Dimension),
  1017. X      offset(matrix.space), XmRImmediate, (XtPointer) 6 },
  1018. X    { XmNtextTranslations, XmCTranslations, XmRTranslationTable,
  1019. X      sizeof(XtTranslations), offset(matrix.text_translations),
  1020. X      XmRString, (XtPointer) TEXT_TRANSLATIONS },
  1021. X    { XmNtopRow, XmCTopRow, XmRInt, sizeof(int),
  1022. X      offset(matrix.top_row), XmRImmediate, (XtPointer) 0 },
  1023. X    { XmNtraverseCellCallback, XmCCallback, XmRCallback,sizeof(XtCallbackList),
  1024. X      offset(matrix.traverse_cell_callback), XmRCallback, NULL },
  1025. X    { XmNvisibleColumns, XmCVisibleColumns, XmRDimension, sizeof(Dimension),
  1026. X      offset(matrix.visible_columns), XmRImmediate, (XtPointer) 0 },
  1027. X    { XmNvisibleRows, XmCVisibleRows, XmRDimension, sizeof(Dimension),
  1028. X      offset(matrix.visible_rows), XmRImmediate, (XtPointer) 0 },
  1029. X
  1030. X    /* Override Manager default */
  1031. X    { XmNshadowThickness, XmCShadowThickness, XmRHorizontalDimension,
  1032. X      sizeof(Dimension),
  1033. X      XtOffsetOf(XmManagerRec, manager.shadow_thickness),
  1034. X      XmRImmediate, (XtPointer) 2 },
  1035. };
  1036. X
  1037. static XmSyntheticResource syn_resources[] = {
  1038. X    { XmNcellHighlightThickness, sizeof(Dimension),
  1039. X      offset(matrix.cell_highlight_thickness),
  1040. X      _XmFromHorizontalPixels, _XmToHorizontalPixels },
  1041. X    { XmNcellMarginHeight, sizeof(Dimension),
  1042. X      offset(matrix.cell_margin_height),
  1043. X      _XmFromVerticalPixels, _XmToVerticalPixels },
  1044. X    { XmNcellMarginWidth, sizeof(Dimension),
  1045. X      offset(matrix.cell_margin_width),
  1046. X      _XmFromHorizontalPixels, _XmToHorizontalPixels },
  1047. X    { XmNcellShadowThickness, sizeof(Dimension),
  1048. X      offset(matrix.cell_shadow_thickness),
  1049. X      _XmFromHorizontalPixels, _XmToHorizontalPixels },
  1050. X    { XmNspace, sizeof(Dimension),
  1051. X      offset(matrix.space),
  1052. X      _XmFromHorizontalPixels, _XmToHorizontalPixels },
  1053. };
  1054. X
  1055. /*
  1056. X * End of array flags for the array type converters
  1057. X */
  1058. #define BAD_WIDTH    0
  1059. #define BAD_MAXLENGTH    0
  1060. #define BAD_ALIGNMENT    3    /* see Xm.h */
  1061. X
  1062. /*
  1063. X * Macros to retrieve our children.  Children must be created in this order.
  1064. X */
  1065. #define HorizScrollChild(mw)    (mw->composite.children[0])
  1066. #define VertScrollChild(mw)    (mw->composite.children[1])
  1067. #define ClipChild(mw)        (mw->composite.children[2])
  1068. #define TextChild(mw)        (mw->composite.children[3])
  1069. /*
  1070. X * Macros
  1071. X */
  1072. #define FONT_WIDTH(mw)        (mw->matrix.font->max_bounds.width)
  1073. #define TEXT_WIDTH_OFFSET(mw)    (mw->matrix.cell_margin_width +\
  1074. X                 mw->matrix.cell_shadow_thickness +\
  1075. X                 mw->matrix.cell_highlight_thickness)
  1076. #define TEXT_HEIGHT_OFFSET(mw)    (mw->matrix.cell_margin_height +\
  1077. X                 mw->matrix.cell_shadow_thickness +\
  1078. X                 mw->matrix.cell_highlight_thickness)
  1079. #define COLUMN_WIDTH(mw, col)    ((mw->matrix.column_widths[col] * \
  1080. X                  FONT_WIDTH(mw)) + \
  1081. X                 (TEXT_WIDTH_OFFSET(mw) * 2))
  1082. #define TEXT_HEIGHT(mw)        (mw->matrix.font->descent + \
  1083. X                 mw->matrix.font->ascent)
  1084. #define ROW_HEIGHT(mw)        (int)((TEXT_HEIGHT_OFFSET(mw) * 2) + \
  1085. X                        TEXT_HEIGHT(mw))
  1086. X
  1087. #define TEXT_X_OFFSET(mw)    (int)(TEXT_WIDTH_OFFSET(mw))
  1088. #define TEXT_Y_OFFSET(mw)    (int)(mw->matrix.text_baseline)
  1089. X
  1090. #define ROW_LABEL_WIDTH(mw)    (mw->matrix.row_labels \
  1091. X                 ? (mw->matrix.row_label_width * \
  1092. X                    FONT_WIDTH(mw)) + \
  1093. X                    TEXT_WIDTH_OFFSET(mw) * 2 \
  1094. X                 : 0)
  1095. #define COLUMN_LABEL_HEIGHT(mw) (mw->matrix.column_labels \
  1096. X                 ? TEXT_HEIGHT_OFFSET(mw) * 2 + \
  1097. X                   mw->matrix.column_label_maxlines * \
  1098. X                   TEXT_HEIGHT(mw) \
  1099. X                 : 0)
  1100. X
  1101. #define FIXED_COLUMN_WIDTH(mw)    mw->matrix.column_positions \
  1102. X                    [mw->matrix.fixed_columns]
  1103. #define COLUMN_LABEL_OFFSET(mw)    (ROW_LABEL_WIDTH(mw) + \
  1104. X                 mw->manager.shadow_thickness)
  1105. #define FIXED_COLUMN_LABEL_OFFSET(mw) (COLUMN_LABEL_OFFSET(mw) + \
  1106. X                       FIXED_COLUMN_WIDTH(mw))
  1107. X
  1108. #define FIXED_ROW_HEIGHT(mw)    (mw->matrix.fixed_rows * ROW_HEIGHT(mw))
  1109. #define ROW_LABEL_OFFSET(mw)    (COLUMN_LABEL_HEIGHT(mw) + \
  1110. X                 mw->manager.shadow_thickness)
  1111. #define FIXED_ROW_LABEL_OFFSET(mw) (ROW_LABEL_OFFSET(mw) + \
  1112. X                    FIXED_ROW_HEIGHT(mw))
  1113. X
  1114. #define CELL_TOTAL_WIDTH(mw)    mw->matrix.cell_total_width
  1115. #define CELL_TOTAL_HEIGHT(mw)    ((mw->matrix.rows - \
  1116. X                  (int) mw->matrix.fixed_rows) \
  1117. X                 * ROW_HEIGHT(mw))
  1118. X
  1119. #define VISIBLE_WIDTH(mw)    (ClipChild(mw)->core.width)
  1120. #define VISIBLE_HEIGHT(mw)    (ClipChild(mw)->core.height)
  1121. X
  1122. #define VERT_ORIGIN(mw)        (mw->matrix.top_row)
  1123. #define HORIZ_ORIGIN(mw)    (mw->matrix.horiz_origin)
  1124. X
  1125. #define VSCROLL_WIDTH(mw)    (VertScrollChild(mw)->core.width + \
  1126. X                 2 * VertScrollChild(mw)->core.border_width +\
  1127. X                 mw->matrix.space)
  1128. #define VSCROLL_HEIGHT(mw)    (VertScrollChild(mw)->core.height + \
  1129. X                 2 * VertScrollChild(mw)->core.border_width)
  1130. #define HSCROLL_WIDTH(mw)    (HorizScrollChild(mw)->core.width + \
  1131. X                 2 * HorizScrollChild(mw)->core.border_width)
  1132. #define HSCROLL_HEIGHT(mw)    (HorizScrollChild(mw)->core.height + \
  1133. X                 2 * HorizScrollChild(mw)->core.border_width+\
  1134. X                 mw->matrix.space)
  1135. X
  1136. #define IS_FIXED(mw, row, column) (row < mw->matrix.fixed_rows || \
  1137. X                   column < mw->matrix.fixed_columns)
  1138. #define CELL_WINDOW(mw, row, column) \
  1139. X    (IS_FIXED(mw, row, column) \
  1140. X     ? XtWindow(mw) \
  1141. X     : XtWindow(ClipChild(mw)))
  1142. X
  1143. /* Inline functions */
  1144. #define FreeColumnWidths(mw)        XtFree((XtPointer) \
  1145. X                           mw->matrix.column_widths)
  1146. #define FreeColumnMaxLengths(mw)    XtFree((XtPointer) \
  1147. X                           mw->matrix.column_max_lengths)
  1148. #define FreeColumnPositions(mw)        XtFree((XtPointer) \
  1149. X                           mw->matrix.column_positions)
  1150. #define FreeColumnAlignments(mw)    XtFree((XtPointer) \
  1151. X                           mw->matrix.column_alignments)
  1152. #define FreeColumnLabelAlignments(mw)    XtFree((XtPointer) \
  1153. X                           mw->matrix.\
  1154. X                           column_label_alignments)
  1155. #define CreateColumnPositions(mw)    (int *) XtMalloc(mw->matrix.columns * \
  1156. X                             sizeof(int))
  1157. #define YtoRow(mw, y)            ((y) / (ROW_HEIGHT(mw)))
  1158. X
  1159. X
  1160. /*
  1161. X * Macros used for Rectangle calculations.  A Rectangle is defined by it's
  1162. X * upper left and lower right corners.
  1163. X */
  1164. X
  1165. /*
  1166. X * Set a Rectangle. (x1,y1) is upper left corner, (x2,y2) is lower right corner
  1167. X */
  1168. #define SETRECT(r, X1, Y1, X2, Y2) { (r).x1 = X1; (r).y1 = Y1; \
  1169. X                     (r).x2 = X2; (r).y2 = Y2; }
  1170. X
  1171. /*
  1172. X * Evaluates to 1 if two Rectangles overlap, 0 if no overlap
  1173. X */
  1174. #define OVERLAP(r1, r2) \
  1175. X    ((r1).x2 > (r2).x1 && \
  1176. X     (r1).x1 < (r2).x2 && \
  1177. X     (r1).y2 > (r2).y1 && \
  1178. X     (r1).y1 < (r2).y2)
  1179. X
  1180. /*
  1181. X * Intersect rectangles r1 and r2, place the result in res.
  1182. X * Result will be in r1's coord system.
  1183. X * Max and Min are defined in Xm/XmP.h.
  1184. X */
  1185. #define X_INTERSECT(r1, r2, res) { (res).x1 = Max((r1).x1, (r2).x1) - (r1).x1;\
  1186. X                   (res).x2 = Min((r1).x2, (r2).x2) - (r1).x1;}
  1187. #define Y_INTERSECT(r1, r2, res) { (res).y1 = Max((r1).y1, (r2).y1) - (r1).y1;\
  1188. X                   (res).y2 = Min((r1).y2, (r2).y2) - (r1).y1;}
  1189. #define INTERSECT(r1, r2, res)    { X_INTERSECT(r1, r2, res); \
  1190. X                      Y_INTERSECT(r1, r2, res); }
  1191. X
  1192. /*
  1193. X * Evaluates to 1 if the point is in the Rectangle, 0 if not
  1194. X */
  1195. #define INBOX(r, x, y) \
  1196. X      ( ( ((r).x2 >= x)) && \
  1197. X    ( ((r).x1 <= x)) && \
  1198. X    ( ((r).y2 >= y)) && \
  1199. X    ( ((r).y1 <= y)) )
  1200. X
  1201. /*
  1202. X * Rectangle struct used for internal calculations.  (x1,y1) are the upper
  1203. X * left corner, (x2,y2) are the lower right.
  1204. X */
  1205. typedef struct _Rectangle {
  1206. X    int x1, y1;
  1207. X    int x2, y2;
  1208. } Rectangle;
  1209. X
  1210. /*
  1211. X * Enumeration for type of a cell
  1212. X */
  1213. typedef enum {FixedCell, NonFixedCell} CellType;
  1214. X
  1215. /*
  1216. X * Declaration of methods
  1217. X */
  1218. static void ClassInitialize();
  1219. static void ClassPartInitialize();
  1220. static void Initialize();
  1221. static void Realize();
  1222. static void InsertChild();
  1223. static void Redisplay();
  1224. static Boolean SetValues();
  1225. static void SetValuesAlmost();
  1226. static void Destroy();
  1227. static void Resize();
  1228. static XtGeometryResult GeometryManager();
  1229. static XtGeometryResult QueryGeometry();
  1230. X
  1231. /*
  1232. X * Redraw function for clip widget
  1233. X */
  1234. static void ClipRedisplay();
  1235. X
  1236. /*
  1237. X * New Matrix methods
  1238. X */
  1239. static void SetCell();
  1240. static void EditCell();
  1241. static void SelectCell();
  1242. static void SelectRow();
  1243. static void SelectColumn();
  1244. static void DeselectAll();
  1245. static void DeselectCell();
  1246. static void DeselectRow();
  1247. static void DeselectColumn();
  1248. static String GetCell();
  1249. static Boolean CommitEdit();
  1250. static void CancelEdit();
  1251. static void AddRows();
  1252. static void DeleteRows();
  1253. static void AddColumns();
  1254. static void DeleteColumns();
  1255. static void SetRowColors();
  1256. static void SetColumnColors();
  1257. static void SetCellColor();
  1258. X
  1259. /*
  1260. X * Private functions unique to Matrix
  1261. X */
  1262. static void CreateDrawGC(), GetInverseGC(),
  1263. X    CreateDrawClipGC(), CreateInverseClipGC(),
  1264. X    CreateTopShadowClipGC(), CreateBottomShadowClipGC(),
  1265. X    SetClipMask(), NewFont(),
  1266. X    GetCellTotalWidth(), GetColumnPositions(),
  1267. X    DrawString(), DrawColumnLabel(), DrawRowLabel(), DrawCell(),
  1268. X    RedrawCells(), RedrawLabelsAndFixed(), ComputeSize(),
  1269. X    FreeCells(), FreeRowLabels(), FreeColumnLabels(), FreeColors(),
  1270. X    FreeSelectedCells(), CreateColors(), CopySelectedCells(),
  1271. X    ResizeCells(), ResizeSelectedCells(), ResizeColors(), RowColToXY(),
  1272. X    AddRowsToTable(), DeleteRowsFromTable(), AddColumnsToTable(),
  1273. X    DeleteColumnsFromTable(), ClearCell(), GetVisibleRows(),
  1274. X    GetVisibleColumns(), GetVisibleCells(),
  1275. X    MakeRowVisible(), MakeColumnVisible(),
  1276. X    MakeCellVisible(), AdjustTopRow();
  1277. static Boolean IsRowVisible(), IsColumnVisible(), IsCellVisible(),
  1278. X    XYToRowCol(), DoCommitEdit(), EventToXY();
  1279. static short MaxRowLabel();
  1280. static int XtoCol();
  1281. static void CopyRowLabels(), CopyColumnLabels(), CopyCells(),
  1282. X    CopyColumnWidths(), CopyColumnMaxLengths(),
  1283. X    CopyColumnAlignments(), CopyColumnLabelAlignments(), CopyColors();
  1284. static void ParseColumnLabel();
  1285. X
  1286. /*
  1287. X * Scrollbar callbacks
  1288. X */
  1289. static void ScrollVertCB(), ScrollHorizCB();
  1290. X
  1291. /*
  1292. X * TextField modifyVerifyCallback
  1293. X */
  1294. static void ModifyVerifyCB();
  1295. X
  1296. /*
  1297. X * Clip widget focusCallback
  1298. X */
  1299. static void TraverseInCB();
  1300. X
  1301. /*
  1302. X * ScrollMgr implementation
  1303. X */
  1304. static SmScrollMgr SmCreateScrollMgr();
  1305. static void SmDestroyScrollMgr(), SmAddScroll(),
  1306. X    SmRemoveScroll(), SmScrollEvent();
  1307. X
  1308. /*
  1309. X * Public convenience functions
  1310. X */
  1311. void XbaeMatrixSetCell();
  1312. void XbaeMatrixEditCell();
  1313. void XbaeMatrixSelectCell();
  1314. void XbaeMatrixSelectRow();
  1315. void XbaeMatrixSelectColumn();
  1316. void XbaeMatrixDeselectAll();
  1317. void XbaeMatrixDeselectCell();
  1318. void XbaeMatrixDeselectRow();
  1319. void XbaeMatrixDeselectColumn();
  1320. String XbaeMatrixGetCell();
  1321. Boolean XbaeMatrixCommitEdit();
  1322. void XbaeMatrixCancelEdit();
  1323. void XbaeMatrixAddRows();
  1324. void XbaeMatrixDeleteRows();
  1325. void XbaeMatrixAddColumns();
  1326. void XbaeMatrixDeleteColumns();
  1327. void XbaeMatrixSetRowColors();
  1328. void XbaeMatrixSetColumnColors();
  1329. void XbaeMatrixSetCellColor();
  1330. X
  1331. /*
  1332. X * Type converters
  1333. X */
  1334. Boolean CvtStringToStringArray();
  1335. void StringArrayDestructor();
  1336. Boolean CvtStringToWidthArray();
  1337. void WidthArrayDestructor();
  1338. Boolean CvtStringToMaxLengthArray();
  1339. void MaxLengthArrayDestructor();
  1340. Boolean StringsAreEqual();
  1341. Boolean CvtStringToAlignmentArray();
  1342. void AlignmentArrayDestructor();
  1343. X
  1344. /*
  1345. X * Actions
  1346. X */
  1347. static void EditCellACT(), CancelEditACT(), CommitEditACT(),
  1348. X    SelectCellACT(), TraverseNextACT(), TraversePrevACT();
  1349. X
  1350. /*
  1351. X * Matrix actions
  1352. X */
  1353. static XtActionsRec actions[] = {
  1354. X    {"EditCell",    EditCellACT},
  1355. X    {"CancelEdit",    CancelEditACT},
  1356. X    {"CommitEdit",    CommitEditACT},
  1357. X    {"SelectCell",    SelectCellACT},
  1358. X    {"TraverseNext",    TraverseNextACT},
  1359. X    {"TraversePrev",    TraversePrevACT},
  1360. };
  1361. X
  1362. X
  1363. XXbaeMatrixClassRec xbaeMatrixClassRec = {
  1364. X    {
  1365. X    /* core_class fields */
  1366. X    /* superclass            */ (WidgetClass) &xmManagerClassRec,
  1367. X    /* class_name            */ "XbaeMatrix",
  1368. X    /* widget_size            */ sizeof(XbaeMatrixRec),
  1369. X    /* class_initialize        */ ClassInitialize,
  1370. X    /* class_part_initialize    */ ClassPartInitialize,
  1371. X    /* class_inited            */ False,
  1372. X    /* initialize            */ Initialize,
  1373. X    /* initialize_hook        */ NULL,
  1374. X    /* realize            */ Realize,
  1375. X    /* actions            */ actions,
  1376. X    /* num_actions            */ XtNumber(actions),
  1377. X    /* resources            */ resources,
  1378. X    /* num_resources        */ XtNumber(resources),
  1379. X    /* xrm_class            */ NULLQUARK,
  1380. X    /* compress_motion        */ True,
  1381. X    /* compress_exposure        */ XtExposeCompressSeries |
  1382. X                        XtExposeGraphicsExpose |
  1383. X                            XtExposeNoExpose,
  1384. X    /* compress_enterleave        */ True,
  1385. X    /* visible_interest        */ False,
  1386. X    /* destroy            */ Destroy,
  1387. X    /* resize            */ Resize,
  1388. X    /* expose            */ Redisplay,
  1389. X    /* set_values            */ SetValues,
  1390. X    /* set_values_hook        */ NULL,
  1391. X    /* set_values_almost        */ SetValuesAlmost,
  1392. X    /* get_values_hook        */ NULL,
  1393. X    /* accept_focus            */ NULL,
  1394. X    /* version            */ XtVersion,
  1395. X    /* callback_private        */ NULL,
  1396. X    /* tm_table            */ defaultTranslations,
  1397. X    /* query_geometry        */ QueryGeometry,
  1398. X    /* display_accelerator        */ NULL,
  1399. X    /* extension            */ NULL
  1400. X    },
  1401. X
  1402. /*
  1403. X * XXX I should be able to use XtInheritGeometryManager &
  1404. X * XtInheritChangeManaged but Composite defines these as NULL.
  1405. X * (Xt seems to allow change_managed to be NULL)
  1406. X */
  1407. X    {
  1408. X    /* composite_class fields */
  1409. X    /* geometry_manager        */ GeometryManager,
  1410. X    /* change_managed        */ NULL,
  1411. X    /* insert_child            */ InsertChild,
  1412. X    /* delete_child            */ XtInheritDeleteChild,
  1413. X    /* extension            */ NULL,
  1414. X    },
  1415. X    {
  1416. X    /* constraint_class fields */
  1417. X    /* resources            */ NULL,
  1418. X    /* num_resources        */ 0,
  1419. X    /* constraint_size        */ 0,
  1420. X    /* initialize            */ NULL,
  1421. X    /* destroy            */ NULL,
  1422. X    /* set_values            */ NULL,
  1423. X    /* extension            */ NULL
  1424. X    },
  1425. X    {
  1426. X    /* manager_class fields */
  1427. X    /* translations            */  XtInheritTranslations,
  1428. X    /* syn_resources        */  syn_resources,
  1429. X    /* num_syn_resources        */  XtNumber(syn_resources),
  1430. X    /* syn_constraint_resources    */  NULL,
  1431. X    /* num_syn_constraint_resources */  0,
  1432. X    /* parent_process        */  XmInheritParentProcess,
  1433. X    /* extension            */  NULL
  1434. X    },
  1435. X    {
  1436. X    /* matrix_class fields */
  1437. X    /* set_cell            */ SetCell,
  1438. X    /* get_cell            */ GetCell,
  1439. X    /* edit_cell            */ EditCell,
  1440. X    /* select_cell            */ SelectCell,
  1441. X    /* select_row            */ SelectRow,
  1442. X    /* select_column        */ SelectColumn,
  1443. X    /* deselect_all            */ DeselectAll,
  1444. X    /* deselect_cell        */ DeselectCell,
  1445. X    /* deselect_row            */ DeselectRow,
  1446. X    /* deselect_column        */ DeselectColumn,
  1447. X    /* commit_edit            */ CommitEdit,
  1448. X    /* cancel_edit            */ CancelEdit,
  1449. X    /* add_rows            */ AddRows,
  1450. X    /* delete_rows            */ DeleteRows,
  1451. X    /* add_columns            */ AddColumns,
  1452. X    /* delete_columns        */ DeleteColumns,
  1453. X    /* set_row_colors        */ SetRowColors,
  1454. X    /* set_column_colors        */ SetColumnColors,
  1455. X    /* set_cell_color        */ SetCellColor,
  1456. X    /* extension            */ NULL,
  1457. X    }
  1458. };
  1459. X
  1460. WidgetClass xbaeMatrixWidgetClass = (WidgetClass)&xbaeMatrixClassRec;
  1461. X
  1462. X
  1463. static void
  1464. ClassInitialize()
  1465. {
  1466. X    /*
  1467. X     * String to StringArray is used for XmNrowLabels and XmNcolumnLabels
  1468. X     * We make a private copy of this table, should we cache? XXX
  1469. X     */
  1470. X    XtSetTypeConverter(XmRString, XmRStringArray,
  1471. X               CvtStringToStringArray, NULL, 0,
  1472. X               XtCacheAll | XtCacheRefCount,
  1473. X               StringArrayDestructor);
  1474. X
  1475. X    /*
  1476. X     * String to ShortArray is used for XmNcolumnWidths resource.
  1477. X     * We make a private copy of this table, should we cache? XXX
  1478. X     */
  1479. X    XtSetTypeConverter(XmRString, XmRWidthArray,
  1480. X               CvtStringToWidthArray, NULL, 0,
  1481. X               XtCacheAll | XtCacheRefCount,
  1482. X               WidthArrayDestructor);
  1483. X
  1484. X    /*
  1485. X     * String to IntArray is used for XmNcolumnMaxLengths resource.
  1486. X     * We make a private copy of this table, should we cache? XXX
  1487. X     */
  1488. X    XtSetTypeConverter(XmRString, XmRMaxLengthArray,
  1489. X               CvtStringToMaxLengthArray, NULL, 0,
  1490. X               XtCacheAll | XtCacheRefCount,
  1491. X               MaxLengthArrayDestructor);
  1492. X
  1493. X    /*
  1494. X     * String to AlignmentArray is used for XmNcolumnAlignments
  1495. X     * and XmNcolumnLabelAlignments resources.
  1496. X     */
  1497. X    XtSetTypeConverter(XmRString, XmRAlignmentArray,
  1498. X               CvtStringToAlignmentArray, NULL, 0,
  1499. X               XtCacheAll | XtCacheRefCount,
  1500. X               AlignmentArrayDestructor);
  1501. }
  1502. X
  1503. static void
  1504. ClassPartInitialize(mwc)
  1505. XXbaeMatrixWidgetClass mwc;
  1506. {
  1507. X    register XbaeMatrixWidgetClass super =
  1508. X    (XbaeMatrixWidgetClass) mwc->core_class.superclass;
  1509. X
  1510. X    /*
  1511. X     * Allow subclasses to inherit new Matrix methods
  1512. X     */
  1513. X    if (mwc->matrix_class.set_cell == XbaeInheritSetCell)
  1514. X    mwc->matrix_class.set_cell = super->matrix_class.set_cell;
  1515. X    if (mwc->matrix_class.get_cell == XbaeInheritGetCell)
  1516. X    mwc->matrix_class.get_cell = super->matrix_class.get_cell;
  1517. X    if (mwc->matrix_class.edit_cell == XbaeInheritEditCell)
  1518. X    mwc->matrix_class.edit_cell = super->matrix_class.edit_cell;
  1519. X    if (mwc->matrix_class.select_cell == XbaeInheritSelectCell)
  1520. X    mwc->matrix_class.select_cell = super->matrix_class.select_cell;
  1521. X    if (mwc->matrix_class.select_row == XbaeInheritSelectRow)
  1522. X    mwc->matrix_class.select_row = super->matrix_class.select_row;
  1523. X    if (mwc->matrix_class.select_column == XbaeInheritSelectColumn)
  1524. X    mwc->matrix_class.select_column = super->matrix_class.select_column;
  1525. X    if (mwc->matrix_class.deselect_all == XbaeInheritDeselectAll)
  1526. X    mwc->matrix_class.deselect_all = super->matrix_class.deselect_all;
  1527. X    if (mwc->matrix_class.deselect_cell == XbaeInheritDeselectCell)
  1528. X    mwc->matrix_class.deselect_cell = super->matrix_class.deselect_cell;
  1529. X    if (mwc->matrix_class.deselect_row == XbaeInheritDeselectRow)
  1530. X    mwc->matrix_class.deselect_row = super->matrix_class.deselect_row;
  1531. X    if (mwc->matrix_class.deselect_column == XbaeInheritDeselectColumn)
  1532. X    mwc->matrix_class.deselect_column =
  1533. X        super->matrix_class.deselect_column;
  1534. X    if (mwc->matrix_class.commit_edit == XbaeInheritCommitEdit)
  1535. X    mwc->matrix_class.commit_edit = super->matrix_class.commit_edit;
  1536. X    if (mwc->matrix_class.cancel_edit == XbaeInheritCancelEdit)
  1537. X    mwc->matrix_class.cancel_edit = super->matrix_class.cancel_edit;
  1538. X    if (mwc->matrix_class.add_rows == XbaeInheritAddRows)
  1539. X    mwc->matrix_class.add_rows = super->matrix_class.add_rows;
  1540. X    if (mwc->matrix_class.delete_rows == XbaeInheritDeleteRows)
  1541. X    mwc->matrix_class.delete_rows = super->matrix_class.delete_rows;
  1542. X    if (mwc->matrix_class.add_columns == XbaeInheritAddColumns)
  1543. X    mwc->matrix_class.add_columns = super->matrix_class.add_columns;
  1544. X    if (mwc->matrix_class.delete_columns == XbaeInheritDeleteColumns)
  1545. X    mwc->matrix_class.delete_columns = super->matrix_class.delete_columns;
  1546. X    if (mwc->matrix_class.set_row_colors == XbaeInheritSetRowColors)
  1547. X    mwc->matrix_class.set_row_colors = super->matrix_class.set_row_colors;
  1548. X    if (mwc->matrix_class.set_column_colors == XbaeInheritSetColumnColors)
  1549. X    mwc->matrix_class.set_column_colors =
  1550. X        super->matrix_class.set_column_colors;
  1551. X    if (mwc->matrix_class.set_cell_color == XbaeInheritSetCellColor)
  1552. X    mwc->matrix_class.set_cell_color = super->matrix_class.set_cell_color;
  1553. }
  1554. X
  1555. static void
  1556. CreateDrawGC(mw)
  1557. XXbaeMatrixWidget mw;
  1558. {
  1559. X    XGCValues values;
  1560. X    unsigned long mask = GCForeground | GCFont;
  1561. X
  1562. X    /*
  1563. X     * GC for drawing cells/labels. We create it instead of using a cached one,
  1564. X     * since the foreground may change frequently.
  1565. X     */
  1566. X    values.foreground = mw->manager.foreground;
  1567. X    values.font = mw->matrix.font->fid;
  1568. X    mw->matrix.draw_gc = XCreateGC(XtDisplay(mw),
  1569. X                   RootWindowOfScreen(XtScreen(mw)),
  1570. X                   mask, &values);
  1571. }
  1572. X
  1573. static void
  1574. GetInverseGC(mw)
  1575. XXbaeMatrixWidget mw;
  1576. {
  1577. X    XGCValues values;
  1578. X    XtGCMask mask = GCForeground | GCFont;
  1579. X
  1580. X    /*
  1581. X     * GC for drawing selected cells.
  1582. X     */
  1583. X    values.foreground = mw->core.background_pixel;
  1584. X    values.font = mw->matrix.font->fid;
  1585. X    mw->matrix.inverse_gc = XtGetGC((Widget)mw, mask, &values);
  1586. }
  1587. X
  1588. static void
  1589. CreateDrawClipGC(mw)
  1590. XXbaeMatrixWidget mw;
  1591. {
  1592. X    XGCValues values;
  1593. X    unsigned long mask = GCForeground | GCFont;
  1594. X
  1595. X    /*
  1596. X     * GC for drawing cells/labels with clipping.
  1597. X     */
  1598. X    values.foreground = mw->manager.foreground;
  1599. X    values.font = mw->matrix.font->fid;
  1600. X    mw->matrix.draw_clip_gc = XCreateGC(XtDisplay(mw),
  1601. X                    RootWindowOfScreen(XtScreen(mw)),
  1602. X                    mask, &values);
  1603. }
  1604. X
  1605. static void
  1606. CreateInverseClipGC(mw)
  1607. XXbaeMatrixWidget mw;
  1608. {
  1609. X    XGCValues values;
  1610. X    XtGCMask mask = GCForeground | GCFont;
  1611. X
  1612. X    /*
  1613. X     * GC for drawing selected cells with clipping.
  1614. X     */
  1615. X    values.foreground = mw->core.background_pixel;
  1616. X    values.font = mw->matrix.font->fid;
  1617. X
  1618. X    mw->matrix.inverse_clip_gc = XCreateGC(XtDisplay(mw),
  1619. X                       RootWindowOfScreen(XtScreen(mw)),
  1620. X                       mask, &values);
  1621. }
  1622. X
  1623. static void
  1624. CreateTopShadowClipGC(mw)
  1625. XXbaeMatrixWidget mw;
  1626. {
  1627. X    XGCValues values;
  1628. X    XtGCMask mask = GCForeground | GCBackground;
  1629. X
  1630. X    /*
  1631. X     * GC for drawing top shadow inside cells with clipping.
  1632. SHAR_EOF
  1633. true || echo 'restore of Xbae/src/Matrix.c failed'
  1634. fi
  1635. echo 'End of Xbae part 5'
  1636. echo 'File Xbae/src/Matrix.c is continued in part 6'
  1637. echo 6 > _shar_seq_.tmp
  1638. exit 0
  1639. -- 
  1640. --
  1641. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  1642. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  1643. Sunnyvale, California 94086            at&t: 408/522-9236
  1644.