Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libtk/generic/tkImage.c
1810 views
1
/*
2
* tkImage.c --
3
*
4
* This module implements the image protocol, which allows lots
5
* of different kinds of images to be used in lots of different
6
* widgets.
7
*
8
* Copyright (c) 1994 The Regents of the University of California.
9
* Copyright (c) 1994-1996 Sun Microsystems, Inc.
10
*
11
* See the file "license.terms" for information on usage and redistribution
12
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13
*
14
* SCCS: @(#) tkImage.c 1.11 96/03/01 17:19:28
15
*/
16
17
#include "tkInt.h"
18
19
/*
20
* Each call to Tk_GetImage returns a pointer to one of the following
21
* structures, which is used as a token by clients (widgets) that
22
* display images.
23
*/
24
25
typedef struct Image {
26
Tk_Window tkwin; /* Window passed to Tk_GetImage (needed to
27
* "re-get" the image later if the manager
28
* changes). */
29
Display *display; /* Display for tkwin. Needed because when
30
* the image is eventually freed tkwin may
31
* not exist anymore. */
32
struct ImageMaster *masterPtr;
33
/* Master for this image (identifiers image
34
* manager, for example). */
35
ClientData instanceData;
36
/* One word argument to pass to image manager
37
* when dealing with this image instance. */
38
Tk_ImageChangedProc *changeProc;
39
/* Code in widget to call when image changes
40
* in a way that affects redisplay. */
41
ClientData widgetClientData;
42
/* Argument to pass to changeProc. */
43
struct Image *nextPtr; /* Next in list of all image instances
44
* associated with the same name. */
45
46
} Image;
47
48
/*
49
* For each image master there is one of the following structures,
50
* which represents a name in the image table and all of the images
51
* instantiated from it. Entries in mainPtr->imageTable point to
52
* these structures.
53
*/
54
55
typedef struct ImageMaster {
56
Tk_ImageType *typePtr; /* Information about image type. NULL means
57
* that no image manager owns this image: the
58
* image was deleted. */
59
ClientData masterData; /* One-word argument to pass to image mgr
60
* when dealing with the master, as opposed
61
* to instances. */
62
int width, height; /* Last known dimensions for image. */
63
Tcl_HashTable *tablePtr; /* Pointer to hash table containing image
64
* (the imageTable field in some TkMainInfo
65
* structure). */
66
Tcl_HashEntry *hPtr; /* Hash entry in mainPtr->imageTable for
67
* this structure (used to delete the hash
68
* entry). */
69
Image *instancePtr; /* Pointer to first in list of instances
70
* derived from this name. */
71
} ImageMaster;
72
73
/*
74
* The following variable points to the first in a list of all known
75
* image types.
76
*/
77
78
static Tk_ImageType *imageTypeList = NULL;
79
80
/*
81
* Prototypes for local procedures:
82
*/
83
84
static void DeleteImage _ANSI_ARGS_((ImageMaster *masterPtr));
85
86
/*
87
*----------------------------------------------------------------------
88
*
89
* Tk_CreateImageType --
90
*
91
* This procedure is invoked by an image manager to tell Tk about
92
* a new kind of image and the procedures that manage the new type.
93
* The procedure is typically invoked during Tcl_AppInit.
94
*
95
* Results:
96
* None.
97
*
98
* Side effects:
99
* The new image type is entered into a table used in the "image
100
* create" command.
101
*
102
*----------------------------------------------------------------------
103
*/
104
105
void
106
Tk_CreateImageType(typePtr)
107
Tk_ImageType *typePtr; /* Structure describing the type. All of
108
* the fields except "nextPtr" must be filled
109
* in by caller. Must not have been passed
110
* to Tk_CreateImageType previously. */
111
{
112
Tk_ImageType *typePtr2;
113
114
typePtr2 = (Tk_ImageType *) ckalloc(sizeof(Tk_ImageType));
115
*typePtr2 = *typePtr;
116
typePtr2->name = (char *) ckalloc((unsigned) (strlen(typePtr->name) + 1));
117
strcpy(typePtr2->name, typePtr->name);
118
typePtr2->nextPtr = imageTypeList;
119
imageTypeList = typePtr2;
120
}
121
122
/*
123
*----------------------------------------------------------------------
124
*
125
* Tk_ImageCmd --
126
*
127
* This procedure is invoked to process the "image" Tcl command.
128
* See the user documentation for details on what it does.
129
*
130
* Results:
131
* A standard Tcl result.
132
*
133
* Side effects:
134
* See the user documentation.
135
*
136
*----------------------------------------------------------------------
137
*/
138
139
int
140
Tk_ImageCmd(clientData, interp, argc, argv)
141
ClientData clientData; /* Main window associated with interpreter. */
142
Tcl_Interp *interp; /* Current interpreter. */
143
int argc; /* Number of arguments. */
144
char **argv; /* Argument strings. */
145
{
146
TkWindow *winPtr = (TkWindow *) clientData;
147
int c, i, new, firstOption;
148
size_t length;
149
Tk_ImageType *typePtr;
150
ImageMaster *masterPtr;
151
Image *imagePtr;
152
Tcl_HashEntry *hPtr;
153
Tcl_HashSearch search;
154
char idString[30], *name;
155
static int id = 0;
156
157
if (argc < 2) {
158
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
159
" option ?args?\"", (char *) NULL);
160
return TCL_ERROR;
161
}
162
c = argv[1][0];
163
length = strlen(argv[1]);
164
if ((c == 'c') && (strncmp(argv[1], "create", length) == 0)) {
165
if (argc < 3) {
166
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
167
" create type ?name? ?options?\"", (char *) NULL);
168
return TCL_ERROR;
169
}
170
c = argv[2][0];
171
172
/*
173
* Look up the image type.
174
*/
175
176
for (typePtr = imageTypeList; typePtr != NULL;
177
typePtr = typePtr->nextPtr) {
178
if ((c == typePtr->name[0])
179
&& (strcmp(argv[2], typePtr->name) == 0)) {
180
break;
181
}
182
}
183
if (typePtr == NULL) {
184
Tcl_AppendResult(interp, "image type \"", argv[2],
185
"\" doesn't exist", (char *) NULL);
186
return TCL_ERROR;
187
}
188
189
/*
190
* Figure out a name to use for the new image.
191
*/
192
193
if ((argc == 3) || (argv[3][0] == '-')) {
194
id++;
195
sprintf(idString, "image%d", id);
196
name = idString;
197
firstOption = 3;
198
} else {
199
name = argv[3];
200
firstOption = 4;
201
}
202
203
/*
204
* Create the data structure for the new image.
205
*/
206
207
hPtr = Tcl_CreateHashEntry(&winPtr->mainPtr->imageTable, name, &new);
208
if (new) {
209
masterPtr = (ImageMaster *) ckalloc(sizeof(ImageMaster));
210
masterPtr->typePtr = NULL;
211
masterPtr->masterData = NULL;
212
masterPtr->width = masterPtr->height = 1;
213
masterPtr->tablePtr = &winPtr->mainPtr->imageTable;
214
masterPtr->hPtr = hPtr;
215
masterPtr->instancePtr = NULL;
216
Tcl_SetHashValue(hPtr, masterPtr);
217
} else {
218
/*
219
* An image already exists by this name. Disconnect the
220
* instances from the master.
221
*/
222
223
masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
224
if (masterPtr->typePtr != NULL) {
225
for (imagePtr = masterPtr->instancePtr; imagePtr != NULL;
226
imagePtr = imagePtr->nextPtr) {
227
(*masterPtr->typePtr->freeProc)(
228
imagePtr->instanceData, imagePtr->display);
229
(*imagePtr->changeProc)(imagePtr->widgetClientData, 0, 0,
230
masterPtr->width, masterPtr->height, masterPtr->width,
231
masterPtr->height);
232
}
233
(*masterPtr->typePtr->deleteProc)(masterPtr->masterData);
234
masterPtr->typePtr = NULL;
235
}
236
}
237
238
/*
239
* Call the image type manager so that it can perform its own
240
* initialization, then re-"get" for any existing instances of
241
* the image.
242
*/
243
244
if ((*typePtr->createProc)(interp, name, argc-firstOption,
245
argv+firstOption, typePtr, (Tk_ImageMaster) masterPtr,
246
&masterPtr->masterData) != TCL_OK) {
247
DeleteImage(masterPtr);
248
return TCL_ERROR;
249
}
250
masterPtr->typePtr = typePtr;
251
for (imagePtr = masterPtr->instancePtr; imagePtr != NULL;
252
imagePtr = imagePtr->nextPtr) {
253
imagePtr->instanceData = (*typePtr->getProc)(
254
imagePtr->tkwin, masterPtr->masterData);
255
}
256
interp->result = Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr);
257
} else if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0)) {
258
for (i = 2; i < argc; i++) {
259
hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, argv[i]);
260
if (hPtr == NULL) {
261
Tcl_AppendResult(interp, "image \"", argv[i],
262
"\" doesn't exist", (char *) NULL);
263
return TCL_ERROR;
264
}
265
masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
266
DeleteImage(masterPtr);
267
}
268
} else if ((c == 'h') && (strncmp(argv[1], "height", length) == 0)) {
269
if (argc != 3) {
270
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
271
" height name\"", (char *) NULL);
272
return TCL_ERROR;
273
}
274
hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, argv[2]);
275
if (hPtr == NULL) {
276
Tcl_AppendResult(interp, "image \"", argv[2],
277
"\" doesn't exist", (char *) NULL);
278
return TCL_ERROR;
279
}
280
masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
281
sprintf(interp->result, "%d", masterPtr->height);
282
} else if ((c == 'n') && (strncmp(argv[1], "names", length) == 0)) {
283
if (argc != 2) {
284
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
285
" names\"", (char *) NULL);
286
return TCL_ERROR;
287
}
288
for (hPtr = Tcl_FirstHashEntry(&winPtr->mainPtr->imageTable, &search);
289
hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
290
Tcl_AppendElement(interp, Tcl_GetHashKey(
291
&winPtr->mainPtr->imageTable, hPtr));
292
}
293
} else if ((c == 't') && (strcmp(argv[1], "type") == 0)) {
294
if (argc != 3) {
295
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
296
" type name\"", (char *) NULL);
297
return TCL_ERROR;
298
}
299
hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, argv[2]);
300
if (hPtr == NULL) {
301
Tcl_AppendResult(interp, "image \"", argv[2],
302
"\" doesn't exist", (char *) NULL);
303
return TCL_ERROR;
304
}
305
masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
306
if (masterPtr->typePtr != NULL) {
307
interp->result = masterPtr->typePtr->name;
308
}
309
} else if ((c == 't') && (strcmp(argv[1], "types") == 0)) {
310
if (argc != 2) {
311
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
312
" types\"", (char *) NULL);
313
return TCL_ERROR;
314
}
315
for (typePtr = imageTypeList; typePtr != NULL;
316
typePtr = typePtr->nextPtr) {
317
Tcl_AppendElement(interp, typePtr->name);
318
}
319
} else if ((c == 'w') && (strncmp(argv[1], "width", length) == 0)) {
320
if (argc != 3) {
321
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
322
" width name\"", (char *) NULL);
323
return TCL_ERROR;
324
}
325
hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, argv[2]);
326
if (hPtr == NULL) {
327
Tcl_AppendResult(interp, "image \"", argv[2],
328
"\" doesn't exist", (char *) NULL);
329
return TCL_ERROR;
330
}
331
masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
332
sprintf(interp->result, "%d", masterPtr->width);
333
} else {
334
Tcl_AppendResult(interp, "bad option \"", argv[1],
335
"\": must be create, delete, height, names, type, types,",
336
" or width", (char *) NULL);
337
return TCL_ERROR;
338
}
339
return TCL_OK;
340
}
341
342
/*
343
*----------------------------------------------------------------------
344
*
345
* Tk_ImageChanged --
346
*
347
* This procedure is called by an image manager whenever something
348
* has happened that requires the image to be redrawn (some of its
349
* pixels have changed, or its size has changed).
350
*
351
* Results:
352
* None.
353
*
354
* Side effects:
355
* Any widgets that display the image are notified so that they
356
* can redisplay themselves as appropriate.
357
*
358
*----------------------------------------------------------------------
359
*/
360
361
void
362
Tk_ImageChanged(imageMaster, x, y, width, height, imageWidth,
363
imageHeight)
364
Tk_ImageMaster imageMaster; /* Image that needs redisplay. */
365
int x, y; /* Coordinates of upper-left pixel of
366
* region of image that needs to be
367
* redrawn. */
368
int width, height; /* Dimensions (in pixels) of region of
369
* image to redraw. If either dimension
370
* is zero then the image doesn't need to
371
* be redrawn (perhaps all that happened is
372
* that its size changed). */
373
int imageWidth, imageHeight;/* New dimensions of image. */
374
{
375
ImageMaster *masterPtr = (ImageMaster *) imageMaster;
376
Image *imagePtr;
377
378
masterPtr->width = imageWidth;
379
masterPtr->height = imageHeight;
380
for (imagePtr = masterPtr->instancePtr; imagePtr != NULL;
381
imagePtr = imagePtr->nextPtr) {
382
(*imagePtr->changeProc)(imagePtr->widgetClientData, x, y,
383
width, height, imageWidth, imageHeight);
384
}
385
}
386
387
/*
388
*----------------------------------------------------------------------
389
*
390
* Tk_NameOfImage --
391
*
392
* Given a token for an image master, this procedure returns
393
* the name of the image.
394
*
395
* Results:
396
* The return value is the string name for imageMaster.
397
*
398
* Side effects:
399
* None.
400
*
401
*----------------------------------------------------------------------
402
*/
403
404
char *
405
Tk_NameOfImage(imageMaster)
406
Tk_ImageMaster imageMaster; /* Token for image. */
407
{
408
ImageMaster *masterPtr = (ImageMaster *) imageMaster;
409
410
return Tcl_GetHashKey(masterPtr->tablePtr, masterPtr->hPtr);
411
}
412
413
/*
414
*----------------------------------------------------------------------
415
*
416
* Tk_GetImage --
417
*
418
* This procedure is invoked by a widget when it wants to use
419
* a particular image in a particular window.
420
*
421
* Results:
422
* The return value is a token for the image. If there is no image
423
* by the given name, then NULL is returned and an error message is
424
* left in interp->result.
425
*
426
* Side effects:
427
* Tk records the fact that the widget is using the image, and
428
* it will invoke changeProc later if the widget needs redisplay
429
* (i.e. its size changes or some of its pixels change). The
430
* caller must eventually invoke Tk_FreeImage when it no longer
431
* needs the image.
432
*
433
*----------------------------------------------------------------------
434
*/
435
436
Tk_Image
437
Tk_GetImage(interp, tkwin, name, changeProc, clientData)
438
Tcl_Interp *interp; /* Place to leave error message if image
439
* can't be found. */
440
Tk_Window tkwin; /* Token for window in which image will
441
* be used. */
442
char *name; /* Name of desired image. */
443
Tk_ImageChangedProc *changeProc;
444
/* Procedure to invoke when redisplay is
445
* needed because image's pixels or size
446
* changed. */
447
ClientData clientData; /* One-word argument to pass to damageProc. */
448
{
449
Tcl_HashEntry *hPtr;
450
ImageMaster *masterPtr;
451
Image *imagePtr;
452
453
hPtr = Tcl_FindHashEntry(&((TkWindow *) tkwin)->mainPtr->imageTable, name);
454
if (hPtr == NULL) {
455
goto noSuchImage;
456
}
457
masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
458
if (masterPtr->typePtr == NULL) {
459
goto noSuchImage;
460
}
461
imagePtr = (Image *) ckalloc(sizeof(Image));
462
imagePtr->tkwin = tkwin;
463
imagePtr->display = Tk_Display(tkwin);
464
imagePtr->masterPtr = masterPtr;
465
imagePtr->instanceData =
466
(*masterPtr->typePtr->getProc)(tkwin, masterPtr->masterData);
467
imagePtr->changeProc = changeProc;
468
imagePtr->widgetClientData = clientData;
469
imagePtr->nextPtr = masterPtr->instancePtr;
470
masterPtr->instancePtr = imagePtr;
471
return (Tk_Image) imagePtr;
472
473
noSuchImage:
474
Tcl_AppendResult(interp, "image \"", name, "\" doesn't exist",
475
(char *) NULL);
476
return NULL;
477
}
478
479
/*
480
*----------------------------------------------------------------------
481
*
482
* Tk_FreeImage --
483
*
484
* This procedure is invoked by a widget when it no longer needs
485
* an image acquired by a previous call to Tk_GetImage. For each
486
* call to Tk_GetImage there must be exactly one call to Tk_FreeImage.
487
*
488
* Results:
489
* None.
490
*
491
* Side effects:
492
* The association between the image and the widget is removed.
493
*
494
*----------------------------------------------------------------------
495
*/
496
497
void
498
Tk_FreeImage(image)
499
Tk_Image image; /* Token for image that is no longer
500
* needed by a widget. */
501
{
502
Image *imagePtr = (Image *) image;
503
ImageMaster *masterPtr = imagePtr->masterPtr;
504
Image *prevPtr;
505
506
/*
507
* Clean up the particular instance.
508
*/
509
510
if (masterPtr->typePtr != NULL) {
511
(*masterPtr->typePtr->freeProc)(imagePtr->instanceData,
512
imagePtr->display);
513
}
514
prevPtr = masterPtr->instancePtr;
515
if (prevPtr == imagePtr) {
516
masterPtr->instancePtr = imagePtr->nextPtr;
517
} else {
518
while (prevPtr->nextPtr != imagePtr) {
519
prevPtr = prevPtr->nextPtr;
520
}
521
prevPtr->nextPtr = imagePtr->nextPtr;
522
}
523
ckfree((char *) imagePtr);
524
525
/*
526
* If there are no more instances left for the master, and if the
527
* master image has been deleted, then delete the master too.
528
*/
529
530
if ((masterPtr->typePtr == NULL) && (masterPtr->instancePtr == NULL)) {
531
Tcl_DeleteHashEntry(masterPtr->hPtr);
532
ckfree((char *) masterPtr);
533
}
534
}
535
536
/*
537
*----------------------------------------------------------------------
538
*
539
* Tk_RedrawImage --
540
*
541
* This procedure is called by widgets that contain images in order
542
* to redisplay an image on the screen or an off-screen pixmap.
543
*
544
* Results:
545
* None.
546
*
547
* Side effects:
548
* The image's manager is notified, and it redraws the desired
549
* portion of the image before returning.
550
*
551
*----------------------------------------------------------------------
552
*/
553
554
void
555
Tk_RedrawImage(image, imageX, imageY, width, height, drawable,
556
drawableX, drawableY)
557
Tk_Image image; /* Token for image to redisplay. */
558
int imageX, imageY; /* Upper-left pixel of region in image that
559
* needs to be redisplayed. */
560
int width, height; /* Dimensions of region to redraw. */
561
Drawable drawable; /* Drawable in which to display image
562
* (window or pixmap). If this is a pixmap,
563
* it must have the same depth as the window
564
* used in the Tk_GetImage call for the
565
* image. */
566
int drawableX, drawableY; /* Coordinates in drawable that correspond
567
* to imageX and imageY. */
568
{
569
Image *imagePtr = (Image *) image;
570
571
if (imagePtr->masterPtr->typePtr == NULL) {
572
/*
573
* No master for image, so nothing to display.
574
*/
575
576
return;
577
}
578
579
/*
580
* Clip the redraw area to the area of the image.
581
*/
582
583
if (imageX < 0) {
584
width += imageX;
585
drawableX -= imageX;
586
imageX = 0;
587
}
588
if (imageY < 0) {
589
height += imageY;
590
drawableY -= imageY;
591
imageY = 0;
592
}
593
if ((imageX + width) > imagePtr->masterPtr->width) {
594
width = imagePtr->masterPtr->width - imageX;
595
}
596
if ((imageY + height) > imagePtr->masterPtr->height) {
597
height = imagePtr->masterPtr->height - imageY;
598
}
599
(*imagePtr->masterPtr->typePtr->displayProc)(
600
imagePtr->instanceData, imagePtr->display, drawable,
601
imageX, imageY, width, height, drawableX, drawableY);
602
}
603
604
/*
605
*----------------------------------------------------------------------
606
*
607
* Tk_SizeOfImage --
608
*
609
* This procedure returns the current dimensions of an image.
610
*
611
* Results:
612
* The width and height of the image are returned in *widthPtr
613
* and *heightPtr.
614
*
615
* Side effects:
616
* None.
617
*
618
*----------------------------------------------------------------------
619
*/
620
621
void
622
Tk_SizeOfImage(image, widthPtr, heightPtr)
623
Tk_Image image; /* Token for image whose size is wanted. */
624
int *widthPtr; /* Return width of image here. */
625
int *heightPtr; /* Return height of image here. */
626
{
627
Image *imagePtr = (Image *) image;
628
629
*widthPtr = imagePtr->masterPtr->width;
630
*heightPtr = imagePtr->masterPtr->height;
631
}
632
633
/*
634
*----------------------------------------------------------------------
635
*
636
* Tk_DeleteImage --
637
*
638
* Given the name of an image, this procedure destroys the
639
* image.
640
*
641
* Results:
642
* None.
643
*
644
* Side effects:
645
* The image is destroyed; existing instances will display as
646
* blank areas. If no such image exists then the procedure does
647
* nothing.
648
*
649
*----------------------------------------------------------------------
650
*/
651
652
void
653
Tk_DeleteImage(interp, name)
654
Tcl_Interp *interp; /* Interpreter in which the image was
655
* created. */
656
char *name; /* Name of image. */
657
{
658
Tcl_HashEntry *hPtr;
659
Tcl_CmdInfo info;
660
TkWindow *winPtr;
661
662
if (Tcl_GetCommandInfo(interp, "winfo", &info) == 0) {
663
return;
664
}
665
winPtr = (TkWindow *) info.clientData;
666
hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, name);
667
if (hPtr == NULL) {
668
return;
669
}
670
DeleteImage((ImageMaster *) Tcl_GetHashValue(hPtr));
671
}
672
673
/*
674
*----------------------------------------------------------------------
675
*
676
* DeleteImage --
677
*
678
* This procedure is responsible for deleting an image.
679
*
680
* Results:
681
* None.
682
*
683
* Side effects:
684
* The connection is dropped between instances of this image and
685
* an image master. Image instances will redisplay themselves
686
* as empty areas, but existing instances will not be deleted.
687
*
688
*----------------------------------------------------------------------
689
*/
690
691
static void
692
DeleteImage(masterPtr)
693
ImageMaster *masterPtr; /* Pointer to main data structure for image. */
694
{
695
Image *imagePtr;
696
Tk_ImageType *typePtr;
697
698
typePtr = masterPtr->typePtr;
699
masterPtr->typePtr = NULL;
700
if (typePtr != NULL) {
701
for (imagePtr = masterPtr->instancePtr; imagePtr != NULL;
702
imagePtr = imagePtr->nextPtr) {
703
(*typePtr->freeProc)(imagePtr->instanceData,
704
imagePtr->display);
705
(*imagePtr->changeProc)(imagePtr->widgetClientData, 0, 0,
706
masterPtr->width, masterPtr->height, masterPtr->width,
707
masterPtr->height);
708
}
709
(*typePtr->deleteProc)(masterPtr->masterData);
710
}
711
if (masterPtr->instancePtr == NULL) {
712
Tcl_DeleteHashEntry(masterPtr->hPtr);
713
ckfree((char *) masterPtr);
714
}
715
}
716
717
/*
718
*----------------------------------------------------------------------
719
*
720
* TkDeleteAllImages --
721
*
722
* This procedure is called when an application is deleted. It
723
* calls back all of the managers for all images so that they
724
* can cleanup, then it deletes all of Tk's internal information
725
* about images.
726
*
727
* Results:
728
* None.
729
*
730
* Side effects:
731
* All information for all images gets deleted.
732
*
733
*----------------------------------------------------------------------
734
*/
735
736
void
737
TkDeleteAllImages(mainPtr)
738
TkMainInfo *mainPtr; /* Structure describing application that is
739
* going away. */
740
{
741
Tcl_HashSearch search;
742
Tcl_HashEntry *hPtr;
743
ImageMaster *masterPtr;
744
745
for (hPtr = Tcl_FirstHashEntry(&mainPtr->imageTable, &search);
746
hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
747
masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
748
DeleteImage(masterPtr);
749
}
750
Tcl_DeleteHashTable(&mainPtr->imageTable);
751
}
752
753