OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [insight/] [tix/] [win/] [tixWinDraw.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
2
 * tixWinDraw.c --
3
 *
4
 *      Implement the Windows specific function calls for drawing.
5
 *
6
 * Copyright (c) 1996, Expert Interface Technologies
7
 *
8
 * See the file "license.terms" for information on usage and redistribution
9
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10
 *
11
 */
12
 
13
#include <tkInt.h>
14
#include <tkWinInt.h>
15
#include <tixInt.h>
16
#include <tixPort.h>
17
 
18
/*----------------------------------------------------------------------
19
 * TixpDrawTmpLine --
20
 *
21
 *      Draws a "temporarily" line on the desktop window with XOR
22
 *      drawing mode. This function is used by the PanedWindow and
23
 *      ResizeHandler to draw the rubberband lines. Calling the
24
 *      function again with the same parameters cancels the temporary
25
 *      lines without affecting what was originally on the screen.
26
 *----------------------------------------------------------------------
27
 */
28
 
29
void
30
TixpDrawTmpLine(x1, y1, x2, y2, tkwin)
31
    int x1;
32
    int y1;
33
    int x2;
34
    int y2;
35
    Tk_Window tkwin;
36
{
37
    HWND desktop;
38
    HDC hdc;
39
    HPEN hpen;
40
    HGDIOBJ old;
41
 
42
    desktop = GetDesktopWindow();
43
    hdc = GetWindowDC(desktop);
44
    hpen = CreatePen(PS_SOLID, 0, RGB(255,255,255));
45
 
46
    old = SelectObject(hdc, hpen);
47
    SetROP2(hdc, R2_XORPEN);
48
 
49
    MoveToEx(hdc, x1, y1, NULL);
50
    LineTo(hdc, x2, y2);
51
 
52
    SelectObject(hdc, old);
53
    DeleteObject(hpen);
54
    ReleaseDC(desktop, hdc);
55
}
56
 
57
/*----------------------------------------------------------------------
58
 * TixpDrawAnchorLines --
59
 *
60
 *      See comments near Tix_DrawAnchorLines.
61
 *----------------------------------------------------------------------
62
 */
63
 
64
void
65
TixpDrawAnchorLines(display, drawable, gc, x, y, w, h)
66
    Display *display;
67
    Drawable drawable;
68
    GC gc;
69
    int x;
70
    int y;
71
    int w;
72
    int h;
73
{
74
    HDC hdc;
75
    TkWinDCState state;
76
    HPEN hpen;
77
    HGDIOBJ old;
78
 
79
    hdc = TkWinGetDrawableDC(display, drawable, &state);
80
    hpen = CreatePen(PS_DOT, 1, gc->foreground);
81
 
82
    old = SelectObject(hdc, hpen);
83
    MoveToEx(hdc, x, y, NULL);
84
    LineTo(hdc, x,     y+h-1);
85
    LineTo(hdc, x+w-1, y+h-1);
86
    LineTo(hdc, x+w-1, y);
87
    LineTo(hdc, x,     y);
88
 
89
    SelectObject(hdc, old);
90
    DeleteObject(hpen);
91
 
92
    TkWinReleaseDrawableDC(drawable, hdc, &state);
93
}
94
 
95
/*----------------------------------------------------------------------
96
 * TixpStartSubRegionDraw --
97
 *
98
 *      Limits the subsequent drawing operations into the prescribed
99
 *      rectangle region. This takes effect up to a matching
100
 *      TixEndSubRegionDraw() call.
101
 *
102
 * Return value:
103
 *      none.
104
 *----------------------------------------------------------------------
105
 */
106
 
107
void
108
TixpStartSubRegionDraw(display, drawable, gc, subRegPtr, origX, origY,
109
        x, y, width, height, needWidth, needHeight)
110
    Display *display;
111
    Drawable drawable;
112
    GC gc;
113
    TixpSubRegion * subRegPtr;
114
    int origX;
115
    int origY;
116
    int x;
117
    int y;
118
    int width;
119
    int height;
120
    int needWidth;
121
    int needHeight;
122
{
123
    TkWinDrawable * wdrPtr;
124
    int depth;
125
 
126
    if ((width < needWidth) || (height < needHeight)) {
127
        subRegPtr->origX  = origX;
128
        subRegPtr->origY  = origY;
129
        subRegPtr->x      = x;
130
        subRegPtr->y      = y;
131
        subRegPtr->width  = width;
132
        subRegPtr->height = height;
133
 
134
        /*
135
         * Find out the depth of the drawable and create a pixmap of
136
         * the same depth.
137
         */
138
 
139
        wdrPtr = (TkWinDrawable *)drawable;
140
        if (wdrPtr->type == TWD_BITMAP) {
141
            depth = wdrPtr->bitmap.depth;
142
        } else {
143
            depth = wdrPtr->window.winPtr->depth;
144
        }
145
 
146
        subRegPtr->pixmap = Tk_GetPixmap(display, drawable, width, height,
147
                depth);
148
 
149
        if (subRegPtr->pixmap != None) {
150
            /*
151
             * It could be None if we have somehow exhausted the Windows
152
             * GDI resources.
153
             */
154
            XCopyArea(display, drawable, subRegPtr->pixmap, gc, x, y,
155
                    width, height, 0, 0);
156
        }
157
    } else {
158
        subRegPtr->pixmap = None;
159
    }
160
}
161
 
162
/*----------------------------------------------------------------------
163
 * TixpEndSubRegionDraw --
164
 *
165
 *
166
 *----------------------------------------------------------------------
167
 */
168
void
169
TixpEndSubRegionDraw(display, drawable, gc, subRegPtr)
170
    Display *display;
171
    Drawable drawable;
172
    GC gc;
173
    TixpSubRegion * subRegPtr;
174
{
175
    if (subRegPtr->pixmap != None) {
176
        XCopyArea(display, subRegPtr->pixmap, drawable, gc, 0, 0,
177
                subRegPtr->width, subRegPtr->height,
178
                subRegPtr->x, subRegPtr->y);
179
        Tk_FreePixmap(display, subRegPtr->pixmap);
180
        subRegPtr->pixmap = None;
181
    }
182
}
183
 
184
/*
185
 *----------------------------------------------------------------------
186
 *
187
 * TixpSubRegDisplayText --
188
 *
189
 *      Display a text string on one or more lines in a sub region.
190
 *
191
 * Results:
192
 *      See TkDisplayText
193
 *
194
 * Side effects:
195
 *      See TkDisplayText
196
 *
197
 *----------------------------------------------------------------------
198
 */
199
 
200
void
201
TixpSubRegDisplayText(display, drawable, gc, subRegPtr, font, string,
202
        numChars, x, y, length, justify, underline)
203
    Display *display;           /* X display to use for drawing text. */
204
    Drawable drawable;          /* Window or pixmap in which to draw the
205
                                 * text. */
206
    GC gc;                      /* Graphics context to use for drawing text. */
207
    TixpSubRegion * subRegPtr;  /* Information about the subregion */
208
    TixFont font;               /* Font that determines geometry of text
209
                                 * (should be same as font in gc). */
210
    char *string;               /* String to display;  may contain embedded
211
                                 * newlines. */
212
    int numChars;               /* Number of characters to use from string. */
213
    int x, y;                   /* Pixel coordinates within drawable of
214
                                 * upper left corner of display area. */
215
    int length;                 /* Line length in pixels;  used to compute
216
                                 * word wrap points and also for
217
                                 * justification.   Must be > 0. */
218
    Tk_Justify justify;         /* How to justify lines. */
219
    int underline;              /* Index of character to underline, or < 0
220
                                 * for no underlining. */
221
{
222
    if (subRegPtr->pixmap != None) {
223
        TixDisplayText(display, subRegPtr->pixmap, font, string,
224
                numChars, x - subRegPtr->x, y - subRegPtr->y,
225
                length, justify, underline, gc);
226
    } else {
227
        TixDisplayText(display, drawable, font, string,
228
                numChars, x, y, length, justify, underline, gc);
229
    }
230
}
231
 
232
/*----------------------------------------------------------------------
233
 * TixpSubRegFillRectangle --
234
 *
235
 *
236
 *----------------------------------------------------------------------
237
 */
238
 
239
void
240
TixpSubRegFillRectangle(display, drawable, gc, subRegPtr, x, y, width, height)
241
    Display *display;           /* X display to use for drawing rectangle. */
242
    Drawable drawable;          /* Window or pixmap in which to draw the
243
                                 * rectangle. */
244
    GC gc;                      /* Graphics context to use for drawing. */
245
    TixpSubRegion * subRegPtr;  /* Information about the subregion */
246
    int x, y;                   /* Pixel coordinates within drawable of
247
                                 * upper left corner of display area. */
248
    int width, height;          /* Size of the rectangle. */
249
{
250
    if (subRegPtr->pixmap != None) {
251
        XFillRectangle(display, subRegPtr->pixmap, gc,
252
                x - subRegPtr->x, y - subRegPtr->x, width, height);
253
    } else {
254
        XFillRectangle(display, drawable, gc, x, y, width, height);
255
    }
256
}
257
 
258
/*----------------------------------------------------------------------
259
 * TixpSubRegDrawImage  --
260
 *
261
 *      Draws a Tk image in a subregion.
262
 *----------------------------------------------------------------------
263
 */
264
 
265
void
266
TixpSubRegDrawImage(subRegPtr, image, imageX, imageY, width, height,
267
        drawable, drawableX, drawableY)
268
    TixpSubRegion * subRegPtr;
269
    Tk_Image image;
270
    int imageX;
271
    int imageY;
272
    int width;
273
    int height;
274
    Drawable drawable;
275
    int drawableX;
276
    int drawableY;
277
{
278
    if (subRegPtr->pixmap != None) {
279
        Tk_RedrawImage(image, imageX, imageY, width, height, subRegPtr->pixmap,
280
                drawableX - subRegPtr->x, drawableY - subRegPtr->y);
281
    } else {
282
        Tk_RedrawImage(image, imageX, imageY, width, height, drawable,
283
                drawableX, drawableY);
284
    }
285
}
286
 
287
void
288
TixpSubRegDrawBitmap(display, drawable, gc, subRegPtr, bitmap, src_x, src_y,
289
        width, height, dest_x, dest_y, plane)
290
    Display *display;
291
    Drawable drawable;
292
    GC gc;
293
    TixpSubRegion * subRegPtr;
294
    Pixmap bitmap;
295
    int src_x, src_y;
296
    int width, height;
297
    int dest_x, dest_y;
298
    unsigned long plane;
299
{
300
    XSetClipOrigin(display, gc, dest_x, dest_y);
301
    if (subRegPtr->pixmap != None) {
302
        XCopyPlane(display, bitmap, subRegPtr->pixmap, gc, src_x, src_y,
303
                width, height, dest_x - subRegPtr->x, dest_y - subRegPtr->y,
304
                plane);
305
    } else {
306
        XCopyPlane(display, bitmap, drawable, gc, src_x, src_y, width, height,
307
                dest_x, dest_y, plane);
308
    }
309
    XSetClipOrigin(display, gc, 0, 0);
310
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.