Added kernel module for starting the usb stack at boot time. It's not activated thoug...
[cake.git] / rom / intuition / scrollwindowraster.c
blob1fe085fa08070f89f0f8929036af29a880549568
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include <intuition/gadgetclass.h>
8 #include <proto/graphics.h>
9 #include <proto/layers.h>
10 #include <stdlib.h>
11 #include "intuition_intern.h"
12 #include "inputhandler.h"
13 #include "inputhandler_actions.h"
14 #include "inputhandler_support.h"
16 #ifdef __MORPHOS__
17 # include "mosmisc.h"
18 #endif
20 struct ScrollWindowRasterMsg
22 struct IntuiActionMsg msg;
23 struct Window *window;
26 static VOID int_scrollwindowraster(struct ScrollWindowRasterMsg *msg,
27 struct IntuitionBase *IntuitionBase);
29 /*****************************************************************************
31 NAME */
32 #include <proto/intuition.h>
34 AROS_LH7(void, ScrollWindowRaster,
36 /* SYNOPSIS */
37 AROS_LHA(struct Window *, win , A1),
38 AROS_LHA(WORD , dx , D0),
39 AROS_LHA(WORD , dy , D1),
40 AROS_LHA(WORD , xmin, D2),
41 AROS_LHA(WORD , ymin, D3),
42 AROS_LHA(WORD , xmax, D4),
43 AROS_LHA(WORD , ymax, D5),
45 /* LOCATION */
46 struct IntuitionBase *, IntuitionBase, 133, Intuition)
48 /* FUNCTION
49 Scrolls the content of the rectangle defined by (xmin,ymin)-
50 (xmax,ymax) by (dx,dy) towards (0,0). This function calls
51 ScrollRasterBF().
52 The advantage of this function over calling ScrollRasterBF() is
53 that the window will be informed about damages. A damage happens
54 if in a simple window parts from concelealed areas are scrolled
55 to visible areas. The visible areas will be blank as simple
56 windows store no data for concealed areas.
57 The blank parts that appear due to the scroll will be filled
58 with EraseRect() and are not considered damaged areas.
60 INPUTS
61 win - pointer to window in which to scroll
62 dx,dy - scroll by (dx,dy) towards (0,0)
63 xmin,ymin - upper left corner of the rectangle that will be
64 affected by the scroll
65 xmax,ymax - lower rigfht corner of the rectangle that will be
66 affected by the scroll
68 RESULT
70 NOTES
72 EXAMPLE
74 BUGS
76 SEE ALSO
78 INTERNALS
80 *****************************************************************************/
82 AROS_LIBFUNC_INIT
84 DEBUG_SCROLLWINDOWRASTER(dprintf("ScrollWindowRaster: window 0x%lx dx %d dy %d (%d,%d)-(%d,%d)\n",
85 win, dx, dy, xmin, ymin, xmax, ymax));
87 SANITY_CHECK(win)
89 #ifdef __MORPHOS__
90 LockLayers(&win->WScreen->LayerInfo);
91 #endif
93 ScrollRasterBF(win->RPort,
94 dx,
95 dy,
96 xmin,
97 ymin,
98 xmax,
99 ymax);
101 /* Has there been damage to the layer? */
102 if (WLAYER(win)->Flags & LAYERREFRESH)
105 Send a refresh message to the window if it doesn't already
106 have one.
109 struct ScrollWindowRasterMsg msg;
110 msg.window = win;
112 #ifdef DAMAGECACHE
113 RecordDamage(win->WScreen,IntuitionBase);
114 #endif
116 #ifdef __MORPHOS
117 UnlockLayers(&win->WScreen->LayerInfo);
118 #endif
120 DoASyncAction((APTR)int_scrollwindowraster, &msg.msg, sizeof(msg), IntuitionBase);
122 else
124 #ifdef __MORPHOS__
125 UnlockLayers(&win->WScreen->LayerInfo);
126 #endif
129 AROS_LIBFUNC_EXIT
130 } /* ScrollWindowRaster */
132 AROS_LH7(void, ScrollWindowRasterNoFill,
134 /* SYNOPSIS */
135 AROS_LHA(struct Window *, win , A1),
136 AROS_LHA(WORD , dx , D0),
137 AROS_LHA(WORD , dy , D1),
138 AROS_LHA(WORD , xmin, D2),
139 AROS_LHA(WORD , ymin, D3),
140 AROS_LHA(WORD , xmax, D4),
141 AROS_LHA(WORD , ymax, D5),
143 /* LOCATION */
144 struct IntuitionBase *, IntuitionBase, 159, Intuition)
147 AROS_LIBFUNC_INIT
149 DEBUG_SCROLLWINDOWRASTER(dprintf("ScrollWindowRaster: window 0x%lx dx %d dy %d (%d,%d)-(%d,%d)\n",
150 win, dx, dy, xmin, ymin, xmax, ymax));
152 SANITY_CHECK(win)
154 #ifdef __MORPHOS__
155 LockLayers(&win->WScreen->LayerInfo);
156 #endif
159 WORD adx = abs(dx);
160 WORD ady = abs(dy);
161 WORD width = xmax - xmin + 1;
162 WORD height = ymax - ymin + 1;
163 BOOL scroll = TRUE;
165 if (adx<width && ady<height)
167 WORD cw = width - adx;
168 WORD ch = height - ady;
169 WORD x1 = xmin;
170 WORD x2 = xmin;
171 WORD y1 = ymin;
172 WORD y2 = ymin;
174 if (dx>=0) x1 += dx;
175 else x2 -= dx;
177 if (dy>=0) y1 += dy;
178 else y2 -= dy;
180 ClipBlit(win->RPort,x1,y1,win->RPort,x2,y2,cw,ch,0xc0);
183 if (!(WLAYER(win)->Flags & LAYERREFRESH))
185 struct Rectangle rect;
186 struct ClipRect *cr;
188 rect.MinX = WLAYER(win)->bounds.MinX + xmin;
189 rect.MinY = WLAYER(win)->bounds.MinY + ymin;
190 rect.MaxX = WLAYER(win)->bounds.MinX + xmax;
191 rect.MaxY = WLAYER(win)->bounds.MinY + ymax;
193 for (cr=WLAYER(win)->ClipRect;cr;cr=cr->Next)
195 if (rect.MinX < cr->bounds.MinX) continue;
196 if (rect.MaxX > cr->bounds.MaxX) continue;
197 if (rect.MinY < cr->bounds.MinY) continue;
198 if (rect.MaxY > cr->bounds.MaxY) continue;
199 scroll = FALSE;
200 break;
204 if (scroll)
206 ULONG mask = win->RPort->Mask;
207 win->RPort->Mask = 0;
208 ScrollRaster(win->RPort,dx,dy,xmin,ymin,xmax,ymax);
209 win->RPort->Mask = mask;
213 /* Has there been damage to the layer? */
214 if (WLAYER(win)->Flags & LAYERREFRESH)
217 Send a refresh message to the window if it doesn't already
218 have one.
221 struct ScrollWindowRasterMsg msg;
222 msg.window = win;
224 #ifdef DAMAGECACHE
225 RecordDamage(win->WScreen,IntuitionBase);
226 #endif
228 #ifdef __MORPHOS__
229 UnlockLayers(&win->WScreen->LayerInfo);
230 #endif
231 DoASyncAction((APTR)int_scrollwindowraster, &msg.msg, sizeof(msg), IntuitionBase);
233 else
235 #ifdef __MORPHOS__
236 UnlockLayers(&win->WScreen->LayerInfo);
237 #endif
240 AROS_LIBFUNC_EXIT
241 } /* ScrollWindowRaster */
243 static VOID int_scrollwindowraster(struct ScrollWindowRasterMsg *msg,
244 struct IntuitionBase *IntuitionBase)
246 struct Window *window = msg->window;
248 LOCK_REFRESH(window->WScreen);
250 if (WLAYER(window)->Flags & LAYERREFRESH)
251 WindowNeedsRefresh(window, IntuitionBase);
253 UNLOCK_REFRESH(window->WScreen);