added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / system / AboutAROS / aboutaros.c
blob32ed657782bebf7d99cdde2ed13ae7563e25c98a
1 /*
2 Copyright © 2003-2004, The AROS Development Team. All rights reserved.
3 This file is part of the About program, which is distributed under
4 the terms of version 2 of the GNU General Public License.
6 $Id$
7 */
9 #define MUIMASTER_YES_INLINE_STDARG
11 #include <aros/debug.h>
12 #include <aros/build.h>
13 #include <aros/inquire.h>
14 #include <exec/types.h>
15 #include <utility/tagitem.h>
16 #include <libraries/mui.h>
18 #include <proto/aros.h>
19 #include <proto/exec.h>
20 #include <proto/dos.h>
21 #include <proto/intuition.h>
22 #include <proto/utility.h>
23 #include <proto/muimaster.h>
24 #include <proto/workbench.h>
26 #include <zune/aboutwindow.h>
27 #include <zune/customclasses.h>
30 #include <string.h>
32 #include "aboutaros.h"
33 #include "locale.h"
34 #include "logotype.h"
36 #include "authors.h"
37 #include "sponsors.h"
38 #include "acknowledgements.h"
40 #define VERSION "$VER: AboutAROS 0.1 ("ADATE") ©AROS Dev Team"
42 #define WINDOW_BG ((IPTR) "2:00000000,00000000,00000000")
43 #define REGISTER_BG ((IPTR) "7:V,00000000,92000000,91000000-00000000,82000000,81000000")
44 #define LIST_BG ((IPTR) "2:00000000,82000000,81000000")
46 #define SETUP_INST_DATA struct AboutAROS_DATA *data = INST_DATA(CLASS, self)
48 /*** Private methods ********************************************************/
49 #define MUIM_AboutAROS_ShowLicense (TAG_USER | 0x20000000)
51 /*** Instance Data **********************************************************/
52 struct AboutAROS_DATA
54 Object *aad_Window;
55 APTR aad_Pool;
58 /*** Utility Functions ******************************************************/
59 STRPTR Section2Name(ULONG section)
61 switch (section)
63 case SID_COORDINATION: return _(MSG_SECTION_COORDINATION);
64 case SID_EVANGELISM: return _(MSG_SECTION_EVANGELISM);
65 case SID_HIDD: return _(MSG_SECTION_HIDD);
66 case SID_INTUITION: return _(MSG_SECTION_INTUITION);
67 case SID_GRAPHICS: return _(MSG_SECTION_GRAPHICS);
68 case SID_SHELL_COMMANDS: return _(MSG_SECTION_SHELL_COMMANDS);
69 case SID_WORKBENCH: return _(MSG_SECTION_WORKBENCH);
70 case SID_TOOLS: return _(MSG_SECTION_TOOLS);
71 case SID_PREFERENCES: return _(MSG_SECTION_PREFERENCES);
72 case SID_BGUI: return _(MSG_SECTION_BGUI);
73 case SID_ZUNE: return _(MSG_SECTION_ZUNE);
74 case SID_KERNEL: return _(MSG_SECTION_KERNEL);
75 case SID_DOS: return _(MSG_SECTION_DOS);
76 case SID_LIBC_POSIX: return _(MSG_SECTION_LIBC_POSIX);
77 case SID_DOCUMENTATION: return _(MSG_SECTION_DOCUMENTATION);
78 case SID_TRANSLATION: return _(MSG_SECTION_TRANSLATION);
79 case SID_ARTISTRY: return _(MSG_SECTION_ARTISTRY);
80 case SID_WEBSITE: return _(MSG_SECTION_WEBSITE);
81 case SID_DATATYPES: return _(MSG_SECTION_DATATYPES);
82 default: return NULL;
86 BOOL NamesToList
88 Object *list, struct TagItem *tags, struct AboutAROS_DATA *data
91 const struct TagItem *tstate = tags;
92 struct TagItem *tag = NULL;
93 BOOL success = TRUE;
94 IPTR section = SID_NONE;
95 STRPTR sectionName = NULL;
96 BOOL sectionFirst = TRUE;
97 STRPTR name;
98 STRPTR buffer;
99 ULONG length = 0;
101 if (tags == NULL) return FALSE;
103 while ((tag = NextTagItem(&tstate)) != NULL && success == TRUE)
105 switch (tag->ti_Tag)
107 case SECTION_ID:
108 section = tag->ti_Data;
109 sectionName = Section2Name(section);
111 if (sectionName != NULL)
113 sectionFirst
114 ? sectionFirst = FALSE
115 : DoMethod
117 list, MUIM_List_InsertSingle, (IPTR) "",
118 MUIV_List_Insert_Bottom
121 length = strlen(MUIX_B) + strlen(sectionName) + 1;
122 buffer = AllocPooled(data->aad_Pool, length);
123 if (buffer != NULL)
125 buffer[0] = '\0';
126 strcat(buffer, MUIX_B);
127 strcat(buffer, sectionName);
129 DoMethod
131 list, MUIM_List_InsertSingle,
132 (IPTR) buffer, MUIV_List_Insert_Bottom
135 else
137 success = FALSE;
138 break;
142 break;
144 case NAME_STRING:
145 name = (STRPTR) tag->ti_Data;
147 length = strlen(name) + 1;
148 if (sectionName != NULL) length += 4;
150 buffer = AllocPooled(data->aad_Pool, length);
151 if (buffer != NULL)
153 buffer[0] = '\0';
154 if (sectionName != NULL) strcat(buffer, " ");
155 strcat(buffer, name);
157 DoMethod
159 list, MUIM_List_InsertSingle,
160 (IPTR) buffer, MUIV_List_Insert_Bottom
163 else
165 success = FALSE;
166 break;
169 break;
173 return success;
176 /*** Methods ****************************************************************/
177 Object *AboutAROS__OM_NEW(Class *CLASS, Object *self, struct opSet *message)
179 Object *window,
180 *licenseButton,
181 *authorsList,
182 *sponsorsList,
183 *acknowledgementsList;
185 STRPTR pages[4] = { NULL };
186 STRPTR builddate;
187 STRPTR variant;
188 BOOL showLogotype;
189 BPTR lock;
190 APTR pool;
192 /* Allocate memory pool ------------------------------------------------*/
193 pool = CreatePool(MEMF_ANY, 4096, 4096);
194 if (pool == NULL) return NULL;
196 /* Check if the logotype is available ----------------------------------*/
197 if ((lock = Lock(LOGOTYPE_IMAGE, ACCESS_READ)) != NULL)
199 showLogotype = TRUE;
200 UnLock(lock);
202 else
204 showLogotype = FALSE;
207 /* Retrieve the build date and the variant name ------------------------*/
208 ArosInquire(AI_ArosBuildDate, (IPTR) &builddate,
209 AI_ArosVariant, (IPTR) &variant,
210 TAG_DONE);
212 /* Initialize page labels ----------------------------------------------*/
213 pages[0] = _(MSG_PAGE_AUTHORS);
214 pages[1] = _(MSG_PAGE_SPONSORS);
215 pages[2] = _(MSG_PAGE_ACKNOWLEDGEMENTS);
217 /* Create application and window objects -------------------------------*/
218 self = (Object *) DoSuperNewTags
220 CLASS, self, NULL,
222 MUIA_Application_Title, __(MSG_TITLE),
223 MUIA_Application_Version, (IPTR)VERSION,
224 MUIA_Application_Copyright, (IPTR)"© 2006, The AROS Development Team",
225 MUIA_Application_Description, __(MSG_TITLE),
226 MUIA_Application_Base, (IPTR) "ABOUTAROS",
227 SubWindow, (IPTR) (window = WindowObject,
228 MUIA_Window_Title, __(MSG_TITLE),
229 MUIA_Window_Width, MUIV_Window_Width_MinMax(0),
230 MUIA_Window_NoMenus, TRUE,
231 MUIA_Window_Activate, TRUE,
232 MUIA_Window_ID, MAKE_ID('A','B','W','N'),
233 WindowContents, (IPTR) VGroup,
234 InnerSpacing(0, 0),
235 GroupSpacing(2),
236 MUIA_Background, WINDOW_BG,
238 Child, showLogotype
239 ? (IPTR) ImageObject,
240 MUIA_Image_Spec, (IPTR) "3:"LOGOTYPE_IMAGE,
242 : (IPTR) TextObject,
243 MUIA_Font, MUIV_Font_Fixed,
244 MUIA_Text_PreParse, (IPTR) "\0333\033b\033c",
245 MUIA_Text_Contents, (IPTR) LOGOTYPE_ASCII,
246 MUIA_Weight, 0,
249 Child, (IPTR) VSpace(4),
250 Child, (IPTR) HGroup,
251 InnerSpacing(0,0),
253 GroupSpacing(6),
254 Child, (IPTR) HVSpace,
255 Child, (IPTR) TextObject,
256 MUIA_Font, MUIV_Font_Big,
257 MUIA_Text_PreParse, (IPTR) "\0333\033b",
258 MUIA_Text_Contents, (IPTR) __(MSG_BUILD_TYPE),
259 MUIA_Weight, 0,
260 End,
261 Child, (IPTR) TextObject,
262 MUIA_Font, MUIV_Font_Big,
263 MUIA_Text_PreParse, (IPTR) "\0333\033b",
264 MUIA_Text_Contents, (IPTR) variant,
265 MUIA_Weight, 0,
266 End,
267 Child, (IPTR) TextObject,
268 MUIA_Font, MUIV_Font_Big,
269 MUIA_Text_PreParse, (IPTR) "\0333\033b",
270 MUIA_Text_Contents, (IPTR) builddate,
271 MUIA_Weight, 0,
272 End,
273 Child, (IPTR) HVSpace,
274 End,
275 Child, (IPTR) VSpace(4),
276 Child, (IPTR) TextObject,
277 MUIA_Text_PreParse, (IPTR) "\0333\033c",
278 MUIA_Text_Contents, __(MSG_COPYRIGHT),
279 End,
280 Child, (IPTR) HGroup,
281 InnerSpacing(0,0),
282 GroupSpacing(0),
284 Child, (IPTR) HVSpace,
285 Child, (IPTR) TextObject,
286 MUIA_Text_PreParse, (IPTR) "\0333",
287 MUIA_Text_Contents, __(MSG_LICENSE_1),
288 MUIA_Weight, 0,
289 End,
290 Child, (IPTR) TextObject,
291 MUIA_Text_Contents, (IPTR) " ",
292 MUIA_Weight, 0,
293 End,
294 Child, (IPTR) (licenseButton = TextObject,
295 MUIA_InputMode, MUIV_InputMode_RelVerify,
296 MUIA_Text_PreParse, (IPTR) "\0333\033u",
297 MUIA_Text_Contents, __(MSG_LICENSE_2),
298 MUIA_Weight, 0,
299 End),
300 Child, (IPTR) TextObject,
301 MUIA_Text_PreParse, (IPTR) "\0333",
302 MUIA_Text_Contents, __(MSG_LICENSE_3),
303 MUIA_Weight, 0,
304 End,
305 Child, (IPTR) HVSpace,
306 End,
307 Child, (IPTR) TextObject,
308 MUIA_Text_PreParse, (IPTR) "\0333\033c",
309 MUIA_Text_Contents, __(MSG_MORE_INFORMATION),
310 End,
311 Child, (IPTR) VSpace(4),
312 Child, (IPTR) VGroup,
313 InnerSpacing(4,4),
315 Child, (IPTR) RegisterGroup(pages),
316 MUIA_Background, REGISTER_BG,
318 Child, (IPTR) ListviewObject,
319 MUIA_Listview_List, (IPTR) (authorsList = ListObject,
320 TextFrame,
321 MUIA_Background, LIST_BG,
322 End),
323 End,
324 Child, (IPTR) ListviewObject,
325 MUIA_Listview_List, (IPTR) (sponsorsList = ListObject,
326 TextFrame,
327 MUIA_Background, LIST_BG,
328 End),
329 End,
330 Child, (IPTR) ListviewObject,
331 MUIA_Listview_List, (IPTR) (acknowledgementsList = ListObject,
332 TextFrame,
333 MUIA_Background, LIST_BG,
334 End),
335 End,
336 End,
337 End,
338 End,
339 End),
341 TAG_DONE
344 if (self != NULL)
346 SETUP_INST_DATA;
348 data->aad_Window = window;
349 data->aad_Pool = pool;
351 /*-- Initialize lists --------------------------------------------------*/
352 NamesToList(authorsList, AUTHORS, data);
353 NamesToList(sponsorsList, SPONSORS, data);
355 DoMethod
357 acknowledgementsList, MUIM_List_Insert,
358 (IPTR) ACKNOWLEDGEMENTS, ACKNOWLEDGEMENTS_SIZE, MUIV_List_Insert_Top
361 /*-- Setup notifications -----------------------------------------------*/
362 DoMethod
364 window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
365 (IPTR) self, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
368 DoMethod
370 licenseButton, MUIM_Notify, MUIA_Pressed, FALSE,
371 (IPTR) self, 1, MUIM_AboutAROS_ShowLicense
375 return self;
378 IPTR AboutAROS__OM_DISPOSE(Class *CLASS, Object *self, Msg message)
380 SETUP_INST_DATA;
382 if (data->aad_Pool != NULL) DeletePool(data->aad_Pool);
384 return DoSuperMethodA(CLASS, self, message);
387 IPTR AboutAROS__MUIM_Application_Execute(Class *CLASS, Object *self, Msg message)
389 SETUP_INST_DATA;
391 SET(data->aad_Window, MUIA_Window_Open, TRUE);
392 DoSuperMethodA(CLASS, self, message);
393 SET(data->aad_Window, MUIA_Window_Open, FALSE);
395 return 0;
398 IPTR AboutAROS__MUIM_AboutAROS_ShowLicense(Class *CLASS, Object *self, Msg message)
400 OpenWorkbenchObject("HELP:LICENSE", TAG_DONE);
402 return 0;
405 /*** Setup ******************************************************************/
406 ZUNE_CUSTOMCLASS_4
408 AboutAROS, NULL, MUIC_Application, NULL,
409 OM_NEW, struct opSet *,
410 OM_DISPOSE, Msg,
411 MUIM_Application_Execute, Msg,
412 MUIM_AboutAROS_ShowLicense, Msg