added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / rom / intuition / refreshwindowframe_aros.c
blob12cf02de5f0ca18df09d66535bc06fb2afa26c38
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 <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
61 EnterFunc(bug("RefreshWindowFrame(window=%p)\n", window));
63 int_refreshwindowframe(window, 0, 0, IntuitionBase);
65 ReturnVoid("RefreshWindowFrame");
67 AROS_LIBFUNC_EXIT
68 } /* RefreshWindowFrame */
70 VOID int_RefreshWindowFrame(struct Window *window,
71 LONG mustbe, LONG mustnotbe, LONG mode,
72 struct IntuitionBase *IntuitionBase)
74 /* Draw a frame around the window */
75 struct RastPort *rp = window->BorderRPort;
76 struct DrawInfo *dri;
77 struct Region *old_clipregion;
79 #ifdef GADGETCLIPPING
80 struct Region *gadgetclipregion;
81 #endif
83 WORD old_scroll_x, old_scroll_y;
85 if (!(window->Flags & WFLG_BORDERLESS))
87 dri = GetScreenDrawInfo(window->WScreen);
88 if (dri)
90 LOCK_REFRESH(window->WScreen);
91 LOCKGADGET
92 #if 1
93 if ((rp->Layer==NULL) ||
94 ((!(window->Flags & WFLG_GIMMEZEROZERO)) && (rp->Layer != window->RPort->Layer)))
96 dprintf("RefreshWindowFrame: Window 0x%lx\n",window);
97 dprintf("RefreshWindowFrame: WLayer 0x%lx\n",window->WLayer);
98 dprintf("RefreshWindowFrame: RPort 0x%lx BorderRPort 0x%lx\n",window->RPort,window->BorderRPort);
99 dprintf("RefreshWindowFrame: RPort's layer 0x%lx BorderRPort's layer 0x%lx\n",window->RPort,window->RPort->Layer,window->BorderRPort,window->BorderRPort->Layer);
102 #endif
104 LockLayer(0,rp->Layer);
106 old_scroll_x = rp->Layer->Scroll_X;
107 old_scroll_y = rp->Layer->Scroll_Y;
109 rp->Layer->Scroll_X = 0;
110 rp->Layer->Scroll_Y = 0;
112 #ifdef GADGETCLIPPING
113 gadgetclipregion = NewRegion();
114 if (gadgetclipregion)
116 struct Rectangle rect;
118 /* add all gadgets to region */
119 clipbordergadgets(gadgetclipregion,window,IntuitionBase);
121 /* then remove them with xor */
122 rect.MinX = 0;
123 rect.MinY = 0;
124 rect.MaxX = window->Width - 1;
125 rect.MaxY = window->Height - 1;
126 XorRectRegion(gadgetclipregion,&rect);
130 old_clipregion = InstallClipRegion(rp->Layer, gadgetclipregion);
131 #else
132 old_clipregion = InstallClipRegion(rp->Layer, NULL);
133 #endif
136 struct wdpDrawWinBorder msg;
138 msg.MethodID = WDM_DRAW_WINBORDER;
139 msg.wdp_TrueColor = (((struct IntScreen *)window->WScreen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR);
140 msg.wdp_Window = window;
141 msg.wdp_RPort = rp;
142 msg.wdp_Flags = (mustbe == REFRESHGAD_TOPBORDER) ? WDF_DWB_TOP_ONLY : 0;
143 msg.wdp_Dri = dri;
144 msg.wdp_UserBuffer = ((struct IntWindow *)window)->DecorUserBuffer;
145 DoMethodA(((struct IntScreen *)(window->WScreen))->WinDecorObj, (Msg)&msg);
148 #ifdef GADGETCLIPPING
149 InstallClipRegion(rp->Layer,NULL);
150 #endif
152 /* Emm: RefreshWindowFrame() is documented to refresh *all* the gadgets,
153 * but when a window is activated/deactivated, only border gadgets
154 * are refreshed. */
155 #if 1
156 /* Refresh rel gadgets first, since wizard.library (burn in hell!) seems
157 * to rely on that. */
158 int_refreshglist(window->FirstGadget,
159 window,
160 NULL,
162 mustbe | REFRESHGAD_REL,
163 mustnotbe,
164 IntuitionBase);
165 int_refreshglist(window->FirstGadget,
166 window,
167 NULL,
169 mustbe,
170 mustnotbe | REFRESHGAD_REL,
171 IntuitionBase);
172 #else
173 int_refreshglist(window->FirstGadget,
174 window,
175 NULL,
177 mustbe,
178 mustnotbe,
179 IntuitionBase);
180 #endif
182 InstallClipRegion(rp->Layer,old_clipregion);
184 #ifdef GADGETCLIPPING
185 if (gadgetclipregion) DisposeRegion(gadgetclipregion);
186 #endif
188 rp->Layer->Scroll_X = old_scroll_x;
189 rp->Layer->Scroll_Y = old_scroll_y;
191 UnlockLayer(rp->Layer);
192 UNLOCKGADGET
194 UNLOCK_REFRESH(window->WScreen);
196 FreeScreenDrawInfo(window->WScreen, (struct DrawInfo *)dri);
198 } /* if (dri) */
200 } /* if (!(win->Flags & WFLG_BORDERLESS)) */
203 #ifdef GADGETCLIPPING
204 void clipbordergadgets(struct Region *region,struct Window *w,struct IntuitionBase *IntuitionBase)
206 struct Gadget *gad;
208 for (gad = w->FirstGadget; gad; gad = gad->NextGadget)
210 BOOL qualified = FALSE;
211 WORD left,top,right,bottom;
213 top = gad->TopEdge;
214 left = gad->LeftEdge;
216 if (gad->Flags & GFLG_RELBOTTOM) top = w->Height - 1 + gad->TopEdge;
217 if (gad->Flags & GFLG_RELRIGHT) left = w->Width - 1 + gad->LeftEdge;
219 /* we need to be prepared for GFLG_GADGIMAGE and IA_Left set to -1, etc */
220 if (gad->Flags & GFLG_GADGIMAGE && gad->SelectRender)
221 left += ((struct Image *)gad->SelectRender)->LeftEdge;
223 right = left + gad->Width - 1;
224 bottom = top + gad->Height - 1;
226 /* let's do some clipping now */
228 if (left >= w->Width) continue;
229 if (top >= w->Height) continue;
230 if (right < 0) continue;
231 if (bottom < 0) continue;
233 if (left < 0) left = 0;
234 if (top < 0) top = 0;
235 if (right > w->Width) right = w->Width;
236 if (top > w->Height) top = w->Height;
238 /* sanity check */
240 if (right < left) continue;
241 if (bottom < top) continue;
243 /* clip this gadget ? */
245 if (top >= w->Height - 1 - w->BorderBottom) qualified = TRUE;
246 if (left >= w->Width - 1 - w->BorderRight) qualified = TRUE;
247 if (top + gad->Height - 1 <= w->BorderTop) qualified = TRUE;
248 if (left + gad->Width - 1 <= w->BorderLeft) qualified = TRUE;
250 if (qualified)
252 struct Rectangle rect;
254 rect.MinX = left;
255 rect.MinY = top;
256 rect.MaxX = right;
257 rect.MaxY = bottom;
259 OrRectRegion(region,&rect);
265 #endif