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

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [insight/] [tk/] [mac/] [tkMacRegion.c] - Blame information for rev 1780

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
2
 * tkMacRegion.c --
3
 *
4
 *      Implements X window calls for manipulating regions
5
 *
6
 * Copyright (c) 1995-1996 Sun Microsystems, Inc.
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
 * RCS: @(#) $Id: tkMacRegion.c,v 1.1.1.1 2002-01-16 10:25:57 markom Exp $
12
 */
13
 
14
#include "tkInt.h"
15
#include "X.h"
16
#include "Xlib.h"
17
 
18
#include <Windows.h>
19
#include <QDOffscreen.h>
20
 
21
/*
22
 * Temporary region that can be reused.
23
 */
24
static RgnHandle tmpRgn = NULL;
25
 
26
 
27
/*
28
 *----------------------------------------------------------------------
29
 *
30
 * TkCreateRegion --
31
 *
32
 *      Implements the equivelent of the X window function
33
 *      XCreateRegion.  See X window documentation for more details.
34
 *
35
 * Results:
36
 *      Returns an allocated region handle.
37
 *
38
 * Side effects:
39
 *      None.
40
 *
41
 *----------------------------------------------------------------------
42
 */
43
 
44
TkRegion
45
TkCreateRegion()
46
{
47
    RgnHandle rgn;
48
 
49
    rgn = NewRgn();
50
    return (TkRegion) rgn;
51
}
52
 
53
/*
54
 *----------------------------------------------------------------------
55
 *
56
 * TkDestroyRegion --
57
 *
58
 *      Implements the equivelent of the X window function
59
 *      XDestroyRegion.  See X window documentation for more details.
60
 *
61
 * Results:
62
 *      None.
63
 *
64
 * Side effects:
65
 *      Memory is freed.
66
 *
67
 *----------------------------------------------------------------------
68
 */
69
 
70
void
71
TkDestroyRegion(
72
    TkRegion r)
73
{
74
    RgnHandle rgn = (RgnHandle) r;
75
 
76
    DisposeRgn(rgn);
77
}
78
 
79
/*
80
 *----------------------------------------------------------------------
81
 *
82
 * TkIntersectRegion --
83
 *
84
 *      Implements the equivilent of the X window function
85
 *      XIntersectRegion.  See X window documentation for more details.
86
 *
87
 * Results:
88
 *      None.
89
 *
90
 * Side effects:
91
 *      None.
92
 *
93
 *----------------------------------------------------------------------
94
 */
95
 
96
void
97
TkIntersectRegion(
98
    TkRegion sra,
99
    TkRegion srb,
100
    TkRegion dr_return)
101
{
102
    RgnHandle srcRgnA = (RgnHandle) sra;
103
    RgnHandle srcRgnB = (RgnHandle) srb;
104
    RgnHandle destRgn = (RgnHandle) dr_return;
105
 
106
    SectRgn(srcRgnA, srcRgnB, destRgn);
107
}
108
 
109
/*
110
 *----------------------------------------------------------------------
111
 *
112
 * TkUnionRectWithRegion --
113
 *
114
 *      Implements the equivelent of the X window function
115
 *      XUnionRectWithRegion.  See X window documentation for more
116
 *      details.
117
 *
118
 * Results:
119
 *      None.
120
 *
121
 * Side effects:
122
 *      None.
123
 *
124
 *----------------------------------------------------------------------
125
 */
126
 
127
void
128
TkUnionRectWithRegion(
129
    XRectangle* rectangle,
130
    TkRegion src_region,
131
    TkRegion dest_region_return)
132
{
133
    RgnHandle srcRgn = (RgnHandle) src_region;
134
    RgnHandle destRgn = (RgnHandle) dest_region_return;
135
 
136
    if (tmpRgn == NULL) {
137
        tmpRgn = NewRgn();
138
    }
139
    SetRectRgn(tmpRgn, rectangle->x, rectangle->y,
140
            rectangle->x + rectangle->width, rectangle->y + rectangle->height);
141
    UnionRgn(srcRgn, tmpRgn, destRgn);
142
}
143
 
144
/*
145
 *----------------------------------------------------------------------
146
 *
147
 * TkRectInRegion --
148
 *
149
 *      Implements the equivelent of the X window function
150
 *      XRectInRegion.  See X window documentation for more details.
151
 *
152
 * Results:
153
 *      Returns one of: RectangleOut, RectangleIn, RectanglePart.
154
 *
155
 * Side effects:
156
 *      None.
157
 *
158
 *----------------------------------------------------------------------
159
 */
160
 
161
int
162
TkRectInRegion(
163
    TkRegion region,
164
    int x,
165
    int y,
166
    unsigned int width,
167
    unsigned int height)
168
{
169
    RgnHandle rgn = (RgnHandle) region;
170
    RgnHandle rectRgn, destRgn;
171
    int result;
172
 
173
    rectRgn = NewRgn();
174
    destRgn = NewRgn();
175
    SetRectRgn(rectRgn, x,  y, x + width, y + height);
176
    SectRgn(rgn, rectRgn, destRgn);
177
    if (EmptyRgn(destRgn)) {
178
        result = RectangleOut;
179
    } else if (EqualRgn(rgn, destRgn)) {
180
        result = RectangleIn;
181
    } else {
182
        result = RectanglePart;
183
    }
184
    DisposeRgn(rectRgn);
185
    DisposeRgn(destRgn);
186
    return result;
187
}
188
 
189
/*
190
 *----------------------------------------------------------------------
191
 *
192
 * TkClipBox --
193
 *
194
 *      Implements the equivelent of the X window function XClipBox.
195
 *      See X window documentation for more details.
196
 *
197
 * Results:
198
 *      None.
199
 *
200
 * Side effects:
201
 *      None.
202
 *
203
 *----------------------------------------------------------------------
204
 */
205
 
206
void
207
TkClipBox(
208
    TkRegion r,
209
    XRectangle* rect_return)
210
{
211
    RgnHandle rgn = (RgnHandle) r;
212
 
213
    rect_return->x = (**rgn).rgnBBox.left;
214
    rect_return->y = (**rgn).rgnBBox.top;
215
    rect_return->width = (**rgn).rgnBBox.right - (**rgn).rgnBBox.left;
216
    rect_return->height = (**rgn).rgnBBox.bottom - (**rgn).rgnBBox.top;
217
}

powered by: WebSVN 2.1.0

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