2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Special requesters needed for things like Delete in File Requester.
10 #include <proto/exec.h>
11 #include <proto/utility.h>
12 #include <proto/intuition.h>
13 #include <proto/graphics.h>
14 #include <exec/memory.h>
16 #include <intuition/screens.h>
17 #include <intuition/gadgetclass.h>
18 #include <graphics/gfx.h>
21 #include "asl_intern.h"
23 #include "specialreq.h"
25 #if USE_SHARED_COOLIMAGES
26 #include <libraries/coolimages.h>
27 #include <proto/coolimages.h>
29 #include "coolimages.h"
35 #include <aros/debug.h>
37 /*****************************************************************************************/
43 /*****************************************************************************************/
45 STRPTR
REQ_String(STRPTR title
, STRPTR stringtext
, STRPTR oktext
, STRPTR canceltext
,
46 struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
50 Object
*okbutton
= NULL
;
51 Object
*cancelbutton
= NULL
;
52 Object
*textstring
= NULL
;
53 WORD x
, x2
, y
, y2
, winwidth
, winheight
;
54 WORD buttonwidth
, buttonheight
;
55 #if USE_SHARED_COOLIMAGES
56 const struct CoolImage
*useimg
= NULL
;
57 const struct CoolImage
*cancelimg
= NULL
;
59 #define cool_useimage (*useimg)
60 #define cool_cancelimage (*cancelimg)
68 #if USE_SHARED_COOLIMAGES
69 #if SPECIALREQ_COOL_BUTTONS
72 useimg
= COOL_ObtainImageA(COOL_USEIMAGE_ID
, NULL
);
73 cancelimg
= COOL_ObtainImageA(COOL_CANCELIMAGE_ID
, NULL
);
78 if (!stringtext
) stringtext
= "";
80 edithook
.h_Entry
= (APTR
)AROS_ASMSYMNAME(StringEditFunc
);
81 edithook
.h_SubEntry
= NULL
;
82 edithook
.h_Data
= AslBase
;
84 /* Calc. button width */
86 x
= TextLength(&ld
->ld_DummyRP
, oktext
, strlen(oktext
));
88 #if USE_SHARED_COOLIMAGES
91 #if SPECIALREQ_COOL_BUTTONS
94 x
+= IMAGEBUTTONEXTRAWIDTH
+ cool_useimage
.width
;
98 x2
= TextLength(&ld
->ld_DummyRP
, canceltext
, strlen(canceltext
));
100 #if USE_SHARED_COOLIMAGES
103 #if SPECIALREQ_COOL_BUTTONS
104 if (ld
->ld_TrueColor
)
106 x2
+= IMAGEBUTTONEXTRAWIDTH
+ cool_cancelimage
.width
;
110 buttonwidth
= BUTTONEXTRAWIDTH
+ ((x2
> x
) ? x2
: x
);
112 /* Calc. button height */
114 #if SPECIALREQ_COOL_BUTTONS
115 y
= BUTTONEXTRAHEIGHT
+ ld
->ld_Font
->tf_YSize
;
116 if (ld
->ld_TrueColor
)
118 y2
= IMAGEBUTTONEXTRAHEIGHT
+ DEF_COOLIMAGEHEIGHT
;
124 buttonheight
= (y
> y2
) ? y
: y2
;
126 buttonheight
= BUTTONEXTRAHEIGHT
+ ld
->ld_Font
->tf_YSize
;
131 winwidth
= OUTERSPACINGX
* 2 +
134 winheight
= OUTERSPACINGY
* 2 + buttonheight
* 2 + GADGETSPACINGY
;
136 x
= ld
->ld_WBorLeft
+ OUTERSPACINGX
;
137 y
= ld
->ld_WBorTop
+ OUTERSPACINGY
+ buttonheight
+ GADGETSPACINGY
;
139 /* Make button gadgets */
142 struct TagItem button_tags
[] =
144 {GA_Text
, (IPTR
)oktext
},
148 {GA_UserData
, (IPTR
)ld
},
151 {GA_Width
, buttonwidth
},
152 {GA_Height
, buttonheight
},
153 {GA_Image
, 0 }, /* 0 means we want a frame */
154 {GA_RelVerify
, TRUE
},
158 #if USE_SHARED_COOLIMAGES
161 button_tags
[3].ti_Tag
= ASLBT_CoolImage
;
162 button_tags
[3].ti_Data
= (IPTR
)useimg
;
165 button_tags
[3].ti_Tag
= ASLBT_CoolImage
;
166 button_tags
[3].ti_Data
= (IPTR
)&cool_useimage
;
169 okbutton
= NewObjectA(AslBase
->aslbuttonclass
, NULL
, button_tags
);
171 button_tags
[0].ti_Data
= (IPTR
)canceltext
;
172 if (okbutton
) button_tags
[1].ti_Tag
= GA_Previous
;
173 button_tags
[1].ti_Data
= (IPTR
)okbutton
;
174 button_tags
[2].ti_Data
= CANCEL_ID
;
176 #if USE_SHARED_COOLIMAGES
179 button_tags
[3].ti_Tag
= TAG_IGNORE
;
183 button_tags
[3].ti_Data
= (IPTR
)cancelimg
;
186 button_tags
[3].ti_Data
= (IPTR
)&cool_cancelimage
;
189 button_tags
[5].ti_Data
+= buttonwidth
* 2;
191 cancelbutton
= NewObjectA(AslBase
->aslbuttonclass
, NULL
, button_tags
);
193 if (okbutton
&& cancelbutton
)
195 /* Make String Gadget */
197 struct TagItem string_tags
[] =
199 {GA_Previous
, (IPTR
)cancelbutton
},
200 {GA_ID
, STRING_ID
},
202 {GA_Top
, y
- buttonheight
- GADGETSPACINGY
},
203 {GA_Width
, winwidth
- OUTERSPACINGX
* 2 },
204 {GA_Height
, buttonheight
},
205 {GA_RelVerify
, TRUE
},
206 {GA_UserData
, (IPTR
)ld
},
207 {STRINGA_MaxChars
, 256 },
208 {STRINGA_TextVal
, (IPTR
)stringtext
},
209 {STRINGA_BufferPos
, strlen(stringtext
) },
210 {STRINGA_EditHook
, (IPTR
)&edithook
},
214 textstring
= NewObjectA(AslBase
->aslstringclass
, NULL
, string_tags
);
217 x
= ld
->ld_Window
->LeftEdge
+
218 ld
->ld_Window
->Width
/ 2 -
219 (winwidth
+ ld
->ld_WBorLeft
+ ld
->ld_WBorRight
) / 2;
221 y
= ld
->ld_Window
->TopEdge
+
222 ld
->ld_Window
->Height
/ 2 -
223 (winheight
+ ld
->ld_WBorTop
+ ld
->ld_WBorBottom
) / 2;
225 win
= OpenWindowTags(NULL
, WA_CustomScreen
, (IPTR
)ld
->ld_Screen
,
228 WA_InnerWidth
, winwidth
,
229 WA_InnerHeight
, winheight
,
230 WA_AutoAdjust
, TRUE
,
231 WA_Title
, (IPTR
)title
,
232 WA_CloseGadget
, TRUE
,
234 WA_DepthGadget
, TRUE
,
236 WA_SimpleRefresh
, TRUE
,
237 WA_NoCareRefresh
, TRUE
,
239 WA_IDCMP
, IDCMP_CLOSEWINDOW
|
243 WA_Gadgets
, (IPTR
)okbutton
,
248 BOOL quitme
= FALSE
, doit
= FALSE
;
250 ActivateGadget((struct Gadget
*)textstring
, win
, NULL
);
252 while(!quitme
&& !doit
)
254 struct IntuiMessage
*msg
;
256 WaitPort(win
->UserPort
);
257 while((msg
= (struct IntuiMessage
*)GetMsg(win
->UserPort
)))
261 case IDCMP_CLOSEWINDOW
:
266 switch(((struct Gadget
*)msg
->IAddress
)->GadgetID
)
290 } /* switch(((struct Gadget *)msg->IAddress)->GadgetID) */
293 case IDCMP_VANILLAKEY
:
301 ActivateGadget((struct Gadget
*)textstring
, win
, NULL
);
307 } /* switch(msg->Class) */
308 ReplyMsg((struct Message
*)msg
);
310 } /* while((msg = (struct IntuiMessage *)GetMsg(win->UserPort))) */
312 } /* while(!quitme && !doit) */
319 GetAttr(STRINGA_TextVal
, textstring
, (IPTR
*)&text
);
324 retval
= VecPooledCloneString(text
, NULL
, ld
->ld_IntReq
->ir_MemPool
, AslBase
);
325 if (retval
) strcpy(retval
, text
);
330 RemoveGadget(win
, (struct Gadget
*)okbutton
);
331 RemoveGadget(win
, (struct Gadget
*)cancelbutton
);
332 RemoveGadget(win
, (struct Gadget
*)textstring
);
338 DisposeObject(textstring
);
340 } /* if (textstring) */
342 } /* if (okbutton && cancelbutton) */
344 if (okbutton
) DisposeObject(okbutton
);
345 if (cancelbutton
) DisposeObject(cancelbutton
);
353 /*****************************************************************************************/