2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
7 #include <aros/debug.h>
9 #include <exec/types.h>
10 #include <workbench/startup.h>
12 #include <proto/exec.h>
13 #include <proto/dos.h>
14 #include <proto/intuition.h>
15 #include <proto/icon.h>
16 #include <proto/alib.h>
18 #define MUIMASTER_YES_INLINE_STDARG
19 #include <proto/muimaster.h>
20 #include <libraries/mui.h>
21 #include <zune/clock.h>
23 #include <string.h> /* memset() */
24 #include <stdlib.h> /* exit() */
29 /*** Version string *********************************************************/
31 char *versionString
= VERSIONSTR
;
33 /*** Argument parsing *******************************************************/
35 #define ARG_TEMPLATE "LEFT/N,TOP/N,WIDTH/N,HEIGHT/N,PUBSCREEN/K"
46 /*** Variables **************************************************************/
47 /* Options ******************************************************************/
49 static LONG optionLeft
= MUIV_Window_LeftEdge_Centered
,
50 optionTop
= MUIV_Window_TopEdge_Centered
,
53 static STRPTR optionPubscr
= NULL
;
55 /* User interface ***********************************************************/
56 Object
*application
, *window
;
59 /*** Functions **************************************************************/
61 void ShowMessage(CONST_STRPTR title
, CONST_STRPTR text
, CONST_STRPTR gadgets
)
63 MUI_RequestA(application
, window
, 0, title
, gadgets
, text
, NULL
);
66 void Cleanup(CONST_STRPTR message
)
73 && ((struct Process
*) FindTask(NULL
))->pr_CLI
== BNULL
76 ShowMessage("Clock", message
, MSG(MSG_OK
));
80 Printf("Clock: %s\n", message
);
84 FreeVec(optionPubscr
);
85 Locale_Deinitialize();
93 static void GetArguments(int argc
, char **argv
)
95 if (argc
== 0) /* started from WB */
97 UBYTE
**array
= ArgArrayInit(argc
, (UBYTE
**)argv
);
98 optionLeft
= ArgInt(array
, "LEFT", optionLeft
);
99 optionTop
= ArgInt(array
, "TOP", optionTop
);
100 optionWidth
= ArgInt(array
, "WIDTH", optionWidth
);
101 optionHeight
= ArgInt(array
, "HEIGHT", optionHeight
);
102 optionPubscr
= StrDup(ArgString(array
, "PUBSCREEN", optionPubscr
));
109 struct RDArgs
*rdargs
= NULL
;
112 memset(args
, 0, sizeof(args
));
113 rdargs
= ReadArgs(ARG_TEMPLATE
, args
, NULL
);
116 Fault(IoErr(), 0, tmp
, TMPSIZE
);
120 if (args
[ARG_LEFT
]) optionLeft
= *(LONG
*)args
[ARG_LEFT
];
121 if (args
[ARG_TOP
]) optionTop
= *(LONG
*)args
[ARG_TOP
];
122 if (args
[ARG_WIDTH
]) optionWidth
= *(LONG
*)args
[ARG_WIDTH
];
123 if (args
[ARG_HEIGHT
]) optionHeight
= *(LONG
*)args
[ARG_HEIGHT
];
124 if (args
[ARG_HEIGHT
]) optionPubscr
= StrDup((STRPTR
)args
[ARG_PUBSCREEN
]);
129 D(bug("Clock left %d top %d width %d height %d pubscr %s\n",
130 optionLeft
, optionTop
, optionWidth
, optionHeight
, optionPubscr
));
133 int main(int argc
, char **argv
)
136 GetArguments(argc
, argv
);
138 application
= (Object
*)ApplicationObject
,
139 MUIA_Application_Title
, (IPTR
) MSG(MSG_WINDOW_TITLE
),
140 MUIA_Application_Version
, (IPTR
) versionString
,
141 MUIA_Application_Copyright
, (IPTR
)"© 2006, The AROS Development Team",
142 MUIA_Application_Description
, (IPTR
) MSG(MSG_DESCRIPTION
),
143 MUIA_Application_Base
, (IPTR
) "CLOCK",
144 SubWindow
, (IPTR
) (window
= (Object
*)WindowObject
,
145 MUIA_Window_Title
, (IPTR
) MSG(MSG_WINDOW_TITLE
),
146 MUIA_Window_Activate
, TRUE
,
147 MUIA_Window_NoMenus
, TRUE
,
148 MUIA_Window_LeftEdge
, optionLeft
,
149 MUIA_Window_TopEdge
, optionTop
,
150 MUIA_Window_Width
, optionWidth
,
151 MUIA_Window_Height
, optionHeight
,
152 MUIA_Window_PublicScreen
, (IPTR
) optionPubscr
,
153 MUIA_Window_ID
, MAKE_ID('C','K','W','N'),
154 WindowContents
, (IPTR
) ClockObject
,
163 window
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
164 (IPTR
) application
, 2,
165 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
168 SetAttrs(window
, MUIA_Window_Open
, TRUE
, TAG_DONE
);
170 DoMethod(application
, MUIM_Application_Execute
);
172 SetAttrs(window
, MUIA_Window_Open
, FALSE
, TAG_DONE
);
173 MUI_DisposeObject(application
);
177 Cleanup(MSG(MSG_ERROR_CANT_CREATE_APPLICATION
));