summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2021-05-08 00:30:44 (GMT)
committerKevin Walzer <kw@codebykevin.com>2021-05-08 00:30:44 (GMT)
commit840a31c2cb9adc4fd9bf623f96d9c13c6f770b58 (patch)
treefbddbe2eaca29c8781a73a219e480e8753674262
parent8e6d6481d28a0d922380c5c24cdf4e58085f07c3 (diff)
downloadtk-840a31c2cb9adc4fd9bf623f96d9c13c6f770b58.zip
tk-840a31c2cb9adc4fd9bf623f96d9c13c6f770b58.tar.gz
tk-840a31c2cb9adc4fd9bf623f96d9c13c6f770b58.tar.bz2
More changes
-rw-r--r--win/Makefile.in1
-rw-r--r--win/makefile.vc1
-rw-r--r--win/tkWinHDC.c295
-rw-r--r--win/tkWinHDC.h29
-rw-r--r--win/tkWinPrint.c7
5 files changed, 5 insertions, 328 deletions
diff --git a/win/Makefile.in b/win/Makefile.in
index d46ce74..849e79c 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -309,7 +309,6 @@ TK_OBJS = \
tkWinEmbed.$(OBJEXT) \
tkWinFont.$(OBJEXT) \
tkWinGDI.$(OBJEXT) \
- tkWinHDC.$(OBJEXT) \
tkWinIco.$(OBJEXT) \
tkWinImage.$(OBJEXT) \
tkWinInit.$(OBJEXT) \
diff --git a/win/makefile.vc b/win/makefile.vc
index ee42f1e..4624265 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -189,7 +189,6 @@ TKOBJS = \
$(TMP_DIR)\tkWinEmbed.obj \
$(TMP_DIR)\tkWinFont.obj \
$(TMP_DIR)\tkWinGDI.obj \
- $(TMP_DIR)\tkWinHDC.obj \
$(TMP_DIR)\tkWinIco.obj \
$(TMP_DIR)\tkWinImage.obj \
$(TMP_DIR)\tkWinInit.obj \
diff --git a/win/tkWinHDC.c b/win/tkWinHDC.c
deleted file mode 100644
index 9464f07..0000000
--- a/win/tkWinHDC.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * tkWinHDC.c --
- *
- * This module implements utility functions for accessing hardware device contexts
- * for graphics rendering in Windows.
- *
- * Copyright © 2009 Michael I. Schwartz.
- * Copyright © 2021 Kevin Walzer/WordTech Communications LLC.
- *
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
- */
-
-
-#include "tkWinHDC.h"
-
-/*
- *----------------------------------------------------------------------
- *
- * hdc_build_name --
- *
- * Creates HDC name.
- *
- * Results:
- * HDC name created.
- *
- *----------------------------------------------------------------------
- */
-
-static const char * hdc_build_name(int type)
-{
- const char *prefix;
- Tcl_HashEntry *data;
- int status;
-
- if ( (data = Tcl_FindHashEntry(&hdcprefixes, (char *)type)) != 0 )
- prefix = (const char *)Tcl_GetHashValue(data);
- else
- {
- char *cp;
- prefix = "hdc";
- if ( (cp = (char *)Tcl_Alloc(4)) != 0 )
- {
- strcpy (cp, prefix);
- if ( (data = Tcl_CreateHashEntry(&hdcprefixes, (char *)type, &status)) != 0 )
- Tcl_SetHashValue(data, (ClientData)cp);
- }
- }
-
- sprintf(hdc_name, "%s%ld", prefix, ++hdc_count);
- return hdc_name;
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * hdc_create --
- *
- * Creates device context.
- *
- * Results:
- * HDC created.
- *
- *----------------------------------------------------------------------
- */
-
-const char * hdc_create (Tcl_Interp *interp, void *ptr, int type)
-{
- struct hdc_value *pval;
- const char *name;
- Tcl_HashEntry *entry;
- int status;
-
- pval = (struct hdc_value *)Tcl_Alloc(sizeof(struct hdc_value));
- if (pval == 0)
- {
- return 0;
- }
- pval->addr = ptr;
- pval->type = type;
-
- name = hdc_build_name(type);
- if ( ( entry = Tcl_CreateHashEntry(&hdcs, name, &status)) != 0 )
- Tcl_SetHashValue(entry, (ClientData)pval);
- return name;
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * hdc_valid --
- *
- * Tests validity of HDC.
- *
- * Results:
- * HDC tested.
- *
- *----------------------------------------------------------------------
- */
-
-int hdc_valid (Tcl_Interp *interp, const char *hdcname, int type)
-{
- struct hdc_value *val;
- Tcl_HashEntry *data;
-
- if ( (data = Tcl_FindHashEntry(&hdcs, hdcname)) != 0 )
- {
- val = (struct hdc_value *)Tcl_GetHashValue(data);
-
- if ( type <= 0 || val->type == type )
- return 1;
- }
- return 0;
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * hdc_delete --
- *
- * Dletes device context.
- *
- * Results:
- * HDC created.
- *
- *----------------------------------------------------------------------
- */
-
-int hdc_delete (Tcl_Interp *interp, const char *hdcname)
-{
- struct hdc_value *val;
- Tcl_HashEntry *data;
-
- if ( (data = Tcl_FindHashEntry(&hdcs, hdcname)) != 0 )
- {
- val = (struct hdc_value *)Tcl_GetHashValue(data);
-
- Tcl_DeleteHashEntry(data);
- Tcl_Free((void *)val);
- return 1;
- }
- return 0;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * hdc_get --
- *
- * Gets device context.
- *
- * Results:
- * HDC returned.
- *
- *----------------------------------------------------------------------
- */
-
-void * hdc_get (Tcl_Interp *interp, const char *hdcname)
-{
- struct hdc_value *val;
- Tcl_HashEntry *data;
-
- if ( (data = Tcl_FindHashEntry(&hdcs, hdcname)) != 0 )
- val = (struct hdc_value *)Tcl_GetHashValue(data);
- else
- return 0;
-
- return val->addr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * hdc_typeof --
- *
- * Gets HDC type.
- *
- * Results:
- * Type returned.
- *
- *----------------------------------------------------------------------
- */
-
-
-int hdc_typeof (Tcl_Interp *interp, const char *hdcname)
-{
- struct hdc_value *val;
- Tcl_HashEntry *data;
-
- if ( (data = Tcl_FindHashEntry(&hdcs, hdcname)) != 0 )
- val = (struct hdc_value *)Tcl_GetHashValue(data);
-
- return val->type;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * hdc_prefixof --
- *
- * Gets HDC prefix.
- *
- * Results:
- * Prefix returned.
- *
- *----------------------------------------------------------------------
- */
-
-const char * hdc_prefixof (Tcl_Interp *interp, int type, const char *newprefix)
-{
- const char *prefix;
- Tcl_HashEntry *data;
-
- if ( (data = Tcl_FindHashEntry(&hdcprefixes, (char *)type)) != 0 )
- prefix = (const char *)Tcl_GetHashValue(data);
-
- if ( newprefix )
- {
- char *cp;
- size_t siz, len;
-
- siz = strlen(newprefix);
- len = siz > 32 ? 32 : siz;
-
- if ( (cp = (char *)Tcl_Alloc(len+1)) != 0 )
- {
- int newptr = 0;
-
- strncpy (cp, newprefix, len);
- cp[len] = '\0';
- if ( data == 0 )
- data = Tcl_CreateHashEntry(&hdcprefixes,(char *)type,&newptr);
- Tcl_SetHashValue(data, (ClientData)cp);
- prefix = cp;
- }
- }
-
- return prefix;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * hdc_list --
- *
- * Lists all device contexts.
- *
- * Results:
- * List of device contexts returned.
- *
- *----------------------------------------------------------------------
- */
-
-int hdc_list (Tcl_Interp *interp, int type, const char *out[], int *poutlen)
-{
- Tcl_HashEntry *ent;
- Tcl_HashSearch srch;
- int i=0;
- const char *cp;
- int retval = 0;
- struct hdc_value *val;
-
- for ( ent = Tcl_FirstHashEntry(&hdcs, &srch); ent !=0; ent=Tcl_NextHashEntry(&srch))
- {
- if ( (cp = Tcl_GetHashKey(&hdcs, ent)) != 0 )
- {
- if ( i < *poutlen )
- {
- if ( (val = (struct hdc_value *)Tcl_GetHashValue(ent) ) != 0 )
- {
- if ( type <= 0 || type == val->type )
- {
- out[i++] = cp;
- retval++;
- }
- }
- }
- }
- }
- *poutlen = i;
- return retval;
-}
-
-/*
- * Local Variables:
- * mode: c
- * c-basic-offset: 4
- * fill-column: 78
- * End:
- */
-
-
diff --git a/win/tkWinHDC.h b/win/tkWinHDC.h
deleted file mode 100644
index e9d4c1b..0000000
--- a/win/tkWinHDC.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <tcl.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-
-/*
- * Static data and function prototypes.
- */
-
-struct hdc_value
-{
- void *addr;
- int type;
-};
-
-static unsigned long hdc_count = 0L;
-static Tcl_HashTable hdcs;
-static Tcl_HashTable hdcprefixes;
-static char hdc_name [32+12+1];
-
-
-const char * hdc_create (Tcl_Interp *interp, void *ptr, int type);
-int hdc_valid (Tcl_Interp *interp, const char *hdcname, int type);
-int hdc_delete (Tcl_Interp *interp, const char *hdcname);
-const char * hdc_prefixof (Tcl_Interp *interp, int type, const char *newprefix);
-int hdc_typeof (Tcl_Interp *interp, const char *hdcname);
-void * hdc_get (Tcl_Interp *interp, const char *hdcname);
-static const char *hdc_build_name(int type);
diff --git a/win/tkWinPrint.c b/win/tkWinPrint.c
index 4328e1b..3b3cc12 100644
--- a/win/tkWinPrint.c
+++ b/win/tkWinPrint.c
@@ -125,7 +125,8 @@ static int PrintSelectPrinter(ClientData clientData, Tcl_Interp *interp, int arg
GlobalFree(pd.hDevMode);
}
}
-
+
+
/*
* Store print properties and link variables
* so they can be accessed from script level.
@@ -339,12 +340,14 @@ int PrintGetHDC(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj *co
(void) clientData;
(void) argc;
(void) objv;
+
+ hDC = CreateDC( L"WINSPOOL", localPrinterName, NULL, NULL);
if ( hDC == NULL) {
return TCL_ERROR;
}
- get_hdc();
+ // get_hdc();
return TCL_OK;
}