1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
|
/*********************************************************************************/
/* This file is part of Xcolorsel, a multipurpose viewer for X11 rgb.txt files. */
/* Copyright (C) 1993, 1994 Michael Weller */
/* */
/* This program is free software; you can redistribute it and/or modify it under */
/* the terms of the GNU General Public License as published be the Free Software */
/* Foundation; either version 2 of the License, or (at your opinion) any later */
/* version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT */
/* ANY WARRANTY; without even the implied warranty of MERCHANBILITY or FITNESS */
/* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more */
/* details. */
/* */
/* You should have received a copy of the GNU General Public License along with */
/* this program; if not, write to the Free Software Foundation, Inc., 675 Mass */
/* Ave, Cambridge, MA 02139, USA. */
/* */
/* The author can be reached by means of email as eowmob@exp-math.uni-essen.de */
/* or eowmob@pollux.exp-math.uni-essen.de or mat42b@vm.hrz.uni-essen.de or */
/* mat42b@de0hrz1a.bitnet. Or as: Michael Weller, Heiderhoefen 116b, D 46049 */
/* Oberhausen, Germany. */
/* */
/* Part of the files are derived from the Template Widget of the Athena Widgets */
/* as published by the Massachusetts Institute of Technology. Actually these */
/* files do not contain any code by the M.I.T but only variable declarations. */
/* Nevertheless these parts of these files are still distributed under the terms */
/* of the M.I.T copyright which are here repeated: */
/* */
/* Copyright Massachusetts Institute of Technology 1987, 1988 */
/* */
/* Permission to use, copy, modify, distribute, and sell this software and its */
/* documentation for any purpose is hereby granted without fee, provided that */
/* the above copyright notice appear in all copies and that both that */
/* copyright notice and this permission notice appear in supporting */
/* documentation, and that the name of M.I.T. not be used in advertising or */
/* publicity pertaining to distribution of the software without specific, */
/* written prior permission. M.I.T. makes no representations about the */
/* suitability of this software for any purpose. It is provided "as is" */
/* without express or implied warranty. */
/* */
/* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL */
/* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T. */
/* 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 PERFORMANCE OF THIS SOFTWARE. */
/*********************************************************************************/
/*****************************************************************************************
* This defines a RgbText Widget. This is a subclass of an AsciiTextWidget. It displays *
* the contents of an rgb.txt in a standard read-only AsciiTextWidget together with *
* little tiles of color probes. Since it needs to allocate ReadWrite Colorcells at the *
* Xserver often, this is done at initialization time. So a maximum number of displayed *
* lines is needed. This is written in the max resource for correct interaction with *
* constraint widgets. *
* If the maximum Row number is exceeded, incorrect color values will be displayed. *
* *
*****************************************************************************************/
/* This was inspirated from: */
/* $XConsortium: Template.h,v 1.5 90/12/19 18:46:00 converse Exp $ */
/* Copyright Massachusetts Institute of Technology 1987, 1988
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* 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 PERFORMANCE OF THIS SOFTWARE.
*
*/
/* Additional Resources compared to the AsciiTextWidget are:
Name Class RepType Default
---- ----- ------- -------
maxRows MaxRows Dimension 30 This is the number of writeable
colorcells this widget allocates!
Use with care!
rows Rows Dimension 10 This is converted to pixels and
returned as the preferred
height of this widget
columns Columns Dimension 30 Same as above but for columns.
file File String "/usr/lib/X11/rgb.txt" The file to display
tileWidth TileWidth Dimension 3 The width of the displayed colortiles
measured in space characters
grabCursor Cursor Cursor None The cursor to use for grabbing of
colors.
maxRed MaxRed Short 0 |The Maximum of these values and
maxGreen MaxGreen Short 0 |the values in file is scaled to the
maxBlue MaxBlue Short 0 |highest R/G/B-value on the screen (65535).
maxIntensity MaxIntensity Short 255 Same as above, but applies to all R/G/B values.
Note that since scaling from zero is impossible
this value has to be at least 1.
breakPercentage BreakPercentage Short 9500 The maximum percentage a color may differ
from the selected color to be still found.
displayFormat DisplayFormat String input The format in which the colors are printed.
Allowed values are:
rgb4, rgb8, rgb12, rgb16, rgb, rgbi, ciexyz,
cieuvy, ciexyy, cielab, cieluv,
tekhvc, #rgb, #rrggbb, #rrrgggbbb, #rrrrggggbbbb,
input (These are the dezimal values out of file).
(The value is not case sensitiv. However it is
return be getvalue in same case as it was set)
realized Realized Boolean True Show values the Xserver can actual display
instead of the theoretic values.
Has no effect for displayFormat: input
comma Comma Boolean False Colorvalues are seperated by ", " instead of /
Has no effect for displayFormat: #rgb,...
Also C-style numberformats are used.
string, type, editType are forced to the needed values.
No resizes are made when rows or columns is changed!
*/
#ifndef _RgbText_h
#define _RgbText_h
#include <X11/Xaw3d/AsciiText.h>
#define XtNmaxRows "maxRows"
#define XtNrows "rows"
#define XtNcolumns "columns"
#define XtNtileWidth "tileWidth"
#define XtNmaxRed "maxRed"
#define XtNmaxGreen "maxGreen"
#define XtNmaxBlue "maxBlue"
#define XtNmaxIntensity "maxIntensity"
#define XtNbreakPercentage "breakPercentage"
#define XtNgrabCursor "grabCursor"
#define XtNdisplayFormat "displayFormat"
#define XtNrealized "realized"
#define XtNcomma "comma"
#define XtCMaxRows "MaxRows"
#define XtCRows "Rows"
#define XtCColumns "Columns"
#define XtCTileWidth "TileWidth"
#define XtCMaxRed "MaxRed"
#define XtCMaxGreen "MaxGreen"
#define XtCMaxBlue "MaxBlue"
#define XtCMaxIntensity "MaxIntensity"
#define XtCBreakPercentage "BreakPercentage"
#define XtCDisplayFormat "DisplayFormat"
#define XtCRealized "Realized"
#define XtCComma "Comma"
/* All Values in Pixels! */
typedef struct {
Cardinal offset; /* Number of selected hit (1..numhits),
0 if no hit exists. */
/* (One is best hit) */
Cardinal numhits; /* number of all hits */
Cardinal numexact; /* number of exact hits */
Dimension percentage; /* Exactness of hit in percents*100
(for example 4235 = 42.35% ) */
String repres; /* Pointer to READ-ONLY! ascii repres of
searched color */
} RgbTextAnswer;
typedef void (* RgbTextAnswerProc)(Widget w, XColor *color, RgbTextAnswer *answer);
extern String GetRgbFile(Widget w); /* get the pointer to the name of the file that was read in
(read only) valid until widget is destroyed, NULL is
returned if none is defined */
extern Cardinal GetNumEntries(Widget w); /* get the number of lines read in */
extern Cardinal GetNumDifferent(Widget w); /* number of different colors defined */
extern Cardinal GetNumRealisable(Widget w); /* get the number of different colors when realised
on the screen */
extern Dimension GetMaxPixels(Widget w); /* get the maximum height allowed in pixels. */
extern String GetColorName(Widget w); /* Gets the name of the Color in the
line in which the selection starts,
or if there is no selection in which
the cursor (caret) is positioned.
If there is no caret shown, NULL is
returned. The pointer points to read only
data!!! It is valid until a new rgb-file via
set-value file is set or the widget is deleted. */
extern int GetColorSpec(Widget w, XColor *color);
/* Same as above, but returns the color itself.
The index value is set to 0;
flags to DoRed|DoGreen|DoBlue;
If 0 is returned, there is no color
selected and black was returned. */
extern void FindColor(Widget w, XColor *color, RgbTextAnswer *answer);
/* if color == NULL, the offset-th hit is found. If
color != NULL then the given color is searched.
In both cases all fields of answer are set to the
actual values. */
extern void GrabColor(Widget w, RgbTextAnswerProc answer_proc);
/* same as FindColor, but a pointer grab is done, and
the user can select any point on the screen, which is
then given to FindColor. FindColor's answer is then
returned by calling answer_proc(w,color,answer).
The grabbed color is copied to color (with flags set
to DoRed|DoBlue|DoGreen). answer and color are returned
in read-only buffers, that are changed in the next
call to GrabColor on this widget.
These buffers remain valid and are the same until
the rgbTextWidget is destroyed.
*/
/* Miscanellous */
typedef struct _RgbTextClassRec * RgbTextWidgetClass;
typedef struct _RgbTextRec * RgbTextWidget;
extern WidgetClass rgbTextWidgetClass;
#endif /* _RgbText_h */
|