added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / rom / intuition / refreshwindowframe_morphos.c
blob1e0007e6777b2a3f87012ed38c542466032c2f9a
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
39 INPUTS
41 RESULT
43 NOTES
45 EXAMPLE
47 BUGS
49 SEE ALSO
51 INTERNALS
53 *****************************************************************************/
55 AROS_LIBFUNC_INIT
57 EnterFunc(bug("RefreshWindowFrame(window=%p)\n", window));
59 int_refreshwindowframe(window, 0, 0, IntuitionBase);
61 ReturnVoid("RefreshWindowFrame");
63 AROS_LIBFUNC_EXIT
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;
75 #ifdef GADGETCLIPPING
76 struct Region *gadgetclipregion;
77 #endif
78 struct windowclassprefs *wcprefs=NULL;
79 WORD old_scroll_x, old_scroll_y;
80 WORD left = 0;
81 WORD leftoffset=0,topoffset=0,rightoffset=1,bottomoffset=1;
83 if (!(window->Flags & WFLG_BORDERLESS))
86 dri = (struct IntDrawInfo *)GetScreenDrawInfo(window->WScreen);
88 if (dri)
90 wcprefs = (struct windowclassprefs *)int_GetCustomPrefs(TYPE_WINDOWCLASS,dri,IntuitionBase);
92 LOCK_REFRESH(window->WScreen);
93 LOCKGADGET
94 #if 0
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);
104 #endif
106 if (!rp->Layer || !layer)
108 //must NOT happen!
109 dprintf("RefreshWindowFrame: Panic! Window 0x%lx has no layer in BorderRPort!\n",(ULONG)window);
110 return;
113 LockLayer(0,layer);
115 old_scroll_x = layer->Scroll_X;
116 old_scroll_y = layer->Scroll_Y;
118 layer->Scroll_X = 0;
119 layer->Scroll_Y = 0;
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 */
131 rect.MinX = 0;
132 rect.MinY = 0;
133 rect.MaxX = window->Width - 1;
134 rect.MaxY = window->Height - 1;
135 XorRectRegion(gadgetclipregion,&rect);
139 old_clipregion = InstallClipRegion(layer, gadgetclipregion);
140 #else
141 old_clipregion = InstallClipRegion(layer, NULL);
142 #endif
144 /* if (((wcprefs->flags & WINDOWCLASS_PREFS_USEBORDERSEFFECT) && (dri->dri_Flags & DRIF_DIRECTCOLOR)) || (wcprefs->flags & WINDOWCLASS_PREFS_FRAMELESS))
146 leftoffset = 0;
147 rightoffset = 1;
148 topoffset = 0;
149 bottomoffset = 1;
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);
173 #endif
175 /* Emm: RefreshWindowFrame() is documented to refresh *all* the gadgets,
176 * but when a window is activated/deactivated, only border gadgets
177 * are refreshed. */
178 #if 1
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,
186 window,
187 NULL,
189 mustbe | REFRESHGAD_REL | (((window->Height <= window->BorderTop) ? REFRESHGAD_TOPBORDER : 0)),
190 mustnotbe,
191 IntuitionBase);
192 int_refreshglist(window->FirstGadget,
193 window,
194 NULL,
196 mustbe | (((window->Height <= window->BorderTop) ? REFRESHGAD_TOPBORDER : 0)),
197 mustnotbe | REFRESHGAD_REL,
198 IntuitionBase);
199 #else
200 int_refreshglist(window->FirstGadget,
201 window,
202 NULL,
204 mustbe,
205 mustnotbe ,
206 IntuitionBase);
207 #endif
209 InstallClipRegion(layer,old_clipregion);
211 #ifdef GADGETCLIPPING
212 if (gadgetclipregion) DisposeRegion(gadgetclipregion);
213 #endif
215 layer->Scroll_X = old_scroll_x;
216 layer->Scroll_Y = old_scroll_y;
218 UnlockLayer(layer);
220 UNLOCKGADGET
222 UNLOCK_REFRESH(window->WScreen);
224 int_FreeCustomPrefs(TYPE_WINDOWCLASS,(struct IntDrawInfo*)dri,IntuitionBase);
226 FreeScreenDrawInfo(window->WScreen, (struct DrawInfo *)dri);
230 } /* if (dri) */
232 } /* if (!(win->Flags & WFLG_BORDERLESS)) */