| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#include "bltInt.h" |
| 19 |
|
| 20 |
#ifndef NO_TILEFRAME |
| 21 |
|
| 22 |
#include "bltTile.h" |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
#define DEF_FRAME_BACKGROUND STD_NORMAL_BACKGROUND |
| 28 |
#define DEF_FRAME_BG_MONO STD_NORMAL_BG_MONO |
| 29 |
#define DEF_FRAME_BORDERWIDTH "0" |
| 30 |
#define DEF_FRAME_CLASS "Frame" |
| 31 |
#define DEF_FRAME_COLORMAP "" |
| 32 |
#define DEF_FRAME_CONTAINER "0" |
| 33 |
#define DEF_FRAME_CURSOR "" |
| 34 |
#define DEF_FRAME_HEIGHT "0" |
| 35 |
#define DEF_FRAME_HIGHLIGHT_BG STD_NORMAL_BACKGROUND |
| 36 |
#define DEF_FRAME_HIGHLIGHT RGB_BLACK |
| 37 |
#define DEF_FRAME_HIGHLIGHT_WIDTH "0" |
| 38 |
#define DEF_FRAME_RELIEF "flat" |
| 39 |
#define DEF_FRAME_TAKE_FOCUS "0" |
| 40 |
#define DEF_FRAME_USE "" |
| 41 |
#define DEF_FRAME_VISUAL "" |
| 42 |
#define DEF_FRAME_WIDTH "0" |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
#define DEF_TOPLEVEL_CLASS "Toplevel" |
| 50 |
#define DEF_TOPLEVEL_SCREEN "" |
| 51 |
#define DEF_TOPLEVEL_MENU "" |
| 52 |
|
| 53 |
extern Tk_CustomOption bltTileOption; |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
typedef struct { |
| 61 |
Tk_Window tkwin; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
Display *display; |
| 66 |
|
| 67 |
|
| 68 |
Tcl_Interp *interp; |
| 69 |
|
| 70 |
Tcl_Command widgetCmd; |
| 71 |
char *className; |
| 72 |
|
| 73 |
int mask; |
| 74 |
|
| 75 |
|
| 76 |
char *screenName; |
| 77 |
|
| 78 |
|
| 79 |
char *visualName; |
| 80 |
|
| 81 |
|
| 82 |
char *colormapName; |
| 83 |
|
| 84 |
|
| 85 |
char *menuName; |
| 86 |
|
| 87 |
Colormap colormap; |
| 88 |
|
| 89 |
|
| 90 |
Tk_3DBorder border; |
| 91 |
|
| 92 |
|
| 93 |
int borderWidth; |
| 94 |
int relief; |
| 95 |
int highlightWidth; |
| 96 |
|
| 97 |
|
| 98 |
XColor *highlightBgColorPtr; |
| 99 |
|
| 100 |
|
| 101 |
XColor *highlightColorPtr; |
| 102 |
int width; |
| 103 |
|
| 104 |
int height; |
| 105 |
|
| 106 |
Tk_Cursor cursor; |
| 107 |
char *takeFocus; |
| 108 |
|
| 109 |
|
| 110 |
int isContainer; |
| 111 |
|
| 112 |
char *useThis; |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
int flags; |
| 117 |
|
| 118 |
Blt_Tile tile; |
| •119 |
} bltFrame; |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
#define REDRAW_PENDING 1 |
| 132 |
#define GOT_FOCUS 4 |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
#define FRAME TK_CONFIG_USER_BIT |
| 140 |
#define TOPLEVEL (TK_CONFIG_USER_BIT << 1) |
| 141 |
#define BOTH (FRAME | TOPLEVEL) |
| 142 |
|
| 143 |
static Tk_ConfigSpec configSpecs[] = |
| 144 |
{ |
| 145 |
{TK_CONFIG_BORDER, "-background", "background", "Background", |
| •146 |
DEF_FRAME_BACKGROUND, Tk_Offset(bltFrame, border), |
| 147 |
BOTH | TK_CONFIG_COLOR_ONLY | TK_CONFIG_NULL_OK}, |
| 148 |
{TK_CONFIG_BORDER, "-background", "background", "Background", |
| •149 |
DEF_FRAME_BG_MONO, Tk_Offset(bltFrame, border), |
| 150 |
BOTH | TK_CONFIG_MONO_ONLY | TK_CONFIG_NULL_OK}, |
| 151 |
{TK_CONFIG_SYNONYM, "-bd", "borderWidth", (char *)NULL, |
| 152 |
(char *)NULL, 0, BOTH}, |
| 153 |
{TK_CONFIG_SYNONYM, "-bg", "background", (char *)NULL, |
| 154 |
(char *)NULL, 0, BOTH}, |
| 155 |
{TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", |
| •156 |
DEF_FRAME_BORDERWIDTH, Tk_Offset(bltFrame, borderWidth), BOTH}, |
| 157 |
{TK_CONFIG_STRING, "-class", "class", "Class", |
| •158 |
DEF_FRAME_CLASS, Tk_Offset(bltFrame, className), FRAME}, |
| 159 |
{TK_CONFIG_STRING, "-class", "class", "Class", |
| •160 |
DEF_TOPLEVEL_CLASS, Tk_Offset(bltFrame, className), TOPLEVEL}, |
| 161 |
{TK_CONFIG_STRING, "-colormap", "colormap", "Colormap", |
| •162 |
DEF_FRAME_COLORMAP, Tk_Offset(bltFrame, colormapName), |
| 163 |
BOTH | TK_CONFIG_NULL_OK}, |
| 164 |
#if (TK_MAJOR_VERSION > 4) |
| 165 |
{TK_CONFIG_BOOLEAN, "-container", "container", "Container", |
| •166 |
DEF_FRAME_CONTAINER, Tk_Offset(bltFrame, isContainer), BOTH}, |
| 167 |
#endif |
| 168 |
{TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor", |
| •169 |
DEF_FRAME_CURSOR, Tk_Offset(bltFrame, cursor), BOTH | TK_CONFIG_NULL_OK}, |
| 170 |
{TK_CONFIG_PIXELS, "-height", "height", "Height", |
| •171 |
DEF_FRAME_HEIGHT, Tk_Offset(bltFrame, height), BOTH}, |
| 172 |
{TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground", |
| 173 |
"HighlightBackground", DEF_FRAME_HIGHLIGHT_BG, |
| •174 |
Tk_Offset(bltFrame, highlightBgColorPtr), BOTH}, |
| 175 |
{TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", |
| •176 |
DEF_FRAME_HIGHLIGHT, Tk_Offset(bltFrame, highlightColorPtr), BOTH}, |
| 177 |
{TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness", |
| 178 |
"HighlightThickness", |
| •179 |
DEF_FRAME_HIGHLIGHT_WIDTH, Tk_Offset(bltFrame, highlightWidth), BOTH}, |
| 180 |
#if (TK_MAJOR_VERSION > 4) |
| 181 |
{TK_CONFIG_STRING, "-menu", "menu", "Menu", |
| •182 |
DEF_TOPLEVEL_MENU, Tk_Offset(bltFrame, menuName), |
| 183 |
TOPLEVEL | TK_CONFIG_NULL_OK}, |
| 184 |
#endif |
| 185 |
{TK_CONFIG_RELIEF, "-relief", "relief", "Relief", |
| •186 |
DEF_FRAME_RELIEF, Tk_Offset(bltFrame, relief), BOTH}, |
| 187 |
{TK_CONFIG_STRING, "-screen", "screen", "Screen", |
| •188 |
DEF_TOPLEVEL_SCREEN, Tk_Offset(bltFrame, screenName), |
| 189 |
TOPLEVEL | TK_CONFIG_NULL_OK}, |
| 190 |
{TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus", |
| •191 |
DEF_FRAME_TAKE_FOCUS, Tk_Offset(bltFrame, takeFocus), |
| 192 |
BOTH | TK_CONFIG_NULL_OK}, |
| 193 |
{TK_CONFIG_CUSTOM, "-tile", "tile", "Tile", |
| •194 |
(char *)NULL, Tk_Offset(bltFrame, tile), BOTH | TK_CONFIG_NULL_OK, |
| 195 |
&bltTileOption}, |
| 196 |
#if (TK_MAJOR_VERSION > 4) |
| 197 |
{TK_CONFIG_STRING, "-use", "use", "Use", |
| •198 |
DEF_FRAME_USE, Tk_Offset(bltFrame, useThis), TOPLEVEL|TK_CONFIG_NULL_OK}, |
| 199 |
#endif |
| 200 |
{TK_CONFIG_STRING, "-visual", "visual", "Visual", |
| •201 |
DEF_FRAME_VISUAL, Tk_Offset(bltFrame, visualName), |
| 202 |
BOTH | TK_CONFIG_NULL_OK}, |
| 203 |
{TK_CONFIG_PIXELS, "-width", "width", "Width", |
| •204 |
DEF_FRAME_WIDTH, Tk_Offset(bltFrame, width), BOTH}, |
| 205 |
{TK_CONFIG_END, (char *)NULL, (char *)NULL, (char *)NULL, |
| 206 |
(char *)NULL, 0, 0} |
| 207 |
}; |
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
static int ConfigureFrame _ANSI_ARGS_((Tcl_Interp *interp, |
| •214 |
bltFrame * framePtr, int argc, CONST84 char **argv, |
| 215 |
int flags)); |
| 216 |
static void DestroyFrame _ANSI_ARGS_((DestroyData *memPtr)); |
| 217 |
static void DisplayFrame _ANSI_ARGS_((ClientData clientData)); |
| 218 |
static void FrameCmdDeletedProc _ANSI_ARGS_(( |
| 219 |
ClientData clientData)); |
| 220 |
static void FrameEventProc _ANSI_ARGS_((ClientData clientData, |
| 221 |
XEvent *eventPtr)); |
| 222 |
static void MapFrame _ANSI_ARGS_((ClientData clientData)); |
| 223 |
|
| 224 |
static Blt_TileChangedProc TileChangedProc; |
| •225 |
static Tcl_CmdProc FrameCmd, ToplevelCmd, FrameWidgetCmd; |
| 226 |
|
| 227 |
static |
| •228 |
int BltCreateFrame _ANSI_ARGS_((ClientData clientData, |
| 229 |
Tcl_Interp *interp, int argc, CONST84 char **argv, |
| 230 |
int toplevel, char *appName)); |
| 231 |
|
| 232 |
#if (TK_MAJOR_VERSION == 8) && (TK_MINOR_VERSION > 3) |
| 233 |
#define TkSetClassProcs Tk_SetClassProcs |
| 234 |
#else |
| 235 |
EXTERN void TkSetClassProcs _ANSI_ARGS_((Tk_Window tkwin, void *procs, |
| 236 |
ClientData instanceData)); |
| 237 |
#endif |
| 238 |
|
| •239 |
#if (TCL_VERSION_NUMBER < _VERSION(8,6,0)) |
| 240 |
EXTERN void TkpSetMainMenubar _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, |
| 241 |
char * menuName)); |
| •242 |
#endif |
| 243 |
EXTERN void TkpMakeContainer _ANSI_ARGS_((Tk_Window tkwin)); |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
static int |
| 266 |
FrameCmd(clientData, interp, argc, argv) |
| 267 |
ClientData clientData; |
| 268 |
|
| 269 |
Tcl_Interp *interp; |
| 270 |
int argc; |
| •271 |
CONST84 char **argv; |
| 272 |
{ |
| •273 |
return BltCreateFrame(clientData, interp, argc, argv, 0, (char *)NULL); |
| 274 |
} |
| 275 |
|
| 276 |
static int |
| 277 |
ToplevelCmd(clientData, interp, argc, argv) |
| 278 |
ClientData clientData; |
| 279 |
|
| 280 |
Tcl_Interp *interp; |
| 281 |
int argc; |
| •282 |
CONST84 char **argv; |
| 283 |
{ |
| •284 |
return BltCreateFrame(clientData, interp, argc, argv, 1, (char *)NULL); |
| 285 |
} |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
#ifndef TILE_MAINWINDOW |
| 308 |
static |
| 309 |
#endif |
| 310 |
int |
| •311 |
BltCreateFrame(clientData, interp, argc, argv, toplevel, appName) |
| 312 |
ClientData clientData; |
| 313 |
|
| 314 |
|
| 315 |
Tcl_Interp *interp; |
| 316 |
int argc; |
| •317 |
CONST84 char *argv[]; |
| 318 |
int toplevel; |
| 319 |
|
| 320 |
char *appName; |
| 321 |
|
| 322 |
|
| 323 |
{ |
| •324 |
bltFrame *framePtr; |
| 325 |
Tk_Window new; |
| 326 |
char *className, *screenName, *visualName, *colormapName, *arg, *useOption; |
| 327 |
int i, c, length, depth; |
| 328 |
unsigned int mask; |
| 329 |
Colormap colormap; |
| 330 |
Visual *visual; |
| 331 |
Tk_Window tkwin; |
| 332 |
|
| 333 |
if (argc < 2) { |
| 334 |
Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 335 |
argv[0], " pathName ?options?\"", (char *)NULL); |
| 336 |
return TCL_ERROR; |
| 337 |
} |
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
className = colormapName = screenName = visualName = useOption = NULL; |
| 346 |
colormap = None; |
| 347 |
for (i = 2; i < argc; i += 2) { |
| 348 |
arg = argv[i]; |
| 349 |
length = strlen(arg); |
| 350 |
if (length < 2) { |
| 351 |
continue; |
| 352 |
} |
| 353 |
c = arg[1]; |
| 354 |
if ((c == 'c') && (strncmp(arg, "-class", strlen(arg)) == 0) |
| 355 |
&& (length >= 3)) { |
| 356 |
className = argv[i + 1]; |
| 357 |
} else if ((c == 'c') |
| 358 |
&& (strncmp(arg, "-colormap", strlen(arg)) == 0)) { |
| 359 |
colormapName = argv[i + 1]; |
| 360 |
} else if ((c == 's') && toplevel |
| 361 |
&& (strncmp(arg, "-screen", strlen(arg)) == 0)) { |
| 362 |
screenName = argv[i + 1]; |
| 363 |
} else if ((c == 'u') && toplevel |
| 364 |
&& (strncmp(arg, "-use", strlen(arg)) == 0)) { |
| 365 |
useOption = argv[i + 1]; |
| 366 |
} else if ((c == 'v') |
| 367 |
&& (strncmp(arg, "-visual", strlen(arg)) == 0)) { |
| 368 |
visualName = argv[i + 1]; |
| 369 |
} |
| 370 |
} |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
if (screenName == NULL) { |
| 388 |
screenName = (toplevel) ? "" : NULL; |
| 389 |
} |
| 390 |
tkwin = Tk_MainWindow(interp); |
| 391 |
if (tkwin != NULL) { |
| 392 |
new = Tk_CreateWindowFromPath(interp, tkwin, argv[1], screenName); |
| 393 |
} else { |
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
if (appName == NULL) { |
| •399 |
panic("BltCreateFrame didn't get application name"); |
| 400 |
} |
| 401 |
new = (Tk_Window)TkCreateMainWindow(interp, screenName, appName); |
| 402 |
} |
| 403 |
if (new == NULL) { |
| 404 |
goto error; |
| 405 |
} |
| 406 |
if (className == NULL) { |
| 407 |
className = (char *)Tk_GetOption(new, "class", "Class"); |
| 408 |
if (className == NULL) { |
| 409 |
className = (toplevel) ? "Toplevel" : "Frame"; |
| 410 |
} |
| 411 |
} |
| 412 |
Tk_SetClass(new, className); |
| 413 |
#if (TK_MAJOR_VERSION > 4) |
| 414 |
if (useOption == NULL) { |
| 415 |
useOption = (char *)Tk_GetOption(new, "use", "Use"); |
| 416 |
} |
| 417 |
if (useOption != NULL) { |
| 418 |
if (TkpUseWindow(interp, new, useOption) != TCL_OK) { |
| 419 |
goto error; |
| 420 |
} |
| 421 |
} |
| 422 |
#endif |
| 423 |
if (visualName == NULL) { |
| 424 |
visualName = (char *)Tk_GetOption(new, "visual", "Visual"); |
| 425 |
} |
| 426 |
if (colormapName == NULL) { |
| 427 |
colormapName = (char *)Tk_GetOption(new, "colormap", "Colormap"); |
| 428 |
} |
| 429 |
if (visualName != NULL) { |
| 430 |
visual = Tk_GetVisual(interp, new, visualName, &depth, |
| 431 |
(colormapName == NULL) ? &colormap : (Colormap *) NULL); |
| 432 |
if (visual == NULL) { |
| 433 |
goto error; |
| 434 |
} |
| 435 |
Tk_SetWindowVisual(new, visual, depth, colormap); |
| 436 |
} |
| 437 |
if (colormapName != NULL) { |
| 438 |
colormap = Tk_GetColormap(interp, new, colormapName); |
| 439 |
if (colormap == None) { |
| 440 |
goto error; |
| 441 |
} |
| 442 |
Tk_SetWindowColormap(new, colormap); |
| 443 |
} |
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
if (toplevel) { |
| 451 |
Tk_GeometryRequest(new, 200, 200); |
| 452 |
} |
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| •459 |
framePtr = Blt_Malloc(sizeof(bltFrame)); |
| 460 |
framePtr->tkwin = new; |
| 461 |
framePtr->display = Tk_Display(new); |
| 462 |
framePtr->interp = interp; |
| 463 |
framePtr->widgetCmd = Tcl_CreateCommand(interp, |
| 464 |
Tk_PathName(new), FrameWidgetCmd, |
| 465 |
(ClientData)framePtr, FrameCmdDeletedProc); |
| 466 |
framePtr->className = NULL; |
| 467 |
framePtr->mask = (toplevel) ? TOPLEVEL : FRAME; |
| 468 |
framePtr->screenName = NULL; |
| 469 |
framePtr->visualName = NULL; |
| 470 |
framePtr->colormapName = NULL; |
| 471 |
framePtr->colormap = colormap; |
| 472 |
framePtr->border = NULL; |
| 473 |
framePtr->borderWidth = 0; |
| 474 |
framePtr->relief = TK_RELIEF_FLAT; |
| 475 |
framePtr->highlightWidth = 0; |
| 476 |
framePtr->highlightBgColorPtr = NULL; |
| 477 |
framePtr->highlightColorPtr = NULL; |
| 478 |
framePtr->width = 0; |
| 479 |
framePtr->height = 0; |
| 480 |
framePtr->cursor = None; |
| 481 |
framePtr->takeFocus = NULL; |
| 482 |
framePtr->isContainer = 0; |
| 483 |
framePtr->useThis = NULL; |
| 484 |
framePtr->flags = 0; |
| 485 |
framePtr->tile = NULL; |
| 486 |
framePtr->menuName = NULL; |
| 487 |
|
| 488 |
#if (TK_MAJOR_VERSION > 4) |
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
TkSetClassProcs(new, NULL, (ClientData)framePtr); |
| 493 |
#endif |
| 494 |
|
| 495 |
mask = ExposureMask | StructureNotifyMask | FocusChangeMask; |
| 496 |
if (toplevel) { |
| 497 |
mask |= ActivateMask; |
| 498 |
} |
| 499 |
Tk_CreateEventHandler(new, mask, FrameEventProc, (ClientData)framePtr); |
| 500 |
if (ConfigureFrame(interp, framePtr, argc - 2, argv + 2, 0) != TCL_OK) { |
| 501 |
goto error; |
| 502 |
} |
| 503 |
#if (TK_MAJOR_VERSION > 4) |
| 504 |
if ((framePtr->isContainer)) { |
| 505 |
if (framePtr->useThis == NULL) { |
| 506 |
TkpMakeContainer(framePtr->tkwin); |
| 507 |
} else { |
| 508 |
Tcl_AppendResult(interp, "A window cannot have both the -use ", |
| 509 |
"and the -container option set.", (char *)NULL); |
| 510 |
return TCL_ERROR; |
| 511 |
} |
| 512 |
} |
| 513 |
#endif |
| 514 |
if (toplevel) { |
| 515 |
Tcl_DoWhenIdle(MapFrame, (ClientData)framePtr); |
| 516 |
} |
| 517 |
Tcl_SetResult(interp, Tk_PathName(new), TCL_VOLATILE); |
| 518 |
return TCL_OK; |
| 519 |
|
| 520 |
error: |
| 521 |
if (new != NULL) { |
| 522 |
Tk_DestroyWindow(new); |
| 523 |
} |
| 524 |
return TCL_ERROR; |
| 525 |
} |
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
static int |
| 546 |
FrameWidgetCmd(clientData, interp, argc, argv) |
| 547 |
ClientData clientData; |
| 548 |
Tcl_Interp *interp; |
| 549 |
int argc; |
| •550 |
CONST84 char *argv[]; |
| 551 |
{ |
| •552 |
register bltFrame *framePtr = (bltFrame *) clientData; |
| 553 |
int result; |
| 554 |
size_t length; |
| 555 |
int c, i; |
| 556 |
|
| 557 |
if (argc < 2) { |
| 558 |
Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 559 |
argv[0], " option ?arg arg ...?\"", (char *)NULL); |
| 560 |
return TCL_ERROR; |
| 561 |
} |
| 562 |
Tcl_Preserve((ClientData)framePtr); |
| 563 |
c = argv[1][0]; |
| 564 |
length = strlen(argv[1]); |
| 565 |
if ((c == 'c') && (strncmp(argv[1], "cget", length) == 0) |
| 566 |
&& (length >= 2)) { |
| 567 |
if (argc != 3) { |
| 568 |
Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 569 |
argv[0], " cget option\"", |
| 570 |
(char *)NULL); |
| 571 |
result = TCL_ERROR; |
| 572 |
goto done; |
| 573 |
} |
| 574 |
result = Tk_ConfigureValue(interp, framePtr->tkwin, configSpecs, |
| 575 |
(char *)framePtr, argv[2], framePtr->mask); |
| 576 |
} else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0) |
| 577 |
&& (length >= 2)) { |
| 578 |
if (argc == 2) { |
| 579 |
result = Tk_ConfigureInfo(interp, framePtr->tkwin, configSpecs, |
| 580 |
(char *)framePtr, (char *)NULL, framePtr->mask); |
| 581 |
} else if (argc == 3) { |
| 582 |
result = Tk_ConfigureInfo(interp, framePtr->tkwin, configSpecs, |
| 583 |
(char *)framePtr, argv[2], framePtr->mask); |
| 584 |
} else { |
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
for (i = 2; i < argc; i++) { |
| 591 |
length = strlen(argv[i]); |
| 592 |
if (length < 2) { |
| 593 |
continue; |
| 594 |
} |
| 595 |
c = argv[i][1]; |
| 596 |
if (((c == 'c') && (strncmp(argv[i], "-class", length) == 0) |
| 597 |
&& (length >= 2)) |
| 598 |
|| ((c == 'c') && (framePtr->mask == TOPLEVEL) |
| 599 |
&& (strncmp(argv[i], "-colormap", length) == 0) |
| 600 |
&& (length >= 3)) |
| 601 |
|| ((c == 'c') |
| 602 |
&& (strncmp(argv[i], "-container", length) == 0) |
| 603 |
&& (length >= 3)) |
| 604 |
|| ((c == 's') && (framePtr->mask == TOPLEVEL) |
| 605 |
&& (strncmp(argv[i], "-screen", length) == 0)) |
| 606 |
|| ((c == 'u') && (framePtr->mask == TOPLEVEL) |
| 607 |
&& (strncmp(argv[i], "-use", length) == 0)) |
| 608 |
|| ((c == 'v') && (framePtr->mask == TOPLEVEL) |
| 609 |
&& (strncmp(argv[i], "-visual", length) == 0))) { |
| 610 |
Tcl_AppendResult(interp, "can't modify ", argv[i], |
| 611 |
" option after widget is created", (char *)NULL); |
| 612 |
result = TCL_ERROR; |
| 613 |
goto done; |
| 614 |
} |
| 615 |
} |
| 616 |
result = ConfigureFrame(interp, framePtr, argc - 2, argv + 2, |
| 617 |
TK_CONFIG_ARGV_ONLY); |
| 618 |
} |
| 619 |
} else { |
| 620 |
Tcl_AppendResult(interp, "bad option \"", argv[1], |
| 621 |
"\": must be cget or configure", (char *)NULL); |
| 622 |
result = TCL_ERROR; |
| 623 |
} |
| 624 |
|
| 625 |
done: |
| 626 |
Tcl_Release((ClientData)framePtr); |
| 627 |
return result; |
| 628 |
} |
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
static void |
| 649 |
DestroyFrame(memPtr) |
| 650 |
DestroyData *memPtr; |
| 651 |
{ |
| •652 |
register bltFrame *framePtr = (bltFrame *) memPtr; |
| 653 |
|
| 654 |
Tk_FreeOptions(configSpecs, (char *)framePtr, framePtr->display, |
| 655 |
framePtr->mask); |
| 656 |
if (framePtr->tile != NULL) { |
| 657 |
Blt_FreeTile(framePtr->tile); |
| 658 |
} |
| 659 |
if (framePtr->colormap != None) { |
| 660 |
Tk_FreeColormap(framePtr->display, framePtr->colormap); |
| 661 |
} |
| 662 |
Blt_Free(framePtr); |
| 663 |
} |
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
static void |
| 677 |
TileChangedProc(clientData, tile) |
| 678 |
ClientData clientData; |
| 679 |
Blt_Tile tile; |
| 680 |
{ |
| •681 |
bltFrame *framePtr = (bltFrame *) clientData; |
| 682 |
|
| 683 |
if (framePtr->tkwin != NULL) { |
| 684 |
if (!(framePtr->flags & REDRAW_PENDING)) { |
| 685 |
Tcl_DoWhenIdle(DisplayFrame, (ClientData)framePtr); |
| 686 |
framePtr->flags |= REDRAW_PENDING; |
| 687 |
} |
| 688 |
} |
| 689 |
} |
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
static int |
| 713 |
ConfigureFrame(interp, framePtr, argc, argv, flags) |
| 714 |
Tcl_Interp *interp; |
| •715 |
register bltFrame *framePtr; |
| 716 |
|
| 717 |
int argc; |
| •718 |
CONST84 char **argv; |
| 719 |
int flags; |
| 720 |
{ |
| 721 |
#if (TK_MAJOR_VERSION > 4) |
| 722 |
char *oldMenuName; |
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
if (framePtr->menuName == NULL) { |
| 729 |
oldMenuName = NULL; |
| 730 |
} else { |
| 731 |
oldMenuName = Blt_Malloc(strlen(framePtr->menuName) + 1); |
| 732 |
strcpy(oldMenuName, framePtr->menuName); |
| 733 |
} |
| 734 |
#endif |
| 735 |
|
| 736 |
if (Tk_ConfigureWidget(interp, framePtr->tkwin, configSpecs, |
| •737 |
argc, (CONST char **)argv, (char *)framePtr, flags | framePtr->mask) != TCL_OK) { |
| 738 |
return TCL_ERROR; |
| 739 |
} |
| 740 |
if (framePtr->tile != NULL) { |
| 741 |
Blt_SetTileChangedProc(framePtr->tile, TileChangedProc, |
| 742 |
(ClientData)framePtr); |
| 743 |
} |
| 744 |
#if (TK_MAJOR_VERSION > 4) |
| 745 |
if (((oldMenuName == NULL) && (framePtr->menuName != NULL)) |
| 746 |
|| ((oldMenuName != NULL) && (framePtr->menuName == NULL)) |
| 747 |
|| ((oldMenuName != NULL) && (framePtr->menuName != NULL) |
| 748 |
&& strcmp(oldMenuName, framePtr->menuName) != 0)) { |
| 749 |
TkSetWindowMenuBar(interp, framePtr->tkwin, oldMenuName, |
| 750 |
framePtr->menuName); |
| 751 |
} |
| 752 |
#endif |
| 753 |
if (framePtr->border != NULL) { |
| 754 |
Tk_SetBackgroundFromBorder(framePtr->tkwin, framePtr->border); |
| 755 |
} else { |
| 756 |
Tk_SetWindowBackgroundPixmap(framePtr->tkwin, None); |
| 757 |
} |
| 758 |
if (framePtr->highlightWidth < 0) { |
| 759 |
framePtr->highlightWidth = 0; |
| 760 |
} |
| 761 |
Tk_SetInternalBorder(framePtr->tkwin, |
| 762 |
framePtr->borderWidth + framePtr->highlightWidth); |
| 763 |
if ((framePtr->width > 0) || (framePtr->height > 0)) { |
| 764 |
Tk_GeometryRequest(framePtr->tkwin, framePtr->width, |
| 765 |
framePtr->height); |
| 766 |
} |
| 767 |
#if (TK_MAJOR_VERSION > 4) |
| 768 |
if (oldMenuName != NULL) { |
| 769 |
Blt_Free(oldMenuName); |
| 770 |
} |
| 771 |
#endif |
| 772 |
|
| 773 |
if (Tk_IsMapped(framePtr->tkwin)) { |
| 774 |
if (!(framePtr->flags & REDRAW_PENDING)) { |
| 775 |
Tcl_DoWhenIdle(DisplayFrame, (ClientData)framePtr); |
| 776 |
} |
| 777 |
framePtr->flags |= REDRAW_PENDING; |
| 778 |
} |
| 779 |
return TCL_OK; |
| 780 |
} |
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
static void |
| 799 |
DisplayFrame(clientData) |
| 800 |
ClientData clientData; |
| 801 |
{ |
| •802 |
register bltFrame *framePtr = (bltFrame *) clientData; |
| 803 |
register Tk_Window tkwin = framePtr->tkwin; |
| 804 |
GC gc; |
| 805 |
|
| 806 |
framePtr->flags &= ~REDRAW_PENDING; |
| 807 |
if ((framePtr->tkwin == NULL) || !Tk_IsMapped(tkwin) |
| 808 |
|| framePtr->isContainer) { |
| 809 |
return; |
| 810 |
} |
| 811 |
if (framePtr->tile == NULL) { |
| 812 |
Blt_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), |
| 813 |
framePtr->border, framePtr->highlightWidth, |
| 814 |
framePtr->highlightWidth, |
| 815 |
Tk_Width(tkwin) - 2 * framePtr->highlightWidth, |
| 816 |
Tk_Height(tkwin) - 2 * framePtr->highlightWidth, |
| 817 |
framePtr->borderWidth, framePtr->relief); |
| 818 |
} else { |
| 819 |
Blt_SetTileOrigin(tkwin, framePtr->tile, 0, 0); |
| 820 |
Blt_TileRectangle(tkwin, Tk_WindowId(tkwin), framePtr->tile, 0, 0, |
| 821 |
Tk_Width(tkwin), Tk_Height(tkwin)); |
| 822 |
if ((framePtr->border != NULL) && |
| 823 |
(framePtr->relief != TK_RELIEF_FLAT)) { |
| 824 |
Blt_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), |
| 825 |
framePtr->border, framePtr->highlightWidth, |
| 826 |
framePtr->highlightWidth, |
| 827 |
Tk_Width(tkwin) - 2 * framePtr->highlightWidth, |
| 828 |
Tk_Height(tkwin) - 2 * framePtr->highlightWidth, |
| 829 |
framePtr->borderWidth, framePtr->relief); |
| 830 |
} |
| 831 |
} |
| 832 |
if (framePtr->highlightWidth != 0) { |
| 833 |
if (framePtr->flags & GOT_FOCUS) { |
| 834 |
gc = Tk_GCForColor(framePtr->highlightColorPtr, |
| 835 |
Tk_WindowId(tkwin)); |
| 836 |
} else { |
| 837 |
gc = Tk_GCForColor(framePtr->highlightBgColorPtr, |
| 838 |
Tk_WindowId(tkwin)); |
| 839 |
} |
| 840 |
Tk_DrawFocusHighlight(tkwin, gc, framePtr->highlightWidth, |
| 841 |
Tk_WindowId(tkwin)); |
| 842 |
} |
| 843 |
} |
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
static void |
| 865 |
FrameEventProc(clientData, eventPtr) |
| 866 |
ClientData clientData; |
| 867 |
register XEvent *eventPtr; |
| 868 |
{ |
| •869 |
register bltFrame *framePtr = (bltFrame *) clientData; |
| 870 |
|
| 871 |
if (((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) |
| 872 |
|| (eventPtr->type == ConfigureNotify)) { |
| 873 |
goto redraw; |
| 874 |
} else if (eventPtr->type == DestroyNotify) { |
| 875 |
#if (TK_MAJOR_VERSION > 4) |
| 876 |
if (framePtr->menuName != NULL) { |
| 877 |
TkSetWindowMenuBar(framePtr->interp, framePtr->tkwin, |
| 878 |
framePtr->menuName, NULL); |
| 879 |
Blt_Free(framePtr->menuName); |
| 880 |
framePtr->menuName = NULL; |
| 881 |
} |
| 882 |
#endif |
| 883 |
if (framePtr->tkwin != NULL) { |
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
|
| 893 |
|
| 894 |
Tk_DeleteEventHandler(framePtr->tkwin, |
| 895 |
ExposureMask | StructureNotifyMask | FocusChangeMask, |
| 896 |
FrameEventProc, (ClientData)framePtr); |
| 897 |
framePtr->tkwin = NULL; |
| 898 |
Tcl_DeleteCommandFromToken(framePtr->interp, framePtr->widgetCmd); |
| 899 |
} |
| 900 |
if (framePtr->flags & REDRAW_PENDING) { |
| 901 |
Tcl_CancelIdleCall(DisplayFrame, (ClientData)framePtr); |
| 902 |
} |
| 903 |
Tcl_CancelIdleCall(MapFrame, (ClientData)framePtr); |
| 904 |
Tcl_EventuallyFree((ClientData)framePtr, (Tcl_FreeProc *)DestroyFrame); |
| 905 |
} else if (eventPtr->type == FocusIn) { |
| 906 |
if (eventPtr->xfocus.detail != NotifyInferior) { |
| 907 |
framePtr->flags |= GOT_FOCUS; |
| 908 |
if (framePtr->highlightWidth > 0) { |
| 909 |
goto redraw; |
| 910 |
} |
| 911 |
} |
| 912 |
} else if (eventPtr->type == FocusOut) { |
| 913 |
if (eventPtr->xfocus.detail != NotifyInferior) { |
| 914 |
framePtr->flags &= ~GOT_FOCUS; |
| 915 |
if (framePtr->highlightWidth > 0) { |
| 916 |
goto redraw; |
| 917 |
} |
| 918 |
} |
| 919 |
#if (TK_MAJOR_VERSION > 4) |
| 920 |
} else if (eventPtr->type == ActivateNotify) { |
| 921 |
TkpSetMainMenubar(framePtr->interp, framePtr->tkwin, |
| 922 |
framePtr->menuName); |
| 923 |
#endif |
| 924 |
} |
| 925 |
return; |
| 926 |
|
| 927 |
redraw: |
| 928 |
if ((framePtr->tkwin != NULL) && !(framePtr->flags & REDRAW_PENDING)) { |
| 929 |
Tcl_DoWhenIdle(DisplayFrame, (ClientData)framePtr); |
| 930 |
framePtr->flags |= REDRAW_PENDING; |
| 931 |
} |
| 932 |
} |
| 933 |
|
| 934 |
|
| 935 |
|
| 936 |
|
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
|
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
|
| 948 |
|
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
static void |
| 953 |
FrameCmdDeletedProc(clientData) |
| 954 |
ClientData clientData; |
| 955 |
{ |
| •956 |
bltFrame *framePtr = (bltFrame *) clientData; |
| 957 |
Tk_Window tkwin = framePtr->tkwin; |
| 958 |
|
| 959 |
#if (TK_MAJOR_VERSION > 4) |
| 960 |
if (framePtr->menuName != NULL) { |
| 961 |
TkSetWindowMenuBar(framePtr->interp, framePtr->tkwin, |
| 962 |
framePtr->menuName, NULL); |
| 963 |
Blt_Free(framePtr->menuName); |
| 964 |
framePtr->menuName = NULL; |
| 965 |
} |
| 966 |
#endif |
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
if (tkwin != NULL) { |
| 976 |
framePtr->tkwin = NULL; |
| 977 |
Tk_DestroyWindow(tkwin); |
| 978 |
} |
| 979 |
} |
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
|
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
static void |
| 999 |
MapFrame(clientData) |
| 1000 |
ClientData clientData; |
| 1001 |
{ |
| •1002 |
bltFrame *framePtr = (bltFrame *) clientData; |
| 1003 |
|
| 1004 |
|
| 1005 |
|
| 1006 |
|
| 1007 |
|
| 1008 |
|
| 1009 |
|
| 1010 |
|
| 1011 |
Tcl_Preserve((ClientData)framePtr); |
| 1012 |
for(;;) { |
| 1013 |
if (Tcl_DoOneEvent(TCL_IDLE_EVENTS) == 0) { |
| 1014 |
break; |
| 1015 |
} |
| 1016 |
|
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
if (framePtr->tkwin == NULL) { |
| 1022 |
Tcl_Release((ClientData)framePtr); |
| 1023 |
return; |
| 1024 |
} |
| 1025 |
} |
| 1026 |
Tk_MapWindow(framePtr->tkwin); |
| 1027 |
Tcl_Release((ClientData)framePtr); |
| 1028 |
} |
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
|
| 1033 |
|
| 1034 |
|
| 1035 |
|
| 1036 |
|
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
|
| 1046 |
|
| 1047 |
|
| 1048 |
|
| 1049 |
|
| 1050 |
#ifdef notdef |
| 1051 |
void |
| 1052 |
TkInstallFrameMenu(tkwin) |
| 1053 |
Tk_Window tkwin; |
| 1054 |
{ |
| 1055 |
#if (TK_MAJOR_VERSION > 4) |
| 1056 |
#define Tk_InstanceData(tkwin) (((Tk_FakeWin *)(tkwin))->dummy18) |
| 1057 |
#define Tk_MainPtr(tkwin) (((Tk_FakeWin *)(tkwin))->dummy5) |
| 1058 |
if (Tk_MainPtr(tkwin) != NULL) { |
| •1059 |
bltFrame *framePtr; |
| 1060 |
|
| •1061 |
framePtr = (bltFrame *) Tk_InstanceData(tkwin); |
| 1062 |
TkpMenuNotifyToplevelCreate(framePtr->interp, framePtr->menuName); |
| 1063 |
} |
| 1064 |
#endif |
| 1065 |
} |
| 1066 |
|
| 1067 |
#endif |
| 1068 |
|
| 1069 |
int |
| 1070 |
Blt_FrameInit(interp) |
| 1071 |
Tcl_Interp *interp; |
| 1072 |
{ |
| 1073 |
static Blt_CmdSpec cmdSpecs[2] = |
| 1074 |
{ |
| 1075 |
#if HAVE_NAMESPACES |
| 1076 |
{"frame", FrameCmd,}, |
| 1077 |
{"toplevel", ToplevelCmd,}, |
| 1078 |
#else |
| 1079 |
{"tileframe", FrameCmd,}, |
| 1080 |
{"tiletoplevel", ToplevelCmd,}, |
| 1081 |
#endif |
| 1082 |
}; |
| 1083 |
return Blt_InitCmds(interp, "blt::tile", cmdSpecs, 2); |
| 1084 |
} |
| 1085 |
|
| 1086 |
#endif |