diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-12-13 15:11:26 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-12-13 15:11:26 (GMT) |
commit | d761ee11ddfbf78f99ff1cf29011f5c899983250 (patch) | |
tree | 38f47266dc9b377ed8a529e07f01ade1ad082d71 | |
parent | ef4c01636da67186ae85866657ffa6170548a0ce (diff) | |
download | tk-d761ee11ddfbf78f99ff1cf29011f5c899983250.zip tk-d761ee11ddfbf78f99ff1cf29011f5c899983250.tar.gz tk-d761ee11ddfbf78f99ff1cf29011f5c899983250.tar.bz2 |
Use more "default" in case-statements
-rw-r--r-- | generic/tk.h | 2 | ||||
-rw-r--r-- | generic/tkCanvBmap.c | 4 | ||||
-rw-r--r-- | generic/tkCanvImg.c | 4 | ||||
-rw-r--r-- | generic/tkCanvPs.c | 16 | ||||
-rw-r--r-- | generic/tkCanvText.c | 36 | ||||
-rw-r--r-- | generic/tkCanvWind.c | 4 | ||||
-rw-r--r-- | generic/tkPack.c | 4 | ||||
-rw-r--r-- | generic/tkPlace.c | 2 | ||||
-rw-r--r-- | generic/tkTest.c | 2 | ||||
-rw-r--r-- | generic/tkUtil.c | 32 | ||||
-rw-r--r-- | tests/config.test | 4 | ||||
-rw-r--r-- | win/tkWinGDI.c | 2 |
12 files changed, 51 insertions, 61 deletions
diff --git a/generic/tk.h b/generic/tk.h index be14690..ae870c7 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -557,7 +557,7 @@ typedef enum { */ typedef enum { - TK_JUSTIFY_NULL = -1, + TK_JUSTIFY_NULL = -1, TK_JUSTIFY_LEFT, TK_JUSTIFY_RIGHT, TK_JUSTIFY_CENTER } Tk_Justify; diff --git a/generic/tkCanvBmap.c b/generic/tkCanvBmap.c index 18618b3..69a37bd 100644 --- a/generic/tkCanvBmap.c +++ b/generic/tkCanvBmap.c @@ -540,7 +540,7 @@ ComputeBitmapBbox( break; case TK_ANCHOR_NW: break; - case TK_ANCHOR_CENTER: + default: x -= width/2; y -= height/2; break; @@ -945,7 +945,7 @@ BitmapToPostscript( case TK_ANCHOR_S: x -= width/2.0; break; case TK_ANCHOR_SW: break; case TK_ANCHOR_W: y -= height/2.0; break; - case TK_ANCHOR_CENTER: x -= width/2.0; y -= height/2.0; break; + default: x -= width/2.0; y -= height/2.0; break; } /* diff --git a/generic/tkCanvImg.c b/generic/tkCanvImg.c index fcdebf0..16b8345 100644 --- a/generic/tkCanvImg.c +++ b/generic/tkCanvImg.c @@ -491,7 +491,7 @@ ComputeImageBbox( break; case TK_ANCHOR_NW: break; - case TK_ANCHOR_CENTER: + default: x -= width/2; y -= height/2; break; @@ -747,7 +747,7 @@ ImageToPostscript( case TK_ANCHOR_S: x -= width/2.0; break; case TK_ANCHOR_SW: break; case TK_ANCHOR_W: y -= height/2.0; break; - case TK_ANCHOR_CENTER: x -= width/2.0; y -= height/2.0; break; + default: x -= width/2.0; y -= height/2.0; break; } if (!prepass) { diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c index b1e7b72..8266536 100644 --- a/generic/tkCanvPs.c +++ b/generic/tkCanvPs.c @@ -285,16 +285,14 @@ TkCanvPostscriptCmd( case TK_ANCHOR_SW: deltaX = 0; break; - case TK_ANCHOR_N: - case TK_ANCHOR_CENTER: - case TK_ANCHOR_S: - deltaX = -psInfo.width/2; - break; case TK_ANCHOR_NE: case TK_ANCHOR_E: case TK_ANCHOR_SE: deltaX = -psInfo.width; break; + default: + deltaX = -psInfo.width/2; + break; } switch (psInfo.pageAnchor) { case TK_ANCHOR_NW: @@ -302,16 +300,14 @@ TkCanvPostscriptCmd( case TK_ANCHOR_NE: deltaY = - psInfo.height; break; - case TK_ANCHOR_W: - case TK_ANCHOR_CENTER: - case TK_ANCHOR_E: - deltaY = -psInfo.height/2; - break; case TK_ANCHOR_SW: case TK_ANCHOR_S: case TK_ANCHOR_SE: deltaY = 0; break; + default: + deltaY = -psInfo.height/2; + break; } if (psInfo.colorMode == NULL) { diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index 9b7d377..89ba7cc 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -755,15 +755,6 @@ ComputeTextBbox( case TK_ANCHOR_NE: break; - case TK_ANCHOR_W: - case TK_ANCHOR_CENTER: - case TK_ANCHOR_E: - topY -= height / 2; - for (i=0 ; i<4 ; i++) { - dy[i] = -height / 2; - } - break; - case TK_ANCHOR_SW: case TK_ANCHOR_S: case TK_ANCHOR_SE: @@ -772,6 +763,13 @@ ComputeTextBbox( dy[i] = -height; } break; + + default: + topY -= height / 2; + for (i=0 ; i<4 ; i++) { + dy[i] = -height / 2; + } + break; } switch (textPtr->anchor) { case TK_ANCHOR_NW: @@ -779,15 +777,6 @@ ComputeTextBbox( case TK_ANCHOR_SW: break; - case TK_ANCHOR_N: - case TK_ANCHOR_CENTER: - case TK_ANCHOR_S: - leftX -= width / 2; - for (i=0 ; i<4 ; i++) { - dx[i] = -width / 2; - } - break; - case TK_ANCHOR_NE: case TK_ANCHOR_E: case TK_ANCHOR_SE: @@ -796,6 +785,13 @@ ComputeTextBbox( dx[i] = -width; } break; + + default: + leftX -= width / 2; + for (i=0 ; i<4 ; i++) { + dx[i] = -width / 2; + } + break; } textPtr->actualWidth = width; @@ -1742,8 +1738,8 @@ TextToPostscript( case TK_ANCHOR_S: x = 1; y = 2; break; case TK_ANCHOR_SW: x = 0; y = 2; break; case TK_ANCHOR_W: x = 0; y = 1; break; - case TK_ANCHOR_CENTER: x = 1; y = 1; break; - default: x = 0; y = 0; break; + case TK_ANCHOR_NW: x = 0; y = 0; break; + default: x = 1; y = 1; break; } switch (textPtr->justify) { case TK_JUSTIFY_CENTER: justify = "0.5"; break; diff --git a/generic/tkCanvWind.c b/generic/tkCanvWind.c index 9de843a..3031a94 100644 --- a/generic/tkCanvWind.c +++ b/generic/tkCanvWind.c @@ -518,7 +518,7 @@ ComputeWindowBbox( break; case TK_ANCHOR_NW: break; - case TK_ANCHOR_CENTER: + default: x -= width/2; y -= height/2; break; @@ -826,7 +826,7 @@ WinItemToPostscript( case TK_ANCHOR_S: x -= width/2.0; break; case TK_ANCHOR_SW: break; case TK_ANCHOR_W: y -= height/2.0; break; - case TK_ANCHOR_CENTER: x -= width/2.0; y -= height/2.0; break; + default: x -= width/2.0; y -= height/2.0; break; } return CanvasPsWindow(interp, tkwin, canvas, x, y, width, height); diff --git a/generic/tkPack.c b/generic/tkPack.c index ac5d73f..dd8977c 100644 --- a/generic/tkPack.c +++ b/generic/tkPack.c @@ -826,12 +826,10 @@ ArrangePacking( x = frameX + borderLeft; y = frameY + borderTop; break; - case TK_ANCHOR_CENTER: + default: x = frameX + (borderLeft + frameWidth - width - borderRight)/2; y = frameY + (borderTop + frameHeight - height - borderBtm)/2; break; - default: - Tcl_Panic("bad frame factor in ArrangePacking"); } width -= contentPtr->doubleBw; height -= contentPtr->doubleBw; diff --git a/generic/tkPlace.c b/generic/tkPlace.c index 8e26c71..7818976 100644 --- a/generic/tkPlace.c +++ b/generic/tkPlace.c @@ -1010,7 +1010,7 @@ RecomputePlacement( break; case TK_ANCHOR_NW: break; - case TK_ANCHOR_CENTER: + default: x -= width/2; y -= height/2; break; diff --git a/generic/tkTest.c b/generic/tkTest.c index 1ed475a..4642d55 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -949,7 +949,7 @@ TestobjconfigObjCmd( recordPtr->relief = TK_RELIEF_FLAT; recordPtr->cursor = NULL; recordPtr->justify = TK_JUSTIFY_LEFT; - recordPtr->anchor = TK_ANCHOR_N; + recordPtr->anchor = TK_ANCHOR_CENTER; recordPtr->pixels = 0; recordPtr->mm = 0.0; recordPtr->tkwin = NULL; diff --git a/generic/tkUtil.c b/generic/tkUtil.c index e83731d..41ac565 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -820,17 +820,17 @@ TkComputeAnchor( *xPtr = Tk_InternalBorderLeft(tkwin) + padX; break; - case TK_ANCHOR_N: - case TK_ANCHOR_CENTER: - case TK_ANCHOR_S: - *xPtr = (Tk_Width(tkwin) - innerWidth - Tk_InternalBorderLeft(tkwin) - - Tk_InternalBorderRight(tkwin)) / 2 + - Tk_InternalBorderLeft(tkwin); + case TK_ANCHOR_NE: + case TK_ANCHOR_E: + case TK_ANCHOR_SE: + *xPtr = Tk_Width(tkwin) - Tk_InternalBorderRight(tkwin) - padX + - innerWidth; break; default: - *xPtr = Tk_Width(tkwin) - Tk_InternalBorderRight(tkwin) - padX - - innerWidth; + *xPtr = (Tk_Width(tkwin) - innerWidth - Tk_InternalBorderLeft(tkwin) - + Tk_InternalBorderRight(tkwin)) / 2 + + Tk_InternalBorderLeft(tkwin); break; } @@ -845,17 +845,17 @@ TkComputeAnchor( *yPtr = Tk_InternalBorderTop(tkwin) + padY; break; - case TK_ANCHOR_W: - case TK_ANCHOR_CENTER: - case TK_ANCHOR_E: - *yPtr = (Tk_Height(tkwin) - innerHeight- Tk_InternalBorderTop(tkwin) - - Tk_InternalBorderBottom(tkwin)) / 2 + - Tk_InternalBorderTop(tkwin); + case TK_ANCHOR_SW: + case TK_ANCHOR_S: + case TK_ANCHOR_SE: + *yPtr = Tk_Height(tkwin) - Tk_InternalBorderBottom(tkwin) - padY + - innerHeight; break; default: - *yPtr = Tk_Height(tkwin) - Tk_InternalBorderBottom(tkwin) - padY - - innerHeight; + *yPtr = (Tk_Height(tkwin) - innerHeight- Tk_InternalBorderTop(tkwin) - + Tk_InternalBorderBottom(tkwin)) / 2 + + Tk_InternalBorderTop(tkwin); break; } } diff --git a/tests/config.test b/tests/config.test index 1407ba6..1c6f488 100644 --- a/tests/config.test +++ b/tests/config.test @@ -1443,11 +1443,11 @@ test config-8.18 {Tk_RestoreSavedOptions - anchor internal form} -constraints { testobjconfig } -body { testobjconfig internal .a - catch {.a csave -anchor center -color bogus} + catch {.a csave -anchor n -color bogus} .a cget -anchor } -cleanup { killTables -} -result {n} +} -result {center} test config-8.19 {Tk_RestoreSavedOptions - window internal form} -constraints { testobjconfig } -body { diff --git a/win/tkWinGDI.c b/win/tkWinGDI.c index 7c6705a..9daca0f 100644 --- a/win/tkWinGDI.c +++ b/win/tkWinGDI.c @@ -1628,7 +1628,7 @@ int GdiText( case TK_ANCHOR_SW: y = (sizerect.bottom - sizerect.top); break; - case TK_ANCHOR_CENTER: + default: x = (sizerect.right - sizerect.left) / 2; y = (sizerect.bottom - sizerect.top) / 2; break; |