New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / intuition / refreshwindowframe_aros.c
blob1143776403c9dc6cc05f1bf7649572cef554dd0c
1 /*
2 Copyright © 1995-2003, 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 <intuition/intuitionbase.h>
9 #include <intuition/windecorclass.h>
10 #include <graphics/rpattr.h>
11 #include <cybergraphx/cybergraphics.h>
13 #include <proto/layers.h>
14 #include <proto/graphics.h>
15 #include <proto/layers.h>
17 #include <string.h>
19 #include "inputhandler_actions.h"
20 #include "intuition_intern.h"
22 //#define GADGETCLIPPING
24 #ifdef GADGETCLIPPING
25 void clipbordergadgets(struct Region *region,struct Window *w,struct IntuitionBase *IntuitionBase);
26 #endif
28 /*****************************************************************************
30 NAME */
31 #include <proto/intuition.h>
33 AROS_LH1(void, RefreshWindowFrame,
35 /* SYNOPSIS */
36 AROS_LHA(struct Window *, window, A0),
38 /* LOCATION */
39 struct IntuitionBase *, IntuitionBase, 76, Intuition)
41 /* FUNCTION
43 INPUTS
45 RESULT
47 NOTES
49 EXAMPLE
51 BUGS
53 SEE ALSO
55 INTERNALS
57 *****************************************************************************/
59 AROS_LIBFUNC_INIT
60 AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
62 EnterFunc(bug("RefreshWindowFrame(window=%p)\n", window));
64 int_refreshwindowframe(window, 0, 0, IntuitionBase);
66 ReturnVoid("RefreshWindowFrame");
68 AROS_LIBFUNC_EXIT
69 } /* RefreshWindowFrame */
71 VOID int_RefreshWindowFrame(struct Window *window,
72 LONG mustbe, LONG mustnotbe, LONG mode,
73 struct IntuitionBase *IntuitionBase)
75 /* Draw a frame around the window */
76 struct RastPort *rp = window->BorderRPort;
77 struct DrawInfo *dri;
78 struct Region *old_clipregion;
80 #ifdef GADGETCLIPPING
81 struct Region *gadgetclipregion;
82 #endif
84 WORD old_scroll_x, old_scroll_y;
86 if (!(window->Flags & WFLG_BORDERLESS))
88 dri = GetScreenDrawInfo(window->WScreen);
89 if (dri)
91 LOCK_REFRESH(window->WScreen);
92 LOCKGADGET
93 #if 1
94 if ((rp->Layer==NULL) ||
95 ((!(window->Flags & WFLG_GIMMEZEROZERO)) && (rp->Layer != window->RPort->Layer)))
97 dprintf("RefreshWindowFrame: Window 0x%lx\n",window);
98 dprintf("RefreshWindowFrame: WLayer 0x%lx\n",window->WLayer);
99 dprintf("RefreshWindowFrame: RPort 0x%lx BorderRPort 0x%lx\n",window->RPort,window->BorderRPort);
100 dprintf("RefreshWindowFrame: RPort's layer 0x%lx BorderRPort's layer 0x%lx\n",window->RPort,window->RPort->Layer,window->BorderRPort,window->BorderRPort->Layer);
103 #endif
105 LockLayer(0,rp->Layer);
107 old_scroll_x = rp->Layer->Scroll_X;
108 old_scroll_y = rp->Layer->Scroll_Y;
110 rp->Layer->Scroll_X = 0;
111 rp->Layer->Scroll_Y = 0;
113 #ifdef GADGETCLIPPING
114 gadgetclipregion = NewRegion();
115 if (gadgetclipregion)
117 struct Rectangle rect;
119 /* add all gadgets to region */
120 clipbordergadgets(gadgetclipregion,window,IntuitionBase);
122 /* then remove them with xor */
123 rect.MinX = 0;
124 rect.MinY = 0;
125 rect.MaxX = window->Width - 1;
126 rect.MaxY = window->Height - 1;
127 XorRectRegion(gadgetclipregion,&rect);
131 old_clipregion = InstallClipRegion(rp->Layer, gadgetclipregion);
132 #else
133 old_clipregion = InstallClipRegion(rp->Layer, NULL);
134 #endif
136 LOCKSHARED_WINDECOR(dri);
139 struct wdpDrawWinBorder msg;
141 msg.MethodID = WDM_DRAW_WINBORDER;
142 msg.wdp_Window = window;
143 msg.wdp_RPort = rp;
144 msg.wdp_Flags = (mustbe == REFRESHGAD_TOPBORDER) ? WDF_DWB_TOP_ONLY : 0;
146 DoMethodA(((struct IntDrawInfo *)(dri))->dri_WinDecorObj, (Msg)&msg);
149 /* Render the titlebar */
150 if (NULL != window->Title)
152 struct wdpDrawWinTitle msg;
154 msg.MethodID = WDM_DRAW_WINTITLE;
155 msg.wdp_Window = window;
156 msg.wdp_RPort = rp;
157 msg.wdp_TitleAlign = WD_DWTA_LEFT;
158 msg.wdp_Flags = 0;
160 DoMethodA(((struct IntDrawInfo *)(dri))->dri_WinDecorObj, (Msg)&msg);
163 UNLOCK_WINDECOR(dri);
165 #ifdef GADGETCLIPPING
166 InstallClipRegion(rp->Layer,NULL);
167 #endif
169 /* Emm: RefreshWindowFrame() is documented to refresh *all* the gadgets,
170 * but when a window is activated/deactivated, only border gadgets
171 * are refreshed. */
172 #if 1
173 /* Refresh rel gadgets first, since wizard.library (burn in hell!) seems
174 * to rely on that. */
175 int_refreshglist(window->FirstGadget,
176 window,
177 NULL,
179 mustbe | REFRESHGAD_REL,
180 mustnotbe,
181 IntuitionBase);
182 int_refreshglist(window->FirstGadget,
183 window,
184 NULL,
186 mustbe,
187 mustnotbe | REFRESHGAD_REL,
188 IntuitionBase);
189 #else
190 int_refreshglist(window->FirstGadget,
191 window,
192 NULL,
194 mustbe,
195 mustnotbe,
196 IntuitionBase);
197 #endif
199 InstallClipRegion(rp->Layer,old_clipregion);
201 #ifdef GADGETCLIPPING
202 if (gadgetclipregion) DisposeRegion(gadgetclipregion);
203 #endif
205 rp->Layer->Scroll_X = old_scroll_x;
206 rp->Layer->Scroll_Y = old_scroll_y;
208 UnlockLayer(rp->Layer);
209 UNLOCKGADGET
211 UNLOCK_REFRESH(window->WScreen);
213 FreeScreenDrawInfo(window->WScreen, (struct DrawInfo *)dri);
215 } /* if (dri) */
217 } /* if (!(win->Flags & WFLG_BORDERLESS)) */
220 #ifdef GADGETCLIPPING
221 void clipbordergadgets(struct Region *region,struct Window *w,struct IntuitionBase *IntuitionBase)
223 struct Gadget *gad;
225 for (gad = w->FirstGadget; gad; gad = gad->NextGadget)
227 BOOL qualified = FALSE;
228 WORD left,top,right,bottom;
230 top = gad->TopEdge;
231 2 left = gad->LeftEdge;
233 if (gad->Flags & GFLG_RELBOTTOM) top = w->Height - 1 + gad->TopEdge;
234 if (gad->Flags & GFLG_RELRIGHT) left = w->Width - 1 + gad->LeftEdge;
236 /* we need to be prepared for GFLG_GADGIMAGE and IA_Left set to -1, etc */
237 if (gad->Flags & GFLG_GADGIMAGE && gad->SelectRender)
238 left += ((struct Image *)gad->SelectRender)->LeftEdge;
240 right = left + gad->Width - 1;
241 bottom = top + gad->Height - 1;
243 /* let's do some clipping now */
245 if (left >= w->Width) continue;
246 if (top >= w->Height) continue;
247 if (right < 0) continue;
248 if (bottom < 0) continue;
250 if (left < 0) left = 0;
251 if (top < 0) top = 0;
252 if (right > w->Width) right = w->Width;
253 if (top > w->Height) top = w->Height;
255 /* sanity check */
257 if (right < left) continue;
258 if (bottom < top) continue;
260 /* clip this gadget ? */
262 if (top >= w->Height - 1 - w->BorderBottom) qualified = TRUE;
263 if (left >= w->Width - 1 - w->BorderRight) qualified = TRUE;
264 if (top + gad->Height - 1 <= w->BorderTop) qualified = TRUE;
265 if (left + gad->Width - 1 <= w->BorderLeft) qualified = TRUE;
267 if (qualified)
269 struct Rectangle rect;
271 rect.MinX = left;
272 rect.MinY = top;
273 rect.MaxX = right;
274 rect.MaxY = bottom;
276 OrRectRegion(region,&rect);
282 #endif