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/
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>
32 IPTR
Setup(struct IClass
*cl
, Object
*obj
, struct MUI_RenderInfo
*rinfo
)
34 struct InstData
*data
= (struct InstData
*)INST_DATA(cl
, obj
);
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
);
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
);
62 if((tag
= FindTagItem(MUIA_HotkeyString_Snoop
, msg
->ops_AttrList
)))
65 setFlag(data
->Flags
, FLG_Snoop
);
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
)
95 switch(msg
->opg_AttrID
)
98 ti_Data
= LIB_VERSION
;
102 ti_Data
= LIB_REVISION
;
106 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
109 *msg
->opg_Storage
= ti_Data
;
113 DISPATCHER(_Dispatcher
)
115 struct InstData
*data
= (struct InstData
*)INST_DATA(cl
, obj
);
118 switch(msg
->MethodID
)
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
);
133 result
= Setup(cl
, obj
, (struct MUI_RenderInfo
*)msg
);
137 Set(cl
, obj
, (struct opSet
*)msg
);
138 result
= DoSuperMethodA(cl
, obj
, msg
);
142 result
= Get(cl
, obj
, (struct opGet
*)msg
);
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
);
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
);
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
);
173 result
= Cleanup(cl
, obj
, msg
);
177 result
= DoSuperMethodA(cl
, obj
, msg
);