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>
12 #include "muimiamipanel_intern.h"
13 #include "muimiamipanel_locale.h"
14 #include "muimiamipanel_misc.h"
16 /***********************************************************************/
18 static UBYTE
*bpss
, *Kbss
, *Mbss
;
20 struct MiamiPanelRateClass_DATA
30 FLG_NoGrouping
= 1<<1,
33 /***********************************************************************/
35 static struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
;
38 MUIPC_Rate__OM_NEW(struct IClass
*CLASS
,Object
*self
,struct opSet
*message
)
40 register struct TagItem
*attrs
= message
->ops_AttrList
;
42 if (self
= (Object
*)DoSuperNewTags
46 MUIA_Frame
, MUIV_Frame_Gauge
,
47 MUIA_Gauge_Horiz
, TRUE
,
48 MUIA_Gauge_InfoText
, "0",
51 message
->MethodID
= OM_SET
;
52 DoMethodA(self
,(Msg
)message
);
53 message
->MethodID
= OM_NEW
;
59 /***********************************************************************/
62 MUIPC_Rate__OM_SET(struct IClass
*CLASS
,Object
*self
,struct opSet
*message
)
64 register struct MiamiPanelRateClass_DATA
*data
= INST_DATA(CLASS
,self
);
65 register struct TagItem
*tag
;
66 struct TagItem
*tstate
;
67 register ULONG redraw
;
69 for (redraw
= FALSE
, tstate
= message
->ops_AttrList
; tag
= NextTagItem(&tstate
); )
71 register ULONG tidata
= tag
->ti_Data
;
76 if (!BOOLSAME(PREFS(tidata
)->flags
& MPV_Flags_RateShort
,data
->flags
& FLG_Short
) ||
77 !BOOLSAME(PREFS(tidata
)->flags
& MPV_Flags_RateNoGrouping
,data
->flags
& FLG_NoGrouping
))
79 if (PREFS(tidata
)->flags
& MPV_Flags_RateShort
) data
->flags
|= FLG_Short
;
80 else data
->flags
&= ~FLG_Short
;
82 if (PREFS(tidata
)->flags
& MPV_Flags_RateNoGrouping
) data
->flags
|= FLG_NoGrouping
;
83 else data
->flags
&= ~FLG_NoGrouping
;
90 if (data
->rate
!=tidata
)
95 SetSuperAttrs(CLASS
, self
, MUIA_Gauge_Current
, tidata
, TAG_DONE
);
103 register ULONG rate
= data
->rate
;
105 if (data
->flags
& FLG_Short
)
107 UBYTE buf
[16], *dp
= MiamiPanelBaseIntern
->mpb_decPoint
;
114 sprintf(buf
, "%u", q
);
116 if (!(data
->flags
& FLG_NoGrouping
)) grouping(buf
, MiamiPanelBaseIntern
);
117 sprintf(cont
,"%s%s%3.3lu %s",buf
,dp
,r
,Mbss
);
123 sprintf(buf
, "%u", q
);
124 if (!(data
->flags
& FLG_NoGrouping
)) grouping(buf
, MiamiPanelBaseIntern
);
125 sprintf(cont
,"%s%s%1.1lu %s",buf
,dp
,(r
<100) ? 0 : r
,Kbss
);
130 sprintf(cont
, "%u", rate
);
131 if (!(data
->flags
& FLG_NoGrouping
)) grouping(cont
, MiamiPanelBaseIntern
);
136 sprintf(data
->cont
,"\33l%s",cont
);
137 SetSuperAttrs(CLASS
, self
, MUIA_Gauge_InfoText
, data
->cont
,TAG_DONE
);
140 return DoSuperMethodA(CLASS
,self
,(Msg
)message
);
143 /***********************************************************************/
145 BOOPSI_DISPATCHER(IPTR
, MUIPC_Rate_Dispatcher
, CLASS
, self
, message
)
147 switch (message
->MethodID
)
149 case OM_SET
: return MUIPC_Rate__OM_SET(CLASS
,self
,(APTR
)message
);
150 case OM_NEW
: return MUIPC_Rate__OM_NEW(CLASS
,self
,(APTR
)message
);
151 default: return DoSuperMethodA(CLASS
,self
,message
);
155 BOOPSI_DISPATCHER_END
157 /***********************************************************************/
160 MUIPC_Rate_ClassInit(struct MiamiPanelBase_intern
*MiamiPanelBase
)
162 MiamiPanelBaseIntern
= MiamiPanelBase
;
163 if (MiamiPanelBaseIntern
->mpb_rateClass
= MUI_CreateCustomClass(NULL
,MUIC_Gauge
,NULL
,sizeof(struct MiamiPanelRateClass_DATA
), MUIPC_Rate_Dispatcher
))
165 bpss
= __(MSG_Rate_Bs
);
166 Kbss
= __(MSG_Rate_KBs
);
167 Mbss
= __(MSG_Rate_MBs
);
175 /***********************************************************************/