2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include <proto/layers.h>
8 #include <proto/graphics.h>
9 #include <proto/cybergraphics.h>
10 #include <intuition/gadgetclass.h>
11 #include <graphics/rpattr.h>
12 #include <cybergraphx/cybergraphics.h>
13 #include "intuition_intern.h"
14 #include "inputhandler.h"
15 #include "inputhandler_actions.h"
16 #include "intuition_customize.h"
17 #include "renderwindowframe.h"
22 #define GADGETCLIPPING
24 /*****************************************************************************
27 #include <proto/intuition.h>
29 AROS_LH1(void, RefreshWindowFrame
,
32 AROS_LHA(struct Window
*, window
, A0
),
35 struct IntuitionBase
*, IntuitionBase
, 76, Intuition
)
53 *****************************************************************************/
57 EnterFunc(bug("RefreshWindowFrame(window=%p)\n", window
));
59 int_refreshwindowframe(window
, 0, 0, IntuitionBase
);
61 ReturnVoid("RefreshWindowFrame");
64 } /* RefreshWindowFrame */
66 VOID
int_RefreshWindowFrame(struct Window
*window
,
67 LONG mustbe
, LONG mustnotbe
, LONG mode
,
68 struct IntuitionBase
*IntuitionBase
)
70 /* Draw a frame around the window */
71 struct RastPort
*rp
= window
->BorderRPort
;
72 struct Layer
*layer
= (BLAYER(window
)) ? BLAYER(window
) : WLAYER(window
);
73 struct IntDrawInfo
*dri
;
74 struct Region
*old_clipregion
;
76 struct Region
*gadgetclipregion
;
78 struct windowclassprefs
*wcprefs
=NULL
;
79 WORD old_scroll_x
, old_scroll_y
;
81 WORD leftoffset
=0,topoffset
=0,rightoffset
=1,bottomoffset
=1;
83 if (!(window
->Flags
& WFLG_BORDERLESS
))
86 dri
= (struct IntDrawInfo
*)GetScreenDrawInfo(window
->WScreen
);
90 wcprefs
= (struct windowclassprefs
*)int_GetCustomPrefs(TYPE_WINDOWCLASS
,dri
,IntuitionBase
);
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", (ULONG
) window
);
99 dprintf("RefreshWindowFrame: WLayer 0x%lx\n", (ULONG
) window
->WLayer
);
100 dprintf("RefreshWindowFrame: RPort 0x%lx BorderRPort 0x%lx\n", (ULONG
) window
->RPort
, (ULONG
) window
->BorderRPort
);
101 dprintf("RefreshWindowFrame: RPort's layer 0x%lx BorderRPort's layer 0x%lx\n", (ULONG
) window
->RPort
->Layer
, (ULONG
) window
->BorderRPort
->Layer
);
106 if (!rp
->Layer
|| !layer
)
109 dprintf("RefreshWindowFrame: Panic! Window 0x%lx has no layer in BorderRPort!\n",(ULONG
)window
);
115 old_scroll_x
= layer
->Scroll_X
;
116 old_scroll_y
= layer
->Scroll_Y
;
121 #ifdef GADGETCLIPPING
122 gadgetclipregion
= NewRegion();
123 if (gadgetclipregion
)
125 struct Rectangle rect
;
127 /* add all gadgets to region */
128 clipbordergadgets(gadgetclipregion
,window
,IntuitionBase
);
130 /* then remove them with xor */
133 rect
.MaxX
= window
->Width
- 1;
134 rect
.MaxY
= window
->Height
- 1;
135 XorRectRegion(gadgetclipregion
,&rect
);
139 old_clipregion
= InstallClipRegion(layer
, gadgetclipregion
);
141 old_clipregion
= InstallClipRegion(layer
, NULL
);
144 /* if (((wcprefs->flags & WINDOWCLASS_PREFS_USEBORDERSEFFECT) && (dri->dri_Flags & DRIF_DIRECTCOLOR)) || (wcprefs->flags & WINDOWCLASS_PREFS_FRAMELESS))
152 if (!(mustbe
& REFRESHGAD_TOPBORDER
))
154 if (window
->BorderLeft
> leftoffset
+ 1)
155 RenderWindowFrame(window
,leftoffset
,window
->BorderTop
,window
->BorderLeft
- (leftoffset
*2),window
->Height
- window
->BorderTop
- window
->BorderBottom
+ 1,TRUE
,mode
,NULL
,dri
,IntuitionBase
);
157 if (window
->BorderRight
> rightoffset
)
158 RenderWindowFrame(window
,window
->Width
- window
->BorderRight
+ leftoffset
,window
->BorderTop
,window
->BorderRight
- rightoffset
- leftoffset
+ 1,window
->Height
- bottomoffset
- window
->BorderTop
- 1,TRUE
,mode
,NULL
,dri
,IntuitionBase
);
160 if (window
->BorderBottom
> bottomoffset
)
161 RenderWindowFrame(window
,leftoffset
,window
->Height
- window
->BorderBottom
+ topoffset
,window
->Width
- leftoffset
- rightoffset
+ 1,window
->BorderBottom
- topoffset
- bottomoffset
+ 1,TRUE
,mode
,NULL
,dri
,IntuitionBase
);
165 if (window
->BorderTop
> leftoffset
*2)
167 ((struct IntWindow
*)(window
))->titlepos
= left
+ 3;
168 RenderWindowFrame(window
,0,0,window
->Width
,window
->BorderTop
,TRUE
,mode
,NULL
,(struct IntDrawInfo
*)dri
,IntuitionBase
);
171 #ifdef GADGETCLIPPING
172 InstallClipRegion(layer
,NULL
);
175 /* Emm: RefreshWindowFrame() is documented to refresh *all* the gadgets,
176 * but when a window is activated/deactivated, only border gadgets
179 /* Refresh rel gadgets first, since wizard.library (burn in hell!) seems
180 * to rely on that. */
181 /* jDc: | ((window->Height <= window->BorderTop) ? REFRESHGAD_TOPBORDER : 0)
182 ** is here to protect from sizegadget drawing on depthgadget when window is
183 ** zoomed to titlebar height (example: magellan listers)
185 int_refreshglist(window
->FirstGadget
,
189 mustbe
| REFRESHGAD_REL
| (((window
->Height
<= window
->BorderTop
) ? REFRESHGAD_TOPBORDER
: 0)),
192 int_refreshglist(window
->FirstGadget
,
196 mustbe
| (((window
->Height
<= window
->BorderTop
) ? REFRESHGAD_TOPBORDER
: 0)),
197 mustnotbe
| REFRESHGAD_REL
,
200 int_refreshglist(window
->FirstGadget
,
209 InstallClipRegion(layer
,old_clipregion
);
211 #ifdef GADGETCLIPPING
212 if (gadgetclipregion
) DisposeRegion(gadgetclipregion
);
215 layer
->Scroll_X
= old_scroll_x
;
216 layer
->Scroll_Y
= old_scroll_y
;
222 UNLOCK_REFRESH(window
->WScreen
);
224 int_FreeCustomPrefs(TYPE_WINDOWCLASS
,(struct IntDrawInfo
*)dri
,IntuitionBase
);
226 FreeScreenDrawInfo(window
->WScreen
, (struct DrawInfo
*)dri
);
232 } /* if (!(win->Flags & WFLG_BORDERLESS)) */