Tk Source Code

Check-in [2eedd5f1]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:More typos fixed
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip-441
Files: files | file ages | folders
SHA1: 2eedd5f166cb69bec453a934c4377b0ea4503730
User & Date: fvogel 2016-01-13 07:49:55
Context
2016-01-13
18:07
Rebased to latest trunk check-in: 51daaaff user: fvogel tags: tip-441
07:49
More typos fixed check-in: 2eedd5f1 user: fvogel tags: tip-441
07:16
Typo fixed check-in: a61ce95b user: fvogel tags: tip-441
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkListbox.c.

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
...
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
...
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
...
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
...
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
....
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
....
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
....
2820
2821
2822
2823
2824
2825
2826


2827


2828
2829
2830
2831
2832
2833
2834
....
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
    int fullLines;		/* Number of lines that are completely
				 * visible in window. There may be one
				 * additional line at the bottom that is
				 * partially visible. */
    int partialLine;		/* 0 means that the window holds exactly
				 * fullLines lines. 1 means that there is one
				 * additional line that is partially
				 * visble. */
    int setGrid;		/* Non-zero means pass gridding information to
				 * window manager. */

    /*
     * Information to support horizontal scrolling:
     */

................................................................................
    int selectAnchor;		/* Fixed end of selection (i.e. element at
				 * which selection was started.) */
    int exportSelection;	/* Non-zero means tie internal listbox to X
				 * selection. */
    int active;			/* Index of "active" element (the one that has
				 * been selected by keyboard traversal). -1
				 * means none. */
    int activeStyle;		/* style in which to draw the active element.
				 * One of: underline, none, dotbox */

    /*
     * Information for scanning:
     */

    int scanMarkX;		/* X-position at which scan started (e.g.
................................................................................
 *				already been queued to redraw this window.
 * UPDATE_V_SCROLLBAR:		Non-zero means vertical scrollbar needs to be
 *				updated.
 * UPDATE_H_SCROLLBAR:		Non-zero means horizontal scrollbar needs to
 *				be updated.
 * GOT_FOCUS:			Non-zero means this widget currently has the
 *				input focus.
 * MAXWIDTH_IS_STALE:		Stored maxWidth may be out-of-date
 * LISTBOX_DELETED:		This listbox has been effectively destroyed.
 */

#define REDRAW_PENDING		1
#define UPDATE_V_SCROLLBAR	2
#define UPDATE_H_SCROLLBAR	4
#define GOT_FOCUS		8
................................................................................
	 DEF_LISTBOX_LIST_VARIABLE, -1, Tk_Offset(Listbox, listVarName),
	 TK_OPTION_NULL_OK, 0, 0},
    {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
};

/*
 * The itemAttrOptionSpecs table defines the valid configuration options for
 * listbox items
 */

static const Tk_OptionSpec itemAttrOptionSpecs[] = {
    {TK_OPTION_BORDER, "-background", "background", "Background",
     NULL, -1, Tk_Offset(ItemAttr, border),
     TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT,
     DEF_LISTBOX_BG_MONO, 0},
................................................................................
     NULL, -1, Tk_Offset(ItemAttr, selFgColor),
     TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT,
     DEF_LISTBOX_SELECT_FG_MONO, 0},
    {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
};

/*
 * The following tables define the listbox widget commands (and sub- commands)
 * and map the indexes into the string tables into enumerated types used to
 * dispatch the listbox widget command.
 */

static const char *const commandNames[] = {
    "activate", "bbox", "cget", "configure", "curselection", "delete", "get",
    "index", "insert", "itemcget", "itemconfigure", "nearest", "scan",
................................................................................
    if (objc < 2) {
	Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
	return TCL_ERROR;
    }

    /*
     * Parse the command by looking up the second argument in the list of
     * valid subcommand names
     */

    result = Tcl_GetIndexFromObj(interp, objv[1], commandNames,
	    "option", 0, &cmdIndex);
    if (result != TCL_OK) {
	return result;
    }
................................................................................
			    width+left+right, listPtr->selBorderWidth, 0, 0, 0,
			    TK_RELIEF_RAISED);
		}
		prevSelected = 1;
	    } else {
		/*
		 * If there is an item attributes record for this item, draw
		 * the background box and set the foreground color accordingly
		 */

		if (entry != NULL) {
		    attrs = Tcl_GetHashValue(entry);
		    gcValues.foreground = listPtr->fgColorPtr->pixel;
		    gcValues.font = Tk_FontId(listPtr->tkfont);
		    gcValues.graphics_exposures = False;
................................................................................
	    ckfree(Tcl_GetHashValue(entry));
	    Tcl_DeleteHashEntry(entry);
	}

	/*
	 * Check width of the element. We only have to check if widthChanged
	 * has not already been set to 1, because we only need one maxWidth
	 * element to disappear for us to have to recompute the width
	 */

	if (widthChanged == 0) {
	    Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &element);
	    stringRep = Tcl_GetStringFromObj(element, &length);
	    pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, length);
	    if (pixelWidth == listPtr->maxWidth) {
................................................................................

    /*
     * The index didn't match any of the named indices; maybe it's an @x,y
     */

    stringRep = Tcl_GetString(indexObj);
    if (stringRep[0] == '@') {


	/* @x,y index */


	int y;
	const char *start;
	char *end;

	start = stringRep + 1;
	y = strtol(start, &end, 0);
	if ((start == end) || (*end != ',')) {
................................................................................
	 */

	Tcl_DecrRefCount(oldListObj);
    }

    /*
     * If the list length has decreased, then we should clean up selection and
     * attributes information for elements past the end of the new list
     */

    oldLength = listPtr->nElements;
    Tcl_ListObjLength(listPtr->interp, listPtr->listObj, &listPtr->nElements);
    if (listPtr->nElements < oldLength) {
	for (i = listPtr->nElements; i < oldLength; i++) {
	    /*






|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







>
>
|
>
>







 







|







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
...
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
...
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
...
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
...
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
....
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
....
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
....
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
....
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
    int fullLines;		/* Number of lines that are completely
				 * visible in window. There may be one
				 * additional line at the bottom that is
				 * partially visible. */
    int partialLine;		/* 0 means that the window holds exactly
				 * fullLines lines. 1 means that there is one
				 * additional line that is partially
				 * visible. */
    int setGrid;		/* Non-zero means pass gridding information to
				 * window manager. */

    /*
     * Information to support horizontal scrolling:
     */

................................................................................
    int selectAnchor;		/* Fixed end of selection (i.e. element at
				 * which selection was started.) */
    int exportSelection;	/* Non-zero means tie internal listbox to X
				 * selection. */
    int active;			/* Index of "active" element (the one that has
				 * been selected by keyboard traversal). -1
				 * means none. */
    int activeStyle;		/* Style in which to draw the active element.
				 * One of: underline, none, dotbox */

    /*
     * Information for scanning:
     */

    int scanMarkX;		/* X-position at which scan started (e.g.
................................................................................
 *				already been queued to redraw this window.
 * UPDATE_V_SCROLLBAR:		Non-zero means vertical scrollbar needs to be
 *				updated.
 * UPDATE_H_SCROLLBAR:		Non-zero means horizontal scrollbar needs to
 *				be updated.
 * GOT_FOCUS:			Non-zero means this widget currently has the
 *				input focus.
 * MAXWIDTH_IS_STALE:		Stored maxWidth may be out-of-date.
 * LISTBOX_DELETED:		This listbox has been effectively destroyed.
 */

#define REDRAW_PENDING		1
#define UPDATE_V_SCROLLBAR	2
#define UPDATE_H_SCROLLBAR	4
#define GOT_FOCUS		8
................................................................................
	 DEF_LISTBOX_LIST_VARIABLE, -1, Tk_Offset(Listbox, listVarName),
	 TK_OPTION_NULL_OK, 0, 0},
    {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
};

/*
 * The itemAttrOptionSpecs table defines the valid configuration options for
 * listbox items.
 */

static const Tk_OptionSpec itemAttrOptionSpecs[] = {
    {TK_OPTION_BORDER, "-background", "background", "Background",
     NULL, -1, Tk_Offset(ItemAttr, border),
     TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT,
     DEF_LISTBOX_BG_MONO, 0},
................................................................................
     NULL, -1, Tk_Offset(ItemAttr, selFgColor),
     TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT,
     DEF_LISTBOX_SELECT_FG_MONO, 0},
    {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
};

/*
 * The following tables define the listbox widget commands (and sub-commands)
 * and map the indexes into the string tables into enumerated types used to
 * dispatch the listbox widget command.
 */

static const char *const commandNames[] = {
    "activate", "bbox", "cget", "configure", "curselection", "delete", "get",
    "index", "insert", "itemcget", "itemconfigure", "nearest", "scan",
................................................................................
    if (objc < 2) {
	Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
	return TCL_ERROR;
    }

    /*
     * Parse the command by looking up the second argument in the list of
     * valid subcommand names.
     */

    result = Tcl_GetIndexFromObj(interp, objv[1], commandNames,
	    "option", 0, &cmdIndex);
    if (result != TCL_OK) {
	return result;
    }
................................................................................
			    width+left+right, listPtr->selBorderWidth, 0, 0, 0,
			    TK_RELIEF_RAISED);
		}
		prevSelected = 1;
	    } else {
		/*
		 * If there is an item attributes record for this item, draw
		 * the background box and set the foreground color accordingly.
		 */

		if (entry != NULL) {
		    attrs = Tcl_GetHashValue(entry);
		    gcValues.foreground = listPtr->fgColorPtr->pixel;
		    gcValues.font = Tk_FontId(listPtr->tkfont);
		    gcValues.graphics_exposures = False;
................................................................................
	    ckfree(Tcl_GetHashValue(entry));
	    Tcl_DeleteHashEntry(entry);
	}

	/*
	 * Check width of the element. We only have to check if widthChanged
	 * has not already been set to 1, because we only need one maxWidth
	 * element to disappear for us to have to recompute the width.
	 */

	if (widthChanged == 0) {
	    Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &element);
	    stringRep = Tcl_GetStringFromObj(element, &length);
	    pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, length);
	    if (pixelWidth == listPtr->maxWidth) {
................................................................................

    /*
     * The index didn't match any of the named indices; maybe it's an @x,y
     */

    stringRep = Tcl_GetString(indexObj);
    if (stringRep[0] == '@') {

        /*
         * @x,y index
         */

	int y;
	const char *start;
	char *end;

	start = stringRep + 1;
	y = strtol(start, &end, 0);
	if ((start == end) || (*end != ',')) {
................................................................................
	 */

	Tcl_DecrRefCount(oldListObj);
    }

    /*
     * If the list length has decreased, then we should clean up selection and
     * attributes information for elements past the end of the new list.
     */

    oldLength = listPtr->nElements;
    Tcl_ListObjLength(listPtr->interp, listPtr->listObj, &listPtr->nElements);
    if (listPtr->nElements < oldLength) {
	for (i = listPtr->nElements; i < oldLength; i++) {
	    /*