summaryrefslogtreecommitdiffstats
path: root/generic/tkListbox.c
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2016-01-11 14:32:00 (GMT)
committerfvogel <fvogelnew1@free.fr>2016-01-11 14:32:00 (GMT)
commit5147bd27c61d07d5acfdd82046fccfdbb1aa38df (patch)
treea13886fb9069b5674bc2cbf07f0e23f5e0ad1423 /generic/tkListbox.c
parentddae56bbd0023f29a24d0529ed4fa0e3820ce7f2 (diff)
downloadtk-5147bd27c61d07d5acfdd82046fccfdbb1aa38df.zip
tk-5147bd27c61d07d5acfdd82046fccfdbb1aa38df.tar.gz
tk-5147bd27c61d07d5acfdd82046fccfdbb1aa38df.tar.bz2
Improved patch formatting. No functional change
Diffstat (limited to 'generic/tkListbox.c')
-rw-r--r--generic/tkListbox.c70
1 files changed, 44 insertions, 26 deletions
diff --git a/generic/tkListbox.c b/generic/tkListbox.c
index f16218b..2929882 100644
--- a/generic/tkListbox.c
+++ b/generic/tkListbox.c
@@ -165,8 +165,9 @@ typedef struct {
Pixmap gray; /* Pixmap for displaying disabled text. */
int flags; /* Various flag bits: see below for
* definitions. */
- Tk_Justify justify; /* Justification */
- int oldMaxOffset; /* Used in scrolling for right/center justification */
+ Tk_Justify justify; /* Justification. */
+ int oldMaxOffset; /* Used in scrolling for right/center
+ * justification. */
} Listbox;
/*
@@ -277,6 +278,8 @@ static const Tk_OptionSpec optionSpecs[] = {
{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",
@@ -310,8 +313,6 @@ static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_STRING, "-listvariable", "listVariable", "Variable",
DEF_LISTBOX_LIST_VARIABLE, -1, Tk_Offset(Listbox, listVarName),
TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_LISTBOX_JUSTIFY, -1, Tk_Offset(Listbox, justify), 0, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
};
@@ -440,7 +441,7 @@ static char * ListboxListVarProc(ClientData clientData,
const char *name2, int flags);
static void MigrateHashEntries(Tcl_HashTable *table,
int first, int last, int offset);
-static int GetMaxOffset(Listbox *listPtr);
+static int GetMaxOffset(Listbox *listPtr);
/*
* The structure below defines button class behavior by means of procedures
@@ -1125,7 +1126,7 @@ ListboxBboxSubCmd(
Tk_GetFontMetrics(listPtr->tkfont, &fm);
pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen);
- x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset;
+ x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset;
y = ((index - listPtr->topIndex)*listPtr->lineHeight)
+ listPtr->inset + listPtr->selBorderWidth;
results[0] = Tcl_NewIntObj(x);
@@ -2071,23 +2072,27 @@ DisplayListbox(
/*
* Draw the actual text of this item.
*/
- Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement);
- stringRep = Tcl_GetStringFromObj(curElement, &stringLen);
- Tk_ComputeTextLayout(listPtr->tkfont,
- stringRep, stringLen, 0,
- listPtr->justify, TK_IGNORE_NEWLINES, &totalLength, &height);
+
+ Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement);
+ stringRep = Tcl_GetStringFromObj(curElement, &stringLen);
+ Tk_ComputeTextLayout(listPtr->tkfont, stringRep, stringLen, 0,
+ listPtr->justify, TK_IGNORE_NEWLINES, &totalLength, &height);
Tk_GetFontMetrics(listPtr->tkfont, &fm);
y += fm.ascent + listPtr->selBorderWidth;
- if (listPtr->justify == TK_JUSTIFY_LEFT) {
- x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset;
- } else if (listPtr->justify == TK_JUSTIFY_RIGHT) {
- x = width - totalLength - listPtr->inset - listPtr->selBorderWidth - listPtr->xOffset + GetMaxOffset(listPtr) - 1;
- } else {
- x = (width + GetMaxOffset(listPtr))/2 - totalLength/2 - listPtr->xOffset;
- }
- Tk_DrawChars(listPtr->display, pixmap, gc, listPtr->tkfont,
+ if (listPtr->justify == TK_JUSTIFY_LEFT) {
+ x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset;
+ } else if (listPtr->justify == TK_JUSTIFY_RIGHT) {
+ x = width - totalLength - listPtr->inset -
+ listPtr->selBorderWidth - listPtr->xOffset +
+ GetMaxOffset(listPtr) - 1;
+ } else {
+ x = (width + GetMaxOffset(listPtr))/2 - totalLength/2 -
+ listPtr->xOffset;
+ }
+
+ Tk_DrawChars(listPtr->display, pixmap, gc, listPtr->tkfont,
stringRep, stringLen, x, y);
/*
@@ -2641,7 +2646,12 @@ ListboxEventProc(
ChangeListboxView(listPtr, listPtr->topIndex);
if (listPtr->justify == TK_JUSTIFY_RIGHT) {
maxOffset = GetMaxOffset(listPtr);
- if (maxOffset != listPtr->oldMaxOffset && listPtr->oldMaxOffset > 0) { // window has shrunk
+ if (maxOffset != listPtr->oldMaxOffset && listPtr->oldMaxOffset > 0) {
+
+ /*
+ * Window has shrunk.
+ */
+
if (maxOffset > listPtr->oldMaxOffset) {
tmpOffset = maxOffset - listPtr->oldMaxOffset;
} else {
@@ -2661,7 +2671,12 @@ ListboxEventProc(
listPtr->oldMaxOffset = maxOffset;
} else if (listPtr->justify == TK_JUSTIFY_CENTER) {
maxOffset = GetMaxOffset(listPtr);
- if (maxOffset != listPtr->oldMaxOffset && listPtr->oldMaxOffset > 0) { // window has shrunk
+ if (maxOffset != listPtr->oldMaxOffset && listPtr->oldMaxOffset > 0) {
+
+ /*
+ * Window has shrunk.
+ */
+
tmpOffset2 = maxOffset / 2;
if (maxOffset > listPtr->oldMaxOffset) {
tmpOffset = maxOffset/2 - listPtr->oldMaxOffset/2;
@@ -3661,21 +3676,24 @@ MigrateHashEntries(
*
* GetMaxOffset --
*
- * Passing in a listbox pointer, returns the maximum offset for the box
+ * Passing in a listbox pointer, returns the maximum offset for the box.
*
* Results:
- * Listbox's maxOffset
+ * Listbox's maxOffset.
*
* Side effects:
- * None
+ * None.
*
*----------------------------------------------------------------------
*/
-static int GetMaxOffset(register Listbox *listPtr)
+static int GetMaxOffset(
+ register Listbox *listPtr)
{
int maxOffset;
- maxOffset = listPtr->maxWidth - (Tk_Width(listPtr->tkwin) - 2*listPtr->inset - 2*listPtr->selBorderWidth) + listPtr->xScrollUnit - 1;
+ maxOffset = listPtr->maxWidth -
+ (Tk_Width(listPtr->tkwin) - 2*listPtr->inset -
+ 2*listPtr->selBorderWidth) + listPtr->xScrollUnit - 1;
if (maxOffset < 0) {
maxOffset = 0;
}