2 ** OpenURL - MUI preferences for openurl.library
4 ** Written by Troels Walsted Hansen <troels@thule.no>
5 ** Placed in the public domain.
8 ** - Alfonso Ranieri <alforan@tin.it>
9 ** - Stefan Kost <ensonic@sonicpulse.de>
11 ** Ported to OS4 by Alexandre Balaban <alexandre@balaban.name>
18 #if defined(__amigaos4__)
22 /**************************************************************************/
24 #define _KEY(k) ((ULONG)(k)) ? MUIA_ControlChar : TAG_IGNORE, ((ULONG)(k)) ? (ULONG)getKeyChar(NULL,(ULONG)(k)) : 0
25 #define _HELP(h) ((ULONG)(h)) ? MUIA_ShortHelp : TAG_IGNORE, ((ULONG)(h)) ? (ULONG)getString((ULONG)(h)) : 0
27 /***********************************************************************/
29 #if !defined(__MORPHOS__) && !defined(__amigaos4__)
31 DoSuperNew(struct IClass
*cl
,Object
*obj
,ULONG tag1
,...)
33 return DoSuperMethod(cl
,obj
,OM_NEW
,&tag1
,NULL
);
37 /**************************************************************************/
40 int stccpy(char *dst
, const char *src
, int m
)
45 while((c
= *src
++) != '\0')
55 #endif /* __amigaos4__ */
57 /**************************************************************************/
60 /**********************************************************
62 ** The following function saves the variable name passed in
63 ** 'varname' to the ENV(ARC) system so that the application
64 ** can become AmiUpdate aware.
66 **********************************************************/
67 void SetAmiUpdateENVVariable( CONST_STRPTR varname
)
69 /* AmiUpdate support code */
73 /* obtain the lock to the home directory */
74 if(( lock
= GetProgramDir() ))
77 TEXT varpath
[1024] = "AppPaths";
80 get a unique name for the lock,
81 this call uses device names,
82 as there can be multiple volumes
83 with the same name on the system
86 if( DevNameFromLock( lock
, progpath
, sizeof(progpath
), DN_FULLPATH
))
88 /* stop any "Insert volume..." type requesters */
89 oldwin
= SetProcWindow((APTR
)-1);
92 finally set the variable to the
93 path the executable was run from
94 don't forget to supply the variable
95 name to suit your application
98 AddPart( varpath
, varname
, 1024);
99 SetVar( varpath
, progpath
, -1, GVF_GLOBAL_ONLY
|GVF_SAVE_VAR
);
101 /* turn requesters back on */
102 SetProcWindow( oldwin
);
107 #endif /* __amigaos4__ */
109 /**************************************************************************/
111 xget(Object
*obj
,ULONG attribute
)
115 get(obj
,attribute
,&x
);
120 /**************************************************************************/
125 return Label((ULONG
)getString(id
));
128 /****************************************************************************/
133 return LLabel((ULONG
)getString(id
));
136 /****************************************************************************/
141 return LLabel1((ULONG
)getString(id
));
144 /****************************************************************************/
149 return Label1((ULONG
)getString(id
));
152 /***********************************************************************/
157 return Label2((ULONG
)getString(id
));
160 /****************************************************************************/
165 return FreeLabel((ULONG
)getString(text
));
168 /****************************************************************************/
171 obutton(ULONG text
,ULONG help
)
175 if (obj
= MUI_MakeObject(MUIO_Button
,(ULONG
)getString(text
)))
176 SetAttrs(obj
,MUIA_CycleChain
,TRUE
,_HELP(help
),TAG_DONE
);
181 /***********************************************************************/
184 oibutton(ULONG spec
,ULONG help
)
186 if (spec
==IBT_Up
) spec
= (ULONG
)"\33I[6:38]";
187 else if (spec
==IBT_Down
) spec
= (ULONG
)"\33I[6:39]";
192 MUIA_CycleChain
, TRUE
,
193 MUIA_Font
, MUIV_Font_Button
,
194 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
196 MUIA_Background
, MUII_ButtonBack
,
197 MUIA_Text_Contents
, spec
,
198 MUIA_Text_PreParse
, MUIX_C
,
199 MUIA_Text_SetMax
, TRUE
,
203 /****************************************************************************/
206 otbutton(ULONG label
,ULONG help
)
211 MUIA_CycleChain
, TRUE
,
212 MUIA_Font
, MUIV_Font_Button
,
213 MUIA_InputMode
, MUIV_InputMode_Toggle
,
215 MUIA_Background
, MUII_ButtonBack
,
216 MUIA_Text_Contents
, getString(label
),
217 MUIA_Text_PreParse
, MUIX_C
,
218 MUIA_Text_HiCharIdx
, '_',
222 /****************************************************************************/
225 ocheckmark(ULONG key
,ULONG help
)
229 if (obj
= MUI_MakeObject(MUIO_Checkmark
,(ULONG
)getString(key
)))
230 SetAttrs(obj
,MUIA_CycleChain
,TRUE
,_HELP(help
),TAG_DONE
);
235 /****************************************************************************/
238 opopbutton(ULONG img
,ULONG help
)
242 if (obj
= MUI_MakeObject(MUIO_PopButton
,img
))
243 SetAttrs(obj
,MUIA_CycleChain
,TRUE
,_HELP(help
),TAG_DONE
);
248 /****************************************************************************/
251 ostring(ULONG maxlen
,ULONG key
,ULONG help
)
256 MUIA_CycleChain
, TRUE
,
258 MUIA_String_AdvanceOnCR
, TRUE
,
259 MUIA_String_MaxLen
, maxlen
,
263 /***********************************************************************/
266 opopport(ULONG maxLen
,ULONG key
,ULONG help
)
268 return popportObject
,
270 MUIA_Popport_Key
, key
,
271 MUIA_Popport_Len
, maxLen
,
275 /***********************************************************************/
278 opopph(STRPTR
*syms
,STRPTR
*names
,ULONG maxLen
,ULONG key
,ULONG asl
,ULONG help
)
282 MUIA_Popph_Syms
, syms
,
283 MUIA_Popph_Names
, names
,
284 MUIA_Popph_MaxLen
, maxLen
,
290 /***********************************************************************/
293 openWindow(Object
*app
,Object
*win
)
299 set(win
,MUIA_Window_Open
,TRUE
);
300 get(win
,MUIA_Window_Open
,&v
);
301 if (!v
) get(app
,MUIA_Application_Iconified
,&v
);
305 if (!v
) DisplayBeep(0);
310 /***********************************************************************/
312 #if !defined(__MORPHOS__) && !defined(__AROS__)
313 static ULONG fmtfunc
= 0x16C04E75;
316 msprintf(STRPTR to
, STRPTR fmt
,...)
318 #if defined(__amigaos4__)
320 va_startlinear(va
,fmt
);
321 RawDoFmt(fmt
,va_getlinearva(va
,CONST APTR
),(APTR
)&fmtfunc
,to
);
324 RawDoFmt(fmt
,&fmt
+1,(APTR
)&fmtfunc
,to
);
329 /**************************************************************************/
343 register struct stream
*s
= (struct stream
*)REG_A3
;
344 register UBYTE c
= (TEXT
)REG_D0
;
345 #elif defined(__AROS__)
346 AROS_UFH2S(void, msnprintfStuff
,
347 AROS_UFHA(TEXT
, c
, D0
),
348 AROS_UFHA(struct stream
*, s
, A3
))
352 static void SAVEDS ASM
353 msnprintfStuff(REG(d0
,TEXT c
),REG(a3
,struct stream
*s
))
358 if (++s
->counter
>=s
->size
)
363 else *(s
->buf
++) = c
;
371 static struct EmulLibEntry msnprintfStuffTrap
= {TRAP_LIB
,0,(void *)&msnprintfStuff
};
376 #if !defined( __MORPHOS__ )
379 msnprintf(STRPTR buf
,int size
, STRPTR fmt
,...)
385 #elif defined(__amigaos4__)
387 va_startlinear(va
,fmt
);
396 RawDoFmt(fmt
,va
->overflow_arg_area
,(APTR
)&msnprintfStuffTrap
,&s
);
398 #elif defined(__amigaos4__)
399 RawDoFmt(fmt
,va_getlinearva(va
,CONST APTR
),(APTR
)msnprintfStuff
,&s
);
402 RawDoFmt(fmt
,&fmt
+1,(APTR
)msnprintfStuff
,&s
);
408 /**************************************************************************/
411 delEntry(Object
*obj
,APTR entry
)
418 DoMethod(obj
,MUIM_List_GetEntry
,i
,(ULONG
)&e
);
419 if (!e
|| e
==entry
) break;
422 if (e
) DoMethod(obj
,MUIM_List_Remove
,i
);
427 /**************************************************************************/