2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
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>
19 #include "inputhandler_actions.h"
20 #include "intuition_intern.h"
22 //#define GADGETCLIPPING
25 void clipbordergadgets(struct Region
*region
,struct Window
*w
,struct IntuitionBase
*IntuitionBase
);
28 /*****************************************************************************
31 #include <proto/intuition.h>
33 AROS_LH1(void, RefreshWindowFrame
,
36 AROS_LHA(struct Window
*, window
, A0
),
39 struct IntuitionBase
*, IntuitionBase
, 76, Intuition
)
57 *****************************************************************************/
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");
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
;
78 struct Region
*old_clipregion
;
81 struct Region
*gadgetclipregion
;
84 WORD old_scroll_x
, old_scroll_y
;
86 if (!(window
->Flags
& WFLG_BORDERLESS
))
88 dri
= GetScreenDrawInfo(window
->WScreen
);
91 LOCK_REFRESH(window
->WScreen
);
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
);
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 */
125 rect
.MaxX
= window
->Width
- 1;
126 rect
.MaxY
= window
->Height
- 1;
127 XorRectRegion(gadgetclipregion
,&rect
);
131 old_clipregion
= InstallClipRegion(rp
->Layer
, gadgetclipregion
);
133 old_clipregion
= InstallClipRegion(rp
->Layer
, NULL
);
136 LOCKSHARED_WINDECOR(dri
);
139 struct wdpDrawWinBorder msg
;
141 msg
.MethodID
= WDM_DRAW_WINBORDER
;
142 msg
.wdp_Window
= window
;
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
;
157 msg
.wdp_TitleAlign
= WD_DWTA_LEFT
;
160 DoMethodA(((struct IntDrawInfo
*)(dri
))->dri_WinDecorObj
, (Msg
)&msg
);
163 UNLOCK_WINDECOR(dri
);
165 #ifdef GADGETCLIPPING
166 InstallClipRegion(rp
->Layer
,NULL
);
169 /* Emm: RefreshWindowFrame() is documented to refresh *all* the gadgets,
170 * but when a window is activated/deactivated, only border gadgets
173 /* Refresh rel gadgets first, since wizard.library (burn in hell!) seems
174 * to rely on that. */
175 int_refreshglist(window
->FirstGadget
,
179 mustbe
| REFRESHGAD_REL
,
182 int_refreshglist(window
->FirstGadget
,
187 mustnotbe
| REFRESHGAD_REL
,
190 int_refreshglist(window
->FirstGadget
,
199 InstallClipRegion(rp
->Layer
,old_clipregion
);
201 #ifdef GADGETCLIPPING
202 if (gadgetclipregion
) DisposeRegion(gadgetclipregion
);
205 rp
->Layer
->Scroll_X
= old_scroll_x
;
206 rp
->Layer
->Scroll_Y
= old_scroll_y
;
208 UnlockLayer(rp
->Layer
);
211 UNLOCK_REFRESH(window
->WScreen
);
213 FreeScreenDrawInfo(window
->WScreen
, (struct DrawInfo
*)dri
);
217 } /* if (!(win->Flags & WFLG_BORDERLESS)) */
220 #ifdef GADGETCLIPPING
221 void clipbordergadgets(struct Region
*region
,struct Window
*w
,struct IntuitionBase
*IntuitionBase
)
225 for (gad
= w
->FirstGadget
; gad
; gad
= gad
->NextGadget
)
227 BOOL qualified
= FALSE
;
228 WORD left
,top
,right
,bottom
;
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
;
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
;
269 struct Rectangle rect
;
276 OrRectRegion(region
,&rect
);