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

Subversion Repositories or1k

[/] [or1k/] [tags/] [MW_0_8_9PRE7/] [mw/] [src/] [mwin/] [winclip2.c] - Blame information for rev 673

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

Line No. Rev Author Line
1 673 markom
/*
2
 * Copyright (c) 2000 Greg Haerr <greg@censoft.com>
3
 * Portions Copyright (c) 1991 David I. Bell
4
 * Permission is granted to use, distribute, or modify this source,
5
 * provided that this copyright notice remains intact.
6
 *
7
 * DYNAMICREGIONS MwSetClipWindow
8
 */
9
#include "windows.h"
10
#include "wintern.h"
11
 
12
/*
13
 * Set the clip rectangles for a window taking into account other
14
 * windows that may be obscuring it.  The windows that may be obscuring
15
 * this one are the siblings of each direct ancestor which are higher
16
 * in priority than those ancestors.  Also, each parent limits the visible
17
 * area of the window.
18
 */
19
void
20
MwSetClipWindow(HDC hdc)
21
{
22
        HWND            wp = hdc->hwnd;
23
        HWND            pwp;            /* parent window */
24
        HWND            sibwp;          /* sibling windows */
25
        MWCOORD         diff;           /* difference in coordinates */
26
        PRECT           prc;            /* client or window rectangle*/
27
        MWCLIPREGION    *vis, *r;
28
        MWCOORD         x, y, width, height;
29
 
30
        /*
31
         * Start with the rectangle for the complete window.
32
         * We will then cut pieces out of it as needed.
33
         */
34
        prc = MwIsClientDC(hdc)? &wp->clirect: &wp->winrect;
35
        x = prc->left;
36
        y = prc->top;
37
        width = prc->right - prc->left;
38
        height = prc->bottom - prc->top;
39
 
40
        /*
41
         * First walk upwards through all parent windows,
42
         * and restrict the visible part of this window to the part
43
         * that shows through all of those parent windows client areas.
44
         */
45
        pwp = wp;
46
        while (pwp != rootwp) {
47
                pwp = pwp->parent;
48
 
49
                diff = pwp->clirect.left - x;
50
                if (diff > 0) {
51
                        width -= diff;
52
                        x = pwp->clirect.left;
53
                }
54
 
55
                diff = pwp->clirect.right - (x + width);
56
                if (diff < 0)
57
                        width += diff;
58
 
59
                diff = pwp->clirect.top - y;
60
                if (diff > 0) {
61
                        height -= diff;
62
                        y = pwp->clirect.top;
63
                }
64
 
65
                diff = pwp->clirect.bottom - (y + height);
66
                if (diff < 0)
67
                        height += diff;
68
        }
69
 
70
        /*
71
         * If the window is completely clipped out of view, then
72
         * set the clipping region to indicate that.
73
         */
74
        if (width <= 0 || height <= 0) {
75
                GdSetClipRegion(hdc->psd, NULL);
76
                return;
77
        }
78
 
79
        /*
80
         * Allocate initial vis region to parent-clipped size of window
81
         */
82
        vis = GdAllocRectRegion(x, y, x+width, y+height);
83
 
84
        /*
85
         * Allocate temp region
86
         */
87
        r = GdAllocRegion();
88
 
89
        /*
90
         * Now examine all windows that obscure this window, and
91
         * for each obscuration, break up the clip rectangles into
92
         * the smaller pieces that are still visible.  The windows
93
         * that can obscure us are the earlier siblings of all of
94
         * our parents. When clipping the root window, search all children.
95
         */
96
        pwp = wp;
97
        while (pwp != NULL) {
98
                wp = pwp;
99
                pwp = wp->parent;
100
                if(!pwp) {
101
                        /* We're clipping the root window*/
102
                        if(hdc->flags & DCX_CLIPCHILDREN)
103
                                /* start with root's children*/
104
                                sibwp = rootwp->children;
105
                        else sibwp = NULL;      /* no search*/
106
                        wp = NULL;              /* search all root's children*/
107
                } else {
108
                        if(hdc->flags & DCX_CLIPSIBLINGS)
109
                                sibwp = pwp->children;
110
                        else sibwp = wp;        /* no search*/
111
                }
112
                for (; sibwp != wp; sibwp = sibwp->siblings) {
113
                        if (sibwp->unmapcount)
114
                                continue;
115
 
116
                        GdSetRectRegionIndirect(r, &sibwp->winrect);
117
                        GdSubtractRegion(vis, vis, r);
118
                }
119
 
120
                /* if not clipping the root window, stop when you reach it*/
121
                if(pwp == rootwp)
122
                        break;
123
        }
124
 
125
        /*
126
         * If not the root window and we're going to be drawing
127
         * in the client area, clip all children.  This is
128
         * required for non-special paint handling for child windows.
129
         * Non-client dc's don't clip children in order to get
130
         * proper border clipping in the case of border-clipped children.
131
         */
132
        wp = hdc->hwnd;
133
        if(wp != rootwp && MwIsClientDC(hdc)) {
134
                for (sibwp=wp->children; sibwp; sibwp = sibwp->siblings) {
135
                        if (sibwp->unmapcount)
136
                                continue;
137
 
138
                        GdSetRectRegionIndirect(r, &sibwp->winrect);
139
                        GdSubtractRegion(vis, vis, r);
140
                }
141
        }
142
 
143
#if UPDATEREGIONS
144
        /*
145
         * Intersect with update region, unless requested not to.
146
         */
147
        if(!(hdc->flags & DCX_EXCLUDEUPDATE))
148
                GdIntersectRegion(vis, vis, wp->update);
149
#endif
150
        /*
151
         * Intersect with user region, if set.
152
         */
153
        if (hdc->region)
154
                GdIntersectRegion(vis, vis, hdc->region->rgn);
155
        /*
156
         * Set the clip region (later destroy handled by GdSetClipRegion)
157
         */
158
        GdSetClipRegion(hdc->psd, vis);
159
 
160
        /*
161
         * Destroy temp region
162
         */
163
        GdDestroyRegion(r);
164
}

powered by: WebSVN 2.1.0

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