VOID insa_gtypes(LONG tree, BYTE *ptypes) { WORD i, j; BYTE *pstr, doctype[4]; j = 0; *ptypes = '\0'; for(i=0; i<8; i++) { pstr = &doctype[0]; inf_sget(tree, APDFTYPE+i, pstr); if (*pstr) { if (j != 0) ptypes[j++] = ','; strcpy(&ptypes[j], "*.*"); strcpy(&ptypes[j+2], pstr); j += 2 + (WORD)strlen(pstr); } } }
WORD insa_dial(LONG tree, WORD nicon, WORD numics) { WORD firstslot, nstate, ystate, i; WORD touchob, oicon, value; WORD mx, my, kret, bret, cont; BYTE *pstr, doctype[4]; GRECT pt; /* draw the form */ show_hide(FMD_START, tree); /* init for while loop by forcing initial fs_newdir call */ cont = TRUE; while ( cont ) { firstslot = 6; for (i = 0; i < firstslot; i++) { pstr = &doctype[0]; inf_sget(tree, APDFTYPE+i, pstr); if (*pstr == '\0') firstslot = i; } touchob = form_do((OBJECT FAR *)tree, APDFTYPE+firstslot); graf_mkstate(&mx, &my, &kret, &bret); value = nstate = ystate = 0; touchob &= 0x7fff; switch ( touchob ) { case APINST: case APREMV: case APCNCL: cont = FALSE; break; case APFUPARO: value = -1; break; case APFDNARO: value = 1; break; case APGEM: nstate = SELECTED; ystate = DISABLED; break; case APDOS: case APPARMS: nstate = LWGET(OB_STATE(APNMEM)); ystate = LWGET(OB_STATE(APYMEM)); if ( ystate == DISABLED ) { nstate = SELECTED; ystate = NORMAL; } break; case APFSVSLI: ob_actxywh(tree, APFSVELE, &pt); pt.g_x -= 3; pt.g_w += 6; if ( rc_inside(&pt, mx, my) ) goto dofelev; value = (my <= pt.g_y) ? -1 : 1; break; case APFSVELE: dofelev: wind_update(3); ob_relxywh(tree, APFSVSLI, &pt); pt.g_x += 3; pt.g_w -= 6; LWSET(OB_X(APFSVSLI), pt.g_x); LWSET(OB_WIDTH(APFSVSLI), pt.g_w); value = graf_slidebox((OBJECT FAR *)tree, APFSVSLI, APFSVELE, TRUE); pt.g_x -= 3; pt.g_w += 6; LWSET(OB_X(APFSVSLI), pt.g_x); LWSET(OB_WIDTH(APFSVSLI), pt.g_w); wind_update(2); #if M68000 value = (WORD)((LONG)value * (LONG)(numics-1) / 1000) - nicon; #else value = mul_div(value, numics-1, 1000) - nicon; #endif break; } if (nstate != ystate) { LWSET(OB_STATE(APNMEM), nstate); LWSET(OB_STATE(APYMEM), ystate); draw_fld(tree, APMEMBOX); } if (value) { oicon = nicon; nicon += value; if (nicon < 0) nicon = 0; if (nicon >= numics) nicon = numics - 1; if (oicon != nicon) { insa_elev(tree, nicon, numics); draw_fld(tree, APFTITLE); draw_fld(tree, APFSVSLI); draw_fld(tree, APFILEBO); } } } /* undraw the form */ show_hide(FMD_FINISH, tree); return(nicon); }
/* * File Selector input routine that takes control of the mouse * and keyboard, searchs and sort the directory, draws the file * selector, interacts with the user to determine a selection * or change of path, and returns to the application with * the selected path, filename, and exit button. */ WORD fs_input(BYTE *pipath, BYTE *pisel, WORD *pbutton, BYTE *pilabel) { register WORD touchob, value, fnum; WORD curr, count, sel; WORD mx, my; LONG tree; ULONG bitmask; BYTE *ad_fpath, *ad_fname, *ad_ftitle; WORD drive; WORD dclkret, cont, newlist, newsel, newdrive; register BYTE *pstr; GRECT pt; BYTE locstr[LEN_ZPATH+1], mask[LEN_ZFNAME+1], selname[LEN_FSNAME]; OBJECT *obj; TEDINFO *tedinfo; curr = 0; count = 0; /* get out quick if path is */ /* nullptr or if pts to null. */ if (pipath == NULL) return(FALSE); /* if path string is empty, */ /* set reasonable default */ if (*pipath == '\0') { strcpy(pipath,"A:\\*.*"); *pipath += dos_gdrv(); } /* get memory for the filename buffer */ /* & the array that points to it */ for (nm_files = MAX_NM_FILES; nm_files >= MIN_NM_FILES; nm_files /= 2) { ad_fsnames = (BYTE *)dos_alloc(nm_files*(LEN_FSNAME+sizeof(BYTE *))); if (ad_fsnames) break; } if (!ad_fsnames) return(FALSE); g_fslist = (LONG *)(ad_fsnames+nm_files*LEN_FSNAME); strcpy(locstr, pipath); tree = ad_fstree; /* init strings in form */ obj = ((OBJECT *)tree) + FTITLE; tedinfo = (TEDINFO *)obj->ob_spec; ad_ftitle = (BYTE *)tedinfo->te_ptext; set_mask(mask, locstr); /* save caller's mask */ strcpy(ad_ftitle, mask); /* & copy to title line */ obj = ((OBJECT *)tree) + FSDIRECT; tedinfo = (TEDINFO *)obj->ob_spec; ad_fpath = (BYTE *)tedinfo->te_ptext; inf_sset(tree, FSDIRECT, locstr); obj = ((OBJECT *)tree) + FSSELECT; tedinfo = (TEDINFO *)obj->ob_spec; ad_fname = (BYTE *)tedinfo->te_ptext; fmt_str(pisel, selname); /* selname[] is without dot */ inf_sset(tree, FSSELECT, selname); obj = ((OBJECT *)tree) + FSTITLE; obj->ob_spec = pilabel ? (LONG)pilabel : (LONG)rs_str(ITEMSLCT); /* set drive buttons */ obj = ((OBJECT *)tree) + DRIVE_OFFSET; for (drive = 0, bitmask = 1; drive < NM_DRIVES; drive++, bitmask <<= 1, obj++) { if (drvbits & bitmask) obj->ob_state &= ~DISABLED; else obj->ob_state |= DISABLED; } select_drive(tree,locstr[0]-'A',0); /* set clip and start */ /* form fill-in by */ /* drawing the form */ gsx_sclip(&gl_rfs); fm_dial(FMD_START, &gl_rfs); ob_draw(tree, ROOT, 2); /* init for while loop */ /* by forcing initial */ /* fs_newdir call */ sel = 0; newsel = FALSE; cont = newlist = TRUE; while( cont ) { touchob = (newlist) ? 0x0 : fm_do(tree, FSSELECT); gsx_mxmy(&mx, &my); if ( newlist ) { fs_sel(sel, NORMAL); if ( (touchob == FSOK) || (touchob == FSCANCEL) ) ob_change(tree, touchob, NORMAL, TRUE); inf_sset(tree, FSDIRECT, locstr); pstr = fs_pspec(locstr, NULL); strcpy(pstr, mask); fs_newdir(locstr, mask, tree, &count); curr = 0; sel = touchob = 0; newlist = FALSE; } value = 0; dclkret = ((touchob & 0x8000) != 0); switch( (touchob &= 0x7fff) ) { case FSOK: case FSCANCEL: cont = FALSE; break; case FUPAROW: case FDNAROW: value = 1; break; case FSVSLID: ob_actxywh(tree, FSVELEV, &pt); /* anemic slidebars pt.g_x -= 3; pt.g_w += 6; */ if ( !inside(mx, my, &pt) ) { touchob = (my <= pt.g_y) ? FUPAROW : FDNAROW; value = NM_NAMES; break; } /* drop through */ case FSVELEV: fm_own(TRUE); value = gr_slidebox(tree, FSVSLID, FSVELEV, TRUE); fm_own(FALSE); value = curr - mul_div(value, count-NM_NAMES, 1000); if (value >= 0) touchob = FUPAROW; else { touchob = FDNAROW; value = -value; } break; case F1NAME: case F2NAME: case F3NAME: case F4NAME: case F5NAME: case F6NAME: case F7NAME: case F8NAME: case F9NAME: fnum = touchob - F1NAME + 1; if ( fnum > count ) break; if ( (sel) && (sel != fnum) ) fs_sel(sel, NORMAL); if ( sel != fnum) { sel = fnum; fs_sel(sel, SELECTED); } /* get string and see */ /* if file or folder */ inf_sget(tree, touchob, selname); if (selname[0] == ' ') /* a file was selected */ { /* copy to selection */ newsel = TRUE; if (dclkret) cont = FALSE; } else /* a folder was selected: */ { /* insert name before mask */ pstr = fs_pspec(locstr, NULL); unfmt_str(selname+1, pstr); pstr += strlen(pstr); *pstr++ = '\\'; strcpy(pstr, mask); newlist = TRUE; } break; case FCLSBOX: pstr = fs_back(locstr, NULL); if (*pstr-- != '\\') /* ignore strange path string */ break; if (*pstr != ':') /* not at root of drive, so back up */ { pstr = fs_back(locstr, pstr); if (*pstr == '\\') /* we must have at least X:\ */ strcpy(pstr+1, mask); } newlist = TRUE; break; default: drive = touchob - DRIVE_OFFSET; if ((drive < 0) || (drive >= NM_DRIVES))/* not for us */ break; if (drive == locstr[0] - 'A') /* no change */ break; obj = ((OBJECT *)tree) + touchob; if (obj->ob_state & DISABLED) /* non-existent drive */ break; strcpy(locstr, "A:\\*.*"); locstr[0] += drive; newdrive = TRUE; break; } if (!newlist && !newdrive && path_changed(locstr)) /* path changed manually */ { if (ad_fpath[0] != locstr[0]) /* drive has changed */ newdrive = TRUE; else newlist = TRUE; strcpy(locstr, ad_fpath); } if (newdrive) { select_drive(tree, touchob-DRIVE_OFFSET,1); newdrive = FALSE; newlist = TRUE; } if (newlist) { inf_sset(tree, FSDIRECT, locstr); set_mask(mask, locstr); /* set mask */ selname[1] = '\0'; /* selected is empty */ newsel = TRUE; } if (newsel) { strcpy(ad_fname, selname + 1); ob_draw(tree, FSSELECT, MAX_DEPTH); if (!cont) ob_change(tree, FSOK, SELECTED, TRUE); newsel = FALSE; } if (value) curr = fs_nscroll(tree, &sel, curr, count, touchob, value); } /* return path and */ /* file name to app */ strcpy(pipath, locstr); unfmt_str(ad_fname, selname); strcpy(pisel, selname); /* start the redraw */ fm_dial(FMD_FINISH, &gl_rfs); /* return exit button */ *pbutton = inf_what(tree, FSOK, FSCANCEL); dos_free((LONG)ad_fsnames); return( TRUE ); }
/* ins_disk */ WORD ins_disk(ANODE *pa) { LONG tree; WORD change, icon, flop, hard, fld; BYTE cletter[2], clabel[13]; BYTE nletter[2], nlabel[13]; ANODE *newpa; tree = G.a_trees[ADINSDIS]; change = FALSE; cletter[0] = pa->a_letter; cletter[1] = '\0'; strcpy(&clabel[0], pa->a_pappl); inf_sset(tree, DRID, &cletter[0]); inf_sset(tree, DRLABEL, &clabel[0]); flop = (pa->a_aicon == IG_FLOPPY) ? SELECTED : NORMAL; hard = (pa->a_aicon == IG_HARD) ? SELECTED : NORMAL; LWSET(OB_STATE(DRFLOPPY), flop); LWSET(OB_STATE(DRHARD), hard); LWSET(OB_STATE(DRREM), (lastdisk()) ? DISABLED : NORMAL ); inf_show(tree, 0); inf_sget(tree, DRID, &nletter[0]); inf_sget(tree, DRLABEL, &nlabel[0]); fld = inf_gindex(tree, DRINST, 3); /* which exit button? */ LWSET(OB_STATE(DRINST + fld), NORMAL); icon = ( LWGET(OB_STATE(DRFLOPPY)) & SELECTED ); icon = (icon) ? IG_FLOPPY : IG_HARD; if ( fld == 0 ) /* Install */ { if ( (cletter[0] != nletter[0]) && (nletter[0] != '\0') ) { newpa = get_disk(nletter[0]); if (!newpa) { newpa = app_alloc(FALSE); if (newpa) { newpa->a_flags = pa->a_flags; newpa->a_type = pa->a_type; newpa->a_obid = pa->a_obid; newpa->a_pappl = pa->a_pappl; scan_str("@", &newpa->a_pdata); newpa->a_aicon = pa->a_aicon; newpa->a_dicon = NIL; newpa->a_letter = nletter[0]; } /* if newpa */ else fun_alert(1, STAPGONE, NULL); } /* if !newpa */ if (newpa) pa = newpa; change = TRUE; } /* if cletter */ /* see if icon changed */ if (pa->a_aicon != icon) { pa->a_aicon = icon; change = TRUE; } /* see if label changed */ if ( (!strcmp(&clabel[0], &nlabel[0])) && (nlabel[0] != '\0') ) { nlabel[ strlen(&nlabel[0]) ] = '@'; scan_str(&nlabel[0], &pa->a_pappl); change = TRUE; } } /* if INSTALL */ else if ( fld == 1 ) /* Remove */ { /* find matching anode delete it */ for (pa = G.g_ahead; pa; pa = pa->a_next) { if ( (pa->a_aicon == icon) && (pa->a_letter == nletter[0]) ) { app_free(pa); change = TRUE; } } /* for */ } /* if REMOVE */ return(change); } /* ins_disk */
/* * Routine that creates a new directory in the specified window/path */ WORD fun_mkdir(WNODE *pw_node) { PNODE *pp_node; OBJECT *tree; WORD i, len, err; BYTE fnew_name[LEN_ZFNAME], unew_name[LEN_ZFNAME], *ptmp; BYTE path[MAXPATHLEN]; tree = G.a_trees[ADMKDBOX]; pp_node = pw_node->w_path; ptmp = path; strcpy(ptmp, pp_node->p_spec); i = 0; while (*ptmp++) { if (*ptmp == '\\') i++; } if (i > MAX_LEVEL) { fun_alert(1, STFO8DEE); return FALSE; } while(1) { fnew_name[0] = '\0'; inf_sset(tree, MKNAME, fnew_name); show_hide(FMD_START, tree); form_do(tree, 0); if (inf_what(tree, MKOK, MKCNCL) == 0) break; inf_sget(tree, MKNAME, fnew_name); unfmt_str(fnew_name, unew_name); if (unew_name[0] == '\0') break; ptmp = add_fname(path, unew_name); err = dos_mkdir(path); if (err == 0) /* mkdir succeeded */ { fun_rebld(pw_node); break; } /* * if we're getting a BIOS (rather than GEMDOS) error, the * critical error handler has already issued a message, so * just quit */ if (IS_BIOS_ERROR(err)) break; len = strlen(path); /* before we restore old path */ restore_path(ptmp); /* restore original path */ if (len >= LEN_ZPATH-3) { fun_alert(1,STDEEPPA); break; } /* * mkdir failed with a recoverable error: * prompt for Cancel or Retry */ if (fun_alert(2,STFOFAIL) == 1) /* Cancel */ break; } show_hide(FMD_FINISH, tree); return TRUE; }