home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.x
- Path: uunet!usc!rpi!zaphod.mps.ohio-state.edu!mips!msi!dcmartin
- From: Andrew Wason <aw@bae.bellcore.com>
- Subject: v17i039: Xbae widgets (MOTIF), Part12/12
- Message-ID: <1992Mar23.180458.16458@msi.com>
- Originator: dcmartin@fascet
- Sender: dcmartin@msi.com (David C. Martin - Moderator)
- Organization: Molecular Simulations, Inc.
- References: <csx-17i028-xbae@uunet.UU.NET>
- Date: Mon, 23 Mar 1992 18:04:58 GMT
- Approved: dcmartin@msi.com
- Lines: 360
-
- Submitted-by: Andrew Wason <aw@bae.bellcore.com>
- Posting-number: Volume 17, Issue 39
- Archive-name: xbae/part12
-
- Submitted-by: aw@jello
- Archive-name: Xbae/part12
-
- ---- Cut Here and feed the following to sh ----
- #!/bin/sh
- # this is Xbae.shar.12 (part 12 of Xbae)
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file Xbae/examples/README continued
- #
- if test ! -r _shar_seq_.tmp; then
- echo 'Please unpack part 1 first!'
- exit 1
- fi
- (read Scheck
- if test "$Scheck" != 12; then
- echo Please unpack part "$Scheck" next!
- exit 1
- else
- exit 0
- fi
- ) < _shar_seq_.tmp || exit 1
- if test ! -f _shar_wnt_.tmp; then
- echo 'x - still skipping Xbae/examples/README'
- else
- echo 'x - continuing file Xbae/examples/README'
- sed 's/^X//' << 'SHAR_EOF' >> 'Xbae/examples/README' &&
- set the XENVIRONMENT variable to point to the appropriate resource
- file and run the program, e.g.:
- X
- X cd matrix
- X XENVIRONMENT=Matrix.ad matrix
- X
- You can also use the shell script "runtest" in this directory to
- run all the examples.
- X
- X
- matrix
- X A simple example of a loaded XbaeMatrix widget.
- X
- colors
- X Interactively sets row, column and cell colors to the color name
- X entered in a cell.
- X
- traversal
- X Example of custom traversal. Defines new traversal type -- when Return
- X is pressed, moves down a row and back to the first column (carriage return).
- X
- dynamic
- X Dynamically expands the matrix when a row/column boundary is passed.
- X
- select
- X Demonstrates row/column/cell selection techniques. Requires Wcl.
- X
- select-drag
- X Demonstrates "dragging out a rectangle" selection technique.
- X
- add
- X Demonstrates dynamically adding multiple rows and columns.
- X
- caption
- X Demonstrates five configurations using XbaeCaption.
- X
- Mri
- X A version of Mri which knows about the XbaeMatrix and XbaeCaption widgets.
- X Requires Wcl. Two simple Wcl resource files creating a Matrix and
- X Caption widget are provided.
- SHAR_EOF
- echo 'File Xbae/examples/README is complete' &&
- chmod 0644 Xbae/examples/README ||
- echo 'restore of Xbae/examples/README failed'
- Wc_c="`wc -c < 'Xbae/examples/README'`"
- test 1157 -eq "$Wc_c" ||
- echo 'Xbae/examples/README: original size 1157, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= Xbae/examples/Imakefile ==============
- if test -f 'Xbae/examples/Imakefile' -a X"$1" != X"-c"; then
- echo 'x - skipping Xbae/examples/Imakefile (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting Xbae/examples/Imakefile (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/Imakefile' &&
- #include "../Xbae.tmpl"
- X
- #define IHaveSubdirs
- #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
- X
- #if HaveWcl
- X SUBDIRS = Mri add caption colors dynamic matrix select select-drag traversal
- #else
- X SUBDIRS = add caption colors dynamic matrix select-drag traversal
- #endif
- X
- MakeSubdirs($(SUBDIRS))
- DependSubdirs($(SUBDIRS))
- SHAR_EOF
- chmod 0644 Xbae/examples/Imakefile ||
- echo 'restore of Xbae/examples/Imakefile failed'
- Wc_c="`wc -c < 'Xbae/examples/Imakefile'`"
- test 327 -eq "$Wc_c" ||
- echo 'Xbae/examples/Imakefile: original size 327, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= Xbae/examples/select-drag/Imakefile ==============
- if test ! -d 'Xbae/examples/select-drag'; then
- echo 'x - creating directory Xbae/examples/select-drag'
- mkdir 'Xbae/examples/select-drag'
- fi
- if test -f 'Xbae/examples/select-drag/Imakefile' -a X"$1" != X"-c"; then
- echo 'x - skipping Xbae/examples/select-drag/Imakefile (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting Xbae/examples/select-drag/Imakefile (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/select-drag/Imakefile' &&
- #include "../../Xbae.tmpl"
- X
- X LOCAL_LDFLAGS = -L../../src
- X LOCAL_LIBRARIES = -lXbae -lXm -lXt -lX11
- X DEPLIBS =
- X INCLUDES = -I../../src
- X DEFINES = -D_NO_PROTO
- X
- UninstalledSimpleProgramTarget(select-drag)
- SHAR_EOF
- chmod 0644 Xbae/examples/select-drag/Imakefile ||
- echo 'restore of Xbae/examples/select-drag/Imakefile failed'
- Wc_c="`wc -c < 'Xbae/examples/select-drag/Imakefile'`"
- test 227 -eq "$Wc_c" ||
- echo 'Xbae/examples/select-drag/Imakefile: original size 227, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= Xbae/examples/select-drag/select-drag.c ==============
- if test -f 'Xbae/examples/select-drag/select-drag.c' -a X"$1" != X"-c"; then
- echo 'x - skipping Xbae/examples/select-drag/select-drag.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting Xbae/examples/select-drag/select-drag.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/select-drag/select-drag.c' &&
- /*
- X * Copyright(c) 1992 Bell Communications Research, Inc. (Bellcore)
- X * All rights reserved
- X * Permission to use, copy, modify and distribute this material for
- X * any purpose and without fee is hereby granted, provided that the
- X * above copyright notice and this permission notice appear in all
- X * copies, and that the name of Bellcore not be used in advertising
- X * or publicity pertaining to this material without the specific,
- X * prior written permission of an authorized representative of
- X * Bellcore.
- X *
- X * BELLCORE MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, EX-
- X * PRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT
- X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- X * FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST IN-
- X * FRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS. THE
- X * SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL BELLCORE OR
- X * ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY
- X * LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELAT-
- X * ING TO THE SOFTWARE.
- X */
- X
- #include <stdio.h>
- #include <Xm/Xm.h>
- #include <Xbae/Matrix.h>
- X
- void LoadMatrix();
- void SelectCB();
- X
- /*
- X * Create an uneditable matrix. When Btn1 is dragged, a rectangular region
- X * of cells is selected.
- X */
- X
- void
- main(argc, argv)
- int argc;
- char *argv[];
- {
- X Widget toplevel, matrix;
- X XtAppContext app;
- X
- X toplevel = XtAppInitialize(&app, "Select-drag",
- X NULL, 0,
- X (Cardinal *)&argc, argv,
- X NULL,
- X NULL, 0);
- X
- X matrix = XtVaCreateManagedWidget("matrix",
- X xbaeMatrixWidgetClass, toplevel,
- X NULL);
- X XtAddCallback(matrix, XmNselectCellCallback, SelectCB, NULL);
- X LoadMatrix(matrix);
- X
- X XtRealizeWidget(toplevel);
- X XtAppMainLoop(app);
- }
- X
- /*
- X * Callback when the mouse is moved, we want to select a rectangle of cells
- X */
- /* ARGSUSED */
- void
- SelectCB(w, client_data, call_data)
- Widget w;
- XXtPointer client_data;
- XXbaeMatrixSelectCellCallbackStruct *call_data;
- {
- X static int start_row, start_column;
- X static int last_row, last_column;
- X int i, j;
- X
- X /*
- X * If we have params, we must be starting a rectangle
- X */
- X if (call_data->num_params) {
- X start_row = last_row = call_data->row;
- X start_column = last_column = call_data->column;
- X XbaeMatrixSelectCell(w, last_row, last_column);
- X }
- X /*
- X * Else we are in the middle of dragging a rectangle
- X */
- X else {
- X /*
- X * This is a pretty simplistic, stupid implementation
- X * of selecting a rectangle.
- X */
- X if (call_data->row > last_row) {
- X for (i = last_row + 1; i <= call_data->row; i++)
- X for (j = start_column; j <= call_data->column; j++)
- X XbaeMatrixSelectCell(w, i, j);
- X }
- X if (call_data->column > last_column) {
- X for (i = start_row; i <= last_row; i++)
- X for (j = last_column + 1; j <= call_data->column; j++)
- X XbaeMatrixSelectCell(w, i, j);
- X }
- X
- X last_row = call_data->row;
- X last_column = call_data->column;
- X }
- }
- X
- /* ARGSUSED */
- void
- LoadMatrix(matrix)
- Widget matrix;
- {
- X int i, j;
- X int rows, columns;
- X char buf[BUFSIZ];
- X String **cells;
- X
- X XtVaGetValues(matrix,
- X XmNrows, &rows,
- X XmNcolumns, &columns,
- X NULL);
- X
- X cells = (String **) XtMalloc(sizeof(String *) * rows);
- X for (i = 0; i < rows; i++) {
- X cells[i] = (String *) XtMalloc(sizeof(String) * columns);
- X for (j = 0; j < columns; j++) {
- X sprintf(buf, "r%dc%d", i, j);
- X cells[i][j] = XtNewString(buf);
- X }
- X }
- X
- X XtVaSetValues(matrix,
- X XmNcells, cells,
- X NULL);
- X
- X for (i = 0; i < rows; i++) {
- X for (j = 0; j < columns; j++)
- X XtFree((XtPointer)cells[i][j]);
- X XtFree((XtPointer)cells[i]);
- X }
- X XtFree((XtPointer)cells);
- }
- SHAR_EOF
- chmod 0644 Xbae/examples/select-drag/select-drag.c ||
- echo 'restore of Xbae/examples/select-drag/select-drag.c failed'
- Wc_c="`wc -c < 'Xbae/examples/select-drag/select-drag.c'`"
- test 3695 -eq "$Wc_c" ||
- echo 'Xbae/examples/select-drag/select-drag.c: original size 3695, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= Xbae/examples/select-drag/Select-drag.ad ==============
- if test -f 'Xbae/examples/select-drag/Select-drag.ad' -a X"$1" != X"-c"; then
- echo 'x - skipping Xbae/examples/select-drag/Select-drag.ad (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting Xbae/examples/select-drag/Select-drag.ad (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/select-drag/Select-drag.ad' &&
- *matrix.rows: 25
- *matrix.columns: 15
- *matrix.columnWidths: 10,10,10,6,6,6,10,10,10,6,6,6,6,6,6
- *matrix.visibleRows: 15
- X
- !
- ! We have an uneditable matrix. Apply translations to clip widget too
- ! to get autoscrolling as we drag
- !
- *matrix.translations: #replace\n\
- X <Btn1Down>: SelectCell(start)\n\
- X <Btn1Motion>: SelectCell()
- *matrix.clip.translations: #replace\n\
- X <Btn1Down>: SelectCell(start)\n\
- X <Btn1Motion>: SelectCell()
- *matrix.traversalOn: off
- SHAR_EOF
- chmod 0644 Xbae/examples/select-drag/Select-drag.ad ||
- echo 'restore of Xbae/examples/select-drag/Select-drag.ad failed'
- Wc_c="`wc -c < 'Xbae/examples/select-drag/Select-drag.ad'`"
- test 461 -eq "$Wc_c" ||
- echo 'Xbae/examples/select-drag/Select-drag.ad: original size 461, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= Xbae/examples/runtest ==============
- if test -f 'Xbae/examples/runtest' -a X"$1" != X"-c"; then
- echo 'x - skipping Xbae/examples/runtest (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting Xbae/examples/runtest (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'Xbae/examples/runtest' &&
- #!/bin/sh
- X
- env XENVIRONMENT=Mri/Matrix.ad Mri/Mri
- env XENVIRONMENT=Mri/Caption.ad Mri/Mri
- env XENVIRONMENT=add/Add.ad add/add
- env XENVIRONMENT=caption/Caption.ad caption/caption
- env XENVIRONMENT=colors/Colors.ad colors/colors
- env XENVIRONMENT=dynamic/Dynamic.ad dynamic/dynamic
- env XENVIRONMENT=matrix/Matrix.ad matrix/matrix
- env XENVIRONMENT=select/Select.ad select/select
- env XENVIRONMENT=select-drag/Select-drag.ad select-drag/select-drag
- env XENVIRONMENT=traversal/Traversal.ad traversal/traversal
- SHAR_EOF
- chmod 0755 Xbae/examples/runtest ||
- echo 'restore of Xbae/examples/runtest failed'
- Wc_c="`wc -c < 'Xbae/examples/runtest'`"
- test 502 -eq "$Wc_c" ||
- echo 'Xbae/examples/runtest: original size 502, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- rm -f _shar_seq_.tmp
- echo You have unpacked the last part
- exit 0
- --
- --
- Molecular Simulations, Inc. mail: dcmartin@msi.com
- 796 N. Pastoria Avenue uucp: uunet!dcmartin
- Sunnyvale, California 94086 at&t: 408/522-9236
-