arch/cpu.resource: remove dead code
[AROS.git] / workbench / classes / zune / busy / busy.c
blobe5d0a50ae6609ab70037fda29c9b1a91e9b0396e
1 /*
2 Copyright © 1995-2011, 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/alib.h>
15 #include <proto/muimaster.h>
16 #include <proto/graphics.h>
17 #include <proto/intuition.h>
18 #include <proto/utility.h>
19 #include <proto/timer.h>
21 #include <string.h>
22 #include <stdio.h>
24 #include "Busy_mcc.h"
25 #include "busy_private.h"
27 /*** Methods ****************************************************************/
28 IPTR Busy__OM_NEW(Class *cl, Object *obj, struct opSet *msg)
30 struct Busy_DATA *data;
32 obj = (Object *) DoSuperMethodA(cl, obj, (Msg)msg);
33 if (!obj) return 0;
35 data = INST_DATA(cl, obj);
36 if (GetTagData(MUIA_Busy_ShowHideIH, FALSE, msg->ops_AttrList))
38 data->flags |= FLG_SHOWHIDEIH;
40 data->speed = 50;
42 data->ihn.ihn_Flags = MUIIHNF_TIMER;
43 data->ihn.ihn_Method = MUIM_Busy_Move;
44 data->ihn.ihn_Object = obj;
45 data->ihn.ihn_Millis = 0;
47 return (IPTR)obj;
50 IPTR Busy__OM_SET(Class *cl, Object *obj, struct opSet *msg)
52 struct Busy_DATA *data = INST_DATA(cl, obj);
53 struct TagItem *tags = msg->ops_AttrList;
54 struct TagItem *tag;
55 BOOL redraw = FALSE;
57 while ((tag = NextTagItem(&tags)) != NULL)
59 switch(tag->ti_Tag)
61 case MUIA_Busy_Speed:
62 if ((LONG)tag->ti_Data == MUIV_Busy_Speed_User)
64 data->speed = 50;
66 else
68 data->speed = tag->ti_Data;
71 if ((data->flags & FLG_SHOWN) ||
72 ((data->flags & FLG_SETUP) && !(data->flags & FLG_SHOWHIDEIH)))
74 if (data->ihn.ihn_Millis)
76 DoMethod(_app(obj), MUIM_Application_RemInputHandler, (IPTR) &data->ihn);
79 data->ihn.ihn_Millis = data->speed;
81 if (data->ihn.ihn_Millis)
83 DoMethod(_app(obj), MUIM_Application_AddInputHandler, (IPTR) &data->ihn);
86 break;
88 } /* switch(tag->ti_Tag) */
90 } /* while ((tag = NextTagItem(&tags)) != NULL) */
92 if (redraw)
94 MUI_Redraw(obj, MADF_DRAWUPDATE);
97 return DoSuperMethodA(cl, obj, (Msg)msg);
101 IPTR Busy__OM_GET(Class *cl, Object *obj, struct opGet *msg)
103 struct Busy_DATA *data = INST_DATA(cl, obj);
104 IPTR retval = TRUE;
106 switch(msg->opg_AttrID)
108 case MUIA_Busy_Speed:
109 *msg->opg_Storage = data->speed;
110 break;
112 default:
113 retval = DoSuperMethodA(cl, obj, (Msg)msg);
114 break;
117 return retval;
121 IPTR Busy__MUIM_Setup(Class *cl, Object *obj, struct MUIP_Setup *msg)
123 struct Busy_DATA *data = INST_DATA(cl, obj);
125 if (!DoSuperMethodA(cl, obj, (Msg)msg)) return FALSE;
127 if (data->speed && !(data->flags & FLG_SHOWHIDEIH))
129 data->ihn.ihn_Millis = data->speed;
130 DoMethod(_app(obj), MUIM_Application_AddInputHandler, (IPTR) &data->ihn);
133 data->flags |= FLG_SETUP;
135 return TRUE;
139 IPTR Busy__MUIM_Cleanup(Class *cl, Object *obj, struct MUIP_Cleanup *msg)
141 struct Busy_DATA *data = INST_DATA(cl, obj);
143 if (data->ihn.ihn_Millis && !(data->flags & FLG_SHOWHIDEIH))
145 DoMethod(_app(obj), MUIM_Application_RemInputHandler, (IPTR) &data->ihn);
146 data->ihn.ihn_Millis = 0;
149 data->flags &= ~FLG_SETUP;
151 return DoSuperMethodA(cl, obj, (Msg)msg);
154 IPTR Busy__MUIM_Show(Class *cl, Object *obj, struct MUIP_Show *msg)
156 struct Busy_DATA *data = INST_DATA(cl, obj);
157 IPTR retval;
159 retval = DoSuperMethodA(cl, obj, (Msg)msg);
161 if (data->speed && (data->flags & FLG_SHOWHIDEIH))
163 data->ihn.ihn_Millis = data->speed;
164 DoMethod(_app(obj), MUIM_Application_AddInputHandler, (IPTR) &data->ihn);
167 data->flags |= FLG_SHOWN;
169 return retval;
173 IPTR Busy__MUIM_Hide(Class *cl, Object *obj, struct MUIP_Hide *msg)
175 struct Busy_DATA *data = INST_DATA(cl, obj);
177 if (data->ihn.ihn_Millis && (data->flags & FLG_SHOWHIDEIH))
179 DoMethod(_app(obj), MUIM_Application_RemInputHandler, (IPTR) &data->ihn);
180 data->ihn.ihn_Millis = 0;
183 data->flags &= ~FLG_SHOWN;
185 return DoSuperMethodA(cl, obj, (Msg)msg);
188 IPTR Busy__MUIM_AskMinMax(Class *cl, Object *obj, struct MUIP_AskMinMax *msg)
190 DoSuperMethodA(cl, obj, (Msg)msg);
192 msg->MinMaxInfo->MinWidth += 50;
193 msg->MinMaxInfo->MinHeight += 4;
194 msg->MinMaxInfo->DefWidth += 50;
195 msg->MinMaxInfo->DefHeight += 4;
196 msg->MinMaxInfo->MaxWidth = MUI_MAXMAX;
197 msg->MinMaxInfo->MaxHeight = MUI_MAXMAX;
199 return TRUE;
203 IPTR Busy__MUIM_Draw(Class *cl, Object *obj, struct MUIP_Draw *msg)
205 struct Busy_DATA *data = INST_DATA(cl, obj);
206 WORD x;
207 IPTR retval;
209 retval = DoSuperMethodA(cl, obj, (Msg)msg);
211 if (!(msg->flags & (MADF_DRAWOBJECT | MADF_DRAWUPDATE))) return 0;
213 for(x = 0; x < _mwidth(obj); x++)
215 WORD col;
217 col = ((x + data->pos) / 8) % 2;
218 SetAPen(_rp(obj), _pens(obj)[col ? MPEN_SHADOW : MPEN_SHINE]);
219 RectFill(_rp(obj), _mleft(obj) + x, _mtop(obj), _mleft(obj) + x, _mbottom(obj));
222 return retval;
226 IPTR Busy__MUIM_Busy_Move(Class *cl, Object *obj, Msg msg)
228 struct Busy_DATA *data;
230 data = INST_DATA(cl, obj);
231 data->pos++;
233 MUI_Redraw(obj, MADF_DRAWUPDATE);
235 return 0;