Test initialisation of MUIA_List_AdjustWidth and MUIA_List_AdjustHeight, and
[AROS.git] / workbench / tools / SysExplorer / ataunit_window_cl.c
blob581b5d487b95d3d026b9ba5e52590e630ca4a4d8
1 /*
2 Copyright (C) 2013, The AROS Development Team.
3 $Id$
4 */
6 #include <aros/debug.h>
8 #define MUIMASTER_YES_INLINE_STDARG
10 #include <proto/alib.h>
11 #include <proto/exec.h>
12 #include <proto/muimaster.h>
13 #include <proto/utility.h>
14 #include <proto/intuition.h>
16 #include <exec/memory.h>
17 #include <libraries/mui.h>
18 #include <zune/customclasses.h>
19 #include <mui/NFloattext_mcc.h>
20 #include <utility/tagitem.h>
21 #include <utility/hooks.h>
23 #include <hidd/ata.h>
25 #include "classes.h"
26 #include "locale.h"
28 #include <ctype.h>
29 #include <stdio.h>
30 #include <stdlib.h>
32 extern OOP_AttrBase HiddATAUnitAB;
34 /*** Instance Data **********************************************************/
35 struct ATAUnitWindow_DATA
37 /* Nothing to add */
40 static const char *const xferModeNames[] =
42 "PIO0" , "PIO1" , "PIO2 ", "PIO3" , "PIO4" ,
43 "MDMA0", "MDMA1", "MDMA2",
44 "UDMA0", "UDMA1", "UDMA2", "UDMA3", "UDMA4", "UDMA5", "UDMA6",
45 (const char *)AB_XFER_48BIT,
46 "LBA48", "Multisector", "ATAPI", "LBA", "PIO32",
47 NULL
50 static void DecodeBits(char *str, ULONG flags, const char *const *names)
52 unsigned char i, done;
54 for (i = 0, done = 0; *names; names++)
56 if ((IPTR)*names < 32)
58 i = (IPTR)*names;
59 continue;
61 if (flags & (1 << i))
63 strcpy(str, *names);
64 str += strlen(*names);
65 if ((done % 5) == 4)
66 *str++ = '\n';
67 else
68 *str++ = ' ';
69 done++;
71 i++;
74 *str = 0;
77 static Object *ATAUnitWindow__OM_NEW(Class *cl, Object *self, struct opSet *msg)
79 OOP_Object *dev = (OOP_Object *)GetTagData(MUIA_PropertyWin_Object, 0, msg->ops_AttrList);
80 IPTR model, revision, serial;
81 IPTR val;
82 char xfermodes_str[256];
83 char usemodes_str[256];
84 char multisector_str[4];
85 char unit_str[6];
86 LONG removable;
88 OOP_GetAttr(dev, aHidd_ATAUnit_Model , &model);
89 OOP_GetAttr(dev, aHidd_ATAUnit_Revision, &revision);
90 OOP_GetAttr(dev, aHidd_ATAUnit_Serial , &serial);
92 removable = OOP_GET(dev, aHidd_ATAUnit_Removable) ? IDS_SELECTED : IDS_NORMAL;
94 OOP_GetAttr(dev, aHidd_ATAUnit_Number, &val);
95 snprintf(unit_str, sizeof(unit_str), "%ld", val);
97 OOP_GetAttr(dev, aHidd_ATAUnit_XferModes, &val);
98 DecodeBits(xfermodes_str, val, xferModeNames),
100 OOP_GetAttr(dev, aHidd_ATAUnit_ConfiguredModes, &val);
101 DecodeBits(usemodes_str, val, xferModeNames),
103 OOP_GetAttr(dev, aHidd_ATAUnit_MultiSector, &val);
104 snprintf(multisector_str, sizeof(multisector_str), "%ld", val);
106 return (Object *) DoSuperNewTags
108 cl, self, NULL,
109 MUIA_Window_Title, __(MSG_ATA_UNIT_PROPERTIES),
110 MUIA_Window_ID, MAKE_ID('A', 'U', 'N', 'P'),
111 WindowContents, (IPTR)(ColGroup(2),
112 Child, (IPTR)Label(_(MSG_UNIT_NUMBER)),
113 Child, (IPTR)(TextObject,
114 TextFrame,
115 MUIA_Background, MUII_TextBack,
116 MUIA_CycleChain, 1,
117 MUIA_Text_Contents, (IPTR)unit_str,
118 End),
119 Child, (IPTR)Label(_(MSG_MODEL)),
120 Child, (IPTR)(TextObject,
121 TextFrame,
122 MUIA_Background, MUII_TextBack,
123 MUIA_CycleChain, 1,
124 MUIA_Text_Contents, model,
125 End),
126 Child, (IPTR)Label(_(MSG_REVISION)),
127 Child, (IPTR)(TextObject,
128 TextFrame,
129 MUIA_Background, MUII_TextBack,
130 MUIA_CycleChain, 1,
131 MUIA_Text_Contents, revision,
132 End),
133 Child, (IPTR)Label(_(MSG_SERIAL)),
134 Child, (IPTR)(TextObject,
135 TextFrame,
136 MUIA_Background, MUII_TextBack,
137 MUIA_CycleChain, 1,
138 MUIA_Text_Contents, serial,
139 End),
140 Child, (IPTR)Label(_(MSG_TRANSFER_MODES)),
141 Child, (IPTR)(NFloattextObject,
142 TextFrame,
143 MUIA_Background, MUII_TextBack,
144 MUIA_CycleChain, 1,
145 MUIA_Floattext_Text, (IPTR)xfermodes_str,
146 End),
147 Child, (IPTR)Label(_(MSG_CONFIG_MODES)),
148 Child, (IPTR)(NFloattextObject,
149 TextFrame,
150 MUIA_Background, MUII_TextBack,
151 MUIA_CycleChain, 1,
152 MUIA_Floattext_Text, (IPTR)usemodes_str,
153 End),
154 Child, (IPTR)Label(_(MSG_MULTISECTOR)),
155 Child, (IPTR)(TextObject,
156 TextFrame,
157 MUIA_Background, MUII_TextBack,
158 MUIA_CycleChain, 1,
159 MUIA_Text_Contents, (IPTR)multisector_str,
160 End),
161 Child, (IPTR)Label(_(MSG_REMOVABLE)),
162 Child, (IPTR)(HGroup,
163 Child, (IPTR)(ImageObject,
164 MUIA_Image_Spec, MUII_CheckMark,
165 MUIA_Image_State, removable,
166 TextFrame,
167 MUIA_CycleChain, 1,
168 MUIA_Background, MUII_TextBack,
169 End),
170 Child, (IPTR)HSpace(0),
171 End),
172 End),
173 TAG_DONE
177 /*** Setup ******************************************************************/
178 ZUNE_CUSTOMCLASS_1
180 ATAUnitWindow, NULL, MUIC_Window, NULL,
181 OM_NEW, struct opSet *