Experiment:
[AROS-Contrib.git] / bgui / Prefs / BGUIPrefs_iff.c
blobf8f4d8b6fc09f2f9baa723e91a36171b4b305419
1 /*
2 * @(#) $Header$
4 * BGUI Prefs Editor
5 * BGUIPrefs_iff.c
7 * (C) Copyright 1998 Manuel Lemos.
8 * (C) Copyright 1996-1997 Respect Software
9 * (C) Copyright 1996-1997 Ian J. Einman.
10 * All Rights Reserved.
12 * $Log$
13 * Revision 42.0 2000/05/09 22:17:05 mlemos
14 * Bumped to revision 42.0 before handing BGUI to AROS team
16 * Revision 41.11 2000/05/09 20:29:54 mlemos
17 * Bumped to revision 41.11
19 * Revision 1.2 2000/05/09 19:56:54 mlemos
20 * Merged with the branch Manuel_Lemos_fixes.
22 * Revision 1.1.2.1 1998/09/20 17:28:48 mlemos
23 * Peter Bornhall sources.
29 extern Object **ar = BGUIPrefsObjs;
30 extern Object *BGUIPrefsObjs[ BGP_NUMGADS ];
32 // GROUP DEFAULTS
33 extern ULONG grp_frmtype,
34 grp_recessed,
35 grp_vspnarrow,
36 grp_hspnarrow,
37 grp_vspnormal,
38 grp_hspnormal,
39 grp_vspwide,
40 grp_hspwide,
42 // BUTTON DEFAULTS
43 but_frmtype,
44 but_recessed,
46 // STRING DEFAULTS
47 str_frmtype,
48 str_recessed,
50 // CHECKBOX DEFAULTS
51 chk_frmtype,
52 chk_recessed,
54 // CYCLE DEFAULTS
55 cyc_frmtype,
56 cyc_recessed,
57 cyc_popup,
58 cyc_popactive,
60 // INFO DEFAULTS
61 inf_frmtype,
62 inf_recessed,
64 // PROGRESS DEFAULTS
65 prg_frmtype,
66 prg_recessed,
68 // INDICATOR DEFAULTS
69 ind_frmtype,
70 ind_recessed;
73 struct TagItem *
74 CloneTagList( ULONG t, ... )
76 return CloneTagItems( ( struct TagItem * )&t );
80 void
81 SaveTagList( struct IFFHandle *iff, ULONG type, struct TagItem *tags )
83 struct TagItem *tag;
84 ULONG zero = TAG_DONE;
86 PushChunk( iff, ID_BGUI, ID_DTAG, IFFSIZE_UNKNOWN );
87 WriteChunkBytes( iff, ( UBYTE * )&type, sizeof( ULONG ) );
89 while( tag = NextTagItem( &tags ) ) {
91 WriteChunkBytes( iff, ( UBYTE * )tag, sizeof( struct TagItem ) );
95 WriteChunkBytes( iff, ( UBYTE * )&zero, sizeof( ULONG ) );
96 PopChunk( iff );
101 void
102 SaveBGUIPrefs( char *dirname, char *name )
104 BPTR dir,
105 olddir;
106 struct IFFHandle *iff;
107 struct TagItem *objecttags = NULL;
109 dir = Lock( dirname, ACCESS_READ );
111 if( !dir ) dir = CreateDir( dirname );
113 if( dir ) {
115 olddir = CurrentDir( dir );
117 if( iff = AllocIFF() ) {
119 if( iff->iff_Stream = Open( name, MODE_NEWFILE ) ) {
121 InitIFFasDOS( iff );
122 if( OpenIFF( iff, IFFF_WRITE ) == 0 ) {
124 PushChunk( iff, ID_BGUI, ID_FORM, IFFSIZE_UNKNOWN );
126 // GROUP
127 objecttags = CloneTagList(
128 FRM_DefaultType, grp_frmtype,
129 FRM_Recessed, grp_recessed,
130 GROUP_DefVSpaceNarrow, grp_vspnarrow,
131 GROUP_DefHSpaceNarrow, grp_hspnarrow,
132 GROUP_DefVSpaceNormal, grp_vspnormal,
133 GROUP_DefHSpaceNormal, grp_hspnormal,
134 GROUP_DefVSpaceWide, grp_vspwide,
135 GROUP_DefHSpaceWide, grp_hspwide,
136 TAG_DONE
138 SaveTagList( iff, BGUI_GROUP_GADGET, objecttags );
140 // BUTTON
141 objecttags = CloneTagList(
142 FRM_Type, but_frmtype,
143 FRM_Recessed, but_recessed,
144 TAG_DONE
146 SaveTagList( iff, BGUI_BUTTON_GADGET, objecttags );
148 // STRING
149 objecttags = CloneTagList(
150 FRM_Type, str_frmtype,
151 FRM_Recessed, str_recessed,
152 TAG_DONE
154 SaveTagList( iff, BGUI_STRING_GADGET, objecttags );
156 // CHECKBOX
157 objecttags = CloneTagList(
158 FRM_Type, chk_frmtype,
159 FRM_Recessed, chk_recessed,
160 TAG_DONE
162 SaveTagList( iff, BGUI_CHECKBOX_GADGET, objecttags );
164 // CYCLE
165 objecttags = CloneTagList(
166 FRM_Type, cyc_frmtype,
167 FRM_Recessed, cyc_recessed,
168 CYC_PopActive, cyc_popactive,
169 CYC_Popup, cyc_popup,
170 TAG_DONE
172 SaveTagList( iff, BGUI_CYCLE_GADGET, objecttags );
174 // INFO
175 objecttags = CloneTagList(
176 FRM_DefaultType, inf_frmtype,
177 FRM_Recessed, inf_recessed,
178 TAG_DONE
180 SaveTagList( iff, BGUI_INFO_GADGET, objecttags );
182 // PROGRESS
183 objecttags = CloneTagList(
184 FRM_Type, prg_frmtype,
185 FRM_Recessed, prg_recessed,
186 TAG_DONE
188 SaveTagList( iff, BGUI_PROGRESS_GADGET, objecttags );
190 // INDICATOR
191 objecttags = CloneTagList(
192 FRM_DefaultType, ind_frmtype,
193 FRM_Recessed, ind_recessed,
194 TAG_DONE
196 SaveTagList( iff, BGUI_INDICATOR_GADGET, objecttags );
198 PopChunk( iff );
199 CloseIFF( iff );
201 Close( iff->iff_Stream );
203 FreeIFF( iff );
205 CurrentDir( olddir );
206 UnLock( dir );