/[dtapublic]/projs/ets/trunk/src/c_tk_base_7_5_w_mods/tkwinpixmap.c
ViewVC logotype

Annotation of /projs/ets/trunk/src/c_tk_base_7_5_w_mods/tkwinpixmap.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 44 - (hide annotations) (download)
Fri Oct 14 02:09:58 2016 UTC (7 years, 8 months ago) by dashley
Original Path: projs/trunk/shared_source/c_tk_base_7_5_w_mods/tkwinpixmap.c
File MIME type: text/plain
File size: 5340 byte(s)
Rename for reorganization.
1 dashley 25 /* $Header: /cvsroot/esrg/sfesrg/esrgpcpj/shared/tk_base/tkwinpixmap.c,v 1.1.1.1 2001/06/13 05:14:08 dtashley Exp $ */
2    
3     /*
4     * tkWinPixmap.c --
5     *
6     * This file contains the Xlib emulation functions pertaining to
7     * creating and destroying pixmaps.
8     *
9     * Copyright (c) 1995 Sun Microsystems, Inc.
10     *
11     * See the file "license.terms" for information on usage and redistribution
12     * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13     *
14     * RCS: @(#) $Id: tkwinpixmap.c,v 1.1.1.1 2001/06/13 05:14:08 dtashley Exp $
15     */
16    
17     #include "tkWinInt.h"
18    
19    
20     /*
21     *----------------------------------------------------------------------
22     *
23     * Tk_GetPixmap --
24     *
25     * Creates an in memory drawing surface.
26     *
27     * Results:
28     * Returns a handle to a new pixmap.
29     *
30     * Side effects:
31     * Allocates a new Win32 bitmap.
32     *
33     *----------------------------------------------------------------------
34     */
35    
36     Pixmap
37     Tk_GetPixmap(display, d, width, height, depth)
38     Display* display;
39     Drawable d;
40     int width;
41     int height;
42     int depth;
43     {
44     TkWinDrawable *newTwdPtr, *twdPtr;
45     int planes;
46     Screen *screen;
47    
48     display->request++;
49    
50     newTwdPtr = (TkWinDrawable*) ckalloc(sizeof(TkWinDrawable));
51     newTwdPtr->type = TWD_BITMAP;
52     newTwdPtr->bitmap.depth = depth;
53     twdPtr = (TkWinDrawable *)d;
54     if (twdPtr->type != TWD_BITMAP) {
55     if (twdPtr->window.winPtr == NULL) {
56     newTwdPtr->bitmap.colormap = DefaultColormap(display,
57     DefaultScreen(display));
58     } else {
59     newTwdPtr->bitmap.colormap = twdPtr->window.winPtr->atts.colormap;
60     }
61     } else {
62     newTwdPtr->bitmap.colormap = twdPtr->bitmap.colormap;
63     }
64     screen = &display->screens[0];
65     planes = 1;
66     if (depth == screen->root_depth) {
67     planes = (int) screen->ext_data;
68     depth /= planes;
69     }
70     newTwdPtr->bitmap.handle = CreateBitmap(width, height, planes, depth, NULL);
71    
72     if (newTwdPtr->bitmap.handle == NULL) {
73     ckfree((char *) newTwdPtr);
74     return None;
75     }
76    
77     return (Pixmap)newTwdPtr;
78     }
79    
80     /*
81     *----------------------------------------------------------------------
82     *
83     * Tk_FreePixmap --
84     *
85     * Release the resources associated with a pixmap.
86     *
87     * Results:
88     * None.
89     *
90     * Side effects:
91     * Deletes the bitmap created by Tk_GetPixmap.
92     *
93     *----------------------------------------------------------------------
94     */
95    
96     void
97     Tk_FreePixmap(display, pixmap)
98     Display* display;
99     Pixmap pixmap;
100     {
101     TkWinDrawable *twdPtr = (TkWinDrawable *) pixmap;
102    
103     display->request++;
104     if (twdPtr != NULL) {
105     DeleteObject(twdPtr->bitmap.handle);
106     ckfree((char *)twdPtr);
107     }
108     }
109    
110     /*
111     *----------------------------------------------------------------------
112     *
113     * TkSetPixmapColormap --
114     *
115     * The following function is a hack used by the photo widget to
116     * explicitly set the colormap slot of a Pixmap.
117     *
118     * Results:
119     * None.
120     *
121     * Side effects:
122     * None.
123     *
124     *----------------------------------------------------------------------
125     */
126    
127     void
128     TkSetPixmapColormap(pixmap, colormap)
129     Pixmap pixmap;
130     Colormap colormap;
131     {
132     TkWinDrawable *twdPtr = (TkWinDrawable *)pixmap;
133     twdPtr->bitmap.colormap = colormap;
134     }
135    
136     /*
137     *----------------------------------------------------------------------
138     *
139     * XGetGeometry --
140     *
141     * Retrieve the geometry of the given drawable. Note that
142     * this is a degenerate implementation that only returns the
143     * size of a pixmap or window.
144     *
145     * Results:
146     * Returns 0.
147     *
148     * Side effects:
149     * None.
150     *
151     *----------------------------------------------------------------------
152     */
153    
154     int
155     XGetGeometry(display, d, root_return, x_return, y_return, width_return,
156     height_return, border_width_return, depth_return)
157     Display* display;
158     Drawable d;
159     Window* root_return;
160     int* x_return;
161     int* y_return;
162     unsigned int* width_return;
163     unsigned int* height_return;
164     unsigned int* border_width_return;
165     unsigned int* depth_return;
166     {
167     TkWinDrawable *twdPtr = (TkWinDrawable *)d;
168    
169     if (twdPtr->type == TWD_BITMAP) {
170     HDC dc;
171     BITMAPINFO info;
172    
173     if (twdPtr->bitmap.handle == NULL) {
174     panic("XGetGeometry: invalid pixmap");
175     }
176     dc = GetDC(NULL);
177     info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
178     info.bmiHeader.biBitCount = 0;
179     if (!GetDIBits(dc, twdPtr->bitmap.handle, 0, 0, NULL, &info,
180     DIB_RGB_COLORS)) {
181     panic("XGetGeometry: unable to get bitmap size");
182     }
183     ReleaseDC(NULL, dc);
184    
185     *width_return = info.bmiHeader.biWidth;
186     *height_return = info.bmiHeader.biHeight;
187     } else if (twdPtr->type == TWD_WINDOW) {
188     RECT rect;
189    
190     if (twdPtr->window.handle == NULL) {
191     panic("XGetGeometry: invalid window");
192     }
193     GetClientRect(twdPtr->window.handle, &rect);
194     *width_return = rect.right - rect.left;
195     *height_return = rect.bottom - rect.top;
196     } else {
197     panic("XGetGeometry: invalid window");
198     }
199     return 1;
200     }
201    
202    
203     /* $History: tkWinPixmap.c $
204     *
205     * ***************** Version 1 *****************
206     * User: Dtashley Date: 1/02/01 Time: 3:13a
207     * Created in $/IjuScripter, IjuConsole/Source/Tk Base
208     * Initial check-in.
209     */
210    
211     /* End of TKWINPIXMAP.C */

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25