2 Copyright © 1995-1997 Stefan Stuntz.
3 Copyright © 2009-2010, The AROS Development Team.
9 #include <proto/intuition.h>
10 #include <proto/muimaster.h>
11 #include <proto/utility.h>
12 #include <proto/graphics.h>
14 #include "displayidinfo_class.h"
16 #define USE_PSI_COLORS_BODY
17 #include "psi_colors.bh"
19 #define USE_PSI_SIZES_BODY
20 #define USE_PSI_SIZES_COLORS
21 #include "psi_sizes.bh"
23 #define USE_PSI_FREQS_BODY
24 #include "psi_freqs.bh"
26 /****************************************************************************************/
28 struct DispIDinfo_Data
30 Object
*TX_Visible
[2];
31 Object
*TX_Minimum
[2];
32 Object
*TX_Maximum
[2];
33 Object
*TX_BitsPerGun
;
39 /****************************************************************************************/
41 Object
*MakeMoni(LONG w
, LONG h
, LONG d
, const UBYTE
*body
, const ULONG
*colors
)
43 Object
*obj
= BodychunkObject
,
46 MUIA_Bitmap_Width
, w
,
47 MUIA_Bitmap_Height
, h
,
48 MUIA_Bodychunk_Depth
, d
,
49 MUIA_Bodychunk_Body
, (UBYTE
*)body
,
50 MUIA_Bodychunk_Compression
, PSI_COLORS_COMPRESSION
,
51 MUIA_Bodychunk_Masking
, PSI_COLORS_MASKING
,
52 MUIA_Bitmap_SourceColors
, (ULONG
*)colors
,
53 MUIA_Bitmap_Transparent
, 0,
59 /****************************************************************************************/
61 Object
*MakeSize(void)
63 Object
*obj
= TextObject
,
64 MUIA_Text_Contents
, "0",
65 MUIA_Text_PreParse
, "\33r",
66 MUIA_FixWidthTxt
, "00000",
72 /****************************************************************************************/
74 IPTR
DispIDinfo_New(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
76 Object
*TX_Visible
[2];
77 Object
*TX_Minimum
[2];
78 Object
*TX_Maximum
[2];
79 Object
*TX_BitsPerGun
;
85 obj
= (Object
*)DoSuperNewTags(cl
, obj
, NULL
,
86 MUIA_Group_Columns
, 2,
87 Child
, g1
= MakeMoni(PSI_SIZES_WIDTH
,PSI_SIZES_HEIGHT
,PSI_SIZES_DEPTH
,psi_sizes_body
,psi_sizes_colors
),
88 Child
, ColGroup(4), MUIA_Group_VertSpacing
, 0, MUIA_Group_HorizSpacing
, 4,
89 Child
, MakeLabel(MSG_LABEL_VISIBLE
),
90 Child
, TX_Visible
[0]=MakeSize(),
92 Child
, TX_Visible
[1]=MakeSize(),
93 Child
, MakeLabel(MSG_LABEL_MINIMUM
),
94 Child
, TX_Minimum
[0]=MakeSize(),
96 Child
, TX_Minimum
[1]=MakeSize(),
97 Child
, MakeLabel(MSG_LABEL_MAXIMUM
),
98 Child
, TX_Maximum
[0]=MakeSize(),
100 Child
, TX_Maximum
[1]=MakeSize(),
102 Child
, g2
= MakeMoni(PSI_COLORS_WIDTH
,PSI_COLORS_HEIGHT
,PSI_COLORS_DEPTH
,psi_colors_body
,psi_sizes_colors
),
103 Child
, ColGroup(2), MUIA_Group_VertSpacing
, 0, MUIA_Group_HorizSpacing
, 4,
104 Child
, MakeLabel(MSG_LABEL_BITSPERGUN
),
105 Child
, TX_BitsPerGun
= TextObject
, End
,
106 Child
, MakeLabel(MSG_LABEL_MAXIMUM
),
107 Child
, TX_NumColors
= TextObject
, End
,
109 Child
, g3
= MakeMoni(PSI_FREQS_WIDTH
,PSI_FREQS_HEIGHT
,PSI_FREQS_DEPTH
,psi_freqs_body
,psi_sizes_colors
),
110 Child
, ColGroup(2), MUIA_Group_VertSpacing
, 0, MUIA_Group_HorizSpacing
, 4,
111 Child
, MakeLabel(MSG_LABEL_SCANRATE
),
112 Child
, TX_ScanRate
= TextObject
, End
,
113 Child
, MakeLabel(MSG_LABEL_SCANLINE
),
114 Child
, TX_ScanLine
= TextObject
, End
,
116 TAG_MORE
, msg
->ops_AttrList
);
120 struct DispIDinfo_Data
*data
= INST_DATA(cl
, obj
);
123 set(g1,MUIA_VertDisappear,3);
124 set(g2,MUIA_VertDisappear,2);
125 set(g3,MUIA_VertDisappear,1);
128 data
->TX_Visible
[0] = TX_Visible
[0];
129 data
->TX_Visible
[1] = TX_Visible
[1];
130 data
->TX_Minimum
[0] = TX_Minimum
[0];
131 data
->TX_Minimum
[1] = TX_Minimum
[1];
132 data
->TX_Maximum
[0] = TX_Maximum
[0];
133 data
->TX_Maximum
[1] = TX_Maximum
[1];
134 data
->TX_BitsPerGun
= TX_BitsPerGun
;
135 data
->TX_NumColors
= TX_NumColors
;
136 data
->TX_ScanRate
= TX_ScanRate
;
137 data
->TX_ScanLine
= TX_ScanLine
;
145 /****************************************************************************************/
147 IPTR
DispIDinfo_Set(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
149 #define offset(a,b) (((IPTR)b)-(((IPTR)a)))
150 struct DispIDinfo_Data
*data
= INST_DATA(cl
, obj
);
153 if ((tag
= FindTagItem(MUIA_DispIDinfo_ID
,msg
->ops_AttrList
)))
155 struct DisplayInfo dis
;
156 struct DimensionInfo dim
;
157 struct MonitorInfo mon
;
162 set(data
->TX_Visible
[0], MUIA_String_Contents
, "");
163 set(data
->TX_Visible
[1], MUIA_String_Contents
, "");
164 set(data
->TX_Minimum
[0], MUIA_String_Contents
, "");
165 set(data
->TX_Minimum
[1], MUIA_String_Contents
, "");
166 set(data
->TX_Maximum
[0], MUIA_String_Contents
, "");
167 set(data
->TX_Maximum
[1], MUIA_String_Contents
, "");
168 set(data
->TX_BitsPerGun
, MUIA_String_Contents
, "");
169 set(data
->TX_NumColors
, MUIA_String_Contents
, "");
170 set(data
->TX_ScanRate
, MUIA_String_Contents
, "");
171 set(data
->TX_ScanLine
, MUIA_String_Contents
, "");
173 dislen
= GetDisplayInfoData(0, (char *)&dis
, sizeof(struct DisplayInfo
), DTAG_DISP
,tag
->ti_Data
);
174 dimlen
= GetDisplayInfoData(0, (char *)&dim
, sizeof(struct DimensionInfo
), DTAG_DIMS
,tag
->ti_Data
);
175 monlen
= GetDisplayInfoData(0, (char *)&mon
, sizeof(struct MonitorInfo
), DTAG_MNTR
,tag
->ti_Data
);
177 if (dimlen
> offset(&dim
, &dim
.MaxOScan
))
179 settxt(data
->TX_Visible
[0], RectangleWidth (dim
.MaxOScan
));
180 settxt(data
->TX_Visible
[1], RectangleHeight(dim
.MaxOScan
));
181 settxt(data
->TX_Minimum
[0], dim
.MinRasterWidth
);
182 settxt(data
->TX_Minimum
[1], dim
.MinRasterHeight
);
183 settxt(data
->TX_Maximum
[0], dim
.MaxRasterWidth
);
184 settxt(data
->TX_Maximum
[1], dim
.MaxRasterHeight
);
185 settxt(data
->TX_NumColors
, 1 << dim
.MaxDepth
);
188 if (dislen
> offset(&dis
, &dis
.BlueBits
))
192 data
->TX_BitsPerGun
, MUIM_SetAsString
, MUIA_Text_Contents
, "%ld x %ld x %ld",
193 dis
.RedBits
, dis
.GreenBits
, dis
.BlueBits
197 if (monlen
> offset(&mon
, &mon
.TotalColorClocks
))
199 /* These calculations were taken from ScreenManager by Bernhard "ZZA" Moellemann. Thanks! */
203 ULONG vfreqint
=1000000000L / ((ULONG
)mon
.TotalColorClocks
* 280 * mon
.TotalRows
/ 1000) + 5;
206 data
->TX_ScanRate
, MUIM_SetAsString
, MUIA_Text_Contents
, "%ld.%02ld Hz",
207 vfreqint
/ 1000, (vfreqint
- (vfreqint
/ 1000) * 1000) / 10
210 if (mon
.TotalColorClocks
)
212 ULONG hfreq
= 1000000000L / ((ULONG
)mon
.TotalColorClocks
* 280) + 5;
213 ULONG hfreqint
= hfreq
/ 1000;
216 data
->TX_ScanLine
, MUIM_SetAsString
, MUIA_Text_Contents
, "%ld.%02ld kHz",
217 hfreqint
, (hfreq
-hfreqint
* 1000) / 10
223 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
226 /****************************************************************************************/
228 BOOPSI_DISPATCHER(IPTR
, DispIDinfo_Dispatcher
, cl
, obj
, msg
)
230 switch (msg
->MethodID
)
232 case OM_NEW
: return DispIDinfo_New(cl
, obj
, (APTR
)msg
);
233 case OM_SET
: return DispIDinfo_Set(cl
, obj
, (APTR
)msg
);
235 return DoSuperMethodA(cl
, obj
, msg
);
237 BOOPSI_DISPATCHER_END
239 /****************************************************************************************/
241 VOID
DispIDinfo_Init(VOID
)
243 CL_DispIDinfo
= MUI_CreateCustomClass
245 NULL
, MUIC_Group
, NULL
, sizeof(struct DispIDinfo_Data
), DispIDinfo_Dispatcher
249 /****************************************************************************************/
251 VOID
DispIDinfo_Exit(VOID
)
253 if (CL_DispIDinfo
) MUI_DeleteCustomClass(CL_DispIDinfo
);