2 Copyright © 2002-2011, The AROS Development Team. All rights reserved.
10 #include <intuition/intuitionbase.h>
12 #include <clib/alib_protos.h>
13 #include <proto/exec.h>
14 #include <proto/utility.h>
15 #include <proto/intuition.h>
16 #include <proto/muimaster.h>
19 #include "muimaster_intern.h"
22 extern struct Library
*MUIMasterBase
;
24 struct Scrollbutton_DATA
31 struct MUI_EventHandlerNode ehn
;
35 IPTR
Scrollbutton__OM_NEW(struct IClass
*cl
, Object
*o
, struct opSet
*msg
)
37 return DoSuperNewTags(cl
, o
, NULL
,
39 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
40 MUIA_Background
, MUII_ButtonBack
,
41 TAG_MORE
, (IPTR
) msg
->ops_AttrList
);
44 IPTR
Scrollbutton__OM_GET(struct IClass
*cl
, Object
*o
,
47 struct Scrollbutton_DATA
*data
=
48 (struct Scrollbutton_DATA
*)INST_DATA(cl
, o
);
49 switch (msg
->opg_AttrID
)
51 case MUIA_Scrollbutton_NewPosition
:
52 *msg
->opg_Storage
= data
->pos
;
55 case MUIA_Scrollbutton_HorizProp
:
56 *msg
->opg_Storage
= (IPTR
) data
->horiz_prop
;
59 case MUIA_Scrollbutton_VertProp
:
60 *msg
->opg_Storage
= (IPTR
) data
->horiz_prop
;
64 return DoSuperMethodA(cl
, o
, (Msg
) msg
);
68 IPTR
Scrollbutton__OM_SET(struct IClass
*cl
, Object
*o
,
71 struct Scrollbutton_DATA
*data
=
72 (struct Scrollbutton_DATA
*)INST_DATA(cl
, o
);
73 struct TagItem
*tl
= msg
->ops_AttrList
;
76 while ((ti
= NextTagItem(&tl
)))
80 case MUIA_Scrollbutton_Horiz
:
81 data
->cx
= ti
->ti_Data
;
84 case MUIA_Scrollbutton_Vert
:
85 data
->cy
= ti
->ti_Data
;
89 return DoSuperMethodA(cl
, o
, (Msg
) msg
);
92 IPTR
Scrollbutton__MUIM_AskMinMax(struct IClass
*cl
, Object
*o
,
93 struct MUIP_AskMinMax
*msg
)
95 DoSuperMethodA(cl
, o
, (Msg
) msg
);
97 msg
->MinMaxInfo
->MinWidth
+= 2;
98 msg
->MinMaxInfo
->DefWidth
+= 2;
99 msg
->MinMaxInfo
->MaxWidth
+= MUI_MAXMAX
;
101 msg
->MinMaxInfo
->MinHeight
+= 2;
102 msg
->MinMaxInfo
->DefHeight
+= 2;
103 msg
->MinMaxInfo
->MaxHeight
+= MUI_MAXMAX
;
107 IPTR
Scrollbutton__MUIM_Setup(struct IClass
*cl
, Object
*o
, Msg msg
)
109 struct Scrollbutton_DATA
*data
=
110 (struct Scrollbutton_DATA
*)INST_DATA(cl
, o
);
111 if (!DoSuperMethodA(cl
, o
, msg
))
114 data
->ehn
.ehn_Events
= IDCMP_MOUSEBUTTONS
;
115 data
->ehn
.ehn_Priority
= 0;
116 data
->ehn
.ehn_Flags
= 0;
117 data
->ehn
.ehn_Object
= o
;
118 data
->ehn
.ehn_Class
= cl
;
120 DoMethod(_win(o
), MUIM_Window_AddEventHandler
, (IPTR
) & data
->ehn
);
125 IPTR
Scrollbutton__MUIM_Cleanup(struct IClass
*cl
, Object
*o
, Msg msg
)
127 struct Scrollbutton_DATA
*data
=
128 (struct Scrollbutton_DATA
*)INST_DATA(cl
, o
);
129 DoMethod(_win(o
), MUIM_Window_RemEventHandler
, (IPTR
) & data
->ehn
);
130 DoSuperMethodA(cl
, o
, msg
);
134 IPTR
Scrollbutton__MUIM_HandleEvent(struct IClass
*cl
, Object
*o
,
135 struct MUIP_HandleEvent
*msg
)
137 struct Scrollbutton_DATA
*data
=
138 (struct Scrollbutton_DATA
*)INST_DATA(cl
, o
);
141 switch (msg
->imsg
->Class
)
143 case IDCMP_MOUSEBUTTONS
:
144 if (msg
->imsg
->Code
== SELECTDOWN
)
146 if (msg
->imsg
->MouseX
>= _left(o
)
147 && msg
->imsg
->MouseX
<= _right(o
)
148 && msg
->imsg
->MouseY
>= _top(o
)
149 && msg
->imsg
->MouseY
<= _bottom(o
))
151 DoMethod(_win(o
), MUIM_Window_RemEventHandler
,
153 data
->ehn
.ehn_Events
|= IDCMP_MOUSEMOVE
;
154 DoMethod(_win(o
), MUIM_Window_AddEventHandler
,
157 set(o
, MUIA_Selected
, TRUE
);
158 data
->mx
= msg
->imsg
->MouseX
;
159 data
->my
= msg
->imsg
->MouseY
;
165 if (data
->ehn
.ehn_Events
& IDCMP_MOUSEMOVE
)
167 DoMethod(_win(o
), MUIM_Window_RemEventHandler
,
169 data
->ehn
.ehn_Events
&= ~IDCMP_MOUSEMOVE
;
170 DoMethod(_win(o
), MUIM_Window_AddEventHandler
,
173 set(o
, MUIA_Selected
, FALSE
);
178 case IDCMP_MOUSEMOVE
:
182 get(o
, MUIA_Selected
, &sel
);
185 UWORD x
= (msg
->imsg
->MouseX
- data
->mx
) + data
->cx
;
186 UWORD y
= (msg
->imsg
->MouseY
- data
->my
) + data
->cy
;
187 ULONG pos
= x
<< 16 | y
;
190 set(o
, MUIA_Scrollbutton_NewPosition
, pos
);
200 BOOPSI_DISPATCHER(IPTR
, Scrollbutton_Dispatcher
, cl
, obj
, msg
)
202 switch (msg
->MethodID
)
205 return Scrollbutton__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
207 return Scrollbutton__OM_GET(cl
, obj
, (struct opGet
*)msg
);
209 return Scrollbutton__OM_SET(cl
, obj
, (struct opSet
*)msg
);
211 return Scrollbutton__MUIM_AskMinMax(cl
, obj
,
212 (struct MUIP_AskMinMax
*)msg
);
214 return Scrollbutton__MUIM_Setup(cl
, obj
, msg
);
216 return Scrollbutton__MUIM_Cleanup(cl
, obj
, msg
);
217 case MUIM_HandleEvent
:
218 return Scrollbutton__MUIM_HandleEvent(cl
, obj
,
219 (struct MUIP_HandleEvent
*)msg
);
221 return DoSuperMethodA(cl
, obj
, msg
);
224 BOOPSI_DISPATCHER_END
226 const struct __MUIBuiltinClass _MUI_Scrollbutton_desc
=
230 sizeof(struct Scrollbutton_DATA
),
231 (void *) Scrollbutton_Dispatcher