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 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
|
The command <comdraw-window> launches the IVTools graphic
editor "comdraw" and returns a window descriptor that
directly draws into the comdraw editable window.
IVTools is available from http://www.ivtools.org.
This feature requires version 1.0.6 with the attached patch.
These patches will be part of the forthcoming version 1.0.7.
<----------------------------------------------------------------------------->
diff -u src/ComUnidraw.orig/comeditor.c src/ComUnidraw/comeditor.c
--- src/ComUnidraw.orig/comeditor.c 2002-11-06 17:29:25.000000000 -0500
+++ src/ComUnidraw/comeditor.c 2002-11-06 17:42:41.000000000 -0500
@@ -149,7 +149,10 @@
comterp->add_command("brush", new BrushFunc(comterp, this));
comterp->add_command("pattern", new PatternFunc(comterp, this));
comterp->add_command("colors", new ColorFunc(comterp, this));
-
+ //SECIL
+ comterp->add_command("fontbyname", new FontByNameFunc(comterp, this));
+ comterp->add_command("colorsrgb", new ColorRgbFunc(comterp, this));
+ //SECIL
comterp->add_command("nfonts", new NFontsFunc(comterp, this));
comterp->add_command("nbrushes", new NBrushesFunc(comterp, this));
comterp->add_command("npatterns", new NPatternsFunc(comterp, this));
@@ -218,6 +221,9 @@
comterp->add_command("poke", new PixelPokeFunc(comterp, this));
comterp->add_command("peek", new PixelPeekFunc(comterp, this));
+ //SECIL
+ comterp->add_command("pokeline", new PixelPokeLineFunc(comterp, this));
+ //SECIL
comterp->add_command("pcols", new PixelColsFunc(comterp, this));
comterp->add_command("prows", new PixelRowsFunc(comterp, this));
comterp->add_command("pflush", new PixelFlushFunc(comterp, this));
Only in src/ComUnidraw: comeditor.c.rej
diff -u src/ComUnidraw.orig/grfunc.c src/ComUnidraw/grfunc.c
--- src/ComUnidraw.orig/grfunc.c 2002-11-06 17:29:25.000000000 -0500
+++ src/ComUnidraw/grfunc.c 2002-11-06 17:42:41.000000000 -0500
@@ -62,6 +62,13 @@
#include <Unidraw/Graphic/ellipses.h>
#include <InterViews/transformer.h>
+//SECIL
+#include <IV-2_6/InterViews/world.h>
+#include <IV-X11/Xlib.h>
+#include <IV-X11/xdisplay.h>
+#include <IV-X11/xfont.h>
+#include <X11/Xatom.h>
+//SECIL
#include <Attribute/aliterator.h>
#include <Attribute/attrlist.h>
@@ -673,6 +680,143 @@
}
/*****************************************************************************/
+//SECIL
+FontByNameFunc::FontByNameFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) {
+}
+
+static char *psfonttoxfont(char* f)
+{
+ /* convert a PS name to a X... */
+ char type[10];
+ int size=0;
+ static char copy[256];
+ static char name[256];
+ static char *wght[] = { "bold","demi","light","demibold","book",0 };
+ char *s;
+
+ if (*f=='-')
+ return f;
+
+ strcpy(copy,f);
+ s = copy;
+ while (*s) {
+ *s = tolower(*s);
+ s++;
+ }
+ f = copy+strlen(copy);
+
+ s = strchr(copy,'-');
+ if (!s) {
+ strcpy(type,"medium-r");
+ } else {
+ *s=0;
+ s++;
+ for (size=0;wght[size];size++)
+ if (!strncmp(s,wght[size],strlen(wght[size]))) {
+ strcpy(type,wght[size]);
+ strcat(type,"-");
+ s+=strlen(wght[size]);
+ break;
+ }
+ if (!wght[size])
+ strcpy(type,"medium-");
+ switch (*s) {
+ case 'i':
+ strcat(type,"i");
+ break;
+ case 'o':
+ strcat(type,"o");
+ break;
+ default:
+ strcat(type,"r");
+ break;
+ }
+ }
+
+ size = 11;
+ while (f[-1]>='0' && f[-1]<='9')
+ f--;
+
+ if (*f)
+ size = atoi(f);
+ f[0] = 0;
+ if (f[-1]=='-')
+ f[-1] = 0;
+ sprintf(name,"-*-%s-%s-normal-*-%d-*",
+ copy, type, size );
+ return name;
+}
+/*****************************************************************************/
+void FontByNameFunc::execute() {
+ ComValue& fontarg = stack_arg(0);
+ const char* fontval = fontarg.string_ptr();
+ reset_stack();
+
+ char* fontvaldup=strdup(fontval);
+ Catalog* catalog = unidraw->GetCatalog();
+ XDisplay* dpy =World::current()->display()->rep()->display_;
+ XFontStruct* xfs = XLoadQueryFont(dpy, fontvaldup);
+ PSFont* font = nil;
+
+ if (!xfs){
+ char* xfontval=psfonttoxfont(fontvaldup);
+ fontvaldup = strdup(xfontval);
+ xfs = XLoadQueryFont(dpy,xfontval);
+ if (!xfs){
+ fprintf(stderr, "Can not load font: %s, \n", fontval);
+ fprintf(stderr, "Keeping the current font.\n");
+ }
+ }
+ if (xfs){
+ unsigned long value;
+ char fontname[CHARBUFSIZE];
+ char fontsizeptr[CHARBUFSIZE];
+ char fontfullname[CHARBUFSIZE];
+
+ XGetFontProperty(xfs, XA_FULL_NAME, &value);
+ strcpy(fontfullname, XGetAtomName(dpy, (Atom)value));
+
+ XGetFontProperty(xfs, XA_FONT_NAME, &value);
+ strcpy(fontname, XGetAtomName(dpy, (Atom)value));
+
+ XGetFontProperty(xfs,XA_POINT_SIZE, &value);
+ sprintf(fontsizeptr,"%d",(unsigned int)(value/10));
+
+ font = catalog->FindFont(fontvaldup,fontname,fontsizeptr);
+ delete fontvaldup;
+ }
+ FontCmd* cmd = nil;
+
+ if (font) {
+ cmd = new FontCmd(_ed, font);
+ }
+
+ execute_log(cmd);
+}
+/*****************************************************************************/
+ColorRgbFunc::ColorRgbFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) {
+ }
+
+void ColorRgbFunc::execute() {
+ ComValue& fgarg = stack_arg(0);
+ ComValue& bgarg = stack_arg(1);
+ const char* fgname = fgarg.string_ptr();
+ const char* bgname = bgarg.string_ptr();
+ reset_stack();
+ PSColor* fgcolor=nil;
+ PSColor* bgcolor=nil;
+ Catalog* catalog = unidraw->GetCatalog();
+ fgcolor = catalog->FindColor(fgname);
+ //This comparison is made because the user can set only the foreground color by calling
+ //colorsrgb with one argument.
+ if (strcmp(bgname,"sym")!=0){
+ bgcolor = catalog->FindColor(bgname);
+ }
+ ColorCmd* cmd = new ColorCmd(_ed, fgcolor, bgcolor);
+ execute_log(cmd);
+}
+/*****************************************************************************/
+//SECIL
BrushFunc::BrushFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) {
}
Only in src/ComUnidraw: grfunc.c.orig
Only in src/ComUnidraw: grfunc.c.rej
diff -u src/ComUnidraw.orig/grfunc.h src/ComUnidraw/grfunc.h
--- src/ComUnidraw.orig/grfunc.h 2002-11-06 17:29:25.000000000 -0500
+++ src/ComUnidraw/grfunc.h 2002-11-06 17:42:41.000000000 -0500
@@ -131,6 +131,17 @@
return "%s(fontnum) -- set current font from menu order"; }
};
+//SECIL
+//: command for setting font state variable by font name in comdraw.
+// fontbyname(fontname) -- set current font by name
+class FontByNameFunc : public UnidrawFunc {
+ public:
+ FontByNameFunc(ComTerp*,Editor*);
+ virtual void execute();
+ virtual const char* docstring() {
+ return "%s(fontname) -- set current font by X font name"; }
+};
+
//: command for setting brush state variable in comdraw.
// brush(brushnum) -- set current brush from menu order
class BrushFunc : public UnidrawFunc {
@@ -161,6 +172,18 @@
return "%s(fgcolornum bgcolornum) -- set current colors from menu order"; }
};
+//SECIL
+//:comand for setting color state variables by RGB name in comdraw.
+// colors(fgcolorname bgcolorname). The colorname format is "#RRGGBB"
+class ColorRgbFunc : public UnidrawFunc {
+ public:
+ ColorRgbFunc(ComTerp*,Editor*);
+ virtual void execute();
+ virtual const char* docstring() {
+ return "%s(fgcolorname bgcolorname) -- set current colors by RGB name. The colorname format is \"#RGB\" for 4 bits, \"#RRGGBB\" for 8 bits,\"#RRRGGGBBB\" for 12 bits,\"#RRRRGGGGBBBB\" for 16 bits"; }
+};
+//SECIL
+
//: command to select graphics in comdraw.
// select([compview ...] :all :clear) -- make these graphics the current selection,
// default returns current selection.
diff -u src/ComUnidraw.orig/pixelfunc.c src/ComUnidraw/pixelfunc.c
--- src/ComUnidraw.orig/pixelfunc.c 2002-11-06 17:29:25.000000000 -0500
+++ src/ComUnidraw/pixelfunc.c 2002-11-06 17:43:40.000000000 -0500
@@ -28,6 +28,59 @@
#include <Unidraw/iterator.h>
#include <Unidraw/viewer.h>
#include <Attribute/attrlist.h>
+//SECIL
+#include <IV-2_6/InterViews/world.h>
+/*****************************************************************************/
+PixelPokeLineFunc::PixelPokeLineFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) {
+}
+
+void PixelPokeLineFunc::execute() {
+ Viewer* viewer = _ed->GetViewer();
+
+ ComValue rastcompv(stack_arg(0));
+ ComValue xv(stack_arg(1));
+ ComValue yv(stack_arg(2));
+ ComValue wv(stack_arg(3));
+ ComValue vallistv(stack_arg(4));
+ int xval = xv.int_val();
+ int yval = yv.int_val();
+ int wval = wv.int_val();
+ int pixelvals[wval];
+
+ if(!vallistv.is_type(ComValue::ArrayType) || vallistv.array_len() != wval){
+ reset_stack();
+ push_stack(ComValue::nullval());
+ return;
+ }
+
+ ALIterator i;
+ AttributeValueList* avl = vallistv.array_val();
+ avl->First(i);
+ for (int j=0; j<wval && !avl->Done(i); j++){
+ pixelvals[j]= avl->GetAttrVal(i)->int_val();
+ avl->Next(i);
+ }
+ reset_stack();
+
+ RasterOvComp* rastcomp = (RasterOvComp*) rastcompv.geta(RasterOvComp::class_symid());
+ OverlayRasterRect* rastrect = rastcomp ? rastcomp->GetOverlayRasterRect() : nil;
+ OverlayRaster* raster = rastrect ? rastrect->GetOriginal() : nil;
+
+ if (raster) {
+ for(int j=0; j<wval; j++){
+ ColorIntensity r,g,b;
+ int pixelcolor = pixelvals[j];
+ char colorname[7];
+ sprintf(colorname,"#%06x",pixelcolor);
+ Color::find(World::current()->display(),colorname, r, g, b);
+ raster->poke(xval+j, yval, r, g, b, 1.0);
+ }
+ push_stack(rastcompv);
+ }
+ else
+ push_stack(ComValue::nullval());
+}
+//SECIL
/*****************************************************************************/
diff -u src/ComUnidraw.orig/pixelfunc.h src/ComUnidraw/pixelfunc.h
--- src/ComUnidraw.orig/pixelfunc.h 2002-11-06 17:29:25.000000000 -0500
+++ src/ComUnidraw/pixelfunc.h 2002-11-06 17:45:09.000000000 -0500
@@ -26,6 +26,21 @@
#include <ComUnidraw/unifunc.h>
+//SECIL
+//: command to poke a line of pixel values into raster
+// pokeline(compview x y w vallist) -- poke pixel values of a line listed in vallist into raster. w is the width of the line(length of the list).
+
+class PixelPokeLineFunc : public UnidrawFunc {
+ public:
+ PixelPokeLineFunc(ComTerp*,Editor*);
+ virtual void execute();
+ virtual const char* docstring() {
+ return "%s(compview x y w vallist) -- poke pixel values of a line listed in vallist into raster. w is the width of the line(length of the list)";
+ }
+};
+
+//SECIL
+
//: command to poke pixel values into raster
// poke(compview x y val) -- poke pixel value into raster
class PixelPokeFunc : public UnidrawFunc {
|