summaryrefslogtreecommitdiffstats
path: root/win/ttkWinXPTheme.c
diff options
context:
space:
mode:
Diffstat (limited to 'win/ttkWinXPTheme.c')
-rw-r--r--win/ttkWinXPTheme.c138
1 files changed, 60 insertions, 78 deletions
diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c
index b01bdcd..4b868aa 100644
--- a/win/ttkWinXPTheme.c
+++ b/win/ttkWinXPTheme.c
@@ -2,9 +2,9 @@
* Tk theme engine which uses the Windows XP "Visual Styles" API
* Adapted from Georgios Petasis' XP theme patch.
*
- * Copyright (c) 2003 Georgios Petasis, petasis@iit.demokritos.gr.
- * Copyright (c) 2003 Joe English
- * Copyright (c) 2003 Pat Thoyts
+ * Copyright © 2003 Georgios Petasis, petasis@iit.demokritos.gr.
+ * Copyright © 2003 Joe English
+ * Copyright © 2003 Pat Thoyts
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -15,30 +15,18 @@
* shellcc/platform/commctls/userex/refentry.asp >
*/
-#define WINVER 0x0501 /* Requires Windows XP APIs */
-
#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; }
-#else
-
#include <windows.h>
#include <uxtheme.h>
-#if defined(HAVE_VSSYM32_H) || _MSC_VER > 1500
-# include <vssym32.h>
-#else
-# include <tmschema.h>
-#endif
-
-#include "ttk/ttkTheme.h"
+#include <vssym32.h>
+#include "ttk/ttkThemeInt.h"
typedef HTHEME (STDAPICALLTYPE OpenThemeDataProc)(HWND hwnd,
LPCWSTR pszClassList);
typedef HRESULT (STDAPICALLTYPE CloseThemeDataProc)(HTHEME hTheme);
typedef HRESULT (STDAPICALLTYPE DrawThemeBackgroundProc)(HTHEME hTheme,
- HDC hdc, int iPartId, int iStateId, const RECT *pRect,
- OPTIONAL const RECT *pClipRect);
+ HDC hdc, int iPartId, int iStateId, const RECT *pRect,
+ OPTIONAL const RECT *pClipRect);
typedef HRESULT (STDAPICALLTYPE DrawThemeEdgeProc)(HTHEME hTheme,
HDC hdc, int iPartId, int iStateId, const RECT *pDestRect,
unsigned int uEdge, unsigned int uFlags,
@@ -177,12 +165,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 },
@@ -194,7 +182,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},
@@ -213,7 +201,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},
@@ -230,7 +218,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 }
@@ -239,7 +227,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 },
@@ -254,7 +242,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 },
@@ -265,7 +253,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 },
@@ -276,7 +264,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 },
@@ -288,7 +276,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 },
@@ -296,7 +284,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 },
@@ -304,7 +292,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 },
@@ -312,7 +300,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 },
@@ -320,7 +308,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 },
@@ -328,7 +316,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 },
@@ -339,7 +327,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 },
@@ -348,7 +336,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 },
@@ -383,11 +371,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 */
unsigned flags;
# define IGNORE_THEMESIZE 0x80000000U /* See NOTE-GetThemePartSize */
@@ -571,7 +559,7 @@ static void GenericElementDraw(
FreeElementData(elementData);
}
-static Ttk_ElementSpec GenericElementSpec =
+static const Ttk_ElementSpec GenericElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NullElement),
@@ -611,7 +599,7 @@ GenericSizedElementSize(
*widthPtr /= 2;
}
-static Ttk_ElementSpec GenericSizedElementSpec = {
+static const Ttk_ElementSpec GenericSizedElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
@@ -641,7 +629,7 @@ SpinboxArrowElementSize(
*heightPtr /= 2;
}
-static Ttk_ElementSpec SpinboxArrowElementSpec = {
+static const Ttk_ElementSpec SpinboxArrowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
@@ -682,7 +670,7 @@ static void ThumbElementDraw(
FreeElementData(elementData);
}
-static Ttk_ElementSpec ThumbElementSpec =
+static const Ttk_ElementSpec ThumbElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NullElement),
@@ -714,7 +702,7 @@ static void PbarElementSize(
}
}
-static Ttk_ElementSpec PbarElementSpec =
+static const Ttk_ElementSpec PbarElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NullElement),
@@ -788,7 +776,6 @@ static void TabElementDraw(
int partId = elementData->info->partId;
int isSelected = (state & TTK_STATE_SELECTED);
int stateId = Ttk_StateTableLookup(elementData->info->statemap, state);
- RECT rc;
if (mainInfoPtr != NULL) {
nbTabsStickBit = (Ttk_PositionSpec) mainInfoPtr->ttkNbTabsStickBit;
@@ -812,13 +799,13 @@ static void TabElementDraw(
break;
}
- rc = BoxToRect(b);
+ RECT rc = BoxToRect(b);
if (!InitElementData(elementData, tkwin, d))
return;
if (nbTabsStickBit == TTK_STICK_S) {
- if (state & TTK_STATE_USER1) {
+ if (state & TTK_STATE_FIRST) {
partId = TABP_TABITEMLEFTEDGE;
}
@@ -864,7 +851,7 @@ static void TabElementDraw(
FreeElementData(elementData);
}
-static Ttk_ElementSpec TabElementSpec =
+static const Ttk_ElementSpec TabElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NullElement),
@@ -879,17 +866,14 @@ static Ttk_ElementSpec TabElementSpec =
* Generic element, but don't display at all if TTK_STATE_LEAF (=USER2) set
*/
-#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},
@@ -897,7 +881,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 },
@@ -908,11 +892,11 @@ static void TreeIndicatorElementDraw(
Drawable d, Ttk_Box b, Ttk_State state)
{
if (!(state & TTK_STATE_LEAF)) {
- GenericElementDraw(clientData,elementRecord,tkwin,d,b,state);
+ GenericElementDraw(clientData,elementRecord,tkwin,d,b,state);
}
}
-static Ttk_ElementSpec TreeIndicatorElementSpec =
+static const Ttk_ElementSpec TreeIndicatorElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NullElement),
@@ -943,9 +927,9 @@ typedef struct
static const Ttk_ElementOptionSpec TextElementOptions[] =
{
{ "-text", TK_OPTION_STRING,
- Tk_Offset(TextElement,textObj), "" },
+ offsetof(TextElement,textObj), "" },
{ "-font", TK_OPTION_FONT,
- Tk_Offset(TextElement,fontObj), DEFAULT_FONT },
+ offsetof(TextElement,fontObj), DEFAULT_FONT },
{ NULL }
};
@@ -958,7 +942,7 @@ static void TextElementSize(
RECT rc = {0, 0};
HRESULT hr = S_OK;
const char *src;
- int len;
+ Tcl_Size len;
Tcl_DString ds;
if (!InitElementData(elementData, tkwin, 0))
@@ -997,7 +981,7 @@ static void TextElementDraw(
RECT rc = BoxToRect(b);
HRESULT hr = S_OK;
const char *src;
- int len;
+ Tcl_Size len;
Tcl_DString ds;
if (!InitElementData(elementData, tkwin, d))
@@ -1020,7 +1004,7 @@ static void TextElementDraw(
FreeElementData(elementData);
}
-static Ttk_ElementSpec TextElementSpec =
+static const Ttk_ElementSpec TextElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(TextElement),
@@ -1047,7 +1031,7 @@ TTK_LAYOUT("TMenubutton",
TTK_NODE("Menubutton.dropdown", TTK_PACK_RIGHT|TTK_FILL_Y)
TTK_GROUP("Menubutton.button", TTK_FILL_BOTH,
TTK_GROUP("Menubutton.padding", TTK_FILL_X,
- TTK_NODE("Menubutton.label", 0))))
+ TTK_NODE("Menubutton.label", 0))))
TTK_LAYOUT("Horizontal.TScrollbar",
TTK_GROUP("Horizontal.Scrollbar.trough", TTK_FILL_X,
@@ -1086,7 +1070,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",
@@ -1198,12 +1182,12 @@ GetSysFlagFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr)
};
Tcl_Obj **objv;
- int i, objc;
+ Tcl_Size i, objc;
if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK)
return TCL_ERROR;
if (objc != 2) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("wrong # args", -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("wrong # args", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL);
return TCL_ERROR;
}
@@ -1235,7 +1219,7 @@ Ttk_CreateVsapiElement(
void *clientData,
Ttk_Theme theme,
const char *elementName,
- int objc,
+ Tcl_Size objc,
Tcl_Obj *const objv[])
{
XPThemeData *themeData = (XPThemeData *)clientData;
@@ -1246,21 +1230,21 @@ Ttk_CreateVsapiElement(
Ttk_StateTable *stateTable;
Ttk_Padding pad = {0, 0, 0, 0};
int flags = 0;
- int length = 0;
+ Tcl_Size length = 0;
char *name;
LPWSTR wname;
- Ttk_ElementSpec *elementSpec = &GenericElementSpec;
+ const Ttk_ElementSpec *elementSpec = &GenericElementSpec;
Tcl_DString classBuf;
static const char *const optionStrings[] =
- { "-padding","-width","-height","-margins", "-syssize",
- "-halfheight", "-halfwidth", NULL };
- enum { O_PADDING, O_WIDTH, O_HEIGHT, O_MARGINS, O_SYSSIZE,
- O_HALFHEIGHT, O_HALFWIDTH };
+ { "-halfheight", "-halfwidth", "-height", "-margins", "-padding",
+ "-syssize", "-width", NULL };
+ enum { O_HALFHEIGHT, O_HALFWIDTH, O_HEIGHT, O_MARGINS, O_PADDING,
+ O_SYSSIZE, O_WIDTH };
if (objc < 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "missing required arguments 'class' and/or 'partId'", -1));
+ "missing required arguments 'class' and/or 'partId'", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TTK", "VSAPI", "REQUIRED", NULL);
return TCL_ERROR;
}
@@ -1274,7 +1258,7 @@ Ttk_CreateVsapiElement(
/* flags or padding */
if (objc > 3) {
- int i = 3;
+ Tcl_Size i = 3;
int option = 0;
for (i = 3; i < objc; i += 2) {
int tmp = 0;
@@ -1342,7 +1326,7 @@ Ttk_CreateVsapiElement(
/* convert a statemap into a state table */
if (objc > 2) {
Tcl_Obj **specs;
- int n, j, count;
+ Tcl_Size n, j, count;
int status = TCL_OK;
if (Tcl_ListObjGetElements(interp, objv[2], &count, &specs) != TCL_OK)
goto retErr;
@@ -1391,7 +1375,7 @@ Ttk_CreateVsapiElement(
theme, elementName, elementPtr->elementSpec, elementData);
Ttk_RegisterCleanup(interp, elementData, DestroyElementData);
- Tcl_SetObjResult(interp, Tcl_NewStringObj(elementName, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(elementName, TCL_INDEX_NONE));
Tcl_DStringFree(&classBuf);
return TCL_OK;
@@ -1425,7 +1409,7 @@ TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd)
themePtr = Ttk_CreateTheme(interp, "xpnative", parentPtr);
if (!themePtr)
- return TCL_ERROR;
+ return TCL_ERROR;
/*
* Set theme data and cleanup proc
@@ -1472,5 +1456,3 @@ TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd)
return TCL_OK;
}
-
-#endif /* HAVE_UXTHEME_H */