2 Copyright 1995-2007, 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 *****************************************************************************/
61 EnterFunc(bug("RefreshWindowFrame(window=%p)\n", window
));
63 int_refreshwindowframe(window
, 0, 0, IntuitionBase
);
65 ReturnVoid("RefreshWindowFrame");
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
;
77 struct Region
*old_clipregion
;
80 struct Region
*gadgetclipregion
;
83 WORD old_scroll_x
, old_scroll_y
;
85 if (!(window
->Flags
& WFLG_BORDERLESS
))
87 dri
= GetScreenDrawInfo(window
->WScreen
);
90 LOCK_REFRESH(window
->WScreen
);
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
);
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 */
124 rect
.MaxX
= window
->Width
- 1;
125 rect
.MaxY
= window
->Height
- 1;
126 XorRectRegion(gadgetclipregion
,&rect
);
130 old_clipregion
= InstallClipRegion(rp
->Layer
, gadgetclipregion
);
132 old_clipregion
= InstallClipRegion(rp
->Layer
, NULL
);
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
;
142 msg
.wdp_Flags
= (mustbe
== REFRESHGAD_TOPBORDER
) ? WDF_DWB_TOP_ONLY
: 0;
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
);
152 /* Emm: RefreshWindowFrame() is documented to refresh *all* the gadgets,
153 * but when a window is activated/deactivated, only border gadgets
156 /* Refresh rel gadgets first, since wizard.library (burn in hell!) seems
157 * to rely on that. */
158 int_refreshglist(window
->FirstGadget
,
162 mustbe
| REFRESHGAD_REL
,
165 int_refreshglist(window
->FirstGadget
,
170 mustnotbe
| REFRESHGAD_REL
,
173 int_refreshglist(window
->FirstGadget
,
182 InstallClipRegion(rp
->Layer
,old_clipregion
);
184 #ifdef GADGETCLIPPING
185 if (gadgetclipregion
) DisposeRegion(gadgetclipregion
);
188 rp
->Layer
->Scroll_X
= old_scroll_x
;
189 rp
->Layer
->Scroll_Y
= old_scroll_y
;
191 UnlockLayer(rp
->Layer
);
194 UNLOCK_REFRESH(window
->WScreen
);
196 FreeScreenDrawInfo(window
->WScreen
, (struct DrawInfo
*)dri
);
200 } /* if (!(win->Flags & WFLG_BORDERLESS)) */
203 #ifdef GADGETCLIPPING
204 void clipbordergadgets(struct Region
*region
,struct Window
*w
,struct IntuitionBase
*IntuitionBase
)
208 for (gad
= w
->FirstGadget
; gad
; gad
= gad
->NextGadget
)
210 BOOL qualified
= FALSE
;
211 WORD left
,top
,right
,bottom
;
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
;
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
;
252 struct Rectangle rect
;
259 OrRectRegion(region
,&rect
);