/*! load Sppedo fonts */ void load_fontspeedo(void) { int nb_fonts, i; char fontname[128], temp[35]; if(vq_vgdos() == GDOS_FSM) { graf_mouse(BUSYBEE , 0); nb_fonts = vst_load_fonts(work_display.handle, 0); fgdos = TRUE; i = 2; do { vqt_name(work_display.handle, i, temp); strcpy(fontname, " "); strcat(fontname, temp); if(strlen(fontname) > 33) fontname[33] = '\0'; set_text(ir_trindex[FONTS], i, fontname); ir_trindex[FONTS][i].ob_state &= ~DISABLED; i++; } while(((i - 1) <= nb_fonts) &&(i <= 41)); graf_mouse(ARROW, 0); fid = 1; } /* if GDOS loaded */ size = 13; } /* endof load_fontspeedo */
/* ------------------------------------------------------------------ */ static void choose_font(void) { OBJECT *loading; int cx, cy, cw, ch; bool is_prn; is_prn = (form_alert( 1, "[0][select device][screen|printer]" )==2); dprintf(( "\033Hselected %s workstation\n", is_prn? "printer": "screen" )); if( init_wkstn( is_prn ) ) { graf_mouse(BUSY_BEE, 0); dprintf(( "ready to load fonts ... " )); dgetchar(); rsrc_gaddr( R_TREE, LDGFONTS, &loading ); form_center( loading, &cx, &cy, &cw, &ch); form_dial(FMD_START, 0, 0, 0, 0, cx, cy, cw, ch); objc_draw( loading, ROOT, MAX_DEPTH, cx, cy, cw, ch); (void)vst_load_fonts(handle, 0); form_dial( FMD_FINISH, 0, 0, 0, 0, cx, cy, cw, ch ); dprintf(( "\033Hdone\nnow getting font names ..." )); dgetchar(); if( get_fontnames( *(tGemFont **)(&_contrl[10]) ) ) { dprintf(( "done\n" )); dgetchar(); graf_mouse(ARROW, 0); while( select_font( is_prn ) ) { if( iSelected == NO_INDEX ) { form_alert( 1, "[1][You must choose|a font to dump][Try Again]" ); } else if( gem_file_name[0] == '\0' ) { form_alert( 1, "[1][You must choose a|" "gem font file name][Try Again]" ); } else { dump_font(); gem_file_name[0] = '\0'; /* reset entries for next round */ iSelected = NO_INDEX; } /* if */ } /* while */ } /* if */ vst_unload_fonts(handle, 0); free(name_table); dprintf(( "\033Hclosing %s workstation ...", is_prn? "printer": "screen" )); if( is_prn ) v_clswk(handle); else v_clsvwk(handle); } else form_alert(1, "[3][Can't open workstation][OK]"); } /* choose_font() */
void init_rsrc( void ) { int16 work_out[57]; int16 ag1, ag2, ag3, ag4; vdi_handle = open_vwork(work_out); if (gl_gdos) vst_load_fonts(vdi_handle, 0); if ( (_GemParBlk.global[0] >= 0x0400) || (_app == 0) ) menu_id = menu_register(gl_apid, " Control Center"); rsrc_gaddr( R_TREE, MENUTREE, &menu ); /* get tree pointer */ if(_app) create_menu(menu); rsrc_gaddr( R_TREE, MAINDIAL, &maindial ); rsrc_gaddr( R_TREE, WINICON, &wicon ); rsrc_gaddr( R_TREE, ABOUT, &about ); rsrc_gaddr( R_TREE, TOOLS, &tools ); rsrc_gaddr( R_TREE, ICONS, &icons ); rsrc_gaddr( R_FRSTR, WRITE_ERROR, &fstring_addr ); /* get first alert */ fix_popup( tools, 1 ); if ( appl_xgetinfo( 13, &ag1, &ag2, &ag3, &ag4 )) /* Unterfunktion 13, Objekte */ { if ( ag4 & 0x08 ) /* G_SHORTCUT unterst�tzt ? */ aes_flags |= GAI_GSHORTCUT; if ( ag1 && ag2 ) /* 3D-Objekte und objc_sysvar() vorhanden? */ { if ( objc_sysvar( 0, AD3DVALUE, 0, 0, &h3d, &v3d )) /* 3D-Look eingeschaltet? */ { if ( gl_planes >= 4 ) /* mindestens 16 Farben? */ { int16 radio_bgcol, dummy; aes_flags |= GAI_3D; objc_sysvar( 0, BACKGRCOL, 0, 0, &radio_bgcol, &dummy ); } } } } }
/******************************************************* * load fonts for device * get font chain and dump fonts (width table only) in current directory */ static void dump_gem_fonts( int16 dev_nr ) { const tGemFont *pgf; /* pointer to the font chain */ int16 handle; char *err_msg; register tGemFont *phdr; /* pointer to font we are making */ char *const gempath = ((void**)pInfo)[-1]; FILE *fp; int xdial,ydial,wdial,hdial; /* co-ords for dialog box */ int x,y,w,h; handle = init_wkstn( dev_nr ); /* open the workstation */ if( handle == 0 ) { sprintf( err_string, "[3][can't connect to %s][skip]", dev_nr>10? "printer": "screen" ); form_alert(1, err_string ); return; } /* if */ if( vst_load_fonts( handle, 0 ) == 0 ) { sprintf( err_string, "[3][can't find fonts for %s][skip]", dev_nr>10? "printer": "screen" ); goto error0; } /* if */ pgf = *(tGemFont **)(&_contrl[10]); /* get pointer to font chain */ save[dev_nr].pw->first_font = gem_font_count; /****************** * loop thru font chain, * writing a new font file for each font found in the chain * count the fonts so we can assign them to the workstations * this can take quite a while, so report progress as we go */ form_center (&rs_object,&xdial,&ydial,&wdial,&hdial); x=y=w=h=0; form_dial (FMD_START,x,y,w,h,xdial,ydial,wdial,hdial); /* reserve room */ for( ; pgf!=NULL; pgf=pgf->next_font ) { const uint16 nr_entries = pgf->last_ade - pgf->first_ade + 1; const uint32 size_wid = (nr_entries+1) * sizeof(int16); /* sizeof(*(tGemFont*)->off_table) */ register int16 *char_tbl; register uint16 i; /* printf( "line %d, %.32s, %d points\n", (int)__LINE__, pgf->name, pgf->size ); */ sprintf( usr_msg, "storing gem fonts: %d", gem_font_count ); objc_draw( &rs_object, 0, 2, xdial, ydial, wdial, hdial ); /* draw the dialog box */ phdr = (tGemFont*)malloc( sizeof(tGemFont) + size_wid ); if( phdr == NULL ) { err_msg = "[3][Not enough memory|to dump font][OK]"; goto error1; } /* if */ *phdr = *pgf; /* copy header data */ phdr->off_table = (int16*)sizeof(tGemFont); memcpy( phdr+1, pgf->off_table, size_wid ); phdr->dat_table = 0L; /** convert font to intel format before dumping **/ for( i = nr_entries+1, char_tbl = (int16*)(phdr+1); i > 0; i--, char_tbl++ ) { Swapw(*char_tbl); } /* for */ /* swap header words and longs */ phdr->flags &= ~MOT_FLAG; Swapw(phdr->font_id); Swapw(phdr->size); Swapw(phdr->first_ade); Swapw(phdr->last_ade); Swapw(phdr->top); Swapw(phdr->ascent); Swapw(phdr->half); Swapw(phdr->descent); Swapw(phdr->bottom); Swapw(phdr->max_char_width); Swapw(phdr->max_cell_width); Swapw(phdr->left_offset); Swapw(phdr->right_offset); Swapw(phdr->thicken); Swapw(phdr->ul_size); Swapw(phdr->lighten); Swapw(phdr->skew); Swapw(phdr->flags); Swapl(phdr->h_table); Swapl(phdr->off_table); Swapl(phdr->dat_table); Swapw(phdr->form_width); Swapw(phdr->form_height); /* printf( "line %dn", (int)__LINE__); getchar(); */ FONT_FILE_NAME( gempath+pInfo->len_gem_path, gem_font_count ); fp = fopen( gempath, "wb" ); if( fp == NULL ) { err_msg = "[3][can't open gem font file|%s][OK]"; goto error2; } /* if */ /** write the font header **/ if( fwrite( phdr, sizeof( *phdr), 1, fp ) != 1 ) { goto error3; } /* if */ /** write the character offset table **/ if( fwrite( phdr+1, size_wid, 1, fp ) != 1 ) { goto error3; } /* if */ fclose( fp ); free( phdr ); gem_font_count++; } /* for */ save[dev_nr].pw->nr_gemfonts = gem_font_count - save[dev_nr].pw->first_font; (void)vst_unload_fonts( handle, 0 ); if( dev_nr>10 ) v_clswk(handle); else v_clsvwk(handle); form_dial( FMD_FINISH, x, y, w, h, xdial, ydial, wdial, hdial ); /* release its room */ return; error3: fclose(fp); err_msg = "[3][can't write to gem font file|%s][OK]"; error2: sprintf( err_string, err_msg, strerror(errno) ); free( phdr ); error1: form_dial( FMD_FINISH, x, y, w, h, xdial, ydial, wdial, hdial ); /* release its room */ error0: (void)vst_unload_fonts( handle, 0 ); if( dev_nr>10 ) v_clswk(handle); else v_clsvwk(handle); form_alert(1, err_string ); } /* dump_gem_fonts() */
int print_image(MFDB *raster, INFO_IMAGE *in_info) { GEM_WINDOW *wprog = NULL ; DLGDATA dlg_data ; DLGPRINTER_USER_DATA dlg_user_data ; GEM_WINDOW *dlg ; MFDB src ; float sizex, sizey ; float ptpx, ptpy ; int pintin[256], pintout[256] ; int xyarray[4] ; int print_handle ; int i, xoffset, yoffset ; int bouton ; int dither_mono, print_color ; char *filename = dlg_user_data.filename ; char *c ; char buffer[200] ; char nom[30] ; if ( !Gdos ) return(PNOGDOS) ; if ( !printer_init ) scan_drivers() ; if ( nb_drivers <= 0 ) return( PNODRIVER ) ; memset( &dlg_user_data, 0, sizeof(DLGPRINTER_USER_DATA) ) ; if ( raster ) memcpy( &dlg_user_data.raster, raster, sizeof(MFDB) ) ; if ( in_info ) memcpy( &dlg_user_data.info, in_info, sizeof(INFO_IMAGE) ) ; while ( dlg_user_data.raster.fd_w == 0 ) { strcpy( buffer, filename ) ; c = strrchr( buffer, '\\' ) ; if ( c ) *c = 0 ; strcat( buffer, "\\*.*" ) ; if ( file_name( buffer, "", buffer ) == 1 ) { INFO_IMAGE inf ; strcpy( dlg_user_data.filename, buffer ) ; if ( img_format(dlg_user_data.filename, &inf) == 0 ) { memcpy(&dlg_user_data.info, &inf, sizeof(INFO_IMAGE)) ; memset(&dlg_user_data.raster, 0, sizeof(MFDB)) ; dlg_user_data.raster.fd_w = inf.largeur ; dlg_user_data.raster.fd_h = inf.hauteur ; dlg_user_data.raster.fd_nplanes = inf.nplans ; dlg_user_data.raster.fd_wdwidth = dlg_user_data.raster.fd_w/16 ; if (dlg_user_data.raster.fd_w % 16) dlg_user_data.raster.fd_wdwidth++ ; } } else return(PCANCEL) ; } memset( &dlg_data, 0, sizeof(DLGDATA) ) ; dlg_data.RsrcId = FORM_PRINT ; dlg_data.UserData = &dlg_user_data ; dlg_data.ExtensionSize = 0 ; /* Sera alloue par OnInitPrinterDialog */ dlg_data.OnInitDialog = OnInitPrinterDialog ; dlg_data.OnObjectNotify = OnObjectNotifyPrinterDialog ; dlg_data.OnCloseDialog = OnClosePrinterDialog ; dlg = GWCreateDialog( &dlg_data ) ; bouton = GWDoModal( dlg, PRINT_XPC ) ; if ( bouton == IDCANCEL ) return( PCANCEL ) ; printer_index = dlg_user_data.printer_index ; type_index = dlg_user_data.type_index ; if ( dlg_user_data.filename[0] ) { INFO_IMAGE inf ; int analyse = img_analyse ; img_analyse = 0 ; if ( img_format( dlg_user_data.filename, &inf ) == 0 ) { memcpy(&dlg_user_data.info, &inf, sizeof(INFO_IMAGE)) ; src.fd_nplanes = -1 ; /* Conserver le nombre de plans */ Force16BitsLoad = 0 ; wprog = DisplayStdProg( msg[MSG_LOADINGIMG], "", dlg_user_data.filename, 0 ) ; if ( load_picture( dlg_user_data.filename, &src, &inf, wprog ) != 0 ) { GWDestroyWindow( wprog ) ; img_analyse = analyse ; return(PCANCEL) ; } StdProgWText( wprog, 1, "" ) ; } else { img_analyse = analyse ; return( PCANCEL ) ; } img_analyse = analyse ; GWDestroyWindow( wprog ) ; wprog = NULL ; } else memcpy( &src, &dlg_user_data.raster, sizeof(MFDB) ) ; pintin[0] = id[dlg_user_data.printer_index] ; if ((pintin[0] < 21) || (pintin[0] > 30)) return( PNOHANDLE ) ; for (i = 1; i < 10; i++) pintin[i] = 1 ; pintin[10] = 2 ; v_opnwk( pintin, &print_handle, pintout ) ; if ( print_handle <= 0 ) return(PNOHANDLE) ; ptpx = (float)pintout[3] ; /* Largeur d'un point imprimante en microns */ ptpy = (float)pintout[4] ; /* Hauteur d'un point imprimante en microns */ wprog = DisplayStdProg( "", "", "", CLOSER ) ; dither_mono = (dlg_user_data.type_index == 1) && (src.fd_nplanes > 1) ; print_color = (dlg_user_data.type_index == 0) ; if ( dither_mono ) /* Mode noir et blanc */ { MFDB virtuel ; int pc_x, pc_y ; StdProgWText( wprog, 0, msg[MSG_DITHER] ) ; virtuel.fd_nplanes = 1 ; if ( dlg_user_data.rotate90 ) pc_x = (int) (dlg_user_data.xpc*(float)dlg_user_data.info.lpix/ptpy) ; else pc_x = (int) (dlg_user_data.xpc*(float)dlg_user_data.info.lpix/ptpx) ; if ( dlg_user_data.rotate90 ) pc_y = (int) (dlg_user_data.ypc*(float)dlg_user_data.info.hpix/ptpx) ; else pc_y = (int) (dlg_user_data.ypc*(float)dlg_user_data.info.hpix/ptpy) ; mouse_busy() ; if ( dither_ratio(&src, &dlg_user_data.info, &virtuel, pc_x, pc_y, wprog ) == -1 ) { if ( dlg_user_data.filename[0] ) { free( src.fd_addr ) ; if ( dlg_user_data.filename[0] && dlg_user_data.info.palette ) free( dlg_user_data.info.palette ) ; } mouse_restore() ; GWDestroyWindow( wprog ) ; v_clswk( print_handle ) ; return( PROTERR ) ; } wprog->ProgPc( wprog, 0, NULL ) ; mouse_restore() ; if ( dlg_user_data.filename[0] ) free( src.fd_addr ) ; memcpy( &src, &virtuel, sizeof(MFDB) ) ; } if ( dlg_user_data.rotate90 ) { MFDB virtuel ; StdProgWText( wprog, 0, msg[MSG_ROTATING] ) ; mouse_busy() ; if ( raster_r90( &src, &virtuel, wprog ) != 0 ) { if ( dither_mono || dlg_user_data.filename[0] ) free( src.fd_addr ) ; if ( dlg_user_data.filename[0] && dlg_user_data.info.palette ) free( dlg_user_data.info.palette ) ; mouse_restore() ; GWDestroyWindow( wprog ) ; v_clswk( print_handle ) ; return( PROTERR ) ; } mouse_restore() ; if ( dither_mono || dlg_user_data.filename[0] ) free(src.fd_addr ) ; memcpy( &src, &virtuel, sizeof(MFDB) ) ; } sizex = (float)src.fd_w*(float)dlg_user_data.info.lpix*dlg_user_data.xpc/100.0 ; sizey = (float)src.fd_h*(float)dlg_user_data.info.hpix*dlg_user_data.ypc/100.0 ; sizex /= 10000.0 ; sizey /= 10000.0 ; if ( !print_color ) { StdProgWText( wprog, 0, msg[MSG_DOGDOSIMG] ) ; strcpy(nom, "VSCRAP.IMG") ; if ( img_sauve( nom, &src, &dlg_user_data.info, wprog ) ) { if ( dither_mono || dlg_user_data.filename[0] || dlg_user_data.rotate90 ) free( src.fd_addr ) ; if ( dlg_user_data.filename[0] && dlg_user_data.info.palette ) free( dlg_user_data.info.palette ) ; GWDestroyWindow( wprog ) ; v_clswk( print_handle ) ; return( PWRITERR ) ; } } else { INFO_IMAGE new_info ; MFDB new_img ; memcpy( &new_info, &dlg_user_data.info, sizeof(INFO_IMAGE) ) ; memcpy( &new_img, &src, sizeof(MFDB) ) ; if ( new_img.fd_nplanes <= 8 ) { new_info.nb_cpal = 0 ; new_info.palette = NULL ; new_info.nplans = 16 ; new_img.fd_addr = NULL ; new_img.fd_nplanes = 16 ; StdProgWText( wprog, 0, msg[MSG_DOGDOSIMG] ) ; if ( index2truecolor( &src, &dlg_user_data.info, &new_img, wprog ) != 0 ) { if ( dither_mono || dlg_user_data.filename[0] || dlg_user_data.rotate90 ) free( src.fd_addr ) ; if ( dlg_user_data.filename[0] && dlg_user_data.info.palette ) free( dlg_user_data.info.palette ) ; v_clswk( print_handle ) ; GWDestroyWindow( wprog ) ; return( PWRITERR ) ; } } strcpy( nom, "VSCRAP.TGA" ) ; if ( targa_sauve( nom, &new_img, &new_info, wprog ) ) { if ( dither_mono || dlg_user_data.filename[0] || dlg_user_data.rotate90 ) free( src.fd_addr ) ; if ( dlg_user_data.filename[0] && dlg_user_data.info.palette ) free( dlg_user_data.info.palette ) ; v_clswk( print_handle ) ; GWDestroyWindow( wprog ) ; return( PWRITERR ) ; } if ( src.fd_nplanes <= 8 ) free( new_img.fd_addr ) ; } if ( dither_mono || dlg_user_data.filename[0] || dlg_user_data.rotate90 ) free( src.fd_addr ) ; if ( dlg_user_data.filename[0] && dlg_user_data.info.palette ) free( dlg_user_data.info.palette ) ; StdProgWText( wprog, 0, msg[MSG_PRINTING] ) ; vst_unload_fonts( handle, 0 ) ; xoffset = (int) (10000.0*dlg_user_data.posx/ptpx) ; yoffset = (int) (10000.0*dlg_user_data.posy/ptpy) ; xyarray[0] = xoffset ; xyarray[1] = yoffset ; xyarray[2] = xoffset+(int) (10000.0*sizex/ptpx) ; xyarray[3] = yoffset+(int) (10000.0*sizey/ptpy) ; mouse_busy() ; vs_page_info(print_handle, APPL, MENU_NAME) ; vs_page_info(print_handle, DOC, nom) ; vs_page_info(print_handle, CREAT, "") ; vs_page_info(print_handle, REM, "Thanks to Thierry Rodolfo !" ) ; if (dither_mono) v_bit_image(print_handle, nom, 0, INTEGER, INTEGER, 0, 0, xyarray) ; else v_bit_image(print_handle, nom, 0, FRACTIONAL, FRACTIONAL, 0, 0, xyarray) ; v_updwk(print_handle) ; v_clrwk(print_handle) ; v_clswk(print_handle) ; vst_load_fonts(handle, 0) ; mouse_restore() ; unlink(nom) ; GWDestroyWindow( wprog ) ; return( 0 ) ; }