From a5f0b6f9f4a8fe8e8d641cfb982332c98f5d1f9e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 16 May 2024 12:15:36 +0000 Subject: Resolve some compiler warnings on Windows. spacing cleanup --- generic/ttk/ttkClassicTheme.c | 49 ++++++++++++++++++++++--------------------- generic/ttk/ttkDefaultTheme.c | 16 ++++++++------ generic/ttk/ttkElements.c | 8 ++++--- 3 files changed, 40 insertions(+), 33 deletions(-) diff --git a/generic/ttk/ttkClassicTheme.c b/generic/ttk/ttkClassicTheme.c index 279ac1a..7a53930 100644 --- a/generic/ttk/ttkClassicTheme.c +++ b/generic/ttk/ttkClassicTheme.c @@ -28,7 +28,7 @@ static Ttk_ElementOptionSpec HighlightElementOptions[] = { { "-highlightthickness",TK_OPTION_PIXELS, Tk_Offset(HighlightElement,highlightThicknessObj), "0" }, { "-default", TK_OPTION_ANY, - offsetof(HighlightElement,defaultStateObj), "disabled" }, + Tk_Offset(HighlightElement,defaultStateObj), "disabled" }, { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; @@ -43,8 +43,7 @@ static void HighlightElementSize( HighlightElement *hl = (HighlightElement *)elementRecord; int highlightThickness = 0; - Tk_GetPixelsFromObj(NULL, tkwin, hl->highlightThicknessObj, - &highlightThickness); + Tk_GetPixelsFromObj(NULL, tkwin, hl->highlightThicknessObj, &highlightThickness); *paddingPtr = Ttk_UniformPadding((short)highlightThickness); } @@ -59,14 +58,15 @@ static void HighlightElementDraw( HighlightElement *hl = (HighlightElement *)elementRecord; int highlightThickness = 0; XColor *highlightColor = Tk_GetColorFromObj(tkwin, hl->highlightColorObj); - Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED; + int defaultState = TTK_BUTTON_DEFAULT_DISABLED; Tk_GetPixelsFromObj(NULL, tkwin, hl->highlightThicknessObj, &highlightThickness); if (highlightColor && highlightThickness > 0) { + GC gc; Ttk_GetButtonDefaultStateFromObj(NULL, hl->defaultStateObj, - (int *)&defaultState); - GC gc = Tk_GCForColor(highlightColor, d); + &defaultState); + gc = Tk_GCForColor(highlightColor, d); if (defaultState == TTK_BUTTON_DEFAULT_NORMAL) { TkDrawInsetFocusHighlight(tkwin, gc, highlightThickness, d, 5); } else { @@ -173,15 +173,15 @@ static void ButtonBorderElementDraw( inset += 5; break; case TTK_BUTTON_DEFAULT_ACTIVE : - Tk_Draw3DRectangle(tkwin, d, border, + Tk_Draw3DRectangle(tkwin, d, border, b.x+inset, b.y+inset, b.width - 2*inset, b.height - 2*inset, 2, TK_RELIEF_FLAT); - inset += 2; - Tk_Draw3DRectangle(tkwin, d, border, + inset += 2; + Tk_Draw3DRectangle(tkwin, d, border, b.x+inset, b.y+inset, b.width - 2*inset, b.height - 2*inset, 1, TK_RELIEF_SUNKEN); ++inset; - Tk_Draw3DRectangle(tkwin, d, border, + Tk_Draw3DRectangle(tkwin, d, border, b.x+inset, b.y+inset, b.width - 2*inset, b.height - 2*inset, 2, TK_RELIEF_FLAT); inset += 2; @@ -451,37 +451,37 @@ TTK_BEGIN_LAYOUT_TABLE(LayoutTable) TTK_LAYOUT("TButton", TTK_GROUP("Button.highlight", TTK_FILL_BOTH, - TTK_GROUP("Button.border", TTK_FILL_BOTH|TTK_BORDER, + TTK_GROUP("Button.border", TTK_FILL_BOTH|TTK_BORDER, TTK_GROUP("Button.padding", TTK_FILL_BOTH, - TTK_NODE("Button.label", TTK_FILL_BOTH))))) + TTK_NODE("Button.label", TTK_FILL_BOTH))))) TTK_LAYOUT("TCheckbutton", TTK_GROUP("Checkbutton.highlight", TTK_FILL_BOTH, - TTK_GROUP("Checkbutton.border", TTK_FILL_BOTH, + TTK_GROUP("Checkbutton.border", TTK_FILL_BOTH, TTK_GROUP("Checkbutton.padding", TTK_FILL_BOTH, - TTK_NODE("Checkbutton.indicator", TTK_PACK_LEFT) - TTK_NODE("Checkbutton.label", TTK_PACK_LEFT|TTK_FILL_BOTH))))) + TTK_NODE("Checkbutton.indicator", TTK_PACK_LEFT) + TTK_NODE("Checkbutton.label", TTK_PACK_LEFT|TTK_FILL_BOTH))))) TTK_LAYOUT("TRadiobutton", TTK_GROUP("Radiobutton.highlight", TTK_FILL_BOTH, - TTK_GROUP("Radiobutton.border", TTK_FILL_BOTH, + TTK_GROUP("Radiobutton.border", TTK_FILL_BOTH, TTK_GROUP("Radiobutton.padding", TTK_FILL_BOTH, - TTK_NODE("Radiobutton.indicator", TTK_PACK_LEFT) - TTK_NODE("Radiobutton.label", TTK_PACK_LEFT|TTK_FILL_BOTH))))) + TTK_NODE("Radiobutton.indicator", TTK_PACK_LEFT) + TTK_NODE("Radiobutton.label", TTK_PACK_LEFT|TTK_FILL_BOTH))))) TTK_LAYOUT("TMenubutton", TTK_GROUP("Menubutton.highlight", TTK_FILL_BOTH, - TTK_GROUP("Menubutton.border", TTK_FILL_BOTH, + TTK_GROUP("Menubutton.border", TTK_FILL_BOTH, TTK_NODE("Menubutton.indicator", TTK_PACK_RIGHT) TTK_GROUP("Menubutton.padding", TTK_FILL_X, - TTK_NODE("Menubutton.label", 0))))) + TTK_NODE("Menubutton.label", 0))))) /* "classic" entry, includes highlight border */ TTK_LAYOUT("TEntry", TTK_GROUP("Entry.highlight", TTK_FILL_BOTH, - TTK_GROUP("Entry.field", TTK_FILL_BOTH|TTK_BORDER, + TTK_GROUP("Entry.field", TTK_FILL_BOTH|TTK_BORDER, TTK_GROUP("Entry.padding", TTK_FILL_BOTH, - TTK_NODE("Entry.textarea", TTK_FILL_BOTH))))) + TTK_NODE("Entry.textarea", TTK_FILL_BOTH))))) /* "classic" combobox, includes highlight border */ TTK_LAYOUT("TCombobox", @@ -494,7 +494,7 @@ TTK_LAYOUT("TCombobox", /* "classic" spinbox, includes highlight border */ TTK_LAYOUT("TSpinbox", TTK_GROUP("Spinbox.highlight", TTK_FILL_BOTH, - TTK_GROUP("Spinbox.field", TTK_FILL_BOTH|TTK_FILL_X, + TTK_GROUP("Spinbox.field", TTK_FILL_BOTH|TTK_FILL_X, TTK_GROUP("null", TTK_PACK_RIGHT, TTK_NODE("Spinbox.uparrow", TTK_PACK_TOP|TTK_STICK_E) TTK_NODE("Spinbox.downarrow", TTK_PACK_BOTTOM|TTK_STICK_E)) @@ -526,7 +526,8 @@ TTK_END_LAYOUT_TABLE * Install classic theme. */ -MODULE_SCOPE int TtkClassicTheme_Init(Tcl_Interp *interp) +MODULE_SCOPE int +TtkClassicTheme_Init(Tcl_Interp *interp) { Ttk_Theme theme = Ttk_CreateTheme(interp, "classic", NULL); diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c index 58bf85a..d75dbe0 100644 --- a/generic/ttk/ttkDefaultTheme.c +++ b/generic/ttk/ttkDefaultTheme.c @@ -339,9 +339,9 @@ static Ttk_ElementOptionSpec FieldElementOptions[] = { "white" }, { "-bordercolor",TK_OPTION_COLOR, Tk_Offset(FieldElement,borderColorObj), "black" }, - { "-focuswidth", TK_OPTION_PIXELS, offsetof(FieldElement,focusWidthObj), + { "-focuswidth", TK_OPTION_PIXELS, Tk_Offset(FieldElement,focusWidthObj), "2" }, - { "-focuscolor", TK_OPTION_COLOR, offsetof(FieldElement,focusColorObj), + { "-focuscolor", TK_OPTION_COLOR, Tk_Offset(FieldElement,focusColorObj), "#4a6984" }, { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; @@ -378,6 +378,7 @@ static void FieldElementDraw( int x1 = b.x, x2 = b.x + b.width - 1; int y1 = b.y, y2 = b.y + b.height - 1; int w = WIN32_XDRAWLINE_HACK; + GC bgGC; /* * Draw the outer rounded rectangle @@ -396,7 +397,7 @@ static void FieldElementDraw( /* * Fill the inner rectangle */ - GC bgGC = Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC); + bgGC = Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC); XFillRectangle(disp, d, bgGC, b.x+1, b.y+1, b.width-2, b.height-2); } else { /* @@ -581,12 +582,15 @@ static void IndicatorElementDraw( Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding); b = Ttk_PadBox(b, padding); + /* + * Sanity check + */ if ( b.x < 0 || b.y < 0 || Tk_Width(tkwin) < b.x + spec->width || Tk_Height(tkwin) < b.y + spec->height) { - /* Oops! not enough room to display the image. + /* Oops! Not enough room to display the image. * Don't draw anything. */ return; @@ -778,8 +782,8 @@ static void ArrowElementDraw( Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief); - 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); b = Ttk_PadBox(b, ArrowPadding); diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c index 2e90317..365314f 100644 --- a/generic/ttk/ttkElements.c +++ b/generic/ttk/ttkElements.c @@ -247,6 +247,7 @@ static void FieldElementDraw( int x1 = b.x, x2 = b.x + b.width - 1; int y1 = b.y, y2 = b.y + b.height - 1; int w = WIN32_XDRAWLINE_HACK; + GC bgGC; /* * Draw the outer rounded rectangle @@ -265,7 +266,7 @@ static void FieldElementDraw( /* * Fill the inner rectangle */ - GC bgGC = Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC); + bgGC = Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC); XFillRectangle(disp, d, bgGC, b.x+1, b.y+1, b.width-2, b.height-2); } else { /* @@ -459,7 +460,7 @@ typedef struct { static Ttk_ElementOptionSpec SeparatorElementOptions[] = { { "-orient", TK_OPTION_ANY, - Tk_Offset(SeparatorElement,orientObj), "horizontal" }, + Tk_Offset(SeparatorElement, orientObj), "horizontal" }, { "-background", TK_OPTION_BORDER, Tk_Offset(SeparatorElement,borderObj), DEFAULT_BACKGROUND }, { NULL, TK_OPTION_BOOLEAN, 0, NULL } @@ -516,6 +517,7 @@ static void GeneralSeparatorElementDraw( { SeparatorElement *separator = (SeparatorElement *)elementRecord; int orient; + Ttk_GetOrientFromObj(NULL, separator->orientObj, &orient); switch (orient) { case TTK_ORIENT_HORIZONTAL: @@ -695,7 +697,7 @@ static void DiamondIndicatorElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { - IndicatorElement *indicator = elementRecord; + IndicatorElement *indicator = (IndicatorElement *)elementRecord; Ttk_Padding margins; int diameter = 0; Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins); -- cgit v0.12