From dac0d44e8ac09f7ff824c1ff952201122b60245e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 10 May 2024 10:29:55 +0000 Subject: More usage of Tk_GetPixelsFromObj() and TCL_UNUSED(), all backported from Tk 8.7. More TCL_UNUSED --- generic/ttk/ttkButton.c | 31 +++--- generic/ttk/ttkClamTheme.c | 234 +++++++++++++++++++++-------------------- generic/ttk/ttkClassicTheme.c | 76 +++++++------- generic/ttk/ttkDefaultTheme.c | 217 +++++++++++++++++++++++--------------- generic/ttk/ttkElements.c | 84 +++++++++------ generic/ttk/ttkLabel.c | 58 ++++++---- generic/ttk/ttkPanedwindow.c | 9 +- generic/ttk/ttkProgress.c | 33 +++--- generic/ttk/ttkScale.c | 15 +-- generic/ttk/ttkScrollbar.c | 7 +- generic/ttk/ttkSquare.c | 23 ++-- generic/ttk/ttkTrace.c | 10 +- generic/ttk/ttkWidget.c | 5 +- win/tkWinTest.c | 65 ++++-------- win/ttkWinTheme.c | 239 ++++++++++++++++++++++++++++-------------- win/ttkWinXPTheme.c | 70 ++++++++----- 16 files changed, 681 insertions(+), 495 deletions(-) diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c index 92edea2..b096f63 100644 --- a/generic/ttk/ttkButton.c +++ b/generic/ttk/ttkButton.c @@ -91,8 +91,8 @@ static Tk_OptionSpec BaseOptionSpecs[] = * Compatibility/legacy options */ {TK_OPTION_STRING, "-state", "state", "State", - "normal", Tk_Offset(Base,base.stateObj), -1, - 0,0,STATE_CHANGED }, + "normal", Tk_Offset(Base,base.stateObj), -1, + 0,0,STATE_CHANGED }, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; @@ -119,10 +119,11 @@ static void TextVariableChanged(void *clientData, const char *value) } static void -BaseInitialize(Tcl_Interp *dummy, void *recordPtr) +BaseInitialize( + TCL_UNUSED(Tcl_Interp *), + void *recordPtr) { Base *basePtr = (Base *)recordPtr; - (void)dummy; basePtr->base.textVariableTrace = 0; basePtr->base.imageSpec = NULL; @@ -140,16 +141,15 @@ BaseCleanup(void *recordPtr) static void BaseImageChanged( - ClientData clientData, int x, int y, int width, int height, - int imageWidth, int imageHeight) + void *clientData, + TCL_UNUSED(int), + TCL_UNUSED(int), + TCL_UNUSED(int), + TCL_UNUSED(int), + TCL_UNUSED(int), + TCL_UNUSED(int)) { Base *basePtr = (Base *)clientData; - (void)x; - (void)y; - (void)width; - (void)height; - (void)imageWidth; - (void)imageHeight; TtkResizeWidget(&basePtr->core); } @@ -199,12 +199,13 @@ error: } static int -BasePostConfigure(Tcl_Interp *dummy, void *recordPtr, int mask) +BasePostConfigure( + TCL_UNUSED(Tcl_Interp *), + void *recordPtr, + TCL_UNUSED(int)) { Base *basePtr = (Base *)recordPtr; int status = TCL_OK; - (void)dummy; - (void)mask; if (basePtr->base.textVariableTrace) { status = Ttk_FireTrace(basePtr->base.textVariableTrace); diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c index 6dbe315..8c2b33b 100644 --- a/generic/ttk/ttkClamTheme.c +++ b/generic/ttk/ttkClamTheme.c @@ -67,24 +67,24 @@ static void DrawSmoothBorder( if ( outerColorObj && (gc=Ttk_GCForColor(tkwin,outerColorObj,d))) { - XDrawLine(display,d,gc, x1+1,y1, x2-1+w,y1); /* N */ - XDrawLine(display,d,gc, x1+1,y2, x2-1+w,y2); /* S */ - XDrawLine(display,d,gc, x1,y1+1, x1,y2-1+w); /* E */ - XDrawLine(display,d,gc, x2,y1+1, x2,y2-1+w); /* W */ + XDrawLine(display,d,gc, x1+1,y1, x2-1+w,y1); /* N */ + XDrawLine(display,d,gc, x1+1,y2, x2-1+w,y2); /* S */ + XDrawLine(display,d,gc, x1,y1+1, x1,y2-1+w); /* W */ + XDrawLine(display,d,gc, x2,y1+1, x2,y2-1+w); /* E */ } if ( upperColorObj && (gc=Ttk_GCForColor(tkwin,upperColorObj,d))) { - XDrawLine(display,d,gc, x1+1,y1+1, x2-1+w,y1+1); /* N */ - XDrawLine(display,d,gc, x1+1,y1+1, x1+1,y2-1); /* E */ + XDrawLine(display,d,gc, x1+1,y1+1, x2-1+w,y1+1); /* N */ + XDrawLine(display,d,gc, x1+1,y1+1, x1+1,y2-1); /* W */ } if ( lowerColorObj && (gc=Ttk_GCForColor(tkwin,lowerColorObj,d))) { - XDrawLine(display,d,gc, x2-1,y2-1, x1+1-w,y2-1); /* S */ - XDrawLine(display,d,gc, x2-1,y2-1, x2-1,y1+1-w); /* W */ + XDrawLine(display,d,gc, x2-1,y2-1, x1+1-w,y2-1); /* S */ + XDrawLine(display,d,gc, x2-1,y2-1, x2-1,y1+1-w); /* E */ } } @@ -129,14 +129,15 @@ static Ttk_ElementOptionSpec BorderElementOptions[] = { */ static void BorderElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + Ttk_Padding *paddingPtr) { BorderElement *border = (BorderElement*)elementRecord; int borderWidth = 2; - (void)dummy; - (void)widthPtr; - (void)heightPtr; Tk_GetPixelsFromObj(NULL, tkwin, border->borderWidthObj, &borderWidth); if (borderWidth == 1) ++borderWidth; @@ -144,15 +145,17 @@ static void BorderElementSize( } static void BorderElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { BorderElement *border = (BorderElement *)elementRecord; int relief = TK_RELIEF_FLAT; int borderWidth = 2; Tcl_Obj *outer = 0, *upper = 0, *lower = 0; - (void)dummy; - (void)state; Tk_GetReliefFromObj(NULL, border->reliefObj, &relief); Tk_GetPixelsFromObj(NULL, tkwin, border->borderWidthObj, &borderWidth); @@ -212,29 +215,29 @@ static Ttk_ElementOptionSpec FieldElementOptions[] = { }; static void FieldElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + TCL_UNUSED(void *), /* elementRecord */ + TCL_UNUSED(Tk_Window), + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + Ttk_Padding *paddingPtr) { - (void)dummy; - (void)elementRecord; - (void)tkwin; - (void)widthPtr; - (void)heightPtr; - *paddingPtr = Ttk_UniformPadding(2); } static void FieldElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { FieldElement *field = (FieldElement *)elementRecord; Tk_3DBorder bg = Tk_Get3DBorderFromObj(tkwin, field->backgroundObj); Ttk_Box f = Ttk_PadBox(b, Ttk_UniformPadding(2)); Tcl_Obj *outer = field->borderColorObj, *inner = field->lightColorObj; - (void)dummy; - (void)state; DrawSmoothBorder(tkwin, d, b, outer, inner, inner); Tk_Fill3DRectangle( @@ -255,7 +258,7 @@ static Ttk_ElementSpec FieldElementSpec = { */ static void ComboboxFieldElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned state) + Drawable d, Ttk_Box b, Ttk_State state) { FieldElement *field = (FieldElement *)elementRecord; GC gc = Ttk_GCForColor(tkwin,field->borderColorObj,d); @@ -306,14 +309,13 @@ static Ttk_ElementOptionSpec IndicatorElementOptions[] = { }; static void IndicatorElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { IndicatorElement *indicator = (IndicatorElement *)elementRecord; Ttk_Padding margins; int size = 10; - (void)dummy; - (void)paddingPtr; Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins); Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size); @@ -322,7 +324,7 @@ static void IndicatorElementSize( } static void RadioIndicatorElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, + TCL_UNUSED(void *), void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned state) { IndicatorElement *indicator = (IndicatorElement *)elementRecord; @@ -331,7 +333,6 @@ static void RadioIndicatorElementDraw( GC gcu=Ttk_GCForColor(tkwin,indicator->upperColorObj,d); GC gcl=Ttk_GCForColor(tkwin,indicator->lowerColorObj,d); Ttk_Padding padding; - (void)dummy; Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding); b = Ttk_PadBox(b, padding); @@ -351,8 +352,8 @@ static void RadioIndicatorElementDraw( } static void CheckIndicatorElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned state) + TCL_UNUSED(void *), void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, Ttk_State state) { Display *display = Tk_Display(tkwin); IndicatorElement *indicator = (IndicatorElement *)elementRecord; @@ -363,7 +364,6 @@ static void CheckIndicatorElementDraw( GC gcl=Ttk_GCForColor(tkwin,indicator->lowerColorObj,d); Ttk_Padding padding; const int w = WIN32_XDRAWLINE_HACK; - (void)dummy; Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding); b = Ttk_PadBox(b, padding); @@ -431,14 +431,13 @@ static Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = }; static void MenuIndicatorElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { MenuIndicatorElement *indicator = (MenuIndicatorElement *)elementRecord; Ttk_Padding margins; int size = MENUBUTTON_ARROW_SIZE; - (void)dummy; - (void)paddingPtr; Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size); Ttk_GetPaddingFromObj(NULL, tkwin, indicator->paddingObj, &margins); @@ -448,16 +447,15 @@ static void MenuIndicatorElementSize( } static void MenuIndicatorElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, + TCL_UNUSED(Ttk_State)) { MenuIndicatorElement *indicator = (MenuIndicatorElement *)elementRecord; XColor *arrowColor = Tk_GetColorFromObj(tkwin, indicator->colorObj); GC gc = Tk_GCForColor(arrowColor, d); int size = MENUBUTTON_ARROW_SIZE; int width, height; - (void)dummy; - (void)state; Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size); @@ -496,22 +494,21 @@ static Ttk_ElementOptionSpec GripElementOptions[] = { Tk_Offset(GripElement,lightColorObj), LIGHT_COLOR }, { "-bordercolor", TK_OPTION_COLOR, Tk_Offset(GripElement,borderColorObj), DARKEST_COLOR }, - { "-gripcount", TK_OPTION_INT, + { "-gripcount", TK_OPTION_PIXELS, Tk_Offset(GripElement,gripCountObj), "5" }, { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; static void GripElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + int *widthPtr, int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL; GripElement *grip = (GripElement *)elementRecord; int gripCount = 0; - (void)tkwin; - (void)paddingPtr; - Tcl_GetIntFromObj(NULL, grip->gripCountObj, &gripCount); + Tk_GetPixelsFromObj(NULL, tkwin, grip->gripCountObj, &gripCount); if (horizontal) { *widthPtr = 2*gripCount; } else { @@ -521,7 +518,8 @@ static void GripElementSize( static void GripElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned state) + Drawable d, Ttk_Box b, + TCL_UNUSED(Ttk_State)) { const int w = WIN32_XDRAWLINE_HACK; int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL; @@ -531,7 +529,7 @@ static void GripElementDraw( int gripPad = 1, gripCount = 0; int i; - Tcl_GetIntFromObj(NULL, grip->gripCountObj, &gripCount); + Tk_GetPixelsFromObj(NULL, tkwin, grip->gripCountObj, &gripCount); if (horizontal) { int x = b.x + b.width / 2 - gripCount; @@ -595,22 +593,24 @@ static Ttk_ElementOptionSpec ScrollbarElementOptions[] = { Tk_Offset(ScrollbarElement,arrowColorObj), "#000000" }, { "-arrowsize", TK_OPTION_PIXELS, Tk_Offset(ScrollbarElement,arrowSizeObj), STR(SCROLLBAR_THICKNESS) }, - { "-gripcount", TK_OPTION_INT, + { "-gripcount", TK_OPTION_PIXELS, Tk_Offset(ScrollbarElement,gripCountObj), "5" }, - { "-sliderlength", TK_OPTION_INT, + { "-sliderlength", TK_OPTION_PIXELS, Tk_Offset(ScrollbarElement,sliderlengthObj), "30" }, { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; static void TroughElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { ScrollbarElement *sb = (ScrollbarElement *)elementRecord; GC gcb = Ttk_GCForColor(tkwin,sb->borderColorObj,d); GC gct = Ttk_GCForColor(tkwin,sb->troughColorObj,d); - (void)dummy; - (void)state; XFillRectangle(Tk_Display(tkwin), d, gct, b.x, b.y, b.width-1, b.height-1); XDrawRectangle(Tk_Display(tkwin), d, gcb, b.x, b.y, b.width-1, b.height-1); @@ -625,22 +625,27 @@ static Ttk_ElementSpec TroughElementSpec = { }; static void ThumbElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { ScrollbarElement *sb = (ScrollbarElement *)elementRecord; int size = SCROLLBAR_THICKNESS; - (void)dummy; - (void)tkwin; - (void)paddingPtr; - Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &size); + Tk_GetPixelsFromObj(NULL, tkwin, sb->arrowSizeObj, &size); *widthPtr = *heightPtr = size; } static void ThumbElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { ScrollbarElement *sb = (ScrollbarElement *)elementRecord; int gripCount = 0; @@ -648,8 +653,6 @@ static void ThumbElementDraw( GC lightGC, darkGC; int x1, y1, x2, y2, dx, dy, i; const int w = WIN32_XDRAWLINE_HACK; - (void)dummy; - (void)state; DrawSmoothBorder(tkwin, d, b, sb->borderColorObj, sb->lightColorObj, sb->darkColorObj); @@ -661,7 +664,7 @@ static void ThumbElementDraw( * Draw grip: */ Ttk_GetOrientFromObj(NULL, sb->orientObj, &orient); - Tcl_GetIntFromObj(NULL, sb->gripCountObj, &gripCount); + Tk_GetPixelsFromObj(NULL, tkwin, sb->gripCountObj, &gripCount); lightGC = Ttk_GCForColor(tkwin,sb->lightColorObj,d); darkGC = Ttk_GCForColor(tkwin,sb->borderColorObj,d); @@ -697,18 +700,20 @@ static Ttk_ElementSpec ThumbElementSpec = { * +++ Slider element. */ static void SliderElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { ScrollbarElement *sb = (ScrollbarElement *)elementRecord; int length, thickness; int orient; - (void)dummy; - (void)paddingPtr; length = thickness = SCROLLBAR_THICKNESS; Ttk_GetOrientFromObj(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; @@ -717,7 +722,6 @@ static void SliderElementSize( *heightPtr = thickness; *widthPtr = length; } - } static Ttk_ElementSpec SliderElementSpec = { @@ -743,12 +747,14 @@ static void PbarElementSize( } static void PbarElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { ScrollbarElement *sb = (ScrollbarElement *)elementRecord; - (void)dummy; - (void)state; b = Ttk_PadBox(b, Ttk_UniformPadding(2)); if (b.width > 4 && b.height > 4) { @@ -768,7 +774,6 @@ static Ttk_ElementSpec PbarElementSpec = { PbarElementDraw }; - /*------------------------------------------------------------------------ * +++ Scrollbar arrows. */ @@ -776,16 +781,15 @@ static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT }; static void ArrowElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + int *widthPtr, int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { ScrollbarElement *sb = (ScrollbarElement *)elementRecord; ArrowDirection direction = *(ArrowDirection*)clientData; Ttk_Padding padding = Ttk_UniformPadding(3); int size = SCROLLBAR_THICKNESS; - (void)tkwin; - (void)paddingPtr; - Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &size); + Tk_GetPixelsFromObj(NULL, tkwin, sb->arrowSizeObj, &size); size -= Ttk_PaddingWidth(padding); TtkArrowSize(size/2, direction, widthPtr, heightPtr); *widthPtr += Ttk_PaddingWidth(padding); @@ -799,7 +803,8 @@ static void ArrowElementSize( static void ArrowElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned state) + Drawable d, Ttk_Box b, + TCL_UNUSED(Ttk_State)) { ScrollbarElement *sb = (ScrollbarElement *)elementRecord; ArrowDirection direction = *(ArrowDirection*)clientData; @@ -848,21 +853,19 @@ static Ttk_ElementSpec ArrowElementSpec = { /* * Modified arrow element for spinboxes: - * The width and height are different. + * The width and height are different. */ - static void SpinboxArrowElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + int *widthPtr, int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { ScrollbarElement *sb = (ScrollbarElement *)elementRecord; ArrowDirection direction = *(ArrowDirection*)clientData; Ttk_Padding padding = Ttk_UniformPadding(3); int size = 10; - (void)tkwin; - (void)paddingPtr; - Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &size); + Tk_GetPixelsFromObj(NULL, tkwin, sb->arrowSizeObj, &size); size -= Ttk_PaddingWidth(padding); TtkArrowSize(size/2, direction, widthPtr, heightPtr); *widthPtr += Ttk_PaddingWidth(padding); @@ -904,17 +907,16 @@ static Ttk_ElementOptionSpec NotebookElementOptions[] = { }; static void TabElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + TCL_UNUSED(void *), /* elementRecord */ + Tk_Window tkwin, + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + Ttk_Padding *paddingPtr) { Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; int borderWidth = 2; - (void)dummy; - (void)elementRecord; - (void)tkwin; - (void)widthPtr; - (void)heightPtr; if (mainInfoPtr != NULL) { nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; @@ -939,8 +941,12 @@ static void TabElementSize( } static void TabElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + Ttk_State state) { Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; @@ -951,7 +957,6 @@ static void TabElementDraw( int x1, y1, x2, y2; GC gc; const int w = WIN32_XDRAWLINE_HACK; - (void)dummy; if (mainInfoPtr != NULL) { nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit; @@ -1063,28 +1068,29 @@ static Ttk_ElementSpec TabElementSpec = }; static void ClientElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + TCL_UNUSED(void *), /* elementRecord */ + TCL_UNUSED(Tk_Window), + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + Ttk_Padding *paddingPtr) { int borderWidth = 2; - (void)dummy; - (void)elementRecord; - (void)tkwin; - (void)widthPtr; - (void)heightPtr; *paddingPtr = Ttk_UniformPadding((short)borderWidth); } static void ClientElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { NotebookElement *ce = (NotebookElement *)elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, ce->backgroundObj); int borderWidth = 2; - (void)dummy; - (void)state; Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth,TK_RELIEF_FLAT); diff --git a/generic/ttk/ttkClassicTheme.c b/generic/ttk/ttkClassicTheme.c index 8436aec..854ef78 100644 --- a/generic/ttk/ttkClassicTheme.c +++ b/generic/ttk/ttkClassicTheme.c @@ -30,32 +30,33 @@ static Ttk_ElementOptionSpec HighlightElementOptions[] = { }; static void HighlightElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + Ttk_Padding *paddingPtr) { HighlightElement *hl = (HighlightElement *)elementRecord; int highlightThickness = 0; - (void)dummy; - (void)tkwin; - (void)widthPtr; - (void)heightPtr; - Tcl_GetIntFromObj(NULL,hl->highlightThicknessObj,&highlightThickness); + Tk_GetPixelsFromObj(NULL, tkwin, hl->highlightThicknessObj, &highlightThickness); *paddingPtr = Ttk_UniformPadding((short)highlightThickness); } static void HighlightElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + TCL_UNUSED(Ttk_Box), + TCL_UNUSED(Ttk_State)) { HighlightElement *hl = (HighlightElement *)elementRecord; int highlightThickness = 0; XColor *highlightColor = Tk_GetColorFromObj(tkwin, hl->highlightColorObj); - (void)dummy; - (void)b; - (void)state; - Tcl_GetIntFromObj(NULL,hl->highlightThicknessObj,&highlightThickness); + Tk_GetPixelsFromObj(NULL, tkwin, hl->highlightThicknessObj, &highlightThickness); if (highlightColor && highlightThickness > 0) { GC gc = Tk_GCForColor(highlightColor, d); Tk_DrawFocusHighlight(tkwin, gc, highlightThickness, d); @@ -102,18 +103,18 @@ static Ttk_ElementOptionSpec ButtonBorderElementOptions[] = }; static void ButtonBorderElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + Ttk_Padding *paddingPtr) { ButtonBorderElement *bd = (ButtonBorderElement *)elementRecord; int defaultState = TTK_BUTTON_DEFAULT_DISABLED; int borderWidth = 0; - (void)dummy; - (void)tkwin; - (void)widthPtr; - (void)heightPtr; - Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, bd->borderWidthObj, &borderWidth); Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState); if (defaultState != TTK_BUTTON_DEFAULT_DISABLED) { @@ -128,22 +129,24 @@ static void ButtonBorderElementSize( * when the button is active.) */ static void ButtonBorderElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { ButtonBorderElement *bd = (ButtonBorderElement *)elementRecord; Tk_3DBorder border = NULL; int borderWidth = 1, relief = TK_RELIEF_FLAT; int defaultState = TTK_BUTTON_DEFAULT_DISABLED; int inset = 0; - (void)dummy; - (void)state; /* * Get option values. */ border = Tk_Get3DBorderFromObj(tkwin, bd->borderObj); - Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, bd->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, bd->reliefObj, &relief); Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState); @@ -221,13 +224,15 @@ static Ttk_ElementOptionSpec ArrowElementOptions[] = }; static void ArrowElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { ArrowElement *arrow = (ArrowElement *)elementRecord; int size = 12; - (void)dummy; - (void)paddingPtr; Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size); *widthPtr = *heightPtr = size; @@ -235,7 +240,8 @@ static void ArrowElementSize( static void ArrowElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + Drawable d, Ttk_Box b, + TCL_UNUSED(Ttk_State)) { int direction = *(int *)clientData; ArrowElement *arrow = (ArrowElement *)elementRecord; @@ -244,12 +250,10 @@ static void ArrowElementDraw( int relief = TK_RELIEF_RAISED; int size = b.width < b.height ? b.width : b.height; XPoint points[3]; - (void)state; Tk_GetPixelsFromObj(NULL, tkwin, arrow->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief); - /* * @@@ There are off-by-one pixel errors in the way these are drawn; * @@@ need to take a look at Tk_Fill3DPolygon and X11 to find the @@ -337,12 +341,12 @@ static Ttk_ElementOptionSpec SashOptions[] = { static void SashElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + int *widthPtr, int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { SashElement *sash = (SashElement *)elementRecord; int sashPad = 2, sashThickness = 6, handleSize = 8; int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL; - (void)paddingPtr; Tk_GetPixelsFromObj(NULL, tkwin, sash->sashThicknessObj, &sashThickness); Tk_GetPixelsFromObj(NULL, tkwin, sash->handleSizeObj, &handleSize); @@ -359,7 +363,8 @@ static void SashElementSize( static void SashElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, Ttk_State state) + Drawable d, Ttk_Box b, + TCL_UNUSED(Ttk_State)) { SashElement *sash = (SashElement *)elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, sash->borderObj); @@ -368,7 +373,6 @@ static void SashElementDraw( int handleSize = 8, handlePad = 8; int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL; Ttk_Box hb; - (void)state; Tk_GetPixelsFromObj(NULL, tkwin, sash->handleSizeObj, &handleSize); Tk_GetPixelsFromObj(NULL, tkwin, sash->handlePadObj, &handlePad); diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c index b551a83..302e872 100644 --- a/generic/ttk/ttkDefaultTheme.c +++ b/generic/ttk/ttkDefaultTheme.c @@ -108,7 +108,7 @@ static void DrawBorder( break; default: /* Fall back to Motif-style borders: */ Tk_Draw3DRectangle(tkwin, d, border, - b.x, b.y, b.width, b.height, borderWidth,relief); + b.x, b.y, b.width, b.height, borderWidth, relief); break; } } @@ -138,11 +138,11 @@ static void DrawFieldBorder( * ArrowPoints -- * Compute points of arrow polygon. */ -static void ArrowPoints(Ttk_Box b, ArrowDirection dir, XPoint points[4]) +static void ArrowPoints(Ttk_Box b, ArrowDirection direction, XPoint points[4]) { int cx, cy, h; - switch (dir) { + switch (direction) { case ARROW_UP: h = (b.width - 1)/2; cx = b.x + h; @@ -186,9 +186,9 @@ static void ArrowPoints(Ttk_Box b, ArrowDirection dir, XPoint points[4]) } /*public*/ -void TtkArrowSize(int h, ArrowDirection dir, int *widthPtr, int *heightPtr) +void TtkArrowSize(int h, ArrowDirection direction, int *widthPtr, int *heightPtr) { - switch (dir) { + switch (direction) { case ARROW_UP: case ARROW_DOWN: *widthPtr = 2*h+1; *heightPtr = h+1; break; case ARROW_LEFT: @@ -202,10 +202,10 @@ void TtkArrowSize(int h, ArrowDirection dir, int *widthPtr, int *heightPtr) */ /*public*/ void TtkFillArrow( - Display *display, Drawable d, GC gc, Ttk_Box b, ArrowDirection dir) + Display *display, Drawable d, GC gc, Ttk_Box b, ArrowDirection direction) { XPoint points[4]; - ArrowPoints(b, dir, points); + ArrowPoints(b, direction, points); XFillPolygon(display, d, gc, points, 3, Convex, CoordModeOrigin); XDrawLines(display, d, gc, points, 4, CoordModeOrigin); @@ -215,10 +215,10 @@ void TtkFillArrow( /*public*/ void TtkDrawArrow( - Display *display, Drawable d, GC gc, Ttk_Box b, ArrowDirection dir) + Display *display, Drawable d, GC gc, Ttk_Box b, ArrowDirection direction) { XPoint points[4]; - ArrowPoints(b, dir, points); + ArrowPoints(b, direction, points); XDrawLines(display, d, gc, points, 4, CoordModeOrigin); /* Work around bug [77527326e5] - ttk artifacts on Ubuntu */ @@ -251,22 +251,26 @@ static Ttk_ElementOptionSpec BorderElementOptions[] = { Tk_Offset(BorderElement,borderColorObj), "black" }, { "-default", TK_OPTION_ANY, Tk_Offset(BorderElement,defaultStateObj), "disabled" }, - { "-borderwidth",TK_OPTION_PIXELS,Tk_Offset(BorderElement,borderWidthObj), + { "-borderwidth",TK_OPTION_PIXELS, Tk_Offset(BorderElement,borderWidthObj), STRINGIFY(BORDERWIDTH) }, { "-relief", TK_OPTION_RELIEF, Tk_Offset(BorderElement,reliefObj), "flat" }, - { NULL, 0, 0, NULL } + { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; static void BorderElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + Ttk_Padding *paddingPtr) { - BorderElement *bd = elementRecord; + BorderElement *bd = (BorderElement *)elementRecord; int borderWidth = 0; int defaultState = TTK_BUTTON_DEFAULT_DISABLED; - Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, bd->borderWidthObj, &borderWidth); Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState); if (defaultState != TTK_BUTTON_DEFAULT_DISABLED) { @@ -277,10 +281,14 @@ static void BorderElementSize( } static void BorderElementDraw( - void *clientData, void *elementRecord, - Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { - BorderElement *bd = elementRecord; + BorderElement *bd = (BorderElement *)elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, bd->borderObj); XColor *borderColor = Tk_GetColorFromObj(tkwin, bd->borderColorObj); int borderWidth = 2; @@ -290,7 +298,7 @@ static void BorderElementDraw( /* * Get option values. */ - Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, bd->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, bd->reliefObj, &relief); Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState); @@ -329,21 +337,26 @@ static Ttk_ElementOptionSpec FieldElementOptions[] = { "white" }, { "-bordercolor",TK_OPTION_COLOR, Tk_Offset(FieldElement,borderColorObj), "black" }, - { NULL, 0, 0, NULL } + { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; static void FieldElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + TCL_UNUSED(void *), /* elementRecord */ + TCL_UNUSED(Tk_Window), + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + Ttk_Padding *paddingPtr) { *paddingPtr = Ttk_UniformPadding(2); } static void FieldElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, Ttk_State state) { - FieldElement *field = elementRecord; + FieldElement *field = (FieldElement *)elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, field->borderObj); XColor *borderColor = Tk_GetColorFromObj(tkwin, field->borderColorObj); @@ -480,15 +493,16 @@ static Ttk_ElementOptionSpec IndicatorElementOptions[] = { Tk_Offset(IndicatorElement,borderColorObj), "black" }, { "-indicatormargin", TK_OPTION_STRING, Tk_Offset(IndicatorElement,marginObj), "0 2 4 2" }, - { NULL, 0, 0, NULL } + { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; static void IndicatorElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + int *widthPtr, int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { - IndicatorSpec *spec = clientData; - IndicatorElement *indicator = elementRecord; + IndicatorSpec *spec = (IndicatorSpec *)clientData; + IndicatorElement *indicator = (IndicatorElement *)elementRecord; Ttk_Padding margins; Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins); *widthPtr = spec->width + Ttk_PaddingWidth(margins); @@ -657,14 +671,14 @@ static Ttk_ElementOptionSpec ArrowElementOptions[] = { { "-arrowsize", TK_OPTION_PIXELS, Tk_Offset(ArrowElement,sizeObj), STRINGIFY(SCROLLBAR_WIDTH) }, { "-arrowcolor", TK_OPTION_COLOR, - Tk_Offset(ArrowElement,colorObj),"black"}, + Tk_Offset(ArrowElement,colorObj), "black"}, { "-background", TK_OPTION_BORDER, Tk_Offset(ArrowElement,borderObj), DEFAULT_BACKGROUND }, { "-bordercolor", TK_OPTION_COLOR, Tk_Offset(ArrowElement,borderColorObj), "black" }, { "-relief", TK_OPTION_RELIEF, - Tk_Offset(ArrowElement,reliefObj),"raised"}, - { NULL, 0, 0, NULL } + Tk_Offset(ArrowElement,reliefObj), "raised"}, + { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; /* @@ -676,9 +690,10 @@ static Ttk_Padding ArrowPadding = { 3,3,4,4 }; static void ArrowElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + int *widthPtr, int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { - ArrowElement *arrow = elementRecord; + ArrowElement *arrow = (ArrowElement *)elementRecord; int direction = *(int *)clientData; int size = SCROLLBAR_WIDTH; @@ -696,9 +711,10 @@ static void ArrowElementSize( static void ArrowElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + Drawable d, Ttk_Box b, + TCL_UNUSED(Ttk_State)) { - ArrowElement *arrow = elementRecord; + ArrowElement *arrow = (ArrowElement *)elementRecord; int direction = *(int *)clientData; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj); XColor *borderColor = Tk_GetColorFromObj(tkwin, arrow->borderColorObj); @@ -747,15 +763,16 @@ static Ttk_ElementSpec ArrowElementSpec = { /* * Modified arrow element for comboboxes and spinboxes: - * The width and height are different, and the left edge is drawn in the + * The width and height are different, and the left edge is drawn in the * same color as the inner part of the right one. */ static void BoxArrowElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + int *widthPtr, int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { - ArrowElement *arrow = elementRecord; + ArrowElement *arrow = (ArrowElement *)elementRecord; int direction = *(int *)clientData; int size = SCROLLBAR_WIDTH; @@ -768,9 +785,10 @@ static void BoxArrowElementSize( static void BoxArrowElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + Drawable d, Ttk_Box b, + TCL_UNUSED(Ttk_State)) { - ArrowElement *arrow = elementRecord; + ArrowElement *arrow = (ArrowElement *)elementRecord; int direction = *(int *)clientData; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj); XColor *borderColor = Tk_GetColorFromObj(tkwin, arrow->borderColorObj); @@ -782,8 +800,8 @@ static void BoxArrowElementDraw( XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj); GC arrowGC = Tk_GCForColor(arrowColor, d); - Tk_Fill3DRectangle( - tkwin, d, border, b.x, b.y, b.width, b.height, 0, TK_RELIEF_FLAT); + Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height, + 0, TK_RELIEF_FLAT); DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief); XDrawLine(disp, d, darkGC, b.x, b.y+1, b.x, b.y+b.height-2+w); @@ -831,18 +849,22 @@ static Ttk_ElementOptionSpec MenubuttonArrowElementOptions[] = { Tk_Offset(MenubuttonArrowElement,directionObj), "below" }, { "-arrowsize", TK_OPTION_PIXELS, Tk_Offset(MenubuttonArrowElement,sizeObj), STRINGIFY(MENUBUTTON_ARROW_SIZE)}, - { "-arrowcolor",TK_OPTION_COLOR, + { "-arrowcolor", TK_OPTION_COLOR, Tk_Offset(MenubuttonArrowElement,colorObj), "black"}, - { NULL, 0, 0, NULL } + { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; static Ttk_Padding MenubuttonArrowPadding = { 3, 0, 3, 0 }; static void MenubuttonArrowElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { - MenubuttonArrowElement *arrow = elementRecord; + MenubuttonArrowElement *arrow = (MenubuttonArrowElement *)elementRecord; int size = MENUBUTTON_ARROW_SIZE; Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size); *widthPtr = *heightPtr = 2 * size + 1; @@ -851,10 +873,14 @@ static void MenubuttonArrowElementSize( } static void MenubuttonArrowElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { - MenubuttonArrowElement *arrow = elementRecord; + MenubuttonArrowElement *arrow = (MenubuttonArrowElement *)elementRecord; XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj); GC gc = Tk_GCForColor(arrowColor, d); int size = MENUBUTTON_ARROW_SIZE; @@ -997,17 +1023,23 @@ static Ttk_ElementOptionSpec ThumbElementOptions[] = { DEFAULT_BACKGROUND }, { "-bordercolor", TK_OPTION_COLOR, Tk_Offset(ThumbElement,borderColorObj), "black" }, - { "-relief", TK_OPTION_RELIEF,Tk_Offset(ThumbElement,reliefObj),"raised" }, - { "-orient", TK_OPTION_ANY,Tk_Offset(ThumbElement,orientObj),"horizontal"}, - { NULL, 0, 0, NULL } + { "-relief", TK_OPTION_RELIEF, Tk_Offset(ThumbElement,reliefObj),"raised" }, + { "-orient", TK_OPTION_ANY, Tk_Offset(ThumbElement,orientObj),"horizontal"}, + { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; static void ThumbElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { - ThumbElement *thumb = elementRecord; - int orient, size; + ThumbElement *thumb = (ThumbElement *)elementRecord; + int orient; + int size; + Tk_GetPixelsFromObj(NULL, tkwin, thumb->sizeObj, &size); Ttk_GetOrientFromObj(NULL, thumb->orientObj, &orient); @@ -1021,10 +1053,14 @@ static void ThumbElementSize( } static void ThumbElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { - ThumbElement *thumb = elementRecord; + ThumbElement *thumb = (ThumbElement *)elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, thumb->borderObj); XColor *borderColor = Tk_GetColorFromObj(tkwin, thumb->borderColorObj); int relief = TK_RELIEF_RAISED; @@ -1073,7 +1109,7 @@ typedef struct { } SliderElement; static Ttk_ElementOptionSpec SliderElementOptions[] = { - { "-sliderthickness",TK_OPTION_PIXELS,Tk_Offset(SliderElement,thicknessObj), + { "-sliderthickness", TK_OPTION_PIXELS, Tk_Offset(SliderElement,thicknessObj), "15" }, { "-sliderrelief", TK_OPTION_RELIEF, Tk_Offset(SliderElement,reliefObj), "raised" }, @@ -1085,15 +1121,20 @@ static Ttk_ElementOptionSpec SliderElementOptions[] = { STRINGIFY(BORDERWIDTH) }, { "-orient", TK_OPTION_ANY, Tk_Offset(SliderElement,orientObj), "horizontal" }, - { NULL, 0, 0, NULL } + { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; static void SliderElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { - SliderElement *slider = elementRecord; - int orient, thickness, borderWidth; + SliderElement *slider = (SliderElement *)elementRecord; + int orient; + int thickness, borderWidth; Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient); Tk_GetPixelsFromObj(NULL, tkwin, slider->thicknessObj, &thickness); @@ -1104,7 +1145,6 @@ static void SliderElementSize( *widthPtr = thickness + (borderWidth *2); *heightPtr = *widthPtr/2; break; - case TTK_ORIENT_HORIZONTAL: *heightPtr = thickness + (borderWidth *2); *widthPtr = *heightPtr/2; @@ -1113,10 +1153,14 @@ static void SliderElementSize( } static void SliderElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { - SliderElement *slider = elementRecord; + SliderElement *slider = (SliderElement *)elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, slider->borderObj); XColor *borderColor = Tk_GetColorFromObj(tkwin, slider->borderColorObj); int relief = TK_RELIEF_RAISED, borderWidth = 2; @@ -1158,28 +1202,33 @@ static Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = { Tk_Offset(TreeitemIndicator,diameterObj), "9" }, { "-indicatormargins", TK_OPTION_STRING, Tk_Offset(TreeitemIndicator,marginObj), "2 2 4 2" }, - { NULL, 0, 0, NULL } + { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; static void TreeitemIndicatorSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { - TreeitemIndicator *indicator = elementRecord; - int diameter = 0; + TreeitemIndicator *indicator = (TreeitemIndicator *)elementRecord; + int size = 0; Ttk_Padding margins; - Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &diameter); + Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &size); Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins); - *widthPtr = diameter + Ttk_PaddingWidth(margins); - *heightPtr = diameter + Ttk_PaddingHeight(margins); + *widthPtr = size + Ttk_PaddingWidth(margins); + *heightPtr = size + Ttk_PaddingHeight(margins); } static void TreeitemIndicatorDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { - TreeitemIndicator *indicator = elementRecord; + TreeitemIndicator *indicator = (TreeitemIndicator *)elementRecord; XColor *color = Tk_GetColorFromObj(tkwin, indicator->colorObj); GC gc = Tk_GCForColor(color, d); Ttk_Padding padding = Ttk_UniformPadding(0); @@ -1230,9 +1279,9 @@ MODULE_SCOPE int TtkAltTheme_Init(Tcl_Interp *interp) Ttk_RegisterElement(interp, theme, "border", &BorderElementSpec, NULL); Ttk_RegisterElement(interp, theme, "Checkbutton.indicator", - &IndicatorElementSpec, &checkbutton_spec); + &IndicatorElementSpec, (void *)&checkbutton_spec); Ttk_RegisterElement(interp, theme, "Radiobutton.indicator", - &IndicatorElementSpec, &radiobutton_spec); + &IndicatorElementSpec, (void *)&radiobutton_spec); Ttk_RegisterElement(interp, theme, "Menubutton.indicator", &MenubuttonArrowElementSpec, NULL); @@ -1260,7 +1309,7 @@ MODULE_SCOPE int TtkAltTheme_Init(Tcl_Interp *interp) &ArrowElementSpec, &ArrowElements[0]); Ttk_RegisterElement(interp, theme, "Treeitem.indicator", - &TreeitemIndicatorElementSpec, 0); + &TreeitemIndicatorElementSpec, NULL); Tcl_PkgProvide(interp, "ttk::theme::alt", TTK_VERSION); diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c index beb3225..19bd71a 100644 --- a/generic/ttk/ttkElements.c +++ b/generic/ttk/ttkElements.c @@ -25,19 +25,27 @@ * and may be used in other engines. */ -/* public */ Ttk_ElementOptionSpec TtkNullElementOptions[] = { { NULL, 0, 0, NULL } }; +/* public */ Ttk_ElementOptionSpec TtkNullElementOptions[] = { { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; /* public */ void TtkNullElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + TCL_UNUSED(void *), /* elementRecord */ + TCL_UNUSED(Tk_Window), + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + TCL_UNUSED(Ttk_Padding *)) { } /* public */ void TtkNullElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + TCL_UNUSED(void *), /* elementRecord */ + TCL_UNUSED(Tk_Window), + TCL_UNUSED(Drawable), + TCL_UNUSED(Ttk_Box), + TCL_UNUSED(Ttk_State)) { } @@ -131,7 +139,7 @@ static void BorderElementSize( { BorderElement *bd = elementRecord; int borderWidth = 0; - Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, bd->borderWidthObj, &borderWidth); *paddingPtr = Ttk_UniformPadding((short)borderWidth); } @@ -144,7 +152,7 @@ static void BorderElementDraw( int borderWidth = 1, relief = TK_RELIEF_FLAT; border = Tk_Get3DBorderFromObj(tkwin, bd->borderObj); - Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, bd->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, bd->reliefObj, &relief); if (border && borderWidth > 0 && relief != TK_RELIEF_FLAT) { @@ -307,7 +315,7 @@ static void FocusElementSize( FocusElement *focus = elementRecord; int focusThickness = 0; - Tcl_GetIntFromObj(NULL, focus->focusThicknessObj, &focusThickness); + Tk_GetPixelsFromObj(NULL, tkwin, focus->focusThicknessObj, &focusThickness); *paddingPtr = Ttk_UniformPadding((short)focusThickness); } @@ -319,7 +327,7 @@ static void FocusElementDraw( int focusThickness = 0; if (state & TTK_STATE_FOCUS) { - Tcl_GetIntFromObj(NULL,focus->focusThicknessObj,&focusThickness); + Tk_GetPixelsFromObj(NULL, tkwin, focus->focusThicknessObj, &focusThickness); DrawFocusRing(tkwin, d, focus->focusColorObj, b); } } @@ -542,7 +550,7 @@ static void SquareIndicatorElementDraw( interior = Tk_Get3DBorderFromObj(tkwin, indicator->colorObj); border = Tk_Get3DBorderFromObj(tkwin, indicator->backgroundObj); - Tcl_GetIntFromObj(NULL,indicator->borderWidthObj,&borderWidth); + Tk_GetPixelsFromObj(NULL,tkwin, indicator->borderWidthObj,&borderWidth); Tk_GetReliefFromObj(NULL,indicator->reliefObj,&relief); Ttk_GetPaddingFromObj(NULL,tkwin,indicator->marginObj,&padding); @@ -585,7 +593,7 @@ static void DiamondIndicatorElementDraw( interior = Tk_Get3DBorderFromObj(tkwin, indicator->colorObj); border = Tk_Get3DBorderFromObj(tkwin, indicator->backgroundObj); - Tcl_GetIntFromObj(NULL,indicator->borderWidthObj,&borderWidth); + Tk_GetPixelsFromObj(NULL,tkwin, indicator->borderWidthObj,&borderWidth); Tk_GetReliefFromObj(NULL,indicator->reliefObj,&relief); Ttk_GetPaddingFromObj(NULL,tkwin,indicator->marginObj,&padding); @@ -1190,15 +1198,18 @@ typedef struct { static Ttk_ElementOptionSpec TabElementOptions[] = { { "-borderwidth", TK_OPTION_PIXELS, - Tk_Offset(TabElement,borderWidthObj),"1" }, + Tk_Offset(TabElement,borderWidthObj), "1" }, { "-background", TK_OPTION_BORDER, Tk_Offset(TabElement,backgroundObj), DEFAULT_BACKGROUND }, - {0,0,0,0} + {0,TK_OPTION_BOOLEAN,0,0} }; static void TabElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, Tk_Window tkwin, + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + Ttk_Padding *paddingPtr) { TabElement *tab = (TabElement *)elementRecord; int borderWidth = 1; @@ -1230,8 +1241,9 @@ static void TabElementSize( } static void TabElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, Ttk_State state) { Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; @@ -1323,7 +1335,7 @@ static void TabElementDraw( break; } - Tcl_GetIntFromObj(NULL, tab->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, tab->borderWidthObj, &borderWidth); while (borderWidth--) { XDrawLines(disp, d, Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC), pts, 4, CoordModeOrigin); @@ -1367,30 +1379,36 @@ static Ttk_ElementSpec TabElementSpec = { typedef TabElement ClientElement; #define ClientElementOptions TabElementOptions +static void ClientElementSize( + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, Tk_Window tkwin, + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + Ttk_Padding *paddingPtr) +{ + ClientElement *ce = (ClientElement *)elementRecord; + int borderWidth = 1; + + Tk_GetPixelsFromObj(0, tkwin, ce->borderWidthObj, &borderWidth); + *paddingPtr = Ttk_UniformPadding((short)borderWidth); +} + static void ClientElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, + TCL_UNUSED(Ttk_State)) { - ClientElement *ce = elementRecord; + ClientElement *ce = (ClientElement *)elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, ce->backgroundObj); int borderWidth = 1; - Tcl_GetIntFromObj(NULL, ce->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, ce->borderWidthObj, &borderWidth); Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth,TK_RELIEF_RAISED); } -static void ClientElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) -{ - ClientElement *ce = elementRecord; - int borderWidth = 1; - Tk_GetPixelsFromObj(0, tkwin, ce->borderWidthObj, &borderWidth); - *paddingPtr = Ttk_UniformPadding((short)borderWidth); -} - static Ttk_ElementSpec ClientElementSpec = { TK_STYLE_VERSION_2, sizeof(ClientElement), @@ -1429,7 +1447,7 @@ void TtkElements_Init(Tcl_Interp *interp) Ttk_RegisterElement(interp, theme, "Menubutton.indicator", &MenuIndicatorElementSpec, NULL); - Ttk_RegisterElement(interp, theme, "indicator", &ttkNullElementSpec,NULL); + Ttk_RegisterElement(interp, theme, "indicator", &ttkNullElementSpec, NULL); Ttk_RegisterElement(interp, theme, "uparrow", &ArrowElementSpec, &ArrowElements[0]); diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c index 54ecabd..850ad2b 100644 --- a/generic/ttk/ttkLabel.c +++ b/generic/ttk/ttkLabel.c @@ -193,12 +193,14 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b) } static void TextElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { TextElement *text = (TextElement *)elementRecord; - (void)dummy; - (void)paddingPtr; if (!TextSetup(text, tkwin)) return; @@ -212,12 +214,14 @@ static void TextElementSize( } static void TextElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, Ttk_State state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { TextElement *text = (TextElement *)elementRecord; - (void)dummy; - (void)state; if (TextSetup(text, tkwin)) { TextDraw(text, tkwin, d, b); @@ -365,12 +369,14 @@ static void ImageDraw( } static void ImageElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { ImageElement *image = (ImageElement *)elementRecord; - (void)dummy; - (void)paddingPtr; if (ImageSetup(image, tkwin, 0)) { *widthPtr = image->width; @@ -380,11 +386,14 @@ static void ImageElementSize( } static void ImageElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, Ttk_State state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + Ttk_State state) { ImageElement *image = (ImageElement *)elementRecord; - (void)dummy; if (ImageSetup(image, tkwin, state)) { ImageDraw(image, tkwin, d, b, state); @@ -569,13 +578,15 @@ static void LabelCleanup(LabelElement *c) } static void LabelElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { LabelElement *label = (LabelElement *)elementRecord; int textReqWidth = 0; - (void)dummy; - (void)paddingPtr; LabelSetup(label, tkwin, 0); @@ -628,12 +639,15 @@ static void DrawCompound( } static void LabelElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, Ttk_State state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + Ttk_State state) { LabelElement *l = (LabelElement *)elementRecord; Tk_Anchor anchor = TK_ANCHOR_CENTER; - (void)dummy; LabelSetup(l, tkwin, state); diff --git a/generic/ttk/ttkPanedwindow.c b/generic/ttk/ttkPanedwindow.c index 133de96..eae99a2 100644 --- a/generic/ttk/ttkPanedwindow.c +++ b/generic/ttk/ttkPanedwindow.c @@ -733,11 +733,10 @@ static int PanedIdentifyCommand( return TCL_ERROR; } - if ( Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK - || Tcl_GetIntFromObj(interp, objv[objc-1], &y) != TCL_OK - || (objc == 5 && Tcl_GetIndexFromObjStruct(interp, objv[2], whatTable, - sizeof(char *), "option", 0, &what) != TCL_OK) - ) { + if (Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK + || Tcl_GetIntFromObj(interp, objv[objc-1], &y) != TCL_OK + || (objc == 5 && Tcl_GetIndexFromObjStruct(interp, objv[2], whatTable, + sizeof(char *), "option", 0, &what) != TCL_OK)) { return TCL_ERROR; } diff --git a/generic/ttk/ttkProgress.c b/generic/ttk/ttkProgress.c index 2a0ef4a..d83603a 100644 --- a/generic/ttk/ttkProgress.c +++ b/generic/ttk/ttkProgress.c @@ -96,7 +96,7 @@ static int AnimationEnabled(Progressbar *pb) * Increments the -phase option, redisplays the widget, * and reschedules itself if animation still enabled. */ -static void AnimateProgressProc(ClientData clientData) +static void AnimateProgressProc(void *clientData) { Progressbar *pb = (Progressbar *)clientData; @@ -185,10 +185,11 @@ static void VariableChanged(void *recordPtr, const char *value) * +++ Widget class methods: */ -static void ProgressbarInitialize(Tcl_Interp *dummy, void *recordPtr) +static void ProgressbarInitialize( + TCL_UNUSED(Tcl_Interp *), + void *recordPtr) { Progressbar *pb = (Progressbar *)recordPtr; - (void)dummy; pb->progress.variableTrace = 0; pb->progress.timer = 0; @@ -236,12 +237,12 @@ static int ProgressbarConfigure(Tcl_Interp *interp, void *recordPtr, int mask) * Post-configuration hook: */ static int ProgressbarPostConfigure( - Tcl_Interp *dummy, void *recordPtr, int mask) + TCL_UNUSED(Tcl_Interp *), + void *recordPtr, + TCL_UNUSED(int)) { Progressbar *pb = (Progressbar *)recordPtr; int status = TCL_OK; - (void)dummy; - (void)mask; if (pb->progress.variableTrace) { status = Ttk_FireTrace(pb->progress.variableTrace); @@ -464,7 +465,7 @@ static int ProgressbarStartStopCommand( prefix[0] = Tcl_NewStringObj(cmdName, -1); prefix[1] = objv[0]; - Tcl_ListObjReplace(interp, cmd, 0,2, 2,prefix); + Tcl_ListObjReplace(interp, cmd, 0, 2, 2,prefix); Tcl_IncrRefCount(cmd); status = Tcl_EvalObjEx(interp, cmd, 0); @@ -474,21 +475,23 @@ static int ProgressbarStartStopCommand( } static int ProgressbarStartCommand( - void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) + TCL_UNUSED(void *), + Tcl_Interp *interp, + int objc, + Tcl_Obj *const objv[]) { - (void)recordPtr; - return ProgressbarStartStopCommand( - interp, "::ttk::progressbar::start", objc, objv); + interp, "::ttk::progressbar::start", objc, objv); } static int ProgressbarStopCommand( - void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) + TCL_UNUSED(void *), + Tcl_Interp *interp, + int objc, + Tcl_Obj *const objv[]) { - (void)recordPtr; - return ProgressbarStartStopCommand( - interp, "::ttk::progressbar::stop", objc, objv); + interp, "::ttk::progressbar::stop", objc, objv); } static const Ttk_Ensemble ProgressbarCommands[] = { diff --git a/generic/ttk/ttkScale.c b/generic/ttk/ttkScale.c index 9b9e4d2..34ed2e1 100644 --- a/generic/ttk/ttkScale.c +++ b/generic/ttk/ttkScale.c @@ -57,7 +57,7 @@ static Tk_OptionSpec ScaleOptionSpecs[] = TK_OPTION_NULL_OK,0,0}, {TK_OPTION_STRING, "-variable", "variable", "Variable", "", Tk_Offset(Scale,scale.variableObj), -1, - 0,0,0}, + 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal", Tk_Offset(Scale,scale.orientObj), Tk_Offset(Scale,scale.orient), @@ -75,7 +75,7 @@ static Tk_OptionSpec ScaleOptionSpecs[] = {TK_OPTION_STRING, "-state", "state", "State", "normal", Tk_Offset(Scale,scale.stateObj), -1, - 0,0,STATE_CHANGED}, + 0, 0, STATE_CHANGED}, WIDGET_TAKEFOCUS_TRUE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) @@ -110,10 +110,11 @@ static void ScaleVariableChanged(void *recordPtr, const char *value) /* ScaleInitialize -- * Scale widget initialization hook. */ -static void ScaleInitialize(Tcl_Interp *dummy, void *recordPtr) +static void ScaleInitialize( + TCL_UNUSED(Tcl_Interp *), + void *recordPtr) { Scale *scalePtr = (Scale *)recordPtr; - (void)dummy; TtkTrackElementState(&scalePtr->core); } @@ -163,12 +164,12 @@ static int ScaleConfigure(Tcl_Interp *interp, void *recordPtr, int mask) * Post-configuration hook. */ static int ScalePostConfigure( - Tcl_Interp *dummy, void *recordPtr, int mask) + TCL_UNUSED(Tcl_Interp *), + void *recordPtr, + TCL_UNUSED(int)) { Scale *scale = (Scale *)recordPtr; int status = TCL_OK; - (void)dummy; - (void)mask; if (scale->scale.variableTrace) { status = Ttk_FireTrace(scale->scale.variableTrace); diff --git a/generic/ttk/ttkScrollbar.c b/generic/ttk/ttkScrollbar.c index af2f0b0..7663b6b 100644 --- a/generic/ttk/ttkScrollbar.c +++ b/generic/ttk/ttkScrollbar.c @@ -34,7 +34,7 @@ typedef struct static Tk_OptionSpec ScrollbarOptionSpecs[] = { {TK_OPTION_STRING, "-command", "command", "Command", "", - Tk_Offset(Scrollbar,scrollbar.commandObj), -1, 0,0,0}, + Tk_Offset(Scrollbar,scrollbar.commandObj), -1, 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical", Tk_Offset(Scrollbar,scrollbar.orientObj), @@ -50,10 +50,11 @@ static Tk_OptionSpec ScrollbarOptionSpecs[] = */ static void -ScrollbarInitialize(Tcl_Interp *dummy, void *recordPtr) +ScrollbarInitialize( + TCL_UNUSED(Tcl_Interp *), + void *recordPtr) { Scrollbar *sb = (Scrollbar *)recordPtr; - (void)dummy; sb->scrollbar.first = 0.0; sb->scrollbar.last = 1.0; diff --git a/generic/ttk/ttkSquare.c b/generic/ttk/ttkSquare.c index a2b2823..8629ae9 100644 --- a/generic/ttk/ttkSquare.c +++ b/generic/ttk/ttkSquare.c @@ -198,14 +198,17 @@ static Ttk_ElementOptionSpec SquareElementOptions[] = */ static void SquareElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + Ttk_Padding *paddingPtr) { SquareElement *square = (SquareElement *)elementRecord; int borderWidth = 0; - (void)dummy; - Tcl_GetIntFromObj(NULL, square->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, square->borderWidthObj, &borderWidth); *paddingPtr = Ttk_UniformPadding((short)borderWidth); Tk_GetPixelsFromObj(NULL, tkwin, square->widthObj, widthPtr); Tk_GetPixelsFromObj(NULL, tkwin, square->heightObj, heightPtr); @@ -216,17 +219,19 @@ static void SquareElementSize( */ static void SquareElementDraw( - void *dummy, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { SquareElement *square = (SquareElement *)elementRecord; Tk_3DBorder foreground = NULL; int borderWidth = 1, relief = TK_RELIEF_FLAT; - (void)dummy; - (void)state; foreground = Tk_Get3DBorderFromObj(tkwin, square->foregroundObj); - Tcl_GetIntFromObj(NULL, square->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, square->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, square->reliefObj, &relief); Tk_Fill3DRectangle(tkwin, d, foreground, diff --git a/generic/ttk/ttkTrace.c b/generic/ttk/ttkTrace.c index d086c02..c292c11 100644 --- a/generic/ttk/ttkTrace.c +++ b/generic/ttk/ttkTrace.c @@ -24,17 +24,15 @@ struct TtkTraceHandle_ */ static char * VarTraceProc( - ClientData clientData, /* Widget record pointer */ + void *clientData, /* Widget record pointer */ Tcl_Interp *interp, /* Interpreter containing variable. */ - const char *name1, /* (unused) */ - const char *name2, /* (unused) */ + TCL_UNUSED(const char *), /* name1 */ + TCL_UNUSED(const char *), /* name2 */ int flags) /* Information about what happened. */ { Ttk_TraceHandle *tracePtr = (Ttk_TraceHandle *)clientData; const char *name, *value; Tcl_Obj *valuePtr; - (void)name1; - (void)name2; if (Tcl_InterpDeleted(interp)) { return NULL; @@ -116,7 +114,7 @@ Ttk_TraceHandle *Ttk_TraceVariable( void Ttk_UntraceVariable(Ttk_TraceHandle *h) { if (h) { - ClientData cd = NULL; + void *cd = NULL; /* * Workaround for Tcl Bug 3062331. The trace design problem is diff --git a/generic/ttk/ttkWidget.c b/generic/ttk/ttkWidget.c index 37cc5ed..2c4f28e 100644 --- a/generic/ttk/ttkWidget.c +++ b/generic/ttk/ttkWidget.c @@ -758,9 +758,8 @@ int TtkWidgetIdentifyCommand( } } - if ( Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK - || Tcl_GetIntFromObj(interp, objv[objc-1], &y) != TCL_OK - ) { + if (Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK + || Tcl_GetIntFromObj(interp, objv[objc-1], &y) != TCL_OK) { return TCL_ERROR; } diff --git a/win/tkWinTest.c b/win/tkWinTest.c index 617bfd8..49231d5 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -26,22 +26,12 @@ HWND tkWinCurrentDialog; * Forward declarations of functions defined later in this file: */ -static int TestclipboardObjCmd(ClientData clientData, - Tcl_Interp *interp, int objc, - Tcl_Obj *const objv[]); -static int TestwineventObjCmd(ClientData clientData, - Tcl_Interp *interp, int objc, - Tcl_Obj *const objv[]); -static int TestfindwindowObjCmd(ClientData clientData, - Tcl_Interp *interp, int objc, - Tcl_Obj *const objv[]); -static int TestgetwindowinfoObjCmd(ClientData clientData, - Tcl_Interp *interp, int objc, - Tcl_Obj *const objv[]); -static int TestwinlocaleObjCmd(ClientData clientData, - Tcl_Interp *interp, int objc, - Tcl_Obj *const objv[]); -static Tk_GetSelProc SetSelectionResult; +static Tcl_ObjCmdProc TestclipboardObjCmd; +static Tcl_ObjCmdProc TestwineventObjCmd; +static Tcl_ObjCmdProc TestfindwindowObjCmd; +static Tcl_ObjCmdProc TestgetwindowinfoObjCmd; +static Tcl_ObjCmdProc TestwinlocaleObjCmd; +static Tk_GetSelProc SetSelectionResult; /* *---------------------------------------------------------------------- @@ -229,19 +219,17 @@ AppendSystemError( static int SetSelectionResult( - ClientData dummy, + TCL_UNUSED(void *), Tcl_Interp *interp, const char *selection) { - (void)dummy; - Tcl_AppendResult(interp, selection, NULL); return TCL_OK; } static int TestclipboardObjCmd( - ClientData clientData, /* Main window for application. */ + void *clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument values. */ @@ -275,7 +263,7 @@ TestclipboardObjCmd( static int TestwineventObjCmd( - ClientData dummy, /* Main window for application. */ + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ @@ -298,7 +286,6 @@ TestwineventObjCmd( {WM_COMMAND, "WM_COMMAND"}, {-1, NULL} }; - (void)dummy; if ((objc == 3) && (strcmp(Tcl_GetString(objv[1]), "debug") == 0)) { int b; @@ -314,7 +301,7 @@ TestwineventObjCmd( return TCL_ERROR; } - hwnd = INT2PTR(strtol(Tcl_GetString(objv[1]), &rest, 0)); + hwnd = (HWND)INT2PTR(strtol(Tcl_GetString(objv[1]), &rest, 0)); if (rest == Tcl_GetString(objv[1])) { hwnd = FindWindowA(NULL, Tcl_GetString(objv[1])); if (hwnd == NULL) { @@ -373,8 +360,7 @@ TestwineventObjCmd( SendMessageA(control, WM_GETTEXT, (WPARAM)sizeof(buf), (LPARAM) buf); #endif - Tcl_ExternalToUtfDString(NULL, buf, -1, &ds); - Tcl_AppendResult(interp, Tcl_DStringValue(&ds), NULL); + Tcl_AppendResult(interp, Tcl_ExternalToUtfDString(NULL, buf, -1, &ds), NULL); Tcl_DStringFree(&ds); break; } @@ -388,8 +374,7 @@ TestwineventObjCmd( return TCL_ERROR; } Tcl_UtfToExternalDString(NULL, Tcl_GetString(objv[4]), -1, &ds); - result = SendMessageA(control, WM_SETTEXT, 0, - (LPARAM) Tcl_DStringValue(&ds)); + result = SendMessageA(control, WM_SETTEXT, 0, (LPARAM)Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); if (result == 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to send text to dialog: ", -1)); @@ -433,7 +418,7 @@ TestwineventObjCmd( static int TestfindwindowObjCmd( - ClientData dummy, /* Main window for application. */ + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument values. */ @@ -443,7 +428,6 @@ TestfindwindowObjCmd( HWND hwnd = NULL; int r = TCL_OK; DWORD myPid; - (void)dummy; Tcl_DStringInit(&classString); Tcl_DStringInit(&titleString); @@ -484,7 +468,7 @@ TestfindwindowObjCmd( AppendSystemError(interp, GetLastError()); r = TCL_ERROR; } else { - Tcl_SetObjResult(interp, Tcl_NewWideIntObj((Tcl_WideInt)(((size_t)hwnd) + 1) - 1)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(PTR2INT(hwnd))); } Tcl_DStringFree(&titleString); @@ -500,13 +484,13 @@ EnumChildrenProc( { Tcl_Obj *listObj = (Tcl_Obj *) lParam; - Tcl_ListObjAppendElement(NULL, listObj, Tcl_NewWideIntObj((Tcl_WideInt)(((size_t)hwnd) + 1) - 1)); + Tcl_ListObjAppendElement(NULL, listObj, Tcl_NewWideIntObj(PTR2INT(hwnd))); return TRUE; } static int TestgetwindowinfoObjCmd( - ClientData dummy, + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) @@ -517,7 +501,6 @@ TestgetwindowinfoObjCmd( WCHAR buf[512]; int cch, cchBuf = 256; Tcl_DString ds; - (void)dummy; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "hwnd"); @@ -527,7 +510,7 @@ TestgetwindowinfoObjCmd( if (Tcl_GetWideIntFromObj(interp, objv[1], &hwnd) != TCL_OK) return TCL_ERROR; - cch = GetClassNameW(INT2PTR(hwnd), buf, cchBuf); + cch = GetClassNameW((HWND)INT2PTR(hwnd), buf, cchBuf); if (cch == 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to get class name: ", -1)); AppendSystemError(interp, GetLastError()); @@ -542,9 +525,9 @@ TestgetwindowinfoObjCmd( dictObj = Tcl_NewDictObj(); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("class", 5), classObj); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("id", 2), - Tcl_NewWideIntObj(GetWindowLongPtrW(INT2PTR(hwnd), GWL_ID))); + Tcl_NewWideIntObj(GetWindowLongPtrW((HWND)INT2PTR(hwnd), GWL_ID))); - cch = GetWindowTextW(INT2PTR(hwnd), buf, cchBuf); + cch = GetWindowTextW((HWND)INT2PTR(hwnd), buf, cchBuf); Tcl_DStringInit(&ds); Tcl_WCharToUtfDString(buf, cch, &ds); textObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); @@ -552,10 +535,10 @@ TestgetwindowinfoObjCmd( Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("text", 4), textObj); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("parent", 6), - Tcl_NewWideIntObj((Tcl_WideInt)(((size_t)GetParent((INT2PTR(hwnd)))) + 1) - 1)); + Tcl_NewWideIntObj(PTR2INT(GetParent((HWND)INT2PTR(hwnd))))); childrenObj = Tcl_NewListObj(0, NULL); - EnumChildWindows(INT2PTR(hwnd), EnumChildrenProc, (LPARAM)childrenObj); + EnumChildWindows((HWND)INT2PTR(hwnd), EnumChildrenProc, (LPARAM)childrenObj); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("children", -1), childrenObj); Tcl_SetObjResult(interp, dictObj); @@ -564,18 +547,16 @@ TestgetwindowinfoObjCmd( static int TestwinlocaleObjCmd( - ClientData dummy, /* Main window for application. */ + TCL_UNUSED(void *), /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument values. */ { - (void)dummy; - if (objc != 1) { Tcl_WrongNumArgs(interp, 1, objv, NULL); return TCL_ERROR; } - Tcl_SetObjResult(interp, Tcl_NewIntObj((int)GetThreadLocale())); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetThreadLocale())); return TCL_OK; } diff --git a/win/ttkWinTheme.c b/win/ttkWinTheme.c index c53dc6e..6288da1 100644 --- a/win/ttkWinTheme.c +++ b/win/ttkWinTheme.c @@ -5,7 +5,7 @@ #define WIN32_LEAN_AND_MEAN #endif -#include +#include "tkWinInt.h" #ifndef DFCS_HOT /* Windows 98/Me, Windows 2000/XP only */ #define DFCS_HOT 0 @@ -96,25 +96,26 @@ typedef struct { const char *name; /* element name */ int classId; /* class id for DrawFrameControl */ int partId; /* part id for DrawFrameControl */ - int cxId; /* system metric ids for width/height... */ - int cyId; /* ... or size if FIXEDSIZE bit set */ + unsigned cxId; /* system metric ids for width/height... */ + unsigned cyId; /* ... or size if FIXEDSIZE bit set */ Ttk_StateTable *stateMap; /* map Tk states to Win32 flags */ Ttk_Padding margins; /* additional placement padding */ } FrameControlElementData; -#define _FIXEDSIZE 0x80000000L -#define _HALFMETRIC 0x40000000L +#define BASE_DIM 13 +#define _FIXEDSIZE 0x80000000UL +#define _HALFMETRIC 0x40000000UL #define FIXEDSIZE(id) (id|_FIXEDSIZE) #define HALFMETRIC(id) (id|_HALFMETRIC) #define GETMETRIC(m) \ - ((m) & _FIXEDSIZE ? (int)((m) & ~_FIXEDSIZE) : GetSystemMetrics((m)&0x0fffffff)) + ((m) & _FIXEDSIZE ? (int)((m) & ~_FIXEDSIZE) : GetSystemMetrics((m)&0xFFFFFFF)) static FrameControlElementData FrameControlElements[] = { { "Checkbutton.indicator", - DFC_BUTTON, DFCS_BUTTONCHECK, FIXEDSIZE(13), FIXEDSIZE(13), + DFC_BUTTON, DFCS_BUTTONCHECK, FIXEDSIZE(BASE_DIM), FIXEDSIZE(BASE_DIM), checkbutton_statemap, {0,0,4,0} }, { "Radiobutton.indicator", - DFC_BUTTON, DFCS_BUTTONRADIO, FIXEDSIZE(13), FIXEDSIZE(13), + DFC_BUTTON, DFCS_BUTTONRADIO, FIXEDSIZE(BASE_DIM), FIXEDSIZE(BASE_DIM), checkbutton_statemap, {0,0,4,0} }, { "uparrow", DFC_SCROLL, DFCS_SCROLLUP, SM_CXVSCROLL, SM_CYVSCROLL, @@ -144,23 +145,33 @@ static FrameControlElementData FrameControlElements[] = { /* ---------------------------------------------------------------------- */ static void FrameControlElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + void *clientData, + TCL_UNUSED(void *), /* elementRecord */ + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { - FrameControlElementData *p = clientData; + FrameControlElementData *p = (FrameControlElementData *)clientData; int cx = GETMETRIC(p->cxId); int cy = GETMETRIC(p->cyId); + if (p->cxId & _HALFMETRIC) cx /= 2; if (p->cyId & _HALFMETRIC) cy /= 2; + *widthPtr = cx + Ttk_PaddingWidth(p->margins); *heightPtr = cy + Ttk_PaddingHeight(p->margins); } static void FrameControlElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + void *clientData, + TCL_UNUSED(void *), /* elementRecord */ + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + Ttk_State state) { - FrameControlElementData *elementData = clientData; + FrameControlElementData *elementData = (FrameControlElementData *)clientData; RECT rc = BoxToRect(Ttk_PadBox(b, elementData->margins)); TkWinDCState dcState; HDC hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState); @@ -188,23 +199,31 @@ typedef struct { } BorderElement; static Ttk_ElementOptionSpec BorderElementOptions[] = { - { "-relief",TK_OPTION_RELIEF,Tk_Offset(BorderElement,reliefObj), "flat" }, - {NULL, 0, 0, NULL} + { "-relief", TK_OPTION_RELIEF, Tk_Offset(BorderElement,reliefObj), "flat" }, + {NULL, TK_OPTION_BOOLEAN, 0, NULL} }; static void BorderElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + TCL_UNUSED(void *), /* elementRecord */ + TCL_UNUSED(Tk_Window), + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + Ttk_Padding *paddingPtr) { paddingPtr->left = paddingPtr->right = GetSystemMetrics(SM_CXEDGE); paddingPtr->top = paddingPtr->bottom = GetSystemMetrics(SM_CYEDGE); } static void BorderElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { - BorderElement *border = elementRecord; + BorderElement *border = (BorderElement *)elementRecord; RECT rc = BoxToRect(b); int relief = TK_RELIEF_FLAT; TkWinDCState dcState; @@ -240,22 +259,30 @@ typedef struct { static Ttk_ElementOptionSpec FieldElementOptions[] = { { "-fieldbackground", TK_OPTION_BORDER, Tk_Offset(FieldElement,backgroundObj), "white" }, - { NULL, 0, 0, NULL } + { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; static void FieldElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + TCL_UNUSED(void *), /* elementRecord */ + TCL_UNUSED(Tk_Window), + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + Ttk_Padding *paddingPtr) { paddingPtr->left = paddingPtr->right = GetSystemMetrics(SM_CXEDGE); paddingPtr->top = paddingPtr->bottom = GetSystemMetrics(SM_CYEDGE); } static void FieldElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { - FieldElement *field = elementRecord; + FieldElement *field = (FieldElement *)elementRecord; Tk_3DBorder bg = Tk_Get3DBorderFromObj(tkwin, field->backgroundObj); RECT rc = BoxToRect(b); TkWinDCState dcState; @@ -295,14 +322,18 @@ static Ttk_ElementOptionSpec ButtonBorderElementOptions[] = { Tk_Offset(ButtonBorderElement,highlightColorObj), "black" }, { "-default", TK_OPTION_ANY, Tk_Offset(ButtonBorderElement,defaultStateObj), "disabled" }, - {NULL, 0, 0, NULL} + {NULL, TK_OPTION_BOOLEAN, 0, NULL} }; static void ButtonBorderElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + TCL_UNUSED(Tk_Window), + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + Ttk_Padding *paddingPtr) { - ButtonBorderElement *bd = elementRecord; + ButtonBorderElement *bd = (ButtonBorderElement *)elementRecord; int relief = TK_RELIEF_RAISED; int defaultState = TTK_BUTTON_DEFAULT_DISABLED; short int cx, cy; @@ -327,10 +358,14 @@ static void ButtonBorderElementSize( } static void ButtonBorderElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + Ttk_State state) { - ButtonBorderElement *bd = elementRecord; + ButtonBorderElement *bd = (ButtonBorderElement *)elementRecord; int relief = TK_RELIEF_FLAT; int defaultState = TTK_BUTTON_DEFAULT_DISABLED; TkWinDCState dcState; @@ -381,15 +416,23 @@ static Ttk_ElementSpec ButtonBorderElementSpec = { */ static void FocusElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + TCL_UNUSED(void *), /* elementRecord */ + TCL_UNUSED(Tk_Window), + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + Ttk_Padding *paddingPtr) { *paddingPtr = Ttk_UniformPadding(1); } static void FocusElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + TCL_UNUSED(void *), /* elementRecord */ + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + Ttk_State state) { if (state & TTK_STATE_FOCUS) { RECT rc = BoxToRect(b); @@ -419,15 +462,20 @@ typedef struct { static Ttk_ElementOptionSpec FillFocusElementOptions[] = { { "-focusfill", TK_OPTION_COLOR, Tk_Offset(FillFocusElement,fillColorObj), "white" }, - {NULL, 0, 0, NULL} + {NULL, TK_OPTION_BOOLEAN, 0, NULL} }; /* @@@ FIX THIS */ static void FillFocusElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + Ttk_State state) { - FillFocusElement *focus = elementRecord; + FillFocusElement *focus = (FillFocusElement *)elementRecord; + if (state & TTK_STATE_FOCUS) { RECT rc = BoxToRect(b); TkWinDCState dcState; @@ -448,7 +496,7 @@ static void FillFocusElementDraw( */ static void ComboboxFocusElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + Drawable d, Ttk_Box b, Ttk_State state) { if (state & TTK_STATE_READONLY) { FillFocusElementDraw(clientData, elementRecord, tkwin, d, b, state); @@ -482,7 +530,7 @@ static const WORD Pattern[] = { static void TroughClientDataDeleteProc(void *clientData) { - TroughClientData *cd = clientData; + TroughClientData *cd = (TroughClientData *)clientData; DeleteObject(cd->PatternBrush); DeleteObject(cd->PatternBitmap); ckfree(clientData); @@ -490,7 +538,7 @@ static void TroughClientDataDeleteProc(void *clientData) static TroughClientData *TroughClientDataInit(Tcl_Interp *interp) { - TroughClientData *cd = ckalloc(sizeof(*cd)); + TroughClientData *cd = (TroughClientData *)ckalloc(sizeof(*cd)); cd->PatternBitmap = CreateBitmap(8, 8, 1, 1, Pattern); cd->PatternBrush = CreatePatternBrush(cd->PatternBitmap); Ttk_RegisterCleanup(interp, cd, TroughClientDataDeleteProc); @@ -498,16 +546,20 @@ static TroughClientData *TroughClientDataInit(Tcl_Interp *interp) } static void TroughElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + void *clientData, + TCL_UNUSED(void *), /* elementRecord */ + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { - TroughClientData *cd = clientData; + TroughClientData *cd = (TroughClientData *)clientData; TkWinDCState dcState; HDC hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState); HBRUSH hbr; COLORREF bk, oldbk, oldtxt; - hbr = SelectObject(hdc, GetSysColorBrush(COLOR_SCROLLBAR)); + hbr = (HBRUSH)SelectObject(hdc, GetSysColorBrush(COLOR_SCROLLBAR)); bk = GetSysColor(COLOR_3DHIGHLIGHT); oldtxt = SetTextColor(hdc, GetSysColor(COLOR_3DFACE)); oldbk = SetBkColor(hdc, bk); @@ -542,15 +594,19 @@ typedef struct { } ThumbElement; static Ttk_ElementOptionSpec ThumbElementOptions[] = { - { "-orient", TK_OPTION_ANY,Tk_Offset(ThumbElement,orientObj),"horizontal"}, - { NULL, 0, 0, NULL } + { "-orient", TK_OPTION_ANY, Tk_Offset(ThumbElement,orientObj),"horizontal"}, + { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; static void ThumbElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + TCL_UNUSED(Tk_Window), + int *widthPtr, + int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { - ThumbElement *thumbPtr = elementRecord; + ThumbElement *thumbPtr = (ThumbElement *)elementRecord; int orient; Ttk_GetOrientFromObj(NULL, thumbPtr->orientObj, &orient); @@ -564,8 +620,12 @@ static void ThumbElementSize( } static void ThumbElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + TCL_UNUSED(void *), /* elementRecord */ + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + Ttk_State state) { RECT rc = BoxToRect(b); TkWinDCState dcState; @@ -600,14 +660,18 @@ typedef struct { static Ttk_ElementOptionSpec SliderElementOptions[] = { { "-orient", TK_OPTION_ANY, Tk_Offset(SliderElement,orientObj), "horizontal" }, - { NULL, 0, 0, NULL } + { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; static void SliderElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + TCL_UNUSED(Tk_Window), + int *widthPtr, + int *heightPtr, + TCL_UNUSED(Ttk_Padding *)) { - SliderElement *slider = elementRecord; + SliderElement *slider = (SliderElement *)elementRecord; int orient; Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient); @@ -621,8 +685,12 @@ static void SliderElementSize( } static void SliderElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + TCL_UNUSED(void *), /* elementRecord */ + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { RECT rc = BoxToRect(b); TkWinDCState dcState; @@ -652,15 +720,19 @@ typedef struct { static Ttk_ElementOptionSpec TabElementOptions[] = { { "-borderwidth", TK_OPTION_PIXELS, - offsetof(TabElement,borderWidthObj), "1" }, + Tk_Offset(TabElement,borderWidthObj), "1" }, { "-background", TK_OPTION_BORDER, - offsetof(TabElement,backgroundObj), DEFAULT_BACKGROUND }, + Tk_Offset(TabElement,backgroundObj), DEFAULT_BACKGROUND }, {0,TK_OPTION_BOOLEAN,0,0} }; static void TabElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + Ttk_Padding *paddingPtr) { TabElement *tab = (TabElement *)elementRecord; int borderWidth = 1; @@ -692,8 +764,12 @@ static void TabElementSize( } static void TabElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + void *elementRecord, + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + Ttk_State state) { Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; @@ -769,7 +845,7 @@ static void TabElementDraw( XFillPolygon(disp, d, Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC), pts, 6, Convex, CoordModeOrigin); - Tcl_GetIntFromObj(NULL, tab->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, tab->borderWidthObj, &borderWidth); while (borderWidth--) { XDrawLines(disp, d, Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC), pts, 4, CoordModeOrigin); @@ -807,20 +883,29 @@ static Ttk_ElementSpec TabElementSpec = { }; static void ClientElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + TCL_UNUSED(void *), /* clientData */ + TCL_UNUSED(void *), /* elementRecord */ + TCL_UNUSED(Tk_Window), + TCL_UNUSED(int *), /* widthPtr */ + TCL_UNUSED(int *), /* heightPtr */ + Ttk_Padding *paddingPtr) { paddingPtr->left = paddingPtr->right = GetSystemMetrics(SM_CXEDGE); paddingPtr->top = paddingPtr->bottom = GetSystemMetrics(SM_CYEDGE); } static void ClientElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + TCL_UNUSED(void *), /* clientData */ + TCL_UNUSED(void *), /* elementRecord */ + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + TCL_UNUSED(Ttk_State)) { RECT rc = BoxToRect(b); TkWinDCState dcState; HDC hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState); + DrawEdge(hdc, &rc, EDGE_RAISED, BF_RECT | BF_SOFT); TkWinReleaseDrawableDC(d, hdc, &dcState); } @@ -856,10 +941,12 @@ TTK_END_LAYOUT_TABLE /* ---------------------------------------------------------------------- */ MODULE_SCOPE -int TtkWinTheme_Init(Tcl_Interp *interp, HWND hwnd) +int TtkWinTheme_Init( + Tcl_Interp *interp, + TCL_UNUSED(HWND)) { Ttk_Theme themePtr, parentPtr; - FrameControlElementData *fce = FrameControlElements; + const FrameControlElementData *fce = FrameControlElements; parentPtr = Ttk_GetTheme(interp, "alt"); themePtr = Ttk_CreateTheme(interp, "winnative", parentPtr); @@ -884,7 +971,7 @@ int TtkWinTheme_Init(Tcl_Interp *interp, HWND hwnd) for (fce = FrameControlElements; fce->name != 0; ++fce) { Ttk_RegisterElementSpec(themePtr, fce->name, - &FrameControlElementSpec, fce); + &FrameControlElementSpec, (void *)fce); } Ttk_RegisterLayouts(themePtr, LayoutTable); diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index a12220e..179bf0e 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -17,7 +17,7 @@ #define WINVER 0x0501 /* Requires Windows XP APIs */ -#include +#include "tkWinInt.h" #ifndef HAVE_UXTHEME_H /* Stub for platforms that lack the XP theme API headers: */ int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd) { return TCL_OK; } @@ -148,12 +148,13 @@ XPThemeDeleteProc(void *clientData) } static int -XPThemeEnabled(Ttk_Theme theme, void *clientData) +XPThemeEnabled( + TCL_UNUSED(Ttk_Theme), + void *clientData) { XPThemeData *themeData = (XPThemeData *)clientData; int active = themeData->procs->IsThemeActive(); int themed = themeData->procs->IsAppThemed(); - (void)theme; return (active && themed); } @@ -500,13 +501,16 @@ FreeElementData(ElementData *elementData) */ static void GenericElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + void *clientData, + TCL_UNUSED(void *), /* elementRecord */ + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + Ttk_Padding *paddingPtr) { ElementData *elementData = (ElementData *)clientData; HRESULT result; SIZE size; - (void)elementRecord; if (!InitElementData(elementData, tkwin, 0)) return; @@ -537,12 +541,15 @@ static void GenericElementSize( } static void GenericElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + void *clientData, + TCL_UNUSED(void *), /* elementRecord */ + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + Ttk_State state) { ElementData *elementData = (ElementData *)clientData; RECT rc; - (void)elementRecord; if (!InitElementData(elementData, tkwin, d)) { return; @@ -648,13 +655,16 @@ static Ttk_ElementSpec SpinboxArrowElementSpec = { */ static void ThumbElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + void *clientData, + TCL_UNUSED(void *), /* elementRecord */ + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + Ttk_State state) { ElementData *elementData = (ElementData *)clientData; unsigned stateId = Ttk_StateTableLookup(elementData->info->statemap, state); RECT rc = BoxToRect(b); - (void)elementRecord; /* * Don't draw the thumb if we are disabled. @@ -729,8 +739,12 @@ static Ttk_ElementSpec PbarElementSpec = */ static void TabElementSize( - void *clientData, void *elementRecord, Tk_Window tkwin, - int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) + void *clientData, + void *elementRecord, + Tk_Window tkwin, + int *widthPtr, + int *heightPtr, + Ttk_Padding *paddingPtr) { Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; @@ -761,8 +775,12 @@ static void TabElementSize( } static void TabElementDraw( - void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + void *clientData, + TCL_UNUSED(void *), /* elementRecord */ + Tk_Window tkwin, + Drawable d, + Ttk_Box b, + Ttk_State state) { Ttk_PositionSpec nbTabsStickBit = TTK_STICK_S; TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr; @@ -887,7 +905,7 @@ static Ttk_StateTable tvpglyph_statemap[] = static void TreeIndicatorElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + Drawable d, Ttk_Box b, Ttk_State state) { if (!(state & TTK_STATE_LEAF)) { GenericElementDraw(clientData,elementRecord,tkwin,d,b,state); @@ -971,8 +989,8 @@ static void TextElementSize( } static void TextElementDraw( - ClientData clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, Ttk_State state) { TextElement *element = elementRecord; ElementData *elementData = clientData; @@ -1222,7 +1240,7 @@ Ttk_CreateVsapiElement( { XPThemeData *themeData = (XPThemeData *)clientData; ElementInfo *elementPtr = NULL; - ClientData elementData; + void *elementData; LPCWSTR className; int partId = 0; Ttk_StateTable *stateTable; @@ -1256,7 +1274,8 @@ Ttk_CreateVsapiElement( /* flags or padding */ if (objc > 3) { - int i = 3, option = 0; + int i = 3; + int option = 0; for (i = 3; i < objc; i += 2) { int tmp = 0; if (i == objc -1) { @@ -1266,8 +1285,8 @@ Ttk_CreateVsapiElement( Tcl_SetErrorCode(interp, "TTK", "VSAPI", "MISSING", NULL); goto retErr; } - if (Tcl_GetIndexFromObjStruct(interp, objv[i], optionStrings, - sizeof(char *), "option", 0, &option) != TCL_OK) + if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, + "option", 0, &option) != TCL_OK) goto retErr; switch (option) { case O_PADDING: @@ -1323,7 +1342,8 @@ Ttk_CreateVsapiElement( /* convert a statemap into a state table */ if (objc > 2) { Tcl_Obj **specs; - int n,j,count, status = TCL_OK; + int n, j, count; + int status = TCL_OK; if (Tcl_ListObjGetElements(interp, objv[2], &count, &specs) != TCL_OK) goto retErr; /* we over-allocate to ensure there is a terminating entry */ @@ -1434,7 +1454,7 @@ MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd) * New elements: */ for (infoPtr = ElementInfoTable; infoPtr->elementName != 0; ++infoPtr) { - ClientData clientData = NewElementData(procs, infoPtr); + void *clientData = NewElementData(procs, infoPtr); Ttk_RegisterElementSpec( themePtr, infoPtr->elementName, infoPtr->elementSpec, clientData); Ttk_RegisterCleanup(interp, clientData, DestroyElementData); -- cgit v0.12