Tk Source Code

Check-in [b653185b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Initial implementation of listbox enhancement.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | poormans-tablelistbox
Files: files | file ages | folders
SHA3-256: b653185bb0a6201c44426e76e9ec328f3b16f6a68cebd0377a27965b0246d857
User & Date: griffin 2020-05-26 01:40:49
Context
2020-05-26
01:40
Initial implementation of listbox enhancement. Leaf check-in: b653185b user: griffin tags: poormans-tablelistbox
00:59
Create new branch named "poormans-tablelistbox" check-in: a3c035ea user: griffin tags: poormans-tablelistbox
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkListbox.c.

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53




54
55
56
57
58
59
60
} ListboxOptionTables;

/*
 * A data structure of the following type is kept for each listbox widget
 * managed by this file:
 */

typedef struct {
    Tk_Window tkwin;		/* Window that embodies the listbox. NULL
				 * means that the window has been destroyed
				 * but the data structures haven't yet been
				 * cleaned up. */
    Display *display;		/* Display containing widget. Used, among
				 * other things, so that resources can be
				 * freed even after tkwin has gone away. */
    Tcl_Interp *interp;		/* Interpreter associated with listbox. */
    Tcl_Command widgetCmd;	/* Token for listbox's widget command. */
    Tk_OptionTable optionTable;	/* Table that defines configuration options
				 * available for this widget. */
    Tk_OptionTable itemAttrOptionTable;
				/* Table that defines configuration options
				 * available for listbox items. */
    char *listVarName;		/* List variable name */
    Tcl_Obj *listObj;		/* Pointer to the list object being used */
    int nElements;		/* Holds the current count of elements */




    Tcl_HashTable *selection;	/* Tracks selection */
    Tcl_HashTable *itemAttrTable;
				/* Tracks item attributes */

    /*
     * Information used when displaying widget:
     */







|

















>
>
>
>







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
} ListboxOptionTables;

/*
 * A data structure of the following type is kept for each listbox widget
 * managed by this file:
 */

typedef struct Listbox {
    Tk_Window tkwin;		/* Window that embodies the listbox. NULL
				 * means that the window has been destroyed
				 * but the data structures haven't yet been
				 * cleaned up. */
    Display *display;		/* Display containing widget. Used, among
				 * other things, so that resources can be
				 * freed even after tkwin has gone away. */
    Tcl_Interp *interp;		/* Interpreter associated with listbox. */
    Tcl_Command widgetCmd;	/* Token for listbox's widget command. */
    Tk_OptionTable optionTable;	/* Table that defines configuration options
				 * available for this widget. */
    Tk_OptionTable itemAttrOptionTable;
				/* Table that defines configuration options
				 * available for listbox items. */
    char *listVarName;		/* List variable name */
    Tcl_Obj *listObj;		/* Pointer to the list object being used */
    int nElements;		/* Holds the current count of elements */
    int column;                 /* >=0 display column number, <0 all columns */
    Tk_Window masterwin;        /* Controlling master listbox widget */
    struct Listbox *masterListbox; /* Master listbox handle */
    Tcl_HashTable *dependentsTable; /* Dependent listbox widgets */
    Tcl_HashTable *selection;	/* Tracks selection */
    Tcl_HashTable *itemAttrTable;
				/* Tracks item attributes */

    /*
     * Information used when displaying widget:
     */
206
207
208
209
210
211
212






213
214
215
216
217
218
219
#define REDRAW_PENDING		1
#define UPDATE_V_SCROLLBAR	2
#define UPDATE_H_SCROLLBAR	4
#define GOT_FOCUS		8
#define MAXWIDTH_IS_STALE	16
#define LISTBOX_DELETED		32







/*
 * The following enum is used to define a type for the -state option of the
 * Listbox widget. These values are used as indices into the string table
 * below.
 */

enum state {







>
>
>
>
>
>







210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#define REDRAW_PENDING		1
#define UPDATE_V_SCROLLBAR	2
#define UPDATE_H_SCROLLBAR	4
#define GOT_FOCUS		8
#define MAXWIDTH_IS_STALE	16
#define LISTBOX_DELETED		32


/*
 * Access (any) other Listbox widget instance data
 */
#define LISTBOX_CLIENTDATA(otherListboxTkwin) ((otherListboxTkwin) ? (((struct TkWindow *) (otherListboxTkwin))->instanceData) : NULL)

/*
 * The following enum is used to define a type for the -state option of the
 * Listbox widget. These values are used as indices into the string table
 * below.
 */

enum state {
247
248
249
250
251
252
253


254
255
256
257
258
259
260
    {TK_OPTION_SYNONYM, "-bd", NULL, NULL,
	 NULL, 0, -1, 0, "-borderwidth", 0},
    {TK_OPTION_SYNONYM, "-bg", NULL, NULL,
	 NULL, 0, -1, 0, "-background", 0},
    {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
	 DEF_LISTBOX_BORDER_WIDTH, -1, Tk_Offset(Listbox, borderWidth),
	 0, 0, 0},


    {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
	 DEF_LISTBOX_CURSOR, -1, Tk_Offset(Listbox, cursor),
	 TK_OPTION_NULL_OK, 0, 0},
    {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
	 "DisabledForeground", DEF_LISTBOX_DISABLED_FG, -1,
	 Tk_Offset(Listbox, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
    {TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",







>
>







257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
    {TK_OPTION_SYNONYM, "-bd", NULL, NULL,
	 NULL, 0, -1, 0, "-borderwidth", 0},
    {TK_OPTION_SYNONYM, "-bg", NULL, NULL,
	 NULL, 0, -1, 0, "-background", 0},
    {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
	 DEF_LISTBOX_BORDER_WIDTH, -1, Tk_Offset(Listbox, borderWidth),
	 0, 0, 0},
    {TK_OPTION_INT, "-column", "column", "Column",
	 DEF_LISTBOX_COLUMN, -1, Tk_Offset(Listbox, column), 0, 0, 0},
    {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
	 DEF_LISTBOX_CURSOR, -1, Tk_Offset(Listbox, cursor),
	 TK_OPTION_NULL_OK, 0, 0},
    {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
	 "DisabledForeground", DEF_LISTBOX_DISABLED_FG, -1,
	 Tk_Offset(Listbox, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
    {TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
275
276
277
278
279
280
281



282
283
284
285
286
287
288
	 DEF_LISTBOX_HIGHLIGHT, -1, Tk_Offset(Listbox, highlightColorPtr),
	 0, 0, 0},
    {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
	 "HighlightThickness", DEF_LISTBOX_HIGHLIGHT_WIDTH, -1,
	 Tk_Offset(Listbox, highlightWidth), 0, 0, 0},
    {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
	DEF_LISTBOX_JUSTIFY, -1, Tk_Offset(Listbox, justify), 0, 0, 0},



    {TK_OPTION_RELIEF, "-relief", "relief", "Relief",
	 DEF_LISTBOX_RELIEF, -1, Tk_Offset(Listbox, relief), 0, 0, 0},
    {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
	 DEF_LISTBOX_SELECT_COLOR, -1, Tk_Offset(Listbox, selBorder),
	 0, DEF_LISTBOX_SELECT_MONO, 0},
    {TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth",
	 "BorderWidth", DEF_LISTBOX_SELECT_BD, -1,







>
>
>







287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
	 DEF_LISTBOX_HIGHLIGHT, -1, Tk_Offset(Listbox, highlightColorPtr),
	 0, 0, 0},
    {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
	 "HighlightThickness", DEF_LISTBOX_HIGHLIGHT_WIDTH, -1,
	 Tk_Offset(Listbox, highlightWidth), 0, 0, 0},
    {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
	DEF_LISTBOX_JUSTIFY, -1, Tk_Offset(Listbox, justify), 0, 0, 0},
    {TK_OPTION_WINDOW, "-master", NULL, NULL,
	 DEF_LISTBOX_MASTER, -1, Tk_Offset(Listbox, masterwin),
	 TK_OPTION_NULL_OK, 0, 0},
    {TK_OPTION_RELIEF, "-relief", "relief", "Relief",
	 DEF_LISTBOX_RELIEF, -1, Tk_Offset(Listbox, relief), 0, 0, 0},
    {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
	 DEF_LISTBOX_SELECT_COLOR, -1, Tk_Offset(Listbox, selBorder),
	 0, DEF_LISTBOX_SELECT_MONO, 0},
    {TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth",
	 "BorderWidth", DEF_LISTBOX_SELECT_BD, -1,
548
549
550
551
552
553
554



555
556
557
558
559
560
561
    listPtr->fullLines		 = 1;
    listPtr->xScrollUnit	 = 1;
    listPtr->exportSelection	 = 1;
    listPtr->cursor		 = NULL;
    listPtr->state		 = STATE_NORMAL;
    listPtr->gray		 = None;
    listPtr->justify             = TK_JUSTIFY_LEFT;




    /*
     * Keep a hold of the associated tkwin until we destroy the listbox,
     * otherwise Tk might free it while we still need it.
     */

    Tcl_Preserve(listPtr->tkwin);







>
>
>







563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
    listPtr->fullLines		 = 1;
    listPtr->xScrollUnit	 = 1;
    listPtr->exportSelection	 = 1;
    listPtr->cursor		 = NULL;
    listPtr->state		 = STATE_NORMAL;
    listPtr->gray		 = None;
    listPtr->justify             = TK_JUSTIFY_LEFT;
    listPtr->masterwin           = NULL;
    listPtr->masterListbox       = NULL;
    listPtr->dependentsTable     = NULL;

    /*
     * Keep a hold of the associated tkwin until we destroy the listbox,
     * otherwise Tk might free it while we still need it.
     */

    Tcl_Preserve(listPtr->tkwin);
1191
1192
1193
1194
1195
1196
1197




1198
1199
1200
1201
1202
1203
1204
     */

    if ((listPtr->state == STATE_DISABLED)
	    && (selCmdIndex != SELECTION_INCLUDES)) {
	return TCL_OK;
    }





    switch (selCmdIndex) {
    case SELECTION_ANCHOR:
	if (objc != 4) {
	    Tcl_WrongNumArgs(interp, 3, objv, "index");
	    return TCL_ERROR;
	}
	if (first >= listPtr->nElements) {







>
>
>
>







1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
     */

    if ((listPtr->state == STATE_DISABLED)
	    && (selCmdIndex != SELECTION_INCLUDES)) {
	return TCL_OK;
    }

    if (listPtr->masterListbox) {
	return ListboxSelectionSubCmd(interp, listPtr->masterListbox, objc, objv);
    }
    
    switch (selCmdIndex) {
    case SELECTION_ANCHOR:
	if (objc != 4) {
	    Tcl_WrongNumArgs(interp, 3, objv, "index");
	    return TCL_ERROR;
	}
	if (first >= listPtr->nElements) {
1371
1372
1373
1374
1375
1376
1377



1378

1379
1380
1381
1382
1383
1384
1385
	case TK_SCROLL_UNITS:
	    index = listPtr->topIndex + count;
	    break;
	case TK_SCROLL_ERROR:
	default:
	    return TCL_ERROR;
	}



	ChangeListboxView(listPtr, index);

    }
    return TCL_OK;
}

/*
 *----------------------------------------------------------------------
 *







>
>
>
|
>







1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
	case TK_SCROLL_UNITS:
	    index = listPtr->topIndex + count;
	    break;
	case TK_SCROLL_ERROR:
	default:
	    return TCL_ERROR;
	}
	if (listPtr->masterListbox) {
	    ChangeListboxView(listPtr->masterListbox, index);
	} else {
	    ChangeListboxView(listPtr, index);
	}
    }
    return TCL_OK;
}

/*
 *----------------------------------------------------------------------
 *
1446
1447
1448
1449
1450
1451
1452























1453
1454
1455
1456
1457
1458
1459
DestroyListbox(
    void *memPtr)		/* Info about listbox widget. */
{
    register Listbox *listPtr = memPtr;
    Tcl_HashEntry *entry;
    Tcl_HashSearch search;
























    /*
     * If we have an internal list object, free it.
     */

    if (listPtr->listObj != NULL) {
	Tcl_DecrRefCount(listPtr->listObj);
	listPtr->listObj = NULL;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
DestroyListbox(
    void *memPtr)		/* Info about listbox widget. */
{
    register Listbox *listPtr = memPtr;
    Tcl_HashEntry *entry;
    Tcl_HashSearch search;

    /*
     * Unlink master and dependent
     */
    if (listPtr->dependentsTable) {
	Tcl_HashEntry *hPtr;
	Tcl_HashSearch search;
	Listbox *otherListbox;
	
	hPtr = Tcl_FirstHashEntry(listPtr->dependentsTable, &search);
	while (hPtr) {
	    otherListbox = (Listbox*) Tcl_GetHashValue(hPtr);
	    otherListbox->masterwin = NULL;
	    otherListbox->masterListbox = NULL;
	    hPtr = Tcl_NextHashEntry(&search);
	}
	Tcl_DeleteHashTable(listPtr->dependentsTable);
    } else if (listPtr->masterListbox && listPtr->masterListbox->dependentsTable) {
	Tcl_HashEntry *hPtr = Tcl_FindHashEntry(listPtr->masterListbox->dependentsTable, (char*) listPtr->tkwin);
	if (hPtr) Tcl_DeleteHashEntry(hPtr);
	listPtr->masterListbox = NULL;
	listPtr->masterwin = NULL;
    }
	
    /*
     * If we have an internal list object, free it.
     */

    if (listPtr->listObj != NULL) {
	Tcl_DecrRefCount(listPtr->listObj);
	listPtr->listObj = NULL;
1667
1668
1669
1670
1671
1672
1673






























1674
1675
1676
1677
1678
1679
1680
	} else if (listPtr->listObj == NULL) {
	    listPtr->listObj = Tcl_NewObj();
	}
	Tcl_IncrRefCount(listPtr->listObj);
	if (oldListObj != NULL) {
	    Tcl_DecrRefCount(oldListObj);
	}






























	break;
    }
    if (!error) {
	Tk_FreeSavedOptions(&savedOptions);
    }

    /*







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
	} else if (listPtr->listObj == NULL) {
	    listPtr->listObj = Tcl_NewObj();
	}
	Tcl_IncrRefCount(listPtr->listObj);
	if (oldListObj != NULL) {
	    Tcl_DecrRefCount(oldListObj);
	}

	/* (re)Register this listbox with Master listbox widget */
	if (listPtr->masterwin) {
	    Listbox *otherListboxPtr = LISTBOX_CLIENTDATA(listPtr->masterwin);
	    Tcl_HashEntry *hPtr;
	    if (listPtr->masterListbox && listPtr->masterListbox != otherListboxPtr) {
		// Clean up old reference
		hPtr = Tcl_FindHashEntry(listPtr->masterListbox->dependentsTable, (char*) listPtr->tkwin);
		if (hPtr) Tcl_DeleteHashEntry(hPtr);
	    }
	    if (otherListboxPtr) {
		int isNew;
		if (otherListboxPtr->dependentsTable == NULL) {
		    otherListboxPtr->dependentsTable = ckalloc(sizeof(Tcl_HashTable));
		    Tcl_InitHashTable(otherListboxPtr->dependentsTable, TCL_ONE_WORD_KEYS);
		}
		hPtr = Tcl_CreateHashEntry(otherListboxPtr->dependentsTable, (char*) listPtr->tkwin, &isNew);
		Listbox *priorPtr = Tcl_GetHashValue(hPtr);
		if (isNew || priorPtr != listPtr) {
		    Tcl_SetHashValue(hPtr, listPtr);
		    // Trigger update?
		}
	    }
	    listPtr->masterListbox = otherListboxPtr;
	} else if (listPtr->masterListbox) {
	    Tcl_HashEntry *hPtr;
	    // Clean up old reference
	    hPtr = Tcl_FindHashEntry(listPtr->masterListbox->dependentsTable, (char*) listPtr->tkwin);
	    if (hPtr) Tcl_DeleteHashEntry(hPtr);
	}
	break;
    }
    if (!error) {
	Tk_FreeSavedOptions(&savedOptions);
    }

    /*
2070
2071
2072
2073
2074
2075
2076











2077
2078
2079
2080
2081
2082
2083
2084
	}

	/*
	 * Draw the actual text of this item.
	 */

        Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement);











        stringRep = Tcl_GetStringFromObj(curElement, &stringLen);
        textWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen);

	Tk_GetFontMetrics(listPtr->tkfont, &fm);
	y += fm.ascent + listPtr->selBorderWidth;

        if (listPtr->justify == TK_JUSTIFY_LEFT) {
            x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset;







>
>
>
>
>
>
>
>
>
>
>
|







2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
	}

	/*
	 * Draw the actual text of this item.
	 */

        Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement);
	if (curElement && listPtr->column >= 0) {
	    Tcl_Obj *colObj = NULL;
	    int result = Tcl_ListObjIndex(listPtr->interp, curElement,
					  listPtr->column, &colObj);
	    if (result == TCL_OK) {
		curElement = colObj;
	    } else {
		printf("result=%d colObj=%p interp=%s\n",result,colObj,Tcl_GetStringResult(listPtr->interp));
	    }
	}
	stringLen = 0;
        stringRep = curElement ? Tcl_GetStringFromObj(curElement, &stringLen) :"";
        textWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen);

	Tk_GetFontMetrics(listPtr->tkfont, &fm);
	y += fm.ascent + listPtr->selBorderWidth;

        if (listPtr->justify == TK_JUSTIFY_LEFT) {
            x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset;
2252
2253
2254
2255
2256
2257
2258









2259
2260
2261
2262
2263
2264
2265
	     * Compute the pixel width of the current element.
	     */

	    result = Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i,
		    &element);
	    if (result != TCL_OK) {
		continue;









	    }
	    text = Tcl_GetStringFromObj(element, &textLength);
	    Tk_GetFontMetrics(listPtr->tkfont, &fm);
	    pixelWidth = Tk_TextWidth(listPtr->tkfont, text, textLength);
	    if (pixelWidth > listPtr->maxWidth) {
		listPtr->maxWidth = pixelWidth;
	    }







>
>
>
>
>
>
>
>
>







2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
	     * Compute the pixel width of the current element.
	     */

	    result = Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i,
		    &element);
	    if (result != TCL_OK) {
		continue;
	    }
	    if (listPtr->column >= 0) {
		Tcl_Obj *colObj = NULL;
		int result = Tcl_ListObjIndex(listPtr->interp, element,
					      listPtr->column, &colObj);
		if (result != TCL_OK || colObj == NULL) {
		    continue;
		}
		element = colObj;
	    }
	    text = Tcl_GetStringFromObj(element, &textLength);
	    Tk_GetFontMetrics(listPtr->tkfont, &fm);
	    pixelWidth = Tk_TextWidth(listPtr->tkfont, text, textLength);
	    if (pixelWidth > listPtr->maxWidth) {
		listPtr->maxWidth = pixelWidth;
	    }
3072
3073
3074
3075
3076
3077
3078





3079
3080
3081
3082
3083
3084
3085
3086













3087
3088
3089
3090
3091
3092
3093
		if (firstRedisplay < 0) {
		    firstRedisplay = i;
		}
	    }
	}
    }






    if (firstRedisplay >= 0) {
	EventuallyRedrawRange(listPtr, first, last);
    }
    if ((oldCount == 0) && (listPtr->numSelected > 0)
	    && (listPtr->exportSelection)
	    && (!Tcl_IsSafe(listPtr->interp))) {
	Tk_OwnSelection(listPtr->tkwin, XA_PRIMARY,
		ListboxLostSelection, listPtr);













    }
    return TCL_OK;
}

/*
 *----------------------------------------------------------------------
 *







>
>
>
>
>
|
|
|
|


|
|
>
>
>
>
>
>
>
>
>
>
>
>
>







3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
		if (firstRedisplay < 0) {
		    firstRedisplay = i;
		}
	    }
	}
    }

    /* 
     * If we are the master, propagate the update to all the 
     * dependent widgets.  If not, let the master do it.
     */
    if (listPtr->masterwin == NULL) {
	if (firstRedisplay >= 0) {
	    EventuallyRedrawRange(listPtr, first, last);
	}
	if ((oldCount == 0) && (listPtr->numSelected > 0)
	    && (listPtr->exportSelection)
	    && (!Tcl_IsSafe(listPtr->interp))) {
	    Tk_OwnSelection(listPtr->tkwin, XA_PRIMARY,
			    ListboxLostSelection, listPtr);
	}
	if (listPtr->dependentsTable) {
	    Tcl_HashEntry *hPtr;
	    Tcl_HashSearch search;
	    Listbox *otherListbox;
	
	    hPtr = Tcl_FirstHashEntry(listPtr->dependentsTable, &search);
	    while (hPtr) {
		otherListbox = (Listbox*) Tcl_GetHashValue(hPtr);
		ListboxSelect(otherListbox, first, last, select);
		hPtr = Tcl_NextHashEntry(&search);
	    }
	}
    }
    return TCL_OK;
}

/*
 *----------------------------------------------------------------------
 *
3263
3264
3265
3266
3267
3268
3269



























3270
3271
3272
3273
3274
3275
3276
    if ((listPtr->flags & REDRAW_PENDING)
	    || (listPtr->flags & LISTBOX_DELETED)
	    || !Tk_IsMapped(listPtr->tkwin)) {
	return;
    }
    listPtr->flags |= REDRAW_PENDING;
    Tcl_DoWhenIdle(DisplayListbox, listPtr);



























}

/*
 *----------------------------------------------------------------------
 *
 * ListboxUpdateVScrollbar --
 *







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
    if ((listPtr->flags & REDRAW_PENDING)
	    || (listPtr->flags & LISTBOX_DELETED)
	    || !Tk_IsMapped(listPtr->tkwin)) {
	return;
    }
    listPtr->flags |= REDRAW_PENDING;
    Tcl_DoWhenIdle(DisplayListbox, listPtr);

    /* The master commands all dependents to Display also */
    if (listPtr->dependentsTable) {
	Tcl_HashEntry *hPtr;
	Tcl_HashSearch search;
	Listbox *otherListbox;
	
	hPtr = Tcl_FirstHashEntry(listPtr->dependentsTable, &search);
	while (hPtr) {
	    otherListbox = (Listbox*) Tcl_GetHashValue(hPtr);
	    //if (otherListbox->listobj)
	    // something doen with listobj and listvarname
	    otherListbox->nElements = listPtr->nElements;
	    otherListbox->topIndex = listPtr->topIndex;
	    otherListbox->active = listPtr->active;
	    otherListbox->numSelected = listPtr->numSelected;
	    otherListbox->selectAnchor = listPtr->selectAnchor;
	    otherListbox->flags = listPtr->flags;
	    otherListbox->fullLines = listPtr->fullLines;
	    otherListbox->partialLine = listPtr->partialLine;

	    /* Schedule redraw of other listbox */
	    Tcl_DoWhenIdle(DisplayListbox, otherListbox);
	    
	    hPtr = Tcl_NextHashEntry(&search);
	}
    }
}

/*
 *----------------------------------------------------------------------
 *
 * ListboxUpdateVScrollbar --
 *
3295
3296
3297
3298
3299
3300
3301
3302

3303
3304
3305
3306
3307
3308
3309
{
    char firstStr[TCL_DOUBLE_SPACE], lastStr[TCL_DOUBLE_SPACE];
    double first, last;
    int result;
    Tcl_Interp *interp;
    Tcl_DString buf;

    if (listPtr->yScrollCmd == NULL) {

	return;
    }
    if (listPtr->nElements == 0) {
	first = 0.0;
	last = 1.0;
    } else {
	first = listPtr->topIndex / (double) listPtr->nElements;







|
>







3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
{
    char firstStr[TCL_DOUBLE_SPACE], lastStr[TCL_DOUBLE_SPACE];
    double first, last;
    int result;
    Tcl_Interp *interp;
    Tcl_DString buf;

    if (listPtr->yScrollCmd == NULL ||
	listPtr->masterwin) { // let master do this
	return;
    }
    if (listPtr->nElements == 0) {
	first = 0.0;
	last = 1.0;
    } else {
	first = listPtr->topIndex / (double) listPtr->nElements;

Changes to macosx/tkMacOSXDefault.h.

246
247
248
249
250
251
252

253
254
255
256
257
258
259
260
261
262

263
264
265
266
267
268
269
 * Defaults for listboxes:
 */

#define DEF_LISTBOX_ACTIVE_STYLE	"dotbox"
#define DEF_LISTBOX_BG_COLOR		TEXT_BG
#define DEF_LISTBOX_BG_MONO		WHITE
#define DEF_LISTBOX_BORDER_WIDTH	"1"

#define DEF_LISTBOX_CURSOR		""
#define DEF_LISTBOX_DISABLED_FG		DISABLED
#define DEF_LISTBOX_EXPORT_SELECTION	"1"
#define DEF_LISTBOX_FONT		"TkTextFont"
#define DEF_LISTBOX_FG			NORMAL_FG
#define DEF_LISTBOX_HEIGHT		"10"
#define DEF_LISTBOX_HIGHLIGHT_BG	NORMAL_BG
#define DEF_LISTBOX_HIGHLIGHT		BLACK
#define DEF_LISTBOX_HIGHLIGHT_WIDTH	"0"
#define DEF_LISTBOX_JUSTIFY		"left"

#define DEF_LISTBOX_RELIEF		"solid"
#define DEF_LISTBOX_SCROLL_COMMAND	""
#define DEF_LISTBOX_LIST_VARIABLE	""
#define DEF_LISTBOX_SELECT_COLOR	SELECT_BG
#define DEF_LISTBOX_SELECT_MONO		BLACK
#define DEF_LISTBOX_SELECT_BD		"0"
#define DEF_LISTBOX_SELECT_FG_COLOR	SELECT_FG







>










>







246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
 * Defaults for listboxes:
 */

#define DEF_LISTBOX_ACTIVE_STYLE	"dotbox"
#define DEF_LISTBOX_BG_COLOR		TEXT_BG
#define DEF_LISTBOX_BG_MONO		WHITE
#define DEF_LISTBOX_BORDER_WIDTH	"1"
#define DEF_LISTBOX_COLUMN              "-1"
#define DEF_LISTBOX_CURSOR		""
#define DEF_LISTBOX_DISABLED_FG		DISABLED
#define DEF_LISTBOX_EXPORT_SELECTION	"1"
#define DEF_LISTBOX_FONT		"TkTextFont"
#define DEF_LISTBOX_FG			NORMAL_FG
#define DEF_LISTBOX_HEIGHT		"10"
#define DEF_LISTBOX_HIGHLIGHT_BG	NORMAL_BG
#define DEF_LISTBOX_HIGHLIGHT		BLACK
#define DEF_LISTBOX_HIGHLIGHT_WIDTH	"0"
#define DEF_LISTBOX_JUSTIFY		"left"
#define DEF_LISTBOX_MASTER              ((char*) NULL)
#define DEF_LISTBOX_RELIEF		"solid"
#define DEF_LISTBOX_SCROLL_COMMAND	""
#define DEF_LISTBOX_LIST_VARIABLE	""
#define DEF_LISTBOX_SELECT_COLOR	SELECT_BG
#define DEF_LISTBOX_SELECT_MONO		BLACK
#define DEF_LISTBOX_SELECT_BD		"0"
#define DEF_LISTBOX_SELECT_FG_COLOR	SELECT_FG

Changes to unix/tkUnixDefault.h.

207
208
209
210
211
212
213

214
215
216
217
218
219
220
221
222
223

224
225
226
227
228
229
230
 * Defaults for listboxes:
 */

#define DEF_LISTBOX_ACTIVE_STYLE	"dotbox"
#define DEF_LISTBOX_BG_COLOR		WHITE
#define DEF_LISTBOX_BG_MONO		WHITE
#define DEF_LISTBOX_BORDER_WIDTH	"1"

#define DEF_LISTBOX_CURSOR		""
#define DEF_LISTBOX_DISABLED_FG		DISABLED
#define DEF_LISTBOX_EXPORT_SELECTION	"1"
#define DEF_LISTBOX_FONT		"TkDefaultFont"
#define DEF_LISTBOX_FG			BLACK
#define DEF_LISTBOX_HEIGHT		"10"
#define DEF_LISTBOX_HIGHLIGHT_BG	NORMAL_BG
#define DEF_LISTBOX_HIGHLIGHT		BLACK
#define DEF_LISTBOX_HIGHLIGHT_WIDTH	"1"
#define DEF_LISTBOX_JUSTIFY		"left"

#define DEF_LISTBOX_RELIEF		"sunken"
#define DEF_LISTBOX_SCROLL_COMMAND	""
#define DEF_LISTBOX_LIST_VARIABLE	""
#define DEF_LISTBOX_SELECT_COLOR	SELECT_BG
#define DEF_LISTBOX_SELECT_MONO		BLACK
#define DEF_LISTBOX_SELECT_BD		"0"
#define DEF_LISTBOX_SELECT_FG_COLOR	BLACK







>










>







207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
 * Defaults for listboxes:
 */

#define DEF_LISTBOX_ACTIVE_STYLE	"dotbox"
#define DEF_LISTBOX_BG_COLOR		WHITE
#define DEF_LISTBOX_BG_MONO		WHITE
#define DEF_LISTBOX_BORDER_WIDTH	"1"
#define DEF_LISTBOX_COLUMN              "-1"
#define DEF_LISTBOX_CURSOR		""
#define DEF_LISTBOX_DISABLED_FG		DISABLED
#define DEF_LISTBOX_EXPORT_SELECTION	"1"
#define DEF_LISTBOX_FONT		"TkDefaultFont"
#define DEF_LISTBOX_FG			BLACK
#define DEF_LISTBOX_HEIGHT		"10"
#define DEF_LISTBOX_HIGHLIGHT_BG	NORMAL_BG
#define DEF_LISTBOX_HIGHLIGHT		BLACK
#define DEF_LISTBOX_HIGHLIGHT_WIDTH	"1"
#define DEF_LISTBOX_JUSTIFY		"left"
#define DEF_LISTBOX_MASTER              ((char*) NULL)
#define DEF_LISTBOX_RELIEF		"sunken"
#define DEF_LISTBOX_SCROLL_COMMAND	""
#define DEF_LISTBOX_LIST_VARIABLE	""
#define DEF_LISTBOX_SELECT_COLOR	SELECT_BG
#define DEF_LISTBOX_SELECT_MONO		BLACK
#define DEF_LISTBOX_SELECT_BD		"0"
#define DEF_LISTBOX_SELECT_FG_COLOR	BLACK

Changes to win/tkWinDefault.h.

211
212
213
214
215
216
217

218
219
220
221
222
223
224
225
226
227

228
229
230
231
232
233
234
 * Defaults for listboxes:
 */

#define DEF_LISTBOX_ACTIVE_STYLE	"underline"
#define DEF_LISTBOX_BG_COLOR		"SystemWindow"
#define DEF_LISTBOX_BG_MONO		WHITE
#define DEF_LISTBOX_BORDER_WIDTH	"1"

#define DEF_LISTBOX_CURSOR		""
#define DEF_LISTBOX_DISABLED_FG		DISABLED
#define DEF_LISTBOX_EXPORT_SELECTION	"1"
#define DEF_LISTBOX_FONT		"TkDefaultFont"
#define DEF_LISTBOX_FG			NORMAL_FG
#define DEF_LISTBOX_HEIGHT		"10"
#define DEF_LISTBOX_HIGHLIGHT_BG	NORMAL_BG
#define DEF_LISTBOX_HIGHLIGHT		HIGHLIGHT
#define DEF_LISTBOX_HIGHLIGHT_WIDTH	"1"
#define DEF_LISTBOX_JUSTIFY		"left"

#define DEF_LISTBOX_RELIEF		"sunken"
#define DEF_LISTBOX_SCROLL_COMMAND	""
#define DEF_LISTBOX_LIST_VARIABLE	""
#define DEF_LISTBOX_SELECT_COLOR	SELECT_BG
#define DEF_LISTBOX_SELECT_MONO		BLACK
#define DEF_LISTBOX_SELECT_BD		"0"
#define DEF_LISTBOX_SELECT_FG_COLOR	SELECT_FG







>










>







211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
 * Defaults for listboxes:
 */

#define DEF_LISTBOX_ACTIVE_STYLE	"underline"
#define DEF_LISTBOX_BG_COLOR		"SystemWindow"
#define DEF_LISTBOX_BG_MONO		WHITE
#define DEF_LISTBOX_BORDER_WIDTH	"1"
#define DEF_LISTBOX_COLUMN              "-1"
#define DEF_LISTBOX_CURSOR		""
#define DEF_LISTBOX_DISABLED_FG		DISABLED
#define DEF_LISTBOX_EXPORT_SELECTION	"1"
#define DEF_LISTBOX_FONT		"TkDefaultFont"
#define DEF_LISTBOX_FG			NORMAL_FG
#define DEF_LISTBOX_HEIGHT		"10"
#define DEF_LISTBOX_HIGHLIGHT_BG	NORMAL_BG
#define DEF_LISTBOX_HIGHLIGHT		HIGHLIGHT
#define DEF_LISTBOX_HIGHLIGHT_WIDTH	"1"
#define DEF_LISTBOX_JUSTIFY		"left"
#define DEF_LISTBOX_MASTER              ((char*) NULL)
#define DEF_LISTBOX_RELIEF		"sunken"
#define DEF_LISTBOX_SCROLL_COMMAND	""
#define DEF_LISTBOX_LIST_VARIABLE	""
#define DEF_LISTBOX_SELECT_COLOR	SELECT_BG
#define DEF_LISTBOX_SELECT_MONO		BLACK
#define DEF_LISTBOX_SELECT_BD		"0"
#define DEF_LISTBOX_SELECT_FG_COLOR	SELECT_FG