1 /*********************************************/
3 /* Designer (C) Ian OConnor 1994 */
5 /* Designer Produced C include file */
7 /*********************************************/
9 #include <exec/types.h>
10 #include <libraries/locale.h>
11 #include <exec/memory.h>
12 #include <dos/dosextens.h>
13 #include <intuition/screens.h>
14 #include <intuition/intuition.h>
15 #include <intuition/gadgetclass.h>
16 #include <libraries/gadtools.h>
17 #include <diskfont/diskfont.h>
18 #include <utility/utility.h>
19 #include <graphics/gfxbase.h>
20 #include <workbench/workbench.h>
21 #include <graphics/scale.h>
22 #include <clib/locale_protos.h>
23 #include <clib/exec_protos.h>
24 #include <clib/wb_protos.h>
25 #include <clib/intuition_protos.h>
26 #include <clib/gadtools_protos.h>
27 #include <clib/graphics_protos.h>
28 #include <clib/utility_protos.h>
30 #include <clib/diskfont_protos.h>
32 #include "GUI.extras.h"
38 (GTBB_Recessed
), TRUE
,
42 UBYTE Win0FirstScaleTexts
= 0;
44 UBYTE Win0TextsLocalized
= 0;
46 struct IntuiText Win0Texts
[] =
48 1, 3, JAM1
, 230, 101, NULL
, (UBYTE
*)Win0Texts1
, NULL
51 struct Window
*Win0
= NULL
;
54 struct Gadget
*Win0GList
;
55 struct Gadget
*Win0Gadgets
[15];
56 UBYTE Win0FirstRun
= 0;
58 STRPTR Win0_formatLabels
[] =
60 (STRPTR
)Win0_formatString0
,
61 (STRPTR
)Win0_formatString1
,
65 ULONG Win0GadgetTags
[] =
67 (GTLV_ShowSelected
), 0,
71 (GTLV_ShowSelected
), 0,
75 (GTSL_LevelFormat
), 0,
76 (GTSL_MaxLevelLen
), 64,
84 (GTTX_CopyText
), TRUE
,
85 (GT_TagBase
+74), 0, /* Justification in V39 */
87 (GTTX_CopyText
), TRUE
,
88 (GT_TagBase
+74), 0, /* Justification in V39 */
93 (GTSL_LevelFormat
), 0,
94 (GTSL_MaxLevelLen
), 64,
101 (GT_Underscore
), '_',
104 (GT_TagBase
+74), 0, /* Justification in V39 */
105 (GT_TagBase
+75), 0, /* String Formatting */
107 (GTST_String
), (IPTR
)"NewSample.AIFC",
108 (GTST_MaxChars
), 1024,
109 (GT_Underscore
), '_',
111 (GT_Underscore
), '_',
113 (GT_Underscore
), '_',
115 (GT_Underscore
), '_',
118 (GT_TagBase
+74), 0, /* Justification in V39 */
120 (GT_Underscore
), '_',
122 (GTCY_Labels
), (IPTR
)&Win0_formatLabels
[0],
126 UWORD Win0GadgetTypes
[] =
145 struct NewGadget Win0NewGadgets
[] =
147 16, 24, 140, 28, (UBYTE
*)Win0_srclistString
, NULL
, Win0_srclist
, 4, NULL
, (APTR
)&Win0GadgetTags
[0],
148 163, 24, 140, 28, (UBYTE
*)Win0_dstlistString
, NULL
, Win0_dstlist
, 4, NULL
, (APTR
)&Win0GadgetTags
[7],
149 163, 54, 93, 14, (UBYTE
*)Win0_volsliderString
, NULL
, Win0_volslider
, 1, NULL
, (APTR
)&Win0GadgetTags
[14],
150 312, 54, 267, 14, (UBYTE
*)Win0_ambuttonString
, NULL
, Win0_ambutton
, 16, NULL
, (APTR
)&Win0GadgetTags
[27],
151 317, 26, 258, 12, (UBYTE
*)Win0_amtext1String
, NULL
, Win0_amtext1
, 4, NULL
, (APTR
)&Win0GadgetTags
[30],
152 317, 38, 258, 12, (UBYTE
*)Win0_amtext2String
, NULL
, Win0_amtext2
, 1, NULL
, (APTR
)&Win0GadgetTags
[35],
153 163, 70, 93, 14, (UBYTE
*)Win0_gainsliderString
, NULL
, Win0_gainslider
, 1, NULL
, (APTR
)&Win0GadgetTags
[40],
154 163, 98, 61, 14, (UBYTE
*)Win0_durationString
, NULL
, Win0_duration
, 1, NULL
, (APTR
)&Win0GadgetTags
[59],
155 163, 114, 141, 14, (UBYTE
*)Win0_lengthString
, NULL
, Win0_length
, 1, NULL
, (APTR
)&Win0GadgetTags
[64],
156 163, 130, 416, 14, (UBYTE
*)Win0_filenameString
, NULL
, Win0_filename
, 1, NULL
, (APTR
)&Win0GadgetTags
[71],
157 16, 130, 141, 14, (UBYTE
*)Win0_fnbuttonString
, NULL
, Win0_fnbutton
, 16, NULL
, (APTR
)&Win0GadgetTags
[78],
158 312, 98, 267, 14, (UBYTE
*)Win0_createString
, NULL
, Win0_create
, 16, NULL
, (APTR
)&Win0GadgetTags
[81],
159 312, 114, 267, 14, (UBYTE
*)Win0_beginString
, NULL
, Win0_begin
, 16, NULL
, (APTR
)&Win0GadgetTags
[84],
160 401, 146, 70, 14, (UBYTE
*)Win0_secleftString
, NULL
, Win0_secleft
, 2, NULL
, (APTR
)&Win0GadgetTags
[87],
161 163, 146, 230, 14, (UBYTE
*)Win0_formatString
, NULL
, Win0_format
, 1, NULL
, (APTR
)&Win0GadgetTags
[92],
164 struct Library
*AslBase
= NULL
;
165 struct Library
*DiskfontBase
= NULL
;
166 struct Library
*GadToolsBase
= NULL
;
167 struct GfxBase
*GfxBase
= NULL
;
168 struct IntuitionBase
*IntuitionBase
= NULL
;
169 struct Library
*UtilityBase
= NULL
;
170 struct LocaleBase
*LocaleBase
= NULL
;
171 struct Catalog
*HardDiskRecord_Catalog
= NULL
;
172 STRPTR HardDiskRecord_BuiltInLanguage
= (STRPTR
)"english";
173 LONG HardDiskRecord_Version
= 0;
175 STRPTR HardDiskRecord_Strings
[] =
177 (STRPTR
)"Please select an audio mode!",
178 (STRPTR
)"File has not been prepared yet!",
180 (STRPTR
)"Can't allocate audio hardware.",
181 (STRPTR
)"Unknown error.",
185 (STRPTR
)"IFF-AIFC (Not compr.)",
190 (STRPTR
)"Loopback dest.",
191 (STRPTR
)"Loopback volume",
192 (STRPTR
)"Select audio mode...",
195 (STRPTR
)"Input gain",
196 (STRPTR
)"Sample duration",
197 (STRPTR
)"Sample length",
199 (STRPTR
)"File name...",
200 (STRPTR
)"Prepare sample file",
201 (STRPTR
)"Begin recording",
202 (STRPTR
)"seconds left",
203 (STRPTR
)"File format",
204 (STRPTR
)"AHI Hard disk record example",
205 (STRPTR
)"HardDiskRecord",
208 void RendWindowWin0( struct Window
*Win
, void *vi
)
213 scalex
= 65535*Win
->WScreen
->RastPort
.Font
->tf_XSize
/8;
214 scaley
= 65535*Win
->WScreen
->RastPort
.Font
->tf_YSize
/8;
215 offx
= Win
->BorderLeft
;
216 offy
= Win
->BorderTop
;
219 BevelTags
[3] = (IPTR
)vi
;
220 DrawBevelBoxA( Win
->RPort
, 8*scalex
/65535+offx
,4*scaley
/65535+offy
,579*scalex
/65535,85*scaley
/65535, (struct TagItem
*)(&BevelTags
[0]));
221 DrawBevelBoxA( Win
->RPort
, 8*scalex
/65535+offx
,93*scaley
/65535+offy
,579*scalex
/65535,72*scaley
/65535, (struct TagItem
*)(&BevelTags
[0]));
222 DrawBevelBoxA( Win
->RPort
, 312*scalex
/65535+offx
,24*scaley
/65535+offy
,267*scalex
/65535,28*scaley
/65535, (struct TagItem
*)(&BevelTags
[0]));
223 for( loop
=0; loop
<1; loop
++)
225 if (Win0Texts
[loop
].ITextFont
==NULL
)
226 Win0Texts
[loop
].ITextFont
=Win
->WScreen
->Font
;
227 if (Win0FirstScaleTexts
==0)
229 Win0Texts
[loop
].LeftEdge
= Win0Texts
[loop
].LeftEdge
*scalex
/65535;
230 Win0Texts
[loop
].TopEdge
= Win0Texts
[loop
].TopEdge
*scaley
/65535;
233 Win0FirstScaleTexts
= 1;
234 if (Win0TextsLocalized
== 0)
236 Win0TextsLocalized
= 1;
237 for( loop
=0; loop
<1; loop
++)
238 Win0Texts
[loop
].IText
= GetString((LONG
)Win0Texts
[loop
].IText
);
240 PrintIText( Win
->RPort
, Win0Texts
, offx
, offy
);
244 int OpenWindowWin0( STRPTR ScrName
)
249 struct NewGadget newgad
;
254 if (Win0FirstRun
== 0)
257 for ( loop
=0; loop
<2; loop
++)
258 Win0_formatLabels
[loop
] = GetString((LONG
)Win0_formatLabels
[loop
]);
259 Win0GadgetTags
[15] = (IPTR
)GetString(Win0_volsliderLevelFormat
);
260 Win0GadgetTags
[47] = (IPTR
)GetString(Win0_gainsliderLevelFormat
);
261 Win0GadgetTags
[69] = (IPTR
)GetString(Win0_lengthStringFormat
);
265 Scr
= LockPubScreen(ScrName
);
267 Scr
= LockPubScreen(NULL
);
270 offx
= Scr
->WBorLeft
;
271 offy
= Scr
->WBorTop
+ Scr
->Font
->ta_YSize
+1;
272 scalex
= 65535*Scr
->RastPort
.Font
->tf_XSize
/8;
273 scaley
= 65535*Scr
->RastPort
.Font
->tf_YSize
/8;
274 if (NULL
!= ( Win0VisualInfo
= GetVisualInfoA( Scr
, NULL
)))
276 if (NULL
!= ( Win0DrawInfo
= GetScreenDrawInfo( Scr
)))
279 Gad
= CreateContext( &Win0GList
);
280 for ( loop
=0 ; loop
<15 ; loop
++ )
281 if (Win0GadgetTypes
[loop
] != 198)
283 CopyMem((char * )&Win0NewGadgets
[loop
], ( char * )&newgad
, (long)sizeof( struct NewGadget
));
284 newgad
.ng_VisualInfo
= Win0VisualInfo
;
285 newgad
.ng_LeftEdge
= newgad
.ng_LeftEdge
*scalex
/65535;
286 newgad
.ng_TopEdge
= newgad
.ng_TopEdge
*scaley
/65535;
287 if (Win0GadgetTypes
[loop
] != GENERIC_KIND
)
289 newgad
.ng_Width
= newgad
.ng_Width
*scalex
/65535;
290 newgad
.ng_Height
= newgad
.ng_Height
*scaley
/65535;
292 newgad
.ng_TextAttr
= Scr
->Font
;
293 newgad
.ng_LeftEdge
+= offx
;
294 newgad
.ng_TopEdge
+= offy
;
295 if ( newgad
.ng_GadgetText
!= (UBYTE
*)~0)
296 newgad
.ng_GadgetText
= GetString((LONG
)newgad
.ng_GadgetText
);
298 newgad
.ng_GadgetText
= (UBYTE
*)0;
299 Win0Gadgets
[ loop
] = NULL
;
300 Win0Gadgets
[ newgad
.ng_GadgetID
- Win0FirstID
] = Gad
= CreateGadgetA( Win0GadgetTypes
[loop
], Gad
, &newgad
, (struct TagItem
*) newgad
.ng_UserData
);
302 for ( loop
=0 ; loop
<15 ; loop
++ )
303 if (Win0GadgetTypes
[loop
] == 198)
305 Win0Gadgets
[ loop
] = NULL
;
308 Win0Gadgets
[ loop
] = Gad2
= (struct Gadget
*) NewObjectA( (struct IClass
*)Cla
, Win0NewGadgets
[ loop
].ng_GadgetText
, (struct TagItem
*)Win0NewGadgets
[ loop
].ng_UserData
);
312 if (NULL
!= (Win0
= OpenWindowTags( NULL
, (WA_Left
), 7,
314 (WA_InnerWidth
), 595*scalex
/65535,
315 (WA_InnerHeight
), 169*scaley
/65535,
316 (WA_Title
), (LONG
)GetString(Win0Title
),
317 (WA_ScreenTitle
), (LONG
)GetString(Win0ScreenTitle
),
321 (WA_MaxHeight
), 1200,
323 (WA_DepthGadget
), TRUE
,
324 (WA_CloseGadget
), TRUE
,
326 (WA_Dummy
+0x30), TRUE
,
327 (WA_SmartRefresh
), TRUE
,
328 (WA_AutoAdjust
), TRUE
,
329 (WA_Gadgets
), Win0GList
,
330 (WA_PubScreen
) , (LONG
)Scr
,
334 RendWindowWin0(Win0
, Win0VisualInfo
);
335 GT_RefreshWindow( Win0
, NULL
);
336 RefreshGList( Win0GList
, Win0
, NULL
, ~0);
337 UnlockPubScreen( NULL
, Scr
);
341 FreeGadgets( Win0GList
);
342 FreeScreenDrawInfo( Scr
, (struct DrawInfo
*) Win0DrawInfo
);
344 FreeVisualInfo( Win0VisualInfo
);
346 UnlockPubScreen( NULL
, Scr
);
352 ActivateWindow(Win0
);
358 void CloseWindowWin0( void )
362 FreeScreenDrawInfo( Win0
->WScreen
, (struct DrawInfo
*) Win0DrawInfo
);
366 FreeVisualInfo( Win0VisualInfo
);
367 FreeGadgets( Win0GList
);
373 LocaleBase
= (struct LocaleBase
* )OpenLibrary((UBYTE
*)"locale.library", 38);
374 if ( NULL
!= (AslBase
= OpenLibrary((UBYTE
*)"asl.library" , 37)))
375 if ( NULL
!= (DiskfontBase
= OpenLibrary((UBYTE
*)"diskfont.library" , 36)))
376 if ( NULL
!= (GadToolsBase
= OpenLibrary((UBYTE
*)"gadtools.library" , 37)))
377 if ( NULL
!= (GfxBase
= (struct GfxBase
* )OpenLibrary((UBYTE
*)"graphics.library" , 37)))
378 if ( NULL
!= (IntuitionBase
= (struct IntuitionBase
* )OpenLibrary((UBYTE
*)"intuition.library" , 37)))
379 if ( NULL
!= (UtilityBase
= OpenLibrary((UBYTE
*)"utility.library" , 37)))
385 void CloseLibs( void )
387 if (NULL
!= AslBase
)
388 CloseLibrary( AslBase
);
389 if (NULL
!= DiskfontBase
)
390 CloseLibrary( DiskfontBase
);
391 if (NULL
!= GadToolsBase
)
392 CloseLibrary( GadToolsBase
);
393 if (NULL
!= GfxBase
)
394 CloseLibrary( ( struct Library
* )GfxBase
);
395 if (NULL
!= IntuitionBase
)
396 CloseLibrary( ( struct Library
* )IntuitionBase
);
397 if (NULL
!= UtilityBase
)
398 CloseLibrary( UtilityBase
);
399 if (NULL
!= LocaleBase
)
400 CloseLibrary( ( struct Library
* )LocaleBase
);
403 STRPTR
GetString(LONG strnum
)
405 if (HardDiskRecord_Catalog
== NULL
)
406 return(HardDiskRecord_Strings
[strnum
]);
407 return(GetCatalogStr(HardDiskRecord_Catalog
, strnum
, HardDiskRecord_Strings
[strnum
]));
410 void CloseHardDiskRecordCatalog(void)
412 if (LocaleBase
!= NULL
)
413 CloseCatalog(HardDiskRecord_Catalog
);
414 HardDiskRecord_Catalog
= NULL
;
417 void OpenHardDiskRecordCatalog(struct Locale
*loc
, STRPTR language
)
420 if (language
== NULL
)
425 tagarg
= (LONG
)language
;
427 if (LocaleBase
!= NULL
&& HardDiskRecord_Catalog
== NULL
)
428 HardDiskRecord_Catalog
= OpenCatalog(loc
, (STRPTR
) "HardDiskRecord.catalog",
429 OC_BuiltInLanguage
, HardDiskRecord_BuiltInLanguage
,
431 OC_Version
, HardDiskRecord_Version
,