summaryrefslogtreecommitdiffstats
path: root/generic/ttk/ttkImage.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/ttk/ttkImage.c')
-rw-r--r--generic/ttk/ttkImage.c83
1 files changed, 52 insertions, 31 deletions
diff --git a/generic/ttk/ttkImage.c b/generic/ttk/ttkImage.c
index 7de4d92..35ec36f 100644
--- a/generic/ttk/ttkImage.c
+++ b/generic/ttk/ttkImage.c
@@ -1,8 +1,8 @@
/*
* Image specifications and image element factory.
*
- * Copyright (C) 2004 Pat Thoyts <patthoyts@users.sf.net>
- * Copyright (C) 2004 Joe English
+ * Copyright © 2004 Pat Thoyts <patthoyts@users.sf.net>
+ * Copyright © 2004 Joe English
*
* An imageSpec is a multi-element list; the first element
* is the name of the default image to use, the remainder of the
@@ -25,20 +25,28 @@ struct TtkImageSpec {
Ttk_StateSpec *states; /* array[mapCount] of states ... */
Tk_Image *images; /* ... per-state images to use */
Tk_ImageChangedProc *imageChanged;
- ClientData imageChangedClientData;
+ void *imageChangedClientData;
};
/* NullImageChanged --
* Do-nothing Tk_ImageChangedProc.
*/
-static void NullImageChanged(ClientData clientData,
- int x, int y, int width, int height, int imageWidth, int imageHeight)
-{ /* No-op */ }
+static void NullImageChanged(
+ TCL_UNUSED(void *),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int))
+{
+ /* No-op */
+}
/* ImageSpecImageChanged --
* Image changes should trigger a repaint.
*/
-static void ImageSpecImageChanged(ClientData clientData,
+static void ImageSpecImageChanged(void *clientData,
int x, int y, int width, int height, int imageWidth, int imageHeight)
{
Ttk_ImageSpec *imageSpec = (Ttk_ImageSpec *)clientData;
@@ -68,13 +76,14 @@ TtkGetImageSpec(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr)
*/
Ttk_ImageSpec *
TtkGetImageSpecEx(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr,
- Tk_ImageChangedProc *imageChangedProc, ClientData imageChangedClientData)
+ Tk_ImageChangedProc *imageChangedProc, void *imageChangedClientData)
{
Ttk_ImageSpec *imageSpec = 0;
- int i = 0, n = 0, objc;
+ int i = 0, n = 0;
+ Tcl_Size objc;
Tcl_Obj **objv;
- imageSpec = ckalloc(sizeof(*imageSpec));
+ imageSpec = (Ttk_ImageSpec *)ckalloc(sizeof(*imageSpec));
imageSpec->baseImage = 0;
imageSpec->mapCount = 0;
imageSpec->states = 0;
@@ -97,8 +106,8 @@ TtkGetImageSpecEx(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr,
}
n = (objc - 1) / 2;
- imageSpec->states = ckalloc(n * sizeof(Ttk_StateSpec));
- imageSpec->images = ckalloc(n * sizeof(Tk_Image *));
+ imageSpec->states = (Ttk_StateSpec *)ckalloc(n * sizeof(Ttk_StateSpec));
+ imageSpec->images = (Tk_Image *)ckalloc(n * sizeof(Tk_Image));
/* Get base image:
*/
@@ -203,7 +212,11 @@ static Ttk_Box BPadding(Ttk_Box b, Ttk_Padding p)
* the source area of the image.
*/
static void Ttk_Fill(
- Tk_Window tkwin, Drawable d, Tk_Image image, Ttk_Box src, Ttk_Box dst)
+ TCL_UNUSED(Tk_Window),
+ Drawable d,
+ Tk_Image image,
+ Ttk_Box src,
+ Ttk_Box dst)
{
int dr = dst.x + dst.width;
int db = dst.y + dst.height;
@@ -257,7 +270,7 @@ typedef struct { /* ClientData for image elements */
Ttk_Padding border; /* Fixed border region */
Ttk_Padding padding; /* Internal padding */
-#if TILE_07_COMPAT
+#ifdef TILE_07_COMPAT
Ttk_ResourceCache cache; /* Resource cache for images */
Ttk_StateMap imageMap; /* State-based lookup table for images */
#endif
@@ -265,19 +278,23 @@ typedef struct { /* ClientData for image elements */
static void FreeImageData(void *clientData)
{
- ImageData *imageData = clientData;
+ ImageData *imageData = (ImageData *)clientData;
if (imageData->imageSpec) { TtkFreeImageSpec(imageData->imageSpec); }
-#if TILE_07_COMPAT
+#ifdef TILE_07_COMPAT
if (imageData->imageMap) { Tcl_DecrRefCount(imageData->imageMap); }
#endif
ckfree(clientData);
}
static void ImageElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ void *clientData,
+ TCL_UNUSED(void *), /* elementRecord */
+ TCL_UNUSED(Tk_Window),
+ int *widthPtr,
+ int *heightPtr,
+ Ttk_Padding *paddingPtr)
{
- ImageData *imageData = clientData;
+ ImageData *imageData = (ImageData *)clientData;
Tk_Image image = imageData->imageSpec->baseImage;
if (image) {
@@ -294,15 +311,19 @@ static void ImageElementSize(
}
static void ImageElementDraw(
- 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)
{
- ImageData *imageData = clientData;
+ ImageData *imageData = (ImageData *)clientData;
Tk_Image image = 0;
int imgWidth, imgHeight;
Ttk_Box src, dst;
-#if TILE_07_COMPAT
+#ifdef TILE_07_COMPAT
if (imageData->imageMap) {
Tcl_Obj *imageObj = Ttk_StateMapLookup(NULL,imageData->imageMap,state);
if (imageObj) {
@@ -327,7 +348,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),
@@ -342,10 +363,10 @@ static Ttk_ElementSpec ImageElementSpec =
static int
Ttk_CreateImageElement(
Tcl_Interp *interp,
- void *clientData,
+ TCL_UNUSED(void *),
Ttk_Theme theme,
const char *elementName,
- int objc, Tcl_Obj *const objv[])
+ Tcl_Size objc, Tcl_Obj *const objv[])
{
static const char *const optionStrings[] =
{ "-border","-height","-padding","-sticky","-width",NULL };
@@ -354,9 +375,9 @@ Ttk_CreateImageElement(
Ttk_ImageSpec *imageSpec = 0;
ImageData *imageData = 0;
int padding_specified = 0;
- int i;
+ Tcl_Size i;
- if (objc <= 0) {
+ if (objc + 1 < 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"Must supply a base image", -1));
Tcl_SetErrorCode(interp, "TTK", "IMAGE", "BASE", NULL);
@@ -368,12 +389,12 @@ Ttk_CreateImageElement(
return TCL_ERROR;
}
- imageData = ckalloc(sizeof(*imageData));
+ imageData = (ImageData *)ckalloc(sizeof(*imageData));
imageData->imageSpec = imageSpec;
imageData->minWidth = imageData->minHeight = -1;
imageData->sticky = TTK_FILL_BOTH;
imageData->border = imageData->padding = Ttk_UniformPadding(0);
-#if TILE_07_COMPAT
+#ifdef TILE_07_COMPAT
imageData->cache = Ttk_GetResourceCache(interp);
imageData->imageMap = 0;
#endif
@@ -388,7 +409,7 @@ Ttk_CreateImageElement(
goto error;
}
-#if TILE_07_COMPAT
+#ifdef TILE_07_COMPAT
if (!strcmp("-map", Tcl_GetString(objv[i]))) {
imageData->imageMap = objv[i+1];
Tcl_IncrRefCount(imageData->imageMap);