grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / classes / zune / betterstring / mcc / hotkeystring / Dispatcher.c
blobd9b40bb5be2a2e2bc1e987790d60eab7939cb2b5
1 /***************************************************************************
3 BetterString.mcc - A better String gadget MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005-2013 by BetterString.mcc Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 BetterString class Support Site: http://www.sf.net/projects/bstring-mcc/
19 $Id$
21 ***************************************************************************/
23 #include <clib/alib_protos.h>
24 #include <proto/intuition.h>
25 #include <proto/muimaster.h>
26 #include <proto/utility.h>
27 #include <libraries/mui.h>
29 #include "private.h"
30 #include "version.h"
32 IPTR Setup(struct IClass *cl, Object *obj, struct MUI_RenderInfo *rinfo)
34 struct InstData *data = (struct InstData *)INST_DATA(cl, obj);
35 IPTR result;
37 if((result = DoSuperMethodA(cl, obj, (Msg)rinfo)))
39 data->EventNode.ehn_Priority = 1;
40 data->EventNode.ehn_Flags = 0;
41 data->EventNode.ehn_Object = obj;
42 data->EventNode.ehn_Class = cl;
43 data->EventNode.ehn_Events = IDCMP_RAWKEY;
44 DoMethod(_win(obj), MUIM_Window_AddEventHandler, &data->EventNode);
46 return result;
49 IPTR Cleanup (struct IClass *cl, Object *obj, Msg msg)
51 struct InstData *data = (struct InstData *)INST_DATA(cl, obj);
53 DoMethod(_win(obj), MUIM_Window_RemEventHandler, &data->EventNode);
54 return DoSuperMethodA(cl, obj, msg);
57 VOID Set (struct IClass *cl, Object *obj, struct opSet *msg)
59 struct InstData *data = (struct InstData *)INST_DATA(cl, obj);
60 struct TagItem *tag;
62 if((tag = FindTagItem(MUIA_HotkeyString_Snoop, msg->ops_AttrList)))
64 if(tag->ti_Data)
65 setFlag(data->Flags, FLG_Snoop);
66 else
67 clearFlag(data->Flags, FLG_Snoop);
69 if(isFlagSet(data->Flags, FLG_Active))
70 set(_win(obj), MUIA_Window_DisableKeys, isFlagSet(data->Flags, FLG_Snoop) ? 0xffffff : 0);
73 if((tag = FindTagItem(MUIA_HotkeyString_IX, msg->ops_AttrList)))
75 struct InputXpression *ix = (struct InputXpression *)tag->ti_Data;
76 struct IntuiMessage imsg;
78 if (ix && ix->ix_Class == IECLASS_RAWKEY)
80 struct MUIP_HandleEvent msg = { 0, &imsg, MUIKEY_NONE };
82 imsg.Class = IDCMP_RAWKEY;
83 imsg.Code = ix->ix_Code;
84 imsg.Qualifier = ix->ix_Qualifier;
86 HandleInput(cl, obj, &msg);
91 IPTR Get (struct IClass *cl, Object *obj, struct opGet *msg)
93 IPTR ti_Data;
95 switch(msg->opg_AttrID)
97 case MUIA_Version:
98 ti_Data = LIB_VERSION;
99 break;
101 case MUIA_Revision:
102 ti_Data = LIB_REVISION;
103 break;
105 default:
106 return DoSuperMethodA(cl, obj, (Msg)msg);
107 break;
109 *msg->opg_Storage = ti_Data;
110 return TRUE;
113 DISPATCHER(_Dispatcher)
115 struct InstData *data = (struct InstData *)INST_DATA(cl, obj);
116 IPTR result = 0;
118 switch(msg->MethodID)
120 case OM_NEW:
122 if((obj = (Object *)(result = DoSuperMethodA(cl, obj, msg))))
124 struct InstData *data = (struct InstData *)INST_DATA(cl, obj);
126 setFlag(data->Flags, FLG_Snoop);
127 Set(cl, obj, (struct opSet *)msg);
130 break;
132 case MUIM_Setup:
133 result = Setup(cl, obj, (struct MUI_RenderInfo *)msg);
134 break;
136 case OM_SET:
137 Set(cl, obj, (struct opSet *)msg);
138 result = DoSuperMethodA(cl, obj, msg);
139 break;
141 case OM_GET:
142 result = Get(cl, obj, (struct opGet *)msg);
143 break;
145 case MUIM_HandleEvent:
147 struct MUIP_HandleEvent *hmsg = (struct MUIP_HandleEvent *)msg;
149 if(isFlagSet(data->Flags, FLG_Active) && isFlagSet(data->Flags, FLG_Snoop) && hmsg->imsg)
150 result = HandleInput(cl, obj, hmsg);
152 break;
154 case MUIM_GoActive:
156 setFlag(data->Flags, FLG_Active);
157 if(isFlagSet(data->Flags, FLG_Snoop))
158 set(_win(obj), MUIA_Window_DisableKeys, 0xffffffff);
159 result = DoSuperMethodA(cl, obj, msg);
161 break;
163 case MUIM_GoInactive:
165 clearFlag(data->Flags, FLG_Active);
166 if(isFlagSet(data->Flags, FLG_Snoop))
167 set(_win(obj), MUIA_Window_DisableKeys, 0);
168 result = DoSuperMethodA(cl, obj, msg);
170 break;
172 case MUIM_Cleanup:
173 result = Cleanup(cl, obj, msg);
174 break;
176 default:
177 result = DoSuperMethodA(cl, obj, msg);
178 break;
180 return result;