| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#include <tkInt.h> |
| 16 |
|
| 17 |
#if !defined(MAC_TCL) && !defined(MAC_OSX_TK) |
| 18 |
# include <X11/Xlib.h> |
| 19 |
#endif |
| 20 |
#ifdef MAC_TCL |
| 21 |
# include <Xlib.h> |
| 22 |
# include <X.h> |
| 23 |
# define Cursor XCursor |
| 24 |
# define Region XRegion |
| 25 |
#endif |
| 26 |
#ifdef MAC_OSX_TK |
| 27 |
# include <X11/Xlib.h> |
| 28 |
# include <X11/X.h> |
| 29 |
# define Cursor XCursor |
| 30 |
# define Region XRegion |
| 31 |
#endif |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
GC |
| 51 |
XCreateGC(display, d, mask, values) |
| 52 |
Display* display; |
| 53 |
Drawable d; |
| 54 |
unsigned long mask; |
| 55 |
XGCValues* values; |
| 56 |
{ |
| 57 |
GC gp; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
#define MAX_DASH_LIST_SIZE 10 |
| 66 |
|
| 67 |
gp = (XGCValues *)ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE); |
| 68 |
if (!gp) { |
| 69 |
return None; |
| 70 |
} |
| 71 |
|
| 72 |
gp->function = (mask & GCFunction) ?values->function :GXcopy; |
| 73 |
gp->plane_mask = (mask & GCPlaneMask) ?values->plane_mask :~0; |
| 74 |
gp->foreground = (mask & GCForeground) ?values->foreground :0; |
| 75 |
gp->background = (mask & GCBackground) ?values->background :0xffffff; |
| 76 |
gp->line_width = (mask & GCLineWidth) ?values->line_width :0; |
| 77 |
gp->line_style = (mask & GCLineStyle) ?values->line_style :LineSolid; |
| 78 |
gp->cap_style = (mask & GCCapStyle) ?values->cap_style :0; |
| 79 |
gp->join_style = (mask & GCJoinStyle) ?values->join_style :0; |
| 80 |
gp->fill_style = (mask & GCFillStyle) ?values->fill_style :FillSolid; |
| 81 |
gp->fill_rule = (mask & GCFillRule) ?values->fill_rule :WindingRule; |
| 82 |
gp->arc_mode = (mask & GCArcMode) ?values->arc_mode :ArcPieSlice; |
| 83 |
gp->tile = (mask & GCTile) ?values->tile :None; |
| 84 |
gp->stipple = (mask & GCStipple) ?values->stipple :None; |
| 85 |
gp->ts_x_origin = (mask & GCTileStipXOrigin) ?values->ts_x_origin:0; |
| 86 |
gp->ts_y_origin = (mask & GCTileStipYOrigin) ?values->ts_y_origin:0; |
| 87 |
gp->font = (mask & GCFont) ?values->font :None; |
| 88 |
gp->subwindow_mode = (mask & GCSubwindowMode)?values->subwindow_mode:ClipByChildren; |
| 89 |
gp->graphics_exposures = (mask & GCGraphicsExposures)?values->graphics_exposures:True; |
| 90 |
gp->clip_x_origin = (mask & GCClipXOrigin) ?values->clip_x_origin :0; |
| 91 |
gp->clip_y_origin = (mask & GCClipYOrigin) ?values->clip_y_origin :0; |
| 92 |
gp->dash_offset = (mask & GCDashOffset) ?values->dash_offset :0; |
| 93 |
gp->dashes = (mask & GCDashList) ?values->dashes :4; |
| 94 |
(&(gp->dashes))[1] = 0; |
| 95 |
|
| 96 |
if (mask & GCClipMask) { |
| 97 |
gp->clip_mask = (Pixmap)ckalloc(sizeof(TkpClipMask)); |
| 98 |
((TkpClipMask*)gp->clip_mask)->type = TKP_CLIP_PIXMAP; |
| 99 |
((TkpClipMask*)gp->clip_mask)->value.pixmap = values->clip_mask; |
| 100 |
} else { |
| 101 |
gp->clip_mask = None; |
| 102 |
} |
| 103 |
|
| 104 |
return gp; |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
void |
| 125 |
XChangeGC(d, gc, mask, values) |
| 126 |
Display * d; |
| 127 |
GC gc; |
| 128 |
unsigned long mask; |
| 129 |
XGCValues *values; |
| 130 |
{ |
| 131 |
if (mask & GCFunction) { gc->function = values->function; } |
| 132 |
if (mask & GCPlaneMask) { gc->plane_mask = values->plane_mask; } |
| 133 |
if (mask & GCForeground) { gc->foreground = values->foreground; } |
| 134 |
if (mask & GCBackground) { gc->background = values->background; } |
| 135 |
if (mask & GCLineWidth) { gc->line_width = values->line_width; } |
| 136 |
if (mask & GCLineStyle) { gc->line_style = values->line_style; } |
| 137 |
if (mask & GCCapStyle) { gc->cap_style = values->cap_style; } |
| 138 |
if (mask & GCJoinStyle) { gc->join_style = values->join_style; } |
| 139 |
if (mask & GCFillStyle) { gc->fill_style = values->fill_style; } |
| 140 |
if (mask & GCFillRule) { gc->fill_rule = values->fill_rule; } |
| 141 |
if (mask & GCArcMode) { gc->arc_mode = values->arc_mode; } |
| 142 |
if (mask & GCTile) { gc->tile = values->tile; } |
| 143 |
if (mask & GCStipple) { gc->stipple = values->stipple; } |
| 144 |
if (mask & GCTileStipXOrigin) { gc->ts_x_origin = values->ts_x_origin; } |
| 145 |
if (mask & GCTileStipYOrigin) { gc->ts_y_origin = values->ts_y_origin; } |
| 146 |
if (mask & GCFont) { gc->font = values->font; } |
| 147 |
if (mask & GCSubwindowMode) { gc->subwindow_mode = values->subwindow_mode; } |
| 148 |
if (mask & GCGraphicsExposures) { gc->graphics_exposures = values->graphics_exposures; } |
| 149 |
if (mask & GCClipXOrigin) { gc->clip_x_origin = values->clip_x_origin; } |
| 150 |
if (mask & GCClipYOrigin) { gc->clip_y_origin = values->clip_y_origin; } |
| 151 |
if (mask & GCClipMask) { XSetClipMask(d, gc, values->clip_mask); } |
| 152 |
if (mask & GCDashOffset) { gc->dash_offset = values->dash_offset; } |
| 153 |
if (mask & GCDashList) { gc->dashes = values->dashes; (&(gc->dashes))[1] = 0;} |
| 154 |
} |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
void XFreeGC(d, gc) |
| 173 |
Display * d; |
| 174 |
GC gc; |
| 175 |
{ |
| 176 |
if (gc != None) { |
| 177 |
if (gc->clip_mask != None) { |
| 178 |
ckfree((char*) gc->clip_mask); |
| 179 |
} |
| 180 |
ckfree((char *) gc); |
| 181 |
} |
| 182 |
} |
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
void |
| 202 |
XSetForeground(display, gc, foreground) |
| 203 |
Display *display; |
| 204 |
GC gc; |
| 205 |
unsigned long foreground; |
| 206 |
{ |
| 207 |
gc->foreground = foreground; |
| 208 |
} |
| 209 |
|
| 210 |
void |
| 211 |
XSetBackground(display, gc, background) |
| 212 |
Display *display; |
| 213 |
GC gc; |
| 214 |
unsigned long background; |
| 215 |
{ |
| 216 |
gc->background = background; |
| 217 |
} |
| 218 |
|
| 219 |
void |
| 220 |
XSetDashes(display, gc, dash_offset, dash_list, n) |
| 221 |
Display* display; |
| 222 |
GC gc; |
| 223 |
int dash_offset; |
| 224 |
_Xconst char* dash_list; |
| 225 |
int n; |
| 226 |
{ |
| 227 |
char *p = &(gc->dashes); |
| 228 |
|
| 229 |
#ifdef TkWinDeleteBrush |
| 230 |
TkWinDeleteBrush(gc->fgBrush); |
| 231 |
TkWinDeletePen(gc->fgPen); |
| 232 |
TkWinDeleteBrush(gc->bgBrush); |
| 233 |
TkWinDeletePen(gc->fgExtPen); |
| 234 |
#endif |
| 235 |
gc->dash_offset = dash_offset; |
| 236 |
if (n > MAX_DASH_LIST_SIZE) n = MAX_DASH_LIST_SIZE; |
| 237 |
while (n-- > 0) { |
| 238 |
*p++ = *dash_list++; |
| 239 |
} |
| 240 |
*p = 0; |
| 241 |
} |
| 242 |
|
| 243 |
void |
| 244 |
XSetFunction(display, gc, function) |
| 245 |
Display *display; |
| 246 |
GC gc; |
| 247 |
int function; |
| 248 |
{ |
| 249 |
gc->function = function; |
| 250 |
} |
| 251 |
|
| 252 |
void |
| 253 |
XSetFillRule(display, gc, fill_rule) |
| 254 |
Display *display; |
| 255 |
GC gc; |
| 256 |
int fill_rule; |
| 257 |
{ |
| 258 |
gc->fill_rule = fill_rule; |
| 259 |
} |
| 260 |
|
| 261 |
void |
| 262 |
XSetFillStyle(display, gc, fill_style) |
| 263 |
Display *display; |
| 264 |
GC gc; |
| 265 |
int fill_style; |
| 266 |
{ |
| 267 |
gc->fill_style = fill_style; |
| 268 |
} |
| 269 |
|
| 270 |
void |
| 271 |
XSetTSOrigin(display, gc, x, y) |
| 272 |
Display *display; |
| 273 |
GC gc; |
| 274 |
int x, y; |
| 275 |
{ |
| 276 |
gc->ts_x_origin = x; |
| 277 |
gc->ts_y_origin = y; |
| 278 |
} |
| 279 |
|
| 280 |
void |
| 281 |
XSetFont(display, gc, font) |
| 282 |
Display *display; |
| 283 |
GC gc; |
| 284 |
Font font; |
| 285 |
{ |
| 286 |
gc->font = font; |
| 287 |
} |
| 288 |
|
| 289 |
void |
| 290 |
XSetArcMode(display, gc, arc_mode) |
| 291 |
Display *display; |
| 292 |
GC gc; |
| 293 |
int arc_mode; |
| 294 |
{ |
| 295 |
gc->arc_mode = arc_mode; |
| 296 |
} |
| 297 |
|
| 298 |
void |
| 299 |
XSetStipple(display, gc, stipple) |
| 300 |
Display *display; |
| 301 |
GC gc; |
| 302 |
Pixmap stipple; |
| 303 |
{ |
| 304 |
gc->stipple = stipple; |
| 305 |
} |
| 306 |
|
| 307 |
void |
| 308 |
XSetLineAttributes(display, gc, line_width, line_style, cap_style, |
| 309 |
join_style) |
| 310 |
Display *display; |
| 311 |
GC gc; |
| 312 |
unsigned int line_width; |
| 313 |
int line_style; |
| 314 |
int cap_style; |
| 315 |
int join_style; |
| 316 |
{ |
| 317 |
gc->line_width = line_width; |
| 318 |
gc->line_style = line_style; |
| 319 |
gc->cap_style = cap_style; |
| 320 |
gc->join_style = join_style; |
| 321 |
} |
| 322 |
|
| 323 |
void |
| 324 |
XSetClipOrigin(display, gc, clip_x_origin, clip_y_origin) |
| 325 |
Display* display; |
| 326 |
GC gc; |
| 327 |
int clip_x_origin; |
| 328 |
int clip_y_origin; |
| 329 |
{ |
| 330 |
gc->clip_x_origin = clip_x_origin; |
| 331 |
gc->clip_y_origin = clip_y_origin; |
| 332 |
} |
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
void |
| 356 |
TkSetRegion(display, gc, r) |
| 357 |
Display* display; |
| 358 |
GC gc; |
| 359 |
TkRegion r; |
| 360 |
{ |
| 361 |
if (r == None) { |
| 362 |
if (gc->clip_mask) { |
| 363 |
ckfree((char*) gc->clip_mask); |
| 364 |
gc->clip_mask = None; |
| 365 |
} |
| 366 |
return; |
| 367 |
} |
| 368 |
|
| 369 |
if (gc->clip_mask == None) { |
| 370 |
gc->clip_mask = (Pixmap)ckalloc(sizeof(TkpClipMask)); |
| 371 |
} |
| 372 |
((TkpClipMask*)gc->clip_mask)->type = TKP_CLIP_REGION; |
| 373 |
((TkpClipMask*)gc->clip_mask)->value.region = r; |
| 374 |
} |
| 375 |
|
| 376 |
void |
| 377 |
XSetClipMask(display, gc, pixmap) |
| 378 |
Display* display; |
| 379 |
GC gc; |
| 380 |
Pixmap pixmap; |
| 381 |
{ |
| 382 |
if (pixmap == None) { |
| 383 |
if (gc->clip_mask) { |
| 384 |
ckfree((char*) gc->clip_mask); |
| 385 |
gc->clip_mask = None; |
| 386 |
} |
| 387 |
return; |
| 388 |
} |
| 389 |
|
| 390 |
if (gc->clip_mask == None) { |
| 391 |
gc->clip_mask = (Pixmap)ckalloc(sizeof(TkpClipMask)); |
| 392 |
} |
| 393 |
((TkpClipMask*)gc->clip_mask)->type = TKP_CLIP_PIXMAP; |
| 394 |
((TkpClipMask*)gc->clip_mask)->value.pixmap = pixmap; |
| 395 |
} |
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
Cursor |
| 402 |
XCreateFontCursor(display, shape) |
| 403 |
Display* display; |
| 404 |
unsigned int shape; |
| 405 |
{ |
| 406 |
return (Cursor) 0; |
| 407 |
} |
| 408 |
|
| 409 |
void |
| 410 |
XDrawImageString(display, d, gc, x, y, string, length) |
| 411 |
Display* display; |
| 412 |
Drawable d; |
| 413 |
GC gc; |
| 414 |
int x; |
| 415 |
int y; |
| 416 |
_Xconst char* string; |
| 417 |
int length; |
| 418 |
{ |
| 419 |
} |
| 420 |
|
| 421 |
void |
| 422 |
XDrawPoint(display, d, gc, x, y) |
| 423 |
Display* display; |
| 424 |
Drawable d; |
| 425 |
GC gc; |
| 426 |
int x; |
| 427 |
int y; |
| 428 |
{ |
| 429 |
XDrawLine(display, d, gc, x, y, x, y); |
| 430 |
} |
| 431 |
|
| 432 |
#if 0 |
| 433 |
void |
| 434 |
XDrawPoints(display, d, gc, points, npoints, mode) |
| 435 |
Display* display; |
| 436 |
Drawable d; |
| 437 |
GC gc; |
| 438 |
XPoint* points; |
| 439 |
int npoints; |
| 440 |
int mode; |
| 441 |
{ |
| 442 |
int i; |
| 443 |
|
| 444 |
for (i=0; i<npoints; i++) { |
| 445 |
XDrawPoint(display, d, gc, points[i].x, points[i].y); |
| 446 |
} |
| 447 |
} |
| 448 |
#endif |
| 449 |
|
| 450 |
#if !defined(MAC_TCL) && !defined(MAC_OSX_TK) |
| 451 |
void |
| 452 |
XDrawSegments(display, d, gc, segments, nsegments) |
| 453 |
Display* display; |
| 454 |
Drawable d; |
| 455 |
GC gc; |
| 456 |
XSegment* segments; |
| 457 |
int nsegments; |
| 458 |
{ |
| 459 |
} |
| 460 |
#endif |
| 461 |
|
| 462 |
char * |
| 463 |
XFetchBuffer(display, nbytes_return, buffer) |
| 464 |
Display* display; |
| 465 |
int* nbytes_return; |
| 466 |
int buffer; |
| 467 |
{ |
| 468 |
return (char *) 0; |
| 469 |
} |
| 470 |
|
| 471 |
int |
| 472 |
XFetchName(display, w, window_name_return) |
| 473 |
Display* display; |
| 474 |
Window w; |
| 475 |
char** window_name_return; |
| 476 |
{ |
| 477 |
*window_name_return = NULL; |
| 478 |
return 0; |
| 479 |
} |
| 480 |
|
| 481 |
Atom *XListProperties(display, w, num_prop_return) |
| 482 |
Display* display; |
| 483 |
Window w; |
| 484 |
int* num_prop_return; |
| 485 |
{ |
| 486 |
return (Atom *) 0; |
| 487 |
} |
| 488 |
|
| 489 |
void |
| 490 |
XMapRaised(display, w) |
| 491 |
Display* display; |
| 492 |
Window w; |
| 493 |
{ |
| 494 |
} |
| 495 |
|
| 496 |
#ifndef XPutImage |
| 497 |
void |
| 498 |
XPutImage(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height) |
| 499 |
Display* display; |
| 500 |
Drawable d; |
| 501 |
GC gc; |
| 502 |
XImage *image; |
| 503 |
int src_x; |
| 504 |
int src_y; |
| 505 |
int dest_x; |
| 506 |
int dest_y; |
| 507 |
unsigned int width; |
| 508 |
unsigned int height; |
| 509 |
{ |
| 510 |
} |
| 511 |
#endif |
| 512 |
|
| 513 |
void XQueryTextExtents(display, font_ID, string, nchars, direction_return, |
| 514 |
font_ascent_return, font_descent_return, overall_return) |
| 515 |
Display* display; |
| 516 |
XID font_ID; |
| 517 |
_Xconst char* string; |
| 518 |
int nchars; |
| 519 |
int* direction_return; |
| 520 |
int* font_ascent_return; |
| 521 |
int* font_descent_return; |
| 522 |
XCharStruct* overall_return; |
| 523 |
{ |
| 524 |
} |
| 525 |
|
| 526 |
void |
| 527 |
XReparentWindow(display, w, parent, x, y) |
| 528 |
Display* display; |
| 529 |
Window w; |
| 530 |
Window parent; |
| 531 |
int x; |
| 532 |
int y; |
| 533 |
{ |
| 534 |
} |
| 535 |
|
| 536 |
void |
| 537 |
XRotateBuffers(display, rotate) |
| 538 |
Display* display; |
| 539 |
int rotate; |
| 540 |
{ |
| 541 |
} |
| 542 |
|
| 543 |
void |
| 544 |
XStoreBuffer(display, bytes, nbytes, buffer) |
| 545 |
Display* display; |
| 546 |
_Xconst char* bytes; |
| 547 |
int nbytes; |
| 548 |
int buffer; |
| 549 |
{ |
| 550 |
} |
| 551 |
|
| 552 |
void |
| 553 |
XUndefineCursor(display, w) |
| 554 |
Display* display; |
| 555 |
Window w; |
| 556 |
{ |
| 557 |
} |