added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / classes / gadgets / texteditor / mcp / Dispatcher.c
blob7dbd3a9a3021e73ec2cf7f70ba51b48de3dbf3b6
1 /***************************************************************************
3 TextEditor.mcc - Textediting MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005 by 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 DISPATCHERPROTO(_DispatcherP)
41 DISPATCHER_INIT
43 switch(msg->MethodID)
45 case OM_NEW: return(New(cl, obj, (APTR)msg));
46 case OM_DISPOSE: return(Dispose(cl, obj, (APTR)msg));
47 case MUIM_Settingsgroup_ConfigToGadgets: return(ConfigToGadgets(cl, obj, (APTR)msg));
48 case MUIM_Settingsgroup_GadgetsToConfig: return(GadgetsToConfig(cl, obj, (APTR)msg));
51 return(DoSuperMethodA(cl, obj, msg));
53 DISPATCHER_EXIT
56 DISPATCHERPROTO(Text_Dispatcher)
58 DISPATCHER_INIT
60 switch(msg->MethodID)
62 case OM_SET:
64 struct opSet *set_msg = (struct opSet *)msg;
65 struct TagItem *tag;
67 if((tag = FindTagItem(MUIA_UserData, set_msg->ops_AttrList)))
68 set(obj, MUIA_Text_Contents, FunctionName(tag->ti_Data));
70 break;
73 return(DoSuperMethodA(cl, obj, msg));
75 DISPATCHER_EXIT
78 DISPATCHERPROTO(WidthSlider_Dispatcher)
80 DISPATCHER_INIT
82 if(msg->MethodID == MUIM_Numeric_Stringify)
84 struct MUIP_Numeric_Stringify *smsg = (struct MUIP_Numeric_Stringify *)msg;
86 if(smsg->value == 1)
87 return (ULONG)GetStr(MSG_SliderText_MinWidth);
89 if(smsg->value == 6)
90 return (ULONG)GetStr(MSG_SliderText_MaxWidth);
93 return(DoSuperMethodA(cl, obj, msg));
95 DISPATCHER_EXIT
98 DISPATCHERPROTO(SpeedSlider_Dispatcher)
100 DISPATCHER_INIT
102 if(msg->MethodID == MUIM_Numeric_Stringify)
104 struct MUIP_Numeric_Stringify *smsg = (struct MUIP_Numeric_Stringify *)msg;
106 if(smsg->value == 0)
107 return (ULONG)GetStr(MSG_SliderText_MinSpeed);
108 else
110 static char buf[20];
112 sprintf(buf, "%ld ms", smsg->value*25);
114 return (ULONG)buf;
118 return(DoSuperMethodA(cl, obj, msg));
120 DISPATCHER_EXIT
123 struct MUI_CustomClass *widthslider_mcc = NULL;
124 struct MUI_CustomClass *speedslider_mcc = NULL;
125 struct MUI_CustomClass *text_mcc = NULL;
127 #ifndef __AROS__
128 BOOL CreateSubClasses(void)
130 if((widthslider_mcc = MUI_CreateCustomClass(NULL, "Slider.mui", NULL, 0, ENTRY(WidthSlider_Dispatcher))))
132 if((speedslider_mcc = MUI_CreateCustomClass(NULL, "Slider.mui", NULL, 0, ENTRY(SpeedSlider_Dispatcher))))
134 if((text_mcc = MUI_CreateCustomClass(NULL, "Text.mui", NULL, 0, ENTRY(Text_Dispatcher))))
136 return TRUE;
141 return FALSE;
144 void DeleteSubClasses(void)
146 if(text_mcc)
148 MUI_DeleteCustomClass(text_mcc);
149 text_mcc = NULL;
152 if(speedslider_mcc)
154 MUI_DeleteCustomClass(speedslider_mcc);
155 speedslider_mcc = NULL;
158 if(widthslider_mcc)
160 MUI_DeleteCustomClass(widthslider_mcc);
161 widthslider_mcc = NULL;
165 #endif