Added kernel module for starting the usb stack at boot time. It's not activated thoug...
[cake.git] / rom / intuition / buildsysrequest_morphos.c
blobc0c628d5e65c25cec95d909ebe1180cd32a36f25
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 #define DEBUG_BUILDSYSREQUEST(x) ;
9 /**********************************************************************************************/
11 #include <proto/exec.h>
12 #include <proto/intuition.h>
13 #include <proto/graphics.h>
14 #include <stdio.h>
15 #include <stdarg.h>
16 #include <strings.h>
17 #include <clib/macros.h>
18 #include <exec/memory.h>
19 #include <intuition/gadgetclass.h>
20 #include <intuition/imageclass.h>
21 #include <intuition/screens.h>
22 #include <graphics/rastport.h>
23 #include <graphics/gfxmacros.h>
24 #include <utility/tagitem.h>
25 #include "intuition_intern.h"
26 #include "requesters.h"
28 /**********************************************************************************************
30 NAME */
31 #include <proto/intuition.h>
32 #include <exec/types.h>
33 #include <intuition/intuition.h>
35 AROS_LH7(struct Window *, BuildSysRequest,
37 /* SYNOPSIS */
38 AROS_LHA(struct Window * , window, A0),
39 AROS_LHA(struct IntuiText *, bodytext, A1),
40 AROS_LHA(struct IntuiText *, postext, A2),
41 AROS_LHA(struct IntuiText *, negtext, A3),
42 AROS_LHA(ULONG , IDCMPFlags , D0),
43 AROS_LHA(WORD , width, D2),
44 AROS_LHA(WORD , height, D3),
46 /* LOCATION */
47 struct IntuitionBase *, IntuitionBase, 60, Intuition)
49 /* FUNCTION
51 INPUTS
52 window - The window in which the requester will appear
53 bodytext - The Text to be shown in the body of the requester
54 postext - The Text to be shown in the positive choice gadget
55 negtext - The Text to be shown in the negative choice gadget
56 IDCMPFlags - The IDCMP Flags for this requester
57 width, height - The dimensions of the requester
59 RESULT
61 NOTES
63 EXAMPLE
65 BUGS
67 SEE ALSO
68 FreeSysRequest(), DisplayAlert(), ModifyIDCMP(), exec-library/Wait(),
69 Request(), AutoRequest(), EasyRequest(), BuildEasyRequestArgs()
71 INTERNALS
73 HISTORY
75 *****************************************************************************/
77 AROS_LIBFUNC_INIT
79 struct Screen *scr = NULL, *lockedscr = NULL;
80 struct Window *req;
81 //struct Gadget *gadgets;
82 STRPTR reqtitle;
83 //STRPTR gadgetlabels[3];
84 struct IntRequestUserData *requserdata;
85 int negtextlen;
87 DEBUG_BUILDSYSREQUEST(dprintf("intrequest_buildsysrequest: window 0x%lx body <%s> postext <%s> negtext <%s> IDCMPFlags 0x%lx width %ld height %ld\n",
88 (ULONG) window,
89 bodytext ? (char *) bodytext->IText : "<NULL>",
90 postext->IText ? (char *) postext->IText : "<NULL>",
91 negtext->IText ? (char *) negtext->IText : "<NULL>",
92 IDCMPFlags,
93 (LONG) width,
94 (LONG) height));
96 /* negtext and bodytest must be specified, postext is optional */
97 if (!negtext || !bodytext) return NULL;
99 /* get requester title */
101 reqtitle = NULL;
102 if (window) reqtitle = window->Title;
103 if (!reqtitle) reqtitle = "System Request"; /* stegerg: should be localized */
105 /* get screen and screendrawinfo */
106 if (window)
107 scr = window->WScreen;
108 if (!scr)
110 scr = LockPubScreen(NULL);
111 if (!scr)
112 return NULL;
113 lockedscr = scr;
116 requserdata = AllocVec(sizeof (struct IntRequestUserData),MEMF_PUBLIC|MEMF_CLEAR);
117 if (!requserdata) goto fail;
119 requserdata->ReqScreen = scr;
121 negtextlen = strlen(negtext->IText) + 1;
123 if (postext)
125 int postextlen = strlen(postext->IText) + 1;
127 requserdata->NumGadgets = 2;
128 requserdata->GadgetLabels = AllocVec((requserdata->NumGadgets + 1) * sizeof(STRPTR), MEMF_PUBLIC|MEMF_CLEAR);
129 if (!requserdata->GadgetLabels) goto fail;
130 requserdata->GadgetLabels[0] = AllocVec(postextlen + negtextlen, MEMF_PUBLIC);
131 if (!requserdata->GadgetLabels[0])
133 FreeVec(requserdata->GadgetLabels); goto fail;
135 CopyMem(postext->IText,requserdata->GadgetLabels[0], postextlen);
136 requserdata->GadgetLabels[1] = requserdata->GadgetLabels[0] + postextlen;
137 CopyMem(negtext->IText,requserdata->GadgetLabels[1], negtextlen);
138 } else {
139 requserdata->NumGadgets = 1;
140 requserdata->GadgetLabels = AllocVec((requserdata->NumGadgets + 1) * sizeof(STRPTR), MEMF_PUBLIC|MEMF_CLEAR);
141 if (!requserdata->GadgetLabels) goto fail;
142 requserdata->GadgetLabels[0] = AllocVec(negtextlen, MEMF_PUBLIC);
143 if (!requserdata->GadgetLabels[0])
145 FreeVec(requserdata->GadgetLabels); goto fail;
147 CopyMem(negtext->IText,requserdata->GadgetLabels[0], negtextlen);
150 /* create everything */
152 requserdata->Text = bodytext;
155 struct IntuiText *it = bodytext;
156 while (it)
158 requserdata->NumLines++;
159 it = it->NextText;
163 requserdata->ReqGadgets = AllocVec(requserdata->NumGadgets * (sizeof (struct RequesterGadget)),MEMF_PUBLIC);
164 if (!requserdata->ReqGadgets) goto fail;
166 intrequest_layoutrequester(requserdata,IntuitionBase);
167 if (!requserdata->wwidth) goto fail;
169 if (!(intrequest_creategadgets(requserdata,IntuitionBase))) goto fail;
172 struct TagItem win_tags[] =
174 { WA_Width , requserdata->wwidth },
175 { WA_Height , requserdata->wheight },
176 { WA_Left , (scr->Width/2) - (requserdata->wwidth/2) },
177 { WA_Top , (scr->Height/2) - (requserdata->wheight/2) },
178 { WA_IDCMP , IDCMP_GADGETUP | IDCMP_RAWKEY | (IDCMPFlags & ~IDCMP_VANILLAKEY) | IDCMP_REFRESHWINDOW},
179 { WA_Gadgets , (IPTR)requserdata->Gadgets },
180 { WA_Title , (IPTR)reqtitle },
181 { (lockedscr ? WA_PubScreen : WA_CustomScreen), (IPTR)scr },
182 { WA_Flags , WFLG_DRAGBAR |
183 WFLG_DEPTHGADGET |
184 WFLG_ACTIVATE |
185 WFLG_SIMPLE_REFRESH |
186 WFLG_RMBTRAP },
187 { WA_SkinInfo , NULL },
188 {TAG_DONE }
191 req = OpenWindowTagList(NULL, win_tags);
194 if (req)
197 if (lockedscr) UnlockPubScreen(NULL, lockedscr);
199 req->UserData = (BYTE *)requserdata;
200 requserdata->IDCMP = IDCMPFlags;
201 requserdata->ReqWindow = req;
203 intrequest_drawrequester(requserdata,IntuitionBase);
205 return req;
208 fail:
210 if (requserdata)
212 intrequest_freegadgets(requserdata->Gadgets,IntuitionBase);
213 intrequest_freelabels(requserdata->GadgetLabels, IntuitionBase);
214 if (requserdata->dri) FreeScreenDrawInfo(requserdata->ReqScreen,(struct DrawInfo *)requserdata->dri);
215 if (requserdata->freeitext) intrequest_freeitext(requserdata->Text,IntuitionBase);
216 if (requserdata->ReqGadgets) FreeVec(requserdata->ReqGadgets);
217 FreeVec(requserdata);
220 if (lockedscr) UnlockPubScreen(NULL, lockedscr);
222 return NULL;
224 AROS_LIBFUNC_EXIT
226 } /* BuildSysRequest */
228 /**********************************************************************************************/