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
)
42 Redraw window borders.
45 window - pointer to a window whose borders should be redrawn
59 *****************************************************************************/
63 EnterFunc(bug("RefreshWindowFrame(window=%p)\n", window
));
65 int_refreshwindowframe(window
, 0, 0, IntuitionBase
);
67 ReturnVoid("RefreshWindowFrame");
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
;
79 struct Region
*old_clipregion
;
82 struct Region
*gadgetclipregion
;
85 WORD old_scroll_x
, old_scroll_y
;
87 if (!(window
->Flags
& WFLG_BORDERLESS
))
89 dri
= GetScreenDrawInfo(window
->WScreen
);
92 LOCK_REFRESH(window
->WScreen
);
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
);
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 */
126 rect
.MaxX
= window
->Width
- 1;
127 rect
.MaxY
= window
->Height
- 1;
128 XorRectRegion(gadgetclipregion
,&rect
);
132 old_clipregion
= InstallClipRegion(rp
->Layer
, gadgetclipregion
);
134 old_clipregion
= InstallClipRegion(rp
->Layer
, NULL
);
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
;
144 msg
.wdp_Flags
= (mustbe
== REFRESHGAD_TOPBORDER
) ? WDF_DWB_TOP_ONLY
: 0;
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
);
154 /* Emm: RefreshWindowFrame() is documented to refresh *all* the gadgets,
155 * but when a window is activated/deactivated, only border gadgets
158 /* Refresh rel gadgets first, since wizard.library (burn in hell!) seems
159 * to rely on that. */
160 int_refreshglist(window
->FirstGadget
,
164 mustbe
| REFRESHGAD_REL
,
167 int_refreshglist(window
->FirstGadget
,
172 mustnotbe
| REFRESHGAD_REL
,
175 int_refreshglist(window
->FirstGadget
,
184 InstallClipRegion(rp
->Layer
,old_clipregion
);
186 #ifdef GADGETCLIPPING
187 if (gadgetclipregion
) DisposeRegion(gadgetclipregion
);
190 rp
->Layer
->Scroll_X
= old_scroll_x
;
191 rp
->Layer
->Scroll_Y
= old_scroll_y
;
193 UnlockLayer(rp
->Layer
);
196 UNLOCK_REFRESH(window
->WScreen
);
198 FreeScreenDrawInfo(window
->WScreen
, (struct DrawInfo
*)dri
);
202 } /* if (!(win->Flags & WFLG_BORDERLESS)) */
205 #ifdef GADGETCLIPPING
206 void clipbordergadgets(struct Region
*region
,struct Window
*w
,struct IntuitionBase
*IntuitionBase
)
210 for (gad
= w
->FirstGadget
; gad
; gad
= gad
->NextGadget
)
212 BOOL qualified
= FALSE
;
213 WORD left
,top
,right
,bottom
;
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
;
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
;
254 struct Rectangle rect
;
261 OrRectRegion(region
,&rect
);