home *** CD-ROM | disk | FTP | other *** search
- #define ASL_V38_NAMES_ONLY
- #include <ctype.h>
- #include <stdio.h>
- #include <string.h>
- #include <dos.h>
- #include <dos/dosextens.h>
- #include <exec/types.h>
- #include <graphics/displayinfo.h>
- #include <intuition/gadgetclass.h>
- #include <intuition/intuition.h>
- #include <libraries/asl.h>
- #include <libraries/gadtools.h>
- #include <libraries/locale.h>
- #include <prefs/printertxt.h>
- #include <clib/asl_protos.h>
- #include <clib/diskfont_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/exec_protos.h>
- #include <clib/gadtools_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/icon_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/locale_protos.h>
- #include <clib/wb_protos.h>
-
- #define CATCOMP_NUMBERS
- #include "tapecover_strings.h"
-
- #define MAXFILELEN FNSIZE
- #define MAXPATHLEN FNSIZE
- #define MAXFONTLEN 30
- #define MAINGADWIDTH 15
- #define TAPELENGTH 1302
- #define TITLES_PER_SIDE 14
- #define TITLE_LENGTH 34
- #define LABELS 2
- #define LABEL_LENGTH 68
- #define BIGLABEL_LENGTH 46
- #define INFOS 3
- #define INFO_LENGTH 68
- #define MAIN_LINES (TITLES_PER_SIDE + LABELS + INFOS + 3)
- #define BUF_LENGTH (TITLES_PER_SIDE * TITLE_LENGTH * 2 + LABELS * LABEL_LENGTH + INFOS * INFO_LENGTH)
- #define TBUF_LENGTH (TITLES_PER_SIDE * TITLE_LENGTH * 2)
- #define LBUF_LENGTH (LABELS * LABEL_LENGTH)
- #define IBUF_LENGTH (INFOS * INFO_LENGTH)
- #define TLBUF_LENGTH (TBUF_LENGTH + LBUF_LENGTH)
- #define ASLLOADTPC 1
- #define ASLSAVETPC 2
- #define ASLSAVEEXP 3
- #define ASLPATH 4
- #define ASLLOADPREF 5
- #define ASLSAVEPREF 6
- #define PREFGADWIDTH 25
- #define PREFSTRGADWIDTH 40
- #define OWNSCR_GAD 0
- #define SCRNAMESTR_GAD 1
- #define SCRMODE_GAD 2
- #define SCRMODETXT_GAD 3
- #define ICONS_GAD 4
- #define FORMFEED_GAD 5
- #define CENTERED_GAD 6
- #define TAPEPATH_GAD 7
- #define TAPEPATHTXT_GAD 8
- #define EXPPATH_GAD 9
- #define EXPPATHTXT_GAD 10
- #define MASKFONT_GAD 11
- #define MASKFONTTXT_GAD 12
- #define GENFONT_GAD 13
- #define GENFONTTXT_GAD 14
-
- char tcname_str[] = "TapeCover",
- tcpname_str[] = "TapeCover.prefs",
- cat_str[] = "tapecover.catalog",
- defpath_str[] = "TapeCover:",
- deftpath_str[] = "Tapes",
- defxpath_str[] = "Export",
- defscr_str[] = "TAPECOVER.1",
- defpub_str[] = "Workbench",
- tciname_str[] = "Icons/def_project",
- name_str[] = "TapeCover V2.12",
- tapehdr_str[] = "TPCV1.0T",
- confhdr_str[] = "TPCV2.1C",
- tpcext_str[] = ".tpc",
- ascext_str[] = ".asc",
- tpcwld_str[] = "#?.tpc",
- prefwld_str[] = "#?.prefs",
- prttxtname_str[] = "ENV:Sys/printer.prefs",
- CMD_INIT[] = "\x1b\x63\x1b#1",
- CMD_FLEN[] = "\x1b[36t",
- CMD_LQ_ON[] = "\x1b[2\"z",
- CMD_NM[] = "\x1b[0w",
- CMD_CD_ON[] = "\x1b[4w",
- CMD_EL_ON[] = "\x1b[2w",
- CMD_EL_OFF[] = "\x1b[1w",
- CMD_UL_ON[] = "\x1b[4m",
- CMD_UL_OFF[] = "\x1b[24m";
-
- UWORD __chip waitPointer[] =
- { 0x0000, 0x0000,
- 0x0400, 0x07C0,
- 0x0000, 0x07C0,
- 0x0100, 0x0380,
- 0x0000, 0x07E0,
- 0x07C0, 0x1FF8,
- 0x1FF0, 0x3FEC,
- 0x3FF8, 0x7FDE,
- 0x3FF8, 0x7FBE,
- 0x7FFC, 0xFF7F,
- 0x7EFC, 0xFFFF,
- 0x7FFC, 0xFFFF,
- 0x3FF8, 0x7FFE,
- 0x3FF8, 0x7FFE,
- 0x1FF0, 0x3FFC,
- 0x07C0, 0x1FF8,
- 0x0000, 0x07E0,
- 0x0000, 0x0000 };
-
- struct NewMenu newmenu[] =
- {
- { NM_TITLE, (STRPTR) MSG_PROJECT_MENU, 0, 0, 0, 0,},
- { NM_ITEM, (STRPTR) MSG_PROJECT_NEW, 0, 0, 0, 0,},
- { NM_ITEM, (STRPTR) MSG_PROJECT_OPEN, 0, 0, 0, 0,},
- { NM_ITEM, NM_BARLABEL, 0, 0, 0, 0,},
- { NM_ITEM, (STRPTR) MSG_PROJECT_SAVE, 0, 0, 0, 0,},
- { NM_ITEM, (STRPTR) MSG_PROJECT_SAVEAS, 0, 0, 0, 0,},
- { NM_ITEM, NM_BARLABEL, 0, 0, 0, 0,},
- { NM_ITEM, (STRPTR) MSG_PROJECT_PRINT, 0, 0, 0, 0,},
- { NM_ITEM, NM_BARLABEL, 0, 0, 0, 0,},
- { NM_ITEM, (STRPTR) MSG_PROJECT_EDIT, 0, 0, 0, 0,},
- { NM_ITEM, NM_BARLABEL, 0, 0, 0, 0,},
- { NM_ITEM, (STRPTR) MSG_PROJECT_PREFS, 0, 0, 0, 0,},
- { NM_ITEM, NM_BARLABEL, 0, 0, 0, 0,},
- { NM_ITEM, (STRPTR) MSG_PROJECT_ABOUT, 0, 0, 0, 0,},
- { NM_ITEM, NM_BARLABEL, 0, 0, 0, 0,},
- { NM_ITEM, (STRPTR) MSG_PROJECT_QUIT, 0, 0, 0, 0,},
- { NM_TITLE, (STRPTR) MSG_MASK_MENU, 0, 0, 0, 0,},
- { NM_ITEM, (STRPTR) MSG_MASK_LABEL1BOLD, 0, CHECKIT | MENUTOGGLE, 0, 0,},
- { NM_ITEM, (STRPTR) MSG_MASK_LABEL2BOLD, 0, CHECKIT | MENUTOGGLE, 0, 0,},
- { NM_ITEM, NM_BARLABEL, 0, 0, 0, 0,},
- { NM_ITEM, (STRPTR) MSG_MASK_CLEARSIDES, 0, 0, 0, 0,},
- { NM_TITLE, (STRPTR) MSG_EXPORT_MENU, 0, 0, 0, 0,},
- { NM_ITEM, (STRPTR) MSG_EXPORT_ASCII, 0, 0, 0, 0,},
- { NM_END, NULL, 0, 0, 0, 0,},
- };
-
- typedef struct TapeDat
- { char *sidea[TITLES_PER_SIDE],
- *sideb[TITLES_PER_SIDE];
- char *label[LABELS];
- char *info[INFOS];
- struct { unsigned int line1_bold : 1;
- unsigned int line2_bold : 1;
- } size;
- };
-
- typedef struct PrefDat
- { char scrname[100],
- tapepath[MAXPATHLEN],
- exppath[MAXPATHLEN],
- fontname[2][MAXFONTLEN];
- ULONG scrid,
- scrwidth,
- scrheight;
- UWORD scrdepth,
- scroscan,
- fontysize[2];
- WORD winleft,
- wintop,
- aslwidth,
- aslheight;
- UBYTE fontstyle[2],
- fontflags[2];
- BOOL ownscr,
- scrascroll,
- centered,
- icons,
- ff;
- };
-
- typedef struct IntDat
- { struct LocaleInfo li;
- struct Screen *scr;
- struct Window *mainwin;
- struct AppWindow *mainappwin;
- struct Menu *mainmenu;
- struct MsgPort *mainmsgport;
- struct TextAttr maskfont,
- genfont;
- struct TextFont *tmaskfont,
- *tgenfont;
- struct Gadget *mainglist,
- *maingad;
- APTR *mainvi;
- BPTR prt;
- char winname[MAXFILELEN],
- scrname[MAXFILELEN],
- maskfontname[MAXFONTLEN],
- genfontname[MAXFONTLEN],
- mainpath[MAXPATHLEN],
- prefpath[MAXPATHLEN],
- loadpath[MAXPATHLEN],
- file[MAXFILELEN],
- expfile[MAXFILELEN],
- preffile[MAXFILELEN];
- BOOL firstload,
- filesaved;
- };
-
- char tdat_buf[BUF_LENGTH];
- struct TapeDat tdat;
- struct PrefDat prefs,
- newprefs;
- struct IntDat idat;
- struct Library *LocaleBase,
- *DiskfontBase,
- *IntuitionBase,
- *GfxBase,
- *IconBase,
- *GadToolsBase,
- *AslBase;
-
- UWORD pens[] = { 0xFFFF };
-
- STRPTR __asm GetString(register __a0 struct LocaleInfo *li,
- register __d0 LONG stringNum);
-
- void LocalizeNewMenu(struct LocaleInfo *li, struct NewMenu *nm)
- {
- UWORD i;
-
- for (i = 0; nm[i].nm_Type != NM_END; i++)
- {
- if (nm[i].nm_Type == NM_TITLE)
- nm[i].nm_Label = GetString(li, (LONG)nm[i].nm_Label);
- else if (nm[i].nm_Label != NM_BARLABEL)
- {
- nm[i].nm_CommKey = GetString(li, (LONG)nm[i].nm_Label);
- nm[i].nm_Label = nm[i].nm_CommKey+2;
- if (nm[i].nm_CommKey[0] == ' ')
- nm[i].nm_CommKey = NULL;
- }
- }
- }
-
- int getgadkey(char *gadtext)
- {
- char *gadchar;
- int intchar;
-
- gadchar = strchr(gadtext, '_');
- if (gadchar)
- {
- intchar = gadchar[1];
- intchar = tolower(intchar);
- }
- return intchar;
- }
-
- void busy(struct Window *wp)
- {
- if (IntuitionBase->lib_Version < 39)
- SetPointer(wp, waitPointer, 16, 16, -6, 0);
- else
- SetWindowPointer(wp, WA_BusyPointer, TRUE, TAG_END);
- ModifyIDCMP(wp, IDCMP_REFRESHWINDOW);
- /*
- OffMenu(wp, FULLMENUNUM(0, NOITEM, NOSUB));
- OffMenu(wp, FULLMENUNUM(1, NOITEM, NOSUB));
- OffMenu(wp, FULLMENUNUM(2, NOITEM, NOSUB));
- */
- }
-
- void unbusy(struct Window *wp)
- {
- ModifyIDCMP(wp, IDCMP_CLOSEWINDOW | IDCMP_MENUPICK |
- IDCMP_RAWKEY | IDCMP_VANILLAKEY |
- IDCMP_GADGETUP | IDCMP_REFRESHWINDOW);
- /*
- OnMenu(wp, FULLMENUNUM(2, NOITEM, NOSUB));
- OnMenu(wp, FULLMENUNUM(1, NOITEM, NOSUB));
- OnMenu(wp, FULLMENUNUM(0, NOITEM, NOSUB));
- */
- if (IntuitionBase->lib_Version < 39)
- ClearPointer(wp);
- else
- SetWindowPointer(wp, WA_Pointer, NULL, TAG_END);
- }
-
- void fehler(struct IntDat *idat, LONG error_num, char *error_text)
- {
- struct EasyStruct ereq;
- char errorstr[10 + 40 + FNSIZE + 5];
-
- ereq.es_StructSize = sizeof(struct EasyStruct);
- ereq.es_Flags = 0;
- ereq.es_Title = name_str;
- ereq.es_GadgetFormat = GetString(&idat->li, MSG_ERROR_RGAD);
- strcpy(errorstr, GetString(&idat->li, MSG_ERROR));
- strcat(errorstr, "\n");
- strcat(errorstr, GetString(&idat->li, error_num));
- strcat(errorstr, "\n");
- if (error_text)
- {
- strcat(errorstr, "\"");
- strcat(errorstr, error_text);
- strcat(errorstr, "\"");
- }
- ereq.es_TextFormat = errorstr;
- EasyRequest(idat->mainwin, &ereq, NULL);
- }
-
- #include "tapecover_io.c"
-
- void save(struct IntDat *idat, struct PrefDat *prefs, struct TapeDat *tdat);
- void save_as(struct IntDat *idat, struct PrefDat *prefs, struct TapeDat *tdat);
-
- BOOL open_mainwin(struct IntDat *idat, struct PrefDat *prefs, struct TapeDat *tdat)
- {
- struct NewGadget ng;
- BOOL success = FALSE;
- WORD wintop,
- winleftedge,
- wintopedge,
- winwidth,
- winheight,
- xsize,
- ysize,
- hbor;
- FLOAT gaddis;
- ULONG appwinid = 1,
- userdata = 0;
-
- xsize = idat->tgenfont->tf_XSize;
- ysize = idat->tgenfont->tf_YSize;
- wintop = idat->scr->WBorTop + idat->scr->Font->ta_YSize + 1;
- hbor = idat->scr->WBorLeft + idat->scr->WBorRight;
- winwidth = hbor + (INFO_LENGTH - 1) * idat->tmaskfont->tf_XSize + 40;
- idat->maingad = CreateContext(&idat->mainglist);
- ng.ng_TextAttr = &idat->genfont;
- ng.ng_VisualInfo = idat->mainvi;
- ng.ng_Width = 10 + MAINGADWIDTH * xsize;
- if (hbor + 40 + (4 * ng.ng_Width) > winwidth)
- winwidth = hbor + 40 + (4 * ng.ng_Width);
- gaddis = (winwidth - 4 * ng.ng_Width - hbor) / 5;
- ng.ng_Height = 5 + ysize;
- ng.ng_LeftEdge = idat->scr->WBorLeft + gaddis;
- ng.ng_TopEdge = wintop + MAIN_LINES * (idat->tmaskfont->tf_YSize + 6) + 25;
- ng.ng_GadgetText = GetString(&idat->li, MSG_NEW_GAD);
- ng.ng_GadgetID = MSG_NEW_GAD;
- ng.ng_Flags = 0;
- idat->maingad = CreateGadget(BUTTON_KIND, idat->maingad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_LeftEdge += gaddis + ng.ng_Width;
- ng.ng_GadgetText = GetString(&idat->li, MSG_OPEN_GAD);
- ng.ng_GadgetID = MSG_OPEN_GAD;
- idat->maingad = CreateGadget(BUTTON_KIND, idat->maingad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_LeftEdge += gaddis + ng.ng_Width;
- ng.ng_GadgetText = GetString(&idat->li, MSG_SAVE_GAD);
- ng.ng_GadgetID = MSG_SAVE_GAD;
- idat->maingad = CreateGadget(BUTTON_KIND, idat->maingad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_LeftEdge += gaddis + ng.ng_Width;
- ng.ng_GadgetText = GetString(&idat->li, MSG_SAVEAS_GAD);
- ng.ng_GadgetID = MSG_SAVEAS_GAD;
- idat->maingad = CreateGadget(BUTTON_KIND, idat->maingad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_TopEdge += ng.ng_Height + 5;
- ng.ng_LeftEdge = idat->scr->WBorLeft + gaddis;
- ng.ng_GadgetText = GetString(&idat->li, MSG_EDIT_GAD);
- ng.ng_GadgetID = MSG_EDIT_GAD;
- idat->maingad = CreateGadget(BUTTON_KIND, idat->maingad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_LeftEdge += gaddis + ng.ng_Width;
- ng.ng_GadgetText = GetString(&idat->li, MSG_MPRINT_GAD);
- ng.ng_GadgetID = MSG_MPRINT_GAD;
- idat->maingad = CreateGadget(BUTTON_KIND, idat->maingad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_LeftEdge += gaddis + ng.ng_Width;
- ng.ng_GadgetText = GetString(&idat->li, MSG_PREFS_GAD);
- ng.ng_GadgetID = MSG_PREFS_GAD;
- idat->maingad = CreateGadget(BUTTON_KIND, idat->maingad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_LeftEdge += gaddis + ng.ng_Width;
- ng.ng_GadgetText = GetString(&idat->li, MSG_QUIT_GAD);
- ng.ng_GadgetID = MSG_QUIT_GAD;
- idat->maingad = CreateGadget(BUTTON_KIND, idat->maingad, &ng, GT_Underscore, '_',
- TAG_END);
- winheight = wintop + idat->scr->WBorBottom +
- (MAIN_LINES * (idat->tmaskfont->tf_YSize + 6)) +
- (2 * ng.ng_Height) + 35;
- if ((winwidth <= idat->scr->Width) && (winheight <= idat->scr->Height))
- {
- if (idat->maingad)
- {
- if (idat->mainmsgport = CreateMsgPort())
- {
- if (strlen(idat->file) == 0)
- strcpy(idat->winname, GetString(&idat->li, MSG_UNNAMED));
- else
- strcpy(idat->winname, idat->file);
- winleftedge = (idat->scr->Width - winwidth) / 2;
- wintopedge = (idat->scr->Height - winheight) / 2;
- if (!prefs->centered && ((prefs->winleft + winwidth) <= idat->scr->Width))
- winleftedge = prefs->winleft;
- if (!prefs->centered && ((prefs->wintop + winheight) <= idat->scr->Height))
- wintopedge = prefs->wintop;
- if (idat->mainwin = OpenWindowTags(NULL,
- WA_Left, winleftedge,
- WA_Top, wintopedge,
- WA_Width, winwidth,
- WA_Height, winheight,
- WA_Gadgets, idat->mainglist,
- WA_DragBar, TRUE,
- WA_CloseGadget, TRUE,
- WA_DepthGadget, TRUE,
- WA_Activate, TRUE,
- WA_SmartRefresh, TRUE,
- WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_MENUPICK |
- IDCMP_RAWKEY | IDCMP_VANILLAKEY |
- IDCMP_GADGETUP | IDCMP_REFRESHWINDOW,
- WA_Title, idat->winname,
- WA_PubScreen, idat->scr,
- WA_ScreenTitle, name_str,
- WA_NewLookMenus, TRUE,
- TAG_END))
- {
- GT_RefreshWindow(idat->mainwin, NULL);
- SetFont(idat->mainwin->RPort, idat->tmaskfont);
- if (idat->mainmenu = CreateMenus(newmenu, GTMN_NewLookMenus, TRUE,
- GTMN_FullMenu, TRUE,
- TAG_END))
- {
- if (LayoutMenus(idat->mainmenu, idat->mainvi,
- GTMN_NewLookMenus, TRUE,
- TAG_END))
- {
- if (SetMenuStrip(idat->mainwin, idat->mainmenu))
- {
- if (idat->mainappwin = AddAppWindow(appwinid, userdata, idat->mainwin,
- idat->mainmsgport, NULL))
- {
- success = TRUE;
- ScreenToFront(idat->scr);
- write_mask(idat);
- write_dat(idat, tdat);
- }
- else
- fehler(idat, MSG_WIN_ERROR, GetString(&idat->li, MSG_AWIN_ERROR));
- }
- else
- fehler(idat, MSG_SMENU_ERROR, GetString(&idat->li, MSG_MWIN_ERROR));
- }
- else
- fehler(idat, MSG_LMENU_ERROR, GetString(&idat->li, MSG_MWIN_ERROR));
- }
- else
- fehler(idat, MSG_MENU_ERROR, GetString(&idat->li, MSG_MWIN_ERROR));
- }
- else
- fehler(idat, MSG_WIN_ERROR, GetString(&idat->li, MSG_MWIN_ERROR));
- }
- else
- fehler(idat, MSG_MSGPORT_ERROR, GetString(&idat->li, MSG_MWIN_ERROR));
- }
- else
- fehler(idat, MSG_GAD_ERROR, GetString(&idat->li, MSG_MWIN_ERROR));
- }
- else
- fehler(idat, MSG_WINSIZE_ERROR, GetString(&idat->li, MSG_MWIN_ERROR));
- return success;
- }
-
- void close_mainwin(struct IntDat *idat)
- {
- if (idat->mainappwin)
- {
- RemoveAppWindow(idat->mainappwin);
- idat->mainappwin = NULL;
- }
- if (idat->mainmenu)
- {
- ClearMenuStrip(idat->mainwin);
- FreeMenus(idat->mainmenu);
- idat->mainmenu = NULL;
- }
- if (idat->mainwin)
- {
- CloseWindow(idat->mainwin);
- idat->mainwin = NULL;
- }
- if (idat->mainmsgport)
- {
- DeleteMsgPort(idat->mainmsgport);
- idat->mainmsgport = NULL;
- }
- if (idat->mainglist)
- {
- FreeGadgets(idat->mainglist);
- idat->mainglist = NULL;
- }
- }
-
- BOOL ask_changed(struct IntDat *idat, struct PrefDat *prefs, struct TapeDat *tdat)
- {
- struct EasyStruct ereq;
- char askstr[MAXFILELEN + 44];
- LONG answer;
- BOOL doit = FALSE;
-
- ereq.es_StructSize = sizeof(struct EasyStruct);
- ereq.es_Flags = 0;
- ereq.es_Title = name_str;
- strcpy(askstr, "\"");
- if (strlen(idat->file) == 0)
- strcat(askstr, GetString(&idat->li, MSG_UNNAMED));
- else
- strcat(askstr, idat->file);
- strcat(askstr, "\"\n");
- strcat(askstr, GetString(&idat->li, MSG_CHANGED));
- ereq.es_TextFormat = askstr;
- ereq.es_GadgetFormat = GetString(&idat->li, MSG_CHANGED_RGAD);
- answer = EasyRequest(idat->mainwin, &ereq, NULL);
- switch (answer) {
- case 1:
- if (strlen(idat->file) == 0)
- save_as(idat, prefs, tdat);
- else
- save(idat, prefs, tdat);
- doit = TRUE;
- break;
- case 2:
- doit = TRUE;
- break;
- default:
- break;
- }
- return doit;
- }
-
- BOOL ask_overwrite(struct IntDat *idat, char *e_file)
- {
- struct EasyStruct ereq;
- char askstr[MAXFILELEN + 42];
- LONG answer;
- BOOL doit = TRUE;
-
- ereq.es_StructSize = sizeof(struct EasyStruct);
- ereq.es_Flags = 0;
- ereq.es_Title = name_str;
- strcpy(askstr, "\"");
- strcat(askstr, e_file);
- strcat(askstr, "\"\n");
- strcat(askstr, GetString(&idat->li, MSG_OVERWRITE_QUEST));
- ereq.es_TextFormat = askstr;
- ereq.es_GadgetFormat = GetString(&idat->li, MSG_OVERWRITE_RGAD);
- answer = EasyRequest(idat->mainwin, &ereq, NULL);
- switch (answer) {
- case 1:
- doit = FALSE;
- break;
- default:
- break;
- }
- return doit;
- }
-
- void info(struct IntDat *idat)
- {
- #define MAX_INFO_TXT 40
- #define INFO_LINES 10
-
- struct Window *info_window;
- struct IntuiMessage *msg;
- struct NewGadget ng;
- struct Gadget *glist, *gad;
- BOOL done = FALSE;
- WORD xsize,
- ysize,
- winwidth,
- winheight,
- wintop,
- hbor;
-
- xsize = idat->tgenfont->tf_XSize;
- ysize = idat->tgenfont->tf_YSize;
- wintop = idat->scr->WBorTop + idat->scr->Font->ta_YSize + 1 + 15;
- hbor = idat->scr->WBorLeft + idat->scr->WBorRight;
- winwidth = hbor + 30 + MAX_INFO_TXT * xsize;
- gad = CreateContext(&glist);
- ng.ng_TextAttr = &idat->genfont;
- ng.ng_VisualInfo = idat->mainvi;
- ng.ng_Width = 20 + (strlen(GetString(&idat->li, MSG_OK_GAD)) - 1) * xsize;
- if (hbor + 10 + ng.ng_Width > winwidth)
- winwidth = hbor + 10 + ng.ng_Width;
- ng.ng_Height = 5 + ysize;
- ng.ng_LeftEdge = (winwidth - ng.ng_Width) / 2;
- ng.ng_TopEdge = wintop + (ysize + 2) * INFO_LINES + 15;
- ng.ng_GadgetText = GetString(&idat->li, MSG_OK_GAD);
- ng.ng_GadgetID = 1;
- ng.ng_Flags = 0;
- gad = CreateGadget(BUTTON_KIND, gad, &ng, GT_Underscore, '_',
- TAG_END);
- winheight = wintop + idat->scr->WBorBottom +
- INFO_LINES * (ysize + 2) + ng.ng_Height +
- 20;
- if (gad)
- {
- if (info_window = OpenWindowTags(NULL,
- WA_Left, (idat->scr->Width - winwidth) / 2,
- WA_Top, (idat->scr->Height - winheight) /2,
- WA_Width, winwidth,
- WA_Height, winheight,
- WA_Gadgets, glist,
- WA_DragBar, TRUE,
- WA_CloseGadget, TRUE,
- WA_DepthGadget, TRUE,
- WA_Activate, TRUE,
- WA_SmartRefresh, TRUE,
- WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY |
- IDCMP_GADGETUP | IDCMP_REFRESHWINDOW,
- WA_Title, GetString(&idat->li, MSG_INFO_WIN),
- WA_PubScreen, idat->scr,
- WA_ScreenTitle, name_str,
- TAG_END))
- {
- busy(idat->mainwin);
- GT_RefreshWindow(info_window, NULL);
- SetFont(info_window->RPort, idat->tgenfont);
- box_bor(info_window, info_window->BorderLeft + 10, wintop - 10,
- winwidth - info_window->BorderRight - 10,
- wintop + INFO_LINES * (ysize+ 2) + 5);
- write_ctext3d(info_window, wintop, 1, 3,
- name_str);
- write_ctext3d(info_window, wintop + ysize + 2, 1, 3,
- GetString(&idat->li, MSG_RELEASE));
- write_ctext3d(info_window, wintop + (ysize + 2) * 2, 1, 2,
- GetString(&idat->li, MSG_COPYRIGHT));
- write_ctext3d(info_window, wintop + (ysize + 2) * 3, 2, 1,
- GetString(&idat->li, MSG_AUTHOR));
- write_ctext3d(info_window, wintop + (ysize + 2) * 4, 2, 1,
- GetString(&idat->li, MSG_STREET));
- write_ctext3d(info_window, wintop + (ysize + 2) * 5, 2, 1,
- GetString(&idat->li, MSG_CITY));
- write_ctext3d(info_window, wintop + (ysize + 2) * 6, 2, 1,
- GetString(&idat->li, MSG_COUNTRY));
- write_ctext3d(info_window, wintop + (ysize + 2) * 7, 2, 1,
- GetString(&idat->li, MSG_INT_PHONE));
- write_ctext3d(info_window, wintop + (ysize + 2) * 8, 2, 1,
- GetString(&idat->li, MSG_EMAIL1));
- write_ctext3d(info_window, wintop + (ysize + 2) * 9, 2, 1,
- GetString(&idat->li, MSG_EMAIL2));
- while (! done)
- {
- WaitPort(info_window->UserPort);
- msg = (struct IntuiMessage *)GT_GetIMsg(info_window->UserPort);
- if (msg->Class == IDCMP_REFRESHWINDOW)
- {
- GT_BeginRefresh(info_window);
- box_bor(info_window, info_window->BorderLeft + 10, wintop - 10,
- winwidth - info_window->BorderRight - 10,
- wintop + INFO_LINES * (ysize+ 2) + 5);
- write_ctext3d(info_window, wintop, 1, 3,
- name_str);
- write_ctext3d(info_window, wintop + ysize + 2, 1, 3,
- GetString(&idat->li, MSG_RELEASE));
- write_ctext3d(info_window, wintop + (ysize + 2) * 2, 1, 2,
- GetString(&idat->li, MSG_COPYRIGHT));
- write_ctext3d(info_window, wintop + (ysize + 2) * 3, 2, 1,
- GetString(&idat->li, MSG_AUTHOR));
- write_ctext3d(info_window, wintop + (ysize + 2) * 4, 2, 1,
- GetString(&idat->li, MSG_STREET));
- write_ctext3d(info_window, wintop + (ysize + 2) * 5, 2, 1,
- GetString(&idat->li, MSG_CITY));
- write_ctext3d(info_window, wintop + (ysize + 2) * 6, 2, 1,
- GetString(&idat->li, MSG_COUNTRY));
- write_ctext3d(info_window, wintop + (ysize + 2) * 7, 2, 1,
- GetString(&idat->li, MSG_INT_PHONE));
- write_ctext3d(info_window, wintop + (ysize + 2) * 8, 2, 1,
- GetString(&idat->li, MSG_EMAIL1));
- write_ctext3d(info_window, wintop + (ysize + 2) * 9, 2, 1,
- GetString(&idat->li, MSG_EMAIL2));
- GT_EndRefresh(info_window, TRUE);
- }
- if (msg->Class == IDCMP_CLOSEWINDOW ||
- msg->Class == IDCMP_GADGETUP ||
- msg->Class == IDCMP_VANILLAKEY)
- done = TRUE;
- GT_ReplyIMsg(msg);
- }
- unbusy(idat->mainwin);
- CloseWindow(info_window);
- }
- else
- fehler(idat, MSG_WIN_ERROR, GetString(&idat->li, MSG_INFO_WIN));
- FreeGadgets(glist);
- }
- else
- fehler(idat, MSG_GAD_ERROR, GetString(&idat->li, MSG_INFO_WIN));
- }
-
- void load_start(struct IntDat *idat, struct PrefDat *prefs, struct TapeDat *tdat)
- {
- BPTR datei;
- char header[8],
- buffer[BUF_LENGTH + 2];
- UBYTE flags;
- LONG length;
-
- datei = Open(idat->loadpath, MODE_OLDFILE);
- if (datei)
- {
- length = Read(datei, header, 8);
- if (0 == memcmp(header, tapehdr_str, 8))
- {
- length += Read(datei, buffer, BUF_LENGTH + 2);
- if (length == TAPELENGTH)
- {
- memcpy(tdat->sidea[0], buffer, BUF_LENGTH);
- strmid(idat->loadpath, prefs->tapepath, 1, strlen(idat->loadpath)
- - strlen(FilePart(idat->loadpath)));
- strcpy(idat->file, FilePart(idat->loadpath));
- strcpy(idat->expfile, idat->file);
- flags = buffer[BUF_LENGTH];
- tdat->size.line2_bold = flags & 1;
- flags >>= 1;
- tdat->size.line1_bold = flags & 1;
- if (tdat->size.line1_bold)
- newmenu[17].nm_Flags |= CHECKED;
- else
- newmenu[17].nm_Flags &= ~CHECKED;
- if (tdat->size.line2_bold)
- newmenu[18].nm_Flags |= CHECKED;
- else
- newmenu[18].nm_Flags &= ~CHECKED;
- idat->filesaved = TRUE;
- }
- else
- fehler(idat, MSG_LOAD_ERROR, idat->loadpath);
- }
- else
- fehler(idat, MSG_DATASET_ERROR, idat->loadpath);
- }
- else
- fehler(idat, MSG_OPEN_ERROR, idat->loadpath);
- Close(datei);
- }
-
- void load_direct(struct IntDat *idat, struct PrefDat *prefs, struct TapeDat *tdat)
- {
- struct MenuItem *item;
- BPTR datei;
- char header[8],
- buffer[BUF_LENGTH + 2];
- UBYTE flags;
- LONG length;
- BOOL doit = TRUE;
-
- busy(idat->mainwin);
- if (! idat->filesaved)
- doit = ask_changed(idat, prefs, tdat);
- if (doit)
- {
- datei = Open(idat->loadpath, MODE_OLDFILE);
- if (datei)
- {
- length = Read(datei, header, 8);
- if (0 == memcmp(header, tapehdr_str, 8))
- {
- length += Read(datei, buffer, BUF_LENGTH + 2);
- if (length == TAPELENGTH)
- {
- memcpy(tdat->sidea[0], buffer, BUF_LENGTH);
- strcpy(idat->file, FilePart(idat->loadpath));
- strcpy(idat->expfile, idat->file);
- flags = buffer[BUF_LENGTH];
- tdat->size.line2_bold = flags & 1;
- flags >>= 1;
- tdat->size.line1_bold = flags & 1;
- item = ItemAddress(idat->mainmenu, FULLMENUNUM(1, 0, NOSUB));
- if (tdat->size.line1_bold)
- {
- if (item)
- item->Flags |= CHECKED;
- newmenu[17].nm_Flags |= CHECKED;
- }
- else
- {
- if (item)
- item->Flags &= ~CHECKED;
- newmenu[17].nm_Flags &= ~CHECKED;
- }
- item = ItemAddress(idat->mainmenu, FULLMENUNUM(1, 1, NOSUB));
- if (tdat->size.line2_bold)
- {
- if (item)
- item->Flags |= CHECKED;
- newmenu[18].nm_Flags |= CHECKED;
- }
- else
- {
- if (item)
- item->Flags &= ~CHECKED;
- newmenu[18].nm_Flags &= ~CHECKED;
- }
- write_dat(idat, tdat);
- SetWindowTitles(idat->mainwin, idat->file, (UBYTE *)-1);
- idat->filesaved = TRUE;
- }
- else
- fehler(idat, MSG_LOAD_ERROR, idat->loadpath);
- }
- else
- fehler(idat, MSG_DATASET_ERROR, idat->loadpath);
- }
- else
- fehler(idat, MSG_OPEN_ERROR, idat->loadpath);
- Close(datei);
- }
- unbusy(idat->mainwin);
- }
-
- void load(struct IntDat *idat, struct PrefDat *prefs, struct TapeDat *tdat)
- {
- struct MenuItem *item;
- BPTR datei;
- char bpath[MAXPATHLEN],
- bfile[MAXFILELEN],
- header[8],
- buffer[BUF_LENGTH + 2];
- UBYTE flags;
- LONG length;
- BOOL doit = TRUE;
-
- busy(idat->mainwin);
- if (! idat->filesaved)
- doit = ask_changed(idat, prefs, tdat);
- if (doit)
- {
- strcpy(bpath, prefs->tapepath);
- strcpy(bfile, idat->file);
- if (asl_fr(idat, prefs, idat->mainwin, ASLLOADTPC, bpath, bfile))
- {
- if (AddPart(bpath, bfile, MAXPATHLEN))
- {
- datei = Open(bpath, MODE_OLDFILE);
- if (datei)
- {
- length = Read(datei, header, 8);
- if (0 == memcmp(header, tapehdr_str, 8))
- {
- length += Read(datei, buffer, BUF_LENGTH + 2);
- if (length == TAPELENGTH)
- {
- memcpy(tdat->sidea[0], buffer, BUF_LENGTH);
- strmid(bpath, prefs->tapepath, 1, strlen(bpath) - strlen(bfile));
- strcpy(idat->file, bfile);
- strcpy(idat->expfile, bfile);
- flags = buffer[BUF_LENGTH];
- tdat->size.line2_bold = flags & 1;
- flags >>= 1;
- tdat->size.line1_bold = flags & 1;
- item = ItemAddress(idat->mainmenu, FULLMENUNUM(1, 0, NOSUB));
- if (tdat->size.line1_bold)
- {
- if (item)
- item->Flags |= CHECKED;
- newmenu[17].nm_Flags |= CHECKED;
- }
- else
- {
- if (item)
- item->Flags &= ~CHECKED;
- newmenu[17].nm_Flags &= ~CHECKED;
- }
- item = ItemAddress(idat->mainmenu, FULLMENUNUM(1, 1, NOSUB));
- if (tdat->size.line2_bold)
- {
- if (item)
- item->Flags |= CHECKED;
- newmenu[18].nm_Flags |= CHECKED;
- }
- else
- {
- if (item)
- item->Flags &= ~CHECKED;
- newmenu[18].nm_Flags &= ~CHECKED;
- }
- write_dat(idat, tdat);
- SetWindowTitles(idat->mainwin, idat->file, (UBYTE *)-1);
- idat->filesaved = TRUE;
- }
- else
- fehler(idat, MSG_LOAD_ERROR, bpath);
- }
- else
- fehler(idat, MSG_DATASET_ERROR, bpath);
- }
- else
- fehler(idat, MSG_OPEN_ERROR, bpath);
- Close(datei);
- }
- else
- fehler(idat, MSG_PATH_ERROR, bpath);
- }
- }
- unbusy(idat->mainwin);
- }
-
- void add_icon(struct IntDat *idat, char *p_file)
- {
- struct DiskObject *TC_DiskObject;
- char prog_path[MAXPATHLEN],
- *olddeftool,
- **oldtooltypes;
- UBYTE *newtooltypes[] =
- {
- "FILETYPE=TapeCover V1.x",
- "ACTION=LOAD",
- NULL
- };
-
- busy(idat->mainwin);
- strcpy(prog_path, idat->mainpath);
- if(AddPart(prog_path, tciname_str, MAXPATHLEN))
- if (TC_DiskObject = GetDiskObject(prog_path))
- {
- strcpy(prog_path, idat->mainpath);
- if (!AddPart(prog_path, tcname_str, MAXPATHLEN))
- strcpy(prog_path, tcname_str);
- olddeftool = TC_DiskObject->do_DefaultTool;
- TC_DiskObject->do_DefaultTool = prog_path;
- oldtooltypes = TC_DiskObject->do_ToolTypes;
- TC_DiskObject->do_ToolTypes = newtooltypes;
- TC_DiskObject->do_Type = WBPROJECT;
- TC_DiskObject->do_CurrentX = NO_ICON_POSITION;
- TC_DiskObject->do_CurrentY = NO_ICON_POSITION;
- PutDiskObject(p_file, TC_DiskObject);
- TC_DiskObject->do_DefaultTool = olddeftool;
- TC_DiskObject->do_ToolTypes = oldtooltypes;
- FreeDiskObject(TC_DiskObject);
- }
- unbusy(idat->mainwin);
- }
-
- void save(struct IntDat *idat, struct PrefDat *prefs, struct TapeDat *tdat)
- {
- BPTR datei;
- char bpath[MAXPATHLEN],
- bfile[MAXFILELEN];
- UBYTE flags;
- LONG length;
-
- busy(idat->mainwin);
- strcpy(bpath, prefs->tapepath);
- strcpy(bfile, idat->file);
- if (AddPart(bpath, bfile, MAXPATHLEN))
- {
- datei = Open(bpath, MODE_NEWFILE);
- if (datei)
- {
- length = Write(datei, tapehdr_str, 8);
- length += Write(datei, tdat->sidea[0], BUF_LENGTH);
- flags = tdat->size.line1_bold;
- flags <<= 1;
- flags |= tdat->size.line2_bold;
- length += Write(datei, &flags, 1);
- flags = 0;
- length += Write(datei, &flags, 1);
- if (length != TAPELENGTH)
- fehler(idat, MSG_SAVE_ERROR, bpath);
- else
- {
- SetComment(bpath, GetString(&idat->li, MSG_COMMENT));
- idat->filesaved = TRUE;
- if (prefs->icons)
- add_icon(idat, bpath);
- }
- }
- else
- fehler(idat, MSG_OPEN_ERROR, bpath);
- Close(datei);
- }
- else
- fehler(idat, MSG_PATH_ERROR, bpath);
- unbusy(idat->mainwin);
- }
-
- void save_as(struct IntDat *idat, struct PrefDat *prefs, struct TapeDat *tdat)
- {
- BPTR datei;
- char bpath[MAXPATHLEN],
- fpath[MAXPATHLEN],
- bfile[MAXFILELEN];
- UBYTE flags;
- LONG length;
- BOOL doit,
- again;
-
- busy(idat->mainwin);
- strcpy(bpath, prefs->tapepath);
- strcpy(bfile, idat->file);
- do {
- doit = TRUE;
- again = FALSE;
- if (asl_fr(idat, prefs, idat->mainwin, ASLSAVETPC, bpath, bfile))
- {
- length = strlen(bfile);
- if (length >= 4)
- {
- if (0 != strcmp(bfile + length - 4, tpcext_str))
- strcat(bfile, tpcext_str);
- }
- else
- strcat(bfile, tpcext_str);
- strcpy(fpath, bpath);
- if (AddPart(fpath, bfile, MAXPATHLEN))
- {
- datei = Open(fpath, MODE_OLDFILE);
- if (datei)
- {
- doit = ask_overwrite(idat, fpath);
- if (! doit)
- again = TRUE;
- }
- Close(datei);
- if (doit)
- {
- datei = Open(fpath, MODE_NEWFILE);
- if (datei)
- {
- length = Write(datei, tapehdr_str, 8);
- length += Write(datei, tdat->sidea[0], BUF_LENGTH);
- flags = tdat->size.line1_bold;
- flags <<= 1;
- flags |= tdat->size.line2_bold;
- length += Write(datei, &flags, 1);
- flags = 0;
- length += Write(datei, &flags, 1);
- if (length != TAPELENGTH)
- fehler(idat, MSG_SAVE_ERROR, fpath);
- else
- {
- strcpy(prefs->tapepath, bpath);
- strcpy(idat->file, bfile);
- strcpy(idat->expfile, bfile);
- SetWindowTitles(idat->mainwin, idat->file, (UBYTE *)-1);
- SetComment(fpath, GetString(&idat->li, MSG_COMMENT));
- idat->filesaved = TRUE;
- if (prefs->icons)
- add_icon(idat, fpath);
- }
- }
- else
- fehler(idat, MSG_OPEN_ERROR, fpath);
- Close(datei);
- }
- }
- else
- fehler(idat, MSG_PATH_ERROR, fpath);
- }
- } while (again);
- unbusy(idat->mainwin);
- }
-
- void get_prtname(struct IntDat *idat, char *pnam)
- {
- BPTR datei;
- char buffer[DRIVERNAMESIZE];
- LONG length;
-
- strcpy(pnam, "");
- datei = Open(prttxtname_str, MODE_OLDFILE);
- if (datei)
- {
- length = Read(datei, buffer, 8);
- if (0 == memcmp(buffer, "FORM", 4))
- {
- length += Read(datei, buffer, 18);
- if (0 == memcmp(buffer, "PREFPRHD", 8))
- {
- length += Read(datei, buffer, 24);
- if (0 == memcmp(buffer, "PTXT", 4))
- {
- length += Read(datei, buffer, 30);
- strcpy(pnam, buffer);
- }
- else
- fehler(idat, MSG_PTXT_ERROR, prttxtname_str);
- }
- else
- fehler(idat, MSG_PREF_ERROR, prttxtname_str);
- }
- else
- fehler(idat, MSG_FORM_ERROR, prttxtname_str);
- Close(datei);
- }
- }
-
- void print_n(BPTR prt, int n)
- {
- unsigned int i;
-
- for(i = 0; i < n; i++)
- {
- FPuts(prt, " ");
- }
- }
-
- void print_l(BPTR prt, int n)
- {
- unsigned int i;
-
- for(i = 0; i < n; i++)
- {
- FPuts(prt, "-");
- }
- }
-
- void print_dat(struct IntDat *idat, struct PrefDat *prefs, struct TapeDat *tdat)
- {
- #define MAX_PRINT_TXT DRIVERNAMESIZE
- #define PRINT_LINES 2
-
- struct Window *print_window;
- struct IntuiMessage *msg;
- struct NewGadget ng;
- struct Gadget *glist,
- *gad,
- *msg_gad;
- ULONG msg_class;
- UWORD msg_code;
- BOOL done = FALSE,
- doit = FALSE;
- WORD xsize,
- ysize,
- winwidth,
- winheight,
- wintop,
- hbor,
- box_left,
- box_top,
- box_width,
- box_height;
- UBYTE i;
- char prtname[DRIVERNAMESIZE],
- buffer[BIGLABEL_LENGTH];
- int print_key,
- cancel_key;
-
- get_prtname(idat, prtname);
- print_key = getgadkey(GetString(&idat->li, MSG_PRINT_GAD));
- cancel_key = getgadkey(GetString(&idat->li, MSG_CANCEL_GAD));
- xsize = idat->tgenfont->tf_XSize;
- ysize = idat->tgenfont->tf_YSize;
- wintop = idat->scr->WBorTop + idat->scr->Font->ta_YSize + 1 + 5;
- hbor = idat->scr->WBorLeft + idat->scr->WBorRight;
- winwidth = hbor + 40 + MAX_PRINT_TXT * xsize;
- gad = CreateContext(&glist);
- ng.ng_TextAttr = &idat->genfont;
- ng.ng_VisualInfo = idat->mainvi;
- if (strlen(GetString(&idat->li, MSG_PRINT_GAD)) > strlen(GetString(&idat->li, MSG_CANCEL_GAD)))
- ng.ng_Width = 20 + (strlen(GetString(&idat->li, MSG_PRINT_GAD)) - 1) * xsize;
- else
- ng.ng_Width = 20 + (strlen(GetString(&idat->li, MSG_CANCEL_GAD)) - 1) * xsize;
-
- if (hbor + 20 + (2 * ng.ng_Width) > winwidth)
- winwidth = hbor + 20 + (2 * ng.ng_Width);
- ng.ng_Height = 5 + ysize;
- ng.ng_LeftEdge = (winwidth - (2 * ng.ng_Width)) / 3;
- ng.ng_TopEdge = wintop + (ysize + 2) * PRINT_LINES + 15;
- ng.ng_GadgetText = GetString(&idat->li, MSG_PRINT_GAD);
- ng.ng_GadgetID = 1;
- ng.ng_Flags = 0;
- gad = CreateGadget(BUTTON_KIND, gad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_LeftEdge = 2 * ((winwidth - (2 * ng.ng_Width)) / 3) + ng.ng_Width;
- ng.ng_GadgetText = GetString(&idat->li, MSG_CANCEL_GAD);
- ng.ng_GadgetID = 2;
- gad = CreateGadget(BUTTON_KIND, gad, &ng, GT_Underscore, '_',
- TAG_END);
-
- ng.ng_Height = 10 + 2 * ysize;
- ng.ng_TopEdge = wintop + (ysize + 2) * (PRINT_LINES + 1) + 20;
- ng.ng_LeftEdge = 2 * ((winwidth - (2 * ng.ng_Width)) / 3) + ng.ng_Width;
- ng.ng_GadgetText = "Field 1\nButton";
- ng.ng_GadgetID = 3;
- gad = CreateGadget(BUTTON_KIND, gad, &ng, GT_Underscore, '_',
- TAG_END);
- winheight = wintop + idat->scr->WBorBottom +
- PRINT_LINES * (ysize + 2) + ng.ng_Height +
- 20;
- if (gad)
- {
- if (print_window = OpenWindowTags(NULL,
- WA_Left, (idat->scr->Width - winwidth) / 2,
- WA_Top, (idat->scr->Height - winheight) /2,
- WA_Width, winwidth,
- WA_Height, winheight,
- WA_Gadgets, glist,
- WA_DragBar, TRUE,
- WA_CloseGadget, TRUE,
- WA_DepthGadget, TRUE,
- WA_Activate, TRUE,
- WA_SmartRefresh, TRUE,
- WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY |
- IDCMP_GADGETUP | IDCMP_REFRESHWINDOW,
- WA_Title, GetString(&idat->li, MSG_PRINT_WIN),
- WA_PubScreen, idat->scr,
- WA_ScreenTitle, name_str,
- TAG_END))
- {
- busy(idat->mainwin);
- GT_RefreshWindow(print_window, NULL);
- SetFont(print_window->RPort,idat-> tgenfont);
- box_rec(print_window, (winwidth - (MAX_PRINT_TXT * xsize)) / 4,
- wintop,
- 3 * ((winwidth - (MAX_PRINT_TXT * xsize)) / 4) +
- MAX_PRINT_TXT * xsize,
- wintop + (ysize + 2) * PRINT_LINES + 5);
- write_ctext(print_window, wintop + 5, 1, 0,
- GetString(&idat->li, MSG_PRINTERDRIVER));
- write_ctext(print_window, wintop + 5 + ysize + 2, 2, 0,
- prtname);
- while (! done)
- {
- WaitPort(print_window->UserPort);
- msg = (struct IntuiMessage *)GT_GetIMsg(print_window->UserPort);
- msg_gad = (struct Gadget *)msg->IAddress;
- msg_class = msg->Class;
- msg_code = msg->Code;
- GT_ReplyIMsg(msg);
- switch (msg_class) {
- case IDCMP_CLOSEWINDOW:
- done = TRUE;
- break;
- case IDCMP_GADGETUP:
- switch (msg_gad->GadgetID) {
- case 1:
- doit = TRUE;
- done = TRUE;
- break;
- case 2:
- done = TRUE;
- break;
- default:
- break;
- }
- break;
- case IDCMP_VANILLAKEY:
- if (msg_code == print_key)
- {
- doit = TRUE;
- done = TRUE;
- }
- else if (msg_code == cancel_key)
- done = TRUE;
- break;
- case IDCMP_REFRESHWINDOW :
- GT_BeginRefresh(print_window);
- box_rec(print_window, (winwidth - (MAX_PRINT_TXT * xsize)) / 4,
- wintop,
- 3 * ((winwidth - (MAX_PRINT_TXT * xsize)) / 4) +
- MAX_PRINT_TXT * xsize,
- wintop + (ysize + 2) * PRINT_LINES + 5);
- write_ctext(print_window, wintop + 5, 1, 0,
- GetString(&idat->li, MSG_PRINTERDRIVER));
- write_ctext(print_window, wintop + 5 + ysize + 2, 2, 0,
- prtname);
- GT_EndRefresh(print_window, TRUE);
- break;
- default:
- break;
- }
- }
- CloseWindow(print_window);
- }
- else
- fehler(idat, MSG_WIN_ERROR, GetString(&idat->li, MSG_PRINT_WIN));
- FreeGadgets(glist);
- }
- else
- fehler(idat, MSG_GAD_ERROR, GetString(&idat->li, MSG_PRINT_WIN));
- if (doit)
- {
- hbor = idat->scr->WBorLeft + idat->scr->WBorRight;
- if (strlen(idat->file) > 40)
- winwidth = hbor + 10 + strlen(idat->file) * xsize;
- else
- winwidth = hbor + 10 + 30 * xsize;
- wintop = idat->scr->WBorTop + idat->scr->Font->ta_YSize + 1 + 5;
- winheight = wintop + idat->scr->WBorBottom + 3 * (ysize + 2) + 10;
- if (print_window = OpenWindowTags(NULL,
- WA_Left, (idat->scr->Width - winwidth) / 2,
- WA_Top, (idat->scr->Height - winheight) /2,
- WA_Width, winwidth,
- WA_Height, winheight,
- WA_DragBar, TRUE,
- WA_DepthGadget, TRUE,
- WA_Activate, TRUE,
- WA_SmartRefresh, TRUE,
- WA_NoCareRefresh, TRUE,
- WA_Title, GetString(&idat->li, MSG_PLEASEWAIT),
- WA_PubScreen, idat->scr,
- WA_ScreenTitle, name_str,
- TAG_END))
- {
- if (IntuitionBase->lib_Version < 39)
- SetPointer(print_window, waitPointer, 16, 16, -6, 0);
- else
- SetWindowPointer(print_window, WA_BusyPointer, TRUE, TAG_END);
- SetFont(print_window->RPort, idat->tgenfont);
- write_ctext(print_window, wintop, 1, 0, GetString(&idat->li, MSG_PRINTING));
- write_ctext(print_window, wintop + ysize + 2, 2, 0, idat->file);
- box_width = winwidth - hbor - xsize * 6 - 20;
- box_height = ysize;
- box_left = print_window->BorderLeft + 2 * xsize + 10;
- box_top = wintop + 2 * (ysize + 2) + 5;
- box_rec(print_window, box_left - 1, box_top - 1, box_left + box_width, box_top + box_height);
- write_textjam2(print_window->RPort, print_window->BorderLeft + 5, box_top, 1, 0, "0%");
- write_textjam2(print_window->RPort,
- winwidth - print_window->BorderRight - 4 * xsize - 5, box_top, 1, 0, "100%");
- idat->prt = Open("PRT:", MODE_NEWFILE);
- if (idat->prt)
- {
- FPuts(idat->prt, CMD_INIT);
- if (prefs->ff)
- FPuts(idat->prt, CMD_FLEN);
- FPuts(idat->prt, CMD_LQ_ON);
- FPuts(idat->prt, CMD_NM);
- print_l(idat->prt, 40);
- print_l(idat->prt, 40);
- FPuts(idat->prt, "\n");
- FPuts(idat->prt, CMD_NM);
- FPuts(idat->prt, CMD_UL_ON);
- box_fill(print_window, box_left, box_top, box_width, box_height, 10);
- print_n(idat->prt, 1); FPuts(idat->prt, GetString(&idat->li, MSG_SIDEA));
- print_n(idat->prt, (20 - strlen(GetString(&idat->li, MSG_SIDEA))));
- FPuts(idat->prt, GetString(&idat->li, MSG_SIDEB));
- print_n(idat->prt, (18 - strlen(GetString(&idat->li, MSG_SIDEB))));
-
- FPuts(idat->prt, "|");
-
- print_n(idat->prt, 1); FPuts(idat->prt, GetString(&idat->li, MSG_SIDEA));
- print_n(idat->prt, (20 - strlen(GetString(&idat->li, MSG_SIDEA))));
- FPuts(idat->prt, GetString(&idat->li, MSG_SIDEB));
- print_n(idat->prt, (19 - strlen(GetString(&idat->li, MSG_SIDEB))));
-
- FPuts(idat->prt, CMD_UL_OFF);
- FPuts(idat->prt, "\n");
-
- FPuts(idat->prt, CMD_CD_ON);
- for(i = 0; i < TITLES_PER_SIDE; i++)
- {
- box_fill(print_window, box_left, box_top, box_width, box_height,
- 14 + i * 4);
- print_n(idat->prt, 1); FPuts(idat->prt, tdat->sidea[i]);
- print_n(idat->prt, 1); FPuts(idat->prt, tdat->sideb[i]);
-
- print_n(idat->prt, 2); FPuts(idat->prt, tdat->sidea[i]);
- print_n(idat->prt, 1); FPuts(idat->prt, tdat->sideb[i]);
-
- FPuts(idat->prt, "\n");
-
- }
- box_fill(print_window, box_left, box_top, box_width, box_height, 75);
- FPuts(idat->prt, CMD_NM);
- print_l(idat->prt, 40);
- print_l(idat->prt, 40);
- FPuts(idat->prt, "\n");
-
- if (tdat->size.line1_bold)
- {
- FPuts(idat->prt, CMD_EL_ON);
- strmid(tdat->label[0], buffer, 1, BIGLABEL_LENGTH);
- print_n(idat->prt, 1); FPuts(idat->prt, buffer);
-
- strmid(tdat->label[0], buffer, 1, BIGLABEL_LENGTH);
- print_n(idat->prt, 2); FPuts(idat->prt, buffer); FPuts(idat->prt, "\n");
- FPuts(idat->prt, CMD_EL_OFF);
- }
- else
- {
- FPuts(idat->prt, CMD_CD_ON);
- print_n(idat->prt, 1); FPuts(idat->prt, tdat->label[0]);
-
- print_n(idat->prt, 2); FPuts(idat->prt, tdat->label[0]); FPuts(idat->prt, "\n");
- }
- box_fill(print_window, box_left, box_top, box_width, box_height, 80);
- if (tdat->size.line2_bold)
- {
- FPuts(idat->prt, CMD_NM); FPuts(idat->prt, CMD_EL_ON);
- strmid(tdat->label[1], buffer, 1, BIGLABEL_LENGTH);
- print_n(idat->prt, 1); FPuts(idat->prt, buffer);
-
- strmid(tdat->label[1], buffer, 1, BIGLABEL_LENGTH);
- print_n(idat->prt, 2); FPuts(idat->prt, buffer); FPuts(idat->prt, "\n");
- FPuts(idat->prt, CMD_EL_OFF);
- }
- else
- {
- FPuts(idat->prt, CMD_CD_ON);
- print_n(idat->prt, 1); FPuts(idat->prt, tdat->label[1]);
-
- print_n(idat->prt, 2); FPuts(idat->prt, tdat->label[1]); FPuts(idat->prt, "\n");
- }
- box_fill(print_window, box_left, box_top, box_width, box_height, 85);
- FPuts(idat->prt, CMD_NM);
- print_l(idat->prt, 40);
- print_l(idat->prt, 40);
- FPuts(idat->prt, "\n");
- FPuts(idat->prt, CMD_CD_ON);
- print_n(idat->prt, 1); FPuts(idat->prt, tdat->info[0]);
- print_n(idat->prt, 2); FPuts(idat->prt, tdat->info[0]); FPuts(idat->prt, "\n");
- print_n(idat->prt, 1); FPuts(idat->prt, tdat->info[1]);
- print_n(idat->prt, 2); FPuts(idat->prt, tdat->info[1]); FPuts(idat->prt, "\n");
- print_n(idat->prt, 1); FPuts(idat->prt, tdat->info[2]);
- print_n(idat->prt, 2); FPuts(idat->prt, tdat->info[2]); FPuts(idat->prt, "\n");
- box_fill(print_window, box_left, box_top, box_width, box_height, 100);
- FPuts(idat->prt, CMD_NM);
- print_l(idat->prt, 40);
- print_l(idat->prt, 40);
- FPuts(idat->prt, "\n");
- FPuts(idat->prt, CMD_NM);
- if (prefs->ff)
- FPuts(idat->prt, "\f");
- Close(idat->prt);
- idat->prt = NULL;
- }
- else
- fehler(idat, MSG_PRINTER_ERROR, NULL);
- CloseWindow(print_window);
- }
- else
- fehler(idat, MSG_WIN_ERROR, GetString(&idat->li, MSG_PRINT_WIN));
- }
- unbusy(idat->mainwin);
- }
-
- void edit(struct IntDat *idat, struct TapeDat *tdat)
- {
- struct RastPort *rp;
- ULONG font_x,
- font_y,
- winleft,
- wintop;
- int pos = 1;
- BOOL big;
-
- rp = idat->mainwin->RPort;
- font_x = rp->Font->tf_XSize;
- font_y = rp->Font->tf_YSize;
- winleft = (idat->mainwin->Width - (INFO_LENGTH - 1) * font_x) / 2;
- wintop = idat->mainwin->BorderTop;
- ClearMenuStrip(idat->mainwin);
- while (pos <= ((TITLES_PER_SIDE * 2) + LABELS + INFOS)) {
- if (pos <= TITLES_PER_SIDE)
- read_line(idat->mainwin, winleft,
- wintop + 10 + pos * (font_y + 6),
- tdat->sidea[pos - 1],
- &pos,
- FALSE);
- else if (pos <= (TITLES_PER_SIDE * 2))
- read_line(idat->mainwin, winleft + TITLE_LENGTH * font_x,
- wintop + 10 + (pos - TITLES_PER_SIDE) * (font_y + 6),
- tdat->sideb[pos - TITLES_PER_SIDE - 1],
- &pos,
- FALSE);
- else if (pos <= (TITLES_PER_SIDE * 2 + LABELS))
- {
- if (pos == (TITLES_PER_SIDE * 2 + 1))
- big = tdat->size.line1_bold;
- else
- big = tdat->size.line2_bold;
- read_line(idat->mainwin, winleft,
- wintop + 10 + (pos - TITLES_PER_SIDE + 1) * (font_y + 6),
- tdat->label[pos - TITLES_PER_SIDE * 2 - 1],
- &pos,
- big);
- }
- else
- read_line(idat->mainwin, winleft,
- wintop + 10 + (pos - TITLES_PER_SIDE + 2) * (font_y + 6),
- tdat->info[pos - TITLES_PER_SIDE * 2 - LABELS - 1],
- &pos,
- FALSE);
- pos++;
- }
- ResetMenuStrip(idat->mainwin, idat->mainmenu);
- idat->filesaved = FALSE;
- }
-
- LONG get_length(char *tapeline)
- {
- LONG i;
-
- i = strlen(tapeline);
- while ((i > 0) && (0 == memcmp(tapeline + i - 1, " ", 1)))
- i--;
- return i;
- }
-
- LONG how_many(char *tapeside[TITLES_PER_SIDE])
- {
- LONG i = TITLES_PER_SIDE;
-
- while ((i > 0) && (get_length(tapeside[i - 1]) == 0))
- i--;
- return i;
- }
-
- void exp_ascii(struct IntDat *idat, struct PrefDat *prefs, struct TapeDat *tdat)
- {
- BPTR datei;
- char bpath[MAXPATHLEN],
- fpath[MAXPATHLEN],
- bfile[MAXFILELEN];
- LONG length,
- st_len,
- r_len = 0,
- i,
- j;
- BOOL doit,
- again;
-
- busy(idat->mainwin);
- strcpy(bpath, prefs->exppath);
- strcpy(bfile, idat->expfile);
- length = strlen(bfile);
- if (0 == strcmp(bfile + length - 4, tpcext_str))
- bfile[length - 4] = '\0';
- do {
- doit = TRUE;
- again = FALSE;
- if (asl_fr(idat, prefs, idat->mainwin, ASLSAVEEXP, bpath, bfile))
- {
- length = strlen(bfile);
- if (length >= 4)
- {
- if (0 != strcmp(bfile + length - 4, ascext_str))
- strcat(bfile, ascext_str);
- }
- else
- strcat(bfile, ascext_str);
- strcpy(fpath, bpath);
- if (AddPart(fpath, bfile, MAXPATHLEN))
- {
- datei = Open(fpath, MODE_OLDFILE);
- if (datei)
- {
- doit = ask_overwrite(idat, fpath);
- if (! doit)
- again = TRUE;
- }
- Close(datei);
- if (doit)
- {
- datei = Open(fpath, MODE_NEWFILE);
- if (datei)
- {
- length = 0;
- st_len = get_length(tdat->label[0]);
- if (st_len > 0)
- {
- length += Write(datei, tdat->label[0], st_len);
- length += Write(datei, "\n", 1);
- r_len += st_len + 1;
- }
- st_len = get_length(tdat->label[1]);
- if (st_len > 0)
- {
- length += Write(datei, tdat->label[1], st_len);
- length += Write(datei, "\n", 1);
- r_len += st_len + 1;
- }
- j = how_many(tdat->sidea);
- if (j > 0)
- {
- st_len = get_length(tdat->sidea[0]);
- length += Write(datei, "A:", 2);
- length += Write(datei, tdat->sidea[0], st_len);
- length += Write(datei, "\n", 1);
- r_len += st_len + 3;
- if (j > 1)
- {
- for (i = 1; i < j; i++)
- {
- st_len = get_length(tdat->sidea[i]);
- length += Write(datei, " ", 2);
- length += Write(datei, tdat->sidea[i], st_len);
- length += Write(datei, "\n", 1);
- r_len += st_len + 3;
- }
- }
- }
- j = how_many(tdat->sideb);
- if (j > 0)
- {
- st_len = get_length(tdat->sideb[0]);
- length += Write(datei, "B:", 2);
- length += Write(datei, tdat->sideb[0], st_len);
- length += Write(datei, "\n", 1);
- r_len += st_len + 3;
- if (j > 1)
- {
- for (i = 1; i < j; i++)
- {
- st_len = get_length(tdat->sideb[i]);
- length += Write(datei, " ", 2);
- length += Write(datei, tdat->sideb[i], st_len);
- length += Write(datei, "\n", 1);
- r_len += st_len + 3;
- }
- }
- }
- if (length != r_len)
- fehler(idat, MSG_SAVE_ERROR, fpath);
- else
- {
- strcpy(prefs->exppath, bpath);
- strcpy(idat->expfile, bfile);
- }
- }
- else
- fehler(idat, MSG_OPEN_ERROR, fpath);
- Close(datei);
- }
- }
- else
- fehler(idat, MSG_PATH_ERROR, fpath);
- }
- } while (again);
- unbusy(idat->mainwin);
- }
-
- void copyta2prefs(UBYTE i, struct PrefDat *dest, struct TextAttr *source)
- {
- i--;
- strcpy(dest->fontname[i], source->ta_Name);
- dest->fontysize[i] = source->ta_YSize;
- dest->fontstyle[i] = source->ta_Style;
- dest->fontflags[i] = source->ta_Flags;
- }
-
- void copyprefs2ta(UBYTE i, struct TextAttr *dest, struct PrefDat *source)
- {
- i--;
- strcpy(dest->ta_Name, source->fontname[i]);
- dest->ta_YSize = source->fontysize[i];
- dest->ta_Style = source->fontstyle[i];
- dest->ta_Flags = source->fontflags[i];
- }
-
- void convertfontname(char *name, struct TextAttr *tfont)
- {
- if (strlen(tfont->ta_Name) > 5)
- {
- strmid(tfont->ta_Name, name, 1, strlen(tfont->ta_Name) - 4);
- stci_d(&name[strlen(name)], tfont->ta_YSize);
- }
- }
-
- void font_default(UBYTE i, struct PrefDat *prefs)
- {
- i--;
- strcpy(&prefs->fontname[i][0], "topaz.font");
- prefs->fontysize[i] = 8;
- prefs->fontstyle[i] = NULL;
- prefs->fontflags[i] = FPF_ROMFONT;
- }
-
- void pref_default(struct PrefDat *prefs)
- {
- font_default(1, prefs);
- font_default(2, prefs);
- strcpy(prefs->scrname, defpub_str);
- strcpy(prefs->tapepath, deftpath_str);
- strcpy(prefs->exppath, defxpath_str);
- prefs->centered = TRUE;
- prefs->icons = prefs->ff = prefs->ownscr = FALSE;
- prefs->scrid = PAL_MONITOR_ID | HIRESLACE_KEY;
- prefs->scrwidth = 640;
- prefs->scrheight = 512;
- prefs->scrdepth = 2;
- prefs->scroscan = OSCAN_TEXT;
- prefs->scrascroll = TRUE;
- prefs->winleft = prefs->wintop = 0;
- prefs->aslwidth = 200;
- prefs->aslheight = 230;
- }
-
- BOOL pref_load(struct IntDat *idat, struct PrefDat *prefs)
- {
- struct PrefDat newprefs;
- BPTR datei;
- char header[8],
- loadfile[MAXPATHLEN];
- LONG length;
- BOOL success = FALSE;
-
- strcpy(loadfile, idat->prefpath);
- if (AddPart(loadfile, idat->preffile, MAXPATHLEN))
- {
- datei = Open(loadfile, MODE_OLDFILE);
- if (datei)
- {
- length = Read(datei, header, 8);
- if (0 == memcmp(header, confhdr_str, 8))
- {
- length += Read(datei, &newprefs, sizeof newprefs);
- if (length == (8 + sizeof newprefs))
- {
- success = TRUE;
- *prefs = newprefs;
- }
- else
- fehler(idat, MSG_CONFIG_ERROR, loadfile);
- }
- else
- fehler(idat, MSG_NOCONFIG_ERROR, loadfile);
- Close(datei);
- }
- else
- if (! idat->firstload)
- fehler(idat, MSG_OPEN_ERROR, loadfile);
- }
- else
- if (! idat->firstload)
- fehler(idat, MSG_PATH_ERROR, loadfile);
- return success;
- }
-
- void pref_save(struct IntDat *idat, struct PrefDat *saveprefs)
- {
- BPTR datei;
- char savefile[MAXPATHLEN];
- LONG length;
-
- strcpy(savefile, idat->prefpath);
- if (AddPart(savefile, idat->preffile, MAXPATHLEN))
- {
- datei = Open(savefile, MODE_NEWFILE);
- if (datei)
- {
- length = Write(datei, confhdr_str, 8);
- length += Write(datei, saveprefs, sizeof *saveprefs);
- Close(datei);
- if (length != (8 + sizeof *saveprefs))
- fehler(idat, MSG_SAVE_ERROR, savefile);
- }
- else
- fehler(idat, MSG_OPEN_ERROR, savefile);
- }
- else
- fehler(idat, MSG_PATH_ERROR, savefile);
- }
-
- void init_idat(struct IntDat *idat, struct PrefDat *prefs, struct TapeDat *tdat,
- int argc, char **argv)
- {
- struct WBStartup *argmsg;
- struct WBArg *wb_arg;
- struct DiskObject *dob;
- int tmpargcnt;
- char *tool;
- BPTR olddir;
- BOOL noprefs = TRUE;
-
- strcpy(idat->scrname, "TAPECOVER.1");
- strcpy(idat->mainpath, defpath_str);
- strcpy(idat->prefpath, defpath_str);
- strcpy(idat->preffile, tcpname_str);
- idat->maskfont.ta_Name = idat->maskfontname;
- idat->genfont.ta_Name = idat->genfontname;
- idat->firstload = idat->filesaved = TRUE;
- idat->scr = NULL;
- idat->mainwin = NULL;
- idat->mainappwin = NULL;
- idat->mainmenu = NULL;
- idat->mainmsgport = NULL;
- idat->tmaskfont = NULL;
- idat->tgenfont = NULL;
- idat->mainglist = NULL;
- idat->maingad = NULL;
- idat->mainvi = NULL;
- LocalizeNewMenu(&idat->li, newmenu);
- if (argc == 0)
- {
- argmsg = (struct WBStartup *)argv;
- wb_arg = argmsg->sm_ArgList;
- if (dob = GetDiskObject(wb_arg->wa_Name))
- {
- tool = FindToolType(dob->do_ToolTypes,"SETTINGS");
- if (tool)
- {
- strcpy(idat->preffile, FilePart(tool));
- strmid(tool, idat->prefpath, 1, strlen(tool) - strlen(idat->preffile));
- noprefs = !pref_load(idat, prefs);
- }
- tool = FindToolType(dob->do_ToolTypes,"PATH");
- if (tool)
- strcpy(idat->mainpath, tool);
- tool = FindToolType(dob->do_ToolTypes,"FILE");
- if (tool)
- {
- strcpy(idat->loadpath, tool);
- load_start(idat, prefs, tdat);
- }
- FreeDiskObject(dob);
- }
- if (argmsg->sm_NumArgs > 1)
- {
- wb_arg++;
- if ((wb_arg->wa_Lock) && (*wb_arg->wa_Name))
- {
- olddir = CurrentDir(wb_arg->wa_Lock);
- strcpy(idat->loadpath, wb_arg->wa_Name);
- load_start(idat, prefs, tdat);
- CurrentDir(olddir);
- }
- }
- }
- else if (argc > 1)
- {
- for(tmpargcnt=1; tmpargcnt<argc; tmpargcnt++)
- {
- if ((0 == strcmp(argv[tmpargcnt], "SETTINGS")
- && (tmpargcnt < argc - 1)))
- {
- strcpy(idat->preffile, FilePart(argv[tmpargcnt + 1]));
- strmid(argv[tmpargcnt + 1], idat->prefpath, 1, strlen(argv[tmpargcnt + 1]) - strlen(idat->preffile));
- tmpargcnt++;
- noprefs = !pref_load(idat, prefs);
- }
- else if ((0 == strcmp(argv[tmpargcnt], "PATH") && (tmpargcnt < argc - 1)))
- {
- strcpy(idat->mainpath, argv[tmpargcnt + 1]);
- tmpargcnt++;
- }
- else if ((0 == strcmp(argv[tmpargcnt], "FILE") && (tmpargcnt < argc - 1)))
- {
- strcpy(idat->loadpath, argv[tmpargcnt + 1]);
- load_start(idat, prefs, tdat);
- tmpargcnt++;
- }
- }
- }
- if (noprefs)
- {
- strcpy(idat->prefpath, "");
- if (! pref_load(idat, prefs))
- {
- strcpy(idat->prefpath, idat->mainpath);
- strcpy(idat->preffile, tcpname_str);
- if (! pref_load(idat, prefs))
- pref_default(prefs);
- }
- }
- idat->firstload = FALSE;
- }
-
- BOOL open_all(struct IntDat *idat, struct PrefDat *prefs)
- {
- int i = 1;
- BOOL success = FALSE;
- char errorfont[MAXFONTLEN];
-
- copyprefs2ta(1, &idat->maskfont, prefs);
- if (! (idat->tmaskfont = OpenDiskFont(&idat->maskfont)))
- {
- convertfontname(errorfont, &idat->maskfont);
- fehler(idat, MSG_FONT_ERROR, errorfont);
- font_default(1, prefs);
- copyprefs2ta(1, &idat->maskfont, prefs);
- idat->tmaskfont = OpenDiskFont(&idat->maskfont);
- }
- copyprefs2ta(2, &idat->genfont, prefs);
- if (! (idat->tgenfont = OpenDiskFont(&idat->genfont)))
- {
- convertfontname(errorfont, &idat->genfont);
- fehler(idat, MSG_FONT_ERROR, errorfont);
- font_default(2, prefs);
- copyprefs2ta(2, &idat->genfont, prefs);
- idat->tgenfont = OpenDiskFont(&idat->genfont);
- }
- if (idat->tmaskfont && idat->tgenfont)
- {
- if (prefs->ownscr)
- {
- idat->scr = LockPubScreen(idat->scrname);
- while (idat->scr && (i < 100))
- {
- UnlockPubScreen(NULL, idat->scr);
- i++;
- stci_d(&idat->scrname[10], i);
- idat->scr = LockPubScreen(idat->scrname);
- }
- if (NULL == (idat->scr = OpenScreenTags(NULL, SA_Pens, (ULONG) pens,
- SA_PubName, idat->scrname,
- SA_Type, PUBLICSCREEN,
- SA_DisplayID, prefs->scrid,
- SA_Width, prefs->scrwidth,
- SA_Height, prefs->scrheight,
- SA_Depth, prefs->scrdepth,
- SA_Overscan, prefs->scroscan,
- SA_AutoScroll, prefs->scrascroll,
- TAG_END)))
- {
- fehler(idat, MSG_OPENSCREEN_ERROR, idat->scrname);
- prefs->ownscr = FALSE;
- if (NULL == (idat->scr = LockPubScreen(prefs->scrname)))
- {
- fehler(idat, MSG_SCREEN_ERROR, prefs->scrname);
- idat->scr = LockPubScreen(NULL);
- }
- }
- else
- PubScreenStatus(idat->scr, 0);
- }
- else
- {
- if (NULL == (idat->scr = LockPubScreen(prefs->scrname)))
- {
- fehler(idat, MSG_SCREEN_ERROR, prefs->scrname);
- idat->scr = LockPubScreen(NULL);
- }
- }
- if (idat->scr)
- {
- success = TRUE;
- idat->mainvi = GetVisualInfo(idat->scr, TAG_END);
- }
- else
- fehler(idat, MSG_SCREEN_ERROR, "Workbench Screen");
- }
- else
- {
- if (! idat->tmaskfont)
- {
- convertfontname(errorfont, &idat->maskfont);
- fehler(idat, MSG_FONT_ERROR, errorfont);
- }
- else
- {
- convertfontname(errorfont, &idat->genfont);
- fehler(idat, MSG_FONT_ERROR, errorfont);
- }
- }
- return success;
- }
-
- void close_all(struct IntDat *idat, struct PrefDat *prefs)
- {
- if (idat->mainvi)
- {
- FreeVisualInfo(idat->mainvi);
- idat->mainvi = NULL;
- }
- if (prefs->ownscr)
- CloseScreen(idat->scr);
- else
- UnlockPubScreen(NULL, idat->scr);
- idat->scr = NULL;
- if (idat->tmaskfont)
- {
- CloseFont(idat->tmaskfont);
- idat->tmaskfont = NULL;
- }
- if (idat->tgenfont)
- {
- CloseFont(idat->tgenfont);
- idat->tmaskfont = NULL;
- }
- }
-
- void refresh_prgads(struct Window *window, struct Gadget *gads[], struct PrefDat *prefs)
- {
- struct NameInfo displaymode;
- struct TextAttr font;
- static char scrmodename[DISPLAYNAMELEN],
- maskfontname[PREFSTRGADWIDTH],
- genfontname[PREFSTRGADWIDTH],
- fontstr[MAXFONTLEN];
- UWORD state;
-
- font.ta_Name = fontstr;
- if (prefs->ownscr)
- state = 1;
- else
- state = 0;
- GT_SetGadgetAttrs(gads[OWNSCR_GAD], window, NULL,
- GTMX_Active, state,
- TAG_END);
- GT_SetGadgetAttrs(gads[SCRMODE_GAD] ,window, NULL,
- GA_Disabled, !prefs->ownscr,
- TAG_END);
- GT_SetGadgetAttrs(gads[SCRNAMESTR_GAD] ,window, NULL,
- GA_Disabled, prefs->ownscr,
- TAG_END);
- GetDisplayInfoData(NULL, (UBYTE *) &displaymode,
- sizeof(displaymode), DTAG_NAME,
- prefs->scrid);
- strcpy(scrmodename, displaymode.Name);
- GT_SetGadgetAttrs(gads[SCRMODETXT_GAD], window, NULL,
- GTTX_Text, scrmodename,
- TAG_END);
- GT_SetGadgetAttrs(gads[ICONS_GAD], window, NULL,
- GTCB_Checked, prefs->icons,
- TAG_END);
- GT_SetGadgetAttrs(gads[FORMFEED_GAD], window, NULL,
- GTCB_Checked, prefs->ff,
- TAG_END);
- if (prefs->centered)
- state = 1;
- else
- state = 0;
- GT_SetGadgetAttrs(gads[CENTERED_GAD], window, NULL,
- GTMX_Active, state,
- TAG_END);
- GT_SetGadgetAttrs(gads[TAPEPATHTXT_GAD], window, NULL,
- GTTX_Text, prefs->tapepath,
- TAG_END);
- GT_SetGadgetAttrs(gads[EXPPATHTXT_GAD], window, NULL,
- GTTX_Text, prefs->exppath,
- TAG_END);
- copyprefs2ta(1, &font, prefs);
- convertfontname(maskfontname, &font);
- GT_SetGadgetAttrs(gads[MASKFONTTXT_GAD], window, NULL,
- GTTX_Text, maskfontname,
- TAG_END);
- copyprefs2ta(2, &font, prefs);
- convertfontname(genfontname, &font);
- GT_SetGadgetAttrs(gads[GENFONTTXT_GAD], window, NULL,
- GTTX_Text, genfontname,
- TAG_END);
- }
-
- BOOL prefs_window(struct IntDat *idat, struct PrefDat *newprefs)
- {
- struct Window *pr_window;
- struct IntuiMessage *msg;
- struct NewGadget ng;
- struct Gadget *pr_glist,
- *pr_gad,
- *pr_gads[15],
- *msg_gad;
- struct TextAttr newfont;
- APTR *pr_VisualInfo;
- BOOL done = FALSE,
- doit = FALSE;
- WORD wintop,
- winwidth,
- winheight,
- xsize,
- ysize,
- hbor;
- FLOAT gaddis;
- char *mxscrgads[3],
- *mxwingads[3],
- *strgad,
- newfontstr[MAXFONTLEN];
- ULONG msg_class;
- UWORD msg_code;
- int gad_key[17];
-
- gad_key[0] = getgadkey(GetString(&idat->li, MSG_OPEN_GAD));
- gad_key[1] = getgadkey(GetString(&idat->li, MSG_SAVEAS_GAD));
- gad_key[2] = getgadkey(GetString(&idat->li, MSG_SAVE_GAD));
- gad_key[3] = getgadkey(GetString(&idat->li, MSG_OK_GAD));
- gad_key[4] = getgadkey(GetString(&idat->li, MSG_DEFAULT_GAD));
- gad_key[5] = getgadkey(GetString(&idat->li, MSG_CANCEL_GAD));
- gad_key[6] = getgadkey(GetString(&idat->li, MSG_PUBSCR_GAD));
- gad_key[7] = getgadkey(GetString(&idat->li, MSG_OWNSCR_GAD));
- gad_key[8] = getgadkey(GetString(&idat->li, MSG_SCRMODE_GAD));
- gad_key[9] = getgadkey(GetString(&idat->li, MSG_ICONS_GAD));
- gad_key[10] = getgadkey(GetString(&idat->li, MSG_FORMFEED_GAD));
- gad_key[11] = getgadkey(GetString(&idat->li, MSG_SNAPSHOT_GAD));
- gad_key[12] = getgadkey(GetString(&idat->li, MSG_CENTERED_GAD));
- gad_key[13] = getgadkey(GetString(&idat->li, MSG_TAPEPATH_GAD));
- gad_key[14] = getgadkey(GetString(&idat->li, MSG_EXPPATH_GAD));
- gad_key[15] = getgadkey(GetString(&idat->li, MSG_MASKFONT_GAD));
- gad_key[16] = getgadkey(GetString(&idat->li, MSG_GENFONT_GAD));
- newfont.ta_Name = newfontstr;
- newprefs->winleft = idat->mainwin->LeftEdge;
- newprefs->wintop = idat->mainwin->TopEdge;
- pr_VisualInfo = GetVisualInfo(idat->scr, TAG_END);
- xsize = idat->tgenfont->tf_XSize;
- ysize = idat->tgenfont->tf_YSize;
- wintop = idat->scr->WBorTop + idat->scr->Font->ta_YSize + 1;
- hbor = idat->scr->WBorLeft + idat->scr->WBorRight;
- winwidth = hbor + (PREFGADWIDTH + PREFSTRGADWIDTH) * xsize + 60;
- if (hbor + 30 + (3 * MAINGADWIDTH * xsize) > winwidth)
- winwidth = hbor + 30 + (3 * MAINGADWIDTH * xsize);
- pr_gad = CreateContext(&pr_glist);
- ng.ng_TextAttr = &idat->genfont;
- ng.ng_VisualInfo = pr_VisualInfo;
- mxscrgads[0] = GetString(&idat->li, MSG_PUBSCR_GAD);
- mxscrgads[1] = GetString(&idat->li, MSG_OWNSCR_GAD);
- mxscrgads[2] = NULL;
- ng.ng_Width = 2 * xsize;
- ng.ng_Height = ysize;
- ng.ng_LeftEdge = idat->scr->WBorLeft + 20;
- ng.ng_TopEdge = wintop + 15;
- ng.ng_GadgetID = OWNSCR_GAD;
- ng.ng_Flags = PLACETEXT_RIGHT;
- pr_gads[OWNSCR_GAD] = pr_gad = CreateGadget(MX_KIND, pr_gad, &ng, GT_Underscore, '_',
- GTMX_Labels, mxscrgads,
- GTMX_Spacing, 10,
- GTMX_Scaled, TRUE,
- TAG_END);
- ng.ng_Width = 10 + PREFGADWIDTH * xsize;
- ng.ng_Height = ysize + 6;
- ng.ng_TopEdge += 2 * (ysize + 10);
- ng.ng_GadgetText = GetString(&idat->li, MSG_SCRMODE_GAD);
- ng.ng_GadgetID = SCRMODE_GAD;
- ng.ng_Flags = 0;
- pr_gads[SCRMODE_GAD] = pr_gad = CreateGadget(BUTTON_KIND, pr_gad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_Width = 3 * xsize;
- ng.ng_Height = ysize;
- ng.ng_TopEdge += ysize + 15;
- ng.ng_GadgetText = GetString(&idat->li, MSG_ICONS_GAD);
- ng.ng_GadgetID = ICONS_GAD;
- ng.ng_Flags = PLACETEXT_RIGHT;
- pr_gads[ICONS_GAD] = pr_gad = CreateGadget(CHECKBOX_KIND, pr_gad, &ng, GT_Underscore, '_',
- GTCB_Scaled, TRUE,
- TAG_END);
- ng.ng_TopEdge += ysize + 10;
- ng.ng_GadgetText = GetString(&idat->li, MSG_FORMFEED_GAD);
- ng.ng_GadgetID = FORMFEED_GAD;
- pr_gads[FORMFEED_GAD] = pr_gad = CreateGadget(CHECKBOX_KIND, pr_gad, &ng, GT_Underscore, '_',
- GTCB_Scaled, TRUE,
- TAG_END);
- ng.ng_Width = 10 + PREFGADWIDTH * xsize;
- ng.ng_Height = ysize + 6;
- ng.ng_TopEdge += ysize + 13;
- ng.ng_GadgetText = GetString(&idat->li, MSG_TAPEPATH_GAD);
- ng.ng_GadgetID = TAPEPATH_GAD;
- ng.ng_Flags = 0;
- pr_gads[TAPEPATH_GAD] = pr_gad = CreateGadget(BUTTON_KIND, pr_gad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_TopEdge += ysize + 15;
- ng.ng_GadgetText = GetString(&idat->li, MSG_EXPPATH_GAD);
- ng.ng_GadgetID = EXPPATH_GAD;
- pr_gads[EXPPATH_GAD] = pr_gad = CreateGadget(BUTTON_KIND, pr_gad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_TopEdge += ysize + 15;
- ng.ng_GadgetText = GetString(&idat->li, MSG_MASKFONT_GAD);
- ng.ng_GadgetID = MASKFONT_GAD;
- pr_gads[MASKFONT_GAD] = pr_gad = CreateGadget(BUTTON_KIND, pr_gad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_TopEdge += ysize + 15;
- ng.ng_GadgetText = GetString(&idat->li, MSG_GENFONT_GAD);
- ng.ng_GadgetID = GENFONT_GAD;
- pr_gads[GENFONT_GAD] = pr_gad = CreateGadget(BUTTON_KIND, pr_gad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_Width = xsize * PREFSTRGADWIDTH;
- ng.ng_LeftEdge = idat->scr->WBorLeft + PREFGADWIDTH * xsize + 40;
- ng.ng_TopEdge = wintop + 13;
- ng.ng_GadgetText = NULL;
- ng.ng_GadgetID = SCRNAMESTR_GAD;
- ng.ng_Flags = 0;
- pr_gads[SCRNAMESTR_GAD] = pr_gad = CreateGadget(STRING_KIND, pr_gad, &ng, GTST_String, newprefs->scrname,
- GTST_MaxChars, 100,
- GA_Disabled, newprefs->ownscr,
- TAG_END);
- if (pr_gad)
- strgad = ((struct StringInfo *) (pr_gad->SpecialInfo))->Buffer;
- ng.ng_TopEdge += 2 * ysize + 22;
- ng.ng_GadgetID = SCRMODETXT_GAD;
- pr_gads[SCRMODETXT_GAD] = pr_gad = CreateGadget(TEXT_KIND, pr_gad, &ng, GTTX_Border, TRUE,
- TAG_END);
- mxwingads[0] = GetString(&idat->li, MSG_SNAPSHOT_GAD);
- mxwingads[1] = GetString(&idat->li, MSG_CENTERED_GAD);
- mxwingads[2] = NULL;
- ng.ng_Width = 2 * xsize;
- ng.ng_Height -= 6;
- ng.ng_TopEdge += ysize + 16;
- ng.ng_GadgetID = CENTERED_GAD;
- ng.ng_Flags = PLACETEXT_RIGHT;
- pr_gads[CENTERED_GAD] = pr_gad = CreateGadget(MX_KIND, pr_gad, &ng, GT_Underscore, '_',
- GTMX_Labels, mxwingads,
- GTMX_Spacing, 10,
- GTMX_Scaled, TRUE,
- TAG_END);
- ng.ng_Width = xsize * PREFSTRGADWIDTH;
- ng.ng_Height += 6;
- ng.ng_TopEdge += 2 * ysize + 22;
- ng.ng_GadgetID = TAPEPATHTXT_GAD;
- ng.ng_Flags = 0;
- pr_gads[TAPEPATHTXT_GAD] = pr_gad = CreateGadget(TEXT_KIND, pr_gad, &ng, GTTX_Border, TRUE,
- TAG_END);
- ng.ng_TopEdge += ysize + 15;
- ng.ng_GadgetID = EXPPATHTXT_GAD;
- pr_gads[EXPPATHTXT_GAD] = pr_gad = CreateGadget(TEXT_KIND, pr_gad, &ng, GTTX_Border, TRUE,
- TAG_END);
- ng.ng_TopEdge += ysize + 15;
- ng.ng_GadgetID = MASKFONTTXT_GAD;
- pr_gads[MASKFONTTXT_GAD] = pr_gad = CreateGadget(TEXT_KIND, pr_gad, &ng, GTTX_Border, TRUE,
- TAG_END);
- ng.ng_TopEdge += ysize + 15;
- ng.ng_GadgetID = GENFONTTXT_GAD;
- pr_gads[GENFONTTXT_GAD] = pr_gad = CreateGadget(TEXT_KIND, pr_gad, &ng, GTTX_Border, TRUE,
- TAG_END);
- ng.ng_Width = 10 + MAINGADWIDTH * xsize;
- gaddis = (winwidth - 3 * ng.ng_Width - hbor) / 4;
- ng.ng_Height = 5 + ysize;
- ng.ng_LeftEdge = idat->scr->WBorLeft + gaddis;
- ng.ng_TopEdge += ysize + 25;
- ng.ng_GadgetText = GetString(&idat->li, MSG_OPEN_GAD);
- ng.ng_GadgetID = MSG_OPEN_GAD;
- ng.ng_Flags = 0;
- pr_gad = CreateGadget(BUTTON_KIND, pr_gad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_LeftEdge += gaddis + ng.ng_Width;
- ng.ng_GadgetText = GetString(&idat->li, MSG_SAVEAS_GAD);
- ng.ng_GadgetID = MSG_SAVEAS_GAD;
- pr_gad = CreateGadget(BUTTON_KIND, pr_gad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_LeftEdge += gaddis + ng.ng_Width;
- ng.ng_GadgetText = GetString(&idat->li, MSG_SAVE_GAD);
- ng.ng_GadgetID = MSG_SAVE_GAD;
- pr_gad = CreateGadget(BUTTON_KIND, pr_gad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_TopEdge += ysize + 10;
- ng.ng_LeftEdge = idat->scr->WBorLeft + gaddis;
- ng.ng_GadgetText = GetString(&idat->li, MSG_OK_GAD);
- ng.ng_GadgetID = MSG_OK_GAD;
- pr_gad = CreateGadget(BUTTON_KIND, pr_gad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_LeftEdge += gaddis + ng.ng_Width;
- ng.ng_GadgetText = GetString(&idat->li, MSG_DEFAULT_GAD);
- ng.ng_GadgetID = MSG_DEFAULT_GAD;
- pr_gad = CreateGadget(BUTTON_KIND, pr_gad, &ng, GT_Underscore, '_',
- TAG_END);
- ng.ng_LeftEdge += gaddis + ng.ng_Width;
- ng.ng_GadgetText = GetString(&idat->li, MSG_CANCEL_GAD);
- ng.ng_GadgetID = MSG_CANCEL_GAD;
- pr_gad = CreateGadget(BUTTON_KIND, pr_gad, &ng, GT_Underscore, '_',
- TAG_END);
- if (pr_gad)
- {
- winheight = wintop + idat->scr->WBorBottom +
- 11 * (ysize + 10) + 55;
- if ((winwidth <= idat->scr->Width) && (winheight <= idat->scr->Height))
- {
- if (pr_window = OpenWindowTags(NULL,
- WA_Left, (idat->scr->Width - winwidth) / 2,
- WA_Top, (idat->scr->Height - winheight) /2,
- WA_Width, winwidth,
- WA_Height, winheight,
- WA_Gadgets, pr_glist,
- WA_DragBar, TRUE,
- WA_DepthGadget, TRUE,
- WA_Activate, TRUE,
- WA_SmartRefresh, TRUE,
- WA_IDCMP, IDCMP_RAWKEY | IDCMP_VANILLAKEY |
- IDCMP_GADGETUP | IDCMP_GADGETDOWN |
- IDCMP_REFRESHWINDOW,
- WA_Title, GetString(&idat->li, MSG_PREF_WIN),
- WA_PubScreen, idat->scr,
- WA_ScreenTitle, name_str,
- TAG_END))
- {
- busy(idat->mainwin);
- GT_RefreshWindow(pr_window, NULL);
- box_bor(pr_window, pr_window->BorderLeft + 10, wintop + 5,
- winwidth - pr_window->BorderRight - 10,
- wintop + 9 * (ysize + 10) + 42);
- refresh_prgads(pr_window, pr_gads, newprefs);
- while (!done)
- {
- WaitPort(pr_window->UserPort);
- while ((!done) &&
- (msg = GT_GetIMsg(pr_window->UserPort)))
- {
- msg_gad = (struct Gadget *)msg->IAddress;
- msg_class = msg->Class;
- msg_code = msg->Code;
- GT_ReplyIMsg(msg);
- switch (msg_class) {
- case IDCMP_GADGETDOWN:
- switch (msg_gad->GadgetID) {
- case OWNSCR_GAD :
- if (msg_code == 0)
- newprefs->ownscr = FALSE;
- else if (msg_code == 1)
- newprefs->ownscr = TRUE;
- break;
- case CENTERED_GAD :
- if (msg_code == 0)
- {
- newprefs->winleft = idat->mainwin->LeftEdge;
- newprefs->wintop = idat->mainwin->TopEdge;
- newprefs->centered = FALSE;
- }
- else if (msg_code == 1)
- newprefs->centered = TRUE;
- break;
- default:
- break;
- }
- refresh_prgads(pr_window, pr_gads, newprefs);
- break;
- case IDCMP_GADGETUP:
- switch (msg_gad->GadgetID) {
- case MSG_OPEN_GAD :
- if (asl_fr(idat, newprefs, pr_window, ASLLOADPREF,
- idat->prefpath, idat->preffile))
- {
- pref_load(idat, newprefs);
- GT_SetGadgetAttrs(pr_gads[SCRNAMESTR_GAD] ,pr_window, NULL,
- GTST_String, newprefs->scrname,
- GA_Disabled, newprefs->ownscr,
- TAG_END);
- }
- break;
- case MSG_SAVEAS_GAD :
- if (asl_fr(idat, newprefs, pr_window, ASLSAVEPREF,
- idat->prefpath, idat->preffile))
- {
- newprefs->winleft = idat->mainwin->LeftEdge;
- newprefs->wintop = idat->mainwin->TopEdge;
- pref_save(idat, newprefs);
- }
- break;
- case MSG_SAVE_GAD :
- newprefs->winleft = idat->mainwin->LeftEdge;
- newprefs->wintop = idat->mainwin->TopEdge;
- pref_save(idat, newprefs);
- break;
- case MSG_OK_GAD :
- doit = TRUE;
- done = TRUE;
- break;
- case MSG_DEFAULT_GAD :
- pref_default(newprefs);
- GT_SetGadgetAttrs(pr_gads[SCRNAMESTR_GAD] ,pr_window, NULL,
- GTST_String, newprefs->scrname,
- GA_Disabled, newprefs->ownscr,
- TAG_END);
- break;
- case MSG_CANCEL_GAD :
- done = TRUE;
- break;
- case SCRMODE_GAD :
- asl_smr(idat, pr_window, newprefs);
- break;
- case ICONS_GAD :
- newprefs->icons = !newprefs->icons;
- break;
- case FORMFEED_GAD :
- newprefs->ff = !newprefs->ff;
- break;
- case TAPEPATH_GAD :
- asl_fr(idat, newprefs, pr_window, ASLPATH, newprefs->tapepath, NULL);
- break;
- case EXPPATH_GAD :
- asl_fr(idat, newprefs, pr_window, ASLPATH, newprefs->exppath, NULL);
- break;
- case MASKFONT_GAD :
- copyprefs2ta(1, &newfont, newprefs);
- if (asl_for(idat, newprefs, pr_window, &newfont))
- copyta2prefs(1, newprefs, &newfont);
- break;
- case GENFONT_GAD :
- copyprefs2ta(2, &newfont, newprefs);
- if (asl_for(idat, newprefs, pr_window, &newfont))
- copyta2prefs(2, newprefs, &newfont);
- break;
- default:
- break;
- }
- refresh_prgads(pr_window, pr_gads, newprefs);
- break;
- case IDCMP_VANILLAKEY:
- if (msg_code == gad_key[0])
- {
- if (asl_fr(idat, newprefs, pr_window, ASLLOADPREF,
- idat->prefpath, idat->preffile))
- {
- pref_load(idat, newprefs);
- GT_SetGadgetAttrs(pr_gads[SCRNAMESTR_GAD] ,pr_window, NULL,
- GTST_String, newprefs->scrname,
- GA_Disabled, newprefs->ownscr,
- TAG_END);
- }
- }
- else if (msg_code == gad_key[1])
- {
- if (asl_fr(idat, newprefs, pr_window, ASLSAVEPREF,
- idat->prefpath, idat->preffile))
- {
- newprefs->winleft = idat->mainwin->LeftEdge;
- newprefs->wintop = idat->mainwin->TopEdge;
- pref_save(idat, newprefs);
- }
- }
- else if (msg_code == gad_key[2])
- {
- newprefs->winleft = idat->mainwin->LeftEdge;
- newprefs->wintop = idat->mainwin->TopEdge;
- pref_save(idat, newprefs);
- }
- else if (msg_code == gad_key[3])
- {
- doit = TRUE;
- done = TRUE;
- }
- else if (msg_code == gad_key[4])
- {
- pref_default(newprefs);
- GT_SetGadgetAttrs(pr_gads[SCRNAMESTR_GAD] ,pr_window, NULL,
- GTST_String, newprefs->scrname,
- GA_Disabled, newprefs->ownscr,
- TAG_END);
- }
- else if (msg_code == gad_key[5])
- done = TRUE;
- else if (msg_code == gad_key[6])
- newprefs->ownscr = FALSE;
- else if (msg_code == gad_key[7])
- newprefs->ownscr = TRUE;
- else if (msg_code == gad_key[8])
- asl_smr(idat, pr_window, newprefs);
- else if (msg_code == gad_key[9])
- newprefs->icons = !newprefs->icons;
- else if (msg_code == gad_key[10])
- newprefs->ff = !newprefs->ff;
- else if (msg_code == gad_key[11])
- {
- newprefs->winleft = idat->mainwin->LeftEdge;
- newprefs->wintop = idat->mainwin->TopEdge;
- newprefs->centered = FALSE;
- }
- else if (msg_code == gad_key[12])
- newprefs->centered = TRUE;
- else if (msg_code == gad_key[13])
- asl_fr(idat, newprefs, pr_window, ASLPATH, newprefs->tapepath, NULL);
- else if (msg_code == gad_key[14])
- asl_fr(idat, newprefs, pr_window, ASLPATH, newprefs->exppath, NULL);
- else if (msg_code == gad_key[15])
- {
- copyprefs2ta(1, &newfont, newprefs);
- if (asl_for(idat, newprefs, pr_window, &newfont))
- copyta2prefs(1, newprefs, &newfont);
- }
- else if (msg_code == gad_key[16])
- {
- copyprefs2ta(2, &newfont, newprefs);
- if (asl_for(idat, newprefs, pr_window, &newfont))
- copyta2prefs(2, newprefs, &newfont);
- }
- refresh_prgads(pr_window, pr_gads, newprefs);
- break;
- case IDCMP_REFRESHWINDOW :
- GT_BeginRefresh(pr_window);
- box_bor(pr_window, pr_window->BorderLeft + 10, wintop + 5,
- winwidth - pr_window->BorderRight - 10,
- wintop + 9 * (ysize + 10) + 42);
- GT_EndRefresh(pr_window, TRUE);
- break;
- default:
- break;
- }
- strcpy(newprefs->scrname, strgad);
- }
- }
- unbusy(idat->mainwin);
- CloseWindow(pr_window);
- FreeGadgets(pr_glist);
- FreeVisualInfo(pr_VisualInfo);
- }
- else
- fehler(idat, MSG_WIN_ERROR, GetString(&idat->li, MSG_PREF_WIN));
- }
- else
- fehler(idat, MSG_WINSIZE_ERROR, GetString(&idat->li, MSG_PREF_WIN));
- }
- else
- {
- FreeGadgets(pr_glist);
- fehler(idat, MSG_GAD_ERROR, GetString(&idat->li, MSG_PREF_WIN));
- }
- return doit;
- }
-
- BOOL get_input(struct IntDat *idat, struct PrefDat *prefs,
- struct PrefDat *newprefs, struct TapeDat *tdat)
- {
- struct IntuiMessage *msg;
- struct MenuItem *item;
- struct AppMessage *amsg;
- struct Gadget *msg_gad;
- struct WBArg *argptr;
- BPTR olddir;
- ULONG msg_class,
- winsig,
- appwinsig,
- signals;
- UWORD msg_code;
- UWORD menuNumber,
- menuNum,
- itemNum;
- int gad_key[8];
- BOOL done = FALSE,
- prefs_call = FALSE;
-
- gad_key[0] = getgadkey(GetString(&idat->li, MSG_NEW_GAD));
- gad_key[1] = getgadkey(GetString(&idat->li, MSG_OPEN_GAD));
- gad_key[2] = getgadkey(GetString(&idat->li, MSG_SAVE_GAD));
- gad_key[3] = getgadkey(GetString(&idat->li, MSG_SAVEAS_GAD));
- gad_key[4] = getgadkey(GetString(&idat->li, MSG_EDIT_GAD));
- gad_key[5] = getgadkey(GetString(&idat->li, MSG_MPRINT_GAD));
- gad_key[6] = getgadkey(GetString(&idat->li, MSG_PREFS_GAD));
- gad_key[7] = getgadkey(GetString(&idat->li, MSG_QUIT_GAD));
- winsig = 1L << idat->mainwin->UserPort->mp_SigBit;
- appwinsig = 1L << idat->mainmsgport->mp_SigBit;
- while ((!done) && (!prefs_call))
- {
- signals = Wait(winsig | appwinsig);
- if (signals & winsig)
- {
- while ((!done) && (!prefs_call) && (msg = GT_GetIMsg(idat->mainwin->UserPort)))
- {
- msg_gad = (struct Gadget *)msg->IAddress;
- msg_class = msg->Class;
- msg_code = msg->Code;
- GT_ReplyIMsg(msg);
- switch (msg_class) {
- case IDCMP_CLOSEWINDOW:
- done = TRUE;
- if (!idat->filesaved)
- done = ask_changed(idat, prefs, tdat);
- break;
- case IDCMP_GADGETUP:
- switch (msg_gad->GadgetID) {
- case MSG_NEW_GAD :
- if (! idat->filesaved)
- idat->filesaved = ask_changed(idat, prefs, tdat);
- if (idat->filesaved)
- {
- strcpy(idat->file, "");
- SetWindowTitles(idat->mainwin, GetString(&idat->li, MSG_UNNAMED), (UBYTE *) - 1);
- init_tdat(tdat, tdat_buf);
- write_dat(idat, tdat);
- idat->filesaved = TRUE;
- strcpy(idat->expfile, idat->file);
- }
- break;
- case MSG_OPEN_GAD :
- load(idat, prefs, tdat);
- break;
- case MSG_SAVE_GAD :
- if (strlen(idat->file) == 0)
- save_as(idat, prefs, tdat);
- else
- save(idat, prefs, tdat);
- break;
- case MSG_SAVEAS_GAD :
- save_as(idat, prefs, tdat);
- break;
- case MSG_EDIT_GAD :
- edit(idat, tdat);
- break;
- case MSG_MPRINT_GAD :
- print_dat(idat, prefs, tdat);
- break;
- case MSG_PREFS_GAD :
- if (! (prefs_call = prefs_window(idat, newprefs)))
- *newprefs = *prefs;
- break;
- case MSG_QUIT_GAD :
- done = TRUE;
- if (! idat->filesaved)
- done = ask_changed(idat, prefs, tdat);
- break;
- default:
- break;
- }
- break;
- case IDCMP_VANILLAKEY:
- if (msg_code == gad_key[0])
- {
- if (! idat->filesaved)
- idat->filesaved = ask_changed(idat, prefs, tdat);
- if (idat->filesaved)
- {
- strcpy(idat->file, "");
- SetWindowTitles(idat->mainwin, GetString(&idat->li, MSG_UNNAMED), (UBYTE *) - 1);
- init_tdat(tdat, tdat_buf);
- write_dat(idat, tdat);
- idat->filesaved = TRUE;
- strcpy(idat->expfile, idat->file);
- }
- }
- else if (msg_code == gad_key[1])
- load(idat, prefs, tdat);
- else if (msg_code == gad_key[2])
- if (strlen(idat->file) == 0)
- save_as(idat, prefs, tdat);
- else
- save(idat, prefs, tdat);
- else if (msg_code == gad_key[3])
- save_as(idat, prefs, tdat);
- else if (msg_code == gad_key[4])
- edit(idat, tdat);
- else if (msg_code == gad_key[5])
- print_dat(idat, prefs, tdat);
- else if (msg_code == gad_key[6])
- {
- if (! (prefs_call = prefs_window(idat, newprefs)))
- *newprefs = *prefs;
- }
- else if (msg_code == gad_key[7])
- {
- done = TRUE;
- if (! idat->filesaved)
- done = ask_changed(idat, prefs, tdat);
- }
- break;
- case IDCMP_MENUPICK:
- menuNumber = msg_code;
- while ((menuNumber != MENUNULL) && (!done))
- {
- item = ItemAddress(idat->mainmenu, menuNumber);
- menuNum = MENUNUM(menuNumber);
- itemNum = ITEMNUM(menuNumber);
- switch (menuNum) {
- case 0:
- switch (itemNum) {
- case 0:
- if (! idat->filesaved)
- idat->filesaved = ask_changed(idat, prefs, tdat);
- if (idat->filesaved)
- {
- strcpy(idat->file, "");
- strcpy(idat->expfile, idat->file);
- SetWindowTitles(idat->mainwin, GetString(&idat->li, MSG_UNNAMED), (UBYTE *) - 1);
- init_tdat(tdat, tdat_buf);
- write_dat(idat, tdat);
- idat->filesaved = TRUE;
- }
- break;
- case 1:
- load(idat, prefs, tdat);
- break;
- case 3:
- if (strlen(idat->file) == 0)
- save_as(idat, prefs, tdat);
- else
- save(idat, prefs, tdat);
- break;
- case 4:
- save_as(idat, prefs, tdat);
- break;
- case 6:
- print_dat(idat, prefs, tdat);
- break;
- case 8:
- edit(idat, tdat);
- break;
- case 10:
- if (! (prefs_call = prefs_window(idat, newprefs)))
- *newprefs = *prefs;
- break;
- case 12:
- info(idat);
- break;
- case 14:
- done = TRUE;
- if (! idat->filesaved)
- done = ask_changed(idat, prefs, tdat);
- break;
- default:
- break;
- }
- break;
- case 1:
- switch (itemNum) {
- case 0:
- tdat->size.line1_bold = !tdat->size.line1_bold;
- write_dat(idat, tdat);
- break;
- case 1:
- tdat->size.line2_bold = !tdat->size.line2_bold;
- write_dat(idat, tdat);
- break;
- case 3:
- if (! idat->filesaved)
- idat->filesaved = ask_changed(idat, prefs, tdat);
- if (idat->filesaved)
- {
- idat->filesaved = FALSE;
- clear_sides(tdat->sidea[0]);
- write_dat(idat, tdat);
- }
- break;
-
- default:
- break;
- }
- break;
- case 2:
- switch (itemNum) {
- case 0:
- exp_ascii(idat, prefs, tdat);
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- menuNumber = item->NextSelect;
- }
- break;
- case IDCMP_REFRESHWINDOW :
- GT_BeginRefresh(idat->mainwin);
- write_mask(idat);
- write_dat(idat, tdat);
- GT_EndRefresh(idat->mainwin, TRUE);
- break;
- default:
- break;
- }
- item = ItemAddress(idat->mainmenu, FULLMENUNUM(1, 0, NOSUB));
- if (! (((item->Flags & CHECKED) == CHECKED) && (tdat->size.line1_bold)))
- {
- tdat->size.line1_bold = ((item->Flags & CHECKED) == CHECKED);
- write_dat(idat, tdat);
- }
- item = ItemAddress(idat->mainmenu, FULLMENUNUM(1, 1, NOSUB));
- if (! (((item->Flags & CHECKED) == CHECKED) && (tdat->size.line2_bold)))
- {
- tdat->size.line2_bold = ((item->Flags & CHECKED) == CHECKED);
- write_dat(idat, tdat);
- }
- }
- }
- if (signals & appwinsig)
- {
- while (amsg = (struct AppMessage *)GetMsg(idat->mainmsgport))
- {
- argptr = amsg->am_ArgList;
- if ((argptr->wa_Lock) && (*argptr->wa_Name))
- {
- olddir = CurrentDir(argptr->wa_Lock);
- strcpy(idat->loadpath, argptr->wa_Name);
- load_direct(idat, prefs, tdat);
- CurrentDir(olddir);
- }
- ReplyMsg((struct Message *) amsg);
- }
- }
- }
- while (amsg = (struct AppMessage *)GetMsg(idat->mainmsgport))
- ReplyMsg((struct Message *)amsg);
- return prefs_call;
- }
-
- void main(int argc, char **argv)
- {
- if (LocaleBase = OpenLibrary("locale.library",38L))
- {
- idat.li.li_LocaleBase = LocaleBase;
- idat.li.li_Catalog = OpenCatalog(NULL, cat_str,
- OC_BuiltInCodeSet, 0,
- OC_Version, 2,
- TAG_END);
- }
- if (IntuitionBase = OpenLibrary("intuition.library",37L))
- {
- if (AslBase = OpenLibrary("asl.library",38L))
- {
- if (GfxBase = OpenLibrary("graphics.library",37L))
- {
- if (DiskfontBase = OpenLibrary("diskfont.library",37L))
- {
- if (IconBase = OpenLibrary("icon.library", 37L))
- {
- if (GadToolsBase = OpenLibrary("gadtools.library",37L))
- {
- init_tdat(&tdat, tdat_buf);
- init_idat(&idat, &prefs, &tdat, argc, argv);
- if (open_all(&idat, &prefs))
- {
- if (open_mainwin(&idat, &prefs, &tdat))
- {
- newprefs = prefs;
- while (get_input(&idat, &prefs, &newprefs, &tdat))
- {
- close_mainwin(&idat);
- close_all(&idat, &prefs);
- prefs = newprefs;
- if (open_all(&idat, &prefs))
- {
- if (!open_mainwin(&idat, &prefs, &tdat))
- break;
- }
- else
- break;
- }
- }
- close_mainwin(&idat);
- }
- close_all(&idat, &prefs);
- CloseLibrary(GadToolsBase);
- }
- else
- fehler(&idat, MSG_LIB_ERROR, "gadtools.library >= V37");
- CloseLibrary(IconBase);
- }
- else
- fehler(&idat, MSG_LIB_ERROR, "icon.library >= V37");
- CloseLibrary(DiskfontBase);
- }
- else
- fehler(&idat, MSG_LIB_ERROR, "diskfont.library >= V37");
- CloseLibrary(GfxBase);
- }
- else
- fehler(&idat, MSG_LIB_ERROR, "graphics.library >= V37");
- CloseLibrary(AslBase);
- }
- else
- fehler(&idat, MSG_LIB_ERROR, "asl.library >= V38");
- CloseLibrary(IntuitionBase);
- }
- else
- {
- printf("%s\n%s\nintuition.library >= V37\n", GetString(&idat.li, MSG_ERROR),
- GetString(&idat.li, MSG_LIB_ERROR));
- if (argc == 0)
- getchar();
- }
- if (LocaleBase)
- {
- CloseCatalog(idat.li.li_Catalog);
- CloseLibrary(LocaleBase);
- }
- }
-
-