home *** CD-ROM | disk | FTP | other *** search
- /*
- * Routines dealing with processing of Yak's icon
- * (be they for tooltypes or AppIcon purposes).
- *
- * MWS, Tuesday 13-Oct-92
- */
- #include <exec/types.h>
- #include <exec/ports.h>
- #include <dos/dos.h>
- #include <workbench/startup.h>
- #include <workbench/workbench.h>
- #include <proto/exec.h>
- #include <proto/dos.h>
- #include <proto/wb.h>
- #include <proto/icon.h>
- #include <string.h>
- #include "icon.h"
-
- static struct DiskObject *diskobj;
-
- __regargs BOOL
- GetOurIcon(struct WBStartup *WBenchMsg)
- {
- if (WBenchMsg)
- diskobj = GetDiskObject(WBenchMsg->sm_ArgList->wa_Name);
- return (BOOL)(diskobj ? TRUE : FALSE);
- }
-
- /* can cope with multiple calls */
- void
- FreeOurIcon()
- {
- if (diskobj)
- {
- FreeDiskObject(diskobj);
- diskobj = NULL;
- }
- }
-
- /* like ArgString() */
- __regargs char *
- TTString(char *name, char *def)
- {
- char *what;
- if (diskobj)
- if (what = FindToolType(diskobj->do_ToolTypes, name))
- return what;
- return def;
- }
-
- /* like ArgInt() */
- __regargs LONG
- TTInt(char *name, LONG def)
- {
- char *what;
- if (diskobj)
- if (what = FindToolType(diskobj->do_ToolTypes, name))
- StrToLong(what, &def);
- return def;
- }
-
- /* simple extension to ArgXXX routines */
- __regargs BOOL
- TTBool(char *name, BOOL def)
- {
- char *s;
-
- s = TTString(name, def ? "YES" : "NO");
-
- return (BOOL)(((strcmp(s, "YES") == 0) ||
- (strcmp(s, "TRUE") == 0) ||
- (strcmp(s, "ON") == 0)) ? TRUE : FALSE);
- }
-
- #ifndef NO_APPICON
-
- LONG appsigflag;
-
- static struct AppIcon *appicon;
- static struct MsgPort *appport;
-
- /* create our AppIcon */
- __regargs BOOL
- MakeOurAppIcon(char *name)
- {
- if (diskobj)
- if (appport = CreateMsgPort())
- {
- diskobj->do_CurrentX = TTInt("ICONXPOS", NO_ICON_POSITION);
- diskobj->do_CurrentY = TTInt("ICONYPOS", NO_ICON_POSITION);
- if (appicon = AddAppIconA(0,0L,name,appport,0L,diskobj,0L))
- {
- appsigflag = 1 << appport->mp_SigBit;
- return TRUE;
- }
- else DeleteMsgPort(appport);
- }
- return FALSE;
- }
-
- /* bye bye icon... */
- void
- RemoveOurAppIcon()
- {
- if (appicon) RemoveAppIcon(appicon);
- if (appport) DeleteMsgPort(appport);
- }
-
- /* just clear the port */
- void
- RespondToAppIcon()
- {
- struct Message *msg;
- while (msg = GetMsg(appport))
- ReplyMsg(msg);
- }
-
- #endif /* !NO_APPICON */
-