tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / workbench / network / stacks / AROSTCP / MUI.MiamiPanel / Classes / muimiamipanel_class_timetext.c
blob0a3cd1d903e5482fd698884062b70a6b73057c95
2 #include <proto/intuition.h>
3 #include <proto/muimaster.h>
4 #include <proto/utility.h>
6 #include <libraries/mui.h>
7 #include <libraries/gadtools.h>
9 #include <stdio.h>
11 #include "muimiamipanel_intern.h"
12 #include "muimiamipanel_locale.h"
14 /***********************************************************************/
16 struct MiamiPanelTimeTextClass_DATA
18 ULONG secs;
21 /***********************************************************************/
23 static struct MiamiPanelBase_intern *MiamiPanelBaseIntern;
25 static ULONG
26 MUIPC_TimeText__OM_NEW(struct IClass *CLASS,Object *self,struct opSet *message)
28 register struct TagItem *attrs = message->ops_AttrList;
30 if (self = (Object *)DoSuperNewTags
32 CLASS, self, NULL,
34 MUIA_Text_Contents, "00:00:00",
35 TAG_MORE,attrs))
37 register struct MiamiPanelTimeTextClass_DATA *data = INST_DATA(CLASS,self);
39 data->secs = GetTagData(MPA_Value,0,attrs);
42 return (ULONG)self;
45 /***********************************************************************/
47 static ULONG
48 MUIPC_TimeText__OM_SET(struct IClass *CLASS,Object *self,struct opSet *message)
50 register struct MiamiPanelTimeTextClass_DATA *data = INST_DATA(CLASS,self);
51 register struct TagItem *tag;
52 struct TagItem *tstate;
54 for (tstate = message->ops_AttrList; tag = NextTagItem(&tstate); )
56 register ULONG tidata = tag->ti_Data;
58 switch(tag->ti_Tag)
60 case MPA_Value:
61 if (tidata!=data->secs)
63 UBYTE buf[64];
65 if (tidata>0)
67 register ULONG d, h, m;
68 ULONG s = tidata;
70 d = s/86400;
71 s = s%86400;
72 h = s/3600;
73 s = s%3600;
74 m = s/60;
75 s = s%60;
77 if (d>0) sprintf(buf,"%lu %02lu:%02lu:%02lu",d,h,m,s);
78 else sprintf(buf,"%02lu:%02lu:%02lu",h,m,s);
80 else strcpy(buf,"00:00:00");
82 data->secs = tidata;
83 SetSuperAttrs(CLASS, self, MUIA_Text_Contents, buf, TAG_DONE);
85 break;
89 return DoSuperMethodA(CLASS,self,(APTR)message);
92 /***********************************************************************/
94 BOOPSI_DISPATCHER(IPTR, MUIPC_TimeText_Dispatcher, CLASS, self, message)
96 switch (message->MethodID)
98 case OM_SET: return MUIPC_TimeText__OM_SET(CLASS,self,(APTR)message);
99 case OM_NEW: return MUIPC_TimeText__OM_NEW(CLASS,self,(APTR)message);
100 default: return DoSuperMethodA(CLASS,self,message);
102 return 0;
104 BOOPSI_DISPATCHER_END
106 /***********************************************************************/
108 ULONG
109 MUIPC_TimeText_ClassInit(struct MiamiPanelBase_intern *MiamiPanelBase)
111 MiamiPanelBaseIntern = MiamiPanelBase;
112 return (ULONG)(MiamiPanelBaseIntern->mpb_timeTextClass = MUI_CreateCustomClass(NULL, MUIC_Text, NULL, sizeof(struct MiamiPanelTimeTextClass_DATA), MUIPC_TimeText_Dispatcher));
115 /***********************************************************************/