Belarusian
[AROS.git] / rom / intuition / refreshwindowframe_morphos.c
blobb5aa5f59716952d0e92e08645f44bab26b399933
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
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"
18 #include "mosmisc.h"
20 #include <string.h>
22 #define GADGETCLIPPING
24 /*****************************************************************************
26 NAME */
27 #include <proto/intuition.h>
29 AROS_LH1(void, RefreshWindowFrame,
31 /* SYNOPSIS */
32 AROS_LHA(struct Window *, window, A0),
34 /* LOCATION */
35 struct IntuitionBase *, IntuitionBase, 76, Intuition)
37 /* FUNCTION
38 Redraw window borders.
40 INPUTS
41 window - pointer to a window whose borders should be redrawn
43 RESULT
45 NOTES
47 EXAMPLE
49 BUGS
51 SEE ALSO
53 INTERNALS
55 *****************************************************************************/
57 AROS_LIBFUNC_INIT
59 EnterFunc(bug("RefreshWindowFrame(window=%p)\n", window));
61 int_refreshwindowframe(window, 0, 0, IntuitionBase);
63 ReturnVoid("RefreshWindowFrame");
65 AROS_LIBFUNC_EXIT
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;
77 #ifdef GADGETCLIPPING
78 struct Region *gadgetclipregion;
79 #endif
80 struct windowclassprefs *wcprefs=NULL;
81 WORD old_scroll_x, old_scroll_y;
82 WORD left = 0;
83 WORD leftoffset=0,topoffset=0,rightoffset=1,bottomoffset=1;
85 if (!(window->Flags & WFLG_BORDERLESS))
88 dri = (struct IntDrawInfo *)GetScreenDrawInfo(window->WScreen);
90 if (dri)
92 wcprefs = (struct windowclassprefs *)int_GetCustomPrefs(TYPE_WINDOWCLASS,dri,IntuitionBase);
94 LOCK_REFRESH(window->WScreen);
95 LOCKGADGET
96 #if 0
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);
106 #endif
108 if (!rp->Layer || !layer)
110 //must NOT happen!
111 dprintf("RefreshWindowFrame: Panic! Window 0x%lx has no layer in BorderRPort!\n",(ULONG)window);
112 return;
115 LockLayer(0,layer);
117 old_scroll_x = layer->Scroll_X;
118 old_scroll_y = layer->Scroll_Y;
120 layer->Scroll_X = 0;
121 layer->Scroll_Y = 0;
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 */
133 rect.MinX = 0;
134 rect.MinY = 0;
135 rect.MaxX = window->Width - 1;
136 rect.MaxY = window->Height - 1;
137 XorRectRegion(gadgetclipregion,&rect);
141 old_clipregion = InstallClipRegion(layer, gadgetclipregion);
142 #else
143 old_clipregion = InstallClipRegion(layer, NULL);
144 #endif
146 /* if (((wcprefs->flags & WINDOWCLASS_PREFS_USEBORDERSEFFECT) && (dri->dri_Flags & DRIF_DIRECTCOLOR)) || (wcprefs->flags & WINDOWCLASS_PREFS_FRAMELESS))
148 leftoffset = 0;
149 rightoffset = 1;
150 topoffset = 0;
151 bottomoffset = 1;
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);
175 #endif
177 /* Emm: RefreshWindowFrame() is documented to refresh *all* the gadgets,
178 * but when a window is activated/deactivated, only border gadgets
179 * are refreshed. */
180 #if 1
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,
188 window,
189 NULL,
191 mustbe | REFRESHGAD_REL | (((window->Height <= window->BorderTop) ? REFRESHGAD_TOPBORDER : 0)),
192 mustnotbe,
193 IntuitionBase);
194 int_refreshglist(window->FirstGadget,
195 window,
196 NULL,
198 mustbe | (((window->Height <= window->BorderTop) ? REFRESHGAD_TOPBORDER : 0)),
199 mustnotbe | REFRESHGAD_REL,
200 IntuitionBase);
201 #else
202 int_refreshglist(window->FirstGadget,
203 window,
204 NULL,
206 mustbe,
207 mustnotbe ,
208 IntuitionBase);
209 #endif
211 InstallClipRegion(layer,old_clipregion);
213 #ifdef GADGETCLIPPING
214 if (gadgetclipregion) DisposeRegion(gadgetclipregion);
215 #endif
217 layer->Scroll_X = old_scroll_x;
218 layer->Scroll_Y = old_scroll_y;
220 UnlockLayer(layer);
222 UNLOCKGADGET
224 UNLOCK_REFRESH(window->WScreen);
226 int_FreeCustomPrefs(TYPE_WINDOWCLASS,(struct IntDrawInfo*)dri,IntuitionBase);
228 FreeScreenDrawInfo(window->WScreen, (struct DrawInfo *)dri);
232 } /* if (dri) */
234 } /* if (!(win->Flags & WFLG_BORDERLESS)) */