2 #include <proto/exec.h>
3 #include <proto/intuition.h>
4 #include <proto/muimaster.h>
5 #include <proto/utility.h>
7 #include <mui/Urltext_mcc.h>
9 #include "muimiamipanel_intern.h"
10 #include "muimiamipanel_misc.h"
11 #include "muimiamipanel_locale.h"
13 /***********************************************************************/
15 #if !defined(__MORPHOS____) && !defined(__AROS__)
17 DoSuperNew(struct IClass
*cl
, Object
*obj
, ULONG tag1
,...)
19 return DoSuperMethod(cl
, obj
, OM_NEW
, &tag1
, NULL
);
23 /***********************************************************************/
28 return RectangleObject
,
29 MUIA_FixHeightTxt
, "A",
33 /****************************************************************************/
38 return RectangleObject
,
39 MUIA_FixWidthTxt
, "A",
43 /****************************************************************************/
49 MUIA_Text_Contents
, "-",
50 MUIA_Text_SetMax
, TRUE
,
54 /****************************************************************************/
57 obartitle(ULONG id
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
59 return MUI_MakeObject(MUIO_BarTitle
, __(id
));
62 /****************************************************************************/
67 return RectangleObject
,
72 /****************************************************************************/
75 olabel(ULONG id
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
80 /****************************************************************************/
83 olabel1(ULONG id
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
85 return Label1(__(id
));
88 /****************************************************************************/
91 ollabel1(ULONG id
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
93 return LLabel1(__(id
));
96 /***********************************************************************/
99 olabel2(ULONG id
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
101 return Label2(__(id
));
104 /***********************************************************************/
107 obutton(ULONG label
, ULONG help
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
109 register Object
*obj
;
111 if (obj
= MUI_MakeObject(MUIO_Button
, __(label
)))
112 SetAttrs(obj
, MUIA_CycleChain
, TRUE
,
113 MUIA_ShortHelp
, __(help
),
119 /***********************************************************************/
122 ourlText(UBYTE
*url
, UBYTE
*text
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
124 return UrltextObject
,
125 MUIA_Urltext_Text
, text
,
126 MUIA_Urltext_Url
, url
,
127 MUIA_Urltext_SetMax
, 0,
131 /***********************************************************************/
134 ocheck(ULONG key
, ULONG help
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
136 register Object
*obj
;
138 if (obj
= MUI_MakeObject(MUIO_Checkmark
, __(key
)))
139 SetAttrs(obj
, MUIA_CycleChain
, TRUE
, MUIA_ShortHelp
, __(help
), TAG_DONE
);
144 /***********************************************************************/
147 ocycle(ULONG key
, UBYTE
**entries
, ULONG help
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
149 register Object
*obj
;
151 if (obj
= MUI_MakeObject(MUIO_Cycle
, __(key
), (ULONG
)entries
))
152 SetAttrs(obj
, MUIA_CycleChain
, TRUE
, MUIA_ShortHelp
,__(help
), TAG_DONE
);
157 /***********************************************************************/
160 openWindow(Object
*app
, Object
*win
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
166 set(win
, MUIA_Window_Open
, TRUE
);
167 get(win
, MUIA_Window_Open
, &v
);
168 if (!v
) get(app
, MUIA_Application_Iconified
, &v
);
172 if (!v
) DisplayBeep(0);
177 /***********************************************************************/
180 grouping(UBYTE
*source
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
183 register UBYTE
*s
, *d
, c
= MiamiPanelBaseIntern
->mpb_groupSep
[0];
186 for (j
= 3, s
= source
+strlen(source
)-1, d
= buf
; s
>=source
; j
--, d
++, s
--)
198 for (s
= buf
+strlen(buf
)-1, d
= source
; s
>=buf
; d
++, s
--) *d
= *s
;
202 /***********************************************************************/
204 #if !defined(__AROS__)
207 sprintf(UBYTE
*to
, UBYTE
*fmt
,...)
212 VNewRawDoFmt(fmt
, (APTR
)0, to
, args
);
216 static UWORD fmtfunc
[] = { 0x16c0, 0x4e75 };
219 sprintf(UBYTE
*to
, UBYTE
*fmt
,...)
221 RawDoFmt(fmt
, &fmt
+1, (APTR
)fmtfunc
, to
);
224 #endif /* !__AROS__ */
226 /***********************************************************************/
228 #if !defined(__AROS__)
233 register struct stream
*s
= (struct stream
*)REG_A3
;
234 register UBYTE c
= (UBYTE
)REG_D0
;
237 snprintfStuff(REG(d0
, UBYTE c
), REG(a3
, struct stream
*s
))
243 if (++s
->counter
>=s
->size
)
248 else *(s
->buf
++) = c
;
253 static struct EmulLibEntry snprintfStuffTrap
= {TRAP_LIB
, 0, (void *)&snprintfStuff
};
258 snprintf(UBYTE
*buf
, int size
, UBYTE
*fmt
,...)
273 RawDoFmt(fmt
, va
->overflow_arg_area
, (APTR
)&snprintfStuffTrap
, &s
);
276 RawDoFmt(fmt
, &fmt
+1, (APTR
)snprintfStuff
, &s
);
283 /****************************************************************************/
285 ** The following functions are used
286 ** to handle the per interface scale
290 IDToValue(Tag tag
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
292 return GetTagData(tag
, 0, scales
);
294 /****************************************************************************/
299 register struct TagItem
*t
;
301 for (t
= scales
; (t
->ti_Tag
!=TAG_DONE
) && (t
->ti_Data
!=val
); t
++);
306 /****************************************************************************/
309 createIFNode(struct MPS_Prefs
*prefs
,UBYTE
*name
,ULONG scale
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
311 register struct ifnode
*ifnode
;
313 ObtainSemaphore(&MiamiPanelBaseIntern
->mpb_memSem
);
315 if (ifnode
= AllocPooled(MiamiPanelBaseIntern
->mpb_pool
, sizeof(struct ifnode
)))
317 stccpy(ifnode
->name
,name
, sizeof(ifnode
->name
));
318 ifnode
->scale
= scale
;
320 AddHead((struct List
*)&prefs
->iflist
, (struct Node
*)ifnode
);
323 ReleaseSemaphore(&MiamiPanelBaseIntern
->mpb_memSem
);
328 /****************************************************************************/
331 findIFNode(struct MPS_Prefs
*prefs
,UBYTE
*name
)
333 register struct ifnode
*ifnode
;
335 for (ifnode
= (struct ifnode
*)prefs
->iflist
.mlh_Head
; ifnode
->link
.mln_Succ
; ifnode
= (struct ifnode
*)ifnode
->link
.mln_Succ
)
336 if (!strcmp(ifnode
->name
,name
)) break;
338 return (ifnode
->link
.mln_Succ
) ? ifnode
: NULL
;
341 /****************************************************************************/
344 freeIFList(struct MPS_Prefs
*prefs
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
346 register struct Node
*node
;
348 ObtainSemaphore(&MiamiPanelBaseIntern
->mpb_memSem
);
350 while (node
= RemHead((struct List
*)&prefs
->iflist
))
351 FreePooled(MiamiPanelBaseIntern
->mpb_pool
, node
, sizeof(struct ifnode
));
353 ReleaseSemaphore(&MiamiPanelBaseIntern
->mpb_memSem
);
356 /****************************************************************************/
359 moveMinList(struct MinList
*to
,struct MinList
*from
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
361 register struct Node
*node
;
363 while (node
= RemTail((struct List
*)from
)) AddTail((struct List
*)to
, node
);
366 /****************************************************************************/
370 memcpy(void *to
,const void *from
,size_t len
)
372 CopyMem((APTR
)from
, (APTR
)to
, len
);
378 /****************************************************************************/