summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/ttk/ttkClamTheme.c55
-rw-r--r--generic/ttk/ttkElements.c23
2 files changed, 43 insertions, 35 deletions
diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c
index 60e9df3..807090e 100644
--- a/generic/ttk/ttkClamTheme.c
+++ b/generic/ttk/ttkClamTheme.c
@@ -495,7 +495,7 @@ static const Ttk_ElementOptionSpec GripElementOptions[] = {
offsetof(GripElement,lightColorObj), LIGHT_COLOR },
{ "-bordercolor", TK_OPTION_COLOR,
offsetof(GripElement,borderColorObj), DARKEST_COLOR },
- { "-gripcount", TK_OPTION_INT,
+ { "-gripcount", TK_OPTION_PIXELS,
offsetof(GripElement,gripCountObj), "5" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -506,15 +506,15 @@ static void GripElementSize(
{
Ttk_Orient orient = (Ttk_Orient)PTR2INT(clientData);
GripElement *grip = (GripElement *)elementRecord;
- int gripCount = 0;
- (void)tkwin;
+ int gripSize = 0;
(void)paddingPtr;
- Tcl_GetIntFromObj(NULL, grip->gripCountObj, &gripCount);
+ Tk_GetPixelsFromObj(NULL, tkwin, grip->gripCountObj, &gripSize);
+ gripSize *= 2;
if (orient == TTK_ORIENT_HORIZONTAL) {
- *widthPtr = 2*gripCount;
+ *widthPtr = gripSize;
} else {
- *heightPtr = 2*gripCount;
+ *heightPtr = gripSize;
}
}
@@ -527,25 +527,24 @@ static void GripElementDraw(
GripElement *grip = (GripElement *)elementRecord;
GC lightGC = Ttk_GCForColor(tkwin,grip->lightColorObj,d);
GC darkGC = Ttk_GCForColor(tkwin,grip->borderColorObj,d);
- int gripPad = 1, gripCount = 0;
+ int gripPad = 1, gripSize = 0;
int i;
(void)state;
- Tcl_GetIntFromObj(NULL, grip->gripCountObj, &gripCount);
+ Tk_GetPixelsFromObj(NULL, tkwin, grip->gripCountObj, &gripSize);
+ gripSize *= 2;
if (orient == TTK_ORIENT_HORIZONTAL) {
- int x = b.x + b.width / 2 - gripCount;
+ int x = b.x + (b.width - gripSize) / 2;
int y1 = b.y + gripPad, y2 = b.y + b.height - gripPad - 1 + w;
- for (i=0; i<gripCount; ++i) {
- XDrawLine(Tk_Display(tkwin), d, darkGC, x,y1, x,y2); ++x;
- XDrawLine(Tk_Display(tkwin), d, lightGC, x,y1, x,y2); ++x;
+ for (i=0; i<gripSize; ++i) {
+ XDrawLine(Tk_Display(tkwin), d, (i&1)?lightGC:darkGC, x,y1, x,y2); ++x;
}
} else {
- int y = b.y + b.height / 2 - gripCount;
+ int y = b.y + (b.height - gripSize) / 2;
int x1 = b.x + gripPad, x2 = b.x + b.width - gripPad - 1 + w;
- for (i=0; i<gripCount; ++i) {
- XDrawLine(Tk_Display(tkwin), d, darkGC, x1,y, x2,y); ++y;
- XDrawLine(Tk_Display(tkwin), d, lightGC, x1,y, x2,y); ++y;
+ for (i=0; i<gripSize; ++i) {
+ XDrawLine(Tk_Display(tkwin), d, (i&1)?lightGC:darkGC, x1,y, x2,y); ++y;
}
}
}
@@ -595,7 +594,7 @@ static const Ttk_ElementOptionSpec ScrollbarElementOptions[] = {
offsetof(ScrollbarElement,arrowColorObj), "#000000" },
{ "-arrowsize", TK_OPTION_PIXELS,
offsetof(ScrollbarElement,arrowSizeObj), STR(SCROLLBAR_THICKNESS) },
- { "-gripcount", TK_OPTION_INT,
+ { "-gripcount", TK_OPTION_PIXELS,
offsetof(ScrollbarElement,gripCountObj), "5" },
{ "-sliderlength", TK_OPTION_INT,
offsetof(ScrollbarElement,sliderlengthObj), "30" },
@@ -634,7 +633,7 @@ static void ThumbElementSize(
(void)tkwin;
(void)paddingPtr;
- Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &size);
+ Tk_GetPixelsFromObj(NULL, tkwin, sb->arrowSizeObj, &size);
*widthPtr = *heightPtr = size;
}
@@ -643,7 +642,7 @@ static void ThumbElementDraw(
Drawable d, Ttk_Box b, unsigned state)
{
ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
- int gripCount = 0;
+ int gripSize = 0;
Ttk_Orient orient = TTK_ORIENT_HORIZONTAL;
GC lightGC, darkGC;
int x1, y1, x2, y2, dx, dy, i;
@@ -661,27 +660,27 @@ static void ThumbElementDraw(
* Draw grip:
*/
TtkGetOrientFromObj(NULL, sb->orientObj, &orient);
- Tcl_GetIntFromObj(NULL, sb->gripCountObj, &gripCount);
+ Tk_GetPixelsFromObj(NULL, tkwin, sb->gripCountObj, &gripSize);
+ gripSize *= 2;
lightGC = Ttk_GCForColor(tkwin,sb->lightColorObj,d);
darkGC = Ttk_GCForColor(tkwin,sb->borderColorObj,d);
if (orient == TTK_ORIENT_HORIZONTAL) {
dx = 1; dy = 0;
- x1 = x2 = b.x + b.width / 2 - gripCount;
+ x1 = x2 = b.x + (b.width - gripSize) / 2;
y1 = b.y + 2;
y2 = b.y + b.height - 3 + w;
} else {
dx = 0; dy = 1;
- y1 = y2 = b.y + b.height / 2 - gripCount;
+ y1 = y2 = b.y + (b.height - gripSize) / 2;
x1 = b.x + 2;
x2 = b.x + b.width - 3 + w;
}
- for (i=0; i<gripCount; ++i) {
- XDrawLine(Tk_Display(tkwin), d, darkGC, x1,y1, x2,y2);
- x1 += dx; x2 += dx; y1 += dy; y2 += dy;
- XDrawLine(Tk_Display(tkwin), d, lightGC, x1,y1, x2,y2);
+ for (i=0; i<gripSize; ++i) {
+ XDrawLine(Tk_Display(tkwin), d, (i&1)?lightGC:darkGC, x1,y1, x2,y2);
x1 += dx; x2 += dx; y1 += dy; y2 += dy;
+
}
}
@@ -708,7 +707,7 @@ static void SliderElementSize(
length = thickness = SCROLLBAR_THICKNESS;
TtkGetOrientFromObj(NULL, sb->orientObj, &orient);
- Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &thickness);
+ Tk_GetPixelsFromObj(NULL, tkwin, sb->arrowSizeObj, &thickness);
Tk_GetPixelsFromObj(NULL, tkwin, sb->sliderlengthObj, &length);
if (orient == TTK_ORIENT_VERTICAL) {
*heightPtr = length;
@@ -782,7 +781,7 @@ static void ArrowElementSize(
(void)tkwin;
(void)paddingPtr;
- Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &size);
+ Tk_GetPixelsFromObj(NULL, tkwin, sb->arrowSizeObj, &size);
*widthPtr = *heightPtr = size;
}
diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c
index e2626e5..698f460 100644
--- a/generic/ttk/ttkElements.c
+++ b/generic/ttk/ttkElements.c
@@ -475,11 +475,14 @@ static const Ttk_ElementSpec SeparatorElementSpec = {
typedef struct {
Tcl_Obj *backgroundObj;
+ Tcl_Obj *gripSizeObj;
} SizegripElement;
static const Ttk_ElementOptionSpec SizegripOptions[] = {
{ "-background", TK_OPTION_BORDER,
offsetof(SizegripElement,backgroundObj), DEFAULT_BACKGROUND },
+ { "-gripsize", TK_OPTION_PIXELS,
+ offsetof(SizegripElement,gripSizeObj), "15" },
{0,TK_OPTION_BOOLEAN,0,0}
};
@@ -487,13 +490,14 @@ static void SizegripSize(
void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- int gripCount = 3, gripSpace = 2, gripThickness = 3;
+ SizegripElement *grip = (SizegripElement *)elementRecord;
+ int gripSize = 0;
(void)dummy;
- (void)elementRecord;
(void)tkwin;
(void)paddingPtr;
- *widthPtr = *heightPtr = gripCount * (gripSpace + gripThickness);
+ Tk_GetPixelsFromObj(NULL, tkwin, grip->gripSizeObj, &gripSize);
+ *widthPtr = *heightPtr = gripSize;
}
static void SizegripDraw(
@@ -501,7 +505,8 @@ static void SizegripDraw(
Drawable d, Ttk_Box b, Ttk_State state)
{
SizegripElement *grip = (SizegripElement *)elementRecord;
- int gripCount = 3, gripSpace = 2;
+ int gripSize = 0;
+ int gripCount = 3, gripSpace, gripThickness;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, grip->backgroundObj);
GC lightGC = Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC);
GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC);
@@ -509,11 +514,15 @@ static void SizegripDraw(
(void)dummy;
(void)state;
+ Tk_GetPixelsFromObj(NULL, tkwin, grip->gripSizeObj, &gripSize);
+ gripThickness = gripSize * 3 / (gripCount * 5);
+ gripSpace = gripSize / 3 - gripThickness;
while (gripCount--) {
x1 -= gripSpace; y2 -= gripSpace;
- XDrawLine(Tk_Display(tkwin), d, darkGC, x1,y1, x2,y2); --x1; --y2;
- XDrawLine(Tk_Display(tkwin), d, darkGC, x1,y1, x2,y2); --x1; --y2;
- XDrawLine(Tk_Display(tkwin), d, lightGC, x1,y1, x2,y2); --x1; --y2;
+ for (int i = 1; i < gripThickness; i++) {
+ XDrawLine(Tk_Display(tkwin), d, darkGC, x1,y1, x2,y2); --x1; --y2;
+ }
+ XDrawLine(Tk_Display(tkwin), d, lightGC, x1,y1, x2,y2); --x1; --y2;
}
}