revert 213 commits (to 56092) from the last month. 10 still need work to resolve...
[AROS.git] / workbench / classes / zune / texteditor / mcp / Dispatcher.c
blob2820a29be81adcabfb30dad99fd9b223385da6ad
1 /***************************************************************************
3 TextEditor.mcc - Textediting MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005-2014 TextEditor.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 TextEditor class Support Site: http://www.sf.net/projects/texteditor-mcc
19 $Id$
21 ***************************************************************************/
23 #include <stdio.h>
25 #include <clib/alib_protos.h>
26 #include <utility/tagitem.h>
27 #include <libraries/mui.h>
28 #include <proto/intuition.h>
29 #include <proto/utility.h>
30 #include <proto/muimaster.h>
32 #include "locale.h"
33 #include "private.h"
35 #include "SDI_compiler.h"
36 #include "SDI_hook.h"
38 // the main mcp dispatcher
39 DISPATCHER(_DispatcherP)
41 switch(msg->MethodID)
43 case OM_NEW: return(New(cl, obj, (APTR)msg));
44 case OM_DISPOSE: return(Dispose(cl, obj, (APTR)msg));
45 case MUIM_Settingsgroup_ConfigToGadgets: return(ConfigToGadgets(cl, obj, (APTR)msg));
46 case MUIM_Settingsgroup_GadgetsToConfig: return(GadgetsToConfig(cl, obj, (APTR)msg));
49 return(DoSuperMethodA(cl, obj, msg));
52 DISPATCHER(Text_Dispatcher)
54 switch(msg->MethodID)
56 case OM_SET:
58 struct opSet *set_msg = (struct opSet *)msg;
59 struct TagItem *tag;
61 if((tag = FindTagItem(MUIA_UserData, set_msg->ops_AttrList)))
62 set(obj, MUIA_Text_Contents, FunctionName(tag->ti_Data));
64 break;
67 return(DoSuperMethodA(cl, obj, msg));
70 DISPATCHER(WidthSlider_Dispatcher)
72 if(msg->MethodID == MUIM_Numeric_Stringify)
74 struct MUIP_Numeric_Stringify *smsg = (struct MUIP_Numeric_Stringify *)msg;
76 if(smsg->value == 1)
77 return (IPTR)tr(MSG_SliderText_MinWidth);
79 if(smsg->value == 6)
80 return (IPTR)tr(MSG_SliderText_MaxWidth);
83 return(DoSuperMethodA(cl, obj, msg));
86 DISPATCHER(SpeedSlider_Dispatcher)
88 if(msg->MethodID == MUIM_Numeric_Stringify)
90 struct MUIP_Numeric_Stringify *smsg = (struct MUIP_Numeric_Stringify *)msg;
92 if(smsg->value == 0)
93 return (IPTR)tr(MSG_SliderText_MinSpeed);
94 else
96 static char buf[20];
98 snprintf(buf, sizeof(buf), "%d ms", (int)smsg->value*25);
100 return (IPTR)buf;
104 return(DoSuperMethodA(cl, obj, msg));
107 struct MUI_CustomClass *widthslider_mcc = NULL;
108 struct MUI_CustomClass *speedslider_mcc = NULL;
109 struct MUI_CustomClass *text_mcc = NULL;
111 BOOL CreateSubClasses(void)
113 if((widthslider_mcc = MUI_CreateCustomClass(NULL, "Slider.mui", NULL, 0, ENTRY(WidthSlider_Dispatcher))))
115 if((speedslider_mcc = MUI_CreateCustomClass(NULL, "Slider.mui", NULL, 0, ENTRY(SpeedSlider_Dispatcher))))
117 if((text_mcc = MUI_CreateCustomClass(NULL, "Text.mui", NULL, 0, ENTRY(Text_Dispatcher))))
119 return TRUE;
124 return FALSE;
127 void DeleteSubClasses(void)
129 if(text_mcc)
131 MUI_DeleteCustomClass(text_mcc);
132 text_mcc = NULL;
135 if(speedslider_mcc)
137 MUI_DeleteCustomClass(speedslider_mcc);
138 speedslider_mcc = NULL;
141 if(widthslider_mcc)
143 MUI_DeleteCustomClass(widthslider_mcc);
144 widthslider_mcc = NULL;