Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / network / stacks / AROSTCP / MUI.MiamiPanel / Classes / muimiamipanel_class_lbutton.c
blob0f558e0fc7348fdef4307923dbff630f2bb08520
2 #include <proto/intuition.h>
3 #include <proto/muimaster.h>
4 #include <proto/utility.h>
6 #include <libraries/mui.h>
7 #include <libraries/gadtools.h>
9 #include "muimiamipanel_intern.h"
10 #include "muimiamipanel_locale.h"
12 #include <mui/Lamp_mcc.h>
14 /***********************************************************************/
16 static UBYTE *ons, *offs, *btFixWidthTxt;
18 /***********************************************************************/
20 struct MiamiPanelLButtonClass_DATA
22 Object *lamp;
23 Object *text;
26 /***********************************************************************/
28 static struct MiamiPanelBase_intern *MiamiPanelBaseIntern;
30 static ULONG
31 MUIPC_LButton__OM_NEW(struct IClass *CLASS,Object *self,struct opSet *message)
33 struct MiamiPanelLButtonClass_DATA temp;
34 struct TagItem *attrs = message->ops_AttrList;
36 temp.lamp = LampObject, End;
38 if (self = (Object *)DoSuperNewTags
40 CLASS, self, NULL,
42 MUIA_Frame, MUIV_Frame_Button,
43 MUIA_Background, MUII_ButtonBack,
44 MUIA_Font, MUIV_Font_Button,
45 MUIA_InputMode, MUIV_InputMode_RelVerify,
46 MUIA_CycleChain, TRUE,
47 MUIA_Group_Horiz, TRUE,
48 MUIA_Group_HorizSpacing, 0,
50 temp.lamp ? Child : TAG_IGNORE, temp.lamp,
51 temp.lamp ? Child : TAG_IGNORE, temp.lamp ? (RectangleObject, MUIA_FixWidthTxt, ".", End) : NULL,
53 Child, temp.text = TextObject,
54 MUIA_FixWidthTxt, btFixWidthTxt,
55 MUIA_Text_PreParse, MUIX_C,
56 MUIA_Text_Contents, ons,
57 End,
59 TAG_MORE,attrs))
61 struct MiamiPanelLButtonClass_DATA *data = INST_DATA(CLASS,self);
63 CopyMem(&temp, data, sizeof(struct MiamiPanelLButtonClass_DATA));
66 return (ULONG)self;
69 /***********************************************************************/
71 static ULONG
72 MUIPC_LButton__OM_SET(struct IClass *CLASS,Object *self,struct opSet *message)
74 struct MiamiPanelLButtonClass_DATA *data = INST_DATA(CLASS,self);
75 struct TagItem *tag;
77 if (tag = FindTagItem(MPA_LButton_State,message->ops_AttrList))
79 UBYTE *text;
80 ULONG color, dis;
82 switch (tag->ti_Data)
84 case MIAMIPANELV_AddInterface_State_GoingOnline:
85 color = MUIV_Lamp_Color_Error;
86 text = offs;
87 dis = FALSE;
88 break;
90 case MIAMIPANELV_AddInterface_State_GoingOffline:
91 color = MUIV_Lamp_Color_Warning;
92 text = ons;
93 dis = TRUE;
94 break;
96 case MIAMIPANELV_AddInterface_State_Suspending:
97 color = MUIV_Lamp_Color_FatalError;
98 text = NULL;
99 dis = TRUE;
100 break;
102 case MIAMIPANELV_AddInterface_State_Online:
103 color = MUIV_Lamp_Color_Ok;
104 text = offs;
105 dis = FALSE;
106 break;
108 case MIAMIPANELV_AddInterface_State_Suspended:
109 color = MUIV_Lamp_Color_Processing;
110 text = NULL;
111 dis = TRUE;
112 break;
114 default:
115 color = MUIV_Lamp_Color_Off;
116 text = ons;
117 dis = FALSE;
118 break;
121 if (data->lamp) set(data->lamp,MUIA_Lamp_Color,color);
122 if (text) set(data->text,MUIA_Text_Contents,text);
123 SetSuperAttrs(CLASS,self,MUIA_Disabled,dis,TAG_DONE);
126 return DoSuperMethodA(CLASS,self,(Msg)message);
129 /***********************************************************************/
131 BOOPSI_DISPATCHER(IPTR, MUIPC_LButton_Dispatcher, CLASS, self, message)
133 switch (message->MethodID)
135 case OM_SET: return MUIPC_LButton__OM_SET(CLASS,self,(APTR)message);
136 case OM_NEW: return MUIPC_LButton__OM_NEW(CLASS,self,(APTR)message);
137 default: return DoSuperMethodA(CLASS,self,message);
139 return 0;
141 BOOPSI_DISPATCHER_END
143 /***********************************************************************/
145 ULONG
146 MUIPC_LButton_ClassInit(struct MiamiPanelBase_intern *MiamiPanelBase)
148 MiamiPanelBaseIntern = MiamiPanelBase;
149 if (MiamiPanelBaseIntern->mpb_lbuttonClass = MUI_CreateCustomClass(NULL, MUIC_Group, NULL, sizeof(struct MiamiPanelLButtonClass_DATA), MUIPC_LButton_Dispatcher))
151 ons = __(MSG_IF_Button_Online);
152 offs = __(MSG_IF_Button_Offline);
154 if (strlen(ons)>strlen(offs)) btFixWidthTxt = ons;
155 else btFixWidthTxt = offs;
157 return TRUE;
160 return FALSE;
163 /***********************************************************************/