diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-05-10 10:29:55 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-05-10 10:29:55 (GMT) |
commit | dac0d44e8ac09f7ff824c1ff952201122b60245e (patch) | |
tree | 51e1ecc4829a564ef487c9cd3b864a526884b47f /win | |
parent | 794c5c6783a20e8c42ee94337edb9e02eb06662a (diff) | |
download | tk-dac0d44e8ac09f7ff824c1ff952201122b60245e.zip tk-dac0d44e8ac09f7ff824c1ff952201122b60245e.tar.gz tk-dac0d44e8ac09f7ff824c1ff952201122b60245e.tar.bz2 |
More usage of Tk_GetPixelsFromObj() and TCL_UNUSED(), all backported from Tk 8.7.
More TCL_UNUSED
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinTest.c | 65 | ||||
-rw-r--r-- | win/ttkWinTheme.c | 239 | ||||
-rw-r--r-- | win/ttkWinXPTheme.c | 70 |
3 files changed, 231 insertions, 143 deletions
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 <tkWinInt.h> +#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 <tkWinInt.h> +#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); |