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

  1. Newsgroups: comp.sources.x
  2. Path: uunet!zaphod.mps.ohio-state.edu!mips!msi!dcmartin
  3. From: Andrew Wason <aw@bae.bellcore.com>
  4. Subject: v17i038: Xbae widgets (MOTIF), Part11/12
  5. Message-ID: <1992Mar23.180429.16399@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:04:29 GMT
  11. Approved: dcmartin@msi.com
  12.  
  13. Submitted-by: Andrew Wason <aw@bae.bellcore.com>
  14. Posting-number: Volume 17, Issue 38
  15. Archive-name: xbae/part11
  16.  
  17. ---- Cut Here and feed the following to sh ----
  18. #!/bin/sh
  19. # this is Xbae.shar.11 (part 11 of Xbae)
  20. # do not concatenate these parts, unpack them in order with /bin/sh
  21. # file Xbae/examples/caption/caption.c continued
  22. #
  23. if test ! -r _shar_seq_.tmp; then
  24.     echo 'Please unpack part 1 first!'
  25.     exit 1
  26. fi
  27. (read Scheck
  28.  if test "$Scheck" != 11; then
  29.     echo Please unpack part "$Scheck" next!
  30.     exit 1
  31.  else
  32.     exit 0
  33.  fi
  34. ) < _shar_seq_.tmp || exit 1
  35. if test ! -f _shar_wnt_.tmp; then
  36.     echo 'x - still skipping Xbae/examples/caption/caption.c'
  37. else
  38. echo 'x - continuing file Xbae/examples/caption/caption.c'
  39. sed 's/^X//' << 'SHAR_EOF' >> 'Xbae/examples/caption/caption.c' &&
  40. X
  41. main(argc, argv)
  42. int argc;
  43. char *argv[];
  44. {
  45. X    Widget toplevel, rc, button;
  46. X    XtAppContext app;
  47. X
  48. X    toplevel = XtVaAppInitialize(&app, "Caption",
  49. X                 NULL, 0,
  50. X                 &argc, argv,
  51. X                 NULL,
  52. X                 NULL);
  53. X
  54. X    rc = XtVaCreateManagedWidget("rc",
  55. X                 xmRowColumnWidgetClass, toplevel,
  56. X                 NULL);
  57. X
  58. X    button = XtVaCreateManagedWidget("button1",
  59. X                     xmPushButtonWidgetClass, rc,
  60. X                     NULL);
  61. X    XtAddCallback(button, XmNactivateCallback, popupCaptionTextF,
  62. X          (XtPointer)"caption1");
  63. X    button = XtVaCreateManagedWidget("button2",
  64. X                     xmPushButtonWidgetClass, rc,
  65. X                     NULL);
  66. X    XtAddCallback(button, XmNactivateCallback, popupCaptionFrame,
  67. X          (XtPointer)"caption2");
  68. X    button = XtVaCreateManagedWidget("button3",
  69. X                     xmPushButtonWidgetClass, rc,
  70. X                     NULL);
  71. X    XtAddCallback(button, XmNactivateCallback, popupCaptionFrame,
  72. X          (XtPointer)"caption3");
  73. X    button = XtVaCreateManagedWidget("button4",
  74. X                     xmPushButtonWidgetClass, rc,
  75. X                     NULL);
  76. X    XtAddCallback(button, XmNactivateCallback, popupCaptionTextF,
  77. X          (XtPointer)"caption4");
  78. X    button = XtVaCreateManagedWidget("button5",
  79. X                     xmPushButtonWidgetClass, rc,
  80. X                     NULL);
  81. X    XtAddCallback(button, XmNactivateCallback, popupCaptionToggle, NULL);
  82. X    
  83. X    XtRealizeWidget(toplevel);
  84. X    XtAppMainLoop(app);
  85. }
  86. X
  87. /* ARGSUSED */
  88. void
  89. popupCaptionTextF(w, name, call_data)
  90. Widget w;
  91. String name;
  92. XXtPointer call_data;
  93. {
  94. X    Widget shell, cw;
  95. X
  96. X    shell = XtCreatePopupShell(name,
  97. X                   xmDialogShellWidgetClass, w,
  98. X                   NULL, 0);
  99. X    
  100. X    cw = XtCreateWidget("cw",
  101. X            xbaeCaptionWidgetClass, shell,
  102. X            NULL, 0);
  103. X
  104. X    XtVaCreateManagedWidget("text",
  105. X                xmTextFieldWidgetClass, cw,
  106. X                NULL);
  107. X
  108. X    XtManageChild(cw);
  109. }
  110. X
  111. /* ARGSUSED */
  112. void
  113. popupCaptionFrame(w, name, call_data)
  114. Widget w;
  115. String name;
  116. XXtPointer call_data;
  117. {
  118. X    Widget shell, form, cw, frame, rc;
  119. X    int i;
  120. X
  121. X    shell = XtCreatePopupShell(name,
  122. X                   xmDialogShellWidgetClass, w,
  123. X                   NULL, 0);
  124. X
  125. X    form = XtCreateWidget("form",
  126. X              xmFormWidgetClass, shell,
  127. X              NULL, 0);
  128. X    cw = XtVaCreateManagedWidget("cw",
  129. X                 xbaeCaptionWidgetClass, form,
  130. X                 NULL);
  131. X    frame = XtVaCreateManagedWidget("frame",
  132. X                    xmFrameWidgetClass, cw,
  133. X                    NULL);
  134. X    rc = XtVaCreateManagedWidget("rc",
  135. X                 xmRowColumnWidgetClass, frame,
  136. X                 NULL);
  137. X    for (i = 0; i < 3; i++)
  138. X    XtVaCreateManagedWidget("button",
  139. X                xmPushButtonWidgetClass, rc,
  140. X                NULL);
  141. X
  142. X    XtManageChild(form);
  143. }
  144. X
  145. /* ARGSUSED */
  146. void
  147. popupCaptionToggle(w, client_data, call_data)
  148. Widget w;
  149. XXtPointer client_data;
  150. XXtPointer call_data;
  151. {
  152. X    Widget shell, form, cw, frame, rc;
  153. X    int i;
  154. X
  155. X    shell = XtCreatePopupShell("caption5",
  156. X                   xmDialogShellWidgetClass, w,
  157. X                   NULL, 0);
  158. X
  159. X    form = XtCreateWidget("form",
  160. X                   xmFormWidgetClass, shell,
  161. X                   NULL, 0);
  162. X
  163. X    cw = XtVaCreateManagedWidget("cw1",
  164. X                 xbaeCaptionWidgetClass, form,
  165. X                 NULL);
  166. X    frame = XtVaCreateManagedWidget("frame",
  167. X                    xmFrameWidgetClass, cw,
  168. X                    NULL);
  169. X    rc = XmCreateRadioBox(frame, "rc", NULL, 0);
  170. X    XtManageChild(rc);
  171. X
  172. X    for (i = 0; i < 4; i++)
  173. X    XtVaCreateManagedWidget("button",
  174. X                xmToggleButtonWidgetClass, rc,
  175. X                NULL);
  176. X
  177. X
  178. X    cw = XtVaCreateManagedWidget("cw2",
  179. X                 xbaeCaptionWidgetClass, form,
  180. X                 NULL);
  181. X    frame = XtVaCreateManagedWidget("frame",
  182. X                    xmFrameWidgetClass, cw,
  183. X                    NULL);
  184. X    rc = XmCreateRadioBox(frame, "rc", NULL, 0);
  185. X    XtManageChild(rc);
  186. X
  187. X    for (i = 0; i < 4; i++)
  188. X    XtVaCreateManagedWidget("button",
  189. X                xmToggleButtonWidgetClass, rc,
  190. X                NULL);
  191. X
  192. X    XtManageChild(form);
  193. }
  194. X
  195. SHAR_EOF
  196. echo 'File Xbae/examples/caption/caption.c is complete' &&
  197. chmod 0644 Xbae/examples/caption/caption.c ||
  198. echo 'restore of Xbae/examples/caption/caption.c failed'
  199. Wc_c="`wc -c < 'Xbae/examples/caption/caption.c'`"
  200. test 4981 -eq "$Wc_c" ||
  201.     echo 'Xbae/examples/caption/caption.c: original size 4981, current size' "$Wc_c"
  202. rm -f _shar_wnt_.tmp
  203. fi
  204. # ============= Xbae/examples/caption/Imakefile ==============
  205. if test -f 'Xbae/examples/caption/Imakefile' -a X"$1" != X"-c"; then
  206.     echo 'x - skipping Xbae/examples/caption/Imakefile (File already exists)'
  207.     rm -f _shar_wnt_.tmp
  208. else
  209. > _shar_wnt_.tmp
  210. echo 'x - extracting Xbae/examples/caption/Imakefile (Text)'
  211. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/caption/Imakefile' &&
  212. #include "../../Xbae.tmpl"
  213. X
  214. X   LOCAL_LDFLAGS = -L../../src
  215. X LOCAL_LIBRARIES = -lXbae -lXm -lXt -lX11
  216. X         DEPLIBS =
  217. X        INCLUDES = -I../../src
  218. X         DEFINES = -D_NO_PROTO
  219. X
  220. UninstalledSimpleProgramTarget(caption)
  221. SHAR_EOF
  222. chmod 0644 Xbae/examples/caption/Imakefile ||
  223. echo 'restore of Xbae/examples/caption/Imakefile failed'
  224. Wc_c="`wc -c < 'Xbae/examples/caption/Imakefile'`"
  225. test 223 -eq "$Wc_c" ||
  226.     echo 'Xbae/examples/caption/Imakefile: original size 223, current size' "$Wc_c"
  227. rm -f _shar_wnt_.tmp
  228. fi
  229. # ============= Xbae/examples/colors/Colors.ad ==============
  230. if test ! -d 'Xbae/examples/colors'; then
  231.     echo 'x - creating directory Xbae/examples/colors'
  232.     mkdir 'Xbae/examples/colors'
  233. fi
  234. if test -f 'Xbae/examples/colors/Colors.ad' -a X"$1" != X"-c"; then
  235.     echo 'x - skipping Xbae/examples/colors/Colors.ad (File already exists)'
  236.     rm -f _shar_wnt_.tmp
  237. else
  238. > _shar_wnt_.tmp
  239. echo 'x - extracting Xbae/examples/colors/Colors.ad (Text)'
  240. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/colors/Colors.ad' &&
  241. *mw.rows:        7
  242. *mw.columns:        5
  243. *mw.columnWidths:    10, 10, 10, 10, 10
  244. *mw.columnLabels:    Color0, Color1, Color2, Color3, Color4
  245. *mw.rowLabels:        Color0, Color1, Color2, Color3, Color4, Color5, Color6
  246. X
  247. *menu*cell.labelString:        Cell Orientation
  248. *menu*row.labelString:        Row Orientation
  249. *menu*column.labelString:    Column Orientation
  250. *reset.labelString:        Reset
  251. SHAR_EOF
  252. chmod 0644 Xbae/examples/colors/Colors.ad ||
  253. echo 'restore of Xbae/examples/colors/Colors.ad failed'
  254. Wc_c="`wc -c < 'Xbae/examples/colors/Colors.ad'`"
  255. test 349 -eq "$Wc_c" ||
  256.     echo 'Xbae/examples/colors/Colors.ad: original size 349, current size' "$Wc_c"
  257. rm -f _shar_wnt_.tmp
  258. fi
  259. # ============= Xbae/examples/colors/colors.c ==============
  260. if test -f 'Xbae/examples/colors/colors.c' -a X"$1" != X"-c"; then
  261.     echo 'x - skipping Xbae/examples/colors/colors.c (File already exists)'
  262.     rm -f _shar_wnt_.tmp
  263. else
  264. > _shar_wnt_.tmp
  265. echo 'x - extracting Xbae/examples/colors/colors.c (Text)'
  266. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/colors/colors.c' &&
  267. /*
  268. X * Copyright(c) 1992 Bell Communications Research, Inc. (Bellcore)
  269. X *                        All rights reserved
  270. X * Permission to use, copy, modify and distribute this material for
  271. X * any purpose and without fee is hereby granted, provided that the
  272. X * above copyright notice and this permission notice appear in all
  273. X * copies, and that the name of Bellcore not be used in advertising
  274. X * or publicity pertaining to this material without the specific,
  275. X * prior written permission of an authorized representative of
  276. X * Bellcore.
  277. X *
  278. X * BELLCORE MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, EX-
  279. X * PRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT
  280. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  281. X * FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST IN-
  282. X * FRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS.  THE
  283. X * SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL BELLCORE OR
  284. X * ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY
  285. X * LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELAT-
  286. X * ING TO THE SOFTWARE.
  287. X */
  288. X
  289. #include <stdio.h>
  290. #include <X11/StringDefs.h>
  291. #include <Xm/Form.h>
  292. #include <Xm/RowColumn.h>
  293. #include <Xm/Label.h>
  294. #include <Xm/PushB.h>
  295. #include <Xbae/Matrix.h>
  296. X
  297. /*
  298. X * Interactively set row, column and cell colors.
  299. X * Consists of an option menu to select row, column or cell orientation.
  300. X * Then when a color name is entered in a cell, that row, column or cell
  301. X * (depending on the orientation) is set to the color entered.
  302. X */
  303. X
  304. void SetColorCB();
  305. void RowOrientationCB();
  306. void ColumnOrientationCB();
  307. void CellOrientationCB();
  308. void ResetCB();
  309. void LoadMatrix();
  310. X
  311. typedef enum {
  312. X    CellOrientation,
  313. X    RowOrientation,
  314. X    ColumnOrientation
  315. } ColorOrientation;
  316. typedef struct {
  317. X    Widget matrix;
  318. X    ColorOrientation orientation;
  319. } ColorDataRec, *ColorData;
  320. X
  321. main(argc, argv)
  322. int argc;
  323. char *argv[];
  324. {
  325. X    Widget toplevel, form, menu, row, column, cell, reset, option;
  326. X    XtAppContext app;
  327. X    ColorDataRec colorData;
  328. X    Arg args[2];
  329. X    int n;
  330. X
  331. X    toplevel = XtVaAppInitialize(&app, "Colors",
  332. X                 NULL, 0,
  333. X                 &argc, argv,
  334. X                 NULL,
  335. X                 NULL);
  336. X
  337. X    /*
  338. X     * Create a Form to hold everything
  339. X     */
  340. X    form = XtCreateManagedWidget("form",
  341. X                                 xmFormWidgetClass,     toplevel,
  342. X                                 NULL, 0);
  343. X
  344. X    /*
  345. X     * Create a menu for use in an OptionMenu
  346. X     */
  347. X    menu = XmCreatePulldownMenu(form, "menu", NULL, 0);
  348. X
  349. X    /*
  350. X     * Create a menu button to select cell orientation
  351. X     */
  352. X    cell = XtVaCreateManagedWidget("cell",
  353. X                   xmPushButtonWidgetClass,    menu,
  354. X                   NULL);
  355. X    XtAddCallback(cell, XmNactivateCallback, CellOrientationCB,
  356. X          (XtPointer)&colorData);
  357. X
  358. X    /*
  359. X     * Create a menu button to select row orientation
  360. X     */
  361. X    row = XtVaCreateManagedWidget("row",
  362. X                  xmPushButtonWidgetClass,    menu,
  363. X                  NULL);
  364. X    XtAddCallback(row, XmNactivateCallback, RowOrientationCB,
  365. X          (XtPointer)&colorData);
  366. X
  367. X    /*
  368. X     * Create a menu button to select column orientation
  369. X     */
  370. X    column = XtVaCreateManagedWidget("column",
  371. X                     xmPushButtonWidgetClass,   menu,
  372. X                     NULL);
  373. X    XtAddCallback(column, XmNactivateCallback, ColumnOrientationCB,
  374. X          (XtPointer)&colorData);
  375. X
  376. X    /*
  377. X     * Setup and create the option menu
  378. X     */
  379. X    n = 0;
  380. X    XtSetArg(args[n], XmNsubMenuId, menu);        n++;
  381. X    XtSetArg(args[n], XmNmenuHistory, cell);        n++;
  382. X    option = XmCreateOptionMenu(form, "option", args, n);
  383. X    XtManageChild(option);
  384. X
  385. X
  386. X    colorData.orientation = CellOrientation;
  387. X
  388. X    /*
  389. X     * Create a Matrix widget.  Add a callback to get the color entered
  390. X     * in a cell.
  391. X     */
  392. X    colorData.matrix =
  393. X    XtVaCreateManagedWidget("mw",
  394. X                xbaeMatrixWidgetClass,    form,
  395. X                XmNtopAttachment,    XmATTACH_WIDGET,
  396. X                XmNtopWidget,        option,
  397. X                XmNleftAttachment,    XmATTACH_FORM,
  398. X                XmNrightAttachment,    XmATTACH_FORM,
  399. X                XmNbottomAttachment,    XmATTACH_FORM,
  400. X                NULL);
  401. X    XtAddCallback(colorData.matrix, XmNleaveCellCallback, SetColorCB,
  402. X          (XtPointer)&colorData);
  403. X
  404. X    /*
  405. X     * Create a button to reset XmNcolors
  406. X     */
  407. X    reset = XtVaCreateManagedWidget("reset",
  408. X                    xmPushButtonWidgetClass, form,
  409. X                    XmNleftAttachment, XmATTACH_WIDGET,
  410. X                    XmNleftWidget, option,
  411. X                    NULL);
  412. X    XtAddCallback(reset, XmNactivateCallback, ResetCB,
  413. X          (XtPointer)colorData.matrix);
  414. X
  415. X
  416. X    /*
  417. X     * Load the matrix with default values
  418. X     */
  419. X    LoadMatrix(colorData.matrix);
  420. X
  421. X    XtRealizeWidget(toplevel);
  422. X    XtAppMainLoop(app);
  423. }
  424. X
  425. /* ARGSUSED */
  426. void
  427. CellOrientationCB(w, colorData, call_data)
  428. Widget w;
  429. ColorData colorData;
  430. XXtPointer call_data;
  431. {
  432. X    colorData->orientation = CellOrientation;
  433. }
  434. X
  435. /* ARGSUSED */
  436. void
  437. RowOrientationCB(w, colorData, call_data)
  438. Widget w;
  439. ColorData colorData;
  440. XXtPointer call_data;
  441. {
  442. X    colorData->orientation = RowOrientation;
  443. }
  444. X
  445. /* ARGSUSED */
  446. void
  447. ColumnOrientationCB(w, colorData, call_data)
  448. Widget w;
  449. ColorData colorData;
  450. XXtPointer call_data;
  451. {
  452. X    colorData->orientation = ColumnOrientation;
  453. }
  454. X
  455. /* ARGSUSED */
  456. void
  457. SetColorCB(w, colorData, call_data)
  458. Widget w;
  459. ColorData colorData;
  460. XXbaeMatrixLeaveCellCallbackStruct *call_data;
  461. {
  462. X    XrmValue fromVal, toVal;
  463. X    Pixel color;
  464. X
  465. X    /*
  466. X     * If the color is "X" or "Z", ignore it since that is what we load
  467. X     * the matrix with
  468. X     */
  469. X    if (call_data->value[0] == 'X' || call_data->value[0] == 'Z')
  470. X    return;
  471. X
  472. X    /*
  473. X     * Attempt to convert the string in this cell to a Pixel
  474. X     */
  475. X    fromVal.size = strlen(call_data->value) + 1;
  476. X    fromVal.addr = call_data->value;
  477. X    toVal.size = sizeof(Pixel);
  478. X    toVal.addr = (caddr_t) &color;
  479. X    if (!XtConvertAndStore(w, XtRString, &fromVal, XtRPixel, &toVal))
  480. X    return;
  481. X
  482. X    /*
  483. X     * Set the current row/column to the specified color based on our
  484. X     * current orientation.
  485. X     */
  486. X    switch (colorData->orientation) {
  487. X    case CellOrientation:
  488. X    XbaeMatrixSetCellColor(colorData->matrix,
  489. X                   call_data->row, call_data->column, color);
  490. X    break;
  491. X    case RowOrientation:
  492. X    XbaeMatrixSetRowColors(colorData->matrix, call_data->row, &color, 1);
  493. X    break;
  494. X    case ColumnOrientation:
  495. X    XbaeMatrixSetColumnColors(colorData->matrix, call_data->column,
  496. X                  &color, 1);
  497. X    break;
  498. X    }
  499. }
  500. X
  501. /* ARGSUSED */
  502. void
  503. ResetCB(w, matrix, client_data)
  504. Widget w;
  505. Widget matrix;
  506. XXtPointer client_data;
  507. {
  508. X    XtVaSetValues(matrix,
  509. X          XmNcolors, NULL,
  510. X          NULL);
  511. X    LoadMatrix(matrix);
  512. }
  513. X
  514. void
  515. LoadMatrix(w)
  516. Widget w;
  517. {
  518. X    int rows, columns;
  519. X    int i, j;
  520. X    String *rowArrays, **cells;
  521. X
  522. X    XtVaGetValues(w,
  523. X          XmNrows,    &rows,
  524. X          XmNcolumns,    &columns,
  525. X          NULL);
  526. X
  527. X    cells = (String **)XtMalloc(rows * sizeof(String *));
  528. X    rowArrays = (String *)XtMalloc(rows * columns * sizeof(String));
  529. X
  530. X    for (i = 0; i < rows; i++) {
  531. X    cells[i] = &rowArrays[i * columns];
  532. X    if (i % 2)
  533. X        for (j = 0; j < columns; j++)
  534. X        rowArrays[i * columns + j] = "X";
  535. X    else
  536. X        for (j = 0; j < columns; j++)
  537. X        rowArrays[i * columns + j] = "Z";
  538. X    }
  539. X
  540. X    XtVaSetValues(w,
  541. X          XmNcells,    cells,
  542. X          NULL);
  543. X
  544. X    XtFree((XtPointer) rowArrays);
  545. X    XtFree((XtPointer) cells);
  546. }
  547. X
  548. SHAR_EOF
  549. chmod 0644 Xbae/examples/colors/colors.c ||
  550. echo 'restore of Xbae/examples/colors/colors.c failed'
  551. Wc_c="`wc -c < 'Xbae/examples/colors/colors.c'`"
  552. test 7063 -eq "$Wc_c" ||
  553.     echo 'Xbae/examples/colors/colors.c: original size 7063, current size' "$Wc_c"
  554. rm -f _shar_wnt_.tmp
  555. fi
  556. # ============= Xbae/examples/colors/Imakefile ==============
  557. if test -f 'Xbae/examples/colors/Imakefile' -a X"$1" != X"-c"; then
  558.     echo 'x - skipping Xbae/examples/colors/Imakefile (File already exists)'
  559.     rm -f _shar_wnt_.tmp
  560. else
  561. > _shar_wnt_.tmp
  562. echo 'x - extracting Xbae/examples/colors/Imakefile (Text)'
  563. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/colors/Imakefile' &&
  564. #include "../../Xbae.tmpl"
  565. X
  566. X   LOCAL_LDFLAGS = -L../../src
  567. X LOCAL_LIBRARIES = -lXbae -lXm -lXt -lX11
  568. X         DEPLIBS =
  569. X        INCLUDES = -I../../src
  570. X         DEFINES = -D_NO_PROTO
  571. X
  572. UninstalledSimpleProgramTarget(colors)
  573. SHAR_EOF
  574. chmod 0644 Xbae/examples/colors/Imakefile ||
  575. echo 'restore of Xbae/examples/colors/Imakefile failed'
  576. Wc_c="`wc -c < 'Xbae/examples/colors/Imakefile'`"
  577. test 222 -eq "$Wc_c" ||
  578.     echo 'Xbae/examples/colors/Imakefile: original size 222, current size' "$Wc_c"
  579. rm -f _shar_wnt_.tmp
  580. fi
  581. # ============= Xbae/examples/dynamic/Dynamic.ad ==============
  582. if test ! -d 'Xbae/examples/dynamic'; then
  583.     echo 'x - creating directory Xbae/examples/dynamic'
  584.     mkdir 'Xbae/examples/dynamic'
  585. fi
  586. if test -f 'Xbae/examples/dynamic/Dynamic.ad' -a X"$1" != X"-c"; then
  587.     echo 'x - skipping Xbae/examples/dynamic/Dynamic.ad (File already exists)'
  588.     rm -f _shar_wnt_.tmp
  589. else
  590. > _shar_wnt_.tmp
  591. echo 'x - extracting Xbae/examples/dynamic/Dynamic.ad (Text)'
  592. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/dynamic/Dynamic.ad' &&
  593. *mw.rows:            6
  594. *mw.columns:            5
  595. *mw.columnWidths:        5, 15, 10, 10, 15
  596. X
  597. *mw.rowLabels:            Row1, Row2, Row3, Row4, Row5, RowSix
  598. *mw.columnLabels:        Col1, Col2, Col3, Col4, ColFive
  599. *mw.visibleRows:        6
  600. SHAR_EOF
  601. chmod 0644 Xbae/examples/dynamic/Dynamic.ad ||
  602. echo 'restore of Xbae/examples/dynamic/Dynamic.ad failed'
  603. Wc_c="`wc -c < 'Xbae/examples/dynamic/Dynamic.ad'`"
  604. test 194 -eq "$Wc_c" ||
  605.     echo 'Xbae/examples/dynamic/Dynamic.ad: original size 194, current size' "$Wc_c"
  606. rm -f _shar_wnt_.tmp
  607. fi
  608. # ============= Xbae/examples/dynamic/dynamic.c ==============
  609. if test -f 'Xbae/examples/dynamic/dynamic.c' -a X"$1" != X"-c"; then
  610.     echo 'x - skipping Xbae/examples/dynamic/dynamic.c (File already exists)'
  611.     rm -f _shar_wnt_.tmp
  612. else
  613. > _shar_wnt_.tmp
  614. echo 'x - extracting Xbae/examples/dynamic/dynamic.c (Text)'
  615. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/dynamic/dynamic.c' &&
  616. /*
  617. X * Copyright(c) 1992 Bell Communications Research, Inc. (Bellcore)
  618. X *                        All rights reserved
  619. X * Permission to use, copy, modify and distribute this material for
  620. X * any purpose and without fee is hereby granted, provided that the
  621. X * above copyright notice and this permission notice appear in all
  622. X * copies, and that the name of Bellcore not be used in advertising
  623. X * or publicity pertaining to this material without the specific,
  624. X * prior written permission of an authorized representative of
  625. X * Bellcore.
  626. X *
  627. X * BELLCORE MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, EX-
  628. X * PRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT
  629. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  630. X * FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST IN-
  631. X * FRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS.  THE
  632. X * SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL BELLCORE OR
  633. X * ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY
  634. X * LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELAT-
  635. X * ING TO THE SOFTWARE.
  636. X */
  637. X
  638. #include <Xm/RowColumn.h>
  639. #include <Xm/Label.h>
  640. #include <Xm/PushB.h>
  641. #include <Xbae/Matrix.h>
  642. X
  643. /*
  644. X * Dynamically expand the matrix when tabbing past the last row or column.
  645. X */
  646. X
  647. X
  648. void TraverseCB();
  649. X
  650. main(argc, argv)
  651. int argc;
  652. char *argv[];
  653. {
  654. X    Widget toplevel, mw;
  655. X    XtAppContext app;
  656. X
  657. X    toplevel = XtVaAppInitialize(&app, "Dynamic",
  658. X                 NULL, 0,
  659. X                 &argc, argv,
  660. X                 NULL,
  661. X                 NULL);
  662. X
  663. X    mw = XtVaCreateManagedWidget("mw",
  664. X                 xbaeMatrixWidgetClass,    toplevel,
  665. X                 NULL);
  666. X    XtAddCallback(mw, XmNtraverseCellCallback, TraverseCB, NULL);
  667. X
  668. X    XtRealizeWidget(toplevel);
  669. X    XtAppMainLoop(app);
  670. }
  671. X
  672. /* ARGSUSED */
  673. void
  674. TraverseCB(w, client_data, call_data)
  675. Widget w;
  676. XXtPointer client_data;
  677. XXbaeMatrixTraverseCellCallbackStruct *call_data;
  678. {
  679. X    static XrmQuark QRight = NULLQUARK;
  680. X    static XrmQuark QDown = NULLQUARK;
  681. X
  682. X    /*
  683. X     * Get the Quarks we care about
  684. X     */
  685. X    if (QRight == NULLQUARK) {
  686. X    QRight = XrmStringToQuark("Right");
  687. X    QDown = XrmStringToQuark("Down");
  688. X    }
  689. X
  690. X    /*
  691. X     * If we are moving down, and we are at the last row, add a new row
  692. X     * and traverse to it.
  693. X     */
  694. X    if (call_data->qparam == QDown &&
  695. X    call_data->row == call_data->num_rows - 1) {
  696. X    XbaeMatrixAddRows(w, call_data->num_rows, NULL, NULL, NULL, 1);
  697. X    call_data->next_row = call_data->num_rows;
  698. X    call_data->next_column = call_data->column;
  699. X    }
  700. X    /*
  701. X     * If we are moving right, and we are at the last column, add a new column
  702. X     * and traverse to it.
  703. X     */
  704. X    else if (call_data->qparam == QRight &&
  705. X    call_data->column == call_data->num_columns - 1) {
  706. X    short width = 10;
  707. X    XbaeMatrixAddColumns(w, call_data->num_columns, NULL, NULL,
  708. X                 &width, NULL, NULL, NULL, NULL, 1);
  709. X    call_data->next_column = call_data->num_columns;
  710. X    call_data->next_row = call_data->row;
  711. X    }
  712. }
  713. X
  714. X
  715. SHAR_EOF
  716. chmod 0644 Xbae/examples/dynamic/dynamic.c ||
  717. echo 'restore of Xbae/examples/dynamic/dynamic.c failed'
  718. Wc_c="`wc -c < 'Xbae/examples/dynamic/dynamic.c'`"
  719. test 2890 -eq "$Wc_c" ||
  720.     echo 'Xbae/examples/dynamic/dynamic.c: original size 2890, current size' "$Wc_c"
  721. rm -f _shar_wnt_.tmp
  722. fi
  723. # ============= Xbae/examples/dynamic/Imakefile ==============
  724. if test -f 'Xbae/examples/dynamic/Imakefile' -a X"$1" != X"-c"; then
  725.     echo 'x - skipping Xbae/examples/dynamic/Imakefile (File already exists)'
  726.     rm -f _shar_wnt_.tmp
  727. else
  728. > _shar_wnt_.tmp
  729. echo 'x - extracting Xbae/examples/dynamic/Imakefile (Text)'
  730. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/dynamic/Imakefile' &&
  731. #include "../../Xbae.tmpl"
  732. X
  733. X   LOCAL_LDFLAGS = -L../../src
  734. X LOCAL_LIBRARIES = -lXbae -lXm -lXt -lX11
  735. X         DEPLIBS =
  736. X        INCLUDES = -I../../src
  737. X         DEFINES = -D_NO_PROTO
  738. X
  739. UninstalledSimpleProgramTarget(dynamic)
  740. SHAR_EOF
  741. chmod 0644 Xbae/examples/dynamic/Imakefile ||
  742. echo 'restore of Xbae/examples/dynamic/Imakefile failed'
  743. Wc_c="`wc -c < 'Xbae/examples/dynamic/Imakefile'`"
  744. test 223 -eq "$Wc_c" ||
  745.     echo 'Xbae/examples/dynamic/Imakefile: original size 223, current size' "$Wc_c"
  746. rm -f _shar_wnt_.tmp
  747. fi
  748. # ============= Xbae/examples/matrix/Matrix.ad ==============
  749. if test ! -d 'Xbae/examples/matrix'; then
  750.     echo 'x - creating directory Xbae/examples/matrix'
  751.     mkdir 'Xbae/examples/matrix'
  752. fi
  753. if test -f 'Xbae/examples/matrix/Matrix.ad' -a X"$1" != X"-c"; then
  754.     echo 'x - skipping Xbae/examples/matrix/Matrix.ad (File already exists)'
  755.     rm -f _shar_wnt_.tmp
  756. else
  757. > _shar_wnt_.tmp
  758. echo 'x - extracting Xbae/examples/matrix/Matrix.ad (Text)'
  759. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/matrix/Matrix.ad' &&
  760. *mw.rowLabels:        1, 2, 3, 4, 5, 6
  761. *mw.columnLabels:    Color, #, Texture, Measure, Size
  762. *mw.columnLabelAlignments:alignment_beginning, alignment_center,\
  763. X            alignment_beginning, alignment_beginning,\
  764. X            alignment_beginning
  765. *mw.columnAlignments:    alignment_beginning, alignment_end,\
  766. X            alignment_beginning, alignment_beginning,\
  767. X            alignment_beginning
  768. *mw.visibleRows:    4
  769. SHAR_EOF
  770. chmod 0644 Xbae/examples/matrix/Matrix.ad ||
  771. echo 'restore of Xbae/examples/matrix/Matrix.ad failed'
  772. Wc_c="`wc -c < 'Xbae/examples/matrix/Matrix.ad'`"
  773. test 365 -eq "$Wc_c" ||
  774.     echo 'Xbae/examples/matrix/Matrix.ad: original size 365, current size' "$Wc_c"
  775. rm -f _shar_wnt_.tmp
  776. fi
  777. # ============= Xbae/examples/matrix/matrix.c ==============
  778. if test -f 'Xbae/examples/matrix/matrix.c' -a X"$1" != X"-c"; then
  779.     echo 'x - skipping Xbae/examples/matrix/matrix.c (File already exists)'
  780.     rm -f _shar_wnt_.tmp
  781. else
  782. > _shar_wnt_.tmp
  783. echo 'x - extracting Xbae/examples/matrix/matrix.c (Text)'
  784. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/matrix/matrix.c' &&
  785. /*
  786. X * Copyright(c) 1992 Bell Communications Research, Inc. (Bellcore)
  787. X *                        All rights reserved
  788. X * Permission to use, copy, modify and distribute this material for
  789. X * any purpose and without fee is hereby granted, provided that the
  790. X * above copyright notice and this permission notice appear in all
  791. X * copies, and that the name of Bellcore not be used in advertising
  792. X * or publicity pertaining to this material without the specific,
  793. X * prior written permission of an authorized representative of
  794. X * Bellcore.
  795. X *
  796. X * BELLCORE MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, EX-
  797. X * PRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT
  798. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  799. X * FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST IN-
  800. X * FRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS.  THE
  801. X * SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL BELLCORE OR
  802. X * ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY
  803. X * LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELAT-
  804. X * ING TO THE SOFTWARE.
  805. X */
  806. X
  807. #include <Xbae/Matrix.h>
  808. X
  809. /*
  810. X * Simple example of loaded Matrix
  811. X */
  812. X
  813. #define ROWS        6
  814. #define COLUMNS        5
  815. X
  816. String rows[ROWS][COLUMNS] = {
  817. X    "Orange", "12", "Rough", "Inches", "Large",
  818. X    "Blue", "323", "Smooth", "Feet", "Medium",
  819. X    "Yellow", "456", "Bristly", "Meters", "Large",
  820. X    "Green", "1", "Knobby", "Miles", "Small",
  821. X    "Pink", "33", "Hairy", "Quarts", "Small",
  822. X    "Black", "7", "Silky", "Gallons", "Small"
  823. };
  824. String *cells[ROWS];
  825. X
  826. short widths[5] = { 6, 3, 10, 10, 10 };
  827. X
  828. main(argc, argv)
  829. int argc;
  830. char *argv[];
  831. {
  832. X    Widget toplevel, mw;
  833. X    XtAppContext app;
  834. X    int i;
  835. X
  836. X    toplevel = XtVaAppInitialize(&app, "Simple",
  837. X                 NULL, 0,
  838. X                 &argc, argv,
  839. X                 NULL,
  840. X                 NULL);
  841. X
  842. X    for (i = 0; i < ROWS; i++)
  843. X    cells[i] = &rows[i][0];
  844. X
  845. X    mw = XtVaCreateManagedWidget("mw",
  846. X                 xbaeMatrixWidgetClass, toplevel,
  847. X                 XmNrows,        ROWS,
  848. X                 XmNcolumns,        COLUMNS,
  849. X                 XmNcolumnWidths,    widths,
  850. X                 XmNcells,        cells,
  851. X                 NULL);
  852. X
  853. X    XtRealizeWidget(toplevel);
  854. X    XtAppMainLoop(app);
  855. }
  856. X
  857. SHAR_EOF
  858. chmod 0644 Xbae/examples/matrix/matrix.c ||
  859. echo 'restore of Xbae/examples/matrix/matrix.c failed'
  860. Wc_c="`wc -c < 'Xbae/examples/matrix/matrix.c'`"
  861. test 2097 -eq "$Wc_c" ||
  862.     echo 'Xbae/examples/matrix/matrix.c: original size 2097, current size' "$Wc_c"
  863. rm -f _shar_wnt_.tmp
  864. fi
  865. # ============= Xbae/examples/matrix/Imakefile ==============
  866. if test -f 'Xbae/examples/matrix/Imakefile' -a X"$1" != X"-c"; then
  867.     echo 'x - skipping Xbae/examples/matrix/Imakefile (File already exists)'
  868.     rm -f _shar_wnt_.tmp
  869. else
  870. > _shar_wnt_.tmp
  871. echo 'x - extracting Xbae/examples/matrix/Imakefile (Text)'
  872. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/matrix/Imakefile' &&
  873. #include "../../Xbae.tmpl"
  874. X
  875. X   LOCAL_LDFLAGS = -L../../src
  876. X LOCAL_LIBRARIES = -lXbae -lXm -lXt -lX11
  877. X         DEPLIBS =
  878. X        INCLUDES = -I../../src
  879. X         DEFINES = -D_NO_PROTO
  880. X
  881. UninstalledSimpleProgramTarget(matrix)
  882. SHAR_EOF
  883. chmod 0644 Xbae/examples/matrix/Imakefile ||
  884. echo 'restore of Xbae/examples/matrix/Imakefile failed'
  885. Wc_c="`wc -c < 'Xbae/examples/matrix/Imakefile'`"
  886. test 222 -eq "$Wc_c" ||
  887.     echo 'Xbae/examples/matrix/Imakefile: original size 222, current size' "$Wc_c"
  888. rm -f _shar_wnt_.tmp
  889. fi
  890. # ============= Xbae/examples/select/select.c ==============
  891. if test ! -d 'Xbae/examples/select'; then
  892.     echo 'x - creating directory Xbae/examples/select'
  893.     mkdir 'Xbae/examples/select'
  894. fi
  895. if test -f 'Xbae/examples/select/select.c' -a X"$1" != X"-c"; then
  896.     echo 'x - skipping Xbae/examples/select/select.c (File already exists)'
  897.     rm -f _shar_wnt_.tmp
  898. else
  899. > _shar_wnt_.tmp
  900. echo 'x - extracting Xbae/examples/select/select.c (Text)'
  901. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/select/select.c' &&
  902. /*
  903. X * Copyright(c) 1992 Bell Communications Research, Inc. (Bellcore)
  904. X *                        All rights reserved
  905. X * Permission to use, copy, modify and distribute this material for
  906. X * any purpose and without fee is hereby granted, provided that the
  907. X * above copyright notice and this permission notice appear in all
  908. X * copies, and that the name of Bellcore not be used in advertising
  909. X * or publicity pertaining to this material without the specific,
  910. X * prior written permission of an authorized representative of
  911. X * Bellcore.
  912. X *
  913. X * BELLCORE MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, EX-
  914. X * PRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT
  915. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  916. X * FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST IN-
  917. X * FRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS.  THE
  918. X * SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL BELLCORE OR
  919. X * ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY
  920. X * LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELAT-
  921. X * ING TO THE SOFTWARE.
  922. X */
  923. X
  924. #include <stdio.h>
  925. #include <Xm/Xm.h>
  926. #include <Wc/WcCreate.h>
  927. #include <Xbae/Matrix.h>
  928. X
  929. /*
  930. X * Creates a matrix and two option menus.  One menu selects the type of
  931. X * selection desired (row, column or cell).  The other selects the mode
  932. X * (exclusive - only one item at a time, or add - multiple items
  933. X * can be selected).
  934. X * The File menu can be used to load the matrix with dummy data.
  935. X * The Edit menu can be used to copy, clear or delete the currently
  936. X * selected item, or to deselect all selections.
  937. X */
  938. X
  939. #define RCO(name, func)        WcRegisterConstructor(app, name, func)
  940. #define RCN(name, class)    WcRegisterClassName(app, name, class)
  941. #define RCP(name, class)    WcRegisterClassPtr(app, name, class)
  942. X
  943. extern void MriRegisterMotif();
  944. X
  945. X
  946. typedef enum {
  947. X    NoSelection,
  948. X    CellSelection,
  949. X    RowSelection,
  950. X    ColumnSelection
  951. } SelectionType;
  952. X
  953. typedef enum {
  954. X    AddMode,
  955. X    ExclusiveMode
  956. } SelectionMode;
  957. X
  958. typedef struct _SelectionStruct {
  959. X    int row, column;
  960. X    SelectionType type;
  961. X    SelectionMode mode;
  962. X    Boolean selected;
  963. X    Widget matrix;
  964. } *SelectionPtr, SelectionStruct;
  965. X
  966. SelectionPtr GetSelectionFromWidget();
  967. void SelectCB(), NewMatrixCB(), RegisterSelectionWidgetCB();
  968. void SetSelectionTypeCB(), SetSelectionModeCB();
  969. void DeleteCB(), CopyCB(), ClearCB(), LoadCB(), DeselectCB();
  970. X
  971. void
  972. main(argc, argv)
  973. int argc;
  974. char *argv[];
  975. {
  976. X    Widget toplevel;
  977. X    XtAppContext app;
  978. X
  979. X    toplevel = XtAppInitialize(&app, "Select",
  980. X                   NULL, 0,
  981. X                   &argc, argv,
  982. X                   NULL,
  983. X                   NULL, 0);
  984. X
  985. X    MriRegisterMotif(app);
  986. X    
  987. X    RCN("XbaeMatrix", xbaeMatrixWidgetClass);
  988. X    RCP("xbaeMatrixWidgetClass", xbaeMatrixWidgetClass);
  989. X
  990. X    WcRegisterCallback(app, "NewMatrixCB", NewMatrixCB, NULL);
  991. X    WcRegisterCallback(app, "RegisterSelectionWidgetCB",
  992. X               RegisterSelectionWidgetCB, NULL);
  993. X    WcRegisterCallback(app, "SelectCB", SelectCB, NULL);
  994. X    WcRegisterCallback(app, "SetSelectionTypeCB", SetSelectionTypeCB, NULL);
  995. X    WcRegisterCallback(app, "SetSelectionModeCB", SetSelectionModeCB, NULL);
  996. X    WcRegisterCallback(app, "DeleteCB", DeleteCB, NULL);
  997. X    WcRegisterCallback(app, "CopyCB", CopyCB, NULL);
  998. X    WcRegisterCallback(app, "ClearCB", ClearCB, NULL);
  999. X    WcRegisterCallback(app, "LoadCB", LoadCB, NULL);
  1000. X    WcRegisterCallback(app, "DeselectCB", DeselectCB, NULL);
  1001. X
  1002. X    WcWidgetCreation(toplevel);
  1003. X
  1004. X    XtRealizeWidget(toplevel);
  1005. X    XtAppMainLoop(app);
  1006. }
  1007. X
  1008. /*
  1009. X * Create our internal matrix object and associate it with the widget
  1010. X */
  1011. /* ARGSUSED */
  1012. void
  1013. NewMatrixCB(w, client_data, call_data)
  1014. Widget w;
  1015. XXtPointer client_data;
  1016. XXtPointer call_data;
  1017. {
  1018. X    SelectionPtr selection = XtNew(SelectionStruct);
  1019. X    selection->type = NoSelection;
  1020. X    selection->selected = False;
  1021. X    selection->matrix = w;
  1022. X
  1023. X    XtVaSetValues(w,
  1024. X          XmNuserData, selection,
  1025. X          NULL);
  1026. }
  1027. X
  1028. /*
  1029. X * Associate the selection object with a widget
  1030. X */
  1031. /* ARGSUSED */
  1032. void
  1033. RegisterSelectionWidgetCB(w, client_data, call_data)
  1034. Widget w;
  1035. XXtPointer client_data;
  1036. XXtPointer call_data;
  1037. {
  1038. X    SelectionPtr selection;
  1039. X    Widget matrix;
  1040. X
  1041. X    if ((matrix = WcFullNameToWidget(w, (String)client_data)) == NULL)
  1042. X    return;
  1043. X
  1044. X    selection = GetSelectionFromWidget(matrix);
  1045. X    XtVaSetValues(w,
  1046. X          XmNuserData, selection,
  1047. X          NULL);
  1048. }
  1049. X
  1050. /*
  1051. X * Callback when a cell is clicked on
  1052. X */
  1053. /* ARGSUSED */
  1054. void
  1055. SelectCB(w, client_data, call_data)
  1056. Widget w;
  1057. XXtPointer client_data;
  1058. XXbaeMatrixSelectCellCallbackStruct *call_data;
  1059. {
  1060. X    SelectionPtr selection = GetSelectionFromWidget(w);
  1061. X
  1062. X    if (selection->mode == ExclusiveMode && selection->selected)
  1063. X    switch (selection->type) {
  1064. X    case CellSelection:
  1065. X        XbaeMatrixDeselectCell(w, selection->row, selection->column);
  1066. X        break;
  1067. X    case RowSelection:
  1068. X        XbaeMatrixDeselectRow(w, selection->row);
  1069. X        break;
  1070. X    case ColumnSelection:
  1071. X        XbaeMatrixDeselectColumn(w, selection->column);
  1072. X        break;
  1073. X    }
  1074. X
  1075. X    selection->row = call_data->row;
  1076. X    selection->column = call_data->column;
  1077. X
  1078. X    switch (selection->type) {
  1079. X    case CellSelection:
  1080. X    XbaeMatrixSelectCell(w, selection->row, selection->column);
  1081. X    break;
  1082. X    case RowSelection:
  1083. X    XbaeMatrixSelectRow(w, selection->row);
  1084. X    break;
  1085. X    case ColumnSelection:
  1086. X    XbaeMatrixSelectColumn(w, selection->column);
  1087. X    break;
  1088. X    }
  1089. X
  1090. X    selection->selected = True;
  1091. }
  1092. X
  1093. /* ARGSUSED */
  1094. void
  1095. SetSelectionTypeCB(w, client_data, call_data)
  1096. Widget w;
  1097. XXtPointer client_data;
  1098. XXtPointer call_data;
  1099. {
  1100. X    SelectionPtr selection = GetSelectionFromWidget(w);
  1101. X
  1102. X    XbaeMatrixDeselectAll(selection->matrix);
  1103. X    selection->selected = False;
  1104. X
  1105. X    switch (((String)client_data)[0]) {
  1106. X    case '1':
  1107. X    selection->type = CellSelection;
  1108. X    break;
  1109. X    case '2':
  1110. X    selection->type = RowSelection;
  1111. X    break;
  1112. X    case '3':
  1113. X    selection->type = ColumnSelection;
  1114. X    break;
  1115. X    default:
  1116. X    XtAppWarningMsg(XtWidgetToApplicationContext(w),
  1117. X            "setSelectionTypeCB", "badParam", "Select",
  1118. X            "Bad param passed to SetSelectionTypeCB",
  1119. X            (String *) NULL, (Cardinal *) NULL);
  1120. X    break;
  1121. X    }
  1122. }
  1123. X
  1124. /* ARGSUSED */
  1125. void
  1126. SetSelectionModeCB(w, client_data, call_data)
  1127. Widget w;
  1128. XXtPointer client_data;
  1129. XXtPointer call_data;
  1130. {
  1131. X    SelectionPtr selection = GetSelectionFromWidget(w);
  1132. X
  1133. X    XbaeMatrixDeselectAll(selection->matrix);
  1134. X    selection->selected = False;
  1135. X
  1136. X    switch (((String)client_data)[0]) {
  1137. X    case '0':
  1138. X    selection->mode = ExclusiveMode;
  1139. X    break;
  1140. X    case '1':
  1141. X    selection->mode = AddMode;
  1142. X    break;
  1143. X    default:
  1144. X    XtAppWarningMsg(XtWidgetToApplicationContext(w),
  1145. X            "setSelectionModeCB", "badParam", "Select",
  1146. X            "Bad param passed to SetSelectionModeCB",
  1147. X            (String *) NULL, (Cardinal *) NULL);
  1148. X    break;
  1149. X    }
  1150. }
  1151. X
  1152. /*
  1153. X * Delete the selected row or column.
  1154. X */
  1155. /* ARGSUSED */
  1156. void
  1157. DeleteCB(w, client_data, call_data)
  1158. Widget w;
  1159. XXtPointer client_data;
  1160. XXtPointer call_data;
  1161. {
  1162. X    Widget matrix;
  1163. X    SelectionPtr selection;
  1164. X
  1165. X    if ((matrix = WcFullNameToWidget(w, (String)client_data)) == NULL)
  1166. X    return;
  1167. X
  1168. X    selection = GetSelectionFromWidget(matrix);
  1169. X
  1170. X    if (!selection->selected)
  1171. X    return;
  1172. X
  1173. X    /*
  1174. X     * We cop out and only delete the last row/column selected
  1175. X     */
  1176. X    switch (selection->type) {
  1177. X    case RowSelection:
  1178. X    XbaeMatrixDeleteRows(matrix, selection->row, 1);
  1179. X    break;
  1180. X    case ColumnSelection:
  1181. X    XbaeMatrixDeleteColumns(matrix, selection->column, 1);
  1182. X    break;
  1183. X    }
  1184. }
  1185. X
  1186. /*
  1187. X * Clear the selected row, column or cell.
  1188. X */
  1189. /* ARGSUSED */
  1190. void
  1191. ClearCB(w, client_data, call_data)
  1192. Widget w;
  1193. XXtPointer client_data;
  1194. XXtPointer call_data;
  1195. {
  1196. X    Widget matrix;
  1197. X    int rows, columns;
  1198. X    int i;
  1199. X    SelectionPtr selection;
  1200. X
  1201. X    if ((matrix = WcFullNameToWidget(w, (String)client_data)) == NULL)
  1202. X    return;
  1203. X
  1204. X    selection = GetSelectionFromWidget(matrix);
  1205. X
  1206. X    if (!selection->selected)
  1207. X    return;
  1208. X
  1209. X    XtVaGetValues(matrix,
  1210. X          XmNcolumns, &columns,
  1211. X          XmNrows, &rows,
  1212. X          NULL);
  1213. X
  1214. X    /*
  1215. X     * We only clear the last selection made
  1216. X     */
  1217. X    switch (selection->type) {
  1218. X    case CellSelection:
  1219. X    XbaeMatrixSetCell(matrix, selection->row, selection->column, "");
  1220. X    break;
  1221. X    case RowSelection:
  1222. X    for (i = 0; i < columns; i++)
  1223. X        XbaeMatrixSetCell(matrix, selection->row, i, "");
  1224. X    break;
  1225. X    case ColumnSelection:
  1226. X    for (i = 0; i < rows; i++)
  1227. X        XbaeMatrixSetCell(matrix, i, selection->column, "");
  1228. X    break;
  1229. X    }
  1230. }
  1231. /*
  1232. X * Copy the selected row or column. Place the copy below it.
  1233. X */
  1234. /* ARGSUSED */
  1235. void
  1236. CopyCB(w, client_data, call_data)
  1237. Widget w;
  1238. XXtPointer client_data;
  1239. XXtPointer call_data;
  1240. {
  1241. X    Widget matrix;
  1242. X    int rows;
  1243. X    String **cells;
  1244. X    String *data;
  1245. X    String label, *row_labels, *column_labels;
  1246. X    short *widths, width;
  1247. X    int *lengths, length;
  1248. X    int i;
  1249. X    SelectionPtr selection;
  1250. X
  1251. X    if ((matrix = WcFullNameToWidget(w, (String)client_data)) == NULL)
  1252. X    return;
  1253. X
  1254. X    selection = GetSelectionFromWidget(matrix);
  1255. X
  1256. X    if (!selection->selected)
  1257. X    return;
  1258. X
  1259. X    XtVaGetValues(matrix,
  1260. X          XmNcells, &cells,
  1261. X          XmNrows, &rows,
  1262. X          XmNcolumnWidths, &widths,
  1263. X          XmNcolumnMaxLengths, &lengths,
  1264. X          XmNrowLabels, &row_labels,
  1265. X          XmNcolumnLabels, &column_labels,
  1266. X          NULL);
  1267. X
  1268. X    /*
  1269. X     * Using data retrieved via GetValues in an Xt/widget function
  1270. X     * without copying it locally is dangerous.
  1271. X     * The below is just for demo purposes.
  1272. X     * We only copy the last selection made
  1273. X     */
  1274. X    switch (selection->type) {
  1275. X    case RowSelection:
  1276. X    label = row_labels ? row_labels[selection->row] : NULL;
  1277. X    XbaeMatrixAddRows(matrix, selection->row, cells[selection->row],
  1278. X              &label, NULL, 1);
  1279. X    break;
  1280. X    case ColumnSelection:
  1281. X    data = (String *)XtMalloc(rows * sizeof(String));
  1282. X    for (i = 0; i < rows; i++)
  1283. X        data[i] = cells[i][selection->column];
  1284. X    /* We could get colors, alignments etc and copy those too,
  1285. X     * but I am lazy */
  1286. X    width = widths[selection->column];
  1287. X    length = lengths ?
  1288. X        lengths[selection->column] : widths[selection->column];
  1289. X    label = column_labels ? column_labels[selection->column] : NULL;
  1290. X    XbaeMatrixAddColumns(matrix, selection->column, data,
  1291. X                 &label, &width, &length, NULL, NULL, NULL, 1);
  1292. X    XtFree((XtPointer)data);
  1293. X    break;
  1294. X    }
  1295. }
  1296. X
  1297. /* ARGSUSED */
  1298. void
  1299. DeselectCB(w, client_data, call_data)
  1300. Widget w;
  1301. XXtPointer client_data;
  1302. XXtPointer call_data;
  1303. {
  1304. X    Widget matrix;
  1305. X    SelectionPtr selection;
  1306. X
  1307. X    if ((matrix = WcFullNameToWidget(w, (String)client_data)) == NULL)
  1308. X    return;
  1309. X
  1310. X    selection = GetSelectionFromWidget(matrix);
  1311. X
  1312. X    XbaeMatrixDeselectAll(matrix);
  1313. X    selection->selected = False;
  1314. }
  1315. X
  1316. /* ARGSUSED */
  1317. void
  1318. LoadCB(w, client_data, call_data)
  1319. Widget w;
  1320. XXtPointer client_data;
  1321. XXtPointer call_data;
  1322. {
  1323. X    int i, j;
  1324. X    int rows, columns;
  1325. X    char buf[BUFSIZ];
  1326. X    String **cells;
  1327. X    Widget matrix;
  1328. X
  1329. X    if ((matrix = WcFullNameToWidget(w, client_data)) == NULL)
  1330. X    return;
  1331. X
  1332. X    XtVaGetValues(matrix,
  1333. X          XmNrows, &rows,
  1334. X          XmNcolumns, &columns,
  1335. X          NULL);
  1336. X
  1337. X    cells = (String **) XtMalloc(sizeof(String *) * rows);
  1338. X    for (i = 0; i < rows; i++) {
  1339. X    cells[i] = (String *) XtMalloc(sizeof(String) * columns);
  1340. X    for (j = 0; j < columns; j++) {
  1341. X        sprintf(buf, "r%dc%d", i, j);
  1342. X        cells[i][j] = XtNewString(buf);
  1343. X    }
  1344. X    }
  1345. X
  1346. X    XtVaSetValues(matrix,
  1347. X          XmNcells, cells,
  1348. X          NULL);
  1349. X
  1350. X    for (i = 0; i < rows; i++) {
  1351. X    for (j = 0; j < columns; j++)
  1352. X        XtFree((XtPointer)cells[i][j]);
  1353. X    XtFree((XtPointer)cells[i]);
  1354. X    }
  1355. X    XtFree((XtPointer)cells);
  1356. }
  1357. X
  1358. SelectionPtr
  1359. GetSelectionFromWidget(w)
  1360. Widget w;
  1361. {
  1362. X    SelectionPtr selection = NULL;
  1363. X
  1364. X    XtVaGetValues(w,
  1365. X          XmNuserData, &selection,
  1366. X          NULL);
  1367. X    if (selection == NULL)
  1368. X    XtAppErrorMsg(XtWidgetToApplicationContext(w),
  1369. X              "getSelectionFromWidget", "notRegistered", "Select",
  1370. X              "Widget not registered",
  1371. X              NULL, 0);
  1372. X    return selection;
  1373. }
  1374. SHAR_EOF
  1375. chmod 0644 Xbae/examples/select/select.c ||
  1376. echo 'restore of Xbae/examples/select/select.c failed'
  1377. Wc_c="`wc -c < 'Xbae/examples/select/select.c'`"
  1378. test 11563 -eq "$Wc_c" ||
  1379.     echo 'Xbae/examples/select/select.c: original size 11563, current size' "$Wc_c"
  1380. rm -f _shar_wnt_.tmp
  1381. fi
  1382. # ============= Xbae/examples/select/Select.ad ==============
  1383. if test -f 'Xbae/examples/select/Select.ad' -a X"$1" != X"-c"; then
  1384.     echo 'x - skipping Xbae/examples/select/Select.ad (File already exists)'
  1385.     rm -f _shar_wnt_.tmp
  1386. else
  1387. > _shar_wnt_.tmp
  1388. echo 'x - extracting Xbae/examples/select/Select.ad (Text)'
  1389. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/select/Select.ad' &&
  1390. Select.wcChildren:        mainWin
  1391. X
  1392. *XbaeMatrix.fontList:        -*-courier-medium-r-*-*-*-140-*-*-*-*-*-*
  1393. *fontList:            -*-helvetica-bold-r-*-*-*-140-*-*-*-*-*-*
  1394. X
  1395. *menuBar*background:        VioletRed3
  1396. *background:            salmon2
  1397. X
  1398. X
  1399. *mainWin.wcClassName:        XmMainWindow
  1400. *mainWin.showSeparators:    True
  1401. *mainWin.wcChildren:        menuBar, matrix, buttonBox
  1402. X
  1403. !
  1404. ! Menubar and all menus
  1405. !
  1406. X
  1407. *menuBar.wcConstructor:     XmCreateMenuBar
  1408. *menuBar.wcCallback:        WcSetValueCB( *mainWin.menuBar: this )
  1409. *menuBar.wcChildren:        file, edit, help
  1410. *menuBar.wcPopups:        fileMenu, editMenu, helpMenu
  1411. X
  1412. *menuBar*XmCascadeButton.marginWidth:    8
  1413. *menuBar*XmRowColumn.spacing:        0
  1414. X
  1415. *file.wcConstructor:        XmCreateCascadeButton
  1416. *file.labelString:        File
  1417. *file.subMenuId:        *fileMenu
  1418. *fileMenu.wcConstructor:    XmCreatePulldownMenu
  1419. *fileMenu.wcChildren:        f_load, f_exit
  1420. X
  1421. *fileMenu*wcConstructor:    XmCreatePushButton
  1422. *f_load.labelString:        Load
  1423. *f_load.activateCallback:    LoadCB(*matrix)
  1424. *f_exit.labelString:        Exit
  1425. *f_exit.activateCallback:    WcExitCB()
  1426. X
  1427. *edit.wcConstructor:        XmCreateCascadeButton
  1428. *edit.labelString:        Edit
  1429. *edit.subMenuId:        *editMenu
  1430. *editMenu.wcConstructor:    XmCreatePulldownMenu
  1431. *editMenu.wcChildren:        e_copy, e_clear, e_delete, e_deselect
  1432. X
  1433. *editMenu*wcConstructor:    XmCreatePushButton
  1434. *e_copy.labelString:        Copy
  1435. *e_copy.activateCallback:     CopyCB(*matrix)
  1436. *e_clear.labelString:        Clear
  1437. *e_clear.activateCallback:     ClearCB(*matrix)
  1438. *e_delete.labelString:        Delete
  1439. *e_delete.activateCallback:     DeleteCB(*matrix)
  1440. *e_deselect.labelString:    Deselect
  1441. *e_deselect.activateCallback:     DeselectCB(*matrix)
  1442. X
  1443. *help.wcConstructor:        XmCreateCascadeButton
  1444. *help.wcCallback:        WcSetValueCB( ^.menuHelpWidget: this )
  1445. *help.labelString:        Help
  1446. *help.subMenuId:        *helpMenu
  1447. *helpMenu.wcConstructor:    XmCreatePulldownMenu
  1448. *helpMenu.wcChildren:        h_onSelect
  1449. X
  1450. *helpMenu*wcConstructor:    XmCreatePushButton
  1451. *h_onSelect.labelString:    On Select...
  1452. *h_onSelect.activateCallback:    WcCreateChildrenCB( Select, helpDialog ),\
  1453. X                WcSetValueCB(this.activateCallback: \
  1454. X                    WcManageCB( *helpDialog ))
  1455. X
  1456. *helpDialog.wcConstructor:    XmCreateInformationDialog
  1457. *helpDialog.wcCallback:        WcUnmanageCB( .Cancel, .Help )
  1458. *helpDialog.messageString:\
  1459. Shift-Click Button1 to select a row, column or cell.\n\
  1460. Select the mode with the "Selection Mode" menu.\n\
  1461. Select the type with the "Selection Type" menu.
  1462. X
  1463. X
  1464. !
  1465. ! Matrix
  1466. !
  1467. X
  1468. *matrix.wcClassName:        XbaeMatrix
  1469. *matrix.wcCallback:        WcSetValueCB( *mainWin.workWindow: this ),\
  1470. X                NewMatrixCB()
  1471. *matrix.boldLabels:        True
  1472. *matrix.rowLabels:        1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
  1473. *matrix.columnLabels:        One,Two,Three,Four,Five,Six,Seven,Eight,\
  1474. X                Nine,Ten
  1475. *matrix.rows:            15
  1476. *matrix.columns:        10
  1477. *matrix.visibleRows:        8
  1478. *matrix.visibleColumns:        5
  1479. *matrix.columnWidths:        10,5,10,5,10,5,10,10,5,10
  1480. *matrix.selectCellCallback:    SelectCB()
  1481. *matrix.translations:        #override\n\
  1482. X                Shift<Btn1Down>:    SelectCell()
  1483. X
  1484. !
  1485. ! buttonBox
  1486. !
  1487. *buttonBox.wcClassName:        XmRowColumn
  1488. *buttonBox.wcChildren:        selectionType, selectionMode
  1489. *buttonBox.wcCallback:        WcSetValueCB( *mainWin.commandWindow: this )
  1490. X
  1491. X
  1492. *selectionType.wcConstructor:    XmCreateOptionMenu
  1493. *selectionType.labelString:    Selection Type:
  1494. *selectionType.wcPopups:    typeMenu
  1495. X
  1496. *typeMenu.wcConstructor:    XmCreatePulldownMenu
  1497. *typeMenu.wcCallback:        WcSetValueCB(^^.subMenuId: this)
  1498. *typeMenu.wcChildren:        cellType, rowType, columnType
  1499. X
  1500. *typeMenu*wcConstructor:    XmCreatePushButton
  1501. X
  1502. *cellType.labelString:        Cell
  1503. *cellType.wcCallback:        RegisterSelectionWidgetCB(*matrix),\
  1504. X                SetSelectionTypeCB(1)
  1505. *cellType.activateCallback:    SetSelectionTypeCB(1)
  1506. *rowType.labelString:        Row
  1507. *rowType.wcCallback:        RegisterSelectionWidgetCB(*matrix)
  1508. *rowType.activateCallback:    SetSelectionTypeCB(2)
  1509. *columnType.labelString:    Column
  1510. *columnType.wcCallback:        RegisterSelectionWidgetCB(*matrix)
  1511. *columnType.activateCallback:    SetSelectionTypeCB(3)
  1512. X
  1513. X
  1514. *selectionMode.wcConstructor:    XmCreateOptionMenu
  1515. *selectionMode.labelString:    Selection Mode:
  1516. *selectionMode.wcPopups:    modeMenu
  1517. X
  1518. *modeMenu.wcConstructor:    XmCreatePulldownMenu
  1519. *modeMenu.wcCallback:        WcSetValueCB(^^.subMenuId: this)
  1520. *modeMenu.wcChildren:        exclusiveMode, addMode
  1521. *modeMenu*wcConstructor:    XmCreatePushButton
  1522. X
  1523. *exclusiveMode.labelString:    Exclusive
  1524. *exclusiveMode.wcCallback:    RegisterSelectionWidgetCB(*matrix),\
  1525. X                SetSelectionModeCB(0)
  1526. *exclusiveMode.activateCallback:SetSelectionModeCB(0)
  1527. X
  1528. *addMode.labelString:        Add
  1529. *addMode.wcCallback:        RegisterSelectionWidgetCB(*matrix)
  1530. *addMode.activateCallback:    SetSelectionModeCB(1)
  1531. SHAR_EOF
  1532. chmod 0644 Xbae/examples/select/Select.ad ||
  1533. echo 'restore of Xbae/examples/select/Select.ad failed'
  1534. Wc_c="`wc -c < 'Xbae/examples/select/Select.ad'`"
  1535. test 4422 -eq "$Wc_c" ||
  1536.     echo 'Xbae/examples/select/Select.ad: original size 4422, current size' "$Wc_c"
  1537. rm -f _shar_wnt_.tmp
  1538. fi
  1539. # ============= Xbae/examples/select/Imakefile ==============
  1540. if test -f 'Xbae/examples/select/Imakefile' -a X"$1" != X"-c"; then
  1541.     echo 'x - skipping Xbae/examples/select/Imakefile (File already exists)'
  1542.     rm -f _shar_wnt_.tmp
  1543. else
  1544. > _shar_wnt_.tmp
  1545. echo 'x - extracting Xbae/examples/select/Imakefile (Text)'
  1546. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/select/Imakefile' &&
  1547. #include "../../Xbae.tmpl"
  1548. X
  1549. X   LOCAL_LDFLAGS = -L../../src
  1550. X LOCAL_LIBRARIES = -lXbae -lXmp -lXm -lWc -lXt -lX11
  1551. X         DEPLIBS =
  1552. X        INCLUDES = -I../../src
  1553. X         DEFINES = -D_NO_PROTO
  1554. X
  1555. UninstalledSimpleProgramTarget(select)
  1556. SHAR_EOF
  1557. chmod 0644 Xbae/examples/select/Imakefile ||
  1558. echo 'restore of Xbae/examples/select/Imakefile failed'
  1559. Wc_c="`wc -c < 'Xbae/examples/select/Imakefile'`"
  1560. test 233 -eq "$Wc_c" ||
  1561.     echo 'Xbae/examples/select/Imakefile: original size 233, current size' "$Wc_c"
  1562. rm -f _shar_wnt_.tmp
  1563. fi
  1564. # ============= Xbae/examples/traversal/traversal.c ==============
  1565. if test ! -d 'Xbae/examples/traversal'; then
  1566.     echo 'x - creating directory Xbae/examples/traversal'
  1567.     mkdir 'Xbae/examples/traversal'
  1568. fi
  1569. if test -f 'Xbae/examples/traversal/traversal.c' -a X"$1" != X"-c"; then
  1570.     echo 'x - skipping Xbae/examples/traversal/traversal.c (File already exists)'
  1571.     rm -f _shar_wnt_.tmp
  1572. else
  1573. > _shar_wnt_.tmp
  1574. echo 'x - extracting Xbae/examples/traversal/traversal.c (Text)'
  1575. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/traversal/traversal.c' &&
  1576. /*
  1577. X * Copyright(c) 1992 Bell Communications Research, Inc. (Bellcore)
  1578. X *                        All rights reserved
  1579. X * Permission to use, copy, modify and distribute this material for
  1580. X * any purpose and without fee is hereby granted, provided that the
  1581. X * above copyright notice and this permission notice appear in all
  1582. X * copies, and that the name of Bellcore not be used in advertising
  1583. X * or publicity pertaining to this material without the specific,
  1584. X * prior written permission of an authorized representative of
  1585. X * Bellcore.
  1586. X *
  1587. X * BELLCORE MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, EX-
  1588. X * PRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT
  1589. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1590. X * FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST IN-
  1591. X * FRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS.  THE
  1592. X * SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL BELLCORE OR
  1593. X * ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY
  1594. X * LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELAT-
  1595. X * ING TO THE SOFTWARE.
  1596. X */
  1597. X
  1598. #include <Xbae/Matrix.h>
  1599. X
  1600. /*
  1601. X * Custom traversal.
  1602. X * Defines a new type of traversal.  Pressing the Return key will
  1603. X * now move down a row and back to the first column (like a carriage
  1604. X * return).
  1605. X */
  1606. X
  1607. void TraverseCB();
  1608. X
  1609. main(argc, argv)
  1610. int argc;
  1611. char *argv[];
  1612. {
  1613. X    Widget toplevel, mw;
  1614. X    XtAppContext app;
  1615. X
  1616. X    toplevel = XtVaAppInitialize(&app, "Traversal",
  1617. X                 NULL, 0,
  1618. X                 &argc, argv,
  1619. X                 NULL,
  1620. X                 NULL);
  1621. X
  1622. X    mw = XtVaCreateManagedWidget("mw",
  1623. X                 xbaeMatrixWidgetClass, toplevel,
  1624. X                 NULL);
  1625. X    XtAddCallback(mw, XmNtraverseCellCallback, TraverseCB, NULL);
  1626. X
  1627. X    XtRealizeWidget(toplevel);
  1628. X    XtAppMainLoop(app);
  1629. }
  1630. X
  1631. /*
  1632. X * Custom traversal callback.  If the EditCell() action has the param
  1633. X * "Return", then we move down a row and back to the first editable
  1634. X * column.
  1635. X */
  1636. /* ARGSUSED */
  1637. void
  1638. TraverseCB(w, client_data, call_data)
  1639. Widget w;
  1640. XXtPointer client_data;
  1641. XXbaeMatrixTraverseCellCallbackStruct *call_data;
  1642. {
  1643. X    static XrmQuark Qreturn = NULLQUARK;
  1644. X
  1645. X    /*
  1646. X     * Get a Quark for our special action parm (for faster comparisons)
  1647. X     */
  1648. X    if (Qreturn == NULLQUARK)
  1649. X    Qreturn = XrmStringToQuark("Return");
  1650. X
  1651. X    /*
  1652. X     * See if this is our special quark
  1653. X     */
  1654. X    if (call_data->qparam != Qreturn)
  1655. X    return;
  1656. X
  1657. X    /*
  1658. X     * If we are on the last row we don't move
  1659. X     */
  1660. X    if (call_data->row == call_data->num_rows - 1)
  1661. X    return;
  1662. X
  1663. X    /*
  1664. X     * Move down a row and back to the first non-fixed column
  1665. X     */
  1666. X    call_data->next_row = call_data->row + 1;
  1667. X    call_data->next_column = call_data->fixed_columns;
  1668. }
  1669. X
  1670. X
  1671. X
  1672. SHAR_EOF
  1673. chmod 0644 Xbae/examples/traversal/traversal.c ||
  1674. echo 'restore of Xbae/examples/traversal/traversal.c failed'
  1675. Wc_c="`wc -c < 'Xbae/examples/traversal/traversal.c'`"
  1676. test 2639 -eq "$Wc_c" ||
  1677.     echo 'Xbae/examples/traversal/traversal.c: original size 2639, current size' "$Wc_c"
  1678. rm -f _shar_wnt_.tmp
  1679. fi
  1680. # ============= Xbae/examples/traversal/Traversal.ad ==============
  1681. if test -f 'Xbae/examples/traversal/Traversal.ad' -a X"$1" != X"-c"; then
  1682.     echo 'x - skipping Xbae/examples/traversal/Traversal.ad (File already exists)'
  1683.     rm -f _shar_wnt_.tmp
  1684. else
  1685. > _shar_wnt_.tmp
  1686. echo 'x - extracting Xbae/examples/traversal/Traversal.ad (Text)'
  1687. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/traversal/Traversal.ad' &&
  1688. *mw.rows:        10
  1689. *mw.columns:        5
  1690. *mw.columnWidths:    10, 5, 10, 15, 1
  1691. X
  1692. ! We need translations on the TextField edit widget to do our custom
  1693. ! traversal (EditCell(Return))
  1694. *mw.textTranslations:    #override\n\
  1695. X            Shift ~Ctrl ~Meta ~Alt <Key>Tab:   EditCell(Left)\n\
  1696. X            ~Ctrl ~Meta ~Alt <Key>Tab:       EditCell(Right)\n\
  1697. X            <Key>osfUp:               EditCell(Up)\n\
  1698. X            <Key>osfDown:               EditCell(Down)\n\
  1699. X            <Key>osfActivate:           EditCell(Return)\n\
  1700. X            ~Shift ~Meta ~Alt <Key>Return:       EditCell(Return)\n\
  1701. X            <Key>osfCancel:               CancelEdit()
  1702. SHAR_EOF
  1703. chmod 0644 Xbae/examples/traversal/Traversal.ad ||
  1704. echo 'restore of Xbae/examples/traversal/Traversal.ad failed'
  1705. Wc_c="`wc -c < 'Xbae/examples/traversal/Traversal.ad'`"
  1706. test 524 -eq "$Wc_c" ||
  1707.     echo 'Xbae/examples/traversal/Traversal.ad: original size 524, current size' "$Wc_c"
  1708. rm -f _shar_wnt_.tmp
  1709. fi
  1710. # ============= Xbae/examples/traversal/Imakefile ==============
  1711. if test -f 'Xbae/examples/traversal/Imakefile' -a X"$1" != X"-c"; then
  1712.     echo 'x - skipping Xbae/examples/traversal/Imakefile (File already exists)'
  1713.     rm -f _shar_wnt_.tmp
  1714. else
  1715. > _shar_wnt_.tmp
  1716. echo 'x - extracting Xbae/examples/traversal/Imakefile (Text)'
  1717. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/traversal/Imakefile' &&
  1718. #include "../../Xbae.tmpl"
  1719. X
  1720. X   LOCAL_LDFLAGS = -L../../src
  1721. X LOCAL_LIBRARIES = -lXbae -lXm -lXt -lX11
  1722. X         DEPLIBS =
  1723. X        INCLUDES = -I../../src
  1724. X         DEFINES = -D_NO_PROTO
  1725. X
  1726. UninstalledSimpleProgramTarget(traversal)
  1727. SHAR_EOF
  1728. chmod 0644 Xbae/examples/traversal/Imakefile ||
  1729. echo 'restore of Xbae/examples/traversal/Imakefile failed'
  1730. Wc_c="`wc -c < 'Xbae/examples/traversal/Imakefile'`"
  1731. test 225 -eq "$Wc_c" ||
  1732.     echo 'Xbae/examples/traversal/Imakefile: original size 225, current size' "$Wc_c"
  1733. rm -f _shar_wnt_.tmp
  1734. fi
  1735. # ============= Xbae/examples/README ==============
  1736. if test -f 'Xbae/examples/README' -a X"$1" != X"-c"; then
  1737.     echo 'x - skipping Xbae/examples/README (File already exists)'
  1738.     rm -f _shar_wnt_.tmp
  1739. else
  1740. > _shar_wnt_.tmp
  1741. echo 'x - extracting Xbae/examples/README (Text)'
  1742. sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/README' &&
  1743. To run the example programs, change into the example directory,
  1744. SHAR_EOF
  1745. true || echo 'restore of Xbae/examples/README failed'
  1746. fi
  1747. echo 'End of Xbae part 11'
  1748. echo 'File Xbae/examples/README is continued in part 12'
  1749. echo 12 > _shar_seq_.tmp
  1750. exit 0
  1751. -- 
  1752. --
  1753. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  1754. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  1755. Sunnyvale, California 94086            at&t: 408/522-9236
  1756.