2 Copyright © 1995-2003, 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 *****************************************************************************/
56 AROS_LIBBASE_EXT_DECL(struct IntuitionBase
*,IntuitionBase
)
58 EnterFunc(bug("RefreshWindowFrame(window=%p)\n", window
));
60 int_refreshwindowframe(window
, 0, 0, IntuitionBase
);
62 ReturnVoid("RefreshWindowFrame");
65 } /* RefreshWindowFrame */
67 VOID
int_RefreshWindowFrame(struct Window
*window
,
68 LONG mustbe
, LONG mustnotbe
, LONG mode
,
69 struct IntuitionBase
*IntuitionBase
)
71 /* Draw a frame around the window */
72 struct RastPort
*rp
= window
->BorderRPort
;
73 struct Layer
*layer
= (BLAYER(window
)) ? BLAYER(window
) : WLAYER(window
);
74 struct IntDrawInfo
*dri
;
75 struct Region
*old_clipregion
;
77 struct Region
*gadgetclipregion
;
79 struct windowclassprefs
*wcprefs
=NULL
;
80 WORD old_scroll_x
, old_scroll_y
;
82 WORD leftoffset
=0,topoffset
=0,rightoffset
=1,bottomoffset
=1;
84 if (!(window
->Flags
& WFLG_BORDERLESS
))
87 dri
= (struct IntDrawInfo
*)GetScreenDrawInfo(window
->WScreen
);
91 wcprefs
= (struct windowclassprefs
*)int_GetCustomPrefs(TYPE_WINDOWCLASS
,dri
,IntuitionBase
);
93 LOCK_REFRESH(window
->WScreen
);
96 if ((rp
->Layer
==NULL
) ||
97 ((!(window
->Flags
& WFLG_GIMMEZEROZERO
)) && (rp
->Layer
!= window
->RPort
->Layer
)))
99 dprintf("RefreshWindowFrame: Window 0x%lx\n", (ULONG
) window
);
100 dprintf("RefreshWindowFrame: WLayer 0x%lx\n", (ULONG
) window
->WLayer
);
101 dprintf("RefreshWindowFrame: RPort 0x%lx BorderRPort 0x%lx\n", (ULONG
) window
->RPort
, (ULONG
) window
->BorderRPort
);
102 dprintf("RefreshWindowFrame: RPort's layer 0x%lx BorderRPort's layer 0x%lx\n", (ULONG
) window
->RPort
->Layer
, (ULONG
) window
->BorderRPort
->Layer
);
107 if (!rp
->Layer
|| !layer
)
110 dprintf("RefreshWindowFrame: Panic! Window 0x%lx has no layer in BorderRPort!\n",(ULONG
)window
);
116 old_scroll_x
= layer
->Scroll_X
;
117 old_scroll_y
= layer
->Scroll_Y
;
122 #ifdef GADGETCLIPPING
123 gadgetclipregion
= NewRegion();
124 if (gadgetclipregion
)
126 struct Rectangle rect
;
128 /* add all gadgets to region */
129 clipbordergadgets(gadgetclipregion
,window
,IntuitionBase
);
131 /* then remove them with xor */
134 rect
.MaxX
= window
->Width
- 1;
135 rect
.MaxY
= window
->Height
- 1;
136 XorRectRegion(gadgetclipregion
,&rect
);
140 old_clipregion
= InstallClipRegion(layer
, gadgetclipregion
);
142 old_clipregion
= InstallClipRegion(layer
, NULL
);
145 /* if (((wcprefs->flags & WINDOWCLASS_PREFS_USEBORDERSEFFECT) && (dri->dri_Flags & DRIF_DIRECTCOLOR)) || (wcprefs->flags & WINDOWCLASS_PREFS_FRAMELESS))
153 if (!(mustbe
& REFRESHGAD_TOPBORDER
))
155 if (window
->BorderLeft
> leftoffset
+ 1)
156 RenderWindowFrame(window
,leftoffset
,window
->BorderTop
,window
->BorderLeft
- (leftoffset
*2),window
->Height
- window
->BorderTop
- window
->BorderBottom
+ 1,TRUE
,mode
,NULL
,dri
,IntuitionBase
);
158 if (window
->BorderRight
> rightoffset
)
159 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
);
161 if (window
->BorderBottom
> bottomoffset
)
162 RenderWindowFrame(window
,leftoffset
,window
->Height
- window
->BorderBottom
+ topoffset
,window
->Width
- leftoffset
- rightoffset
+ 1,window
->BorderBottom
- topoffset
- bottomoffset
+ 1,TRUE
,mode
,NULL
,dri
,IntuitionBase
);
166 if (window
->BorderTop
> leftoffset
*2)
168 ((struct IntWindow
*)(window
))->titlepos
= left
+ 3;
169 RenderWindowFrame(window
,0,0,window
->Width
,window
->BorderTop
,TRUE
,mode
,NULL
,(struct IntDrawInfo
*)dri
,IntuitionBase
);
172 #ifdef GADGETCLIPPING
173 InstallClipRegion(layer
,NULL
);
176 /* Emm: RefreshWindowFrame() is documented to refresh *all* the gadgets,
177 * but when a window is activated/deactivated, only border gadgets
180 /* Refresh rel gadgets first, since wizard.library (burn in hell!) seems
181 * to rely on that. */
182 /* jDc: | ((window->Height <= window->BorderTop) ? REFRESHGAD_TOPBORDER : 0)
183 ** is here to protect from sizegadget drawing on depthgadget when window is
184 ** zoomed to titlebar height (example: magellan listers)
186 int_refreshglist(window
->FirstGadget
,
190 mustbe
| REFRESHGAD_REL
| (((window
->Height
<= window
->BorderTop
) ? REFRESHGAD_TOPBORDER
: 0)),
193 int_refreshglist(window
->FirstGadget
,
197 mustbe
| (((window
->Height
<= window
->BorderTop
) ? REFRESHGAD_TOPBORDER
: 0)),
198 mustnotbe
| REFRESHGAD_REL
,
201 int_refreshglist(window
->FirstGadget
,
210 InstallClipRegion(layer
,old_clipregion
);
212 #ifdef GADGETCLIPPING
213 if (gadgetclipregion
) DisposeRegion(gadgetclipregion
);
216 layer
->Scroll_X
= old_scroll_x
;
217 layer
->Scroll_Y
= old_scroll_y
;
223 UNLOCK_REFRESH(window
->WScreen
);
225 int_FreeCustomPrefs(TYPE_WINDOWCLASS
,(struct IntDrawInfo
*)dri
,IntuitionBase
);
227 FreeScreenDrawInfo(window
->WScreen
, (struct DrawInfo
*)dri
);
233 } /* if (!(win->Flags & WFLG_BORDERLESS)) */