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
)
38 Redraw window borders.
41 window - pointer to a window whose borders should be redrawn
55 *****************************************************************************/
59 EnterFunc(bug("RefreshWindowFrame(window=%p)\n", window
));
61 int_refreshwindowframe(window
, 0, 0, IntuitionBase
);
63 ReturnVoid("RefreshWindowFrame");
66 } /* RefreshWindowFrame */
68 VOID
int_RefreshWindowFrame(struct Window
*window
,
69 LONG mustbe
, LONG mustnotbe
, LONG mode
,
70 struct IntuitionBase
*IntuitionBase
)
72 /* Draw a frame around the window */
73 struct RastPort
*rp
= window
->BorderRPort
;
74 struct Layer
*layer
= (BLAYER(window
)) ? BLAYER(window
) : WLAYER(window
);
75 struct IntDrawInfo
*dri
;
76 struct Region
*old_clipregion
;
78 struct Region
*gadgetclipregion
;
80 struct windowclassprefs
*wcprefs
=NULL
;
81 WORD old_scroll_x
, old_scroll_y
;
83 WORD leftoffset
=0,topoffset
=0,rightoffset
=1,bottomoffset
=1;
85 if (!(window
->Flags
& WFLG_BORDERLESS
))
88 dri
= (struct IntDrawInfo
*)GetScreenDrawInfo(window
->WScreen
);
92 wcprefs
= (struct windowclassprefs
*)int_GetCustomPrefs(TYPE_WINDOWCLASS
,dri
,IntuitionBase
);
94 LOCK_REFRESH(window
->WScreen
);
97 if ((rp
->Layer
==NULL
) ||
98 ((!(window
->Flags
& WFLG_GIMMEZEROZERO
)) && (rp
->Layer
!= window
->RPort
->Layer
)))
100 dprintf("RefreshWindowFrame: Window 0x%lx\n", (ULONG
) window
);
101 dprintf("RefreshWindowFrame: WLayer 0x%lx\n", (ULONG
) window
->WLayer
);
102 dprintf("RefreshWindowFrame: RPort 0x%lx BorderRPort 0x%lx\n", (ULONG
) window
->RPort
, (ULONG
) window
->BorderRPort
);
103 dprintf("RefreshWindowFrame: RPort's layer 0x%lx BorderRPort's layer 0x%lx\n", (ULONG
) window
->RPort
->Layer
, (ULONG
) window
->BorderRPort
->Layer
);
108 if (!rp
->Layer
|| !layer
)
111 dprintf("RefreshWindowFrame: Panic! Window 0x%lx has no layer in BorderRPort!\n",(ULONG
)window
);
117 old_scroll_x
= layer
->Scroll_X
;
118 old_scroll_y
= layer
->Scroll_Y
;
123 #ifdef GADGETCLIPPING
124 gadgetclipregion
= NewRegion();
125 if (gadgetclipregion
)
127 struct Rectangle rect
;
129 /* add all gadgets to region */
130 clipbordergadgets(gadgetclipregion
,window
,IntuitionBase
);
132 /* then remove them with xor */
135 rect
.MaxX
= window
->Width
- 1;
136 rect
.MaxY
= window
->Height
- 1;
137 XorRectRegion(gadgetclipregion
,&rect
);
141 old_clipregion
= InstallClipRegion(layer
, gadgetclipregion
);
143 old_clipregion
= InstallClipRegion(layer
, NULL
);
146 /* if (((wcprefs->flags & WINDOWCLASS_PREFS_USEBORDERSEFFECT) && (dri->dri_Flags & DRIF_DIRECTCOLOR)) || (wcprefs->flags & WINDOWCLASS_PREFS_FRAMELESS))
154 if (!(mustbe
& REFRESHGAD_TOPBORDER
))
156 if (window
->BorderLeft
> leftoffset
+ 1)
157 RenderWindowFrame(window
,leftoffset
,window
->BorderTop
,window
->BorderLeft
- (leftoffset
*2),window
->Height
- window
->BorderTop
- window
->BorderBottom
+ 1,TRUE
,mode
,NULL
,dri
,IntuitionBase
);
159 if (window
->BorderRight
> rightoffset
)
160 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
);
162 if (window
->BorderBottom
> bottomoffset
)
163 RenderWindowFrame(window
,leftoffset
,window
->Height
- window
->BorderBottom
+ topoffset
,window
->Width
- leftoffset
- rightoffset
+ 1,window
->BorderBottom
- topoffset
- bottomoffset
+ 1,TRUE
,mode
,NULL
,dri
,IntuitionBase
);
167 if (window
->BorderTop
> leftoffset
*2)
169 ((struct IntWindow
*)(window
))->titlepos
= left
+ 3;
170 RenderWindowFrame(window
,0,0,window
->Width
,window
->BorderTop
,TRUE
,mode
,NULL
,(struct IntDrawInfo
*)dri
,IntuitionBase
);
173 #ifdef GADGETCLIPPING
174 InstallClipRegion(layer
,NULL
);
177 /* Emm: RefreshWindowFrame() is documented to refresh *all* the gadgets,
178 * but when a window is activated/deactivated, only border gadgets
181 /* Refresh rel gadgets first, since wizard.library (burn in hell!) seems
182 * to rely on that. */
183 /* jDc: | ((window->Height <= window->BorderTop) ? REFRESHGAD_TOPBORDER : 0)
184 ** is here to protect from sizegadget drawing on depthgadget when window is
185 ** zoomed to titlebar height (example: magellan listers)
187 int_refreshglist(window
->FirstGadget
,
191 mustbe
| REFRESHGAD_REL
| (((window
->Height
<= window
->BorderTop
) ? REFRESHGAD_TOPBORDER
: 0)),
194 int_refreshglist(window
->FirstGadget
,
198 mustbe
| (((window
->Height
<= window
->BorderTop
) ? REFRESHGAD_TOPBORDER
: 0)),
199 mustnotbe
| REFRESHGAD_REL
,
202 int_refreshglist(window
->FirstGadget
,
211 InstallClipRegion(layer
,old_clipregion
);
213 #ifdef GADGETCLIPPING
214 if (gadgetclipregion
) DisposeRegion(gadgetclipregion
);
217 layer
->Scroll_X
= old_scroll_x
;
218 layer
->Scroll_Y
= old_scroll_y
;
224 UNLOCK_REFRESH(window
->WScreen
);
226 int_FreeCustomPrefs(TYPE_WINDOWCLASS
,(struct IntDrawInfo
*)dri
,IntuitionBase
);
228 FreeScreenDrawInfo(window
->WScreen
, (struct DrawInfo
*)dri
);
234 } /* if (!(win->Flags & WFLG_BORDERLESS)) */