New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / intuition / refreshwindowframe_morphos.c
blob9228adb4ceacfbf33800e0a1e8c4d4a3fbe8ab5f
1 /*
2 Copyright © 1995-2003, 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
39 INPUTS
41 RESULT
43 NOTES
45 EXAMPLE
47 BUGS
49 SEE ALSO
51 INTERNALS
53 *****************************************************************************/
55 AROS_LIBFUNC_INIT
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");
64 AROS_LIBFUNC_EXIT
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;
76 #ifdef GADGETCLIPPING
77 struct Region *gadgetclipregion;
78 #endif
79 struct windowclassprefs *wcprefs=NULL;
80 WORD old_scroll_x, old_scroll_y;
81 WORD left = 0;
82 WORD leftoffset=0,topoffset=0,rightoffset=1,bottomoffset=1;
84 if (!(window->Flags & WFLG_BORDERLESS))
87 dri = (struct IntDrawInfo *)GetScreenDrawInfo(window->WScreen);
89 if (dri)
91 wcprefs = (struct windowclassprefs *)int_GetCustomPrefs(TYPE_WINDOWCLASS,dri,IntuitionBase);
93 LOCK_REFRESH(window->WScreen);
94 LOCKGADGET
95 #if 0
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);
105 #endif
107 if (!rp->Layer || !layer)
109 //must NOT happen!
110 dprintf("RefreshWindowFrame: Panic! Window 0x%lx has no layer in BorderRPort!\n",(ULONG)window);
111 return;
114 LockLayer(0,layer);
116 old_scroll_x = layer->Scroll_X;
117 old_scroll_y = layer->Scroll_Y;
119 layer->Scroll_X = 0;
120 layer->Scroll_Y = 0;
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 */
132 rect.MinX = 0;
133 rect.MinY = 0;
134 rect.MaxX = window->Width - 1;
135 rect.MaxY = window->Height - 1;
136 XorRectRegion(gadgetclipregion,&rect);
140 old_clipregion = InstallClipRegion(layer, gadgetclipregion);
141 #else
142 old_clipregion = InstallClipRegion(layer, NULL);
143 #endif
145 /* if (((wcprefs->flags & WINDOWCLASS_PREFS_USEBORDERSEFFECT) && (dri->dri_Flags & DRIF_DIRECTCOLOR)) || (wcprefs->flags & WINDOWCLASS_PREFS_FRAMELESS))
147 leftoffset = 0;
148 rightoffset = 1;
149 topoffset = 0;
150 bottomoffset = 1;
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);
174 #endif
176 /* Emm: RefreshWindowFrame() is documented to refresh *all* the gadgets,
177 * but when a window is activated/deactivated, only border gadgets
178 * are refreshed. */
179 #if 1
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,
187 window,
188 NULL,
190 mustbe | REFRESHGAD_REL | (((window->Height <= window->BorderTop) ? REFRESHGAD_TOPBORDER : 0)),
191 mustnotbe,
192 IntuitionBase);
193 int_refreshglist(window->FirstGadget,
194 window,
195 NULL,
197 mustbe | (((window->Height <= window->BorderTop) ? REFRESHGAD_TOPBORDER : 0)),
198 mustnotbe | REFRESHGAD_REL,
199 IntuitionBase);
200 #else
201 int_refreshglist(window->FirstGadget,
202 window,
203 NULL,
205 mustbe,
206 mustnotbe ,
207 IntuitionBase);
208 #endif
210 InstallClipRegion(layer,old_clipregion);
212 #ifdef GADGETCLIPPING
213 if (gadgetclipregion) DisposeRegion(gadgetclipregion);
214 #endif
216 layer->Scroll_X = old_scroll_x;
217 layer->Scroll_Y = old_scroll_y;
219 UnlockLayer(layer);
221 UNLOCKGADGET
223 UNLOCK_REFRESH(window->WScreen);
225 int_FreeCustomPrefs(TYPE_WINDOWCLASS,(struct IntDrawInfo*)dri,IntuitionBase);
227 FreeScreenDrawInfo(window->WScreen, (struct DrawInfo *)dri);
231 } /* if (dri) */
233 } /* if (!(win->Flags & WFLG_BORDERLESS)) */