summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2020-10-12 01:34:57 (GMT)
committerKevin Walzer <kw@codebykevin.com>2020-10-12 01:34:57 (GMT)
commitb702ba89a394de8668091f7442e4b08da0e94dcb (patch)
tree24f82ac90bc11798fc08fa3672833be464719772 /win
parent4057120bb20bac23d00b670a51d5547269520588 (diff)
downloadtk-b702ba89a394de8668091f7442e4b08da0e94dcb.zip
tk-b702ba89a394de8668091f7442e4b08da0e94dcb.tar.gz
tk-b702ba89a394de8668091f7442e4b08da0e94dcb.tar.bz2
Remove and refactor some irrelevant code
Diffstat (limited to 'win')
-rw-r--r--win/tkWinIco.c69
-rw-r--r--win/tkWinIco.h2
-rw-r--r--win/tkWinSysTray.c93
-rw-r--r--win/tkWinWm.c114
4 files changed, 72 insertions, 206 deletions
diff --git a/win/tkWinIco.c b/win/tkWinIco.c
index b301ceb..f23d619 100644
--- a/win/tkWinIco.c
+++ b/win/tkWinIco.c
@@ -123,6 +123,75 @@ BytesPerLine(
/*
+ *----------------------------------------------------------------------
+ *
+ * AdjustIconImagePointers --
+ *
+ * Adjusts internal pointers in icon resource struct, as given by
+ * LPICONIMAGE lpImage - the resource to handle. Used by titlebar icon
+ * code.
+ *
+ * Results:
+ * BOOL - TRUE for success, FALSE for failure
+ *
+ *----------------------------------------------------------------------
+ */
+
+static BOOL
+AdjustIconImagePointers(
+ LPICONIMAGE lpImage)
+{
+ /*
+ * Sanity check.
+ */
+
+ if (lpImage == NULL) {
+ return FALSE;
+ }
+
+ /*
+ * BITMAPINFO is at beginning of bits.
+ */
+
+ lpImage->lpbi = (LPBITMAPINFO) lpImage->lpBits;
+
+ /*
+ * Width - simple enough.
+ */
+
+ lpImage->Width = lpImage->lpbi->bmiHeader.biWidth;
+
+ /*
+ * Icons are stored in funky format where height is doubled so account for
+ * that.
+ */
+
+ lpImage->Height = (lpImage->lpbi->bmiHeader.biHeight)/2;
+
+ /*
+ * How many colors?
+ */
+
+ lpImage->Colors = lpImage->lpbi->bmiHeader.biPlanes
+ * lpImage->lpbi->bmiHeader.biBitCount;
+
+ /*
+ * XOR bits follow the header and color table.
+ */
+
+ lpImage->lpXOR = (LPBYTE) FindDIBBits((LPSTR) lpImage->lpbi);
+
+ /*
+ * AND bits follow the XOR bits.
+ */
+
+ lpImage->lpAND = lpImage->lpXOR +
+ lpImage->Height*BytesPerLine((LPBITMAPINFOHEADER) lpImage->lpbi);
+ return TRUE;
+}
+
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4
diff --git a/win/tkWinIco.h b/win/tkWinIco.h
index c8d51a1..db2e204 100644
--- a/win/tkWinIco.h
+++ b/win/tkWinIco.h
@@ -92,6 +92,8 @@ LPSTR FindDIBBits(LPSTR lpbi);
WORD PaletteSize(LPSTR lpbi);
WORD DIBNumColors(LPSTR lpbi);
int ReadICOHeader(Tcl_Channel channel);
+BOOL AdjustIconImagePointers(LPICONIMAGE lpImage);
+
/*
* Local Variables:
diff --git a/win/tkWinSysTray.c b/win/tkWinSysTray.c
index 5044d60..f26c39d 100644
--- a/win/tkWinSysTray.c
+++ b/win/tkWinSysTray.c
@@ -176,99 +176,6 @@ FreeIconResource(BlockOfIconImagesPtr lpIR) {
}
-
-/*
- *----------------------------------------------------------------------
- *
- * AdjustICONIMAGEPointers --
- *
- * Adjust internal pointers in icon resource struct.
- *
- * Results:
- * Pointers adjusted as needed in icon resource struct.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static BOOL
-AdjustICONIMAGEPointers(LPICONIMAGE lpImage) {
- /* Sanity check */
- if (lpImage == NULL)
- return FALSE;
- /* BITMAPINFO is at beginning of bits */
- lpImage -> lpbi = (LPBITMAPINFO) lpImage -> lpBits;
- /* Width - simple enough */
- lpImage -> Width = lpImage -> lpbi -> bmiHeader.biWidth;
- /* Icons are stored in funky format where height is doubled - account for it */
- lpImage -> Height = (lpImage -> lpbi -> bmiHeader.biHeight) / 2;
- /* How many colors? */
- lpImage -> Colors = lpImage -> lpbi -> bmiHeader.biPlanes * lpImage -> lpbi -> bmiHeader.biBitCount;
- /* XOR bits follow the header and color table */
- lpImage -> lpXOR = (LPBYTE) FindDIBBits((LPSTR) lpImage -> lpbi);
- /* AND bits follow the XOR bits */
- lpImage -> lpAND = lpImage -> lpXOR + (lpImage -> Height * BytesPerLine((LPBITMAPINFOHEADER)(lpImage -> lpbi)));
- return TRUE;
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * ReadICOHeader --
- *
- * Read the header from an ICO file.
- *
- * Results:
- * Icon is created.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-
-static int
-ReadICOHeader(Tcl_Channel channel) {
- WORD Input;
- DWORD dwBytesRead;
-
- /* Read the 'reserved' WORD */
- if ((dwBytesRead = Tcl_Read(channel, (char * ) & Input, sizeof(WORD))) < 0)
- return -1;
-
- /* Did we get a WORD? */
- if (dwBytesRead != sizeof(WORD))
- return -1;
-
- /* Was it 'reserved' ? (ie 0) */
- if (Input != 0)
- return -1;
-
- /* Read the type WORD */
- if ((dwBytesRead = Tcl_Read(channel, (char * ) & Input, sizeof(WORD))) < 0)
- return -1;
-
- /* Did we get a WORD? */
- if (dwBytesRead != sizeof(WORD))
- return -1;
- /* Was it type 1? */
- if (Input != 1)
- return -1;
-
- /* Get the count of images */
- if ((dwBytesRead = Tcl_Read(channel, (char * ) & Input, sizeof(WORD))) < 0)
- return -1;
- /* Did we get a WORD? */
- if (dwBytesRead != sizeof(WORD))
- return -1;
- /* Return the count */
- return (int) Input;
-}
-
/*
* If someone wants to see the several masks somewhere on the screen...
* set the ICO_DRAW define and feel free to make some Tcl commands
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 587d6af..d856da0 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -14,7 +14,7 @@
*/
#include "tkWinInt.h"
-#include "TkWinIco.h"
+#include "tkWinIco.h"
#include <shellapi.h>
/*
@@ -561,119 +561,7 @@ PaletteSize(
return (WORD) (DIBNumColors(lpbi) * sizeof(RGBQUAD));
}
-/*
- *----------------------------------------------------------------------
- *
- * FindDIBits --
- *
- * Locate the image bits in a CF_DIB format DIB, as given by LPSTR lpbi -
- * pointer to the CF_DIB memory block. Used by titlebar icon code.
- *
- * Results:
- * pointer to the image bits
- *
- * Side effects: None
- *
- *
- *----------------------------------------------------------------------
- */
-static LPSTR
-FindDIBBits(
- LPSTR lpbi)
-{
- return lpbi + *((LPDWORD) lpbi) + PaletteSize(lpbi);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * BytesPerLine --
- *
- * Calculates the number of bytes in one scan line, as given by
- * LPBITMAPINFOHEADER lpBMIH - pointer to the BITMAPINFOHEADER that
- * begins the CF_DIB block. Used by titlebar icon code.
- *
- * Results:
- * number of bytes in one scan line (DWORD aligned)
- *
- *----------------------------------------------------------------------
- */
-
-static DWORD
-BytesPerLine(
- LPBITMAPINFOHEADER lpBMIH)
-{
- return WIDTHBYTES(lpBMIH->biWidth * lpBMIH->biPlanes * lpBMIH->biBitCount);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * AdjustIconImagePointers --
- *
- * Adjusts internal pointers in icon resource struct, as given by
- * LPICONIMAGE lpImage - the resource to handle. Used by titlebar icon
- * code.
- *
- * Results:
- * BOOL - TRUE for success, FALSE for failure
- *
- *----------------------------------------------------------------------
- */
-
-static BOOL
-AdjustIconImagePointers(
- LPICONIMAGE lpImage)
-{
- /*
- * Sanity check.
- */
-
- if (lpImage == NULL) {
- return FALSE;
- }
-
- /*
- * BITMAPINFO is at beginning of bits.
- */
-
- lpImage->lpbi = (LPBITMAPINFO) lpImage->lpBits;
-
- /*
- * Width - simple enough.
- */
-
- lpImage->Width = lpImage->lpbi->bmiHeader.biWidth;
-
- /*
- * Icons are stored in funky format where height is doubled so account for
- * that.
- */
-
- lpImage->Height = (lpImage->lpbi->bmiHeader.biHeight)/2;
-
- /*
- * How many colors?
- */
-
- lpImage->Colors = lpImage->lpbi->bmiHeader.biPlanes
- * lpImage->lpbi->bmiHeader.biBitCount;
-
- /*
- * XOR bits follow the header and color table.
- */
-
- lpImage->lpXOR = (LPBYTE) FindDIBBits((LPSTR) lpImage->lpbi);
-
- /*
- * AND bits follow the XOR bits.
- */
-
- lpImage->lpAND = lpImage->lpXOR +
- lpImage->Height*BytesPerLine((LPBITMAPINFOHEADER) lpImage->lpbi);
- return TRUE;
-}
/*
*----------------------------------------------------------------------