2 Copyright © 1995-1997 Stefan Stuntz.
3 Copyright © 2009-2016, The AROS Development Team.
9 #include <proto/exec.h>
10 #include <proto/dos.h>
11 #include <proto/gadtools.h>
12 #include <proto/locale.h>
13 #include <proto/intuition.h>
14 #include <proto/muimaster.h>
15 #include <proto/muiscreen.h>
21 #include "displayidinfo_class.h"
22 #include "displayidlist_class.h"
23 #include "editpanel_class.h"
24 #include "editwindow_class.h"
25 #include "mainwindow_class.h"
26 #include "screenlist_class.h"
27 #include "screenpanel_class.h"
28 #include "syspenfield_class.h"
30 /****************************************************************************/
32 /****************************************************************************/
34 const char VersionString
[] = "$VER: PSI 20.1 (10.06.2010)";
35 struct Catalog
*Catalog
;
37 /****************************************************************************/
39 /****************************************************************************/
41 #define CATALOG_NAME "System/Prefs/PSI.catalog"
42 #define CATALOG_VERSION 19
44 /****************************************************************************************/
46 CONST_STRPTR
GetStr(int num
)
48 struct CatCompArrayType
*cca
= (struct CatCompArrayType
*)CatCompArray
;
49 while (cca
->cca_ID
!= num
) cca
++;
51 return GetCatalogStr(Catalog
,num
,cca
->cca_Str
);
53 return (char *)cca
->cca_Str
;
56 /****************************************************************************************/
58 VOID
LocalizeStringArray(CONST_STRPTR
*array
)
61 for (x
= array
; *x
; x
++)
62 *x
= GetStr((int)(IPTR
)*x
);
65 /****************************************************************************************/
67 VOID
LocalizeNewMenu(struct NewMenu
*nm
)
69 for ( ; nm
->nm_Type
!= NM_END
; nm
++)
70 if (nm
->nm_Label
!= NM_BARLABEL
)
71 nm
->nm_Label
= GetStr((int)(IPTR
)nm
->nm_Label
);
74 /****************************************************************************************/
78 Catalog
= OpenCatalog(NULL
, CATALOG_NAME
, OC_Version
, CATALOG_VERSION
, TAG_DONE
);
80 LocalizeNewMenu(MainMenu
);
81 LocalizeNewMenu(PaletteMenu
);
82 /*LocalizeNewMenu(EditMenu);*/
83 LocalizeStringArray(CYA_Overscan
);
84 LocalizeStringArray(CYA_EditPages
);
87 /****************************************************************************************/
93 CloseCatalog(Catalog
);
99 /****************************************************************************/
100 /* Misc Help Functions */
101 /****************************************************************************/
103 IPTR
xget(Object
*obj
, IPTR attribute
)
106 get(obj
, attribute
, &x
);
110 /****************************************************************************************/
112 char *getstr(Object
*obj
)
114 return (char *)xget(obj
,MUIA_String_Contents
);
117 /****************************************************************************************/
119 BOOL
getbool(Object
*obj
)
121 return (BOOL
)xget(obj
, MUIA_Selected
);
124 /****************************************************************************************/
126 VOID
setstr(APTR str
, LONG num
)
128 DoMethod(str
, MUIM_SetAsString
, MUIA_String_Contents
, "%ld", num
);
131 /****************************************************************************************/
133 VOID
settxt(APTR str
, LONG num
)
135 DoMethod(str
, MUIM_SetAsString
, MUIA_Text_Contents
, "%ld", num
);
138 /****************************************************************************************/
140 Object
*MakeCheck(int num
)
142 Object
*obj
= MUI_MakeObject(MUIO_Checkmark
, GetStr(num
));
144 set(obj
, MUIA_CycleChain
, 1);
149 /****************************************************************************************/
151 Object
*MakeButton(int num
)
153 Object
*obj
= MUI_MakeObject(MUIO_Button
, GetStr(num
));
155 set(obj
, MUIA_CycleChain
, 1);
160 /****************************************************************************************/
163 Object *MakeBackground(int num)
167 obj = MUI_NewObject(MUIC_Popimage,
168 MUIA_Imageadjust_Type, MUIV_Imageadjust_Type_Background,
169 MUIA_Window_Title, "Adjust Screen Background",
177 /****************************************************************************************/
179 Object
*MakeString(int maxlen
,int num
)
181 Object
*obj
= MUI_MakeObject(MUIO_String
, GetStr(num
), maxlen
);
189 MUIA_String_AdvanceOnCR
, TRUE
,
197 /****************************************************************************************/
199 Object
*MakeCycle(CONST_STRPTR
*array
, int num
)
201 Object
*obj
= MUI_MakeObject(MUIO_Cycle
, GetStr(num
), array
);
203 set(obj
, MUIA_CycleChain
, 1);
208 /****************************************************************************************/
210 Object
*MakeSlider(int min
, int max
, int num
)
212 Object
*obj
= MUI_MakeObject(MUIO_Slider
, GetStr(num
), min
,max
);
214 set(obj
, MUIA_CycleChain
, 1);
219 /****************************************************************************************/
221 Object
*MakeCLabel(int num
)
223 return MUI_MakeObject(MUIO_Label
, GetStr(num
), MUIO_Label_Centered
);
226 /****************************************************************************************/
228 Object
*MakeLabel(int num
)
230 return MUI_MakeObject(MUIO_Label
, GetStr(num
),0);
233 /****************************************************************************************/
235 Object
*MakeLabel1(int num
)
237 return MUI_MakeObject(MUIO_Label
, GetStr(num
), MUIO_Label_SingleFrame
);
240 /****************************************************************************************/
242 Object
*MakeLabel2(int num
)
244 return MUI_MakeObject(MUIO_Label
, GetStr(num
), MUIO_Label_DoubleFrame
);
247 Object
*MakeLLabel(int num
)
249 return MUI_MakeObject(MUIO_Label
, GetStr(num
), MUIO_Label_LeftAligned
);
252 /****************************************************************************************/
254 Object
*MakeLLabel1(int num
)
256 return MUI_MakeObject(MUIO_Label
, GetStr(num
), MUIO_Label_LeftAligned
| MUIO_Label_SingleFrame
);
259 Object
*MakeFreeLabel(int num
)
261 return MUI_MakeObject(MUIO_Label
, GetStr(num
), MUIO_Label_FreeVert
);
264 /****************************************************************************************/
266 Object
*MakeFreeLLabel(int num
)
268 return MUI_MakeObject(MUIO_Label
, GetStr(num
), MUIO_Label_FreeVert
| MUIO_Label_LeftAligned
);
271 /****************************************************************************************/
273 BOOL
TestPubScreen(char *name
)
276 struct PubScreenNode
*psn
,*succ
;
278 pslist
= LockPubScreenList();
279 ForEntries(pslist
,psn
,succ
)
281 if (!stricmp(psn
->psn_Node
.ln_Name
,name
))
287 UnlockPubScreenList();
293 /****************************************************************************/
294 /* Init/Exit Functions */
295 /****************************************************************************/
297 VOID
ExitClasses(VOID
)
309 /****************************************************************************************/
311 BOOL
InitClasses(VOID
)
324 CL_SysPenField
&& CL_EditWindow
&& CL_EditPanel
&& CL_DispIDlist
325 && CL_DispIDinfo
&& CL_ScreenList
&& CL_ScreenPanel
&& CL_MainWindow
334 /****************************************************************************************/
336 const char CLITemplate
[] = "NAME,OPEN/S,CLOSE/S";
338 const char CLIHelp
[] = "\
340 Usage: PSI <name> OPEN/CLOSE\n\
341 <name>: name of (preconfigured) public screen\n\
342 OPEN : open this public screen\n\
343 CLOSE: close this public screen\n\
346 /****************************************************************************************/
348 LONG
HandleArgs(Object
*mainwin
)
350 struct MUI_PubScreenDesc
*desc
;
351 struct RDArgs
*rda
,*rdas
;
358 } argarray
= { 0,0,0 };
360 if ((rdas
= AllocDosObject(DOS_RDARGS
, NULL
)))
362 rdas
->RDA_ExtHelp
= (char *)CLIHelp
;
364 if ((rda
= ReadArgs((char *)CLITemplate
, (IPTR
*)&argarray
,rdas
)))
368 DoMethod(mainwin
, MUIM_ScreenList_Find
, argarray
.Name
, &desc
);
373 msg
= MSG_CLI_SCREENNOTFOUND
;
374 else if (MUIS_OpenPubScreen(desc
))
375 msg
= MSG_CLI_SCREENOPENED
;
377 msg
= MSG_CLI_SCREENOPENFAILED
;
379 else if (argarray
.Close
)
382 msg
= MSG_CLI_SCREENNOTFOUND
;
383 else if (MUIS_ClosePubScreen(desc
->Name
))
384 msg
= MSG_CLI_SCREENCLOSED
;
386 msg
= MSG_CLI_SCREENCLOSEFAILED
;
391 if (argarray
.Open
|| argarray
.Close
)
392 msg
= MSG_CLI_SYNTAXERROR
;
396 FreeDosObject(DOS_RDARGS
,rdas
);
399 msg
= MSG_CLI_OUTOFMEMORY
;
405 /****************************************************************************/
407 /****************************************************************************/
409 int main(int argc
, char *argv
[])
411 struct MUIS_InfoClient sic
;
422 app
= ApplicationObject
,
423 MUIA_Application_Title
, "PSI",
424 MUIA_Application_Version
, VersionString
,
425 MUIA_Application_Copyright
, "©1995-97, Stefan Stuntz",
426 MUIA_Application_Author
, "Stefan Stuntz",
427 MUIA_Application_Description
, "Public Screen Inspector",
428 MUIA_Application_SingleTask
, TRUE
,
429 MUIA_Application_Base
, "PSI",
430 MUIA_Application_Window
, win
= NewObject(CL_MainWindow
->mcc_Class
, NULL
, TAG_DONE
),
438 msg
= HandleArgs(win
);
442 set(win
, MUIA_Window_Open
, TRUE
);
444 /* special magic to keep track about public screen open/close status */
445 sic
.task
= FindTask(NULL
);
446 sic
.sigbit
= SIGBREAKF_CTRL_E
;
447 MUIS_AddInfoClient(&sic
);
449 while (DoMethod(app
, MUIM_Application_NewInput
, &sigs
) != MUIV_Application_ReturnID_Quit
)
453 sigs
= Wait(sigs
| SIGBREAKF_CTRL_C
| SIGBREAKF_CTRL_E
| SIGBREAKF_CTRL_F
);
455 /* quit when receiving break from console */
456 if (sigs
& SIGBREAKF_CTRL_C
)
459 /* update listview whenever a screen was opened/closed */
460 if (sigs
& SIGBREAKF_CTRL_E
)
461 DoMethod(win
, MUIM_ScreenPanel_Update
);
463 /* deiconify & activate on ctrl-f just like the other prefs programs */
464 if (sigs
& SIGBREAKF_CTRL_F
)
466 set(app
, MUIA_Application_Iconified
, FALSE
);
467 set(win
, MUIA_Window_Open
, TRUE
);
472 MUIS_RemInfoClient(&sic
);
474 DoMethod(win
, MUIM_ScreenPanel_CloseWindows
);
475 set(win
, MUIA_Window_Open
, FALSE
);
477 MUI_DisposeObject(app
);
479 else msg
= MSG_CLI_NOAPPLICATION
;
482 else msg
= MSG_CLI_OUTOFMEMORY
;
486 CONST_STRPTR str
= GetStr(msg
);
487 char *c
= strchr(str
,'(');
488 Write(Output(),str
,strlen(str
));
489 res
= c
? atol(c
+1) : RETURN_OK
;