home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
x
/
xtici.zip
/
xtici
/
patch.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-28
|
6KB
|
249 lines
/*
* Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
* All Rights Reserved
*
* This file is a component of an X Window System client which uses the Xcms
* Color Management System. TekColor is a trademark of Tektronix, Inc. The
* TekColor Editor is the subject of U.S. and foreign patents pending. The
* term "TekHVC" designates a particular color space that is the subject of
* U.S. Patent No. 4,985,853 (equivalent foreign patents pending).
* Permission is hereby granted to use, copy, modify, sell, and otherwise
* distribute this software and its documentation for the X Window System
* environment, for any purpose and without fee, provided that:
*
* 1. The code and documentation are only used to implement a
* TekColor Editor in an X Window System environment; and
* 2. This copyright and permission notice is reproduced in all copies
* of the code and in supporting documentation.
*
* Permission is granted to modify this code as required to allow it to
* be compiled on any host computer, provided that the functionality of
* the TekColor Editor is not modified in any way. A description of any
* modifications must be sent to Tektronix, Inc. Contact
* Tektronix Inc., P.O. Box 1000, Mail Station 60-850,
* Network Displays Division Engineering, Wilsonville, OR 97070.
*
* Tektronix makes no representation about the suitability of this software
* for any purpose. It is provided "as is" and with all faults.
*
* TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
* INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF
* CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.
*
* NAME
* patch - create and manage patch widgets
*
* DESCRIPTION
* The patch widget displays the current color and the index
* of the current color cell. When in shading mode, it splits
* and shows color cells on each end of the shading range.
* Create, manage and respond to user input in the patch.
*/
#ifndef LINT
static char *copy_notice = "Copyright 1991 Tektronix, Inc.";
#ifdef RCS_ID
static char *rcsid= "$Header: patch.c,v 1.2 91/08/22 11:34:12 adamsc Exp $";
#endif /* RCS_ID */
#endif /* LINT */
/*
* EXTERNAL INCLUDES
*/
/*
* INTERNAL INCLUDES
*/
#include <X11/StringDefs.h>
#include <X11/IntrinsicP.h>
#include <X11/CoreP.h>
#include <X11/Xaw/AsciiTextP.h>
#include <X11/Xaw/Box.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Text.h>
#include "xtici.h"
#include "patch.h"
#include "widgets/xticiSD.h"
/*
* EXTERNS
*/
/*
* GLOBALS
*/
#ifdef DEC
# define GLOBAL global
#else
# define GLOBAL
#endif
/*
* The index to the current cell
*/
GLOBAL Pixel currentIndex = 0;
/*
* LOCAL DEFINES
*/
#define WidgetCt PatchMaxCt
/*
* LOCAL TYPEDEFS
*/
/*
* LOCALS VARIABLES
*/
#ifdef DEBUG
# define STATIC
#else
# define STATIC static
#endif
STATIC Widget wlist[WidgetCt];
STATIC Arg textArgs[] = {
{XtNeditType, (XtArgVal)XawtextEdit},
{XtNlength, 3},
{XtNresize, (XtArgVal)XawtextResizeBoth},
{XtNstring, (XtArgVal)"0"},
{XtNuseStringInPlace, False},
{XtNwidth, 50},
{XtNheight, 30},
{XtNtop, (XtArgVal)XawChainTop},
{XtNleft, (XtArgVal)XawChainLeft},
};
STATIC Arg boxArgs[] = {
{XtNwidth, 203},
{XtNheight, 79},
{XtNtop, (XtArgVal)XawChainTop},
{XtNbottom, (XtArgVal)XawChainBottom},
{XtNleft, (XtArgVal)XawChainLeft},
{XtNright, (XtArgVal)XawChainRight},
};
/************************************************************************
* *
* PRIVATE ROUTINES *
* *
************************************************************************/
#define BUFLEN 5
/* ARGSUSED */
STATIC void setIndexGesture(wid, source, call)
Widget wid;
XtPointer source;
XtPointer call;
{
gesture = GestureCell0;
}
/************************************************************************
* *
* PUBLIC ROUTINES *
* *
************************************************************************/
Widget CreatePatch(parent)
Widget parent;
{
Widget self = XtCreateManagedWidget("patch", formWidgetClass, parent,
NULL, 0);
Widget asw;
XtTranslations mytrans;
STATIC char defaults[] = "#augment\n\
<Leave>: leave()";
wlist[0] = XtCreateManagedWidget("patchtext",
asciiTextWidgetClass, self, textArgs, XtNumber(textArgs));
mytrans = XtParseTranslationTable(defaults);
XtAugmentTranslations (wlist[0], mytrans);
asw = XawTextGetSource(wlist[0]);
XtAddCallback(asw, XtNcallback, setIndexGesture, (XtPointer)NULL);
wlist[1] = XtCreateManagedWidget("patcharea", boxWidgetClass, self,
boxArgs, XtNumber(boxArgs));
return(self);
}
/*
* return the list of index that are being displayed in the interface, ie,
* that could be edited or interpolated.
*/
Pixel *EditingIndexes(cnt)
int *cnt;
{
*cnt = 1;
return(clist);
}
/* ARGSUSED */
Pixel GetPatchIndex(patch)
int patch;
{
AsciiWidget tw = (AsciiWidget) wlist[0];
Arg args[1];
String new;
int val;
XtSetArg (args[0], XtNstring, &new);
XtGetValues ((Widget)tw, args, 1);
val = atoi(new);
return(ConstrainIndex((Pixel)val));
}
/* void NewPatch(new, where)
* int new;
* int where;
* {
* currentPatch = new;
*
* NewIndex((int)clist[new], where);
* }
*/
void PatchDraw (wid, pix)
Widget wid;
Pixel pix;
{
Display *dpy = XtDisplayOfObject(wid);
Window win = XtWindowOfObject(wid);
Arg args[1];
XtSetArg (args[0], XtNbackground, pix);
XtSetValues (wid, args, 1);
/* if no window, must not yet be realized */
if (!dpy || !win)
return;
XSetWindowBackground (dpy, win, pix);
XClearWindow (dpy, win);
}
void UpdatePatchWidget(where)
int where;
{
Arg args[1];
Widget source;
char buf[BUFLEN];
if (where != PatchWidget) {
bzero(buf, BUFLEN);
source = XawTextGetSource(wlist[0]);
sprintf(buf, "%d", currentIndex);
XtSetArg (args[0], XtNstring, (XtPointer)buf);
XtSetValues (source, args, 1);
}
PatchDraw (wlist[1], currentIndex);
}