Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / classes / zune / busy / busy.c
blobff0c7f6811197967bda6471b05b4e98d11d4d988
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define MUIMASTER_YES_INLINE_STDARG
8 #include <exec/types.h>
9 #include <utility/date.h>
11 #include <aros/debug.h>
12 #include <aros/asmcall.h>
14 #include <proto/muimaster.h>
15 #include <proto/graphics.h>
16 #include <proto/intuition.h>
17 #include <proto/utility.h>
18 #include <proto/timer.h>
20 #include <string.h>
21 #include <stdio.h>
23 #include "Busy_mcc.h"
24 #include "busy_private.h"
26 /*** Methods ****************************************************************/
27 IPTR Busy__OM_NEW(Class *cl, Object *obj, struct opSet *msg)
29 struct Busy_DATA *data;
31 obj = (Object *) DoSuperMethodA(cl, obj, (Msg)msg);
32 if (!obj) return 0;
34 data = INST_DATA(cl, obj);
35 if (GetTagData(MUIA_Busy_ShowHideIH, FALSE, msg->ops_AttrList))
37 data->flags |= FLG_SHOWHIDEIH;
39 data->speed = 50;
41 data->ihn.ihn_Flags = MUIIHNF_TIMER;
42 data->ihn.ihn_Method = MUIM_Busy_Move;
43 data->ihn.ihn_Object = obj;
44 data->ihn.ihn_Millis = 0;
46 return (IPTR)obj;
49 IPTR Busy__OM_SET(Class *cl, Object *obj, struct opSet *msg)
51 struct Busy_DATA *data = INST_DATA(cl, obj);
52 struct TagItem *tags = msg->ops_AttrList;
53 struct TagItem *tag;
54 BOOL redraw = FALSE;
56 while ((tag = NextTagItem((const struct TagItem **)&tags)) != NULL)
58 switch(tag->ti_Tag)
60 case MUIA_Busy_Speed:
61 if ((LONG)tag->ti_Data == MUIV_Busy_Speed_User)
63 data->speed = 50;
65 else
67 data->speed = tag->ti_Data;
70 if ((data->flags & FLG_SHOWN) ||
71 ((data->flags & FLG_SETUP) && !(data->flags & FLG_SHOWHIDEIH)))
73 if (data->ihn.ihn_Millis)
75 DoMethod(_app(obj), MUIM_Application_RemInputHandler, (IPTR) &data->ihn);
78 data->ihn.ihn_Millis = data->speed;
80 if (data->ihn.ihn_Millis)
82 DoMethod(_app(obj), MUIM_Application_AddInputHandler, (IPTR) &data->ihn);
85 break;
87 } /* switch(tag->ti_Tag) */
89 } /* while ((tag = NextTagItem(&tags)) != NULL) */
91 if (redraw)
93 MUI_Redraw(obj, MADF_DRAWUPDATE);
96 return DoSuperMethodA(cl, obj, (Msg)msg);
100 IPTR Busy__OM_GET(Class *cl, Object *obj, struct opGet *msg)
102 struct Busy_DATA *data = INST_DATA(cl, obj);
103 IPTR retval = TRUE;
105 switch(msg->opg_AttrID)
107 case MUIA_Busy_Speed:
108 *msg->opg_Storage = data->speed;
109 break;
111 default:
112 retval = DoSuperMethodA(cl, obj, (Msg)msg);
113 break;
116 return retval;
120 IPTR Busy__MUIM_Setup(Class *cl, Object *obj, struct MUIP_Setup *msg)
122 struct Busy_DATA *data = INST_DATA(cl, obj);
124 if (!DoSuperMethodA(cl, obj, (Msg)msg)) return FALSE;
126 if (data->speed && !(data->flags & FLG_SHOWHIDEIH))
128 data->ihn.ihn_Millis = data->speed;
129 DoMethod(_app(obj), MUIM_Application_AddInputHandler, (IPTR) &data->ihn);
132 data->flags |= FLG_SETUP;
134 return TRUE;
138 IPTR Busy__MUIM_Cleanup(Class *cl, Object *obj, struct MUIP_Cleanup *msg)
140 struct Busy_DATA *data = INST_DATA(cl, obj);
142 if (data->ihn.ihn_Millis && !(data->flags & FLG_SHOWHIDEIH))
144 DoMethod(_app(obj), MUIM_Application_RemInputHandler, (IPTR) &data->ihn);
145 data->ihn.ihn_Millis = 0;
148 data->flags &= ~FLG_SETUP;
150 return DoSuperMethodA(cl, obj, (Msg)msg);
153 IPTR Busy__MUIM_Show(Class *cl, Object *obj, struct MUIP_Show *msg)
155 struct Busy_DATA *data = INST_DATA(cl, obj);
156 IPTR retval;
158 retval = DoSuperMethodA(cl, obj, (Msg)msg);
160 if (data->speed && (data->flags & FLG_SHOWHIDEIH))
162 data->ihn.ihn_Millis = data->speed;
163 DoMethod(_app(obj), MUIM_Application_AddInputHandler, (IPTR) &data->ihn);
166 data->flags |= FLG_SHOWN;
168 return retval;
172 IPTR Busy__MUIM_Hide(Class *cl, Object *obj, struct MUIP_Hide *msg)
174 struct Busy_DATA *data = INST_DATA(cl, obj);
176 if (data->ihn.ihn_Millis && (data->flags & FLG_SHOWHIDEIH))
178 DoMethod(_app(obj), MUIM_Application_RemInputHandler, (IPTR) &data->ihn);
179 data->ihn.ihn_Millis = 0;
182 data->flags &= ~FLG_SHOWN;
184 return DoSuperMethodA(cl, obj, (Msg)msg);
187 IPTR Busy__MUIM_AskMinMax(Class *cl, Object *obj, struct MUIP_AskMinMax *msg)
189 DoSuperMethodA(cl, obj, (Msg)msg);
191 msg->MinMaxInfo->MinWidth += 50;
192 msg->MinMaxInfo->MinHeight += 4;
193 msg->MinMaxInfo->DefWidth += 50;
194 msg->MinMaxInfo->DefHeight += 4;
195 msg->MinMaxInfo->MaxWidth = MUI_MAXMAX;
196 msg->MinMaxInfo->MaxHeight = MUI_MAXMAX;
198 return TRUE;
202 IPTR Busy__MUIM_Draw(Class *cl, Object *obj, struct MUIP_Draw *msg)
204 struct Busy_DATA *data = INST_DATA(cl, obj);
205 WORD x;
206 IPTR retval;
208 retval = DoSuperMethodA(cl, obj, (Msg)msg);
210 if (!(msg->flags & (MADF_DRAWOBJECT | MADF_DRAWUPDATE))) return 0;
212 for(x = 0; x < _mwidth(obj); x++)
214 WORD col;
216 col = ((x + data->pos) / 8) % 2;
217 SetAPen(_rp(obj), _pens(obj)[col ? MPEN_SHADOW : MPEN_SHINE]);
218 RectFill(_rp(obj), _mleft(obj) + x, _mtop(obj), _mleft(obj) + x, _mbottom(obj));
221 return retval;
225 IPTR Busy__MUIM_Busy_Move(Class *cl, Object *obj, Msg msg)
227 struct Busy_DATA *data;
229 data = INST_DATA(cl, obj);
230 data->pos++;
232 MUI_Redraw(obj, MADF_DRAWUPDATE);
234 return 0;