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
/
gesture.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-28
|
7KB
|
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
* gesture.c -- various routines to handle specific actions
*
* DESCRIPTION
*
*
* HISTORY
*
* HISTORY END
*
*/
#ifndef LINT
static char *copy_notice = "Copyright 1991 Tektronix, Inc.";
#ifdef RCS_ID
static char *rcsid= "$Header: gesture.c,v 1.1 91/08/22 11:15:04 adamsc Exp $";
#endif /* RCS_ID */
#endif /* LINT */
#include "xtici.h"
#include <X11/Xaw/AsciiText.h>
/* indicates if the user is in the middle of a gesture */
int gesture = GestureNone;
Bool restoreFill = False;
/* This is a routine that looks to see if a valid entry has
* been made in a text widget.
*/
/* ARGSUSED */
void Leave (wid, event)
Widget wid;
XAnyEvent event;
{
switch (gesture) {
case GestureHue:
case GestureValue:
case GestureChroma:
case GestureRed:
case GestureGreen:
case GestureBlue:
case GestureUprime:
case GestureVprime:
case GestureCapY:
case GestureCell0:
case GestureCell1:
break;
default:
return;
}
TerminateGesture();
gesture = GestureNone;
}
/*
* The user has begun a new gesture.
* Examine the current state to determine if an existing gesture must be
* terminated. Set the passed undo state and new gesture.
*/
void BeginGesture(gestureFlag)
int gestureFlag;
{
if (gesture != GestureNone)
TerminateGesture();
if ( (gestureFlag == GestureMouse) && (leafState & LeafFilled) ) {
restoreFill = True;
NewLeafState(leafState & ~LeafFilled, NoWidget);
}
gesture = gestureFlag;
}
/*
* A gesture which changed the color has ended. Adjust state and interface.
* Assumes currentHvc contains the latest values.
*/
void EndColor(from)
int from;
{
gesture = GestureNone;
if (restoreFill) {
restoreFill = False;
NewLeafState(leafState | LeafFilled, NoWidget);
}
if (RgbShowing && (from != RgbWidget) )
UpdateShowWidget(RgbWidget);
if (UvyShowing && (from != UvyWidget) )
UpdateShowWidget(UvyWidget);
}
void EndIndex(from)
int from;
{
gesture = GestureNone;
/* May have ended on a reserved index, don't allow that */
if (IndexProtected(currentIndex)) {
return;
}
EndColor(from);
}
/*
* Take action to force user to terminate a gesture or abort it.
* Mouse gestures are automatically terminated by the constraints of
* button transition reporting when dragging.
* What we are really addressing here is when the user types in text
* and then moves off to somewhere else without entering (CR).
* We cannot allow this because this leaves text in the widget that
* does not accurately reflect current values.
*/
static char *returnHelp = "\
Values entered into text sensitive fields are not applied until a the\n\
carriage return key is used. If you choose OK, the text will be applied\n\
as if you had typed the return. If you choose Cancel, the entered text\n\
will be discarded.";
void TerminateGesture()
{
XcmsColor hvc;
int change = 0;
XColor rgb;
XcmsCIEuvY uvy;
Pixel newIndex;
/* This should not happen */
if (gesture <= GestureMouse) {
return;
}
if (Ask("Apply last keyboard input?", returnHelp) == MessageOK) {
/* get text value and apply */
/* does no good to set undo here, user has started another gesture */
switch (gesture) {
case GestureHue:
case GestureValue:
case GestureChroma:
GetShowHvc(&hvc);
if (hvc.spec.TekHVC.H != currentHvc.spec.TekHVC.H)
change |= HueChange;
if (hvc.spec.TekHVC.V != currentHvc.spec.TekHVC.V)
change |= ValueChange;
if (hvc.spec.TekHVC.C != currentHvc.spec.TekHVC.C)
change |= ChromaChange;
if (change) {
hvc.pixel = currentHvc.pixel;
NewHvc(&hvc, NoWidget, change);
}
break;
case GestureRed:
case GestureGreen:
case GestureBlue:
GetShowRgb(&rgb);
if (rgb.red != currentRgb.red)
NewRgb(RedChange, rgb.red, NoWidget);
if (rgb.green != currentRgb.green)
NewRgb(GreenChange, rgb.green, NoWidget);
if (rgb.blue != currentRgb.blue)
NewRgb(BlueChange, rgb.blue, NoWidget);
break;
case GestureUprime:
case GestureVprime:
case GestureCapY:
GetShowUvy(&uvy);
if (uvy.u_prime != currentUvy.u_prime)
NewUvy(UprimeChange, uvy.u_prime, NoWidget);
if (uvy.v_prime != currentUvy.v_prime)
NewUvy(VprimeChange, uvy.v_prime, NoWidget);
if (uvy.Y != currentUvy.Y)
NewUvy(CapYChange, uvy.Y, NoWidget);
break;
case GestureCell0:
case GestureCell1:
newIndex = GetPatchIndex(gesture - GestureCell0);
if (newIndex != currentIndex)
NewIndex((int)newIndex, NoWidget);
else
UpdatePatchWidget(NoWidget);
break;
}
#ifdef LATER
} else {
/* reset text value */
switch (gesture) {
case GestureHue:
case GestureValue:
case GestureChroma:
UpdateShowWidget(HvcWidget);
break;
case GestureRed:
case GestureGreen:
case GestureBlue:
UpdateShowWidget(RgbWidget);
break;
case GestureUprime:
case GestureVprime:
case GestureCapY:
UpdateShowWidget(UvyWidget);
break;
case GestureCell0:
case GestureCell1:
UpdatePatchWidget(NoWidget);
break;
}
#endif
}
}