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
/
leaf.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-28
|
7KB
|
260 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
* leaf - deal with the hue leaf widget
*
* DESCRIPTION
* Create, update and respond to user input in the leaf widget.
*/
#ifndef LINT
static char *copy_notice = "Copyright 1991 Tektronix, Inc.";
#ifdef RCS_ID
static char *rcsid= "$Header: leaf.c,v 1.2 91/08/22 11:33:53 adamsc Exp $";
#endif /* RCS_ID */
#endif /* LINT */
/*
* EXTERNAL INCLUDES
*/
/*
* INTERNAL INCLUDES
*/
#include "xtici.h"
#include "widgets/HvcleafP.h"
#include "widgets/Hueleaf.h"
/*
* EXTERNS
*/
/*
* GLOBALS
*/
#ifdef DEC
# define GLOBAL global
#else
# define GLOBAL
#endif
/*
* LOCAL DEFINES
*/
/*
* LOCAL TYPEDEFS
*/
/*
* LOCALS VARIABLES
*/
#ifdef DEBUG
# define STATIC
#else
# define STATIC static
#endif
STATIC Widget leafGraph;
STATIC XcmsFloat valueInc = 1.0;
STATIC XcmsFloat chromaInc = 1.0;
/************************************************************************
* *
* PRIVATE ROUTINES *
* *
************************************************************************/
/* ARGSUSED */
STATIC void leafInc(w, pdirection, pcall)
Widget w;
XtPointer pdirection;
XtPointer pcall;
{
int direction = (int)pdirection;
ScaleCallbackStruct *call = (ScaleCallbackStruct *)pcall;
XcmsColor new;
int what;
/* just indicates change-of-gesture; don't change hvc */
if (call->reason == CR_DISARM) {
EndColor(LeafWidget);
return;
}
if (call->reason == CR_ARM) {
BeginGesture(GestureMouse);
return;
}
new.pixel = currentHvc.pixel;
new.format = XcmsTekHVCFormat;
new.spec.TekHVC.H = currentHvc.spec.TekHVC.H;
new.spec.TekHVC.V = currentHvc.spec.TekHVC.V;
new.spec.TekHVC.C = currentHvc.spec.TekHVC.C;
switch (direction) {
case RightArrow:
new.spec.TekHVC.C += chromaInc;
what = ChromaChange;
break;
case LeftArrow:
new.spec.TekHVC.C -= chromaInc;
what = ChromaChange;
break;
case UpArrow:
new.spec.TekHVC.V += valueInc;
what = ValueChange;
break;
case DownArrow:
new.spec.TekHVC.V -= valueInc;
what = ValueChange;
break;
}
NewHvc(&new, NoWidget, what); /* force leaf redraw */
}
/* ARGSUSED */
STATIC void leafInput(w, client, pcall)
Widget w;
XtPointer client;
XtPointer pcall;
{
HvcCallbackStruct *call = (HvcCallbackStruct *)pcall;
XcmsColor new;
/* this just indicates end-of-gesture; don't change hvc */
if (call->reason == CR_DISARM) {
EndColor(LeafWidget);
call->hvc->spec.TekHVC.V = currentHvc.spec.TekHVC.V;
call->hvc->spec.TekHVC.C = currentHvc.spec.TekHVC.C;
return;
}
if (call->reason == CR_ARM) {
BeginGesture(GestureMouse);
}
new.pixel = currentIndex;
new.spec.TekHVC.H = currentHvc.spec.TekHVC.H;
new.spec.TekHVC.V = call->hvc->spec.TekHVC.V;
new.spec.TekHVC.C = call->hvc->spec.TekHVC.C;
NewHvc(&new, LeafWidget, ValueChromaChange);
call->hvc->spec.TekHVC.V = currentHvc.spec.TekHVC.V;
call->hvc->spec.TekHVC.C = currentHvc.spec.TekHVC.C;
}
/************************************************************************
* *
* PUBLIC ROUTINES *
* *
************************************************************************/
Widget CreateLeafForm(parent, name)
Widget parent;
char *name;
{
Arg args[1];
Pixel base;
XcmsColor hvc;
Widget self;
Widget arw;
int cnt = 0;
bcopy ((char *)¤tHvc, (char *)&hvc, sizeof (XcmsColor));
XtSetArg(args[0], XtNhvc, &hvc); cnt++;
self = XtCreateManagedWidget(name, hvcleafWidgetClass, parent, args, cnt);
XtAddCallback(self, XtNactivateCallback, leafInput, (XtPointer)NULL);
leafGraph = ((HvcleafWidget)self)->hvcleaf.wlist[HueLeaf];
arw = ((HvcleafWidget)self)->hvcleaf.wlist[UpArrow];
XtAddCallback(arw, XtNarmCallback, leafInc, (XtPointer)UpArrow);
XtAddCallback(arw, XtNdisarmCallback, leafInc, (XtPointer)UpArrow);
XtAddCallback(arw, XtNactivateCallback, leafInc, (XtPointer)UpArrow);
arw = ((HvcleafWidget)self)->hvcleaf.wlist[DownArrow];
XtAddCallback(arw, XtNarmCallback, leafInc, (XtPointer)DownArrow);
XtAddCallback(arw, XtNdisarmCallback, leafInc, (XtPointer)DownArrow);
XtAddCallback(arw, XtNactivateCallback, leafInc, (XtPointer)DownArrow);
arw = ((HvcleafWidget)self)->hvcleaf.wlist[LeftArrow];
XtAddCallback(arw, XtNarmCallback, leafInc, (XtPointer)LeftArrow);
XtAddCallback(arw, XtNdisarmCallback, leafInc, (XtPointer)LeftArrow);
XtAddCallback(arw, XtNactivateCallback, leafInc, (XtPointer)LeftArrow);
arw = ((HvcleafWidget)self)->hvcleaf.wlist[RightArrow];
XtAddCallback(arw, XtNarmCallback, leafInc, (XtPointer)RightArrow);
XtAddCallback(arw, XtNdisarmCallback, leafInc, (XtPointer)RightArrow);
XtAddCallback(arw, XtNactivateCallback, leafInc, (XtPointer)RightArrow);
if (leafState & LeafFilled) {
LeafRangeSave((Pixel *)&base);
SetLeafBase(base);
}
return((Widget)self);
}
/* This cannot be done until the window for the widget is created */
void LeafRealize()
{
XDefineCursor(dpy, XtWindow(leafGraph), hvcCursor);
}
void SetLeafBase(base)
Pixel base;
{
HueleafSetBase((HueleafWidget)leafGraph, base);
}
void UpdateLeafWidget()
{
XcmsColor hvc;
Arg arg;
hvc.spec.TekHVC.H = currentHvc.spec.TekHVC.H;
hvc.spec.TekHVC.V = currentHvc.spec.TekHVC.V;
hvc.spec.TekHVC.C = currentHvc.spec.TekHVC.C;
XtSetArg(arg, XtNhvc, &hvc);
XtSetValues(leafGraph, &arg, 1);
}