summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-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
-rw-r--r--macosx/ttkMacOSXTheme.c4
-rw-r--r--win/ttkWinTheme.c11
-rw-r--r--win/ttkWinXPTheme.c6
10 files changed, 81 insertions, 45 deletions
diff --git a/ChangeLog b/ChangeLog
index ff8b6e3..e0b5295 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2007-11-07 Joe English <jenglish@users.sourceforge.net>
+
+ * generic/ttk/ttkTheme.c(Ttk_ElementSize): Fixed longstanding,
+ subtle bug that caused element padding to sometimes be counted
+ twice in size computations.
+
+ * generic/ttk/ttkElements.c, generic/ttk/ttkClamTheme.c,
+ generic/ttk/ttkDefaultTheme.c, generic/ttk/ttkTreeview.c,
+ generic/ttk/ttkImage.c, macosx/ttkMacOSXTheme.c,
+ win/ttkWinTheme.c, win/ttkWinXPTheme.c:
+
+ Fix ElementSizeProcs affected by previous change.
+
+
2007-11-06 Andreas Kupries <andreask@activestate.com>
* doc/CrtConsoleChan.3: Fixed markup typo and extended see also
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(
diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c
index 88ff37a..9ca20ae 100644
--- a/macosx/ttkMacOSXTheme.c
+++ b/macosx/ttkMacOSXTheme.c
@@ -27,7 +27,7 @@
* top-level window, not to the Tk_Window. BoxToRect()
* accounts for this.
*
- * RCS: @(#) $Id: ttkMacOSXTheme.c,v 1.14 2007/11/05 16:37:50 jenglish Exp $
+ * RCS: @(#) $Id: ttkMacOSXTheme.c,v 1.15 2007/11/08 01:40:25 jenglish Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -205,6 +205,8 @@ static void ButtonElementSize(
*/
*paddingPtr = Ttk_AddPadding(*paddingPtr, ButtonMargins);
+ *widthPtr += Ttk_PaddingWidth(ButtonMargins);
+ *heightPtr += Ttk_PaddingHeight(ButtonMargins);
}
static void ButtonElementDraw(
diff --git a/win/ttkWinTheme.c b/win/ttkWinTheme.c
index 41754ee..18c6405 100644
--- a/win/ttkWinTheme.c
+++ b/win/ttkWinTheme.c
@@ -1,6 +1,6 @@
/* winTheme.c - Copyright (C) 2004 Pat Thoyts <patthoyts@users.sf.net>
*
- * $Id: ttkWinTheme.c,v 1.8 2007/10/25 07:08:26 jenglish Exp $
+ * $Id: ttkWinTheme.c,v 1.9 2007/11/08 01:40:25 jenglish Exp $
*/
#ifdef _MSC_VER
@@ -93,7 +93,7 @@ typedef struct
int cxId; /* system metric id for size in x */
int cyId; /* system metric id for size in y */
Ttk_StateTable *stateMap; /* map Tk states to Win32 flags */
- Ttk_Padding padding; /* additional placement padding */
+ Ttk_Padding margins; /* additional placement padding */
} FrameControlElementData;
static FrameControlElementData FrameControlElements[] =
@@ -129,10 +129,9 @@ static void FrameControlElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- FrameControlElementData *elementData = clientData;
- *widthPtr = GetSystemMetrics(elementData->cxId);
- *heightPtr = GetSystemMetrics(elementData->cyId);
- *paddingPtr = elementData->padding;
+ FrameControlElementData *p = clientData;
+ *widthPtr = GetSystemMetrics(p->cxId) + Ttk_PaddingWidth(p->margins);
+ *heightPtr = GetSystemMetrics(p->cyId) + Ttk_PaddingHeight(p->margins);
}
static void FrameControlElementDraw(
diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c
index e18d604..9f42cf6 100644
--- a/win/ttkWinXPTheme.c
+++ b/win/ttkWinXPTheme.c
@@ -1,5 +1,5 @@
/*
- * $Id: ttkWinXPTheme.c,v 1.13 2007/10/25 07:08:27 jenglish Exp $
+ * $Id: ttkWinXPTheme.c,v 1.14 2007/11/08 01:40:26 jenglish Exp $
*
* Tk theme engine which uses the Windows XP "Visual Styles" API
* Adapted from Georgios Petasis' XP theme patch.
@@ -493,6 +493,10 @@ static void GenericElementSize(
/* See NOTE-GetThemeMargins
*/
*paddingPtr = elementData->info->padding;
+ if (elementData->info->flags & PAD_MARGINS) {
+ *widthPtr += Ttk_PaddingWidth(elementData->info->padding);
+ *heightPtr += Ttk_PaddingHeight(elementData->info->padding);
+ }
}
static void GenericElementDraw(