| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#include "tkInt.h" |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
typedef struct { |
| 26 |
Tk_Window tkwin; |
| 27 |
|
| 28 |
|
| 29 |
Display *display; |
| 30 |
Tcl_Interp *interp; |
| 31 |
Tcl_Command widgetCmd; |
| 32 |
Tk_OptionTable optionTable; |
| 33 |
|
| 34 |
Tcl_Obj *xPtr, *yPtr; |
| 35 |
|
| 36 |
int x, y; |
| 37 |
Tcl_Obj *sizeObjPtr; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
Tcl_Obj *borderWidthPtr; |
| 44 |
Tcl_Obj *bgBorderPtr; |
| 45 |
Tcl_Obj *fgBorderPtr; |
| 46 |
Tcl_Obj *reliefPtr; |
| 47 |
GC gc; |
| 48 |
|
| 49 |
Tcl_Obj *doubleBufferPtr; |
| 50 |
|
| 51 |
|
| 52 |
int updatePending; |
| 53 |
|
| 54 |
} Square; |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
static Tk_OptionSpec optionSpecs[] = { |
| 61 |
{TK_OPTION_BORDER, "-background", "background", "Background", |
| 62 |
"#d9d9d9", Tk_Offset(Square, bgBorderPtr), -1, 0, |
| 63 |
(ClientData) "white"}, |
| 64 |
{TK_OPTION_SYNONYM, "-bd", (char *) NULL, (char *) NULL, |
| 65 |
(char *) NULL, 0, -1, 0, (ClientData) "-borderwidth"}, |
| 66 |
{TK_OPTION_SYNONYM, "-bg", (char *) NULL, (char *) NULL, |
| 67 |
(char *) NULL, 0, -1, 0, (ClientData) "-background"}, |
| 68 |
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", |
| 69 |
"2", Tk_Offset(Square, borderWidthPtr), -1}, |
| 70 |
{TK_OPTION_BOOLEAN, "-dbl", "doubleBuffer", "DoubleBuffer", |
| 71 |
"1", Tk_Offset(Square, doubleBufferPtr), -1}, |
| 72 |
{TK_OPTION_SYNONYM, "-fg", (char *) NULL, (char *) NULL, |
| 73 |
(char *) NULL, 0, -1, 0, (ClientData) "-foreground"}, |
| 74 |
{TK_OPTION_BORDER, "-foreground", "foreground", "Foreground", |
| 75 |
"#b03060", Tk_Offset(Square, fgBorderPtr), -1, 0, |
| 76 |
(ClientData) "black"}, |
| 77 |
{TK_OPTION_PIXELS, "-posx", "posx", "PosX", "0", |
| 78 |
Tk_Offset(Square, xPtr), -1}, |
| 79 |
{TK_OPTION_PIXELS, "-posy", "posy", "PosY", "0", |
| 80 |
Tk_Offset(Square, yPtr), -1}, |
| 81 |
{TK_OPTION_RELIEF, "-relief", "relief", "Relief", |
| 82 |
"raised", Tk_Offset(Square, reliefPtr), -1}, |
| 83 |
{TK_OPTION_PIXELS, "-size", "size", "Size", "20", |
| 84 |
Tk_Offset(Square, sizeObjPtr), -1}, |
| 85 |
{TK_OPTION_END} |
| 86 |
}; |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
int SquareObjCmd _ANSI_ARGS_((ClientData clientData, |
| 93 |
Tcl_Interp *interp, int objc, |
| 94 |
Tcl_Obj * CONST objv[])); |
| 95 |
static void SquareDeletedProc _ANSI_ARGS_(( |
| 96 |
ClientData clientData)); |
| 97 |
static int SquareConfigure _ANSI_ARGS_((Tcl_Interp *interp, |
| 98 |
Square *squarePtr)); |
| 99 |
static void SquareDestroy _ANSI_ARGS_((char *memPtr)); |
| 100 |
static void SquareDisplay _ANSI_ARGS_((ClientData clientData)); |
| 101 |
static void KeepInWindow _ANSI_ARGS_((Square *squarePtr)); |
| 102 |
static void SquareObjEventProc _ANSI_ARGS_((ClientData clientData, |
| 103 |
XEvent *eventPtr)); |
| 104 |
static int SquareWidgetObjCmd _ANSI_ARGS_((ClientData clientData, |
| 105 |
Tcl_Interp *, int objc, Tcl_Obj * CONST objv[])); |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
int |
| 125 |
SquareObjCmd(clientData, interp, objc, objv) |
| 126 |
ClientData clientData; |
| 127 |
Tcl_Interp *interp; |
| 128 |
int objc; |
| 129 |
Tcl_Obj *CONST objv[]; |
| 130 |
{ |
| 131 |
Square *squarePtr; |
| 132 |
Tk_Window tkwin; |
| 133 |
Tk_OptionTable optionTable; |
| 134 |
|
| 135 |
if (objc < 2) { |
| 136 |
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); |
| 137 |
return TCL_ERROR; |
| 138 |
} |
| 139 |
|
| 140 |
tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), |
| 141 |
Tcl_GetStringFromObj(objv[1], NULL), (char *) NULL); |
| 142 |
if (tkwin == NULL) { |
| 143 |
return TCL_ERROR; |
| 144 |
} |
| 145 |
Tk_SetClass(tkwin, "Square"); |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
optionTable = Tk_CreateOptionTable(interp, optionSpecs); |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
squarePtr = (Square *) ckalloc(sizeof(Square)); |
| 163 |
memset((void *) squarePtr, 0, (sizeof(Square))); |
| 164 |
|
| 165 |
squarePtr->tkwin = tkwin; |
| 166 |
squarePtr->display = Tk_Display(tkwin); |
| 167 |
squarePtr->interp = interp; |
| 168 |
squarePtr->widgetCmd = Tcl_CreateObjCommand(interp, |
| 169 |
Tk_PathName(squarePtr->tkwin), SquareWidgetObjCmd, |
| 170 |
(ClientData) squarePtr, SquareDeletedProc); |
| 171 |
squarePtr->gc = None; |
| 172 |
squarePtr->optionTable = optionTable; |
| 173 |
|
| 174 |
if (Tk_InitOptions(interp, (char *) squarePtr, optionTable, tkwin) |
| 175 |
!= TCL_OK) { |
| 176 |
Tk_DestroyWindow(squarePtr->tkwin); |
| 177 |
ckfree((char *) squarePtr); |
| 178 |
return TCL_ERROR; |
| 179 |
} |
| 180 |
|
| 181 |
Tk_CreateEventHandler(squarePtr->tkwin, ExposureMask|StructureNotifyMask, |
| 182 |
SquareObjEventProc, (ClientData) squarePtr); |
| 183 |
if (Tk_SetOptions(interp, (char *) squarePtr, optionTable, objc - 2, |
| 184 |
objv + 2, tkwin, NULL, (int *) NULL) != TCL_OK) { |
| 185 |
goto error; |
| 186 |
} |
| 187 |
if (SquareConfigure(interp, squarePtr) != TCL_OK) { |
| 188 |
goto error; |
| 189 |
} |
| 190 |
|
| 191 |
Tcl_SetObjResult(interp, |
| 192 |
Tcl_NewStringObj(Tk_PathName(squarePtr->tkwin), -1)); |
| 193 |
return TCL_OK; |
| 194 |
|
| 195 |
error: |
| 196 |
Tk_DestroyWindow(squarePtr->tkwin); |
| 197 |
return TCL_ERROR; |
| 198 |
} |
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
static int |
| 219 |
SquareWidgetObjCmd(clientData, interp, objc, objv) |
| 220 |
ClientData clientData; |
| 221 |
Tcl_Interp *interp; |
| 222 |
int objc; |
| 223 |
Tcl_Obj *CONST objv[]; |
| 224 |
{ |
| 225 |
Square *squarePtr = (Square *) clientData; |
| 226 |
int result = TCL_OK; |
| 227 |
static CONST char *squareOptions[] = {"cget", "configure", (char *) NULL}; |
| 228 |
enum { |
| 229 |
SQUARE_CGET, SQUARE_CONFIGURE |
| 230 |
}; |
| 231 |
Tcl_Obj *resultObjPtr; |
| 232 |
int index; |
| 233 |
|
| 234 |
if (objc < 2) { |
| 235 |
Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg...?"); |
| 236 |
return TCL_ERROR; |
| 237 |
} |
| 238 |
|
| 239 |
if (Tcl_GetIndexFromObj(interp, objv[1], squareOptions, "command", |
| 240 |
0, &index) != TCL_OK) { |
| 241 |
return TCL_ERROR; |
| 242 |
} |
| 243 |
|
| 244 |
Tcl_Preserve((ClientData) squarePtr); |
| 245 |
|
| 246 |
switch (index) { |
| 247 |
case SQUARE_CGET: { |
| 248 |
if (objc != 3) { |
| 249 |
Tcl_WrongNumArgs(interp, 2, objv, "option"); |
| 250 |
goto error; |
| 251 |
} |
| 252 |
resultObjPtr = Tk_GetOptionValue(interp, (char *) squarePtr, |
| 253 |
squarePtr->optionTable, objv[2], squarePtr->tkwin); |
| 254 |
if (resultObjPtr == NULL) { |
| 255 |
result = TCL_ERROR; |
| 256 |
} else { |
| 257 |
Tcl_SetObjResult(interp, resultObjPtr); |
| 258 |
} |
| 259 |
break; |
| 260 |
} |
| 261 |
case SQUARE_CONFIGURE: { |
| 262 |
resultObjPtr = NULL; |
| 263 |
if (objc == 2) { |
| 264 |
resultObjPtr = Tk_GetOptionInfo(interp, (char *) squarePtr, |
| 265 |
squarePtr->optionTable, (Tcl_Obj *) NULL, |
| 266 |
squarePtr->tkwin); |
| 267 |
if (resultObjPtr == NULL) { |
| 268 |
result = TCL_ERROR; |
| 269 |
} |
| 270 |
} else if (objc == 3) { |
| 271 |
resultObjPtr = Tk_GetOptionInfo(interp, (char *) squarePtr, |
| 272 |
squarePtr->optionTable, objv[2], squarePtr->tkwin); |
| 273 |
if (resultObjPtr == NULL) { |
| 274 |
result = TCL_ERROR; |
| 275 |
} |
| 276 |
} else { |
| 277 |
result = Tk_SetOptions(interp, (char *) squarePtr, |
| 278 |
squarePtr->optionTable, objc - 2, objv + 2, |
| 279 |
squarePtr->tkwin, NULL, (int *) NULL); |
| 280 |
if (result == TCL_OK) { |
| 281 |
result = SquareConfigure(interp, squarePtr); |
| 282 |
} |
| 283 |
if (!squarePtr->updatePending) { |
| 284 |
Tcl_DoWhenIdle(SquareDisplay, (ClientData) squarePtr); |
| 285 |
squarePtr->updatePending = 1; |
| 286 |
} |
| 287 |
} |
| 288 |
if (resultObjPtr != NULL) { |
| 289 |
Tcl_SetObjResult(interp, resultObjPtr); |
| 290 |
} |
| 291 |
} |
| 292 |
} |
| 293 |
Tcl_Release((ClientData) squarePtr); |
| 294 |
return result; |
| 295 |
|
| 296 |
error: |
| 297 |
Tcl_Release((ClientData) squarePtr); |
| 298 |
return TCL_ERROR; |
| 299 |
} |
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
static int |
| 323 |
SquareConfigure(interp, squarePtr) |
| 324 |
Tcl_Interp *interp; |
| 325 |
Square *squarePtr; |
| 326 |
{ |
| 327 |
int borderWidth; |
| 328 |
Tk_3DBorder bgBorder; |
| 329 |
int doubleBuffer; |
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
bgBorder = Tk_Get3DBorderFromObj(squarePtr->tkwin, |
| 337 |
squarePtr->bgBorderPtr); |
| 338 |
Tk_SetWindowBackground(squarePtr->tkwin, |
| 339 |
Tk_3DBorderColor(bgBorder)->pixel); |
| 340 |
Tcl_GetBooleanFromObj(NULL, squarePtr->doubleBufferPtr, &doubleBuffer); |
| 341 |
if ((squarePtr->gc == None) && (doubleBuffer)) { |
| 342 |
XGCValues gcValues; |
| 343 |
gcValues.function = GXcopy; |
| 344 |
gcValues.graphics_exposures = False; |
| 345 |
squarePtr->gc = Tk_GetGC(squarePtr->tkwin, |
| 346 |
GCFunction|GCGraphicsExposures, &gcValues); |
| 347 |
} |
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
Tk_GeometryRequest(squarePtr->tkwin, 200, 150); |
| 355 |
Tk_GetPixelsFromObj(NULL, squarePtr->tkwin, squarePtr->borderWidthPtr, |
| 356 |
&borderWidth); |
| 357 |
Tk_SetInternalBorder(squarePtr->tkwin, borderWidth); |
| 358 |
if (!squarePtr->updatePending) { |
| 359 |
Tcl_DoWhenIdle(SquareDisplay, (ClientData) squarePtr); |
| 360 |
squarePtr->updatePending = 1; |
| 361 |
} |
| 362 |
KeepInWindow(squarePtr); |
| 363 |
return TCL_OK; |
| 364 |
} |
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
static void |
| 385 |
SquareObjEventProc(clientData, eventPtr) |
| 386 |
ClientData clientData; |
| 387 |
XEvent *eventPtr; |
| 388 |
{ |
| 389 |
Square *squarePtr = (Square *) clientData; |
| 390 |
|
| 391 |
if (eventPtr->type == Expose) { |
| 392 |
if (!squarePtr->updatePending) { |
| 393 |
Tcl_DoWhenIdle(SquareDisplay, (ClientData) squarePtr); |
| 394 |
squarePtr->updatePending = 1; |
| 395 |
} |
| 396 |
} else if (eventPtr->type == ConfigureNotify) { |
| 397 |
KeepInWindow(squarePtr); |
| 398 |
if (!squarePtr->updatePending) { |
| 399 |
Tcl_DoWhenIdle(SquareDisplay, (ClientData) squarePtr); |
| 400 |
squarePtr->updatePending = 1; |
| 401 |
} |
| 402 |
} else if (eventPtr->type == DestroyNotify) { |
| 403 |
if (squarePtr->tkwin != NULL) { |
| 404 |
Tk_FreeConfigOptions((char *) squarePtr, squarePtr->optionTable, |
| 405 |
squarePtr->tkwin); |
| 406 |
if (squarePtr->gc != None) { |
| 407 |
Tk_FreeGC(squarePtr->display, squarePtr->gc); |
| 408 |
} |
| 409 |
squarePtr->tkwin = NULL; |
| 410 |
Tcl_DeleteCommandFromToken(squarePtr->interp, |
| 411 |
squarePtr->widgetCmd); |
| 412 |
} |
| 413 |
if (squarePtr->updatePending) { |
| 414 |
Tcl_CancelIdleCall(SquareDisplay, (ClientData) squarePtr); |
| 415 |
} |
| 416 |
Tcl_EventuallyFree((ClientData) squarePtr, SquareDestroy); |
| 417 |
} |
| 418 |
} |
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
static void |
| 439 |
SquareDeletedProc(clientData) |
| 440 |
ClientData clientData; |
| 441 |
{ |
| 442 |
Square *squarePtr = (Square *) clientData; |
| 443 |
Tk_Window tkwin = squarePtr->tkwin; |
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
if (tkwin != NULL) { |
| 453 |
Tk_DestroyWindow(tkwin); |
| 454 |
} |
| 455 |
} |
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
static void |
| 476 |
SquareDisplay(clientData) |
| 477 |
ClientData clientData; |
| 478 |
{ |
| 479 |
Square *squarePtr = (Square *) clientData; |
| 480 |
Tk_Window tkwin = squarePtr->tkwin; |
| 481 |
Pixmap pm = None; |
| 482 |
Drawable d; |
| 483 |
int borderWidth, size, relief; |
| 484 |
Tk_3DBorder bgBorder, fgBorder; |
| 485 |
int doubleBuffer; |
| 486 |
|
| 487 |
squarePtr->updatePending = 0; |
| 488 |
if (!Tk_IsMapped(tkwin)) { |
| 489 |
return; |
| 490 |
} |
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
Tcl_GetBooleanFromObj(NULL, squarePtr->doubleBufferPtr, &doubleBuffer); |
| 497 |
if (doubleBuffer) { |
| 498 |
pm = Tk_GetPixmap(Tk_Display(tkwin), Tk_WindowId(tkwin), |
| 499 |
Tk_Width(tkwin), Tk_Height(tkwin), |
| 500 |
DefaultDepthOfScreen(Tk_Screen(tkwin))); |
| 501 |
d = pm; |
| 502 |
} else { |
| 503 |
d = Tk_WindowId(tkwin); |
| 504 |
} |
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
Tk_GetPixelsFromObj(NULL, squarePtr->tkwin, squarePtr->borderWidthPtr, |
| 511 |
&borderWidth); |
| 512 |
bgBorder = Tk_Get3DBorderFromObj(squarePtr->tkwin, |
| 513 |
squarePtr->bgBorderPtr); |
| 514 |
Tk_GetReliefFromObj(NULL, squarePtr->reliefPtr, &relief); |
| 515 |
Tk_Fill3DRectangle(tkwin, d, bgBorder, 0, 0, Tk_Width(tkwin), |
| 516 |
Tk_Height(tkwin), borderWidth, relief); |
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
Tk_GetPixelsFromObj(NULL, squarePtr->tkwin, squarePtr->sizeObjPtr, &size); |
| 523 |
fgBorder = Tk_Get3DBorderFromObj(squarePtr->tkwin, |
| 524 |
squarePtr->fgBorderPtr); |
| 525 |
Tk_Fill3DRectangle(tkwin, d, fgBorder, squarePtr->x, squarePtr->y, size, |
| 526 |
size, borderWidth, TK_RELIEF_RAISED); |
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
if (doubleBuffer) { |
| 533 |
XCopyArea(Tk_Display(tkwin), pm, Tk_WindowId(tkwin), squarePtr->gc, |
| 534 |
0, 0, (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin), |
| 535 |
0, 0); |
| 536 |
Tk_FreePixmap(Tk_Display(tkwin), pm); |
| 537 |
} |
| 538 |
} |
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
static void |
| 559 |
SquareDestroy(memPtr) |
| 560 |
char *memPtr; |
| 561 |
{ |
| 562 |
Square *squarePtr = (Square *) memPtr; |
| 563 |
|
| 564 |
ckfree((char *) squarePtr); |
| 565 |
} |
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
static void |
| 586 |
KeepInWindow(squarePtr) |
| 587 |
register Square *squarePtr; |
| 588 |
{ |
| 589 |
int i, bd, relief; |
| 590 |
int borderWidth, size; |
| 591 |
|
| 592 |
Tk_GetPixelsFromObj(NULL, squarePtr->tkwin, squarePtr->borderWidthPtr, |
| 593 |
&borderWidth); |
| 594 |
Tk_GetPixelsFromObj(NULL, squarePtr->tkwin, squarePtr->xPtr, |
| 595 |
&squarePtr->x); |
| 596 |
Tk_GetPixelsFromObj(NULL, squarePtr->tkwin, squarePtr->yPtr, |
| 597 |
&squarePtr->y); |
| 598 |
Tk_GetPixelsFromObj(NULL, squarePtr->tkwin, squarePtr->sizeObjPtr, &size); |
| 599 |
Tk_GetReliefFromObj(NULL, squarePtr->reliefPtr, &relief); |
| 600 |
bd = 0; |
| 601 |
if (relief != TK_RELIEF_FLAT) { |
| 602 |
bd = borderWidth; |
| 603 |
} |
| 604 |
i = (Tk_Width(squarePtr->tkwin) - bd) - (squarePtr->x + size); |
| 605 |
if (i < 0) { |
| 606 |
squarePtr->x += i; |
| 607 |
} |
| 608 |
i = (Tk_Height(squarePtr->tkwin) - bd) - (squarePtr->y + size); |
| 609 |
if (i < 0) { |
| 610 |
squarePtr->y += i; |
| 611 |
} |
| 612 |
if (squarePtr->x < bd) { |
| 613 |
squarePtr->x = bd; |
| 614 |
} |
| 615 |
if (squarePtr->y < bd) { |
| 616 |
squarePtr->y = bd; |
| 617 |
} |
| 618 |
} |