some fixes to accented characters
[tangerine.git] / rom / intuition / refreshwindowframe_aros.c
blobaf39d8a906f1b884ebe45d189784b0fae96b38d5
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
42 Redraw window borders.
44 INPUTS
45 window - pointer to a window whose borders should be redrawn
47 RESULT
49 NOTES
51 EXAMPLE
53 BUGS
55 SEE ALSO
57 INTERNALS
59 *****************************************************************************/
61 AROS_LIBFUNC_INIT
63 EnterFunc(bug("RefreshWindowFrame(window=%p)\n", window));
65 int_refreshwindowframe(window, 0, 0, IntuitionBase);
67 ReturnVoid("RefreshWindowFrame");
69 AROS_LIBFUNC_EXIT
70 } /* RefreshWindowFrame */
72 VOID int_RefreshWindowFrame(struct Window *window,
73 LONG mustbe, LONG mustnotbe, LONG mode,
74 struct IntuitionBase *IntuitionBase)
76 /* Draw a frame around the window */
77 struct RastPort *rp = window->BorderRPort;
78 struct DrawInfo *dri;
79 struct Region *old_clipregion;
81 #ifdef GADGETCLIPPING
82 struct Region *gadgetclipregion;
83 #endif
85 WORD old_scroll_x, old_scroll_y;
87 if (!(window->Flags & WFLG_BORDERLESS))
89 dri = GetScreenDrawInfo(window->WScreen);
90 if (dri)
92 LOCK_REFRESH(window->WScreen);
93 LOCKGADGET
94 #if 1
95 if ((rp->Layer==NULL) ||
96 ((!(window->Flags & WFLG_GIMMEZEROZERO)) && (rp->Layer != window->RPort->Layer)))
98 dprintf("RefreshWindowFrame: Window 0x%lx\n",window);
99 dprintf("RefreshWindowFrame: WLayer 0x%lx\n",window->WLayer);
100 dprintf("RefreshWindowFrame: RPort 0x%lx BorderRPort 0x%lx\n",window->RPort,window->BorderRPort);
101 dprintf("RefreshWindowFrame: RPort's layer 0x%lx BorderRPort's layer 0x%lx\n",window->RPort,window->RPort->Layer,window->BorderRPort,window->BorderRPort->Layer);
104 #endif
106 LockLayer(0,rp->Layer);
108 old_scroll_x = rp->Layer->Scroll_X;
109 old_scroll_y = rp->Layer->Scroll_Y;
111 rp->Layer->Scroll_X = 0;
112 rp->Layer->Scroll_Y = 0;
114 #ifdef GADGETCLIPPING
115 gadgetclipregion = NewRegion();
116 if (gadgetclipregion)
118 struct Rectangle rect;
120 /* add all gadgets to region */
121 clipbordergadgets(gadgetclipregion,window,IntuitionBase);
123 /* then remove them with xor */
124 rect.MinX = 0;
125 rect.MinY = 0;
126 rect.MaxX = window->Width - 1;
127 rect.MaxY = window->Height - 1;
128 XorRectRegion(gadgetclipregion,&rect);
132 old_clipregion = InstallClipRegion(rp->Layer, gadgetclipregion);
133 #else
134 old_clipregion = InstallClipRegion(rp->Layer, NULL);
135 #endif
138 struct wdpDrawWinBorder msg;
140 msg.MethodID = WDM_DRAW_WINBORDER;
141 msg.wdp_TrueColor = (((struct IntScreen *)window->WScreen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR);
142 msg.wdp_Window = window;
143 msg.wdp_RPort = rp;
144 msg.wdp_Flags = (mustbe == REFRESHGAD_TOPBORDER) ? WDF_DWB_TOP_ONLY : 0;
145 msg.wdp_Dri = dri;
146 msg.wdp_UserBuffer = ((struct IntWindow *)window)->DecorUserBuffer;
147 DoMethodA(((struct IntScreen *)(window->WScreen))->WinDecorObj, (Msg)&msg);
150 #ifdef GADGETCLIPPING
151 InstallClipRegion(rp->Layer,NULL);
152 #endif
154 /* Emm: RefreshWindowFrame() is documented to refresh *all* the gadgets,
155 * but when a window is activated/deactivated, only border gadgets
156 * are refreshed. */
157 #if 1
158 /* Refresh rel gadgets first, since wizard.library (burn in hell!) seems
159 * to rely on that. */
160 int_refreshglist(window->FirstGadget,
161 window,
162 NULL,
164 mustbe | REFRESHGAD_REL,
165 mustnotbe,
166 IntuitionBase);
167 int_refreshglist(window->FirstGadget,
168 window,
169 NULL,
171 mustbe,
172 mustnotbe | REFRESHGAD_REL,
173 IntuitionBase);
174 #else
175 int_refreshglist(window->FirstGadget,
176 window,
177 NULL,
179 mustbe,
180 mustnotbe,
181 IntuitionBase);
182 #endif
184 InstallClipRegion(rp->Layer,old_clipregion);
186 #ifdef GADGETCLIPPING
187 if (gadgetclipregion) DisposeRegion(gadgetclipregion);
188 #endif
190 rp->Layer->Scroll_X = old_scroll_x;
191 rp->Layer->Scroll_Y = old_scroll_y;
193 UnlockLayer(rp->Layer);
194 UNLOCKGADGET
196 UNLOCK_REFRESH(window->WScreen);
198 FreeScreenDrawInfo(window->WScreen, (struct DrawInfo *)dri);
200 } /* if (dri) */
202 } /* if (!(win->Flags & WFLG_BORDERLESS)) */
205 #ifdef GADGETCLIPPING
206 void clipbordergadgets(struct Region *region,struct Window *w,struct IntuitionBase *IntuitionBase)
208 struct Gadget *gad;
210 for (gad = w->FirstGadget; gad; gad = gad->NextGadget)
212 BOOL qualified = FALSE;
213 WORD left,top,right,bottom;
215 top = gad->TopEdge;
216 left = gad->LeftEdge;
218 if (gad->Flags & GFLG_RELBOTTOM) top = w->Height - 1 + gad->TopEdge;
219 if (gad->Flags & GFLG_RELRIGHT) left = w->Width - 1 + gad->LeftEdge;
221 /* we need to be prepared for GFLG_GADGIMAGE and IA_Left set to -1, etc */
222 if (gad->Flags & GFLG_GADGIMAGE && gad->SelectRender)
223 left += ((struct Image *)gad->SelectRender)->LeftEdge;
225 right = left + gad->Width - 1;
226 bottom = top + gad->Height - 1;
228 /* let's do some clipping now */
230 if (left >= w->Width) continue;
231 if (top >= w->Height) continue;
232 if (right < 0) continue;
233 if (bottom < 0) continue;
235 if (left < 0) left = 0;
236 if (top < 0) top = 0;
237 if (right > w->Width) right = w->Width;
238 if (top > w->Height) top = w->Height;
240 /* sanity check */
242 if (right < left) continue;
243 if (bottom < top) continue;
245 /* clip this gadget ? */
247 if (top >= w->Height - 1 - w->BorderBottom) qualified = TRUE;
248 if (left >= w->Width - 1 - w->BorderRight) qualified = TRUE;
249 if (top + gad->Height - 1 <= w->BorderTop) qualified = TRUE;
250 if (left + gad->Width - 1 <= w->BorderLeft) qualified = TRUE;
252 if (qualified)
254 struct Rectangle rect;
256 rect.MinX = left;
257 rect.MinY = top;
258 rect.MaxX = right;
259 rect.MaxY = bottom;
261 OrRectRegion(region,&rect);
267 #endif