summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjenglish <jenglish@flightlab.com>2007-11-08 01:40:24 (GMT)
committerjenglish <jenglish@flightlab.com>2007-11-08 01:40:24 (GMT)
commit20121b9b291bee97ea1985c2b3c16470ee92afa1 (patch)
treeadd48b19aba5fd375a93fc51364bb2e52cfb953d /generic
parent467a688247fb6279144a01f04bac8aac679d166b (diff)
downloadtk-20121b9b291bee97ea1985c2b3c16470ee92afa1.zip
tk-20121b9b291bee97ea1985c2b3c16470ee92afa1.tar.gz
tk-20121b9b291bee97ea1985c2b3c16470ee92afa1.tar.bz2
Ttk_ElementSize: Fixed longstanding, subtle bug that caused element padding
to sometimes be counted twice in size computations. Fix ElementSizeProcs affected by previous change.
Diffstat (limited to 'generic')
-rw-r--r--generic/ttk/ttkClamTheme.c15
-rw-r--r--generic/ttk/ttkDefaultTheme.c22
-rw-r--r--generic/ttk/ttkElements.c38
-rw-r--r--generic/ttk/ttkImage.c4
-rw-r--r--generic/ttk/ttkTheme.c4
-rw-r--r--generic/ttk/ttkTreeview.c8
6 files changed, 54 insertions, 37 deletions
diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c
index 1ce75e0..39d38b4 100644
--- a/generic/ttk/ttkClamTheme.c
+++ b/generic/ttk/ttkClamTheme.c
@@ -1,5 +1,5 @@
/*
- * $Id: ttkClamTheme.c,v 1.6 2007/10/25 07:08:26 jenglish Exp $
+ * $Id: ttkClamTheme.c,v 1.7 2007/11/08 01:40:24 jenglish Exp $
*
* Copyright (C) 2004 Joe English
*
@@ -301,10 +301,12 @@ static void IndicatorElementSize(
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
IndicatorElement *indicator = elementRecord;
+ Ttk_Padding margins;
int size = 10;
- Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, paddingPtr);
+ Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
- *widthPtr = *heightPtr = size;
+ *widthPtr = size + Ttk_PaddingWidth(margins);
+ *heightPtr = size + Ttk_PaddingHeight(margins);
}
static void RadioIndicatorElementDraw(
@@ -418,10 +420,13 @@ static void MenuIndicatorElementSize(
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
MenuIndicatorElement *indicator = elementRecord;
+ Ttk_Padding margins;
int size = MENUBUTTON_ARROW_SIZE;
Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
+ Ttk_GetPaddingFromObj(NULL, tkwin, indicator->paddingObj, &margins);
TtkArrowSize(size, ARROW_DOWN, widthPtr, heightPtr);
- Ttk_GetPaddingFromObj(NULL, tkwin, indicator->paddingObj, paddingPtr);
+ *widthPtr += Ttk_PaddingWidth(margins);
+ *heightPtr += Ttk_PaddingHeight(margins);
}
static void MenuIndicatorElementDraw(
@@ -698,6 +703,8 @@ static void PbarElementSize(
SliderElementSize(clientData, elementRecord, tkwin,
widthPtr, heightPtr, paddingPtr);
*paddingPtr = Ttk_UniformPadding(2);
+ *widthPtr += 4;
+ *heightPtr += 4;
}
static void PbarElementDraw(
diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c
index 0e8c35d..54bb450 100644
--- a/generic/ttk/ttkDefaultTheme.c
+++ b/generic/ttk/ttkDefaultTheme.c
@@ -1,4 +1,4 @@
-/* $Id: ttkDefaultTheme.c,v 1.9 2007/11/05 00:00:00 jenglish Exp $
+/* $Id: ttkDefaultTheme.c,v 1.10 2007/11/08 01:40:25 jenglish Exp $
*
* Copyright (c) 2003, Joe English
*
@@ -496,9 +496,10 @@ static void IndicatorElementSize(
{
IndicatorSpec *spec = clientData;
IndicatorElement *indicator = elementRecord;
- Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, paddingPtr);
- *widthPtr = spec->width;
- *heightPtr = spec->height;
+ Ttk_Padding margins;
+ Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
+ *widthPtr = spec->width + Ttk_PaddingWidth(margins);
+ *heightPtr = spec->height + Ttk_PaddingHeight(margins);
}
static void IndicatorElementDraw(
@@ -649,7 +650,8 @@ static void ArrowElementSize(
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &width);
width -= Ttk_PaddingWidth(ArrowPadding);
TtkArrowSize(width/2, direction, widthPtr, heightPtr);
- *paddingPtr = ArrowPadding;
+ *widthPtr += Ttk_PaddingWidth(ArrowPadding);
+ *heightPtr += Ttk_PaddingHeight(ArrowPadding);
}
static void ArrowElementDraw(
@@ -722,7 +724,8 @@ static void MenubuttonArrowElementSize(
int size = MENUBUTTON_ARROW_SIZE;
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
*widthPtr = *heightPtr = 2 * size + 1;
- *paddingPtr = MenubuttonArrowPadding;
+ *widthPtr += Ttk_PaddingWidth(MenubuttonArrowPadding);
+ *heightPtr += Ttk_PaddingHeight(MenubuttonArrowPadding);
}
static void MenubuttonArrowElementDraw(
@@ -1058,9 +1061,12 @@ static void TreeitemIndicatorSize(
{
TreeitemIndicator *indicator = elementRecord;
int diameter = 0;
- Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, paddingPtr);
+ Ttk_Padding margins;
+
+ Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &diameter);
- *widthPtr = *heightPtr = diameter;
+ *widthPtr = diameter + Ttk_PaddingWidth(margins);
+ *heightPtr = diameter + Ttk_PaddingHeight(margins);
}
static void TreeitemIndicatorDraw(
diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c
index 958122c..0c5ea72 100644
--- a/generic/ttk/ttkElements.c
+++ b/generic/ttk/ttkElements.c
@@ -1,4 +1,4 @@
-/* $Id: ttkElements.c,v 1.7 2007/10/25 07:08:26 jenglish Exp $
+/* $Id: ttkElements.c,v 1.8 2007/11/08 01:40:25 jenglish Exp $
*
* Copyright (c) 2003, Joe English
*
@@ -531,10 +531,12 @@ static void SquareIndicatorElementSize(
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
IndicatorElement *indicator = elementRecord;
+ Ttk_Padding margins;
int diameter = 0;
- Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, paddingPtr);
+ Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &diameter);
- *widthPtr = *heightPtr = diameter;
+ *widthPtr = diameter + Ttk_PaddingWidth(margins);
+ *heightPtr = diameter + Ttk_PaddingHeight(margins);
}
static void SquareIndicatorElementDraw(
@@ -571,10 +573,12 @@ static void DiamondIndicatorElementSize(
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
IndicatorElement *indicator = elementRecord;
+ Ttk_Padding margins;
int diameter = 0;
- Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, paddingPtr);
+ Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &diameter);
- *widthPtr = *heightPtr = diameter + 3;
+ *widthPtr = diameter + 3 + Ttk_PaddingWidth(margins);
+ *heightPtr = diameter + 3 + Ttk_PaddingHeight(margins);
}
static void DiamondIndicatorElementDraw(
@@ -673,9 +677,12 @@ static void MenuIndicatorElementSize(
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
MenuIndicatorElement *mi = elementRecord;
+ Ttk_Padding margins;
Tk_GetPixelsFromObj(NULL, tkwin, mi->widthObj, widthPtr);
Tk_GetPixelsFromObj(NULL, tkwin, mi->heightObj, heightPtr);
- Ttk_GetPaddingFromObj(NULL,tkwin,mi->marginObj,paddingPtr);
+ Ttk_GetPaddingFromObj(NULL,tkwin,mi->marginObj, &margins);
+ *widthPtr += Ttk_PaddingWidth(margins);
+ *heightPtr += Ttk_PaddingHeight(margins);
}
static void MenuIndicatorElementDraw(
@@ -735,7 +742,7 @@ static Ttk_ElementOptionSpec ArrowElementOptions[] =
{ NULL }
};
-static Ttk_Padding ArrowPadding = { 3,3,3,3 };
+static Ttk_Padding ArrowMargins = { 3,3,3,3 };
static void ArrowElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
@@ -746,9 +753,10 @@ static void ArrowElementSize(
int width = 14;
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &width);
- width -= Ttk_PaddingWidth(ArrowPadding);
+ width -= Ttk_PaddingWidth(ArrowMargins);
TtkArrowSize(width/2, direction, widthPtr, heightPtr);
- *paddingPtr = ArrowPadding;
+ *widthPtr += Ttk_PaddingWidth(ArrowMargins);
+ *heightPtr += Ttk_PaddingWidth(ArrowMargins);
}
static void ArrowElementDraw(
@@ -768,7 +776,7 @@ static void ArrowElementDraw(
tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth, relief);
TtkFillArrow(Tk_Display(tkwin), d, Tk_GCForColor(arrowColor, d),
- Ttk_PadBox(b, ArrowPadding), direction);
+ Ttk_PadBox(b, ArrowMargins), direction);
}
static Ttk_ElementSpec ArrowElementSpec =
@@ -1075,16 +1083,14 @@ static void PbarElementSize(
switch (orient) {
case TTK_ORIENT_HORIZONTAL:
- *widthPtr = length;
- *heightPtr = thickness;
+ *widthPtr = length + 2 * borderWidth;
+ *heightPtr = thickness + 2 * borderWidth;
break;
case TTK_ORIENT_VERTICAL:
- *widthPtr = thickness;
- *heightPtr = length;
+ *widthPtr = thickness + 2 * borderWidth;
+ *heightPtr = length + 2 * borderWidth;
break;
}
-
- *paddingPtr = Ttk_UniformPadding((short)borderWidth);
}
static void PbarElementDraw(
diff --git a/generic/ttk/ttkImage.c b/generic/ttk/ttkImage.c
index acc4e8f..30d5ef5 100644
--- a/generic/ttk/ttkImage.c
+++ b/generic/ttk/ttkImage.c
@@ -1,4 +1,4 @@
-/* $Id: ttkImage.c,v 1.5 2006/12/14 19:51:04 jenglish Exp $
+/* $Id: ttkImage.c,v 1.6 2007/11/08 01:40:25 jenglish Exp $
* Image specifications and image element factory.
*
* Copyright (C) 2004 Pat Thoyts <patthoyts@users.sf.net>
@@ -258,8 +258,6 @@ static void ImageElementSize(
}
*paddingPtr = imageData->padding;
- *widthPtr -= Ttk_PaddingWidth(imageData->padding);
- *heightPtr -= Ttk_PaddingHeight(imageData->padding);
}
static void ImageElementDraw(
diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c
index a16ba00..74ffcf0 100644
--- a/generic/ttk/ttkTheme.c
+++ b/generic/ttk/ttkTheme.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * $Id: ttkTheme.c,v 1.6 2007/01/11 19:59:26 jenglish Exp $
+ * $Id: ttkTheme.c,v 1.7 2007/11/08 01:40:25 jenglish Exp $
*/
#include <stdlib.h>
@@ -1095,8 +1095,6 @@ Ttk_ElementSize(
element->specPtr->size(
element->clientData, element->elementRecord,
tkwin, widthPtr, heightPtr, paddingPtr);
- *widthPtr += paddingPtr->left + paddingPtr->right;
- *heightPtr += paddingPtr->top + paddingPtr->bottom;
}
/*
diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c
index 73928c5..a9d53e3 100644
--- a/generic/ttk/ttkTreeview.c
+++ b/generic/ttk/ttkTreeview.c
@@ -1,4 +1,4 @@
-/* $Id: ttkTreeview.c,v 1.20 2007/11/05 00:00:00 jenglish Exp $
+/* $Id: ttkTreeview.c,v 1.21 2007/11/08 01:40:25 jenglish Exp $
* Copyright (c) 2004, Joe English
*
* ttk::treeview widget implementation.
@@ -3099,12 +3099,14 @@ static void TreeitemIndicatorSize(
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
TreeitemIndicator *indicator = elementRecord;
+ Ttk_Padding margins;
int size = 0;
- Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginsObj, paddingPtr);
+ Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginsObj, &margins);
Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
- *widthPtr = *heightPtr = size;
+ *widthPtr = size + Ttk_PaddingWidth(margins);
+ *heightPtr = size + Ttk_PaddingHeight(margins);
}
static void TreeitemIndicatorDraw(