grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / prefs / Zune / zunestuff.c
blob04586d1685214e204389665b3579cff8a029605d
1 /*
2 Copyright © 2002-2011, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/exec.h>
7 #include <proto/dos.h>
8 #include <string.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)
26 /* msg=a name to show
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);
36 if (AslBase)
38 struct TagItem frtags[] =
41 { ASLFR_TitleText, (IPTR)msg },
42 { ASLFR_InitialDrawer, (IPTR)dirpart},
43 { ASLFR_InitialFile, (IPTR)filepart},
44 { TAG_MORE, (IPTR)tags }
46 };
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);
57 FreeAslRequest(fr);
58 CloseLibrary(AslBase);
60 return 1;
63 if (AslBase) CloseLibrary(AslBase);
65 return 0;
71 return 0;
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);
81 if (obj)
83 SetAttrs(obj,
84 MUIA_CycleChain, 1,
85 TAG_DONE);
87 return obj;
90 Object *MakeSpacingSlider (void)
92 Object *obj = MUI_MakeObject(MUIO_Slider, (IPTR)"", 0, 9);
93 if (obj)
94 set(obj, MUIA_CycleChain, 1);
95 return obj;
98 Object *MakeCycle (CONST_STRPTR label, CONST_STRPTR entries[])
100 Object *obj = MUI_MakeObject(MUIO_Cycle, (IPTR)label, (IPTR)entries);
101 if (obj)
102 set(obj, MUIA_CycleChain, 1);
103 return obj;
106 Object *MakeCheck (CONST_STRPTR label)
108 Object *obj = MUI_MakeObject(MUIO_Checkmark, (IPTR)label);
109 if (obj)
110 set(obj, MUIA_CycleChain, 1);
111 return obj;
114 Object *MakeBackgroundPopimage(void)
116 return MUI_NewObject(MUIC_Popimage,
117 MUIA_Imageadjust_Type, MUIV_Imageadjust_Type_Background,
118 MUIA_CycleChain, 1,
119 MUIA_Window_Title, (IPTR) _(MSG_ADJUST_BACKGROUND),
120 TAG_DONE);
123 Object *MakePopframe(void)
125 return MUI_NewObject(MUIC_Popframe,
126 MUIA_CycleChain, 1,
127 MUIA_Window_Title, (IPTR) _(MSG_ADJUST_FRAME),
128 TAG_DONE);
131 Object *MakePoppen(void)
133 return MUI_NewObject(MUIC_Poppen,
134 MUIA_CycleChain, 1,
135 MUIA_Window_Title, (IPTR) _(MSG_ADJUST_PEN),
136 TAG_DONE);
139 Object *MakeString(void)
141 return StringObject,
142 StringFrame,
143 MUIA_CycleChain, 1,
144 End;
147 Object *MakePopfont(BOOL fixed)
149 return PopaslObject,
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),
155 End;
158 Object *MakePopfile(BOOL fixed, CONST_STRPTR pattern)
160 return PopaslObject,
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),
167 End;
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)
184 CONST_STRPTR str;
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)
192 CONST_STRPTR str;
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)
200 CONST_STRPTR str;
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)
224 CONST_STRPTR spec;
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)
232 STRPTR spec;
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));