2 Copyright © 2002-2011, The AROS Development Team. All rights reserved.
6 #include <proto/exec.h>
10 #include <libraries/mui.h>
12 #include <proto/alib.h>
13 #include <proto/intuition.h>
14 #include <proto/muimaster.h>
15 #include <proto/asl.h>
17 #include "zunestuff.h"
20 /****************************************************************
21 aslfilerequest for load/save - buffer overflow safe
22 *****************************************************************/
23 long aslfilerequest(char *msg
,char *dirpart
,char *filepart
,char *fullname
, struct TagItem
*tags
)
27 tags=can be 0 or some additional tags
28 dirpart= a pointer to a buffer of 500 bytes that receive the selected directory
29 filepart= a pointer to a buffer of 500 bytes that receive the selected filename
30 fullname= a pointer to a buffer of 1000 bytes that receive the selected full filename */
32 struct FileRequester
*fr
;
33 struct Library
*AslBase
;
34 AslBase
= OpenLibrary("asl.library", 37L);
38 struct TagItem frtags
[] =
41 { ASLFR_TitleText
, (IPTR
)msg
},
42 { ASLFR_InitialDrawer
, (IPTR
)dirpart
},
43 { ASLFR_InitialFile
, (IPTR
)filepart
},
44 { TAG_MORE
, (IPTR
)tags
}
49 if ( (fr
= (struct FileRequester
*) AllocAslRequest(ASL_FileRequest
, frtags
) ) )
51 if (AslRequest(fr
, NULL
))
53 strncpy(dirpart
,fr
->fr_Drawer
,498);
54 strncpy(filepart
,fr
->fr_File
,498);
55 strncpy(fullname
,dirpart
,498);
56 AddPart(fullname
,filepart
,998);
58 CloseLibrary(AslBase
);
63 if (AslBase
) CloseLibrary(AslBase
);
75 /****************************************************************
76 Create a button (within the cycle chain)
77 *****************************************************************/
78 Object
*MakeButton(CONST_STRPTR str
)
80 Object
*obj
= MUI_MakeObject(MUIO_Button
, (IPTR
)str
);
90 Object
*MakeSpacingSlider (void)
92 Object
*obj
= MUI_MakeObject(MUIO_Slider
, (IPTR
)"", 0, 9);
94 set(obj
, MUIA_CycleChain
, 1);
98 Object
*MakeCycle (CONST_STRPTR label
, CONST_STRPTR entries
[])
100 Object
*obj
= MUI_MakeObject(MUIO_Cycle
, (IPTR
)label
, (IPTR
)entries
);
102 set(obj
, MUIA_CycleChain
, 1);
106 Object
*MakeCheck (CONST_STRPTR label
)
108 Object
*obj
= MUI_MakeObject(MUIO_Checkmark
, (IPTR
)label
);
110 set(obj
, MUIA_CycleChain
, 1);
114 Object
*MakeBackgroundPopimage(void)
116 return MUI_NewObject(MUIC_Popimage
,
117 MUIA_Imageadjust_Type
, MUIV_Imageadjust_Type_Background
,
119 MUIA_Window_Title
, (IPTR
) _(MSG_ADJUST_BACKGROUND
),
123 Object
*MakePopframe(void)
125 return MUI_NewObject(MUIC_Popframe
,
127 MUIA_Window_Title
, (IPTR
) _(MSG_ADJUST_FRAME
),
131 Object
*MakePoppen(void)
133 return MUI_NewObject(MUIC_Poppen
,
135 MUIA_Window_Title
, (IPTR
) _(MSG_ADJUST_PEN
),
139 Object
*MakeString(void)
147 Object
*MakePopfont(BOOL fixed
)
150 MUIA_Popasl_Type
, ASL_FontRequest
,
151 ASLFO_MaxHeight
, 100,
152 ASLFO_FixedWidthOnly
, fixed
? TRUE
: FALSE
,
153 MUIA_Popstring_String
, (IPTR
) MakeString(),
154 MUIA_Popstring_Button
, (IPTR
) PopButton(MUII_PopUp
),
158 Object
*MakePopfile(BOOL fixed
, CONST_STRPTR pattern
)
161 ASLFR_InitialPattern
, (IPTR
) pattern
,
162 ASLFR_RejectIcons
, TRUE
,
163 ASLFO_MaxHeight
, 100,
164 ASLFO_FixedWidthOnly
, fixed
? TRUE
: FALSE
,
165 MUIA_Popstring_String
, (IPTR
) MakeString(),
166 MUIA_Popstring_Button
, (IPTR
) PopButton(MUII_PopFile
),
170 void SliderToConfig (Object
*slider
, Object
*configdata
, ULONG cfg
)
172 DoMethod(configdata
, MUIM_Configdata_SetULong
, cfg
,
173 XGET(slider
, MUIA_Numeric_Value
));
176 void CheckmarkToConfig (Object
*checkmark
, Object
*configdata
, ULONG cfg
)
178 DoMethod(configdata
, MUIM_Configdata_SetULong
, cfg
,
179 XGET(checkmark
, MUIA_Selected
));
182 void FrameToConfig (Object
*popframe
, Object
*configdata
, ULONG cfg
)
186 str
= (CONST_STRPTR
)XGET(popframe
, MUIA_Framedisplay_Spec
);
187 DoMethod(configdata
, MUIM_Configdata_SetFramespec
, cfg
, (IPTR
)str
);
190 void PenToConfig (Object
*poppen
, Object
*configdata
, ULONG cfg
)
194 str
= (CONST_STRPTR
)XGET(poppen
, MUIA_Pendisplay_Spec
);
195 DoMethod(configdata
, MUIM_Configdata_SetPenspec
, cfg
, (IPTR
)str
);
198 void StringToConfig (Object
*string
, Object
*configdata
, ULONG cfg
)
202 str
= (CONST_STRPTR
)XGET(string
, MUIA_String_Contents
);
203 DoMethod(configdata
, MUIM_Configdata_SetString
, cfg
, (IPTR
)str
);
206 void CycleToConfig (Object
*cycle
, Object
*configdata
, ULONG cfg
)
208 DoMethod(configdata
, MUIM_Configdata_SetULong
, cfg
,
209 XGET(cycle
, MUIA_Cycle_Active
));
212 void ConfigToSlider (Object
*configdata
, ULONG cfg
, Object
*slider
)
214 setslider(slider
, DoMethod(configdata
, MUIM_Configdata_GetULong
, cfg
));
217 void ConfigToCheckmark (Object
*configdata
, ULONG cfg
, Object
*checkmark
)
219 setcheckmark(checkmark
, DoMethod(configdata
, MUIM_Configdata_GetULong
, cfg
));
222 void ConfigToFrame (Object
*configdata
, ULONG cfg
, Object
*popframe
)
226 spec
= (CONST_STRPTR
)DoMethod(configdata
, MUIM_Configdata_GetString
, cfg
);
227 set(popframe
, MUIA_Framedisplay_Spec
, (IPTR
)spec
);
230 void ConfigToPen (Object
*configdata
, ULONG cfg
, Object
*poppen
)
234 spec
= (STRPTR
)DoMethod(configdata
, MUIM_Configdata_GetString
, cfg
);
235 set(poppen
, MUIA_Pendisplay_Spec
, (IPTR
)spec
);
238 void ConfigToCycle (Object
*configdata
, ULONG cfg
, Object
*cycle
)
240 setcycle(cycle
, DoMethod(configdata
, MUIM_Configdata_GetULong
, cfg
));
243 void ConfigToString (Object
*configdata
, ULONG cfg
, Object
*string
)
245 setstring(string
, DoMethod(configdata
, MUIM_Configdata_GetString
, cfg
));