| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#include "default.h" |
| 19 |
#include "tkPort.h" |
| 20 |
#include "tkInt.h" |
| 21 |
#include "tkOption.h" |
| 22 |
#include "tkOption.m" |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
enum FrameType { |
| 29 |
TYPE_FRAME, TYPE_TOPLEVEL, TYPE_LABELFRAME |
| 30 |
}; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
typedef struct { |
| 38 |
Tk_Window tkwin; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
Display *display; |
| 43 |
|
| 44 |
|
| 45 |
Tcl_Interp *interp; |
| 46 |
|
| 47 |
Tcl_Command widgetCmd; |
| 48 |
Tk_OptionTable optionTable; |
| 49 |
|
| 50 |
char *className; |
| 51 |
|
| 52 |
enum FrameType type; |
| 53 |
char *screenName; |
| 54 |
|
| 55 |
|
| 56 |
Tcl_Obj * visualName; |
| 57 |
|
| 58 |
|
| 59 |
char *colormapName; |
| 60 |
|
| 61 |
|
| 62 |
Tcl_Obj *menuName; |
| 63 |
|
| 64 |
Colormap colormap; |
| 65 |
|
| 66 |
|
| 67 |
Tk_3DBorder border; |
| 68 |
|
| 69 |
|
| 70 |
int borderWidth; |
| 71 |
int relief; |
| 72 |
int highlightWidth; |
| 73 |
|
| 74 |
|
| 75 |
XColor *highlightBgColorPtr; |
| 76 |
|
| 77 |
|
| 78 |
XColor *highlightColorPtr; |
| 79 |
int width; |
| 80 |
|
| 81 |
int height; |
| 82 |
|
| 83 |
Tk_Cursor cursor; |
| 84 |
char *takeFocus; |
| 85 |
|
| 86 |
|
| 87 |
int isContainer; |
| 88 |
|
| 89 |
Tcl_Obj * useThis; |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
int flags; |
| 94 |
|
| 95 |
Tcl_Obj *padXPtr; |
| 96 |
|
| 97 |
|
| 98 |
int padX; |
| 99 |
Tcl_Obj *padYPtr; |
| 100 |
|
| 101 |
|
| 102 |
int padY; |
| 103 |
} Frame; |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
typedef struct { |
| 111 |
Frame frame; |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
Tcl_Obj *textPtr; |
| 120 |
|
| 121 |
Tk_Font tkfont; |
| 122 |
|
| 123 |
XColor *textColorPtr; |
| 124 |
|
| 125 |
int labelAnchor; |
| 126 |
|
| 127 |
Tk_Window labelWin; |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
GC textGC; |
| 135 |
Tk_TextLayout textLayout; |
| 136 |
XRectangle labelBox; |
| 137 |
int labelReqWidth; |
| 138 |
int labelReqHeight; |
| 139 |
int labelTextX, labelTextY; |
| 140 |
|
| 141 |
} Labelframe; |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
#define LABELSPACING 1 |
| 149 |
#define LABELMARGIN 4 |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
#define REDRAW_PENDING 1 |
| 162 |
#define GOT_FOCUS 4 |
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
enum labelanchor { |
| 171 |
LABELANCHOR_E, LABELANCHOR_EN, LABELANCHOR_ES, |
| 172 |
LABELANCHOR_N, LABELANCHOR_NE, LABELANCHOR_NW, |
| 173 |
LABELANCHOR_S, LABELANCHOR_SE, LABELANCHOR_SW, |
| 174 |
LABELANCHOR_W, LABELANCHOR_WN, LABELANCHOR_WS |
| 175 |
}; |
| 176 |
|
| 177 |
static char *labelAnchorStrings[] = { |
| 178 |
"e", "en", "es", "n", "ne", "nw", "s", "se", "sw", "w", "wn", "ws", |
| 179 |
(char *) NULL |
| 180 |
}; |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
static Tk_OptionSpec commonOptSpec[] = { |
| 188 |
{TK_OPTION_BORDER, "-background", "background", "Background", |
| 189 |
DEF_FRAME_BG_COLOR, -1, Tk_Offset(Frame, border), |
| 190 |
TK_OPTION_NULL_OK, (ClientData) DEF_FRAME_BG_MONO, 0}, |
| 191 |
{TK_OPTION_SYNONYM, "-bg", (char *) NULL, (char *) NULL, |
| 192 |
(char *) NULL, 0, -1, 0, (ClientData) "-background", 0}, |
| 193 |
{TK_OPTION_STRING, "-colormap", "colormap", "Colormap", |
| 194 |
DEF_FRAME_COLORMAP, -1, Tk_Offset(Frame, colormapName), |
| 195 |
TK_OPTION_NULL_OK, 0, 0}, |
| 196 |
{TK_OPTION_BOOLEAN, "-container", "container", "Container", |
| 197 |
DEF_FRAME_CONTAINER, -1, Tk_Offset(Frame, isContainer), |
| 198 |
0, 0, 0}, |
| 199 |
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", |
| 200 |
DEF_FRAME_CURSOR, -1, Tk_Offset(Frame, cursor), |
| 201 |
TK_OPTION_NULL_OK, 0, 0}, |
| 202 |
{TK_OPTION_PIXELS, "-height", "height", "Height", |
| 203 |
DEF_FRAME_HEIGHT, -1, Tk_Offset(Frame, height), |
| 204 |
0, 0, 0}, |
| 205 |
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground", |
| 206 |
"HighlightBackground", DEF_FRAME_HIGHLIGHT_BG, -1, |
| 207 |
Tk_Offset(Frame, highlightBgColorPtr), 0, 0, 0}, |
| 208 |
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", |
| 209 |
DEF_FRAME_HIGHLIGHT, -1, Tk_Offset(Frame, highlightColorPtr), |
| 210 |
0, 0, 0}, |
| 211 |
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", |
| 212 |
"HighlightThickness", DEF_FRAME_HIGHLIGHT_WIDTH, -1, |
| 213 |
Tk_Offset(Frame, highlightWidth), 0, 0, 0}, |
| 214 |
{TK_OPTION_PIXELS, "-padx", "padX", "Pad", |
| 215 |
DEF_FRAME_PADX, Tk_Offset(Frame, padXPtr), |
| 216 |
Tk_Offset(Frame, padX), 0, 0, 0}, |
| 217 |
{TK_OPTION_PIXELS, "-pady", "padY", "Pad", |
| 218 |
DEF_FRAME_PADY, Tk_Offset(Frame, padYPtr), |
| 219 |
Tk_Offset(Frame, padY), 0, 0, 0}, |
| 220 |
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", |
| 221 |
DEF_FRAME_TAKE_FOCUS, -1, Tk_Offset(Frame, takeFocus), |
| 222 |
TK_OPTION_NULL_OK, 0, 0}, |
| 223 |
{TK_OPTION_STRING, "-visual", "visual", "Visual", |
| 224 |
DEF_FRAME_VISUAL, -1, Tk_Offset(Frame, visualName), |
| 225 |
TK_OPTION_NULL_OK, 0, 0}, |
| 226 |
{TK_OPTION_PIXELS, "-width", "width", "Width", |
| 227 |
DEF_FRAME_WIDTH, -1, Tk_Offset(Frame, width), |
| 228 |
0, 0, 0}, |
| 229 |
{TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, |
| 230 |
(char *) NULL, 0, 0, 0, 0, 0} |
| 231 |
}; |
| 232 |
|
| 233 |
static Tk_OptionSpec frameOptSpec[] = { |
| 234 |
{TK_OPTION_SYNONYM, "-bd", (char *) NULL, (char *) NULL, |
| 235 |
(char *) NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, |
| 236 |
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", |
| 237 |
DEF_FRAME_BORDER_WIDTH, -1, Tk_Offset(Frame, borderWidth), |
| 238 |
0, 0, 0}, |
| 239 |
{TK_OPTION_STRING, "-class", "class", "Class", |
| 240 |
DEF_FRAME_CLASS, -1, Tk_Offset(Frame, className), |
| 241 |
0, 0, 0}, |
| 242 |
{TK_OPTION_RELIEF, "-relief", "relief", "Relief", |
| 243 |
DEF_FRAME_RELIEF, -1, Tk_Offset(Frame, relief), |
| 244 |
0, 0, 0}, |
| 245 |
{TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, |
| 246 |
(char *) NULL, 0, 0, 0, (ClientData) commonOptSpec, 0} |
| 247 |
}; |
| 248 |
|
| 249 |
static Tk_OptionSpec toplevelOptSpec[] = { |
| 250 |
{TK_OPTION_SYNONYM, "-bd", (char *) NULL, (char *) NULL, |
| 251 |
(char *) NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, |
| 252 |
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", |
| 253 |
DEF_FRAME_BORDER_WIDTH, -1, Tk_Offset(Frame, borderWidth), |
| 254 |
0, 0, 0}, |
| 255 |
{TK_OPTION_STRING, "-class", "class", "Class", |
| 256 |
DEF_TOPLEVEL_CLASS, -1, Tk_Offset(Frame, className), |
| 257 |
0, 0, 0}, |
| 258 |
{TK_OPTION_OBJ, "-menu", "menu", "Menu", |
| 259 |
DEF_TOPLEVEL_MENU, -1, Tk_Offset(Frame, menuName), |
| 260 |
TK_OPTION_NULL_OK, 0, 0}, |
| 261 |
{TK_OPTION_RELIEF, "-relief", "relief", "Relief", |
| 262 |
DEF_FRAME_RELIEF, -1, Tk_Offset(Frame, relief), |
| 263 |
0, 0, 0}, |
| 264 |
{TK_OPTION_STRING, "-screen", "screen", "Screen", |
| 265 |
DEF_TOPLEVEL_SCREEN, -1, Tk_Offset(Frame, screenName), |
| 266 |
TK_OPTION_NULL_OK, 0, 0}, |
| 267 |
{TK_OPTION_STRING, "-use", "use", "Use", |
| 268 |
DEF_TOPLEVEL_USE, -1, Tk_Offset(Frame, useThis), |
| 269 |
TK_OPTION_NULL_OK, 0, 0}, |
| 270 |
{TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, |
| 271 |
(char *) NULL, 0, 0, 0, (ClientData) commonOptSpec, 0} |
| 272 |
}; |
| 273 |
|
| 274 |
static Tk_OptionSpec labelframeOptSpec[] = { |
| 275 |
{TK_OPTION_SYNONYM, "-bd", (char *) NULL, (char *) NULL, |
| 276 |
(char *) NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, |
| 277 |
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", |
| 278 |
DEF_LABELFRAME_BORDER_WIDTH, -1, Tk_Offset(Frame, borderWidth), |
| 279 |
0, 0, 0}, |
| 280 |
{TK_OPTION_STRING, "-class", "class", "Class", |
| 281 |
DEF_LABELFRAME_CLASS, -1, Tk_Offset(Frame, className), |
| 282 |
0, 0, 0}, |
| 283 |
{TK_OPTION_SYNONYM, "-fg", "foreground", (char *) NULL, |
| 284 |
(char *) NULL, 0, -1, 0, (ClientData) "-foreground", 0}, |
| 285 |
{TK_OPTION_FONT, "-font", "font", "Font", |
| 286 |
DEF_LABELFRAME_FONT, -1, Tk_Offset(Labelframe, tkfont), 0, 0, 0}, |
| 287 |
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", |
| 288 |
DEF_LABELFRAME_FG, -1, Tk_Offset(Labelframe, textColorPtr), 0, 0, 0}, |
| 289 |
{TK_OPTION_STRING_TABLE, "-labelanchor", "labelAnchor", "LabelAnchor", |
| 290 |
DEF_LABELFRAME_LABELANCHOR, -1, Tk_Offset(Labelframe, labelAnchor), |
| 291 |
0, (ClientData) labelAnchorStrings, 0}, |
| 292 |
{TK_OPTION_WINDOW, "-labelwidget", "labelWidget", "LabelWidget", |
| 293 |
(char *) NULL, -1, Tk_Offset(Labelframe, labelWin), |
| 294 |
TK_OPTION_NULL_OK, 0, 0}, |
| 295 |
{TK_OPTION_RELIEF, "-relief", "relief", "Relief", |
| 296 |
DEF_LABELFRAME_RELIEF, -1, Tk_Offset(Frame, relief), |
| 297 |
0, 0, 0}, |
| 298 |
{TK_OPTION_STRING, "-text", "text", "Text", |
| 299 |
DEF_LABELFRAME_TEXT, Tk_Offset(Labelframe, textPtr), -1, |
| 300 |
TK_OPTION_NULL_OK, 0, 0}, |
| 301 |
{TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, |
| 302 |
(char *) NULL, 0, 0, 0, (ClientData) commonOptSpec, 0} |
| 303 |
}; |
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
static char *classNames[] = {"Frame", "Toplevel", "Labelframe"}; |
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
static Tk_OptionSpec *optionSpecs[] = { |
| 317 |
frameOptSpec, |
| 318 |
toplevelOptSpec, |
| 319 |
labelframeOptSpec, |
| 320 |
}; |
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
static void ComputeFrameGeometry _ANSI_ARGS_((Frame *framePtr)); |
| 327 |
static int ConfigureFrame _ANSI_ARGS_((Tcl_Interp *interp, |
| 328 |
Frame *framePtr, int objc, Tcl_Obj *CONST objv[])); |
| 329 |
static int CreateFrame _ANSI_ARGS_((ClientData clientData, |
| 330 |
Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], |
| 331 |
enum FrameType type, char *appName)); |
| 332 |
static void DestroyFrame _ANSI_ARGS_((char *memPtr)); |
| 333 |
static void DestroyFramePartly _ANSI_ARGS_((Frame *framePtr)); |
| 334 |
static void DisplayFrame _ANSI_ARGS_((ClientData clientData)); |
| 335 |
static void FrameCmdDeletedProc _ANSI_ARGS_(( |
| 336 |
ClientData clientData)); |
| 337 |
static void FrameEventProc _ANSI_ARGS_((ClientData clientData, |
| 338 |
XEvent *eventPtr)); |
| 339 |
static void FrameLostSlaveProc _ANSI_ARGS_(( |
| 340 |
ClientData clientData, Tk_Window tkwin)); |
| 341 |
static void FrameRequestProc _ANSI_ARGS_((ClientData clientData, |
| 342 |
Tk_Window tkwin)); |
| 343 |
static void FrameStructureProc _ANSI_ARGS_(( |
| 344 |
ClientData clientData, XEvent *eventPtr)); |
| 345 |
static int FrameWidgetObjCmd _ANSI_ARGS_((ClientData clientData, |
| 346 |
Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); |
| 347 |
static void FrameWorldChanged _ANSI_ARGS_(( |
| 348 |
ClientData instanceData)); |
| 349 |
static void MapFrame _ANSI_ARGS_((ClientData clientData)); |
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
static Tk_ClassProcs frameClass = { |
| 357 |
sizeof(Tk_ClassProcs), |
| 358 |
FrameWorldChanged |
| 359 |
}; |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
static Tk_GeomMgr frameGeomType = { |
| 367 |
"labelframe", |
| 368 |
FrameRequestProc, |
| 369 |
FrameLostSlaveProc |
| 370 |
}; |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
int |
| 393 |
Tk_FrameObjCmd(clientData, interp, objc, objv) |
| 394 |
ClientData clientData; |
| 395 |
Tcl_Interp *interp; |
| 396 |
int objc; |
| 397 |
Tcl_Obj *CONST objv[]; |
| 398 |
{ |
| 399 |
return CreateFrame(clientData, interp, objc, objv, TYPE_FRAME, |
| 400 |
(char *) NULL); |
| 401 |
} |
| 402 |
|
| 403 |
int |
| 404 |
Tk_ToplevelObjCmd(clientData, interp, objc, objv) |
| 405 |
ClientData clientData; |
| 406 |
Tcl_Interp *interp; |
| 407 |
int objc; |
| 408 |
Tcl_Obj *CONST objv[]; |
| 409 |
{ |
| 410 |
return CreateFrame(clientData, interp, objc, objv, TYPE_TOPLEVEL, |
| 411 |
(char *) NULL); |
| 412 |
} |
| 413 |
|
| 414 |
int |
| 415 |
Tk_LabelframeObjCmd(clientData, interp, objc, objv) |
| 416 |
ClientData clientData; |
| 417 |
Tcl_Interp *interp; |
| 418 |
int objc; |
| 419 |
Tcl_Obj *CONST objv[]; |
| 420 |
{ |
| 421 |
return CreateFrame(clientData, interp, objc, objv, TYPE_LABELFRAME, |
| 422 |
(char *) NULL); |
| 423 |
} |
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
int |
| 445 |
TkCreateFrame(clientData, interp, argc, argv, toplevel, appName) |
| 446 |
ClientData clientData; |
| 447 |
Tcl_Interp *interp; |
| 448 |
int argc; |
| 449 |
char **argv; |
| 450 |
int toplevel; |
| 451 |
|
| 452 |
char *appName; |
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
{ |
| 457 |
int result, i; |
| 458 |
#ifndef _LANG |
| 459 |
Tcl_Obj **objv = (Tcl_Obj **) ckalloc((argc+1) * sizeof(Tcl_Obj **)); |
| 460 |
for (i=0; i<argc; i++) { |
| 461 |
objv[i] = Tcl_NewStringObj(args[i], -1); |
| 462 |
Tcl_IncrRefCount(objv[i]); |
| 463 |
} |
| 464 |
objv[argc] = NULL; |
| 465 |
#endif |
| 466 |
result = CreateFrame(clientData, interp, argc, objv, |
| 467 |
toplevel ? TYPE_TOPLEVEL : TYPE_FRAME, appName); |
| 468 |
#ifndef _LANG |
| 469 |
for (i=0; i<argc; i++) { |
| 470 |
Tcl_DecrRefCount(objv[i]); |
| 471 |
} |
| 472 |
ckfree((char *) objv); |
| 473 |
#endif |
| 474 |
return result; |
| 475 |
} |
| 476 |
|
| 477 |
static int |
| 478 |
CreateFrame(clientData, interp, objc, objv, type, appName) |
| 479 |
ClientData clientData; |
| 480 |
Tcl_Interp *interp; |
| 481 |
int objc; |
| 482 |
Tcl_Obj *CONST objv[]; |
| 483 |
enum FrameType type; |
| 484 |
char *appName; |
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
{ |
| 489 |
Tk_Window tkwin; |
| 490 |
Frame *framePtr; |
| 491 |
Tk_OptionTable optionTable; |
| 492 |
Tk_Window new; |
| 493 |
CONST char *className, *screenName, *colormapName, *arg; |
| 494 |
Tcl_Obj *visualName; |
| 495 |
Tcl_Obj *useOption; |
| 496 |
int i, c, depth; |
| 497 |
size_t length; |
| 498 |
unsigned int mask; |
| 499 |
Colormap colormap; |
| 500 |
Visual *visual; |
| 501 |
|
| 502 |
if (objc < 2) { |
| 503 |
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); |
| 504 |
return TCL_ERROR; |
| 505 |
} |
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
optionTable = Tk_CreateOptionTable(interp, optionSpecs[type]); |
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
className = colormapName = screenName = NULL; |
| 522 |
useOption = NULL; |
| 523 |
visualName = NULL; |
| 524 |
colormap = None; |
| 525 |
for (i = 2; i < objc; i += 2) { |
| 526 |
arg = Tcl_GetStringFromObj(objv[i], (int *) &length); |
| 527 |
if (length < 2) { |
| 528 |
continue; |
| 529 |
} |
| 530 |
c = arg[1]; |
| 531 |
if ((c == 'c') && (strncmp(arg, "-class", length) == 0) |
| 532 |
&& (length >= 3)) { |
| 533 |
className = Tcl_GetString(objv[i+1]); |
| 534 |
} else if ((c == 'c') |
| 535 |
&& (strncmp(arg, "-colormap", length) == 0)) { |
| 536 |
colormapName = Tcl_GetString(objv[i+1]); |
| 537 |
} else if ((c == 's') && (type == TYPE_TOPLEVEL) |
| 538 |
&& (strncmp(arg, "-screen", length) == 0)) { |
| 539 |
screenName = Tcl_GetString(objv[i+1]); |
| 540 |
} else if ((c == 'u') && (type == TYPE_TOPLEVEL) |
| 541 |
&& (strncmp(arg, "-use", length) == 0)) { |
| 542 |
useOption = objv[i+1]; |
| 543 |
} else if ((c == 'v') |
| 544 |
&& (strncmp(arg, "-visual", length) == 0)) { |
| 545 |
visualName = objv[i+1]; |
| 546 |
} |
| 547 |
} |
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
if (screenName == NULL) { |
| 565 |
screenName = (type == TYPE_TOPLEVEL) ? "" : NULL; |
| 566 |
} |
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
tkwin = Tk_MainWindow(interp); |
| 575 |
if (tkwin != NULL) { |
| 576 |
new = Tk_CreateWindowFromPath(interp, tkwin, Tcl_GetString(objv[1]), |
| 577 |
screenName); |
| 578 |
} else if (appName == NULL) { |
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
Tcl_AppendResult(interp, "unable to create widget \"", |
| 585 |
Tcl_GetString(objv[1]), "\"", (char *) NULL); |
| 586 |
new = NULL; |
| 587 |
} else { |
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
new = TkCreateMainWindow(interp, screenName, appName); |
| 593 |
} |
| 594 |
if (new == NULL) { |
| 595 |
goto error; |
| 596 |
} |
| 597 |
if (className == NULL) { |
| 598 |
className = Tk_GetOption(new, "class", "Class"); |
| 599 |
if (className == NULL) { |
| 600 |
className = classNames[type]; |
| 601 |
} |
| 602 |
} |
| 603 |
Tk_SetClass(new, className); |
| 604 |
if (useOption == NULL) { |
| 605 |
CONST char *s = Tk_GetOption(new, "use", "Use"); |
| 606 |
if (s) |
| 607 |
LangSetDefault(&useOption,s); |
| 608 |
} |
| 609 |
if (!LangNull(useOption)) { |
| 610 |
if (TkpUseWindow(interp, new, useOption) != TCL_OK) { |
| 611 |
goto error; |
| 612 |
} |
| 613 |
} |
| 614 |
if (visualName == NULL) { |
| 615 |
CONST char *s = Tk_GetOption(new, "visual", "Visual"); |
| 616 |
if (s) |
| 617 |
LangSetDefault(&visualName,s); |
| 618 |
} |
| 619 |
if (colormapName == NULL) { |
| 620 |
colormapName = Tk_GetOption(new, "colormap", "Colormap"); |
| 621 |
} |
| 622 |
if ((colormapName != NULL) && (*colormapName == 0)) { |
| 623 |
colormapName = NULL; |
| 624 |
} |
| 625 |
if (visualName != NULL) { |
| 626 |
visual = Tk_GetVisual(interp, new, visualName, &depth, |
| 627 |
(colormapName == NULL) ? &colormap : (Colormap *) NULL); |
| 628 |
if (visual == NULL) { |
| 629 |
goto error; |
| 630 |
} |
| 631 |
Tk_SetWindowVisual(new, visual, depth, colormap); |
| 632 |
} |
| 633 |
if (colormapName != NULL) { |
| 634 |
colormap = Tk_GetColormap(interp, new, colormapName); |
| 635 |
if (colormap == None) { |
| 636 |
goto error; |
| 637 |
} |
| 638 |
Tk_SetWindowColormap(new, colormap); |
| 639 |
} |
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
if (type == TYPE_TOPLEVEL) { |
| 648 |
Tk_GeometryRequest(new, 200, 200); |
| 649 |
} |
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
if (type == TYPE_LABELFRAME) { |
| 658 |
framePtr = (Frame *) ckalloc(sizeof(Labelframe)); |
| 659 |
memset((void *) framePtr, 0, (sizeof(Labelframe))); |
| 660 |
} else { |
| 661 |
framePtr = (Frame *) ckalloc(sizeof(Frame)); |
| 662 |
memset((void *) framePtr, 0, (sizeof(Frame))); |
| 663 |
} |
| 664 |
framePtr->tkwin = new; |
| 665 |
framePtr->display = Tk_Display(new); |
| 666 |
framePtr->interp = interp; |
| 667 |
framePtr->widgetCmd = Tcl_CreateObjCommand(interp, |
| 668 |
Tk_PathName(new), FrameWidgetObjCmd, |
| 669 |
(ClientData) framePtr, FrameCmdDeletedProc); |
| 670 |
framePtr->optionTable = optionTable; |
| 671 |
framePtr->type = type; |
| 672 |
framePtr->colormap = colormap; |
| 673 |
framePtr->relief = TK_RELIEF_FLAT; |
| 674 |
framePtr->cursor = None; |
| 675 |
|
| 676 |
if (framePtr->type == TYPE_LABELFRAME) { |
| 677 |
Labelframe *labelframePtr = (Labelframe *) framePtr; |
| 678 |
labelframePtr->labelAnchor = LABELANCHOR_NW; |
| 679 |
labelframePtr->textGC = None; |
| 680 |
} |
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
Tk_SetClassProcs(new, &frameClass, (ClientData) framePtr); |
| 686 |
|
| 687 |
mask = ExposureMask | StructureNotifyMask | FocusChangeMask; |
| 688 |
if (type == TYPE_TOPLEVEL) { |
| 689 |
mask |= ActivateMask; |
| 690 |
} |
| 691 |
Tk_CreateEventHandler(new, mask, FrameEventProc, (ClientData) framePtr); |
| 692 |
if ((Tk_InitOptions(interp, (char *) framePtr, optionTable, new) |
| 693 |
!= TCL_OK) || |
| 694 |
(ConfigureFrame(interp, framePtr, objc-2, objv+2) != TCL_OK)) { |
| 695 |
goto error; |
| 696 |
} |
| 697 |
if ((framePtr->isContainer)) { |
| 698 |
if (framePtr->useThis == NULL) { |
| 699 |
TkpMakeContainer(framePtr->tkwin); |
| 700 |
} else { |
| 701 |
Tcl_AppendResult(interp, "A window cannot have both the -use ", |
| 702 |
"and the -container option set.", (char *) NULL); |
| 703 |
goto error; |
| 704 |
} |
| 705 |
} |
| 706 |
if (type == TYPE_TOPLEVEL) { |
| 707 |
Tcl_DoWhenIdle(MapFrame, (ClientData) framePtr); |
| 708 |
} |
| 709 |
Tcl_SetResult(interp, Tk_PathName(new), TCL_STATIC); |
| 710 |
return TCL_OK; |
| 711 |
|
| 712 |
error: |
| 713 |
if (new != NULL) { |
| 714 |
Tk_DestroyWindow(new); |
| 715 |
} |
| 716 |
return TCL_ERROR; |
| 717 |
} |
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
static int |
| 738 |
FrameWidgetObjCmd(clientData, interp, objc, objv) |
| 739 |
ClientData clientData; |
| 740 |
Tcl_Interp *interp; |
| 741 |
int objc; |
| 742 |
Tcl_Obj *CONST objv[]; |
| 743 |
{ |
| 744 |
static CONST char *frameOptions[] = { |
| 745 |
"cget", "configure", (char *) NULL |
| 746 |
}; |
| 747 |
enum options { |
| 748 |
FRAME_CGET, FRAME_CONFIGURE |
| 749 |
}; |
| 750 |
register Frame *framePtr = (Frame *) clientData; |
| 751 |
int result = TCL_OK, index; |
| 752 |
size_t length; |
| 753 |
int c, i; |
| 754 |
Tcl_Obj *objPtr; |
| 755 |
|
| 756 |
if (objc < 2) { |
| 757 |
Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); |
| 758 |
return TCL_ERROR; |
| 759 |
} |
| 760 |
if (Tcl_GetIndexFromObj(interp, objv[1], frameOptions, "option", 0, |
| 761 |
&index) != TCL_OK) { |
| 762 |
return TCL_ERROR; |
| 763 |
} |
| 764 |
Tcl_Preserve((ClientData) framePtr); |
| 765 |
switch ((enum options) index) { |
| 766 |
case FRAME_CGET: { |
| 767 |
if (objc != 3) { |
| 768 |
Tcl_WrongNumArgs(interp, 2, objv, "option"); |
| 769 |
result = TCL_ERROR; |
| 770 |
goto done; |
| 771 |
} |
| 772 |
objPtr = Tk_GetOptionValue(interp, (char *) framePtr, |
| 773 |
framePtr->optionTable, objv[2], framePtr->tkwin); |
| 774 |
if (objPtr == NULL) { |
| 775 |
result = TCL_ERROR; |
| 776 |
goto done; |
| 777 |
} else { |
| 778 |
Tcl_SetObjResult(interp, objPtr); |
| 779 |
} |
| 780 |
break; |
| 781 |
} |
| 782 |
case FRAME_CONFIGURE: { |
| 783 |
if (objc <= 3) { |
| 784 |
objPtr = Tk_GetOptionInfo(interp, (char *) framePtr, |
| 785 |
framePtr->optionTable, |
| 786 |
(objc == 3) ? objv[2] : (Tcl_Obj *) NULL, |
| 787 |
framePtr->tkwin); |
| 788 |
if (objPtr == NULL) { |
| 789 |
result = TCL_ERROR; |
| 790 |
goto done; |
| 791 |
} else { |
| 792 |
Tcl_SetObjResult(interp, objPtr); |
| 793 |
} |
| 794 |
} else { |
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
for (i = 2; i < objc; i++) { |
| 801 |
char *arg = Tcl_GetStringFromObj(objv[i], (int *) &length); |
| 802 |
if (length < 2) { |
| 803 |
continue; |
| 804 |
} |
| 805 |
c = arg[1]; |
| 806 |
if (((c == 'c') && (strncmp(arg, "-class", length) == 0) |
| 807 |
&& (length >= 2)) |
| 808 |
|| ((c == 'c') |
| 809 |
&& (strncmp(arg, "-colormap", length) == 0) |
| 810 |
&& (length >= 3)) |
| 811 |
|| ((c == 'c') |
| 812 |
&& (strncmp(arg, "-container", length) == 0) |
| 813 |
&& (length >= 3)) |
| 814 |
|| ((c == 's') && (framePtr->type == TYPE_TOPLEVEL) |
| 815 |
&& (strncmp(arg, "-screen", length) == 0)) |
| 816 |
|| ((c == 'u') && (framePtr->type == TYPE_TOPLEVEL) |
| 817 |
&& (strncmp(arg, "-use", length) == 0)) |
| 818 |
|| ((c == 'v') |
| 819 |
&& (strncmp(arg, "-visual", length) == 0))) { |
| 820 |
Tcl_AppendResult(interp, "can't modify ", arg, |
| 821 |
" option after widget is created", (char *) NULL); |
| 822 |
result = TCL_ERROR; |
| 823 |
goto done; |
| 824 |
} |
| 825 |
} |
| 826 |
result = ConfigureFrame(interp, framePtr, objc-2, objv+2); |
| 827 |
} |
| 828 |
break; |
| 829 |
} |
| 830 |
} |
| 831 |
|
| 832 |
done: |
| 833 |
Tcl_Release((ClientData) framePtr); |
| 834 |
return result; |
| 835 |
} |
| 836 |
|
| 837 |
|
| 838 |
|
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
static void |
| 856 |
DestroyFrame(memPtr) |
| 857 |
char *memPtr; |
| 858 |
{ |
| 859 |
register Frame *framePtr = (Frame *) memPtr; |
| 860 |
register Labelframe *labelframePtr = (Labelframe *) memPtr; |
| 861 |
|
| 862 |
if (framePtr->type == TYPE_LABELFRAME) { |
| 863 |
Tk_FreeTextLayout(labelframePtr->textLayout); |
| 864 |
if (labelframePtr->textGC != None) { |
| 865 |
Tk_FreeGC(framePtr->display, labelframePtr->textGC); |
| 866 |
} |
| 867 |
} |
| 868 |
if (framePtr->colormap != None) { |
| 869 |
Tk_FreeColormap(framePtr->display, framePtr->colormap); |
| 870 |
} |
| 871 |
ckfree((char *) framePtr); |
| 872 |
} |
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
|
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
|
| 893 |
static void |
| 894 |
DestroyFramePartly(framePtr) |
| 895 |
Frame *framePtr; |
| 896 |
{ |
| 897 |
register Labelframe *labelframePtr = (Labelframe *) framePtr; |
| 898 |
|
| 899 |
if (framePtr->type == TYPE_LABELFRAME && labelframePtr->labelWin != NULL) { |
| 900 |
Tk_DeleteEventHandler(labelframePtr->labelWin, StructureNotifyMask, |
| 901 |
FrameStructureProc, (ClientData) framePtr); |
| 902 |
Tk_ManageGeometry(labelframePtr->labelWin, (Tk_GeomMgr *) NULL, |
| 903 |
(ClientData) NULL); |
| 904 |
if (framePtr->tkwin != Tk_Parent(labelframePtr->labelWin)) { |
| 905 |
Tk_UnmaintainGeometry(labelframePtr->labelWin, framePtr->tkwin); |
| 906 |
} |
| 907 |
Tk_UnmapWindow(labelframePtr->labelWin); |
| 908 |
labelframePtr->labelWin = NULL; |
| 909 |
} |
| 910 |
|
| 911 |
Tk_FreeConfigOptions((char *) framePtr, framePtr->optionTable, |
| 912 |
framePtr->tkwin); |
| 913 |
} |
| 914 |
|
| 915 |
|
| 916 |
|
| 917 |
|
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
|
| 935 |
|
| 936 |
static int |
| 937 |
ConfigureFrame(interp, framePtr, objc, objv) |
| 938 |
Tcl_Interp *interp; |
| 939 |
register Frame *framePtr; |
| 940 |
|
| 941 |
int objc; |
| 942 |
Tcl_Obj *CONST objv[]; |
| 943 |
{ |
| 944 |
Tk_SavedOptions savedOptions; |
| 945 |
Tcl_Obj *oldMenuName; |
| 946 |
Tk_Window oldWindow = NULL; |
| 947 |
Labelframe *labelframePtr = (Labelframe *) framePtr; |
| 948 |
|
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
|
| 953 |
if (framePtr->menuName == NULL) { |
| 954 |
oldMenuName = NULL; |
| 955 |
} else { |
| 956 |
oldMenuName = LangCopyArg(framePtr->menuName); |
| 957 |
} |
| 958 |
|
| 959 |
if (framePtr->type == TYPE_LABELFRAME) { |
| 960 |
oldWindow = labelframePtr->labelWin; |
| 961 |
} |
| 962 |
if (Tk_SetOptions(interp, (char *) framePtr, |
| 963 |
framePtr->optionTable, objc, objv, |
| 964 |
framePtr->tkwin, &savedOptions, (int *) NULL) != TCL_OK) { |
| 965 |
if (oldMenuName != NULL) { |
| 966 |
#ifndef _LANG |
| 967 |
ckfree(oldMenuName); |
| 968 |
#else |
| 969 |
LangFreeArg(oldMenuName,TCL_DYNAMIC); |
| 970 |
#endif |
| 971 |
} |
| 972 |
return TCL_ERROR; |
| 973 |
} else { |
| 974 |
Tk_FreeSavedOptions(&savedOptions); |
| 975 |
} |
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
if (((oldMenuName == NULL) && (framePtr->menuName != NULL)) |
| 982 |
|| ((oldMenuName != NULL) && (framePtr->menuName == NULL)) |
| 983 |
|| ((oldMenuName != NULL) && (framePtr->menuName != NULL) |
| 984 |
&& oldMenuName != framePtr->menuName |
| 985 |
&& strcmp(Tcl_GetString(oldMenuName), Tcl_GetString(framePtr->menuName)) != 0)) { |
| 986 |
TkSetWindowMenuBar(interp, framePtr->tkwin, oldMenuName, |
| 987 |
framePtr->menuName); |
| 988 |
} |
| 989 |
|
| 990 |
#ifndef _LANG |
| 991 |
if (oldMenuName != NULL) { |
| 992 |
ckfree(oldMenuName); |
| 993 |
} |
| 994 |
#endif |
| 995 |
|
| 996 |
if (framePtr->border != NULL) { |
| 997 |
Tk_SetBackgroundFromBorder(framePtr->tkwin, framePtr->border); |
| 998 |
} else { |
| 999 |
Tk_SetWindowBackgroundPixmap(framePtr->tkwin, None); |
| 1000 |
} |
| 1001 |
|
| 1002 |
if (framePtr->highlightWidth < 0) { |
| 1003 |
framePtr->highlightWidth = 0; |
| 1004 |
} |
| 1005 |
if (framePtr->padX < 0) { |
| 1006 |
framePtr->padX = 0; |
| 1007 |
} |
| 1008 |
if (framePtr->padY < 0) { |
| 1009 |
framePtr->padY = 0; |
| 1010 |
} |
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
if (framePtr->type == TYPE_LABELFRAME) { |
| 1018 |
if (oldWindow != labelframePtr->labelWin) { |
| 1019 |
if (oldWindow != NULL) { |
| 1020 |
Tk_DeleteEventHandler(oldWindow, StructureNotifyMask, |
| 1021 |
FrameStructureProc, (ClientData) framePtr); |
| 1022 |
Tk_ManageGeometry(oldWindow, (Tk_GeomMgr *) NULL, |
| 1023 |
(ClientData) NULL); |
| 1024 |
Tk_UnmaintainGeometry(oldWindow, framePtr->tkwin); |
| 1025 |
Tk_UnmapWindow(oldWindow); |
| 1026 |
} |
| 1027 |
if (labelframePtr->labelWin != NULL) { |
| 1028 |
Tk_Window ancestor, parent, sibling = NULL; |
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
|
| 1033 |
|
| 1034 |
|
| 1035 |
|
| 1036 |
|
| 1037 |
parent = Tk_Parent(labelframePtr->labelWin); |
| 1038 |
for (ancestor = framePtr->tkwin; ; |
| 1039 |
ancestor = Tk_Parent(ancestor)) { |
| 1040 |
if (ancestor == parent) { |
| 1041 |
break; |
| 1042 |
} |
| 1043 |
sibling = ancestor; |
| 1044 |
if (Tk_IsTopLevel(ancestor)) { |
| 1045 |
badWindow: |
| 1046 |
Tcl_AppendResult(interp, "can't use ", |
| 1047 |
Tk_PathName(labelframePtr->labelWin), |
| 1048 |
" as label in this frame", (char *) NULL); |
| 1049 |
labelframePtr->labelWin = NULL; |
| 1050 |
return TCL_ERROR; |
| 1051 |
} |
| 1052 |
} |
| 1053 |
if (Tk_IsTopLevel(labelframePtr->labelWin)) { |
| 1054 |
goto badWindow; |
| 1055 |
} |
| 1056 |
if (labelframePtr->labelWin == framePtr->tkwin) { |
| 1057 |
goto badWindow; |
| 1058 |
} |
| 1059 |
Tk_CreateEventHandler(labelframePtr->labelWin, |
| 1060 |
StructureNotifyMask, FrameStructureProc, |
| 1061 |
(ClientData) framePtr); |
| 1062 |
Tk_ManageGeometry(labelframePtr->labelWin, &frameGeomType, |
| 1063 |
(ClientData) framePtr); |
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
if (sibling != NULL) { |
| 1072 |
Tk_RestackWindow(labelframePtr->labelWin, Above, sibling); |
| 1073 |
} |
| 1074 |
} |
| 1075 |
} |
| 1076 |
} |
| 1077 |
|
| 1078 |
FrameWorldChanged((ClientData) framePtr); |
| 1079 |
|
| 1080 |
return TCL_OK; |
| 1081 |
} |
| 1082 |
|
| 1083 |
|
| 1084 |
|
| 1085 |
|
| 1086 |
|
| 1087 |
|
| 1088 |
|
| 1089 |
|
| 1090 |
|
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
|
| 1096 |
|
| 1097 |
|
| 1098 |
|
| 1099 |
|
| 1100 |
|
| 1101 |
static void |
| 1102 |
FrameWorldChanged(instanceData) |
| 1103 |
ClientData instanceData; |
| 1104 |
{ |
| 1105 |
Frame *framePtr = (Frame *) instanceData; |
| 1106 |
Labelframe *labelframePtr = (Labelframe *) framePtr; |
| 1107 |
Tk_Window tkwin = framePtr->tkwin; |
| 1108 |
XGCValues gcValues; |
| 1109 |
GC gc; |
| 1110 |
int anyTextLabel, anyWindowLabel; |
| 1111 |
int bWidthLeft, bWidthRight, bWidthTop, bWidthBottom; |
| 1112 |
char *labelText; |
| 1113 |
|
| 1114 |
anyTextLabel = (framePtr->type == TYPE_LABELFRAME) && |
| 1115 |
(labelframePtr->textPtr != NULL) && |
| 1116 |
(labelframePtr->labelWin == NULL); |
| 1117 |
anyWindowLabel = (framePtr->type == TYPE_LABELFRAME) && |
| 1118 |
(labelframePtr->labelWin != NULL); |
| 1119 |
|
| 1120 |
if (framePtr->type == TYPE_LABELFRAME) { |
| 1121 |
|
| 1122 |
|
| 1123 |
|
| 1124 |
|
| 1125 |
|
| 1126 |
gcValues.font = Tk_FontId(labelframePtr->tkfont); |
| 1127 |
gcValues.foreground = labelframePtr->textColorPtr->pixel; |
| 1128 |
gcValues.graphics_exposures = False; |
| 1129 |
gc = Tk_GetGC(tkwin, GCForeground | GCFont | GCGraphicsExposures, |
| 1130 |
&gcValues); |
| 1131 |
if (labelframePtr->textGC != None) { |
| 1132 |
Tk_FreeGC(framePtr->display, labelframePtr->textGC); |
| 1133 |
} |
| 1134 |
labelframePtr->textGC = gc; |
| 1135 |
|
| 1136 |
|
| 1137 |
|
| 1138 |
|
| 1139 |
|
| 1140 |
labelframePtr->labelReqWidth = labelframePtr->labelReqHeight = 0; |
| 1141 |
|
| 1142 |
if (anyTextLabel) { |
| 1143 |
labelText = Tcl_GetString(labelframePtr->textPtr); |
| 1144 |
Tk_FreeTextLayout(labelframePtr->textLayout); |
| 1145 |
labelframePtr->textLayout = Tk_ComputeTextLayout(labelframePtr->tkfont, |
| 1146 |
labelText, -1, 0, TK_JUSTIFY_CENTER, 0, |
| 1147 |
&labelframePtr->labelReqWidth, &labelframePtr->labelReqHeight); |
| 1148 |
labelframePtr->labelReqWidth += 2 * LABELSPACING; |
| 1149 |
labelframePtr->labelReqHeight += 2 * LABELSPACING; |
| 1150 |
} else if (anyWindowLabel) { |
| 1151 |
labelframePtr->labelReqWidth = Tk_ReqWidth(labelframePtr->labelWin); |
| 1152 |
labelframePtr->labelReqHeight = Tk_ReqHeight(labelframePtr->labelWin); |
| 1153 |
} |
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
|
| 1161 |
if ((labelframePtr->labelAnchor >= LABELANCHOR_N) && |
| 1162 |
(labelframePtr->labelAnchor <= LABELANCHOR_SW)) { |
| 1163 |
if (labelframePtr->labelReqHeight < framePtr->borderWidth) { |
| 1164 |
labelframePtr->labelReqHeight = framePtr->borderWidth; |
| 1165 |
} |
| 1166 |
} else { |
| 1167 |
if (labelframePtr->labelReqWidth < framePtr->borderWidth) { |
| 1168 |
labelframePtr->labelReqWidth = framePtr->borderWidth; |
| 1169 |
} |
| 1170 |
} |
| 1171 |
} |
| 1172 |
|
| 1173 |
|
| 1174 |
|
| 1175 |
|
| 1176 |
|
| 1177 |
bWidthBottom = bWidthTop = bWidthRight = bWidthLeft = |
| 1178 |
framePtr->borderWidth + framePtr->highlightWidth; |
| 1179 |
|
| 1180 |
bWidthLeft += framePtr->padX; |
| 1181 |
bWidthRight += framePtr->padX; |
| 1182 |
bWidthTop += framePtr->padY; |
| 1183 |
bWidthBottom += framePtr->padY; |
| 1184 |
|
| 1185 |
if (anyTextLabel || anyWindowLabel) { |
| 1186 |
switch (labelframePtr->labelAnchor) { |
| 1187 |
case LABELANCHOR_E: |
| 1188 |
case LABELANCHOR_EN: |
| 1189 |
case LABELANCHOR_ES: |
| 1190 |
bWidthRight += labelframePtr->labelReqWidth - |
| 1191 |
framePtr->borderWidth; |
| 1192 |
break; |
| 1193 |
case LABELANCHOR_N: |
| 1194 |
case LABELANCHOR_NE: |
| 1195 |
case LABELANCHOR_NW: |
| 1196 |
bWidthTop += labelframePtr->labelReqHeight - framePtr->borderWidth; |
| 1197 |
break; |
| 1198 |
case LABELANCHOR_S: |
| 1199 |
case LABELANCHOR_SE: |
| 1200 |
case LABELANCHOR_SW: |
| 1201 |
bWidthBottom += labelframePtr->labelReqHeight - |
| 1202 |
framePtr->borderWidth; |
| 1203 |
break; |
| 1204 |
default: |
| 1205 |
bWidthLeft += labelframePtr->labelReqWidth - framePtr->borderWidth; |
| 1206 |
break; |
| 1207 |
} |
| 1208 |
} |
| 1209 |
|
| 1210 |
Tk_SetInternalBorderEx(tkwin, bWidthLeft, bWidthRight, bWidthTop, |
| 1211 |
bWidthBottom); |
| 1212 |
|
| 1213 |
ComputeFrameGeometry(framePtr); |
| 1214 |
|
| 1215 |
|
| 1216 |
|
| 1217 |
|
| 1218 |
|
| 1219 |
if (framePtr->type == TYPE_LABELFRAME) { |
| 1220 |
int minwidth = labelframePtr->labelReqWidth; |
| 1221 |
int minheight = labelframePtr->labelReqHeight; |
| 1222 |
int padding = framePtr->highlightWidth; |
| 1223 |
if (framePtr->borderWidth > 0) { |
| 1224 |
padding += framePtr->borderWidth + LABELMARGIN; |
| 1225 |
} |
| 1226 |
padding *= 2; |
| 1227 |
if ((labelframePtr->labelAnchor >= LABELANCHOR_N) && |
| 1228 |
(labelframePtr->labelAnchor <= LABELANCHOR_SW)) { |
| 1229 |
minwidth += padding; |
| 1230 |
minheight += framePtr->borderWidth + framePtr->highlightWidth; |
| 1231 |
} else { |
| 1232 |
minheight += padding; |
| 1233 |
minwidth += framePtr->borderWidth + framePtr->highlightWidth; |
| 1234 |
} |
| 1235 |
Tk_SetMinimumRequestSize(tkwin, minwidth, minheight); |
| 1236 |
} |
| 1237 |
|
| 1238 |
if ((framePtr->width > 0) || (framePtr->height > 0)) { |
| 1239 |
Tk_GeometryRequest(tkwin, framePtr->width, framePtr->height); |
| 1240 |
} |
| 1241 |
|
| 1242 |
if (Tk_IsMapped(tkwin)) { |
| 1243 |
if (!(framePtr->flags & REDRAW_PENDING)) { |
| 1244 |
Tcl_DoWhenIdle(DisplayFrame, (ClientData) framePtr); |
| 1245 |
} |
| 1246 |
framePtr->flags |= REDRAW_PENDING; |
| 1247 |
} |
| 1248 |
} |
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
|
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
|
| 1259 |
|
| 1260 |
|
| 1261 |
|
| 1262 |
|
| 1263 |
|
| 1264 |
|
| 1265 |
|
| 1266 |
|
| 1267 |
|
| 1268 |
static void |
| 1269 |
ComputeFrameGeometry(framePtr) |
| 1270 |
register Frame *framePtr; |
| 1271 |
{ |
| 1272 |
int otherWidth, otherHeight, otherWidthT, otherHeightT, padding; |
| 1273 |
int maxWidth, maxHeight; |
| 1274 |
Tk_Window tkwin; |
| 1275 |
Labelframe *labelframePtr = (Labelframe *) framePtr; |
| 1276 |
|
| 1277 |
|
| 1278 |
|
| 1279 |
|
| 1280 |
|
| 1281 |
if (framePtr->type != TYPE_LABELFRAME) return; |
| 1282 |
if ((labelframePtr->textPtr == NULL) && |
| 1283 |
(labelframePtr->labelWin == NULL)) return; |
| 1284 |
|
| 1285 |
tkwin = framePtr->tkwin; |
| 1286 |
|
| 1287 |
|
| 1288 |
|
| 1289 |
|
| 1290 |
|
| 1291 |
labelframePtr->labelBox.width = labelframePtr->labelReqWidth; |
| 1292 |
labelframePtr->labelBox.height = labelframePtr->labelReqHeight; |
| 1293 |
|
| 1294 |
padding = framePtr->highlightWidth; |
| 1295 |
if (framePtr->borderWidth > 0) { |
| 1296 |
padding += framePtr->borderWidth + LABELMARGIN; |
| 1297 |
} |
| 1298 |
padding *= 2; |
| 1299 |
|
| 1300 |
maxHeight = Tk_Height(tkwin); |
| 1301 |
maxWidth = Tk_Width(tkwin); |
| 1302 |
|
| 1303 |
if ((labelframePtr->labelAnchor >= LABELANCHOR_N) && |
| 1304 |
(labelframePtr->labelAnchor <= LABELANCHOR_SW)) { |
| 1305 |
maxWidth -= padding; |
| 1306 |
if (maxWidth < 1) maxWidth = 1; |
| 1307 |
} else { |
| 1308 |
maxHeight -= padding; |
| 1309 |
if (maxHeight < 1) maxHeight = 1; |
| 1310 |
} |
| 1311 |
if (labelframePtr->labelBox.width > maxWidth) { |
| 1312 |
labelframePtr->labelBox.width = maxWidth; |
| 1313 |
} |
| 1314 |
if (labelframePtr->labelBox.height > maxHeight) { |
| 1315 |
labelframePtr->labelBox.height = maxHeight; |
| 1316 |
} |
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
|
| 1324 |
otherWidth = Tk_Width(tkwin) - labelframePtr->labelBox.width; |
| 1325 |
otherHeight = Tk_Height(tkwin) - labelframePtr->labelBox.height; |
| 1326 |
otherWidthT = Tk_Width(tkwin) - labelframePtr->labelReqWidth; |
| 1327 |
otherHeightT = Tk_Height(tkwin) - labelframePtr->labelReqHeight; |
| 1328 |
padding = framePtr->highlightWidth; |
| 1329 |
|
| 1330 |
switch (labelframePtr->labelAnchor) { |
| 1331 |
case LABELANCHOR_E: |
| 1332 |
case LABELANCHOR_EN: |
| 1333 |
case LABELANCHOR_ES: |
| 1334 |
labelframePtr->labelTextX = otherWidthT - padding; |
| 1335 |
labelframePtr->labelBox.x = otherWidth - padding; |
| 1336 |
break; |
| 1337 |
case LABELANCHOR_N: |
| 1338 |
case LABELANCHOR_NE: |
| 1339 |
case LABELANCHOR_NW: |
| 1340 |
labelframePtr->labelTextY = padding; |
| 1341 |
labelframePtr->labelBox.y = padding; |
| 1342 |
break; |
| 1343 |
case LABELANCHOR_S: |
| 1344 |
case LABELANCHOR_SE: |
| 1345 |
case LABELANCHOR_SW: |
| 1346 |
labelframePtr->labelTextY = otherHeightT - padding; |
| 1347 |
labelframePtr->labelBox.y = otherHeight - padding; |
| 1348 |
break; |
| 1349 |
default: |
| 1350 |
labelframePtr->labelTextX = padding; |
| 1351 |
labelframePtr->labelBox.x = padding; |
| 1352 |
break; |
| 1353 |
} |
| 1354 |
|
| 1355 |
if (framePtr->borderWidth > 0) { |
| 1356 |
padding += framePtr->borderWidth + LABELMARGIN; |
| 1357 |
} |
| 1358 |
|
| 1359 |
switch (labelframePtr->labelAnchor) { |
| 1360 |
case LABELANCHOR_NW: |
| 1361 |
case LABELANCHOR_SW: |
| 1362 |
labelframePtr->labelTextX = padding; |
| 1363 |
labelframePtr->labelBox.x = padding; |
| 1364 |
break; |
| 1365 |
case LABELANCHOR_N: |
| 1366 |
case LABELANCHOR_S: |
| 1367 |
labelframePtr->labelTextX = otherWidthT / 2; |
| 1368 |
labelframePtr->labelBox.x = otherWidth / 2; |
| 1369 |
break; |
| 1370 |
case LABELANCHOR_NE: |
| 1371 |
case LABELANCHOR_SE: |
| 1372 |
labelframePtr->labelTextX = otherWidthT - padding; |
| 1373 |
labelframePtr->labelBox.x = otherWidth - padding; |
| 1374 |
break; |
| 1375 |
case LABELANCHOR_EN: |
| 1376 |
case LABELANCHOR_WN: |
| 1377 |
labelframePtr->labelTextY = padding; |
| 1378 |
labelframePtr->labelBox.y = padding; |
| 1379 |
break; |
| 1380 |
case LABELANCHOR_E: |
| 1381 |
case LABELANCHOR_W: |
| 1382 |
labelframePtr->labelTextY = otherHeightT / 2; |
| 1383 |
labelframePtr->labelBox.y = otherHeight / 2; |
| 1384 |
break; |
| 1385 |
default: |
| 1386 |
labelframePtr->labelTextY = otherHeightT - padding; |
| 1387 |
labelframePtr->labelBox.y = otherHeight - padding; |
| 1388 |
break; |
| 1389 |
} |
| 1390 |
} |
| 1391 |
|
| 1392 |
|
| 1393 |
|
| 1394 |
|
| 1395 |
|
| 1396 |
|
| 1397 |
|
| 1398 |
|
| 1399 |
|
| 1400 |
|
| 1401 |
|
| 1402 |
|
| 1403 |
|
| 1404 |
|
| 1405 |
|
| 1406 |
|
| 1407 |
|
| 1408 |
|
| 1409 |
static void |
| 1410 |
DisplayFrame(clientData) |
| 1411 |
ClientData clientData; |
| 1412 |
{ |
| 1413 |
register Frame *framePtr = (Frame *) clientData; |
| 1414 |
register Tk_Window tkwin = framePtr->tkwin; |
| 1415 |
int bdX1, bdY1, bdX2, bdY2, hlWidth; |
| 1416 |
Pixmap pixmap; |
| 1417 |
TkRegion clipRegion = NULL; |
| 1418 |
|
| 1419 |
framePtr->flags &= ~REDRAW_PENDING; |
| 1420 |
|
| 1421 |
if ((framePtr->tkwin == NULL) || !Tk_IsMapped(tkwin) |
| 1422 |
|| framePtr->isContainer) { |
| 1423 |
return; |
| 1424 |
} |
| 1425 |
|
| 1426 |
|
| 1427 |
|
| 1428 |
|
| 1429 |
|
| 1430 |
hlWidth = framePtr->highlightWidth; |
| 1431 |
|
| 1432 |
if (hlWidth != 0) { |
| 1433 |
GC fgGC, bgGC; |
| 1434 |
|
| 1435 |
bgGC = Tk_GCForColor(framePtr->highlightBgColorPtr, |
| 1436 |
Tk_WindowId(tkwin)); |
| 1437 |
if (framePtr->flags & GOT_FOCUS) { |
| 1438 |
fgGC = Tk_GCForColor(framePtr->highlightColorPtr, |
| 1439 |
Tk_WindowId(tkwin)); |
| 1440 |
TkpDrawHighlightBorder(tkwin, fgGC, bgGC, hlWidth, |
| 1441 |
Tk_WindowId(tkwin)); |
| 1442 |
} else { |
| 1443 |
TkpDrawHighlightBorder(tkwin, bgGC, bgGC, hlWidth, |
| 1444 |
Tk_WindowId(tkwin)); |
| 1445 |
} |
| 1446 |
} |
| 1447 |
|
| 1448 |
|
| 1449 |
|
| 1450 |
|
| 1451 |
|
| 1452 |
if (framePtr->border == NULL) return; |
| 1453 |
|
| 1454 |
if (framePtr->type != TYPE_LABELFRAME) { |
| 1455 |
|
| 1456 |
|
| 1457 |
|
| 1458 |
|
| 1459 |
noLabel: |
| 1460 |
Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), |
| 1461 |
framePtr->border, hlWidth, hlWidth, |
| 1462 |
Tk_Width(tkwin) - 2 * hlWidth, |
| 1463 |
Tk_Height(tkwin) - 2 * hlWidth, |
| 1464 |
framePtr->borderWidth, framePtr->relief); |
| 1465 |
} else { |
| 1466 |
Labelframe *labelframePtr = (Labelframe *) framePtr; |
| 1467 |
|
| 1468 |
if ((labelframePtr->textPtr == NULL) && |
| 1469 |
(labelframePtr->labelWin == NULL)) { |
| 1470 |
goto noLabel; |
| 1471 |
} |
| 1472 |
|
| 1473 |
|
| 1474 |
|
| 1475 |
|
| 1476 |
|
| 1477 |
|
| 1478 |
|
| 1479 |
|
| 1480 |
pixmap = Tk_GetPixmap(framePtr->display, Tk_WindowId(tkwin), |
| 1481 |
Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin)); |
| 1482 |
|
| 1483 |
|
| 1484 |
|
| 1485 |
|
| 1486 |
|
| 1487 |
Tk_Fill3DRectangle(tkwin, pixmap, framePtr->border, 0, 0, |
| 1488 |
Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); |
| 1489 |
|
| 1490 |
|
| 1491 |
|
| 1492 |
|
| 1493 |
|
| 1494 |
bdX1 = bdY1 = hlWidth; |
| 1495 |
bdX2 = Tk_Width(tkwin) - hlWidth; |
| 1496 |
bdY2 = Tk_Height(tkwin) - hlWidth; |
| 1497 |
|
| 1498 |
switch (labelframePtr->labelAnchor) { |
| 1499 |
case LABELANCHOR_E: |
| 1500 |
case LABELANCHOR_EN: |
| 1501 |
case LABELANCHOR_ES: |
| 1502 |
bdX2 -= (labelframePtr->labelBox.width - framePtr->borderWidth) |
| 1503 |
/ 2; |
| 1504 |
break; |
| 1505 |
case LABELANCHOR_N: |
| 1506 |
case LABELANCHOR_NE: |
| 1507 |
case LABELANCHOR_NW: |
| 1508 |
|
| 1509 |
|
| 1510 |
|
| 1511 |
|
| 1512 |
|
| 1513 |
bdY1 += (labelframePtr->labelBox.height - framePtr->borderWidth +1) |
| 1514 |
/ 2; |
| 1515 |
break; |
| 1516 |
case LABELANCHOR_S: |
| 1517 |
case LABELANCHOR_SE: |
| 1518 |
case LABELANCHOR_SW: |
| 1519 |
bdY2 -= (labelframePtr->labelBox.height - framePtr->borderWidth) |
| 1520 |
/ 2; |
| 1521 |
break; |
| 1522 |
default: |
| 1523 |
bdX1 += (labelframePtr->labelBox.width - framePtr->borderWidth) |
| 1524 |
/ 2; |
| 1525 |
break; |
| 1526 |
} |
| 1527 |
|
| 1528 |
|
| 1529 |
|
| 1530 |
|
| 1531 |
|
| 1532 |
Tk_Draw3DRectangle(tkwin, pixmap, framePtr->border, bdX1, bdY1, |
| 1533 |
bdX2 - bdX1, bdY2 - bdY1, framePtr->borderWidth, |
| 1534 |
framePtr->relief); |
| 1535 |
|
| 1536 |
if (labelframePtr->labelWin == NULL) { |
| 1537 |
|
| 1538 |
|
| 1539 |
|
| 1540 |
|
| 1541 |
Tk_Fill3DRectangle(tkwin, pixmap, |
| 1542 |
framePtr->border, labelframePtr->labelBox.x, |
| 1543 |
labelframePtr->labelBox.y, labelframePtr->labelBox.width, |
| 1544 |
labelframePtr->labelBox.height, 0, TK_RELIEF_FLAT); |
| 1545 |
|
| 1546 |
|
| 1547 |
|
| 1548 |
|
| 1549 |
|
| 1550 |
|
| 1551 |
|
| 1552 |
if ((labelframePtr->labelBox.width < labelframePtr->labelReqWidth) |
| 1553 |
|| (labelframePtr->labelBox.height < |
| 1554 |
labelframePtr->labelReqHeight)) { |
| 1555 |
clipRegion = TkCreateRegion(); |
| 1556 |
TkUnionRectWithRegion(&labelframePtr->labelBox, clipRegion, |
| 1557 |
clipRegion); |
| 1558 |
TkSetRegion(framePtr->display, labelframePtr->textGC, |
| 1559 |
clipRegion); |
| 1560 |
} |
| 1561 |
|
| 1562 |
Tk_DrawTextLayout(framePtr->display, pixmap, |
| 1563 |
labelframePtr->textGC, labelframePtr->textLayout, |
| 1564 |
labelframePtr->labelTextX + LABELSPACING, |
| 1565 |
labelframePtr->labelTextY + LABELSPACING, 0, -1); |
| 1566 |
|
| 1567 |
if (clipRegion != NULL) { |
| 1568 |
XSetClipMask(framePtr->display, labelframePtr->textGC, None); |
| 1569 |
TkDestroyRegion(clipRegion); |
| 1570 |
} |
| 1571 |
} else { |
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
|
| 1577 |
if (framePtr->tkwin == Tk_Parent(labelframePtr->labelWin)) { |
| 1578 |
if ((labelframePtr->labelBox.x != Tk_X(labelframePtr->labelWin)) |
| 1579 |
|| (labelframePtr->labelBox.y != |
| 1580 |
Tk_Y(labelframePtr->labelWin)) |
| 1581 |
|| (labelframePtr->labelBox.width != |
| 1582 |
Tk_Width(labelframePtr->labelWin)) |
| 1583 |
|| (labelframePtr->labelBox.height != |
| 1584 |
Tk_Height(labelframePtr->labelWin))) { |
| 1585 |
Tk_MoveResizeWindow(labelframePtr->labelWin, |
| 1586 |
labelframePtr->labelBox.x, labelframePtr->labelBox.y, |
| 1587 |
labelframePtr->labelBox.width, |
| 1588 |
labelframePtr->labelBox.height); |
| 1589 |
} |
| 1590 |
Tk_MapWindow(labelframePtr->labelWin); |
| 1591 |
} else { |
| 1592 |
Tk_MaintainGeometry(labelframePtr->labelWin, framePtr->tkwin, |
| 1593 |
labelframePtr->labelBox.x, labelframePtr->labelBox.y, |
| 1594 |
labelframePtr->labelBox.width, |
| 1595 |
labelframePtr->labelBox.height); |
| 1596 |
} |
| 1597 |
} |
| 1598 |
|
| 1599 |
|
| 1600 |
|
| 1601 |
|
| 1602 |
|
| 1603 |
|
| 1604 |
|
| 1605 |
XCopyArea(framePtr->display, pixmap, Tk_WindowId(tkwin), |
| 1606 |
labelframePtr->textGC, hlWidth, hlWidth, |
| 1607 |
(unsigned) (Tk_Width(tkwin) - 2 * hlWidth), |
| 1608 |
(unsigned) (Tk_Height(tkwin) - 2 * hlWidth), |
| 1609 |
hlWidth, hlWidth); |
| 1610 |
Tk_FreePixmap(framePtr->display, pixmap); |
| 1611 |
} |
| 1612 |
|
| 1613 |
} |
| 1614 |
|
| 1615 |
|
| 1616 |
|
| 1617 |
|
| 1618 |
|
| 1619 |
|
| 1620 |
|
| 1621 |
|
| 1622 |
|
| 1623 |
|
| 1624 |
|
| 1625 |
|
| 1626 |
|
| 1627 |
|
| 1628 |
|
| 1629 |
|
| 1630 |
|
| 1631 |
|
| 1632 |
|
| 1633 |
|
| 1634 |
static void |
| 1635 |
FrameEventProc(clientData, eventPtr) |
| 1636 |
ClientData clientData; |
| 1637 |
register XEvent *eventPtr; |
| 1638 |
{ |
| 1639 |
register Frame *framePtr = (Frame *) clientData; |
| 1640 |
|
| 1641 |
if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) { |
| 1642 |
goto redraw; |
| 1643 |
} else if (eventPtr->type == ConfigureNotify) { |
| 1644 |
ComputeFrameGeometry(framePtr); |
| 1645 |
goto redraw; |
| 1646 |
} else if (eventPtr->type == DestroyNotify) { |
| 1647 |
if (framePtr->menuName != NULL) { |
| 1648 |
TkSetWindowMenuBar(framePtr->interp, framePtr->tkwin, |
| 1649 |
framePtr->menuName, NULL); |
| 1650 |
LangFreeArg(framePtr->menuName,TCL_DYNAMIC); |
| 1651 |
framePtr->menuName = NULL; |
| 1652 |
} |
| 1653 |
if (framePtr->tkwin != NULL) { |
| 1654 |
|
| 1655 |
|
| 1656 |
|
| 1657 |
|
| 1658 |
|
| 1659 |
|
| 1660 |
|
| 1661 |
|
| 1662 |
|
| 1663 |
|
| 1664 |
|
| 1665 |
|
| 1666 |
|
| 1667 |
|
| 1668 |
|
| 1669 |
|
| 1670 |
DestroyFramePartly(framePtr); |
| 1671 |
|
| 1672 |
Tk_DeleteEventHandler(framePtr->tkwin, |
| 1673 |
ExposureMask|StructureNotifyMask|FocusChangeMask, |
| 1674 |
FrameEventProc, (ClientData) framePtr); |
| 1675 |
framePtr->tkwin = NULL; |
| 1676 |
Tcl_DeleteCommandFromToken(framePtr->interp, framePtr->widgetCmd); |
| 1677 |
} |
| 1678 |
if (framePtr->flags & REDRAW_PENDING) { |
| 1679 |
Tcl_CancelIdleCall(DisplayFrame, (ClientData) framePtr); |
| 1680 |
} |
| 1681 |
Tcl_CancelIdleCall(MapFrame, (ClientData) framePtr); |
| 1682 |
Tcl_EventuallyFree((ClientData) framePtr, DestroyFrame); |
| 1683 |
} else if (eventPtr->type == FocusIn) { |
| 1684 |
if (eventPtr->xfocus.detail != NotifyInferior) { |
| 1685 |
framePtr->flags |= GOT_FOCUS; |
| 1686 |
if (framePtr->highlightWidth > 0) { |
| 1687 |
goto redraw; |
| 1688 |
} |
| 1689 |
} |
| 1690 |
} else if (eventPtr->type == FocusOut) { |
| 1691 |
if (eventPtr->xfocus.detail != NotifyInferior) { |
| 1692 |
framePtr->flags &= ~GOT_FOCUS; |
| 1693 |
if (framePtr->highlightWidth > 0) { |
| 1694 |
goto redraw; |
| 1695 |
} |
| 1696 |
} |
| 1697 |
} else if (eventPtr->type == ActivateNotify) { |
| 1698 |
TkpSetMainMenubar(framePtr->interp, framePtr->tkwin, |
| 1699 |
Tcl_GetString(framePtr->menuName)); |
| 1700 |
} |
| 1701 |
return; |
| 1702 |
|
| 1703 |
redraw: |
| 1704 |
if ((framePtr->tkwin != NULL) && !(framePtr->flags & REDRAW_PENDING)) { |
| 1705 |
Tcl_DoWhenIdle(DisplayFrame, (ClientData) framePtr); |
| 1706 |
framePtr->flags |= REDRAW_PENDING; |
| 1707 |
} |
| 1708 |
} |
| 1709 |
|
| 1710 |
|
| 1711 |
|
| 1712 |
|
| 1713 |
|
| 1714 |
|
| 1715 |
|
| 1716 |
|
| 1717 |
|
| 1718 |
|
| 1719 |
|
| 1720 |
|
| 1721 |
|
| 1722 |
|
| 1723 |
|
| 1724 |
|
| 1725 |
|
| 1726 |
|
| 1727 |
|
| 1728 |
static void |
| 1729 |
FrameCmdDeletedProc(clientData) |
| 1730 |
ClientData clientData; |
| 1731 |
{ |
| 1732 |
Frame *framePtr = (Frame *) clientData; |
| 1733 |
Tk_Window tkwin = framePtr->tkwin; |
| 1734 |
|
| 1735 |
if (framePtr->menuName != NULL) { |
| 1736 |
TkSetWindowMenuBar(framePtr->interp, framePtr->tkwin, |
| 1737 |
framePtr->menuName, NULL); |
| 1738 |
LangFreeArg(framePtr->menuName,TCL_DYNAMIC); |
| 1739 |
framePtr->menuName = NULL; |
| 1740 |
} |
| 1741 |
|
| 1742 |
|
| 1743 |
|
| 1744 |
|
| 1745 |
|
| 1746 |
|
| 1747 |
|
| 1748 |
|
| 1749 |
if (tkwin != NULL) { |
| 1750 |
|
| 1751 |
|
| 1752 |
|
| 1753 |
|
| 1754 |
|
| 1755 |
DestroyFramePartly(framePtr); |
| 1756 |
|
| 1757 |
framePtr->tkwin = NULL; |
| 1758 |
Tk_DestroyWindow(tkwin); |
| 1759 |
} |
| 1760 |
} |
| 1761 |
|
| 1762 |
|
| 1763 |
|
| 1764 |
|
| 1765 |
|
| 1766 |
|
| 1767 |
|
| 1768 |
|
| 1769 |
|
| 1770 |
|
| 1771 |
|
| 1772 |
|
| 1773 |
|
| 1774 |
|
| 1775 |
|
| 1776 |
|
| 1777 |
|
| 1778 |
|
| 1779 |
static void |
| 1780 |
MapFrame(clientData) |
| 1781 |
ClientData clientData; |
| 1782 |
{ |
| 1783 |
Frame *framePtr = (Frame *) clientData; |
| 1784 |
|
| 1785 |
|
| 1786 |
|
| 1787 |
|
| 1788 |
|
| 1789 |
|
| 1790 |
|
| 1791 |
|
| 1792 |
Tcl_Preserve((ClientData) framePtr); |
| 1793 |
while (1) { |
| 1794 |
if (Tcl_DoOneEvent(TCL_IDLE_EVENTS) == 0) { |
| 1795 |
break; |
| 1796 |
} |
| 1797 |
|
| 1798 |
|
| 1799 |
|
| 1800 |
|
| 1801 |
|
| 1802 |
|
| 1803 |
if (framePtr->tkwin == NULL) { |
| 1804 |
Tcl_Release((ClientData) framePtr); |
| 1805 |
return; |
| 1806 |
} |
| 1807 |
} |
| 1808 |
Tk_MapWindow(framePtr->tkwin); |
| 1809 |
Tcl_Release((ClientData) framePtr); |
| 1810 |
} |
| 1811 |
|
| 1812 |
|
| 1813 |
|
| 1814 |
|
| 1815 |
|
| 1816 |
|
| 1817 |
|
| 1818 |
|
| 1819 |
|
| 1820 |
|
| 1821 |
|
| 1822 |
|
| 1823 |
|
| 1824 |
|
| 1825 |
|
| 1826 |
|
| 1827 |
|
| 1828 |
|
| 1829 |
|
| 1830 |
|
| 1831 |
|
| 1832 |
void |
| 1833 |
TkInstallFrameMenu(tkwin) |
| 1834 |
Tk_Window tkwin; |
| 1835 |
{ |
| 1836 |
TkWindow *winPtr = (TkWindow *) tkwin; |
| 1837 |
|
| 1838 |
if (winPtr->mainPtr != NULL) { |
| 1839 |
Frame *framePtr; |
| 1840 |
framePtr = (Frame*) winPtr->instanceData; |
| 1841 |
if (framePtr == NULL) { |
| 1842 |
panic("TkInstallFrameMenu couldn't get frame pointer"); |
| 1843 |
} |
| 1844 |
TkpMenuNotifyToplevelCreate(winPtr->mainPtr->interp, |
| 1845 |
Tcl_GetString(framePtr->menuName)); |
| 1846 |
} |
| 1847 |
} |
| 1848 |
|
| 1849 |
|
| 1850 |
|
| 1851 |
|
| 1852 |
|
| 1853 |
|
| 1854 |
|
| 1855 |
|
| 1856 |
|
| 1857 |
|
| 1858 |
|
| 1859 |
|
| 1860 |
|
| 1861 |
|
| 1862 |
|
| 1863 |
|
| 1864 |
|
| 1865 |
|
| 1866 |
|
| 1867 |
|
| 1868 |
|
| 1869 |
static void |
| 1870 |
FrameStructureProc(clientData, eventPtr) |
| 1871 |
ClientData clientData; |
| 1872 |
XEvent *eventPtr; |
| 1873 |
{ |
| 1874 |
Labelframe *labelframePtr = (Labelframe *) clientData; |
| 1875 |
|
| 1876 |
if (eventPtr->type == DestroyNotify) { |
| 1877 |
|
| 1878 |
|
| 1879 |
|
| 1880 |
|
| 1881 |
|
| 1882 |
if (labelframePtr->frame.type == TYPE_LABELFRAME) { |
| 1883 |
labelframePtr->labelWin = NULL; |
| 1884 |
FrameWorldChanged((ClientData) labelframePtr); |
| 1885 |
} |
| 1886 |
} |
| 1887 |
} |
| 1888 |
|
| 1889 |
|
| 1890 |
|
| 1891 |
|
| 1892 |
|
| 1893 |
|
| 1894 |
|
| 1895 |
|
| 1896 |
|
| 1897 |
|
| 1898 |
|
| 1899 |
|
| 1900 |
|
| 1901 |
|
| 1902 |
|
| 1903 |
|
| 1904 |
|
| 1905 |
|
| 1906 |
|
| 1907 |
static void |
| 1908 |
FrameRequestProc(clientData, tkwin) |
| 1909 |
ClientData clientData; |
| 1910 |
Tk_Window tkwin; |
| 1911 |
|
| 1912 |
{ |
| 1913 |
Frame *framePtr = (Frame *) clientData; |
| 1914 |
|
| 1915 |
FrameWorldChanged((ClientData) framePtr); |
| 1916 |
} |
| 1917 |
|
| 1918 |
|
| 1919 |
|
| 1920 |
|
| 1921 |
|
| 1922 |
|
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
|
| 1927 |
|
| 1928 |
|
| 1929 |
|
| 1930 |
|
| 1931 |
|
| 1932 |
|
| 1933 |
|
| 1934 |
|
| 1935 |
static void |
| 1936 |
FrameLostSlaveProc(clientData, tkwin) |
| 1937 |
ClientData clientData; |
| 1938 |
|
| 1939 |
Tk_Window tkwin; |
| 1940 |
{ |
| 1941 |
Frame *framePtr = (Frame *) clientData; |
| 1942 |
Labelframe *labelframePtr = (Labelframe *) clientData; |
| 1943 |
|
| 1944 |
|
| 1945 |
|
| 1946 |
|
| 1947 |
|
| 1948 |
|
| 1949 |
if (labelframePtr->frame.type == TYPE_LABELFRAME) { |
| 1950 |
Tk_DeleteEventHandler(labelframePtr->labelWin, StructureNotifyMask, |
| 1951 |
FrameStructureProc, (ClientData) labelframePtr); |
| 1952 |
if (framePtr->tkwin != Tk_Parent(labelframePtr->labelWin)) { |
| 1953 |
Tk_UnmaintainGeometry(labelframePtr->labelWin, framePtr->tkwin); |
| 1954 |
} |
| 1955 |
Tk_UnmapWindow(labelframePtr->labelWin); |
| 1956 |
labelframePtr->labelWin = NULL; |
| 1957 |
} |
| 1958 |
FrameWorldChanged((ClientData) framePtr); |
| 1959 |
} |
| 1960 |
|
| 1961 |
|
| 1962 |
|
| 1963 |
|
| 1964 |
|
| 1965 |
|
| 1966 |
|
| 1967 |
|
| 1968 |
|
| 1969 |
|
| 1970 |
|
| 1971 |
|
| 1972 |
|
| 1973 |
|
| 1974 |
|
| 1975 |
|
| 1976 |
|
| 1977 |
|
| 1978 |
|
| 1979 |
|
| 1980 |
|
| 1981 |
|
| 1982 |
Tk_Window |
| 1983 |
TkToplevelWindowForCommand(interp, cmdName) |
| 1984 |
Tcl_Interp *interp; |
| 1985 |
CONST char *cmdName; |
| 1986 |
{ |
| 1987 |
Tcl_CmdInfo cmdInfo; |
| 1988 |
Frame *framePtr; |
| 1989 |
|
| 1990 |
if (Tcl_GetCommandInfo(interp, cmdName, &cmdInfo) == 0) { |
| 1991 |
return NULL; |
| 1992 |
} |
| 1993 |
if (cmdInfo.objProc != FrameWidgetObjCmd) { |
| 1994 |
return NULL; |
| 1995 |
} |
| 1996 |
framePtr = (Frame *) cmdInfo.objClientData; |
| 1997 |
if (framePtr->type != TYPE_TOPLEVEL) { |
| 1998 |
return NULL; |
| 1999 |
} |
| 2000 |
return framePtr->tkwin; |
| 2001 |
} |
| 2002 |
|