make.tmpl: add missing compiler attribute to build_progs
[AROS.git] / external / openurl / prefs / utils.c
bloba2f5fb487ed8b35922e0e7b2abcd70d915c1e1a0
1 /***************************************************************************
3 openurl.library - universal URL display and browser launcher library
4 Copyright (C) 1998-2005 by Troels Walsted Hansen, et al.
5 Copyright (C) 2005-2013 by openurl.library Open Source Team
7 This library is free software; it has been placed in the public domain
8 and you can freely redistribute it and/or modify it. Please note, however,
9 that some components may be under the LGPL or GPL license.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 openurl.library project: http://sourceforge.net/projects/openurllib/
17 $Id$
19 ***************************************************************************/
21 #include "openurl.h"
23 #include "SDI_stdarg.h"
24 #include "macros.h"
26 #include "debug.h"
28 /**************************************************************************/
30 #define _KEY(k) ((ULONG)(k)) ? MUIA_ControlChar : TAG_IGNORE, ((ULONG)(k)) ? (ULONG)getKeyChar(NULL,(ULONG)(k)) : 0
31 #define _HELP(h) ((ULONG)(h)) ? MUIA_ShortHelp : TAG_IGNORE, ((ULONG)(h)) ? (IPTR)getString((ULONG)(h)) : 0
33 /***********************************************************************/
35 // DoSuperNew()
36 // Calls parent NEW method within a subclass
37 #if !defined(__MORPHOS__)
38 #if !defined(__AROS__)
39 Object * VARARGS68K DoSuperNew(struct IClass *cl, Object *obj, ...)
41 Object *rc;
42 VA_LIST args;
44 ENTER();
46 VA_START(args, obj);
47 rc = (Object *)DoSuperMethod(cl, obj, OM_NEW, VA_ARG(args, ULONG), NULL);
48 VA_END(args);
50 RETURN(rc);
51 return rc;
53 #endif
54 #endif
56 /**************************************************************************/
58 #ifdef __amigaos4__
59 /**********************************************************
61 ** The following function saves the variable name passed in
62 ** 'varname' to the ENV(ARC) system so that the application
63 ** can become AmiUpdate aware.
65 **********************************************************/
66 void SetAmiUpdateENVVariable( CONST_STRPTR varname )
68 /* AmiUpdate support code */
69 BPTR lock;
70 APTR oldwin;
72 /* obtain the lock to the home directory */
73 if(( lock = GetProgramDir() ))
75 TEXT progpath[2048];
76 TEXT varpath[1024] = "AppPaths";
79 get a unique name for the lock,
80 this call uses device names,
81 as there can be multiple volumes
82 with the same name on the system
85 if( DevNameFromLock( lock, progpath, sizeof(progpath), DN_FULLPATH ))
87 /* stop any "Insert volume..." type requesters */
88 oldwin = SetProcWindow((APTR)-1);
91 finally set the variable to the
92 path the executable was run from
93 don't forget to supply the variable
94 name to suit your application
97 AddPart( varpath, varname, 1024);
98 SetVar( varpath, progpath, -1, GVF_GLOBAL_ONLY|GVF_SAVE_VAR );
100 /* turn requesters back on */
101 SetProcWindow( oldwin );
106 #endif /* __amigaos4__ */
108 /**************************************************************************/
110 Object *olabel(ULONG id)
112 return Label((IPTR)getString(id));
115 /****************************************************************************/
117 Object *ollabel(ULONG id)
119 return LLabel((IPTR)getString(id));
122 /****************************************************************************/
124 Object *ollabel1(ULONG id)
126 return LLabel1((IPTR)getString(id));
129 /****************************************************************************/
131 Object *olabel1(ULONG id)
133 return Label1((IPTR)getString(id));
136 /***********************************************************************/
138 Object *olabel2(ULONG id)
140 return Label2((IPTR)getString(id));
143 /****************************************************************************/
145 Object *oflabel(ULONG text)
147 return FreeLabel((IPTR)getString(text));
150 /****************************************************************************/
152 Object *obutton(ULONG text, ULONG help)
154 Object *obj;
156 if((obj = MUI_MakeObject(MUIO_Button, (IPTR)getString(text))) != NULL)
157 SetAttrs(obj,MUIA_CycleChain,TRUE,_HELP(help),TAG_DONE);
159 return obj;
162 /***********************************************************************/
164 Object *oibutton(ULONG spec, ULONG help)
166 if (spec==IBT_Up) spec = (IPTR)"\33I[6:38]";
167 else if (spec==IBT_Down) spec = (IPTR)"\33I[6:39]";
168 else return NULL;
170 return TextObject,
171 _HELP(help),
172 MUIA_CycleChain, TRUE,
173 MUIA_Font, MUIV_Font_Button,
174 MUIA_InputMode, MUIV_InputMode_RelVerify,
175 ButtonFrame,
176 MUIA_Background, MUII_ButtonBack,
177 MUIA_Text_Contents, spec,
178 MUIA_Text_PreParse, MUIX_C,
179 MUIA_Text_SetMax, TRUE,
180 End;
183 /****************************************************************************/
185 Object *otbutton(ULONG label, ULONG help)
187 return TextObject,
188 _KEY(label),
189 _HELP(help),
190 MUIA_CycleChain, TRUE,
191 MUIA_Font, MUIV_Font_Button,
192 MUIA_InputMode, MUIV_InputMode_Toggle,
193 ButtonFrame,
194 MUIA_Background, MUII_ButtonBack,
195 MUIA_Text_Contents, getString(label),
196 MUIA_Text_PreParse, MUIX_C,
197 MUIA_Text_HiCharIdx, '_',
198 End;
201 /****************************************************************************/
203 Object *ocheckmark(ULONG key, ULONG help)
205 Object *obj;
207 if((obj = MUI_MakeObject(MUIO_Checkmark, (IPTR)getString(key))) != NULL)
208 SetAttrs(obj,MUIA_CycleChain,TRUE,_HELP(help),TAG_DONE);
210 return obj;
213 /****************************************************************************/
215 Object *opopbutton(ULONG img, ULONG help)
217 Object *obj;
219 if((obj = MUI_MakeObject(MUIO_PopButton, img)) != NULL)
220 SetAttrs(obj,MUIA_CycleChain,TRUE,_HELP(help),TAG_DONE);
222 return obj;
225 /****************************************************************************/
227 Object *ostring(ULONG maxlen, ULONG key, ULONG help)
229 return StringObject,
230 _KEY(key),
231 _HELP(help),
232 MUIA_CycleChain, TRUE,
233 StringFrame,
234 MUIA_String_AdvanceOnCR, TRUE,
235 MUIA_String_MaxLen, maxlen,
236 End;
239 /***********************************************************************/
241 Object *opopport(ULONG maxLen, ULONG key, ULONG help)
243 return popportObject,
244 _HELP(help),
245 MUIA_Popport_Key, key,
246 MUIA_Popport_Len, maxLen,
247 End;
250 /***********************************************************************/
252 Object *opopph(CONST_STRPTR *syms, STRPTR *names, ULONG maxLen, ULONG key, ULONG asl, ULONG help)
254 return popphObject,
255 _HELP(help),
256 MUIA_Popph_Syms, syms,
257 MUIA_Popph_Names, names,
258 MUIA_Popph_MaxLen, maxLen,
259 MUIA_Popph_Key, key,
260 MUIA_Popph_Asl, asl,
261 End;
264 /***********************************************************************/
266 ULONG openWindow(Object *app, Object *win)
268 ULONG v;
270 if (win)
272 set(win,MUIA_Window_Open,TRUE);
273 v = xget(win, MUIA_Window_Open);
274 if (!v)
275 v = xget(app, MUIA_Application_Iconified);
277 else v = FALSE;
279 if (!v) DisplayBeep(0);
281 return v;
284 /***********************************************************************/
286 IPTR delEntry(Object *obj, APTR entry)
288 APTR e = NULL;
289 int i;
291 for (i = 0; ;i++)
293 DoMethod(obj,MUIM_List_GetEntry,i,(IPTR)&e);
294 if (!e || e==entry) break;
297 if (e) DoMethod(obj,MUIM_List_Remove,i);
299 return (IPTR)e;
302 /**************************************************************************/