From bb451dfa1c09cc91c232cae7df94ecd215ee309b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 6 Feb 2020 11:52:04 +0000 Subject: Add many 'const' modifiers, allowing the C-compiler to put many configuration-tables in static read-only memory. Mainly for Ttk (because Tk already did this a long time ago). --- generic/tkPkgConfig.c | 2 +- generic/ttk/ttk.decls | 6 ++-- generic/ttk/ttkButton.c | 16 +++++----- generic/ttk/ttkClamTheme.c | 42 ++++++++++++------------- generic/ttk/ttkClassicTheme.c | 16 +++++----- generic/ttk/ttkDecls.h | 12 ++++---- generic/ttk/ttkDefaultTheme.c | 44 +++++++++++++------------- generic/ttk/ttkElements.c | 72 +++++++++++++++++++++---------------------- generic/ttk/ttkEntry.c | 10 +++--- generic/ttk/ttkFrame.c | 4 +-- generic/ttk/ttkImage.c | 2 +- generic/ttk/ttkInit.c | 8 ++--- generic/ttk/ttkLabel.c | 12 ++++---- generic/ttk/ttkNotebook.c | 8 ++--- generic/ttk/ttkPanedwindow.c | 8 ++--- generic/ttk/ttkProgress.c | 2 +- generic/ttk/ttkScale.c | 2 +- generic/ttk/ttkScrollbar.c | 2 +- generic/ttk/ttkSeparator.c | 4 +-- generic/ttk/ttkSquare.c | 6 ++-- generic/ttk/ttkState.c | 2 +- generic/ttk/ttkTagSet.c | 8 ++--- generic/ttk/ttkTheme.c | 16 +++++----- generic/ttk/ttkTheme.h | 8 ++--- generic/ttk/ttkTreeview.c | 18 +++++------ generic/ttk/ttkWidget.h | 10 +++--- win/ttkWinMonitor.c | 4 +-- win/ttkWinTheme.c | 46 +++++++++++++-------------- win/ttkWinXPTheme.c | 72 +++++++++++++++++++++---------------------- 29 files changed, 231 insertions(+), 231 deletions(-) diff --git a/generic/tkPkgConfig.c b/generic/tkPkgConfig.c index ac0583f..a3666d4 100644 --- a/generic/tkPkgConfig.c +++ b/generic/tkPkgConfig.c @@ -94,7 +94,7 @@ # define CFG_FONTSYSTEM "x11" #endif -static Tcl_Config const cfg[] = { +static const Tcl_Config cfg[] = { {"debug", CFG_DEBUG}, {"threaded", CFG_THREADED}, {"profiled", CFG_PROFILED}, diff --git a/generic/ttk/ttk.decls b/generic/ttk/ttk.decls index e668a2a..b3297b4 100644 --- a/generic/ttk/ttk.decls +++ b/generic/ttk/ttk.decls @@ -25,7 +25,7 @@ declare 5 { int Ttk_RegisterElementSpec( Ttk_Theme theme, const char *elementName, - Ttk_ElementSpec *elementSpec, + const Ttk_ElementSpec *elementSpec, void *clientData) } @@ -34,7 +34,7 @@ declare 6 { Tcl_Interp *interp, Ttk_Theme theme, const char *elementName, - Ttk_ElementSpec *elementSpec, + const Ttk_ElementSpec *elementSpec, void *clientData) } @@ -72,7 +72,7 @@ declare 13 { } declare 14 { int Ttk_StateTableLookup( - Ttk_StateTable map[], Ttk_State state) + const Ttk_StateTable *map, Ttk_State state) } diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c index 47e704c..3fc849f 100644 --- a/generic/ttk/ttkButton.c +++ b/generic/ttk/ttkButton.c @@ -54,7 +54,7 @@ typedef struct BasePart base; } Base; -static Tk_OptionSpec BaseOptionSpecs[] = +static const Tk_OptionSpec BaseOptionSpecs[] = { {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", "left", offsetof(Base,base.justifyObj), -1, @@ -85,7 +85,7 @@ static Tk_OptionSpec BaseOptionSpecs[] = */ {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", NULL, offsetof(Base,base.compoundObj), -1, - TK_OPTION_NULL_OK,(ClientData)ttkCompoundStrings, + TK_OPTION_NULL_OK,(void *)ttkCompoundStrings, GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-padding", "padding", "Pad", NULL, offsetof(Base,base.paddingObj), -1, @@ -230,7 +230,7 @@ typedef struct LabelPart label; } Label; -static Tk_OptionSpec LabelOptionSpecs[] = +static const Tk_OptionSpec LabelOptionSpecs[] = { {TK_OPTION_BORDER, "-background", "frameColor", "FrameColor", NULL, offsetof(Label,label.backgroundObj), -1, @@ -313,13 +313,13 @@ typedef struct /* * Option specifications: */ -static Tk_OptionSpec ButtonOptionSpecs[] = +static const Tk_OptionSpec ButtonOptionSpecs[] = { {TK_OPTION_STRING, "-command", "command", "Command", "", offsetof(Button, button.commandObj), -1, 0,0,0}, {TK_OPTION_STRING_TABLE, "-default", "default", "Default", "normal", offsetof(Button, button.defaultStateObj), -1, - 0, (ClientData) ttkDefaultStrings, DEFAULTSTATE_CHANGED}, + 0, (void *)ttkDefaultStrings, DEFAULTSTATE_CHANGED}, WIDGET_TAKEFOCUS_TRUE, WIDGET_INHERIT_OPTIONS(BaseOptionSpecs) @@ -423,7 +423,7 @@ typedef struct /* * Option specifications: */ -static Tk_OptionSpec CheckbuttonOptionSpecs[] = +static const Tk_OptionSpec CheckbuttonOptionSpecs[] = { {TK_OPTION_STRING, "-variable", "variable", "Variable", NULL, offsetof(Checkbutton, checkbutton.variableObj), -1, @@ -631,7 +631,7 @@ typedef struct /* * Option specifications: */ -static Tk_OptionSpec RadiobuttonOptionSpecs[] = +static const Tk_OptionSpec RadiobuttonOptionSpecs[] = { {TK_OPTION_STRING, "-variable", "variable", "Variable", "::selectedButton", offsetof(Radiobutton, radiobutton.variableObj),-1, @@ -806,7 +806,7 @@ typedef struct static const char *const directionStrings[] = { "above", "below", "left", "right", "flush", NULL }; -static Tk_OptionSpec MenubuttonOptionSpecs[] = +static const Tk_OptionSpec MenubuttonOptionSpecs[] = { {TK_OPTION_STRING, "-menu", "menu", "Menu", "", offsetof(Menubutton, menubutton.menuObj), -1, 0,0,0}, diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c index 8657fba..fd12a11 100644 --- a/generic/ttk/ttkClamTheme.c +++ b/generic/ttk/ttkClamTheme.c @@ -106,7 +106,7 @@ typedef struct { Tcl_Obj *borderWidthObj; /* See <> */ } BorderElement; -static Ttk_ElementOptionSpec BorderElementOptions[] = { +static const Ttk_ElementOptionSpec BorderElementOptions[] = { { "-bordercolor", TK_OPTION_COLOR, offsetof(BorderElement,borderColorObj), DARKEST_COLOR }, { "-lightcolor", TK_OPTION_COLOR, @@ -177,7 +177,7 @@ static void BorderElementDraw( DrawSmoothBorder(tkwin, d, b, outer, upper, lower); } -static Ttk_ElementSpec BorderElementSpec = { +static const Ttk_ElementSpec BorderElementSpec = { TK_STYLE_VERSION_2, sizeof(BorderElement), BorderElementOptions, @@ -196,7 +196,7 @@ typedef struct { Tcl_Obj *backgroundObj; } FieldElement; -static Ttk_ElementOptionSpec FieldElementOptions[] = { +static const Ttk_ElementOptionSpec FieldElementOptions[] = { { "-bordercolor", TK_OPTION_COLOR, offsetof(FieldElement,borderColorObj), DARKEST_COLOR }, { "-lightcolor", TK_OPTION_COLOR, @@ -230,7 +230,7 @@ static void FieldElementDraw( tkwin, d, bg, f.x, f.y, f.width, f.height, 0, TK_RELIEF_SUNKEN); } -static Ttk_ElementSpec FieldElementSpec = { +static const Ttk_ElementSpec FieldElementSpec = { TK_STYLE_VERSION_2, sizeof(FieldElement), FieldElementOptions, @@ -257,7 +257,7 @@ static void ComboboxFieldElementDraw( b.x + b.width - 1, b.y + b.height - 1 + WIN32_XDRAWLINE_HACK); } -static Ttk_ElementSpec ComboboxFieldElementSpec = { +static const Ttk_ElementSpec ComboboxFieldElementSpec = { TK_STYLE_VERSION_2, sizeof(FieldElement), FieldElementOptions, @@ -278,7 +278,7 @@ typedef struct { Tcl_Obj *lowerColorObj; } IndicatorElement; -static Ttk_ElementOptionSpec IndicatorElementOptions[] = { +static const Ttk_ElementOptionSpec IndicatorElementOptions[] = { { "-indicatorsize", TK_OPTION_PIXELS, offsetof(IndicatorElement,sizeObj), "10" }, { "-indicatormargin", TK_OPTION_STRING, @@ -375,7 +375,7 @@ static void CheckIndicatorElementDraw( } } -static Ttk_ElementSpec RadioIndicatorElementSpec = { +static const Ttk_ElementSpec RadioIndicatorElementSpec = { TK_STYLE_VERSION_2, sizeof(IndicatorElement), IndicatorElementOptions, @@ -383,7 +383,7 @@ static Ttk_ElementSpec RadioIndicatorElementSpec = { RadioIndicatorElementDraw }; -static Ttk_ElementSpec CheckIndicatorElementSpec = { +static const Ttk_ElementSpec CheckIndicatorElementSpec = { TK_STYLE_VERSION_2, sizeof(IndicatorElement), IndicatorElementOptions, @@ -399,7 +399,7 @@ typedef struct { Tcl_Obj *paddingObj; } MenuIndicatorElement; -static Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = +static const Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = { { "-arrowsize", TK_OPTION_PIXELS, offsetof(MenuIndicatorElement,sizeObj), @@ -444,7 +444,7 @@ static void MenuIndicatorElementDraw( TtkFillArrow(Tk_Display(tkwin), d, gc, b, ARROW_DOWN); } -static Ttk_ElementSpec MenuIndicatorElementSpec = +static const Ttk_ElementSpec MenuIndicatorElementSpec = { TK_STYLE_VERSION_2, sizeof(MenuIndicatorElement), @@ -469,7 +469,7 @@ typedef struct { Tcl_Obj *gripCountObj; } GripElement; -static Ttk_ElementOptionSpec GripElementOptions[] = { +static const Ttk_ElementOptionSpec GripElementOptions[] = { { "-lightcolor", TK_OPTION_COLOR, offsetof(GripElement,lightColorObj), LIGHT_COLOR }, { "-bordercolor", TK_OPTION_COLOR, @@ -526,7 +526,7 @@ static void GripElementDraw( } } -static Ttk_ElementSpec GripElementSpec = { +static const Ttk_ElementSpec GripElementSpec = { TK_STYLE_VERSION_2, sizeof(GripElement), GripElementOptions, @@ -554,7 +554,7 @@ typedef struct { /* Common element record for scrollbar elements */ Tcl_Obj *sliderlengthObj; } ScrollbarElement; -static Ttk_ElementOptionSpec ScrollbarElementOptions[] = { +static const Ttk_ElementOptionSpec ScrollbarElementOptions[] = { { "-orient", TK_OPTION_ANY, offsetof(ScrollbarElement, orientObj), "horizontal" }, { "-background", TK_OPTION_BORDER, @@ -589,7 +589,7 @@ static void TroughElementDraw( XDrawRectangle(Tk_Display(tkwin), d, gcb, b.x, b.y, b.width-1, b.height-1); } -static Ttk_ElementSpec TroughElementSpec = { +static const Ttk_ElementSpec TroughElementSpec = { TK_STYLE_VERSION_2, sizeof(ScrollbarElement), ScrollbarElementOptions, @@ -651,7 +651,7 @@ static void ThumbElementDraw( } } -static Ttk_ElementSpec ThumbElementSpec = { +static const Ttk_ElementSpec ThumbElementSpec = { TK_STYLE_VERSION_2, sizeof(ScrollbarElement), ScrollbarElementOptions, @@ -683,7 +683,7 @@ static void SliderElementSize( } -static Ttk_ElementSpec SliderElementSpec = { +static const Ttk_ElementSpec SliderElementSpec = { TK_STYLE_VERSION_2, sizeof(ScrollbarElement), ScrollbarElementOptions, @@ -721,7 +721,7 @@ static void PbarElementDraw( } } -static Ttk_ElementSpec PbarElementSpec = { +static const Ttk_ElementSpec PbarElementSpec = { TK_STYLE_VERSION_2, sizeof(ScrollbarElement), ScrollbarElementOptions, @@ -769,7 +769,7 @@ static void ArrowElementDraw( TtkFillArrow(Tk_Display(tkwin), d, gc, b, dir); } -static Ttk_ElementSpec ArrowElementSpec = { +static const Ttk_ElementSpec ArrowElementSpec = { TK_STYLE_VERSION_2, sizeof(ScrollbarElement), ScrollbarElementOptions, @@ -792,7 +792,7 @@ typedef struct { Tcl_Obj *darkColorObj; } NotebookElement; -static Ttk_ElementOptionSpec NotebookElementOptions[] = { +static const Ttk_ElementOptionSpec NotebookElementOptions[] = { { "-background", TK_OPTION_BORDER, offsetof(NotebookElement,backgroundObj), FRAME_COLOR }, { "-bordercolor", TK_OPTION_COLOR, @@ -850,7 +850,7 @@ static void TabElementDraw( XDrawLine(display,d,gc, x1+1,y1+1, x2-1+w,y1+1); } -static Ttk_ElementSpec TabElementSpec = +static const Ttk_ElementSpec TabElementSpec = { TK_STYLE_VERSION_2, sizeof(NotebookElement), @@ -881,7 +881,7 @@ static void ClientElementDraw( ce->borderColorObj, ce->lightColorObj, ce->darkColorObj); } -static Ttk_ElementSpec ClientElementSpec = +static const Ttk_ElementSpec ClientElementSpec = { TK_STYLE_VERSION_2, sizeof(NotebookElement), diff --git a/generic/ttk/ttkClassicTheme.c b/generic/ttk/ttkClassicTheme.c index b22e5d5..dadacad 100644 --- a/generic/ttk/ttkClassicTheme.c +++ b/generic/ttk/ttkClassicTheme.c @@ -21,7 +21,7 @@ typedef struct { Tcl_Obj *highlightThicknessObj; } HighlightElement; -static Ttk_ElementOptionSpec HighlightElementOptions[] = { +static const Ttk_ElementOptionSpec HighlightElementOptions[] = { { "-highlightcolor",TK_OPTION_COLOR, offsetof(HighlightElement,highlightColorObj), DEFAULT_BACKGROUND }, { "-highlightthickness",TK_OPTION_PIXELS, @@ -55,7 +55,7 @@ static void HighlightElementDraw( } } -static Ttk_ElementSpec HighlightElementSpec = +static const Ttk_ElementSpec HighlightElementSpec = { TK_STYLE_VERSION_2, sizeof(HighlightElement), @@ -81,7 +81,7 @@ typedef struct { Tcl_Obj *defaultStateObj; } ButtonBorderElement; -static Ttk_ElementOptionSpec ButtonBorderElementOptions[] = +static const Ttk_ElementOptionSpec ButtonBorderElementOptions[] = { { "-background", TK_OPTION_BORDER, offsetof(ButtonBorderElement,borderObj), DEFAULT_BACKGROUND }, @@ -170,7 +170,7 @@ static void ButtonBorderElementDraw( } } -static Ttk_ElementSpec ButtonBorderElementSpec = +static const Ttk_ElementSpec ButtonBorderElementSpec = { TK_STYLE_VERSION_2, sizeof(ButtonBorderElement), @@ -195,7 +195,7 @@ typedef struct Tcl_Obj *reliefObj; } ArrowElement; -static Ttk_ElementOptionSpec ArrowElementOptions[] = +static const Ttk_ElementOptionSpec ArrowElementOptions[] = { { "-arrowsize", TK_OPTION_PIXELS, offsetof(ArrowElement,sizeObj), DEFAULT_ARROW_SIZE }, @@ -266,7 +266,7 @@ static void ArrowElementDraw( Tk_Fill3DPolygon(tkwin, d, border, points, 3, borderWidth, relief); } -static Ttk_ElementSpec ArrowElementSpec = +static const Ttk_ElementSpec ArrowElementSpec = { TK_STYLE_VERSION_2, sizeof(ArrowElement), @@ -303,7 +303,7 @@ typedef struct { Tcl_Obj *handlePadObj; /* handle's distance from edge */ } SashElement; -static Ttk_ElementOptionSpec SashOptions[] = { +static const Ttk_ElementOptionSpec SashOptions[] = { { "-background", TK_OPTION_BORDER, offsetof(SashElement,borderObj), DEFAULT_BACKGROUND }, { "-sashrelief", TK_OPTION_RELIEF, @@ -401,7 +401,7 @@ static void SashElementDraw( } } -static Ttk_ElementSpec SashElementSpec = { +static const Ttk_ElementSpec SashElementSpec = { TK_STYLE_VERSION_2, sizeof(SashElement), SashOptions, diff --git a/generic/ttk/ttkDecls.h b/generic/ttk/ttkDecls.h index 6701724..1aa0874 100644 --- a/generic/ttk/ttkDecls.h +++ b/generic/ttk/ttkDecls.h @@ -47,12 +47,12 @@ TTKAPI void Ttk_RegisterCleanup(Tcl_Interp *interp, /* 5 */ TTKAPI int Ttk_RegisterElementSpec(Ttk_Theme theme, const char *elementName, - Ttk_ElementSpec *elementSpec, + const Ttk_ElementSpec *elementSpec, void *clientData); /* 6 */ TTKAPI Ttk_ElementClass * Ttk_RegisterElement(Tcl_Interp *interp, Ttk_Theme theme, const char *elementName, - Ttk_ElementSpec *elementSpec, + const Ttk_ElementSpec *elementSpec, void *clientData); /* 7 */ TTKAPI int Ttk_RegisterElementFactory(Tcl_Interp *interp, @@ -77,7 +77,7 @@ TTKAPI Ttk_StateMap Ttk_GetStateMapFromObj(Tcl_Interp *interp, TTKAPI Tcl_Obj * Ttk_StateMapLookup(Tcl_Interp *interp, Ttk_StateMap map, Ttk_State state); /* 14 */ -TTKAPI int Ttk_StateTableLookup(Ttk_StateTable map[], +TTKAPI int Ttk_StateTableLookup(const Ttk_StateTable *map, Ttk_State state); /* Slot 15 is reserved */ /* Slot 16 is reserved */ @@ -144,8 +144,8 @@ typedef struct TtkStubs { Ttk_Theme (*ttk_GetCurrentTheme) (Tcl_Interp *interp); /* 2 */ Ttk_Theme (*ttk_CreateTheme) (Tcl_Interp *interp, const char *name, Ttk_Theme parent); /* 3 */ void (*ttk_RegisterCleanup) (Tcl_Interp *interp, void *deleteData, Ttk_CleanupProc *cleanupProc); /* 4 */ - int (*ttk_RegisterElementSpec) (Ttk_Theme theme, const char *elementName, Ttk_ElementSpec *elementSpec, void *clientData); /* 5 */ - Ttk_ElementClass * (*ttk_RegisterElement) (Tcl_Interp *interp, Ttk_Theme theme, const char *elementName, Ttk_ElementSpec *elementSpec, void *clientData); /* 6 */ + int (*ttk_RegisterElementSpec) (Ttk_Theme theme, const char *elementName, const Ttk_ElementSpec *elementSpec, void *clientData); /* 5 */ + Ttk_ElementClass * (*ttk_RegisterElement) (Tcl_Interp *interp, Ttk_Theme theme, const char *elementName, const Ttk_ElementSpec *elementSpec, void *clientData); /* 6 */ int (*ttk_RegisterElementFactory) (Tcl_Interp *interp, const char *name, Ttk_ElementFactory factoryProc, void *clientData); /* 7 */ void (*ttk_RegisterLayout) (Ttk_Theme theme, const char *className, Ttk_LayoutSpec layoutSpec); /* 8 */ void (*reserved9)(void); @@ -153,7 +153,7 @@ typedef struct TtkStubs { Tcl_Obj * (*ttk_NewStateSpecObj) (unsigned int onbits, unsigned int offbits); /* 11 */ Ttk_StateMap (*ttk_GetStateMapFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr); /* 12 */ Tcl_Obj * (*ttk_StateMapLookup) (Tcl_Interp *interp, Ttk_StateMap map, Ttk_State state); /* 13 */ - int (*ttk_StateTableLookup) (Ttk_StateTable map[], Ttk_State state); /* 14 */ + int (*ttk_StateTableLookup) (const Ttk_StateTable *map, Ttk_State state); /* 14 */ void (*reserved15)(void); void (*reserved16)(void); void (*reserved17)(void); diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c index 002448b..91cef86 100644 --- a/generic/ttk/ttkDefaultTheme.c +++ b/generic/ttk/ttkDefaultTheme.c @@ -116,7 +116,7 @@ static void DrawBorder( /* Alternate shadow colors for entry fields: * NOTE: FLAT color is normally white, and the LITE color is a darker shade. */ -static int fieldShadowColors[4] = { DARK, BRDR, LITE, FLAT }; +static const int fieldShadowColors[4] = { DARK, BRDR, LITE, FLAT }; static void DrawFieldBorder( Tk_Window tkwin, Drawable d, Tk_3DBorder border, XColor *borderColor, @@ -244,7 +244,7 @@ typedef struct { Tcl_Obj *defaultStateObj; /* for buttons */ } BorderElement; -static Ttk_ElementOptionSpec BorderElementOptions[] = { +static const Ttk_ElementOptionSpec BorderElementOptions[] = { { "-background", TK_OPTION_BORDER, offsetof(BorderElement,borderObj), DEFAULT_BACKGROUND }, { "-bordercolor",TK_OPTION_COLOR, @@ -307,7 +307,7 @@ static void BorderElementDraw( DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief); } -static Ttk_ElementSpec BorderElementSpec = { +static const Ttk_ElementSpec BorderElementSpec = { TK_STYLE_VERSION_2, sizeof(BorderElement), BorderElementOptions, @@ -324,7 +324,7 @@ typedef struct { Tcl_Obj *borderColorObj; /* Extra border color */ } FieldElement; -static Ttk_ElementOptionSpec FieldElementOptions[] = { +static const Ttk_ElementOptionSpec FieldElementOptions[] = { { "-fieldbackground", TK_OPTION_BORDER, offsetof(FieldElement,borderObj), "white" }, { "-bordercolor",TK_OPTION_COLOR, offsetof(FieldElement,borderColorObj), @@ -352,7 +352,7 @@ static void FieldElementDraw( DrawFieldBorder(tkwin, d, border, borderColor, b); } -static Ttk_ElementSpec FieldElementSpec = { +static const Ttk_ElementSpec FieldElementSpec = { TK_STYLE_VERSION_2, sizeof(FieldElement), FieldElementOptions, @@ -375,7 +375,7 @@ typedef struct { int height; /* Height of each image */ int nimages; /* #images / row */ const char *const *pixels; /* array[height] of char[width*nimage] */ - Ttk_StateTable *map;/* used to look up image index by state */ + const Ttk_StateTable *map;/* used to look up image index by state */ } IndicatorSpec; #if 0 @@ -395,7 +395,7 @@ static const char *const button_images[] = { }; #endif -static Ttk_StateTable checkbutton_states[] = { +static const Ttk_StateTable checkbutton_states[] = { { 0, 0, TTK_STATE_SELECTED|TTK_STATE_DISABLED }, { 1, TTK_STATE_SELECTED, TTK_STATE_DISABLED }, { 2, TTK_STATE_DISABLED, TTK_STATE_SELECTED }, @@ -425,7 +425,7 @@ static IndicatorSpec checkbutton_spec = { checkbutton_states }; -static Ttk_StateTable radiobutton_states[] = { +static const Ttk_StateTable radiobutton_states[] = { { 0, 0, TTK_STATE_SELECTED|TTK_STATE_DISABLED }, { 1, TTK_STATE_SELECTED, TTK_STATE_DISABLED }, { 2, TTK_STATE_DISABLED, TTK_STATE_SELECTED }, @@ -465,7 +465,7 @@ typedef struct { Tcl_Obj *marginObj; } IndicatorElement; -static Ttk_ElementOptionSpec IndicatorElementOptions[] = { +static const Ttk_ElementOptionSpec IndicatorElementOptions[] = { { "-background", TK_OPTION_COLOR, offsetof(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND }, { "-foreground", TK_OPTION_COLOR, @@ -628,7 +628,7 @@ static void IndicatorElementDraw( XDestroyImage(img); } -static Ttk_ElementSpec IndicatorElementSpec = { +static const Ttk_ElementSpec IndicatorElementSpec = { TK_STYLE_VERSION_2, sizeof(IndicatorElement), IndicatorElementOptions, @@ -652,7 +652,7 @@ typedef struct { Tcl_Obj *colorObj; /* Arrow color */ } ArrowElement; -static Ttk_ElementOptionSpec ArrowElementOptions[] = { +static const Ttk_ElementOptionSpec ArrowElementOptions[] = { { "-arrowsize", TK_OPTION_PIXELS, offsetof(ArrowElement,sizeObj), STRINGIFY(SCROLLBAR_WIDTH) }, { "-background", TK_OPTION_BORDER, @@ -710,7 +710,7 @@ static void ArrowElementDraw( Ttk_PadBox(b, ArrowPadding), direction); } -static Ttk_ElementSpec ArrowElementSpec = { +static const Ttk_ElementSpec ArrowElementSpec = { TK_STYLE_VERSION_2, sizeof(ArrowElement), ArrowElementOptions, @@ -736,7 +736,7 @@ static const char *const directionStrings[] = { /* See also: button.c */ }; enum { POST_ABOVE, POST_BELOW, POST_LEFT, POST_RIGHT, POST_FLUSH }; -static Ttk_ElementOptionSpec MenubuttonArrowElementOptions[] = { +static const Ttk_ElementOptionSpec MenubuttonArrowElementOptions[] = { { "-direction", TK_OPTION_STRING, offsetof(MenubuttonArrowElement,directionObj), "below" }, { "-arrowsize", TK_OPTION_PIXELS, @@ -791,7 +791,7 @@ static void MenubuttonArrowElementDraw( TtkFillArrow(Tk_Display(tkwin), d, gc, b, arrowDirection); } -static Ttk_ElementSpec MenubuttonArrowElementSpec = { +static const Ttk_ElementSpec MenubuttonArrowElementSpec = { TK_STYLE_VERSION_2, sizeof(MenubuttonArrowElement), MenubuttonArrowElementOptions, @@ -820,7 +820,7 @@ typedef struct { Tcl_Obj *orientObj; } TroughElement; -static Ttk_ElementOptionSpec TroughElementOptions[] = { +static const Ttk_ElementOptionSpec TroughElementOptions[] = { { "-orient", TK_OPTION_ANY, offsetof(TroughElement, orientObj), "horizontal" }, { "-troughborderwidth", TK_OPTION_PIXELS, @@ -877,7 +877,7 @@ static void TroughElementDraw( borderWidth, relief); } -static Ttk_ElementSpec TroughElementSpec = { +static const Ttk_ElementSpec TroughElementSpec = { TK_STYLE_VERSION_2, sizeof(TroughElement), TroughElementOptions, @@ -900,7 +900,7 @@ typedef struct { Tcl_Obj *orientObj; } ThumbElement; -static Ttk_ElementOptionSpec ThumbElementOptions[] = { +static const Ttk_ElementOptionSpec ThumbElementOptions[] = { { "-width", TK_OPTION_PIXELS, offsetof(ThumbElement,sizeObj), STRINGIFY(SCROLLBAR_WIDTH) }, { "-background", TK_OPTION_BORDER, offsetof(ThumbElement,borderObj), @@ -954,7 +954,7 @@ static void ThumbElementDraw( DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief); } -static Ttk_ElementSpec ThumbElementSpec = { +static const Ttk_ElementSpec ThumbElementSpec = { TK_STYLE_VERSION_2, sizeof(ThumbElement), ThumbElementOptions, @@ -983,7 +983,7 @@ typedef struct { Tcl_Obj *orientObj; /* Orientation of overall slider */ } SliderElement; -static Ttk_ElementOptionSpec SliderElementOptions[] = { +static const Ttk_ElementOptionSpec SliderElementOptions[] = { { "-sliderlength", TK_OPTION_PIXELS, offsetof(SliderElement,lengthObj), "15" }, { "-sliderthickness",TK_OPTION_PIXELS, offsetof(SliderElement,thicknessObj), @@ -1044,7 +1044,7 @@ static void SliderElementDraw( DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief); } -static Ttk_ElementSpec SliderElementSpec = { +static const Ttk_ElementSpec SliderElementSpec = { TK_STYLE_VERSION_2, sizeof(SliderElement), SliderElementOptions, @@ -1065,7 +1065,7 @@ typedef struct { Tcl_Obj *diameterObj; } TreeitemIndicator; -static Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = { +static const Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = { { "-foreground", TK_OPTION_COLOR, offsetof(TreeitemIndicator,colorObj), DEFAULT_FOREGROUND }, { "-diameter", TK_OPTION_PIXELS, @@ -1121,7 +1121,7 @@ static void TreeitemIndicatorDraw( } } -static Ttk_ElementSpec TreeitemIndicatorElementSpec = { +static const Ttk_ElementSpec TreeitemIndicatorElementSpec = { TK_STYLE_VERSION_2, sizeof(TreeitemIndicator), TreeitemIndicatorOptions, diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c index b6bc1fd..2779cad 100644 --- a/generic/ttk/ttkElements.c +++ b/generic/ttk/ttkElements.c @@ -19,7 +19,7 @@ * and may be used in other engines. */ -/* public */ Ttk_ElementOptionSpec TtkNullElementOptions[] = { { NULL, 0, 0, NULL } }; +/* public */ const Ttk_ElementOptionSpec TtkNullElementOptions[] = { { NULL, 0, 0, NULL } }; /* public */ void TtkNullElementSize( @@ -56,7 +56,7 @@ typedef struct { Tcl_Obj *backgroundObj; } BackgroundElement; -static Ttk_ElementOptionSpec BackgroundElementOptions[] = { +static const Ttk_ElementOptionSpec BackgroundElementOptions[] = { { "-background", TK_OPTION_BORDER, offsetof(BackgroundElement,backgroundObj), DEFAULT_BACKGROUND }, { NULL, 0, 0, NULL } @@ -83,7 +83,7 @@ static void BackgroundElementDraw( d, Ttk_WinBox(tkwin), state); } -static Ttk_ElementSpec FillElementSpec = { +static const Ttk_ElementSpec FillElementSpec = { TK_STYLE_VERSION_2, sizeof(BackgroundElement), BackgroundElementOptions, @@ -91,7 +91,7 @@ static Ttk_ElementSpec FillElementSpec = { FillElementDraw }; -static Ttk_ElementSpec BackgroundElementSpec = { +static const Ttk_ElementSpec BackgroundElementSpec = { TK_STYLE_VERSION_2, sizeof(BackgroundElement), BackgroundElementOptions, @@ -109,7 +109,7 @@ typedef struct { Tcl_Obj *reliefObj; } BorderElement; -static Ttk_ElementOptionSpec BorderElementOptions[] = { +static const Ttk_ElementOptionSpec BorderElementOptions[] = { { "-background", TK_OPTION_BORDER, offsetof(BorderElement,borderObj), DEFAULT_BACKGROUND }, { "-borderwidth", TK_OPTION_PIXELS, @@ -147,7 +147,7 @@ static void BorderElementDraw( } } -static Ttk_ElementSpec BorderElementSpec = { +static const Ttk_ElementSpec BorderElementSpec = { TK_STYLE_VERSION_2, sizeof(BorderElement), BorderElementOptions, @@ -164,7 +164,7 @@ typedef struct { Tcl_Obj *borderWidthObj; } FieldElement; -static Ttk_ElementOptionSpec FieldElementOptions[] = { +static const Ttk_ElementOptionSpec FieldElementOptions[] = { { "-fieldbackground", TK_OPTION_BORDER, offsetof(FieldElement,borderObj), "white" }, { "-borderwidth", TK_OPTION_PIXELS, @@ -195,7 +195,7 @@ static void FieldElementDraw( b.x, b.y, b.width, b.height, borderWidth, TK_RELIEF_SUNKEN); } -static Ttk_ElementSpec FieldElementSpec = { +static const Ttk_ElementSpec FieldElementSpec = { TK_STYLE_VERSION_2, sizeof(FieldElement), FieldElementOptions, @@ -220,7 +220,7 @@ typedef struct { Tcl_Obj *shiftreliefObj; } PaddingElement; -static Ttk_ElementOptionSpec PaddingElementOptions[] = { +static const Ttk_ElementOptionSpec PaddingElementOptions[] = { { "-padding", TK_OPTION_STRING, offsetof(PaddingElement,paddingObj), "0" }, { "-relief", TK_OPTION_RELIEF, @@ -245,7 +245,7 @@ static void PaddingElementSize( *paddingPtr = Ttk_RelievePadding(pad, relief, shiftRelief); } -static Ttk_ElementSpec PaddingElementSpec = { +static const Ttk_ElementSpec PaddingElementSpec = { TK_STYLE_VERSION_2, sizeof(PaddingElement), PaddingElementOptions, @@ -286,7 +286,7 @@ static void DrawFocusRing( Tk_FreeGC(Tk_Display(tkwin), gc); } -static Ttk_ElementOptionSpec FocusElementOptions[] = { +static const Ttk_ElementOptionSpec FocusElementOptions[] = { { "-focuscolor",TK_OPTION_COLOR, offsetof(FocusElement,focusColorObj), "black" }, { "-focusthickness",TK_OPTION_PIXELS, @@ -318,7 +318,7 @@ static void FocusElementDraw( } } -static Ttk_ElementSpec FocusElementSpec = { +static const Ttk_ElementSpec FocusElementSpec = { TK_STYLE_VERSION_2, sizeof(FocusElement), FocusElementOptions, @@ -338,7 +338,7 @@ typedef struct { Tcl_Obj *borderObj; } SeparatorElement; -static Ttk_ElementOptionSpec SeparatorElementOptions[] = { +static const Ttk_ElementOptionSpec SeparatorElementOptions[] = { { "-orient", TK_OPTION_ANY, offsetof(SeparatorElement, orientObj), "horizontal" }, { "-background", TK_OPTION_BORDER, @@ -398,7 +398,7 @@ static void GeneralSeparatorElementDraw( } } -static Ttk_ElementSpec HorizontalSeparatorElementSpec = { +static const Ttk_ElementSpec HorizontalSeparatorElementSpec = { TK_STYLE_VERSION_2, sizeof(SeparatorElement), SeparatorElementOptions, @@ -406,7 +406,7 @@ static Ttk_ElementSpec HorizontalSeparatorElementSpec = { HorizontalSeparatorElementDraw }; -static Ttk_ElementSpec VerticalSeparatorElementSpec = { +static const Ttk_ElementSpec VerticalSeparatorElementSpec = { TK_STYLE_VERSION_2, sizeof(SeparatorElement), SeparatorElementOptions, @@ -414,7 +414,7 @@ static Ttk_ElementSpec VerticalSeparatorElementSpec = { HorizontalSeparatorElementDraw }; -static Ttk_ElementSpec SeparatorElementSpec = { +static const Ttk_ElementSpec SeparatorElementSpec = { TK_STYLE_VERSION_2, sizeof(SeparatorElement), SeparatorElementOptions, @@ -430,7 +430,7 @@ typedef struct { Tcl_Obj *backgroundObj; } SizegripElement; -static Ttk_ElementOptionSpec SizegripOptions[] = { +static const Ttk_ElementOptionSpec SizegripOptions[] = { { "-background", TK_OPTION_BORDER, offsetof(SizegripElement,backgroundObj), DEFAULT_BACKGROUND }, {0,0,0,0} @@ -463,7 +463,7 @@ static void SizegripDraw( } } -static Ttk_ElementSpec SizegripElementSpec = { +static const Ttk_ElementSpec SizegripElementSpec = { TK_STYLE_VERSION_2, sizeof(SizegripElement), SizegripOptions, @@ -491,7 +491,7 @@ typedef struct { Tcl_Obj *borderWidthObj; } IndicatorElement; -static Ttk_ElementOptionSpec IndicatorElementOptions[] = { +static const Ttk_ElementOptionSpec IndicatorElementOptions[] = { { "-background", TK_OPTION_BORDER, offsetof(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND }, { "-indicatorcolor", TK_OPTION_BORDER, @@ -601,7 +601,7 @@ static void DiamondIndicatorElementDraw( Tk_Draw3DPolygon(tkwin,d,border,points,4,borderWidth,relief); } -static Ttk_ElementSpec CheckbuttonIndicatorElementSpec = { +static const Ttk_ElementSpec CheckbuttonIndicatorElementSpec = { TK_STYLE_VERSION_2, sizeof(IndicatorElement), IndicatorElementOptions, @@ -609,7 +609,7 @@ static Ttk_ElementSpec CheckbuttonIndicatorElementSpec = { SquareIndicatorElementDraw }; -static Ttk_ElementSpec RadiobuttonIndicatorElementSpec = { +static const Ttk_ElementSpec RadiobuttonIndicatorElementSpec = { TK_STYLE_VERSION_2, sizeof(IndicatorElement), IndicatorElementOptions, @@ -637,7 +637,7 @@ typedef struct { Tcl_Obj *marginObj; } MenuIndicatorElement; -static Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = { +static const Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = { { "-background", TK_OPTION_BORDER, offsetof(MenuIndicatorElement,backgroundObj), DEFAULT_BACKGROUND }, { "-indicatorwidth", TK_OPTION_PIXELS, @@ -682,7 +682,7 @@ static void MenuIndicatorElementDraw( borderWidth, TK_RELIEF_RAISED); } -static Ttk_ElementSpec MenuIndicatorElementSpec = { +static const Ttk_ElementSpec MenuIndicatorElementSpec = { TK_STYLE_VERSION_2, sizeof(MenuIndicatorElement), MenuIndicatorElementOptions, @@ -706,7 +706,7 @@ typedef struct { Tcl_Obj *colorObj; } ArrowElement; -static Ttk_ElementOptionSpec ArrowElementOptions[] = { +static const Ttk_ElementOptionSpec ArrowElementOptions[] = { { "-background", TK_OPTION_BORDER, offsetof(ArrowElement,borderObj), DEFAULT_BACKGROUND }, { "-relief",TK_OPTION_RELIEF, @@ -757,7 +757,7 @@ static void ArrowElementDraw( Ttk_PadBox(b, ArrowMargins), direction); } -static Ttk_ElementSpec ArrowElementSpec = { +static const Ttk_ElementSpec ArrowElementSpec = { TK_STYLE_VERSION_2, sizeof(ArrowElement), ArrowElementOptions, @@ -777,7 +777,7 @@ typedef struct { Tcl_Obj *reliefObj; } TroughElement; -static Ttk_ElementOptionSpec TroughElementOptions[] = { +static const Ttk_ElementOptionSpec TroughElementOptions[] = { { "-borderwidth", TK_OPTION_PIXELS, offsetof(TroughElement,borderWidthObj), DEFAULT_BORDERWIDTH }, { "-troughcolor", TK_OPTION_BORDER, @@ -814,7 +814,7 @@ static void TroughElementDraw( borderWidth, relief); } -static Ttk_ElementSpec TroughElementSpec = { +static const Ttk_ElementSpec TroughElementSpec = { TK_STYLE_VERSION_2, sizeof(TroughElement), TroughElementOptions, @@ -837,7 +837,7 @@ typedef struct { Tcl_Obj *borderWidthObj; } ThumbElement; -static Ttk_ElementOptionSpec ThumbElementOptions[] = { +static const Ttk_ElementOptionSpec ThumbElementOptions[] = { { "-orient", TK_OPTION_ANY, offsetof(ThumbElement, orientObj), "horizontal" }, { "-width", TK_OPTION_PIXELS, @@ -884,7 +884,7 @@ static void ThumbElementDraw( borderWidth, relief); } -static Ttk_ElementSpec ThumbElementSpec = { +static const Ttk_ElementSpec ThumbElementSpec = { TK_STYLE_VERSION_2, sizeof(ThumbElement), ThumbElementOptions, @@ -908,7 +908,7 @@ typedef struct { Tcl_Obj *borderWidthObj; /* the size of the border */ } SliderElement; -static Ttk_ElementOptionSpec SliderElementOptions[] = { +static const Ttk_ElementOptionSpec SliderElementOptions[] = { { "-sliderlength", TK_OPTION_PIXELS, offsetof(SliderElement,lengthObj), "30" }, { "-sliderthickness",TK_OPTION_PIXELS, offsetof(SliderElement,thicknessObj), @@ -990,7 +990,7 @@ static void SliderElementDraw( } } -static Ttk_ElementSpec SliderElementSpec = { +static const Ttk_ElementSpec SliderElementSpec = { TK_STYLE_VERSION_2, sizeof(SliderElement), SliderElementOptions, @@ -1019,7 +1019,7 @@ typedef struct { Tcl_Obj *borderWidthObj; /* thickness of the border */ } PbarElement; -static Ttk_ElementOptionSpec PbarElementOptions[] = { +static const Ttk_ElementOptionSpec PbarElementOptions[] = { { "-orient", TK_OPTION_ANY, offsetof(PbarElement,orientObj), "horizontal" }, { "-thickness", TK_OPTION_PIXELS, offsetof(PbarElement,thicknessObj), @@ -1075,7 +1075,7 @@ static void PbarElementDraw( borderWidth, relief); } -static Ttk_ElementSpec PbarElementSpec = { +static const Ttk_ElementSpec PbarElementSpec = { TK_STYLE_VERSION_2, sizeof(PbarElement), PbarElementOptions, @@ -1092,7 +1092,7 @@ typedef struct { Tcl_Obj *backgroundObj; } TabElement; -static Ttk_ElementOptionSpec TabElementOptions[] = { +static const Ttk_ElementOptionSpec TabElementOptions[] = { { "-borderwidth", TK_OPTION_PIXELS, offsetof(TabElement,borderWidthObj),"1" }, { "-background", TK_OPTION_BORDER, @@ -1163,7 +1163,7 @@ static void TabElementDraw( } -static Ttk_ElementSpec TabElementSpec = { +static const Ttk_ElementSpec TabElementSpec = { TK_STYLE_VERSION_2, sizeof(TabElement), TabElementOptions, @@ -1202,7 +1202,7 @@ static void ClientElementSize( *paddingPtr = Ttk_UniformPadding((short)borderWidth); } -static Ttk_ElementSpec ClientElementSpec = { +static const Ttk_ElementSpec ClientElementSpec = { TK_STYLE_VERSION_2, sizeof(ClientElement), ClientElementOptions, diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index 842c4b5..e05c153 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -154,7 +154,7 @@ typedef struct { #define DEF_ENTRY_FONT "TkTextFont" #define DEF_LIST_HEIGHT "10" -static Tk_OptionSpec EntryOptionSpecs[] = { +static const Tk_OptionSpec EntryOptionSpecs[] = { {TK_OPTION_BOOLEAN, "-exportselection", "exportSelection", "ExportSelection", "1", -1, offsetof(Entry, entry.exportSelection), 0,0,0 }, @@ -1772,7 +1772,7 @@ typedef struct { ComboboxPart combobox; } Combobox; -static Tk_OptionSpec ComboboxOptionSpecs[] = { +static const Tk_OptionSpec ComboboxOptionSpecs[] = { {TK_OPTION_STRING, "-height", "height", "Height", DEF_LIST_HEIGHT, offsetof(Combobox, combobox.heightObj), -1, 0,0,0 }, @@ -1963,7 +1963,7 @@ typedef struct { SpinboxPart spinbox; } Spinbox; -static Tk_OptionSpec SpinboxOptionSpecs[] = { +static const Tk_OptionSpec SpinboxOptionSpecs[] = { {TK_OPTION_STRING, "-values", "values", "Values", "", offsetof(Spinbox, spinbox.valuesObj), -1, 0,0,0 }, @@ -2065,7 +2065,7 @@ typedef struct { Tcl_Obj *widthObj; } TextareaElement; -static Ttk_ElementOptionSpec TextareaElementOptions[] = { +static const Ttk_ElementOptionSpec TextareaElementOptions[] = { { "-font", TK_OPTION_FONT, offsetof(TextareaElement,fontObj), DEF_ENTRY_FONT }, { "-width", TK_OPTION_INT, @@ -2092,7 +2092,7 @@ static void TextareaElementSize( *widthPtr = prefWidth * avgWidth; } -static Ttk_ElementSpec TextareaElementSpec = { +static const Ttk_ElementSpec TextareaElementSpec = { TK_STYLE_VERSION_2, sizeof(TextareaElement), TextareaElementOptions, diff --git a/generic/ttk/ttkFrame.c b/generic/ttk/ttkFrame.c index bb3dd35..20fcea3 100644 --- a/generic/ttk/ttkFrame.c +++ b/generic/ttk/ttkFrame.c @@ -26,7 +26,7 @@ typedef struct { FramePart frame; } Frame; -static Tk_OptionSpec FrameOptionSpecs[] = { +static const Tk_OptionSpec FrameOptionSpecs[] = { {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", NULL, offsetof(Frame,frame.borderWidthObj), -1, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, @@ -247,7 +247,7 @@ typedef struct { #define LABELWIDGET_CHANGED 0x100 -static Tk_OptionSpec LabelframeOptionSpecs[] = { +static const Tk_OptionSpec LabelframeOptionSpecs[] = { {TK_OPTION_STRING, "-labelanchor", "labelAnchor", "LabelAnchor", "nw", offsetof(Labelframe, label.labelAnchorObj),-1, 0,0,GEOMETRY_CHANGED}, diff --git a/generic/ttk/ttkImage.c b/generic/ttk/ttkImage.c index 002a753..bcac5c1 100644 --- a/generic/ttk/ttkImage.c +++ b/generic/ttk/ttkImage.c @@ -324,7 +324,7 @@ static void ImageElementDraw( Ttk_Tile(tkwin, d, image, src, dst, imageData->border); } -static Ttk_ElementSpec ImageElementSpec = +static const Ttk_ElementSpec ImageElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), diff --git a/generic/ttk/ttkInit.c b/generic/ttk/ttkInit.c index c62e362..f15a556 100644 --- a/generic/ttk/ttkInit.c +++ b/generic/ttk/ttkInit.c @@ -12,7 +12,7 @@ * Legal values for the button -default option. * See also: enum Ttk_ButtonDefaultState. */ -const char *ttkDefaultStrings[] = { +const char *const ttkDefaultStrings[] = { "normal", "active", "disabled", NULL }; @@ -28,7 +28,7 @@ int Ttk_GetButtonDefaultStateFromObj( * Legal values for the -compound option. * See also: enum Ttk_Compound. */ -const char *ttkCompoundStrings[] = { +const char *const ttkCompoundStrings[] = { "none", "text", "image", "center", "top", "bottom", "left", "right", NULL }; @@ -45,7 +45,7 @@ int Ttk_GetCompoundFromObj( * Legal values for the -orient option. * See also: enum Ttk_Orient. */ -const char *ttkOrientStrings[] = { +const char *const ttkOrientStrings[] = { "horizontal", "vertical", NULL }; @@ -175,7 +175,7 @@ int TtkGetOptionValue( */ /* public */ -Tk_OptionSpec ttkCoreOptionSpecs[] = +const Tk_OptionSpec ttkCoreOptionSpecs[] = { {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", NULL, offsetof(WidgetCore, cursorObj), -1, TK_OPTION_NULL_OK,0,0 }, diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c index 2367f99..b680fcd 100644 --- a/generic/ttk/ttkLabel.c +++ b/generic/ttk/ttkLabel.c @@ -46,7 +46,7 @@ typedef struct { /* Text element options table. * NB: Keep in sync with label element option table. */ -static Ttk_ElementOptionSpec TextElementOptions[] = { +static const Ttk_ElementOptionSpec TextElementOptions[] = { { "-text", TK_OPTION_STRING, offsetof(TextElement,textObj), "" }, { "-font", TK_OPTION_FONT, @@ -220,7 +220,7 @@ static void TextElementDraw( } } -static Ttk_ElementSpec TextElementSpec = { +static const Ttk_ElementSpec TextElementSpec = { TK_STYLE_VERSION_2, sizeof(TextElement), TextElementOptions, @@ -246,7 +246,7 @@ typedef struct { /* ===> NB: Keep in sync with label element option table. <=== */ -static Ttk_ElementOptionSpec ImageElementOptions[] = { +static const Ttk_ElementOptionSpec ImageElementOptions[] = { { "-image", TK_OPTION_STRING, offsetof(ImageElement,imageObj), "" }, { "-stipple", TK_OPTION_STRING, /* Really: TK_OPTION_BITMAP */ @@ -384,7 +384,7 @@ static void ImageElementDraw( } } -static Ttk_ElementSpec ImageElementSpec = { +static const Ttk_ElementSpec ImageElementSpec = { TK_STYLE_VERSION_2, sizeof(ImageElement), ImageElementOptions, @@ -440,7 +440,7 @@ typedef struct { int totalWidth, totalHeight; } LabelElement; -static Ttk_ElementOptionSpec LabelElementOptions[] = { +static const Ttk_ElementOptionSpec LabelElementOptions[] = { { "-compound", TK_OPTION_ANY, offsetof(LabelElement,compoundObj), "none" }, { "-space", TK_OPTION_PIXELS, @@ -673,7 +673,7 @@ static void LabelElementDraw( LabelCleanup(l); } -static Ttk_ElementSpec LabelElementSpec = { +static const Ttk_ElementSpec LabelElementSpec = { TK_STYLE_VERSION_2, sizeof(LabelElement), LabelElementOptions, diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index e167374..d1fa1e0 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -55,7 +55,7 @@ typedef struct * PaneOptionSpecs includes additional options for child window placement * and is used to configure the slave. */ -static Tk_OptionSpec TabOptionSpecs[] = +static const Tk_OptionSpec TabOptionSpecs[] = { {TK_OPTION_STRING_TABLE, "-state", "", "", "normal", -1, offsetof(Tab,state), @@ -66,13 +66,13 @@ static Tk_OptionSpec TabOptionSpecs[] = offsetof(Tab,imageObj), -1, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", NULL, offsetof(Tab,compoundObj), -1, - TK_OPTION_NULL_OK,(ClientData)ttkCompoundStrings,GEOMETRY_CHANGED }, + TK_OPTION_NULL_OK,(void *)ttkCompoundStrings,GEOMETRY_CHANGED }, {TK_OPTION_INT, "-underline", "underline", "Underline", "-1", offsetof(Tab,underlineObj), -1, 0,0,GEOMETRY_CHANGED }, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0 } }; -static Tk_OptionSpec PaneOptionSpecs[] = +static const Tk_OptionSpec PaneOptionSpecs[] = { {TK_OPTION_STRING, "-padding", "padding", "Padding", "0", offsetof(Tab,paddingObj), -1, 0,0,GEOMETRY_CHANGED }, @@ -107,7 +107,7 @@ typedef struct NotebookPart notebook; } Notebook; -static Tk_OptionSpec NotebookOptionSpecs[] = +static const Tk_OptionSpec NotebookOptionSpecs[] = { {TK_OPTION_INT, "-width", "width", "Width", "0", offsetof(Notebook,notebook.widthObj),-1, diff --git a/generic/ttk/ttkPanedwindow.c b/generic/ttk/ttkPanedwindow.c index 1b6ff3d..755b2d6 100644 --- a/generic/ttk/ttkPanedwindow.c +++ b/generic/ttk/ttkPanedwindow.c @@ -74,7 +74,7 @@ typedef struct { /* @@@ NOTE: -orient is readonly 'cause dynamic oriention changes NYI */ -static Tk_OptionSpec PanedOptionSpecs[] = { +static const Tk_OptionSpec PanedOptionSpecs[] = { {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical", offsetof(Paned,paned.orientObj), offsetof(Paned,paned.orient), 0,(ClientData)ttkOrientStrings,READONLY_OPTION|STYLE_CHANGED }, @@ -98,7 +98,7 @@ typedef struct { int weight; /* Pane -weight, for resizing */ } Pane; -static Tk_OptionSpec PaneOptionSpecs[] = { +static const Tk_OptionSpec PaneOptionSpecs[] = { {TK_OPTION_INT, "-weight", "weight", "Weight", "0", -1, offsetof(Pane,weight), 0,0,GEOMETRY_CHANGED }, {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0} @@ -920,7 +920,7 @@ typedef struct { Tcl_Obj *thicknessObj; } SashElement; -static Ttk_ElementOptionSpec SashElementOptions[] = { +static const Ttk_ElementOptionSpec SashElementOptions[] = { { "-sashthickness", TK_OPTION_INT, offsetof(SashElement,thicknessObj), "5" }, { NULL, 0, 0, NULL } @@ -936,7 +936,7 @@ static void SashElementSize( *widthPtr = *heightPtr = thickness; } -static Ttk_ElementSpec SashElementSpec = { +static const Ttk_ElementSpec SashElementSpec = { TK_STYLE_VERSION_2, sizeof(SashElement), SashElementOptions, diff --git a/generic/ttk/ttkProgress.c b/generic/ttk/ttkProgress.c index f1dbb2f..b881c14 100644 --- a/generic/ttk/ttkProgress.c +++ b/generic/ttk/ttkProgress.c @@ -48,7 +48,7 @@ typedef struct { ProgressbarPart progress; } Progressbar; -static Tk_OptionSpec ProgressbarOptionSpecs[] = +static const Tk_OptionSpec ProgressbarOptionSpecs[] = { {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", "w", offsetof(Progressbar,progress.anchorObj), -1, diff --git a/generic/ttk/ttkScale.c b/generic/ttk/ttkScale.c index 0e20621..3184a78 100644 --- a/generic/ttk/ttkScale.c +++ b/generic/ttk/ttkScale.c @@ -50,7 +50,7 @@ typedef struct ScalePart scale; } Scale; -static Tk_OptionSpec ScaleOptionSpecs[] = +static const Tk_OptionSpec ScaleOptionSpecs[] = { {TK_OPTION_STRING, "-command", "command", "Command", "", offsetof(Scale,scale.commandObj), -1, diff --git a/generic/ttk/ttkScrollbar.c b/generic/ttk/ttkScrollbar.c index 2825c54..4648d91 100644 --- a/generic/ttk/ttkScrollbar.c +++ b/generic/ttk/ttkScrollbar.c @@ -31,7 +31,7 @@ typedef struct ScrollbarPart scrollbar; } Scrollbar; -static Tk_OptionSpec ScrollbarOptionSpecs[] = +static const Tk_OptionSpec ScrollbarOptionSpecs[] = { {TK_OPTION_STRING, "-command", "command", "Command", "", offsetof(Scrollbar,scrollbar.commandObj), -1, 0,0,0}, diff --git a/generic/ttk/ttkSeparator.c b/generic/ttk/ttkSeparator.c index f7bacdc..f7a9882 100644 --- a/generic/ttk/ttkSeparator.c +++ b/generic/ttk/ttkSeparator.c @@ -22,7 +22,7 @@ typedef struct SeparatorPart separator; } Separator; -static Tk_OptionSpec SeparatorOptionSpecs[] = { +static const Tk_OptionSpec SeparatorOptionSpecs[] = { {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal", offsetof(Separator,separator.orientObj), offsetof(Separator,separator.orient), @@ -83,7 +83,7 @@ TTK_END_LAYOUT * Has no options or methods other than the standard ones. */ -static Tk_OptionSpec SizegripOptionSpecs[] = { +static const Tk_OptionSpec SizegripOptionSpecs[] = { WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; diff --git a/generic/ttk/ttkSquare.c b/generic/ttk/ttkSquare.c index b82faa2..c67ef96 100644 --- a/generic/ttk/ttkSquare.c +++ b/generic/ttk/ttkSquare.c @@ -48,7 +48,7 @@ typedef struct * defined for all widgets. */ -static Tk_OptionSpec SquareOptionSpecs[] = +static const Tk_OptionSpec SquareOptionSpecs[] = { {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEFAULT_BORDERWIDTH, offsetof(Square,square.borderWidthObj), -1, @@ -176,7 +176,7 @@ typedef struct Tcl_Obj *heightObj; } SquareElement; -static Ttk_ElementOptionSpec SquareElementOptions[] = +static const Ttk_ElementOptionSpec SquareElementOptions[] = { { "-background", TK_OPTION_BORDER, offsetof(SquareElement,borderObj), DEFAULT_BACKGROUND }, @@ -230,7 +230,7 @@ static void SquareElementDraw( b.x, b.y, b.width, b.height, borderWidth, relief); } -static Ttk_ElementSpec SquareElementSpec = +static const Ttk_ElementSpec SquareElementSpec = { TK_STYLE_VERSION_2, sizeof(SquareElement), diff --git a/generic/ttk/ttkState.c b/generic/ttk/ttkState.c index 9e5cf4b..115aaf8 100644 --- a/generic/ttk/ttkState.c +++ b/generic/ttk/ttkState.c @@ -261,7 +261,7 @@ Ttk_StateMap Ttk_GetStateMapFromObj( * Ttk_StateTableLooup -- * Look up an index from a statically allocated state table. */ -int Ttk_StateTableLookup(Ttk_StateTable *map, unsigned int state) +int Ttk_StateTableLookup(const Ttk_StateTable *map, unsigned int state) { while ((state & map->onBits) != map->onBits || (~state & map->offBits) != map->offBits) diff --git a/generic/ttk/ttkTagSet.c b/generic/ttk/ttkTagSet.c index f0354d8..fac2cc2 100644 --- a/generic/ttk/ttkTagSet.c +++ b/generic/ttk/ttkTagSet.c @@ -19,7 +19,7 @@ struct TtkTag { struct TtkTagTable { Tk_Window tkwin; /* owner window */ - Tk_OptionSpec *optionSpecs; /* ... */ + const Tk_OptionSpec *optionSpecs; /* ... */ Tk_OptionTable optionTable; /* ... */ int recordSize; /* size of tag record */ int nTags; /* #tags defined so far */ @@ -53,7 +53,7 @@ static void DeleteTag(Ttk_TagTable tagTable, Ttk_Tag tag) Ttk_TagTable Ttk_CreateTagTable( Tcl_Interp *interp, Tk_Window tkwin, - Tk_OptionSpec optionSpecs[], int recordSize) + const Tk_OptionSpec *optionSpecs, int recordSize) { Ttk_TagTable tagTable = ckalloc(sizeof(*tagTable)); tagTable->tkwin = tkwin; @@ -269,7 +269,7 @@ void Ttk_TagSetValues(Ttk_TagTable tagTable, Ttk_TagSet tagSet, void *record) memset(record, 0, tagTable->recordSize); for (i = 0; tagTable->optionSpecs[i].type != TK_OPTION_END; ++i) { - Tk_OptionSpec *optionSpec = tagTable->optionSpecs + i; + const Tk_OptionSpec *optionSpec = tagTable->optionSpecs + i; int offset = optionSpec->objOffset; int prio = LOWEST_PRIORITY; @@ -286,7 +286,7 @@ void Ttk_TagSetValues(Ttk_TagTable tagTable, Ttk_TagSet tagSet, void *record) void Ttk_TagSetApplyStyle( Ttk_TagTable tagTable, Ttk_Style style, Ttk_State state, void *record) { - Tk_OptionSpec *optionSpec = tagTable->optionSpecs; + const Tk_OptionSpec *optionSpec = tagTable->optionSpecs; while (optionSpec->type != TK_OPTION_END) { int offset = optionSpec->objOffset; diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c index 9cb1b92..b492351 100644 --- a/generic/ttk/ttkTheme.c +++ b/generic/ttk/ttkTheme.c @@ -117,7 +117,7 @@ typedef const Tk_OptionSpec **OptionMap; struct Ttk_ElementClass_ { const char *name; /* Points to hash table key */ - Ttk_ElementSpec *specPtr; /* Template provided during registration. */ + const Ttk_ElementSpec *specPtr; /* Template provided during registration. */ void *clientData; /* Client data passed in at registration time */ void *elementRecord; /* Scratch buffer for element record storage */ int nResources; /* #Element options */ @@ -181,7 +181,7 @@ BuildOptionMap(Ttk_ElementClass *elementClass, Tk_OptionTable optionTable) int i; for (i = 0; i < elementClass->nResources; ++i) { - Ttk_ElementOptionSpec *e = elementClass->specPtr->options+i; + const Ttk_ElementOptionSpec *e = elementClass->specPtr->options+i; optionMap[i] = TTKGetOptionSpec(e->optionName, optionTable, e->type); } @@ -216,7 +216,7 @@ GetOptionMap(Ttk_ElementClass *elementClass, Tk_OptionTable optionTable) * from the specified element specification. */ static Ttk_ElementClass * -NewElementClass(const char *name, Ttk_ElementSpec *specPtr,void *clientData) +NewElementClass(const char *name, const Ttk_ElementSpec *specPtr, void *clientData) { Ttk_ElementClass *elementClass = ckalloc(sizeof(Ttk_ElementClass)); int i; @@ -868,7 +868,7 @@ Ttk_ElementClass *Ttk_RegisterElement( Tcl_Interp *interp, /* Where to leave error messages */ Ttk_Theme theme, /* Style engine providing the implementation. */ const char *name, /* Name of new element */ - Ttk_ElementSpec *specPtr, /* Static template information */ + const Ttk_ElementSpec *specPtr, /* Static template information */ void *clientData) /* application-specific data */ { Ttk_ElementClass *elementClass; @@ -909,7 +909,7 @@ Ttk_ElementClass *Ttk_RegisterElement( * Register a new element. */ int Ttk_RegisterElementSpec(Ttk_Theme theme, - const char *name, Ttk_ElementSpec *specPtr, void *clientData) + const char *name, const Ttk_ElementSpec *specPtr, void *clientData) { return Ttk_RegisterElement(NULL, theme, name, specPtr, clientData) ? TCL_OK : TCL_ERROR; @@ -982,7 +982,7 @@ int InitializeElementRecord( OptionMap optionMap = GetOptionMap(eclass,optionTable); int nResources = eclass->nResources; Ttk_ResourceCache cache = style->cache; - Ttk_ElementOptionSpec *elementOption = eclass->specPtr->options; + const Ttk_ElementOptionSpec *elementOption = eclass->specPtr->options; int i; for (i=0; ispecPtr; - Ttk_ElementOptionSpec *option = specPtr->options; + const Ttk_ElementSpec *specPtr = elementClass->specPtr; + const Ttk_ElementOptionSpec *option = specPtr->options; Tcl_Obj *result = Tcl_NewListObj(0,0); while (option->optionName) { diff --git a/generic/ttk/ttkTheme.h b/generic/ttk/ttkTheme.h index e067337..1dc7423 100644 --- a/generic/ttk/ttkTheme.h +++ b/generic/ttk/ttkTheme.h @@ -96,7 +96,7 @@ typedef struct unsigned int offBits; /* Bits which must be cleared */ } Ttk_StateTable; -TTKAPI int Ttk_StateTableLookup(Ttk_StateTable map[], Ttk_State); +TTKAPI int Ttk_StateTableLookup(const Ttk_StateTable *map, Ttk_State); /*------------------------------------------------------------------------ * +++ Padding. @@ -259,14 +259,14 @@ typedef struct Ttk_ElementOptionSpec typedef struct Ttk_ElementSpec { enum TTKStyleVersion2 version; /* Version of the style support. */ size_t elementSize; /* Size of element record */ - Ttk_ElementOptionSpec *options; /* List of options, NULL-terminated */ + const Ttk_ElementOptionSpec *options; /* List of options, NULL-terminated */ Ttk_ElementSizeProc *size; /* Compute min size and padding */ Ttk_ElementDrawProc *draw; /* Draw the element */ } Ttk_ElementSpec; TTKAPI Ttk_ElementClass *Ttk_RegisterElement( Tcl_Interp *interp, Ttk_Theme theme, const char *elementName, - Ttk_ElementSpec *, void *clientData); + const Ttk_ElementSpec *, void *clientData); typedef int (*Ttk_ElementFactory) (Tcl_Interp *, void *clientData, @@ -288,7 +288,7 @@ MODULE_SCOPE void TtkNullElementSize (void *, void *, Tk_Window, int *, int *, Ttk_Padding *); MODULE_SCOPE void TtkNullElementDraw (void *, void *, Tk_Window, Drawable, Ttk_Box, Ttk_State); -MODULE_SCOPE Ttk_ElementOptionSpec TtkNullElementOptions[]; +MODULE_SCOPE const Ttk_ElementOptionSpec TtkNullElementOptions[]; MODULE_SCOPE Ttk_ElementSpec ttkNullElementSpec; /*------------------------------------------------------------------------ diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index a11389b..eb9c445 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -59,7 +59,7 @@ struct TreeItemRec { #define ITEM_OPTION_TAGS_CHANGED 0x100 #define ITEM_OPTION_IMAGE_CHANGED 0x200 -static Tk_OptionSpec ItemOptionSpecs[] = { +static const Tk_OptionSpec ItemOptionSpecs[] = { {TK_OPTION_STRING, "-text", "text", "Text", "", offsetof(TreeItem,textObj), -1, 0,0,0 }, @@ -187,7 +187,7 @@ typedef struct { Tcl_Obj *fontObj; } DisplayItem; -static Tk_OptionSpec TagOptionSpecs[] = { +static const Tk_OptionSpec TagOptionSpecs[] = { {TK_OPTION_STRING, "-text", "text", "Text", NULL, offsetof(DisplayItem,textObj), -1, TK_OPTION_NULL_OK,0,0 }, @@ -271,7 +271,7 @@ static void FreeColumn(TreeColumn *column) /* Don't touch column->data, it's scratch storage */ } -static Tk_OptionSpec ColumnOptionSpecs[] = { +static const Tk_OptionSpec ColumnOptionSpecs[] = { {TK_OPTION_INT, "-width", "width", "Width", DEF_COLWIDTH, -1, offsetof(TreeColumn,width), 0,0,GEOMETRY_CHANGED }, @@ -290,7 +290,7 @@ static Tk_OptionSpec ColumnOptionSpecs[] = { {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0} }; -static Tk_OptionSpec HeadingOptionSpecs[] = { +static const Tk_OptionSpec HeadingOptionSpecs[] = { {TK_OPTION_STRING, "-text", "text", "Text", "", offsetof(TreeColumn,headingObj), -1, 0,0,0 }, @@ -435,7 +435,7 @@ typedef struct { static const char *const SelectModeStrings[] = { "none", "browse", "extended", NULL }; -static Tk_OptionSpec TreeviewOptionSpecs[] = { +static const Tk_OptionSpec TreeviewOptionSpecs[] = { {TK_OPTION_STRING, "-columns", "columns", "Columns", "", offsetof(Treeview,tree.columnsObj), -1, 0,0,COLUMNS_CHANGED | GEOMETRY_CHANGED /*| READONLY_OPTION*/ }, @@ -3348,7 +3348,7 @@ typedef struct { Tcl_Obj *marginsObj; } TreeitemIndicator; -static Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = { +static const Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = { { "-foreground", TK_OPTION_COLOR, offsetof(TreeitemIndicator,colorObj), DEFAULT_FOREGROUND }, { "-indicatorsize", TK_OPTION_PIXELS, @@ -3400,7 +3400,7 @@ static void TreeitemIndicatorDraw( Tk_FreeGC(Tk_Display(tkwin), gc); } -static Ttk_ElementSpec TreeitemIndicatorElementSpec = { +static const Ttk_ElementSpec TreeitemIndicatorElementSpec = { TK_STYLE_VERSION_2, sizeof(TreeitemIndicator), TreeitemIndicatorOptions, @@ -3417,7 +3417,7 @@ typedef struct { Tcl_Obj *rowNumberObj; } RowElement; -static Ttk_ElementOptionSpec RowElementOptions[] = { +static const Ttk_ElementOptionSpec RowElementOptions[] = { { "-background", TK_OPTION_COLOR, offsetof(RowElement,backgroundObj), DEFAULT_BACKGROUND }, { "-rownumber", TK_OPTION_INT, @@ -3436,7 +3436,7 @@ static void RowElementDraw( b.x, b.y, b.width, b.height); } -static Ttk_ElementSpec RowElementSpec = { +static const Ttk_ElementSpec RowElementSpec = { TK_STYLE_VERSION_2, sizeof(RowElement), RowElementOptions, diff --git a/generic/ttk/ttkWidget.h b/generic/ttk/ttkWidget.h index e764c3a..97a01f8 100644 --- a/generic/ttk/ttkWidget.h +++ b/generic/ttk/ttkWidget.h @@ -131,7 +131,7 @@ MODULE_SCOPE int TtkWidgetConstructorObjCmd( /* All widgets should inherit from ttkCoreOptionSpecs[]. */ -MODULE_SCOPE Tk_OptionSpec ttkCoreOptionSpecs[]; +MODULE_SCOPE const Tk_OptionSpec ttkCoreOptionSpecs[]; /* * Useful routines for use inside widget implementations: @@ -212,7 +212,7 @@ typedef struct TtkTagSet { /* TODO: make opaque */ } *Ttk_TagSet; MODULE_SCOPE Ttk_TagTable Ttk_CreateTagTable( - Tcl_Interp *, Tk_Window tkwin, Tk_OptionSpec[], int recordSize); + Tcl_Interp *, Tk_Window tkwin, const Tk_OptionSpec *, int recordSize); MODULE_SCOPE void Ttk_DeleteTagTable(Ttk_TagTable); MODULE_SCOPE Ttk_Tag Ttk_GetTag(Ttk_TagTable, const char *tagName); @@ -247,9 +247,9 @@ MODULE_SCOPE void Ttk_TagSetApplyStyle(Ttk_TagTable,Ttk_Style,Ttk_State,void*); * String tables for widget resource specifications: */ -MODULE_SCOPE const char *ttkOrientStrings[]; -MODULE_SCOPE const char *ttkCompoundStrings[]; -MODULE_SCOPE const char *ttkDefaultStrings[]; +MODULE_SCOPE const char *const ttkOrientStrings[]; +MODULE_SCOPE const char *const ttkCompoundStrings[]; +MODULE_SCOPE const char *const ttkDefaultStrings[]; /* * ... other option types... diff --git a/win/ttkWinMonitor.c b/win/ttkWinMonitor.c index dff44e6..1d31c1c 100644 --- a/win/ttkWinMonitor.c +++ b/win/ttkWinMonitor.c @@ -22,7 +22,7 @@ typedef struct { int index; } SystemColorEntry; -static SystemColorEntry sysColors[] = { +static const SystemColorEntry sysColors[] = { { "System3dDarkShadow", COLOR_3DDKSHADOW }, { "System3dLight", COLOR_3DLIGHT }, { "SystemActiveBorder", COLOR_ACTIVEBORDER }, @@ -55,7 +55,7 @@ static SystemColorEntry sysColors[] = { static void RegisterSystemColors(Tcl_Interp *interp) { Ttk_ResourceCache cache = Ttk_GetResourceCache(interp); - SystemColorEntry *sysColor; + const SystemColorEntry *sysColor; for (sysColor = sysColors; sysColor->name; ++sysColor) { DWORD pixel = GetSysColor(sysColor->index); diff --git a/win/ttkWinTheme.c b/win/ttkWinTheme.c index ad3c94e..4a74c86 100644 --- a/win/ttkWinTheme.c +++ b/win/ttkWinTheme.c @@ -54,7 +54,7 @@ static unsigned int ReliefToEdge(int relief) * +++ State tables for FrameControlElements. */ -static Ttk_StateTable checkbutton_statemap[] = { /* see also SF#1865898 */ +static const Ttk_StateTable checkbutton_statemap[] = { /* see also SF#1865898 */ { DFCS_BUTTON3STATE|DFCS_CHECKED|DFCS_INACTIVE, TTK_STATE_ALTERNATE|TTK_STATE_DISABLED, 0 }, { DFCS_BUTTON3STATE|DFCS_CHECKED|DFCS_PUSHED, @@ -75,14 +75,14 @@ static Ttk_StateTable checkbutton_statemap[] = { /* see also SF#1865898 */ { 0, 0, 0 }, }; -static Ttk_StateTable pushbutton_statemap[] = { +static const Ttk_StateTable pushbutton_statemap[] = { { DFCS_INACTIVE, TTK_STATE_DISABLED, 0 }, { DFCS_PUSHED, TTK_STATE_PRESSED, 0 }, { DFCS_HOT, TTK_STATE_ACTIVE, 0 }, { 0, 0, 0 } }; -static Ttk_StateTable arrow_statemap[] = { +static const Ttk_StateTable arrow_statemap[] = { { DFCS_INACTIVE, TTK_STATE_DISABLED, 0 }, { DFCS_PUSHED | DFCS_FLAT, TTK_STATE_PRESSED, 0 }, { 0, 0, 0 } @@ -98,7 +98,7 @@ typedef struct { int partId; /* part id for DrawFrameControl */ int cxId; /* system metric ids for width/height... */ int cyId; /* ... or size if FIXEDSIZE bit set */ - Ttk_StateTable *stateMap; /* map Tk states to Win32 flags */ + const Ttk_StateTable *stateMap; /* map Tk states to Win32 flags */ Ttk_Padding margins; /* additional placement padding */ } FrameControlElementData; @@ -109,7 +109,7 @@ typedef struct { #define GETMETRIC(m) \ ((m) & _FIXEDSIZE ? (int)((m) & ~_FIXEDSIZE) : GetSystemMetrics((m)&0x0fffffff)) -static FrameControlElementData FrameControlElements[] = { +static const FrameControlElementData FrameControlElements[] = { { "Checkbutton.indicator", DFC_BUTTON, DFCS_BUTTONCHECK, FIXEDSIZE(13), FIXEDSIZE(13), checkbutton_statemap, {0,0,4,0} }, @@ -171,7 +171,7 @@ static void FrameControlElementDraw( TkWinReleaseDrawableDC(d, hdc, &dcState); } -static Ttk_ElementSpec FrameControlElementSpec = { +static const Ttk_ElementSpec FrameControlElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, @@ -187,7 +187,7 @@ typedef struct { Tcl_Obj *reliefObj; } BorderElement; -static Ttk_ElementOptionSpec BorderElementOptions[] = { +static const Ttk_ElementOptionSpec BorderElementOptions[] = { { "-relief",TK_OPTION_RELIEF, offsetof(BorderElement,reliefObj), "flat" }, {NULL, 0, 0, NULL} }; @@ -220,7 +220,7 @@ static void BorderElementDraw( } } -static Ttk_ElementSpec BorderElementSpec = { +static const Ttk_ElementSpec BorderElementSpec = { TK_STYLE_VERSION_2, sizeof(BorderElement), BorderElementOptions, @@ -237,7 +237,7 @@ typedef struct { Tcl_Obj *backgroundObj; } FieldElement; -static Ttk_ElementOptionSpec FieldElementOptions[] = { +static const Ttk_ElementOptionSpec FieldElementOptions[] = { { "-fieldbackground", TK_OPTION_BORDER, offsetof(FieldElement,backgroundObj), "white" }, { NULL, 0, 0, NULL } @@ -269,7 +269,7 @@ static void FieldElementDraw( TkWinReleaseDrawableDC(d, hdc, &dcState); } -static Ttk_ElementSpec FieldElementSpec = { +static const Ttk_ElementSpec FieldElementSpec = { TK_STYLE_VERSION_2, sizeof(FieldElement), FieldElementOptions, @@ -288,7 +288,7 @@ typedef struct { Tcl_Obj *defaultStateObj; } ButtonBorderElement; -static Ttk_ElementOptionSpec ButtonBorderElementOptions[] = { +static const Ttk_ElementOptionSpec ButtonBorderElementOptions[] = { { "-relief",TK_OPTION_RELIEF, offsetof(ButtonBorderElement,reliefObj), "flat" }, { "-highlightcolor",TK_OPTION_COLOR, @@ -367,7 +367,7 @@ static void ButtonBorderElementDraw( TkWinReleaseDrawableDC(d, hdc, &dcState); } -static Ttk_ElementSpec ButtonBorderElementSpec = { +static const Ttk_ElementSpec ButtonBorderElementSpec = { TK_STYLE_VERSION_2, sizeof(ButtonBorderElement), ButtonBorderElementOptions, @@ -400,7 +400,7 @@ static void FocusElementDraw( } } -static Ttk_ElementSpec FocusElementSpec = { +static const Ttk_ElementSpec FocusElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, @@ -416,7 +416,7 @@ typedef struct { Tcl_Obj *fillColorObj; } FillFocusElement; -static Ttk_ElementOptionSpec FillFocusElementOptions[] = { +static const Ttk_ElementOptionSpec FillFocusElementOptions[] = { { "-focusfill", TK_OPTION_COLOR, offsetof(FillFocusElement,fillColorObj), "white" }, {NULL, 0, 0, NULL} @@ -455,7 +455,7 @@ static void ComboboxFocusElementDraw( } } -static Ttk_ElementSpec ComboboxFocusElementSpec = { +static const Ttk_ElementSpec ComboboxFocusElementSpec = { TK_STYLE_VERSION_2, sizeof(FillFocusElement), FillFocusElementOptions, @@ -525,7 +525,7 @@ static void TroughElementDraw( TkWinReleaseDrawableDC(d, hdc, &dcState); } -static Ttk_ElementSpec TroughElementSpec = { +static const Ttk_ElementSpec TroughElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, @@ -541,7 +541,7 @@ typedef struct { Tcl_Obj *orientObj; } ThumbElement; -static Ttk_ElementOptionSpec ThumbElementOptions[] = { +static const Ttk_ElementOptionSpec ThumbElementOptions[] = { { "-orient", TK_OPTION_ANY, offsetof(ThumbElement,orientObj),"horizontal"}, { NULL, 0, 0, NULL } }; @@ -580,7 +580,7 @@ static void ThumbElementDraw( TkWinReleaseDrawableDC(d, hdc, &dcState); } -static Ttk_ElementSpec ThumbElementSpec = { +static const Ttk_ElementSpec ThumbElementSpec = { TK_STYLE_VERSION_2, sizeof(ThumbElement), ThumbElementOptions, @@ -597,7 +597,7 @@ typedef struct { Tcl_Obj *orientObj; /* orientation of the slider widget */ } SliderElement; -static Ttk_ElementOptionSpec SliderElementOptions[] = { +static const Ttk_ElementOptionSpec SliderElementOptions[] = { { "-orient", TK_OPTION_ANY, offsetof(SliderElement,orientObj), "horizontal" }, { NULL, 0, 0, NULL } @@ -633,7 +633,7 @@ static void SliderElementDraw( TkWinReleaseDrawableDC(d, hdc, &dcState); } -static Ttk_ElementSpec SliderElementSpec = { +static const Ttk_ElementSpec SliderElementSpec = { TK_STYLE_VERSION_2, sizeof(SliderElement), SliderElementOptions, @@ -664,7 +664,7 @@ static void ClientElementDraw( TkWinReleaseDrawableDC(d, hdc, &dcState); } -static Ttk_ElementSpec ClientElementSpec = { +static const Ttk_ElementSpec ClientElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, @@ -698,7 +698,7 @@ MODULE_SCOPE int TtkWinTheme_Init(Tcl_Interp *interp, HWND hwnd) { Ttk_Theme themePtr, parentPtr; - FrameControlElementData *fce = FrameControlElements; + const FrameControlElementData *fce = FrameControlElements; parentPtr = Ttk_GetTheme(interp, "alt"); themePtr = Ttk_CreateTheme(interp, "winnative", parentPtr); @@ -722,7 +722,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 784a96d..e63b5fe 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -166,12 +166,12 @@ BoxToRect(Ttk_Box b) /* * Map Tk state bitmaps to XP style enumerated values. */ -static Ttk_StateTable null_statemap[] = { {0,0,0} }; +static const Ttk_StateTable null_statemap[] = { {0,0,0} }; /* * Pushbuttons (Tk: "Button") */ -static Ttk_StateTable pushbutton_statemap[] = +static const Ttk_StateTable pushbutton_statemap[] = { { PBS_DISABLED, TTK_STATE_DISABLED, 0 }, { PBS_PRESSED, TTK_STATE_PRESSED, 0 }, @@ -183,7 +183,7 @@ static Ttk_StateTable pushbutton_statemap[] = /* * Checkboxes (Tk: "Checkbutton") */ -static Ttk_StateTable checkbox_statemap[] = +static const Ttk_StateTable checkbox_statemap[] = { {CBS_MIXEDDISABLED, TTK_STATE_ALTERNATE|TTK_STATE_DISABLED, 0}, {CBS_MIXEDPRESSED, TTK_STATE_ALTERNATE|TTK_STATE_PRESSED, 0}, @@ -202,7 +202,7 @@ static Ttk_StateTable checkbox_statemap[] = /* * Radiobuttons: */ -static Ttk_StateTable radiobutton_statemap[] = +static const Ttk_StateTable radiobutton_statemap[] = { {RBS_UNCHECKEDDISABLED, TTK_STATE_ALTERNATE|TTK_STATE_DISABLED, 0}, {RBS_UNCHECKEDNORMAL, TTK_STATE_ALTERNATE, 0}, @@ -219,7 +219,7 @@ static Ttk_StateTable radiobutton_statemap[] = /* * Groupboxes (tk: "frame") */ -static Ttk_StateTable groupbox_statemap[] = +static const Ttk_StateTable groupbox_statemap[] = { {GBS_DISABLED, TTK_STATE_DISABLED, 0}, {GBS_NORMAL, 0,0 } @@ -228,7 +228,7 @@ static Ttk_StateTable groupbox_statemap[] = /* * Edit fields (tk: "entry") */ -static Ttk_StateTable edittext_statemap[] = +static const Ttk_StateTable edittext_statemap[] = { { ETS_DISABLED, TTK_STATE_DISABLED, 0 }, { ETS_READONLY, TTK_STATE_READONLY, 0 }, @@ -243,7 +243,7 @@ static Ttk_StateTable edittext_statemap[] = * Same as edittext_statemap, but doesn't use ETS_READONLY * (fixes: #1032409) */ -static Ttk_StateTable combotext_statemap[] = +static const Ttk_StateTable combotext_statemap[] = { { ETS_DISABLED, TTK_STATE_DISABLED, 0 }, { ETS_FOCUSED, TTK_STATE_FOCUS, 0 }, @@ -254,7 +254,7 @@ static Ttk_StateTable combotext_statemap[] = /* * Combobox button: (CBP_DROPDOWNBUTTON) */ -static Ttk_StateTable combobox_statemap[] = { +static const Ttk_StateTable combobox_statemap[] = { { CBXS_DISABLED, TTK_STATE_DISABLED, 0 }, { CBXS_PRESSED, TTK_STATE_PRESSED, 0 }, { CBXS_HOT, TTK_STATE_ACTIVE, 0 }, @@ -265,7 +265,7 @@ static Ttk_StateTable combobox_statemap[] = { /* * Toolbar buttons (TP_BUTTON): */ -static Ttk_StateTable toolbutton_statemap[] = { +static const Ttk_StateTable toolbutton_statemap[] = { { TS_DISABLED, TTK_STATE_DISABLED, 0 }, { TS_PRESSED, TTK_STATE_PRESSED, 0 }, { TS_HOTCHECKED, TTK_STATE_SELECTED|TTK_STATE_ACTIVE, 0 }, @@ -277,7 +277,7 @@ static Ttk_StateTable toolbutton_statemap[] = { /* * Scrollbars (Tk: "Scrollbar.thumb") */ -static Ttk_StateTable scrollbar_statemap[] = +static const Ttk_StateTable scrollbar_statemap[] = { { SCRBS_DISABLED, TTK_STATE_DISABLED, 0 }, { SCRBS_PRESSED, TTK_STATE_PRESSED, 0 }, @@ -285,7 +285,7 @@ static Ttk_StateTable scrollbar_statemap[] = { SCRBS_NORMAL, 0, 0 } }; -static Ttk_StateTable uparrow_statemap[] = +static const Ttk_StateTable uparrow_statemap[] = { { ABS_UPDISABLED, TTK_STATE_DISABLED, 0 }, { ABS_UPPRESSED, TTK_STATE_PRESSED, 0 }, @@ -293,7 +293,7 @@ static Ttk_StateTable uparrow_statemap[] = { ABS_UPNORMAL, 0, 0 } }; -static Ttk_StateTable downarrow_statemap[] = +static const Ttk_StateTable downarrow_statemap[] = { { ABS_DOWNDISABLED, TTK_STATE_DISABLED, 0 }, { ABS_DOWNPRESSED, TTK_STATE_PRESSED, 0 }, @@ -301,7 +301,7 @@ static Ttk_StateTable downarrow_statemap[] = { ABS_DOWNNORMAL, 0, 0 } }; -static Ttk_StateTable leftarrow_statemap[] = +static const Ttk_StateTable leftarrow_statemap[] = { { ABS_LEFTDISABLED, TTK_STATE_DISABLED, 0 }, { ABS_LEFTPRESSED, TTK_STATE_PRESSED, 0 }, @@ -309,7 +309,7 @@ static Ttk_StateTable leftarrow_statemap[] = { ABS_LEFTNORMAL, 0, 0 } }; -static Ttk_StateTable rightarrow_statemap[] = +static const Ttk_StateTable rightarrow_statemap[] = { { ABS_RIGHTDISABLED,TTK_STATE_DISABLED, 0 }, { ABS_RIGHTPRESSED, TTK_STATE_PRESSED, 0 }, @@ -317,7 +317,7 @@ static Ttk_StateTable rightarrow_statemap[] = { ABS_RIGHTNORMAL, 0, 0 } }; -static Ttk_StateTable spinbutton_statemap[] = +static const Ttk_StateTable spinbutton_statemap[] = { { DNS_DISABLED, TTK_STATE_DISABLED, 0 }, { DNS_PRESSED, TTK_STATE_PRESSED, 0 }, @@ -328,7 +328,7 @@ static Ttk_StateTable spinbutton_statemap[] = /* * Trackbar thumb: (Tk: "scale slider") */ -static Ttk_StateTable scale_statemap[] = +static const Ttk_StateTable scale_statemap[] = { { TUS_DISABLED, TTK_STATE_DISABLED, 0 }, { TUS_PRESSED, TTK_STATE_PRESSED, 0 }, @@ -337,7 +337,7 @@ static Ttk_StateTable scale_statemap[] = { TUS_NORMAL, 0, 0 } }; -static Ttk_StateTable tabitem_statemap[] = +static const Ttk_StateTable tabitem_statemap[] = { { TIS_DISABLED, TTK_STATE_DISABLED, 0 }, { TIS_SELECTED, TTK_STATE_SELECTED, 0 }, @@ -372,11 +372,11 @@ static Ttk_StateTable tabitem_statemap[] = typedef struct /* XP element specifications */ { const char *elementName; /* Tk theme engine element name */ - Ttk_ElementSpec *elementSpec; + const Ttk_ElementSpec *elementSpec; /* Element spec (usually GenericElementSpec) */ LPCWSTR className; /* Windows window class name */ int partId; /* BP_PUSHBUTTON, BP_CHECKBUTTON, etc. */ - Ttk_StateTable *statemap; /* Map Tk states to XP states */ + const Ttk_StateTable *statemap; /* Map Tk states to XP states */ Ttk_Padding padding; /* See NOTE-GetThemeMargins */ int flags; # define IGNORE_THEMESIZE 0x80000000 /* See NOTE-GetThemePartSize */ @@ -391,7 +391,7 @@ typedef struct /* * Static data, initialized when element is registered: */ - ElementInfo *info; + const ElementInfo *info; XPThemeProcs *procs; /* Pointer to theme procedure table */ /* @@ -407,7 +407,7 @@ typedef struct } ElementData; static ElementData * -NewElementData(XPThemeProcs *procs, ElementInfo *info) +NewElementData(XPThemeProcs *procs, const ElementInfo *info) { ElementData *elementData = ckalloc(sizeof(ElementData)); @@ -552,7 +552,7 @@ static void GenericElementDraw( FreeElementData(elementData); } -static Ttk_ElementSpec GenericElementSpec = +static const Ttk_ElementSpec GenericElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), @@ -592,7 +592,7 @@ GenericSizedElementSize( *widthPtr /= 2; } -static Ttk_ElementSpec GenericSizedElementSpec = { +static const Ttk_ElementSpec GenericSizedElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, @@ -622,7 +622,7 @@ SpinboxArrowElementSize( *heightPtr /= 2; } -static Ttk_ElementSpec SpinboxArrowElementSpec = { +static const Ttk_ElementSpec SpinboxArrowElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, @@ -659,7 +659,7 @@ static void ThumbElementDraw( FreeElementData(elementData); } -static Ttk_ElementSpec ThumbElementSpec = +static const Ttk_ElementSpec ThumbElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), @@ -691,7 +691,7 @@ static void PbarElementSize( } } -static Ttk_ElementSpec PbarElementSpec = +static const Ttk_ElementSpec PbarElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), @@ -732,7 +732,7 @@ static void TabElementDraw( FreeElementData(elementData); } -static Ttk_ElementSpec TabElementSpec = +static const Ttk_ElementSpec TabElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), @@ -750,14 +750,14 @@ static Ttk_ElementSpec TabElementSpec = #define TTK_STATE_OPEN TTK_STATE_USER1 #define TTK_STATE_LEAF TTK_STATE_USER2 -static Ttk_StateTable header_statemap[] = +static const Ttk_StateTable header_statemap[] = { { HIS_PRESSED, TTK_STATE_PRESSED, 0 }, { HIS_HOT, TTK_STATE_ACTIVE, 0 }, { HIS_NORMAL, 0,0 }, }; -static Ttk_StateTable treeview_statemap[] = +static const Ttk_StateTable treeview_statemap[] = { { TREIS_DISABLED, TTK_STATE_DISABLED, 0 }, { TREIS_SELECTED, TTK_STATE_SELECTED, 0}, @@ -765,7 +765,7 @@ static Ttk_StateTable treeview_statemap[] = { TREIS_NORMAL, 0,0 }, }; -static Ttk_StateTable tvpglyph_statemap[] = +static const Ttk_StateTable tvpglyph_statemap[] = { { GLPS_OPENED, TTK_STATE_OPEN, 0 }, { GLPS_CLOSED, 0,0 }, @@ -780,7 +780,7 @@ static void TreeIndicatorElementDraw( } } -static Ttk_ElementSpec TreeIndicatorElementSpec = +static const Ttk_ElementSpec TreeIndicatorElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), @@ -808,7 +808,7 @@ typedef struct Tcl_Obj *fontObj; } TextElement; -static Ttk_ElementOptionSpec TextElementOptions[] = +static const Ttk_ElementOptionSpec TextElementOptions[] = { { "-text", TK_OPTION_STRING, offsetof(TextElement,textObj), "" }, @@ -888,7 +888,7 @@ static void TextElementDraw( FreeElementData(elementData); } -static Ttk_ElementSpec TextElementSpec = +static const Ttk_ElementSpec TextElementSpec = { TK_STYLE_VERSION_2, sizeof(TextElement), @@ -954,7 +954,7 @@ TTK_END_LAYOUT_TABLE /* name spec className partId statemap padding flags */ -static ElementInfo ElementInfoTable[] = { +static const ElementInfo ElementInfoTable[] = { { "Checkbutton.indicator", &GenericElementSpec, L"BUTTON", BP_CHECKBOX, checkbox_statemap, PAD(0, 0, 4, 0), PAD_MARGINS }, { "Radiobutton.indicator", &GenericElementSpec, L"BUTTON", @@ -1119,7 +1119,7 @@ Ttk_CreateVsapiElement( TkSizeT length = 0; char *name; LPWSTR wname; - Ttk_ElementSpec *elementSpec = &GenericElementSpec; + const Ttk_ElementSpec *elementSpec = &GenericElementSpec; Tcl_DString classBuf; static const char *const optionStrings[] = @@ -1278,7 +1278,7 @@ MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd) XPThemeProcs *procs; HINSTANCE hlibrary; Ttk_Theme themePtr, parentPtr, vistaPtr; - ElementInfo *infoPtr; + const ElementInfo *infoPtr; OSVERSIONINFOW os; os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); -- cgit v0.12