summaryrefslogtreecommitdiffstats
path: root/win/tkWinPixmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'win/tkWinPixmap.c')
-rw-r--r--win/tkWinPixmap.c126
1 files changed, 66 insertions, 60 deletions
diff --git a/win/tkWinPixmap.c b/win/tkWinPixmap.c
index 4a7954f..51f0f59 100644
--- a/win/tkWinPixmap.c
+++ b/win/tkWinPixmap.c
@@ -1,17 +1,16 @@
-/*
+/*
* tkWinPixmap.c --
*
- * This file contains the Xlib emulation functions pertaining to
- * creating and destroying pixmaps.
+ * This file contains the Xlib emulation functions pertaining to creating
+ * and destroying pixmaps.
*
* Copyright (c) 1995 Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkWinInt.h"
-
/*
*----------------------------------------------------------------------
@@ -30,23 +29,23 @@
*/
Pixmap
-Tk_GetPixmap(display, d, width, height, depth)
- Display* display;
- Drawable d;
- int width;
- int height;
- int depth;
+Tk_GetPixmap(
+ Display *display,
+ Drawable d,
+ int width,
+ int height,
+ int depth)
{
TkWinDrawable *newTwdPtr, *twdPtr;
int planes;
Screen *screen;
-
+
display->request++;
newTwdPtr = (TkWinDrawable*) ckalloc(sizeof(TkWinDrawable));
newTwdPtr->type = TWD_BITMAP;
newTwdPtr->bitmap.depth = depth;
- twdPtr = (TkWinDrawable *)d;
+ twdPtr = (TkWinDrawable *) d;
if (twdPtr->type != TWD_BITMAP) {
if (twdPtr->window.winPtr == NULL) {
newTwdPtr->bitmap.colormap = DefaultColormap(display,
@@ -60,7 +59,7 @@ Tk_GetPixmap(display, d, width, height, depth)
screen = &display->screens[0];
planes = 1;
if (depth == screen->root_depth) {
- planes = (int) screen->ext_data;
+ planes = PTR2INT(screen->ext_data);
depth /= planes;
}
newTwdPtr->bitmap.handle =
@@ -74,7 +73,7 @@ Tk_GetPixmap(display, d, width, height, depth)
if (newTwdPtr->bitmap.handle == NULL) {
static int repeatError = 0;
- unsigned char *bits = NULL;
+ void *bits = NULL;
BITMAPINFO bitmapInfo;
HDC dc;
@@ -88,7 +87,7 @@ Tk_GetPixmap(display, d, width, height, depth)
bitmapInfo.bmiHeader.biSizeImage = 0;
dc = GetDC(NULL);
newTwdPtr->bitmap.handle = CreateDIBSection(dc, &bitmapInfo,
- DIB_RGB_COLORS, (void **) &bits, 0, 0);
+ DIB_RGB_COLORS, &bits, 0, 0);
ReleaseDC(NULL, dc);
/*
@@ -118,8 +117,8 @@ Tk_GetPixmap(display, d, width, height, depth)
ckfree((char *) newTwdPtr);
return None;
}
-
- return (Pixmap)newTwdPtr;
+
+ return (Pixmap) newTwdPtr;
}
/*
@@ -139,16 +138,16 @@ Tk_GetPixmap(display, d, width, height, depth)
*/
void
-Tk_FreePixmap(display, pixmap)
- Display* display;
- Pixmap pixmap;
+Tk_FreePixmap(
+ Display *display,
+ Pixmap pixmap)
{
TkWinDrawable *twdPtr = (TkWinDrawable *) pixmap;
display->request++;
if (twdPtr != NULL) {
DeleteObject(twdPtr->bitmap.handle);
- ckfree((char *)twdPtr);
+ ckfree((char *) twdPtr);
}
}
@@ -170,9 +169,9 @@ Tk_FreePixmap(display, pixmap)
*/
void
-TkSetPixmapColormap(pixmap, colormap)
- Pixmap pixmap;
- Colormap colormap;
+TkSetPixmapColormap(
+ Pixmap pixmap,
+ Colormap colormap)
{
TkWinDrawable *twdPtr = (TkWinDrawable *)pixmap;
twdPtr->bitmap.colormap = colormap;
@@ -183,9 +182,9 @@ TkSetPixmapColormap(pixmap, colormap)
*
* XGetGeometry --
*
- * Retrieve the geometry of the given drawable. Note that
- * this is a degenerate implementation that only returns the
- * size of a pixmap or window.
+ * Retrieve the geometry of the given drawable. Note that this is a
+ * degenerate implementation that only returns the size of a pixmap or
+ * window.
*
* Results:
* Returns 0.
@@ -197,17 +196,16 @@ TkSetPixmapColormap(pixmap, colormap)
*/
int
-XGetGeometry(display, d, root_return, x_return, y_return, width_return,
- height_return, border_width_return, depth_return)
- Display* display;
- Drawable d;
- Window* root_return;
- int* x_return;
- int* y_return;
- unsigned int* width_return;
- unsigned int* height_return;
- unsigned int* border_width_return;
- unsigned int* depth_return;
+XGetGeometry(
+ Display *display,
+ Drawable d,
+ Window *root_return,
+ int *x_return,
+ int *y_return,
+ unsigned int *width_return,
+ unsigned int *height_return,
+ unsigned int *border_width_return,
+ unsigned int *depth_return)
{
TkWinDrawable *twdPtr = (TkWinDrawable *)d;
@@ -216,30 +214,38 @@ XGetGeometry(display, d, root_return, x_return, y_return, width_return,
BITMAPINFO info;
if (twdPtr->bitmap.handle == NULL) {
- panic("XGetGeometry: invalid pixmap");
- }
- dc = GetDC(NULL);
- info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- info.bmiHeader.biBitCount = 0;
- if (!GetDIBits(dc, twdPtr->bitmap.handle, 0, 0, NULL, &info,
- DIB_RGB_COLORS)) {
- panic("XGetGeometry: unable to get bitmap size");
- }
- ReleaseDC(NULL, dc);
-
- *width_return = info.bmiHeader.biWidth;
- *height_return = info.bmiHeader.biHeight;
+ Tcl_Panic("XGetGeometry: invalid pixmap");
+ }
+ dc = GetDC(NULL);
+ info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ info.bmiHeader.biBitCount = 0;
+ if (!GetDIBits(dc, twdPtr->bitmap.handle, 0, 0, NULL, &info,
+ DIB_RGB_COLORS)) {
+ Tcl_Panic("XGetGeometry: unable to get bitmap size");
+ }
+ ReleaseDC(NULL, dc);
+
+ *width_return = info.bmiHeader.biWidth;
+ *height_return = info.bmiHeader.biHeight;
} else if (twdPtr->type == TWD_WINDOW) {
RECT rect;
- if (twdPtr->window.handle == NULL) {
- panic("XGetGeometry: invalid window");
- }
- GetClientRect(twdPtr->window.handle, &rect);
- *width_return = rect.right - rect.left;
- *height_return = rect.bottom - rect.top;
+ if (twdPtr->window.handle == NULL) {
+ Tcl_Panic("XGetGeometry: invalid window");
+ }
+ GetClientRect(twdPtr->window.handle, &rect);
+ *width_return = rect.right - rect.left;
+ *height_return = rect.bottom - rect.top;
} else {
- panic("XGetGeometry: invalid window");
+ Tcl_Panic("XGetGeometry: invalid window");
}
return 1;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */