2 Copyright © 1995-2013, 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 LayersBase
*LayersBase
= GetPrivIBase(IntuitionBase
)->LayersBase
;
78 struct RastPort
*rp
= window
->BorderRPort
;
80 struct Region
*old_clipregion
;
83 struct Region
*gadgetclipregion
;
86 WORD old_scroll_x
, old_scroll_y
;
88 if (!(window
->Flags
& WFLG_BORDERLESS
))
90 dri
= GetScreenDrawInfo(window
->WScreen
);
93 LOCK_REFRESH(window
->WScreen
);
94 LOCKGADGET(IntuitionBase
)
96 if ((rp
->Layer
==NULL
) ||
97 ((!(window
->Flags
& WFLG_GIMMEZEROZERO
)) && (rp
->Layer
!= window
->RPort
->Layer
)))
99 dprintf("RefreshWindowFrame: Window 0x%lx\n",window
);
100 dprintf("RefreshWindowFrame: WLayer 0x%lx\n",window
->WLayer
);
101 dprintf("RefreshWindowFrame: RPort 0x%lx BorderRPort 0x%lx\n",window
->RPort
,window
->BorderRPort
);
102 dprintf("RefreshWindowFrame: RPort's layer 0x%lx BorderRPort's layer 0x%lx\n",window
->RPort
,window
->RPort
->Layer
,window
->BorderRPort
,window
->BorderRPort
->Layer
);
107 LockLayer(0,rp
->Layer
);
109 old_scroll_x
= rp
->Layer
->Scroll_X
;
110 old_scroll_y
= rp
->Layer
->Scroll_Y
;
112 rp
->Layer
->Scroll_X
= 0;
113 rp
->Layer
->Scroll_Y
= 0;
115 #ifdef GADGETCLIPPING
116 gadgetclipregion
= NewRegion();
117 if (gadgetclipregion
)
119 struct Rectangle rect
;
121 /* add all gadgets to region */
122 clipbordergadgets(gadgetclipregion
,window
,IntuitionBase
);
124 /* then remove them with xor */
127 rect
.MaxX
= window
->Width
- 1;
128 rect
.MaxY
= window
->Height
- 1;
129 XorRectRegion(gadgetclipregion
,&rect
);
133 old_clipregion
= InstallClipRegion(rp
->Layer
, gadgetclipregion
);
135 old_clipregion
= InstallClipRegion(rp
->Layer
, NULL
);
139 struct wdpDrawWinBorder msg
;
141 msg
.MethodID
= WDM_DRAW_WINBORDER
;
142 msg
.wdp_TrueColor
= (((struct IntScreen
*)window
->WScreen
)->DInfo
.dri_Flags
& DRIF_DIRECTCOLOR
) ? TRUE
: FALSE
;
143 msg
.wdp_Window
= window
;
145 msg
.wdp_Flags
= (mustbe
== REFRESHGAD_TOPBORDER
) ? WDF_DWB_TOP_ONLY
: 0;
147 msg
.wdp_UserBuffer
= ((struct IntWindow
*)window
)->DecorUserBuffer
;
148 DoMethodA(((struct IntScreen
*)(window
->WScreen
))->WinDecorObj
, (Msg
)&msg
);
151 #ifdef GADGETCLIPPING
152 InstallClipRegion(rp
->Layer
,NULL
);
155 /* Emm: RefreshWindowFrame() is documented to refresh *all* the gadgets,
156 * but when a window is activated/deactivated, only border gadgets
159 /* Refresh rel gadgets first, since wizard.library (burn in hell!) seems
160 * to rely on that. */
161 int_refreshglist(window
->FirstGadget
,
165 mustbe
| REFRESHGAD_REL
,
168 int_refreshglist(window
->FirstGadget
,
173 mustnotbe
| REFRESHGAD_REL
,
176 int_refreshglist(window
->FirstGadget
,
185 InstallClipRegion(rp
->Layer
,old_clipregion
);
187 #ifdef GADGETCLIPPING
188 if (gadgetclipregion
) DisposeRegion(gadgetclipregion
);
191 rp
->Layer
->Scroll_X
= old_scroll_x
;
192 rp
->Layer
->Scroll_Y
= old_scroll_y
;
194 UnlockLayer(rp
->Layer
);
195 UNLOCKGADGET(IntuitionBase
)
197 UNLOCK_REFRESH(window
->WScreen
);
199 FreeScreenDrawInfo(window
->WScreen
, (struct DrawInfo
*)dri
);
203 } /* if (!(win->Flags & WFLG_BORDERLESS)) */
206 #ifdef GADGETCLIPPING
207 void clipbordergadgets(struct Region
*region
,struct Window
*w
,struct IntuitionBase
*IntuitionBase
)
211 for (gad
= w
->FirstGadget
; gad
; gad
= gad
->NextGadget
)
213 BOOL qualified
= FALSE
;
214 WORD left
,top
,right
,bottom
;
217 left
= gad
->LeftEdge
;
219 if (gad
->Flags
& GFLG_RELBOTTOM
) top
= w
->Height
- 1 + gad
->TopEdge
;
220 if (gad
->Flags
& GFLG_RELRIGHT
) left
= w
->Width
- 1 + gad
->LeftEdge
;
222 /* we need to be prepared for GFLG_GADGIMAGE and IA_Left set to -1, etc */
223 if (gad
->Flags
& GFLG_GADGIMAGE
&& gad
->SelectRender
)
224 left
+= ((struct Image
*)gad
->SelectRender
)->LeftEdge
;
226 right
= left
+ gad
->Width
- 1;
227 bottom
= top
+ gad
->Height
- 1;
229 /* let's do some clipping now */
231 if (left
>= w
->Width
) continue;
232 if (top
>= w
->Height
) continue;
233 if (right
< 0) continue;
234 if (bottom
< 0) continue;
236 if (left
< 0) left
= 0;
237 if (top
< 0) top
= 0;
238 if (right
> w
->Width
) right
= w
->Width
;
239 if (top
> w
->Height
) top
= w
->Height
;
243 if (right
< left
) continue;
244 if (bottom
< top
) continue;
246 /* clip this gadget ? */
248 if (top
>= w
->Height
- 1 - w
->BorderBottom
) qualified
= TRUE
;
249 if (left
>= w
->Width
- 1 - w
->BorderRight
) qualified
= TRUE
;
250 if (top
+ gad
->Height
- 1 <= w
->BorderTop
) qualified
= TRUE
;
251 if (left
+ gad
->Width
- 1 <= w
->BorderLeft
) qualified
= TRUE
;
255 struct Rectangle rect
;
262 OrRectRegion(region
,&rect
);